Fix AI attacking each other. Also easy mode had infinite resources..

master
sigonasr2 1 year ago
parent f63c2b00ca
commit d0a572c4fe
  1. 1
      olcCodeJam2023Entry/Scenario.cpp
  2. 2
      olcCodeJam2023Entry/Unit.cpp
  3. BIN
      olcCodeJam2023Entry/pge.wasm

@ -45,6 +45,7 @@ void Scenario::RunAI(Resources&enemy_resources,std::vector<std::shared_ptr<Colle
if(!setupEasyMode&&flags.difficulty==0){
enemy_resources={100,100,100,100,100};
setupEasyMode=true;
}
attackTimer=std::max(0.f,attackTimer-game.GetPGE()->GetElapsedTime());
unitBuildTimer=std::max(0.f,unitBuildTimer-game.GetPGE()->GetElapsedTime());

@ -960,7 +960,7 @@ void Unit::_Attacked(std::weak_ptr<Unit>attacker,std::vector<std::shared_ptr<Uni
if(!IsFriendly()&&!attacker.lock()->IsFriendly()&&!attacker.lock()->CanInteractWithAllies()){
attacker.lock()->SetTargetLocation(attacker.lock()->GetPos()); //This effectively negates enemies targeting each other for attacking if they're not supposed to. Somehow this occurs sometimes.
}
if(attacker.lock()->IsFriendly()!=IsFriendly()){
if(!IsFriendly()&&attacker.lock()->IsFriendly()!=IsFriendly()){
for(auto&u:otherUnits){
if(this!=u.get()&&!u->IsFriendly()&&u->GetCurrentTarget().expired()&&u->CanMove()&&!u->IsAllocator()){
geom2d::line<float>distLine={GetPos(),u->GetPos()};

Binary file not shown.
Loading…
Cancel
Save