[solved] first steps in developing a C++ AI
Posted: 08 Jan 2014, 15:43
hello,
i'm stuck in the very beginning. how can i give orders?
i'm stuck in the very beginning. how can i give orders?
Open Source Realtime Strategy Game Engine
https://springrts.com/phpbb/
yes, i've seen all those but i'm still lost.abma wrote: http://springrts.com/wiki/AI:Development
http://springrts.com/wiki/AIWrapper:Cpp
minimalistic example ai:
http://springrts.com/wiki/AI:CppTestAI
source code:
https://github.com/spring/spring/blob/d ... TestAI.cpp
full-featured ai:
https://github.com/Tarendai/Shard
i started with the CppTestAI.abma wrote:sorry, can't directly give instrucations as there are mutliple possibilities. which example did you use to start?
i guess you meant GiveOrder(unitid, &Command). but what command ID should i set to build something?abma wrote:giving orders should work sth. like this:
callback->GiveOrders(unitid, &Command);
i thought that it should be the C++ AI Interface Wrapper, shouldn't it?abma wrote:but not sure, depends on the wrapper used.
Code: Select all
this->unit->Stop();
const springai::AIFloat3 pos(p.x, p.y, p.z);
this->unit->Fight(pos);
Code: Select all
springai::UnitDef* ud = ....
const springai::AIFloat3 pos( xcoord..., ycoord..., zcoord... );
if(this->game->Map()->CanBuildHereFacing(t,p,facing)){
try {
this->unit->Build(ud, pos, facing, 0, 10000);
} catch(...){
return false;
}
return true;
} else {
return false;
}
i'm sorry, but since i don't have enough of "common sense and basic deducation combined with basic C++ knowledge", would you please explain to me how to get UnitDef for a solar collector from the C++ AI Interface Wrapper? it would be so tolerant of you.AF wrote:springai::UnitDef* ud = ....
Code: Select all
...
springai::Unit* commanderUnit = callback->GetTeamUnits().front();
...
commanderUnit->Build(callback->GetUnitDefByName("armsolar"), commanderUnit->GetPos(), UNIT_COMMAND_BUILD_NO_FACING);
...