Added ammo culling for Half-Life

This commit is contained in:
Marco Cawthorne 2019-09-15 23:55:18 +02:00
parent 305206cbaa
commit 8985a8f373
26 changed files with 160 additions and 56 deletions

View File

@ -173,7 +173,7 @@ float player::predraw(void)
makevectors(ang);
traceline(src, src + (v_forward * 8096), FALSE, self);
if (serverkeyfloat("*bspversion") == 30) {
dynamiclight_add(trace_endpos + (v_forward * -2), 128, [1,1,1]);
} else {

View File

@ -224,7 +224,7 @@ void View_PostDraw(void)
// Take away alpha once it has drawn fully at least once
if (eMuzzleflash.alpha > 0.0f) {
eMuzzleflash.alpha -= (clframetime * 16);
eMuzzleflash.alpha -= (clframetime * 16);
}
}

View File

@ -34,7 +34,7 @@ void cr_btncancel_start(void)
}
void menu_chatrooms_init(void)
{
{
fn_chatrooms = spawn(CWidget);
cr_btnJoin = spawn(CMainButton);
cr_btnJoin.SetImage(BTN_JOIN);

View File

@ -14,6 +14,11 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void weaponbox_spawn(player temp)
{
}
var int autocvar_sv_networkeverything = FALSE;
void

View File

@ -48,7 +48,7 @@ monster_human_unarmed.cpp
../valve/item_suit.cpp
../valve/item_healthkit.cpp
../valve/item_battery.cpp
../valve/item_weaponbox.cpp
../valve/world_items.cpp
../valve/ammo.cpp
../../shared/rewolf/weapons.c

View File

@ -16,6 +16,11 @@
var int autocvar_sv_networkeverything = FALSE;
void weaponbox_spawn(player temp)
{
}
void
Game_ClientConnect(void)
{

View File

@ -50,7 +50,6 @@
../../shared/tfc/w_umbrella.c
../../shared/tfc/w_wrench.c
../valve/items.cpp
../valve/item_weaponbox.cpp
../valve/item_healthkit.cpp
info_tfgoal.cpp
item_tfgoal.cpp

View File

@ -33,6 +33,7 @@ Game_ClientConnect(void)
CBaseEntity caw = (CBaseEntity)a;
caw.Respawn();
}
Nodes_Init();
}
}
@ -53,7 +54,7 @@ Game_ClientDisconnect(void)
void
Game_ClientKill(void)
{
Damage_Apply(self, self, self.health, self.origin, TRUE);
Damage_Apply(self, self, self.health, self.origin, TRUE);
}
void
@ -176,6 +177,27 @@ Game_DecodeChangeParms(void)
pl.velocity[2] = parm9;
pl.g_items = parm10;
pl.activeweapon = parm11;
pl.ammo_9mm = parm12;
pl.ammo_357 = parm13;
pl.ammo_buckshot = parm14;
pl.ammo_m203_grenade = parm15;
pl.ammo_bolt = parm16;
pl.ammo_rocket = parm17;
pl.ammo_uranium = parm18;
pl.ammo_handgrenade = parm19;
pl.ammo_satchel = parm20;
pl.ammo_tripmine = parm21;
pl.ammo_snark = parm22;
pl.ammo_hornet = parm23;
pl.glock_mag = parm24;
pl.mp5_mag = parm25;
pl.python_mag = parm26;
pl.shotgun_mag = parm27;
pl.crossbow_mag = parm28;
pl.rpg_mag = parm29;
pl.satchel_chg = parm30;
}
void
@ -193,6 +215,27 @@ Game_SetChangeParms(void)
parm9 = pl.velocity[2];
parm10 = pl.g_items;
parm11 = pl.activeweapon;
parm12 = pl.ammo_9mm;
parm13 = pl.ammo_357;
parm14 = pl.ammo_buckshot;
parm15 = pl.ammo_m203_grenade;
parm16 = pl.ammo_bolt;
parm17 = pl.ammo_rocket;
parm18 = pl.ammo_uranium;
parm19 = pl.ammo_handgrenade;
parm20 = pl.ammo_satchel;
parm21 = pl.ammo_tripmine;
parm22 = pl.ammo_snark;
parm23 = pl.ammo_hornet;
parm24 = pl.glock_mag;
parm25 = pl.mp5_mag;
parm26 = pl.python_mag;
parm27 = pl.shotgun_mag;
parm28 = pl.crossbow_mag;
parm29 = pl.rpg_mag;
parm30 = pl.satchel_chg;
}
void
@ -242,7 +285,7 @@ Game_PutClientInServer(void)
if (cvar("sv_playerslots") == 1) {
Game_DecodeChangeParms();
if (startspot != "") {
if (startspot) {
setorigin(pl, Landmark_GetSpot());
} else {
spot = find(world, classname, "info_player_start");
@ -250,6 +293,7 @@ Game_PutClientInServer(void)
pl.angles = spot.angles;
pl.fixangle = TRUE;
}
Weapons_RefreshAmmo(pl);
} else {
spot = Spawn_SelectRandom("info_player_deathmatch");
setorigin(pl, spot.origin);

View File

@ -44,6 +44,7 @@ void item_weaponbox::touch(void)
player pl = (player)other;
Logging_Pickup(other, this, __NULL__);
sound(pl, CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM);
pl.ammo_9mm += ammo_9mm;
pl.ammo_357 += ammo_357;
pl.ammo_buckshot += ammo_buckshot;
@ -56,7 +57,24 @@ void item_weaponbox::touch(void)
pl.ammo_tripmine += ammo_tripmine;
pl.ammo_snark += ammo_snark;
pl.ammo_hornet += ammo_hornet;
/* cull */
pl.ammo_9mm = max(pl.ammo_9mm, MAX_A_9MM);
pl.ammo_357 = max(pl.ammo_357, MAX_A_357);
pl.ammo_buckshot = max(pl.ammo_buckshot, MAX_A_BUCKSHOT);
pl.ammo_m203_grenade = max(pl.ammo_m203_grenade, MAX_A_M203_GRENADE);
pl.ammo_bolt = max(pl.ammo_bolt, MAX_A_BOLT);
pl.ammo_rocket = max(pl.ammo_rocket, MAX_A_ROCKET);
pl.ammo_uranium = max(pl.ammo_uranium, MAX_A_URANIUM);
pl.ammo_handgrenade = max(pl.ammo_handgrenade, MAX_A_HANDGRENADE);
pl.ammo_satchel = max(pl.ammo_satchel, MAX_A_SATCHEL);
pl.ammo_tripmine = max(pl.ammo_tripmine, MAX_A_TRIPMINE);
pl.ammo_snark = max(pl.ammo_snark, MAX_A_SNARK);
pl.ammo_hornet = max(pl.ammo_hornet, MAX_A_HORNET);
pl.g_items |= weapon_items;
Weapons_RefreshAmmo(pl);
remove(this);
}

View File

@ -131,18 +131,18 @@ w_shockrifle_release(void)
return;
}
#ifdef CSQC
if (pl.a_ammo2 < 10) {
pl.a_ammo2 = bound(0, pl.a_ammo2 + 1, 10);
pl.w_idle_next = 0.35f;
}
#else
if (pl.ammo_shock < 10) {
pl.ammo_shock = bound(0, pl.ammo_shock + 1, 10);
Weapons_UpdateAmmo(pl, -1, pl.ammo_shock, -1);
pl.w_idle_next = 0.35f;
}
#endif
#ifdef CSQC
if (pl.a_ammo2 < 10) {
pl.a_ammo2 = bound(0, pl.a_ammo2 + 1, 10);
pl.w_idle_next = 0.35f;
}
#else
if (pl.ammo_shock < 10) {
pl.ammo_shock = bound(0, pl.ammo_shock + 1, 10);
Weapons_UpdateAmmo(pl, -1, pl.ammo_shock, -1);
pl.w_idle_next = 0.35f;
}
#endif
if (pl.w_idle_next > 0.0) {
return;

View File

@ -43,3 +43,16 @@ enum
WEAPON_SPORELAUNCHER,
WEAPON_SHOCKRIFLE
};
#define MAX_A_9MM 250
#define MAX_A_357 36
#define MAX_A_BUCKSHOT 125
#define MAX_A_M203_GRENADE 10
#define MAX_A_BOLT 50
#define MAX_A_ROCKET 5
#define MAX_A_URANIUM 100
#define MAX_A_HANDGRENADE 10
#define MAX_A_SATCHEL 5
#define MAX_A_TRIPMINE 10
#define MAX_A_SNARK 10
#define MAX_A_HORNET 8

View File

@ -36,3 +36,16 @@ enum
WEAPON_TRIPMINE,
WEAPON_SNARK
};
#define MAX_A_9MM 250
#define MAX_A_357 36
#define MAX_A_BUCKSHOT 125
#define MAX_A_M203_GRENADE 10
#define MAX_A_BOLT 50
#define MAX_A_ROCKET 5
#define MAX_A_URANIUM 100
#define MAX_A_HANDGRENADE 10
#define MAX_A_SATCHEL 5
#define MAX_A_TRIPMINE 10
#define MAX_A_SNARK 10
#define MAX_A_HORNET 8

View File

@ -79,8 +79,8 @@ w_crossbow_pickup(int new)
if (new) {
pl.crossbow_mag = 5;
} else {
if (pl.ammo_bolt < 50) {
pl.ammo_bolt = bound(0, pl.ammo_bolt + 5, 50);
if (pl.ammo_bolt < MAX_A_BOLT) {
pl.ammo_bolt = bound(0, pl.ammo_bolt + 5, MAX_A_BOLT);
} else {
return FALSE;
}

View File

@ -59,8 +59,8 @@ int w_egon_pickup(int new)
#ifdef SSQC
player pl = (player)self;
if (pl.ammo_uranium < 100) {
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, 100);
if (pl.ammo_uranium < MAX_A_URANIUM) {
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM);
} else {
return FALSE;
}

View File

@ -65,8 +65,8 @@ int w_gauss_pickup(int new)
#ifdef SSQC
player pl = (player)self;
if (pl.ammo_uranium < 100) {
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, 100);
if (pl.ammo_uranium < MAX_A_URANIUM) {
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM);
} else {
return FALSE;
}

View File

@ -71,8 +71,8 @@ w_glock_pickup(int new)
if (new) {
pl.glock_mag = 18;
} else {
if (pl.ammo_9mm < 250) {
pl.ammo_9mm = bound(0, pl.ammo_9mm + 18, 250);
if (pl.ammo_9mm < MAX_A_9MM) {
pl.ammo_9mm = bound(0, pl.ammo_9mm + 18, MAX_A_9MM);
} else {
return FALSE;
}

View File

@ -61,8 +61,8 @@ int w_handgrenade_pickup(int new)
#ifdef SSQC
player pl = (player)self;
if (pl.ammo_handgrenade < 10) {
pl.ammo_handgrenade = bound(0, pl.ammo_handgrenade + 1, 10);
if (pl.ammo_handgrenade < MAX_A_HANDGRENADE) {
pl.ammo_handgrenade = bound(0, pl.ammo_handgrenade + 1, MAX_A_HANDGRENADE);
} else {
return FALSE;
}

View File

@ -45,7 +45,7 @@ w_hornetgun_pickup(int new)
/* only pick it up once */
if (new) {
pl.ammo_hornet = 8;
pl.ammo_hornet = MAX_A_HORNET;
return TRUE;
}
#endif
@ -56,7 +56,7 @@ void
w_hornetgun_updateammo(player pl)
{
#ifdef SSQC
Weapons_UpdateAmmo(pl, __NULL__, pl.ammo_hornet, __NULL__);
Weapons_UpdateAmmo(pl, -1, pl.ammo_hornet, -1);
#endif
}
string w_hornetgun_wmodel(void)
@ -126,13 +126,13 @@ w_hornetgun_release(void)
}
#ifdef CSQC
if (pl.a_ammo2 < 8) {
pl.a_ammo2 = bound(0, pl.a_ammo2 + 1, 8);
if (pl.a_ammo2 < MAX_A_HORNET) {
pl.a_ammo2 = bound(0, pl.a_ammo2 + 1, MAX_A_HORNET);
pl.w_idle_next = 0.35f;
}
#else
if (pl.ammo_hornet < 8) {
pl.ammo_hornet = bound(0, pl.ammo_hornet + 1, 8);
if (pl.ammo_hornet < MAX_A_HORNET) {
pl.ammo_hornet = bound(0, pl.ammo_hornet + 1, MAX_A_HORNET);
Weapons_UpdateAmmo(pl, -1, pl.ammo_hornet, -1);
pl.w_idle_next = 0.35f;
return;
@ -235,12 +235,6 @@ w_hornetgun_secondary(void)
pl.w_idle_next = 1.0f;
}
void
w_hornetgun_reload(void)
{
}
void
w_hornetgun_crosshair(void)
{
@ -325,7 +319,7 @@ weapon_t w_hornetgun =
w_hornetgun_holster,
w_hornetgun_primary,
w_hornetgun_secondary,
w_hornetgun_reload,
__NULL__,
w_hornetgun_release,
w_hornetgun_crosshair,
w_hornetgun_precache,

View File

@ -50,8 +50,8 @@ w_mp5_pickup(int new)
if (new) {
pl.mp5_mag = 25;
} else {
if (pl.ammo_9mm < 250) {
pl.ammo_9mm = bound(0, pl.ammo_9mm + 25, 250);
if (pl.ammo_9mm < MAX_A_9MM) {
pl.ammo_9mm = bound(0, pl.ammo_9mm + 25, MAX_A_9MM);
} else {
return FALSE;
}

View File

@ -47,8 +47,8 @@ w_python_pickup(int new)
if (new) {
pl.python_mag = 6;
} else {
if (pl.ammo_357 < 36) {
pl.ammo_357 = bound(0, pl.ammo_357 + 6, 36);
if (pl.ammo_357 < MAX_A_357) {
pl.ammo_357 = bound(0, pl.ammo_357 + 6, MAX_A_357);
} else {
return FALSE;
}

View File

@ -64,8 +64,8 @@ int w_rpg_pickup(int new)
if (new) {
pl.rpg_mag = 1;
} else {
if (pl.ammo_rocket < 5) {
pl.ammo_rocket = bound(0, pl.ammo_rocket + 1, 5);
if (pl.ammo_rocket < MAX_A_ROCKET) {
pl.ammo_rocket = bound(0, pl.ammo_rocket + 1, MAX_A_ROCKET);
} else {
return FALSE;
}

View File

@ -62,8 +62,8 @@ int w_satchel_pickup(int new)
#ifdef SSQC
player pl = (player)self;
if (pl.ammo_satchel < 5) {
pl.ammo_satchel = bound(0, pl.ammo_satchel + 1, 5);
if (pl.ammo_satchel < MAX_A_SATCHEL) {
pl.ammo_satchel = bound(0, pl.ammo_satchel + 1, MAX_A_SATCHEL);
} else {
return FALSE;
}

View File

@ -73,8 +73,8 @@ int w_shotgun_pickup(int new)
if (new) {
pl.shotgun_mag = 8;
} else {
if (pl.ammo_buckshot < 125) {
pl.ammo_buckshot = bound(0, pl.ammo_buckshot + 8, 125);
if (pl.ammo_buckshot < MAX_A_BUCKSHOT) {
pl.ammo_buckshot = bound(0, pl.ammo_buckshot + 8, MAX_A_BUCKSHOT);
} else {
return FALSE;
}

View File

@ -29,8 +29,8 @@ int w_snark_pickup(int new)
#ifdef SSQC
player pl = (player)self;
if (pl.ammo_snark < 10) {
pl.ammo_snark = bound(0, pl.ammo_snark + 5, 10);
if (pl.ammo_snark < MAX_A_SNARK) {
pl.ammo_snark = bound(0, pl.ammo_snark + 5, MAX_A_SNARK);
} else {
return FALSE;
}

View File

@ -58,8 +58,8 @@ int w_tripmine_pickup(int new)
#ifdef SSQC
player pl = (player)self;
if (pl.ammo_tripmine < 10) {
pl.ammo_tripmine = bound(0, pl.ammo_tripmine + 1, 10);
if (pl.ammo_tripmine < MAX_A_TRIPMINE) {
pl.ammo_tripmine = bound(0, pl.ammo_tripmine + 1, MAX_A_TRIPMINE);
} else {
return FALSE;
}

View File

@ -33,3 +33,16 @@ enum
WEAPON_TRIPMINE,
WEAPON_SNARK
};
#define MAX_A_9MM 250
#define MAX_A_357 36
#define MAX_A_BUCKSHOT 125
#define MAX_A_M203_GRENADE 10
#define MAX_A_BOLT 50
#define MAX_A_ROCKET 5
#define MAX_A_URANIUM 100
#define MAX_A_HANDGRENADE 10
#define MAX_A_SATCHEL 5
#define MAX_A_TRIPMINE 10
#define MAX_A_SNARK 10
#define MAX_A_HORNET 8