#ifdef REGISTER_WEAPON
REGISTER_WEAPON(
-/* WEP_##id */ NEX,
-/* function */ w_nex,
-/* ammotype */ IT_CELLS,
-/* impulse */ 7,
-/* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
-/* rating */ BOT_PICKUP_RATING_HIGH,
-/* model */ "nex",
-/* shortname */ "nex",
-/* fullname */ _("Nex")
+/* WEP_##id */ NEX,
+/* function */ w_nex,
+/* ammotype */ IT_CELLS,
+/* impulse */ 7,
+/* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
+/* rating */ BOT_PICKUP_RATING_HIGH,
+/* model */ "nex",
+/* netname */ "nex",
+/* fullname */ _("Nex")
);
+
+#define NEX_SETTINGS(weapon) \
+ WEP_ADD_CVAR(weapon, MO_BOTH, ammo) \
+ WEP_ADD_CVAR(weapon, MO_BOTH, animtime) \
+ WEP_ADD_CVAR(weapon, MO_BOTH, damage) \
+ WEP_ADD_CVAR(weapon, MO_BOTH, force) \
+ WEP_ADD_CVAR(weapon, MO_BOTH, damagefalloff_mindist) \
+ WEP_ADD_CVAR(weapon, MO_BOTH, damagefalloff_maxdist) \
+ WEP_ADD_CVAR(weapon, MO_BOTH, damagefalloff_halflife) \
+ WEP_ADD_CVAR(weapon, MO_BOTH, damagefalloff_forcehalflife) \
+ WEP_ADD_CVAR(weapon, MO_BOTH, refire) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_mindmg) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_shot_multiplier) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_animlimit) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_limit) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_rate) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_rot_rate) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_rot_pause) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_start) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_minspeed) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_maxspeed) \
+ WEP_ADD_CVAR(weapon, MO_NONE, charge_velocity_rate) \
+ WEP_ADD_CVAR(weapon, MO_NONE, secondary) \
+ WEP_ADD_CVAR(weapon, MO_SEC, chargepool) \
+ WEP_ADD_CVAR(weapon, MO_SEC, chargepool_regen) \
+ WEP_ADD_CVAR(weapon, MO_SEC, chargepool_pause_regen) \
+ WEP_ADD_PROP(weapon, reloading_ammo, reload_ammo) \
+ WEP_ADD_PROP(weapon, reloading_time, reload_time) \
+ WEP_ADD_PROP(weapon, switchdelay_raise, switchdelay_raise) \
+ WEP_ADD_PROP(weapon, switchdelay_drop, switchdelay_drop)
+
+#ifdef SVQC
+NEX_SETTINGS(nex)
+#endif
#else
#ifdef SVQC
+void spawnfunc_weapon_nex (void) { weapon_defaultspawnfunc(WEP_NEX); }
void SendCSQCNexBeamParticle(float charge) {
vector v;
void W_Nex_Attack (float issecondary)
{
float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
- if(issecondary)
- {
- mydmg = autocvar_g_balance_nex_secondary_damage;
- myforce = autocvar_g_balance_nex_secondary_force;
- mymindist = autocvar_g_balance_nex_secondary_damagefalloff_mindist;
- mymaxdist = autocvar_g_balance_nex_secondary_damagefalloff_maxdist;
- myhalflife = autocvar_g_balance_nex_secondary_damagefalloff_halflife;
- myforcehalflife = autocvar_g_balance_nex_secondary_damagefalloff_forcehalflife;
- myammo = autocvar_g_balance_nex_secondary_ammo;
- }
- else
- {
- mydmg = autocvar_g_balance_nex_primary_damage;
- myforce = autocvar_g_balance_nex_primary_force;
- mymindist = autocvar_g_balance_nex_primary_damagefalloff_mindist;
- mymaxdist = autocvar_g_balance_nex_primary_damagefalloff_maxdist;
- myhalflife = autocvar_g_balance_nex_primary_damagefalloff_halflife;
- myforcehalflife = autocvar_g_balance_nex_primary_damagefalloff_forcehalflife;
- myammo = autocvar_g_balance_nex_primary_ammo;
- }
+
+ mydmg = WEP_CVAR_BOTH(nex, !issecondary, damage);
+ myforce = WEP_CVAR_BOTH(nex, !issecondary, force);
+ mymindist = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_mindist);
+ mymaxdist = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_maxdist);
+ myhalflife = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_halflife);
+ myforcehalflife = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_forcehalflife);
+ myammo = WEP_CVAR_BOTH(nex, !issecondary, ammo);
float flying;
flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
- if(autocvar_g_balance_nex_charge)
+ if(WEP_CVAR(nex, charge))
{
- charge = autocvar_g_balance_nex_charge_mindmg / mydmg + (1 - autocvar_g_balance_nex_charge_mindmg / mydmg) * self.nex_charge;
- self.nex_charge *= autocvar_g_balance_nex_charge_shot_multiplier; // do this AFTER setting mydmg/myforce
+ charge = WEP_CVAR(nex, charge_mindmg) / mydmg + (1 - WEP_CVAR(nex, charge_mindmg) / mydmg) * self.nex_charge;
+ self.nex_charge *= WEP_CVAR(nex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
// O RLY? -- divVerent
// YA RLY -- FruitieX
}
myforce *= charge;
W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", CH_WEAPON_A, mydmg);
- if(charge > autocvar_g_balance_nex_charge_animlimit && autocvar_g_balance_nex_charge_animlimit) // if the Nex is overcharged, we play an extra sound
+ if(charge > WEP_CVAR(nex, charge_animlimit) && WEP_CVAR(nex, charge_animlimit)) // if the Nex is overcharged, we play an extra sound
{
- sound (self, CH_WEAPON_B, "weapons/nexcharge.wav", VOL_BASE * (charge - 0.5 * autocvar_g_balance_nex_charge_animlimit) / (1 - 0.5 * autocvar_g_balance_nex_charge_animlimit), ATTN_NORM);
+ sound (self, CH_WEAPON_B, "weapons/nexcharge.wav", VOL_BASE * (charge - 0.5 * WEP_CVAR(nex, charge_animlimit)) / (1 - 0.5 * WEP_CVAR(nex, charge_animlimit)), ATTN_NORM);
}
yoda = 0;
{
float dt;
float ammo_amount;
- if (req == WR_AIM)
+ switch(req)
{
- if(bot_aim(1000000, 0, 1, FALSE))
- self.BUTTON_ATCK = TRUE;
- else
+ case WR_AIM:
{
- if(autocvar_g_balance_nex_charge)
- self.BUTTON_ATCK2 = TRUE;
- }
- }
- else if (req == WR_THINK)
- {
- if(autocvar_g_balance_nex_charge && self.nex_charge < autocvar_g_balance_nex_charge_limit)
- self.nex_charge = min(1, self.nex_charge + autocvar_g_balance_nex_charge_rate * frametime / W_TICSPERFRAME);
-
- if(autocvar_g_balance_nex_secondary_chargepool)
- if(self.nex_chargepool_ammo < 1)
+ if(bot_aim(1000000, 0, 1, FALSE))
+ self.BUTTON_ATCK = TRUE;
+ else
{
- if(self.nex_chargepool_pauseregen_finished < time)
- self.nex_chargepool_ammo = min(1, self.nex_chargepool_ammo + autocvar_g_balance_nex_secondary_chargepool_regen * frametime / W_TICSPERFRAME);
- self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_nex_secondary_chargepool_pause_health_regen);
+ if(WEP_CVAR(nex, charge))
+ self.BUTTON_ATCK2 = TRUE;
}
-
- if(autocvar_g_balance_nex_reload_ammo && self.clip_load < min(autocvar_g_balance_nex_primary_ammo, autocvar_g_balance_nex_secondary_ammo)) // forced reload
- weapon_action(self.weapon, WR_RELOAD);
- else
+ return TRUE;
+ }
+ case WR_THINK:
{
- if (self.BUTTON_ATCK)
- {
- if (weapon_prepareattack(0, autocvar_g_balance_nex_primary_refire))
+ if(WEP_CVAR(nex, charge) && self.nex_charge < WEP_CVAR(nex, charge_limit))
+ self.nex_charge = min(1, self.nex_charge + WEP_CVAR(nex, charge_rate) * frametime / W_TICSPERFRAME);
+
+ if(WEP_CVAR_SEC(nex, chargepool))
+ if(self.nex_chargepool_ammo < 1)
{
- W_Nex_Attack(0);
- weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nex_primary_animtime, w_ready);
+ if(self.nex_chargepool_pauseregen_finished < time)
+ self.nex_chargepool_ammo = min(1, self.nex_chargepool_ammo + WEP_CVAR_SEC(nex, chargepool_regen) * frametime / W_TICSPERFRAME);
+ self.pauseregen_finished = max(self.pauseregen_finished, time + WEP_CVAR_SEC(nex, chargepool_pause_regen));
}
- }
- if ((autocvar_g_balance_nex_secondary_charge && !autocvar_g_balance_nex_secondary) ? (self.BUTTON_ZOOM | self.BUTTON_ZOOMSCRIPT) : self.BUTTON_ATCK2)
+
+ if(autocvar_g_balance_nex_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(nex, ammo), WEP_CVAR_SEC(nex, ammo))) // forced reload
+ WEP_ACTION(self.weapon, WR_RELOAD);
+ else
{
- if(autocvar_g_balance_nex_secondary_charge)
+ if (self.BUTTON_ATCK)
{
- self.nex_charge_rottime = time + autocvar_g_balance_nex_charge_rot_pause;
- dt = frametime / W_TICSPERFRAME;
-
- if(self.nex_charge < 1)
+ if (weapon_prepareattack(0, WEP_CVAR_PRI(nex, refire)))
{
- if(autocvar_g_balance_nex_secondary_chargepool)
+ W_Nex_Attack(0);
+ weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(nex, animtime), w_ready);
+ }
+ }
+ if ((WEP_CVAR(nex, charge) && !WEP_CVAR(nex, secondary)) ? (self.BUTTON_ZOOM | self.BUTTON_ZOOMSCRIPT) : self.BUTTON_ATCK2)
+ {
+ if(WEP_CVAR(nex, charge))
+ {
+ self.nex_charge_rottime = time + WEP_CVAR(nex, charge_rot_pause);
+ dt = frametime / W_TICSPERFRAME;
+
+ if(self.nex_charge < 1)
{
- if(autocvar_g_balance_nex_secondary_ammo)
+ if(WEP_CVAR_SEC(nex, chargepool))
{
- // always deplete if secondary is held
- self.nex_chargepool_ammo = max(0, self.nex_chargepool_ammo - autocvar_g_balance_nex_secondary_ammo * dt);
+ if(WEP_CVAR_SEC(nex, ammo))
+ {
+ // always deplete if secondary is held
+ self.nex_chargepool_ammo = max(0, self.nex_chargepool_ammo - WEP_CVAR_SEC(nex, ammo) * dt);
- dt = min(dt, (1 - self.nex_charge) / autocvar_g_balance_nex_secondary_charge_rate);
- self.nex_chargepool_pauseregen_finished = time + autocvar_g_balance_nex_secondary_chargepool_pause_regen;
- dt = min(dt, self.nex_chargepool_ammo);
- dt = max(0, dt);
+ dt = min(dt, (1 - self.nex_charge) / WEP_CVAR(nex, charge_rate));
+ self.nex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(nex, chargepool_pause_regen);
+ dt = min(dt, self.nex_chargepool_ammo);
+ dt = max(0, dt);
- self.nex_charge += dt * autocvar_g_balance_nex_secondary_charge_rate;
+ self.nex_charge += dt * WEP_CVAR(nex, charge_rate);
+ }
}
- }
- else if(autocvar_g_balance_nex_secondary_ammo)
- {
- if(self.BUTTON_ATCK2) // only eat ammo when the button is pressed
+ else if(WEP_CVAR_SEC(nex, ammo))
{
- dt = min(dt, (1 - self.nex_charge) / autocvar_g_balance_nex_secondary_charge_rate);
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+ if(self.BUTTON_ATCK2) // only eat ammo when the button is pressed
{
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if(autocvar_g_balance_nex_reload_ammo)
+ dt = min(dt, (1 - self.nex_charge) / WEP_CVAR(nex, charge_rate));
+ if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
{
- dt = min(dt, (self.clip_load - autocvar_g_balance_nex_primary_ammo) / autocvar_g_balance_nex_secondary_ammo);
- dt = max(0, dt);
- if(dt > 0)
+ // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
+ if(autocvar_g_balance_nex_reload_ammo)
{
- self.clip_load = max(autocvar_g_balance_nex_secondary_ammo, self.clip_load - autocvar_g_balance_nex_secondary_ammo * dt);
+ dt = min(dt, (self.clip_load - WEP_CVAR_PRI(nex, ammo)) / WEP_CVAR_SEC(nex, ammo));
+ dt = max(0, dt);
+ if(dt > 0)
+ {
+ self.clip_load = max(WEP_CVAR_SEC(nex, ammo), self.clip_load - WEP_CVAR_SEC(nex, ammo) * dt);
+ }
+ self.(weapon_load[WEP_NEX]) = self.clip_load;
}
- self.(weapon_load[WEP_NEX]) = self.clip_load;
- }
- else
- {
- dt = min(dt, (self.ammo_cells - autocvar_g_balance_nex_primary_ammo) / autocvar_g_balance_nex_secondary_ammo);
- dt = max(0, dt);
- if(dt > 0)
+ else
{
- self.ammo_cells = max(autocvar_g_balance_nex_secondary_ammo, self.ammo_cells - autocvar_g_balance_nex_secondary_ammo * dt);
+ dt = min(dt, (self.ammo_cells - WEP_CVAR_PRI(nex, ammo)) / WEP_CVAR_SEC(nex, ammo));
+ dt = max(0, dt);
+ if(dt > 0)
+ {
+ self.ammo_cells = max(WEP_CVAR_SEC(nex, ammo), self.ammo_cells - WEP_CVAR_SEC(nex, ammo) * dt);
+ }
}
}
+ self.nex_charge += dt * WEP_CVAR(nex, charge_rate);
}
- self.nex_charge += dt * autocvar_g_balance_nex_secondary_charge_rate;
}
- }
- else
- {
- dt = min(dt, (1 - self.nex_charge) / autocvar_g_balance_nex_secondary_charge_rate);
- self.nex_charge += dt * autocvar_g_balance_nex_secondary_charge_rate;
+ else
+ {
+ dt = min(dt, (1 - self.nex_charge) / WEP_CVAR(nex, charge_rate));
+ self.nex_charge += dt * WEP_CVAR(nex, charge_rate);
+ }
}
}
- }
- else if(autocvar_g_balance_nex_secondary)
- {
- if (weapon_prepareattack(0, autocvar_g_balance_nex_secondary_refire))
+ else if(WEP_CVAR(nex, secondary))
{
- W_Nex_Attack(1);
- weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nex_secondary_animtime, w_ready);
+ if (weapon_prepareattack(0, WEP_CVAR_SEC(nex, refire)))
+ {
+ W_Nex_Attack(1);
+ weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(nex, animtime), w_ready);
+ }
}
}
}
+
+ return TRUE;
}
- }
- else if (req == WR_PRECACHE)
- {
- precache_model ("models/nexflash.md3");
- precache_model ("models/weapons/g_nex.md3");
- precache_model ("models/weapons/v_nex.md3");
- precache_model ("models/weapons/h_nex.iqm");
- precache_sound ("weapons/nexfire.wav");
- precache_sound ("weapons/nexcharge.wav");
- precache_sound ("weapons/nexwhoosh1.wav");
- precache_sound ("weapons/nexwhoosh2.wav");
- precache_sound ("weapons/nexwhoosh3.wav");
- //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
- }
- else if (req == WR_SETUP)
- {
- weapon_setup(WEP_NEX);
- self.current_ammo = ammo_cells;
- }
- else if (req == WR_CHECKAMMO1)
- {
- ammo_amount = self.ammo_cells >= autocvar_g_balance_nex_primary_ammo;
- ammo_amount += (autocvar_g_balance_nex_reload_ammo && self.(weapon_load[WEP_NEX]) >= autocvar_g_balance_nex_primary_ammo);
- return ammo_amount;
- }
- else if (req == WR_CHECKAMMO2)
- {
- if(autocvar_g_balance_nex_secondary)
+ case WR_INIT:
{
- // don't allow charging if we don't have enough ammo
- ammo_amount = self.ammo_cells >= autocvar_g_balance_nex_secondary_ammo;
- ammo_amount += self.(weapon_load[WEP_NEX]) >= autocvar_g_balance_nex_secondary_ammo;
+ precache_model ("models/nexflash.md3");
+ precache_model ("models/weapons/g_nex.md3");
+ precache_model ("models/weapons/v_nex.md3");
+ precache_model ("models/weapons/h_nex.iqm");
+ precache_sound ("weapons/nexfire.wav");
+ precache_sound ("weapons/nexcharge.wav");
+ precache_sound ("weapons/nexwhoosh1.wav");
+ precache_sound ("weapons/nexwhoosh2.wav");
+ precache_sound ("weapons/nexwhoosh3.wav");
+ WEP_SET_PROPS(NEX_SETTINGS(nex), WEP_NEX)
+ return TRUE;
+ }
+ case WR_SETUP:
+ {
+ self.current_ammo = ammo_cells;
+ return TRUE;
+ }
+ case WR_CHECKAMMO1:
+ {
+ ammo_amount = self.ammo_cells >= WEP_CVAR_PRI(nex, ammo);
+ ammo_amount += (autocvar_g_balance_nex_reload_ammo && self.(weapon_load[WEP_NEX]) >= WEP_CVAR_PRI(nex, ammo));
return ammo_amount;
}
- else
+ case WR_CHECKAMMO2:
{
- return FALSE; // zoom is not a fire mode
+ if(WEP_CVAR(nex, secondary))
+ {
+ // don't allow charging if we don't have enough ammo
+ ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(nex, ammo);
+ ammo_amount += self.(weapon_load[WEP_NEX]) >= WEP_CVAR_SEC(nex, ammo);
+ return ammo_amount;
+ }
+ else
+ {
+ return FALSE; // zoom is not a fire mode
+ }
+ }
+ case WR_CONFIG:
+ {
+ WEP_CONFIG_SETTINGS(NEX_SETTINGS(nex))
+ return TRUE;
+ }
+ case WR_RELOAD:
+ {
+ W_Reload(min(WEP_CVAR_PRI(nex, ammo), WEP_CVAR_SEC(nex, ammo)), "weapons/reload.wav");
+ return TRUE;
+ }
+ case WR_SUICIDEMESSAGE:
+ {
+ return WEAPON_THINKING_WITH_PORTALS;
+ }
+ case WR_KILLMESSAGE:
+ {
+ return WEAPON_NEX_MURDER;
}
- }
- else if (req == WR_RELOAD)
- {
- W_Reload(min(autocvar_g_balance_nex_primary_ammo, autocvar_g_balance_nex_secondary_ammo), autocvar_g_balance_nex_reload_ammo, autocvar_g_balance_nex_reload_time, "weapons/reload.wav");
- }
- else if (req == WR_SUICIDEMESSAGE)
- {
- return WEAPON_THINKING_WITH_PORTALS;
- }
- else if (req == WR_KILLMESSAGE)
- {
- return WEAPON_NEX_MURDER;
}
return TRUE;
}
#ifdef CSQC
float w_nex(float req)
{
- if(req == WR_IMPACTEFFECT)
- {
- vector org2;
- org2 = w_org + w_backoff * 6;
- pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
- if(!w_issilent)
- sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
- }
- else if(req == WR_PRECACHE)
+ switch(req)
{
- precache_sound("weapons/neximpact.wav");
+ case WR_IMPACTEFFECT:
+ {
+ vector org2;
+ org2 = w_org + w_backoff * 6;
+ pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
+ if(!w_issilent)
+ sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
+
+ return TRUE;
+ }
+ case WR_INIT:
+ {
+ precache_sound("weapons/neximpact.wav");
+ return TRUE;
+ }
}
return TRUE;
}