From 741d22aa77b9d20c67ccda3285235c71f988cfe6 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Tue, 20 Feb 2018 16:53:52 +0100 Subject: [PATCH] Friends always follow the player --- Source/Objects/Person.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 2a4d4ae..52c8fc4 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -8362,6 +8362,7 @@ void Person::doAI() } } } + //stunned if (aitype == passivetype && !(numwaypoints > 1) || stunned > 0 || @@ -8380,6 +8381,27 @@ void Person::doAI() throwkeydown = 0; } + // friends follow player + if (stunned < 1 && + isPlayerFriend() && + !Person::players[0]->dead && + distsq(&coords, &Person::players[0]->coords) > 5) { + XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity; + XYZ targetpoint = Person::players[0]->coords; + velocity = (targetpoint - coords); + velocity.y += 2; + float vellength = findLength(&velocity); + if (vellength != 0 && + distsq(&Person::players[0]->coords, &coords) < distsq(&rotatetarget, &coords)) { + targetpoint += Person::players[0]->velocity * + findDistance(&Person::players[0]->coords, &coords) / vellength; + } + targetyaw = roughDirectionTo(coords, targetpoint); + lookyaw = targetyaw; + forwardkeydown = 1; + aitype = searchtype; + } + XYZ facing; facing = 0; facing.z = -1; -- 2.39.5