]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Turrets: delete 401 lines
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 30 Sep 2015 22:43:07 +0000 (08:43 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 30 Sep 2015 22:43:07 +0000 (08:43 +1000)
19 files changed:
qcsrc/common/turrets/all.qh
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/turrets/config.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/sv_turrets.qh
qcsrc/common/turrets/turret.qh
qcsrc/common/turrets/turret/ewheel.qc
qcsrc/common/turrets/turret/flac.qc
qcsrc/common/turrets/turret/fusionreactor.qc
qcsrc/common/turrets/turret/hellion.qc
qcsrc/common/turrets/turret/hk.qc
qcsrc/common/turrets/turret/machinegun.qc
qcsrc/common/turrets/turret/mlrs.qc
qcsrc/common/turrets/turret/phaser.qc
qcsrc/common/turrets/turret/plasma.qc
qcsrc/common/turrets/turret/plasma_dual.qc
qcsrc/common/turrets/turret/tesla.qc
qcsrc/common/turrets/turret/walker.qc
qcsrc/common/weapons/all.qh

index 1a464c1268bf435c7bfe1dbf3dc151866d845612..87a30c9206be80a234e6a9cd50ac0e7f7b50172c 100644 (file)
@@ -3,59 +3,18 @@
 
 #include "turret.qh"
 
-void register_turret(Turret e, bool(Turret, int) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname);
-
 const int TUR_MAXCOUNT = 24;
 entity turret_info[TUR_MAXCOUNT], turret_info_first, turret_info_last;
 float TUR_COUNT;
 
-#define _REGISTER_TURRET(id, func, turretflags, min_s, max_s, modelname, headmodelname, shortname, mname) \
-       bool func(Turret, int); \
-       REGISTER(RegisterTurrets, TUR, turret_info, TUR_COUNT, id, m_id, NEW(Turret)) { \
-               register_turret(this, func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname); \
-       }
 void RegisterTurrets();
 REGISTER_REGISTRY(RegisterTurrets)
 
-#define REGISTER_TURRET(...) EVAL(OVERLOAD(REGISTER_TURRET, __VA_ARGS__))
-
-#define REGISTER_TURRET_2(id, inst) REGISTER(RegisterTurrets, TUR, turret_info, TUR_COUNT, id, m_id, inst)
-
-#ifdef MENUQC
-#define REGISTER_TURRET_9(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
-       _REGISTER_TURRET(id,t_new,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
-#else
-#define REGISTER_TURRET_9(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
-       _REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
-#endif
-
-void register_turret(Turret e, bool(Turret, int) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname)
-{
-       e.classname = "turret_info";
-
-       e.turret_func = func;
-       e.spawnflags = turretflags;
-       e.mins = min_s;
-       e.maxs = max_s;
-       e.mdl = modelname;
-       e.model = strzone(strcat("models/turrets/", modelname));
-       e.head_model = strzone(strcat("models/turrets/", headmodelname));
-       e.netname = shortname;
-       e.turret_name = mname;
-}
+#define REGISTER_TURRET(id, inst) REGISTER(RegisterTurrets, TUR, turret_info, TUR_COUNT, id, m_id, inst)
 
 entity get_turretinfo(int id);
 
-REGISTER_TURRET(Null,
-       t_new,
-       0,
-       '-0 -0 -0',
-       '0 0 0',
-       "",
-       "",
-       "",
-       "Turret"
-);
+REGISTER_TURRET(Null, NEW(Turret));
 
 #include "all.inc"
 
index 3de0e95b1ddfa90f00fd89dd56448810faefa375..03cb16b886b8ee7573c806ac96a26f41e8ddb8be 100644 (file)
@@ -208,7 +208,7 @@ void turret_construct()
        if(self.tur_head == world)
                self.tur_head = spawn();
 
-       self.netname = TUR_NAME(self.m_id);
+       self.netname = tur.turret_name;
 
        setorigin(self, self.origin);
        _setmodel(self, tur.model);
@@ -241,7 +241,7 @@ void turret_construct()
        self.teamradar_color = '1 0 0';
        self.alpha = 1;
 
-       TUR_ACTION(self.m_id, TR_SETUP);
+       tur.tr_setup(tur, self);
 }
 
 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
index 1a8c2cbe7705e4bf9bf3f037eb37aa8d48107b97..e052d6c1cfcf33dbdc1f388c2eb5aa732bfbb542 100644 (file)
@@ -35,19 +35,19 @@ void Dump_Turret_Settings(void)
                        { tur_config_queue[x] = string_null; }
 
                // step 2: build new queue
-               TUR_ACTION(i, TR_CONFIG);
+               it.tr_config(it);
 
                // step 3: sort queue
                heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, world);
 
                // step 4: write queue
-               TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, TUR_NAME(i)))
+               TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name))
                for(x = 0; x <= TUR_CONFIG_COUNT; ++x)
                        { TUR_CONFIG_WRITETOFILE(tur_config_queue[x]) }
                TUR_CONFIG_WRITETOFILE("// }}}\n")
 
                // step 5: debug info
-               LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, TUR_NAME(i), TUR_CONFIG_COUNT));
+               LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, it.turret_name, TUR_CONFIG_COUNT));
                totalsettings += TUR_CONFIG_COUNT;
        }));
 
index ce04086e7c3d8c35bf1dbe8d2f9e7b44df676bdc..a53a81e90aeca2f7f091ccc00eda1b0dfa0a7c12 100644 (file)
@@ -188,9 +188,10 @@ void turret_die()
 // Go boom
        //RadiusDamage (self,self, min(self.ammo,50),min(self.ammo,50) * 0.25,250,world,min(self.ammo,50)*5,DEATH_TURRET,world);
 
+       Turret tur = get_turretinfo(self.m_id);
        if(self.damage_flags & TFL_DMG_DEATH_NORESPAWN)
        {
-               TUR_ACTION(self.m_id, TR_DEATH);
+               tur.tr_death(tur, self);
 
                remove(self.tur_head);
                remove(self);
@@ -202,7 +203,7 @@ void turret_die()
                self.nextthink   = time + 0.2;
                self.think               = turret_hide;
 
-               TUR_ACTION(self.m_id, TR_DEATH);
+               tur.tr_death(tur, self);
        }
 }
 
@@ -275,7 +276,8 @@ void turret_respawn()
 
        self.SendFlags = TNSF_FULL_UPDATE;
 
-       TUR_ACTION(self.m_id, TR_SETUP);
+       Turret tur = get_turretinfo(self.m_id);
+       tur.tr_setup(tur, self);
 }
 
 
@@ -419,8 +421,10 @@ void load_unit_settings(entity ent, float is_reload)
        ent.track_accel_rotate  = cvar(strcat(sbase,"_track_accel_rot"));
        ent.track_blendrate  = cvar(strcat(sbase,"_track_blendrate"));
 
-       if(is_reload)
-               TUR_ACTION(self.m_id, TR_SETUP);
+       if(is_reload) {
+               Turret tur = get_turretinfo(self.m_id);
+               tur.tr_setup(tur, self);
+       }
 }
 
 void turret_projectile_explode()
@@ -1119,7 +1123,8 @@ void turret_think()
                                if (turret_checkfire())
                                        turret_fire();
 
-                               TUR_ACTION(self.m_id, TR_THINK);
+                               Turret tur = get_turretinfo(self.m_id);
+                               tur.tr_think(tur);
 
                                return;
                        }
@@ -1157,7 +1162,8 @@ void turret_think()
                        if(!(self.track_flags & TFL_TRACK_NO))
                                turret_track();
 
-                       TUR_ACTION(self.m_id, TR_THINK);
+                       Turret tur = get_turretinfo(self.m_id);
+                       tur.tr_think(tur);
 
                        // And bail.
                        return;
@@ -1180,7 +1186,8 @@ void turret_think()
                        turret_fire();
        }
 
-       TUR_ACTION(self.m_id, TR_THINK);
+       Turret tur = get_turretinfo(self.m_id);
+       tur.tr_think(tur);
 }
 
 /*
@@ -1221,7 +1228,8 @@ void turrets_manager_think()
                        if (IS_TURRET(e))
                        {
                                load_unit_settings(e,1);
-                               TUR_ACTION(self.m_id, TR_THINK);
+                               Turret tur = get_turretinfo(self.m_id);
+                               tur.tr_think(tur);
                        }
 
                        e = nextent(e);
@@ -1259,19 +1267,20 @@ void turret_initparams(entity tur)
        #undef TRY
 }
 
-float turret_initialize(float tur_id)
+float turret_initialize(Turret tur)
 {SELFPARAM();
        if(!autocvar_g_turrets)
                return false;
 
-       entity e;
-       entity tur = get_turretinfo(tur_id);
        if(tur.m_id == 0)
                return false; // invalid turret
 
-       if(!self.tur_head) { TUR_ACTION(tur_id, TR_PRECACHE); } // if tur_head exists, we can assume this turret re-spawned
+       // if tur_head exists, we can assume this turret re-spawned
+       if(!self.tur_head) {
+               tur.tr_precache(tur);
+       }
 
-       e = find(world, classname, "turret_manager");
+       entity e = find(world, classname, "turret_manager");
        if(!e)
        {
                e = spawn();
@@ -1339,11 +1348,11 @@ float turret_initialize(float tur_id)
        _setmodel(self, tur.model);
        setsize(self, tur.mins, tur.maxs);
 
-       self.m_id                                       = tur_id;
+       self.m_id                                       = tur.m_id;
        self.classname                          = "turret_main";
        self.active                                     = ACTIVE_ACTIVE;
        self.effects                            = EF_NODRAW;
-       self.netname                            = TUR_NAME(tur_id);
+       self.netname                            = tur.turret_name;
        self.ticrate                            = bound(sys_frametime, self.ticrate, 60);
        self.max_health                         = self.health;
        self.target_validate_flags      = self.target_select_flags;
@@ -1403,7 +1412,7 @@ float turret_initialize(float tur_id)
        turret_respawn();
        turret_tag_fire_update();
 
-       TUR_ACTION(tur_id, TR_SETUP);
+       tur.tr_setup(tur, self);
 
        if(MUTATOR_CALLHOOK(TurretSpawn, self))
                return false;
index 4eca2c6fb1f9d0ac864d58881c4174a9b0b9081d..2d5a5f5f9d00526e67b110d8f9849a42a203efb2 100644 (file)
@@ -87,7 +87,7 @@ void turret_do_updates(entity e_turret);
 
 void turrets_setframe(float _frame, float client_only);
 
-float turret_initialize(float tur_id);
+float turret_initialize(Turret tur);
 
 /// Function to use for target evaluation. usualy turret_targetscore_generic
 .float(entity _turret, entity _target) turret_score_target;
index a2c934277c280a5d6db959f945b09faa837f0220..edf1d5b573f9cd44ba2d45b4c9da6b89e4db33d7 100644 (file)
@@ -1,8 +1,58 @@
 #ifndef TURRET_H
 #define TURRET_H
 
-// functions:
-entity get_turretinfo(int id);
+#include "../weapons/all.qh"
+
+CLASS(Turret, Object)
+    ATTRIB(Turret, m_id, int, 0)
+
+    /** short name */
+    ATTRIB(Turret, netname, string, string_null)
+    /** human readable name */
+    ATTRIB(Turret, turret_name, string, _("Turret"))
+    /** currently a copy of the model */
+    ATTRIB(Turret, mdl, string, string_null)
+    /** full name of model */
+    ATTRIB(Turret, model, string, string_null)
+    /** full name of tur_head model */
+    ATTRIB(Turret, head_model, string, string_null)
+
+    ATTRIB(Turret, spawnflags, int, 0)
+    /** turret hitbox size */
+    ATTRIB(Turret, mins, vector, '-0 -0 -0')
+    /** turret hitbox size */
+    ATTRIB(Turret, maxs, vector, '0 0 0')
+
+    METHOD(Turret, display, void(entity this, void(string name, string icon) returns)) {
+        returns(this.turret_name, string_null);
+    }
+    /** (BOTH) setup turret data */
+    METHOD(Turret, tr_setup, void(Turret this, entity it)) {
+
+    }
+    /** (SERVER) logic to run every frame */
+    METHOD(Turret, tr_think, void(Turret this)) {
+
+    }
+    /** (SERVER) called when turret dies */
+    METHOD(Turret, tr_death, void(Turret this, entity it)) {
+
+    }
+    /** (BOTH) precaches models/sounds used by this turret */
+    METHOD(Turret, tr_precache, void(Turret this)) {
+
+    }
+    ATTRIB(Turret, m_weapon, Weapon, WEP_Null)
+    /** (SERVER) called when turret attacks */
+    METHOD(Turret, tr_attack, void(Turret this)) {
+        Weapon w = this.m_weapon;
+        w.wr_think(w, true, false);
+    }
+    /** (ALL) */
+    METHOD(Turret, tr_config, void(Turret this)) {
+        // TODO
+    }
+ENDCLASS(Turret)
 
 // fields:
 .entity tur_head;
@@ -124,64 +174,4 @@ const int TNSF_ANIM         = 128;
 
 const int TNSF_FULL_UPDATE  = 16777215;
 
-
-// other useful macros
-#define _TUR_ACTION(tur, mrequest) tur.turret_func(tur, mrequest)
-#define TUR_ACTION(tur, mrequest) _TUR_ACTION(get_turretinfo(tur), mrequest)
-#define TUR_NAME(turrettype) (get_turretinfo(turrettype)).turret_name
-
-bool t_new(entity this, int req);
-
-CLASS(Turret, Object)
-    ATTRIB(Turret, m_id, int, 0)
-
-    /** short name */
-    ATTRIB(Turret, netname, string, string_null)
-    /** human readable name */
-    ATTRIB(Turret, turret_name, string, string_null)
-    /** t_... */
-    ATTRIB(Turret, turret_func, float(Turret, int), t_new)
-    /** currently a copy of the model */
-    ATTRIB(Turret, mdl, string, string_null)
-    /** full name of model */
-    ATTRIB(Turret, model, string, string_null)
-    /** full name of tur_head model */
-    ATTRIB(Turret, head_model, string, string_null)
-
-    ATTRIB(Turret, spawnflags, int, 0)
-    /** turret hitbox size */
-    ATTRIB(Turret, mins, vector, '-0 -0 -0')
-    /** turret hitbox size */
-    ATTRIB(Turret, maxs, vector, '0 0 0')
-
-    METHOD(Turret, display, void(entity this, void(string name, string icon) returns)) {
-        returns(this.turret_name, string_null);
-    }
-
-ENDCLASS(Turret)
-
-// turret requests
-const int TR_SETUP = 1; // (BOTH) setup turret data
-.bool(Turret) tr_setup;
-const int TR_THINK = 2; // (SERVER) logic to run every frame
-.bool(Turret) tr_think;
-const int TR_DEATH = 3; // (SERVER) called when turret dies
-.bool(Turret) tr_death;
-const int TR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this turret
-.bool(Turret) tr_precache;
-/** (SERVER) called when turret attacks */
-.void(Turret) tr_attack;
-const int TR_CONFIG = 6; // (ALL)
-.bool(Turret) tr_config;
-
-bool t_new(Turret this, int req)
-{
-    if (req == TR_SETUP) return this.tr_setup ? this.tr_setup(this) : false;
-    if (req == TR_THINK) return this.tr_think ? this.tr_think(this) : false;
-    if (req == TR_DEATH) return this.tr_death ? this.tr_death(this) : false;
-    if (req == TR_PRECACHE) return this.tr_precache ? this.tr_precache(this) : false;
-    if (req == TR_CONFIG) return this.tr_config ? this.tr_config(this) : false;
-    return false;
-}
-
 #endif
index 81336a4951ba84d1f5dc7084f2837d0ef84efec0..b725c029f861b53bd907a41b2c7722cbdcb7f99b 100644 (file)
@@ -1,6 +1,16 @@
 #ifndef TUR_EWHEEL_H
 #define TUR_EWHEEL_H
 
+CLASS(EWheelAttack, PortoLaunch)
+/* flags     */ ATTRIB(EWheelAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(EWheelAttack, impulse, int, 5);
+/* refname   */ ATTRIB(EWheelAttack, netname, string, "turret_ewheel");
+/* wepname   */ ATTRIB(EWheelAttack, message, string, _("eWheel"));
+ENDCLASS(EWheelAttack)
+REGISTER_WEAPON(EWHEEL, NEW(EWheelAttack));
+
+//#define EWHEEL_FANCYPATH
+
 CLASS(EWheel, Turret)
 /* spawnflags */ ATTRIB(EWheel, spawnflags, int, TUR_FLAG_PLAYER | TUR_FLAG_MOVE | TUR_FLAG_ROAM);
 /* mins       */ ATTRIB(EWheel, mins, vector, '-32 -32 0');
@@ -10,18 +20,10 @@ CLASS(EWheel, Turret)
 /* head_model */ ATTRIB(EWheel, head_model, string, strzone(strcat("models/turrets/", "ewheel-gun1.md3")));
 /* netname    */ ATTRIB(EWheel, netname, string, "ewheel");
 /* fullname   */ ATTRIB(EWheel, turret_name, string, _("eWheel Turret"));
+    ATTRIB(EWheel, m_weapon, Weapon, WEP_EWHEEL);
 ENDCLASS(EWheel)
-
 REGISTER_TURRET(EWHEEL, NEW(EWheel));
 
-CLASS(EWheelAttack, PortoLaunch)
-/* flags     */ ATTRIB(EWheelAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(EWheelAttack, impulse, int, 5);
-/* refname   */ ATTRIB(EWheelAttack, netname, string, "turret_ewheel");
-/* wepname   */ ATTRIB(EWheelAttack, message, string, _("eWheel"));
-ENDCLASS(EWheelAttack)
-REGISTER_WEAPON(EWHEEL, NEW(EWheelAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
@@ -70,7 +72,6 @@ const float ewheel_anim_fwd_fast = 2;
 const float ewheel_anim_bck_slow = 3;
 const float ewheel_anim_bck_fast = 4;
 
-//#define EWHEEL_FANCYPATH
 void ewheel_move_path()
 {SELFPARAM();
 #ifdef EWHEEL_FANCYPATH
@@ -168,15 +169,9 @@ void ewheel_move_idle()
         movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
 }
 
-void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL.m_id)) remove(self); }
+void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL)) remove(self); }
 
-        METHOD(EWheel, tr_attack, void(EWheel thistur))
-        {
-            SELFPARAM();
-            Weapon wep = WEP_EWHEEL;
-            wep.wr_think(wep, true, false);
-        }
-        METHOD(EWheel, tr_think, bool(EWheel thistur))
+        METHOD(EWheel, tr_think, void(EWheel thistur))
         {
             SELFPARAM();
             float vz;
@@ -209,41 +204,35 @@ void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL.m
 
             if(vlen(self.velocity))
                 self.SendFlags |= TNSF_MOVE;
-
-            return true;
         }
-        METHOD(EWheel, tr_death, bool(EWheel thistur))
+        METHOD(EWheel, tr_death, void(EWheel this, entity it))
         {
-            SELFPARAM();
-            self.velocity = '0 0 0';
+            it.velocity = '0 0 0';
 
 #ifdef EWHEEL_FANCYPATH
             if (self.pathcurrent)
-                pathlib_deletepath(self.pathcurrent.owner);
+                pathlib_deletepath(it.pathcurrent.owner);
 #endif
-            self.pathcurrent = world;
-
-            return true;
+            it.pathcurrent = NULL;
         }
-        METHOD(EWheel, tr_setup, bool(EWheel thistur))
+        METHOD(EWheel, tr_setup, void(EWheel this, entity it))
         {
-            SELFPARAM();
             entity e;
 
-            if(self.movetype == MOVETYPE_WALK)
+            if(it.movetype == MOVETYPE_WALK)
             {
-                self.velocity = '0 0 0';
-                self.enemy = world;
+                it.velocity = '0 0 0';
+                it.enemy = world;
 
-                setorigin(self, self.pos1);
+                setorigin(it, it.pos1);
 
-                if (self.target != "")
+                if (it.target != "")
                 {
-                    e = find(world, targetname, self.target);
+                    e = find(world, targetname, it.target);
                     if (!e)
                     {
                         LOG_TRACE("Initital waypoint for ewheel does NOT exsist, fix your map!\n");
-                        self.target = "";
+                        it.target = "";
                     }
 
                     if (e.classname != "turret_checkpoint")
@@ -252,37 +241,31 @@ void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL.m
                     {
 
 #ifdef EWHEEL_FANCYPATH
-                        self.pathcurrent = WALKER_PATH(self.origin,e.origin);
-                        self.pathgoal = e;
+                        it.pathcurrent = WALKER_PATH(it.origin,e.origin);
+                        it.pathgoal = e;
 #else
-                        self.pathcurrent  = e;
+                        it.pathcurrent  = e;
 #endif
                     }
                 }
             }
 
-            self.iscreature                            = true;
-            self.teleportable                  = TELEPORT_NORMAL;
-            self.damagedbycontents             = true;
-            self.movetype                              = MOVETYPE_WALK;
-            self.solid                                 = SOLID_SLIDEBOX;
-            self.takedamage                            = DAMAGE_AIM;
-            self.idle_aim                              = '0 0 0';
-            self.pos1                                  = self.origin;
-            self.target_select_flags   = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
-            self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
-            self.frame                                 = self.tur_head.frame = 1;
-            self.ammo_flags                            = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
+            it.iscreature                              = true;
+            it.teleportable                    = TELEPORT_NORMAL;
+            it.damagedbycontents               = true;
+            it.movetype                                = MOVETYPE_WALK;
+            it.solid                                   = SOLID_SLIDEBOX;
+            it.takedamage                              = DAMAGE_AIM;
+            it.idle_aim                                = '0 0 0';
+            it.pos1                                    = it.origin;
+            it.target_select_flags     = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
+            it.target_validate_flags   = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
+            it.frame                                   = it.tur_head.frame = 1;
+            it.ammo_flags                              = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
 
             // Convert from dgr / sec to dgr / tic
-            self.tur_head.aim_speed = (autocvar_g_turrets_unit_ewheel_turnrate);
-            self.tur_head.aim_speed = self.tur_head.aim_speed / (1 / self.ticrate);
-
-            return true;
-        }
-        METHOD(EWheel, tr_precache, bool(EWheel thistur))
-        {
-            return true;
+            it.tur_head.aim_speed = (autocvar_g_turrets_unit_ewheel_turnrate);
+            it.tur_head.aim_speed = it.tur_head.aim_speed / (1 / it.ticrate);
         }
 
 #endif // SVQC
@@ -307,22 +290,15 @@ void ewheel_draw()
         te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
 }
 
-        METHOD(EWheel, tr_setup, bool(EWheel thistur))
+        METHOD(EWheel, tr_setup, void(EWheel this, entity it))
         {
-            SELFPARAM();
-            self.gravity               = 1;
-            self.movetype              = MOVETYPE_BOUNCE;
-            self.move_movetype = MOVETYPE_BOUNCE;
-            self.move_origin   = self.origin;
-            self.move_time             = time;
-            self.draw                  = ewheel_draw;
-
-            return true;
-        }
-        METHOD(EWheel, tr_precache, bool(EWheel thistur))
-        {
-            return true;
+            it.gravity         = 1;
+            it.movetype                = MOVETYPE_BOUNCE;
+            it.move_movetype   = MOVETYPE_BOUNCE;
+            it.move_origin     = it.origin;
+            it.move_time               = time;
+            it.draw                    = ewheel_draw;
         }
 
 #endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index f2554ad541ddfd92ded06c096591f84ea38186f9..c600c4fa92305b158df2434c81b1c69f5dc05398 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef TUR_FLAC_H
 #define TUR_FLAC_H
 
+CLASS(FlacAttack, PortoLaunch)
+/* flags     */ ATTRIB(FlacAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(FlacAttack, impulse, int, 5);
+/* refname   */ ATTRIB(FlacAttack, netname, string, "turret_flac");
+/* wepname   */ ATTRIB(FlacAttack, message, string, _("FLAC"));
+ENDCLASS(FlacAttack)
+REGISTER_WEAPON(FLAC, NEW(FlacAttack));
+
 CLASS(Flac, Turret)
 /* spawnflags */ ATTRIB(Flac, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_FASTPROJ | TUR_FLAG_MISSILE);
 /* mins       */ ATTRIB(Flac, mins, vector, '-32 -32 0');
@@ -10,23 +18,14 @@ CLASS(Flac, Turret)
 /* head_model */ ATTRIB(Flac, head_model, string, strzone(strcat("models/turrets/", "flac.md3")));
 /* netname    */ ATTRIB(Flac, netname, string, "flac");
 /* fullname   */ ATTRIB(Flac, turret_name, string, _("FLAC Cannon"));
+    ATTRIB(Flac, m_weapon, Weapon, WEP_FLAC);
 ENDCLASS(Flac)
-
 REGISTER_TURRET(FLAC, NEW(Flac));
 
-CLASS(FlacAttack, PortoLaunch)
-/* flags     */ ATTRIB(FlacAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(FlacAttack, impulse, int, 5);
-/* refname   */ ATTRIB(FlacAttack, netname, string, "turret_flac");
-/* wepname   */ ATTRIB(FlacAttack, message, string, _("FLAC"));
-ENDCLASS(FlacAttack)
-REGISTER_WEAPON(FLAC, NEW(FlacAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void turret_initparams(entity);
 void turret_flac_projectile_think_explode();
 METHOD(FlacAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
        SELFPARAM();
@@ -77,45 +76,15 @@ void turret_flac_projectile_think_explode()
     remove(self);
 }
 
-void spawnfunc_turret_flac() { SELFPARAM(); if(!turret_initialize(TUR_FLAC.m_id)) remove(self); }
-
-        METHOD(Flac, tr_attack, void(Flac thistur))
-        {
-            Weapon wep = WEP_FLAC;
-            wep.wr_think(wep, true, false);
-        }
-        METHOD(Flac, tr_think, bool(Flac thistur))
-        {
-            return true;
-        }
-        METHOD(Flac, tr_death, bool(Flac thistur))
-        {
-            return true;
-        }
-        METHOD(Flac, tr_setup, bool(Flac thistur))
-        {
-            self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
-            self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
-            self.damage_flags |= TFL_DMG_HEADSHAKE;
-            self.target_select_flags |= TFL_TARGETSELECT_NOTURRETS | TFL_TARGETSELECT_MISSILESONLY;
+void spawnfunc_turret_flac() { SELFPARAM(); if(!turret_initialize(TUR_FLAC)) remove(self); }
 
-            return true;
-        }
-        METHOD(Flac, tr_precache, bool(Flac thistur))
+        METHOD(Flac, tr_setup, void(Flac this, entity it))
         {
-            return true;
+            it.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
+            it.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
+            it.damage_flags |= TFL_DMG_HEADSHAKE;
+            it.target_select_flags |= TFL_TARGETSELECT_NOTURRETS | TFL_TARGETSELECT_MISSILESONLY;
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(Flac, tr_setup, bool(Flac thistur))
-        {
-            return true;
-        }
-        METHOD(Flac, tr_precache, bool(Flac thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index cafcf8ba12d9fb12157e0b1d7c242f70975ce353..671d9a67299859640b171800048bfdb3586a9426 100644 (file)
@@ -11,7 +11,6 @@ CLASS(FusionReactor, Turret)
 /* netname    */ ATTRIB(FusionReactor, netname, string, "fusionreactor");
 /* fullname   */ ATTRIB(FusionReactor, turret_name, string, _("Fusion Reactor"));
 ENDCLASS(FusionReactor)
-
 REGISTER_TURRET(FUSIONREACTOR, NEW(FusionReactor));
 
 #endif
@@ -47,57 +46,32 @@ bool turret_fusionreactor_firecheck()
     return true;
 }
 
-void spawnfunc_turret_fusionreactor() { SELFPARAM(); if(!turret_initialize(TUR_FUSIONREACTOR.m_id)) remove(self); }
+void spawnfunc_turret_fusionreactor() { SELFPARAM(); if(!turret_initialize(TUR_FUSIONREACTOR)) remove(self); }
 
-        METHOD(FusionReactor, tr_attack, void(FusionReactor thistur))
+        METHOD(FusionReactor, tr_attack, void(FusionReactor this))
         {
-            vector fl_org;
-
             self.enemy.ammo = min(self.enemy.ammo + self.shot_dmg,self.enemy.ammo_max);
-            fl_org = 0.5 * (self.enemy.absmin + self.enemy.absmax);
+            vector fl_org = 0.5 * (self.enemy.absmin + self.enemy.absmax);
             te_smallflash(fl_org);
         }
-        METHOD(FusionReactor, tr_think, bool(FusionReactor thistur))
+        METHOD(FusionReactor, tr_think, void(FusionReactor thistur))
         {
             self.tur_head.avelocity = '0 250 0' * (self.ammo / self.ammo_max);
-
-            return true;
         }
-        METHOD(FusionReactor, tr_death, bool(FusionReactor thistur))
+        METHOD(FusionReactor, tr_setup, void(FusionReactor this, entity it))
         {
-            return true;
-        }
-        METHOD(FusionReactor, tr_setup, bool(FusionReactor thistur))
-        {
-            self.ammo_flags                            = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE;
-            self.target_select_flags   = TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_OWNTEAM | TFL_TARGETSELECT_RANGELIMITS;
-            self.firecheck_flags               = TFL_FIRECHECK_AMMO_OWN | TFL_FIRECHECK_AMMO_OTHER | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_DEAD;
-            self.shoot_flags                   = TFL_SHOOT_HITALLVALID;
-            self.aim_flags                             = TFL_AIM_NO;
-            self.track_flags                   = TFL_TRACK_NO;
-
-            self.tur_head.scale = 0.75;
-            self.tur_head.avelocity = '0 50 0';
+            it.ammo_flags                              = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE;
+            it.target_select_flags     = TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_OWNTEAM | TFL_TARGETSELECT_RANGELIMITS;
+            it.firecheck_flags         = TFL_FIRECHECK_AMMO_OWN | TFL_FIRECHECK_AMMO_OTHER | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_DEAD;
+            it.shoot_flags                     = TFL_SHOOT_HITALLVALID;
+            it.aim_flags                               = TFL_AIM_NO;
+            it.track_flags                     = TFL_TRACK_NO;
 
-            self.turret_firecheckfunc = turret_fusionreactor_firecheck;
+            it.tur_head.scale = 0.75;
+            it.tur_head.avelocity = '0 50 0';
 
-            return true;
-        }
-        METHOD(FusionReactor, tr_precache, bool(FusionReactor thistur))
-        {
-            return true;
+            it.turret_firecheckfunc = turret_fusionreactor_firecheck;
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(FusionReactor, tr_setup, bool(FusionReactor thistur))
-        {
-            return true;
-        }
-        METHOD(FusionReactor, tr_precache, bool(FusionReactor thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index d0622bf859a96efde823a43fa31a09f53aecf42a..e2661442cfa008e089ec66f909094531bd65a4c4 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef TUR_HELLION_H
 #define TUR_HELLION_H
 
+CLASS(HellionAttack, PortoLaunch)
+/* flags     */ ATTRIB(HellionAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(HellionAttack, impulse, int, 9);
+/* refname   */ ATTRIB(HellionAttack, netname, string, "turret_hellion");
+/* wepname   */ ATTRIB(HellionAttack, message, string, _("Hellion"));
+ENDCLASS(HellionAttack)
+REGISTER_WEAPON(HELLION, NEW(HellionAttack));
+
 CLASS(Hellion, Turret)
 /* spawnflags */ ATTRIB(Hellion, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_FASTPROJ | TUR_FLAG_PLAYER | TUR_FLAG_MISSILE);
 /* mins       */ ATTRIB(Hellion, mins, vector, '-32 -32 0');
@@ -10,23 +18,14 @@ CLASS(Hellion, Turret)
 /* head_model */ ATTRIB(Hellion, head_model, string, strzone(strcat("models/turrets/", "hellion.md3")));
 /* netname    */ ATTRIB(Hellion, netname, string, "hellion");
 /* fullname   */ ATTRIB(Hellion, turret_name, string, _("Hellion Missile Turret"));
+    ATTRIB(Hellion, m_weapon, Weapon, WEP_HELLION);
 ENDCLASS(Hellion)
-
 REGISTER_TURRET(HELLION, NEW(Hellion));
 
-CLASS(HellionAttack, PortoLaunch)
-/* flags     */ ATTRIB(HellionAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(HellionAttack, impulse, int, 9);
-/* refname   */ ATTRIB(HellionAttack, netname, string, "turret_hellion");
-/* wepname   */ ATTRIB(HellionAttack, message, string, _("Hellion"));
-ENDCLASS(HellionAttack)
-REGISTER_WEAPON(HELLION, NEW(HellionAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void turret_initparams(entity);
 void turret_hellion_missile_think();
 METHOD(HellionAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
        SELFPARAM();
@@ -127,51 +126,23 @@ void turret_hellion_missile_think()
     UpdateCSQCProjectile(self);
 }
 
-void spawnfunc_turret_hellion() { SELFPARAM(); if(!turret_initialize(TUR_HELLION.m_id)) remove(self); }
+void spawnfunc_turret_hellion() { SELFPARAM(); if(!turret_initialize(TUR_HELLION)) remove(self); }
 
-        METHOD(Hellion, tr_attack, void(Hellion thistur))
-        {
-            Weapon wep = WEP_HELLION;
-            wep.wr_think(wep, true, false);
-        }
-        METHOD(Hellion, tr_think, bool(Hellion thistur))
+        METHOD(Hellion, tr_think, void(Hellion thistur))
         {
             if (self.tur_head.frame != 0)
                 self.tur_head.frame += 1;
 
             if (self.tur_head.frame >= 7)
                 self.tur_head.frame = 0;
-
-            return true;
         }
-        METHOD(Hellion, tr_death, bool(Hellion thistur))
+        METHOD(Hellion, tr_setup, void(Hellion this, entity it))
         {
-            return true;
-        }
-        METHOD(Hellion, tr_setup, bool(Hellion thistur))
-        {
-            self.aim_flags = TFL_AIM_SIMPLE;
-            self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK ;
-            self.firecheck_flags = TFL_FIRECHECK_DEAD | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_TEAMCHECK | TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AFF | TFL_FIRECHECK_AMMO_OWN;
-            self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
-
-            return true;
-        }
-        METHOD(Hellion, tr_precache, bool(Hellion thistur))
-        {
-            return true;
+            it.aim_flags = TFL_AIM_SIMPLE;
+            it.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK ;
+            it.firecheck_flags = TFL_FIRECHECK_DEAD | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_TEAMCHECK | TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AFF | TFL_FIRECHECK_AMMO_OWN;
+            it.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(Hellion, tr_setup, bool(Hellion thistur))
-        {
-            return true;
-        }
-        METHOD(Hellion, tr_precache, bool(Hellion thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index 8fedee421c1904362eb17c85a16cf47887bd475e..f659b5e212014dd85b2d566798ffcaea143862c3 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef TUR_HK_H
 #define TUR_HK_H
 
+CLASS(HunterKillerAttack, PortoLaunch)
+/* flags     */ ATTRIB(HunterKillerAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(HunterKillerAttack, impulse, int, 9);
+/* refname   */ ATTRIB(HunterKillerAttack, netname, string, "turret_hk");
+/* wepname   */ ATTRIB(HunterKillerAttack, message, string, _("Hunter-Killer"));
+ENDCLASS(HunterKillerAttack)
+REGISTER_WEAPON(HK, NEW(HunterKillerAttack));
+
 CLASS(HunterKiller, Turret)
 /* spawnflags */ ATTRIB(HunterKiller, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER | TUR_FLAG_RECIEVETARGETS);
 /* mins       */ ATTRIB(HunterKiller, mins, vector, '-32 -32 0');
@@ -10,23 +18,14 @@ CLASS(HunterKiller, Turret)
 /* head_model */ ATTRIB(HunterKiller, head_model, string, strzone(strcat("models/turrets/", "hk.md3")));
 /* netname    */ ATTRIB(HunterKiller, netname, string, "hk");
 /* fullname   */ ATTRIB(HunterKiller, turret_name, string, _("Hunter-Killer Turret"));
+    ATTRIB(HunterKiller, m_weapon, Weapon, WEP_HK);
 ENDCLASS(HunterKiller)
-
 REGISTER_TURRET(HK, NEW(HunterKiller));
 
-CLASS(HunterKillerAttack, PortoLaunch)
-/* flags     */ ATTRIB(HunterKillerAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(HunterKillerAttack, impulse, int, 9);
-/* refname   */ ATTRIB(HunterKillerAttack, netname, string, "turret_hk");
-/* wepname   */ ATTRIB(HunterKillerAttack, message, string, _("Hunter-Killer"));
-ENDCLASS(HunterKillerAttack)
-REGISTER_WEAPON(HK, NEW(HunterKillerAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void turret_initparams(entity);
 void turret_hk_missile_think();
 METHOD(HunterKillerAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
        SELFPARAM();
@@ -322,55 +321,27 @@ float turret_hk_addtarget(entity e_target,entity e_sender)
     return 0;
 }
 
-void spawnfunc_turret_hk() { SELFPARAM(); if(!turret_initialize(TUR_HK.m_id)) remove(self); }
+void spawnfunc_turret_hk() { SELFPARAM(); if(!turret_initialize(TUR_HK)) remove(self); }
 
-        METHOD(HunterKiller, tr_attack, void(HunterKiller thistur))
-        {
-            Weapon wep = WEP_HK;
-            wep.wr_think(wep, true, false);
-        }
-        METHOD(HunterKiller, tr_think, bool(HunterKiller thistur))
+        METHOD(HunterKiller, tr_think, void(HunterKiller thistur))
         {
             if (self.tur_head.frame != 0)
                 self.tur_head.frame = self.tur_head.frame + 1;
 
             if (self.tur_head.frame > 5)
                 self.tur_head.frame = 0;
-
-            return true;
-        }
-        METHOD(HunterKiller, tr_death, bool(HunterKiller thistur))
-        {
-            return true;
-        }
-        METHOD(HunterKiller, tr_setup, bool(HunterKiller thistur))
-        {
-            self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
-            self.aim_flags = TFL_AIM_SIMPLE;
-            self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_TRIGGERTARGET | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
-            self.firecheck_flags = TFL_FIRECHECK_DEAD | TFL_FIRECHECK_TEAMCHECK  | TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AFF;
-            self.shoot_flags = TFL_SHOOT_CLEARTARGET;
-            self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_TEAMCHECK;
-
-            self.turret_addtarget = turret_hk_addtarget;
-
-            return true;
         }
-        METHOD(HunterKiller, tr_precache, bool(HunterKiller thistur))
+        METHOD(HunterKiller, tr_setup, void(HunterKiller this, entity it))
         {
-            return true;
+            it.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
+            it.aim_flags = TFL_AIM_SIMPLE;
+            it.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_TRIGGERTARGET | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
+            it.firecheck_flags = TFL_FIRECHECK_DEAD | TFL_FIRECHECK_TEAMCHECK  | TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AFF;
+            it.shoot_flags = TFL_SHOOT_CLEARTARGET;
+            it.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_TEAMCHECK;
+
+            it.turret_addtarget = turret_hk_addtarget;
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(HunterKiller, tr_setup, bool(HunterKiller thistur))
-        {
-            return true;
-        }
-        METHOD(HunterKiller, tr_precache, bool(HunterKiller thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index 43dc1750d71f81f1a7826ad64ccd0343cb4f616a..336a0f7c8c200a312e999a9430a96e304247b800 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef TUR_MACHINEGUN_H
 #define TUR_MACHINEGUN_H
 
+CLASS(MachineGunTurretAttack, PortoLaunch)
+/* flags     */ ATTRIB(MachineGunTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(MachineGunTurretAttack, impulse, int, 9);
+/* refname   */ ATTRIB(MachineGunTurretAttack, netname, string, "turret_machinegun");
+/* wepname   */ ATTRIB(MachineGunTurretAttack, message, string, _("Machinegun"));
+ENDCLASS(MachineGunTurretAttack)
+REGISTER_WEAPON(TUR_MACHINEGUN, NEW(MachineGunTurretAttack));
+
 CLASS(MachineGunTurret, Turret)
 /* spawnflags */ ATTRIB(MachineGunTurret, spawnflags, int, TUR_FLAG_PLAYER);
 /* mins       */ ATTRIB(MachineGunTurret, mins, vector, '-32 -32 0');
@@ -10,23 +18,14 @@ CLASS(MachineGunTurret, Turret)
 /* head_model */ ATTRIB(MachineGunTurret, head_model, string, strzone(strcat("models/turrets/", "machinegun.md3")));
 /* netname    */ ATTRIB(MachineGunTurret, netname, string, "machinegun");
 /* fullname   */ ATTRIB(MachineGunTurret, turret_name, string, _("Machinegun Turret"));
+    ATTRIB(MachineGunTurret, m_weapon, Weapon, WEP_TUR_MACHINEGUN);
 ENDCLASS(MachineGunTurret)
-
 REGISTER_TURRET(MACHINEGUN, NEW(MachineGunTurret));
 
-CLASS(MachineGunTurretAttack, PortoLaunch)
-/* flags     */ ATTRIB(MachineGunTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(MachineGunTurretAttack, impulse, int, 9);
-/* refname   */ ATTRIB(MachineGunTurretAttack, netname, string, "turret_machinegun");
-/* wepname   */ ATTRIB(MachineGunTurretAttack, message, string, _("Machinegun"));
-ENDCLASS(MachineGunTurretAttack)
-REGISTER_WEAPON(TUR_MACHINEGUN, NEW(MachineGunTurretAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void turret_initparams(entity);
 void W_MachineGun_MuzzleFlash();
 
 METHOD(MachineGunTurretAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
@@ -49,46 +48,16 @@ METHOD(MachineGunTurretAttack, wr_think, bool(entity thiswep, bool fire1, bool f
        return true;
 }
 
-void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN.m_id)) remove(self); }
-
-        METHOD(MachineGunTurret, tr_attack, void(MachineGunTurret thistur))
-        {
-            Weapon wep = WEP_TUR_MACHINEGUN;
-            wep.wr_think(wep, true, false);
-        }
-        METHOD(MachineGunTurret, tr_think, bool(MachineGunTurret thistur))
-        {
-            return true;
-        }
-        METHOD(MachineGunTurret, tr_death, bool(MachineGunTurret thistur))
-        {
-            return true;
-        }
-        METHOD(MachineGunTurret, tr_setup, bool(MachineGunTurret thistur))
-        {
-            self.damage_flags |= TFL_DMG_HEADSHAKE;
-            self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
-            self.ammo_flags = TFL_AMMO_BULLETS | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
-            self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
-            self.turret_flags |= TUR_FLAG_HITSCAN;
+void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN)) remove(self); }
 
-            return true;
-        }
-        METHOD(MachineGunTurret, tr_precache, bool(MachineGunTurret thistur))
+        METHOD(MachineGunTurret, tr_setup, void(MachineGunTurret this, entity it))
         {
-            return true;
+            it.damage_flags |= TFL_DMG_HEADSHAKE;
+            it.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
+            it.ammo_flags = TFL_AMMO_BULLETS | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
+            it.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
+            it.turret_flags |= TUR_FLAG_HITSCAN;
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(MachineGunTurret, tr_setup, bool(MachineGunTurret thistur))
-        {
-            return true;
-        }
-        METHOD(MachineGunTurret, tr_precache, bool(MachineGunTurret thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index 08a1edcfae49349a47b1415b894806a99d4f51fe..93fd49e1a5a8ea38dcca9b988d60abfd28de24b4 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef TUR_MLRS_H
 #define TUR_MLRS_H
 
+CLASS(MLRSTurretAttack, PortoLaunch)
+/* flags     */ ATTRIB(MLRSTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(MLRSTurretAttack, impulse, int, 9);
+/* refname   */ ATTRIB(MLRSTurretAttack, netname, string, "turret_mlrs");
+/* wepname   */ ATTRIB(MLRSTurretAttack, message, string, _("MLRS"));
+ENDCLASS(MLRSTurretAttack)
+REGISTER_WEAPON(TUR_MLRS, NEW(MLRSTurretAttack));
+
 CLASS(MLRSTurret, Turret)
 /* spawnflags */ ATTRIB(MLRSTurret, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER);
 /* mins       */ ATTRIB(MLRSTurret, mins, vector, '-32 -32 0');
@@ -10,23 +18,14 @@ CLASS(MLRSTurret, Turret)
 /* head_model */ ATTRIB(MLRSTurret, head_model, string, strzone(strcat("models/turrets/", "mlrs.md3")));
 /* netname    */ ATTRIB(MLRSTurret, netname, string, "mlrs");
 /* fullname   */ ATTRIB(MLRSTurret, turret_name, string, _("MLRS Turret"));
+    ATTRIB(MLRSTurret, m_weapon, Weapon, WEP_TUR_MLRS);
 ENDCLASS(MLRSTurret)
-
 REGISTER_TURRET(MLRS, NEW(MLRSTurret));
 
-CLASS(MLRSTurretAttack, PortoLaunch)
-/* flags     */ ATTRIB(MLRSTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(MLRSTurretAttack, impulse, int, 9);
-/* refname   */ ATTRIB(MLRSTurretAttack, netname, string, "turret_mlrs");
-/* wepname   */ ATTRIB(MLRSTurretAttack, message, string, _("MLRS"));
-ENDCLASS(MLRSTurretAttack)
-REGISTER_WEAPON(TUR_MLRS, NEW(MLRSTurretAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void turret_initparams(entity);
 METHOD(MLRSTurretAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
        SELFPARAM();
        bool isPlayer = IS_PLAYER(self);
@@ -50,14 +49,9 @@ METHOD(MLRSTurretAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2))
        return true;
 }
 
-void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS.m_id)) remove(self); }
+void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS)) remove(self); }
 
-        METHOD(MLRSTurret, tr_attack, void(MLRSTurret thistur))
-        {
-            Weapon wep = WEP_TUR_MLRS;
-            wep.wr_think(wep, true, false);
-        }
-        METHOD(MLRSTurret, tr_think, bool(MLRSTurret thistur))
+        METHOD(MLRSTurret, tr_think, void(MLRSTurret thistur))
         {
             // 0 = full, 6 = empty
             self.tur_head.frame = bound(0, 6 - floor(0.1 + self.ammo / self.shot_dmg), 6);
@@ -66,39 +60,16 @@ void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS.m_id)
                 LOG_TRACE("ammo:",ftos(self.ammo),"\n");
                 LOG_TRACE("shot_dmg:",ftos(self.shot_dmg),"\n");
             }
-
-            return true;
         }
-        METHOD(MLRSTurret, tr_death, bool(MLRSTurret thistur))
+        METHOD(MLRSTurret, tr_setup, void(MLRSTurret this, entity it))
         {
-            return true;
-        }
-        METHOD(MLRSTurret, tr_setup, bool(MLRSTurret thistur))
-        {
-            self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
-            self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
+            it.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
+            it.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;
 
-            self.damage_flags |= TFL_DMG_HEADSHAKE;
-            self.shoot_flags  |= TFL_SHOOT_VOLLYALWAYS;
-            self.volly_counter = self.shot_volly;
-
-            return true;
-        }
-        METHOD(MLRSTurret, tr_precache, bool(MLRSTurret thistur))
-        {
-            return true;
+            it.damage_flags |= TFL_DMG_HEADSHAKE;
+            it.shoot_flags  |= TFL_SHOOT_VOLLYALWAYS;
+            it.volly_counter = it.shot_volly;
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(MLRSTurret, tr_setup, bool(MLRSTurret thistur))
-        {
-            return true;
-        }
-        METHOD(MLRSTurret, tr_precache, bool(MLRSTurret thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index 7cef889095444b03c0c4263fda01e9ab84f2f47f..c7b11cba962b6917c9379416b6e095e787238aa4 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef TUR_PHASER_H
 #define TUR_PHASER_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));
+
 CLASS(PhaserTurret, Turret)
 /* spawnflags */ ATTRIB(PhaserTurret, spawnflags, int, TUR_FLAG_SNIPER | TUR_FLAG_HITSCAN | TUR_FLAG_PLAYER);
 /* mins       */ ATTRIB(PhaserTurret, mins, vector, '-32 -32 0');
@@ -10,18 +18,10 @@ CLASS(PhaserTurret, Turret)
 /* head_model */ ATTRIB(PhaserTurret, head_model, string, strzone(strcat("models/turrets/", "phaser.md3")));
 /* netname    */ ATTRIB(PhaserTurret, netname, string, "phaser");
 /* fullname   */ ATTRIB(PhaserTurret, turret_name, string, _("Phaser Cannon"));
+    ATTRIB(PhaserTurret, m_weapon, Weapon, WEP_PHASER);
 ENDCLASS(PhaserTurret)
-
 REGISTER_TURRET(PHASER, NEW(PhaserTurret));
 
-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
 
 #ifdef IMPLEMENTATION
@@ -118,14 +118,9 @@ void beam_think()
 
 }
 
-void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER.m_id)) remove(self); }
+void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER)) remove(self); }
 
-        METHOD(PhaserTurret, tr_attack, void(PhaserTurret thistur))
-        {
-            Weapon wep = WEP_PHASER;
-            wep.wr_think(wep, true, false);
-        }
-        METHOD(PhaserTurret, tr_think, bool(PhaserTurret thistur))
+        METHOD(PhaserTurret, tr_think, void(PhaserTurret thistur))
         {
             if (self.tur_head.frame != 0)
             {
@@ -146,37 +141,14 @@ void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER.m
                     }
                 }
             }
-
-            return true;
         }
-        METHOD(PhaserTurret, tr_death, bool(PhaserTurret thistur))
+        METHOD(PhaserTurret, tr_setup, void(PhaserTurret this, entity it))
         {
-            return true;
-        }
-        METHOD(PhaserTurret, tr_setup, bool(PhaserTurret thistur))
-        {
-            self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
-            self.aim_flags = TFL_AIM_LEAD;
+            it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
+            it.aim_flags = TFL_AIM_LEAD;
 
-            self.turret_firecheckfunc = turret_phaser_firecheck;
-
-            return true;
-        }
-        METHOD(PhaserTurret, tr_precache, bool(PhaserTurret thistur))
-        {
-            return true;
+            it.turret_firecheckfunc = turret_phaser_firecheck;
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(PhaserTurret, tr_setup, bool(PhaserTurret thistur))
-        {
-            return true;
-        }
-        METHOD(PhaserTurret, tr_precache, bool(PhaserTurret thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index 319740006366e70000f54bec96ddad8af355a390..1adb45623053010a01c80efa9331710c50e4d714 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef TUR_PLASMA_H
 #define TUR_PLASMA_H
 
+CLASS(PlasmaAttack, PortoLaunch)
+/* flags     */ ATTRIB(PlasmaAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(PlasmaAttack, impulse, int, 5);
+/* refname   */ ATTRIB(PlasmaAttack, netname, string, "turret_plasma");
+/* wepname   */ ATTRIB(PlasmaAttack, message, string, _("Plasma"));
+ENDCLASS(PlasmaAttack)
+REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack));
+
 CLASS(PlasmaTurret, Turret)
 /* spawnflags */ ATTRIB(PlasmaTurret, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER);
 /* mins       */ ATTRIB(PlasmaTurret, mins, vector, '-32 -32 0');
@@ -10,25 +18,15 @@ CLASS(PlasmaTurret, Turret)
 /* head_model */ ATTRIB(PlasmaTurret, head_model, string, strzone(strcat("models/turrets/", "plasma.md3")));
 /* netname    */ ATTRIB(PlasmaTurret, netname, string, "plasma");
 /* fullname   */ ATTRIB(PlasmaTurret, turret_name, string, _("Plasma Cannon"));
+    ATTRIB(PlasmaTurret, m_weapon, Weapon, WEP_PLASMA);
 ENDCLASS(PlasmaTurret)
-
 REGISTER_TURRET(PLASMA, NEW(PlasmaTurret));
 
-CLASS(PlasmaAttack, PortoLaunch)
-/* flags     */ ATTRIB(PlasmaAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(PlasmaAttack, impulse, int, 5);
-/* refname   */ ATTRIB(PlasmaAttack, netname, string, "turret_plasma");
-/* wepname   */ ATTRIB(PlasmaAttack, message, string, _("Plasma"));
-ENDCLASS(PlasmaAttack)
-REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
-
 #ifdef SVQC
 
-void turret_initparams(entity tur);
 METHOD(PlasmaAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
        SELFPARAM();
        bool isPlayer = IS_PLAYER(self);
@@ -49,9 +47,9 @@ METHOD(PlasmaAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
        return true;
 }
 
-void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA.m_id)) remove(self); }
+void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA)) remove(self); }
 
-        METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret thistur))
+        METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this))
         {
             if(g_instagib)
             {
@@ -66,52 +64,28 @@ void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA.m
             }
             else
             {
-                Weapon wep = WEP_PLASMA;
-                wep.wr_think(wep, true, false);
+                super.tr_attack(this);
             }
             if (self.tur_head.frame == 0)
                 self.tur_head.frame = 1;
         }
-        METHOD(PlasmaTurret, tr_think, bool(PlasmaTurret thistur))
+        METHOD(PlasmaTurret, tr_think, void(PlasmaTurret thistur))
         {
             if (self.tur_head.frame != 0)
                 self.tur_head.frame = self.tur_head.frame + 1;
 
             if (self.tur_head.frame > 5)
                 self.tur_head.frame = 0;
-
-            return true;
         }
-        METHOD(PlasmaTurret, tr_death, bool(PlasmaTurret thistur))
+        METHOD(PlasmaTurret, tr_setup, void(PlasmaTurret this, entity it))
         {
-            return true;
-        }
-        METHOD(PlasmaTurret, tr_setup, bool(PlasmaTurret thistur))
-        {
-            self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
-            self.damage_flags |= TFL_DMG_HEADSHAKE;
-            self.firecheck_flags |= TFL_FIRECHECK_AFF;
-            self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
+            it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
+            it.damage_flags |= TFL_DMG_HEADSHAKE;
+            it.firecheck_flags |= TFL_FIRECHECK_AFF;
+            it.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
 
-            turret_do_updates(self);
-
-            return true;
-        }
-        METHOD(PlasmaTurret, tr_precache, bool(PlasmaTurret thistur))
-        {
-            return true;
+            turret_do_updates(it);
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(PlasmaTurret, tr_setup, bool(PlasmaTurret thistur))
-        {
-            return true;
-        }
-        METHOD(PlasmaTurret, tr_precache, bool(PlasmaTurret thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index a8885c0404dad0d6834394410f643ba676afdb38..98f6243ee0e7be9e2cb1a8737e5339712693226e 100644 (file)
@@ -1,7 +1,13 @@
 #ifndef TUR_PLASMA_DUAL_H
 #define TUR_PLASMA_DUAL_H
 
-CLASS(DualPlasmaTurret, Turret)
+CLASS(PlasmaDualAttack, PlasmaAttack)
+/* refname   */ ATTRIB(PlasmaDualAttack, netname, string, "turret_plasma_dual");
+/* wepname   */ ATTRIB(PlasmaDualAttack, message, string, _("Dual plasma"));
+ENDCLASS(PlasmaDualAttack)
+REGISTER_WEAPON(PLASMA_DUAL, NEW(PlasmaDualAttack));
+
+CLASS(DualPlasmaTurret, PlasmaTurret)
 /* spawnflags */ ATTRIB(DualPlasmaTurret, spawnflags, int, TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER);
 /* mins       */ ATTRIB(DualPlasmaTurret, mins, vector, '-32 -32 0');
 /* maxs       */ ATTRIB(DualPlasmaTurret, maxs, vector, '32 32 64');
@@ -10,50 +16,19 @@ CLASS(DualPlasmaTurret, Turret)
 /* head_model */ ATTRIB(DualPlasmaTurret, head_model, string, strzone(strcat("models/turrets/", "plasmad.md3")));
 /* netname    */ ATTRIB(DualPlasmaTurret, netname, string, "plasma_dual");
 /* fullname   */ ATTRIB(DualPlasmaTurret, turret_name, string, _("Dual Plasma Cannon"));
+    ATTRIB(DualPlasmaTurret, m_weapon, Weapon, WEP_PLASMA_DUAL);
 ENDCLASS(DualPlasmaTurret)
-
 REGISTER_TURRET(PLASMA_DUAL, NEW(DualPlasmaTurret));
 
-#include "../../weapons/all.qh"
-
-CLASS(PlasmaDualAttack, PortoLaunch)
-/* flags     */ ATTRIB(PlasmaDualAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(PlasmaDualAttack, impulse, int, 5);
-/* refname   */ ATTRIB(PlasmaDualAttack, netname, string, "turret_plasmadual");
-/* wepname   */ ATTRIB(PlasmaDualAttack, message, string, _("Dual plasma"));
-ENDCLASS(PlasmaDualAttack)
-REGISTER_WEAPON(PLASMA_DUAL, NEW(PlasmaDualAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
 
 #ifdef SVQC
 
-void turret_initparams(entity tur);
-METHOD(PlasmaDualAttack, wr_think, bool(entity thiswep, bool fire1, bool fire2)) {
-       SELFPARAM();
-       bool isPlayer = IS_PLAYER(self);
-       if (fire1)
-       if (!isPlayer || weapon_prepareattack(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;
-            weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
-        }
-        entity missile = turret_projectile(SND(HAGAR_FIRE), 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, true, true);
-        missile.missile_flags = MIF_SPLASH;
-        Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
-       }
-       return true;
-}
+void spawnfunc_turret_plasma_dual() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA_DUAL)) remove(self); }
 
-void spawnfunc_turret_plasma_dual() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA_DUAL.m_id)) remove(self); }
-
-        METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret thistur))
+        METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret this))
         {
             if (g_instagib) {
                 FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
@@ -66,51 +41,18 @@ void spawnfunc_turret_plasma_dual() { SELFPARAM(); if(!turret_initialize(TUR_PLA
                 vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
                 WarpZone_TrailParticles(world, particleeffectnum(EFFECT_VAPORIZER(self.team)), self.tur_shotorg, v);
             } else {
-                Weapon wep = WEP_PLASMA_DUAL;
-                wep.wr_think(wep, true, false);
+                super.vtblbase.tr_attack(this);
             }
             self.tur_head.frame += 1;
         }
-        METHOD(DualPlasmaTurret, tr_think, bool(DualPlasmaTurret thistur))
+        METHOD(DualPlasmaTurret, tr_think, void(DualPlasmaTurret thistur))
         {
             if ((self.tur_head.frame != 0) && (self.tur_head.frame != 3))
                 self.tur_head.frame = self.tur_head.frame + 1;
 
             if (self.tur_head.frame > 6)
                 self.tur_head.frame = 0;
-
-            return true;
-        }
-        METHOD(DualPlasmaTurret, tr_death, bool(DualPlasmaTurret thistur))
-        {
-            return true;
-        }
-        METHOD(DualPlasmaTurret, tr_setup, bool(DualPlasmaTurret thistur))
-        {
-            self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
-            self.damage_flags |= TFL_DMG_HEADSHAKE;
-            self.firecheck_flags |= TFL_FIRECHECK_AFF;
-            self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_SPLASH;
-
-            turret_do_updates(self);
-
-            return true;
-        }
-        METHOD(DualPlasmaTurret, tr_precache, bool(DualPlasmaTurret thistur))
-        {
-            return true;
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(DualPlasmaTurret, tr_setup, bool(DualPlasmaTurret thistur))
-        {
-            return true;
-        }
-        METHOD(DualPlasmaTurret, tr_precache, bool(DualPlasmaTurret thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index 84d959803809193f1abe17cd01f6679ef6f4a89a..02fcd1f4cce2d805b1869c8212aa9e7c152879e9 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef TUR_TESLA_H
 #define TUR_TESLA_H
 
+CLASS(TeslaCoilTurretAttack, PortoLaunch)
+/* flags     */ ATTRIB(TeslaCoilTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(TeslaCoilTurretAttack, impulse, int, 9);
+/* refname   */ ATTRIB(TeslaCoilTurretAttack, netname, string, "turret_tesla");
+/* wepname   */ ATTRIB(TeslaCoilTurretAttack, message, string, _("Tesla Coil"));
+ENDCLASS(TeslaCoilTurretAttack)
+REGISTER_WEAPON(TESLA, NEW(TeslaCoilTurretAttack));
+
 CLASS(TeslaCoil, Turret)
 /* spawnflags */ ATTRIB(TeslaCoil, spawnflags, int, TUR_FLAG_HITSCAN | TUR_FLAG_PLAYER | TUR_FLAG_MISSILE);
 /* mins       */ ATTRIB(TeslaCoil, mins, vector, '-60 -60 0');
@@ -10,18 +18,10 @@ CLASS(TeslaCoil, Turret)
 /* head_model */ ATTRIB(TeslaCoil, head_model, string, strzone(strcat("models/turrets/", "tesla_head.md3")));
 /* netname    */ ATTRIB(TeslaCoil, netname, string, "tesla");
 /* fullname   */ ATTRIB(TeslaCoil, turret_name, string, _("Tesla Coil"));
+    ATTRIB(TeslaCoil, m_weapon, Weapon, WEP_TESLA);
 ENDCLASS(TeslaCoil)
-
 REGISTER_TURRET(TESLA, NEW(TeslaCoil));
 
-CLASS(TeslaCoilTurretAttack, PortoLaunch)
-/* flags     */ ATTRIB(TeslaCoilTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(TeslaCoilTurretAttack, impulse, int, 9);
-/* refname   */ ATTRIB(TeslaCoilTurretAttack, netname, string, "turret_tesla");
-/* wepname   */ ATTRIB(TeslaCoilTurretAttack, message, string, _("Tesla Coil"));
-ENDCLASS(TeslaCoilTurretAttack)
-REGISTER_WEAPON(TESLA, NEW(TeslaCoilTurretAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
@@ -152,19 +152,14 @@ float turret_tesla_firecheck()
     return 0;
 }
 
-void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA.m_id)) remove(self); }
+void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA)) remove(self); }
 
-        METHOD(TeslaCoil, tr_attack, void(TeslaCoil thistur))
-        {
-            Weapon wep = WEP_TESLA;
-            wep.wr_think(wep, true, false);
-        }
-        METHOD(TeslaCoil, tr_think, bool(TeslaCoil thistur))
+        METHOD(TeslaCoil, tr_think, void(TeslaCoil thistur))
         {
             if(!self.active)
             {
                 self.tur_head.avelocity = '0 0 0';
-                return true;
+                return;
             }
 
             if(self.ammo < self.shot_dmg)
@@ -176,7 +171,7 @@ void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA.m_i
                 self.tur_head.avelocity = '0 180 0' * (self.ammo / self.shot_dmg);
 
                 if(self.attack_finished_single > time)
-                    return true;
+                    return;
 
                 float f;
                 f = (self.ammo / self.ammo_max);
@@ -185,45 +180,22 @@ void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA.m_i
                     if(random() < 0.1)
                         te_csqc_lightningarc(self.tur_shotorg,self.tur_shotorg + (randomvec() * 350));
             }
-
-            return true;
         }
-        METHOD(TeslaCoil, tr_death, bool(TeslaCoil thistur))
+        METHOD(TeslaCoil, tr_setup, void(TeslaCoil this, entity it))
         {
-            return true;
-        }
-        METHOD(TeslaCoil, tr_setup, bool(TeslaCoil thistur))
-        {
-            self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES |
+            it.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES |
                                  TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
 
-            self.turret_firecheckfunc = turret_tesla_firecheck;
-            self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES |
+            it.turret_firecheckfunc = turret_tesla_firecheck;
+            it.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES |
                                TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
 
-            self.firecheck_flags       = TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AMMO_OWN;
-            self.shoot_flags           = TFL_SHOOT_CUSTOM;
-            self.ammo_flags                    = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
-            self.aim_flags                     = TFL_AIM_NO;
-            self.track_flags           = TFL_TRACK_NO;
-
-            return true;
-        }
-        METHOD(TeslaCoil, tr_precache, bool(TeslaCoil thistur))
-        {
-            return true;
+            it.firecheck_flags = TFL_FIRECHECK_REFIRE | TFL_FIRECHECK_AMMO_OWN;
+            it.shoot_flags             = TFL_SHOOT_CUSTOM;
+            it.ammo_flags                      = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
+            it.aim_flags                       = TFL_AIM_NO;
+            it.track_flags             = TFL_TRACK_NO;
         }
 
 #endif // SVQC
-#ifdef CSQC
-        METHOD(TeslaCoil, tr_setup, bool(TeslaCoil thistur))
-        {
-            return true;
-        }
-        METHOD(TeslaCoil, tr_precache, bool(TeslaCoil thistur))
-        {
-            return true;
-        }
-
-#endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index d223bf4877c141ce7fcae1a7f5d0b82fa16f888d..37781fa6733502d9a88bcaa92628ff944796bf04 100644 (file)
@@ -1,6 +1,16 @@
 #ifndef TUR_WALKER_H
 #define TUR_WALKER_H
 
+CLASS(WalkerTurretAttack, PortoLaunch)
+/* flags     */ ATTRIB(WalkerTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
+/* impulse   */ ATTRIB(WalkerTurretAttack, impulse, int, 5);
+/* refname   */ ATTRIB(WalkerTurretAttack, netname, string, "turret_walker");
+/* wepname   */ ATTRIB(WalkerTurretAttack, message, string, _("Walker"));
+ENDCLASS(WalkerTurretAttack)
+REGISTER_WEAPON(WALKER, NEW(WalkerTurretAttack));
+
+//#define WALKER_FANCYPATHING
+
 CLASS(WalkerTurret, Turret)
 /* spawnflags */ ATTRIB(WalkerTurret, spawnflags, int, TUR_FLAG_PLAYER | TUR_FLAG_MOVE);
 /* mins       */ ATTRIB(WalkerTurret, mins, vector, '-70 -70 0');
@@ -10,18 +20,10 @@ CLASS(WalkerTurret, Turret)
 /* head_model */ ATTRIB(WalkerTurret, head_model, string, strzone(strcat("models/turrets/", "walker_head_minigun.md3")));
 /* netname    */ ATTRIB(WalkerTurret, netname, string, "walker");
 /* fullname   */ ATTRIB(WalkerTurret, turret_name, string, _("Walker Turret"));
+    ATTRIB(WalkerTurret, m_weapon, Weapon, WEP_WALKER);
 ENDCLASS(WalkerTurret)
-
 REGISTER_TURRET(WALKER, NEW(WalkerTurret));
 
-CLASS(WalkerTurretAttack, PortoLaunch)
-/* flags     */ ATTRIB(WalkerTurretAttack, spawnflags, int, WEP_TYPE_OTHER);
-/* impulse   */ ATTRIB(WalkerTurretAttack, impulse, int, 5);
-/* refname   */ ATTRIB(WalkerTurretAttack, netname, string, "turret_walker");
-/* wepname   */ ATTRIB(WalkerTurretAttack, message, string, _("Walker"));
-ENDCLASS(WalkerTurretAttack)
-REGISTER_WEAPON(WALKER, NEW(WalkerTurretAttack));
-
 #endif
 
 #ifdef IMPLEMENTATION
@@ -69,18 +71,18 @@ float autocvar_g_turrets_unit_walker_turn_strafe;
 float autocvar_g_turrets_unit_walker_turn_swim;
 float autocvar_g_turrets_unit_walker_turn_run;
 
-#define ANIM_NO         0
-#define ANIM_TURN       1
-#define ANIM_WALK       2
-#define ANIM_RUN        3
-#define ANIM_STRAFE_L   4
-#define ANIM_STRAFE_R   5
-#define ANIM_JUMP       6
-#define ANIM_LAND       7
-#define ANIM_PAIN       8
-#define ANIM_MELEE      9
-#define ANIM_SWIM       10
-#define ANIM_ROAM       11
+const int ANIM_NO         = 0;
+const int ANIM_TURN       = 1;
+const int ANIM_WALK       = 2;
+const int ANIM_RUN        = 3;
+const int ANIM_STRAFE_L   = 4;
+const int ANIM_STRAFE_R   = 5;
+const int ANIM_JUMP       = 6;
+const int ANIM_LAND       = 7;
+const int ANIM_PAIN       = 8;
+const int ANIM_MELEE      = 9;
+const int ANIM_SWIM       = 10;
+const int ANIM_ROAM       = 11;
 
 .float animflag;
 .float idletime;
@@ -322,8 +324,6 @@ void walker_move_to(vector _target, float _dist)
     }
 }
 
-//#define WALKER_FANCYPATHING
-
 void walker_move_path()
 {SELFPARAM();
 #ifdef WALKER_FANCYPATHING
@@ -369,14 +369,9 @@ void walker_move_path()
 #endif
 }
 
-void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER.m_id)) remove(self); }
+void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER)) remove(self); }
 
-        METHOD(WalkerTurret, tr_attack, void(WalkerTurret thistur))
-        {
-            Weapon wep = WEP_WALKER;
-            wep.wr_think(wep, true, false);
-        }
-        METHOD(WalkerTurret, tr_think, bool(WalkerTurret thistur))
+        METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur))
         {
             fixedmakevectors(self.angles);
 
@@ -585,64 +580,60 @@ void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER.m
 
             self.oldorigin = self.origin;
             turrets_setframe(self.animflag, false);
-
-            return true;
         }
-        METHOD(WalkerTurret, tr_death, bool(WalkerTurret thistur))
+        METHOD(WalkerTurret, tr_death, void(WalkerTurret this, entity it))
         {
 #ifdef WALKER_FANCYPATHING
-            if (self.pathcurrent)
-                pathlib_deletepath(self.pathcurrent.owner);
+            if (it.pathcurrent)
+                pathlib_deletepath(it.pathcurrent.owner);
 #endif
-            self.pathcurrent = world;
-
-            return true;
+            it.pathcurrent = NULL;
         }
-        METHOD(WalkerTurret, tr_setup, bool(WalkerTurret thistur))
+        METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
         {
-            self.ticrate = 0.05;
+            it.ticrate = 0.05;
 
             entity e;
 
             // Respawn is called & first spawn to, to set team. need to make sure we do not move the initial spawn.
-            if(self.movetype == MOVETYPE_WALK)
+            if(it.movetype == MOVETYPE_WALK)
             {
-                if(self.pos1)
-                    setorigin(self, self.pos1);
-                if(self.pos2)
-                    self.angles = self.pos2;
+                if(it.pos1)
+                    setorigin(it, it.pos1);
+                if(it.pos2)
+                    it.angles = it.pos2;
             }
 
-            self.ammo_flags = TFL_AMMO_BULLETS | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
-            self.aim_flags = TFL_AIM_LEAD;
-            self.turret_flags |= TUR_FLAG_HITSCAN;
-
-            self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
-            self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
-            self.iscreature = true;
-            self.teleportable = TELEPORT_NORMAL;
-            self.damagedbycontents = true;
-            self.solid = SOLID_SLIDEBOX;
-            self.takedamage = DAMAGE_AIM;
-            if(self.movetype != MOVETYPE_WALK)
+            it.ammo_flags = TFL_AMMO_BULLETS | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
+            it.aim_flags = TFL_AIM_LEAD;
+            it.turret_flags |= TUR_FLAG_HITSCAN;
+
+            it.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
+            it.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
+            it.iscreature = true;
+            it.teleportable = TELEPORT_NORMAL;
+            it.damagedbycontents = true;
+            it.solid = SOLID_SLIDEBOX;
+            it.takedamage = DAMAGE_AIM;
+            if(it.movetype != MOVETYPE_WALK)
             {
-                setorigin(self, self.origin);
-                tracebox(self.origin + '0 0 128', self.mins, self.maxs, self.origin - '0 0 10000', MOVE_NORMAL, self);
-                setorigin(self, trace_endpos + '0 0 4');
-                self.pos1 = self.origin;
-                self.pos2 = self.angles;
+                setorigin(it, it.origin);
+                tracebox(it.origin + '0 0 128', it.mins, it.maxs, it.origin - '0 0 10000', MOVE_NORMAL, it);
+                setorigin(it, trace_endpos + '0 0 4');
+                it.pos1 = it.origin;
+                it.pos2 = it.angles;
             }
-            self.movetype = MOVETYPE_WALK;
-            self.idle_aim = '0 0 0';
-            self.turret_firecheckfunc = walker_firecheck;
+            it.movetype = MOVETYPE_WALK;
+            it.idle_aim = '0 0 0';
+            it.turret_firecheckfunc = walker_firecheck;
 
-            if (self.target != "")
+            if (it.target != "")
             {
-                e = find(world, targetname, self.target);
+                e = find(world, targetname, it.target);
                 if (!e)
                 {
                     LOG_TRACE("Initital waypoint for walker does NOT exsist, fix your map!\n");
-                    self.target = "";
+                    it.target = "";
                 }
 
                 if (e.classname != "turret_checkpoint")
@@ -650,19 +641,13 @@ void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER.m
                 else
                 {
 #ifdef WALKER_FANCYPATHING
-                    self.pathcurrent = WALKER_PATH(self.origin, e.origin);
-                    self.pathgoal = e;
+                    it.pathcurrent = WALKER_PATH(it.origin, e.origin);
+                    it.pathgoal = e;
 #else
-                    self.pathcurrent = e;
+                    it.pathcurrent = e;
 #endif
                 }
             }
-
-            return true;
-        }
-        METHOD(WalkerTurret, tr_precache, bool(WalkerTurret thistur))
-        {
-            return true;
         }
 
 #endif // SVQC
@@ -690,21 +675,15 @@ void walker_draw()
         te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
 }
 
-        METHOD(WalkerTurret, tr_setup, bool(WalkerTurret thistur))
-        {
-            self.gravity               = 1;
-            self.movetype              = MOVETYPE_BOUNCE;
-            self.move_movetype = MOVETYPE_BOUNCE;
-            self.move_origin   = self.origin;
-            self.move_time             = time;
-            self.draw                  = walker_draw;
-
-            return true;
-        }
-        METHOD(WalkerTurret, tr_precache, bool(WalkerTurret thistur))
+        METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
         {
-            return true;
+            it.gravity         = 1;
+            it.movetype                = MOVETYPE_BOUNCE;
+            it.move_movetype   = MOVETYPE_BOUNCE;
+            it.move_origin     = it.origin;
+            it.move_time               = time;
+            it.draw                    = walker_draw;
         }
 
 #endif // CSQC
-#endif // REGISTER_TURRET
+#endif
index cf15dd6bc473c8f12e4ffc3cc00c6be64beaf217..d915628cd9f76fc90e78e951d30afb6c7f2d4795 100644 (file)
@@ -281,6 +281,7 @@ void RegisterWeapons();
 REGISTER_REGISTRY(RegisterWeapons)
 entity weapon_info[WEP_MAXCOUNT], weapon_info_first, weapon_info_last;
 entity dummy_weapon_info;
+#define WEP_Null dummy_weapon_info
 
 #define REGISTER_WEAPON(...) EVAL(OVERLOAD(REGISTER_WEAPON, __VA_ARGS__))