]> git.jsancho.org Git - lugaru.git/commitdiff
Player friend looks at the player
authorJavier Sancho <jsf@jsancho.org>
Tue, 20 Feb 2018 10:31:24 +0000 (11:31 +0100)
committerJavier Sancho <jsf@jsancho.org>
Tue, 20 Feb 2018 10:31:24 +0000 (11:31 +0100)
Source/Objects/Person.cpp

index 8022c0fc3323f023bc485bb3ff2eb20a7ae12ad9..2a4d4ae1b9f4e1f320394c3d63547b4e84b426bb 100644 (file)
@@ -7325,7 +7325,7 @@ bool Person::addClothes(const int& clothesId)
 
 void Person::doAI()
 {
-    if (!isPlayerControlled() && !isPlayerFriend() && !Dialog::inDialog()) {
+    if (!isPlayerControlled() && !Dialog::inDialog()) {
         jumpclimb = 0;
         //disable movement in editor
         if (Game::editorenabled) {
@@ -7488,6 +7488,7 @@ void Person::doAI()
 
             if ((!Tutorial::active || cananger) &&
                 hostile &&
+                !isPlayerFriend() &&
                 !Person::players[0]->dead &&
                 distsq(&coords, &Person::players[0]->coords) < 400 &&
                 occluded < 25) {
@@ -7605,7 +7606,7 @@ void Person::doAI()
             //hearing sounds
             if (!Game::editorenabled) {
                 if (howactive <= typesleeping) {
-                    if (numenvsounds > 0 && (!Tutorial::active || cananger) && hostile) {
+                  if (numenvsounds > 0 && (!Tutorial::active || cananger) && !isPlayerFriend() && hostile) {
                         for (int j = 0; j < numenvsounds; j++) {
                             float vol = howactive == typesleeping ? envsoundvol[j] - 14 : envsoundvol[j];
                             if (vol > 0 && distsq(&coords, &envsound[j]) < 2 * (vol + vol * (creature == rabbittype) * 3)) {
@@ -7625,6 +7626,7 @@ void Person::doAI()
 
             if (howactive < typesleeping &&
                 ((!Tutorial::active || cananger) && hostile) &&
+                !isPlayerFriend() &&
                 !Person::players[0]->dead &&
                 distsq(&coords, &Person::players[0]->coords) < 400 &&
                 occluded < 25) {
@@ -7803,7 +7805,7 @@ void Person::doAI()
                 jumpkeydown = 1;
             }
 
-            if (numenvsounds > 0 && ((!Tutorial::active || cananger) && hostile)) {
+            if (numenvsounds > 0 && ((!Tutorial::active || cananger) && !isPlayerFriend() && hostile)) {
                 for (int k = 0; k < numenvsounds; k++) {
                     if (distsq(&coords, &envsound[k]) < 2 * (envsoundvol[k] + envsoundvol[k] * (creature == rabbittype) * 3)) {
                         aitype = attacktypecutoff;
@@ -7812,6 +7814,7 @@ void Person::doAI()
             }
 
             if (!Person::players[0]->dead &&
+                !isPlayerFriend() &&
                 losupdatedelay < 0 &&
                 !Game::editorenabled &&
                 occluded < 2 &&
@@ -7997,7 +8000,7 @@ void Person::doAI()
 
                 lastseentime = 12;
 
-                if (!Person::players[0]->dead && ((!Tutorial::active || cananger) && hostile)) {
+                if (!Person::players[0]->dead && !isPlayerFriend() && ((!Tutorial::active || cananger) && hostile)) {
                     if (ally < 0 || hasWeapon() || lastchecktime <= 0) {
                         aitype = attacktypecutoff;
                         lastseentime = 1;
@@ -8390,6 +8393,9 @@ void Person::doAI()
         } else if (howactive >= typesleeping) {
             targetheadyaw = targetyaw;
             targetheadpitch = 0;
+        } else if (isPlayerFriend()) {
+            targetheadyaw = 180 - roughDirectionTo(coords, Person::players[0]->coords);
+            targetheadpitch = pitchTo(coords, Person::players[0]->coords);
         } else {
             if (interestdelay <= 0) {
                 interestdelay = .7 + (float)(abs(Random() % 100)) / 100;