Change resource management AI behavior.
This commit is contained in:
parent
d0a572c4fe
commit
4ec15f42a2
@ -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()};
|
geom2d::line<float>toCP2={cp2->pos,baseOfOperations.lock()->GetPos()};
|
||||||
return toCP1.length()<toCP2.length();});
|
return toCP1.length()<toCP2.length();});
|
||||||
}
|
}
|
||||||
for(auto&cp:collectionPoints){
|
int maxOfResources=enemy_resources.health;
|
||||||
if(cp->attachedUnit.expired()){
|
maxOfResources=std::max(maxOfResources,enemy_resources.atkSpd);
|
||||||
if(cpCheckTimer.count(cp.get())==0||cpCheckTimer[cp.get()]<=0){
|
maxOfResources=std::max(maxOfResources,enemy_resources.moveSpd);
|
||||||
for(auto&u:units){
|
maxOfResources=std::max(maxOfResources,enemy_resources.procedure);
|
||||||
if(!u->IsFriendly()&&u->IsAllocator()&&u->attachTarget.expired()){
|
maxOfResources=std::max(maxOfResources,enemy_resources.range);
|
||||||
//Tell this unit to move towards that collection point.
|
if(maxOfResources<10){
|
||||||
u->SetTargetCollectionPoint(cp,u);
|
for(auto&cp:collectionPoints){
|
||||||
break;
|
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…
x
Reference in New Issue
Block a user