#ifndef TURRET_H #define TURRET_H // 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(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