From 43b29d6c2092964efbba5ee4d5f4a559d86bc508 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Thu, 22 Feb 2018 16:29:43 +0100 Subject: [PATCH] Friends don't abandon player when enemies flee --- Source/GameTick.cpp | 2 ++ Source/Objects/Person.cpp | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index dbd6f0e..f96dbd4 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -2200,11 +2200,13 @@ void doAttacks() !Person::players[k2]->dead && Person::players[k2]->aitype == attacktypecutoff) { Person::players[k]->victim = Person::players[k2]; + Person::players[k]->hasvictim = true; found = true; break; } } if (!found) { + Person::players[k]->hasvictim = false; Person::players[k]->attackkeydown = 0; } } else { diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 5a735c3..b140307 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -7339,6 +7339,10 @@ void Person::doAI() pause = 1; } + if (isPlayerFriend() && aitype == pathfindtype) { + aitype = passivetype; + } + //pathfinding if (aitype == pathfindtype) { if (finalpathfindpoint == -1) { @@ -8382,8 +8386,16 @@ void Person::doAI() } if (stunned < 1 && isPlayerFriend()) { + // friends help player with its enemies + if (Game::musictype == stream_fighttheme && hasvictim) { + aitype = attacktypecutoff; + } else { + aitype = pathfindtype; + } + // friends follow player if (!Person::players[0]->dead && + aitype == pathfindtype && distsq(&coords, &Person::players[0]->coords) > 5) { XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity; XYZ targetpoint = Person::players[0]->coords; @@ -8398,12 +8410,6 @@ void Person::doAI() targetyaw = roughDirectionTo(coords, targetpoint); lookyaw = targetyaw; forwardkeydown = 1; - aitype = pathfindtype; - } - - // friends help player with its enemies - if (Game::musictype == stream_fighttheme) { - aitype = attacktypecutoff; } } -- 2.39.5