X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fgamemode_ctf.qc;h=d40263fb72f41bd7b754d42a849aa288dc55f2ca;hb=6f37a8f8076a572097afb13de2c367a72717c927;hp=42e7b6294f0792de6b45a1eae4aeb7dd9191a539;hpb=57f409333cc09406298b66421d5e99357a7f586d;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index 42e7b6294..d40263fb7 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -1,3 +1,13 @@ +#include "gamemode_ctf.qh" +#include "../_.qh" + +#include "gamemode.qh" + +#include "../vehicles/vehicles_def.qh" + +#include "../../warpzonelib/common.qh" +#include "../../warpzonelib/mathlib.qh" + // ================================================================ // Official capture the flag game mode coding, reworked by Samual // Last updated: September, 2012 @@ -25,25 +35,25 @@ void ctf_CaptureRecord(entity flag, entity player) float cap_record = ctf_captimerecord; float cap_time = (time - flag.ctf_pickuptime); string refername = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname")); - + // notify about shit if(!ctf_captimerecord) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_2(flag, CHOICE_CTF_CAPTURE_TIME_), player.netname, (cap_time * 100)); } else if(cap_time < cap_record) { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_2(flag, CHOICE_CTF_CAPTURE_BROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); } else { Send_Notification(NOTIF_ALL, world, MSG_CHOICE, APP_TEAM_ENT_2(flag, CHOICE_CTF_CAPTURE_UNBROKEN_), player.netname, refername, (cap_time * 100), (cap_record * 100)); } - + // write that shit in the database if((!ctf_captimerecord) || (cap_time < cap_record)) { ctf_captimerecord = cap_time; db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(cap_time)); db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), player.netname); - write_recordmarker(player, (time - cap_time), cap_time); - } + write_recordmarker(player, (time - cap_time), cap_time); + } } void ctf_FlagcarrierWaypoints(entity player) { - WaypointSprite_Spawn("flagcarrier", 0, 0, player, FLAG_WAYPOINT_OFFSET, world, player.team, player, wps_flagcarrier, TRUE, RADARICON_FLAG, WPCOLOR_FLAGCARRIER(player.team)); + WaypointSprite_Spawn("flagcarrier", 0, 0, player, FLAG_WAYPOINT_OFFSET, world, player.team, player, wps_flagcarrier, true, RADARICON_FLAG, WPCOLOR_FLAGCARRIER(player.team)); WaypointSprite_UpdateMaxHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON) * 2); WaypointSprite_UpdateHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(player.health, player.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON)); WaypointSprite_UpdateTeamRadar(player.wps_flagcarrier, RADARICON_FLAGCARRIER, WPCOLOR_FLAGCARRIER(player.team)); @@ -51,7 +61,7 @@ void ctf_FlagcarrierWaypoints(entity player) void ctf_CalculatePassVelocity(entity flag, vector to, vector from, float turnrate) { - float current_distance = vlen((('1 0 0' * to_x) + ('0 1 0' * to_y)) - (('1 0 0' * from_x) + ('0 1 0' * from_y))); // for the sake of this check, exclude Z axis + float current_distance = vlen((('1 0 0' * to.x) + ('0 1 0' * to.y)) - (('1 0 0' * from.x) + ('0 1 0' * from.y))); // for the sake of this check, exclude Z axis float initial_height = min(autocvar_g_ctf_pass_arc_max, (flag.pass_distance * tanh(autocvar_g_ctf_pass_arc))); float current_height = (initial_height * min(1, (current_distance / flag.pass_distance))); //print("current_height = ", ftos(current_height), ", initial_height = ", ftos(initial_height), ".\n"); @@ -89,13 +99,11 @@ float ctf_CheckPassDirection(vector head_center, vector passer_center, vector pa makevectors(passer_angle); // find the closest point on the enemy to the center of the attack - float ang; // angle between shotdir and h float h; // hypotenuse, which is the distance between attacker to head float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin - + h = vlen(head_center - passer_center); - ang = acos(dotproduct(normalize(head_center - passer_center), v_forward)); - a = h * cos(ang); + a = h * (normalize(head_center - passer_center) * v_forward); vector nearest_on_line = (passer_center + a * v_forward); float distance_from_line = vlen(nearest_to_passer - nearest_on_line); @@ -104,30 +112,30 @@ float ctf_CheckPassDirection(vector head_center, vector passer_center, vector pa spreadlimit = (autocvar_g_ctf_pass_directional_min * (1 - spreadlimit) + autocvar_g_ctf_pass_directional_max * spreadlimit); if(spreadlimit && (distance_from_line <= spreadlimit) && ((vlen(normalize(head_center - passer_center) - v_forward) * RAD2DEG) <= 90)) - { return TRUE; } + { return true; } else - { return FALSE; } + { return false; } } - else { return TRUE; } + else { return true; } } // ======================= -// CaptureShield Functions +// CaptureShield Functions // ======================= -float ctf_CaptureShield_CheckStatus(entity p) +float ctf_CaptureShield_CheckStatus(entity p) { float s, se; entity e; float players_worseeq, players_total; if(ctf_captureshield_max_ratio <= 0) - return FALSE; + return false; s = PlayerScore_Add(p, SP_SCORE, 0); if(s >= -ctf_captureshield_min_negscore) - return FALSE; + return false; players_total = players_worseeq = 0; FOR_EACH_PLAYER(e) @@ -142,11 +150,11 @@ float ctf_CaptureShield_CheckStatus(entity p) // player is in the worse half, if >= half the players are better than him, or consequently, if < half of the players are worse // use this rule here - + if(players_worseeq >= players_total * ctf_captureshield_max_ratio) - return FALSE; + return false; - return TRUE; + return true; } void ctf_CaptureShield_Update(entity player, float wanted_status) @@ -161,28 +169,28 @@ void ctf_CaptureShield_Update(entity player, float wanted_status) float ctf_CaptureShield_Customize() { - if(!other.ctf_captureshielded) { return FALSE; } - if(SAME_TEAM(self, other)) { return FALSE; } - - return TRUE; + if(!other.ctf_captureshielded) { return false; } + if(SAME_TEAM(self, other)) { return false; } + + return true; } void ctf_CaptureShield_Touch() { if(!other.ctf_captureshielded) { return; } if(SAME_TEAM(self, other)) { return; } - + 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); - Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_CTF_CAPTURESHIELD_SHIELDED); + if(IS_REAL_CLIENT(other)) { Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_CTF_CAPTURESHIELD_SHIELDED); } } void ctf_CaptureShield_Spawn(entity flag) { entity shield = spawn(); - + shield.enemy = self; shield.team = self.team; shield.touch = ctf_CaptureShield_Touch; @@ -193,7 +201,7 @@ void ctf_CaptureShield_Spawn(entity flag) shield.solid = SOLID_TRIGGER; shield.avelocity = '7 0 11'; shield.scale = 0.5; - + setorigin(shield, self.origin); setmodel(shield, "models/ctf/shield.md3"); setsize(shield, shield.scale * shield.mins, shield.scale * shield.maxs); @@ -217,28 +225,28 @@ void ctf_Handle_Drop(entity flag, entity player, float droptype) flag.ctf_droptime = time; flag.ctf_dropper = player; flag.ctf_status = FLAG_DROPPED; - + // messages and sounds Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_LOST_), player.netname); sound(flag, CH_TRIGGER, flag.snd_flag_dropped, VOL_BASE, ATTEN_NONE); ctf_EventLog("dropped", player.team, player); // scoring - PlayerTeamScore_AddScore(player, -autocvar_g_ctf_score_penalty_drop); + PlayerTeamScore_AddScore(player, -autocvar_g_ctf_score_penalty_drop); PlayerScore_Add(player, SP_CTF_DROPS, 1); - + // waypoints if(autocvar_g_ctf_flag_dropped_waypoint) - WaypointSprite_Spawn("flagdropped", 0, 0, flag, FLAG_WAYPOINT_OFFSET, world, ((autocvar_g_ctf_flag_dropped_waypoint == 2) ? 0 : player.team), flag, wps_flagdropped, TRUE, RADARICON_FLAG, WPCOLOR_DROPPEDFLAG(flag.team)); + WaypointSprite_Spawn("flagdropped", 0, 0, flag, FLAG_WAYPOINT_OFFSET, world, ((autocvar_g_ctf_flag_dropped_waypoint == 2) ? 0 : player.team), flag, wps_flagdropped, true, RADARICON_FLAG, WPCOLOR_DROPPEDFLAG(flag.team)); if(autocvar_g_ctf_flag_return_time || (autocvar_g_ctf_flag_return_damage && autocvar_g_ctf_flag_health)) { WaypointSprite_UpdateMaxHealth(flag.wps_flagdropped, flag.max_flag_health); WaypointSprite_UpdateHealth(flag.wps_flagdropped, flag.health); } - + player.throw_antispam = time + autocvar_g_ctf_pass_wait; - + if(droptype == DROP_PASS) { flag.pass_distance = 0; @@ -251,14 +259,23 @@ void ctf_Handle_Retrieve(entity flag, entity player) { entity tmp_player; // temporary entity which the FOR_EACH_PLAYER loop uses to scan players entity sender = flag.pass_sender; - + // transfer flag to player flag.owner = player; flag.owner.flagcarried = flag; - + // reset flag - setattachment(flag, player, ""); - setorigin(flag, FLAG_CARRY_OFFSET); + if(player.vehicle) + { + setattachment(flag, player.vehicle, ""); + setorigin(flag, VEHICLE_FLAG_OFFSET); + flag.scale = VEHICLE_FLAG_SCALE; + } + else + { + setattachment(flag, player, ""); + setorigin(flag, FLAG_CARRY_OFFSET); + } flag.movetype = MOVETYPE_NONE; flag.takedamage = DAMAGE_NO; flag.solid = SOLID_NOT; @@ -268,7 +285,7 @@ void ctf_Handle_Retrieve(entity flag, entity player) // messages and sounds sound(player, CH_TRIGGER, flag.snd_flag_pass, VOL_BASE, ATTEN_NORM); ctf_EventLog("receive", flag.team, player); - + FOR_EACH_REALPLAYER(tmp_player) { if(tmp_player == sender) @@ -278,10 +295,10 @@ void ctf_Handle_Retrieve(entity flag, entity player) else if(SAME_TEAM(tmp_player, sender)) Send_Notification(NOTIF_ONE, tmp_player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_PASS_OTHER_), sender.netname, player.netname); } - + // create new waypoint ctf_FlagcarrierWaypoints(player); - + sender.throw_antispam = time + autocvar_g_ctf_pass_wait; player.throw_antispam = sender.throw_antispam; @@ -294,12 +311,12 @@ void ctf_Handle_Throw(entity player, entity receiver, float droptype) { entity flag = player.flagcarried; vector targ_origin, flag_velocity; - + if(!flag) { return; } if((droptype == DROP_PASS) && !receiver) { return; } - + if(flag.speedrunning) { ctf_RespawnFlag(flag); return; } - + // reset the flag setattachment(flag, world, ""); setorigin(flag, player.origin + FLAG_DROP_OFFSET); @@ -308,9 +325,9 @@ void ctf_Handle_Throw(entity player, entity receiver, float droptype) flag.solid = SOLID_TRIGGER; flag.ctf_dropper = player; flag.ctf_droptime = time; - + flag.flags = FL_ITEM | FL_NOTARGET; // clear FL_ONGROUND for MOVETYPE_TOSS - + switch(droptype) { case DROP_PASS: @@ -322,8 +339,8 @@ void ctf_Handle_Throw(entity player, entity receiver, float droptype) WarpZone_RefSys_AddInverse(flag, receiver); // wz1^-1 ... wzn^-1 receiver targ_origin = WarpZone_RefSys_TransformOrigin(receiver, flag, (0.5 * (receiver.absmin + receiver.absmax))); // this is target origin as seen by the flag - flag.pass_distance = vlen((('1 0 0' * targ_origin_x) + ('0 1 0' * targ_origin_y)) - (('1 0 0' * player.origin_x) + ('0 1 0' * player.origin_y))); // for the sake of this check, exclude Z axis - ctf_CalculatePassVelocity(flag, targ_origin, player.origin, FALSE); + flag.pass_distance = vlen((('1 0 0' * targ_origin.x) + ('0 1 0' * targ_origin.y)) - (('1 0 0' * player.origin.x) + ('0 1 0' * player.origin.y))); // for the sake of this check, exclude Z axis + ctf_CalculatePassVelocity(flag, targ_origin, player.origin, false); // main flag.movetype = MOVETYPE_FLY; @@ -331,34 +348,34 @@ void ctf_Handle_Throw(entity player, entity receiver, float droptype) flag.pass_sender = player; flag.pass_target = receiver; flag.ctf_status = FLAG_PASSING; - + // other sound(player, CH_TRIGGER, flag.snd_flag_touch, VOL_BASE, ATTEN_NORM); WarpZone_TrailParticles(world, particleeffectnum(flag.passeffect), player.origin, targ_origin); ctf_EventLog("pass", flag.team, player); break; } - + case DROP_THROW: { - makevectors((player.v_angle_y * '0 1 0') + (bound(autocvar_g_ctf_throw_angle_min, player.v_angle_x, autocvar_g_ctf_throw_angle_max) * '1 0 0')); - + makevectors((player.v_angle.y * '0 1 0') + (bound(autocvar_g_ctf_throw_angle_min, player.v_angle.x, autocvar_g_ctf_throw_angle_max) * '1 0 0')); + flag_velocity = (('0 0 1' * autocvar_g_ctf_throw_velocity_up) + ((v_forward * autocvar_g_ctf_throw_velocity_forward) * ((player.items & IT_STRENGTH) ? autocvar_g_ctf_throw_strengthmultiplier : 1))); - flag.velocity = W_CalculateProjectileVelocity(player.velocity, flag_velocity, FALSE); + flag.velocity = W_CalculateProjectileVelocity(player.velocity, flag_velocity, false); ctf_Handle_Drop(flag, player, droptype); break; } - + case DROP_RESET: { flag.velocity = '0 0 0'; // do nothing break; } - + default: case DROP_NORMAL: { - flag.velocity = W_CalculateProjectileVelocity(player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), FALSE); + flag.velocity = W_CalculateProjectileVelocity(player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), false); ctf_Handle_Drop(flag, player, droptype); break; } @@ -367,10 +384,10 @@ void ctf_Handle_Throw(entity player, entity receiver, float droptype) // kill old waypointsprite WaypointSprite_Ping(player.wps_flagcarrier); WaypointSprite_Kill(player.wps_flagcarrier); - + if(player.wps_enemyflagcarrier) WaypointSprite_Kill(player.wps_enemyflagcarrier); - + // captureshield ctf_CaptureShield_Update(player, 0); // shield player from picking up flag } @@ -384,22 +401,24 @@ void ctf_Handle_Capture(entity flag, entity toucher, float capturetype) { entity enemy_flag = ((capturetype == CAPTURE_NORMAL) ? toucher.flagcarried : toucher); entity player = ((capturetype == CAPTURE_NORMAL) ? toucher : enemy_flag.ctf_dropper); - float old_time, new_time; - + float old_time, new_time; + if (!player) { return; } // without someone to give the reward to, we can't possibly cap - + + nades_GiveBonus(player, autocvar_g_nades_bonus_score_high ); + // messages and sounds Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_2(enemy_flag, CENTER_CTF_CAPTURE_)); ctf_CaptureRecord(enemy_flag, player); sound(player, CH_TRIGGER, flag.snd_flag_capture, VOL_BASE, ATTEN_NONE); - + switch(capturetype) { case CAPTURE_NORMAL: ctf_EventLog("capture", enemy_flag.team, player); break; case CAPTURE_DROPPED: ctf_EventLog("droppedcapture", enemy_flag.team, player); break; default: break; } - + // scoring PlayerTeamScore_AddScore(player, autocvar_g_ctf_score_capture); PlayerTeamScore_Add(player, SP_CTF_CAPS, ST_CTF_CAPS, 1); @@ -418,11 +437,11 @@ void ctf_Handle_Capture(entity flag, entity toucher, float capturetype) { WaypointSprite_Kill(player.wps_flagcarrier); if(flag.speedrunning) { ctf_FakeTimeLimit(player, -1); } - + if((enemy_flag.ctf_dropper) && (player != enemy_flag.ctf_dropper)) { PlayerTeamScore_AddScore(enemy_flag.ctf_dropper, autocvar_g_ctf_score_capture_assist); } } - + // reset the flag player.next_take_time = time + autocvar_g_ctf_flag_collect_delay; ctf_RespawnFlag(enemy_flag); @@ -431,24 +450,36 @@ void ctf_Handle_Capture(entity flag, entity toucher, float capturetype) void ctf_Handle_Return(entity flag, entity player) { // messages and sounds - Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_RETURN_)); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_RETURN_), player.netname); + if(player.flags & FL_MONSTER) + { + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_RETURN_MONSTER_), player.monster_name); + } + else + { + Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_RETURN_)); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_RETURN_), player.netname); + } sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTEN_NONE); ctf_EventLog("return", flag.team, player); // scoring - PlayerTeamScore_AddScore(player, autocvar_g_ctf_score_return); // reward for return - PlayerScore_Add(player, SP_CTF_RETURNS, 1); // add to count of returns + if(IS_PLAYER(player)) + { + PlayerTeamScore_AddScore(player, autocvar_g_ctf_score_return); // reward for return + PlayerScore_Add(player, SP_CTF_RETURNS, 1); // add to count of returns + + nades_GiveBonus(player,autocvar_g_nades_bonus_score_medium); + } TeamScore_AddToTeam(flag.team, ST_SCORE, -autocvar_g_ctf_score_penalty_returned); // punish the team who was last carrying it - - if(flag.ctf_dropper) + + if(flag.ctf_dropper) { PlayerScore_Add(flag.ctf_dropper, SP_SCORE, -autocvar_g_ctf_score_penalty_returned); // punish the player who dropped the flag - ctf_CaptureShield_Update(flag.ctf_dropper, 0); // shield player from picking up flag + ctf_CaptureShield_Update(flag.ctf_dropper, 0); // shield player from picking up flag flag.ctf_dropper.next_take_time = time + autocvar_g_ctf_flag_collect_delay; // set next take time } - + // reset the flag ctf_RespawnFlag(flag); } @@ -457,20 +488,29 @@ void ctf_Handle_Pickup(entity flag, entity player, float pickuptype) { // declarations float pickup_dropped_score; // used to calculate dropped pickup score - + // attach the flag to the player flag.owner = player; player.flagcarried = flag; - setattachment(flag, player, ""); - setorigin(flag, FLAG_CARRY_OFFSET); - + if(player.vehicle) + { + setattachment(flag, player.vehicle, ""); + setorigin(flag, VEHICLE_FLAG_OFFSET); + flag.scale = VEHICLE_FLAG_SCALE; + } + else + { + setattachment(flag, player, ""); + setorigin(flag, FLAG_CARRY_OFFSET); + } + // flag setup flag.movetype = MOVETYPE_NONE; flag.takedamage = DAMAGE_NO; flag.solid = SOLID_NOT; flag.angles = '0 0 0'; flag.ctf_status = FLAG_CARRY; - + switch(pickuptype) { case PICKUP_BASE: flag.ctf_pickuptime = time; break; // used for timing runs @@ -479,26 +519,27 @@ void ctf_Handle_Pickup(entity flag, entity player, float pickuptype) } // messages and sounds - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_PICKUP_), player.netname); + Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_PICKUP_), player.netname); Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_2(flag, CENTER_CTF_PICKUP_)); if(ctf_stalemate) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_STALEMATE_CARRIER); } - + Send_Notification(NOTIF_TEAM_EXCEPT, player, MSG_CHOICE, CHOICE_CTF_PICKUP_TEAM, Team_ColorCode(player.team), player.netname); Send_Notification(NOTIF_TEAM, flag, MSG_CHOICE, CHOICE_CTF_PICKUP_ENEMY, Team_ColorCode(player.team), player.netname); - + sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTEN_NONE); - + // scoring PlayerScore_Add(player, SP_CTF_PICKUPS, 1); + nades_GiveBonus(player, autocvar_g_nades_bonus_score_minor); switch(pickuptype) - { + { case PICKUP_BASE: { PlayerTeamScore_AddScore(player, autocvar_g_ctf_score_pickup_base); ctf_EventLog("steal", flag.team, player); break; } - + case PICKUP_DROPPED: { pickup_dropped_score = (autocvar_g_ctf_flag_return_time ? bound(0, ((flag.ctf_droptime + autocvar_g_ctf_flag_return_time) - time) / autocvar_g_ctf_flag_return_time, 1) : 1); @@ -508,10 +549,10 @@ void ctf_Handle_Pickup(entity flag, entity player, float pickuptype) ctf_EventLog("pickup", flag.team, player); break; } - + default: break; } - + // speedrunning if(pickuptype == PICKUP_BASE) { @@ -519,11 +560,11 @@ void ctf_Handle_Pickup(entity flag, entity player, float pickuptype) if((player.speedrunning) && (ctf_captimerecord)) ctf_FakeTimeLimit(player, time + ctf_captimerecord); } - + // effects pointparticles(particleeffectnum(flag.toucheffect), player.origin, '0 0 0', 1); - - // waypoints + + // waypoints if(pickuptype == PICKUP_DROPPED) { WaypointSprite_Kill(flag.wps_flagdropped); } ctf_FlagcarrierWaypoints(player); WaypointSprite_Ping(player.wps_flagcarrier); @@ -539,7 +580,7 @@ void ctf_CheckFlagReturn(entity flag, float returntype) if((flag.ctf_status == FLAG_DROPPED) || (flag.ctf_status == FLAG_PASSING)) { if(flag.wps_flagdropped) { WaypointSprite_UpdateHealth(flag.wps_flagdropped, flag.health); } - + if((flag.health <= 0) || (time >= flag.ctf_droptime + autocvar_g_ctf_flag_return_time)) { switch(returntype) @@ -548,7 +589,7 @@ void ctf_CheckFlagReturn(entity flag, float returntype) case RETURN_DAMAGE: Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_FLAGRETURN_DAMAGED_)); break; case RETURN_SPEEDRUN: Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_FLAGRETURN_SPEEDRUN_), ctf_captimerecord); break; case RETURN_NEEDKILL: Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_FLAGRETURN_NEEDKILL_)); break; - + default: case RETURN_TIMEOUT: { Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(flag, INFO_CTF_FLAGRETURN_TIMEOUT_)); break; } @@ -577,7 +618,7 @@ void ctf_CheckStalemate(void) { tmp_entity.ctf_staleflagnext = ctf_staleflaglist; // link flag into staleflaglist ctf_staleflaglist = tmp_entity; - + switch(tmp_entity.team) { case NUM_TEAM_1: ++stale_red_flags; break; @@ -587,32 +628,32 @@ void ctf_CheckStalemate(void) } if(stale_red_flags && stale_blue_flags) - ctf_stalemate = TRUE; + ctf_stalemate = true; else if((!stale_red_flags && !stale_blue_flags) && autocvar_g_ctf_stalemate_endcondition == 2) - { ctf_stalemate = FALSE; wpforenemy_announced = FALSE; } + { ctf_stalemate = false; wpforenemy_announced = false; } else if((!stale_red_flags || !stale_blue_flags) && autocvar_g_ctf_stalemate_endcondition == 1) - { ctf_stalemate = FALSE; wpforenemy_announced = FALSE; } - + { ctf_stalemate = false; wpforenemy_announced = false; } + // if sufficient stalemate, then set up the waypointsprite and announce the stalemate if necessary if(ctf_stalemate) { for(tmp_entity = ctf_staleflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_staleflagnext) { if((tmp_entity.owner) && (!tmp_entity.owner.wps_enemyflagcarrier)) - WaypointSprite_Spawn("enemyflagcarrier", 0, 0, tmp_entity.owner, FLAG_WAYPOINT_OFFSET, world, tmp_entity.team, tmp_entity.owner, wps_enemyflagcarrier, TRUE, RADARICON_FLAG, WPCOLOR_ENEMYFC(tmp_entity.owner.team)); + WaypointSprite_Spawn("enemyflagcarrier", 0, 0, tmp_entity.owner, FLAG_WAYPOINT_OFFSET, world, tmp_entity.team, tmp_entity.owner, wps_enemyflagcarrier, true, RADARICON_FLAG, WPCOLOR_ENEMYFC(tmp_entity.owner.team)); } - + if (!wpforenemy_announced) { FOR_EACH_REALPLAYER(tmp_entity) Send_Notification(NOTIF_ONE, tmp_entity, MSG_CENTER, ((tmp_entity.flagcarried) ? CENTER_CTF_STALEMATE_CARRIER : CENTER_CTF_STALEMATE_OTHER)); - - wpforenemy_announced = TRUE; + + wpforenemy_announced = true; } } } -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) { if(ITEM_DAMAGE_NEEDKILL(deathtype)) { @@ -621,7 +662,7 @@ void ctf_FlagDamage(entity inflictor, entity attacker, float damage, float death ctf_CheckFlagReturn(self, RETURN_NEEDKILL); return; } - if(autocvar_g_ctf_flag_return_damage) + if(autocvar_g_ctf_flag_return_damage) { // reduce health and check if it should be returned self.health = self.health - damage; @@ -646,9 +687,9 @@ void ctf_FlagThink() if(self.mins != FLAG_MIN || self.maxs != FLAG_MAX) { // reset the flag boundaries in case it got squished dprint("wtf the flag got squashed?\n"); tracebox(self.origin, FLAG_MIN, FLAG_MAX, self.origin, MOVE_NOMONSTERS, self); - if(!trace_startsolid) // can we resize it without getting stuck? + if(!trace_startsolid || self.noalign) // can we resize it without getting stuck? setsize(self, FLAG_MIN, FLAG_MAX); } - + switch(self.ctf_status) // reset flag angles in case warpzones adjust it { case FLAG_DROPPED: @@ -656,13 +697,13 @@ void ctf_FlagThink() self.angles = '0 0 0'; break; } - + default: break; } // main think method switch(self.ctf_status) - { + { case FLAG_BASE: { if(autocvar_g_ctf_dropped_capture_radius) @@ -675,7 +716,7 @@ void ctf_FlagThink() } return; } - + case FLAG_DROPPED: { if(autocvar_g_ctf_flag_dropped_floatinwater) @@ -684,7 +725,7 @@ void ctf_FlagThink() if(pointcontents(midpoint) == CONTENT_WATER) { self.velocity = self.velocity * 0.5; - + if(pointcontents(midpoint + FLAG_FLOAT_OFFSET) == CONTENT_WATER) { self.velocity_z = autocvar_g_ctf_flag_dropped_floatinwater; } else @@ -706,13 +747,13 @@ void ctf_FlagThink() self.health -= ((self.max_flag_health / autocvar_g_ctf_flag_return_time) * FLAG_THINKRATE); ctf_CheckFlagReturn(self, RETURN_TIMEOUT); return; - } + } return; } - + case FLAG_CARRY: { - if(self.speedrunning && ctf_captimerecord && (time >= self.ctf_pickuptime + ctf_captimerecord)) + if(self.speedrunning && ctf_captimerecord && (time >= self.ctf_pickuptime + ctf_captimerecord)) { self.health = 0; ctf_CheckFlagReturn(self, RETURN_SPEEDRUN); @@ -733,15 +774,16 @@ void ctf_FlagThink() } return; } - + case FLAG_PASSING: { vector targ_origin = ((self.pass_target.absmin + self.pass_target.absmax) * 0.5); targ_origin = WarpZone_RefSys_TransformOrigin(self.pass_target, self, targ_origin); // origin of target as seen by the flag (us) WarpZone_TraceLine(self.origin, targ_origin, MOVE_NOMONSTERS, self); - + if((self.pass_target == world) || (self.pass_target.deadflag != DEAD_NO) + || (self.pass_target.flagcarried) || (vlen(self.origin - targ_origin) > autocvar_g_ctf_pass_radius) || ((trace_fraction < 1) && (trace_ent != self.pass_target)) || (time > self.ctf_droptime + autocvar_g_ctf_pass_timelimit)) @@ -752,7 +794,7 @@ void ctf_FlagThink() else { // still a viable target, go for it - ctf_CalculatePassVelocity(self, targ_origin, self.origin, TRUE); + ctf_CalculatePassVelocity(self, targ_origin, self.origin, true); } return; } @@ -768,9 +810,11 @@ void ctf_FlagThink() void ctf_FlagTouch() { if(gameover) { return; } - + if(trace_dphitcontents & (DPCONTENTS_PLAYERCLIP | DPCONTENTS_MONSTERCLIP)) { return; } + entity toucher = other; - + float is_not_monster = (!(toucher.flags & FL_MONSTER)); + // automatically kill the flag and return it if it touched lava/slime/nodrop surfaces if(ITEM_TOUCH_NEEDKILL()) { @@ -778,15 +822,21 @@ void ctf_FlagTouch() ctf_CheckFlagReturn(self, RETURN_NEEDKILL); return; } - + // special touch behaviors - if(toucher.vehicle_flags & VHF_ISVEHICLE) + if(toucher.frozen) { return; } + else if(toucher.vehicle_flags & VHF_ISVEHICLE) { - if(autocvar_g_ctf_allow_vehicle_touch) + if(autocvar_g_ctf_allow_vehicle_touch && toucher.owner) toucher = toucher.owner; // the player is actually the vehicle owner, not other else return; // do nothing } + else if(toucher.flags & FL_MONSTER) + { + if(!autocvar_g_ctf_allow_monster_touch) + return; // do nothing + } else if (!IS_PLAYER(toucher)) // The flag just touched an object, most likely the world { if(time > self.wait) // if we haven't in a while, play a sound/effect @@ -799,32 +849,32 @@ void ctf_FlagTouch() } else if(toucher.deadflag != DEAD_NO) { return; } - switch(self.ctf_status) - { + switch(self.ctf_status) + { case FLAG_BASE: { - if(SAME_TEAM(toucher, self) && (toucher.flagcarried) && DIFF_TEAM(toucher.flagcarried, self)) + if(SAME_TEAM(toucher, self) && (toucher.flagcarried) && DIFF_TEAM(toucher.flagcarried, self) && is_not_monster) ctf_Handle_Capture(self, toucher, CAPTURE_NORMAL); // toucher just captured the enemies flag to his base - else if(DIFF_TEAM(toucher, self) && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time)) + else if(DIFF_TEAM(toucher, self) && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time) && is_not_monster) ctf_Handle_Pickup(self, toucher, PICKUP_BASE); // toucher just stole the enemies flag break; } - + case FLAG_DROPPED: { if(SAME_TEAM(toucher, self)) ctf_Handle_Return(self, toucher); // toucher just returned his own flag - else if((!toucher.flagcarried) && ((toucher != self.ctf_dropper) || (time > self.ctf_droptime + autocvar_g_ctf_flag_collect_delay))) + else if(is_not_monster && (!toucher.flagcarried) && ((toucher != self.ctf_dropper) || (time > self.ctf_droptime + autocvar_g_ctf_flag_collect_delay))) ctf_Handle_Pickup(self, toucher, PICKUP_DROPPED); // toucher just picked up a dropped enemy flag break; } - + case FLAG_CARRY: { dprint("Someone touched a flag even though it was being carried?\n"); break; } - + case FLAG_PASSING: { if((IS_PLAYER(toucher)) && (toucher.deadflag == DEAD_NO) && (toucher != self.pass_sender)) @@ -847,28 +897,31 @@ void ctf_RespawnFlag(entity flag) { backtrace("flag respawn called twice quickly! please notify Samual about this..."); } flag.last_respawn = time; - + // reset the player (if there is one) if((flag.owner) && (flag.owner.flagcarried == flag)) { if(flag.owner.wps_enemyflagcarrier) WaypointSprite_Kill(flag.owner.wps_enemyflagcarrier); - + WaypointSprite_Kill(flag.wps_flagcarrier); - + flag.owner.flagcarried = world; if(flag.speedrunning) ctf_FakeTimeLimit(flag.owner, -1); } + if((flag.owner) && (flag.owner.vehicle)) + flag.scale = FLAG_SCALE; + if((flag.ctf_status == FLAG_DROPPED) && (flag.wps_flagdropped)) { WaypointSprite_Kill(flag.wps_flagdropped); } // reset the flag setattachment(flag, world, ""); setorigin(flag, flag.ctf_spawnorigin); - + flag.movetype = ((flag.noalign) ? MOVETYPE_NONE : MOVETYPE_TOSS); flag.takedamage = DAMAGE_NO; flag.health = flag.max_flag_health; @@ -876,7 +929,7 @@ void ctf_RespawnFlag(entity flag) flag.velocity = '0 0 0'; flag.angles = flag.mangle; flag.flags = FL_ITEM | FL_NOTARGET; - + flag.ctf_status = FLAG_BASE; flag.owner = world; flag.pass_distance = 0; @@ -885,6 +938,8 @@ void ctf_RespawnFlag(entity flag) flag.ctf_dropper = world; flag.ctf_pickuptime = 0; flag.ctf_droptime = 0; + + ctf_CheckStalemate(); } void ctf_Reset() @@ -892,7 +947,7 @@ void ctf_Reset() if(self.owner) if(IS_PLAYER(self.owner)) ctf_Handle_Throw(self.owner, world, DROP_RESET); - + ctf_RespawnFlag(self); } @@ -904,19 +959,19 @@ void ctf_DelayedFlagSetup(void) // called after a flag is placed on a map by ctf self.bot_basewaypoint = self.nearestwaypoint; // waypointsprites - WaypointSprite_SpawnFixed(((self.team == NUM_TEAM_1) ? "redbase" : "bluebase"), self.origin + FLAG_WAYPOINT_OFFSET, self, wps_flagbase, RADARICON_FLAG, colormapPaletteColor(self.team - 1, FALSE)); - WaypointSprite_UpdateTeamRadar(self.wps_flagbase, RADARICON_FLAG, colormapPaletteColor(self.team - 1, FALSE)); + WaypointSprite_SpawnFixed(((self.team == NUM_TEAM_1) ? "redbase" : "bluebase"), self.origin + FLAG_WAYPOINT_OFFSET, self, wps_flagbase, RADARICON_FLAG, colormapPaletteColor(self.team - 1, false)); + WaypointSprite_UpdateTeamRadar(self.wps_flagbase, RADARICON_FLAG, colormapPaletteColor(self.team - 1, false)); // captureshield setup ctf_CaptureShield_Spawn(self); } -void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc -{ +void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc +{ // declarations - teamnumber = fabs(teamnumber - bound(0, autocvar_g_ctf_reverse, 1)); // if we were originally 1, this will become 0. If we were originally 0, this will become 1. + teamnumber = fabs(teamnumber - bound(0, autocvar_g_ctf_reverse, 1)); // if we were originally 1, this will become 0. If we were originally 0, this will become 1. self = flag; // for later usage with droptofloor() - + // main setup flag.ctf_worldflagnext = ctf_worldflaglist; // link flag into ctf_worldflaglist ctf_worldflaglist = flag; @@ -931,11 +986,11 @@ void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag flag.flags = FL_ITEM | FL_NOTARGET; flag.solid = SOLID_TRIGGER; flag.takedamage = DAMAGE_NO; - flag.damageforcescale = autocvar_g_ctf_flag_damageforcescale; + flag.damageforcescale = autocvar_g_ctf_flag_damageforcescale; flag.max_flag_health = ((autocvar_g_ctf_flag_return_damage && autocvar_g_ctf_flag_health) ? autocvar_g_ctf_flag_health : 100); flag.health = flag.max_flag_health; flag.event_damage = ctf_FlagDamage; - flag.pushable = TRUE; + flag.pushable = true; flag.teleportable = TELEPORT_NORMAL; flag.damagedbytriggers = autocvar_g_ctf_flag_return_when_unreachable; flag.damagedbycontents = autocvar_g_ctf_flag_return_when_unreachable; @@ -954,8 +1009,8 @@ void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag if(flag.toucheffect == "") { flag.toucheffect = ((teamnumber) ? "redflag_touch" : "blueflag_touch"); } if(flag.passeffect == "") { flag.passeffect = ((teamnumber) ? "red_pass" : "blue_pass"); } if(flag.capeffect == "") { flag.capeffect = ((teamnumber) ? "red_cap" : "blue_cap"); } - - // sound + + // sound if(flag.snd_flag_taken == "") { flag.snd_flag_taken = ((teamnumber) ? "ctf/red_taken.wav" : "ctf/blue_taken.wav"); } if(flag.snd_flag_returned == "") { flag.snd_flag_returned = ((teamnumber) ? "ctf/red_returned.wav" : "ctf/blue_returned.wav"); } if(flag.snd_flag_capture == "") { flag.snd_flag_capture = ((teamnumber) ? "ctf/red_capture.wav" : "ctf/blue_capture.wav"); } // blue team scores by capturing the red flag @@ -963,7 +1018,7 @@ void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag if(flag.snd_flag_dropped == "") { flag.snd_flag_dropped = ((teamnumber) ? "ctf/red_dropped.wav" : "ctf/blue_dropped.wav"); } if(flag.snd_flag_touch == "") { flag.snd_flag_touch = "ctf/touch.wav"; } // again has no team-based sound if(flag.snd_flag_pass == "") { flag.snd_flag_pass = "ctf/pass.wav"; } // same story here - + // precache precache_sound(flag.snd_flag_taken); precache_sound(flag.snd_flag_returned); @@ -980,33 +1035,33 @@ void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag setmodel(flag, flag.model); // precision set below setsize(flag, FLAG_MIN, FLAG_MAX); setorigin(flag, (flag.origin + FLAG_SPAWN_OFFSET)); - + if(autocvar_g_ctf_flag_glowtrails) { flag.glow_color = ((teamnumber) ? 251 : 210); // 251: red - 210: blue flag.glow_size = 25; flag.glow_trail = 1; } - + flag.effects |= EF_LOWPRECISION; if(autocvar_g_ctf_fullbrightflags) { flag.effects |= EF_FULLBRIGHT; } if(autocvar_g_ctf_dynamiclights) { flag.effects |= ((teamnumber) ? EF_RED : EF_BLUE); } - + // flag placement if((flag.spawnflags & 1) || flag.noalign) // don't drop to floor, just stay at fixed location - { - flag.dropped_origin = flag.origin; - flag.noalign = TRUE; + { + flag.dropped_origin = flag.origin; + flag.noalign = true; flag.movetype = MOVETYPE_NONE; } else // drop to floor, automatically find a platform and set that as spawn origin - { - flag.noalign = FALSE; + { + flag.noalign = false; self = flag; droptofloor(); - flag.movetype = MOVETYPE_TOSS; - } - + flag.movetype = MOVETYPE_TOSS; + } + InitializeEntity(flag, ctf_DelayedFlagSetup, INITPRIO_SETLOCATION); } @@ -1186,7 +1241,7 @@ void havocbot_goalrating_ctf_carrieritems(float ratingscale, vector org, float s { entity head; float t; - head = findchainfloat(bot_pickup, TRUE); + head = findchainfloat(bot_pickup, true); while (head) { // gather health and armor only @@ -1242,7 +1297,7 @@ void havocbot_ctf_reset_role(entity bot) // if there is only me on the team switch to offense c = 0; FOR_EACH_PLAYER(head) - if(head.team==bot.team) + if(SAME_TEAM(head, bot)) ++c; if(c==1) @@ -1534,7 +1589,7 @@ void havocbot_role_ctf_middle() vector org; org = havocbot_ctf_middlepoint; - org_z = self.origin_z; + org.z = self.origin.z; self.bot_strategytime = time + autocvar_bot_ai_strategyinterval; navigation_goalrating_start(); @@ -1608,7 +1663,7 @@ void havocbot_role_ctf_defense() } if(closestplayer) - if(closestplayer.team!=self.team) + if(DIFF_TEAM(closestplayer, self)) if(vlen(org - self.origin)>1000) if(checkpvs(self.origin,closestplayer)||random()<0.5) havocbot_goalrating_ctf_ourbase(30000); @@ -1675,12 +1730,12 @@ void havocbot_role_ctf_setrole(entity bot, float role) MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink) { entity flag; - + // initially clear items so they can be set as necessary later. self.items &= ~(IT_RED_FLAG_CARRYING | IT_RED_FLAG_TAKEN | IT_RED_FLAG_LOST | IT_BLUE_FLAG_CARRYING | IT_BLUE_FLAG_TAKEN | IT_BLUE_FLAG_LOST | IT_CTF_SHIELDED); - // scan through all the flags and notify the client about them + // scan through all the flags and notify the client about them for(flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) { switch(flag.ctf_status) @@ -1690,7 +1745,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink) { if((flag.owner == self) || (flag.pass_sender == self)) self.items |= ((flag.items & IT_KEY2) ? IT_RED_FLAG_CARRYING : IT_BLUE_FLAG_CARRYING); // carrying: self is currently carrying the flag - else + else self.items |= ((flag.items & IT_KEY2) ? IT_RED_FLAG_TAKEN : IT_BLUE_FLAG_TAKEN); // taken: someone on self's team is carrying the flag break; } @@ -1701,16 +1756,16 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink) } } } - + // item for stopping players from capturing the flag too often if(self.ctf_captureshielded) self.items |= IT_CTF_SHIELDED; - + // update the health of the flag carrier waypointsprite - if(self.wps_flagcarrier) + if(self.wps_flagcarrier) WaypointSprite_UpdateHealth(self.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON)); - - return FALSE; + + return false; } MUTATOR_HOOKFUNCTION(ctf_PlayerDamage) // for changing damage and force values that are applied to players in g_damage.qc @@ -1738,7 +1793,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerDamage) // for changing damage and force values t } // todo: add notification for when flag carrier needs help? } - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(ctf_PlayerDies) @@ -1748,11 +1803,11 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerDies) PlayerTeamScore_AddScore(frag_attacker, autocvar_g_ctf_score_kill); PlayerScore_Add(frag_attacker, SP_CTF_FCKILLS, 1); } - + if(frag_target.flagcarried) { ctf_Handle_Throw(frag_target, world, DROP_NORMAL); } - - return FALSE; + + return false; } MUTATOR_HOOKFUNCTION(ctf_GiveFragsForKill) @@ -1764,33 +1819,33 @@ MUTATOR_HOOKFUNCTION(ctf_GiveFragsForKill) MUTATOR_HOOKFUNCTION(ctf_RemovePlayer) { entity flag; // temporary entity for the search method - + if(self.flagcarried) { ctf_Handle_Throw(self, world, DROP_NORMAL); } - + for(flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) { if(flag.pass_sender == self) { flag.pass_sender = world; } if(flag.pass_target == self) { flag.pass_target = world; } if(flag.ctf_dropper == self) { flag.ctf_dropper = world; } } - - return FALSE; + + return false; } MUTATOR_HOOKFUNCTION(ctf_PortalTeleport) { - if(self.flagcarried) + if(self.flagcarried) if(!autocvar_g_ctf_portalteleport) { ctf_Handle_Throw(self, world, DROP_NORMAL); } - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey) { - if(MUTATOR_RETURNVALUE || gameover) { return FALSE; } - + if(MUTATOR_RETURNVALUE || gameover) { return false; } + entity player = self; if((time > player.throw_antispam) && (player.deadflag == DEAD_NO) && !player.speedrunning && (!player.vehicle || autocvar_g_ctf_allow_vehicle_touch)) @@ -1799,22 +1854,22 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey) if(autocvar_g_ctf_pass) { entity head, closest_target = world; - head = WarpZone_FindRadius(player.origin, autocvar_g_ctf_pass_radius, TRUE); - + head = WarpZone_FindRadius(player.origin, autocvar_g_ctf_pass_radius, true); + while(head) // find the closest acceptable target to pass to { if(IS_PLAYER(head) && head.deadflag == DEAD_NO) if(head != player && SAME_TEAM(head, player)) if(!head.speedrunning && !head.vehicle) { - // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc) + // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc) vector head_center = WarpZone_UnTransformOrigin(head, CENTER_OR_VIEWOFS(head)); vector passer_center = CENTER_OR_VIEWOFS(player); - + if(ctf_CheckPassDirection(head_center, passer_center, player.v_angle, head.WarpZone_findradius_nearest)) { - if(autocvar_g_ctf_pass_request && !player.flagcarried && head.flagcarried) - { + if(autocvar_g_ctf_pass_request && !player.flagcarried && head.flagcarried) + { if(IS_BOT_CLIENT(head)) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_PASS_REQUESTING, head.netname); @@ -1825,8 +1880,8 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey) Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_CTF_PASS_REQUESTED, player.netname); Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_PASS_REQUESTING, head.netname); } - player.throw_antispam = time + autocvar_g_ctf_pass_wait; - return TRUE; + player.throw_antispam = time + autocvar_g_ctf_pass_wait; + return true; } else if(player.flagcarried) { @@ -1842,10 +1897,10 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey) } head = head.chain; } - - if(closest_target) { ctf_Handle_Throw(player, closest_target, DROP_PASS); return TRUE; } + + if(closest_target) { ctf_Handle_Throw(player, closest_target, DROP_PASS); return true; } } - + // throw the flag in front of you if(autocvar_g_ctf_throw && player.flagcarried) { @@ -1856,12 +1911,12 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey) player.throw_prevtime = time; player.throw_count = 1; ctf_Handle_Throw(player, world, DROP_THROW); - return TRUE; + return true; } else { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CTF_FLAG_THROW_PUNISH, rint((player.throw_prevtime + autocvar_g_ctf_throw_punish_delay) - time)); - return FALSE; + return false; } } else @@ -1869,15 +1924,15 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey) if(time > player.throw_prevtime + autocvar_g_ctf_throw_punish_time) { player.throw_count = 1; } else { player.throw_count += 1; } if(player.throw_count >= autocvar_g_ctf_throw_punish_count) { player.throw_count = -1; } - + player.throw_prevtime = time; ctf_Handle_Throw(player, world, DROP_THROW); - return TRUE; + return true; } } } - - return FALSE; + + return false; } MUTATOR_HOOKFUNCTION(ctf_HelpMePing) @@ -1886,14 +1941,14 @@ MUTATOR_HOOKFUNCTION(ctf_HelpMePing) { self.wps_helpme_time = time; WaypointSprite_HelpMePing(self.wps_flagcarrier); - } + } else // create a normal help me waypointsprite { - WaypointSprite_Spawn("helpme", waypointsprite_deployed_lifetime, waypointsprite_limitedrange, self, FLAG_WAYPOINT_OFFSET, world, self.team, self, wps_helpme, FALSE, RADARICON_HELPME, '1 0.5 0'); + WaypointSprite_Spawn("helpme", waypointsprite_deployed_lifetime, waypointsprite_limitedrange, self, FLAG_WAYPOINT_OFFSET, world, self.team, self, wps_helpme, false, RADARICON_HELPME, '1 0.5 0'); WaypointSprite_Ping(self.wps_helpme); } - return TRUE; + return true; } MUTATOR_HOOKFUNCTION(ctf_VehicleEnter) @@ -1905,30 +1960,30 @@ MUTATOR_HOOKFUNCTION(ctf_VehicleEnter) ctf_Handle_Throw(vh_player, world, DROP_NORMAL); } else - { - setattachment(vh_player.flagcarried, vh_vehicle, ""); + { + setattachment(vh_player.flagcarried, vh_vehicle, ""); setorigin(vh_player.flagcarried, VEHICLE_FLAG_OFFSET); vh_player.flagcarried.scale = VEHICLE_FLAG_SCALE; - //vh_player.flagcarried.angles = '0 0 0'; + //vh_player.flagcarried.angles = '0 0 0'; } - return TRUE; + return true; } - - return FALSE; + + return false; } MUTATOR_HOOKFUNCTION(ctf_VehicleExit) { if(vh_player.flagcarried) { - setattachment(vh_player.flagcarried, vh_player, ""); + setattachment(vh_player.flagcarried, vh_player, ""); setorigin(vh_player.flagcarried, FLAG_CARRY_OFFSET); vh_player.flagcarried.scale = FLAG_SCALE; vh_player.flagcarried.angles = '0 0 0'; - return TRUE; + return true; } - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(ctf_AbortSpeedrun) @@ -1937,16 +1992,16 @@ MUTATOR_HOOKFUNCTION(ctf_AbortSpeedrun) { Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_2(self.flagcarried, INFO_CTF_FLAGRETURN_ABORTRUN_)); ctf_RespawnFlag(self.flagcarried); - return TRUE; + return true; } - - return FALSE; + + return false; } MUTATOR_HOOKFUNCTION(ctf_MatchEnd) { entity flag; // temporary entity for the search method - + for(flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) { switch(flag.ctf_status) @@ -1958,12 +2013,12 @@ MUTATOR_HOOKFUNCTION(ctf_MatchEnd) flag.movetype = MOVETYPE_NONE; flag.takedamage = DAMAGE_NO; flag.solid = SOLID_NOT; - flag.nextthink = FALSE; // stop thinking - + flag.nextthink = false; // stop thinking + //dprint("stopping the ", flag.netname, " from moving.\n"); break; } - + default: case FLAG_BASE: case FLAG_CARRY: @@ -1973,14 +2028,14 @@ MUTATOR_HOOKFUNCTION(ctf_MatchEnd) } } } - - return FALSE; + + return false; } MUTATOR_HOOKFUNCTION(ctf_BotRoles) { havocbot_ctf_reset_role(self); - return TRUE; + return true; } @@ -1994,7 +2049,7 @@ Keys: "angle" viewing angle when spawning. */ void spawnfunc_info_player_team1() { if(g_assault) { remove(self); return; } - + self.team = NUM_TEAM_1; // red spawnfunc_info_player_deathmatch(); } @@ -2006,7 +2061,7 @@ Keys: "angle" viewing angle when spawning. */ void spawnfunc_info_player_team2() { if(g_assault) { remove(self); return; } - + self.team = NUM_TEAM_2; // blue spawnfunc_info_player_deathmatch(); } @@ -2017,7 +2072,7 @@ Keys: "angle" viewing angle when spawning. */ void spawnfunc_info_player_team3() { if(g_assault) { remove(self); return; } - + self.team = NUM_TEAM_3; // yellow spawnfunc_info_player_deathmatch(); } @@ -2029,20 +2084,20 @@ Keys: "angle" viewing angle when spawning. */ void spawnfunc_info_player_team4() { if(g_assault) { remove(self); return; } - + self.team = NUM_TEAM_4; // purple spawnfunc_info_player_deathmatch(); } /*QUAKED spawnfunc_item_flag_team1 (0 0.5 0.8) (-48 -48 -37) (48 48 37) CTF flag for team one (Red). -Keys: -"angle" Angle the flag will point (minus 90 degrees)... +Keys: +"angle" Angle the flag will point (minus 90 degrees)... "model" model to use, note this needs red and blue as skins 0 and 1... "noise" sound played when flag is picked up... "noise1" sound played when flag is returned by a teammate... "noise2" sound played when flag is captured... -"noise3" sound played when flag is lost in the field and respawns itself... +"noise3" sound played when flag is lost in the field and respawns itself... "noise4" sound played when flag is dropped by a player... "noise5" sound played when flag touches the ground... */ void spawnfunc_item_flag_team1() @@ -2054,13 +2109,13 @@ void spawnfunc_item_flag_team1() /*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -37) (48 48 37) CTF flag for team two (Blue). -Keys: -"angle" Angle the flag will point (minus 90 degrees)... +Keys: +"angle" Angle the flag will point (minus 90 degrees)... "model" model to use, note this needs red and blue as skins 0 and 1... "noise" sound played when flag is picked up... "noise1" sound played when flag is returned by a teammate... "noise2" sound played when flag is captured... -"noise3" sound played when flag is lost in the field and respawns itself... +"noise3" sound played when flag is lost in the field and respawns itself... "noise4" sound played when flag is dropped by a player... "noise5" sound played when flag touches the ground... */ void spawnfunc_item_flag_team2() @@ -2079,7 +2134,7 @@ Keys: void spawnfunc_ctf_team() { if(!g_ctf) { remove(self); return; } - + self.classname = "ctf_team"; self.team = self.cnt + 1; } @@ -2100,7 +2155,7 @@ void spawnfunc_team_CTF_bluespawn() { spawnfunc_info_player_team2(); } // scoreboard setup void ctf_ScoreRules() { - ScoreRules_basics(2, SFL_SORT_PRIO_PRIMARY, 0, TRUE); + ScoreRules_basics(2, SFL_SORT_PRIO_PRIMARY, 0, true); ScoreInfo_SetLabel_TeamScore (ST_CTF_CAPS, "caps", SFL_SORT_PRIO_PRIMARY); ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME); @@ -2135,7 +2190,7 @@ void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to ctf_SpawnTeam("Red", NUM_TEAM_1 - 1); ctf_SpawnTeam("Blue", NUM_TEAM_2 - 1); } - + ctf_ScoreRules(); } @@ -2146,7 +2201,7 @@ void ctf_Initialize() ctf_captureshield_min_negscore = autocvar_g_ctf_shield_min_negscore; ctf_captureshield_max_ratio = autocvar_g_ctf_shield_max_ratio; ctf_captureshield_force = autocvar_g_ctf_shield_force; - + InitializeEntity(world, ctf_DelayedInit, INITPRIO_GAMETYPE); } @@ -2166,8 +2221,8 @@ MUTATOR_DEFINITION(gamemode_ctf) MUTATOR_HOOK(VehicleEnter, ctf_VehicleEnter, CBC_ORDER_ANY); MUTATOR_HOOK(VehicleExit, ctf_VehicleExit, CBC_ORDER_ANY); MUTATOR_HOOK(AbortSpeedrun, ctf_AbortSpeedrun, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRule, ctf_BotRoles, CBC_ORDER_ANY); - + MUTATOR_HOOK(HavocBot_ChooseRole, ctf_BotRoles, CBC_ORDER_ANY); + MUTATOR_ONADD { if(time > 1) // game loads at time 1