Change resource management AI behavior.

This commit is contained in:
sigonasr2 2023-09-04 05:32:31 -05:00
parent d0a572c4fe
commit 4ec15f42a2
2 changed files with 17 additions and 10 deletions

View File

@ -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.