--- /dev/null
+#include "unit/ewheel.qc"
+#include "unit/flac.qc"
+#include "unit/fusionreactor.qc"
+#include "unit/hellion.qc"
+#include "unit/hk.qc"
+#include "unit/machinegun.qc"
+#include "unit/mlrs.qc"
+#include "unit/phaser.qc"
+#include "unit/plasma.qc"
+#include "unit/plasma_dual.qc"
+#include "unit/tesla.qc"
+#include "unit/walker.qc"
+++ /dev/null
-#include "unit/ewheel.qc"
-#include "unit/flac.qc"
-#include "unit/fusionreactor.qc"
-#include "unit/hellion.qc"
-#include "unit/hk.qc"
-#include "unit/machinegun.qc"
-#include "unit/mlrs.qc"
-#include "unit/phaser.qc"
-#include "unit/plasma.qc"
-#include "unit/plasma_dual.qc"
-#include "unit/tesla.qc"
-#include "unit/walker.qc"
+#include "turrets.qh"
+
void turret_remove()
{SELFPARAM();
remove(self.tur_head);
setsize(self, tur.mins, tur.maxs);
setsize(self.tur_head, '0 0 0', '0 0 0');
- if(self.turretid == TUR_EWHEEL)
+ if(self.turretid == TUR_EWHEEL.m_id)
setattachment(self.tur_head, self, "");
else
setattachment(self.tur_head, self, "tag_head");
if (!autocvar_cl_nogibs)
{
// Base
- if(self.turretid == TUR_EWHEEL)
+ if(self.turretid == TUR_EWHEEL.m_id)
turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', self.velocity + '0 0 400' + '0.1 0.1 1' * (random() * 400), '-1 -1 -1', true);
- else if (self.turretid == TUR_WALKER)
+ else if (self.turretid == TUR_WALKER.m_id)
turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', self.velocity + '0 0 300' + '0.1 0.1 1' * (random() * 200), '-1 -1 -1', true);
- else if (self.turretid == TUR_TESLA)
+ else if (self.turretid == TUR_TESLA.m_id)
turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', '0 0 200', '-1 -1 -1', false);
else
{
void Dump_Turret_Settings(void)
{
- float i, x, totalsettings = 0;
- for(i = TUR_FIRST; i <= TUR_LAST; ++i)
- {
+ float x, totalsettings = 0;
+ FOREACH(turret_info, it != TUR_Null, LAMBDA({
// step 1: clear the queue
TUR_CONFIG_COUNT = 0;
for(x = 0; x <= MAX_TUR_CONFIG; ++x)
// step 5: debug info
LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, TUR_NAME(i), TUR_CONFIG_COUNT));
totalsettings += TUR_CONFIG_COUNT;
- }
+ }));
// clear queue now that we're finished
TUR_CONFIG_COUNT = 0;
{ tur_config_queue[x] = string_null; }
// extra information
- LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (i - 1), totalsettings));
+ LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (TUR_COUNT - 1), totalsettings));
}
-#include "all.qh"
+#include "turrets.qh"
-// TURRET PLUGIN SYSTEM
-entity turret_info[TUR_MAXCOUNT];
-entity dummy_turret_info;
-
-void register_turret(float id, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname)
-{
- entity e;
- turret_info[id - 1] = e = spawn();
- e.classname = "turret_info";
- e.turretid = id;
- e.netname = shortname;
- e.turret_name = mname;
- e.turret_func = func;
- e.mdl = modelname;
- e.cvar_basename = shortname;
- e.spawnflags = turretflags;
- e.mins = min_s;
- e.maxs = max_s;
- e.model = strzone(strcat("models/turrets/", modelname));
- e.head_model = strzone(strcat("models/turrets/", headmodelname));
-}
-float t_null(float dummy) { return 0; }
-void register_turrets_done()
-{
- dummy_turret_info = spawn();
- dummy_turret_info.classname = "turret_info";
- dummy_turret_info.turretid = 0; // you can recognize dummies by this
- dummy_turret_info.netname = "";
- dummy_turret_info.turret_name = "Turret";
- dummy_turret_info.turret_func = t_null;
- dummy_turret_info.mdl = "";
- dummy_turret_info.mins = '-0 -0 -0';
- dummy_turret_info.maxs = '0 0 0';
- dummy_turret_info.model = "";
-}
-entity get_turretinfo(float id)
-{
- entity m;
- if(id < TUR_FIRST || id > TUR_LAST)
- return dummy_turret_info;
- m = turret_info[id - 1];
- if(m)
- return m;
- return dummy_turret_info;
-}
+#define IMPLEMENTATION
+#include "all.inc"
+#undef IMPLEMENTATION
// =====================
float t_null(float dummy);
-void register_turret(float id, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname);
-void register_turrets_done();
+void register_turret(entity e, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname);
-const float TUR_MAXCOUNT = 24;
-const int TUR_FIRST = 1;
+const int TUR_MAXCOUNT = 24;
+entity turret_info[TUR_MAXCOUNT], turret_info_first, turret_info_last;
float TUR_COUNT;
-float TUR_LAST;
-#define REGISTER_TURRET_2(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
- float id; \
+#define _REGISTER_TURRET(id, func, turretflags, min_s, max_s, modelname, headmodelname, shortname, mname) \
float func(float); \
- void RegisterTurrets_##id() \
- { \
- TUR_LAST = (id = TUR_FIRST + TUR_COUNT); \
- ++TUR_COUNT; \
- register_turret(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname); \
- } \
- ACCUMULATE_FUNCTION(RegisterTurrets, RegisterTurrets_##id)
+ REGISTER(RegisterTurrets, TUR, turret_info, TUR_COUNT, id, m_id, spawn()) { \
+ register_turret(this, func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname); \
+ }
+
#ifdef MENUQC
#define REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
- REGISTER_TURRET_2(TUR_##id,t_null,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
+ _REGISTER_TURRET(id,t_null,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
#else
#define REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
- REGISTER_TURRET_2(TUR_##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
-#include "all.qh"
-
-#undef REGISTER_TURRET
-ACCUMULATE_FUNCTION(RegisterTurrets, register_turrets_done)
+void register_turret(entity e, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname)
+{
+ e.classname = "turret_info";
+ e.turretid = e.m_id;
+ e.netname = shortname;
+ e.turret_name = mname;
+ e.turret_func = func;
+ e.mdl = modelname;
+ e.cvar_basename = shortname;
+ e.spawnflags = turretflags;
+ e.mins = min_s;
+ e.maxs = max_s;
+ e.model = strzone(strcat("models/turrets/", modelname));
+ e.head_model = strzone(strcat("models/turrets/", headmodelname));
+}
+float t_null(float dummy) { return 0; }
+
+
+REGISTER_TURRET(Null,
+ t_null,
+ 0,
+ '-0 -0 -0',
+ '0 0 0',
+ "",
+ "",
+ "",
+ "Turret"
+);
+
+entity get_turretinfo(float id)
+{
+ entity m;
+ if(id < 1 || id > TUR_COUNT - 1)
+ return TUR_Null;
+ m = turret_info[id];
+ if(m)
+ return m;
+ return TUR_Null;
+}
+
+#include "all.inc"
#endif
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ EWHEEL,
/* function */ t_ewheel,
movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
}
-void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL)) remove(self); }
+void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL.m_id)) remove(self); }
float t_ewheel(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ FLAC,
/* function */ t_flac,
remove(self);
}
-void spawnfunc_turret_flac() { SELFPARAM(); if(!turret_initialize(TUR_FLAC)) remove(self); }
+void spawnfunc_turret_flac() { SELFPARAM(); if(!turret_initialize(TUR_FLAC.m_id)) remove(self); }
float t_flac(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ FUSIONREACTOR,
/* function */ t_fusionreactor,
return true;
}
-void spawnfunc_turret_fusionreactor() { SELFPARAM(); if(!turret_initialize(TUR_FUSIONREACTOR)) remove(self); }
+void spawnfunc_turret_fusionreactor() { SELFPARAM(); if(!turret_initialize(TUR_FUSIONREACTOR.m_id)) remove(self); }
float t_fusionreactor(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ HELLION,
/* function */ t_hellion,
UpdateCSQCProjectile(self);
}
-void spawnfunc_turret_hellion() { SELFPARAM(); if(!turret_initialize(TUR_HELLION)) remove(self); }
+void spawnfunc_turret_hellion() { SELFPARAM(); if(!turret_initialize(TUR_HELLION.m_id)) remove(self); }
float t_hellion(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ HK,
/* function */ t_hk,
return 0;
}
-void spawnfunc_turret_hk() { SELFPARAM(); if(!turret_initialize(TUR_HK)) remove(self); }
+void spawnfunc_turret_hk() { SELFPARAM(); if(!turret_initialize(TUR_HK.m_id)) remove(self); }
float t_hk(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ MACHINEGUN,
/* function */ t_machinegun,
);
#else
#ifdef SVQC
-void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN)) remove(self); }
+void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN.m_id)) remove(self); }
void W_MachineGun_MuzzleFlash(void);
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ MLRS,
/* function */ t_mlrs,
);
#else
#ifdef SVQC
-void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS)) remove(self); }
+void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS.m_id)) remove(self); }
float t_mlrs(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ PHASER,
/* function */ t_phaser,
}
-void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER)) remove(self); }
+void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER.m_id)) remove(self); }
float t_phaser(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ PLASMA,
/* function */ t_plasma,
);
#else
#ifdef SVQC
-void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA)) remove(self); }
+void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA.m_id)) remove(self); }
float t_plasma(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ PLASMA_DUAL,
/* function */ t_plasma_dual,
);
#else
#ifdef SVQC
-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); }
float t_plasma_dual(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ TESLA,
/* function */ t_tesla,
return 0;
}
-void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA)) remove(self); }
+void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA.m_id)) remove(self); }
float t_tesla(float req)
{SELFPARAM();
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
REGISTER_TURRET(
/* TUR_##id */ WALKER,
/* function */ t_walker,
#endif
}
-void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER)) remove(self); }
+void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER.m_id)) remove(self); }
float t_walker(float req)
{SELFPARAM();