From: bones_was_here Date: Thu, 27 Aug 2020 20:05:37 +0000 (+1000) Subject: Add function to get ammo consumption of primary fire mode X-Git-Tag: xonotic-v0.8.5~352^2~40 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a78be73a3b6007629dde4edb7081551f26e778cc;p=xonotic%2Fxonotic-data.pk3dir.git Add function to get ammo consumption of primary fire mode --- diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index bb4ae216a..6b675468c 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -237,6 +237,22 @@ string GetAmmoName(int ammotype) } } +#ifdef SVQC +int GetAmmoConsumptionPrimary(string netname) +// Returns ammo consumed per shot by the primary/default fire mode +{ + switch (netname) + { + case "arc": return cvar("g_balance_arc_beam_ammo"); + case "devastator": return cvar("g_balance_devastator_ammo"); + case "machinegun": return cvar("g_balance_machinegun_sustained_ammo"); + case "minelayer": return cvar("g_balance_minelayer_ammo"); + case "seeker": return cvar("g_balance_seeker_tag_ammo"); + default: return cvar(strcat("g_balance_", netname, "_primary_ammo")); + } +} +#endif + #ifdef CSQC int GetAmmoTypeFromNum(int i) { diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 67f646cbe..d072dd915 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -231,6 +231,10 @@ string GetAmmoPicture(int ammotype); string GetAmmoName(int ammotype); +#ifdef SVQC +int GetAmmoConsumptionPrimary(string netname); +#endif + #ifdef CSQC int GetAmmoTypeFromNum(int i); int GetAmmoStat(int ammotype); diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index 8ade74aa4..ec9952fff 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -111,19 +111,8 @@ void weapon_defaultspawnfunc(entity this, Weapon wpn) { int ammo = 0; if (this.count > 0) - { - 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; - } + ammo = this.count * GetAmmoConsumptionPrimary(wpn.netname); + // WEAPONTODO: magazines of MG, rifle and OK weapons are unaccounted for else { switch (wpn.ammo_type)