X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FPerson.h;h=cb62622f0710f4984aa2e846e5797cde223dd139;hb=8a32dc9e4e1011b10f009e999d7d008aa2711d8a;hp=754a046676763e5f138798723124659e11fdad68;hpb=320a287705c0463c6f8943ad9cf4c407c556f703;p=lugaru.git diff --git a/Source/Person.h b/Source/Person.h index 754a046..cb62622 100644 --- a/Source/Person.h +++ b/Source/Person.h @@ -1,22 +1,21 @@ /* Copyright (C) 2003, 2010 - Wolfire Games +Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. -Lugaru is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. +Lugaru is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. -This program is distributed in the hope that it will be useful, +Lugaru is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +along with Lugaru. If not, see . */ #ifndef _PERSON_H_ @@ -26,13 +25,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "gamegl.h" #include "Quaternions.h" -#include "Skeleton.h" +#include "Animation/Skeleton.h" #include "Models.h" #include "Terrain.h" #include "Sprite.h" #include +#include #include "Weapons.h" -#include "Animation.h" +#include "Animation/Animation.h" #define passivetype 0 #define guardtype 1 @@ -47,9 +47,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define rabbittype 0 #define wolftype 1 -class Person +struct InvalidPersonException : public exception { + const char * what () const throw () { + return "Invalid weapon number"; + } +}; + +class Person : public enable_shared_from_this { public: + static std::vector> players; + int whichpatchx; int whichpatchz; @@ -86,7 +94,6 @@ public: XYZ realoldcoords; XYZ oldcoords; XYZ coords; - XYZ originalcoords; XYZ velocity; XYZ proportionhead; @@ -126,18 +133,16 @@ public: float permanentdamage; float superpermanentdamage; float lastcollide; + /* Seems to be 0 = alive, 1 = unconscious, 2 = dead */ int dead; float jumppower; bool onground; - int madskills; int wentforweapon; bool calcrot; - bool backwardsanim; - XYZ facing; float bleeding; @@ -153,7 +158,7 @@ public: float grabdelay; - Person *victim; + std::shared_ptr victim; bool hasvictim; float updatedelay; @@ -190,7 +195,6 @@ public: float aiupdatedelay; float losupdatedelay; int ally; - XYZ movetarget; float collide; float collided; float avoidcollided; @@ -225,11 +229,10 @@ public: float weaponmissdelay; float highreversaldelay; float lowreversaldelay; - float nocollidedelay; int creature; - int id; + unsigned id; Skeleton skeleton; @@ -260,26 +263,24 @@ public: bool onfire; float onfiredelay; float burnt; - float fireduration; float flamedelay; - float updatestuffdelay; int playerdetail; int num_weapons; int weaponids[4]; + /* Key of weaponids which is the weapon in hand, if any. -1 otherwise. + * Always 0 or -1 as activeweapon is moved to position 0 when taken */ int weaponactive; int weaponstuck; + /* 0 or 1 to say if weapon is stuck in the front or the back */ int weaponstuckwhere; - int weaponwhere; int numwaypoints; XYZ waypoints[90]; int waypointtype[90]; float pausetime; - bool hastempwaypoint; - XYZ tempwaypoint; XYZ headtarget; float interestdelay; @@ -292,10 +293,8 @@ public: int lastpathfindpoint2; int lastpathfindpoint3; int lastpathfindpoint4; - bool onpath; int waypoint; - bool jumppath; XYZ lastseen; float lastseentime; @@ -303,6 +302,7 @@ public: float stunned; float surprised; float runninghowlong; + int occluded; int lastoccluded; int laststanding; int escapednum; @@ -315,21 +315,22 @@ public: int whichskin; bool rabbitkickragdoll; - XYZ averageloc; - XYZ oldaverageloc; - Animation tempanimation; - float occluded; - bool jumpclimb; + Person(); + Person(FILE*, int, unsigned); + + void skeletonLoad(bool clothes = false); + // convenience functions + inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; } + inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; } + inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; } + inline AnimationFrame& currentFrame() { return Animation::animations.at(animCurrent).frames.at(frameCurrent); } + inline AnimationFrame& targetFrame() { return Animation::animations.at(animTarget).frames.at(frameTarget); } - // convenience - Joint& joint(int); - XYZ& jointPos(int); - XYZ& jointVel(int); void CheckKick(); void CatchFire(); @@ -385,13 +386,18 @@ public: int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model); int DrawSkeleton(); void Puff(int whichlabel); - void FootLand(int which, float opacity); + void FootLand(bodypart whichfoot, float opacity); void DoStuff(); void setAnimation(int); void DoAnimations(); void RagDoll(bool checkcollision); + + void takeWeapon (int weaponId); + + bool addClothes(const int& clothesId); + void addClothes(); }; const int maxplayers = 10; -extern Person player[maxplayers]; + #endif