X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Fturret%2Fphaser_weapon.qc;h=bf901d886a77e407292d8d208d20f37819f5b8cc;hb=916208f493631fae1c27eda45084e54a574a2944;hp=ac817703e8f9282e0443c3f9ead699ddabe314fc;hpb=93f6c1c41d7a17718dfbf7b464c319a9716643f4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/turrets/turret/phaser_weapon.qc b/qcsrc/common/turrets/turret/phaser_weapon.qc index ac817703e..bf901d886 100644 --- a/qcsrc/common/turrets/turret/phaser_weapon.qc +++ b/qcsrc/common/turrets/turret/phaser_weapon.qc @@ -1,105 +1,91 @@ -#ifndef TURRET_PHASER_WEAPON_H -#define TURRET_PHASER_WEAPON_H - -CLASS(PhaserTurretAttack, PortoLaunch) -/* flags */ ATTRIB(PhaserTurretAttack, spawnflags, int, WEP_TYPE_OTHER); -/* impulse */ ATTRIB(PhaserTurretAttack, impulse, int, 9); -/* refname */ ATTRIB(PhaserTurretAttack, netname, string, "turret_phaser"); -/* wepname */ ATTRIB(PhaserTurretAttack, message, string, _("Phaser")); -ENDCLASS(PhaserTurretAttack) -REGISTER_WEAPON(PHASER, NEW(PhaserTurretAttack)); - -#endif +#include "phaser_weapon.qh" #ifdef IMPLEMENTATION #ifdef SVQC -void beam_think(); +void beam_think(entity this); .int fireflag; - -METHOD(PhaserTurretAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) +SOUND(PhaserTurretAttack_FIRE, W_Sound("electro_fire")); +METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); - if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) { + bool isPlayer = IS_PLAYER(actor); + if (fire & 1) + if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - self.shot_speed = 1; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_PhaserTurretAttack_FIRE, CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + actor.shot_speed = 1; + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } entity beam = spawn(); beam.ticrate = 0.1; //autocvar_sys_ticrate; setmodel(beam, MDL_TUR_PHASER_BEAM); beam.effects = EF_LOWPRECISION; beam.solid = SOLID_NOT; - beam.think = beam_think; - beam.cnt = time + self.shot_speed; + setthink(beam, beam_think); + beam.cnt = time + actor.shot_speed; beam.shot_spread = time + 2; beam.nextthink = time; - beam.owner = self; - beam.shot_dmg = self.shot_dmg / (self.shot_speed / beam.ticrate); - beam.scale = self.target_range / 256; - beam.movetype = MOVETYPE_NONE; - beam.enemy = self.enemy; + beam.owner = actor; + beam.shot_dmg = actor.shot_dmg / (actor.shot_speed / beam.ticrate); + beam.scale = actor.target_range / 256; + set_movetype(beam, MOVETYPE_NONE); + beam.enemy = actor.enemy; beam.bot_dodge = true; + IL_PUSH(g_bot_dodge, beam); beam.bot_dodgerating = beam.shot_dmg; sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM); - self.fireflag = 1; + actor.fireflag = 1; - beam.attack_finished_single = self.attack_finished_single; - self.attack_finished_single = time; // + autocvar_sys_ticrate; + beam.attack_finished_single[0] = actor.attack_finished_single[0]; + actor.attack_finished_single[0] = time; // + autocvar_sys_ticrate; - setattachment(beam,self.tur_head, "tag_fire"); + setattachment(beam,actor.tur_head, "tag_fire"); - soundat (self, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM); + soundat (actor, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM); if (!isPlayer) - if (self.tur_head.frame == 0) - self.tur_head.frame = 1; + if (actor.tur_head.frame == 0) + actor.tur_head.frame = 1; } - return true; } -void beam_think() -{SELFPARAM(); - if ((time > self.cnt) || (self.owner.deadflag != DEAD_NO)) +void beam_think(entity this) +{ + if ((time > this.cnt) || (IS_DEAD(this.owner))) { - self.owner.attack_finished_single = time + self.owner.shot_refire; - self.owner.fireflag = 2; - self.owner.tur_head.frame = 10; - sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); - remove(self); + this.owner.attack_finished_single[0] = time + this.owner.shot_refire; + this.owner.fireflag = 2; + this.owner.tur_head.frame = 10; + sound (this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); + delete(this); return; } - turret_do_updates(self.owner); + turret_do_updates(this.owner); - if (time - self.shot_spread > 0) + if (time - this.shot_spread > 0) { - self.shot_spread = time + 2; - sound (self, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM); + this.shot_spread = time + 2; + sound (this, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM); } - self.nextthink = time + self.ticrate; + this.nextthink = time + this.ticrate; - self.owner.attack_finished_single = time + frametime; - setself(self.owner); - FireImoBeam ( self.tur_shotorg, - self.tur_shotorg + self.tur_shotdir_updated * self.target_range, - '-1 -1 -1' * self.shot_radius, - '1 1 1' * self.shot_radius, - self.shot_force, + this.owner.attack_finished_single[0] = time + frametime; + FireImoBeam ( this.owner, this.tur_shotorg, + this.tur_shotorg + this.tur_shotdir_updated * this.target_range, + '-1 -1 -1' * this.shot_radius, + '1 1 1' * this.shot_radius, + this.shot_force, this.shot_dmg, 0.75, - DEATH_TURRET_PHASER); - setself(this); - self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256; + DEATH_TURRET_PHASER.m_id); + this.scale = vlen(this.owner.tur_shotorg - trace_endpos) / 256; }