Shared: Inherit weapon_common from Nuclide's base game.

This commit is contained in:
Marco Cawthorne 2021-05-10 08:18:06 +02:00
parent 73b91819ce
commit 747fdd838d
15 changed files with 110 additions and 181 deletions

View file

@ -2,7 +2,7 @@
../../../valve/src/shared/entities.h
../../../valve/src/shared/flags.h
player.qc
../../../valve/src/shared/weapon_common.h
../../../base/src/shared/weapon_common.h
../../../valve/src/shared/animations.h
../../../valve/src/shared/animations.qc
../../../valve/src/shared/pmove.qc
@ -42,6 +42,6 @@ w_spanner.qc
w_taurus.qc
w_tnt.qc
weapons.qc
../../../valve/src/shared/weapon_common.qc
../../../base/src/shared/weapon_common.qc
input.qc
#endlist

View file

@ -14,26 +14,24 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
=================
Input_Handle
Handles impulse and whatnot
=================
*/
void
Game_Input(void)
{
#ifdef SERVER
if (input_buttons & INPUT_BUTTON5) {
Player_UseDown();
} else {
Player_UseUp();
CGameRules rules = (CGameRules)g_grMode;
if (rules.m_iIntermission) {
rules.IntermissionEnd();
return;
}
if (self.impulse == 100) {
if (input_buttons & INPUT_BUTTON5)
Player_UseDown();
else
Player_UseUp();
if (self.impulse == 100)
Flashlight_Toggle();
}
if (cvar("sv_cheats") == 1) {
player pl = (player)self;
@ -63,27 +61,17 @@ Game_Input(void)
Weapons_AddItem(pl, WEAPON_SNARK, -1);
Weapons_AddItem(pl, WEAPON_MEDKIT, -1);
}
if (self.impulse == 102) {
// Respawn all the entities
for (entity a = world; (a = findfloat(a, ::identity, 1));) {
CBaseEntity caw = (CBaseEntity)a;
caw.Respawn();
}
bprint(PRINT_HIGH, "Respawning all map entities...\n");
}
}
self.impulse = 0;
#endif
if (input_buttons & INPUT_BUTTON0) {
if (input_buttons & INPUT_BUTTON0)
Weapons_Primary();
} else if (input_buttons & INPUT_BUTTON4) {
else if (input_buttons & INPUT_BUTTON4)
Weapons_Reload();
} else if (input_buttons & INPUT_BUTTON3) {
else if (input_buttons & INPUT_BUTTON3)
Weapons_Secondary();
} else {
else
Weapons_Release();
}
}

View file

@ -437,11 +437,11 @@ float
player::SendEntity(entity ePEnt, float fChanged)
{
if (health <= 0 && ePEnt != this) {
return FALSE;
return (0);
}
if (clienttype(ePEnt) != CLIENTTYPE_REAL) {
return FALSE;
return (0);
}
if (ePEnt != self) {
@ -514,6 +514,6 @@ player::SendEntity(entity ePEnt, float fChanged)
WriteByte(MSG_ENTITY, mode_silencer);
}
return TRUE;
return (1);
}
#endif

View file

@ -30,13 +30,12 @@ w_ap9_precache(void)
{
#ifdef SERVER
Sound_Precache("weapon_ap9.fire");
#endif
precache_model("models/v_ap9.mdl");
precache_model("models/w_ap9.mdl");
#else
precache_model("models/v_ap9.mdl");
precache_model("models/p_ap9.mdl");
precache_sound("weapons/ap9_bolt.wav");
precache_sound("weapons/ap9_clipin.wav");
precache_sound("weapons/ap9_clipout.wav");
#endif
}
void
@ -75,11 +74,11 @@ w_ap9_pickup(int new, int startammo)
if (pl.ammo_ap9 < MAX_A_AP9) {
pl.ammo_ap9 = bound(0, pl.ammo_ap9 + 40, MAX_A_AP9);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void
@ -100,14 +99,10 @@ w_ap9_primary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
/* ammo check */
if (!pl.ap9_mag) {
if (!pl.ap9_mag)
return;
}
pl.ap9_mag--;
Weapons_ViewPunchAngle([-2,0,0]);
@ -146,14 +141,11 @@ w_ap9_secondary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0) {
if (pl.w_attack_next > 0)
return;
if ((pl.ap9_mag - 3) < 0)
return;
}
/* ammo check */
if ((pl.ap9_mag - 3) < 0) {
return;
}
pl.ap9_mag -= 3;
Weapons_ViewPunchAngle([-2,0,0]);
@ -192,15 +184,12 @@ w_ap9_reload(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
if (pl.ap9_mag >= 40) {
if (pl.ap9_mag >= 40)
return;
}
if (pl.a_ammo2 <= 0) {
if (pl.a_ammo2 <= 0)
return;
}
#ifdef CLIENT
Weapons_ViewAnimation(AP9_RELOAD);
@ -224,9 +213,8 @@ w_ap9_release(void)
return;
}
if (pl.w_idle_next > 0.0) {
if (pl.w_idle_next > 0.0)
return;
}
Weapons_ViewAnimation(AP9_IDLE);
}

View file

@ -53,11 +53,11 @@ w_chaingun_pickup(int new, int startammo)
if (pl.ammo_9mm < MAX_A_9MM) {
pl.ammo_9mm = bound(0, pl.ammo_9mm + 100, MAX_A_9MM);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void
@ -111,9 +111,8 @@ w_chaingun_release(void)
return;
}
if (pl.w_idle_next > 0.0) {
if (pl.w_idle_next > 0.0)
return;
}
/* end firing */
if (pl.mode_tempstate == 1) {
@ -157,14 +156,12 @@ w_chaingun_primary(void)
return;
}
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
/* ammo check */
if (pl.chaingun_mag <= 0) {
if (pl.chaingun_mag <= 0)
return;
}
/* spin up first */
if (pl.mode_tempstate == 0) {
@ -203,12 +200,10 @@ w_chaingun_reload(void)
}
/* ammo check */
if (pl.chaingun_mag >= 100) {
if (pl.chaingun_mag >= 100)
return;
}
if (pl.ammo_9mm <= 0) {
if (pl.ammo_9mm <= 0)
return;
}
Weapons_ViewAnimation(CHAINGUN_HOLSTER);

View file

@ -74,10 +74,10 @@ w_flame_pickup(int new, int startammo)
if (pl.ammo_gas < MAX_A_GAS) {
pl.ammo_gas = bound(0, pl.ammo_gas + 20, MAX_A_GAS);
} else {
return FALSE;
return (0);
}
#endif
return TRUE;
return (1);
}
void
@ -113,14 +113,12 @@ void
w_flame_primary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
/* Ammo check */
if (pl.ammo_gas <= 0) {
if (pl.ammo_gas <= 0)
return;
}
pl.ammo_gas--;

View file

@ -76,11 +76,11 @@ w_medkit_pickup(int new, int startammo)
if (pl.ammo_medkit < MAX_A_MEDKIT) {
pl.ammo_medkit = bound(0, pl.ammo_medkit + 8, MAX_A_MEDKIT);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
@ -96,19 +96,16 @@ w_medkit_primary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
if (!pl.ammo_medkit) {
if (!pl.ammo_medkit)
return;
}
/* Don't give the player more than 100 health */
if (pl.health >= 100) {
if (pl.health >= 100)
return;
} else {
else
Weapons_ViewAnimation(MEDKIT_USE);
}
pl.ammo_medkit--;
@ -132,9 +129,8 @@ w_medkit_release(void)
{
player pl = (player)self;
if (pl.w_idle_next > 0.0) {
if (pl.w_idle_next > 0.0)
return;
}
int r = (float)input_sequence % 2;
switch (r) {

View file

@ -87,11 +87,11 @@ w_rpg_pickup(int new, int startammo)
if (pl.ammo_rocket < MAX_A_ROCKET) {
pl.ammo_rocket = bound(0, pl.ammo_rocket + 1, MAX_A_ROCKET);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void
@ -111,14 +111,12 @@ void
w_rpg_primary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
/* Ammo check */
if (pl.rpg_mag <= 0) {
if (pl.rpg_mag <= 0)
return;
}
pl.rpg_mag--;
@ -181,17 +179,14 @@ w_rpg_reload(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0) {
if (pl.w_attack_next > 0)
return;
}
/* Ammo check */
if (pl.rpg_mag >= 1) {
if (pl.rpg_mag >= 1)
return;
}
if (pl.ammo_rocket <= 0) {
if (pl.ammo_rocket <= 0)
return;
}
Weapons_ViewAnimation(RPG_RELOAD);
@ -215,9 +210,8 @@ w_rpg_release(void)
return;
}
if (pl.w_idle_next > 0.0) {
if (pl.w_idle_next > 0.0)
return;
}
int r = (float)input_sequence % 3;

View file

@ -84,9 +84,8 @@ w_shovel_primary(void)
vector src;
player pl = (player)self;
if (pl.w_attack_next) {
if (pl.w_attack_next)
return;
}
Weapons_MakeVectors();
src = pl.origin + pl.view_ofs;
@ -138,9 +137,8 @@ w_shovel_primary(void)
#ifdef SERVER
Sound_Play(self, CHAN_WEAPON, "weapon_crowbar.miss");
if (trace_fraction >= 1.0) {
if (trace_fraction >= 1.0)
return;
}
/* don't bother with decals, we got squibs */
if (trace_ent.iBleeds) {
@ -209,7 +207,7 @@ w_shovel_hudpic(int selected, vector pos, float a)
weapon_t w_shovel =
{
.name = "shovel",
.id = ITEM_SHOVEL,
.id = ITEM_SHOVEL,
.slot = 0,
.slot_pos = 1,
.draw = w_shovel_draw,

View file

@ -97,14 +97,12 @@ w_silencer_primary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
/* ammo check */
if (!pl.glock_mag) {
if (!pl.glock_mag)
return;
}
pl.glock_mag--;
@ -155,9 +153,8 @@ w_silencer_secondary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0) {
if (pl.w_attack_next > 0)
return;
}
/* toggle silencer */
pl.mode_silencer = 1 - pl.mode_silencer;

View file

@ -49,11 +49,11 @@ w_sniper_pickup(int new, int startammo)
if (pl.ammo_sniper < MAX_A_SNIPER) {
pl.ammo_sniper = bound(0, pl.ammo_sniper + 5, MAX_A_SNIPER);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void
@ -108,9 +108,8 @@ w_sniper_release(void)
return;
}
if (pl.w_idle_next > 0.0) {
if (pl.w_idle_next > 0.0)
return;
}
if (pl.mode_tempstate == 1) {
Weapons_ViewAnimation(SNIPER_DRAW);
@ -140,14 +139,12 @@ w_sniper_primary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
/* Ammo check */
if (pl.sniper_mag <= 0) {
if (pl.sniper_mag <= 0)
return;
}
pl.sniper_mag--;
@ -176,9 +173,8 @@ w_sniper_secondary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
/* Simple toggle of fovs */
if (pl.viewzoom == 1.0f) {
@ -198,12 +194,10 @@ w_sniper_reload(void)
w_sniper_release();
return;
}
if (pl.sniper_mag >= 5) {
if (pl.sniper_mag >= 5)
return;
}
if (pl.ammo_sniper <= 0) {
if (pl.ammo_sniper <= 0)
return;
}
Weapons_ViewAnimation(SNIPER_HOLSTER);

View file

@ -46,11 +46,11 @@ w_sniper2_pickup(int new, int startammo)
if (pl.ammo_sniper < MAX_A_SNIPER) {
pl.ammo_sniper = bound(0, pl.ammo_sniper + 5, MAX_A_SNIPER);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void
@ -101,9 +101,8 @@ w_sniper2_release(void)
return;
}
if (pl.w_idle_next > 0.0) {
if (pl.w_idle_next > 0.0)
return;
}
int r = floor(random(0,2));
switch (r) {
@ -125,14 +124,12 @@ w_sniper2_primary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
/* Ammo check */
if (pl.sniper_mag <= 0) {
if (pl.sniper_mag <= 0)
return;
}
pl.sniper_mag--;
@ -167,15 +164,12 @@ w_sniper2_reload(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
if (pl.sniper_mag >= 5) {
if (pl.sniper_mag >= 5)
return;
}
if (pl.ammo_sniper <= 0) {
if (pl.ammo_sniper <= 0)
return;
}
Weapons_ViewAnimation(SNIPER_RELOAD);

View file

@ -81,9 +81,8 @@ w_spanner_primary(void)
vector src;
player pl = (player)self;
if (pl.w_attack_next) {
if (pl.w_attack_next)
return;
}
Weapons_MakeVectors();
src = pl.origin + pl.view_ofs;
@ -111,9 +110,8 @@ w_spanner_primary(void)
#ifdef SERVER
Sound_Play(self, CHAN_WEAPON, "weapon_crowbar.miss");
if (trace_fraction >= 1.0) {
if (trace_fraction >= 1.0)
return;
}
/* don't bother with decals, we got squibs */
if (trace_ent.iBleeds) {
@ -181,7 +179,7 @@ w_spanner_hudpic(int selected, vector pos, float a)
weapon_t w_spanner =
{
.name = "spanner",
.id = ITEM_SPANNER,
.id = ITEM_SPANNER,
.slot = 0,
.slot_pos = 2,
.draw = w_spanner_draw,

View file

@ -77,11 +77,11 @@ w_taurus_pickup(int new, int startammo)
if (pl.ammo_taurus < MAX_A_TAURUS) {
pl.ammo_taurus = bound(0, pl.ammo_taurus + 10, MAX_A_TAURUS);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void
@ -102,14 +102,12 @@ w_taurus_primary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
/* ammo check */
if (!pl.taurus_mag) {
if (!pl.taurus_mag)
return;
}
pl.taurus_mag--;
@ -149,15 +147,12 @@ w_taurus_reload(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
if (pl.w_attack_next > 0.0)
return;
}
if (pl.taurus_mag >= 10) {
if (pl.taurus_mag >= 10)
return;
}
if (pl.ammo_taurus <= 0) {
if (pl.ammo_taurus <= 0)
return;
}
if (pl.taurus_mag) {
Weapons_ViewAnimation(TAURUS_RELOAD);
@ -186,9 +181,8 @@ w_taurus_release(void)
return;
}
if (pl.w_idle_next > 0.0) {
if (pl.w_idle_next > 0.0)
return;
}
r = floor(random(0,3));
switch (r) {
@ -228,7 +222,7 @@ w_taurus_hudpic(int selected, vector pos, float a)
weapon_t w_taurus =
{
.name = "taurus",
.id = ITEM_TAURUS,
.id = ITEM_TAURUS,
.slot = 1,
.slot_pos = 3,
.draw = w_taurus_draw,

View file

@ -72,8 +72,7 @@ w_tnt_pickup(int new, int startammo)
void
w_tnt_throw(void)
{
static void WeaponFrag_Throw_Explode(void)
{
static void WeaponFrag_Throw_Explode(void) {
float dmg = Skill_GetValue("plr_hand_grenade", 100);
FX_Explosion(self.origin);
Damage_Radius(self.origin, self.owner, dmg, dmg * 2.5f, TRUE, WEAPON_HANDGRENADE);
@ -81,28 +80,26 @@ w_tnt_throw(void)
remove(self);
}
static void WeaponFrag_Throw_Touch(void)
{
if (other.takedamage == DAMAGE_YES) {
static void WeaponFrag_Throw_Touch(void) {
if (other.takedamage == DAMAGE_YES)
Damage_Apply(other, self.owner, 15, WEAPON_HANDGRENADE, DMG_BLUNT);
} else {
else
Sound_Play(self, CHAN_BODY, "weapon_handgrenade.bounce");
}
self.frame = 0;
}
player pl = (player)self;
vector vPLAngle = pl.v_angle;
if (vPLAngle[0] < 0) {
if (vPLAngle[0] < 0)
vPLAngle[0] = -10 + vPLAngle[0] * ((90 - 10) / 90.0);
} else {
else
vPLAngle[0] = -10 + vPLAngle[0] * ((90 + 10) / 90.0);
}
float flVel = (90 - vPLAngle[0]) * 5;
if (flVel > 1000) {
if (flVel > 1000)
flVel = 1000;
}
makevectors(vPLAngle);
vector vecSrc = pl.origin + pl.view_ofs + v_forward * 16;
@ -161,26 +158,24 @@ w_tnt_release(void)
{
player pl = (player)self;
if (pl.w_idle_next > 0.0) {
if (pl.w_idle_next > 0.0)
return;
}
if (pl.mode_tempstate == 1) {
pl.ammo_handgrenade--;
Weapons_ViewAnimation(HANDGRENADE_THROW1);
#ifdef SERVER
w_tnt_throw();
#endif
Weapons_ViewAnimation(HANDGRENADE_THROW1);
pl.ammo_handgrenade--;
pl.mode_tempstate = 2;
pl.w_attack_next = 1.0f;
pl.w_idle_next = 0.5f;
} else if (pl.mode_tempstate == 2) {
Weapons_ViewAnimation(HANDGRENADE_DRAW);
#ifdef SERVER
if (!pl.ammo_handgrenade) {
if (!pl.ammo_handgrenade)
Weapons_RemoveItem(pl, WEAPON_HANDGRENADE);
}
#endif
Weapons_ViewAnimation(HANDGRENADE_DRAW);
pl.w_attack_next = 0.5f;
pl.w_idle_next = 0.5f;
pl.mode_tempstate = 0;