Page 1 of 1

IsUnitType(id, string)

Posted: Tue Sep 25, 2012 4:20 pm
by enric
Is there a way to get the unit type name e.i if it's a "Sherman", a "M10", a "Priest", or anything else ?
As BA functions only return an integer maybe adding an attribute (int) that matches the name of the units will help.. or, there is a way?.

Obviously checking every unit, with every Name seems a dirty task.
for every unit
if ( IsUnitType(id, "name") then
if ( IsUnitType(id, "name2") then
if ( IsUnitType(id, "name3") then
etc. etc.

Re: IsUnitType(id, string)

Posted: Tue Sep 25, 2012 4:50 pm
by pipfromslitherine
IsUnitType is the only way of checking the unit type.

What task are you trying to achieve?

Cheers

Pip

Re: IsUnitType(id, string)

Posted: Tue Sep 25, 2012 5:30 pm
by enric
We are testing a scenario where the morale for the defender side was oscillating each time a unit is killed, dropping morale when friendly unit is killed and raising when enemy is killed. This will affect the scenario each turn.

Now we just check for "infantry", or "tracked", or "halftrack", but we can not (well not easily) check for more specific cases, so if we want to differentiate between a Sherman or a M10, or M5, we must ask for every case inside tracked vehicles.

Will be nice a function that given an id returns the name of the unit.

Re: IsUnitType(id, string)

Posted: Tue Sep 25, 2012 6:00 pm
by pipfromslitherine
Why not just add a new attrib to all units in the squads file and then drive it from the data? This is what we do for almost all the game logic. It provides the greatest flexibility. You could even use an existing stat such as the cost, or a combo of the AP/HE/Armour ratings. E.g. a more costly unit's loss will produce a greater morale effect.

Cheers

Pip

Re: IsUnitType(id, string)

Posted: Tue Sep 25, 2012 6:28 pm
by enric
Thanks for the suggestion.
Is there a limit to the number of attributes that can be added to the Squad file?

Re: IsUnitType(id, string)

Posted: Tue Sep 25, 2012 7:12 pm
by pipfromslitherine
There is a limit of 128 attributes total (this includes any added by scripts) plus 16 array attribs with 8 entries each.

Cheers

Pip