From 15760ac4bc969993cc32074d98ee122e39ee123c Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Wed, 26 Aug 2020 09:14:35 +1000 Subject: [PATCH] Support count field on weapon pickups, fix 0 ammo with target_give and no count set on weapon ent --- qcsrc/server/compat/quake3.qc | 16 +++++++-------- qcsrc/server/weapons/spawning.qc | 34 +++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index a68cc8a33..5a9d31d86 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -201,35 +201,35 @@ void target_give_init(entity this) IL_EACH(g_items, it.targetname == this.target, { if (it.classname == "weapon_devastator") { - SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO + this.ammo_rockets = it.ammo_rockets; this.netname = cons(this.netname, "devastator"); } else if (it.classname == "weapon_vortex") { - SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO + this.ammo_cells = it.ammo_cells; this.netname = cons(this.netname, "vortex"); } else if (it.classname == "weapon_electro") { - SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO + this.ammo_cells = it.ammo_cells; this.netname = cons(this.netname, "electro"); } else if (it.classname == "weapon_hagar") { - SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO + this.ammo_rockets = it.ammo_rockets; this.netname = cons(this.netname, "hagar"); } else if (it.classname == "weapon_crylink") { - SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO + this.ammo_cells = it.ammo_cells; this.netname = cons(this.netname, "crylink"); } else if (it.classname == "weapon_mortar") { - SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO + this.ammo_rockets = it.ammo_rockets; this.netname = cons(this.netname, "mortar"); } else if (it.classname == "weapon_shotgun") { - SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO + this.ammo_shells = it.ammo_shells; this.netname = cons(this.netname, "shotgun"); } else if (it.classname == "weapon_machinegun") { - SetResourceExplicit(this, RES_BULLETS, GetResource(this, RES_BULLETS) + it.count * WEP_CVAR(machinegun, burst_ammo)); // WEAPONTODO + this.ammo_nails = it.ammo_nails; this.netname = cons(this.netname, "machinegun"); } else if (it.classname == "item_armor_mega") diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index 63bc865e2..8ade74aa4 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -109,15 +109,35 @@ void weapon_defaultspawnfunc(entity this, Weapon wpn) // if we don't already have ammo, give us some ammo if ((wpn.ammo_type != RES_NONE) && !GetResource(this, wpn.ammo_type)) { - switch (wpn.ammo_type) + int ammo = 0; + if (this.count > 0) { - case RES_SHELLS: SetResource(this, wpn.ammo_type, cvar("g_pickup_shells_weapon")); break; - case RES_BULLETS: SetResource(this, wpn.ammo_type, cvar("g_pickup_nails_weapon")); break; - case RES_ROCKETS: SetResource(this, wpn.ammo_type, cvar("g_pickup_rockets_weapon")); break; - case RES_CELLS: SetResource(this, wpn.ammo_type, cvar("g_pickup_cells_weapon")); break; - case RES_PLASMA: SetResource(this, wpn.ammo_type, cvar("g_pickup_plasma_weapon")); break; - case RES_FUEL: SetResource(this, wpn.ammo_type, cvar("g_pickup_fuel_weapon")); break; + switch (wpn.netname) + { + case "arc": ammo = cvar("g_balance_arc_beam_ammo"); break; + case "devastator": ammo = cvar("g_balance_devastator_ammo"); break; + case "machinegun": ammo = cvar("g_balance_machinegun_sustained_ammo"); break; + case "minelayer": ammo = cvar("g_balance_minelayer_ammo"); break; + case "seeker": ammo = cvar("g_balance_seeker_tag_ammo"); break; + default: ammo = cvar(strcat("g_balance_", wpn.netname, "_primary_ammo")); + } + + ammo *= this.count; } + else + { + switch (wpn.ammo_type) + { + case RES_SHELLS: ammo = cvar("g_pickup_shells_weapon"); break; + case RES_BULLETS: ammo = cvar("g_pickup_nails_weapon"); break; + case RES_ROCKETS: ammo = cvar("g_pickup_rockets_weapon"); break; + case RES_CELLS: ammo = cvar("g_pickup_cells_weapon"); break; + case RES_PLASMA: ammo = cvar("g_pickup_plasma_weapon"); break; + case RES_FUEL: ammo = cvar("g_pickup_fuel_weapon"); break; + } + } + + SetResource(this, wpn.ammo_type, ammo); } #if 0 // WEAPONTODO -- 2.39.2