GetUnitDef(int id) causing trouble

GetUnitDef(int id) causing trouble

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

GetUnitDef(int id) causing trouble

Post by submarine »

GetUnitDef(int id) return a null pointer when called during initialization of an ai

however, GetUnitDef("ARMCOM") works fine for me; is it possible that the unit ids are not set when spring ai intefrace calls InitAI() ??
cain
AI Developer
Posts: 124
Joined: 09 Aug 2005, 10:04

Post by cain »

wewll, you shuldn't call it during the init, as you don't have any units.

the first unit you see is the commander after the game start and before the first update.

the best place to put it is inside a unitcreated (called whenewer a unit is started being built) or unitfinisched (called when the unit is ready).
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

lol thanks cain :) i´ve been trying to hunt that bug for hours

i confused UnitDef->id with the unit ids spring assigns to units in the game...

how stupid... :|
Post Reply

Return to “AI”