]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Objects/Person.hpp
New non-atacking player
[lugaru.git] / Source / Objects / Person.hpp
index ba329fe52639255f20c400403fb7b3c2f2198d64..22c76eb17c4e82fd9038352c5e35ad2b022067b4 100644 (file)
@@ -23,12 +23,12 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "Animation/Animation.hpp"
 #include "Animation/Skeleton.hpp"
-#include "Audio/Sounds.hpp"
 #include "Environment/Terrain.hpp"
-#include "Graphic/gamegl.hpp"
 #include "Graphic/Models.hpp"
 #include "Graphic/Sprite.hpp"
+#include "Graphic/gamegl.hpp"
 #include "Math/XYZ.hpp"
+#include "Objects/PersonType.hpp"
 #include "Objects/Weapons.hpp"
 
 #include <cmath>
@@ -44,45 +44,12 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #define getweapontype 7
 #define pathfindtype 8
 
-enum person_type
-{
-    rabbittype = 0,
-    wolftype = 1
-};
-
-struct InvalidPersonException : public exception {
-   const char * what () const throw () {
-      return "Invalid weapon number";
-   }
-};
-
-class PersonType
+struct InvalidPersonException : public exception
 {
-public:
-    // head, body, arms, legs
-    XYZ proportions[4];
-    animation_type animRun;
-    animation_type animRunning;
-    animation_type animCrouch;
-    animation_type animStop;
-    animation_type animLanding;
-    animation_type animLandingHard;
-    sound_type soundsAttack[4];
-    sound_type soundsTalk[2];
-
-    std::string figureFileName;
-    std::string lowFigureFileName;
-    std::string clothesFileName;
-    std::string modelFileNames[7];
-    std::string lowModelFileName;
-    std::string modelClothesFileName;
-
-    std::vector<std::string> skins;
-
-    GLubyte bloodText[512 * 512 * 3] = { 0 };
-
-    static std::vector<PersonType> types;
-    static void Load();
+    const char* what() const throw()
+    {
+        return "Invalid weapon number";
+    }
 };
 
 class Person : public enable_shared_from_this<Person>
@@ -131,11 +98,6 @@ public:
     XYZ coords;
     XYZ velocity;
 
-    //~ XYZ proportionhead;
-    //~ XYZ proportionlegs;
-    //~ XYZ proportionarms;
-    //~ XYZ proportionbody;
-
     float unconscioustime;
 
     bool immobile;
@@ -195,6 +157,7 @@ public:
 
     std::shared_ptr<Person> victim;
     bool hasvictim;
+    bool isplayerfriend;
 
     float updatedelay;
     float normalsupdatedelay;
@@ -223,7 +186,6 @@ public:
     float jumpkeydowntime;
     bool freefall;
 
-
     float turnspeed;
 
     int aitype;
@@ -357,7 +319,7 @@ public:
     Person();
     Person(FILE*, int, unsigned);
 
-    void skeletonLoad(bool clothes = false);
+    void skeletonLoad();
 
     // convenience functions
     inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
@@ -366,8 +328,11 @@ public:
     inline AnimationFrame& currentFrame() { return Animation::animations.at(animCurrent).frames.at(frameCurrent); }
     inline AnimationFrame& targetFrame() { return Animation::animations.at(animTarget).frames.at(frameTarget); }
 
-    void setProportions(float, float, float, float);
-    XYZ getProportion(int part) const;
+    void setProportions(float head, float body, float arms, float legs);
+    float getProportion(int part) const;
+    XYZ getProportionXYZ(int part) const;
+
+    void changeCreatureType(person_type type);
 
     void CheckKick();
     void CatchFire();
@@ -414,13 +379,14 @@ public:
     void Reverse();
     void DoDamage(float howmuch);
     void DoHead();
-    void DoMipmaps() {
+    void DoMipmaps()
+    {
         skeleton.drawmodel.textureptr.bind();
         glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
     }
 
-    int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
+    int SphereCheck(XYZ* p1, float radius, XYZ* p, XYZ* move, float* rotate, Model* model);
     int DrawSkeleton();
     void Puff(int whichlabel);
     void FootLand(bodypart whichfoot, float opacity);
@@ -429,12 +395,18 @@ public:
     void DoAnimations();
     void RagDoll(bool checkcollision);
 
-    void takeWeapon (int weaponId);
+    void takeWeapon(int weaponId);
 
     bool addClothes(const int& clothesId);
     void addClothes();
 
     void doAI();
+
+    bool catchKnife();
+
+    bool hasWeapon() { return (weaponactive != -1); }
+    bool isPlayerControlled() { return (aitype == playercontrolled); }
+    bool isPlayerFriend() { return isplayerfriend; }
 };
 
 const int maxplayers = 10;