Page 1 of 1

[solved] i don't know my enemy

Posted: 22 Jan 2014, 10:59
by Shaitan

Code: Select all

struct SEnemyEnterLOSEvent {int enemy;};
how to get Unit* or UnitDef* out of that?

Re: i don't know my enemy

Posted: 22 Jan 2014, 22:00
by PicassoCT
if you had acess to the synced lua, i would say to try to get this as a enemyid via a pushed lua_call down into the engine identified..

http://www.sourcecodebrowser.com/spring ... ource.html

http://www.sourcecodebrowser.com/spring ... ated_event

Re: i don't know my enemy

Posted: 23 Jan 2014, 04:16
by Shaitan
PicassoCT wrote:if you had acess to the synced lua, i would say to try to get this as a enemyid via a pushed lua_call down into the engine identified..
i'm sorry, i can't understand what you wrote. does that mean i can't get what i want in C++?

Re: i don't know my enemy

Posted: 27 Jan 2014, 14:26
by AF
Here's how I do it in Shard on unit given event:

Code: Select all

// it might not have been given to us! Could have been given to another team
springai::Unit* unit = springai::WrappUnit::GetInstance(skirmishAIId, evt->unitId);
if(callback->GetSkirmishAI()->GetTeamId() == unit->GetTeam()){
        CSpringUnit* u = new CSpringUnit(callback,unit,game);
        aliveUnits[evt->unitId] = u;
        game->Me()->UnitGiven(u);
}
https://github.com/Tarendai/Shard/blob/ ... AI.cpp#L65

Re: i don't know my enemy

Posted: 29 Jan 2014, 08:55
by Shaitan
AF wrote:springai::Unit* unit = springai::WrappUnit::GetInstance(skirmishAIId, evt->unitId);
yes, that's what i needed. thank you, Tom!