COB script -- global, team, and allyteam variables

COB script -- global, team, and allyteam variables

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

COB script -- global, team, and allyteam variables

Post by trepan »

http://spring.clan-sy.com/fisheye/chang ... g/?cs=4732

Code: Select all

4732 created by trepan on 07 November 2007, 02:31:35 +0100 (5 minutes ago) (patch) 

* Added global, team, and ally GET/SET variables to COB scripts
   1024 - 2047:  1024 global variables
   2048 - 2175:  128  variables per team      (the COB script unit's team)
   2176 - 2303:  128  variables per allyteam  (the COB script unit's allyteam) 
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death »

Ooo, more COB toys. Which of course can be readily accesed via LuaCob and/or LuaRules? Not that I was hit by an immediately apparent way I could use it in BTech this time.
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Post by Pressure Line »

Archangel of Death wrote:Not that I was hit by an immediately apparent way I could use it in BTech this time.
'Hero' units that can only be built once during the game and only by one player...
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

LuaCob and LuaRules can use Spring.GetUnitCOBValue() and
Spring.SetUnitCOBValue() to access any COB GET/SET values,
for any unit.

Pressure Line
Your hero unit limiter would be better done with LuaRules.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Not without further Lua.
tombom
Posts: 1933
Joined: 18 Dec 2005, 20:21

Post by tombom »

rattle wrote:Not without further Lua.
What does this mean? It's pretty simple in Lua actually.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Unit variables would have been more useful but still nice.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Unit variables instead of script static vars?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

I think he means a variable accesable by all units of a given type.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Ah, I had mentionned that in #moddev, but didn't get much of a response.
It's easy enough to setup.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

It turns out that KDR actually wants per-unit variables (not per-unitDef),
so that he can pass information between units. To that end, I'm adding
8 per-unit variables, with the ability to get and set variables for other units.

The new layout is as follows:

Code: Select all

  // SIZES
  static const int UNIT_VAR_COUNT   = 8;
  static const int TEAM_VAR_COUNT   = 64; 
  static const int ALLY_VAR_COUNT   = 64;   
  static const int GLOBAL_VAR_COUNT = 1024;

  // CODES
  static const int UNIT_VAR_START   = 1024;
  static const int TEAM_VAR_START   = 2048;
  static const int ALLY_VAR_START   = 3072;
  static const int GLOBAL_VAR_START = 4096;
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

I can't see how per-unit vars are different from static vars...?

Edit: missed 'setting from other units bit' 8)
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

You can't read static-vars in one script from another script. You could use the globals for that but it's confusing.
Post Reply

Return to “Game Development”