Q2 player model test code... move along
This commit is contained in:
parent
b7a4e271ec
commit
8891e84e18
9 changed files with 222 additions and 10 deletions
|
@ -101,7 +101,17 @@ void player::draw(void)
|
|||
this.p_model_bone = gettagindex(this.p_model, "Bip01 R Hand");
|
||||
}
|
||||
|
||||
#warning "FIXME: Clean this mess up"
|
||||
#ifdef VALVE
|
||||
if (playertype == 0) {
|
||||
Animation_PlayerUpdate();
|
||||
} else {
|
||||
Animation_Q2PlayerUpdate();
|
||||
return;
|
||||
}
|
||||
#else
|
||||
Animation_PlayerUpdate();
|
||||
#endif
|
||||
/*makevectors([0, this.angles[1], 0]);
|
||||
float fDirection = dotproduct(this.velocity, v_forward);
|
||||
|
||||
|
@ -190,8 +200,13 @@ float player::predraw(void)
|
|||
|
||||
if (autocvar_cl_thirdperson == TRUE || this.entnum != player_localentnum) {
|
||||
Voice_Draw3D(this);
|
||||
addentity(this);
|
||||
addentity(this.p_model);
|
||||
|
||||
if (playertype == 0) {
|
||||
addentity(this);
|
||||
addentity(this.p_model);
|
||||
} else {
|
||||
addentity(this);
|
||||
}
|
||||
} else {
|
||||
removeentity(this);
|
||||
removeentity(this.p_model);
|
||||
|
@ -199,3 +214,24 @@ float player::predraw(void)
|
|||
|
||||
return PREDRAW_NEXT;
|
||||
}
|
||||
|
||||
void player::set_model(void)
|
||||
{
|
||||
int i = tokenizebyseparator(getplayerkeyvalue(entnum-1, "model"), "/");
|
||||
string out;
|
||||
|
||||
if (i == 1) {
|
||||
playertype = 0;
|
||||
out = sprintf("models/player/%s/%s.mdl", argv(0), argv(0));
|
||||
print(sprintf("HL Player: %s\n", out));
|
||||
} else {
|
||||
playertype = 1;
|
||||
out = sprintf("players/%s/tris.md2", argv(0));
|
||||
print(sprintf("Q2 Player: %s\n", out));
|
||||
}
|
||||
|
||||
if (whichpack(out))
|
||||
setmodel(this, out);
|
||||
else
|
||||
setmodel(this, "models/player.mdl");
|
||||
}
|
|
@ -28,6 +28,7 @@ sound.c
|
|||
text.c
|
||||
voice.c
|
||||
|
||||
../shared/valve/animations.h
|
||||
../shared/valve/animations.c
|
||||
../shared/valve/player.cpp
|
||||
player.c
|
||||
|
|
|
@ -25,6 +25,7 @@ sound.c
|
|||
text.c
|
||||
voice.c
|
||||
|
||||
../shared/valve/animations.h
|
||||
../shared/valve/animations.c
|
||||
../shared/scihunt/player.cpp
|
||||
player.c
|
||||
|
|
|
@ -25,6 +25,7 @@ sound.c
|
|||
text.c
|
||||
voice.c
|
||||
|
||||
../shared/valve/animations.h
|
||||
../shared/valve/animations.c
|
||||
../shared/valve/player.cpp
|
||||
player.c
|
||||
|
|
|
@ -8,18 +8,18 @@
|
|||
|
||||
void Player_ReadEntity(float flIsNew)
|
||||
{
|
||||
player pl = (player)self;
|
||||
if ( flIsNew == TRUE ) {
|
||||
spawnfunc_player();
|
||||
|
||||
self.classname = "player";
|
||||
self.solid = SOLID_SLIDEBOX;
|
||||
self.drawmask = MASK_ENGINE;
|
||||
self.customphysics = Empty;
|
||||
setsize( self, VEC_HULL_MIN, VEC_HULL_MAX );
|
||||
pl.classname = "player";
|
||||
pl.solid = SOLID_SLIDEBOX;
|
||||
pl.drawmask = MASK_ENGINE;
|
||||
pl.customphysics = Empty;
|
||||
setsize( pl, VEC_HULL_MIN, VEC_HULL_MAX );
|
||||
pl.set_model();
|
||||
}
|
||||
|
||||
player pl = (player)self;
|
||||
pl.modelindex = readshort();
|
||||
readshort();
|
||||
pl.origin[0] = readcoord();
|
||||
pl.origin[1] = readcoord();
|
||||
pl.origin[2] = readcoord();
|
||||
|
|
|
@ -37,6 +37,7 @@ class player
|
|||
#ifdef CSQC
|
||||
/* External model */
|
||||
entity p_model;
|
||||
int playertype;
|
||||
int p_hand_bone;
|
||||
int p_model_bone;
|
||||
float pitch;
|
||||
|
@ -51,6 +52,7 @@ class player
|
|||
float netjumptime;
|
||||
float netteleport_time;
|
||||
|
||||
virtual void() set_model;
|
||||
virtual void() gun_offset;
|
||||
virtual void() draw;
|
||||
virtual float() predraw;
|
||||
|
|
|
@ -26,6 +26,38 @@ void Animation_Print( string sWow ) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void Animation_Q2PlayerUpdate_Run(int id)
|
||||
{
|
||||
if (self.frame_time > time) {
|
||||
return;
|
||||
}
|
||||
if (self.frame >= q2_anims[id].start && self.frame <= q2_anims[id].end) {
|
||||
self.frame += q2_anims[id].start;
|
||||
} else {
|
||||
self.frame = q2_anims[id].start;
|
||||
}
|
||||
self.frame_time = time + 0.1f;
|
||||
}
|
||||
|
||||
void Animation_Q2PlayerUpdate(void)
|
||||
{
|
||||
if ( !( self.flags & FL_ONGROUND ) ) {
|
||||
Animation_Q2PlayerUpdate_Run(Q2ANIM_JUMP);
|
||||
} else if ( vlen( self.velocity ) == 0 ) {
|
||||
if ( self.flags & FL_CROUCHING ) {
|
||||
Animation_Q2PlayerUpdate_Run(Q2ANIM_CR_STAND);
|
||||
} else {
|
||||
Animation_Q2PlayerUpdate_Run(Q2ANIM_STAND);
|
||||
}
|
||||
} else {
|
||||
if ( self.flags & FL_CROUCHING ) {
|
||||
Animation_Q2PlayerUpdate_Run(Q2ANIM_CR_WALK);
|
||||
} else {
|
||||
Animation_Q2PlayerUpdate_Run(Q2ANIM_RUN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Animation_PlayerUpdate
|
||||
|
|
137
Source/shared/valve/animations.h
Normal file
137
Source/shared/valve/animations.h
Normal file
|
@ -0,0 +1,137 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
|
||||
*
|
||||
* See the file LICENSE attached with the sources for usage details.
|
||||
*
|
||||
****/
|
||||
|
||||
enum {
|
||||
ANIM_LOOKIDLE,
|
||||
ANIM_IDLE,
|
||||
ANIM_DEEPIDLE,
|
||||
ANIM_RUN2,
|
||||
ANIM_WALK2HANDED,
|
||||
ANIM_2HANDSHOT,
|
||||
ANIM_CRAWL,
|
||||
ANIM_CROUCHIDLE,
|
||||
ANIM_JUMP,
|
||||
ANIM_LONGJUMP,
|
||||
ANIM_SWIM,
|
||||
ANIM_TREADWATER,
|
||||
ANIM_RUN,
|
||||
ANIM_WALK,
|
||||
ANIM_AIM2,
|
||||
ANIM_SHOOT2,
|
||||
ANIM_AIM1,
|
||||
ANIM_SHOOT1,
|
||||
ANIM_DIESIMPLE,
|
||||
ANIM_DIEBACKWARDS1,
|
||||
ANIM_DIEBACKWARDS2,
|
||||
ANIM_DIEFORWARD,
|
||||
ANIM_DIEHEADSHOT,
|
||||
ANIM_DIESPIN,
|
||||
ANIM_DIEGUTSHOT,
|
||||
ANIM_AIMCROWBAR,
|
||||
ANIM_SHOOTCROWBAR,
|
||||
ANIM_CR_AIMCROWBAR,
|
||||
ANIM_CR_SHOOTCROWBAR,
|
||||
ANIM_AIMTRIPMINE,
|
||||
ANIM_SHOOTTRIPMINE,
|
||||
ANIM_CR_AIMTRIPMINE,
|
||||
ANIM_CR_SHOOTTRIPMINE,
|
||||
ANIM_AIM1HAND,
|
||||
ANIM_SHOOT1HAND,
|
||||
ANIM_CR_AIM1HAND,
|
||||
ANIM_CR_SHOOT1HAND,
|
||||
ANIM_AIMPYTHON,
|
||||
ANIM_SHOOTPYTHON,
|
||||
ANIM_CR_AIMPYTHON,
|
||||
ANIM_CR_SHOOTPYTHON,
|
||||
ANIM_AIMSHOTGUN,
|
||||
ANIM_SHOOTSHOTGUN,
|
||||
ANIM_CR_AIMSHOTGUN,
|
||||
ANIM_CR_SHOOTSHOTGUN,
|
||||
ANIM_AIMGAUSS,
|
||||
ANIM_SHOOTGAUSS,
|
||||
ANIM_CR_AIMGAUSS,
|
||||
ANIM_CR_SHOOTGAUSS,
|
||||
ANIM_AIMMP5,
|
||||
ANIM_SHOOTMP5,
|
||||
ANIM_CR_AIMMP5,
|
||||
ANIM_CR_SHOOTMP5,
|
||||
ANIM_AIMRPG,
|
||||
ANIM_SHOOTRPG,
|
||||
ANIM_CR_AIMRPG,
|
||||
ANIM_CR_SHOOTRPG,
|
||||
ANIM_AIMEGON,
|
||||
ANIM_SHOOTEGON,
|
||||
ANIM_CR_AIMEGON,
|
||||
ANIM_CR_SHOOTEGON,
|
||||
ANIM_AIMSQUEAK,
|
||||
ANIM_SHOOTSQUEAK,
|
||||
ANIM_CR_AIMSQUEAK,
|
||||
ANIM_CR_SHOOTSQUEAK,
|
||||
ANIM_AIMHIVE,
|
||||
ANIM_SHOOTHIVE,
|
||||
ANIM_CR_AIMHIVE,
|
||||
ANIM_CR_SHOOTHIVE,
|
||||
ANIM_AIMBOW,
|
||||
ANIM_SHOOTBOW,
|
||||
ANIM_CR_AIMBOW,
|
||||
ANIM_CR_SHOOTBOW
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
string name;
|
||||
float start;
|
||||
float end;
|
||||
} q2_anim_t;
|
||||
|
||||
q2_anim_t q2_anims[] = {
|
||||
{ "stand", 0, 39 },
|
||||
{ "run", 40, 45 },
|
||||
{ "attack", 46, 53 },
|
||||
{ "pain1", 54, 57 },
|
||||
{ "pain2", 58, 65 },
|
||||
{ "jump", 66, 71 },
|
||||
{ "flip", 72, 83 },
|
||||
{ "salute", 84, 94 },
|
||||
{ "taunt", 95, 111 },
|
||||
{ "wave", 112, 122 },
|
||||
{ "point", 123, 134 },
|
||||
{ "cr_stand", 135, 153 },
|
||||
{ "cr_walk", 154, 159 },
|
||||
{ "cr_attack", 160, 168 },
|
||||
{ "cr_pain", 169, 172 },
|
||||
{ "cr_death", 173, 177 },
|
||||
{ "death1", 178, 183 },
|
||||
{ "death2", 184, 189 },
|
||||
{ "death2", 190, 197 }
|
||||
};
|
||||
|
||||
enum {
|
||||
Q2ANIM_STAND,
|
||||
Q2ANIM_RUN,
|
||||
Q2ANIM_ATTACK,
|
||||
Q2ANIM_PAIN1,
|
||||
Q2ANIM_PAIN2,
|
||||
Q2ANIM_JUMP,
|
||||
Q2ANIM_FLIP,
|
||||
Q2ANIM_SALUTE,
|
||||
Q2ANIM_TAUNT,
|
||||
Q2ANIM_WAVE,
|
||||
Q2ANIM_POINT,
|
||||
Q2ANIM_CR_STAND,
|
||||
Q2ANIM_CR_WALK,
|
||||
Q2ANIM_CR_ATTACK,
|
||||
Q2ANIM_CR_PAIN,
|
||||
Q2ANIM_CR_DEATH,
|
||||
Q2ANIM_DEATH1,
|
||||
Q2ANIM_DEATH2,
|
||||
Q2ANIM_DEATH3,
|
||||
};
|
||||
|
||||
void Animation_PlayerTop(float);
|
||||
|
||||
void Animation_PlayerTopTemp(float, float);
|
|
@ -36,6 +36,7 @@ class player
|
|||
#ifdef CSQC
|
||||
/* External model */
|
||||
entity p_model;
|
||||
int playertype;
|
||||
int p_hand_bone;
|
||||
int p_model_bone;
|
||||
float pitch;
|
||||
|
@ -50,6 +51,7 @@ class player
|
|||
float netjumptime;
|
||||
float netteleport_time;
|
||||
|
||||
virtual void() set_model;
|
||||
virtual void() gun_offset;
|
||||
virtual void() draw;
|
||||
virtual float() predraw;
|
||||
|
|
Loading…
Reference in a new issue