X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fw_laser.qc;h=3da9e422b5c377799d9556013c41a2b2d3dfaaa8;hb=d0048a7d590a5485313c93328627b9df7a2ca47f;hp=33a9c164d42793fc16d15be54b8b933b44c553a5;hpb=a3e6c5697b452f706c2fa226c4de1939928beb1f;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/w_laser.qc b/qcsrc/server/w_laser.qc index 33a9c164d..3da9e422b 100644 --- a/qcsrc/server/w_laser.qc +++ b/qcsrc/server/w_laser.qc @@ -1,53 +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_Laser_SetAmmoCounter() -{ - // set clip_load to the weapon we have switched to, if the gun uses reloading - if(!autocvar_g_balance_laser_reload_ammo) - self.clip_load = 0; // also keeps crosshair ammo from displaying - else - { - self.clip_load = self.laser_load; - self.clip_size = autocvar_g_balance_laser_reload_ammo; // for the crosshair ammo display - } -} - -void W_Laser_ReloadedAndReady() -{ - float t; - - self.clip_load = autocvar_g_balance_laser_reload_ammo; // maximum load since this weapon uses no ammo - self.laser_load = self.clip_load; - - t = ATTACK_FINISHED(self) - autocvar_g_balance_laser_reload_time - 1; - ATTACK_FINISHED(self) = t; - w_ready(); -} - -void W_Laser_Reload() -{ - // return if reloading is disabled for this weapon - if(!autocvar_g_balance_laser_reload_ammo) - return; - - if(!W_ReloadCheck(1, 0)) - return; - - float t; - - sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM); - - t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_laser_reload_time + 1; - ATTACK_FINISHED(self) = t; - - weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_laser_reload_time, W_Laser_ReloadedAndReady); - - self.clip_load = -1; -} +void() W_LastWeapon; void W_Laser_Touch (void) { @@ -55,9 +11,9 @@ void W_Laser_Touch (void) self.event_damage = SUB_Null; if (self.dmg) - RadiusDamage (self, self.owner, 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); + 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, 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); + 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); } @@ -75,7 +31,7 @@ void W_Laser_Think() void W_Laser_Attack (float issecondary) { - local entity missile; + entity missile; vector s_forward; float a; float nodamage; @@ -89,15 +45,15 @@ void W_Laser_Attack (float issecondary) 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", CHAN_WEAPON2, 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", CHAN_WEAPON2, autocvar_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", CHAN_WEAPON2, autocvar_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 = 0; if(!nodamage) @@ -140,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) { @@ -163,6 +119,7 @@ float gauntletbeam_send(entity to, float sf) } .entity gauntletbeam; .float prevgauntletfire; +entity lgbeam_owner_ent; void gauntletbeam_think() { float damage, myforce, myradius; @@ -170,8 +127,8 @@ void gauntletbeam_think() 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.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; @@ -179,13 +136,18 @@ void gauntletbeam_think() self.nextthink = time; - makevectors(self.owner.v_angle); + makevectors(self.realowner.v_angle); float dt; dt = frametime; - W_SetupShot_Range(self.owner, TRUE, 0, "", 0, damage * dt, myradius); - WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner)); + 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_ent) @@ -216,7 +178,7 @@ 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; @@ -253,8 +215,8 @@ void spawnfunc_weapon_laser (void) float w_laser(float req) { - local float r1; - local float r2; + float r1; + float r2; if (req == WR_AIM) { if(autocvar_g_balance_laser_secondary) @@ -272,20 +234,12 @@ float w_laser(float req) else if (req == WR_THINK) { if(autocvar_g_balance_laser_reload_ammo && self.clip_load < 1) // forced reload - W_Laser_Reload(); + weapon_action(self.weapon, WR_RELOAD); else if (self.BUTTON_ATCK) { if (weapon_prepareattack(0, autocvar_g_balance_laser_primary_refire)) { - // if this weapon is reloadable, decrease its load - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_laser_reload_ammo) - { - self.clip_load -= 1; - self.laser_load = self.clip_load; - } - } + W_DecreaseAmmo(ammo_none, 1, TRUE); W_Laser_Attack(0); weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_laser_primary_animtime, w_ready); @@ -295,15 +249,7 @@ float w_laser(float req) { if(autocvar_g_balance_laser_secondary) { - // if this weapon is reloadable, decrease its load - if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - { - if(autocvar_g_balance_laser_reload_ammo) - { - self.clip_load -= 1; - self.laser_load = self.clip_load; - } - } + W_DecreaseAmmo(ammo_none, 1, TRUE); if (weapon_prepareattack(0, 0)) { @@ -314,20 +260,9 @@ float w_laser(float req) else { if(self.switchweapon == WEP_LASER) // don't do this if already switching - W_SwitchWeapon (self.cnt); + W_LastWeapon(); } } - if(self.wish_reload) - { - if(self.switchweapon == self.weapon) - { - if(self.weaponentity.state == WS_READY) - { - self.wish_reload = 0; - W_Laser_Reload(); - } - } - } } else if (req == WR_PRECACHE) { @@ -336,21 +271,27 @@ 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"); + //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); - W_Laser_SetAmmoCounter(); + 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_Laser_Reload(); + { + W_Reload(0, autocvar_g_balance_laser_reload_ammo, autocvar_g_balance_laser_reload_time, "weapons/reload.wav"); + } return TRUE; -}; +} #endif #ifdef CSQC float w_laser(float req) @@ -361,20 +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 = "%s lasered themself to hell"; + w_deathtypestring = _("%s lasered themself to hell"); else if (req == WR_KILLMESSAGE) { if(w_deathtype & HITTYPE_SECONDARY) - w_deathtypestring = "%s was cut in half by %s's gauntlet"; // unchecked: SPLASH + 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 + w_deathtypestring = _("%s was lasered to death by %s"); // unchecked: SPLASH } return TRUE; }