]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/turrets.qh
Hunter-Killer: Only loop through entities that can be damaged by contents (not perfec...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turrets.qh
index 9f90d3e520644af12ba58e548188d655dc339201..6f70f09beec2219624baeca92e2cd7deaa104fb4 100644 (file)
@@ -1,197 +1 @@
-// 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)
-
-// functions:
-entity get_turretinfo(float id);
-
-// fields:
-.entity tur_head;
-
-// target selection flags
-.float target_select_flags;
-.float target_validate_flags;
-const float TFL_TARGETSELECT_NO = 2; // don't automatically find targets
-const float TFL_TARGETSELECT_LOS = 4; // require line of sight to find targets
-const float TFL_TARGETSELECT_PLAYERS = 8; // target players
-const float TFL_TARGETSELECT_MISSILES = 16; // target projectiles
-const float TFL_TARGETSELECT_TRIGGERTARGET = 32; // respond to turret_trigger_target events
-const float TFL_TARGETSELECT_ANGLELIMITS = 64; // apply extra angular limits to target selection
-const float TFL_TARGETSELECT_RANGELIMITS = 128; // limit target selection range
-const float TFL_TARGETSELECT_TEAMCHECK = 256; // don't attack teammates
-const float TFL_TARGETSELECT_NOBUILTIN = 512; // only attack targets when triggered
-const float TFL_TARGETSELECT_OWNTEAM = 1024; // only attack teammates
-const float TFL_TARGETSELECT_NOTURRETS = 2048; // don't attack other turrets
-const float TFL_TARGETSELECT_FOV = 4096; // extra limits to attack range
-const float TFL_TARGETSELECT_MISSILESONLY = 8192; // only attack missiles
-
-// aim flags
-.float aim_flags;
-const float TFL_AIM_NO = 1; // no aiming
-const float TFL_AIM_SPLASH = 2; // aim for ground around the target's feet
-const float TFL_AIM_LEAD = 4; // try to predict target movement
-const float TFL_AIM_SHOTTIMECOMPENSATE = 8; // compensate for shot traveltime when leading
-const float TFL_AIM_ZPREDICT = 16; // predict target's z position at impact
-const float TFL_AIM_SIMPLE = 32; // aim at player's current location
-
-// tracking flags
-.float track_flags;
-const float TFL_TRACK_NO = 2; // don't move head
-const float TFL_TRACK_PITCH = 4; // pitch head
-const float TFL_TRACK_ROTATE = 8; // rotate head
-
-// prefire checks
-.float firecheck_flags;
-const float TFL_FIRECHECK_DEAD = 4; // don't attack dead targets (zombies?)
-const float TFL_FIRECHECK_DISTANCES = 8; // another range check
-const float TFL_FIRECHECK_LOS = 16; // line of sight
-const float TFL_FIRECHECK_AIMDIST = 32; // consider distance impactpoint<->aimspot
-const float TFL_FIRECHECK_REALDIST = 64; // consider enemy origin<->impactpoint
-const float TFL_FIRECHECK_ANGLEDIST = 128; // consider angular diff head<->aimspot
-const float TFL_FIRECHECK_TEAMCHECK = 256; // don't attack teammates
-const float TFL_FIRECHECK_AFF = 512; // try to avoid any friendly fire
-const float TFL_FIRECHECK_AMMO_OWN = 1024; // own ammo needs to be larger than damage dealt
-const float TFL_FIRECHECK_AMMO_OTHER = 2048; // target's ammo needs to be less than max
-const float TFL_FIRECHECK_REFIRE = 4096; // check single attack finished delays
-const float TFL_FIRECHECK_NO = 16384; // no prefire checks
-
-// attack flags
-.float shoot_flags;
-const float TFL_SHOOT_NO = 64; // no attacking
-const float TFL_SHOOT_VOLLY = 2; // fire in vollies
-const float TFL_SHOOT_VOLLYALWAYS = 4; // always do a full volly, even if target is lost
-const float TFL_SHOOT_HITALLVALID = 8; // loop through all valid targets
-const float TFL_SHOOT_CLEARTARGET = 16; // lose target after attack (after volly is done if in volly mode)
-const float TFL_SHOOT_CUSTOM = 32; // custom attacking
-
-// turret capabilities
-.float turret_flags;
-const float TUR_FLAG_NONE = 0; // no abilities
-const float TUR_FLAG_SNIPER = 2; // sniping turret
-const float TUR_FLAG_SPLASH = 4; // can deal splash damage
-const float TUR_FLAG_HITSCAN = 8; // hit scan
-const float TUR_FLAG_MULTIGUN = 16; // multiple guns
-const float TUR_FLAG_GUIDED = 32; // laser guided projectiles
-const float TUR_FLAG_SLOWPROJ = 64; // turret fires slow projectiles
-const float TUR_FLAG_MEDPROJ = 128; // turret fires medium projectiles
-const float TUR_FLAG_FASTPROJ = 256; // turret fires fast projectiles
-const float TUR_FLAG_PLAYER = 512; // can damage players
-const float TUR_FLAG_MISSILE = 1024; // can damage missiles
-const float TUR_FLAG_SUPPORT = 2048; // supports other units
-const float TUR_FLAG_AMMOSOURCE = 4096; // can provide ammunition
-const float TUR_FLAG_RECIEVETARGETS = 8192; // can recieve targets from external sources
-const float TUR_FLAG_MOVE = 16384; // can move
-const float TUR_FLAG_ROAM = 32768; // roams around if not attacking
-const float TUR_FLAG_ISTURRET = 65536; // identifies this unit as a turret
-
-// ammo types
-#define ammo_flags currentammo
-const float TFL_AMMO_NONE = 64; // doesn't use ammo
-const float TFL_AMMO_ENERGY = 2; // uses power
-const float TFL_AMMO_BULLETS = 4; // uses bullets
-const float TFL_AMMO_ROCKETS = 8; // uses explosives
-const float TFL_AMMO_RECHARGE = 16; // regenerates ammo
-const float TFL_AMMO_RECIEVE = 32; // can recieve ammo from support units
-
-// damage flags
-.float damage_flags;
-const float TFL_DMG_NO = 256; // doesn't take damage
-const float TFL_DMG_YES = 2; // can be damaged
-const float TFL_DMG_TEAM = 4; // can be damaged by teammates
-const float TFL_DMG_RETALIATE = 8; // target attackers
-const float TFL_DMG_RETALIATE_TEAM = 16; // target attackers, even if on same team
-const float TFL_DMG_TARGETLOSS = 32; // loses target when damaged
-const float TFL_DMG_AIMSHAKE = 64; // damage throws off aim
-const float TFL_DMG_HEADSHAKE = 128; // damage shakes head
-const float TFL_DMG_DEATH_NORESPAWN = 256; // no re-spawning
-
-// spawn flags
-const float TSF_SUSPENDED = 1;
-const float TSF_TERRAINBASE = 2; // currently unused
-const float TSF_NO_AMMO_REGEN = 4; // disable builtin ammo regeneration
-const float TSF_NO_PATHBREAK = 8; // don't break path to chase enemies, will still fire at them if possible
-const float TSL_NO_RESPAWN = 16; // don't re-spawn
-const float TSL_ROAM = 32; // roam while idle
-
-// send flags
-const float TNSF_UPDATE       = 2;
-const float TNSF_STATUS       = 4;
-const float TNSF_SETUP        = 8;
-const float TNSF_ANG          = 16;
-const float TNSF_AVEL         = 32;
-const float TNSF_MOVE         = 64;
-.float anim_start_time;
-const float TNSF_ANIM         = 128;
-
-const float TNSF_FULL_UPDATE  = 16777215;
-
-
-// entity properties of turretinfo:
-.float turretid; // TUR_...
-.string netname; // short name
-.string turret_name; // human readable name
-.float(float) turret_func; // m_...
-.string mdl; // currently a copy of the model
-.string model; // full name of model
-.string head_model; // full name of tur_head model
-.string cvar_basename; // TODO: deprecate!
-.float spawnflags;
-.vector mins, maxs; // turret hitbox size
-
-// 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 m_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();
-
-const float TUR_MAXCOUNT = 24;
-#define TUR_FIRST 1
-float TUR_COUNT;
-float TUR_LAST;
-
-#define REGISTER_TURRET_2(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
-       float id; \
-       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)
-#ifdef MENUQC
-#define REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
-       REGISTER_TURRET_2(TUR_##id,m_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)
-#endif
-
-#define TUR_DUPECHECK(dupecheck,cvar) \
-       #ifndef dupecheck \
-               #define dupecheck \
-               float cvar; \
-       #else \
-               #error DUPLICATE TURRET CVAR: cvar \
-       #endif
-
-#define TUR_ADD_CVAR(turret,name) \
-               TUR_DUPECHECK(TUR_CVAR_##turret##_##name, autocvar_g_turrets_unit_##turret##_##name)
-
-#define TUR_CVAR(turret,name) autocvar_g_turrets_unit_##turret##_##name
-
-#include "all.qh"
-
-#undef TUR_ADD_CVAR
-#undef REGISTER_TURRET
-ACCUMULATE_FUNCTION(RegisterTurrets, register_turrets_done);
+#pragma once