// The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
void CSQC_Ent_Update(bool isnew)
{
- SELFPARAM();
+ SELFPARAM(); // needed for engine functions
this.sourceLoc = __FILE__ ":" STR(__LINE__);
int t = ReadByte();
// CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well.
void CSQC_Ent_Remove()
{
- SELFPARAM();
+ SELFPARAM(); // needed for engine functions
if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype);
if (wasfreed(this))
{
void WaypointSprite_Load();
void CSQC_UpdateView(float w, float h)
{
- SELFPARAM();
+ SELFPARAM(); // needed for engine functions
TC(int, w); TC(int, h);
entity e;
float fov;
if(this.nade_type == NADE_TYPE_TRANSLOCATE.m_id || this.nade_type == NADE_TYPE_SPAWN.m_id)
return;
- if (MUTATOR_CALLHOOK(Nade_Damage, DEATH_WEAPONOF(deathtype), force, damage)) {}
+ if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
{
force *= 1.5;
* called to adjust nade damage and force on hit
*/
#define EV_Nade_Damage(i, o) \
- /** weapon */ i(entity, MUTATOR_ARGV_0_entity) \
- /** force */ i(vector, MUTATOR_ARGV_1_vector) \
- /**/ o(vector, MUTATOR_ARGV_1_vector) \
- /** damage */ i(float, MUTATOR_ARGV_2_float) \
- /**/ o(float, MUTATOR_ARGV_2_float) \
+ /** nade */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** weapon */ i(entity, MUTATOR_ARGV_1_entity) \
+ /** force */ i(vector, MUTATOR_ARGV_2_vector) \
+ /**/ o(vector, MUTATOR_ARGV_2_vector) \
+ /** damage */ i(float, MUTATOR_ARGV_3_float) \
+ /**/ o(float, MUTATOR_ARGV_3_float) \
/**/
MUTATOR_HOOKABLE(Nade_Damage, EV_Nade_Damage);
REGISTER_MUTATOR(hmg_nadesupport, true);
MUTATOR_HOOKFUNCTION(hmg_nadesupport, Nade_Damage)
{
- SELFPARAM();
- if (M_ARGV(0, entity) != WEP_HMG) return;
+ if (M_ARGV(1, entity) != WEP_HMG) return;
return = true;
- M_ARGV(2, float) /* damage */ = self.max_health * 0.1;
+ M_ARGV(3, float) /* damage */ = (M_ARGV(0, entity)).max_health * 0.1;
}
spawnfunc(weapon_hmg) { weapon_defaultspawnfunc(this, WEP_HMG); }
void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- SELFPARAM();
if (!PHYS_INPUT_BUTTON_ATCK(actor))
{
w_ready(thiswep, actor, weaponentity, fire);
return;
}
- W_DecreaseAmmo(WEP_HMG, self, WEP_CVAR(hmg, ammo));
+ W_DecreaseAmmo(WEP_HMG, actor, WEP_CVAR(hmg, ammo));
W_SetupShot (actor, true, 0, SND_UZI_FIRE, CH_WEAPON_A, WEP_CVAR(hmg, damage));
METHOD(HeavyMachineGun, wr_aim, void(entity thiswep, entity actor))
{
- entity this = actor;
- if(vdist(self.origin - self.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
- PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, 1000000, 0, 0.001, false);
+ if(vdist(actor.origin - actor.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
+ PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 0.001, false);
else
- PHYS_INPUT_BUTTON_ATCK2(self) = bot_aim(self, 1000000, 0, 0.001, false);
+ PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, 1000000, 0, 0.001, false);
}
METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
METHOD(HeavyMachineGun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, WEP_CVAR(hmg, ammo), SND_RELOAD);
+ W_Reload(actor, WEP_CVAR(hmg, ammo), SND_RELOAD);
}
METHOD(HeavyMachineGun, wr_suicidemessage, Notification(entity thiswep))
METHOD(HeavyMachineGun, wr_impacteffect, void(entity thiswep, entity actor))
{
- entity this = actor;
vector org2;
org2 = w_org + w_backoff * 2;
pointparticles(EFFECT_MACHINEGUN_IMPACT, org2, w_backoff * 1000, 1);
if(!w_issilent)
- sound(self, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
+ sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
}
#endif
self.nextthink = time;
}
-void W_RocketPropelledChainsaw_Attack (Weapon thiswep)
-{SELFPARAM();
+void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor)
+{
entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(self);
entity flash = spawn ();
- W_DecreaseAmmo(thiswep, self, WEP_CVAR(rpc, ammo));
- W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(rpc, damage));
+ W_DecreaseAmmo(thiswep, actor, WEP_CVAR(rpc, ammo));
+ W_SetupShot_ProjectileSize (actor, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(rpc, damage));
Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
PROJECTILE_MAKETRIGGER(missile);
- missile.owner = missile.realowner = self;
+ missile.owner = missile.realowner = actor;
missile.bot_dodge = true;
missile.bot_dodgerating = WEP_CVAR(rpc, damage) * 2;
setmodel(flash, MDL_RPC_MUZZLEFLASH); // precision set below
SUB_SetFade (flash, time, 0.1);
flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
- W_AttachToShotorg(self, flash, '5 0 0');
+ W_AttachToShotorg(actor, flash, '5 0 0');
missile.pos1 = missile.velocity;
- MUTATOR_CALLHOOK(EditProjectile, self, missile);
+ MUTATOR_CALLHOOK(EditProjectile, actor, missile);
}
METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor))
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(rpc, refire)))
{
- W_RocketPropelledChainsaw_Attack(thiswep);
+ W_RocketPropelledChainsaw_Attack(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready);
}
}
METHOD(RocketPropelledChainsaw, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, WEP_CVAR(rpc, ammo), SND_RELOAD);
+ W_Reload(actor, WEP_CVAR(rpc, ammo), SND_RELOAD);
}
METHOD(RocketPropelledChainsaw, wr_suicidemessage, Notification(entity thiswep))
{
// decide if and how this object can be grabbed
if(autocvar_g_sandbox_readonly)
- self.grab = 0; // no grabbing
- else if(autocvar_g_sandbox_editor_free < 2 && self.crypto_idfp)
- self.grab = 1; // owner only
+ this.grab = 0; // no grabbing
+ else if(autocvar_g_sandbox_editor_free < 2 && this.crypto_idfp)
+ this.grab = 1; // owner only
else
- self.grab = 3; // anyone
+ this.grab = 3; // anyone
// Object owner is stored via player UID, but we also need the owner as an entity (if the player is available on the server).
// Therefore, scan for all players, and update the owner as long as the player is present. We must always do this,
// bots can't have objects
FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
- if(self.crypto_idfp == it.crypto_idfp)
+ if(this.crypto_idfp == it.crypto_idfp)
{
- self.realowner = it;
+ this.realowner = it;
break;
}
- self.realowner = world;
+ this.realowner = world;
));
- self.nextthink = time;
+ this.nextthink = time;
- CSQCMODEL_AUTOUPDATE(self);
+ CSQCMODEL_AUTOUPDATE(this);
}
.float old_solid, old_movetype;
-entity sandbox_ObjectEdit_Get(float permissions)
-{SELFPARAM();
+entity sandbox_ObjectEdit_Get(entity this, float permissions)
+{
// Returns the traced entity if the player can edit it, and world if not.
// If permissions if false, the object is returned regardless of editing rights.
// Attached objects are SOLID_NOT and do not get traced.
- crosshair_trace_plusvisibletriggers(self);
- if(vdist(self.origin - trace_ent.origin, >, autocvar_g_sandbox_editor_distance_edit))
+ crosshair_trace_plusvisibletriggers(this);
+ if(vdist(this.origin - trace_ent.origin, >, autocvar_g_sandbox_editor_distance_edit))
return world; // out of trace range
if(trace_ent.classname != "object")
return world; // entity is not an object
return trace_ent; // don't check permissions, anyone can edit this object
if(trace_ent.crypto_idfp == "")
return trace_ent; // the player who spawned this object did not have an UID, so anyone can edit it
- if (!(trace_ent.realowner != self && autocvar_g_sandbox_editor_free < 2))
+ if (!(trace_ent.realowner != this && autocvar_g_sandbox_editor_free < 2))
return trace_ent; // object does not belong to the player, and players can only edit their own objects on this server
return world;
}
}
}
-entity sandbox_ObjectSpawn(float database)
-{SELFPARAM();
+entity sandbox_ObjectSpawn(entity this, float database)
+{
// spawn a new object with default properties
entity e = new(object);
{
// set the object's owner via player UID
// if the player does not have an UID, the owner cannot be stored and his objects may be edited by anyone
- if(self.crypto_idfp != "")
- e.crypto_idfp = strzone(self.crypto_idfp);
+ if(this.crypto_idfp != "")
+ e.crypto_idfp = strzone(this.crypto_idfp);
else
- print_to(self, "^1SANDBOX - WARNING: ^7You spawned an object, but lack a player UID. ^1Your objects are not secured and can be edited by any player!");
+ print_to(this, "^1SANDBOX - WARNING: ^7You spawned an object, but lack a player UID. ^1Your objects are not secured and can be edited by any player!");
// set public object information
- e.netname = strzone(self.netname); // name of the owner
+ e.netname = strzone(this.netname); // name of the owner
e.message = strzone(strftime(true, "%d-%m-%Y %H:%M:%S")); // creation time
e.message2 = strzone(strftime(true, "%d-%m-%Y %H:%M:%S")); // last editing time
// set origin and direction based on player position and view angle
- makevectors(self.v_angle);
- WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_spawn, MOVE_NORMAL, self);
+ makevectors(this.v_angle);
+ WarpZone_TraceLine(this.origin + this.view_ofs, this.origin + this.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_spawn, MOVE_NORMAL, this);
setorigin(e, trace_endpos);
- e.angles_y = self.v_angle.y;
+ e.angles_y = this.v_angle.y;
}
CSQCMODEL_AUTOINIT(e);
return s;
}
-entity sandbox_ObjectPort_Load(string s, float database)
+entity sandbox_ObjectPort_Load(entity this, string s, float database)
{
// load object properties, and spawn a new object with them
float n, i;
string tagname = string_null;
argv_num = 0;
tokenize_console(port_string[i]);
- e = sandbox_ObjectSpawn(database);
+ e = sandbox_ObjectSpawn(this, database);
// ---------------- OBJECT PROPERTY STORAGE: LOAD ----------------
if(i)
continue;
entity e;
- e = sandbox_ObjectPort_Load(file_read, true);
+ e = sandbox_ObjectPort_Load(NULL, file_read, true);
if(e.material)
{
return true;
}
- e = sandbox_ObjectSpawn(false);
+ e = sandbox_ObjectSpawn(player, false);
_setmodel(e, argv(2));
if(autocvar_g_sandbox_info > 0)
// ---------------- COMMAND: OBJECT, REMOVE ----------------
case "object_remove":
- e = sandbox_ObjectEdit_Get(true);
+ e = sandbox_ObjectEdit_Get(player, true);
if(e != world)
{
if(autocvar_g_sandbox_info > 0)
{
case "copy":
// copies customizable properties of the selected object to the clipboard cvar
- e = sandbox_ObjectEdit_Get(autocvar_g_sandbox_editor_free); // can we copy objects we can't edit?
+ e = sandbox_ObjectEdit_Get(player, autocvar_g_sandbox_editor_free); // can we copy objects we can't edit?
if(e != world)
{
s = sandbox_ObjectPort_Save(e, false);
print_to(player, strcat("^1SANDBOX - WARNING: ^7Cannot spawn any more objects. Up to ^3", ftos(autocvar_g_sandbox_editor_maxobjects), " ^7objects may exist at a time"));
return true;
}
- e = sandbox_ObjectPort_Load(argv(3), false);
+ e = sandbox_ObjectPort_Load(player, argv(3), false);
print_to(player, "^2SANDBOX - INFO: ^7Object pasted successfully");
if(autocvar_g_sandbox_info > 0)
{
case "get":
// select e as the object as meant to be attached
- e = sandbox_ObjectEdit_Get(true);
+ e = sandbox_ObjectEdit_Get(player, true);
if(e != world)
{
player.object_attach = e;
}
// attaches the previously selected object to e
- e = sandbox_ObjectEdit_Get(true);
+ e = sandbox_ObjectEdit_Get(player, true);
if(e != world)
{
sandbox_ObjectAttach_Set(player.object_attach, e, argv(3));
return true;
case "remove":
// removes e if it was attached
- e = sandbox_ObjectEdit_Get(true);
+ e = sandbox_ObjectEdit_Get(player, true);
if(e != world)
{
sandbox_ObjectAttach_Remove(e);
return true;
}
- e = sandbox_ObjectEdit_Get(true);
+ e = sandbox_ObjectEdit_Get(player, true);
if(e != world)
{
switch(argv(2))
print_to(player, "^1SANDBOX - WARNING: ^7You do not have a player UID, and cannot claim objects");
return true;
}
- e = sandbox_ObjectEdit_Get(true);
+ e = sandbox_ObjectEdit_Get(player, true);
if(e != world)
{
// update the owner's name
// ---------------- COMMAND: OBJECT, INFO ----------------
case "object_info":
// prints public information about the object to the player
- e = sandbox_ObjectEdit_Get(false);
+ e = sandbox_ObjectEdit_Get(player, false);
if(e != world)
{
switch(argv(2))
.string superspec_itemfilter; //"classname1 classname2 ..."
-bool superspec_Spectate(entity _player)
-{SELFPARAM();
- if(Spectate(_player) == 1)
- TRANSMUTE(Spectator, self);
+bool superspec_Spectate(entity this, entity targ)
+{
+ if(Spectate(targ) == 1)
+ TRANSMUTE(Spectator, this);
return true;
}
-void superspec_save_client_conf()
-{SELFPARAM();
+void superspec_save_client_conf(entity this)
+{
string fn = "superspec-local.options";
float fh;
- if (!_ISLOCAL(self))
+ if (!_ISLOCAL(this))
{
- if(self.crypto_idfp == "")
+ if(this.crypto_idfp == "")
return;
- fn = sprintf("superspec-%s.options", uri_escape(self.crypto_idfp));
+ fn = sprintf("superspec-%s.options", uri_escape(this.crypto_idfp));
}
fh = fopen(fn, FILE_WRITE);
{
fputs(fh, _SSMAGIX);
fputs(fh, "\n");
- fputs(fh, ftos(self.autospec_flags));
+ fputs(fh, ftos(this.autospec_flags));
fputs(fh, "\n");
- fputs(fh, ftos(self.superspec_flags));
+ fputs(fh, ftos(this.superspec_flags));
fputs(fh, "\n");
- fputs(fh, self.superspec_itemfilter);
+ fputs(fh, this.superspec_itemfilter);
fputs(fh, "\n");
fclose(fh);
}
superspec_msg("", "", it, sprintf("Player %s^7 just picked up ^3%s\n^8(%s^8)\n", toucher.netname, item.netname, item.classname), 1);
if((it.autospec_flags & ASF_SSIM) && it.enemy != toucher)
{
- WITHSELF(it, superspec_Spectate(toucher));
+ superspec_Spectate(it, toucher);
return MUT_ITEMTOUCH_CONTINUE;
}
}
if(it.autospec_flags & ASF_SHOWWHAT)
superspec_msg("", "", it, sprintf("^7Following %s^7 due to picking up %s\n", toucher.netname, item.netname), 2);
- WITHSELF(it, superspec_Spectate(toucher));
+ superspec_Spectate(it, toucher);
}
}
}
if(cmd_name == "followpowerup")
{
- FOREACH_CLIENT(IS_PLAYER(it) && (it.strength_finished > time || it.invincible_finished > time), LAMBDA(return superspec_Spectate(it)));
+ FOREACH_CLIENT(IS_PLAYER(it) && (it.strength_finished > time || it.invincible_finished > time), LAMBDA(return superspec_Spectate(player, it)));
superspec_msg("", "", player, "No active powerup\n", 1);
return true;
if(cmd_name == "followstrength")
{
- FOREACH_CLIENT(IS_PLAYER(it) && it.strength_finished > time, LAMBDA(return superspec_Spectate(it)));
+ FOREACH_CLIENT(IS_PLAYER(it) && it.strength_finished > time, LAMBDA(return superspec_Spectate(player, it)));
superspec_msg("", "", player, "No active Strength\n", 1);
return true;
if(cmd_name == "followshield")
{
- FOREACH_CLIENT(IS_PLAYER(it) && it.invincible_finished > time, LAMBDA(return superspec_Spectate(it)));
+ FOREACH_CLIENT(IS_PLAYER(it) && it.invincible_finished > time, LAMBDA(return superspec_Spectate(player, it)));
superspec_msg("", "", player, "No active Shield\n", 1);
return true;
void superspec_hello(entity this)
{
- if(self.enemy.crypto_idfp == "")
- Send_Notification(NOTIF_ONE_ONLY, self.enemy, MSG_INFO, INFO_SUPERSPEC_MISSING_UID);
+ if(this.enemy.crypto_idfp == "")
+ Send_Notification(NOTIF_ONE_ONLY, this.enemy, MSG_INFO, INFO_SUPERSPEC_MISSING_UID);
- remove(self);
+ remove(this);
}
MUTATOR_HOOKFUNCTION(superspec, ClientConnect)
if(it.autospec_flags & ASF_SHOWWHAT)
superspec_msg("", "", it, sprintf("^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
- WITHSELF(it, superspec_Spectate(frag_attacker));
+ superspec_Spectate(it, frag_attacker);
}
));
{
entity player = M_ARGV(0, entity);
- WITHSELF(player, superspec_save_client_conf());
+ superspec_save_client_conf(player);
}
#endif
bool WaypointSprite_SendEntity(entity this, entity to, float sendflags);
-void WaypointSprite_Reset()
-{SELFPARAM();
+void WaypointSprite_Reset(entity this)
+{
// if a WP wants to time out, let it time out immediately; other WPs ought to be reset/killed by their owners
- if (self.fade_time)
- WaypointSprite_Kill(self);
+ if (this.fade_time)
+ WaypointSprite_Kill(this);
}
entity WaypointSprite_Spawn(
bool WaypointSprite_SendEntity(entity this, entity to, float sendflags);
-void WaypointSprite_Reset();
+void WaypointSprite_Reset(entity this);
entity WaypointSprite_Spawn(
entity spr, // sprite
gamestart_use(this, NULL, NULL);
}
-void self_spawnfunc_trigger_gamestart();
+void self_spawnfunc_trigger_gamestart(entity this);
spawnfunc(trigger_gamestart)
{
this.use = gamestart_use;
else
InitializeEntity(this, gamestart_use_this, INITPRIO_FINDTARGET);
}
-void self_spawnfunc_trigger_gamestart() { SELFPARAM(); spawnfunc_trigger_gamestart(this); }
+void self_spawnfunc_trigger_gamestart(entity this) { WITHSELF(this, spawnfunc_trigger_gamestart(this)); }
#endif
// Waypoints and assault start come LAST
FOREACH_ENTITY_ORDERED(IS_NOT_A_CLIENT(it), {
- if (it.reset2) WITHSELF(it, it.reset2());
+ if (it.reset2) it.reset2(it);
});
FOREACH_CLIENT(IS_PLAYER(it) && STAT(FROZEN, it), LAMBDA(WITHSELF(it, Unfreeze(it))));
void SUB_UseTargets(entity this, entity actor, entity trigger);
.void(entity this) reset; // if set, an entity is reset using this
-.void() reset2; // if set, an entity is reset using this (after calling ALL the reset functions for other entities)
+.void(entity this) reset2; // if set, an entity is reset using this (after calling ALL the reset functions for other entities)
void ClientData_Touch(entity e);
{
assault_roundstart_use(this, NULL, NULL);
}
-void assault_roundstart_use_self()
-{
- SELFPARAM();
- assault_roundstart_use(this, NULL, NULL);
-}
void assault_wall_think(entity this)
{
assault_attacker_team = NUM_TEAM_1;
this.classname = "target_assault_roundstart";
this.use = assault_roundstart_use;
- this.reset2 = assault_roundstart_use_self;
+ this.reset2 = assault_roundstart_use_this;
InitializeEntity(this, assault_roundstart_use_this, INITPRIO_FINDTARGET);
}
M_ARGV(1, string) = ret_string;
}
-bool superspec_Spectate(entity _player); // TODO
+bool superspec_Spectate(entity this, entity targ); // TODO
void superspec_msg(string _center_title, string _con_title, entity _to, string _msg, float _spamlevel); // TODO
MUTATOR_HOOKFUNCTION(ctf, SV_ParseClientCommand)
{
found = true;
if(_team == 0 && IS_SPEC(player) && player.enemy == it)
continue; // already spectating this fc, try another
- return superspec_Spectate(it);
+ return superspec_Spectate(player, it);
}
));