From: Javier Sancho Date: Thu, 22 Feb 2018 15:57:17 +0000 (+0100) Subject: Friends fight with true enemies, before they attacked player but hurting enemies X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=refs%2Fheads%2Fimprovements;p=lugaru.git Friends fight with true enemies, before they attacked player but hurting enemies --- diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index f96dbd4..285c80c 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -2270,7 +2270,9 @@ void doAttacks() Person::players[k]->hasvictim = 0; if (Person::players.size() > 1) { for (unsigned i = 0; i < Person::players.size(); i++) { - if (i == k || !(k == 0 || i == 0)) { + if (i == k || + (Person::players[k]->isPlayerTeam() && Person::players[i]->isPlayerTeam()) || + !(Person::players[k]->isPlayerTeam() || Person::players[i]->isPlayerTeam())) { continue; } if (!Person::players[k]->hasvictim) { diff --git a/Source/Objects/Person.hpp b/Source/Objects/Person.hpp index 22c76eb..3c415a5 100644 --- a/Source/Objects/Person.hpp +++ b/Source/Objects/Person.hpp @@ -407,6 +407,7 @@ public: bool hasWeapon() { return (weaponactive != -1); } bool isPlayerControlled() { return (aitype == playercontrolled); } bool isPlayerFriend() { return isplayerfriend; } + bool isPlayerTeam() { return isPlayerControlled() || isPlayerFriend(); } }; const int maxplayers = 10;