* Find control point or generator owned by the same team self which is nearest to pos
* if max_dist is positive, only control points within this range will be considered
*/
-entity ons_Nearest_ControlPoint(vector pos, float max_dist)
-{SELFPARAM();
+entity ons_Nearest_ControlPoint(entity this, vector pos, float max_dist)
+{
entity tmp_entity, closest_target = world;
tmp_entity = findchain(classname, "onslaught_controlpoint");
while(tmp_entity)
{
- if(SAME_TEAM(tmp_entity, self))
+ if(SAME_TEAM(tmp_entity, this))
if(tmp_entity.iscaptured)
if(max_dist <= 0 || vdist(tmp_entity.origin - pos, <=, max_dist))
if(vlen2(tmp_entity.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == world)
tmp_entity = findchain(classname, "onslaught_generator");
while(tmp_entity)
{
- if(SAME_TEAM(tmp_entity, self))
+ if(SAME_TEAM(tmp_entity, this))
if(max_dist <= 0 || vdist(tmp_entity.origin - pos, <, max_dist))
if(vlen2(tmp_entity.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == world)
closest_target = tmp_entity;
* if max_dist is positive, only control points within this range will be considered
* This function only check distances on the XY plane, disregarding Z
*/
-entity ons_Nearest_ControlPoint_2D(vector pos, float max_dist)
-{SELFPARAM();
+entity ons_Nearest_ControlPoint_2D(entity this, vector pos, float max_dist)
+{
entity tmp_entity, closest_target = world;
vector delta;
float smallest_distance = 0, distance;
delta_z = 0;
distance = vlen(delta);
- if(SAME_TEAM(tmp_entity, self))
+ if(SAME_TEAM(tmp_entity, this))
if(tmp_entity.iscaptured)
if(max_dist <= 0 || distance <= max_dist)
if(closest_target == world || distance <= smallest_distance )
delta_z = 0;
distance = vlen(delta);
- if(SAME_TEAM(tmp_entity, self))
+ if(SAME_TEAM(tmp_entity, this))
if(max_dist <= 0 || distance <= max_dist)
if(closest_target == world || distance <= smallest_distance )
{
}
MUTATOR_HOOKFUNCTION(ons, ClientDisconnect)
-{SELFPARAM();
- self.ons_deathloc = '0 0 0';
- return false;
+{
+ entity player = M_ARGV(0, entity);
+
+ player.ons_deathloc = '0 0 0';
}
MUTATOR_HOOKFUNCTION(ons, MakePlayerObserver)
-{SELFPARAM();
- self.ons_deathloc = '0 0 0';
- return false;
+{
+ entity player = M_ARGV(0, entity);
+
+ player.ons_deathloc = '0 0 0';
}
MUTATOR_HOOKFUNCTION(ons, PlayerSpawn)
-{SELFPARAM();
+{
+ entity player = M_ARGV(0, entity);
+
if(!round_handler_IsRoundStarted())
{
- self.player_blocked = true;
+ player.player_blocked = true;
return false;
}
l.sprite.SendFlags |= 16;
}
- if(ons_stalemate) { Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT); }
+ if(ons_stalemate) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT); }
if ( autocvar_g_onslaught_spawn_choose )
- if ( self.ons_spawn_by )
- if ( ons_Teleport(self,self.ons_spawn_by,autocvar_g_onslaught_teleport_radius,false) )
+ if ( player.ons_spawn_by )
+ if ( ons_Teleport(player,player.ons_spawn_by,autocvar_g_onslaught_teleport_radius,false) )
{
- self.ons_spawn_by = world;
+ player.ons_spawn_by = world;
return false;
}
{
float random_target = autocvar_g_onslaught_spawn_at_controlpoints_random;
entity tmp_entity, closest_target = world;
- vector spawn_loc = self.ons_deathloc;
+ vector spawn_loc = player.ons_deathloc;
// new joining player or round reset, don't bother checking
if(spawn_loc == '0 0 0') { return false; }
for(tmp_entity = ons_worldcplist; tmp_entity; tmp_entity = tmp_entity.ons_worldcpnext)
{
- if(SAME_TEAM(tmp_entity, self))
+ if(SAME_TEAM(tmp_entity, player))
if(random_target)
RandomSelection_Add(tmp_entity, 0, string_null, 1, 1);
else if(vlen(tmp_entity.origin - spawn_loc) <= vlen(closest_target.origin - spawn_loc) || closest_target == world)
iteration_scale -= i / 10;
loc = closest_target.origin + '0 0 96' * iteration_scale;
loc += ('0 1 0' * random()) * 128 * iteration_scale;
- tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, self);
+ tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the world
if(trace_fraction == 1.0 && !trace_startsolid)
{
- setorigin(self, loc);
- self.angles = normalize(loc - closest_target.origin) * RAD2DEG;
+ setorigin(player, loc);
+ player.angles = normalize(loc - closest_target.origin) * RAD2DEG;
return false;
}
}
{
float random_target = autocvar_g_onslaught_spawn_at_generator_random;
entity tmp_entity, closest_target = world;
- vector spawn_loc = self.ons_deathloc;
+ vector spawn_loc = player.ons_deathloc;
// new joining player or round reset, don't bother checking
if(spawn_loc == '0 0 0') { return false; }
RandomSelection_Add(tmp_entity, 0, string_null, 1, 1);
else
{
- if(SAME_TEAM(tmp_entity, self))
+ if(SAME_TEAM(tmp_entity, player))
if(vlen(tmp_entity.origin - spawn_loc) <= vlen(closest_target.origin - spawn_loc) || closest_target == world)
closest_target = tmp_entity;
}
iteration_scale -= i / 10;
loc = closest_target.origin + '0 0 128' * iteration_scale;
loc += ('0 1 0' * random()) * 256 * iteration_scale;
- tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, self);
+ tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the world
if(trace_fraction == 1.0 && !trace_startsolid)
{
- setorigin(self, loc);
- self.angles = normalize(loc - closest_target.origin) * RAD2DEG;
+ setorigin(player, loc);
+ player.angles = normalize(loc - closest_target.origin) * RAD2DEG;
return false;
}
}
MUTATOR_HOOKFUNCTION(ons, PlayerDies)
{
+ entity frag_target = M_ARGV(2, entity);
+
frag_target.ons_deathloc = frag_target.origin;
entity l;
for(l = ons_worldgeneratorlist; l; l = l.ons_worldgeneratornext)
}
MUTATOR_HOOKFUNCTION(ons, MonsterMove)
-{SELFPARAM();
- entity e = find(world, targetname, self.target);
- if (e != world)
- self.team = e.team;
+{
+ entity mon = M_ARGV(0, entity);
- return false;
+ entity e = find(world, targetname, mon.target);
+ if (e != world)
+ mon.team = e.team;
}
void ons_MonsterSpawn_Delayed(entity this)
{
- entity own = self.owner;
+ entity own = this.owner;
if(!own) { remove(this); return; }
}
MUTATOR_HOOKFUNCTION(ons, MonsterSpawn)
-{SELFPARAM();
+{
+ entity mon = M_ARGV(0, entity);
+
entity e = spawn();
- e.owner = self;
+ e.owner = mon;
InitializeEntity(e, ons_MonsterSpawn_Delayed, INITPRIO_FINDTARGET);
-
- return false;
}
void ons_TurretSpawn_Delayed(entity this)
{
- entity own = self.owner;
+ entity own = this.owner;
- if(!own) { remove(self); return; }
+ if(!own) { remove(this); return; }
if(own.targetname)
{
}
}
- remove(self);
+ remove(this);
}
MUTATOR_HOOKFUNCTION(ons, TurretSpawn)
-{SELFPARAM();
+{
+ entity turret = M_ARGV(0, entity);
+
entity e = spawn();
- e.owner = self;
+ e.owner = turret;
InitializeEntity(e, ons_TurretSpawn_Delayed, INITPRIO_FINDTARGET);
return false;
}
MUTATOR_HOOKFUNCTION(ons, HavocBot_ChooseRole)
-{SELFPARAM();
- havocbot_ons_reset_role(self);
+{
+ entity bot = M_ARGV(0, entity);
+
+ havocbot_ons_reset_role(bot);
return true;
}
}
MUTATOR_HOOKFUNCTION(ons, SpectateCopy)
-{SELFPARAM();
- self.ons_roundlost = other.ons_roundlost; // make spectators see it too
- return false;
+{
+ entity spectatee = M_ARGV(0, entity);
+ entity client = M_ARGV(1, entity);
+
+ client.ons_roundlost = spectatee.ons_roundlost; // make spectators see it too
}
MUTATOR_HOOKFUNCTION(ons, SV_ParseClientCommand)
-{SELFPARAM();
+{
if(MUTATOR_RETURNVALUE) // command was already handled?
return false;
+ entity player = M_ARGV(0, entity);
+ string cmd_name = M_ARGV(1, string);
+ int cmd_argc = M_ARGV(2, int);
+
if ( cmd_name == "ons_spawn" )
{
- vector pos = self.origin;
+ vector pos = player.origin;
if(cmd_argc > 1)
pos_x = stof(argv(1));
if(cmd_argc > 2)
if(cmd_argc > 3)
pos_z = stof(argv(3));
- if ( IS_PLAYER(self) )
+ if ( IS_PLAYER(player) )
{
- if ( !STAT(FROZEN, self) )
+ if ( !STAT(FROZEN, player) )
{
- entity source_point = ons_Nearest_ControlPoint(self.origin, autocvar_g_onslaught_teleport_radius);
+ entity source_point = ons_Nearest_ControlPoint(player, player.origin, autocvar_g_onslaught_teleport_radius);
- if ( !source_point && self.health > 0 )
+ if ( !source_point && player.health > 0 )
{
- sprint(self, "\nYou need to be next to a control point\n");
- return 1;
+ sprint(player, "\nYou need to be next to a control point\n");
+ return true;
}
- entity closest_target = ons_Nearest_ControlPoint_2D(pos, autocvar_g_onslaught_click_radius);
+ entity closest_target = ons_Nearest_ControlPoint_2D(player, pos, autocvar_g_onslaught_click_radius);
if ( closest_target == world )
{
- sprint(self, "\nNo control point found\n");
- return 1;
+ sprint(player, "\nNo control point found\n");
+ return true;
}
- if ( self.health <= 0 )
+ if ( player.health <= 0 )
{
- self.ons_spawn_by = closest_target;
- self.respawn_flags = self.respawn_flags | RESPAWN_FORCE;
+ player.ons_spawn_by = closest_target;
+ player.respawn_flags = player.respawn_flags | RESPAWN_FORCE;
}
else
{
if ( source_point == closest_target )
{
- sprint(self, "\nTeleporting to the same point\n");
- return 1;
+ sprint(player, "\nTeleporting to the same point\n");
+ return true;
}
- if ( !ons_Teleport(self,closest_target,autocvar_g_onslaught_teleport_radius,true) )
- sprint(self, "\nUnable to teleport there\n");
+ if ( !ons_Teleport(player,closest_target,autocvar_g_onslaught_teleport_radius,true) )
+ sprint(player, "\nUnable to teleport there\n");
}
- return 1;
+ return true;
}
- sprint(self, "\nNo teleportation for you\n");
+ sprint(player, "\nNo teleportation for you\n");
}
- return 1;
+ return true;
}
- return 0;
+ return false;
}
MUTATOR_HOOKFUNCTION(ons, PlayerUseKey)
if((time > self.teleport_antispam) && (!IS_DEAD(self)) && !self.vehicle)
{
- entity source_point = ons_Nearest_ControlPoint(self.origin, autocvar_g_onslaught_teleport_radius);
+ entity source_point = ons_Nearest_ControlPoint(self, self.origin, autocvar_g_onslaught_teleport_radius);
if ( source_point )
{
stuffcmd(self, "qc_cmd_cl hud clickradar\n");
MUTATOR_HOOKFUNCTION(ons, PlayHitsound)
{
+ entity frag_victim = M_ARGV(0, entity);
+
return (frag_victim.classname == "onslaught_generator" && !frag_victim.isshielded)
|| (frag_victim.classname == "onslaught_controlpoint_icon" && !frag_victim.owner.isshielded);
}
MUTATOR_HOOKFUNCTION(ons, TurretValidateTarget)
{
+ entity turret_target = M_ARGV(1, entity);
+
if(substring(turret_target.classname, 0, 10) == "onslaught_") // don't attack onslaught targets, that's the player's job!
{
- ret_float = -3;
+ M_ARGV(3, float) = -3;
return true;
}