X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fvaporizer.qc;h=4fd81eb309c5a76ae531579e8c0e4f27767137bb;hb=fd20a1f1eae2b2ba955ce9ddedc20cd151a6f362;hp=2ece549321f0a63abda2e02d825c7718d308ef30;hpb=068324d293df795dbc41de75f38256b8c6c35607;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 2ece54932..4fd81eb30 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -137,7 +137,7 @@ void VaporizerBeam_Draw(entity this) NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew) { Net_Accept(vortex_beam); - this.think = SUB_Remove_self; + setthink(this, SUB_Remove); this.nextthink = time + bound(0, autocvar_cl_vaporizerbeam_lifetime, 10); this.draw = VaporizerBeam_Draw; this.drawmask = MASK_NORMAL; @@ -167,8 +167,8 @@ NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew) spawnfunc(weapon_vaporizer) { weapon_defaultspawnfunc(this, WEP_VAPORIZER); } spawnfunc(weapon_minstanex) { spawnfunc_weapon_vaporizer(this); } -void W_RocketMinsta_Explosion(vector loc) -{SELFPARAM(); +void W_RocketMinsta_Explosion(entity actor, vector loc) +{entity this = actor; if(accuracy_canbegooddamage(self)) accuracy_add(self, WEP_DEVASTATOR.m_id, autocvar_g_rm_damage, 0); entity dmgent = spawn(); @@ -178,19 +178,19 @@ void W_RocketMinsta_Explosion(vector loc) remove(dmgent); } -void W_Vaporizer_Attack(Weapon thiswep) -{SELFPARAM(); +void W_Vaporizer_Attack(Weapon thiswep, entity actor) +{entity this = actor; bool flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000); - W_SetupShot(self, true, 0, "", CH_WEAPON_A, vaporizer_damage); + W_SetupShot(self, true, 0, SND_Null, CH_WEAPON_A, vaporizer_damage); // handle sound separately so we can change the volume // added bonus: no longer plays the strength sound (strength gives no bonus to instakill anyway) sound (self, CH_WEAPON_A, SND_MINSTANEXFIRE, VOL_BASE * 0.8, ATTEN_NORM); yoda = 0; damage_goodhits = 0; - FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id); + FireRailgunBullet(self, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id); // do this now, as goodhits is disabled below SendCSQCVaporizerBeamParticle(self, damage_goodhits); @@ -207,13 +207,13 @@ void W_Vaporizer_Attack(Weapon thiswep) if(autocvar_g_rm) if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT))) - W_RocketMinsta_Explosion(trace_endpos); + W_RocketMinsta_Explosion(self, trace_endpos); W_DecreaseAmmo(thiswep, self, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo))); } -void W_RocketMinsta_Laser_Explode () -{SELFPARAM(); +void W_RocketMinsta_Laser_Explode (entity this) +{ if(other.takedamage == DAMAGE_AIM) if(IS_PLAYER(other)) if(DIFF_TEAM(self.realowner, other)) @@ -227,16 +227,21 @@ void W_RocketMinsta_Laser_Explode () remove(self); } -void W_RocketMinsta_Laser_Touch () -{SELFPARAM(); +void W_RocketMinsta_Laser_Explode_use(entity this, entity actor, entity trigger) +{ + WITHSELF(this, W_RocketMinsta_Laser_Explode(this)); +} + +void W_RocketMinsta_Laser_Touch (entity this) +{ PROJECTILE_TOUCH; //W_RocketMinsta_Laser_Explode (); RadiusDamage (self, self.realowner, self.rm_damage, self.rm_edmg, autocvar_g_rm_laser_radius, world, world, self.rm_force, self.projectiledeathtype, other); remove(self); } -void W_RocketMinsta_Attack2() -{SELFPARAM(); +void W_RocketMinsta_Attack2(entity actor) +{entity this = actor; makevectors(self.v_angle); entity proj; @@ -247,7 +252,7 @@ void W_RocketMinsta_Attack2() Weapon w = PS(self).m_weapon; PS(self).m_weapon = WEP_ELECTRO; - W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', false, 2, SND(CRYLINK_FIRE), CH_WEAPON_A, autocvar_g_rm_laser_damage); + W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', false, 2, SND_CRYLINK_FIRE, CH_WEAPON_A, autocvar_g_rm_laser_damage); PS(self).m_weapon = w; Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -258,8 +263,8 @@ void W_RocketMinsta_Attack2() proj.owner = proj.realowner = self; proj.bot_dodge = true; proj.bot_dodgerating = autocvar_g_rm_laser_damage; - proj.use = W_RocketMinsta_Laser_Explode; - proj.think = adaptor_think2use_hittype_splash; + proj.use = W_RocketMinsta_Laser_Explode_use; + setthink(proj, adaptor_think2use_hittype_splash); proj.nextthink = time + autocvar_g_rm_laser_lifetime; PROJECTILE_MAKETRIGGER(proj); proj.projectiledeathtype = WEP_ELECTRO.m_id; @@ -277,7 +282,7 @@ void W_RocketMinsta_Attack2() proj.velocity_z = proj.velocity_z + cvar("g_rm_laser_zspread") * (random() - 0.5); proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true); proj.angles = vectoangles(proj.velocity); - proj.touch = W_RocketMinsta_Laser_Touch; + settouch(proj, W_RocketMinsta_Laser_Touch); setsize(proj, '0 0 -3', '0 0 -3'); proj.flags = FL_PROJECTILE; proj.missile_flags = MIF_SPLASH; @@ -289,8 +294,8 @@ void W_RocketMinsta_Attack2() } } -void W_RocketMinsta_Attack3 () -{SELFPARAM(); +void W_RocketMinsta_Attack3 (entity actor) +{entity this = actor; makevectors(self.v_angle); entity proj; @@ -299,7 +304,7 @@ void W_RocketMinsta_Attack3 () Weapon w = PS(self).m_weapon; PS(self).m_weapon = WEP_ELECTRO; - W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', false, 2, SND(ELECTRO_FIRE2), CH_WEAPON_A, autocvar_g_rm_laser_damage); + W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', false, 2, SND_ELECTRO_FIRE2, CH_WEAPON_A, autocvar_g_rm_laser_damage); PS(self).m_weapon = w; Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -310,8 +315,8 @@ void W_RocketMinsta_Attack3 () proj.owner = proj.realowner = self; proj.bot_dodge = true; proj.bot_dodgerating = autocvar_g_rm_laser_damage; - proj.use = W_RocketMinsta_Laser_Explode; - proj.think = adaptor_think2use_hittype_splash; + proj.use = W_RocketMinsta_Laser_Explode_use; + setthink(proj, adaptor_think2use_hittype_splash); proj.nextthink = time + autocvar_g_rm_laser_lifetime; PROJECTILE_MAKETRIGGER(proj); proj.projectiledeathtype = WEP_ELECTRO.m_id; @@ -327,7 +332,7 @@ void W_RocketMinsta_Attack3 () proj.velocity = w_shotdir * autocvar_g_rm_laser_speed; proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true); proj.angles = vectoangles(proj.velocity); - proj.touch = W_RocketMinsta_Laser_Touch; + settouch(proj, W_RocketMinsta_Laser_Touch); setsize(proj, '0 0 -3', '0 0 -3'); proj.flags = FL_PROJECTILE; proj.missile_flags = MIF_SPLASH; @@ -339,168 +344,172 @@ void W_RocketMinsta_Attack3 () } } - METHOD(Vaporizer, wr_aim, void(entity thiswep)) - { - if(self.(thiswep.ammo_field) > 0) - self.BUTTON_ATCK = bot_aim(1000000, 0, 1, false); - else - self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars - } - METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) - { - float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); - // if the laser uses load, we also consider its ammo for reloading - if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload - thiswep.wr_reload(thiswep, actor, weaponentity); - } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.clip_load < vaporizer_ammo) { // forced reload - thiswep.wr_reload(thiswep, actor, weaponentity); - } - if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor)) - { - if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire))) - { - W_Vaporizer_Attack(thiswep); - weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready); - } - } - if((fire & 2) || ((fire & 1) && !actor.ammo_cells && autocvar_g_rm)) - { - if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2) - { - bool rapid = autocvar_g_rm_laser_rapid; - if(actor.jump_interval <= time && !actor.held_down) - { - if(rapid) - actor.held_down = true; - actor.jump_interval = time + autocvar_g_rm_laser_refire; - actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay; - damage_goodhits = 0; - W_RocketMinsta_Attack2(); - } - else if(rapid && actor.jump_interval2 <= time && actor.held_down) - { - actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire; - damage_goodhits = 0; - W_RocketMinsta_Attack3(); - //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready); - } - } - else if (actor.jump_interval <= time) - { - // handle refire manually, so that primary and secondary can be fired without conflictions (important for instagib) - actor.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor(); - - // decrease ammo for the laser? - if(WEP_CVAR_SEC(vaporizer, ammo)) - W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(vaporizer, ammo)); - - // ugly instagib hack to reuse the fire mode of the laser - makevectors(actor.v_angle); - Weapon oldwep = PS(actor).m_weapon; // we can't avoid this hack - PS(actor).m_weapon = WEP_BLASTER; - W_Blaster_Attack( - actor, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(vaporizer, shotangle), - WEP_CVAR_SEC(vaporizer, damage), - WEP_CVAR_SEC(vaporizer, edgedamage), - WEP_CVAR_SEC(vaporizer, radius), - WEP_CVAR_SEC(vaporizer, force), - WEP_CVAR_SEC(vaporizer, speed), - WEP_CVAR_SEC(vaporizer, spread), - WEP_CVAR_SEC(vaporizer, delay), - WEP_CVAR_SEC(vaporizer, lifetime) - ); - PS(actor).m_weapon = oldwep; - - // now do normal refire - weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready); - } - } - else - actor.held_down = false; - } - METHOD(Vaporizer, wr_setup, void(entity thiswep)) - { - self.ammo_field = (thiswep.ammo_field); - self.vaporizer_lasthit = 0; - } - METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep)) - { - float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); - float ammo_amount = self.(thiswep.ammo_field) >= vaporizer_ammo; - ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo; - return ammo_amount; - } - METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep)) - { - if(!WEP_CVAR_SEC(vaporizer, ammo)) - return true; - float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo); - ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo); - return ammo_amount; - } - METHOD(Vaporizer, wr_resetplayer, void(entity thiswep)) - { - self.vaporizer_lasthit = 0; - } - METHOD(Vaporizer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) - { - float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); - float used_ammo; - if(WEP_CVAR_SEC(vaporizer, ammo)) - used_ammo = min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo)); - else - used_ammo = vaporizer_ammo; - - W_Reload(self, used_ammo, SND(RELOAD)); - } - METHOD(Vaporizer, wr_suicidemessage, int(entity thiswep)) - { - return WEAPON_THINKING_WITH_PORTALS; - } - METHOD(Vaporizer, wr_killmessage, int(entity thiswep)) - { - return WEAPON_VAPORIZER_MURDER; - } +METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor)) +{ + entity this = actor; + if(self.(thiswep.ammo_field) > 0) + PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, 1000000, 0, 1, false); + else + PHYS_INPUT_BUTTON_ATCK2(self) = bot_aim(self, WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars +} +METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) +{ + float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); + // if the laser uses load, we also consider its ammo for reloading + if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload + thiswep.wr_reload(thiswep, actor, weaponentity); + } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.clip_load < vaporizer_ammo) { // forced reload + thiswep.wr_reload(thiswep, actor, weaponentity); + } + if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor)) + { + if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire))) + { + W_Vaporizer_Attack(thiswep, actor); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready); + } + } + if((fire & 2) || ((fire & 1) && !actor.ammo_cells && autocvar_g_rm)) + { + if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2) + { + bool rapid = autocvar_g_rm_laser_rapid; + if(actor.jump_interval <= time && !actor.held_down) + { + if(rapid) + actor.held_down = true; + actor.jump_interval = time + autocvar_g_rm_laser_refire; + actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay; + damage_goodhits = 0; + W_RocketMinsta_Attack2(actor); + } + else if(rapid && actor.jump_interval2 <= time && actor.held_down) + { + actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire; + damage_goodhits = 0; + W_RocketMinsta_Attack3(actor); + //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready); + } + } + else if (actor.jump_interval <= time) + { + // handle refire manually, so that primary and secondary can be fired without conflictions (important for instagib) + actor.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor(); + + // decrease ammo for the laser? + if(WEP_CVAR_SEC(vaporizer, ammo)) + W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(vaporizer, ammo)); + + // ugly instagib hack to reuse the fire mode of the laser + makevectors(actor.v_angle); + Weapon oldwep = PS(actor).m_weapon; // we can't avoid this hack + PS(actor).m_weapon = WEP_BLASTER; + W_Blaster_Attack( + actor, + WEP_BLASTER.m_id | HITTYPE_SECONDARY, + WEP_CVAR_SEC(vaporizer, shotangle), + WEP_CVAR_SEC(vaporizer, damage), + WEP_CVAR_SEC(vaporizer, edgedamage), + WEP_CVAR_SEC(vaporizer, radius), + WEP_CVAR_SEC(vaporizer, force), + WEP_CVAR_SEC(vaporizer, speed), + WEP_CVAR_SEC(vaporizer, spread), + WEP_CVAR_SEC(vaporizer, delay), + WEP_CVAR_SEC(vaporizer, lifetime) + ); + PS(actor).m_weapon = oldwep; + + // now do normal refire + weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready); + } + } + else + actor.held_down = false; +} +METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor)) +{ + entity this = actor; + self.ammo_field = (thiswep.ammo_field); + self.vaporizer_lasthit = 0; +} +METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor)) +{ + float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); + float ammo_amount = actor.(thiswep.ammo_field) >= vaporizer_ammo; + ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo; + return ammo_amount; +} +METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor)) +{ + if(!WEP_CVAR_SEC(vaporizer, ammo)) + return true; + float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo); + ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo); + return ammo_amount; +} +METHOD(Vaporizer, wr_resetplayer, void(entity thiswep, entity actor)) +{ + entity this = actor; + self.vaporizer_lasthit = 0; +} +METHOD(Vaporizer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) +{ + float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); + float used_ammo; + if(WEP_CVAR_SEC(vaporizer, ammo)) + used_ammo = min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo)); + else + used_ammo = vaporizer_ammo; + + W_Reload(actor, used_ammo, SND_RELOAD); +} +METHOD(Vaporizer, wr_suicidemessage, Notification(entity thiswep)) +{ + return WEAPON_THINKING_WITH_PORTALS; +} +METHOD(Vaporizer, wr_killmessage, Notification(entity thiswep)) +{ + return WEAPON_VAPORIZER_MURDER; +} #endif #ifdef CSQC - METHOD(Vaporizer, wr_impacteffect, void(entity thiswep)) - { - vector org2 = w_org + w_backoff * 6; - if(w_deathtype & HITTYPE_SECONDARY) - { - pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1); - if(!w_issilent) { sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); } - } - else - { - pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1); - if(!w_issilent) { sound(self, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM); } - } - } - METHOD(Vaporizer, wr_init, void(entity thiswep)) - { - if(autocvar_cl_reticle && autocvar_cl_reticle_weapon) - { - precache_pic("gfx/reticle_nex"); - } - } - METHOD(Vaporizer, wr_zoomreticle, bool(entity thiswep)) - { - if(button_zoom || zoomscript_caught) - { - reticle_image = "gfx/reticle_nex"; - return true; - } - else - { - // no weapon specific image for this weapon - return false; - } - } +METHOD(Vaporizer, wr_impacteffect, void(entity thiswep, entity actor)) +{ + entity this = actor; + vector org2 = w_org + w_backoff * 6; + if(w_deathtype & HITTYPE_SECONDARY) + { + pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1); + if(!w_issilent) { sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); } + } + else + { + pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1); + if(!w_issilent) { sound(self, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM); } + } +} +METHOD(Vaporizer, wr_init, void(entity thiswep)) +{ + if(autocvar_cl_reticle && autocvar_cl_reticle_weapon) + { + precache_pic("gfx/reticle_nex"); + } +} +METHOD(Vaporizer, wr_zoomreticle, bool(entity thiswep)) +{ + if(button_zoom || zoomscript_caught) + { + reticle_image = "gfx/reticle_nex"; + return true; + } + else + { + // no weapon specific image for this weapon + return false; + } +} #endif #endif