From: Javier Sancho Date: Thu, 22 Feb 2018 15:29:43 +0000 (+0100) Subject: Friends don't abandon player when enemies flee X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=43b29d6c2092964efbba5ee4d5f4a559d86bc508;p=lugaru.git Friends don't abandon player when enemies flee --- 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; } }