-// ================================================================
-// Official capture the flag game mode coding, reworked by Samual
-// Last updated: September, 2012
-// ================================================================
+#include "gamemode_ctf.qh"
+#include "../_all.qh"
+
+#include "gamemode.qh"
+
+#ifdef SVQC
+#include "../../common/vehicles/sv_vehicles.qh"
+#endif
+
+#include "../../warpzonelib/common.qh"
+#include "../../warpzonelib/mathlib.qh"
void ctf_FakeTimeLimit(entity e, float t)
{
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);
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;
{
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 = (('0 0 1' * autocvar_g_ctf_throw_velocity_up) + ((v_forward * autocvar_g_ctf_throw_velocity_forward) * ((player.items & ITEM_Strength.m_itemid) ? autocvar_g_ctf_throw_strengthmultiplier : 1)));
flag.velocity = W_CalculateProjectileVelocity(player.velocity, flag_velocity, false);
ctf_Handle_Drop(flag, player, droptype);
break;
PlayerScore_Add(player, SP_CTF_CAPTIME, new_time - old_time);
// effects
- pointparticles(particleeffectnum(flag.capeffect), flag.origin, '0 0 0', 1);
+ Send_Effect(flag.capeffect, flag.origin, '0 0 0', 1);
//shockwave_spawn("models/ctf/shockwavetransring.md3", flag.origin - '0 0 15', -0.8, 0, 1);
// other
void ctf_Handle_Return(entity flag, entity player)
{
// messages and sounds
- if(player.flags & FL_MONSTER)
+ if(IS_MONSTER(player))
{
Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_RETURN_MONSTER_), player.monster_name);
}
}
// effects
- pointparticles(particleeffectnum(flag.toucheffect), player.origin, '0 0 0', 1);
+ Send_Effect(flag.toucheffect, player.origin, '0 0 0', 1);
// waypoints
if(pickuptype == PICKUP_DROPPED) { WaypointSprite_Kill(flag.wps_flagdropped); }
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)
{
if(ITEM_DAMAGE_NEEDKILL(deathtype))
{
if(trace_dphitcontents & (DPCONTENTS_PLAYERCLIP | DPCONTENTS_MONSTERCLIP)) { return; }
entity toucher = other, tmp_entity;
- bool is_not_monster = (!(toucher.flags & FL_MONSTER)), 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())
// special touch behaviors
if(toucher.frozen) { return; }
- else if(toucher.vehicle_flags & VHF_ISVEHICLE)
+ else if(IS_VEHICLE(toucher))
{
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)
+ else if(IS_MONSTER(toucher))
{
if(!autocvar_g_ctf_allow_monster_touch)
return; // do nothing
{
if(time > self.wait) // if we haven't in a while, play a sound/effect
{
- pointparticles(particleeffectnum(self.toucheffect), self.origin, '0 0 0', 1);
+ Send_Effect(self.toucheffect, self.origin, '0 0 0', 1);
sound(self, CH_TRIGGER, self.snd_flag_touch, VOL_BASE, ATTEN_NORM);
self.wait = time + FLAG_TOUCHRATE;
}
if(flag.skin == 0) { flag.skin = cvar(sprintf("g_ctf_flag_%s_skin", teamname)); }
if(flag.model == "") { flag.model = cvar_string(sprintf("g_ctf_flag_%s_model", teamname)); }
set_flag_string(flag, toucheffect, "%sflag_touch", teamname);
- set_flag_string(flag, passeffect, "%sflag_pass", teamname);
- set_flag_string(flag, capeffect, "%sflag_cap", teamname);
+ set_flag_string(flag, passeffect, "%s_pass", teamname);
+ set_flag_string(flag, capeffect, "%s_cap", teamname);
// sounds
set_flag_string(flag, snd_flag_taken, "ctf/%s_taken.wav", teamname);
}
}
-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)
{
if(vh_player.flagcarried)
{
+ vh_player.flagcarried.nodrawtoclient = vh_player; // hide the flag from the driver
+
if(!autocvar_g_ctf_allow_vehicle_carry && !autocvar_g_ctf_allow_vehicle_touch)
{
ctf_Handle_Throw(vh_player, world, DROP_NORMAL);
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;
return true;
}
void spawnfunc_team_CTF_redspawn() { spawnfunc_info_player_team1(); }
void spawnfunc_team_CTF_bluespawn() { spawnfunc_info_player_team2(); }
+void team_CTF_neutralflag() { spawnfunc_item_flag_neutral(); }
+void team_neutralobelisk() { spawnfunc_item_flag_neutral(); }
+
// ==============
// Initialization
// ==============
// 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;