Simplify prediction code with the help from upstream SDK changes.

This commit is contained in:
Marco Cawthorne 2021-05-08 17:47:02 +02:00
parent 0bb992d592
commit 73b91819ce
15 changed files with 354 additions and 574 deletions

View File

@ -29,13 +29,15 @@ class ammo_egonclip:item_ammo
virtual void(void) touch; virtual void(void) touch;
}; };
void ammo_egonclip::ammo_egonclip(void) void
ammo_egonclip::ammo_egonclip(void)
{ {
model = "models/w_gas.mdl"; model = "models/w_gas.mdl";
Sound_Precache("ammo_gas.pickup"); Sound_Precache("ammo_gas.pickup");
item_ammo::item_ammo(); item_ammo::item_ammo();
} }
void ammo_egonclip::touch(void) void
ammo_egonclip::touch(void)
{ {
if not (other.flags & FL_CLIENT) { if not (other.flags & FL_CLIENT) {
return; return;
@ -64,12 +66,14 @@ class ammo_th_ap9:item_ammo
virtual void(void) touch; virtual void(void) touch;
}; };
void ammo_th_ap9::ammo_th_ap9(void) void
ammo_th_ap9::ammo_th_ap9(void)
{ {
model = "models/w_ap9clip.mdl"; model = "models/w_ap9clip.mdl";
item_ammo::item_ammo(); item_ammo::item_ammo();
} }
void ammo_th_ap9::touch(void) void
ammo_th_ap9::touch(void)
{ {
if not (other.flags & FL_CLIENT) { if not (other.flags & FL_CLIENT) {
return; return;
@ -97,12 +101,14 @@ class ammo_th_taurus:item_ammo
virtual void(void) touch; virtual void(void) touch;
}; };
void ammo_th_taurus::ammo_th_taurus(void) void
ammo_th_taurus::ammo_th_taurus(void)
{ {
model = "models/w_taurusclip.mdl"; model = "models/w_taurusclip.mdl";
item_ammo::item_ammo(); item_ammo::item_ammo();
} }
void ammo_th_taurus::touch(void) void
ammo_th_taurus::touch(void)
{ {
if not (other.flags & FL_CLIENT) { if not (other.flags & FL_CLIENT) {
return; return;
@ -143,12 +149,14 @@ class ammo_th_sniper:item_ammo
virtual void(void) touch; virtual void(void) touch;
}; };
void ammo_th_sniper::ammo_th_sniper(void) void
ammo_th_sniper::ammo_th_sniper(void)
{ {
model = "models/w_antidote.mdl"; model = "models/w_antidote.mdl";
item_ammo::item_ammo(); item_ammo::item_ammo();
} }
void ammo_th_sniper::touch(void) void
ammo_th_sniper::touch(void)
{ {
if not (other.flags & FL_CLIENT) { if not (other.flags & FL_CLIENT) {
return; return;

View File

@ -32,7 +32,8 @@ class item_healthkit:CBaseEntity
virtual void(void) touch; virtual void(void) touch;
}; };
void item_healthkit::touch(void) void
item_healthkit::touch(void)
{ {
if (other.classname != "player") { if (other.classname != "player") {
return; return;
@ -75,7 +76,8 @@ void item_healthkit::touch(void)
} }
} }
void item_healthkit::Respawn(void) void
item_healthkit::Respawn(void)
{ {
SetSolid(SOLID_TRIGGER); SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_TOSS); SetMovetype(MOVETYPE_TOSS);
@ -93,7 +95,8 @@ void item_healthkit::Respawn(void)
droptofloor(); droptofloor();
} }
void item_healthkit::item_healthkit(void) void
item_healthkit::item_healthkit(void)
{ {
Sound_Precache("ammo.pickup"); Sound_Precache("ammo.pickup");
Sound_Precache("item.healthkit"); Sound_Precache("item.healthkit");

View File

@ -21,7 +21,8 @@ Input_Handle
Handles impulse and whatnot Handles impulse and whatnot
================= =================
*/ */
void Game_Input(void) void
Game_Input(void)
{ {
#ifdef SERVER #ifdef SERVER
if (input_buttons & INPUT_BUTTON5) { if (input_buttons & INPUT_BUTTON5) {

View File

@ -45,79 +45,53 @@ enumflags
noref int input_sequence; noref int input_sequence;
class player:base_player class player:base_player
{ {
/* Weapon specific */ /* animation */
int glock_mag; PREDICTED_INT(anim_top);
int glock_mag_net; PREDICTED_FLOAT(anim_top_time);
int mp5_mag; PREDICTED_FLOAT(anim_top_delay);
int mp5_mag_net; PREDICTED_INT(anim_bottom);
int python_mag; PREDICTED_FLOAT(anim_bottom_time);
int python_mag_net;
int shotgun_mag;
int shotgun_mag_net;
int crossbow_mag;
int crossbow_mag_net;
int rpg_mag;
int rpg_mag_net;
int satchel_chg;
int satchel_chg_net;
int ammo_9mm; /* ammo 1 */
int ammo_9mm_net; PREDICTED_INT(glock_mag);
int ammo_357; PREDICTED_INT(mp5_mag);
int ammo_357_net; PREDICTED_INT(python_mag);
int ammo_buckshot; PREDICTED_INT(shotgun_mag);
int ammo_buckshot_net; PREDICTED_INT(crossbow_mag);
int ammo_bolt; PREDICTED_INT(rpg_mag);
int ammo_bolt_net; PREDICTED_INT(satchel_chg);
int ammo_rocket;
int ammo_rocket_net;
int ammo_uranium;
int ammo_uranium_net;
int ammo_handgrenade;
int ammo_handgrenade_net;
int ammo_satchel;
int ammo_satchel_net;
int ammo_tripmine;
int ammo_tripmine_net;
int ammo_snark;
int ammo_snark_net;
int ammo_hornet;
int ammo_hornet_net;
int ammo_m203_grenade; /* ammo 2 */
int ammo_m203_grenade_net; PREDICTED_INT(ammo_9mm);
int ammo_shotgun_state; PREDICTED_INT(ammo_357);
int ammo_shotgun_state_net; PREDICTED_INT(ammo_buckshot);
int ammo_gauss_state; PREDICTED_INT(ammo_bolt);
int ammo_gauss_state_net; PREDICTED_INT(ammo_rocket);
int ammo_gauss_volume; PREDICTED_INT(ammo_uranium);
int ammo_gauss_volume_net; PREDICTED_INT(ammo_handgrenade);
int ammo_egon_state; PREDICTED_INT(ammo_satchel);
int ammo_egon_state_net; PREDICTED_INT(ammo_tripmine);
int ammo_rpg_state; PREDICTED_INT(ammo_snark);
int ammo_rpg_state_net; PREDICTED_INT(ammo_hornet);
int mode_tempstate;
int mode_tempstate_net; /* ammo 3 */
PREDICTED_INT(ammo_m203_grenade);
PREDICTED_INT(ammo_gauss_volume);
PREDICTED_INT(ammo_rpg_state);
PREDICTED_INT(mode_tempstate);
/* hunger */ /* hunger */
int sniper_mag; int sniper_mag_net; PREDICTED_INT(sniper_mag);
int chaingun_mag; int chaingun_mag_net; PREDICTED_INT(chaingun_mag);
int ap9_mag; int ap9_mag_net; PREDICTED_INT(ap9_mag);
int taurus_mag; int taurus_mag_net; PREDICTED_INT(taurus_mag);
int ammo_ap9; int ammo_ap9_net; PREDICTED_INT(ammo_ap9);
int ammo_taurus; int ammo_taurus_net; PREDICTED_INT(ammo_taurus);
int ammo_bolt; int ammo_bolt_net; PREDICTED_INT(ammo_sniper);
int ammo_sniper; int ammo_sniper_net; PREDICTED_INT(ammo_medkit);
int ammo_medkit; int ammo_medkit_net; PREDICTED_INT(ammo_gas);
int ammo_gas; int ammo_gas_net; PREDICTED_INT(mode_silencer);
int mode_silencer; int mode_silencer_net;
float anim_top; float anim_top_net;
float anim_top_time; float anim_top_time_net;
float anim_top_delay; float anim_top_delay_net;
float anim_bottom; float anim_bottom_net;
float anim_bottom_time; float anim_bottom_time_net;
#ifdef CLIENT #ifdef CLIENT
/* External model */ /* External model */
@ -129,7 +103,7 @@ class player:base_player
virtual void(void) draw; virtual void(void) draw;
virtual float() predraw; virtual float() predraw;
virtual void(void) postdraw; virtual void(void) postdraw;
virtual void(float) ReceiveEntity; virtual void(float,float) ReceiveEntity;
virtual void(void) PredictPreFrame; virtual void(void) PredictPreFrame;
virtual void(void) PredictPostFrame; virtual void(void) PredictPostFrame;
#else #else
@ -146,61 +120,9 @@ player::ReceiveEntity
================= =================
*/ */
void void
player::ReceiveEntity(float new) player::ReceiveEntity(float new, float fl)
{ {
float fl; base_player::ReceiveEntity(new, fl);
/* seed for our prediction table */
sequence = servercommandframe;
fl = readfloat();
/* HACK: we need to make this more reliable */
if (fl == UPDATE_ALL) {
/* we respawned */
gravity = __NULL__;
}
if (fl & PLAYER_MODELINDEX)
modelindex = readshort();
if (fl & PLAYER_ORIGIN) {
origin[0] = readcoord();
origin[1] = readcoord();
}
if (fl & PLAYER_ORIGIN_Z)
origin[2] = readcoord();
if (fl & PLAYER_ANGLES_X)
pitch = readfloat();
if (fl & PLAYER_ANGLES_Y)
angles[1] = readfloat();
if (fl & PLAYER_ANGLES_Z)
angles[2] = readfloat();
if (fl & PLAYER_VELOCITY) {
velocity[0] = readcoord();
velocity[1] = readcoord();
}
if (fl & PLAYER_VELOCITY_Z)
velocity[2] = readcoord();
if (fl & PLAYER_FLAGS) {
flags = readfloat();
gflags = readfloat();
}
if (fl & PLAYER_WEAPON)
activeweapon = readbyte();
if (fl & PLAYER_ITEMS)
g_items = (__variant)readfloat();
if (fl & PLAYER_HEALTH)
health = readbyte();
if (fl & PLAYER_ARMOR)
armor = readbyte();
if (fl & PLAYER_MOVETYPE)
movetype = readbyte();
if (fl & PLAYER_VIEWOFS)
view_ofs[2] = readfloat();
/* animation */ /* animation */
if (fl & PLAYER_TOPFRAME) { if (fl & PLAYER_TOPFRAME) {
@ -245,7 +167,6 @@ player::ReceiveEntity(float new)
/* hunger */ /* hunger */
ammo_ap9 = readbyte(); ammo_ap9 = readbyte();
ammo_taurus = readbyte(); ammo_taurus = readbyte();
ammo_bolt = readbyte();
ammo_sniper = readbyte(); ammo_sniper = readbyte();
ammo_medkit = readbyte(); ammo_medkit = readbyte();
ammo_gas = readbyte(); ammo_gas = readbyte();
@ -253,10 +174,7 @@ player::ReceiveEntity(float new)
if (fl & PLAYER_AMMO3) { if (fl & PLAYER_AMMO3) {
ammo_m203_grenade = readbyte(); ammo_m203_grenade = readbyte();
ammo_shotgun_state = readbyte();
ammo_gauss_state = readbyte();
ammo_gauss_volume = readbyte(); ammo_gauss_volume = readbyte();
ammo_egon_state = readbyte();
ammo_rpg_state = readbyte(); ammo_rpg_state = readbyte();
mode_tempstate = readbyte(); mode_tempstate = readbyte();
mode_silencer = readbyte(); mode_silencer = readbyte();
@ -279,53 +197,51 @@ so we can roll them back later.
void void
player::PredictPreFrame(void) player::PredictPreFrame(void)
{ {
glock_mag_net = glock_mag; base_player::PredictPreFrame();
mp5_mag_net = mp5_mag;
python_mag_net = python_mag;
shotgun_mag_net = shotgun_mag;
crossbow_mag_net = crossbow_mag;
rpg_mag_net = rpg_mag;
satchel_chg_net = satchel_chg;
ammo_9mm_net = ammo_9mm;
ammo_357_net = ammo_357;
ammo_buckshot_net = ammo_buckshot;
ammo_bolt_net = ammo_bolt;
ammo_rocket_net = ammo_rocket;
ammo_uranium_net = ammo_uranium;
ammo_handgrenade_net = ammo_handgrenade;
ammo_satchel_net = ammo_satchel;
ammo_tripmine_net = ammo_tripmine;
ammo_snark_net = ammo_snark;
ammo_hornet_net = ammo_hornet;
ammo_m203_grenade_net = ammo_m203_grenade; SAVE_STATE(anim_top);
ammo_shotgun_state_net = ammo_shotgun_state; SAVE_STATE(anim_top_delay);
ammo_gauss_state_net = ammo_gauss_state; SAVE_STATE(anim_top_time);
ammo_gauss_volume_net = ammo_gauss_volume; SAVE_STATE(anim_bottom);
ammo_egon_state_net = ammo_egon_state; SAVE_STATE(anim_bottom_time);
ammo_rpg_state_net = ammo_rpg_state;
mode_tempstate_net = mode_tempstate;
/* gearbox */ SAVE_STATE(glock_mag);
sniper_mag_net = sniper_mag; SAVE_STATE(mp5_mag);
chaingun_mag_net = chaingun_mag; SAVE_STATE(python_mag);
ap9_mag_net = ap9_mag; SAVE_STATE(shotgun_mag);
taurus_mag_net = taurus_mag; SAVE_STATE(crossbow_mag);
SAVE_STATE(rpg_mag);
SAVE_STATE(satchel_chg);
ammo_ap9_net = ammo_ap9; SAVE_STATE(ammo_9mm);
ammo_taurus_net = ammo_taurus; SAVE_STATE(ammo_357);
ammo_bolt_net = ammo_bolt; SAVE_STATE(ammo_buckshot);
ammo_sniper_net = ammo_sniper; SAVE_STATE(ammo_bolt);
ammo_medkit_net = ammo_medkit; SAVE_STATE(ammo_rocket);
ammo_gas_net = ammo_gas; SAVE_STATE(ammo_uranium);
SAVE_STATE(ammo_handgrenade);
SAVE_STATE(ammo_satchel);
SAVE_STATE(ammo_tripmine);
SAVE_STATE(ammo_snark);
SAVE_STATE(ammo_hornet);
mode_silencer_net = mode_silencer; SAVE_STATE(ammo_m203_grenade);
SAVE_STATE(ammo_gauss_volume);
SAVE_STATE(ammo_rpg_state);
SAVE_STATE(mode_tempstate);
anim_top_net = anim_top; /* hunger */
anim_top_delay_net = anim_top_delay; SAVE_STATE(sniper_mag);
anim_top_time_net = anim_top_time; SAVE_STATE(chaingun_mag);
anim_bottom_net = anim_bottom; SAVE_STATE(ap9_mag);
anim_bottom_time_net = anim_bottom_time; SAVE_STATE(taurus_mag);
SAVE_STATE(ammo_ap9);
SAVE_STATE(ammo_taurus);
SAVE_STATE(ammo_sniper);
SAVE_STATE(ammo_medkit);
SAVE_STATE(ammo_gas);
SAVE_STATE(mode_silencer);
} }
/* /*
@ -338,291 +254,178 @@ Where we roll back our values to the ones last sent/verified by the server.
void void
player::PredictPostFrame(void) player::PredictPostFrame(void)
{ {
glock_mag = glock_mag_net; base_player::PredictPostFrame();
mp5_mag = mp5_mag_net;
python_mag = python_mag_net;
shotgun_mag = shotgun_mag_net;
crossbow_mag = crossbow_mag_net;
rpg_mag = rpg_mag_net;
satchel_chg = satchel_chg_net;
ammo_9mm = ammo_9mm_net;
ammo_357 = ammo_357_net;
ammo_buckshot = ammo_buckshot_net;
ammo_m203_grenade = ammo_m203_grenade_net;
ammo_bolt = ammo_bolt_net;
ammo_rocket = ammo_rocket_net;
ammo_uranium = ammo_uranium_net;
ammo_handgrenade = ammo_handgrenade_net;
ammo_satchel = ammo_satchel_net;
ammo_tripmine = ammo_tripmine_net;
ammo_snark = ammo_snark_net;
ammo_hornet = ammo_hornet_net;
ammo_m203_grenade = ammo_m203_grenade_net; ROLL_BACK(anim_top);
ammo_shotgun_state = ammo_shotgun_state_net; ROLL_BACK(anim_top_delay);
ammo_gauss_state = ammo_gauss_state_net; ROLL_BACK(anim_top_time);
ammo_gauss_volume = ammo_gauss_volume_net; ROLL_BACK(anim_bottom);
ammo_egon_state = ammo_egon_state_net; ROLL_BACK(anim_bottom_time);
ammo_rpg_state = ammo_rpg_state_net;
mode_tempstate = mode_tempstate_net; ROLL_BACK(glock_mag);
ROLL_BACK(mp5_mag);
ROLL_BACK(python_mag);
ROLL_BACK(shotgun_mag);
ROLL_BACK(crossbow_mag);
ROLL_BACK(rpg_mag);
ROLL_BACK(satchel_chg);
ROLL_BACK(ammo_9mm);
ROLL_BACK(ammo_357);
ROLL_BACK(ammo_buckshot);
ROLL_BACK(ammo_m203_grenade);
ROLL_BACK(ammo_bolt);
ROLL_BACK(ammo_rocket);
ROLL_BACK(ammo_uranium);
ROLL_BACK(ammo_handgrenade);
ROLL_BACK(ammo_satchel);
ROLL_BACK(ammo_tripmine);
ROLL_BACK(ammo_snark);
ROLL_BACK(ammo_hornet);
ROLL_BACK(ammo_m203_grenade);
ROLL_BACK(ammo_gauss_volume);
ROLL_BACK(ammo_rpg_state);
ROLL_BACK(mode_tempstate);
/* hunger */ /* hunger */
sniper_mag = sniper_mag_net; ROLL_BACK(sniper_mag);
chaingun_mag = chaingun_mag_net; ROLL_BACK(chaingun_mag);
ap9_mag = ap9_mag_net; ROLL_BACK(ap9_mag);
taurus_mag = taurus_mag_net; ROLL_BACK(taurus_mag);
ammo_ap9 = ammo_ap9_net; ROLL_BACK(ammo_ap9);
ammo_taurus = ammo_taurus_net; ROLL_BACK(ammo_taurus);
ammo_bolt = ammo_bolt_net; ROLL_BACK(ammo_sniper);
ammo_sniper = ammo_sniper_net; ROLL_BACK(ammo_medkit);
ammo_medkit = ammo_medkit_net; ROLL_BACK(ammo_gas);
ammo_gas = ammo_gas_net; ROLL_BACK(mode_silencer);
mode_silencer = mode_silencer_net;
anim_top = anim_top_net;
anim_top_delay = anim_top_delay_net;
anim_top_time = anim_top_time_net;
anim_bottom = anim_bottom_net;
anim_bottom_time = anim_bottom_time_net;
} }
#else #else
void void
player::EvaluateEntity(void) player::EvaluateEntity(void)
{ {
SendFlags |= PLAYER_KEEPALIVE; base_player::EvaluateEntity();
if (old_modelindex != modelindex)
SendFlags |= PLAYER_MODELINDEX;
if (old_origin[0] != origin[0])
SendFlags |= PLAYER_ORIGIN;
if (old_origin[1] != origin[1])
SendFlags |= PLAYER_ORIGIN;
if (old_origin[2] != origin[2])
SendFlags |= PLAYER_ORIGIN_Z;
if (old_angles[0] != v_angle[0])
SendFlags |= PLAYER_ANGLES_X;
if (old_angles[1] != angles[1])
SendFlags |= PLAYER_ANGLES_Y;
if (old_angles[2] != angles[2])
SendFlags |= PLAYER_ANGLES_Z;
if (old_velocity[0] != velocity[0])
SendFlags |= PLAYER_VELOCITY;
if (old_velocity[1] != velocity[1])
SendFlags |= PLAYER_VELOCITY;
if (old_velocity[2] != velocity[2])
SendFlags |= PLAYER_VELOCITY_Z;
if (old_flags != flags)
SendFlags |= PLAYER_FLAGS;
if (old_gflags != gflags)
SendFlags |= PLAYER_FLAGS;
if (old_activeweapon != activeweapon)
SendFlags |= PLAYER_WEAPON;
if (old_items != g_items)
SendFlags |= PLAYER_ITEMS;
if (old_health != health)
SendFlags |= PLAYER_HEALTH;
if (old_armor != armor)
SendFlags |= PLAYER_ARMOR;
if (old_movetype != movetype)
SendFlags |= PLAYER_MOVETYPE;
if (old_viewofs != view_ofs[2])
SendFlags |= PLAYER_VIEWOFS;
/* animation */ /* animation */
if (anim_bottom_net != anim_bottom || anim_bottom_time != anim_bottom_time_net) if (ATTR_CHANGED(anim_bottom) || ATTR_CHANGED(anim_bottom_time))
SendFlags |= PLAYER_BOTTOMFRAME; SendFlags |= PLAYER_BOTTOMFRAME;
if (anim_top_net != anim_top || anim_top_time != anim_top_time_net || anim_top_delay != anim_top_delay_net) if (ATTR_CHANGED(anim_top) || ATTR_CHANGED(anim_top_time) || ATTR_CHANGED(anim_top_delay))
SendFlags |= PLAYER_TOPFRAME; SendFlags |= PLAYER_TOPFRAME;
/* ammo 1 type updates */ /* ammo 1 type updates */
if (glock_mag != glock_mag_net) { if (ATTR_CHANGED(glock_mag))
SendFlags |= PLAYER_AMMO1; SendFlags |= PLAYER_AMMO1;
} else if (ATTR_CHANGED(mp5_mag))
if (mp5_mag != mp5_mag_net) {
SendFlags |= PLAYER_AMMO1; SendFlags |= PLAYER_AMMO1;
} else if (ATTR_CHANGED(python_mag))
if (python_mag != python_mag_net) {
SendFlags |= PLAYER_AMMO1; SendFlags |= PLAYER_AMMO1;
} else if (ATTR_CHANGED(shotgun_mag))
if (shotgun_mag != shotgun_mag_net) {
SendFlags |= PLAYER_AMMO1; SendFlags |= PLAYER_AMMO1;
} else if (ATTR_CHANGED(crossbow_mag))
if (crossbow_mag != crossbow_mag_net) {
SendFlags |= PLAYER_AMMO1; SendFlags |= PLAYER_AMMO1;
} else if (ATTR_CHANGED(rpg_mag))
if (rpg_mag != rpg_mag_net) {
SendFlags |= PLAYER_AMMO1; SendFlags |= PLAYER_AMMO1;
} else if (ATTR_CHANGED(satchel_chg))
if (satchel_chg != satchel_chg_net) { SendFlags |= PLAYER_AMMO1;
else if (ATTR_CHANGED(sniper_mag))
SendFlags |= PLAYER_AMMO1;
else if (ATTR_CHANGED(chaingun_mag))
SendFlags |= PLAYER_AMMO1;
else if (ATTR_CHANGED(ap9_mag))
SendFlags |= PLAYER_AMMO1;
else if (ATTR_CHANGED(taurus_mag))
SendFlags |= PLAYER_AMMO1; SendFlags |= PLAYER_AMMO1;
}
/* ammo 2 type updates */ /* ammo 2 type updates */
if (ammo_9mm != ammo_9mm_net) { if (ATTR_CHANGED(ammo_9mm))
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_357))
if (ammo_357 != ammo_357_net) {
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_buckshot))
if (ammo_buckshot != ammo_buckshot_net) {
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_bolt))
if (ammo_bolt != ammo_bolt_net) {
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_rocket))
if (ammo_rocket != ammo_rocket_net) {
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_uranium))
if (ammo_uranium != ammo_uranium_net) {
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_handgrenade))
if (ammo_handgrenade != ammo_handgrenade_net) {
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_satchel))
if (ammo_satchel != ammo_satchel_net) {
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_tripmine))
if (ammo_tripmine != ammo_tripmine_net) {
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_snark))
if (ammo_snark != ammo_snark_net) {
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
} else if (ATTR_CHANGED(ammo_hornet))
if (ammo_hornet != ammo_hornet_net) { SendFlags |= PLAYER_AMMO2;
else if (ATTR_CHANGED(ammo_ap9))
SendFlags |= PLAYER_AMMO2;
else if (ATTR_CHANGED(ammo_taurus))
SendFlags |= PLAYER_AMMO2;
else if (ATTR_CHANGED(ammo_sniper))
SendFlags |= PLAYER_AMMO2;
else if (ATTR_CHANGED(ammo_medkit))
SendFlags |= PLAYER_AMMO2;
else if (ATTR_CHANGED(ammo_gas))
SendFlags |= PLAYER_AMMO2; SendFlags |= PLAYER_AMMO2;
}
if (ammo_m203_grenade != ammo_m203_grenade_net) { if (ATTR_CHANGED(ammo_m203_grenade))
SendFlags |= PLAYER_AMMO3; SendFlags |= PLAYER_AMMO3;
} else if (ATTR_CHANGED(ammo_gauss_volume))
if (ammo_shotgun_state != ammo_shotgun_state_net) {
SendFlags |= PLAYER_AMMO3; SendFlags |= PLAYER_AMMO3;
} else if (ATTR_CHANGED(ammo_rpg_state))
if (ammo_gauss_state != ammo_gauss_state_net) {
SendFlags |= PLAYER_AMMO3; SendFlags |= PLAYER_AMMO3;
} else if (ATTR_CHANGED(mode_tempstate))
if (ammo_gauss_volume != ammo_gauss_volume_net) {
SendFlags |= PLAYER_AMMO3; SendFlags |= PLAYER_AMMO3;
} else if (ATTR_CHANGED(mode_silencer)) /* hunger */
if (ammo_egon_state != ammo_egon_state_net) {
SendFlags |= PLAYER_AMMO3; SendFlags |= PLAYER_AMMO3;
}
if (ammo_rpg_state != ammo_rpg_state_net) {
SendFlags |= PLAYER_AMMO3;
}
if (mode_tempstate != mode_tempstate_net) {
SendFlags |= PLAYER_AMMO3;
}
old_modelindex = modelindex; SAVE_STATE(anim_top);
old_origin = origin; SAVE_STATE(anim_top_delay);
old_angles = angles; SAVE_STATE(anim_top_time);
old_angles[0] = v_angle[0]; SAVE_STATE(anim_bottom);
old_velocity = velocity; SAVE_STATE(anim_bottom_time);
old_flags = flags;
old_gflags = gflags;
old_activeweapon = activeweapon;
old_items = g_items;
old_health = health;
old_armor = armor;
old_movetype = movetype;
old_viewofs = view_ofs[2];
old_baseframe = baseframe;
old_frame = frame;
glock_mag_net = glock_mag; SAVE_STATE(glock_mag);
mp5_mag_net = mp5_mag; SAVE_STATE(mp5_mag);
python_mag_net = python_mag; SAVE_STATE(python_mag);
shotgun_mag_net = shotgun_mag; SAVE_STATE(shotgun_mag);
crossbow_mag_net = crossbow_mag; SAVE_STATE(crossbow_mag);
rpg_mag_net = rpg_mag; SAVE_STATE(rpg_mag);
satchel_chg_net = satchel_chg; SAVE_STATE(satchel_chg);
ammo_9mm_net = ammo_9mm; SAVE_STATE(ammo_9mm);
ammo_357_net = ammo_357; SAVE_STATE(ammo_357);
ammo_buckshot_net = ammo_buckshot; SAVE_STATE(ammo_buckshot);
ammo_m203_grenade_net = ammo_m203_grenade; SAVE_STATE(ammo_bolt);
ammo_bolt_net = ammo_bolt; SAVE_STATE(ammo_rocket);
ammo_rocket_net = ammo_rocket; SAVE_STATE(ammo_uranium);
ammo_uranium_net = ammo_uranium; SAVE_STATE(ammo_handgrenade);
ammo_handgrenade_net = ammo_handgrenade; SAVE_STATE(ammo_satchel);
ammo_satchel_net = ammo_satchel; SAVE_STATE(ammo_tripmine);
ammo_tripmine_net = ammo_tripmine; SAVE_STATE(ammo_snark);
ammo_snark_net = ammo_snark; SAVE_STATE(ammo_hornet);
ammo_hornet_net = ammo_hornet;
ammo_m203_grenade_net = ammo_m203_grenade; SAVE_STATE(ammo_m203_grenade);
ammo_shotgun_state_net = ammo_shotgun_state; SAVE_STATE(ammo_gauss_volume);
ammo_gauss_state_net = ammo_gauss_state; SAVE_STATE(ammo_rpg_state);
ammo_gauss_volume_net = ammo_gauss_volume; SAVE_STATE(mode_tempstate);
ammo_egon_state_net = ammo_egon_state;
ammo_rpg_state_net = ammo_rpg_state;
mode_tempstate_net = mode_tempstate;
/* hunger */ /* hunger */
if (sniper_mag != sniper_mag_net) SAVE_STATE(sniper_mag);
SendFlags |= PLAYER_AMMO1; SAVE_STATE(chaingun_mag);
if (chaingun_mag != chaingun_mag_net) SAVE_STATE(ap9_mag);
SendFlags |= PLAYER_AMMO1; SAVE_STATE(taurus_mag);
if (ap9_mag != ap9_mag_net)
SendFlags |= PLAYER_AMMO1;
if (taurus_mag != taurus_mag_net)
SendFlags |= PLAYER_AMMO1;
if (ammo_ap9 != ammo_ap9_net) SAVE_STATE(ammo_ap9);
SendFlags |= PLAYER_AMMO2; SAVE_STATE(ammo_taurus);
if (ammo_taurus != ammo_taurus_net) SAVE_STATE(ammo_sniper);
SendFlags |= PLAYER_AMMO2; SAVE_STATE(ammo_medkit);
if (ammo_bolt != ammo_bolt_net) SAVE_STATE(ammo_gas);
SendFlags |= PLAYER_AMMO2; SAVE_STATE(mode_silencer);
if (ammo_sniper != ammo_sniper_net)
SendFlags |= PLAYER_AMMO2;
if (ammo_medkit != ammo_medkit_net)
SendFlags |= PLAYER_AMMO2;
if (ammo_gas != ammo_gas_net)
SendFlags |= PLAYER_AMMO2;
if (mode_silencer != mode_silencer_net)
SendFlags |= PLAYER_AMMO3;
sniper_mag_net = sniper_mag;
chaingun_mag_net = chaingun_mag;
ap9_mag_net = ap9_mag;
taurus_mag_net = taurus_mag;
ammo_ap9_net = ammo_ap9;
ammo_taurus_net = ammo_taurus;
ammo_bolt_net = ammo_bolt;
ammo_sniper_net = ammo_sniper;
ammo_medkit_net = ammo_medkit;
ammo_gas_net = ammo_gas;
mode_silencer_net= mode_silencer;
anim_top_net = anim_top;
anim_top_delay_net = anim_top_delay;
anim_top_time_net = anim_top_time;
anim_bottom_net = anim_bottom;
anim_bottom_time_net = anim_bottom_time;
} }
/* /*
@ -654,43 +457,7 @@ player::SendEntity(entity ePEnt, float fChanged)
WriteByte(MSG_ENTITY, ENT_PLAYER); WriteByte(MSG_ENTITY, ENT_PLAYER);
WriteFloat(MSG_ENTITY, fChanged); WriteFloat(MSG_ENTITY, fChanged);
/* really trying to get our moneys worth with 23 bits of mantissa */ base_player::SendEntity(ePEnt, fChanged);
if (fChanged & PLAYER_MODELINDEX)
WriteShort(MSG_ENTITY, modelindex);
if (fChanged & PLAYER_ORIGIN) {
WriteCoord(MSG_ENTITY, origin[0]);
WriteCoord(MSG_ENTITY, origin[1]);
}
if (fChanged & PLAYER_ORIGIN_Z)
WriteCoord(MSG_ENTITY, origin[2]);
if (fChanged & PLAYER_ANGLES_X)
WriteFloat(MSG_ENTITY, v_angle[0]);
if (fChanged & PLAYER_ANGLES_Y)
WriteFloat(MSG_ENTITY, angles[1]);
if (fChanged & PLAYER_ANGLES_Z)
WriteFloat(MSG_ENTITY, angles[2]);
if (fChanged & PLAYER_VELOCITY) {
WriteCoord(MSG_ENTITY, velocity[0]);
WriteCoord(MSG_ENTITY, velocity[1]);
}
if (fChanged & PLAYER_VELOCITY_Z)
WriteCoord(MSG_ENTITY, velocity[2]);
if (fChanged & PLAYER_FLAGS) {
WriteFloat(MSG_ENTITY, flags);
WriteFloat(MSG_ENTITY, gflags);
}
if (fChanged & PLAYER_WEAPON)
WriteByte(MSG_ENTITY, activeweapon);
if (fChanged & PLAYER_ITEMS)
WriteFloat(MSG_ENTITY, (__variant)g_items);
if (fChanged & PLAYER_HEALTH)
WriteByte(MSG_ENTITY, bound(0, health, 255));
if (fChanged & PLAYER_ARMOR)
WriteByte(MSG_ENTITY, armor);
if (fChanged & PLAYER_MOVETYPE)
WriteByte(MSG_ENTITY, movetype);
if (fChanged & PLAYER_VIEWOFS)
WriteFloat(MSG_ENTITY, view_ofs[2]);
if (fChanged & PLAYER_TOPFRAME) { if (fChanged & PLAYER_TOPFRAME) {
WriteByte(MSG_ENTITY, anim_top); WriteByte(MSG_ENTITY, anim_top);
@ -734,7 +501,6 @@ player::SendEntity(entity ePEnt, float fChanged)
/* hunger */ /* hunger */
WriteByte(MSG_ENTITY, ammo_ap9); WriteByte(MSG_ENTITY, ammo_ap9);
WriteByte(MSG_ENTITY, ammo_taurus); WriteByte(MSG_ENTITY, ammo_taurus);
WriteByte(MSG_ENTITY, ammo_bolt);
WriteByte(MSG_ENTITY, ammo_sniper); WriteByte(MSG_ENTITY, ammo_sniper);
WriteByte(MSG_ENTITY, ammo_medkit); WriteByte(MSG_ENTITY, ammo_medkit);
WriteByte(MSG_ENTITY, ammo_gas); WriteByte(MSG_ENTITY, ammo_gas);
@ -742,10 +508,7 @@ player::SendEntity(entity ePEnt, float fChanged)
if (fChanged & PLAYER_AMMO3) { if (fChanged & PLAYER_AMMO3) {
WriteByte(MSG_ENTITY, ammo_m203_grenade); WriteByte(MSG_ENTITY, ammo_m203_grenade);
WriteByte(MSG_ENTITY, ammo_shotgun_state);
WriteByte(MSG_ENTITY, ammo_gauss_state);
WriteByte(MSG_ENTITY, ammo_gauss_volume); WriteByte(MSG_ENTITY, ammo_gauss_volume);
WriteByte(MSG_ENTITY, ammo_egon_state);
WriteByte(MSG_ENTITY, ammo_rpg_state); WriteByte(MSG_ENTITY, ammo_rpg_state);
WriteByte(MSG_ENTITY, mode_tempstate); WriteByte(MSG_ENTITY, mode_tempstate);
WriteByte(MSG_ENTITY, mode_silencer); WriteByte(MSG_ENTITY, mode_silencer);

View File

@ -85,10 +85,8 @@ w_ap9_pickup(int new, int startammo)
void void
w_ap9_draw(void) w_ap9_draw(void)
{ {
#ifdef CLIENT
Weapons_SetModel("models/v_ap9.mdl"); Weapons_SetModel("models/v_ap9.mdl");
Weapons_ViewAnimation(AP9_DRAW); Weapons_ViewAnimation(AP9_DRAW);
#endif
} }
void void
@ -112,11 +110,6 @@ w_ap9_primary(void)
} }
pl.ap9_mag--; pl.ap9_mag--;
/* actual firing */
#ifdef CLIENT
pl.ap9_mag--;
View_SetMuzzleflash(MUZZLE_SMALL);
Weapons_ViewPunchAngle([-2,0,0]); Weapons_ViewPunchAngle([-2,0,0]);
int r = (float)input_sequence % 3; int r = (float)input_sequence % 3;
@ -132,14 +125,16 @@ w_ap9_primary(void)
break; break;
} }
#else
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8, [0.1,0.1], WEAPON_AP9);
Sound_Play(pl, CHAN_WEAPON, "weapon_ap9.fire");
if (self.flags & FL_CROUCHING) if (self.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f); Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
else else
Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f); Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f);
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_SMALL);
#else
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8, [0.1,0.1], WEAPON_AP9);
Sound_Play(pl, CHAN_WEAPON, "weapon_ap9.fire");
#endif #endif
pl.w_attack_next = 0.15f; pl.w_attack_next = 0.15f;
@ -161,8 +156,6 @@ w_ap9_secondary(void)
} }
pl.ap9_mag -= 3; pl.ap9_mag -= 3;
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_SMALL);
Weapons_ViewPunchAngle([-2,0,0]); Weapons_ViewPunchAngle([-2,0,0]);
int r = floor(random(0,2)); int r = floor(random(0,2));
@ -177,14 +170,17 @@ w_ap9_secondary(void)
Weapons_ViewAnimation(AP9_SHOOT3); Weapons_ViewAnimation(AP9_SHOOT3);
break; break;
} }
#else
TraceAttack_FireBullets(3, pl.origin + pl.view_ofs, 8, [0.02,0.02], WEAPON_AP9);
Sound_Play(pl, CHAN_WEAPON, "weapon_ap9.fire");
if (self.flags & FL_CROUCHING) if (self.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f); Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
else else
Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f); Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f);
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_SMALL);
#else
TraceAttack_FireBullets(3, pl.origin + pl.view_ofs, 8, [0.02,0.02], WEAPON_AP9);
Sound_Play(pl, CHAN_WEAPON, "weapon_ap9.fire");
#endif #endif
pl.w_attack_next = 1.0f; pl.w_attack_next = 1.0f;

View File

@ -89,11 +89,8 @@ w_chaingun_draw(void)
{ {
player pl = (player)self; player pl = (player)self;
pl.mode_tempstate = 0; pl.mode_tempstate = 0;
#ifdef CLIENT
Weapons_SetModel("models/v_tfac.mdl"); Weapons_SetModel("models/v_tfac.mdl");
Weapons_ViewAnimation(CHAINGUN_DRAW); Weapons_ViewAnimation(CHAINGUN_DRAW);
#endif
} }
void void
@ -182,11 +179,11 @@ w_chaingun_primary(void)
} }
pl.chaingun_mag--; pl.chaingun_mag--;
/* actual firing */
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_RIFLE);
Weapons_ViewAnimation(CHAINGUN_FIRE); Weapons_ViewAnimation(CHAINGUN_FIRE);
Weapons_ViewPunchAngle([random(-2, 2),0,0]); Weapons_ViewPunchAngle([random(-2, 2),0,0]);
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_RIFLE);
#else #else
TraceAttack_FireBullets(1, Weapons_GetCameraPos(), 8, [0.15,0.15], WEAPON_CHAINGUN); TraceAttack_FireBullets(1, Weapons_GetCameraPos(), 8, [0.15,0.15], WEAPON_CHAINGUN);
Sound_Play(pl, CHAN_WEAPON, "weapon_chaingun.fire"); Sound_Play(pl, CHAN_WEAPON, "weapon_chaingun.fire");
@ -213,9 +210,9 @@ w_chaingun_reload(void)
return; return;
} }
#ifdef CLIENT
Weapons_ViewAnimation(CHAINGUN_HOLSTER); Weapons_ViewAnimation(CHAINGUN_HOLSTER);
#else
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_chaingun.reload"); Sound_Play(pl, CHAN_WEAPON, "weapon_chaingun.reload");
Weapons_ReloadWeapon(pl, player::chaingun_mag, player::ammo_9mm, 100); Weapons_ReloadWeapon(pl, player::chaingun_mag, player::ammo_9mm, 100);
#endif #endif

View File

@ -184,7 +184,7 @@ w_flame_aimanim(void)
return w_egon_aimanim(); return w_egon_aimanim();
} }
void void
w_flame_hudpic(int selected, vector pos, float a) w_flame_hudpic(int selected, vector pos, float a)
{ {
#ifdef CLIENT #ifdef CLIENT

View File

@ -112,15 +112,14 @@ w_medkit_primary(void)
pl.ammo_medkit--; pl.ammo_medkit--;
#ifdef SERVER
/* We want to only give health to the player & skip armor */
Damage_Apply(pl, pl, -15, WEAPON_MEDKIT, DMG_GENERIC);
if (self.flags & FL_CROUCHING) if (self.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f); Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
else else
Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f); Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f);
#ifdef SERVER
/* We want to only give health to the player & skip armor */
Damage_Apply(pl, pl, -15, WEAPON_MEDKIT, DMG_GENERIC);
Sound_Play(pl, CHAN_WEAPON, "weapon_medkit.heal"); Sound_Play(pl, CHAN_WEAPON, "weapon_medkit.heal");
#endif #endif

View File

@ -37,7 +37,8 @@ enum
RPG_FIDGET_UL, RPG_FIDGET_UL,
}; };
void w_rpg_precache(void) void
w_rpg_precache(void)
{ {
#ifdef SERVER #ifdef SERVER
Sound_Precache("weapon_rpg.shoot"); Sound_Precache("weapon_rpg.shoot");
@ -50,24 +51,32 @@ void w_rpg_precache(void)
#endif #endif
} }
void w_rpg_updateammo(player pl) void
w_rpg_updateammo(player pl)
{ {
Weapons_UpdateAmmo(pl, pl.rpg_mag, pl.ammo_rocket, -1); Weapons_UpdateAmmo(pl, pl.rpg_mag, pl.ammo_rocket, -1);
} }
string w_rpg_wmodel(void)
string
w_rpg_wmodel(void)
{ {
return "models/w_rpg.mdl"; return "models/w_rpg.mdl";
} }
string w_rpg_pmodel(void)
string
w_rpg_pmodel(void)
{ {
return "models/p_rpg.mdl"; return "models/p_rpg.mdl";
} }
string w_rpg_deathmsg(void)
string
w_rpg_deathmsg(void)
{ {
return ""; return "";
} }
int w_rpg_pickup(int new, int startammo) int
w_rpg_pickup(int new, int startammo)
{ {
#ifdef SERVER #ifdef SERVER
player pl = (player)self; player pl = (player)self;
@ -85,20 +94,21 @@ int w_rpg_pickup(int new, int startammo)
return TRUE; return TRUE;
} }
void w_rpg_draw(void) void
w_rpg_draw(void)
{ {
#ifdef CLIENT
Weapons_SetModel("models/v_rpg.mdl"); Weapons_SetModel("models/v_rpg.mdl");
Weapons_ViewAnimation(RPG_DRAW1); Weapons_ViewAnimation(RPG_DRAW1);
#endif
} }
void w_rpg_holster(void) void
w_rpg_holster(void)
{ {
} }
void w_rpg_primary(void) void
w_rpg_primary(void)
{ {
player pl = (player)self; player pl = (player)self;
if (pl.w_attack_next > 0.0) { if (pl.w_attack_next > 0.0) {
@ -112,10 +122,10 @@ void w_rpg_primary(void)
pl.rpg_mag--; pl.rpg_mag--;
#ifdef CLIENT
Weapons_ViewAnimation(RPG_FIRE2); Weapons_ViewAnimation(RPG_FIRE2);
Weapons_ViewPunchAngle([-10,0,0]); Weapons_ViewPunchAngle([-10,0,0]);
#else
#ifdef SERVER
static void Rocket_Touch(void) { static void Rocket_Touch(void) {
float dmg = Skill_GetValue("plr_rpg", 100); float dmg = Skill_GetValue("plr_rpg", 100);
FX_Explosion(self.origin); FX_Explosion(self.origin);
@ -166,7 +176,8 @@ void w_rpg_primary(void)
pl.w_idle_next = 2.5f; pl.w_idle_next = 2.5f;
} }
void w_rpg_reload(void) void
w_rpg_reload(void)
{ {
player pl = (player)self; player pl = (player)self;
@ -182,10 +193,9 @@ void w_rpg_reload(void)
return; return;
} }
/* Audio-Visual Bit */
#ifdef CLIENT
Weapons_ViewAnimation(RPG_RELOAD); Weapons_ViewAnimation(RPG_RELOAD);
#else
#ifdef SERVER
Weapons_ReloadWeapon(pl, player::rpg_mag, player::ammo_rocket, 1); Weapons_ReloadWeapon(pl, player::rpg_mag, player::ammo_rocket, 1);
#endif #endif
@ -193,7 +203,8 @@ void w_rpg_reload(void)
pl.w_idle_next = 10.0f; pl.w_idle_next = 10.0f;
} }
void w_rpg_release(void) void
w_rpg_release(void)
{ {
player pl = (player)self; player pl = (player)self;
@ -227,7 +238,8 @@ void w_rpg_release(void)
pl.w_idle_next = 6.0f; pl.w_idle_next = 6.0f;
} }
void w_rpg_secondary(void) void
w_rpg_secondary(void)
{ {
/* Another change to spice things up */ /* Another change to spice things up */
@ -246,12 +258,14 @@ void w_rpg_secondary(void)
} }
} }
float w_rpg_aimanim(void) float
w_rpg_aimanim(void)
{ {
return self.flags & FL_CROUCHING ? ANIM_CR_AIMRPG : ANIM_AIMRPG; return self.flags & FL_CROUCHING ? ANIM_CR_AIMRPG : ANIM_AIMRPG;
} }
void w_rpg_hudpic(int selected, vector pos, float a) void
w_rpg_hudpic(int selected, vector pos, float a)
{ {
#ifdef CLIENT #ifdef CLIENT
player pl = (player)self; player pl = (player)self;
@ -272,7 +286,8 @@ void w_rpg_hudpic(int selected, vector pos, float a)
#endif #endif
} }
void w_rpg_hud(void) void
w_rpg_hud(void)
{ {
#ifdef CLIENT #ifdef CLIENT
player pl = (player)self; player pl = (player)self;
@ -357,7 +372,9 @@ weapon_t w_rpg =
}; };
#ifdef SERVER #ifdef SERVER
void weapon_rpg(void) { void
weapon_rpg(void)
{
Weapons_InitItem(WEAPON_RPG); Weapons_InitItem(WEAPON_RPG);
} }
#endif #endif

View File

@ -111,18 +111,23 @@ w_silencer_primary(void)
/* actual firing */ /* actual firing */
Weapons_ViewPunchAngle([-2,0,0]); Weapons_ViewPunchAngle([-2,0,0]);
if (pl.glock_mag) {
Weapons_ViewAnimation(GLOCK_SHOOT);
} else {
Weapons_ViewAnimation(GLOCK_SHOOT_EMPTY);
}
if (self.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
else
Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f);
#ifdef CLIENT #ifdef CLIENT
if (pl.mode_silencer == 1) { if (pl.mode_silencer == 1) {
View_SetMuzzleflash(0); View_SetMuzzleflash(0);
} else { } else {
View_SetMuzzleflash(MUZZLE_SMALL); View_SetMuzzleflash(MUZZLE_SMALL);
} }
if (pl.glock_mag) {
Weapons_ViewAnimation(GLOCK_SHOOT);
} else {
Weapons_ViewAnimation(GLOCK_SHOOT_EMPTY);
}
#else #else
/* Different sound & accuracy without silencer */ /* Different sound & accuracy without silencer */
if (pl.mode_silencer == 1) { if (pl.mode_silencer == 1) {
@ -133,11 +138,6 @@ w_silencer_primary(void)
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, Skill_GetValue("plr_9mm_bullet", 8), [0.1,0.1], WEAPON_GLOCK); TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, Skill_GetValue("plr_9mm_bullet", 8), [0.1,0.1], WEAPON_GLOCK);
Sound_Play(pl, CHAN_WEAPON, "weapon_glock.fire"); Sound_Play(pl, CHAN_WEAPON, "weapon_glock.fire");
} }
if (self.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
else
Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f);
#endif #endif
/* Fires faster without silencer */ /* Fires faster without silencer */
@ -162,8 +162,6 @@ w_silencer_secondary(void)
/* toggle silencer */ /* toggle silencer */
pl.mode_silencer = 1 - pl.mode_silencer; pl.mode_silencer = 1 - pl.mode_silencer;
/* the sub model isn't setting right, need the right values */
#ifdef CLIENT
if (pl.mode_silencer) { if (pl.mode_silencer) {
Weapons_SetGeomset("geomset 2 2\n"); Weapons_SetGeomset("geomset 2 2\n");
Weapons_ViewAnimation(GLOCK_SILENCER); Weapons_ViewAnimation(GLOCK_SILENCER);
@ -171,7 +169,7 @@ w_silencer_secondary(void)
Weapons_SetGeomset("geomset 2 0\n"); Weapons_SetGeomset("geomset 2 0\n");
Weapons_ViewAnimation(GLOCK_HOLSTER); Weapons_ViewAnimation(GLOCK_HOLSTER);
} }
#endif
if (pl.mode_silencer) { if (pl.mode_silencer) {
pl.w_attack_next = 3.3f; pl.w_attack_next = 3.3f;
pl.w_idle_next = pl.w_attack_next; pl.w_idle_next = pl.w_attack_next;

View File

@ -86,18 +86,14 @@ w_sniper_draw(void)
player pl = (player)self; player pl = (player)self;
pl.mode_tempstate = 0; pl.mode_tempstate = 0;
#ifdef CLIENT
Weapons_SetModel("models/v_tfc_sniper.mdl"); Weapons_SetModel("models/v_tfc_sniper.mdl");
Weapons_ViewAnimation(SNIPER_DRAW); Weapons_ViewAnimation(SNIPER_DRAW);
#endif
} }
void void
w_sniper_holster(void) w_sniper_holster(void)
{ {
#ifdef CLIENT
Weapons_ViewAnimation(SNIPER_HOLSTER); Weapons_ViewAnimation(SNIPER_HOLSTER);
#endif
} }
void void
@ -155,11 +151,11 @@ w_sniper_primary(void)
pl.sniper_mag--; pl.sniper_mag--;
/* Actual firing */
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_SMALL);
Weapons_ViewPunchAngle([-20,0,0]); Weapons_ViewPunchAngle([-20,0,0]);
Weapons_ViewAnimation(SNIPER_FIRE1); Weapons_ViewAnimation(SNIPER_FIRE1);
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_SMALL);
#else #else
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 40, [0.008, 0.008], WEAPON_SNIPER); TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 40, [0.008, 0.008], WEAPON_SNIPER);
Sound_Play(pl, CHAN_WEAPON, "weapon_sniper.fire"); Sound_Play(pl, CHAN_WEAPON, "weapon_sniper.fire");
@ -209,9 +205,9 @@ w_sniper_reload(void)
return; return;
} }
#ifdef CLIENT
Weapons_ViewAnimation(SNIPER_HOLSTER); Weapons_ViewAnimation(SNIPER_HOLSTER);
#else
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_sniper.reload"); Sound_Play(pl, CHAN_WEAPON, "weapon_sniper.reload");
Weapons_ReloadWeapon(pl, player::sniper_mag, player::ammo_sniper, 5); Weapons_ReloadWeapon(pl, player::sniper_mag, player::ammo_sniper, 5);
#endif #endif

View File

@ -80,10 +80,8 @@ w_sniper2_deathmsg(void)
void void
w_sniper2_draw(void) w_sniper2_draw(void)
{ {
#ifdef CLIENT
Weapons_SetModel("models/v_hkg36.mdl"); Weapons_SetModel("models/v_hkg36.mdl");
Weapons_ViewAnimation(SNIPER_DRAW); Weapons_ViewAnimation(SNIPER_DRAW);
#endif
} }
void void
@ -138,11 +136,11 @@ w_sniper2_primary(void)
pl.sniper_mag--; pl.sniper_mag--;
/* Actual firing */
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_SMALL);
Weapons_ViewPunchAngle([-20,0,0]); Weapons_ViewPunchAngle([-20,0,0]);
Weapons_ViewAnimation(SNIPER_FIRE); Weapons_ViewAnimation(SNIPER_FIRE);
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_SMALL);
#else #else
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 40, [0.008, 0.008], WEAPON_SNIPER); TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 40, [0.008, 0.008], WEAPON_SNIPER);
Sound_Play(pl, CHAN_WEAPON, "weapon_sniper.fire"); Sound_Play(pl, CHAN_WEAPON, "weapon_sniper.fire");
@ -179,9 +177,9 @@ w_sniper2_reload(void)
return; return;
} }
#ifdef CLIENT
Weapons_ViewAnimation(SNIPER_RELOAD); Weapons_ViewAnimation(SNIPER_RELOAD);
#else
#ifdef SERVER
Weapons_ReloadWeapon(pl, player::sniper_mag, player::ammo_sniper, 5); Weapons_ReloadWeapon(pl, player::sniper_mag, player::ammo_sniper, 5);
#endif #endif

View File

@ -96,19 +96,19 @@ w_spanner_primary(void)
} }
pl.w_idle_next = 2.5f; pl.w_idle_next = 2.5f;
#ifdef CLIENT
if (random() < 0.5) { if (random() < 0.5) {
Weapons_ViewAnimation(CBAR_ATTACK1); Weapons_ViewAnimation(CBAR_ATTACK1);
} else { } else {
Weapons_ViewAnimation(CBAR_ATTACK2); Weapons_ViewAnimation(CBAR_ATTACK2);
} }
#else
if (pl.flags & FL_CROUCHING) { if (pl.flags & FL_CROUCHING) {
Animation_PlayerTop(pl, ANIM_SHOOTCROWBAR, 0.5f); Animation_PlayerTop(pl, ANIM_SHOOTCROWBAR, 0.5f);
} else { } else {
Animation_PlayerTop(pl, ANIM_CR_SHOOTCROWBAR, 0.42f); Animation_PlayerTop(pl, ANIM_CR_SHOOTCROWBAR, 0.42f);
} }
#ifdef SERVER
Sound_Play(self, CHAN_WEAPON, "weapon_crowbar.miss"); Sound_Play(self, CHAN_WEAPON, "weapon_crowbar.miss");
if (trace_fraction >= 1.0) { if (trace_fraction >= 1.0) {

View File

@ -87,18 +87,14 @@ w_taurus_pickup(int new, int startammo)
void void
w_taurus_draw(void) w_taurus_draw(void)
{ {
#ifdef CLIENT
Weapons_SetModel("models/v_taurus.mdl"); Weapons_SetModel("models/v_taurus.mdl");
Weapons_ViewAnimation(TAURUS_DRAW); Weapons_ViewAnimation(TAURUS_DRAW);
#endif
} }
void void
w_taurus_holster(void) w_taurus_holster(void)
{ {
#ifdef CLIENT
Weapons_ViewAnimation(TAURUS_HOLSTER); Weapons_ViewAnimation(TAURUS_HOLSTER);
#endif
} }
void void
@ -117,9 +113,6 @@ w_taurus_primary(void)
pl.taurus_mag--; pl.taurus_mag--;
/* actual firing */
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_SMALL);
Weapons_ViewPunchAngle([-2,0,0]); Weapons_ViewPunchAngle([-2,0,0]);
if (pl.taurus_mag) { if (pl.taurus_mag) {
@ -127,14 +120,18 @@ w_taurus_primary(void)
} else { } else {
Weapons_ViewAnimation(TAURUS_SHOOT_EMPTY); Weapons_ViewAnimation(TAURUS_SHOOT_EMPTY);
} }
#else
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 12, [0.01,0.01], WEAPON_TAURUS);
Sound_Play(pl, CHAN_WEAPON, "weapon_taurus.fire");
if (self.flags & FL_CROUCHING) if (self.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f); Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
else else
Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f); Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f);
/* actual firing */
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_SMALL);
#else
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 12, [0.01,0.01], WEAPON_TAURUS);
Sound_Play(pl, CHAN_WEAPON, "weapon_taurus.fire");
#endif #endif
pl.w_attack_next = 0.25f; pl.w_attack_next = 0.25f;
@ -162,13 +159,13 @@ w_taurus_reload(void)
return; return;
} }
#ifdef CLIENT
if (pl.taurus_mag) { if (pl.taurus_mag) {
Weapons_ViewAnimation(TAURUS_RELOAD); Weapons_ViewAnimation(TAURUS_RELOAD);
} else { } else {
Weapons_ViewAnimation(TAURUS_RELOAD2); Weapons_ViewAnimation(TAURUS_RELOAD2);
} }
#else
#ifdef SERVER
Weapons_ReloadWeapon(pl, player::taurus_mag, player::ammo_taurus, 10); Weapons_ReloadWeapon(pl, player::taurus_mag, player::ammo_taurus, 10);
#endif #endif

View File

@ -26,7 +26,8 @@ enum
HANDGRENADE_DRAW HANDGRENADE_DRAW
}; };
void w_tnt_precache(void) void
w_tnt_precache(void)
{ {
#ifdef SERVER #ifdef SERVER
Sound_Precache("weapon_handgrenade.bounce"); Sound_Precache("weapon_handgrenade.bounce");
@ -37,33 +38,39 @@ void w_tnt_precache(void)
precache_model("models/p_tnt.mdl"); precache_model("models/p_tnt.mdl");
} }
void w_tnt_updateammo(player pl) void
w_tnt_updateammo(player pl)
{ {
w_handgrenade_updateammo(pl); w_handgrenade_updateammo(pl);
} }
string w_tnt_wmodel(void) string
w_tnt_wmodel(void)
{ {
return "models/w_tnt.mdl"; return "models/w_tnt.mdl";
} }
string w_tnt_pmodel(void) string
w_tnt_pmodel(void)
{ {
return "models/p_tnt.mdl"; return "models/p_tnt.mdl";
} }
string w_tnt_deathmsg(void) string
w_tnt_deathmsg(void)
{ {
return w_handgrenade_deathmsg(); return w_handgrenade_deathmsg();
} }
int w_tnt_pickup(int new, int startammo) int
w_tnt_pickup(int new, int startammo)
{ {
return w_handgrenade_pickup(new, startammo); return w_handgrenade_pickup(new, startammo);
} }
#ifdef SERVER #ifdef SERVER
void w_tnt_throw(void) void
w_tnt_throw(void)
{ {
static void WeaponFrag_Throw_Explode(void) static void WeaponFrag_Throw_Explode(void)
{ {
@ -117,27 +124,29 @@ void w_tnt_throw(void)
} }
#endif #endif
void w_tnt_draw(void) void
w_tnt_draw(void)
{ {
player pl = (player)self; player pl = (player)self;
pl.mode_tempstate = 0; pl.mode_tempstate = 0;
#ifdef CLIENT
Weapons_SetModel("models/v_tnt.mdl"); Weapons_SetModel("models/v_tnt.mdl");
Weapons_ViewAnimation(HANDGRENADE_DRAW); Weapons_ViewAnimation(HANDGRENADE_DRAW);
#endif
} }
void w_tnt_holster(void) void
w_tnt_holster(void)
{ {
} }
void w_tnt_primary(void) void
w_tnt_primary(void)
{ {
w_handgrenade_primary(); w_handgrenade_primary();
} }
void w_tnt_hud(void) void
w_tnt_hud(void)
{ {
#ifdef CLIENT #ifdef CLIENT
HUD_DrawAmmo2(); HUD_DrawAmmo2();
@ -147,7 +156,8 @@ void w_tnt_hud(void)
} }
void w_tnt_release(void) void
w_tnt_release(void)
{ {
player pl = (player)self; player pl = (player)self;
@ -156,20 +166,17 @@ void w_tnt_release(void)
} }
if (pl.mode_tempstate == 1) { if (pl.mode_tempstate == 1) {
#ifdef CLIENT
pl.ammo_handgrenade--; pl.ammo_handgrenade--;
Weapons_ViewAnimation(HANDGRENADE_THROW1); Weapons_ViewAnimation(HANDGRENADE_THROW1);
#else #ifdef SERVER
pl.ammo_handgrenade--;
w_tnt_throw(); w_tnt_throw();
#endif #endif
pl.mode_tempstate = 2; pl.mode_tempstate = 2;
pl.w_attack_next = 1.0f; pl.w_attack_next = 1.0f;
pl.w_idle_next = 0.5f; pl.w_idle_next = 0.5f;
} else if (pl.mode_tempstate == 2) { } else if (pl.mode_tempstate == 2) {
#ifdef CLIENT
Weapons_ViewAnimation(HANDGRENADE_DRAW); Weapons_ViewAnimation(HANDGRENADE_DRAW);
#else #ifdef SERVER
if (!pl.ammo_handgrenade) { if (!pl.ammo_handgrenade) {
Weapons_RemoveItem(pl, WEAPON_HANDGRENADE); Weapons_RemoveItem(pl, WEAPON_HANDGRENADE);
} }
@ -204,7 +211,7 @@ w_tnt_hudpic(int selected, vector pos, float a)
weapon_t w_tnt = weapon_t w_tnt =
{ {
.name = "tnt", .name = "tnt",
.id = ITEM_HANDGRENADE, .id = ITEM_HANDGRENADE,
.slot = 4, .slot = 4,
.slot_pos = 0, .slot_pos = 0,
.draw = w_tnt_draw, .draw = w_tnt_draw,