drawsubpic(pos + eX * mySize.x - eX * min(mySize.x * 0.5, mySize.y), eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0.75 0 0', '0.25 1 0', color, theAlpha, drawflag);
}
-void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, bool vertical, bool icon_right_align, vector color, float theAlpha, float fadelerp)
+void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, bool vertical, int icon_right_align, vector color, float theAlpha, float fadelerp)
{
- TC(bool, vertical); TC(bool, icon_right_align);
+ TC(bool, vertical); TC(int, icon_right_align);
vector newPos = '0 0 0', newSize = '0 0 0';
vector picpos, numpos;
float HUD_GetRowCount(int item_count, vector size, float item_aspect);
vector HUD_Get_Num_Color (float x, float maxvalue);
void DrawNumIcon(vector myPos, vector mySize, float x, string icon, bool vertical, bool icon_right_align, vector color, float theAlpha);
-void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, bool vertical, bool icon_right_align, vector color, float theAlpha, float fadelerp);
+void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, bool vertical, int icon_right_align, vector color, float theAlpha, float fadelerp);
void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag);
vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect);
}
}
-void nb_delayedinit()
+void nb_delayedinit(entity this)
{
if(find(world, classname, "nexball_team") == world)
nb_spawnteams();
self.nextthink = time;
}
-void ons_DelayedLinkSetup()
-{SELFPARAM();
+void ons_DelayedLinkSetup(entity this)
+{
self.goalentity = find(world, targetname, self.target);
self.enemy = find(world, targetname, self.target2);
if(!self.goalentity) { objerror("can not find target\n"); }
CSQCMODEL_AUTOUPDATE(this);
}
-void ons_DelayedControlPoint_Setup()
-{SELFPARAM();
+void ons_DelayedControlPoint_Setup(entity this)
+{
onslaught_updatelinks();
// captureshield setup
onslaught_updatelinks();
}
-void ons_DelayedGeneratorSetup()
-{SELFPARAM();
+void ons_DelayedGeneratorSetup(entity this)
+{
// bot waypoints
waypoint_spawnforitem_force(self, self.origin);
self.nearestwaypointtimeout = 0; // activate waypointing again
return false;
}
-void ons_MonsterSpawn_Delayed()
-{SELFPARAM();
+void ons_MonsterSpawn_Delayed(entity this)
+{
entity e, own = self.owner;
if(!own) { remove(self); return; }
return false;
}
-void ons_TurretSpawn_Delayed()
-{SELFPARAM();
+void ons_TurretSpawn_Delayed(entity this)
+{
entity e, own = self.owner;
if(!own) { remove(self); return; }
ScoreRules_basics_end();
}
-void ons_DelayedInit() // Do this check with a delay so we can wait for teams to be set up
+void ons_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up
{
ons_ScoreRules();
#include <common/gamemodes/all.qh>
.float buff_time = _STAT(BUFF_TIME);
-void buffs_DelayedInit();
+void buffs_DelayedInit(entity this);
REGISTER_MUTATOR(buffs, cvar("g_buffs"))
{
return false;
}
-void buffs_DelayedInit()
+void buffs_DelayedInit(entity this)
{
if(autocvar_g_buffs_spawn_count > 0)
if(find(world, classname, "item_buff") == world)
REGISTER_NET_TEMP(TE_CSQC_SVNOTICE)
#ifdef SVQC
-void sv_notice_join_think()
+void sv_notice_join_think(entity this)
{
- SELFPARAM();
int argc = tokenizebyseparator(autocvar_sv_join_notices, "|");
if (argc <= 0) return;
for (int i = 0; i < argc; ++i)
}
void Item_Reset_self() { SELFPARAM(); Item_Reset(this); }
-void Item_FindTeam()
-{SELFPARAM();
+void Item_FindTeam(entity this)
+{
entity e;
if(self.effects & EF_NODRAW)
void Item_Reset(entity this);
-void Item_FindTeam();
+void Item_FindTeam(entity this);
// Savage: used for item garbage-collection
bool ItemSend(entity this, entity to, int sf);
#ifdef SVQC
void door_link();
#endif
-void LinkDoors()
-{SELFPARAM();
+void LinkDoors(entity this)
+{
entity t;
vector cmins, cmaxs;
}
#endif
-void door_init_startopen()
-{SELFPARAM();
+void door_init_startopen(entity this)
+{
SUB_SETORIGIN(self, self.pos2);
self.pos2 = self.pos1;
self.pos1 = self.origin;
this.drawmask = MASK_NORMAL;
this.use = door_use;
- LinkDoors();
+ LinkDoors(this);
if(this.spawnflags & DOOR_START_OPEN)
- door_init_startopen();
+ door_init_startopen(this);
this.move_time = time;
this.move_origin = this.origin;
this.nextthink = 0;
}
-void door_rotating_init_startopen()
-{SELFPARAM();
+void door_rotating_init_startopen(entity this)
+{
self.angles = self.movedir;
self.pos2 = '0 0 0';
self.pos1 = self.movedir;
#ifdef SVQC
void plat_link();
-void plat_delayedinit()
+void plat_delayedinit(entity this)
{
plat_link();
plat_spawn_inside_trigger(); // the "start moving" trigger
self.use = func_null; // not again
}
-void func_train_find()
-{SELFPARAM();
+void func_train_find(entity this)
+{
entity targ;
targ = find(world, targetname, self.target);
self.target = targ.target;
self.owner.velocity = (self.owner.destvec + func_vectormamamam_origin(self.owner, 0.1) - self.owner.origin) * 10;
}
-void func_vectormamamam_findtarget()
-{SELFPARAM();
+void func_vectormamamam_findtarget(entity this)
+{
if(self.target != "")
self.wp00 = find(world, targetname, self.target);
// the way this entity works makes it no use to CSQC, as it removes itself instantly
#ifdef SVQC
-void follow_init()
-{SELFPARAM();
+void follow_init(entity this)
+{
entity src, dst;
src = world;
dst = world;
}
}
-void misc_laser_init()
-{SELFPARAM();
+void misc_laser_init(entity this)
+{
if(self.target != "")
self.enemy = find(world, targetname, self.target);
}
}
}
-void target_spawn_spawnfirst()
-{SELFPARAM();
+void target_spawn_spawnfirst(entity this)
+{
activator = self.target_spawn_activator;
if(self.spawnflags & 2)
target_spawn_use();
return e;
}
-void teleport_findtarget()
+void teleport_findtarget(entity this)
{
- SELFPARAM();
int n = 0;
entity e;
for(e = world; (e = find(e, targetname, self.target)); )
void Teleport_Touch ();
-void teleport_findtarget();
+void teleport_findtarget(entity this);
entity Teleport_Find(vector mi, vector ma);
#ifdef SVQC
-void gamestart_use()
-{SELFPARAM();
+void gamestart_use(entity this)
+{
activator = self;
SUB_UseTargets();
remove(self);
void self_spawnfunc_trigger_gamestart();
spawnfunc(trigger_gamestart)
{
- this.use = gamestart_use;
+ setuse(this, gamestart_use);
this.reset2 = self_spawnfunc_trigger_gamestart;
if(this.wait)
#ifdef SVQC
void trigger_push_link();
-void trigger_push_updatelink();
+void trigger_push_updatelink(entity this);
#endif
-void trigger_push_findtarget()
-{SELFPARAM();
+void trigger_push_findtarget(entity this)
+{
entity t;
vector org;
return true;
}
-void trigger_push_updatelink()
-{SELFPARAM();
+void trigger_push_updatelink(entity this)
+{
this.SendFlags |= 1;
}
void trigger_push_touch();
.vector dest;
-void trigger_push_findtarget();
+void trigger_push_findtarget(entity this);
/*
* ENTITY PARAMETERS:
return true;
}
-void viewloc_init()
-{SELFPARAM();
+void viewloc_init(entity this)
+{
entity e;
for(e = world; (e = find(e, targetname, self.target)); )
if(e.classname == "target_viewlocation_start")
return turret_firecheck();
}
-void walker_melee_do_dmg()
-{SELFPARAM();
+void walker_melee_do_dmg(entity this)
+{
vector where;
entity e;
}
}
-void walker_setnoanim()
-{SELFPARAM();
+void walker_setnoanim(entity this)
+{
turrets_setframe(ANIM_NO, false);
self.animflag = self.frame;
}
SELFPARAM();
this.think = SUB_Remove_self;
this.nextthink = time;
- WITHSELF(this.owner, this.use());
+ WITHSELF(this.owner, this.selfthink(this));
}
-/*
- Execute func() after time + fdelay.
- self when func is executed = self when defer is called
-*/
- void defer(entity this, float fdelay, void() func)
+ /**
+ * Execute func() after time + fdelay.
+ * self when func is executed = self when defer is called
+ */
+ void defer(entity this, float fdelay, void(entity this) func)
{
entity e = new_pure(deferred);
e.owner = this;
- e.use = func;
+ setthink(e, func);
e.think = defer_think;
e.nextthink = time + fdelay;
}
#endif
// Step 6: Remove SELFPARAM in favor of a parameter
+
+.void(entity this) selftouch;
+void touch_self() { SELFPARAM(); this.selftouch(this); }
+#define settouch(e, f) (e.touch = touch_self, e.selftouch = f)
+
+.void(entity this) selfuse;
+void use_self() { SELFPARAM(); this.selfuse(this); }
+#define setuse(e, f) (e.use = use_self, e.selfuse = f)
+
+.void(entity this) selfthink;
+void think_self() { SELFPARAM(); this.selfthink(this); }
+#define setthink(e, f) (e.think = think_self, e.selfthink = f)
#ifdef SVQC
-void WarpZone_InitStep_FindOriginTarget()
-{SELFPARAM();
+void WarpZone_InitStep_FindOriginTarget(entity this)
+{
if(this.killtarget != "")
{
this.aiment = find(world, targetname, this.killtarget);
}
}
-void WarpZonePosition_InitStep_FindTarget()
-{SELFPARAM();
+void WarpZonePosition_InitStep_FindTarget(entity this)
+{
if(this.target == "")
{
error("Warp zone position with no target");
this.nextthink = time;
}
-void WarpZoneCamera_InitStep_FindTarget()
-{SELFPARAM();
+void WarpZoneCamera_InitStep_FindTarget(entity this)
+{
entity e;
float i;
if(this.target == "")
this.nextthink = 0;
}
-void WarpZone_InitStep_UpdateTransform()
-{SELFPARAM();
+void WarpZone_InitStep_UpdateTransform(entity this)
+{
vector org, ang, norm, point;
float area;
vector tri, a, b, c, n;
this.warpzone_angles = ang;
}
-void WarpZone_InitStep_ClearTarget()
-{SELFPARAM();
+void WarpZone_InitStep_ClearTarget(entity this)
+{
if(this.enemy)
this.enemy.enemy = world;
this.enemy = world;
}
entity warpzone_first; .entity warpzone_next;
-void WarpZone_InitStep_FindTarget()
-{SELFPARAM();
+void WarpZone_InitStep_FindTarget(entity this)
+{
float i;
entity e, e2;
}
void WarpZone_Think();
-void WarpZone_InitStep_FinalizeTransform()
-{SELFPARAM();
+void WarpZone_InitStep_FinalizeTransform(entity this)
+{
if(!this.enemy || this.enemy.enemy != this)
{
error("Invalid warp zone detected. Killed.");
warpzone_camera_first = this;
}
void WarpZones_Reconnect()
-{SELFPARAM();
- for(setself(warpzone_first); self; setself(self.warpzone_next))
- WarpZone_InitStep_ClearTarget();
- for(setself(warpzone_first); self; setself(self.warpzone_next))
- WarpZone_InitStep_FindTarget();
- for(setself(warpzone_camera_first); self; setself(self.warpzone_next))
- WarpZoneCamera_InitStep_FindTarget();
- for(setself(warpzone_first); self; setself(self.warpzone_next))
- WarpZone_InitStep_FinalizeTransform();
- setself(this);
+{
+ for(entity e = warpzone_first; e; e = e.warpzone_next)
+ WarpZone_InitStep_ClearTarget(e);
+ for(entity e = warpzone_first; e; e = e.warpzone_next)
+ WarpZone_InitStep_FindTarget(e);
+ for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
+ WarpZoneCamera_InitStep_FindTarget(e);
+ for(entity e = warpzone_first; e; e = e.warpzone_next)
+ WarpZone_InitStep_FinalizeTransform(e);
}
void WarpZone_Think()
{SELFPARAM();
- if(self.warpzone_save_origin != self.origin
- || self.warpzone_save_angles != self.angles
- || self.warpzone_save_eorigin != self.enemy.origin
- || self.warpzone_save_eangles != self.enemy.angles)
+ if(this.warpzone_save_origin != this.origin
+ || this.warpzone_save_angles != this.angles
+ || this.warpzone_save_eorigin != this.enemy.origin
+ || this.warpzone_save_eangles != this.enemy.angles)
{
- WarpZone_InitStep_UpdateTransform();
- setself(self.enemy);
- WarpZone_InitStep_UpdateTransform();
- setself(this);
- WarpZone_InitStep_FinalizeTransform();
- setself(self.enemy);
- WarpZone_InitStep_FinalizeTransform();
- setself(this);
- self.warpzone_save_origin = self.origin;
- self.warpzone_save_angles = self.angles;
- self.warpzone_save_eorigin = self.enemy.origin;
- self.warpzone_save_eangles = self.enemy.angles;
+ WarpZone_InitStep_UpdateTransform(this);
+ WarpZone_InitStep_UpdateTransform(this.enemy);
+ WarpZone_InitStep_FinalizeTransform(this);
+ WarpZone_InitStep_FinalizeTransform(this.enemy);
+ this.warpzone_save_origin = this.origin;
+ this.warpzone_save_angles = this.angles;
+ this.warpzone_save_eorigin = this.enemy.origin;
+ this.warpzone_save_eangles = this.enemy.angles;
}
- self.nextthink = time;
+ this.nextthink = time;
}
void WarpZone_StartFrame()
if (!warpzone_initialized)
{
warpzone_initialized = true;
- for (setself(warpzone_first); self; setself(self.warpzone_next))
- WarpZone_InitStep_FindOriginTarget();
- for (setself(warpzone_position_first); self; setself(self.warpzone_next))
- WarpZonePosition_InitStep_FindTarget();
- for (setself(warpzone_first); self; setself(self.warpzone_next))
- WarpZone_InitStep_UpdateTransform();
- setself(this);
+ for(entity e = warpzone_first; e; e = e.warpzone_next)
+ WarpZone_InitStep_FindOriginTarget(e);
+ for(entity e = warpzone_position_first; e; e = e.warpzone_next)
+ WarpZonePosition_InitStep_FindTarget(e);
+ for(entity e = warpzone_first; e; e = e.warpzone_next)
+ WarpZone_InitStep_UpdateTransform(e);
WarpZones_Reconnect();
WarpZone_PostInitialize_Callback();
}
entity oldother = other;
- FOREACH_ENTITY(true,
+ FOREACH_ENTITY(!is_pure(it),
{
if(warpzone_warpzones_exist)
WarpZone_StoreProjectileData(it);
}
void trigger_warpzone_reconnect_use()
{SELFPARAM();
- entity e;
- e = self;
// NOTE: this matches for target, not targetname, but of course
// targetname must be set too on the other entities
- for(setself(warpzone_first); self; setself(self.warpzone_next))
- self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && (visible_to_some_client(self) || visible_to_some_client(self.enemy))));
- for(setself(warpzone_camera_first); self; setself(self.warpzone_next))
- self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && visible_to_some_client(self)));
- for(setself(warpzone_first); self; setself(self.warpzone_next))
- if(self.warpzone_reconnecting)
- WarpZone_InitStep_ClearTarget();
- for(setself(warpzone_first); self; setself(self.warpzone_next))
- if(self.warpzone_reconnecting)
- WarpZone_InitStep_FindTarget();
- for(setself(warpzone_camera_first); self; setself(self.warpzone_next))
- if(self.warpzone_reconnecting)
- WarpZoneCamera_InitStep_FindTarget();
- for(setself(warpzone_first); self; setself(self.warpzone_next))
- if(self.warpzone_reconnecting || self.enemy.warpzone_reconnecting)
- WarpZone_InitStep_FinalizeTransform();
- setself(e);
+ for(entity e = warpzone_first; e; e = e.warpzone_next)
+ e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && (visible_to_some_client(e) || visible_to_some_client(e.enemy))));
+ for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
+ e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && visible_to_some_client(e)));
+ for(entity e = warpzone_first; e; e = e.warpzone_next)
+ if(e.warpzone_reconnecting)
+ WarpZone_InitStep_ClearTarget(e);
+ for(entity e = warpzone_first; e; e = e.warpzone_next)
+ if(e.warpzone_reconnecting)
+ WarpZone_InitStep_FindTarget(e);
+ for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
+ if(e.warpzone_reconnecting)
+ WarpZoneCamera_InitStep_FindTarget(e);
+ for(entity e = warpzone_first; e; e = e.warpzone_next)
+ if(e.warpzone_reconnecting || e.enemy.warpzone_reconnecting)
+ WarpZone_InitStep_FinalizeTransform(e);
}
spawnfunc(trigger_warpzone_reconnect)
break
float num_autoscreenshot;
-void info_autoscreenshot_findtarget()
-{SELFPARAM();
+void info_autoscreenshot_findtarget(entity this)
+{
entity e;
e = find(world, targetname, self.target);
if(!e)
setself(new(cheattriggerteleport));
setorigin(self, self.origin);
self.target = argv(1);
- teleport_findtarget();
+ teleport_findtarget(self);
if(!wasfreed(self))
{
Simple_TeleportPlayer(self, this);
self.nextthink = time + 0.1;
}
-void dynlight_find_aiment()
+void dynlight_find_aiment(entity this)
{
- SELFPARAM();
entity targ;
if (!self.target)
objerror ("dynlight: no target to follow");
self.think = dynlight_think;
self.nextthink = time + 0.1;
}
-void dynlight_find_path()
+void dynlight_find_path(entity this)
{
- SELFPARAM();
entity targ;
if (!self.target)
objerror ("dynlight: no target to follow");
self.think = train_next;
self.nextthink = time + 0.1;
}
-void dynlight_find_target()
+void dynlight_find_target(entity this)
{
- SELFPARAM();
entity targ;
if (!self.target)
objerror ("dynlight: no target to follow");
g_clientmodel_setcolormaptoactivator();
}
-void g_model_dropbyspawnflags()
-{SELFPARAM();
+void g_model_dropbyspawnflags(entity this)
+{
if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
{
traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
}
}
-void g_clientmodel_dropbyspawnflags()
-{SELFPARAM();
+void g_clientmodel_dropbyspawnflags(entity this)
+{
vector o0;
o0 = self.origin;
- g_model_dropbyspawnflags();
+ g_model_dropbyspawnflags(self);
if(self.origin != o0)
self.SendFlags |= 2;
}
this.modelindex = this.lodmodelindex0;
}
-void LODmodel_attach()
-{SELFPARAM();
+void LODmodel_attach(entity this)
+{
entity e;
if(!this.loddistance1)
void LOD_uncustomize();
-void LODmodel_attach();
+void LODmodel_attach(entity this);
void ApplyMinMaxScaleAngles(entity e);
builtin_remove(e);
}
-void InitializeEntity(entity e, void() func, float order)
+void InitializeEntity(entity e, void(entity this) func, float order)
{
entity prev, cur;
}
}
void InitializeEntitiesRun()
-{SELFPARAM();
+{
entity startoflist = initialize_entity_first;
initialize_entity_first = NULL;
remove = remove_except_protected;
e.initialize_entity_order = 0;
entity next = e.initialize_entity_next;
e.initialize_entity_next = NULL;
- var void() func = e.initialize_entity;
+ var void(entity this) func = e.initialize_entity;
e.initialize_entity = func_null;
if (e.classname == "initialize_entity")
{
//dprint("Delayed initialization: ", e.classname, "\n");
if (func)
{
- WITHSELF(e, func());
+ WITHSELF(e, func(e));
}
else
{
}
// deferred dropping
-void DropToFloor_Handler()
-{SELFPARAM();
+void DropToFloor_Handler(entity this)
+{
builtin_droptofloor();
self.dropped_origin = self.origin;
}
const float INITPRIO_LINKDOORS = 91;
const float INITPRIO_LAST = 99;
-.void() initialize_entity;
+.void(entity this) initialize_entity;
.float initialize_entity_order;
.entity initialize_entity_next;
entity initialize_entity_first;
float sound_allowed(float dest, entity e);
-void InitializeEntity(entity e, void() func, float order);
+void InitializeEntity(entity e, void(entity this) func, float order);
void SetCustomizer(entity e, float() customizer, void() uncustomizer);
}
}
-void assault_setenemytoobjective()
-{SELFPARAM();
+void assault_setenemytoobjective(entity this)
+{
entity objective;
for(objective = world; (objective = find(objective, targetname, self.target)); )
{
}
}
-void target_objective_decrease_findtarget()
+void target_objective_decrease_findtarget(entity this)
{
- assault_setenemytoobjective();
+ assault_setenemytoobjective(this);
}
void target_assault_roundend_reset(entity this)
self.winning = 1; // round has been won by attackers
}
-void assault_roundstart_use()
-{SELFPARAM();
+void assault_roundstart_use(entity this)
+{
activator = self;
SUB_UseTargets();
WITHSELF(it, turret_respawn());
));
}
+void assault_roundstart_use_self()
+{
+ SELFPARAM();
+ assault_roundstart_use(this);
+}
void assault_wall_think()
{SELFPARAM();
assault_attacker_team = NUM_TEAM_1;
self.classname = "target_assault_roundstart";
- self.use = assault_roundstart_use;
- self.reset2 = assault_roundstart_use;
+ self.use = assault_roundstart_use_self;
+ self.reset2 = assault_roundstart_use_self;
InitializeEntity(self, assault_roundstart_use, INITPRIO_FINDTARGET);
}
ctf_RespawnFlag(this);
}
-void ctf_DelayedFlagSetup() // called after a flag is placed on a map by ctf_FlagSetup()
-{SELFPARAM();
+void ctf_DelayedFlagSetup(entity this) // called after a flag is placed on a map by ctf_FlagSetup()
+{
// bot waypoints
waypoint_spawnforitem_force(self, self.origin);
self.nearestwaypointtimeout = 0; // activate waypointing again
WITHSELF(this, spawnfunc_ctf_team(this));
}
-void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to be set up.
+void ctf_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
{
ctf_teams = 2;
dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, SND_Null, "", "");
}
-void dom_DelayedInit() // Do this check with a delay so we can wait for teams to be set up.
+void dom_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
{
// if no teams are found, spawn defaults
if(find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2)
ScoreRules_basics_end();
}
-void invasion_DelayedInit() // Do this check with a delay so we can wait for teams to be set up.
+void invasion_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
{
if(autocvar_g_invasion_teams)
invasion_teams = bound(2, autocvar_g_invasion_teams, 4);
}
void ka_TouchEvent();
-void ka_RespawnBall() // runs whenever the ball needs to be relocated
-{SELFPARAM();
+void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
+{
if(gameover) { return; }
vector oldballorigin = self.origin;
self.angles = '0 0 0';
self.effects = autocvar_g_keepawayball_effects;
self.touch = ka_TouchEvent;
- self.think = ka_RespawnBall;
+ setthink(self, ka_RespawnBall);
self.nextthink = time + autocvar_g_keepawayball_respawntime;
Send_Effect(EFFECT_ELECTRO_COMBO, oldballorigin, '0 0 0', 1);
if(!self) { return; }
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
{ // The ball fell off the map, respawn it since players can't get to it
- ka_RespawnBall();
+ ka_RespawnBall(self);
return;
}
if(IS_DEAD(other)) { return; }
ball.movetype = MOVETYPE_BOUNCE;
ball.wait = time + 1;
ball.touch = ka_TouchEvent;
- ball.think = ka_RespawnBall;
+ setthink(ball, ka_RespawnBall);
ball.nextthink = time + autocvar_g_keepawayball_respawntime;
ball.takedamage = DAMAGE_YES;
ball.effects &= ~EF_NODRAW;
if(time < game_starttime)
{
- this.think = ka_RespawnBall;
+ setthink(this, ka_RespawnBall);
this.touch = func_null;
this.nextthink = game_starttime;
}
else
- ka_RespawnBall();
+ ka_RespawnBall(this);
}
int autocvar_g_tdm_point_limit;
int autocvar_g_tdm_point_leadlimit;
bool autocvar_g_tdm_team_spawns;
-void tdm_DelayedInit();
+void tdm_DelayedInit(entity this);
REGISTER_MUTATOR(tdm, false)
{
WITHSELF(this, spawnfunc_tdm_team(this));
}
-void tdm_DelayedInit()
+void tdm_DelayedInit(entity this)
{
// if no teams are found, spawn defaults
if(find(world, classname, "tdm_team") == world)
return false;
}
-float have_verified;
-void trigger_race_checkpoint_verify()
-{SELFPARAM();
- entity cp;
- float i, p;
- float qual;
-
- if(have_verified)
- return;
- have_verified = 1;
+void trigger_race_checkpoint_verify(entity this)
+{
+ static bool have_verified;
+ if (have_verified) return;
+ have_verified = true;
- qual = g_race_qualifying;
+ bool qual = g_race_qualifying;
- setself(spawn());
- TRANSMUTE(Player, self);
+ int pl_race_checkpoint = 0;
+ int pl_race_place = 0;
- if(g_race)
- {
- for(i = 0; i <= race_highest_checkpoint; ++i)
- {
- self.race_checkpoint = race_NextCheckpoint(i);
+ if (g_race) {
+ for (int i = 0; i <= race_highest_checkpoint; ++i) {
+ pl_race_checkpoint = race_NextCheckpoint(i);
// race only (middle of the race)
- g_race_qualifying = 0;
- self.race_place = 0;
- if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false))
- error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for respawning in race) - bailing out"));
+ g_race_qualifying = false;
+ pl_race_place = 0;
+ if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for respawning in race) - bailing out"));
+ }
- if(i == 0)
- {
+ if (i == 0) {
// qualifying only
g_race_qualifying = 1;
- self.race_place = race_lowest_place_spawn;
- if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false))
- error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out"));
+ pl_race_place = race_lowest_place_spawn;
+ if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out"));
+ }
// race only (initial spawn)
g_race_qualifying = 0;
- for(p = 1; p <= race_highest_place_spawn; ++p)
- {
- self.race_place = p;
- if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false))
- error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for initially spawning in race) - bailing out"));
+ for (int p = 1; p <= race_highest_place_spawn; ++p) {
+ pl_race_place = p;
+ if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for initially spawning in race) - bailing out"));
+ }
}
}
}
- }
- else if(!defrag_ents)
- {
+ } else if (!defrag_ents) {
// qualifying only
- self.race_checkpoint = race_NextCheckpoint(0);
+ pl_race_checkpoint = race_NextCheckpoint(0);
g_race_qualifying = 1;
- self.race_place = race_lowest_place_spawn;
- if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false))
- error(strcat("Checkpoint 0 misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out"));
- }
- else
- {
- self.race_checkpoint = race_NextCheckpoint(0);
+ pl_race_place = race_lowest_place_spawn;
+ if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ error(strcat("Checkpoint 0 misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out"));
+ }
+ } else {
+ pl_race_checkpoint = race_NextCheckpoint(0);
g_race_qualifying = 1;
- self.race_place = 0; // there's only one spawn on defrag maps
+ pl_race_place = 0; // there's only one spawn on defrag maps
// check if a defragcp file already exists, then read it and apply the checkpoint order
float fh;
string l;
defragcpexists = fh = fopen(strcat("maps/", GetMapname(), ".defragcp"), FILE_READ);
- if(fh >= 0)
- {
- while((l = fgets(fh)))
- {
+ if (fh >= 0) {
+ while ((l = fgets(fh))) {
len = tokenize_console(l);
- if(len != 2)
- {
+ if (len != 2) {
defragcpexists = -1; // something's wrong in the defrag cp file, set defragcpexists to -1 so that it will be rewritten when someone finishes
continue;
}
- for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
- if(argv(0) == cp.targetname)
+ for (entity cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
+ if (argv(0) == cp.targetname) {
cp.race_checkpoint = stof(argv(1));
+ }
+ }
}
fclose(fh);
}
g_race_qualifying = qual;
- if(race_timed_checkpoint)
- {
- if(defrag_ents)
- {
- for(cp = world; (cp = find(cp, classname, "target_startTimer"));)
+ if (race_timed_checkpoint) {
+ if (defrag_ents) {
+ for (entity cp = world; (cp = find(cp, classname, "target_startTimer"));) {
WaypointSprite_UpdateSprites(cp.sprite, WP_RaceStart, WP_Null, WP_Null);
- for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
+ }
+ for (entity cp = world; (cp = find(cp, classname, "target_stopTimer"));) {
WaypointSprite_UpdateSprites(cp.sprite, WP_RaceFinish, WP_Null, WP_Null);
-
- for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
- {
- if(cp.race_checkpoint == -2) // something's wrong with the defrag cp file or it has not been written yet, set defragcpexists to -1 so that it will be rewritten when someone finishes
+ }
+ for (entity cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
+ if (cp.race_checkpoint == -2) { // something's wrong with the defrag cp file or it has not been written yet, set defragcpexists to -1 so that it will be rewritten when someone finishes
defragcpexists = -1;
+ }
}
-
- if(defragcpexists != -1)
- {
+ if (defragcpexists != -1) {
float largest_cp_id = 0;
- for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
- if(cp.race_checkpoint > largest_cp_id)
+ for (entity cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
+ if (cp.race_checkpoint > largest_cp_id) {
largest_cp_id = cp.race_checkpoint;
- for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
+ }
+ }
+ for (entity cp = world; (cp = find(cp, classname, "target_stopTimer"));) {
cp.race_checkpoint = largest_cp_id + 1; // finish line
+ }
race_highest_checkpoint = largest_cp_id + 1;
race_timed_checkpoint = largest_cp_id + 1;
- }
- else
- {
- for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
+ } else {
+ for (entity cp = world; (cp = find(cp, classname, "target_stopTimer"));) {
cp.race_checkpoint = 255; // finish line
+ }
race_highest_checkpoint = 255;
race_timed_checkpoint = 255;
}
- }
- else
- {
- for(cp = world; (cp = find(cp, classname, "trigger_race_checkpoint")); )
- if(cp.sprite)
- {
- if(cp.race_checkpoint == 0)
+ } else {
+ for (entity cp = world; (cp = find(cp, classname, "trigger_race_checkpoint")); ) {
+ if (cp.sprite) {
+ if (cp.race_checkpoint == 0) {
WaypointSprite_UpdateSprites(cp.sprite, WP_RaceStart, WP_Null, WP_Null);
- else if(cp.race_checkpoint == race_timed_checkpoint)
+ } else if (cp.race_checkpoint == race_timed_checkpoint) {
WaypointSprite_UpdateSprites(cp.sprite, WP_RaceFinish, WP_Null, WP_Null);
+ }
}
+ }
}
}
- if(defrag_ents)
- {
- entity trigger, targ;
- for(trigger = world; (trigger = find(trigger, classname, "trigger_multiple")); )
- for(targ = world; (targ = find(targ, targetname, trigger.target)); )
- if (targ.classname == "target_checkpoint" || targ.classname == "target_startTimer" || targ.classname == "target_stopTimer")
- {
+ if (defrag_ents) {
+ for (entity trigger = world; (trigger = find(trigger, classname, "trigger_multiple")); ) {
+ for (entity targ = world; (targ = find(targ, targetname, trigger.target)); ) {
+ if (targ.classname == "target_checkpoint" || targ.classname == "target_startTimer" || targ.classname == "target_stopTimer") {
trigger.wait = 0;
trigger.delay = 0;
targ.wait = 0;
//setorigin(targ, trigger.origin);
//remove(trigger);
}
+ }
+ }
}
- remove(self);
- setself(this);
}
vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current)
.float delay;
// weapon remove ent from df
-void target_init_verify()
+void target_init_verify(entity this)
{
entity trigger, targ;
for(trigger = world; (trigger = find(trigger, classname, "trigger_multiple")); )
}
// weapon give ent from defrag
-void target_give_init()
-{SELFPARAM();
+void target_give_init(entity this)
+{
entity targ;
for (targ = world; (targ = find(targ, targetname, self.target)); ) {
if (targ.classname == "weapon_rocketlauncher" || targ.classname == "weapon_devastator") {
GameLogEcho(strcat(":team:", ftos(player_id), ":", ftos(team_number), ":", ftos(type)));
}
-void default_delayedinit()
+void default_delayedinit(entity this)
{
if(!scores_initialized)
ScoreRules_generic();
void LogTeamchange(float player_id, float team_number, float type);
-void default_delayedinit();
+void default_delayedinit(entity this);
void ActivateTeamplay();
#include "tests.qh"
-void test_weapons_hurt() {
- SELFPARAM();
+void test_weapons_hurt(entity this)
+{
EXPECT_NE(100, this.health);
remove(this.enemy);
remove(this);