Get rid of the View_EjectShell* functions I added last week and replace it
with the much cooler View_AddEvent() which allows for much more.
This commit is contained in:
parent
9c4487b2e9
commit
b043b57ed5
8 changed files with 111 additions and 82 deletions
|
@ -25,10 +25,8 @@ struct
|
|||
entity m_eMuzzleflash;
|
||||
int m_iVMBones;
|
||||
|
||||
/* viewmodel shell ejection */
|
||||
float m_fEjectModel;
|
||||
vector m_vecEjectPos;
|
||||
vector m_vecEjectVel;
|
||||
void(void) m_pEventCall;
|
||||
float m_flEventTime;
|
||||
|
||||
int m_iLastWeapon;
|
||||
int m_iOldWeapon;
|
||||
|
|
|
@ -91,10 +91,8 @@ void GameMessage_Setup(string, int);
|
|||
void Game_Input(void);
|
||||
void View_SetMuzzleflash(int);
|
||||
|
||||
void View_EjectShellBone(int index, int ofs, vector range);
|
||||
void View_EjectShellAttachment(int index, int ofs, vector range);
|
||||
void View_EjectShellPos(int index, vector pos, vector range);
|
||||
|
||||
void Event_Callback(float mtime, __inout float btime);
|
||||
void View_AddEvent(void(void) pCallback, float flTime);
|
||||
void View_PlayAnimation(int);
|
||||
void View_PlayAnimation(int);
|
||||
void Vox_Play(string);
|
||||
|
|
|
@ -878,6 +878,11 @@ CSQC_Ent_Update(float new)
|
|||
break;
|
||||
case ENT_PLAYER:
|
||||
player pl = (player)self;
|
||||
|
||||
/* splitscreen */
|
||||
int s = (float)getproperty(VF_ACTIVESEAT);
|
||||
pSeat = &g_seats[s];
|
||||
|
||||
if (new || self.classname != "player") {
|
||||
spawnfunc_player();
|
||||
pl.classname = "player";
|
||||
|
@ -885,7 +890,21 @@ CSQC_Ent_Update(float new)
|
|||
pl.drawmask = MASK_ENGINE;
|
||||
pl.customphysics = Empty;
|
||||
setsize(pl, VEC_HULL_MIN, VEC_HULL_MAX);
|
||||
} else {
|
||||
if (pl.entnum == player_localentnum) {
|
||||
for (int i = pl.sequence+1; i <= servercommandframe; i++) {
|
||||
/* ...maybe the input state is too old? */
|
||||
if (!getinputstate(i)) {
|
||||
break;
|
||||
}
|
||||
input_sequence = i;
|
||||
PMove_Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* any differences in things that are read below are now
|
||||
officially from prediction misses. */
|
||||
pl.ReceiveEntity(new);
|
||||
break;
|
||||
case ENT_SPECTATOR:
|
||||
|
|
|
@ -22,42 +22,49 @@ Spawns a shell tempentity. Looking fancy
|
|||
====================
|
||||
*/
|
||||
void
|
||||
Event_EjectShell(void)
|
||||
Event_EjectShell(float mtime, __inout float btime)
|
||||
{
|
||||
static void Event_EjectShell_Death(void) {
|
||||
remove(self);
|
||||
}
|
||||
static void Event_EjectShell_Touch(void) {
|
||||
if (other == world)
|
||||
Sound_Play(self, CHAN_BODY, "modelevent_shell.land");
|
||||
}
|
||||
vector vEndPos;
|
||||
|
||||
if (!pSeat->m_fEjectModel)
|
||||
return;
|
||||
|
||||
|
||||
entity eShell = spawn();
|
||||
eShell.modelindex = pSeat->m_fEjectModel;
|
||||
eShell.solid = SOLID_BBOX;
|
||||
eShell.movetype = MOVETYPE_BOUNCE;
|
||||
eShell.drawmask = MASK_ENGINE;
|
||||
eShell.angles = [pSeat->m_eViewModel.angles[0], pSeat->m_eViewModel.angles[1], 0];
|
||||
eShell.velocity = pSeat->m_vecPredictedVelocity;
|
||||
|
||||
makevectors(pSeat->m_eViewModel.angles);
|
||||
eShell.velocity += (v_forward * pSeat->m_vecEjectVel[0]);
|
||||
eShell.velocity += (v_right * pSeat->m_vecEjectVel[1]);
|
||||
eShell.velocity += (v_up * pSeat->m_vecEjectVel[2]);
|
||||
eShell.touch = Event_EjectShell_Touch;
|
||||
|
||||
eShell.avelocity = [0,45,900];
|
||||
eShell.think = Event_EjectShell_Death;
|
||||
eShell.nextthink = time + 2.5f;
|
||||
pSeat->m_fEjectModel = 0;
|
||||
setsize(eShell, [0,0,0], [0,0,0]);
|
||||
setorigin(eShell, pSeat->m_vecEjectPos);
|
||||
Sound_Play(eShell, CHAN_BODY, "modelevent_shell.eject");
|
||||
// static void Event_EjectShell_Death(void) {
|
||||
// remove(self);
|
||||
// }
|
||||
// static void Event_EjectShell_Touch(void) {
|
||||
// if (other == world)
|
||||
// Sound_Play(self, CHAN_BODY, "modelevent_shell.land");
|
||||
// }
|
||||
// vector vEndPos;
|
||||
//
|
||||
// /* only play once */
|
||||
// if (mtime == btime)
|
||||
// return;
|
||||
//
|
||||
// if (pSeat->m_fEjectModel)
|
||||
// if (btime <= pSeat->m_flEjectTime && (mtime > pSeat->m_flEjectTime)) {
|
||||
// entity eShell = spawn();
|
||||
// eShell.modelindex = pSeat->m_fEjectModel;
|
||||
// eShell.solid = SOLID_BBOX;
|
||||
// eShell.movetype = MOVETYPE_BOUNCE;
|
||||
// eShell.drawmask = MASK_ENGINE;
|
||||
// eShell.angles = [pSeat->m_eViewModel.angles[0], pSeat->m_eViewModel.angles[1], 0];
|
||||
// eShell.velocity = pSeat->m_vecPredictedVelocity;
|
||||
//
|
||||
// makevectors(pSeat->m_eViewModel.angles);
|
||||
// eShell.velocity += (v_forward * pSeat->m_vecEjectVel[0]);
|
||||
// eShell.velocity += (v_right * pSeat->m_vecEjectVel[1]);
|
||||
// eShell.velocity += (v_up * pSeat->m_vecEjectVel[2]);
|
||||
// eShell.touch = Event_EjectShell_Touch;
|
||||
//
|
||||
// eShell.avelocity = [0,45,900];
|
||||
// eShell.think = Event_EjectShell_Death;
|
||||
// eShell.nextthink = time + 2.5f;
|
||||
// pSeat->m_fEjectModel = 0;
|
||||
// pSeat->m_flEjectTime = 0.0f;
|
||||
// setsize(eShell, [0,0,0], [0,0,0]);
|
||||
// setorigin(eShell, pSeat->m_vecEjectPos);
|
||||
// Sound_Play(eShell, CHAN_BODY, "modelevent_shell.eject");
|
||||
// print(sprintf("%f %f\n", mtime, btime));
|
||||
//
|
||||
// }
|
||||
// btime = mtime;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -79,25 +86,50 @@ Event_ProcessModel(float flTimeStamp, int iCode, string strData)
|
|||
pSeat->m_eMuzzleflash.alpha = 1.0f;
|
||||
pSeat->m_eMuzzleflash.scale = 0.25;
|
||||
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones;
|
||||
Event_EjectShell();
|
||||
// Event_EjectShell();
|
||||
break;
|
||||
case 5011: /* muzzle flash on attachment 1 */
|
||||
pSeat->m_eMuzzleflash.alpha = 1.0f;
|
||||
pSeat->m_eMuzzleflash.scale = 0.25;
|
||||
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 1;
|
||||
Event_EjectShell();
|
||||
// Event_EjectShell();
|
||||
break;
|
||||
case 5021: /* muzzle flash on attachment 2 */
|
||||
pSeat->m_eMuzzleflash.alpha = 1.0f;
|
||||
pSeat->m_eMuzzleflash.scale = 0.25;
|
||||
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 2;
|
||||
Event_EjectShell();
|
||||
// Event_EjectShell();
|
||||
break;
|
||||
case 5031: /* muzzle flash on attachment 3 */
|
||||
pSeat->m_eMuzzleflash.alpha = 1.0f;
|
||||
pSeat->m_eMuzzleflash.scale = 0.25;
|
||||
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 3;
|
||||
Event_EjectShell();
|
||||
// Event_EjectShell();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
View_ShellEject
|
||||
|
||||
Spawns a shell tempentity. Looking fancy
|
||||
====================
|
||||
*/
|
||||
void
|
||||
Event_Callback(float mtime, __inout float btime)
|
||||
{
|
||||
if (pSeat->m_pEventCall == __NULL__)
|
||||
return;
|
||||
|
||||
/* only play once */
|
||||
if (mtime == btime)
|
||||
return;
|
||||
|
||||
if (btime <= pSeat->m_flEventTime && (mtime > pSeat->m_flEventTime)) {
|
||||
pSeat->m_pEventCall();
|
||||
pSeat->m_pEventCall = __NULL__;
|
||||
}
|
||||
|
||||
btime = mtime;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ player::draw(void)
|
|||
}
|
||||
|
||||
this.subblendfrac = -fCorrect * 0.05f;
|
||||
this.subblend2frac *= -0.1f;
|
||||
//this.subblend2frac *= -0.1f;
|
||||
this.angles[1] -= fCorrect;
|
||||
#else
|
||||
/* hack, we can't play the animations in reverse the normal way */
|
||||
|
|
|
@ -64,7 +64,7 @@ Predict_PlayerPreFrame(player pl)
|
|||
input_sequence = i;
|
||||
|
||||
/* run our custom physics */
|
||||
PMove_Run();
|
||||
PMove_Run(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,11 +39,6 @@ View_Init(void)
|
|||
MUZZLE_RIFLE = (int)getmodelindex("sprites/muzzleflash1.spr");
|
||||
MUZZLE_SMALL = (int)getmodelindex("sprites/muzzleflash2.spr");
|
||||
MUZZLE_WEIRD = (int)getmodelindex("sprites/muzzleflash3.spr");
|
||||
SHELL_DEFAULT = (int)getmodelindex("models/shell.mdl");
|
||||
SHELL_SHOTGUN = (int)getmodelindex("models/shotgunshell.mdl");
|
||||
|
||||
Sound_Precache("modelevent_shell.eject");
|
||||
Sound_Precache("modelevent_shell.land");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -53,31 +48,10 @@ View_SetMuzzleflash(int index)
|
|||
}
|
||||
|
||||
void
|
||||
View_EjectShellBone(int index, int ofs, vector range)
|
||||
View_AddEvent(void(void) pCallback, float flTime)
|
||||
{
|
||||
pSeat->m_fEjectModel = (float)index;
|
||||
pSeat->m_vecEjectPos = gettaginfo(pSeat->m_eViewModel, ofs);
|
||||
pSeat->m_vecEjectVel = range;
|
||||
}
|
||||
|
||||
void
|
||||
View_EjectShellAttachment(int index, int ofs, vector range)
|
||||
{
|
||||
pSeat->m_fEjectModel = (float)index;
|
||||
pSeat->m_vecEjectPos = gettaginfo(pSeat->m_eViewModel, pSeat->m_iVMBones + 1 + ofs);
|
||||
pSeat->m_vecEjectVel = range;
|
||||
}
|
||||
|
||||
void
|
||||
View_EjectShellPos(int index, vector pos, vector range)
|
||||
{
|
||||
makevectors(view_angles);
|
||||
pSeat->m_fEjectModel = (float)index;
|
||||
pSeat->m_vecEjectPos = gettaginfo(pSeat->m_eViewModel, 0) + pSeat->m_ePlayer.view_ofs;
|
||||
pSeat->m_vecEjectPos += v_forward * pos[0];
|
||||
pSeat->m_vecEjectPos += v_right * pos[1];
|
||||
pSeat->m_vecEjectPos += v_up * pos[2];
|
||||
pSeat->m_vecEjectVel = range;
|
||||
pSeat->m_pEventCall = pCallback;
|
||||
pSeat->m_flEventTime = flTime;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -183,9 +157,12 @@ View_DrawViewModel(void)
|
|||
|
||||
View_CalcBob();
|
||||
View_UpdateWeapon(m_eViewModel, m_eMuzzleflash);
|
||||
|
||||
float fBaseTime2 = m_eViewModel.frame1time;
|
||||
float fBaseTime = m_eViewModel.frame1time;
|
||||
m_eViewModel.frame2time = pl.weapontime;
|
||||
m_eViewModel.frame1time = pl.weapontime;
|
||||
Event_Callback(m_eViewModel.frame1time, fBaseTime2);
|
||||
processmodelevents(m_eViewModel.modelindex, m_eViewModel.frame, fBaseTime,
|
||||
m_eViewModel.frame1time, ClientGame_ModelEvent);
|
||||
|
||||
|
|
|
@ -30,22 +30,28 @@ TraceAttack_FireSingle(vector vecPos, vector vAngle, int iDamage, int iWeapon)
|
|||
return;
|
||||
|
||||
if (trace_ent.takedamage == DAMAGE_YES) {
|
||||
Sound_Play(trace_ent, CHAN_BODY, "damage_bullet.hit");
|
||||
|
||||
#ifdef CSTRIKE
|
||||
player pl = (player)trace_ent;
|
||||
/* modify the damage based on the location */
|
||||
switch (trace_surface_id) {
|
||||
case BODY_HEAD:
|
||||
/* the helmet is one power house */
|
||||
if (trace_ent.items & ITEM_HELMET) {
|
||||
if (pl.g_items & ITEM_HELMET) {
|
||||
iDamage = 0;
|
||||
sound(self, CHAN_ITEM, "weapons/ric_metal-2.wav", 1, ATTN_IDLE);
|
||||
trace_ent.items &= ~ITEM_HELMET;
|
||||
Sound_Play(trace_ent, CHAN_BODY, "player.headshotarmor");
|
||||
pl.g_items &= ~ITEM_HELMET;
|
||||
return;
|
||||
} else {
|
||||
iDamage *= 4;
|
||||
Sound_Play(trace_ent, CHAN_BODY, "player.headshot");
|
||||
}
|
||||
break;
|
||||
case BODY_STOMACH:
|
||||
iDamage *= 0.9;
|
||||
if (pl.armor > 0)
|
||||
Sound_Play(trace_ent, CHAN_BODY, "player.hitarmor");
|
||||
break;
|
||||
case BODY_LEGLEFT:
|
||||
case BODY_LEGRIGHT:
|
||||
|
@ -58,7 +64,6 @@ TraceAttack_FireSingle(vector vecPos, vector vAngle, int iDamage, int iWeapon)
|
|||
iDamage *= 3;
|
||||
#endif
|
||||
Damage_Apply(trace_ent, self, iDamage, iWeapon, DMG_BULLET);
|
||||
Sound_Play(trace_ent, CHAN_BODY, "damage_bullet.hit");
|
||||
}
|
||||
|
||||
if (trace_ent.iBleeds == TRUE) {
|
||||
|
|
Loading…
Reference in a new issue