}
MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
-{SELFPARAM();
- return PS(self).m_weapon == WEP_NEXBALL;
+{
+ entity player = M_ARGV(0, entity);
+
+ return PS(player).m_weapon == WEP_NEXBALL;
}
MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon)
-{SELFPARAM();
- return PS(self).m_weapon == WEP_MORTAR; // TODO: what is this for?
+{
+ entity player = M_ARGV(0, entity);
+
+ return PS(player).m_weapon == WEP_MORTAR; // TODO: what is this for?
}
MUTATOR_HOOKFUNCTION(nb, FilterItem)
-{SELFPARAM();
- if(self.classname == "droppedweapon")
- if(self.weapon == WEP_NEXBALL.m_id)
+{
+ entity item = M_ARGV(0, entity);
+
+ if(item.classname == "droppedweapon")
+ if(item.weapon == WEP_NEXBALL.m_id)
return true;
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(buffs, ForbidThrowCurrentWeapon)
-{SELFPARAM();
+{
if(MUTATOR_RETURNVALUE || gameover) { return false; }
+ entity player = M_ARGV(0, entity);
- if(self.buffs & BUFF_SWAPPER.m_itemid)
+ if(player.buffs & BUFF_SWAPPER.m_itemid)
{
float best_distance = autocvar_g_buffs_swapper_range;
entity closest = world;
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
if(!IS_DEAD(it) && !STAT(FROZEN, it) && !it.vehicle)
- if(DIFF_TEAM(it, self))
+ if(DIFF_TEAM(it, player))
{
- float test = vlen2(self.origin - it.origin);
+ float test = vlen2(player.origin - it.origin);
if(test <= best_distance * best_distance)
{
best_distance = sqrt(test);
{
vector my_org, my_vel, my_ang, their_org, their_vel, their_ang;
- my_org = self.origin;
- my_vel = self.velocity;
- my_ang = self.angles;
+ my_org = player.origin;
+ my_vel = player.velocity;
+ my_ang = player.angles;
their_org = closest.origin;
their_vel = closest.velocity;
their_ang = closest.angles;
Drop_Special_Items(closest);
- MUTATOR_CALLHOOK(PortalTeleport, self); // initiate flag dropper
+ MUTATOR_CALLHOOK(PortalTeleport, player); // initiate flag dropper
- setorigin(self, their_org);
+ setorigin(player, their_org);
setorigin(closest, my_org);
closest.velocity = my_vel;
closest.fixangle = true;
closest.oldorigin = my_org;
closest.oldvelocity = my_vel;
- self.velocity = their_vel;
- self.angles = their_ang;
- self.fixangle = true;
- self.oldorigin = their_org;
- self.oldvelocity = their_vel;
-
- // set pusher so self gets the kill if they fall into void
- closest.pusher = self;
+ player.velocity = their_vel;
+ player.angles = their_ang;
+ player.fixangle = true;
+ player.oldorigin = their_org;
+ player.oldvelocity = their_vel;
+
+ // set pusher so player gets the kill if they fall into void
+ closest.pusher = player;
closest.pushltime = time + autocvar_g_maxpushtime;
closest.istypefrag = PHYS_INPUT_BUTTON_CHAT(closest);
Send_Effect(EFFECT_ELECTRO_COMBO, their_org, '0 0 0', 1);
Send_Effect(EFFECT_ELECTRO_COMBO, my_org, '0 0 0', 1);
- sound(self, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NORM);
+ sound(player, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NORM);
sound(closest, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NORM);
// TODO: add a counter to handle how many times one can teleport, and a delay to prevent spam
- self.buffs = 0;
+ player.buffs = 0;
return true;
}
}
MUTATOR_HOOKFUNCTION(buffs, ClientDisconnect) { entity player = M_ARGV(0, entity); return buffs_RemovePlayer(player); }
MUTATOR_HOOKFUNCTION(buffs, CustomizeWaypoint)
-{SELFPARAM();
- entity e = WaypointSprite_getviewentity(other);
+{
+ entity wp = M_ARGV(0, entity);
+ entity player = M_ARGV(1, entity);
+
+ entity e = WaypointSprite_getviewentity(player);
// if you have the invisibility powerup, sprites ALWAYS are restricted to your team
// but only apply this to real players, not to spectators
- if((self.owner.flags & FL_CLIENT) && (self.owner.buffs & BUFF_INVISIBLE.m_itemid) && (e == other))
- if(DIFF_TEAM(self.owner, e))
+ if((wp.owner.flags & FL_CLIENT) && (wp.owner.buffs & BUFF_INVISIBLE.m_itemid) && (e == player))
+ if(DIFF_TEAM(wp.owner, e))
return true;
return false;
}
MUTATOR_HOOKFUNCTION(buffs, OnEntityPreSpawn, CBC_ORDER_LAST)
-{SELFPARAM();
+{
+ entity ent = M_ARGV(0, entity);
+
if(autocvar_g_buffs_replace_powerups)
- switch(self.classname)
+ switch(ent.classname)
{
case "item_strength":
case "item_invincible":
{
entity e = spawn();
- buff_SpawnReplacement(e, self);
+ buff_SpawnReplacement(e, ent);
return true;
}
}
MUTATOR_HOOKFUNCTION(hook, FilterItem)
{
- SELFPARAM();
- return self.weapon == WEP_HOOK.m_id;
+ entity item = M_ARGV(0, entity);
+
+ return item.weapon == WEP_HOOK.m_id;
}
#endif
}
MUTATOR_HOOKFUNCTION(mutator_instagib, FilterItem)
-{SELFPARAM();
- if(self.classname == "item_cells")
+{
+ entity item = M_ARGV(0, entity);
+
+ if(item.classname == "item_cells")
return true; // no normal cells?
- if(self.weapon == WEP_VAPORIZER.m_id && self.classname == "droppedweapon")
+ if(item.weapon == WEP_VAPORIZER.m_id && item.classname == "droppedweapon")
{
- self.ammo_cells = autocvar_g_instagib_ammo_drop;
+ item.ammo_cells = autocvar_g_instagib_ammo_drop;
return false;
}
- if(self.weapon == WEP_DEVASTATOR.m_id || self.weapon == WEP_VORTEX.m_id)
+ if(item.weapon == WEP_DEVASTATOR.m_id || item.weapon == WEP_VORTEX.m_id)
{
entity e = spawn();
- setorigin(e, self.origin);
- e.noalign = self.noalign;
- e.cnt = self.cnt;
- e.team = self.team;
+ setorigin(e, item.origin);
+ e.noalign = item.noalign;
+ e.cnt = item.cnt;
+ e.team = item.team;
e.spawnfunc_checked = true;
WITHSELF(e, spawnfunc_item_minst_cells(e));
return true;
}
- if(self.flags & FL_POWERUP)
+ if(item.flags & FL_POWERUP)
return false;
- if(self.ammo_cells > autocvar_g_instagib_ammo_drop && self.classname != "item_minst_cells")
- self.ammo_cells = autocvar_g_instagib_ammo_drop;
+ if(item.ammo_cells > autocvar_g_instagib_ammo_drop && item.classname != "item_minst_cells")
+ item.ammo_cells = autocvar_g_instagib_ammo_drop;
- if(self.ammo_cells && !self.weapon)
+ if(item.ammo_cells && !item.weapon)
return false;
return true;
}
MUTATOR_HOOKFUNCTION(mutator_instagib, CustomizeWaypoint)
-{SELFPARAM();
- entity e = WaypointSprite_getviewentity(other);
+{
+ entity wp = M_ARGV(0, entity);
+ entity player = M_ARGV(1, entity);
+
+ entity e = WaypointSprite_getviewentity(player);
// if you have the invisibility powerup, sprites ALWAYS are restricted to your team
// but only apply this to real players, not to spectators
- if((self.owner.flags & FL_CLIENT) && (self.owner.items & ITEM_Invisibility.m_itemid) && (e == other))
- if(DIFF_TEAM(self.owner, e))
+ if((wp.owner.flags & FL_CLIENT) && (wp.owner.items & ITEM_Invisibility.m_itemid) && (e == player))
+ if(DIFF_TEAM(wp.owner, e))
return true;
return false;
}
MUTATOR_HOOKFUNCTION(mutator_instagib, OnEntityPreSpawn)
-{SELFPARAM();
+{
if (!autocvar_g_powerups) { return false; }
+ entity ent = M_ARGV(0, entity);
// Can't use .itemdef here
- if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega"))
+ if (!(ent.classname == "item_strength" || ent.classname == "item_invincible" || ent.classname == "item_health_mega"))
return false;
entity e = spawn();
setthink(e, instagib_speed);
e.nextthink = time + 0.1;
- e.spawnflags = self.spawnflags;
- e.noalign = self.noalign;
- setorigin(e, self.origin);
+ e.spawnflags = ent.spawnflags;
+ e.noalign = ent.noalign;
+ setorigin(e, ent.origin);
return true;
}
}
MUTATOR_HOOKFUNCTION(melee_only, FilterItem)
-{SELFPARAM();
- switch (self.items)
+{
+ entity item = M_ARGV(0, entity);
+
+ switch (item.items)
{
case ITEM_HealthSmall.m_itemid:
case ITEM_ArmorSmall.m_itemid:
MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
{
- SELFPARAM();
- if (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
- nades_CheckThrow();
+ entity player = M_ARGV(0, entity);
+
+ if (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
+ WITHSELF(player, nades_CheckThrow());
return true;
}
return false;
}
MUTATOR_HOOKFUNCTION(nt, FilterItem)
-{SELFPARAM();
- if(nt_IsNewToy(self.weapon) && autocvar_g_new_toys_use_pickupsound) {
- self.item_pickupsound = string_null;
- self.item_pickupsound_ent = SND_WEAPONPICKUP_NEW_TOYS;
+{
+ entity item = M_ARGV(0, entity);
+
+ if(nt_IsNewToy(item.weapon) && autocvar_g_new_toys_use_pickupsound) {
+ item.item_pickupsound = string_null;
+ item.item_pickupsound_ent = SND_WEAPONPICKUP_NEW_TOYS;
}
- return 0;
+ return false;
}
#endif
}
MUTATOR_HOOKFUNCTION(nix, FilterItem)
-{SELFPARAM();
- switch (self.items)
+{
+ entity item = M_ARGV(0, entity);
+
+ switch (item.items)
{
case ITEM_HealthSmall.m_itemid:
case ITEM_HealthMedium.m_itemid:
}
MUTATOR_HOOKFUNCTION(nix, OnEntityPreSpawn)
-{SELFPARAM();
- if(self.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo)
+{
+ entity ent = M_ARGV(0, entity);
+
+ if(ent.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo)
return true;
return false;
}
void self_spawnfunc_weapon_rpc(entity this) { spawnfunc_weapon_rpc(this); }
MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
-{SELFPARAM();
+{
+ entity ent = M_ARGV(0, entity);
+
if(autocvar_g_powerups)
if(autocvar_g_overkill_powerups_replace)
{
- if(self.classname == "item_strength")
+ if(ent.classname == "item_strength")
{
entity wep = new(weapon_hmg);
- setorigin(wep, self.origin);
+ setorigin(wep, ent.origin);
setmodel(wep, MDL_OK_HMG);
wep.ok_item = true;
- wep.noalign = self.noalign;
- wep.cnt = self.cnt;
- wep.team = self.team;
+ wep.noalign = ent.noalign;
+ wep.cnt = ent.cnt;
+ wep.team = ent.team;
wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
wep.pickup_anyway = true;
wep.spawnfunc_checked = true;
return true;
}
- if(self.classname == "item_invincible")
+ if(ent.classname == "item_invincible")
{
entity wep = new(weapon_rpc);
- setorigin(wep, self.origin);
+ setorigin(wep, ent.origin);
setmodel(wep, MDL_OK_RPC);
wep.ok_item = true;
- wep.noalign = self.noalign;
- wep.cnt = self.cnt;
- wep.team = self.team;
+ wep.noalign = ent.noalign;
+ wep.cnt = ent.cnt;
+ wep.team = ent.team;
wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
wep.pickup_anyway = true;
wep.spawnfunc_checked = true;
}
MUTATOR_HOOKFUNCTION(ok, FilterItem)
-{SELFPARAM();
- if(self.ok_item)
+{
+ entity item = M_ARGV(0, entity);
+
+ if(item.ok_item)
return false;
- switch(self.items)
+ switch(item.items)
{
case ITEM_HealthMega.m_itemid: return !(autocvar_g_overkill_100h_anyway);
case ITEM_ArmorMega.m_itemid: return !(autocvar_g_overkill_100a_anyway);
return 1;
}
-bool turret_checkfire()
-{SELFPARAM();
- bool ret = false; // dummy
- if(MUTATOR_CALLHOOK(Turret_CheckFire, ret))
- return ret_bool;
+bool turret_checkfire(entity this)
+{
+ if(MUTATOR_CALLHOOK(Turret_CheckFire, this))
+ return M_ARGV(1, bool);
+
+ bool ret = false;
+ WITHSELF(this, ret = this.turret_firecheckfunc());
- return self.turret_firecheckfunc();
+ return ret;
}
void turret_fire()
turret_do_updates(self);
- if (turret_checkfire())
+ if (turret_checkfire(self))
turret_fire();
}
}
turret_do_updates(self);
// Fire?
- if (turret_checkfire())
+ if (turret_checkfire(self))
turret_fire();
}
else
turret_do_updates(self);
// Fire!
- if (turret_checkfire())
+ if (turret_checkfire(self))
turret_fire();
Turret tur = get_turretinfo(self.m_id);
turret_do_updates(self);
// Fire?
- if (turret_checkfire())
+ if (turret_checkfire(self))
turret_fire();
}
default:
{
MUTATOR_CALLHOOK(FormatMessage, this, escape, replacement, msg);
- escape = format_escape;
- replacement = format_replacement;
+ replacement = M_ARGV(2, string);
break;
}
}
/** called when formatting a chat message to replace fancy functions */
#define EV_FormatMessage(i, o) \
- /**/ i(entity, __self) \
- /**/ i(string, format_escape) \
- /**/ i(string, format_replacement) \
- /**/ o(string, format_replacement) \
- /**/ i(string, format_message) \
- /**/
-string format_escape;
-string format_replacement;
-string format_message;
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** escape */ i(string, MUTATOR_ARGV_1_string) \
+ /** replacement */ i(string, MUTATOR_ARGV_2_string) \
+ /**/ o(string, MUTATOR_ARGV_2_string) \
+ /** message */ i(string, MUTATOR_ARGV_3_string) \
+ /**/
MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
/** returns true if throwing the current weapon shall not be allowed */
#define EV_ForbidThrowCurrentWeapon(i, o) \
- /**/ i(entity, __self) \
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
/** returns true if dropping the current weapon shall not be allowed at any time including death */
#define EV_ForbidDropCurrentWeapon(i, o) \
- /**/ i(entity, __self) \
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
/** called every frame. customizes the waypoint for spectators */
#define EV_CustomizeWaypoint(i, o) \
- /** waypoint */ i(entity, __self) \
- /** player; other.enemy = spectator */ i(entity, other) \
+ /** waypoint */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** player; other.enemy = spectator */ i(entity, MUTATOR_ARGV_1_entity) \
/**/
MUTATOR_HOOKABLE(CustomizeWaypoint, EV_CustomizeWaypoint);
* return error to request removal
*/
#define EV_FilterItem(i, o) \
- /** the current item */ i(entity, __self) \
+ /** item */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(FilterItem, EV_FilterItem);
/** return error to request removal */
#define EV_TurretSpawn(i, o) \
- /** turret */ i(entity, __self) \
+ /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(TurretSpawn, EV_TurretSpawn);
/** return error to not attack */
#define EV_TurretFire(i, o) \
- /** turret */ i(entity, __self) \
+ /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(TurretFire, EV_TurretFire);
/** return error to not attack */
#define EV_Turret_CheckFire(i, o) \
- /**/ i(bool, ret_bool) \
- /**/ o(bool, ret_bool) \
+ /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** to fire or not to fire */ o(bool, MUTATOR_ARGV_1_bool) \
/**/
-bool ret_bool;
MUTATOR_HOOKABLE(Turret_CheckFire, EV_Turret_CheckFire);
/** return error to prevent entity spawn, or modify the entity */
#define EV_OnEntityPreSpawn(i, o) \
- /** turret */ i(entity, __self) \
+ /** entity */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_OnEntityPreSpawn);
}
MUTATOR_HOOKFUNCTION(as, TurretSpawn)
-{SELFPARAM();
- if(!self.team || self.team == MAX_SHOT_DISTANCE)
- self.team = 5; // this gets reversed when match starts?
+{
+ entity turret = M_ARGV(0, entity);
+
+ if(!turret.team || turret.team == MAX_SHOT_DISTANCE)
+ turret.team = 5; // this gets reversed when match starts?
return false;
}
MUTATOR_HOOKFUNCTION(as, OnEntityPreSpawn)
{
- SELFPARAM();
- switch(self.classname)
+ entity ent = M_ARGV(0, entity);
+
+ switch(ent.classname)
{
case "info_player_team1":
case "info_player_team2":
MUTATOR_HOOKFUNCTION(ca, ForbidThrowCurrentWeapon)
{
- return 1;
+ return true;
}
MUTATOR_HOOKFUNCTION(ca, GiveFragsForKill, CBC_ORDER_FIRST)
MUTATOR_HOOKFUNCTION(ca, FilterItem)
{
- SELFPARAM();
+ entity item = M_ARGV(0, entity);
+
if (autocvar_g_powerups <= 0)
- if (this.flags & FL_POWERUP)
+ if (item.flags & FL_POWERUP)
return true;
if (autocvar_g_pickup_items <= 0)
}
MUTATOR_HOOKFUNCTION(cts, FilterItem)
-{SELFPARAM();
- if(self.classname == "droppedweapon")
+{
+ entity item = M_ARGV(0, entity);
+
+ if(item.classname == "droppedweapon")
return true;
return false;
}
MUTATOR_HOOKFUNCTION(inv, OnEntityPreSpawn)
-{SELFPARAM();
- if(startsWith(self.classname, "monster_"))
- if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
+{
+ entity ent = M_ARGV(0, entity);
+
+ if(startsWith(ent.classname, "monster_"))
+ if(!(ent.spawnflags & MONSTERFLAG_SPAWNED))
return true;
return false;
}
MUTATOR_HOOKFUNCTION(lms, FilterItem)
-{SELFPARAM();
+{
+ entity item = M_ARGV(0, entity);
+
if(autocvar_g_lms_extra_lives)
- if(self.itemdef == ITEM_ExtraLife)
+ if(item.itemdef == ITEM_ExtraLife)
return false;
return true;
}
MUTATOR_HOOKFUNCTION(lms, OnEntityPreSpawn)
-{SELFPARAM();
+{
if (!autocvar_g_powerups) return false;
if (!autocvar_g_lms_extra_lives) return false;
+ entity ent = M_ARGV(0, entity);
+
// Can't use .itemdef here
- if (self.classname != "item_health_mega") return false;
+ if (ent.classname != "item_health_mega") return false;
entity e = spawn();
setthink(e, lms_extralife);
e.nextthink = time + 0.1;
- e.spawnflags = self.spawnflags;
- e.noalign = self.noalign;
- setorigin(e, self.origin);
+ e.spawnflags = ent.spawnflags;
+ e.noalign = ent.noalign;
+ setorigin(e, ent.origin);
return true;
}