From: Lyberta Date: Sat, 2 Sep 2017 09:24:49 +0000 (+0300) Subject: USR: Ported ammo. X-Git-Tag: xonotic-v0.8.5~2461^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7f6f1dc979173320c7ffe7dfe647a52686f447c2;p=xonotic%2Fxonotic-data.pk3dir.git USR: Ported ammo. --- diff --git a/qcsrc/client/hud/panel/ammo.qc b/qcsrc/client/hud/panel/ammo.qc index 9e8320452..0636f3f2e 100644 --- a/qcsrc/client/hud/panel/ammo.qc +++ b/qcsrc/client/hud/panel/ammo.qc @@ -21,10 +21,10 @@ void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector col void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time); // TODO: mutator -void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite) +void DrawAmmoItem(vector myPos, vector mySize, int ammoType, bool isCurrent, bool isInfinite) { TC(bool, isCurrent); TC(bool, isInfinite); - if(ammoType == ammo_none) + if(ammoType == RESOURCE_NONE) return; // Initialize variables @@ -32,7 +32,7 @@ void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bo int ammo; if(autocvar__hud_configure) { - isCurrent = (ammoType == ammo_rockets); // Rockets always current + isCurrent = (ammoType == RESOURCE_ROCKETS); // Rockets always current ammo = 60; } else @@ -184,14 +184,14 @@ void HUD_Ammo() { if(autocvar__hud_configure) { - DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false); + DrawAmmoItem(pos, ammo_size, RESOURCE_ROCKETS, true, false); } else { DrawAmmoItem( pos, ammo_size, - wep.ammo_field, + wep.ammo_type, true, infinite_ammo ); @@ -206,16 +206,16 @@ void HUD_Ammo() } else { - .int ammotype; + int ammotype; row = column = 0; for(i = 0; i < AMMO_COUNT; ++i) { - ammotype = GetAmmoFieldFromNum(i); + ammotype = GetAmmoTypeFromNum(i); DrawAmmoItem( pos + vec2(column * (ammo_size.x + offset.x), row * (ammo_size.y + offset.y)), ammo_size, ammotype, - (wep.ammo_field == ammotype), + (wep.ammo_type == ammotype), infinite_ammo ); diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc index a7c0ade00..cebd8f5d6 100644 --- a/qcsrc/client/hud/panel/weapons.qc +++ b/qcsrc/client/hud/panel/weapons.qc @@ -479,21 +479,21 @@ void HUD_Weapons() } // draw ammo status bar - if(!infinite_ammo && autocvar_hud_panel_weapons_ammo && (it.ammo_field != ammo_none)) + if(!infinite_ammo && autocvar_hud_panel_weapons_ammo && (it.ammo_type != RESOURCE_NONE)) { float ammo_full; - a = getstati(GetAmmoStat(it.ammo_field)); // how much ammo do we have? + a = getstati(GetAmmoStat(it.ammo_type)); // how much ammo do we have? if(a > 0) { - switch(it.ammo_field) + switch (it.ammo_type) { - case ammo_shells: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break; - case ammo_nails: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break; - case ammo_rockets: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break; - case ammo_cells: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break; - case ammo_plasma: ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma; break; - case ammo_fuel: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break; + case RESOURCE_SHELLS: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break; + case RESOURCE_BULLETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break; + case RESOURCE_ROCKETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break; + case RESOURCE_CELLS: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break; + case RESOURCE_PLASMA: ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma; break; + case RESOURCE_FUEL: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break; default: ammo_full = 60; } diff --git a/qcsrc/common/mutators/mutator/nix/sv_nix.qc b/qcsrc/common/mutators/mutator/nix/sv_nix.qc index 4de24a589..886740aed 100644 --- a/qcsrc/common/mutators/mutator/nix/sv_nix.qc +++ b/qcsrc/common/mutators/mutator/nix/sv_nix.qc @@ -142,26 +142,26 @@ void NIX_GiveCurrentWeapon(entity this) SetResourceAmount(this, RESOURCE_FUEL, 0); if(this.items & IT_UNLIMITED_WEAPON_AMMO) { - switch(e.ammo_field) + switch (e.ammo_type) { - case ammo_shells: SetResourceAmount(this, RESOURCE_SHELLS, autocvar_g_pickup_shells_max); break; - case ammo_nails: SetResourceAmount(this, RESOURCE_BULLETS, autocvar_g_pickup_nails_max); break; - case ammo_rockets: SetResourceAmount(this, RESOURCE_ROCKETS, autocvar_g_pickup_rockets_max); break; - case ammo_cells: SetResourceAmount(this, RESOURCE_CELLS, autocvar_g_pickup_cells_max); break; - case ammo_plasma: SetResourceAmount(this, RESOURCE_PLASMA, autocvar_g_pickup_plasma_max); break; - case ammo_fuel: SetResourceAmount(this, RESOURCE_FUEL, autocvar_g_pickup_fuel_max); break; + case RESOURCE_SHELLS: SetResourceAmount(this, RESOURCE_SHELLS, autocvar_g_pickup_shells_max); break; + case RESOURCE_BULLETS: SetResourceAmount(this, RESOURCE_BULLETS, autocvar_g_pickup_nails_max); break; + case RESOURCE_ROCKETS: SetResourceAmount(this, RESOURCE_ROCKETS, autocvar_g_pickup_rockets_max); break; + case RESOURCE_CELLS: SetResourceAmount(this, RESOURCE_CELLS, autocvar_g_pickup_cells_max); break; + case RESOURCE_PLASMA: SetResourceAmount(this, RESOURCE_PLASMA, autocvar_g_pickup_plasma_max); break; + case RESOURCE_FUEL: SetResourceAmount(this, RESOURCE_FUEL, autocvar_g_pickup_fuel_max); break; } } else { - switch(e.ammo_field) + switch (e.ammo_type) { - case ammo_shells: SetResourceAmount(this, RESOURCE_SHELLS, autocvar_g_balance_nix_ammo_shells); break; - case ammo_nails: SetResourceAmount(this, RESOURCE_BULLETS, autocvar_g_balance_nix_ammo_nails); break; - case ammo_rockets: SetResourceAmount(this, RESOURCE_ROCKETS, autocvar_g_balance_nix_ammo_rockets); break; - case ammo_cells: SetResourceAmount(this, RESOURCE_CELLS, autocvar_g_balance_nix_ammo_cells); break; - case ammo_plasma: SetResourceAmount(this, RESOURCE_PLASMA, autocvar_g_balance_nix_ammo_plasma); break; - case ammo_fuel: SetResourceAmount(this, RESOURCE_FUEL, autocvar_g_balance_nix_ammo_fuel); break; + case RESOURCE_SHELLS: SetResourceAmount(this, RESOURCE_SHELLS, autocvar_g_balance_nix_ammo_shells); break; + case RESOURCE_BULLETS: SetResourceAmount(this, RESOURCE_BULLETS, autocvar_g_balance_nix_ammo_nails); break; + case RESOURCE_ROCKETS: SetResourceAmount(this, RESOURCE_ROCKETS, autocvar_g_balance_nix_ammo_rockets); break; + case RESOURCE_CELLS: SetResourceAmount(this, RESOURCE_CELLS, autocvar_g_balance_nix_ammo_cells); break; + case RESOURCE_PLASMA: SetResourceAmount(this, RESOURCE_PLASMA, autocvar_g_balance_nix_ammo_plasma); break; + case RESOURCE_FUEL: SetResourceAmount(this, RESOURCE_FUEL, autocvar_g_balance_nix_ammo_fuel); break; } } @@ -207,14 +207,14 @@ void NIX_GiveCurrentWeapon(entity this) if(!(this.items & IT_UNLIMITED_WEAPON_AMMO) && time > this.nix_nextincr) { - switch(e.ammo_field) + switch (e.ammo_type) { - case ammo_shells: GiveResource(this, RESOURCE_SHELLS, autocvar_g_balance_nix_ammoincr_shells); break; - case ammo_nails: GiveResource(this, RESOURCE_BULLETS, autocvar_g_balance_nix_ammoincr_nails); break; - case ammo_rockets: GiveResource(this, RESOURCE_ROCKETS, autocvar_g_balance_nix_ammoincr_rockets); break; - case ammo_cells: GiveResource(this, RESOURCE_CELLS, autocvar_g_balance_nix_ammoincr_cells); break; - case ammo_plasma: GiveResource(this, RESOURCE_PLASMA, autocvar_g_balance_nix_ammoincr_plasma); break; - case ammo_fuel: GiveResource(this, RESOURCE_FUEL, autocvar_g_balance_nix_ammoincr_fuel); break; + case RESOURCE_SHELLS: GiveResource(this, RESOURCE_SHELLS, autocvar_g_balance_nix_ammoincr_shells); break; + case RESOURCE_BULLETS: GiveResource(this, RESOURCE_BULLETS, autocvar_g_balance_nix_ammoincr_nails); break; + case RESOURCE_ROCKETS: GiveResource(this, RESOURCE_ROCKETS, autocvar_g_balance_nix_ammoincr_rockets); break; + case RESOURCE_CELLS: GiveResource(this, RESOURCE_CELLS, autocvar_g_balance_nix_ammoincr_cells); break; + case RESOURCE_PLASMA: GiveResource(this, RESOURCE_PLASMA, autocvar_g_balance_nix_ammoincr_plasma); break; + case RESOURCE_FUEL: GiveResource(this, RESOURCE_FUEL, autocvar_g_balance_nix_ammoincr_fuel); break; } this.nix_nextincr = time + autocvar_g_balance_nix_incrtime; diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index caf96a67b..41327956f 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -83,7 +83,7 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(hmg, ammo); if(autocvar_g_balance_hmg_reload_ammo) ammo_amount += actor.(weaponentity).(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo); @@ -93,7 +93,7 @@ METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entit METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(hmg, ammo); if(autocvar_g_balance_hmg_reload_ammo) ammo_amount += actor.(weaponentity).(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo); diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qh b/qcsrc/common/mutators/mutator/overkill/hmg.qh index 99eb4c809..07b31ea3c 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qh +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qh @@ -1,7 +1,7 @@ #pragma once CLASS(HeavyMachineGun, Weapon) -/* ammotype */ ATTRIB(HeavyMachineGun, ammo_field, .int, ammo_nails); +/* ammotype */ ATTRIB(HeavyMachineGun, ammo_type, int, RESOURCE_BULLETS); /* impulse */ ATTRIB(HeavyMachineGun, impulse, int, 3); /* flags */ ATTRIB(HeavyMachineGun, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_SUPERWEAPON); /* rating */ ATTRIB(HeavyMachineGun, bot_pickupbasevalue, float, 10000); diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index e9a5ce2c3..f901d1159 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -140,7 +140,7 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(rpc, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo); return ammo_amount; } diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qh b/qcsrc/common/mutators/mutator/overkill/rpc.qh index 417e9a661..560f7f4fa 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qh +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qh @@ -1,7 +1,7 @@ #pragma once CLASS(RocketPropelledChainsaw, Weapon) -/* ammotype */ ATTRIB(RocketPropelledChainsaw, ammo_field, .int, ammo_rockets); +/* ammotype */ ATTRIB(RocketPropelledChainsaw, ammo_type, int, RESOURCE_ROCKETS); /* impulse */ ATTRIB(RocketPropelledChainsaw, impulse, int, 9); /* flags */ ATTRIB(RocketPropelledChainsaw, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH | WEP_FLAG_SUPERWEAPON); /* rating */ ATTRIB(RocketPropelledChainsaw, bot_pickupbasevalue, float, 10000); diff --git a/qcsrc/common/resources.qh b/qcsrc/common/resources.qh new file mode 100644 index 000000000..a562292b4 --- /dev/null +++ b/qcsrc/common/resources.qh @@ -0,0 +1,20 @@ +#pragma once + +/// \file +/// \brief Header file that describes resource types. +/// \author Lyberta +/// \copyright GNU GPLv2 or any later version. + +/// \brief Describes the available resource types. +enum +{ + RESOURCE_NONE, ///< Indicates the lack of resource. Use with caution. + RESOURCE_HEALTH, ///< Health. + RESOURCE_ARMOR, ///< Armor. + RESOURCE_SHELLS, ///< Shells (used by shotgun). + RESOURCE_BULLETS, ///< Bullets (used by machinegun, rifle, HMG) + RESOURCE_ROCKETS, ///< Rockets (used by mortar, hagar, devastator, etc). + RESOURCE_CELLS, ///< Cells (used by electro, crylink, vortex, etc) + RESOURCE_PLASMA, ///< Plasma (unused). + RESOURCE_FUEL ///< Fuel (used by jetpack). +}; diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 4fc2e3821..a1b0ced69 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -1032,14 +1032,14 @@ float ammo_pickupevalfunc(entity player, entity item) if(!(player.weapons & (it.m_wepset))) continue; - switch(it.ammo_field) + switch(it.ammo_type) { - case ammo_shells: need_shells = true; break; - case ammo_nails: need_nails = true; break; - case ammo_rockets: need_rockets = true; break; - case ammo_cells: need_cells = true; break; - case ammo_plasma: need_plasma = true; break; - case ammo_fuel: need_fuel = true; break; + case RESOURCE_SHELLS: need_shells = true; break; + case RESOURCE_BULLETS: need_nails = true; break; + case RESOURCE_ROCKETS: need_rockets = true; break; + case RESOURCE_CELLS: need_cells = true; break; + case RESOURCE_PLASMA: need_plasma = true; break; + case RESOURCE_FUEL: need_fuel = true; break; } }); rating = item.bot_pickupbasevalue; diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 6605f00c2..e430ec2e7 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -210,48 +210,48 @@ void W_RandomWeapons(entity e, int n) e.weapons = result; } -string GetAmmoPicture(.int ammotype) +string GetAmmoPicture(int ammotype) { switch (ammotype) { - case ammo_shells: return ITEM_Shells.m_icon; - case ammo_nails: return ITEM_Bullets.m_icon; - case ammo_rockets: return ITEM_Rockets.m_icon; - case ammo_cells: return ITEM_Cells.m_icon; - case ammo_plasma: return ITEM_Plasma.m_icon; - case ammo_fuel: return ITEM_JetpackFuel.m_icon; + case RESOURCE_SHELLS: return ITEM_Shells.m_icon; + case RESOURCE_BULLETS: return ITEM_Bullets.m_icon; + case RESOURCE_ROCKETS: return ITEM_Rockets.m_icon; + case RESOURCE_CELLS: return ITEM_Cells.m_icon; + case RESOURCE_PLASMA: return ITEM_Plasma.m_icon; + case RESOURCE_FUEL: return ITEM_JetpackFuel.m_icon; default: return ""; // wtf, no ammo type? } } #ifdef CSQC - .int GetAmmoFieldFromNum(int i) +int GetAmmoTypeFromNum(int i) +{ + switch (i) { - switch (i) - { - case 0: return ammo_shells; - case 1: return ammo_nails; - case 2: return ammo_rockets; - case 3: return ammo_cells; - case 4: return ammo_plasma; - case 5: return ammo_fuel; - default: return ammo_none; - } + case 0: return RESOURCE_SHELLS; + case 1: return RESOURCE_BULLETS; + case 2: return RESOURCE_ROCKETS; + case 3: return RESOURCE_CELLS; + case 4: return RESOURCE_PLASMA; + case 5: return RESOURCE_FUEL; + default: return RESOURCE_NONE; } +} - int GetAmmoStat(.int ammotype) +int GetAmmoStat(int ammotype) +{ + switch (ammotype) { - switch (ammotype) - { - case ammo_shells: return STAT_SHELLS; - case ammo_nails: return STAT_NAILS; - case ammo_rockets: return STAT_ROCKETS; - case ammo_cells: return STAT_CELLS; - case ammo_plasma: return STAT_PLASMA.m_id; - case ammo_fuel: return STAT_FUEL.m_id; - default: return -1; - } + case RESOURCE_SHELLS: return STAT_SHELLS; + case RESOURCE_BULLETS: return STAT_NAILS; + case RESOURCE_ROCKETS: return STAT_ROCKETS; + case RESOURCE_CELLS: return STAT_CELLS; + case RESOURCE_PLASMA: return STAT_PLASMA.m_id; + case RESOURCE_FUEL: return STAT_FUEL.m_id; + default: return -1; } +} #endif string W_Sound(string w_snd) diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 4be22446b..71d7c3db3 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -59,8 +60,8 @@ CLASS(Weapon, Object) ATTRIB(Weapon, m_id, int, 0); /** A: WEPSET_id : WEPSET_... */ ATTRIB(Weapon, weapons, WepSet, '0 0 0'); - /** M: ammotype : main ammo field */ - ATTRIB(Weapon, ammo_field, .int, ammo_none); + /** M: ammotype : main ammo type */ + ATTRIB(Weapon, ammo_type, int, RESOURCE_NONE); /** M: impulse : weapon impulse */ ATTRIB(Weapon, impulse, int, -1); /** M: flags : WEPSPAWNFLAG_... combined */ @@ -213,11 +214,11 @@ string W_FixWeaponOrder_AllowIncomplete(entity this, string order); string W_FixWeaponOrder_ForceComplete(string order); void W_RandomWeapons(entity e, int n); -string GetAmmoPicture(.int ammotype); +string GetAmmoPicture(int ammotype); #ifdef CSQC -.int GetAmmoFieldFromNum(int i); -int GetAmmoStat(.int ammotype); +int GetAmmoTypeFromNum(int i); +int GetAmmoStat(int ammotype); #endif string W_Sound(string w_snd); diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 47b92cc9f..5b982219e 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -258,8 +258,8 @@ void W_Arc_Beam_Think(entity this) if(rootammo) { - coefficient = min(coefficient, own.(thiswep.ammo_field) / rootammo); - own.(thiswep.ammo_field) = max(0, own.(thiswep.ammo_field) - (rootammo * frametime)); + coefficient = min(coefficient, GetResourceAmount(own, thiswep.ammo_type) / rootammo); + SetResourceAmount(own, thiswep.ammo_type, max(0, GetResourceAmount(own, thiswep.ammo_type) - (rootammo * frametime))); } } float heat_speed = burst ? WEP_CVAR(arc, burst_heat) : WEP_CVAR(arc, beam_heat); @@ -697,19 +697,19 @@ METHOD(Arc, wr_init, void(entity thiswep)) } METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - return ((!WEP_CVAR(arc, beam_ammo)) || (actor.(thiswep.ammo_field) > 0)); + return ((!WEP_CVAR(arc, beam_ammo)) || (GetResourceAmount(actor, thiswep.ammo_type) > 0)); } METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { if(WEP_CVAR(arc, bolt)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(arc, bolt_ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(arc, bolt_ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo); return ammo_amount; } else return WEP_CVAR(arc, overheat_max) > 0 && - ((!WEP_CVAR(arc, burst_ammo)) || (actor.(thiswep.ammo_field) > 0)); + ((!WEP_CVAR(arc, burst_ammo)) || (GetResourceAmount(actor, thiswep.ammo_type) > 0)); } METHOD(Arc, wr_killmessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/arc.qh b/qcsrc/common/weapons/weapon/arc.qh index 01c4f2f6a..abd993311 100644 --- a/qcsrc/common/weapons/weapon/arc.qh +++ b/qcsrc/common/weapons/weapon/arc.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Arc, Weapon) -/* ammotype */ ATTRIB(Arc, ammo_field, .int, ammo_cells); +/* ammotype */ ATTRIB(Arc, ammo_type, int, RESOURCE_CELLS); /* impulse */ ATTRIB(Arc, impulse, int, 3); /* flags */ ATTRIB(Arc, spawnflags, int, WEP_TYPE_HITSCAN); /* rating */ ATTRIB(Arc, bot_pickupbasevalue, float, 8000); diff --git a/qcsrc/common/weapons/weapon/blaster.qh b/qcsrc/common/weapons/weapon/blaster.qh index 990add96b..972dcd003 100644 --- a/qcsrc/common/weapons/weapon/blaster.qh +++ b/qcsrc/common/weapons/weapon/blaster.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Blaster, Weapon) -/* ammotype */ //ATTRIB(Blaster, ammo_field, .int, ammo_none); +/* ammotype */ //ATTRIB(Blaster, ammo_type, int, RESOURCE_NONE); /* impulse */ ATTRIB(Blaster, impulse, int, 1); /* flags */ ATTRIB(Blaster, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); /* rating */ ATTRIB(Blaster, bot_pickupbasevalue, float, 0); diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 82b470376..2e2cb519a 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -582,7 +582,7 @@ METHOD(Crylink, wr_checkammo1, bool(entity thiswep, entity actor, .entity weapon if(actor.(weaponentity).crylink_lastgroup && actor.(weaponentity).crylink_waitrelease) return true; - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(crylink, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo); return ammo_amount; } @@ -592,7 +592,7 @@ METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapon if(actor.(weaponentity).crylink_lastgroup && actor.(weaponentity).crylink_waitrelease) return true; - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(crylink, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo); return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/crylink.qh b/qcsrc/common/weapons/weapon/crylink.qh index 326fdf15b..e686cfa94 100644 --- a/qcsrc/common/weapons/weapon/crylink.qh +++ b/qcsrc/common/weapons/weapon/crylink.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Crylink, Weapon) -/* ammotype */ ATTRIB(Crylink, ammo_field, .int, ammo_cells); +/* ammotype */ ATTRIB(Crylink, ammo_type, int, RESOURCE_CELLS); /* impulse */ ATTRIB(Crylink, impulse, int, 6); /* flags */ ATTRIB(Crylink, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH | WEP_FLAG_CANCLIMB | WEP_FLAG_NODUAL); /* rating */ ATTRIB(Crylink, bot_pickupbasevalue, float, 6000); diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 88d50f80a..f4ef7ad32 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -47,7 +47,7 @@ void W_Devastator_Explode(entity this, entity directhitentity) .entity weaponentity = this.weaponentity_fld; if(this.realowner.(weaponentity).m_weapon == thiswep) { - if(this.realowner.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo)) + if(GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo)) if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO)) { this.realowner.cnt = WEP_DEVASTATOR.m_id; @@ -139,7 +139,7 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity) Weapon thiswep = WEP_DEVASTATOR; if(this.realowner.(weaponentity).m_weapon == thiswep) { - if(this.realowner.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo)) + if(GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo)) if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO)) { this.realowner.cnt = WEP_DEVASTATOR.m_id; @@ -478,10 +478,10 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity wea ammo_amount = false; if(WEP_CVAR(devastator, reload_ammo)) { - if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo)) + if(GetResourceAmount(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo)) ammo_amount = true; } - else if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo)) + else if(GetResourceAmount(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo)) ammo_amount = true; return !ammo_amount; } @@ -489,18 +489,18 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity wea #if 0 if(actor.rl_release == 0) { - LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo)); + LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE", actor.rl_release, GetResourceAmount(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo)); return true; } else { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); - LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE")); + LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s", actor.rl_release, GetResourceAmount(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE")); return ammo_amount; } #else - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); return ammo_amount; #endif diff --git a/qcsrc/common/weapons/weapon/devastator.qh b/qcsrc/common/weapons/weapon/devastator.qh index dd68ccf58..9c4197511 100644 --- a/qcsrc/common/weapons/weapon/devastator.qh +++ b/qcsrc/common/weapons/weapon/devastator.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Devastator, Weapon) -/* ammotype */ ATTRIB(Devastator, ammo_field, .int, ammo_rockets); +/* ammotype */ ATTRIB(Devastator, ammo_type, int, RESOURCE_ROCKETS); /* impulse */ ATTRIB(Devastator, impulse, int, 9); /* flags */ ATTRIB(Devastator, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH | WEP_FLAG_NODUAL); /* rating */ ATTRIB(Devastator, bot_pickupbasevalue, float, 8000); diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index f2fb14614..8b3946e46 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -484,7 +484,7 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit } METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo); return ammo_amount; } @@ -493,12 +493,12 @@ METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapon float ammo_amount; if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false. { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); } else { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo); } return ammo_amount; diff --git a/qcsrc/common/weapons/weapon/electro.qh b/qcsrc/common/weapons/weapon/electro.qh index 32b45c692..07c967c49 100644 --- a/qcsrc/common/weapons/weapon/electro.qh +++ b/qcsrc/common/weapons/weapon/electro.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Electro, Weapon) -/* ammotype */ ATTRIB(Electro, ammo_field, .int, ammo_cells); +/* ammotype */ ATTRIB(Electro, ammo_type, int, RESOURCE_CELLS); /* impulse */ ATTRIB(Electro, impulse, int, 5); /* flags */ ATTRIB(Electro, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); /* rating */ ATTRIB(Electro, bot_pickupbasevalue, float, 5000); diff --git a/qcsrc/common/weapons/weapon/fireball.qh b/qcsrc/common/weapons/weapon/fireball.qh index d6d8f017e..e973d2884 100644 --- a/qcsrc/common/weapons/weapon/fireball.qh +++ b/qcsrc/common/weapons/weapon/fireball.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Fireball, Weapon) -/* ammotype */ //ATTRIB(Fireball, ammo_field, .int, ammo_none); +/* ammotype */ //ATTRIB(Fireball, ammo_type, int, RESOURCE_NONE); /* impulse */ ATTRIB(Fireball, impulse, int, 9); /* flags */ ATTRIB(Fireball, spawnflags, int, WEP_FLAG_SUPERWEAPON | WEP_TYPE_SPLASH | WEP_FLAG_NODUAL); /* rating */ ATTRIB(Fireball, bot_pickupbasevalue, float, 5000); diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 5272e6060..be95d5dde 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -270,7 +270,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity) else if(autocvar_g_balance_hagar_reload_ammo) enough_ammo = actor.(weaponentity).(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo); else - enough_ammo = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo); + enough_ammo = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hagar, ammo); bool stopped = loaded || !enough_ammo; @@ -448,13 +448,13 @@ METHOD(Hagar, wr_setup, void(entity thiswep, entity actor, .entity weaponentity) } METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hagar, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo); return ammo_amount; } METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hagar, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo); return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/hagar.qh b/qcsrc/common/weapons/weapon/hagar.qh index 7dfd3c631..24c700cc8 100644 --- a/qcsrc/common/weapons/weapon/hagar.qh +++ b/qcsrc/common/weapons/weapon/hagar.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Hagar, Weapon) -/* ammotype */ ATTRIB(Hagar, ammo_field, .int, ammo_rockets); +/* ammotype */ ATTRIB(Hagar, ammo_type, int, RESOURCE_ROCKETS); /* impulse */ ATTRIB(Hagar, impulse, int, 8); /* flags */ ATTRIB(Hagar, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); /* rating */ ATTRIB(Hagar, bot_pickupbasevalue, float, 6000); diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 0193270a6..2fb16d6e3 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -189,13 +189,13 @@ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, } METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hlac, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo); return ammo_amount; } METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hlac, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo); return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/hlac.qh b/qcsrc/common/weapons/weapon/hlac.qh index f965abcbf..4664e54d9 100644 --- a/qcsrc/common/weapons/weapon/hlac.qh +++ b/qcsrc/common/weapons/weapon/hlac.qh @@ -1,7 +1,7 @@ #pragma once CLASS(HLAC, Weapon) -/* ammotype */ ATTRIB(HLAC, ammo_field, .int, ammo_cells); +/* ammotype */ ATTRIB(HLAC, ammo_type, int, RESOURCE_CELLS); /* impulse */ ATTRIB(HLAC, impulse, int, 6); /* flags */ ATTRIB(HLAC, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH); /* rating */ ATTRIB(HLAC, bot_pickupbasevalue, float, 4000); diff --git a/qcsrc/common/weapons/weapon/hook.qh b/qcsrc/common/weapons/weapon/hook.qh index f67db3d00..4988323fd 100644 --- a/qcsrc/common/weapons/weapon/hook.qh +++ b/qcsrc/common/weapons/weapon/hook.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Hook, Weapon) -/* ammotype */ ATTRIB(Hook, ammo_field, .int, ammo_fuel); +/* ammotype */ ATTRIB(Hook, ammo_type, int, RESOURCE_FUEL); /* impulse */ ATTRIB(Hook, impulse, int, 0); /* flags */ ATTRIB(Hook, spawnflags, int, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); /* rating */ ATTRIB(Hook, bot_pickupbasevalue, float, 0); diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index c4f3b9bb3..8d96c4b10 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -258,9 +258,9 @@ METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity wea { float ammo_amount; if(WEP_CVAR(machinegun, mode) == 1) - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, sustained_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, sustained_ammo); else - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo); if(WEP_CVAR(machinegun, reload_ammo)) { @@ -275,9 +275,9 @@ METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity wea { float ammo_amount; if(WEP_CVAR(machinegun, mode) == 1) - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, burst_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, burst_ammo); else - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo); if(WEP_CVAR(machinegun, reload_ammo)) { diff --git a/qcsrc/common/weapons/weapon/machinegun.qh b/qcsrc/common/weapons/weapon/machinegun.qh index 5cd912a2a..2f0974971 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qh +++ b/qcsrc/common/weapons/weapon/machinegun.qh @@ -1,7 +1,7 @@ #pragma once CLASS(MachineGun, Weapon) -/* ammotype */ ATTRIB(MachineGun, ammo_field, .int, ammo_nails); +/* ammotype */ ATTRIB(MachineGun, ammo_type, int, RESOURCE_BULLETS); /* impulse */ ATTRIB(MachineGun, impulse, int, 3); /* flags */ ATTRIB(MachineGun, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_PENETRATEWALLS); /* rating */ ATTRIB(MachineGun, bot_pickupbasevalue, float, 7000); diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 463f5109b..99b00a814 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -453,7 +453,7 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(minelayer, ammo)) // forced reload { // not if we're holding the minelayer without enough ammo, but can detonate existing mines - if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) { + if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && GetResourceAmount(actor, thiswep.ammo_type) < WEP_CVAR(minelayer, ammo))) { thiswep.wr_reload(thiswep, actor, weaponentity); } } @@ -478,7 +478,7 @@ METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weap // actually do // don't switch while placing a mine //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_MINE_LAYER) //{ - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo); return ammo_amount; //} diff --git a/qcsrc/common/weapons/weapon/minelayer.qh b/qcsrc/common/weapons/weapon/minelayer.qh index e867db8d3..f113e6439 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qh +++ b/qcsrc/common/weapons/weapon/minelayer.qh @@ -1,7 +1,7 @@ #pragma once CLASS(MineLayer, Weapon) -/* ammotype */ ATTRIB(MineLayer, ammo_field, .int, ammo_rockets); +/* ammotype */ ATTRIB(MineLayer, ammo_type, int, RESOURCE_ROCKETS); /* impulse */ ATTRIB(MineLayer, impulse, int, 4); /* flags */ ATTRIB(MineLayer, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH); /* rating */ ATTRIB(MineLayer, bot_pickupbasevalue, float, 7000); diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 186d1f139..6a3d2e125 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -325,13 +325,13 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity } METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(mortar, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo); return ammo_amount; } METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(mortar, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo); return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/mortar.qh b/qcsrc/common/weapons/weapon/mortar.qh index 58b526b8e..4fc5ec9ad 100644 --- a/qcsrc/common/weapons/weapon/mortar.qh +++ b/qcsrc/common/weapons/weapon/mortar.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Mortar, Weapon) -/* ammotype */ ATTRIB(Mortar, ammo_field, .int, ammo_rockets); +/* ammotype */ ATTRIB(Mortar, ammo_type, int, RESOURCE_ROCKETS); /* impulse */ ATTRIB(Mortar, impulse, int, 4); /* flags */ ATTRIB(Mortar, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); /* rating */ ATTRIB(Mortar, bot_pickupbasevalue, float, 7000); diff --git a/qcsrc/common/weapons/weapon/porto.qh b/qcsrc/common/weapons/weapon/porto.qh index 94c6e165c..b46e479aa 100644 --- a/qcsrc/common/weapons/weapon/porto.qh +++ b/qcsrc/common/weapons/weapon/porto.qh @@ -1,7 +1,7 @@ #pragma once CLASS(PortoLaunch, Weapon) -/* ammotype */ ATTRIB(PortoLaunch, ammo_field, .int, ammo_none); +/* ammotype */ ATTRIB(PortoLaunch, ammo_type, int, RESOURCE_NONE); /* impulse */ ATTRIB(PortoLaunch, impulse, int, 0); /* flags */ ATTRIB(PortoLaunch, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_SUPERWEAPON | WEP_FLAG_NODUAL); /* rating */ ATTRIB(PortoLaunch, bot_pickupbasevalue, float, 0); diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 92694e2e2..547842512 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -150,13 +150,13 @@ METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity, } METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(rifle, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo); return ammo_amount; } METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(rifle, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo); return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/rifle.qh b/qcsrc/common/weapons/weapon/rifle.qh index ed5496f05..b1c01b86f 100644 --- a/qcsrc/common/weapons/weapon/rifle.qh +++ b/qcsrc/common/weapons/weapon/rifle.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Rifle, Weapon) -/* ammotype */ ATTRIB(Rifle, ammo_field, .int, ammo_nails); +/* ammotype */ ATTRIB(Rifle, ammo_type, int, RESOURCE_BULLETS); /* impulse */ ATTRIB(Rifle, impulse, int, 7); /* flags */ ATTRIB(Rifle, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_PENETRATEWALLS); /* rating */ ATTRIB(Rifle, bot_pickupbasevalue, float, 7000); diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 35b48b8ea..b2df4f0ef 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -348,7 +348,7 @@ void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seek Weapon thiswep = WEP_SEEKER; .entity weaponentity = this.weaponentity_fld; - if((!(this.realowner.items & IT_UNLIMITED_AMMO) && this.realowner.(thiswep.ammo_field) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (this.realowner.(weaponentity).m_switchweapon != WEP_SEEKER)) + if((!(this.realowner.items & IT_UNLIMITED_AMMO) && GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (this.realowner.(weaponentity).m_switchweapon != WEP_SEEKER)) { delete(this); return; @@ -589,12 +589,12 @@ METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor, .entity weapone float ammo_amount; if(WEP_CVAR(seeker, type) == 1) { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, missile_ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo); } else { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); } return ammo_amount; @@ -604,12 +604,12 @@ METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapone float ammo_amount; if(WEP_CVAR(seeker, type) == 1) { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); } else { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, flac_ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo); } return ammo_amount; diff --git a/qcsrc/common/weapons/weapon/seeker.qh b/qcsrc/common/weapons/weapon/seeker.qh index 04567d1b9..443d0843d 100644 --- a/qcsrc/common/weapons/weapon/seeker.qh +++ b/qcsrc/common/weapons/weapon/seeker.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Seeker, Weapon) -/* ammotype */ ATTRIB(Seeker, ammo_field, .int, ammo_rockets); +/* ammotype */ ATTRIB(Seeker, ammo_type, int, RESOURCE_ROCKETS); /* impulse */ ATTRIB(Seeker, impulse, int, 8); /* flags */ ATTRIB(Seeker, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH); /* rating */ ATTRIB(Seeker, bot_pickupbasevalue, float, 5000); diff --git a/qcsrc/common/weapons/weapon/shockwave.qh b/qcsrc/common/weapons/weapon/shockwave.qh index f863094c0..89685376d 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qh +++ b/qcsrc/common/weapons/weapon/shockwave.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Shockwave, Weapon) -/* ammotype */ //ATTRIB(Shockwave, ammo_field, .int, ammo_none); +/* ammotype */ //ATTRIB(Shockwave, ammo_type, int, RESOURCE_NONE); /* impulse */ ATTRIB(Shockwave, impulse, int, 2); /* flags */ ATTRIB(Shockwave, spawnflags, int, WEP_TYPE_HITSCAN | WEP_FLAG_CANCLIMB | WEP_TYPE_MELEE_SEC); /* rating */ ATTRIB(Shockwave, bot_pickupbasevalue, float, 3000); diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 3644c1357..e163df4bc 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -216,7 +216,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit } if(actor.(weaponentity).clip_load >= 0) // we are not currently reloading if(WEP_CVAR(shotgun, secondary) == 1) - if(((fire & 1) && actor.(thiswep.ammo_field) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2)) + if(((fire & 1) && GetResourceAmount(actor, thiswep.ammo_type) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2)) if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(shotgun, refire))) { // attempt forcing playback of the anim by switching to another anim (that we never play) here... @@ -225,7 +225,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit } METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo); return ammo_amount; } @@ -239,7 +239,7 @@ METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapon case 1: return true; // melee does not use ammo case 2: // secondary triple shot { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo); return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/shotgun.qh b/qcsrc/common/weapons/weapon/shotgun.qh index 2fd734d55..cd646a768 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qh +++ b/qcsrc/common/weapons/weapon/shotgun.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Shotgun, Weapon) -/* ammotype */ ATTRIB(Shotgun, ammo_field, .int, ammo_shells); +/* ammotype */ ATTRIB(Shotgun, ammo_type, int, RESOURCE_SHELLS); /* impulse */ ATTRIB(Shotgun, impulse, int, 2); /* flags */ ATTRIB(Shotgun, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_TYPE_MELEE_SEC); /* rating */ ATTRIB(Shotgun, bot_pickupbasevalue, float, 6000); diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index e47f8fa90..73822b4c5 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -291,7 +291,7 @@ void W_RocketMinsta_Attack3 (entity actor, .entity weaponentity) METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { - if(actor.(thiswep.ammo_field) > 0) + if(GetResourceAmount(actor, thiswep.ammo_type) > 0) PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 1, false); else PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars @@ -378,7 +378,7 @@ METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor, .entity weaponent METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); - float ammo_amount = actor.(thiswep.ammo_field) >= vaporizer_ammo; + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= vaporizer_ammo; ammo_amount += actor.(weaponentity).(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo; return ammo_amount; } @@ -386,7 +386,7 @@ METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weap { if(!WEP_CVAR_SEC(vaporizer, ammo)) return true; - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(vaporizer, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo); return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/vaporizer.qh b/qcsrc/common/weapons/weapon/vaporizer.qh index f0b144341..0c5c19200 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qh +++ b/qcsrc/common/weapons/weapon/vaporizer.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Vaporizer, Weapon) -/* ammotype */ ATTRIB(Vaporizer, ammo_field, .int, ammo_cells); +/* ammotype */ ATTRIB(Vaporizer, ammo_type, int, RESOURCE_CELLS); /* impulse */ ATTRIB(Vaporizer, impulse, int, 7); /* flags */ ATTRIB(Vaporizer, spawnflags, int, WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN | WEP_FLAG_NODUAL); /* rating */ ATTRIB(Vaporizer, bot_pickupbasevalue, float, 10000); diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 454cb8bfb..202780e29 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -241,11 +241,11 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity } else { - dt = min(dt, (actor.(thiswep.ammo_field) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo)); + dt = min(dt, (GetResourceAmount(actor, thiswep.ammo_type) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo)); dt = max(0, dt); if(dt > 0) { - actor.(thiswep.ammo_field) = max(WEP_CVAR_SEC(vortex, ammo), actor.(thiswep.ammo_field) - WEP_CVAR_SEC(vortex, ammo) * dt); + SetResourceAmount(actor, thiswep.ammo_type, max(WEP_CVAR_SEC(vortex, ammo), GetResourceAmount(actor, thiswep.ammo_type) - WEP_CVAR_SEC(vortex, ammo) * dt)); } } } @@ -277,7 +277,7 @@ METHOD(Vortex, wr_setup, void(entity thiswep, entity actor, .entity weaponentity } METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(vortex, ammo); ammo_amount += (autocvar_g_balance_vortex_reload_ammo && actor.(weaponentity).(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo)); return ammo_amount; } @@ -286,7 +286,7 @@ METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapone if(WEP_CVAR(vortex, secondary)) { // don't allow charging if we don't have enough ammo - float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vortex, ammo); + float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(vortex, ammo); ammo_amount += actor.(weaponentity).(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo); return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/vortex.qh b/qcsrc/common/weapons/weapon/vortex.qh index 81ab7e620..5a41b90d8 100644 --- a/qcsrc/common/weapons/weapon/vortex.qh +++ b/qcsrc/common/weapons/weapon/vortex.qh @@ -1,7 +1,7 @@ #pragma once CLASS(Vortex, Weapon) -/* ammotype */ ATTRIB(Vortex, ammo_field, .int, ammo_cells); +/* ammotype */ ATTRIB(Vortex, ammo_type, int, RESOURCE_CELLS); /* impulse */ ATTRIB(Vortex, impulse, int, 7); /* flags */ ATTRIB(Vortex, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_NODUAL); /* rating */ ATTRIB(Vortex, bot_pickupbasevalue, float, 8000); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 7bb8e922d..d6b761c41 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -199,14 +199,14 @@ string NearestLocation(vector p) string AmmoNameFromWeaponentity(entity wpn) { string ammoitems = "batteries"; - switch((wpn.m_weapon).ammo_field) + switch ((wpn.m_weapon).ammo_type) { - case ammo_shells: ammoitems = ITEM_Shells.m_name; break; - case ammo_nails: ammoitems = ITEM_Bullets.m_name; break; - case ammo_rockets: ammoitems = ITEM_Rockets.m_name; break; - case ammo_cells: ammoitems = ITEM_Cells.m_name; break; - case ammo_plasma: ammoitems = ITEM_Plasma.m_name; break; - case ammo_fuel: ammoitems = ITEM_JetpackFuel.m_name; break; + case RESOURCE_SHELLS: ammoitems = ITEM_Shells.m_name; break; + case RESOURCE_BULLETS: ammoitems = ITEM_Bullets.m_name; break; + case RESOURCE_ROCKETS: ammoitems = ITEM_Rockets.m_name; break; + case RESOURCE_CELLS: ammoitems = ITEM_Cells.m_name; break; + case RESOURCE_PLASMA: ammoitems = ITEM_Plasma.m_name; break; + case RESOURCE_FUEL: ammoitems = ITEM_JetpackFuel.m_name; break; } return ammoitems; } diff --git a/qcsrc/server/resources.qc b/qcsrc/server/resources.qc index edf4ff162..a2a1358b9 100644 --- a/qcsrc/server/resources.qc +++ b/qcsrc/server/resources.qc @@ -1,4 +1,5 @@ #include "resources.qh" + /// \file /// \brief Source file that contains implementation of the resource system. /// \author Lyberta diff --git a/qcsrc/server/resources.qh b/qcsrc/server/resources.qh index ce8e1e8e5..dd9dfc232 100644 --- a/qcsrc/server/resources.qh +++ b/qcsrc/server/resources.qh @@ -1,4 +1,5 @@ #pragma once + /// \file /// \brief Header file that describes the resource system. /// \author Lyberta @@ -7,19 +8,6 @@ /// \brief Unconditional maximum amount of resources the entity can have. const int RESOURCE_AMOUNT_HARD_LIMIT = 999; -/// \brief Describes the available resource types. -enum -{ - RESOURCE_HEALTH = 1, ///< Health. - RESOURCE_ARMOR, ///< Armor. - RESOURCE_SHELLS, ///< Shells (used by shotgun). - RESOURCE_BULLETS, ///< Bullets (used by machinegun and rifle) - RESOURCE_ROCKETS, ///< Rockets (used by mortar, hagar, devastator, etc). - RESOURCE_CELLS, ///< Cells (used by electro, crylink, vortex, etc) - RESOURCE_PLASMA, ///< Plasma (unused). - RESOURCE_FUEL ///< Fuel (used by jetpack). -}; - // ============================ Public API ==================================== /// \brief Returns the maximum amount of the given resource. diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index 62b11ea45..850111005 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -101,16 +101,16 @@ void weapon_defaultspawnfunc(entity this, Weapon e) this.superweapons_finished = autocvar_g_balance_superweapons_time; // if we don't already have ammo, give us some ammo - if (!this.(wpn.ammo_field)) + if (!GetResourceAmount(this, wpn.ammo_type)) { - switch (wpn.ammo_field) + switch (wpn.ammo_type) { - case ammo_shells: this.ammo_shells = cvar("g_pickup_shells_weapon"); break; - case ammo_nails: this.ammo_nails = cvar("g_pickup_nails_weapon"); break; - case ammo_rockets: this.ammo_rockets = cvar("g_pickup_rockets_weapon"); break; - case ammo_cells: this.ammo_cells = cvar("g_pickup_cells_weapon"); break; - case ammo_plasma: this.ammo_plasma = cvar("g_pickup_plasma_weapon"); break; - case ammo_fuel: this.ammo_fuel = cvar("g_pickup_fuel_weapon"); break; + case RESOURCE_SHELLS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_shells_weapon")); break; + case RESOURCE_BULLETS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_nails_weapon")); break; + case RESOURCE_ROCKETS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_rockets_weapon")); break; + case RESOURCE_CELLS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_cells_weapon")); break; + case RESOURCE_PLASMA: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_plasma_weapon")); break; + case RESOURCE_FUEL: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_fuel_weapon")); break; } } diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index 4b7d45b96..edfa2209a 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -37,7 +37,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto float thisammo; string s; Weapon info = Weapons_from(wpn); - var .int ammotype = info.ammo_field; + int ammotype = info.ammo_type; entity wep = new(droppedweapon); @@ -88,7 +88,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto wep.pickup_anyway = true; // these are ALWAYS pickable //wa = W_AmmoItemCode(wpn); - if(ammotype == ammo_none) + if(ammotype == RESOURCE_NONE) { return ""; } @@ -102,11 +102,10 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto int i = own.(weaponentity).m_weapon.m_id; if(own.(weaponentity).(weapon_load[i]) > 0) { - own.(ammotype) += own.(weaponentity).(weapon_load[i]); + GiveResource(own, ammotype, own.(weaponentity).(weapon_load[i])); own.(weaponentity).(weapon_load[i]) = -1; // schedule the weapon for reloading } - - wep.(ammotype) = 0; + SetResourceAmount(wep, ammotype, 0); } else if(doreduce) { @@ -114,22 +113,23 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto int i = own.(weaponentity).m_weapon.m_id; if(own.(weaponentity).(weapon_load[i]) > 0) { - own.(ammotype) += own.(weaponentity).(weapon_load[i]); + GiveResource(own, ammotype, own.(weaponentity).(weapon_load[i])); own.(weaponentity).(weapon_load[i]) = -1; // schedule the weapon for reloading } - thisammo = min(own.(ammotype), wep.(ammotype)); - wep.(ammotype) = thisammo; - own.(ammotype) -= thisammo; + float ownderammo = GetResourceAmount(own, ammotype); + thisammo = min(ownderammo, GetResourceAmount(wep, ammotype)); + SetResourceAmount(wep, ammotype, thisammo); + SetResourceAmount(own, ammotype, ownderammo - thisammo); - switch(ammotype) + switch (ammotype) { - case ammo_shells: s = sprintf("%s and %d shells", s, thisammo); break; - case ammo_nails: s = sprintf("%s and %d nails", s, thisammo); break; - case ammo_rockets: s = sprintf("%s and %d rockets", s, thisammo); break; - case ammo_cells: s = sprintf("%s and %d cells", s, thisammo); break; - case ammo_plasma: s = sprintf("%s and %d plasma", s, thisammo); break; - case ammo_fuel: s = sprintf("%s and %d fuel", s, thisammo); break; + case RESOURCE_SHELLS: s = sprintf("%s and %d shells", s, thisammo); break; + case RESOURCE_BULLETS: s = sprintf("%s and %d nails", s, thisammo); break; + case RESOURCE_ROCKETS: s = sprintf("%s and %d rockets", s, thisammo); break; + case RESOURCE_CELLS: s = sprintf("%s and %d cells", s, thisammo); break; + case RESOURCE_PLASMA: s = sprintf("%s and %d plasma", s, thisammo); break; + case RESOURCE_FUEL: s = sprintf("%s and %d fuel", s, thisammo); break; } s = substring(s, 5, -1); @@ -155,7 +155,7 @@ bool W_IsWeaponThrowable(entity this, int w) // start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo) if(start_items & IT_UNLIMITED_WEAPON_AMMO) return false; - if((Weapons_from(w)).ammo_field == ammo_none) + if((Weapons_from(w)).ammo_type == RESOURCE_NONE) return false; } return true; diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index f8949b156..dc1b81d69 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -668,21 +668,22 @@ void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponenti w_ent.clip_load -= ammo_use; w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load; } - else if (wep.ammo_field != ammo_none) + else if (wep.ammo_type != RESOURCE_NONE) { - actor.(wep.ammo_field) -= ammo_use; - if (actor.(wep.ammo_field) < 0) + float ammo = GetResourceAmount(actor, wep.ammo_type); + if (ammo < ammo_use) { backtrace(sprintf( "W_DecreaseAmmo(%.2f): '%s' subtracted too much %s from '%s', resulting with '%.2f' left... " "Please notify Samual immediately with a copy of this backtrace!\n", ammo_use, wep.netname, - GetAmmoPicture(wep.ammo_field), + GetAmmoPicture(wep.ammo_type), actor.netname, - actor.(wep.ammo_field) + ammo )); } + SetResourceAmount(actor, wep.ammo_type, ammo - ammo_use); } } @@ -702,16 +703,17 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int w_ent.clip_load = w_ent.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load - if (!w_ent.reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || wpn.ammo_field == ammo_none) + if (!w_ent.reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || wpn.ammo_type == RESOURCE_NONE) { w_ent.clip_load = w_ent.reload_ammo_amount; } else { // make sure we don't add more ammo than we have - float load = min(w_ent.reload_ammo_amount - w_ent.clip_load, actor.(wpn.ammo_field)); + float ammo = GetResourceAmount(actor, wpn.ammo_type); + float load = min(w_ent.reload_ammo_amount - w_ent.clip_load, ammo); w_ent.clip_load += load; - actor.(wpn.ammo_field) -= load; + SetResourceAmount(actor, wpn.ammo_type, ammo - load); } w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load; @@ -754,9 +756,9 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen if (this.clip_load >= this.reload_ammo_amount) return; // no ammo, so nothing to load - if (e.ammo_field != ammo_none) + if (e.ammo_type != RESOURCE_NONE) { - if (!actor.(e.ammo_field) && this.reload_ammo_min) + if (!GetResourceAmount(actor, e.ammo_type) && this.reload_ammo_min) { if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) {