X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Felectro.qc;h=b75106806269d839cd7af02118a72bbf9cc14a08;hb=78f89dad80d777dfa60a74b92851e6f7628abe00;hp=b308d2e0fc6c87bb7e55a093eb418951d0348133;hpb=28305c2245f99ca5ae21ea8858e05c6bb0a2000b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index b308d2e0f..b75106806 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -1,73 +1,79 @@ #ifndef IMPLEMENTATION -REGISTER_WEAPON( -/* WEP_##id */ ELECTRO, -/* function */ W_Electro, -/* ammotype */ ammo_cells, -/* impulse */ 5, -/* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, -/* rating */ BOT_PICKUP_RATING_MID, -/* color */ '0 0.5 1', -/* modelname */ "electro", -/* simplemdl */ "foobar", -/* crosshair */ "gfx/crosshairelectro 0.6", -/* wepimg */ "weaponelectro", -/* refname */ "electro", -/* wepname */ _("Electro") -); - -#define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro) -#define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \ - w_cvar(id, sn, BOTH, ammo) \ - w_cvar(id, sn, BOTH, animtime) \ - w_cvar(id, sn, BOTH, damage) \ - w_cvar(id, sn, BOTH, edgedamage) \ - w_cvar(id, sn, BOTH, force) \ - w_cvar(id, sn, BOTH, radius) \ - w_cvar(id, sn, BOTH, refire) \ - w_cvar(id, sn, BOTH, speed) \ - w_cvar(id, sn, BOTH, spread) \ - w_cvar(id, sn, BOTH, lifetime) \ - w_cvar(id, sn, PRI, comboradius) \ - w_cvar(id, sn, PRI, midaircombo_explode) \ - w_cvar(id, sn, PRI, midaircombo_interval) \ - w_cvar(id, sn, PRI, midaircombo_radius) \ - w_cvar(id, sn, SEC, bouncefactor) \ - w_cvar(id, sn, SEC, bouncestop) \ - w_cvar(id, sn, SEC, count) \ - w_cvar(id, sn, SEC, damageforcescale) \ - w_cvar(id, sn, SEC, damagedbycontents) \ - w_cvar(id, sn, SEC, health) \ - w_cvar(id, sn, SEC, refire2) \ - w_cvar(id, sn, SEC, speed_up) \ - w_cvar(id, sn, SEC, speed_z) \ - w_cvar(id, sn, SEC, touchexplode) \ - w_cvar(id, sn, NONE, combo_comboradius) \ - w_cvar(id, sn, NONE, combo_comboradius_thruwall) \ - w_cvar(id, sn, NONE, combo_damage) \ - w_cvar(id, sn, NONE, combo_edgedamage) \ - w_cvar(id, sn, NONE, combo_force) \ - w_cvar(id, sn, NONE, combo_radius) \ - w_cvar(id, sn, NONE, combo_speed) \ - w_cvar(id, sn, NONE, combo_safeammocheck) \ - w_prop(id, sn, float, reloading_ammo, reload_ammo) \ - w_prop(id, sn, float, reloading_time, reload_time) \ - w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \ - w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \ - w_prop(id, sn, string, weaponreplace, weaponreplace) \ - w_prop(id, sn, float, weaponstart, weaponstart) \ - w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \ - w_prop(id, sn, float, weaponthrowable, weaponthrowable) +CLASS(Electro, Weapon) +/* ammotype */ ATTRIB(Electro, ammo_field, .int, ammo_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, BOT_PICKUP_RATING_MID); +/* color */ ATTRIB(Electro, wpcolor, vector, '0 0.5 1'); +/* modelname */ ATTRIB(Electro, mdl, string, "electro"); +#ifndef MENUQC +/* model */ ATTRIB(Electro, m_model, Model, MDL_ELECTRO_ITEM); +#endif +/* crosshair */ ATTRIB(Electro, w_crosshair, string, "gfx/crosshairelectro"); +/* crosshair */ ATTRIB(Electro, w_crosshair_size, float, 0.6); +/* wepimg */ ATTRIB(Electro, model2, string, "weaponelectro"); +/* refname */ ATTRIB(Electro, netname, string, "electro"); +/* wepname */ ATTRIB(Electro, m_name, string, _("Electro")); + +#define X(BEGIN, P, END, class, prefix) \ + BEGIN(class) \ + P(class, prefix, ammo, float, BOTH) \ + P(class, prefix, animtime, float, BOTH) \ + P(class, prefix, bouncefactor, float, SEC) \ + P(class, prefix, bouncestop, float, SEC) \ + P(class, prefix, comboradius, float, PRI) \ + P(class, prefix, combo_comboradius, float, NONE) \ + P(class, prefix, combo_comboradius_thruwall, float, NONE) \ + P(class, prefix, combo_damage, float, NONE) \ + P(class, prefix, combo_edgedamage, float, NONE) \ + P(class, prefix, combo_force, float, NONE) \ + P(class, prefix, combo_radius, float, NONE) \ + P(class, prefix, combo_safeammocheck, float, NONE) \ + P(class, prefix, combo_speed, float, NONE) \ + P(class, prefix, count, float, SEC) \ + P(class, prefix, damagedbycontents, float, SEC) \ + P(class, prefix, damageforcescale, float, SEC) \ + P(class, prefix, damage, float, BOTH) \ + P(class, prefix, edgedamage, float, BOTH) \ + P(class, prefix, force, float, BOTH) \ + P(class, prefix, health, float, SEC) \ + P(class, prefix, lifetime, float, BOTH) \ + P(class, prefix, midaircombo_explode, float, PRI) \ + P(class, prefix, midaircombo_interval, float, PRI) \ + P(class, prefix, midaircombo_radius, float, PRI) \ + P(class, prefix, radius, float, BOTH) \ + P(class, prefix, refire2, float, SEC) \ + P(class, prefix, refire, float, BOTH) \ + P(class, prefix, reload_ammo, float, NONE) \ + P(class, prefix, reload_time, float, NONE) \ + P(class, prefix, speed, float, BOTH) \ + P(class, prefix, speed_up, float, SEC) \ + P(class, prefix, speed_z, float, SEC) \ + P(class, prefix, spread, float, BOTH) \ + P(class, prefix, switchdelay_drop, float, NONE) \ + P(class, prefix, switchdelay_raise, float, NONE) \ + P(class, prefix, touchexplode, float, SEC) \ + P(class, prefix, weaponreplace, string,NONE) \ + P(class, prefix, weaponstartoverride, float, NONE) \ + P(class, prefix, weaponstart, float, NONE) \ + P(class, prefix, weaponthrowable, float, NONE) \ + END() + W_PROPS(X, Electro, electro) +#undef X + +ENDCLASS(Electro) +REGISTER_WEAPON(ELECTRO, electro, NEW(Electro)); + #ifdef SVQC -ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) .float electro_count; .float electro_secondarytime; -void W_Electro_ExplodeCombo(void); +void W_Electro_ExplodeCombo(); #endif #endif #ifdef IMPLEMENTATION #ifdef SVQC -void spawnfunc_weapon_electro(void) { weapon_defaultspawnfunc(WEP_ELECTRO.m_id); } +spawnfunc(weapon_electro) { weapon_defaultspawnfunc(this, WEP_ELECTRO); } void W_Electro_TriggerCombo(vector org, float rad, entity own) { @@ -80,7 +86,7 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own) if(WEP_CVAR(electro, combo_comboradius_thruwall)) { // if distance is greater than thruwall distance, check to make sure it's not through a wall - if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall)) + if(vdist(e.WarpZone_findradius_dist, >, WEP_CVAR(electro, combo_comboradius_thruwall))) { WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e); if(trace_fraction != 1) @@ -116,7 +122,7 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own) } } -void W_Electro_ExplodeCombo(void) +void W_Electro_ExplodeCombo() {SELFPARAM(); W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner); @@ -138,12 +144,12 @@ void W_Electro_ExplodeCombo(void) remove(self); } -void W_Electro_Explode(void) +void W_Electro_Explode() {SELFPARAM(); if(other.takedamage == DAMAGE_AIM) if(IS_PLAYER(other)) if(DIFF_TEAM(self.realowner, other)) - if(other.deadflag == DEAD_NO) + if(!IS_DEAD(other)) if(IsFlying(other)) Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH); @@ -185,13 +191,13 @@ void W_Electro_Explode(void) remove(self); } -void W_Electro_TouchExplode(void) +void W_Electro_TouchExplode() { PROJECTILE_TOUCH; W_Electro_Explode(); } -void W_Electro_Bolt_Think(void) +void W_Electro_Bolt_Think() {SELFPARAM(); if(time >= self.ltime) { @@ -243,11 +249,11 @@ void W_Electro_Bolt_Think(void) else { self.nextthink = self.ltime; } } -void W_Electro_Attack_Bolt(void) +void W_Electro_Attack_Bolt(Weapon thiswep) {SELFPARAM(); entity proj; - W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(electro, ammo)); W_SetupShot_ProjectileSize( self, @@ -255,15 +261,14 @@ void W_Electro_Attack_Bolt(void) '0 0 -3', false, 2, - W_Sound("electro_fire"), + SND_ELECTRO_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(electro, damage) ); Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - proj = spawn(); - proj.classname = "electro_bolt"; + proj = new(electro_bolt); proj.owner = proj.realowner = self; proj.bot_dodge = true; proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage); @@ -288,7 +293,7 @@ void W_Electro_Attack_Bolt(void) MUTATOR_CALLHOOK(EditProjectile, self, proj); } -void W_Electro_Orb_Touch(void) +void W_Electro_Orb_Touch() {SELFPARAM(); PROJECTILE_TOUCH; if(other.takedamage == DAMAGE_AIM) @@ -296,39 +301,39 @@ void W_Electro_Orb_Touch(void) else { //UpdateCSQCProjectile(self); - spamsound(self, CH_SHOTS, W_Sound("electro_bounce"), VOL_BASE, ATTEN_NORM); + spamsound(self, CH_SHOTS, SND(ELECTRO_BOUNCE), VOL_BASE, ATTEN_NORM); self.projectiledeathtype |= HITTYPE_BOUNCE; } } -void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) -{SELFPARAM(); - if(self.health <= 0) +void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +{ + if(this.health <= 0) return; // note: combos are usually triggered by W_Electro_TriggerCombo, not damage float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt"); - if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1))) + if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_combo ? 1 : -1))) return; // g_projectiles_damage says to halt - self.health = self.health - damage; - if(self.health <= 0) + this.health = this.health - damage; + if(this.health <= 0) { - self.takedamage = DAMAGE_NO; - self.nextthink = time; + this.takedamage = DAMAGE_NO; + this.nextthink = time; if(is_combo) { // change owner to whoever caused the combo explosion - self.realowner = inflictor.realowner; - self.classname = "electro_orb_chain"; - self.think = W_Electro_ExplodeCombo; - self.nextthink = time + + this.realowner = inflictor.realowner; + this.classname = "electro_orb_chain"; + this.think = W_Electro_ExplodeCombo; + this.nextthink = time + ( // bound the length, inflictor may be in a galaxy far far away (warpzones) min( WEP_CVAR(electro, combo_radius), - vlen(self.origin - inflictor.origin) + vlen(this.origin - inflictor.origin) ) / // delay combo chains, looks cooler @@ -337,15 +342,15 @@ void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, int d } else { - self.use = W_Electro_Explode; - self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately" + this.use = W_Electro_Explode; + this.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately" } } } -void W_Electro_Attack_Orb(void) +void W_Electro_Attack_Orb(Weapon thiswep) {SELFPARAM(); - W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(electro, ammo)); W_SetupShot_ProjectileSize( self, @@ -353,7 +358,7 @@ void W_Electro_Attack_Orb(void) '0 0 -4', false, 2, - W_Sound("electro_fire2"), + SND_ELECTRO_FIRE2, CH_WEAPON_A, WEP_CVAR_SEC(electro, damage) ); @@ -362,8 +367,7 @@ void W_Electro_Attack_Orb(void) Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); - entity proj = spawn(); - proj.classname = "electro_orb"; + entity proj = new(electro_orb); proj.owner = proj.realowner = self; proj.use = W_Electro_Explode; proj.think = adaptor_think2use_hittype_splash; @@ -395,7 +399,7 @@ void W_Electro_Attack_Orb(void) entity p2; p2 = spawn(); copyentity(proj, p2); - setmodel(p2, "models/ebomb.mdl"); + setmodel(p2, MDL_PROJECTILE_ELECTRO); setsize(p2, proj.mins, proj.maxs); #endif @@ -404,218 +408,175 @@ void W_Electro_Attack_Orb(void) MUTATOR_CALLHOOK(EditProjectile, self, proj); } -void W_Electro_CheckAttack(void) +void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire) {SELFPARAM(); if(self.electro_count > 1) - if(self.BUTTON_ATCK2) - if(weapon_prepareattack(1, -1)) + if(PHYS_INPUT_BUTTON_ATCK2(self)) + if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1)) { - W_Electro_Attack_Orb(); + W_Electro_Attack_Orb(WEP_ELECTRO); self.electro_count -= 1; - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); return; } // WEAPONTODO: when the player releases the button, cut down the length of refire2? - w_ready(); + w_ready(thiswep, actor, weaponentity, fire); } .float bot_secondary_electromooth; -bool W_Electro(int req) -{SELFPARAM(); - float ammo_amount; - switch(req) - { - case WR_AIM: - { - self.BUTTON_ATCK = self.BUTTON_ATCK2 = false; - if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; } - if(self.bot_secondary_electromooth == 0) - { - float shoot; - - if(WEP_CVAR_PRI(electro, speed)) - shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false); - else - shoot = bot_aim(1000000, 0, 0.001, false); - - if(shoot) - { - self.BUTTON_ATCK = true; - if(random() < 0.01) self.bot_secondary_electromooth = 1; - } - } - else - { - if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true)) - { - self.BUTTON_ATCK2 = true; - if(random() < 0.03) self.bot_secondary_electromooth = 0; - } - } - - return true; - } - case WR_THINK: - { - if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO - { - ammo_amount = 0; - if(self.clip_load >= WEP_CVAR_PRI(electro, ammo)) - ammo_amount = 1; - if(self.clip_load >= WEP_CVAR_SEC(electro, ammo)) - ammo_amount += 1; - - if(!ammo_amount) - { - WEP_ACTION(self.weapon, WR_RELOAD); - return false; - } - return true; - } - - if(self.BUTTON_ATCK) - { - if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire))) - { - W_Electro_Attack_Bolt(); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); - } - } - else if(self.BUTTON_ATCK2) - { - if(time >= self.electro_secondarytime) - if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire))) - { - W_Electro_Attack_Orb(); - self.electro_count = WEP_CVAR_SEC(electro, count); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); - self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(); - } - } - - return true; - } - case WR_INIT: - { - precache_model(W_Model("g_electro.md3")); - precache_model(W_Model("v_electro.md3")); - precache_model(W_Model("h_electro.iqm")); - precache_sound(W_Sound("electro_bounce")); - precache_sound(W_Sound("electro_fire")); - precache_sound(W_Sound("electro_fire2")); - precache_sound(W_Sound("electro_impact")); - precache_sound(W_Sound("electro_impact_combo")); - ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP); - return true; - } - case WR_CHECKAMMO1: - { - ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo); - ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo); - return ammo_amount; - } - case WR_CHECKAMMO2: - { - 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 = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); - ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); - } - else - { - ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo); - ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo); - } - return ammo_amount; - } - case WR_CONFIG: - { - ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS); - return true; - } - case WR_RESETPLAYER: - { - self.electro_secondarytime = time; - return true; - } - case WR_RELOAD: - { - W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), W_Sound("reload")); - return true; - } - case WR_SUICIDEMESSAGE: - { - if(w_deathtype & HITTYPE_SECONDARY) - return WEAPON_ELECTRO_SUICIDE_ORBS; - else - return WEAPON_ELECTRO_SUICIDE_BOLT; - } - case WR_KILLMESSAGE: - { - if(w_deathtype & HITTYPE_SECONDARY) - { - return WEAPON_ELECTRO_MURDER_ORBS; - } - else - { - if(w_deathtype & HITTYPE_BOUNCE) - return WEAPON_ELECTRO_MURDER_COMBO; - else - return WEAPON_ELECTRO_MURDER_BOLT; - } - } - } - return false; +METHOD(Electro, wr_aim, void(entity thiswep)) +{ + SELFPARAM(); + PHYS_INPUT_BUTTON_ATCK(self) = PHYS_INPUT_BUTTON_ATCK2(self) = false; + if(vdist(self.origin - self.enemy.origin, >, 1000)) { self.bot_secondary_electromooth = 0; } + if(self.bot_secondary_electromooth == 0) + { + float shoot; + + if(WEP_CVAR_PRI(electro, speed)) + shoot = bot_aim(self, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false); + else + shoot = bot_aim(self, 1000000, 0, 0.001, false); + + if(shoot) + { + PHYS_INPUT_BUTTON_ATCK(self) = true; + if(random() < 0.01) self.bot_secondary_electromooth = 1; + } + } + else + { + if(bot_aim(self, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true)) + { + PHYS_INPUT_BUTTON_ATCK2(self) = true; + if(random() < 0.03) self.bot_secondary_electromooth = 0; + } + } +} +METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) +{ + if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO + { + float ammo_amount = 0; + if(actor.clip_load >= WEP_CVAR_PRI(electro, ammo)) + ammo_amount = 1; + if(actor.clip_load >= WEP_CVAR_SEC(electro, ammo)) + ammo_amount += 1; + + if(!ammo_amount) + { + thiswep.wr_reload(thiswep, actor, weaponentity); + return; + } + } + + if(fire & 1) + { + if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) + { + W_Electro_Attack_Bolt(thiswep); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + } + } + else if(fire & 2) + { + if(time >= actor.electro_secondarytime) + if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire))) + { + W_Electro_Attack_Orb(thiswep); + actor.electro_count = WEP_CVAR_SEC(electro, count); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); + actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(); + } + } +} +METHOD(Electro, wr_checkammo1, bool(entity thiswep)) +{ + SELFPARAM(); + float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo); + ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo); + return ammo_amount; +} +METHOD(Electro, wr_checkammo2, bool(entity thiswep)) +{ + SELFPARAM(); + 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 = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); + ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); + } + else + { + ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo); + ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo); + } + return ammo_amount; +} +METHOD(Electro, wr_resetplayer, void(entity thiswep)) +{ + SELFPARAM(); + self.electro_secondarytime = time; +} +METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) +{ + SELFPARAM(); + W_Reload(self, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD); } +METHOD(Electro, wr_suicidemessage, Notification(entity thiswep)) +{ + if(w_deathtype & HITTYPE_SECONDARY) + return WEAPON_ELECTRO_SUICIDE_ORBS; + else + return WEAPON_ELECTRO_SUICIDE_BOLT; +} +METHOD(Electro, wr_killmessage, Notification(entity thiswep)) +{ + if(w_deathtype & HITTYPE_SECONDARY) + { + return WEAPON_ELECTRO_MURDER_ORBS; + } + else + { + if(w_deathtype & HITTYPE_BOUNCE) + return WEAPON_ELECTRO_MURDER_COMBO; + else + return WEAPON_ELECTRO_MURDER_BOLT; + } +} + #endif #ifdef CSQC -bool W_Electro(int req) -{SELFPARAM(); - switch(req) - { - case WR_IMPACTEFFECT: - { - vector org2; - org2 = w_org + w_backoff * 6; - if(w_deathtype & HITTYPE_SECONDARY) - { - pointparticles(particleeffectnum(EFFECT_ELECTRO_BALLEXPLODE), org2, '0 0 0', 1); - if(!w_issilent) - sound(self, CH_SHOTS, W_Sound("electro_impact"), VOL_BASE, ATTEN_NORM); - } - else - { - if(w_deathtype & HITTYPE_BOUNCE) - { - // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls - pointparticles(particleeffectnum(EFFECT_ELECTRO_COMBO), org2, '0 0 0', 1); - if(!w_issilent) - sound(self, CH_SHOTS, W_Sound("electro_impact_combo"), VOL_BASE, ATTEN_NORM); - } - else - { - pointparticles(particleeffectnum(EFFECT_ELECTRO_IMPACT), org2, '0 0 0', 1); - if(!w_issilent) - sound(self, CH_SHOTS, W_Sound("electro_impact"), VOL_BASE, ATTEN_NORM); - } - } - return true; - } - case WR_INIT: - { - precache_sound(W_Sound("electro_impact")); - precache_sound(W_Sound("electro_impact_combo")); - return true; - } - case WR_ZOOMRETICLE: - { - // no weapon specific image for this weapon - return false; - } - } - return false; +METHOD(Electro, wr_impacteffect, void(entity thiswep)) +{ + SELFPARAM(); + vector org2; + org2 = w_org + w_backoff * 6; + if(w_deathtype & HITTYPE_SECONDARY) + { + pointparticles(EFFECT_ELECTRO_BALLEXPLODE, org2, '0 0 0', 1); + if(!w_issilent) + sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM); + } + else + { + if(w_deathtype & HITTYPE_BOUNCE) + { + // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls + pointparticles(EFFECT_ELECTRO_COMBO, org2, '0 0 0', 1); + if(!w_issilent) + sound(self, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM); + } + else + { + pointparticles(EFFECT_ELECTRO_IMPACT, org2, '0 0 0', 1); + if(!w_issilent) + sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM); + } + } } + #endif #endif