]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Objects/Person.cpp
Moved PersonType class to its own file
[lugaru.git] / Source / Objects / Person.cpp
index 6c4bbbbb42df9559c0f09b4a03af5e5230f1c0fb..f020f5e67a9990f8423dbb6b05b71faea3d41944 100644 (file)
@@ -42,8 +42,6 @@ extern float slomodelay;
 extern bool cellophane;
 extern float texdetail;
 extern float realtexdetail;
-extern GLubyte bloodText[512 * 512 * 3];
-extern GLubyte wolfbloodText[512 * 512 * 3];
 extern int bloodtoggle;
 extern bool autoslomo;
 extern float camerashake;
@@ -75,96 +73,6 @@ extern float envsoundlife[30];
 extern XYZ windvector;
 
 std::vector<std::shared_ptr<Person>> Person::players(1, std::shared_ptr<Person>(new Person()));
-std::vector<PersonType> PersonType::types;
-
-void PersonType::Load()
-{
-    types.resize(2);
-
-    /* Wolf */
-    types[wolftype].proportions[0] = 1.1;
-    types[wolftype].proportions[1] = 1.1;
-    types[wolftype].proportions[2] = 1.1;
-    types[wolftype].proportions[3] = 1.1;
-
-    types[wolftype].animRun = wolfrunanim;
-    types[wolftype].animRunning = wolfrunninganim;
-    types[wolftype].animCrouch = wolfcrouchanim;
-    types[wolftype].animStop = wolfstopanim;
-    types[wolftype].animLanding = wolflandanim;
-    types[wolftype].animLandingHard = wolflandhardanim;
-
-    types[wolftype].soundsAttack[0] = barksound;
-    types[wolftype].soundsAttack[1] = bark2sound;
-    types[wolftype].soundsAttack[2] = bark3sound;
-    types[wolftype].soundsAttack[3] = barkgrowlsound;
-    types[wolftype].soundsTalk[0] = growlsound;
-    types[wolftype].soundsTalk[1] = growl2sound;
-
-    types[wolftype].figureFileName = "Skeleton/BasicFigureWolf";
-    types[wolftype].lowFigureFileName = "Skeleton/BasicFigureWolfLow";
-    types[wolftype].clothesFileName = "Skeleton/RabbitBelt";
-    types[wolftype].modelFileNames[0] = "Models/Wolf.solid";
-    types[wolftype].modelFileNames[1] = "Models/Wolf2.solid";
-    types[wolftype].modelFileNames[2] = "Models/Wolf3.solid";
-    types[wolftype].modelFileNames[3] = "Models/Wolf4.solid";
-    types[wolftype].modelFileNames[4] = "Models/Wolf5.solid";
-    types[wolftype].modelFileNames[5] = "Models/Wolf6.solid";
-    types[wolftype].modelFileNames[6] = "Models/Wolf7.solid";
-    types[wolftype].lowModelFileName = "Models/WolfLow.solid";
-    types[wolftype].modelClothesFileName = "Models/Belt.solid";
-
-    types[wolftype].skins.resize(3);
-    types[wolftype].skins[0] = "Textures/Wolf.jpg";
-    types[wolftype].skins[1] = "Textures/DarkWolf.jpg";
-    types[wolftype].skins[2] = "Textures/SnowWolf.jpg";
-
-    /* Rabbit */
-    types[rabbittype].proportions[0] = 1.2;
-    types[rabbittype].proportions[1] = 1.05;
-    types[rabbittype].proportions[2] = 1;
-    types[rabbittype].proportions[3] = 1.1;
-    types[rabbittype].proportions[3].y = 1.05;
-
-    types[rabbittype].animRun = runanim;
-    types[rabbittype].animRunning = rabbitrunninganim;
-    types[rabbittype].animCrouch = crouchanim;
-    types[rabbittype].animStop = stopanim;
-    types[rabbittype].animLanding = landanim;
-    types[rabbittype].animLandingHard = landhardanim;
-
-    types[rabbittype].soundsAttack[0] = rabbitattacksound;
-    types[rabbittype].soundsAttack[1] = rabbitattack2sound;
-    types[rabbittype].soundsAttack[2] = rabbitattack3sound;
-    types[rabbittype].soundsAttack[3] = rabbitattack4sound;
-    types[rabbittype].soundsTalk[0] = rabbitchitter;
-    types[rabbittype].soundsTalk[1] = rabbitchitter2;
-
-    types[rabbittype].figureFileName = "Skeleton/BasicFigure";
-    types[rabbittype].lowFigureFileName = "Skeleton/BasicFigureLow";
-    types[rabbittype].clothesFileName = "Skeleton/RabbitBelt";
-    types[rabbittype].modelFileNames[0] = "Models/Body.solid";
-    types[rabbittype].modelFileNames[1] = "Models/Body2.solid";
-    types[rabbittype].modelFileNames[2] = "Models/Body3.solid";
-    types[rabbittype].modelFileNames[3] = "Models/Body4.solid";
-    types[rabbittype].modelFileNames[4] = "Models/Body5.solid";
-    types[rabbittype].modelFileNames[5] = "Models/Body6.solid";
-    types[rabbittype].modelFileNames[6] = "Models/Body7.solid";
-    types[rabbittype].lowModelFileName = "Models/BodyLow.solid";
-    types[rabbittype].modelClothesFileName = "Models/Belt.solid";
-
-    types[rabbittype].skins.resize(10);
-    types[rabbittype].skins[0] = "Textures/Fur3.jpg";
-    types[rabbittype].skins[1] = "Textures/Fur.jpg";
-    types[rabbittype].skins[2] = "Textures/Fur2.jpg";
-    types[rabbittype].skins[3] = "Textures/Lynx.jpg";
-    types[rabbittype].skins[4] = "Textures/Otter.jpg";
-    types[rabbittype].skins[5] = "Textures/Opal.jpg";
-    types[rabbittype].skins[6] = "Textures/Sable.jpg";
-    types[rabbittype].skins[7] = "Textures/Chocolate.jpg";
-    types[rabbittype].skins[8] = "Textures/BW2.jpg";
-    types[rabbittype].skins[9] = "Textures/WB2.jpg";
-}
 
 Person::Person()
     : whichpatchx(0)
@@ -678,20 +586,15 @@ void Person::CatchFire()
  */
 int Person::getIdle()
 {
-    if (Dialog::inDialog() && (howactive == typeactive) && (creature == rabbittype)) {
-        return talkidleanim;
+    if (Dialog::inDialog() && (howactive == typeactive) && PersonType::types[creature].hasAnimTalkIdle()) {
+        return PersonType::types[creature].animTalkIdle;
     }
     if (hasvictim && (victim != this->shared_from_this())) {
         if ((!victim->dead && victim->aitype != passivetype &&
              victim->aitype != searchtype && aitype != passivetype && aitype != searchtype &&
              victim->id < Person::players.size())) {
             if ((aitype == playercontrolled && stunned <= 0 && weaponactive == -1) || pause) {
-                if (creature == rabbittype) {
-                    return fightidleanim;
-                }
-                if (creature == wolftype) {
-                    return wolfidle;
-                }
+                return PersonType::types[creature].animFightIdle;
             }
             if (aitype == playercontrolled && stunned <= 0 && weaponactive != -1) {
                 if (weapons[weaponids[weaponactive]].getType() == knife) {
@@ -736,13 +639,7 @@ int Person::getIdle()
     if (howactive == typedead4) {
         return dead4anim;
     }
-    if (creature == rabbittype) {
-        return bounceidleanim;
-    }
-    if (creature == wolftype) {
-        return wolfidle;
-    }
-    return 0;
+    return PersonType::types[creature].animBounceIdle;
 }
 
 /* FUNCTION
@@ -857,17 +754,9 @@ void Person::DoBlood(float howmuch, int which)
             bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25;
             bleedxint = 0;
             bleedyint = 0;
-            if (creature == rabbittype) {
-                while (bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
-                    bleedxint = abs(Random() % 512);
-                    bleedyint = abs(Random() % 512);
-                }
-            }
-            if (creature == wolftype) {
-                while (wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
-                    bleedxint = abs(Random() % 512);
-                    bleedyint = abs(Random() % 512);
-                }
+            while (PersonType::types[creature].bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || PersonType::types[creature].bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
+                bleedxint = abs(Random() % 512);
+                bleedyint = abs(Random() % 512);
             }
             bleedy = bleedxint;
             bleedx = bleedyint;
@@ -980,42 +869,20 @@ void Person::DoBloodBig(float howmuch, int which)
         int endx = 0;
         int endy = 0;
         GLubyte color;
-        if (creature == rabbittype) {
-            for (i = 0; i < 512; i++) {
-                for (j = 0; j < 512; j++) {
-                    if (bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
-                        if (i < startx) {
-                            startx = i;
-                        }
-                        if (j < starty) {
-                            starty = j;
-                        }
-                        if (i > endx) {
-                            endx = i;
-                        }
-                        if (j > endy) {
-                            endy = j;
-                        }
+        for (i = 0; i < 512; i++) {
+            for (j = 0; j < 512; j++) {
+                if (PersonType::types[creature].bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && PersonType::types[creature].bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
+                    if (i < startx) {
+                        startx = i;
                     }
-                }
-            }
-        }
-        if (creature == wolftype) {
-            for (i = 0; i < 512; i++) {
-                for (j = 0; j < 512; j++) {
-                    if (wolfbloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && wolfbloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
-                        if (i < startx) {
-                            startx = i;
-                        }
-                        if (j < starty) {
-                            starty = j;
-                        }
-                        if (i > endx) {
-                            endx = i;
-                        }
-                        if (j > endy) {
-                            endy = j;
-                        }
+                    if (j < starty) {
+                        starty = j;
+                    }
+                    if (i > endx) {
+                        endx = i;
+                    }
+                    if (j > endy) {
+                        endy = j;
                     }
                 }
             }
@@ -1052,33 +919,16 @@ void Person::DoBloodBig(float howmuch, int which)
 
         int texdetailint = realtexdetail;
         int where;
-        if (creature == rabbittype) {
-            for (i = startx; i < endx; i++) {
-                for (j = starty; j < endy; j++) {
-                    if (bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
-                        color = Random() % 85 + 170;
-                        where = i * skeleton.skinsize * 3 + j * 3;
-                        if (skeleton.skinText[where + 0] > color / 2) {
-                            skeleton.skinText[where + 0] = color / 2;
-                        }
-                        skeleton.skinText[where + 1] = 0;
-                        skeleton.skinText[where + 2] = 0;
-                    }
-                }
-            }
-        }
-        if (creature == wolftype) {
-            for (i = startx; i < endx; i++) {
-                for (j = starty; j < endy; j++) {
-                    if (wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
-                        color = Random() % 85 + 170;
-                        where = i * skeleton.skinsize * 3 + j * 3;
-                        if (skeleton.skinText[where + 0] > color / 2) {
-                            skeleton.skinText[where + 0] = color / 2;
-                        }
-                        skeleton.skinText[where + 1] = 0;
-                        skeleton.skinText[where + 2] = 0;
+        for (i = startx; i < endx; i++) {
+            for (j = starty; j < endy; j++) {
+                if (PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
+                    color = Random() % 85 + 170;
+                    where = i * skeleton.skinsize * 3 + j * 3;
+                    if (skeleton.skinText[where + 0] > color / 2) {
+                        skeleton.skinText[where + 0] = color / 2;
                     }
+                    skeleton.skinText[where + 1] = 0;
+                    skeleton.skinText[where + 2] = 0;
                 }
             }
         }
@@ -1087,17 +937,9 @@ void Person::DoBloodBig(float howmuch, int which)
 
         bleedxint = 0;
         bleedyint = 0;
-        if (creature == rabbittype) {
-            while (bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
-                bleedxint = abs(Random() % 512);
-                bleedyint = abs(Random() % 512);
-            }
-        }
-        if (creature == wolftype) {
-            while (wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
-                bleedxint = abs(Random() % 512);
-                bleedyint = abs(Random() % 512);
-            }
+        while (PersonType::types[creature].bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || PersonType::types[creature].bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
+            bleedxint = abs(Random() % 512);
+            bleedyint = abs(Random() % 512);
         }
         bleedy = bleedxint + offsetx;
         bleedx = bleedyint + offsety;
@@ -1231,42 +1073,20 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where)
             int endx = 0;
             int endy = 0;
             GLubyte color;
-            if (creature == rabbittype) {
-                for (i = 0; i < 512; i++) {
-                    for (j = 0; j < 512; j++) {
-                        if (bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
-                            if (i < startx) {
-                                startx = i;
-                            }
-                            if (j < starty) {
-                                starty = j;
-                            }
-                            if (i > endx) {
-                                endx = i;
-                            }
-                            if (j > endy) {
-                                endy = j;
-                            }
+            for (i = 0; i < 512; i++) {
+                for (j = 0; j < 512; j++) {
+                    if (PersonType::types[creature].bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && PersonType::types[creature].bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
+                        if (i < startx) {
+                            startx = i;
                         }
-                    }
-                }
-            }
-            if (creature == wolftype) {
-                for (i = 0; i < 512; i++) {
-                    for (j = 0; j < 512; j++) {
-                        if (wolfbloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && wolfbloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
-                            if (i < startx) {
-                                startx = i;
-                            }
-                            if (j < starty) {
-                                starty = j;
-                            }
-                            if (i > endx) {
-                                endx = i;
-                            }
-                            if (j > endy) {
-                                endy = j;
-                            }
+                        if (j < starty) {
+                            starty = j;
+                        }
+                        if (i > endx) {
+                            endx = i;
+                        }
+                        if (j > endy) {
+                            endy = j;
                         }
                     }
                 }
@@ -1302,49 +1122,24 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where)
 
             int texdetailint = realtexdetail;
             int where;
-            if (creature == rabbittype) {
-                for (i = startx; i < endx; i++) {
-                    for (j = starty; j < endy; j++) {
-                        if (bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
-                            color = Random() % 85 + 170;
-                            where = i * skeleton.skinsize * 3 + j * 3;
-                            if (skeleton.skinText[where + 0] > color / 2) {
-                                skeleton.skinText[where + 0] = color / 2;
-                            }
-                            skeleton.skinText[where + 1] = 0;
-                            skeleton.skinText[where + 2] = 0;
-                        } else if (bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= 160 + 4 && bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= 160 - 4) {
-                            color = Random() % 85 + 170;
-                            where = i * skeleton.skinsize * 3 + j * 3;
-                            if (skeleton.skinText[where + 0] > color / 2) {
-                                skeleton.skinText[where + 0] = color / 2;
-                            }
-                            skeleton.skinText[where + 1] = 0;
-                            skeleton.skinText[where + 2] = 0;
+            for (i = startx; i < endx; i++) {
+                for (j = starty; j < endy; j++) {
+                    if (PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
+                        color = Random() % 85 + 170;
+                        where = i * skeleton.skinsize * 3 + j * 3;
+                        if (skeleton.skinText[where + 0] > color / 2) {
+                            skeleton.skinText[where + 0] = color / 2;
                         }
-                    }
-                }
-            }
-            if (creature == wolftype) {
-                for (i = startx; i < endx; i++) {
-                    for (j = starty; j < endy; j++) {
-                        if (wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
-                            color = Random() % 85 + 170;
-                            where = i * skeleton.skinsize * 3 + j * 3;
-                            if (skeleton.skinText[where + 0] > color / 2) {
-                                skeleton.skinText[where + 0] = color / 2;
-                            }
-                            skeleton.skinText[where + 1] = 0;
-                            skeleton.skinText[where + 2] = 0;
-                        } else if (wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= 160 + 4 && wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= 160 - 4) {
-                            color = Random() % 85 + 170;
-                            where = i * skeleton.skinsize * 3 + j * 3;
-                            if (skeleton.skinText[where + 0] > color / 2) {
-                                skeleton.skinText[where + 0] = color / 2;
-                            }
-                            skeleton.skinText[where + 1] = 0;
-                            skeleton.skinText[where + 2] = 0;
+                        skeleton.skinText[where + 1] = 0;
+                        skeleton.skinText[where + 2] = 0;
+                    } else if (PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= 160 + 4 && PersonType::types[creature].bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= 160 - 4) {
+                        color = Random() % 85 + 170;
+                        where = i * skeleton.skinsize * 3 + j * 3;
+                        if (skeleton.skinText[where + 0] > color / 2) {
+                            skeleton.skinText[where + 0] = color / 2;
                         }
+                        skeleton.skinText[where + 1] = 0;
+                        skeleton.skinText[where + 2] = 0;
                     }
                 }
             }