]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Person.cpp
Moved as much as possible init in Person constructor
[lugaru.git] / Source / Person.cpp
index 421709b1ed90481b8a5f3882c26170a8821deedb..3729c4f6ebc3c31895da0956a59698b398cb1413 100644 (file)
@@ -25,6 +25,8 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include "Sounds.h"
 #include "Awards.h"
 #include "Game.h"
+#include "Dialog.h"
+#include "Utils/Folders.h"
 
 extern float multiplier;
 extern Terrain terrain;
@@ -65,8 +67,6 @@ extern float damagedealt;
 extern int hostile;
 extern float hostiletime;
 
-extern int indialogue;
-
 extern bool gamestarted;
 
 std::vector<std::shared_ptr<Person>> Person::players(1, std::shared_ptr<Person>(new Person()));
@@ -74,10 +74,10 @@ std::vector<std::shared_ptr<Person>> Person::players(1, std::shared_ptr<Person>(
 Person::Person() :
     whichpatchx(0),
     whichpatchz(0),
-    animCurrent(0),
-    animTarget(0),
+    animCurrent(bounceidleanim),
+    animTarget(bounceidleanim),
     frameCurrent(0),
-    frameTarget(0),
+    frameTarget(1),
     oldanimCurrent(0),
     oldanimTarget(0),
     oldframeCurrent(0),
@@ -127,14 +127,14 @@ Person::Person() :
     deathbleeding(0),
     tempdeltav(0),
 
-    damagetolerance(0),
+    damagetolerance(200),
     damage(0),
     permanentdamage(0),
     superpermanentdamage(0),
     lastcollide(0),
     dead(0),
 
-    jumppower(0),
+    jumppower(5),
     onground(false),
 
     wentforweapon(0),
@@ -187,12 +187,12 @@ Person::Person() :
 
     turnspeed(0),
 
-    aitype(0),
+    aitype(passivetype),
     aiupdatedelay(0),
     losupdatedelay(0),
     ally(0),
     collide(0),
-    collided(0),
+    collided(-10),
     avoidcollided(0),
     loaded(false),
     whichdirection(false),
@@ -213,7 +213,7 @@ Person::Person() :
     tailmorphness(0),
     targetlefthandmorphness(0),
     targetrighthandmorphness(0),
-    targetheadmorphness(0),
+    targetheadmorphness(1),
     targetchestmorphness(0),
     targettailmorphness(0),
     lefthandmorphstart(0), lefthandmorphend(0),
@@ -262,7 +262,7 @@ Person::Person() :
 
     num_weapons(0),
     weaponactive(-1),
-    weaponstuck(0),
+    weaponstuck(-1),
     weaponstuckwhere(0),
 
     numwaypoints(0),
@@ -288,6 +288,7 @@ Person::Person() :
     stunned(0),
     surprised(0),
     runninghowlong(0),
+    occluded(0),
     lastoccluded(0),
     laststanding(0),
     escapednum(0),
@@ -302,8 +303,6 @@ Person::Person() :
 
     tempanimation(),
 
-    occluded(0),
-
     jumpclimb(false)
 {
 }
@@ -400,6 +399,20 @@ Person::Person(FILE *tfile, int mapvers, unsigned i) : Person()
         clothes[k][templength] = '\0';
         funpackf(tfile, "Bf Bf Bf", &clothestintr[k], &clothestintg[k], &clothestintb[k]);
     }
+
+    loaded = true;
+
+    if (scale < 0) {
+        if (creature == wolftype) {
+            scale = .23;
+            damagetolerance = 300;
+        } else {
+            scale = .2;
+        }
+    }
+
+    oldcoords = coords;
+    realoldcoords = coords;
 }
 
 /* EFFECT
@@ -505,7 +518,7 @@ void Person::CatchFire()
  */
 int Person::getIdle()
 {
-    if (indialogue != -1 && howactive == typeactive && creature == rabbittype)
+    if (Dialog::inDialog() && (howactive == typeactive) && (creature == rabbittype))
         return talkidleanim;
     if (hasvictim && (victim != this->shared_from_this())/*||(id==0&&attackkeydown)*/)
         if (/*(id==0&&attackkeydown)||*/(!victim->dead && victim->aitype != passivetype &&
@@ -6792,7 +6805,7 @@ bool Person::addClothes(const int& clothesId)
 
     //Load Image
     ImageRec texture;
-    bool opened = load_image(fileName, texture);
+    bool opened = load_image(Folders::getResourcePath(fileName).c_str(), texture);
 
     float alphanum;
     //Is it valid?