X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fserver%2Fw_laser.qc;h=5f680eb0811935072a312cd92423c3f838451761;hb=88296a0f82b51a5b98d15f7be8032cdf584eec99;hp=870c26627819df6a7af355e508025a016ad5e243;hpb=b4a912024bf4786b87ee5ab789c53befcc48acb2;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/w_laser.qc b/qcsrc/server/w_laser.qc index 870c26627..fa52a6e0d 100644 --- a/qcsrc/server/w_laser.qc +++ b/qcsrc/server/w_laser.qc @@ -1,8 +1,9 @@ #ifdef REGISTER_WEAPON -REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "laser", "laser", "Laser"); +REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "laser", "laser", _("Laser")) #else #ifdef SVQC void(float imp) W_SwitchWeapon; +void() W_LastWeapon; void W_Laser_Touch (void) { @@ -10,9 +11,9 @@ void W_Laser_Touch (void) self.event_damage = SUB_Null; if (self.dmg) - RadiusDamage (self, self.owner, cvar("g_balance_laser_secondary_damage"), cvar("g_balance_laser_secondary_edgedamage"), cvar("g_balance_laser_secondary_radius"), world, cvar("g_balance_laser_secondary_force"), self.projectiledeathtype, other); + RadiusDamage (self, self.realowner, autocvar_g_balance_laser_secondary_damage, autocvar_g_balance_laser_secondary_edgedamage, autocvar_g_balance_laser_secondary_radius, world, autocvar_g_balance_laser_secondary_force, self.projectiledeathtype, other); else - RadiusDamage (self, self.owner, cvar("g_balance_laser_primary_damage"), cvar("g_balance_laser_primary_edgedamage"), cvar("g_balance_laser_primary_radius"), world, cvar("g_balance_laser_primary_force"), self.projectiledeathtype, other); + RadiusDamage (self, self.realowner, autocvar_g_balance_laser_primary_damage, autocvar_g_balance_laser_primary_edgedamage, autocvar_g_balance_laser_primary_radius, world, autocvar_g_balance_laser_primary_force, self.projectiledeathtype, other); remove (self); } @@ -22,9 +23,9 @@ void W_Laser_Think() self.movetype = MOVETYPE_FLY; self.think = SUB_Remove; if (self.dmg) - self.nextthink = time + cvar("g_balance_laser_secondary_lifetime"); + self.nextthink = time + autocvar_g_balance_laser_secondary_lifetime; else - self.nextthink = time + cvar("g_balance_laser_primary_lifetime"); + self.nextthink = time + autocvar_g_balance_laser_primary_lifetime; CSQCProjectile(self, TRUE, PROJECTILE_LASER, TRUE); } @@ -40,45 +41,34 @@ void W_Laser_Attack (float issecondary) else nodamage = FALSE; - if (issecondary == 1) - a = cvar("g_balance_laser_secondary_shotangle"); - else - a = cvar("g_balance_laser_primary_shotangle"); + a = autocvar_g_balance_laser_primary_shotangle; s_forward = v_forward * cos(a * DEG2RAD) + v_up * sin(a * DEG2RAD); if(nodamage) - W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", 0); + W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, 0); else if(issecondary == 1) - W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", cvar("g_balance_laser_secondary_damage")); + W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, autocvar_g_balance_laser_secondary_damage); else - W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", cvar("g_balance_laser_primary_damage")); + W_SetupShot_Dir (self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, autocvar_g_balance_laser_primary_damage); pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1); missile = spawn (); - missile.owner = self; + missile.owner = missile.realowner = self; missile.classname = "laserbolt"; - missile.dmg = (issecondary == 1); + missile.dmg = 0; if(!nodamage) { missile.bot_dodge = TRUE; - if (issecondary == 1) - missile.bot_dodgerating = cvar("g_balance_laser_secondary_damage"); - else - missile.bot_dodgerating = cvar("g_balance_laser_primary_damage"); + missile.bot_dodgerating = autocvar_g_balance_laser_primary_damage; } PROJECTILE_MAKETRIGGER(missile); missile.projectiledeathtype = WEP_LASER; - if(issecondary == 1) - missile.projectiledeathtype |= HITTYPE_SECONDARY; setorigin (missile, w_shotorg); setsize(missile, '0 0 0', '0 0 0'); - if (issecondary == 1) - W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_secondary); - else - W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_primary); + W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_primary); missile.angles = vectoangles (missile.velocity); //missile.glow_color = 250; // 244, 250 //missile.glow_size = 120; @@ -87,10 +77,10 @@ void W_Laser_Attack (float issecondary) missile.flags = FL_PROJECTILE; missile.think = W_Laser_Think; - if (issecondary == 1) - missile.nextthink = time + cvar("g_balance_laser_secondary_delay"); - else - missile.nextthink = time + cvar("g_balance_laser_primary_delay"); + missile.nextthink = time + autocvar_g_balance_laser_primary_delay; + + other = missile; MUTATOR_CALLHOOK(EditProjectile); + if(time >= missile.nextthink) { entity oldself; @@ -106,12 +96,12 @@ float gauntletbeam_send(entity to, float sf) { WriteByte(MSG_ENTITY, ENT_CLIENT_GAUNTLET); sf = sf & 0x7F; - if(sound_allowed(MSG_BROADCAST, self.owner)) + if(sound_allowed(MSG_BROADCAST, self.realowner)) sf |= 0x80; WriteByte(MSG_ENTITY, sf); if(sf & 1) { - WriteByte(MSG_ENTITY, num_for_edict(self.owner)); + WriteByte(MSG_ENTITY, num_for_edict(self.realowner)); } if(sf & 2) { @@ -129,27 +119,16 @@ float gauntletbeam_send(entity to, float sf) } .entity gauntletbeam; .float prevgauntletfire; +entity lgbeam_owner_ent; void gauntletbeam_think() { - vector endpos; - float oldsolid; - float damage, myforce, myradius; - if(self.cnt) - { - damage = cvar("g_balance_laser_secondary_damage"); - myforce = cvar("g_balance_laser_secondary_force"); - myradius = cvar("g_balance_laser_secondary_radius"); - } - else - { - damage = cvar("g_balance_laser_primary_damage"); - myforce = cvar("g_balance_laser_primary_force"); - myradius = cvar("g_balance_laser_primary_radius"); - } + damage = autocvar_g_balance_laser_secondary_damage; + myforce = autocvar_g_balance_laser_secondary_force; + myradius = autocvar_g_balance_laser_secondary_radius; - self.owner.prevgauntletfire = time; - if (self.owner.weaponentity.state != WS_INUSE || self != self.owner.gauntletbeam || self.owner.deadflag != DEAD_NO || (!self.owner.BUTTON_ATCK2 && self.cnt) || (!self.owner.BUTTON_ATCK && !self.cnt)) + self.realowner.prevgauntletfire = time; + if (self.realowner.weaponentity.state != WS_INUSE || self != self.realowner.gauntletbeam || self.realowner.deadflag != DEAD_NO || !self.realowner.BUTTON_ATCK2) { remove(self); return; @@ -157,56 +136,49 @@ void gauntletbeam_think() self.nextthink = time; - makevectors(self.owner.v_angle); - vector angle; - angle = v_forward; - // get effect origin - vector vecs, org; - if(self.owner.weaponentity.movedir_x > 0) - vecs = self.owner.weaponentity.movedir; - else - vecs = '0 0 0'; - if(debug_shotorg != '0 0 0') - vecs = debug_shotorg; - org = self.owner.origin + self.owner.view_ofs + v_forward * vecs_x + v_right * -vecs_y + v_up * vecs_z; - - oldsolid = self.owner.dphitcontentsmask; - self.owner.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE; + makevectors(self.realowner.v_angle); - WarpZone_traceline_antilag(self.owner, self.owner.origin + self.owner.view_ofs, self.owner.origin + self.owner.view_ofs + angle * myradius, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner)); - endpos = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); - WarpZone_traceline_antilag(self.owner, org, endpos + 4 * normalize(endpos - org), MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner)); + float dt; + dt = frametime; - self.owner.dphitcontentsmask = oldsolid; + W_SetupShot_Range(self.realowner, TRUE, 0, "", 0, damage * dt, myradius); + if(!lgbeam_owner_ent) + { + lgbeam_owner_ent = spawn(); + lgbeam_owner_ent.classname = "lgbeam_owner_ent"; + } + WarpZone_traceline_antilag(lgbeam_owner_ent, w_shotorg, w_shotend, MOVE_NORMAL, lgbeam_owner_ent, ANTILAG_LATENCY(self.owner)); // apply the damage - if(trace_fraction < 1) + if(trace_ent) { vector force; - force = angle * myforce; - Damage (trace_ent, self.owner, self.owner, damage * frametime, WEP_ELECTRO, trace_endpos, force * frametime); + force = w_shotdir * myforce; + if(accuracy_isgooddamage(self.owner, trace_ent)) + accuracy_add(self.owner, WEP_LASER, 0, damage * dt); + Damage (trace_ent, self.owner, self.owner, damage * dt, WEP_LASER | HITTYPE_SECONDARY, trace_endpos, force * dt); } // draw effect - if(org != self.hook_start) + if(w_shotorg != self.hook_start) { self.SendFlags |= 2; - self.hook_start = org; + self.hook_start = w_shotorg; } - if(endpos != self.hook_end) + if(w_shotend != self.hook_end) { self.SendFlags |= 4; - self.hook_end = endpos; + self.hook_end = w_shotend; } } // experimental gauntlet -void W_Laser_Attack2 (float issecondary) +void W_Laser_Attack2 () { // only play fire sound if 0.5 sec has passed since player let go the fire button if(time - self.prevgauntletfire > 0.5) { - sound (self, CHAN_WEAPON, "weapons/gauntlet_fire.wav", VOL_BASE, ATTN_NORM); + sound (self, CH_WEAPON_A, "weapons/gauntlet_fire.wav", VOL_BASE, ATTN_NORM); } entity beam, oldself; @@ -218,8 +190,7 @@ void W_Laser_Attack2 (float issecondary) beam.movetype = MOVETYPE_NONE; beam.shot_spread = 0; beam.bot_dodge = TRUE; - beam.bot_dodgerating = cvar("g_balance_laser_primary_damage"); - beam.cnt = issecondary; + beam.bot_dodgerating = autocvar_g_balance_laser_primary_damage; Net_LinkEntity(beam, FALSE, 0, gauntletbeam_send); oldself = self; @@ -248,46 +219,48 @@ float w_laser(float req) local float r2; if (req == WR_AIM) { - if(cvar("g_balance_laser_secondary")) + if(autocvar_g_balance_laser_secondary) { - r1 = cvar("g_balance_laser_primary_damage"); - r2 = cvar("g_balance_laser_secondary_damage"); + r1 = autocvar_g_balance_laser_primary_damage; + r2 = autocvar_g_balance_laser_secondary_damage; if (random() * (r2 + r1) > r1) - self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_laser_secondary_speed"), 0, cvar("g_balance_laser_secondary_lifetime"), FALSE); + self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_secondary_speed, 0, autocvar_g_balance_laser_secondary_lifetime, FALSE); else - self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE); + self.BUTTON_ATCK = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE); } else - self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE); + self.BUTTON_ATCK = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE); } else if (req == WR_THINK) { - if (self.BUTTON_ATCK) - if (weapon_prepareattack(0, cvar("g_balance_laser_primary_refire"))) + if(autocvar_g_balance_laser_reload_ammo && self.clip_load < 1) // forced reload + weapon_action(self.weapon, WR_RELOAD); + else if (self.BUTTON_ATCK) { - if(cvar("g_balance_laser_primary_gauntlet")) - W_Laser_Attack2(0); - else + if (weapon_prepareattack(0, autocvar_g_balance_laser_primary_refire)) + { + W_DecreaseAmmo(ammo_none, 1, TRUE); + W_Laser_Attack(0); - weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_laser_primary_animtime"), w_ready); + weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_laser_primary_animtime, w_ready); + } } - if (self.BUTTON_ATCK2) + else if (self.BUTTON_ATCK2) { - if(cvar("g_balance_laser_secondary")) + if(autocvar_g_balance_laser_secondary) { - if (weapon_prepareattack(0, cvar("g_balance_laser_secondary_refire"))) + W_DecreaseAmmo(ammo_none, 1, TRUE); + + if (weapon_prepareattack(0, 0)) { - if(cvar("g_balance_laser_secondary_gauntlet")) - W_Laser_Attack2(1); - else - W_Laser_Attack(1); - weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_laser_secondary_animtime"), w_ready); + W_Laser_Attack2(); + weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_laser_secondary_animtime, w_ready); } } else { if(self.switchweapon == WEP_LASER) // don't do this if already switching - W_SwitchWeapon (self.cnt); + W_LastWeapon(); } } } @@ -298,13 +271,25 @@ float w_laser(float req) precache_model ("models/weapons/h_laser.iqm"); precache_sound ("weapons/lasergun_fire.wav"); precache_sound ("weapons/gauntlet_fire.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_LASER); + self.current_ammo = ammo_none; + } else if (req == WR_CHECKAMMO1) + { return TRUE; + } else if (req == WR_CHECKAMMO2) + { return TRUE; + } + else if (req == WR_RELOAD) + { + W_Reload(0, autocvar_g_balance_laser_reload_ammo, autocvar_g_balance_laser_reload_time, "weapons/reload.wav"); + } return TRUE; }; #endif @@ -317,17 +302,20 @@ float w_laser(float req) org2 = w_org + w_backoff * 6; pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1); if(!w_issilent) - sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM); } else if(req == WR_PRECACHE) { precache_sound("weapons/laserimpact.wav"); } else if (req == WR_SUICIDEMESSAGE) - w_deathtypestring = "lasered themself to hell"; + w_deathtypestring = _("%s lasered themself to hell"); else if (req == WR_KILLMESSAGE) { - w_deathtypestring = "was lasered to death by"; // unchecked: SPLASH + if(w_deathtype & HITTYPE_SECONDARY) + w_deathtypestring = _("%s was cut in half by %s's gauntlet"); // unchecked: SPLASH + else + w_deathtypestring = _("%s was lasered to death by %s"); // unchecked: SPLASH } return TRUE; }