entity weapon_info[WEP_MAXCOUNT];
entity dummy_weapon_info;
-void register_weapon(float id, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname)
+void register_weapon(float id, float(float) func, float droptime, float raisetime, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname)
{
entity e;
weapon_info[id - 1] = e = spawn();
e.model2 = strzone(strcat("wpn-", e.mdl));
e.impulse = i;
e.bot_pickupbasevalue = pickupbasevalue;
+
if(ammotype & IT_SHELLS)
e.ammo_field = ammo_shells;
else if(ammotype & IT_NAILS)
e.ammo_field = ammo_fuel;
else
e.ammo_field = ammo_batteries;
+
+ e.switchdelay_drop = droptime;
+ e.switchdelay_raise = raisetime;
}
float w_null(float dummy)
{
dummy_weapon_info.model2 = "";
dummy_weapon_info.impulse = -1;
dummy_weapon_info.bot_pickupbasevalue = 0;
+ dummy_weapon_info.switchdelay_drop = 0;
+ dummy_weapon_info.switchdelay_raise = 0;
float i;
weaponorder_byid = "";
.float bot_pickupbasevalue; // bot weapon priority
.string model2; // wpn- sprite name
..float ammo_field; // main ammo field
+.float switchdelay_drop; // amount of time to complete drop frame for weapon
+.float switchdelay_raise; // amount of time to complete raise frame for weapon
// also, weaponinfo ents can act as a WEPSET
// dynamic weapon adding
float w_null(float dummy);
-void register_weapon(float id, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
+void register_weapon(float id, float(float) func, float droptime, float raisetime, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
void register_weapons_done();
#define WEP_FIRST 1
WEPSET_DECLARE_A(WEPBIT_ALL);
WEPSET_DECLARE_A(WEPBIT_SUPERWEAPONS);
// note: the fabs call is just there to hide "if result is constant" warning
-#define REGISTER_WEAPON_2(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
+#define REGISTER_WEAPON_2(id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
float id; \
float func(float); \
void RegisterWeapons_##id() \
if(fabs(weapontype & WEP_FLAG_SUPERWEAPON)) \
WEPSET_OR_AW(WEPBIT_SUPERWEAPONS, id); \
++WEP_COUNT; \
- register_weapon(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
+ register_weapon(id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
} \
ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
#ifdef MENUQC
-#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
- REGISTER_WEAPON_2(WEP_##id,w_null,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
+#define REGISTER_WEAPON(id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
+ REGISTER_WEAPON_2(WEP_##id,w_null,0,0,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
#else
-#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
- REGISTER_WEAPON_2(WEP_##id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
+#define REGISTER_WEAPON(id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
+ REGISTER_WEAPON_2(WEP_##id,func,droptime,raisetime,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
#endif
#include "../server/w_all.qc"
// Change weapon
if (self.weapon != self.switchweapon)
{
+ entity e;
+ e = get_weaponinfo(self.switchweapon);
+
if (self.weaponentity.state == WS_CLEAR)
{
// end switching!
weapon_action(self.switchweapon, WR_SETUP);
// set our clip load to the load of the weapon we switched to, if it's reloadable
- entity e;
- e = get_weaponinfo(self.switchweapon);
if(e.spawnflags & WEP_FLAG_RELOADABLE && cvar(strcat("g_balance_", e.netname, "_reload_ammo"))) // prevent accessing undefined cvars
{
self.clip_load = self.(weapon_load[self.switchweapon]);
// VorteX: add player model weapon select frame here
// setcustomframe(PlayerWeaponRaise);
- weapon_thinkf(WFRAME_IDLE, ((self.weaponentity.switchdelay_raise < 0) ? autocvar_g_balance_weaponswitchdelay : self.weaponentity.switchdelay_raise), w_ready);
+ weapon_thinkf(WFRAME_IDLE, cvar(sprintf("g_balance_%s_switchdelay_raise", e.netname)), w_ready);
weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');
}
else if (self.weaponentity.state == WS_DROP)
sound (self, CH_WEAPON_SINGLE, "weapons/weapon_switch.wav", VOL_BASE, ATTN_NORM);
self.weaponentity.state = WS_DROP;
// set up weapon switch think in the future, and start drop anim
- weapon_thinkf(WFRAME_DONTCHANGE, ((self.weaponentity.switchdelay_drop < 0) ? autocvar_g_balance_weaponswitchdelay : self.weaponentity.switchdelay_drop), w_clear);
+ weapon_thinkf(WFRAME_DONTCHANGE, cvar(sprintf("g_balance_%s_switchdelay_drop", e.netname)), w_clear);
weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);
#ifndef INDEPENDENT_ATTACK_FINISHED
}