From 129cf6ae83fa24855423c8edec3ad2cb072cb4cd Mon Sep 17 00:00:00 2001 From: TimePath Date: Mon, 28 Sep 2015 15:29:21 +1000 Subject: [PATCH] Turrets: cleanup --- qcsrc/client/main.qc | 1 - qcsrc/client/progs.inc | 2 +- qcsrc/common/nades.qc | 2 +- qcsrc/common/turrets/all.inc | 24 +-- qcsrc/common/turrets/all.qc | 17 ++ qcsrc/common/turrets/all.qh | 189 +----------------- qcsrc/common/turrets/cl_turrets.qc | 2 - qcsrc/common/turrets/cl_turrets.qh | 2 - qcsrc/common/turrets/sv_turrets.qc | 1 - qcsrc/common/turrets/sv_turrets.qh | 6 +- qcsrc/common/turrets/turret.qh | 173 ++++++++++++++++ .../common/turrets/{unit => turret}/ewheel.qc | 7 +- qcsrc/common/turrets/{unit => turret}/flac.qc | 7 +- .../turrets/{unit => turret}/fusionreactor.qc | 7 +- .../turrets/{unit => turret}/hellion.qc | 7 +- qcsrc/common/turrets/{unit => turret}/hk.qc | 7 +- .../turrets/{unit => turret}/machinegun.qc | 7 +- qcsrc/common/turrets/{unit => turret}/mlrs.qc | 7 +- .../common/turrets/{unit => turret}/phaser.qc | 7 +- .../common/turrets/{unit => turret}/plasma.qc | 7 +- .../turrets/{unit => turret}/plasma_dual.qc | 7 +- .../common/turrets/{unit => turret}/tesla.qc | 7 +- .../common/turrets/{unit => turret}/walker.qc | 7 +- qcsrc/server/g_world.qc | 2 - qcsrc/server/progs.inc | 4 +- 25 files changed, 275 insertions(+), 234 deletions(-) create mode 100644 qcsrc/common/turrets/turret.qh rename qcsrc/common/turrets/{unit => turret}/ewheel.qc (99%) rename qcsrc/common/turrets/{unit => turret}/flac.qc (97%) rename qcsrc/common/turrets/{unit => turret}/fusionreactor.qc (96%) rename qcsrc/common/turrets/{unit => turret}/hellion.qc (98%) rename qcsrc/common/turrets/{unit => turret}/hk.qc (99%) rename qcsrc/common/turrets/{unit => turret}/machinegun.qc (95%) rename qcsrc/common/turrets/{unit => turret}/mlrs.qc (96%) rename qcsrc/common/turrets/{unit => turret}/phaser.qc (98%) rename qcsrc/common/turrets/{unit => turret}/plasma.qc (97%) rename qcsrc/common/turrets/{unit => turret}/plasma_dual.qc (98%) rename qcsrc/common/turrets/{unit => turret}/tesla.qc (98%) rename qcsrc/common/turrets/{unit => turret}/walker.qc (99%) diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index ca31f32f7..8bb66c874 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -146,7 +146,6 @@ void CSQC_Init(void) // needs to be done so early because of the constants they create static_init(); - CALL_ACCUMULATED_FUNCTION(RegisterTurrets); CALL_ACCUMULATED_FUNCTION(RegisterNotifications); CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes); CALL_ACCUMULATED_FUNCTION(RegisterHUD_Panels); diff --git a/qcsrc/client/progs.inc b/qcsrc/client/progs.inc index 1b9c587ab..449692d5f 100644 --- a/qcsrc/client/progs.inc +++ b/qcsrc/client/progs.inc @@ -55,11 +55,11 @@ #include "../common/items/all.qc" #include "../common/monsters/all.qc" #include "../common/mutators/all.qc" +#include "../common/turrets/all.qc" #include "../common/vehicles/all.qc" #include "../common/weapons/all.qc" #include "../common/turrets/cl_turrets.qc" -#include "../common/turrets/all.qc" #include "../common/triggers/include.qc" diff --git a/qcsrc/common/nades.qc b/qcsrc/common/nades.qc index f361730ba..d75087125 100644 --- a/qcsrc/common/nades.qc +++ b/qcsrc/common/nades.qc @@ -78,7 +78,7 @@ void ent_healer() {SELFPARAM(); int sf = ReadByte(); - if(sf & TNSF_SETUP) + if(sf & 1) { self.origin_x = ReadCoord(); self.origin_y = ReadCoord(); diff --git a/qcsrc/common/turrets/all.inc b/qcsrc/common/turrets/all.inc index 04bb10f6a..5c9f1e16f 100644 --- a/qcsrc/common/turrets/all.inc +++ b/qcsrc/common/turrets/all.inc @@ -1,12 +1,12 @@ -#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 "turret/ewheel.qc" +#include "turret/flac.qc" +#include "turret/fusionreactor.qc" +#include "turret/hellion.qc" +#include "turret/hk.qc" +#include "turret/machinegun.qc" +#include "turret/mlrs.qc" +#include "turret/phaser.qc" +#include "turret/plasma.qc" +#include "turret/plasma_dual.qc" +#include "turret/tesla.qc" +#include "turret/walker.qc" diff --git a/qcsrc/common/turrets/all.qc b/qcsrc/common/turrets/all.qc index f0fc7195a..c23a13861 100644 --- a/qcsrc/common/turrets/all.qc +++ b/qcsrc/common/turrets/all.qc @@ -1,5 +1,22 @@ #include "all.qh" +Turret get_turretinfo(int id) +{ + if (id < 1 || id > TUR_COUNT - 1) + return TUR_Null; + Turret m = turret_info[id]; + if (m) return m; + return TUR_Null; +} + +#ifdef SVQC +#include "sv_turrets.qh" +#endif + +#ifdef CSQC +#include "cl_turrets.qh" +#endif + #define IMPLEMENTATION #include "all.inc" #undef IMPLEMENTATION diff --git a/qcsrc/common/turrets/all.qh b/qcsrc/common/turrets/all.qh index 4f8a72802..3e4af08f6 100644 --- a/qcsrc/common/turrets/all.qh +++ b/qcsrc/common/turrets/all.qh @@ -1,147 +1,8 @@ -#ifndef TURRETS_H -#define TURRETS_H +#ifndef TURRETS_ALL_H +#define TURRETS_ALL_H -// turret requests -#define TR_SETUP 1 // (BOTH) setup turret data -#define TR_THINK 2 // (SERVER) logic to run every frame -#define TR_DEATH 3 // (SERVER) called when turret dies -#define TR_PRECACHE 4 // (BOTH) precaches models/sounds used by this turret -#define TR_ATTACK 5 // (SERVER) called when turret attacks -#define TR_CONFIG 6 // (ALL) +#include "turret.qh" -// functions: -entity get_turretinfo(int id); - -// fields: -.entity tur_head; - -// target selection flags -.int target_select_flags; -.int target_validate_flags; -const int TFL_TARGETSELECT_NO = 2; // don't automatically find targets -const int TFL_TARGETSELECT_LOS = 4; // require line of sight to find targets -const int TFL_TARGETSELECT_PLAYERS = 8; // target players -const int TFL_TARGETSELECT_MISSILES = 16; // target projectiles -const int TFL_TARGETSELECT_TRIGGERTARGET = 32; // respond to turret_trigger_target events -const int TFL_TARGETSELECT_ANGLELIMITS = 64; // apply extra angular limits to target selection -const int TFL_TARGETSELECT_RANGELIMITS = 128; // limit target selection range -const int TFL_TARGETSELECT_TEAMCHECK = 256; // don't attack teammates -const int TFL_TARGETSELECT_NOBUILTIN = 512; // only attack targets when triggered -const int TFL_TARGETSELECT_OWNTEAM = 1024; // only attack teammates -const int TFL_TARGETSELECT_NOTURRETS = 2048; // don't attack other turrets -const int TFL_TARGETSELECT_FOV = 4096; // extra limits to attack range -const int TFL_TARGETSELECT_MISSILESONLY = 8192; // only attack missiles - -// aim flags -.int aim_flags; -const int TFL_AIM_NO = 1; // no aiming -const int TFL_AIM_SPLASH = 2; // aim for ground around the target's feet -const int TFL_AIM_LEAD = 4; // try to predict target movement -const int TFL_AIM_SHOTTIMECOMPENSATE = 8; // compensate for shot traveltime when leading -const int TFL_AIM_ZPREDICT = 16; // predict target's z position at impact -const int TFL_AIM_SIMPLE = 32; // aim at player's current location - -// tracking flags -.int track_flags; -const int TFL_TRACK_NO = 2; // don't move head -const int TFL_TRACK_PITCH = 4; // pitch head -const int TFL_TRACK_ROTATE = 8; // rotate head - -// prefire checks -.int firecheck_flags; -const int TFL_FIRECHECK_DEAD = 4; // don't attack dead targets (zombies?) -const int TFL_FIRECHECK_DISTANCES = 8; // another range check -const int TFL_FIRECHECK_LOS = 16; // line of sight -const int TFL_FIRECHECK_AIMDIST = 32; // consider distance impactpoint<->aimspot -const int TFL_FIRECHECK_REALDIST = 64; // consider enemy origin<->impactpoint -const int TFL_FIRECHECK_ANGLEDIST = 128; // consider angular diff head<->aimspot -const int TFL_FIRECHECK_TEAMCHECK = 256; // don't attack teammates -const int TFL_FIRECHECK_AFF = 512; // try to avoid any friendly fire -const int TFL_FIRECHECK_AMMO_OWN = 1024; // own ammo needs to be larger than damage dealt -const int TFL_FIRECHECK_AMMO_OTHER = 2048; // target's ammo needs to be less than max -const int TFL_FIRECHECK_REFIRE = 4096; // check single attack finished delays -const int TFL_FIRECHECK_NO = 16384; // no prefire checks - -// attack flags -.int shoot_flags; -const int TFL_SHOOT_NO = 64; // no attacking -const int TFL_SHOOT_VOLLY = 2; // fire in vollies -const int TFL_SHOOT_VOLLYALWAYS = 4; // always do a full volly, even if target is lost -const int TFL_SHOOT_HITALLVALID = 8; // loop through all valid targets -const int TFL_SHOOT_CLEARTARGET = 16; // lose target after attack (after volly is done if in volly mode) -const int TFL_SHOOT_CUSTOM = 32; // custom attacking - -// turret capabilities -.int turret_flags; -const int TUR_FLAG_NONE = 0; // no abilities -const int TUR_FLAG_SNIPER = 2; // sniping turret -const int TUR_FLAG_SPLASH = 4; // can deal splash damage -const int TUR_FLAG_HITSCAN = 8; // hit scan -const int TUR_FLAG_MULTIGUN = 16; // multiple guns -const int TUR_FLAG_GUIDED = 32; // laser guided projectiles -const int TUR_FLAG_SLOWPROJ = 64; // turret fires slow projectiles -const int TUR_FLAG_MEDPROJ = 128; // turret fires medium projectiles -const int TUR_FLAG_FASTPROJ = 256; // turret fires fast projectiles -const int TUR_FLAG_PLAYER = 512; // can damage players -const int TUR_FLAG_MISSILE = 1024; // can damage missiles -const int TUR_FLAG_SUPPORT = 2048; // supports other units -const int TUR_FLAG_AMMOSOURCE = 4096; // can provide ammunition -const int TUR_FLAG_RECIEVETARGETS = 8192; // can recieve targets from external sources -const int TUR_FLAG_MOVE = 16384; // can move -const int TUR_FLAG_ROAM = 32768; // roams around if not attacking -const int TUR_FLAG_ISTURRET = 65536; // identifies this unit as a turret - -// ammo types -#define ammo_flags currentammo -const int TFL_AMMO_NONE = 64; // doesn't use ammo -const int TFL_AMMO_ENERGY = 2; // uses power -const int TFL_AMMO_BULLETS = 4; // uses bullets -const int TFL_AMMO_ROCKETS = 8; // uses explosives -const int TFL_AMMO_RECHARGE = 16; // regenerates ammo -const int TFL_AMMO_RECIEVE = 32; // can recieve ammo from support units - -// damage flags -.int damage_flags; -const int TFL_DMG_NO = 256; // doesn't take damage -const int TFL_DMG_YES = 2; // can be damaged -const int TFL_DMG_TEAM = 4; // can be damaged by teammates -const int TFL_DMG_RETALIATE = 8; // target attackers -const int TFL_DMG_RETALIATE_TEAM = 16; // target attackers, even if on same team -const int TFL_DMG_TARGETLOSS = 32; // loses target when damaged -const int TFL_DMG_AIMSHAKE = 64; // damage throws off aim -const int TFL_DMG_HEADSHAKE = 128; // damage shakes head -const int TFL_DMG_DEATH_NORESPAWN = 256; // no re-spawning - -// spawn flags -const int TSF_SUSPENDED = 1; -const int TSF_TERRAINBASE = 2; // currently unused -const int TSF_NO_AMMO_REGEN = 4; // disable builtin ammo regeneration -const int TSF_NO_PATHBREAK = 8; // don't break path to chase enemies, will still fire at them if possible -const int TSL_NO_RESPAWN = 16; // don't re-spawn -const int TSL_ROAM = 32; // roam while idle - -// send flags -const int TNSF_UPDATE = 2; -const int TNSF_STATUS = 4; -const int TNSF_SETUP = 8; -const int TNSF_ANG = 16; -const int TNSF_AVEL = 32; -const int TNSF_MOVE = 64; -.float anim_start_time; -const int TNSF_ANIM = 128; - -const int TNSF_FULL_UPDATE = 16777215; - - -// other useful macros -#define TUR_ACTION(turrettype,mrequest) (get_turretinfo(turrettype)).turret_func(mrequest) -#define TUR_NAME(turrettype) (get_turretinfo(turrettype)).turret_name - -// ===================== -// Turret Registration -// ===================== - -float t_null(float dummy); 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 int TUR_MAXCOUNT = 24; @@ -164,37 +25,6 @@ REGISTER_REGISTRY(RegisterTurrets) _REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) #endif -float t_null(float dummy) { return 0; } - -CLASS(Turret, Object) - ATTRIB(Turret, m_id, int, 0) - - ATTRIB(Turret, turretid, 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(float), t_null) - /** 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) - /** TODO: deprecate! */ - ATTRIB(Turret, cvar_basename, 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); - } - void register_turret(Turret e, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname) { e.classname = "turret_info"; @@ -210,8 +40,8 @@ void register_turret(Turret e, float(float) func, float turretflags, vector min_ e.model = strzone(strcat("models/turrets/", modelname)); e.head_model = strzone(strcat("models/turrets/", headmodelname)); } -ENDCLASS(Turret) +entity get_turretinfo(int id); REGISTER_TURRET(Null, t_null, @@ -224,17 +54,6 @@ REGISTER_TURRET(Null, "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 diff --git a/qcsrc/common/turrets/cl_turrets.qc b/qcsrc/common/turrets/cl_turrets.qc index b2a0fe1b5..94fb4ae3f 100644 --- a/qcsrc/common/turrets/cl_turrets.qc +++ b/qcsrc/common/turrets/cl_turrets.qc @@ -1,5 +1,3 @@ -#include "all.qh" - void turret_remove() {SELFPARAM(); remove(self.tur_head); diff --git a/qcsrc/common/turrets/cl_turrets.qh b/qcsrc/common/turrets/cl_turrets.qh index f8ea64ad1..0f8ff9485 100644 --- a/qcsrc/common/turrets/cl_turrets.qh +++ b/qcsrc/common/turrets/cl_turrets.qh @@ -1,8 +1,6 @@ #ifndef CL_TURRETS_H #define CL_TURRETS_H -#include "all.qh" - void ent_turret(); #endif diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index c17061b22..337b2789a 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -1,5 +1,4 @@ #ifdef SVQC -#include "all.qh" #include "../../server/autocvars.qh" // Generic aiming diff --git a/qcsrc/common/turrets/sv_turrets.qh b/qcsrc/common/turrets/sv_turrets.qh index 1a4ade680..4eca2c6fb 100644 --- a/qcsrc/common/turrets/sv_turrets.qh +++ b/qcsrc/common/turrets/sv_turrets.qh @@ -1,7 +1,11 @@ #ifndef SV_TURRETS_H #define SV_TURRETS_H -#include "all.qh" +entity turret_projectile(string _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim); +void turret_projectile_explode(); +float turret_validate_target(entity e_turret, entity e_target, float validate_flags); +float turret_firecheck(); +entity turret_select_target(); // turret fields .float ticrate; // interal ai think rate diff --git a/qcsrc/common/turrets/turret.qh b/qcsrc/common/turrets/turret.qh new file mode 100644 index 000000000..e31d93fd2 --- /dev/null +++ b/qcsrc/common/turrets/turret.qh @@ -0,0 +1,173 @@ +#ifndef TURRET_H +#define TURRET_H + +// turret requests +const int TR_SETUP = 1; // (BOTH) setup turret data +const int TR_THINK = 2; // (SERVER) logic to run every frame +const int TR_DEATH = 3; // (SERVER) called when turret dies +const int TR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this turret +const int TR_ATTACK = 5; // (SERVER) called when turret attacks +const int TR_CONFIG = 6; // (ALL) + +// functions: +entity get_turretinfo(int id); + +// fields: +.entity tur_head; + +// target selection flags +.int target_select_flags; +.int target_validate_flags; +const int TFL_TARGETSELECT_NO = 2; // don't automatically find targets +const int TFL_TARGETSELECT_LOS = 4; // require line of sight to find targets +const int TFL_TARGETSELECT_PLAYERS = 8; // target players +const int TFL_TARGETSELECT_MISSILES = 16; // target projectiles +const int TFL_TARGETSELECT_TRIGGERTARGET = 32; // respond to turret_trigger_target events +const int TFL_TARGETSELECT_ANGLELIMITS = 64; // apply extra angular limits to target selection +const int TFL_TARGETSELECT_RANGELIMITS = 128; // limit target selection range +const int TFL_TARGETSELECT_TEAMCHECK = 256; // don't attack teammates +const int TFL_TARGETSELECT_NOBUILTIN = 512; // only attack targets when triggered +const int TFL_TARGETSELECT_OWNTEAM = 1024; // only attack teammates +const int TFL_TARGETSELECT_NOTURRETS = 2048; // don't attack other turrets +const int TFL_TARGETSELECT_FOV = 4096; // extra limits to attack range +const int TFL_TARGETSELECT_MISSILESONLY = 8192; // only attack missiles + +// aim flags +.int aim_flags; +const int TFL_AIM_NO = 1; // no aiming +const int TFL_AIM_SPLASH = 2; // aim for ground around the target's feet +const int TFL_AIM_LEAD = 4; // try to predict target movement +const int TFL_AIM_SHOTTIMECOMPENSATE = 8; // compensate for shot traveltime when leading +const int TFL_AIM_ZPREDICT = 16; // predict target's z position at impact +const int TFL_AIM_SIMPLE = 32; // aim at player's current location + +// tracking flags +.int track_flags; +const int TFL_TRACK_NO = 2; // don't move head +const int TFL_TRACK_PITCH = 4; // pitch head +const int TFL_TRACK_ROTATE = 8; // rotate head + +// prefire checks +.int firecheck_flags; +const int TFL_FIRECHECK_DEAD = 4; // don't attack dead targets (zombies?) +const int TFL_FIRECHECK_DISTANCES = 8; // another range check +const int TFL_FIRECHECK_LOS = 16; // line of sight +const int TFL_FIRECHECK_AIMDIST = 32; // consider distance impactpoint<->aimspot +const int TFL_FIRECHECK_REALDIST = 64; // consider enemy origin<->impactpoint +const int TFL_FIRECHECK_ANGLEDIST = 128; // consider angular diff head<->aimspot +const int TFL_FIRECHECK_TEAMCHECK = 256; // don't attack teammates +const int TFL_FIRECHECK_AFF = 512; // try to avoid any friendly fire +const int TFL_FIRECHECK_AMMO_OWN = 1024; // own ammo needs to be larger than damage dealt +const int TFL_FIRECHECK_AMMO_OTHER = 2048; // target's ammo needs to be less than max +const int TFL_FIRECHECK_REFIRE = 4096; // check single attack finished delays +const int TFL_FIRECHECK_NO = 16384; // no prefire checks + +// attack flags +.int shoot_flags; +const int TFL_SHOOT_NO = 64; // no attacking +const int TFL_SHOOT_VOLLY = 2; // fire in vollies +const int TFL_SHOOT_VOLLYALWAYS = 4; // always do a full volly, even if target is lost +const int TFL_SHOOT_HITALLVALID = 8; // loop through all valid targets +const int TFL_SHOOT_CLEARTARGET = 16; // lose target after attack (after volly is done if in volly mode) +const int TFL_SHOOT_CUSTOM = 32; // custom attacking + +// turret capabilities +.int turret_flags; +const int TUR_FLAG_NONE = 0; // no abilities +const int TUR_FLAG_SNIPER = 2; // sniping turret +const int TUR_FLAG_SPLASH = 4; // can deal splash damage +const int TUR_FLAG_HITSCAN = 8; // hit scan +const int TUR_FLAG_MULTIGUN = 16; // multiple guns +const int TUR_FLAG_GUIDED = 32; // laser guided projectiles +const int TUR_FLAG_SLOWPROJ = 64; // turret fires slow projectiles +const int TUR_FLAG_MEDPROJ = 128; // turret fires medium projectiles +const int TUR_FLAG_FASTPROJ = 256; // turret fires fast projectiles +const int TUR_FLAG_PLAYER = 512; // can damage players +const int TUR_FLAG_MISSILE = 1024; // can damage missiles +const int TUR_FLAG_SUPPORT = 2048; // supports other units +const int TUR_FLAG_AMMOSOURCE = 4096; // can provide ammunition +const int TUR_FLAG_RECIEVETARGETS = 8192; // can recieve targets from external sources +const int TUR_FLAG_MOVE = 16384; // can move +const int TUR_FLAG_ROAM = 32768; // roams around if not attacking +const int TUR_FLAG_ISTURRET = 65536; // identifies this unit as a turret + +// ammo types +#define ammo_flags currentammo +const int TFL_AMMO_NONE = 64; // doesn't use ammo +const int TFL_AMMO_ENERGY = 2; // uses power +const int TFL_AMMO_BULLETS = 4; // uses bullets +const int TFL_AMMO_ROCKETS = 8; // uses explosives +const int TFL_AMMO_RECHARGE = 16; // regenerates ammo +const int TFL_AMMO_RECIEVE = 32; // can recieve ammo from support units + +// damage flags +.int damage_flags; +const int TFL_DMG_NO = 256; // doesn't take damage +const int TFL_DMG_YES = 2; // can be damaged +const int TFL_DMG_TEAM = 4; // can be damaged by teammates +const int TFL_DMG_RETALIATE = 8; // target attackers +const int TFL_DMG_RETALIATE_TEAM = 16; // target attackers, even if on same team +const int TFL_DMG_TARGETLOSS = 32; // loses target when damaged +const int TFL_DMG_AIMSHAKE = 64; // damage throws off aim +const int TFL_DMG_HEADSHAKE = 128; // damage shakes head +const int TFL_DMG_DEATH_NORESPAWN = 256; // no re-spawning + +// spawn flags +const int TSF_SUSPENDED = 1; +const int TSF_TERRAINBASE = 2; // currently unused +const int TSF_NO_AMMO_REGEN = 4; // disable builtin ammo regeneration +const int TSF_NO_PATHBREAK = 8; // don't break path to chase enemies, will still fire at them if possible +const int TSL_NO_RESPAWN = 16; // don't re-spawn +const int TSL_ROAM = 32; // roam while idle + +// send flags +const int TNSF_UPDATE = 2; +const int TNSF_STATUS = 4; +const int TNSF_SETUP = 8; +const int TNSF_ANG = 16; +const int TNSF_AVEL = 32; +const int TNSF_MOVE = 64; +.float anim_start_time; +const int TNSF_ANIM = 128; + +const int TNSF_FULL_UPDATE = 16777215; + + +// other useful macros +#define TUR_ACTION(turrettype,mrequest) (get_turretinfo(turrettype)).turret_func(mrequest) +#define TUR_NAME(turrettype) (get_turretinfo(turrettype)).turret_name + +float t_null(float dummy) { return 0; } + +CLASS(Turret, Object) + ATTRIB(Turret, m_id, int, 0) + + ATTRIB(Turret, turretid, 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(float), t_null) + /** 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) + /** TODO: deprecate! */ + ATTRIB(Turret, cvar_basename, 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) + +#endif diff --git a/qcsrc/common/turrets/unit/ewheel.qc b/qcsrc/common/turrets/turret/ewheel.qc similarity index 99% rename from qcsrc/common/turrets/unit/ewheel.qc rename to qcsrc/common/turrets/turret/ewheel.qc index cd111b258..a27860bc4 100644 --- a/qcsrc/common/turrets/unit/ewheel.qc +++ b/qcsrc/common/turrets/turret/ewheel.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_EWHEEL_H +#define TUR_EWHEEL_H REGISTER_TURRET( /* TUR_##id */ EWHEEL, /* function */ t_ewheel, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "ewheel", /* fullname */ _("eWheel Turret") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC float autocvar_g_turrets_unit_ewheel_speed_fast; float autocvar_g_turrets_unit_ewheel_speed_slow; diff --git a/qcsrc/common/turrets/unit/flac.qc b/qcsrc/common/turrets/turret/flac.qc similarity index 97% rename from qcsrc/common/turrets/unit/flac.qc rename to qcsrc/common/turrets/turret/flac.qc index e19116067..aacefd164 100644 --- a/qcsrc/common/turrets/unit/flac.qc +++ b/qcsrc/common/turrets/turret/flac.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_FLAC_H +#define TUR_FLAC_H REGISTER_TURRET( /* TUR_##id */ FLAC, /* function */ t_flac, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "flac", /* fullname */ _("FLAC Cannon") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC void turret_flac_projectile_think_explode() {SELFPARAM(); diff --git a/qcsrc/common/turrets/unit/fusionreactor.qc b/qcsrc/common/turrets/turret/fusionreactor.qc similarity index 96% rename from qcsrc/common/turrets/unit/fusionreactor.qc rename to qcsrc/common/turrets/turret/fusionreactor.qc index 5a8df2aad..7d2f4f0b6 100644 --- a/qcsrc/common/turrets/unit/fusionreactor.qc +++ b/qcsrc/common/turrets/turret/fusionreactor.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_FUSIONREACTOR_H +#define TUR_FUSIONREACTOR_H REGISTER_TURRET( /* TUR_##id */ FUSIONREACTOR, /* function */ t_fusionreactor, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "fusionreactor", /* fullname */ _("Fusion Reactor") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC bool turret_fusionreactor_firecheck() {SELFPARAM(); diff --git a/qcsrc/common/turrets/unit/hellion.qc b/qcsrc/common/turrets/turret/hellion.qc similarity index 98% rename from qcsrc/common/turrets/unit/hellion.qc rename to qcsrc/common/turrets/turret/hellion.qc index 56f5da90a..9efae2d96 100644 --- a/qcsrc/common/turrets/unit/hellion.qc +++ b/qcsrc/common/turrets/turret/hellion.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_HELLION_H +#define TUR_HELLION_H REGISTER_TURRET( /* TUR_##id */ HELLION, /* function */ t_hellion, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "hellion", /* fullname */ _("Hellion Missile Turret") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC float autocvar_g_turrets_unit_hellion_shot_speed_gain; float autocvar_g_turrets_unit_hellion_shot_speed_max; diff --git a/qcsrc/common/turrets/unit/hk.qc b/qcsrc/common/turrets/turret/hk.qc similarity index 99% rename from qcsrc/common/turrets/unit/hk.qc rename to qcsrc/common/turrets/turret/hk.qc index 106c982ae..8ec6f16bc 100644 --- a/qcsrc/common/turrets/unit/hk.qc +++ b/qcsrc/common/turrets/turret/hk.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_HK_H +#define TUR_HK_H REGISTER_TURRET( /* TUR_##id */ HK, /* function */ t_hk, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "hk", /* fullname */ _("Hunter-Killer Turret") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC float autocvar_g_turrets_unit_hk_shot_speed; float autocvar_g_turrets_unit_hk_shot_speed_accel; diff --git a/qcsrc/common/turrets/unit/machinegun.qc b/qcsrc/common/turrets/turret/machinegun.qc similarity index 95% rename from qcsrc/common/turrets/unit/machinegun.qc rename to qcsrc/common/turrets/turret/machinegun.qc index 35f1921ed..48a200cd7 100644 --- a/qcsrc/common/turrets/unit/machinegun.qc +++ b/qcsrc/common/turrets/turret/machinegun.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_MACHINEGUN_H +#define TUR_MACHINEGUN_H REGISTER_TURRET( /* TUR_##id */ MACHINEGUN, /* function */ t_machinegun, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "machinegun", /* fullname */ _("Machinegun Turret") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN.m_id)) remove(self); } diff --git a/qcsrc/common/turrets/unit/mlrs.qc b/qcsrc/common/turrets/turret/mlrs.qc similarity index 96% rename from qcsrc/common/turrets/unit/mlrs.qc rename to qcsrc/common/turrets/turret/mlrs.qc index 21e0a435d..fe3775bd1 100644 --- a/qcsrc/common/turrets/unit/mlrs.qc +++ b/qcsrc/common/turrets/turret/mlrs.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_MLRS_H +#define TUR_MLRS_H REGISTER_TURRET( /* TUR_##id */ MLRS, /* function */ t_mlrs, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "mlrs", /* fullname */ _("MLRS Turret") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS.m_id)) remove(self); } diff --git a/qcsrc/common/turrets/unit/phaser.qc b/qcsrc/common/turrets/turret/phaser.qc similarity index 98% rename from qcsrc/common/turrets/unit/phaser.qc rename to qcsrc/common/turrets/turret/phaser.qc index 04e226448..9e162495b 100644 --- a/qcsrc/common/turrets/unit/phaser.qc +++ b/qcsrc/common/turrets/turret/phaser.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_PHASER_H +#define TUR_PHASER_H REGISTER_TURRET( /* TUR_##id */ PHASER, /* function */ t_phaser, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "phaser", /* fullname */ _("Phaser Cannon") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC .float fireflag; diff --git a/qcsrc/common/turrets/unit/plasma.qc b/qcsrc/common/turrets/turret/plasma.qc similarity index 97% rename from qcsrc/common/turrets/unit/plasma.qc rename to qcsrc/common/turrets/turret/plasma.qc index baafa51c6..0cfe13ca6 100644 --- a/qcsrc/common/turrets/unit/plasma.qc +++ b/qcsrc/common/turrets/turret/plasma.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_PLASMA_H +#define TUR_PLASMA_H REGISTER_TURRET( /* TUR_##id */ PLASMA, /* function */ t_plasma, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "plasma", /* fullname */ _("Plasma Cannon") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA.m_id)) remove(self); } diff --git a/qcsrc/common/turrets/unit/plasma_dual.qc b/qcsrc/common/turrets/turret/plasma_dual.qc similarity index 98% rename from qcsrc/common/turrets/unit/plasma_dual.qc rename to qcsrc/common/turrets/turret/plasma_dual.qc index 8b2bc252e..74713eaa9 100644 --- a/qcsrc/common/turrets/unit/plasma_dual.qc +++ b/qcsrc/common/turrets/turret/plasma_dual.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_PLASMA_DUAL_H +#define TUR_PLASMA_DUAL_H REGISTER_TURRET( /* TUR_##id */ PLASMA_DUAL, /* function */ t_plasma_dual, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "plasma_dual", /* fullname */ _("Dual Plasma Cannon") ); -#else +#endif + +#ifdef IMPLEMENTATION #include "../../weapons/all.qh" diff --git a/qcsrc/common/turrets/unit/tesla.qc b/qcsrc/common/turrets/turret/tesla.qc similarity index 98% rename from qcsrc/common/turrets/unit/tesla.qc rename to qcsrc/common/turrets/turret/tesla.qc index d3c894b96..66c675157 100644 --- a/qcsrc/common/turrets/unit/tesla.qc +++ b/qcsrc/common/turrets/turret/tesla.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_TESLA_H +#define TUR_TESLA_H REGISTER_TURRET( /* TUR_##id */ TESLA, /* function */ t_tesla, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "tesla", /* fullname */ _("Tesla Coil") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC entity toast(entity from, float range, float damage) {SELFPARAM(); diff --git a/qcsrc/common/turrets/unit/walker.qc b/qcsrc/common/turrets/turret/walker.qc similarity index 99% rename from qcsrc/common/turrets/unit/walker.qc rename to qcsrc/common/turrets/turret/walker.qc index 792e7a338..82fb62238 100644 --- a/qcsrc/common/turrets/unit/walker.qc +++ b/qcsrc/common/turrets/turret/walker.qc @@ -1,4 +1,5 @@ -#ifndef IMPLEMENTATION +#ifndef TUR_WALKER_H +#define TUR_WALKER_H REGISTER_TURRET( /* TUR_##id */ WALKER, /* function */ t_walker, @@ -9,7 +10,9 @@ REGISTER_TURRET( /* netname */ "walker", /* fullname */ _("Walker Turret") ); -#else +#endif + +#ifdef IMPLEMENTATION #ifdef SVQC float autocvar_g_turrets_unit_walker_melee_damage; float autocvar_g_turrets_unit_walker_melee_force; diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index e17e7adbc..2c889c09e 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -557,7 +557,6 @@ void spawnfunc___init_dedicated_server(void) // needs to be done so early because of the constants they create static_init(); - CALL_ACCUMULATED_FUNCTION(RegisterTurrets); CALL_ACCUMULATED_FUNCTION(RegisterNotifications); CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes); @@ -604,7 +603,6 @@ void spawnfunc_worldspawn (void) // needs to be done so early because of the constants they create static_init(); - CALL_ACCUMULATED_FUNCTION(RegisterTurrets); CALL_ACCUMULATED_FUNCTION(RegisterNotifications); CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes); diff --git a/qcsrc/server/progs.inc b/qcsrc/server/progs.inc index 4eceb36b9..86ede6350 100644 --- a/qcsrc/server/progs.inc +++ b/qcsrc/server/progs.inc @@ -101,13 +101,13 @@ #include "../common/items/all.qc" #include "../common/monsters/all.qc" #include "../common/mutators/all.qc" +#include "../common/turrets/all.qc" #include "../common/vehicles/all.qc" -#include "../common/weapons/all.qc" // TODO +#include "../common/weapons/all.qc" #include "../common/turrets/sv_turrets.qc" #include "../common/turrets/config.qc" #include "../common/turrets/util.qc" -#include "../common/turrets/all.qc" #include "../common/turrets/checkpoint.qc" #include "../common/turrets/targettrigger.qc" #include "../common/weapons/config.qc" -- 2.39.2