X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FPerson.h;h=dea9c3ad6202c510cf070127b79a06f0503fe80c;hb=cd043e3f9e26c2b3406b40a354c2840941e9db7f;hp=7f09302c080790a2cc48e61c90536da9ccc1f1bc;hpb=6bd4d8e827e8e47b78db4a1f236cba2eed7032b4;p=lugaru.git diff --git a/Source/Person.h b/Source/Person.h index 7f09302..dea9c3a 100644 --- a/Source/Person.h +++ b/Source/Person.h @@ -3,20 +3,18 @@ Copyright (C) 2003, 2010 - Wolfire Games 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_ @@ -31,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Terrain.h" #include "Sprite.h" #include +#include #include "Weapons.h" #include "Animation.h" @@ -47,387 +46,354 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define rabbittype 0 #define wolftype 1 -struct Person +class Person : public enable_shared_from_this { - int whichpatchx; - int whichpatchz; - - int currentframe; - int targetframe; - int currentanimation; - int targetanimation; - int oldcurrentframe; - int oldtargetframe; - int oldcurrentanimation; - int oldtargetanimation; - - int howactive; - - float parriedrecently; - - bool superruntoggle; - - int lastattack,lastattack2,lastattack3; - - XYZ currentoffset,targetoffset,offset; - float target; - float transspeed; - - XYZ realoldcoords; - XYZ oldcoords; - XYZ coords; - XYZ originalcoords; - XYZ velocity; - - XYZ proportionhead; - XYZ proportionlegs; - XYZ proportionarms; - XYZ proportionbody; - - float heightleft; - float heightright; - - float unconscioustime; - - bool immobile; - - float velspeed; - float targetrotation; - float targetrot; - float rot; - float oldrot; - float lookrotation; - float lookrotation2; - float rotation; - float rotation2; - float lowrotation; - float tilt; - float targettilt; - float tilt2; - float targettilt2; - bool rabbitkickenabled; - - float bloodloss; - float bleeddelay; - float skiddelay; - float skiddingdelay; - float deathbleeding; - float tempdeltav; - - float damagetolerance; - float damage; - float permanentdamage; - float superpermanentdamage; float lastcollide; - int dead; - - float jumppower; - bool onground; - int madskills; - - int wentforweapon; - - bool calcrot; - - bool backwardsanim; - - XYZ facing; - - float bleeding; - float bleedx,bleedy; - int direction; - float texupdatedelay; - - float headrotation,headrotation2; - float targetheadrotation,targetheadrotation2; - - bool onterrain; - bool pause; - - float grabdelay; - - Person *victim; - bool hasvictim; - - float updatedelay; - float normalsupdatedelay; - - bool jumpstart; - - bool forwardkeydown; - bool forwardstogglekeydown; - bool rightkeydown; - bool leftkeydown; - bool backkeydown; - bool jumpkeydown; - bool jumptogglekeydown; - bool crouchkeydown; - bool crouchtogglekeydown; - bool drawkeydown; - bool drawtogglekeydown; - bool throwkeydown; - bool throwtogglekeydown; - bool attackkeydown; - bool feint; - bool lastfeint; - bool headless; - - float crouchkeydowntime; - float jumpkeydowntime; - bool freefall; - - - float turnspeed; - - int aitype; - float aiupdatedelay; - float losupdatedelay; - int ally; - XYZ movetarget; - float collide; - float collided; - float avoidcollided; - bool loaded; - bool whichdirection; - float whichdirectiondelay; - bool avoidsomething; XYZ avoidwhere; - float blooddimamount; - - float staggerdelay; - float blinkdelay; - float twitchdelay; - float twitchdelay2; - float twitchdelay3; - float lefthandmorphness; - float righthandmorphness; - float headmorphness; - float chestmorphness; - float tailmorphness; - float targetlefthandmorphness; - float targetrighthandmorphness; - float targetheadmorphness; - float targetchestmorphness; - float targettailmorphness; - int lefthandmorphstart,lefthandmorphend; - int righthandmorphstart,righthandmorphend; - int headmorphstart,headmorphend; - int chestmorphstart,chestmorphend; - int tailmorphstart,tailmorphend; - - float weaponmissdelay; - float highreversaldelay; - float lowreversaldelay; - float nocollidedelay; - - int creature; - - int id; - - Skeleton skeleton; - - float speed; - float scale; - float power; - float speedmult; - - float protectionhead; - float protectionhigh; - float protectionlow; - float armorhead; - float armorhigh; - float armorlow; - bool metalhead; - bool metalhigh; - bool metallow; - - int numclothes; - char clothes[10][256]; - float clothestintr[10]; - float clothestintg[10]; - float clothestintb[10]; - - bool landhard; - bool bled; - bool spurt; - bool onfire; - float onfiredelay; float burnt; - float fireduration; - - float flamedelay; - float updatestuffdelay; - - int playerdetail; - - int num_weapons; - int weaponids[4]; - int weaponactive; - int weaponstuck; - int weaponstuckwhere; - int weaponwhere; - - int numwaypoints; - XYZ waypoints[90]; - int waypointtype[90]; - float pausetime; - bool hastempwaypoint; - XYZ tempwaypoint; - - XYZ headtarget; - float interestdelay; - - XYZ finalfinaltarget; - XYZ finaltarget; - int finalpathfindpoint; - int targetpathfindpoint; - int lastpathfindpoint; - int lastpathfindpoint2; - int lastpathfindpoint3; - int lastpathfindpoint4; - bool onpath; - - int waypoint; - bool jumppath; - - XYZ lastseen; - float lastseentime; - float lastchecktime; - float stunned; - float surprised; - float runninghowlong; int lastoccluded; - int laststanding; - int escapednum; - - float speechdelay; - float neckspurtdelay; - float neckspurtparticledelay; - float neckspurtamount; - - int whichskin; - bool rabbitkickragdoll; - - XYZ averageloc; - XYZ oldaverageloc; - - Animation tempanimation; - - float occluded; - - void CheckKick(); - void CatchFire(); - void DoBlood(float howmuch, int which); - void DoBloodBig(float howmuch, int which); - bool DoBloodBigWhere(float howmuch, int which, XYZ where); - - bool wasIdle() - { - return animation_bits[currentanimation] & ab_idle; - } - bool isIdle() - { - return animation_bits[targetanimation] & ab_idle; - } - int getIdle(); - - bool isSitting() - { - return animation_bits[targetanimation] & ab_sit; - } - - bool isSleeping() - { - return animation_bits[targetanimation] & ab_sleep; - } - - bool wasCrouch() - { - return animation_bits[currentanimation] & ab_crouch; - } - bool isCrouch() - { - return animation_bits[targetanimation] & ab_crouch; - } - int getCrouch(); - - bool wasStop() - { - return animation_bits[currentanimation] & ab_stop; - } - bool isStop() - { - return animation_bits[targetanimation] & ab_stop; - } - int getStop(); - - bool wasSneak(); - bool isSneak(); - int getSneak(); - - bool wasRun() - { - return animation_bits[currentanimation] & ab_run; - } - bool isRun() - { - return animation_bits[targetanimation] & ab_run; - } - int getRun(); - - bool wasLanding() - { - return animation_bits[currentanimation] & ab_land; - } - bool isLanding() - { - return animation_bits[targetanimation] & ab_land; - } - int getLanding(); - - bool wasLandhard() - { - return animation_bits[currentanimation] & ab_landhard; - } - bool isLandhard() - { - return animation_bits[targetanimation] & ab_landhard; - } - int getLandhard(); - - bool wasFlip() - { - return animation_bits[currentanimation] & ab_flip; - } - bool isFlip() - { - return animation_bits[targetanimation] & ab_flip; - } - - bool jumpclimb; - - bool isWallJump() - { - return animation_bits[targetanimation] & ab_walljump; - } - void Reverse(); - void DoDamage(float howmuch); - void DoHead(); - void DoMipmaps() - { - glBindTexture(GL_TEXTURE_2D, skeleton.drawmodel.textureptr); - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, - skeleton.skinsize, - skeleton.skinsize, - GL_RGB, GL_UNSIGNED_BYTE, - &skeleton.skinText[0]); - } - - 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 DoStuff(); - void DoAnimations(); - void RagDoll(bool checkcollision); +public: + static std::vector> players; + + int whichpatchx; + int whichpatchz; + + // animCurrent and animTarget are used to interpolate between different animations + // (and for a bunch of other things). + // animations interpolate with one another at various speeds. + // animTarget seems to determine the combat state? + int animCurrent; + int animTarget; + + // frameCurrent and frameTarget are used to interpolate between the frames of an animation + // (e.g. the crouched animation has only two frames, lerped back and forth slowly). + // animations advance at various speeds. + int frameCurrent; + int frameTarget; + + int oldanimCurrent; + int oldanimTarget; + int oldframeCurrent; + int oldframeTarget; + + int howactive; + + float parriedrecently; + + bool superruntoggle; + + int lastattack, lastattack2, lastattack3; + + XYZ currentoffset, targetoffset, offset; + float target; + float transspeed; + + XYZ realoldcoords; + XYZ oldcoords; + XYZ coords; + XYZ originalcoords; + XYZ velocity; + + XYZ proportionhead; + XYZ proportionlegs; + XYZ proportionarms; + XYZ proportionbody; + + float unconscioustime; + + bool immobile; + + float velspeed; + float targetyaw; + float targetrot; + float rot; + float oldrot; + float lookyaw; + float lookpitch; + float yaw; + float pitch; + float lowyaw; + float tilt; + float targettilt; + float tilt2; + float targettilt2; + bool rabbitkickenabled; + + float bloodloss; + float bleeddelay; + float skiddelay; + float skiddingdelay; + float deathbleeding; + float tempdeltav; + + float damagetolerance; + float damage; + float permanentdamage; + float superpermanentdamage; + float lastcollide; + int dead; + + float jumppower; + bool onground; + int madskills; + + int wentforweapon; + + bool calcrot; + + bool backwardsanim; + + XYZ facing; + + float bleeding; + float bleedx, bleedy; + int direction; + float texupdatedelay; + + float headyaw, headpitch; + float targetheadyaw, targetheadpitch; + + bool onterrain; + bool pause; + + float grabdelay; + + std::shared_ptr victim; + bool hasvictim; + + float updatedelay; + float normalsupdatedelay; + + bool jumpstart; + + bool forwardkeydown; + bool forwardstogglekeydown; + bool rightkeydown; + bool leftkeydown; + bool backkeydown; + bool jumpkeydown; + bool jumptogglekeydown; + bool crouchkeydown; + bool crouchtogglekeydown; + bool drawkeydown; + bool drawtogglekeydown; + bool throwkeydown; + bool throwtogglekeydown; + bool attackkeydown; + bool feint; + bool lastfeint; + bool headless; + + float crouchkeydowntime; + float jumpkeydowntime; + bool freefall; + + + float turnspeed; + + int aitype; + float aiupdatedelay; + float losupdatedelay; + int ally; + XYZ movetarget; + float collide; + float collided; + float avoidcollided; + bool loaded; + bool whichdirection; + float whichdirectiondelay; + bool avoidsomething; + XYZ avoidwhere; + float blooddimamount; + + float staggerdelay; + float blinkdelay; + float twitchdelay; + float twitchdelay2; + float twitchdelay3; + float lefthandmorphness; + float righthandmorphness; + float headmorphness; + float chestmorphness; + float tailmorphness; + float targetlefthandmorphness; + float targetrighthandmorphness; + float targetheadmorphness; + float targetchestmorphness; + float targettailmorphness; + int lefthandmorphstart, lefthandmorphend; + int righthandmorphstart, righthandmorphend; + int headmorphstart, headmorphend; + int chestmorphstart, chestmorphend; + int tailmorphstart, tailmorphend; + + float weaponmissdelay; + float highreversaldelay; + float lowreversaldelay; + float nocollidedelay; + + int creature; + + unsigned id; + + Skeleton skeleton; + + float speed; + float scale; + float power; + float speedmult; + + float protectionhead; + float protectionhigh; + float protectionlow; + float armorhead; + float armorhigh; + float armorlow; + bool metalhead; + bool metalhigh; + bool metallow; + + int numclothes; + char clothes[10][256]; + float clothestintr[10]; + float clothestintg[10]; + float clothestintb[10]; + + bool landhard; + bool bled; + bool spurt; + bool onfire; + float onfiredelay; + float burnt; + float fireduration; + + float flamedelay; + float updatestuffdelay; + + int playerdetail; + + int num_weapons; + int weaponids[4]; + int weaponactive; + int weaponstuck; + int weaponstuckwhere; + int weaponwhere; + + int numwaypoints; + XYZ waypoints[90]; + int waypointtype[90]; + float pausetime; + bool hastempwaypoint; + XYZ tempwaypoint; + + XYZ headtarget; + float interestdelay; + + XYZ finalfinaltarget; + XYZ finaltarget; + int finalpathfindpoint; + int targetpathfindpoint; + int lastpathfindpoint; + int lastpathfindpoint2; + int lastpathfindpoint3; + int lastpathfindpoint4; + bool onpath; + + int waypoint; + bool jumppath; + + XYZ lastseen; + float lastseentime; + float lastchecktime; + float stunned; + float surprised; + float runninghowlong; + int lastoccluded; + int laststanding; + int escapednum; + + float speechdelay; + float neckspurtdelay; + float neckspurtparticledelay; + float neckspurtamount; + + int whichskin; + bool rabbitkickragdoll; + + XYZ averageloc; + XYZ oldaverageloc; + + Animation tempanimation; + + float occluded; + + bool jumpclimb; + + + + // 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; } + + + void CheckKick(); + void CatchFire(); + void DoBlood(float howmuch, int which); + void DoBloodBig(float howmuch, int which); + bool DoBloodBigWhere(float howmuch, int which, XYZ where); + + bool wasIdle() { return animation_bits[animCurrent] & ab_idle; } + bool isIdle() { return animation_bits[animTarget] & ab_idle; } + int getIdle(); + + bool isSitting() { return animation_bits[animTarget] & ab_sit; } + + bool isSleeping() { return animation_bits[animTarget] & ab_sleep; } + + bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; } + bool isCrouch() { return animation_bits[animTarget] & ab_crouch; } + int getCrouch(); + + bool wasStop() { return animation_bits[animCurrent] & ab_stop; } + bool isStop() { return animation_bits[animTarget] & ab_stop; } + int getStop(); + + bool wasSneak(); + bool isSneak(); + int getSneak(); + + bool wasRun() { return animation_bits[animCurrent] & ab_run; } + bool isRun() { return animation_bits[animTarget] & ab_run; } + int getRun(); + + bool wasLanding() { return animation_bits[animCurrent] & ab_land; } + bool isLanding() { return animation_bits[animTarget] & ab_land; } + int getLanding(); + + bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; } + bool isLandhard() { return animation_bits[animTarget] & ab_landhard; } + int getLandhard(); + + bool wasFlip() { return animation_bits[animCurrent] & ab_flip; } + bool isFlip() { return animation_bits[animTarget] & ab_flip; } + + bool isWallJump() { return animation_bits[animTarget] & ab_walljump; } + void Reverse(); + void DoDamage(float howmuch); + void DoHead(); + 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 DrawSkeleton(); + void Puff(int whichlabel); + void FootLand(int which, float opacity); + void DoStuff(); + void setAnimation(int); + void DoAnimations(); + void RagDoll(bool checkcollision); }; const int maxplayers = 10; -extern Person player[maxplayers]; + #endif