X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FObjects%2FPerson.cpp;h=e1a1e71ae505cebc4a4bdc2abdc4c46c96cbd4d6;hb=c3d275ada8dc8c67e9930d23587e0c203761a056;hp=7f279de859696dee81965ddddcb5b369c65c695e;hpb=3316a497b6dd2305f36099a92ae9a0a5e6a2cf7e;p=lugaru.git diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 7f279de..e1a1e71 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2003, 2010 - Wolfire Games -Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) +Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. @@ -578,8 +578,8 @@ void Person::CheckKick() /* EFFECT * * USES: - * GameTick/doPlayerCollisions - spread fire between players - * GameTick/doDevKeys - press f to ignite + * GameTick::doPlayerCollisions - spread fire between players + * GameTick::ProcessDevKeys - press f to ignite * Person::DoStuff - spread fire from lit campfires and bushes */ void Person::CatchFire() @@ -2177,13 +2177,9 @@ void Person::DoAnimations() } if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) { float gLoc[3]; - float vel[3]; gLoc[0] = coords.x; gLoc[1] = coords.y; gLoc[2] = coords.z; - vel[0] = velocity.x; - vel[1] = velocity.y; - vel[2] = velocity.z; if (id == 0) { OPENAL_3D_SetAttributes(channels[whooshsound], gLoc); @@ -4800,13 +4796,9 @@ void Person::DoStuff() if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) { float gLoc[3]; - float vel[3]; gLoc[0] = coords.x; gLoc[1] = coords.y; gLoc[2] = coords.z; - vel[0] = velocity.x; - vel[1] = velocity.y; - vel[2] = velocity.z; if (id == 0) { OPENAL_3D_SetAttributes(channels[whooshsound], gLoc); @@ -7601,7 +7593,7 @@ void Person::doAI() if (aitype == pathfindtype) { if (finalpathfindpoint == -1) { float closestdistance; - float tempdist; + float tempdist = 0.0f; int closest; XYZ colpoint; closest = -1; @@ -7631,7 +7623,7 @@ void Person::doAI() } if (targetpathfindpoint == -1) { float closestdistance; - float tempdist; + float tempdist = 0.0f; int closest; XYZ colpoint; closest = -1; @@ -8451,10 +8443,11 @@ void Person::doAI() //chase player XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity; XYZ targetpoint = Person::players[0]->coords; - if (distsq(&Person::players[0]->coords, &coords) < - distsq(&rotatetarget, &coords)) { + 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) / findLength(&velocity); + findDistance(&Person::players[0]->coords, &coords) / vellength; } targetyaw = roughDirectionTo(coords, targetpoint); lookyaw = targetyaw;