]> git.jsancho.org Git - lugaru.git/commitdiff
Moved knife catching test to a method and removed hardcoded rabbittype test
authorCôme Chilliet <come@chilliet.eu>
Sat, 19 Aug 2017 00:01:08 +0000 (02:01 +0200)
committerCôme Chilliet <come@chilliet.eu>
Sat, 19 Aug 2017 00:01:08 +0000 (02:01 +0200)
Source/Objects/Person.cpp
Source/Objects/Person.hpp
Source/Objects/PersonType.cpp
Source/Objects/PersonType.hpp
Source/Objects/Weapons.cpp

index 0ca911a0114ae16dc010426f0ca72150036966bd..8898cac60bba81fce30ded86d76c38b5dc9c3ea4 100644 (file)
@@ -8417,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));
+}
index 0bacf772b21744eda7de9d07be2b197c83d02e8b..9492fb704f5ad59a714e7b545299f97e3b4eb2ed 100644 (file)
@@ -400,6 +400,8 @@ public:
     void addClothes();
 
     void doAI();
+
+    bool catchKnife();
 };
 
 const int maxplayers = 10;
index c1a3aec9a8cd52d7351b3a03dc4552ed4d5eef58..0cf880c12d9bf7d36bef4111726dd582af6ef4f5 100644 (file)
@@ -81,6 +81,7 @@ void PersonType::Load()
     types[wolftype].hasClaws = true;
     types[wolftype].clothes = false;
     types[wolftype].maxRunSpeed = 75;
+    types[wolftype].knifeCatchingType = 1;
 
     /* Rabbit */
     types[rabbittype].proportions[0] = 1.2;
@@ -137,4 +138,5 @@ void PersonType::Load()
     types[rabbittype].hasClaws = false;
     types[rabbittype].clothes = true;
     types[rabbittype].maxRunSpeed = 55;
+    types[rabbittype].knifeCatchingType = 0;
 }
index b60fc195c2fd21ad89c33b93c520ea3470aa4c67..f981113bf536fd5fd77642dacede336448cc0b05 100644 (file)
@@ -63,6 +63,7 @@ public:
     bool hasClaws;
     bool clothes;
     unsigned int maxRunSpeed;
+    unsigned int knifeCatchingType;
 
     GLubyte bloodText[512 * 512 * 3] = { 0 };
 
index 846ccad5d3b2d8d57f86254bfed5bc6b18607aa2..015fb91f3738bf4213f72ece28a1b6602510a78d 100644 (file)
@@ -259,8 +259,7 @@ void Weapon::doStuff(int i)
                     distsq(&position, &Person::players[j]->coords) < 4 && Person::players[j]->weaponstuck == -1 &&
                     !Person::players[j]->skeleton.free && (int(j) != oldowner)) {
                     if ((Person::players[j]->aitype != attacktypecutoff || abs(Random() % 6) == 0 || (Person::players[j]->animTarget != backhandspringanim && Person::players[j]->animTarget != rollanim && Person::players[j]->animTarget != flipanim && Random() % 2 == 0)) && !missed) {
-                        if ((Person::players[j]->creature == wolftype && Random() % 3 != 0 && Person::players[j]->weaponactive == -1 && (Person::players[j]->isIdle() || Person::players[j]->isRun() || Person::players[j]->animTarget == walkanim)) ||
-                            (Person::players[j]->creature == rabbittype && Random() % 2 == 0 && Person::players[j]->aitype == attacktypecutoff && Person::players[j]->weaponactive == -1)) {
+                        if (Person::players[j]->catchKnife()) {
                             emit_sound_at(knifedrawsound, Person::players[j]->coords, 128.);
 
                             Person::players[j]->animTarget = removeknifeanim;