Problem detecting resurrected units via AI Interface

Problem detecting resurrected units via AI Interface

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

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

Problem detecting resurrected units via AI Interface

Post by submarine »

I was trying to detect resurrected units via checking the health of the unit when GlobalAI::UnitFinished(..) is called

I found out that this is not possible since ressurected units get their full health assigned in CUnit* CUnitLoader::LoadUnit(...) (which calls BuildingFinished(..) which calls GlobalAI::UnitFinished(..) ) first and the lower health (5% of max health) is assigned afterwards.

I need to detect resurrected units (and maybe other AIs are suffering from this problem as well) so I would suggest to modify

Code: Select all

CUnit* CUnitLoader::LoadUnit(const string& name, float3 pos, int team, bool build, int facing, const CUnit* builder)
to

Code: Select all

CUnit* CUnitLoader::LoadUnit(const string& name, float3 pos, int team, bool build, int facing, const CUnit* builder, float health = 1.0f)
and assigning

Code: Select all

unit->maxHealth = ud->health;
unit->health = ud->health * health;
What do the others think? Am I missing any negative side effects?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Problem detecting resurrected units via AI Interface

Post by hoijui »

I think we should have a UnitRessurected Event for AIs.
Post Reply

Return to “Engine”