}
bool ctf_CaptureShield_Customize()
-{
+{SELFPARAM();
if(!other.ctf_captureshielded) { return false; }
if(CTF_SAMETEAM(self, other)) { return false; }
}
void ctf_CaptureShield_Touch()
-{
+{SELFPARAM();
if(!other.ctf_captureshielded) { return; }
if(CTF_SAMETEAM(self, other)) { return; }
}
void ctf_CaptureShield_Spawn(entity flag)
-{
+{SELFPARAM();
entity shield = spawn();
shield.enemy = self;
shield.scale = 0.5;
setorigin(shield, self.origin);
- setmodel(shield, "models/ctf/shield.md3");
+ setmodel(shield, MDL_CTF_SHIELD);
setsize(shield, shield.scale * shield.mins, shield.scale * shield.maxs);
}
// messages and sounds
Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_LOST_) : INFO_CTF_LOST_NEUTRAL), player.netname);
- sound(flag, CH_TRIGGER, flag.snd_flag_dropped, VOL_BASE, ATTEN_NONE);
+ _sound(flag, CH_TRIGGER, flag.snd_flag_dropped, VOL_BASE, ATTEN_NONE);
ctf_EventLog("dropped", player.team, player);
// scoring
flag.ctf_status = FLAG_CARRY;
// messages and sounds
- sound(player, CH_TRIGGER, flag.snd_flag_pass, VOL_BASE, ATTEN_NORM);
+ _sound(player, CH_TRIGGER, flag.snd_flag_pass, VOL_BASE, ATTEN_NORM);
ctf_EventLog("receive", flag.team, player);
FOR_EACH_REALPLAYER(tmp_player)
flag.ctf_status = FLAG_PASSING;
// other
- sound(player, CH_TRIGGER, flag.snd_flag_touch, VOL_BASE, ATTEN_NORM);
+ _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;
// messages and sounds
Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((enemy_flag.team) ? APP_TEAM_ENT_4(enemy_flag, CENTER_CTF_CAPTURE_) : CENTER_CTF_CAPTURE_NEUTRAL));
ctf_CaptureRecord(enemy_flag, player);
- sound(player, CH_TRIGGER, ((ctf_oneflag) ? player_team_flag.snd_flag_capture : ((DIFF_TEAM(player, flag)) ? enemy_flag.snd_flag_capture : flag.snd_flag_capture)), VOL_BASE, ATTEN_NONE);
+ _sound(player, CH_TRIGGER, ((ctf_oneflag) ? player_team_flag.snd_flag_capture : ((DIFF_TEAM(player, flag)) ? enemy_flag.snd_flag_capture : flag.snd_flag_capture)), VOL_BASE, ATTEN_NONE);
switch(capturetype)
{
Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_ENT_4(flag, CENTER_CTF_RETURN_));
Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_RETURN_), player.netname);
}
- sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTEN_NONE);
+ _sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTEN_NONE);
ctf_EventLog("return", flag.team, player);
// scoring
else
Send_Notification(NOTIF_ONE, tmp_entity, MSG_CHOICE, ((SAME_TEAM(flag, player)) ? CHOICE_CTF_PICKUP_ENEMY_TEAM : CHOICE_CTF_PICKUP_ENEMY), Team_ColorCode(player.team), player.netname);
- sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTEN_NONE);
+ _sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTEN_NONE);
// scoring
PlayerScore_Add(player, SP_CTF_PICKUPS, 1);
case RETURN_TIMEOUT:
{ Send_Notification(NOTIF_ALL, world, MSG_INFO, ((flag.team) ? APP_TEAM_ENT_4(flag, INFO_CTF_FLAGRETURN_TIMEOUT_) : INFO_CTF_FLAGRETURN_TIMEOUT_NEUTRAL)); break; }
}
- sound(flag, CH_TRIGGER, flag.snd_flag_respawn, VOL_BASE, ATTEN_NONE);
+ _sound(flag, CH_TRIGGER, flag.snd_flag_respawn, VOL_BASE, ATTEN_NONE);
ctf_EventLog("returned", flag.team, world);
ctf_RespawnFlag(flag);
}
}
bool ctf_Stalemate_Customize()
-{
+{SELFPARAM();
// make spectators see what the player would see
entity e, wp_owner;
e = WaypointSprite_getviewentity(other);
}
void ctf_FlagDamage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
if(ITEM_DAMAGE_NEEDKILL(deathtype))
{
if(autocvar_g_ctf_flag_return_damage_delay)
}
void ctf_FlagThink()
-{
+{SELFPARAM();
// declarations
entity tmp_entity;
self.health = 0;
ctf_CheckFlagReturn(self, RETURN_SPEEDRUN);
- tmp_entity = self;
- self = self.owner;
+ setself(self.owner);
self.impulse = CHIMPULSE_SPEEDRUN; // move the player back to the waypoint they set
ImpulseCommands();
- self = tmp_entity;
+ setself(this);
}
if(autocvar_g_ctf_stalemate)
{
}
void ctf_FlagTouch()
-{
+{SELFPARAM();
if(gameover) { return; }
if(trace_dphitcontents & (DPCONTENTS_PLAYERCLIP | DPCONTENTS_MONSTERCLIP)) { return; }
if(time > self.wait) // if we haven't in a while, play a sound/effect
{
Send_Effect_(self.toucheffect, self.origin, '0 0 0', 1);
- sound(self, CH_TRIGGER, self.snd_flag_touch, VOL_BASE, ATTEN_NORM);
+ _sound(self, CH_TRIGGER, self.snd_flag_touch, VOL_BASE, ATTEN_NORM);
self.wait = time + FLAG_TOUCHRATE;
}
return;
}
void ctf_Reset()
-{
+{SELFPARAM();
if(self.owner)
if(IS_PLAYER(self.owner))
ctf_Handle_Throw(self.owner, world, DROP_RESET);
}
void ctf_DelayedFlagSetup(void) // called after a flag is placed on a map by ctf_FlagSetup()
-{
+{SELFPARAM();
// bot waypoints
waypoint_spawnforitem_force(self, self.origin);
self.nearestwaypointtimeout = 0; // activate waypointing again
void set_flag_string(entity flag, .string field, string value, string teamname)
{
- if(flag.field == "")
- flag.field = strzone(sprintf(value,teamname));
+ if(flag.(field) == "")
+ flag.(field) = strzone(sprintf(value,teamname));
}
void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
-{
+{SELFPARAM();
// declarations
- string teamname = Static_Team_ColorName_Lower(teamnumber);
- self = flag; // for later usage with droptofloor()
+ setself(flag); // for later usage with droptofloor()
// main setup
flag.ctf_worldflagnext = ctf_worldflaglist; // link flag into ctf_worldflaglist
flag.nextthink = time + FLAG_THINKRATE;
flag.ctf_status = FLAG_BASE;
+ string teamname = Static_Team_ColorName_Lower(teamnumber);
// appearence
if(!flag.scale) { flag.scale = FLAG_SCALE; }
if(flag.skin == 0) { flag.skin = cvar(sprintf("g_ctf_flag_%s_skin", teamname)); }
set_flag_string(flag, capeffect, "%s_cap", teamname);
// sounds
- set_flag_string(flag, snd_flag_taken, "ctf/%s_taken.wav", teamname);
- set_flag_string(flag, snd_flag_returned, "ctf/%s_returned.wav", teamname);
- set_flag_string(flag, snd_flag_capture, "ctf/%s_capture.wav", teamname);
- set_flag_string(flag, snd_flag_dropped, "ctf/%s_dropped.wav", teamname);
- if(flag.snd_flag_respawn == "") { flag.snd_flag_respawn = "ctf/flag_respawn.wav"; } // if there is ever a team-based sound for this, update the code to match.
- 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);
- precache_sound(flag.snd_flag_capture);
+ flag.snd_flag_taken = SND(CTF_TAKEN(teamnumber));
+ flag.snd_flag_returned = SND(CTF_RETURNED(teamnumber));
+ flag.snd_flag_capture = SND(CTF_CAPTURE(teamnumber));
+ flag.snd_flag_dropped = SND(CTF_DROPPED(teamnumber));
+ if (flag.snd_flag_respawn == "") flag.snd_flag_respawn = SND(CTF_RESPAWN); // if there is ever a team-based sound for this, update the code to match.
precache_sound(flag.snd_flag_respawn);
- precache_sound(flag.snd_flag_dropped);
+ if (flag.snd_flag_touch == "") flag.snd_flag_touch = SND(CTF_TOUCH); // again has no team-based sound
precache_sound(flag.snd_flag_touch);
+ if (flag.snd_flag_pass == "") flag.snd_flag_pass = SND(CTF_PASS); // same story here
precache_sound(flag.snd_flag_pass);
+
+ // precache
precache_model(flag.model);
- precache_model("models/ctf/shield.md3");
- precache_model("models/ctf/shockwavetransring.md3");
// appearence
- setmodel(flag, flag.model); // precision set below
+ _setmodel(flag, flag.model); // precision set below
setsize(flag, FLAG_MIN, FLAG_MAX);
setorigin(flag, (flag.origin + FLAG_SPAWN_OFFSET));
else // drop to floor, automatically find a platform and set that as spawn origin
{
flag.noalign = false;
- self = flag;
+ setself(flag);
droptofloor();
flag.movetype = MOVETYPE_TOSS;
}
}
void havocbot_goalrating_ctf_ourflag(float ratingscale)
-{
+{SELFPARAM();
entity head;
head = ctf_worldflaglist;
while (head)
}
void havocbot_goalrating_ctf_ourbase(float ratingscale)
-{
+{SELFPARAM();
entity head;
head = ctf_worldflaglist;
while (head)
}
void havocbot_goalrating_ctf_enemyflag(float ratingscale)
-{
+{SELFPARAM();
entity head;
head = ctf_worldflaglist;
while (head)
}
void havocbot_goalrating_ctf_enemybase(float ratingscale)
-{
+{SELFPARAM();
if (!bot_waypoints_for_items)
{
havocbot_goalrating_ctf_enemyflag(ratingscale);
}
void havocbot_goalrating_ctf_ourstolenflag(float ratingscale)
-{
+{SELFPARAM();
entity mf;
mf = havocbot_ctf_find_flag(self);
}
void havocbot_goalrating_ctf_carrieritems(float ratingscale, vector org, float sradius)
-{
+{SELFPARAM();
entity head;
float t;
head = findchainfloat(bot_pickup, true);
}
void havocbot_role_ctf_carrier()
-{
+{SELFPARAM();
if(self.deadflag != DEAD_NO)
{
havocbot_ctf_reset_role(self);
}
void havocbot_role_ctf_escort()
-{
+{SELFPARAM();
entity mf, ef;
if(self.deadflag != DEAD_NO)
}
void havocbot_role_ctf_offense()
-{
+{SELFPARAM();
entity mf, ef;
vector pos;
// Retriever (temporary role):
void havocbot_role_ctf_retriever()
-{
+{SELFPARAM();
entity mf;
if(self.deadflag != DEAD_NO)
}
void havocbot_role_ctf_middle()
-{
+{SELFPARAM();
entity mf;
if(self.deadflag != DEAD_NO)
}
void havocbot_role_ctf_defense()
-{
+{SELFPARAM();
entity mf;
if(self.deadflag != DEAD_NO)
// ==============
MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink)
-{
+{SELFPARAM();
entity flag;
int t = 0, t2 = 0, t3 = 0;
}
MUTATOR_HOOKFUNCTION(ctf_RemovePlayer)
-{
+{SELFPARAM();
entity flag; // temporary entity for the search method
if(self.flagcarried)
}
MUTATOR_HOOKFUNCTION(ctf_PortalTeleport)
-{
+{SELFPARAM();
if(self.flagcarried)
if(!autocvar_g_ctf_portalteleport)
{ ctf_Handle_Throw(self, world, DROP_NORMAL); }
}
MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey)
-{
+{SELFPARAM();
if(MUTATOR_RETURNVALUE || gameover) { return false; }
entity player = self;
}
MUTATOR_HOOKFUNCTION(ctf_HelpMePing)
-{
+{SELFPARAM();
if(self.wps_flagcarrier) // update the flagcarrier waypointsprite with "NEEDING HELP" notification
{
self.wps_helpme_time = time;
}
MUTATOR_HOOKFUNCTION(ctf_AbortSpeedrun)
-{
+{SELFPARAM();
if(self.flagcarried)
{
Send_Notification(NOTIF_ALL, world, MSG_INFO, ((self.flagcarried.team) ? APP_TEAM_ENT_4(self.flagcarried, INFO_CTF_FLAGRETURN_ABORTRUN_) : INFO_CTF_FLAGRETURN_ABORTRUN_NEUTRAL));
}
MUTATOR_HOOKFUNCTION(ctf_BotRoles)
-{
+{SELFPARAM();
havocbot_ctf_reset_role(self);
return true;
}
}
MUTATOR_HOOKFUNCTION(ctf_SpectateCopy)
-{
+{SELFPARAM();
self.ctf_flagstatus = other.ctf_flagstatus;
return false;
}
"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()
+spawnfunc(item_flag_team1)
{
if(!g_ctf) { remove(self); return; }
"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()
+spawnfunc(item_flag_team2)
{
if(!g_ctf) { remove(self); return; }
"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_team3()
+spawnfunc(item_flag_team3)
{
if(!g_ctf) { remove(self); return; }
"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_team4()
+spawnfunc(item_flag_team4)
{
if(!g_ctf) { remove(self); return; }
"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_neutral()
+spawnfunc(item_flag_neutral)
{
if(!g_ctf) { remove(self); return; }
if(!cvar("g_ctf_oneflag")) { remove(self); return; }
Keys:
"netname" Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)...
"cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
-void spawnfunc_ctf_team()
+spawnfunc(ctf_team)
{
if(!g_ctf) { remove(self); return; }
}
// compatibility for quake maps
-void spawnfunc_team_CTF_redflag() { spawnfunc_item_flag_team1(); }
-void spawnfunc_team_CTF_blueflag() { spawnfunc_item_flag_team2(); }
-void spawnfunc_team_CTF_redplayer() { spawnfunc_info_player_team1(); }
-void spawnfunc_team_CTF_blueplayer() { spawnfunc_info_player_team2(); }
-void spawnfunc_team_CTF_redspawn() { spawnfunc_info_player_team1(); }
-void spawnfunc_team_CTF_bluespawn() { spawnfunc_info_player_team2(); }
+spawnfunc(team_CTF_redflag) { spawnfunc_item_flag_team1(this); }
+spawnfunc(team_CTF_blueflag) { spawnfunc_item_flag_team2(this); }
+spawnfunc(team_CTF_redplayer) { spawnfunc_info_player_team1(this); }
+spawnfunc(team_CTF_blueplayer) { spawnfunc_info_player_team2(this); }
+spawnfunc(team_CTF_redspawn) { spawnfunc_info_player_team1(this); }
+spawnfunc(team_CTF_bluespawn) { spawnfunc_info_player_team2(this); }
-void team_CTF_neutralflag() { spawnfunc_item_flag_neutral(); }
-void team_neutralobelisk() { spawnfunc_item_flag_neutral(); }
+void team_CTF_neutralflag() { SELFPARAM(); spawnfunc_item_flag_neutral(self); }
+void team_neutralobelisk() { SELFPARAM(); spawnfunc_item_flag_neutral(self); }
// ==============
// code from here on is just to support maps that don't have flag and team entities
void ctf_SpawnTeam (string teamname, int teamcolor)
{
- entity oldself;
- oldself = self;
- self = spawn();
- self.classname = "ctf_team";
- self.netname = teamname;
- self.cnt = teamcolor;
-
- spawnfunc_ctf_team();
-
- self = oldself;
+ entity this = new(ctf_team);
+ this.netname = teamname;
+ this.cnt = teamcolor;
+ this.spawnfunc_checked = true;
+ WITH(entity, self, this, spawnfunc_ctf_team(this));
}
void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to be set up.