Improvements to the ammo items. Will now pick up the appropriate amounts and set the right model.

This commit is contained in:
Marco Cawthorne 2023-04-15 14:06:12 -07:00
parent eed46f362e
commit 6869daf464
Signed by: eukara
GPG key ID: CE2032F0A2882A22
3 changed files with 48 additions and 32 deletions

View file

@ -49,13 +49,18 @@ item_ammo::Respawn(void)
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_TOSS);
SetOrigin(GetSpawnOrigin());
SetModel(GetSpawnModel());
if (HasSpawnFlags(1))
SetModel(noise);
else
SetModel(GetSpawnModel());
SetSize([-16,-16,0],[16,16,16]);
ReleaseThink();
if (real_owner && time > 30.0f)
Sound_Play(this, CHAN_ITEM, "ammo.respawn");
Sound_Play(this, CHAN_ITEM, "dmc_item.respawn");
droptofloor();
}
@ -66,7 +71,7 @@ item_ammo::Spawned(void)
super::Spawned();
Sound_Precache("ammo.pickup");
Sound_Precache("ammo.respawn");
Sound_Precache("dmc_item.respawn");
precache_model(model);
}
@ -78,13 +83,12 @@ item_ammo::item_ammo(void)
/*QUAKED item_shells (0 0 0.8) (-16 -16 0) (16 16 32)
HALF-LIFE (1998) ENTITY
DEATHMATCH CLASSIC (1999) ENTITY
Ammo for the .357 Magnum Revolver.
A single ammo_shells will provide 6 bullets.
Shells for the shotguns.
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
model="models/w_357ammobox.mdl"
model="models/w_shotbox_big.mdl"
*/
class
@ -97,7 +101,8 @@ item_shells:item_ammo
void
item_shells::item_shells(void)
{
model = "models/w_shotbox_big.mdl";
model = "models/w_shotbox.mdl";
noise = "models/w_shotbox_big.mdl";
}
void
@ -109,7 +114,11 @@ item_shells::Touch(entity eToucher)
if (eToucher.classname == "player") {
player pl = (player)eToucher;
if (pl.ammo_shells < MAX_A_SHELLS) {
pl.ammo_shells = bound(0, pl.ammo_shells + 6, MAX_A_SHELLS);
if (HasSpawnFlags(1))
pl.ammo_shells = bound(0, pl.ammo_shells + 40, MAX_A_SHELLS);
else
pl.ammo_shells = bound(0, pl.ammo_shells + 20, MAX_A_SHELLS);
item_ammo::Touch(eToucher);
}
}
@ -118,13 +127,12 @@ item_shells::Touch(entity eToucher)
/*QUAKED item_spikes (0 0 0.8) (-16 -16 0) (16 16 32)
HALF-LIFE (1998) ENTITY
DEATHMATCH CLASSIC (1999) ENTITY
Ammo for the .357 Magnum Revolver.
A single ammo_nails will provide 6 bullets.
Nails for the (Super) Nail Gun
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
model="models/w_357ammobox.mdl"
model="models/b_nail1.mdl"
*/
class
@ -137,7 +145,8 @@ item_spikes:item_ammo
void
item_spikes::item_spikes(void)
{
model = "models/b_nail1.mdl";
model = "models/b_nail0.mdl";
noise = "models/b_nail1.mdl";
}
void
@ -149,7 +158,11 @@ item_spikes::Touch(entity eToucher)
if (eToucher.classname == "player") {
player pl = (player)eToucher;
if (pl.ammo_nails < MAX_A_NAILS) {
pl.ammo_nails = bound(0, pl.ammo_nails + 6, MAX_A_NAILS);
if (HasSpawnFlags(1))
pl.ammo_nails = bound(0, pl.ammo_nails + 50, MAX_A_NAILS);
else
pl.ammo_nails = bound(0, pl.ammo_nails + 25, MAX_A_NAILS);
item_ammo::Touch(eToucher);
}
}
@ -159,13 +172,12 @@ item_spikes::Touch(entity eToucher)
/*QUAKED item_rockets (0 0 0.8) (-16 -16 0) (16 16 32)
HALF-LIFE (1998) ENTITY
DEATHMATCH CLASSIC (1999) ENTITY
Ammo for the .357 Magnum Revolver.
A single ammo_rockets will provide 6 bullets.
Rockets for the Grenade & Rocket Launcher
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
model="models/w_357ammobox.mdl"
model="models/w_rpgammo_big.mdl"
*/
class item_rockets:item_ammo
@ -178,6 +190,7 @@ void
item_rockets::item_rockets(void)
{
model = "models/w_rpgammo.mdl";
noise = "models/w_rpgammo_big.mdl";
}
void
@ -189,7 +202,11 @@ item_rockets::Touch(entity eToucher)
if (eToucher.classname == "player") {
player pl = (player)eToucher;
if (pl.ammo_rockets < MAX_A_ROCKETS) {
pl.ammo_rockets = bound(0, pl.ammo_rockets + 6, MAX_A_ROCKETS);
if (HasSpawnFlags(1))
pl.ammo_rockets = bound(0, pl.ammo_rockets + 10, MAX_A_ROCKETS);
else
pl.ammo_rockets = bound(0, pl.ammo_rockets + 5, MAX_A_ROCKETS);
item_ammo::Touch(eToucher);
}
}
@ -199,13 +216,12 @@ item_rockets::Touch(entity eToucher)
/*QUAKED item_cells (0 0 0.8) (-16 -16 0) (16 16 32)
HALF-LIFE (1998) ENTITY
DEATHMATCH CLASSIC (1999) ENTITY
Ammo for the .357 Magnum Revolver.
A single ammo_cells will provide 6 bullets.
Cells for the Lightning Gun
-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------
model="models/w_357ammobox.mdl"
model="models/w_batteryl.mdl"
*/
class item_cells:item_ammo
@ -218,6 +234,7 @@ void
item_cells::item_cells(void)
{
model = "models/w_battery.mdl";
noise = "models/w_batteryl.mdl";
}
void
@ -229,7 +246,11 @@ item_cells::Touch(entity eToucher)
if (eToucher.classname == "player") {
player pl = (player)eToucher;
if (pl.ammo_cells < MAX_A_CELLS) {
pl.ammo_cells = bound(0, pl.ammo_cells + 6, MAX_A_CELLS);
if (HasSpawnFlags(1))
pl.ammo_cells = bound(0, pl.ammo_cells + 12, MAX_A_CELLS);
else
pl.ammo_cells = bound(0, pl.ammo_cells + 6, MAX_A_CELLS);
item_ammo::Touch(eToucher);
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -16,12 +16,7 @@ armor_red.pickup
ammo.pickup
{
}
ammo.respawn
{
sample weapons/lock4.wav
}
item_health_rotten.pickup