Height Detection in Spring

Height Detection in Spring

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Boogalizer
Posts: 6
Joined: 20 Apr 2007, 06:38

Height Detection in Spring

Post by Boogalizer »

I'm working on porting over my mod, Devolution, to Spring and I've run into an issue (or maybe I'm just confused). Many of the features in Devolution rely on one unit detecting another one, and then responding in a certain way. For example, I have Captain units, and when other units are nearby the Captain units, they receive power ups. They do this by detecting the height of the Captain model, which is as far as I know, the best/only functional way to distinguish one unit from another in TA scripting.

When I tried to copy over the scripts into Spring, however, they did not seem to work.

I was wondering if height was measured the same way in Spring as in OTA, or if I should remeasure everything. Or better yet, if there was some way to detect a unit NAME in Spring scripting, rather than just the height.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

You can do loads of stuff using Lua. See CA (caspring.org) for examples.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

It's calculated differently, for s3os it's 65536*radius but I'm afraid you'll have to remeasure your 3dos in Spring since your mod probably uses those.

Identification via Lua is faster and easier AFAIK.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Would it be useful to have a scriptID unitdef tag?
(and an associated 'GET SCRIPTID unitID' COB call)
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Yep. Last time I proposed that I got brushed off with "You can hack that in with get UNIT_HEIGHT".
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

I consider the unit height hack to be very poor form. I'll add the scriptID tag (cobID?).

P.S. It'll be cobID, and the default value is -1.

Code: Select all

#define COB_ID 100 // get
GET COB_ID 0          =>   unit's own cobID
GET COB_ID <unitID>   =>   unitID's cobID
Boogalizer
Posts: 6
Joined: 20 Apr 2007, 06:38

Post by Boogalizer »

I think I may still be confused, how could I use COB_ID to identify a certain unit?

Say I wanted a script to detect where my commander is, for instance. What would my commander's COB_ID be, and how could I find that out for other units? Would I have to set it? If so, how could I set it?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

The easiest way to use this is as follows:

1. Setup a file like the following:

Code: Select all

#define COBID_ARMCOM 1234
#define COBID_CORCOM 1235
etc...
(this step could be automated to generate linear IDs if
you don't mind recompiling the COBs for the changed IDs)

2. Use those definitions while compiling your COB scripts.

3. Add a gamedata/unitdefs_post.lua script to parse the file
(which must be included in your mod archive), and assign the
cobID values to the appropriate unitDefs. The parsing script
would look very much like the one I did for cob->lua sounds.

You could skip step 3 if you add all of the cobIDs to the unitDefs manually.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Note: the cobID / COB_ID code has already been committed to SVN
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Re: Height Detection in Spring

Post by quantum »

Boogalizer wrote:I'm working on porting over my mod, Devolution, to Spring
:o Yay, Devolution Spring!
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

This is such a simple 5 minute job it could have been done ages ago by most of us. Why are we so lazy that trepan needs to step up. :P


Devolution was the mod which had three different commanders where only one was allowed to exist at any time right?

On that note a group limit feature which takes armor.txt groups sure would come in handy as a global override for the local limit tag.
tombom
Posts: 1933
Joined: 18 Dec 2005, 20:21

Post by tombom »

rattle wrote:On that note a group limit feature which takes armor.txt groups sure would come in handy as a global override for the local limit tag.
You could do it with Lua.
DemO
Posts: 541
Joined: 18 Jul 2006, 02:05

Post by DemO »

tombom wrote:You could do it with Lua.
The answer to every scripting question in Spring since 2007!
User avatar
Relative
Posts: 1371
Joined: 15 Oct 2006, 13:17

Post by Relative »

DemO wrote:
tombom wrote:You could do it with Lua.
The answer to every question in Spring since 2007!
Fixed
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

tombom wrote:
rattle wrote:On that note a group limit feature which takes armor.txt groups sure would come in handy as a global override for the local limit tag.
You could do it with Lua.
I did, except it uses a separate config file, not armor.txt.

http://www.unknown-files.net/3632/Group_Limit_Gadget/
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Neat. Now fix LUA syntax to be less like basic. :P
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

...and more like lisp :P
tombom
Posts: 1933
Joined: 18 Dec 2005, 20:21

Post by tombom »

imbaczek wrote:...and more like lisp :P
lisp is the second best language in the world after perl

i've never made anything in lisp
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

Lisp is also over 10 years older than the first C (the one that sucked). It's worth at least reading something about ^^
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Go choke on your brackets, freak!
Post Reply

Return to “Engine”