Improve AI garrisons, player recovery and mission administration
This commit is contained in:
@@ -6,7 +6,7 @@ s=s.replace('override ','').replace('super.','Native::').replace('null','nullptr
|
||||
s=s.replace('ERR_GameMode mode','ERR_GameMode* mode').replace('ERR_ForceRecord record','ERR_ForceRecord* record')
|
||||
s=s.replace('ERR_HQ hq = ERR_HQ.Cast(mode.Command())', 'ERR_HQ* hq = mode->Command()')
|
||||
s=s.replace('array<AIAgent> agents = {};','Array<AIAgent*> agents;').replace('foreach (AIAgent agent : agents)','for (AIAgent* agent : agents)')
|
||||
for name in ('mode','record','Group','agent','hq'):s=s.replace(name+'.',name+'->')
|
||||
for name in ('mode','record','Group','agent','hq','Recovery'):s=s.replace(name+'.',name+'->')
|
||||
s=s.replace('Forces().','Forces()->').replace('ERR_ConvoyRules.','ERR_ConvoyRules::')
|
||||
objective=body(ROOT/'addons/core/Scripts/Game/ERR/10_AI/ERR_ObjectiveDefence.c','static bool Objective(').replace('ERR_LocationKind.','ERR_LocationKind::')
|
||||
run(r'''
|
||||
@@ -20,17 +20,19 @@ struct Ledger{ERR_ForceRecord record;ERR_ForceRecord* FindGroup(GroupType*){retu
|
||||
struct ERR_HQ{int releases=0;void ReleaseRecovery(GroupType*){releases++;}};
|
||||
struct ERR_GameMode{bool active=true;Ledger ledger;ERR_HQ hq;bool Active(){return active;}Ledger* Forces(){return &ledger;}ERR_HQ* Command(){return &hq;}};
|
||||
namespace ERR_ConvoyRules{bool captured=false;bool Captured(void*,GroupType*){return captured;}}
|
||||
struct Native{bool Released=false;int delegated=0,clears=0;GroupType* Group=nullptr;void* Entity=nullptr;void* Downlink=nullptr;
|
||||
struct RecoveryTask{int stops=0;void Stop(){stops++;}};
|
||||
struct Native{RecoveryTask* Recovery=nullptr;bool Released=false;int delegated=0,clears=0;GroupType* Group=nullptr;void* Entity=nullptr;void* Downlink=nullptr;
|
||||
void Release(ERR_GameMode*){delegated++;Released=true;}void ClearOrder(){clears++;}
|
||||
};
|
||||
struct Hunter:Native{
|
||||
'''+s+r'''
|
||||
};
|
||||
namespace ERR_LocationKind{enum{PRISON,RADIO,EXTRACTION,PATROL,DEPOT,OUTPOST,MORTAR};}
|
||||
namespace ERR_LocationKind{enum{PRISON,RADIO,EXTRACTION,PATROL,DEPOT,OUTPOST,MORTAR,HOSPITAL};}
|
||||
'''+objective+r'''
|
||||
int main(){
|
||||
ERR_GameMode mode;GroupType group;Hunter unit;unit.Group=&group;unit.Entity=&group;unit.Downlink=&mode;
|
||||
ERR_GameMode mode;GroupType group;Hunter unit;unit.Group=&group;unit.Entity=&group;unit.Downlink=&mode;RecoveryTask recovery;unit.Recovery=&recovery;
|
||||
unit.Release(&mode);assert(unit.Released&&!unit.Downlink&&unit.clears==1&&unit.delegated==0);
|
||||
assert(recovery.stops==1);
|
||||
assert(!mode.ledger.record.Pinned&&mode.hq.releases==1&&group.lod==-1&&group.agent.writes==1);
|
||||
assert(unit.Entity==&group&&unit.Group==&group); // living and dead actors/vehicle are preserved
|
||||
unit.Release(&mode);assert(unit.clears==1&&mode.hq.releases==1&&group.agent.writes==1);
|
||||
|
||||
Reference in New Issue
Block a user