setsize(shield, shield.scale * shield.mins, shield.scale * shield.maxs);
}
+
// ====================
// Drop/Pass/Throw Code
// ====================
entity flag = player.flagcarried;
if(!flag) { return; }
- if((droptype == DROPTYPE_PASS) && !reciever) { return; }
+ if((droptype == DROP_PASS) && !reciever) { return; }
//if(flag.speedrunning) { ctf_RespawnFlag(flag); return; }
switch(droptype)
{
- case DROPTYPE_PASS:
+ case DROP_PASS:
{
vector targ_origin = (0.5 * (reciever.absmin + reciever.absmax));
flag.velocity = (normalize(targ_origin - player.origin) * autocvar_g_ctf_throw_velocity);
break;
}
- case DROPTYPE_THROW:
+ case DROP_THROW:
{
makevectors((player.v_angle_y * '0 1 0') + (player.v_angle_x * '0.5 0 0'));
flag.velocity = W_CalculateProjectileVelocity(player.velocity, ('0 0 200' + (v_forward * autocvar_g_ctf_throw_velocity)), FALSE);
}
default:
- case DROPTYPE_DROP:
+ case DROP_NORMAL:
{
flag.velocity = ('0 0 200' + ('0 100 0' * crandom()) + ('100 0 0' * crandom()));
break;
switch(droptype)
{
- case DROPTYPE_PASS:
+ case DROP_PASS:
{
// main
flag.movetype = MOVETYPE_FLY;
}
default:
- case DROPTYPE_THROW:
- case DROPTYPE_DROP:
+ case DROP_THROW:
+ case DROP_NORMAL:
{
// main
flag.movetype = MOVETYPE_TOSS;
// Event Handlers
// ==============
-void ctf_Handle_Dropped_Capture(entity flag, entity enemy_flag)
+void ctf_Handle_Capture(entity flag, entity toucher, float capturetype)
{
- // declarations
- string cap_message;
- entity player = enemy_flag.ctf_dropper;
+ entity enemy_flag = ((capturetype == CAPTURE_NORMAL) ? toucher.flagcarried : toucher);
+ entity player = ((capturetype == CAPTURE_NORMAL) ? toucher : enemy_flag.ctf_dropper);
if not(player) { return; } // without someone to give the reward to, we can't possibly cap
// messages and sounds
Send_KillNotification(player.netname, enemy_flag.netname, ctf_CaptureRecord(enemy_flag, player), INFO_CAPTUREFLAG, MSG_INFO);
sound(player, CH_TRIGGER, flag.snd_flag_capture, VOL_BASE, ATTN_NONE);
- ctf_EventLog("droppedcapture", enemy_flag.team, player);
- // scoring
- PlayerTeamScore_AddScore(player, ctf_ReadScore("score_capture"));
- PlayerTeamScore_Add(player, SP_CTF_CAPS, ST_CTF_CAPS, 1);
-
- // effects
- if(autocvar_g_ctf_flag_capture_effects)
+ switch(capturetype)
{
- pointparticles(particleeffectnum((player.team == COLOR_TEAM1) ? "red_ground_quake" : "blue_ground_quake"), flag.origin, '0 0 0', 1);
- //shockwave_spawn("models/ctf/shockwavetransring.md3", flag.origin - '0 0 15', -0.8, 0, 1);
+ case CAPTURE_NORMAL: ctf_EventLog("capture", enemy_flag.team, player); break;
+ case CAPTURE_DROPPED: ctf_EventLog("droppedcapture", enemy_flag.team, player); break;
+ default: break;
}
- player.next_take_time = time + autocvar_g_ctf_flag_collect_delay;
-
- // reset the flag
- ctf_RespawnFlag(enemy_flag);
-}
-
-void ctf_Handle_Capture(entity flag, entity player)
-{
- // messages and sounds
- Send_KillNotification(player.netname, player.flagcarried.netname, ctf_CaptureRecord(player.flagcarried, player), INFO_CAPTUREFLAG, MSG_INFO);
- sound(player, CH_TRIGGER, flag.snd_flag_capture, VOL_BASE, ATTN_NONE);
- ctf_EventLog("capture", player.flagcarried.team, player);
-
// scoring
PlayerTeamScore_AddScore(player, ctf_ReadScore("score_capture"));
PlayerTeamScore_Add(player, SP_CTF_CAPS, ST_CTF_CAPS, 1);
shockwave_spawn("models/ctf/shockwavetransring.md3", flag.origin - '0 0 15', -0.8, 0, 1);
}
- // waypointsprites
- WaypointSprite_Kill(player.wps_flagcarrier);
-
+ // other
+ if(capturetype == CAPTURE_NORMAL)
+ {
+ WaypointSprite_Kill(player.wps_flagcarrier);
+ if(flag.speedrunning) { ctf_FakeTimeLimit(player, -1); }
+ }
+
// reset the flag
- if(flag.speedrunning) { ctf_FakeTimeLimit(player, -1); }
player.next_take_time = time + autocvar_g_ctf_flag_collect_delay;
-
ctf_RespawnFlag(player.flagcarried);
}
switch(pickuptype)
{
- case PICKUPTYPE_BASE: flag.ctf_pickuptime = time; break; // used for timing runs
- case PICKUPTYPE_DROPPED: flag.health = flag.max_flag_health; break; // reset health/return timelimit
+ case PICKUP_BASE: flag.ctf_pickuptime = time; break; // used for timing runs
+ case PICKUP_DROPPED: flag.health = flag.max_flag_health; break; // reset health/return timelimit
default: break;
}
switch(pickuptype)
{
- case PICKUPTYPE_BASE: ctf_EventLog("steal", flag.team, player); break;
- case PICKUPTYPE_DROPPED: ctf_EventLog("pickup", flag.team, player); break;
+ case PICKUP_BASE: ctf_EventLog("steal", flag.team, player); break;
+ case PICKUP_DROPPED: ctf_EventLog("pickup", flag.team, player); break;
default: break;
}
PlayerScore_Add(player, SP_CTF_PICKUPS, 1);
switch(pickuptype)
{
- case PICKUPTYPE_BASE:
+ case PICKUP_BASE:
{
PlayerTeamScore_AddScore(player, ctf_ReadScore("score_pickup_base"));
break;
}
- case PICKUPTYPE_DROPPED:
+ case PICKUP_DROPPED:
{
pickup_dropped_score = (autocvar_g_ctf_flag_returntime ? bound(0, ((flag.ctf_droptime + autocvar_g_ctf_flag_returntime) - time) / autocvar_g_ctf_flag_returntime, 1) : 1);
pickup_dropped_score = floor((ctf_ReadScore("score_pickup_dropped_late") * (1 - pickup_dropped_score) + ctf_ReadScore("score_pickup_dropped_early") * pickup_dropped_score) + 0.5);
}
// speedrunning
- if(pickuptype == PICKUPTYPE_BASE)
+ if(pickuptype == PICKUP_BASE)
{
flag.speedrunning = player.speedrunning; // if speedrunning, flag will flag-return and teleport the owner back after the record
if((player.speedrunning) && (ctf_captimerecord))
pointparticles(particleeffectnum("smoke_ring"), 0.5 * (flag.absmin + flag.absmax), '0 0 0', 1);
// waypoints
- if(pickuptype == PICKUPTYPE_DROPPED) { WaypointSprite_Kill(flag.wps_flagdropped); }
+ if(pickuptype == PICKUP_DROPPED) { WaypointSprite_Kill(flag.wps_flagdropped); }
ctf_FlagcarrierWaypoints(player);
WaypointSprite_Ping(player.wps_flagcarrier);
}
for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
if(tmp_entity.ctf_status == FLAG_DROPPED)
if(vlen(self.origin - tmp_entity.origin) < autocvar_g_ctf_dropped_capture_radius)
- ctf_Handle_Dropped_Capture(self, tmp_entity);
+ ctf_Handle_Capture(self, tmp_entity, CAPTURE_DROPPED);
}
return;
}
case FLAG_BASE:
{
if((other.team == self.team) && (other.flagcarried) && (other.flagcarried.team != self.team))
- ctf_Handle_Capture(self, other); // other just captured the enemies flag to his base
+ ctf_Handle_Capture(self, other, CAPTURE_NORMAL); // other just captured the enemies flag to his base
else if((other.team != self.team) && (!other.flagcarried) && (!other.ctf_captureshielded) && (time > other.next_take_time))
- ctf_Handle_Pickup(self, other, PICKUPTYPE_BASE); // other just stole the enemies flag
+ ctf_Handle_Pickup(self, other, PICKUP_BASE); // other just stole the enemies flag
break;
}
if(other.team == self.team)
ctf_Handle_Return(self, other); // other just returned his own flag
else if((!other.flagcarried) && ((other != self.ctf_dropper) || (time > self.ctf_droptime + autocvar_g_ctf_flag_collect_delay)))
- ctf_Handle_Pickup(self, other, PICKUPTYPE_DROPPED); // other just picked up a dropped enemy flag
+ ctf_Handle_Pickup(self, other, PICKUP_DROPPED); // other just picked up a dropped enemy flag
break;
}
{
if(self.owner)
if(self.owner.classname == "player")
- ctf_Handle_Throw(self.owner, world, DROPTYPE_DROP);
+ ctf_Handle_Throw(self.owner, world, DROP_NORMAL);
ctf_RespawnFlag(self);
}
MUTATOR_HOOKFUNCTION(ctf_HookedDrop)
{
- if(self.flagcarried) { ctf_Handle_Throw(self, world, DROPTYPE_DROP); }
+ if(self.flagcarried) { ctf_Handle_Throw(self, world, DROP_NORMAL); }
return 0;
}
if(clienttype(head) == CLIENTTYPE_BOT)
{
centerprint(player, strcat("Requesting ", head.netname, " to pass you the ", head.flagcarried.netname));
- ctf_Handle_Throw(head, player, DROPTYPE_PASS);
+ ctf_Handle_Throw(head, player, DROP_PASS);
}
else
{
head = head.chain;
}
- if(closest_target) { ctf_Handle_Throw(player, closest_target, DROPTYPE_PASS); return 0; }
+ if(closest_target) { ctf_Handle_Throw(player, closest_target, DROP_PASS); return 0; }
}
// throw the flag in front of you
if(autocvar_g_ctf_allow_drop && player.flagcarried && !player.speedrunning)
- { ctf_Handle_Throw(player, world, DROPTYPE_THROW); }
+ { ctf_Handle_Throw(player, world, DROP_THROW); }
}
return 0;