[solved] i don't know my enemy

[solved] i don't know my enemy

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

Moderators: hoijui, Moderators

Post Reply
Shaitan
Posts: 16
Joined: 04 Jan 2014, 11:54

[solved] i don't know my enemy

Post by Shaitan »

Code: Select all

struct SEnemyEnterLOSEvent {int enemy;};
how to get Unit* or UnitDef* out of that?
Last edited by Shaitan on 29 Jan 2014, 08:56, edited 1 time in total.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: i don't know my enemy

Post 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
Shaitan
Posts: 16
Joined: 04 Jan 2014, 11:54

Re: i don't know my enemy

Post 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++?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: i don't know my enemy

Post 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
Shaitan
Posts: 16
Joined: 04 Jan 2014, 11:54

Re: i don't know my enemy

Post by Shaitan »

AF wrote:springai::Unit* unit = springai::WrappUnit::GetInstance(skirmishAIId, evt->unitId);
yes, that's what i needed. thank you, Tom!
Post Reply

Return to “AI”