crazy mess droidType

For AI and campaign script related discussions and questions
Post Reply
User avatar
Prot
Trained
Trained
Posts: 167
Joined: 29 Nov 2010, 12:41

crazy mess droidType

Post by 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
	{
	case DROID_CONSTRUCT:
		droidType2 = DROID_CYBORG_CONSTRUCT; break;
	case DROID_WEAPON:
		droidType2 = DROID_CYBORG_SUPER; break;
	case DROID_REPAIR:
		droidType2 = DROID_CYBORG_REPAIR; break;
	case DROID_CYBORG:
		droidType2 = DROID_CYBORG_SUPER; break;
	default:
		droidType2 = droidType;
		break;
	}
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??

MIH-XTC
Trained
Trained
Posts: 253
Joined: 31 Jan 2014, 07:06

Re: crazy mess droidType

Post by MIH-XTC » 13 Feb 2018, 22:24

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

https://github.com/Warzone2100/warzone2 ... ction.json

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

DROID_REPAIR
CYBORG_REPAIR

DROID_CONSTRUCT
CYBORG_CONSTRUCT

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3755
Joined: 03 Aug 2006, 19:39

Re: crazy mess droidType

Post by 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.

Post Reply