]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Objects/Person.cpp
Moved hurtidle anim to PersonType to avoid hardcoded wolftype test
[lugaru.git] / Source / Objects / Person.cpp
index 01b9f903e98631d2f568c20b96b98ce20003d47c..279fb32f704e870b61393255d675979c256856dc 100644 (file)
@@ -618,8 +618,8 @@ int Person::getIdle()
             }
         }
     }
-    if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && creature != wolftype) {
-        return hurtidleanim;
+    if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && PersonType::types[creature].hasAnimHurtIdle()) {
+        return PersonType::types[creature].animHurtIdle;
     }
     if (howactive == typesitting) {
         return sitanim;
@@ -6009,19 +6009,10 @@ void Person::DoStuff()
         } else if (isRun()) {
             velocity += facing * multiplier * speed * 700 * scale;
             velspeed = findLength(&velocity);
-            if (creature == rabbittype) {
-                if (velspeed > speed * 55 * scale) {
-                    velocity /= velspeed;
-                    velspeed = speed * 55 * scale;
-                    velocity *= velspeed;
-                }
-            }
-            if (creature == wolftype) {
-                if (velspeed > speed * 75 * scale) {
-                    velocity /= velspeed;
-                    velspeed = speed * 75 * scale;
-                    velocity *= velspeed;
-                }
+            if (velspeed > speed * PersonType::types[creature].maxRunSpeed * scale) {
+                velocity /= velspeed;
+                velspeed = speed * PersonType::types[creature].maxRunSpeed * scale;
+                velocity *= velspeed;
             }
             velocity.y += gravity * multiplier * 20;
             ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
@@ -8426,3 +8417,10 @@ void Person::doAI()
         }
     }
 }
+
+bool Person::catchKnife()
+{
+    return
+        ((PersonType::types[creature].knifeCatchingType == 0) && (Random() % 2 != 0) && (weaponactive == -1) && (aitype == attacktypecutoff)) ||
+        ((PersonType::types[creature].knifeCatchingType == 1) && (Random() % 3 != 0) && (weaponactive == -1) && (isIdle() || isRun() || animTarget == walkanim));
+}