Change resource management AI behavior.

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

@ -78,18 +78,25 @@ void Scenario::RunAI(Resources&enemy_resources,std::vector<std::shared_ptr<Colle
geom2d::line<float>toCP2={cp2->pos,baseOfOperations.lock()->GetPos()};
return toCP1.length()<toCP2.length();});
}
for(auto&cp:collectionPoints){
if(cp->attachedUnit.expired()){
if(cpCheckTimer.count(cp.get())==0||cpCheckTimer[cp.get()]<=0){
for(auto&u:units){
if(!u->IsFriendly()&&u->IsAllocator()&&u->attachTarget.expired()){
//Tell this unit to move towards that collection point.
u->SetTargetCollectionPoint(cp,u);
break;
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){
if(cp->attachedUnit.expired()){
if(cpCheckTimer.count(cp.get())==0||cpCheckTimer[cp.get()]<=0){
for(auto&u:units){
if(!u->IsFriendly()&&u->IsAllocator()&&u->attachTarget.expired()){
//Tell this unit to move towards that collection point.
u->SetTargetCollectionPoint(cp,u);
break;
}
}
//Hasn't been checked recently.
cpCheckTimer[cp.get()]=60;
}
//Hasn't been checked recently.
cpCheckTimer[cp.get()]=60;
}
}
}

Binary file not shown.
Loading…
Cancel
Save