Change resource management AI behavior.

master
sigonasr2 1 year ago
parent d0a572c4fe
commit 4ec15f42a2
  1. 7
      olcCodeJam2023Entry/Scenario.cpp
  2. BIN
      olcCodeJam2023Entry/pge.wasm

@ -78,6 +78,12 @@ void Scenario::RunAI(Resources&enemy_resources,std::vector<std::shared_ptr<Colle
geom2d::line<float>toCP2={cp2->pos,baseOfOperations.lock()->GetPos()}; geom2d::line<float>toCP2={cp2->pos,baseOfOperations.lock()->GetPos()};
return toCP1.length()<toCP2.length();}); return toCP1.length()<toCP2.length();});
} }
int maxOfResources=enemy_resources.health;
maxOfResources=std::max(maxOfResources,enemy_resources.atkSpd);
maxOfResources=std::max(maxOfResources,enemy_resources.moveSpd);
maxOfResources=std::max(maxOfResources,enemy_resources.procedure);
maxOfResources=std::max(maxOfResources,enemy_resources.range);
if(maxOfResources<10){
for(auto&cp:collectionPoints){ for(auto&cp:collectionPoints){
if(cp->attachedUnit.expired()){ if(cp->attachedUnit.expired()){
if(cpCheckTimer.count(cp.get())==0||cpCheckTimer[cp.get()]<=0){ if(cpCheckTimer.count(cp.get())==0||cpCheckTimer[cp.get()]<=0){
@ -93,6 +99,7 @@ void Scenario::RunAI(Resources&enemy_resources,std::vector<std::shared_ptr<Colle
} }
} }
} }
}
for(auto&key:cpCheckTimer){ for(auto&key:cpCheckTimer){
cpCheckTimer[key.first]=std::max(0.0f,cpCheckTimer[key.first]-game.GetPGE()->GetElapsedTime()); cpCheckTimer[key.first]=std::max(0.0f,cpCheckTimer[key.first]-game.GetPGE()->GetElapsedTime());
} }

Binary file not shown.
Loading…
Cancel
Save