]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/turret/phaser_weapon.qc
Simplify progs.inc
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / phaser_weapon.qc
index aa71a47d008c08eac2cb62139a4c7170c566936c..440bdf6a7299a6271363f3968b03a55d258d0db5 100644 (file)
@@ -1,15 +1,4 @@
-#ifndef TURRET_PHASER_WEAPON_H
-#define TURRET_PHASER_WEAPON_H
-
-CLASS(PhaserTurretAttack, PortoLaunch)
-/* flags     */ ATTRIB(PhaserTurretAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
-/* 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
 
@@ -17,20 +6,20 @@ REGISTER_WEAPON(PHASER, NEW(PhaserTurretAttack));
 void beam_think();
 
 .int fireflag;
-
-METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+SOUND(PhaserTurretAttack_FIRE, W_Sound("electro_fire"));
+METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
     bool isPlayer = IS_PLAYER(actor);
-    if (fire1)
-    if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+    if (fire & 1)
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
         if (isPlayer) {
             turret_initparams(actor);
-            W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
+            W_SetupShot_Dir(actor, 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, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
         entity beam = spawn();
         beam.ticrate = 0.1; //autocvar_sys_ticrate;
@@ -51,8 +40,8 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, bool fir
         sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
         actor.fireflag = 1;
 
-        beam.attack_finished_single = actor.attack_finished_single;
-        actor.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,actor.tur_head, "tag_fire");
 
@@ -65,9 +54,9 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, bool fir
 
 void beam_think()
 {SELFPARAM();
-    if ((time > self.cnt) || (self.owner.deadflag != DEAD_NO))
+    if ((time > self.cnt) || (IS_DEAD(self.owner)))
     {
-        self.owner.attack_finished_single = time + self.owner.shot_refire;
+        self.owner.attack_finished_single[0] = 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);
@@ -86,7 +75,7 @@ void beam_think()
 
     self.nextthink = time + self.ticrate;
 
-    self.owner.attack_finished_single = time + frametime;
+    self.owner.attack_finished_single[0] = time + frametime;
     setself(self.owner);
     FireImoBeam (   self.tur_shotorg,
                     self.tur_shotorg + self.tur_shotdir_updated * self.target_range,
@@ -95,7 +84,7 @@ void beam_think()
                     self.shot_force,
                     this.shot_dmg,
                     0.75,
-                    DEATH_TURRET_PHASER);
+                    DEATH_TURRET_PHASER.m_id);
     setself(this);
     self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;