WriteCoord(MSG_ONE, (t + 1) / 60);
}
-void ctf_EventLog(string mode, float flagteam, entity actor) // use an alias for easy changing and quick editing later
+void ctf_EventLog(string mode, int flagteam, entity actor) // use an alias for easy changing and quick editing later
{
if(autocvar_sv_eventlog)
GameLogEcho(sprintf(":ctf:%s:%d:%d:%s", mode, flagteam, actor.team, ((actor != world) ? ftos(actor.playerid) : "")));
else { flag.velocity = (desired_direction * autocvar_g_ctf_pass_velocity); }
}
-float ctf_CheckPassDirection(vector head_center, vector passer_center, vector passer_angle, vector nearest_to_passer)
+bool ctf_CheckPassDirection(vector head_center, vector passer_center, vector passer_angle, vector nearest_to_passer)
{
if(autocvar_g_ctf_pass_directional_max || autocvar_g_ctf_pass_directional_min)
{
// CaptureShield Functions
// =======================
-float ctf_CaptureShield_CheckStatus(entity p)
+bool ctf_CaptureShield_CheckStatus(entity p)
{
- float s, s2, s3, s4, se, se2, se3, se4, sr, ser;
+ int s, s2, s3, s4, se, se2, se3, se4, sr, ser;
entity e;
- float players_worseeq, players_total;
+ int players_worseeq, players_total;
if(ctf_captureshield_max_ratio <= 0)
return false;
return true;
}
-void ctf_CaptureShield_Update(entity player, float wanted_status)
+void ctf_CaptureShield_Update(entity player, bool wanted_status)
{
- float updated_status = ctf_CaptureShield_CheckStatus(player);
+ bool updated_status = ctf_CaptureShield_CheckStatus(player);
if((wanted_status == player.ctf_captureshielded) && (updated_status != wanted_status)) // 0: shield only, 1: unshield only
{
Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((updated_status) ? CENTER_CTF_CAPTURESHIELD_SHIELDED : CENTER_CTF_CAPTURESHIELD_FREE));
}
}
-float ctf_CaptureShield_Customize()
+bool ctf_CaptureShield_Customize()
{
- if(self.enemy.active != ACTIVE_ACTIVE) { return true; }
if(!other.ctf_captureshielded) { return false; }
if(CTF_SAMETEAM(self, other)) { return false; }
void ctf_CaptureShield_Touch()
{
- if(self.enemy.active != ACTIVE_ACTIVE)
- {
- vector mymid = (self.absmin + self.absmax) * 0.5;
- vector othermid = (other.absmin + other.absmax) * 0.5;
-
- Damage(other, self, self, 0, DEATH_HURTTRIGGER, mymid, normalize(othermid - mymid) * ctf_captureshield_force);
- if(IS_REAL_CLIENT(other)) { Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_CTF_CAPTURESHIELD_INACTIVE); }
-
- return;
- }
-
if(!other.ctf_captureshielded) { return; }
if(CTF_SAMETEAM(self, other)) { return; }
// Drop/Pass/Throw Code
// ====================
-void ctf_Handle_Drop(entity flag, entity player, float droptype)
+void ctf_Handle_Drop(entity flag, entity player, int droptype)
{
// declarations
player = (player ? player : flag.pass_sender);
flag.pass_target = world;
}
-void ctf_Handle_Throw(entity player, entity receiver, float droptype)
+void ctf_Handle_Throw(entity player, entity receiver, int droptype)
{
entity flag = player.flagcarried;
vector targ_origin, flag_velocity;
// Event Handlers
// ==============
-void ctf_Handle_Capture(entity flag, entity toucher, float capturetype)
+void ctf_Handle_Capture(entity flag, entity toucher, int capturetype)
{
entity enemy_flag = ((capturetype == CAPTURE_NORMAL) ? toucher.flagcarried : toucher);
entity player = ((capturetype == CAPTURE_NORMAL) ? toucher : enemy_flag.ctf_dropper);
ctf_RespawnFlag(flag);
}
-void ctf_Handle_Pickup(entity flag, entity player, float pickuptype)
+void ctf_Handle_Pickup(entity flag, entity player, int pickuptype)
{
// declarations
float pickup_dropped_score; // used to calculate dropped pickup score
// Main Flag Functions
// ===================
-void ctf_CheckFlagReturn(entity flag, float returntype)
+void ctf_CheckFlagReturn(entity flag, int returntype)
{
if((flag.ctf_status == FLAG_DROPPED) || (flag.ctf_status == FLAG_PASSING))
{
}
}
-float ctf_Stalemate_Customize()
+bool ctf_Stalemate_Customize()
{
// make spectators see what the player would see
entity e, wp_owner;
void ctf_CheckStalemate(void)
{
// declarations
- float stale_flags = 0, stale_red_flags = 0, stale_blue_flags = 0, stale_yellow_flags = 0, stale_pink_flags = 0, stale_neutral_flags = 0;
+ int stale_flags = 0, stale_red_flags = 0, stale_blue_flags = 0, stale_yellow_flags = 0, stale_pink_flags = 0, stale_neutral_flags = 0;
entity tmp_entity;
entity ctf_staleflaglist = world; // reset the list, we need to build the list each time this function runs
if(ctf_oneflag && stale_flags == 1)
ctf_stalemate = true;
- else if(stale_flags == ctf_teams)
+ else if(stale_flags >= 2)
ctf_stalemate = true;
else if(stale_flags == 0 && autocvar_g_ctf_stalemate_endcondition == 2)
{ ctf_stalemate = false; wpforenemy_announced = false; }
- else if(stale_flags < ctf_teams && autocvar_g_ctf_stalemate_endcondition == 1)
+ else if(stale_flags < 2 && autocvar_g_ctf_stalemate_endcondition == 1)
{ ctf_stalemate = false; wpforenemy_announced = false; }
// if sufficient stalemate, then set up the waypointsprite and announce the stalemate if necessary
}
}
-void ctf_FlagDamage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+void ctf_FlagDamage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
{
- self.velocity = self.velocity;
if(ITEM_DAMAGE_NEEDKILL(deathtype))
{
if(autocvar_g_ctf_flag_return_damage_delay)
}
}
-void ctf_FlagUpdate()
+void ctf_FlagThink()
{
// declarations
entity tmp_entity;
+ self.nextthink = time + FLAG_THINKRATE; // only 5 fps, more is unnecessary.
+
// captureshield
if(self == ctf_worldflaglist) // only for the first flag
FOR_EACH_CLIENT(tmp_entity)
}
}
-void ctf_FlagThink()
-{
- self.nextthink = time + FLAG_THINKRATE;
-
- ctf_FlagUpdate();
-
- /*if(time >= self.ctf_thinkrate)
- {
- self.ctf_thinkrate = time + FLAG_THINKRATE;
- ctf_FlagUpdate();
- }*/
-
- //Movetype_Physics_NoMatchServer();
- //Movetype_Physics_MatchTicrate(sys_frametime, 0);
-}
-
void ctf_FlagTouch()
{
if(gameover) { return; }
- if(self.active != ACTIVE_ACTIVE) { return; }
if(trace_dphitcontents & (DPCONTENTS_PLAYERCLIP | DPCONTENTS_MONSTERCLIP)) { return; }
entity toucher = other, tmp_entity;
- float is_not_monster = (!IS_MONSTER(toucher)), num_perteam = 0;
+ bool is_not_monster = (!IS_MONSTER(toucher)), num_perteam = 0;
// automatically kill the flag and return it if it touched lava/slime/nodrop surfaces
if(ITEM_TOUCH_NEEDKILL())
ctf_RespawnFlag(self);
}
-void ctf_Use()
-{
- if(self.ctf_status != FLAG_BASE) { return; }
-
- self.active = ((self.active) ? ACTIVE_NOT : ACTIVE_ACTIVE);
-
- if(self.active == ACTIVE_ACTIVE)
- WaypointSprite_Ping(self.wps_flagbase);
-}
-
-float ctf_FlagWaypoint_Customize()
-{
- if(self.owner.active != ACTIVE_ACTIVE) { return false; }
- return true;
-}
-
void ctf_DelayedFlagSetup(void) // called after a flag is placed on a map by ctf_FlagSetup()
{
// bot waypoints
WaypointSprite_SpawnFixed(basename, self.origin + FLAG_WAYPOINT_OFFSET, self, wps_flagbase, RADARICON_FLAG, ((self.team) ? Team_ColorRGB(self.team) : '1 1 1'));
WaypointSprite_UpdateTeamRadar(self.wps_flagbase, RADARICON_FLAG, ((self.team) ? colormapPaletteColor(self.team - 1, false) : '1 1 1'));
- self.wps_flagbase.customizeentityforclient = ctf_FlagWaypoint_Customize;
// captureshield setup
ctf_CaptureShield_Spawn(self);
-
- //self.move_origin = self.origin;
- //self.angles = self.angles;
- //self.velocity = self.velocity;
}
-void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
+void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
{
// declarations
self = flag; // for later usage with droptofloor()
flag.velocity = '0 0 0';
flag.mangle = flag.angles;
flag.reset = ctf_Reset;
- flag.use = ctf_Use;
flag.touch = ctf_FlagTouch;
flag.think = ctf_FlagThink;
flag.nextthink = time + FLAG_THINKRATE;
if(autocvar_g_ctf_flag_glowtrails)
{
- flag.glow_color = ((teamnumber == NUM_TEAM_1) ? 251 : ((teamnumber == NUM_TEAM_2) ? 210 : ((teamnumber == NUM_TEAM_3) ? 110 : ((teamnumber == NUM_TEAM_4) ? 145 : 254))));
+ switch(teamnumber)
+ {
+ case NUM_TEAM_1: flag.glow_color = 251; break;
+ case NUM_TEAM_2: flag.glow_color = 210; break;
+ case NUM_TEAM_3: flag.glow_color = 110; break;
+ case NUM_TEAM_4: flag.glow_color = 145; break;
+ default: flag.glow_color = 254; break;
+ }
flag.glow_size = 25;
flag.glow_trail = 1;
}
case NUM_TEAM_2: flag.effects |= EF_BLUE; break;
case NUM_TEAM_3: flag.effects |= EF_DIMLIGHT; break;
case NUM_TEAM_4: flag.effects |= EF_RED; break;
- default: flag.effects |= EF_DIMLIGHT; break;
+ default: flag.effects |= EF_DIMLIGHT; break;
}
}
return world;
}
-float havocbot_ctf_teamcount(entity bot, vector org, float tc_radius)
+int havocbot_ctf_teamcount(entity bot, vector org, float tc_radius)
{
if (!teamplay)
return 0;
- float c = 0;
+ int c = 0;
entity head;
FOR_EACH_PLAYER(head)
}
}
-void havocbot_role_ctf_setrole(entity bot, float role)
+void havocbot_role_ctf_setrole(entity bot, int role)
{
dprint(strcat(bot.netname," switched to "));
switch(role)
MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink)
{
entity flag;
-
- float t = 0, t2 = 0, t3 = 0;
+ int t = 0, t2 = 0, t3 = 0;
// initially clear items so they can be set as necessary later.
self.ctf_flagstatus &= ~(CTF_RED_FLAG_CARRYING | CTF_RED_FLAG_TAKEN | CTF_RED_FLAG_LOST
if(vh_player.flagcarried)
{
setattachment(vh_player.flagcarried, vh_player, "");
- setorigin(vh_player.flagcarried, VEHICLE_FLAG_OFFSET);
+ setorigin(vh_player.flagcarried, FLAG_CARRY_OFFSET);
vh_player.flagcarried.scale = FLAG_SCALE;
vh_player.flagcarried.angles = '0 0 0';
vh_player.flagcarried.nodrawtoclient = world;
// ==============
// scoreboard setup
-void ctf_ScoreRules(float teams)
+void ctf_ScoreRules(int teams)
{
CheckAllowedTeams(world);
ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true);
}
// code from here on is just to support maps that don't have flag and team entities
-void ctf_SpawnTeam (string teamname, float teamcolor)
+void ctf_SpawnTeam (string teamname, int teamcolor)
{
entity oldself;
oldself = self;
if(find(world, classname, "ctf_team") == world)
{
print("No ""ctf_team"" entities found on this map, creating them anyway.\n");
- float i;
- for(i = 1; i <= ctf_teams; ++i)
- ctf_SpawnTeam(Team_ColorName(Team_NumberToTeam(i)), Team_NumberToTeam(i) - 1);
+ ctf_SpawnTeam("Red", NUM_TEAM_1 - 1);
+ ctf_SpawnTeam("Blue", NUM_TEAM_2 - 1);
+ if(ctf_teams >= 3)
+ ctf_SpawnTeam("Yellow", NUM_TEAM_3 - 1);
+ if(ctf_teams >= 4)
+ ctf_SpawnTeam("Pink", NUM_TEAM_4 - 1);
}
ctf_ScoreRules(ctf_teams);
void ctf_RespawnFlag(entity flag);
// score rule declarations
-const float ST_CTF_CAPS = 1;
-const float SP_CTF_CAPS = 4;
-const float SP_CTF_CAPTIME = 5;
-const float SP_CTF_PICKUPS = 6;
-const float SP_CTF_DROPS = 7;
-const float SP_CTF_FCKILLS = 8;
-const float SP_CTF_RETURNS = 9;
+const int ST_CTF_CAPS = 1;
+const int SP_CTF_CAPS = 4;
+const int SP_CTF_CAPTIME = 5;
+const int SP_CTF_PICKUPS = 6;
+const int SP_CTF_DROPS = 7;
+const int SP_CTF_FCKILLS = 8;
+const int SP_CTF_RETURNS = 9;
// flag constants // for most of these, there is just one question to be asked: WHYYYYY?
#define FLAG_MIN (PL_MIN + '0 0 -13')
const float FLAG_TOUCHRATE = 0.5;
const float WPFE_THINKRATE = 0.5;
-#define FLAG_DROP_OFFSET ('0 0 32')
-#define FLAG_CARRY_OFFSET ('-16 0 8')
+const vector FLAG_DROP_OFFSET = ('0 0 32');
+const vector FLAG_CARRY_OFFSET = ('-16 0 8');
#define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_z - 13))
-#define FLAG_WAYPOINT_OFFSET ('0 0 64')
-#define FLAG_FLOAT_OFFSET ('0 0 32')
-#define FLAG_PASS_ARC_OFFSET ('0 0 -10')
+const vector FLAG_WAYPOINT_OFFSET = ('0 0 64');
+const vector FLAG_FLOAT_OFFSET = ('0 0 32');
+const vector FLAG_PASS_ARC_OFFSET = ('0 0 -10');
-#define VEHICLE_FLAG_OFFSET ('0 0 96')
+const vector VEHICLE_FLAG_OFFSET = ('0 0 96');
const float VEHICLE_FLAG_SCALE = 1.0;
// waypoint colors
.entity wps_flagdropped;
.entity wps_enemyflagcarrier;
.float wps_helpme_time;
-float wpforenemy_announced;
+bool wpforenemy_announced;
float wpforenemy_nextthink;
// statuses
-const float FLAG_BASE = 1;
-const float FLAG_DROPPED = 2;
-const float FLAG_CARRY = 3;
-const float FLAG_PASSING = 4;
+const int FLAG_BASE = 1;
+const int FLAG_DROPPED = 2;
+const int FLAG_CARRY = 3;
+const int FLAG_PASSING = 4;
-const float DROP_NORMAL = 1;
-const float DROP_THROW = 2;
-const float DROP_PASS = 3;
-const float DROP_RESET = 4;
+const int DROP_NORMAL = 1;
+const int DROP_THROW = 2;
+const int DROP_PASS = 3;
+const int DROP_RESET = 4;
-const float PICKUP_BASE = 1;
-const float PICKUP_DROPPED = 2;
+const int PICKUP_BASE = 1;
+const int PICKUP_DROPPED = 2;
-const float CAPTURE_NORMAL = 1;
-const float CAPTURE_DROPPED = 2;
+const int CAPTURE_NORMAL = 1;
+const int CAPTURE_DROPPED = 2;
-const float RETURN_TIMEOUT = 1;
-const float RETURN_DROPPED = 2;
-const float RETURN_DAMAGE = 3;
-const float RETURN_SPEEDRUN = 4;
-const float RETURN_NEEDKILL = 5;
+const int RETURN_TIMEOUT = 1;
+const int RETURN_DROPPED = 2;
+const int RETURN_DAMAGE = 3;
+const int RETURN_SPEEDRUN = 4;
+const int RETURN_NEEDKILL = 5;
// flag properties
#define ctf_spawnorigin dropped_origin
-float ctf_stalemate; // indicates that a stalemate is active
+bool ctf_stalemate; // indicates that a stalemate is active
float ctf_captimerecord; // record time for capturing the flag
.float ctf_pickuptime;
.float ctf_droptime;
-.float ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
+.int ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
.entity ctf_dropper; // don't allow spam of dropping the flag
-.float max_flag_health;
+.int max_flag_health;
.float next_take_time;
-.float ctf_flagdamaged;
-float ctf_teams;
-//.float ctf_thinkrate;
+.bool ctf_flagdamaged;
+int ctf_teams;
// passing/throwing properties
.float pass_distance;
.entity pass_target;
.float throw_antispam;
.float throw_prevtime;
-.float throw_count;
+.int throw_count;
// CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
-.float ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
+.bool ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
float ctf_captureshield_min_negscore; // punish at -20 points
float ctf_captureshield_max_ratio; // punish at most 30% of each team
float ctf_captureshield_force; // push force of the shield
// 1 flag ctf
-float ctf_oneflag; // indicates whether or not a neutral flag has been found
+bool ctf_oneflag; // indicates whether or not a neutral flag has been found
// bot player logic
-const float HAVOCBOT_CTF_ROLE_NONE = 0;
-const float HAVOCBOT_CTF_ROLE_DEFENSE = 2;
-const float HAVOCBOT_CTF_ROLE_MIDDLE = 4;
-const float HAVOCBOT_CTF_ROLE_OFFENSE = 8;
-const float HAVOCBOT_CTF_ROLE_CARRIER = 16;
-const float HAVOCBOT_CTF_ROLE_RETRIEVER = 32;
-const float HAVOCBOT_CTF_ROLE_ESCORT = 64;
+const int HAVOCBOT_CTF_ROLE_NONE = 0;
+const int HAVOCBOT_CTF_ROLE_DEFENSE = 2;
+const int HAVOCBOT_CTF_ROLE_MIDDLE = 4;
+const int HAVOCBOT_CTF_ROLE_OFFENSE = 8;
+const int HAVOCBOT_CTF_ROLE_CARRIER = 16;
+const int HAVOCBOT_CTF_ROLE_RETRIEVER = 32;
+const int HAVOCBOT_CTF_ROLE_ESCORT = 64;
-.float havocbot_cantfindflag;
+.bool havocbot_cantfindflag;
vector havocbot_ctf_middlepoint;
float havocbot_ctf_middlepoint_radius;
-void havocbot_role_ctf_setrole(entity bot, float role);
+void havocbot_role_ctf_setrole(entity bot, int role);
// team checking
#define CTF_SAMETEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? DIFF_TEAM(a,b) : SAME_TEAM(a,b))
#define CTF_DIFFTEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a,b) : DIFF_TEAM(a,b))
-#endif
-
// networked flag statuses
.int ctf_flagstatus;
+#endif
-const int CTF_RED_FLAG_TAKEN = 1;
-const int CTF_RED_FLAG_LOST = 2;
-const int CTF_RED_FLAG_CARRYING = 3;
-const int CTF_BLUE_FLAG_TAKEN = 4;
-const int CTF_BLUE_FLAG_LOST = 8;
-const int CTF_BLUE_FLAG_CARRYING = 12;
-const int CTF_YELLOW_FLAG_TAKEN = 16;
-const int CTF_YELLOW_FLAG_LOST = 32;
-const int CTF_YELLOW_FLAG_CARRYING = 48;
-const int CTF_PINK_FLAG_TAKEN = 64;
-const int CTF_PINK_FLAG_LOST = 128;
-const int CTF_PINK_FLAG_CARRYING = 192;
-const int CTF_NEUTRAL_FLAG_TAKEN = 256;
-const int CTF_NEUTRAL_FLAG_LOST = 512;
-const int CTF_NEUTRAL_FLAG_CARRYING = 768;
-const int CTF_FLAG_NEUTRAL = 2048;
-const int CTF_SHIELDED = 4096;
+const int CTF_RED_FLAG_TAKEN = 1;
+const int CTF_RED_FLAG_LOST = 2;
+const int CTF_RED_FLAG_CARRYING = 3;
+const int CTF_BLUE_FLAG_TAKEN = 4;
+const int CTF_BLUE_FLAG_LOST = 8;
+const int CTF_BLUE_FLAG_CARRYING = 12;
+const int CTF_YELLOW_FLAG_TAKEN = 16;
+const int CTF_YELLOW_FLAG_LOST = 32;
+const int CTF_YELLOW_FLAG_CARRYING = 48;
+const int CTF_PINK_FLAG_TAKEN = 64;
+const int CTF_PINK_FLAG_LOST = 128;
+const int CTF_PINK_FLAG_CARRYING = 192;
+const int CTF_NEUTRAL_FLAG_TAKEN = 256;
+const int CTF_NEUTRAL_FLAG_LOST = 512;
+const int CTF_NEUTRAL_FLAG_CARRYING = 768;
+const int CTF_FLAG_NEUTRAL = 2048;
+const int CTF_SHIELDED = 4096;
#endif