crazy mess droidType

For AI and campaign script related discussions and questions

crazy mess droidType

Postby Prot » 13 Feb 2018, 19:30

When i need to compare if truck construction or cyborg construction, i'm facing a problem where going something crazy, where i can enum only cyborg construction but not trucks, because enumDroid by type DROID_CONSTRUCT return both types.
Then i look into source and found this crazy whacky code:
Code: Select all
   switch (droidType) // hide some engine craziness
      droidType2 = DROID_CYBORG_CONSTRUCT; break;
      droidType2 = DROID_CYBORG_SUPER; break;
      droidType2 = DROID_CYBORG_REPAIR; break;
      droidType2 = DROID_CYBORG_SUPER; break;
      droidType2 = droidType;

In game cyborg and truck construction is separate, and this really different units, but in function enumDroid cyborg eq to all constructions :augh: whhooaa??
Then i can just call enumDroid(me, 10) and get only cyborgs constructions, but cant get ONLY trucks, if i call enumDroid(me, DROID_CONSTRUCT) i get both types..
Same thing with just compare if(droid.droidType == ???) what i need to pass there to check, if this truck or cyborg ??
Something like if(droid.body == "Body1REC") then it may be starting construction truck... but.. but.. ohh.. this is crazy.
I think we need to separate DROID_CONSTRUCT and DROID_CYBORG_CONSTRUCT.
I don't understand why was there a need to do SO??
User avatar
Posts: 158
Joined: 29 Nov 2010, 12:41

Re: crazy mess droidType

Postby MIH-XTC » 13 Feb 2018, 22:24

I think droidType was introduced sometime last year in /stats/repair.json and /stats/contruction.json ... ction.json

Maybe you are referencing the wrong variable name? These are the droidTypes:


Posts: 251
Joined: 31 Jan 2014, 07:06

Re: crazy mess droidType

Postby Per » 13 Feb 2018, 22:52

This was done deliberately, because DROID_<blah> was a confused mess that altered between pointing to a specific unit, and unit role. In JS scripts now, it is meant to point to a role. If you want to sort by a specific unit, check the name. If you want to check if it is any cyborg construction worker, lookif it is cyborg and construction role.
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3745
Joined: 03 Aug 2006, 19:39

Return to Scripting