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"); }
onslaught_updatelinks();
// Use targets now (somebody make sure this is in the right place..)
- setself(this.owner);
- activator = this;
- WITHSELF(this, SUB_UseTargets());
- setself(this);
+ SUB_UseTargets(this.owner, this, NULL);
this.owner.waslinked = this.owner.islinked;
if(this.owner.model != "models/onslaught/controlpoint_pad.md3")
if(!self.owner.islinked)
self.owner.team = 0;
- setself(self.owner);
- activator = self;
- SUB_UseTargets ();
- setself(this);
+ SUB_UseTargets(self.owner, self, NULL);
self.owner.team = t;
onslaught_updatelinks();
// Use targets now (somebody make sure this is in the right place..)
- setself(self.owner);
- activator = self;
- SUB_UseTargets ();
- setself(this);
+ SUB_UseTargets(self.owner, self, NULL);
self.SendFlags |= CPSF_SETUP;
}
onslaught_updatelinks();
- activator = this;
- SUB_UseTargets(); // to reset the structures, playerspawns etc.
+ SUB_UseTargets(this, this, NULL); // to reset the structures, playerspawns etc.
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();
- entity own = this.owner;
+ void ons_MonsterSpawn_Delayed(entity this)
+ {
- entity e, own = self.owner;
++ entity own = self.owner;
- if(!own) { remove(self); return; }
+ if(!own) { remove(this); return; }
if(own.targetname)
{
- e = find(world, target, own.targetname);
+ entity e = find(world, target, own.targetname);
if(e != world)
{
own.team = e.team;
- activator = e;
- own.use();
+ own.use1(own, e, NULL);
}
}
- remove(self);
+ remove(this);
}
MUTATOR_HOOKFUNCTION(ons, MonsterSpawn)
return false;
}
- void ons_TurretSpawn_Delayed()
- {SELFPARAM();
+ void ons_TurretSpawn_Delayed(entity this)
+ {
- entity e, own = self.owner;
+ entity own = self.owner;
if(!own) { remove(self); return; }
if(own.targetname)
{
- e = find(world, target, own.targetname);
+ entity e = find(world, target, own.targetname);
if(e != world)
{
own.team = e.team;
own.active = ACTIVE_NOT;
- activator = e;
- own.use();
+ own.use1(own, e, NULL);
}
}
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();
}
void Item_Reset_self() { SELFPARAM(); Item_Reset(this); }
- void Item_FindTeam()
- {SELFPARAM();
+ void Item_FindTeam(entity this)
+ {
entity e;
if(self.effects & EF_NODRAW)
// compatibility:
spawnfunc(item_quad) { this.classname = "item_strength";spawnfunc_item_strength(this);}
-void target_items_use()
-{SELFPARAM();
- if(activator.classname == "droppedweapon")
+void target_items_use(entity this, entity actor, entity trigger)
+{
+ other = trigger; // TODO
+
+ if(actor.classname == "droppedweapon")
{
EXACTTRIGGER_TOUCH;
- remove(activator);
+ remove(actor);
return;
}
- if (!IS_PLAYER(activator))
+ if (!IS_PLAYER(actor))
return;
- if(IS_DEAD(activator))
+ if(IS_DEAD(actor))
return;
EXACTTRIGGER_TOUCH;
- FOREACH_ENTITY_ENT(enemy, activator,
+ FOREACH_ENTITY_ENT(enemy, actor,
{
if(it.classname == "droppedweapon")
remove(it);
});
- if(GiveItems(activator, 0, tokenize_console(self.netname)))
- centerprint(activator, self.message);
+ if(GiveItems(actor, 0, tokenize_console(this.netname)))
+ centerprint(actor, this.message);
}
spawnfunc(target_items)
float n, i;
string s;
- self.use = target_items_use;
+ self.use1 = target_items_use;
if(!self.strength_finished)
self.strength_finished = autocvar_g_balance_powerup_strength_time;
if(!self.invincible_finished)
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);
void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter);
-void target_items_use ();
-
float GiveWeapon(entity e, float wpn, float op, float val);
float GiveBit(entity e, .float fld, float bit, float op, float val);
string oldmessage;
oldmessage = self.message;
self.message = "";
- SUB_UseTargets();
+ SUB_UseTargets(self, NULL, NULL);
self.message = oldmessage;
}
return false;
}
-void door_fire()
-{SELFPARAM();
- entity starte;
-
- if (self.owner != self)
- objerror ("door_fire: self.owner != self");
+void door_fire(entity this, entity actor, entity trigger)
+{
+ entity starte;
+ if (this.owner != this)
+ objerror ("door_fire: this.owner != this");
- if (self.spawnflags & DOOR_TOGGLE)
+ if (this.spawnflags & DOOR_TOGGLE)
{
- if (self.state == STATE_UP || self.state == STATE_TOP)
+ if (this.state == STATE_UP || this.state == STATE_TOP)
{
starte = self;
do
setself(this);
}
-void door_use()
-{SELFPARAM();
+void door_use(entity this, entity actor, entity trigger)
+{
//dprint("door_use (model: ");dprint(self.model);dprint(")\n");
- if (self.owner)
- {
- WITHSELF(self.owner, door_fire());
- }
+ if (this.owner)
+ WITHSELF(this.owner, door_fire(this.owner, actor, trigger));
}
void door_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
{
this.owner.health = this.owner.max_health;
this.owner.takedamage = DAMAGE_NO; // wil be reset upon return
- WITHSELF(this.owner, door_use());
+ door_use(this.owner, NULL, NULL);
}
}
string oldmessage;
oldmessage = self.message;
self.message = "";
- SUB_UseTargets();
+ SUB_UseTargets(self, NULL, other); // TODO: is other needed here?
self.message = oldmessage;
}
self.door_finished = time + 1;
- activator = other;
-
- setself(self.owner);
- door_use ();
+ door_use(this.owner, other, NULL);
}
void door_spawnfield(vector fmins, vector fmaxs)
#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;
precache_sound(self.noise3);
self.blocked = door_blocked;
- self.use = door_use;
+ self.use1 = door_use;
if(self.dmg && (self.message == ""))
self.message = "was squished";
this.trigger_touch = door_touch;
this.draw = door_draw;
this.drawmask = MASK_NORMAL;
- this.use = door_use;
+ this.use1 = 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;
self.classname = "door_rotating";
self.blocked = door_blocked;
- self.use = door_use;
+ self.use1 = door_use;
if(self.spawnflags & 8)
self.dmg = 10000;
#ifdef SVQC
void plat_link();
- void plat_delayedinit()
+ void plat_delayedinit(entity this)
{
plat_link();
plat_spawn_inside_trigger(); // the "start moving" trigger
this.movetype = MOVETYPE_PUSH;
this.drawmask = MASK_NORMAL;
this.draw = plat_draw;
- this.use = plat_use;
+ this.use1 = plat_use;
this.entremove = trigger_remove_generic;
plat_reset(this); // also called here
.float train_wait_turning;
void() train_next;
#ifdef SVQC
-void train_use();
+void train_use(entity this, entity actor, entity trigger);
#endif
void train_wait()
{SELFPARAM();
- WITHSELF(self.enemy, SUB_UseTargets());
+ SUB_UseTargets(this.enemy, NULL, NULL);
self.enemy = world;
// if turning is enabled, the train will turn toward the next point while waiting
entity tg = find(world, targetname, self.target);
if(tg.spawnflags & 4)
{
- self.use = train_use;
+ self.use1 = train_use;
self.SUB_THINK = func_null;
self.SUB_NEXTTHINK = 0;
}
//Net_LinkEntity(self, 0, false, train_send);
}
-void train_use()
+void train_use(entity this, entity actor, entity trigger)
{
- SELFPARAM();
- self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
- self.SUB_THINK = train_next;
- self.use = func_null; // not again
+ this.SUB_NEXTTHINK = this.SUB_LTIME + 1;
+ this.SUB_THINK = train_next;
+ this.use1 = 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.effects |= EF_LOWPRECISION;
if(self.spawnflags & 4)
- self.use = train_use;
+ self.use1 = train_use;
if (self.spawnflags & 2)
{
#ifdef SVQC
.float modelscale;
-void misc_laser_aim()
-{SELFPARAM();
+void misc_laser_aim(entity this)
+{
vector a;
- if(self.enemy)
+ if(this.enemy)
{
- if(self.spawnflags & 2)
+ if(this.spawnflags & 2)
{
- if(self.enemy.origin != self.mangle)
+ if(this.enemy.origin != this.mangle)
{
- self.mangle = self.enemy.origin;
- self.SendFlags |= 2;
+ this.mangle = this.enemy.origin;
+ this.SendFlags |= 2;
}
}
else
{
- a = vectoangles(self.enemy.origin - self.origin);
+ a = vectoangles(this.enemy.origin - this.origin);
a_x = -a_x;
- if(a != self.mangle)
+ if(a != this.mangle)
{
- self.mangle = a;
- self.SendFlags |= 2;
+ this.mangle = a;
+ this.SendFlags |= 2;
}
}
}
else
{
- if(self.angles != self.mangle)
+ if(this.angles != this.mangle)
{
- self.mangle = self.angles;
- self.SendFlags |= 2;
+ this.mangle = this.angles;
+ this.SendFlags |= 2;
}
}
- if(self.origin != self.oldorigin)
+ if(this.origin != this.oldorigin)
{
- self.SendFlags |= 1;
- self.oldorigin = self.origin;
+ this.SendFlags |= 1;
+ this.oldorigin = this.origin;
}
}
- void misc_laser_init()
- {SELFPARAM();
+ void misc_laser_init(entity this)
+ {
if(self.target != "")
self.enemy = find(world, targetname, self.target);
}
if(!self.state)
return;
- misc_laser_aim();
+ misc_laser_aim(this);
if(self.enemy)
{
{
self.count = 1;
- activator = self.enemy.pusher;
- WITHSELF(self.enemy, SUB_UseTargets());
+ SUB_UseTargets(self.enemy, self.enemy.pusher, NULL);
}
}
else
{
self.count = 0;
- activator = self.enemy.pusher;
- WITHSELF(self.enemy, SUB_UseTargets());
+ SUB_UseTargets(self.enemy, self.enemy.pusher, NULL);
}
}
}
"dmg"
damage per second (-1 for a laser that kills immediately)
*/
-void laser_use()
-{SELFPARAM();
- self.state = !self.state;
- self.SendFlags |= 4;
- misc_laser_aim();
+void laser_use(entity this, entity actor, entity trigger)
+{
+ this.state = !this.state;
+ this.SendFlags |= 4;
+ misc_laser_aim(this);
}
void laser_reset(entity this)
{
this.reset = laser_reset;
this.reset(this);
- this.use = laser_use;
+ this.use1 = laser_use;
}
else
this.state = 1;
setsize(self, self.mins, self.maxs);
}
-void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity t3, entity t4, entity act)
-{SELFPARAM();
+void target_spawn_edit_entity(entity this, entity e, string msg, entity kt, entity t2, entity t3, entity t4, entity act, entity trigger)
+{
float i, n, valuefieldpos;
string key, value, valuefield, valueoffset, valueoffsetrandom;
entity valueent;
vector data, data2;
- entity oldactivator;
n = tokenize_console(msg);
if(value == "self")
{
- valueent = self;
+ valueent = this;
value = "";
}
else if(value == "activator")
}
else if(value == "other")
{
- valueent = other;
+ valueent = trigger;
value = "";
}
else if(value == "pusher")
value = strcat("target_spawn_helper", value);
putentityfieldstring(target_spawn_spawnfunc_field, e, value);
- oldactivator = activator;
-
- activator = act;
WITHSELF(e, e.target_spawn_spawnfunc(e));
- activator = oldactivator;
// We called an external function, so we have to re-tokenize msg.
n = tokenize_console(msg);
}
}
-void target_spawn_useon(entity e)
-{SELFPARAM();
- self.target_spawn_activator = activator;
+void target_spawn_useon(entity e, entity this, entity actor, entity trigger)
+{
+ this.target_spawn_activator = actor;
target_spawn_edit_entity(
+ this,
e,
- self.message,
- find(world, targetname, self.killtarget),
- find(world, targetname, self.target2),
- find(world, targetname, self.target3),
- find(world, targetname, self.target4),
- activator
+ this.message,
+ find(world, targetname, this.killtarget),
+ find(world, targetname, this.target2),
+ find(world, targetname, this.target3),
+ find(world, targetname, this.target4),
+ actor,
+ trigger
);
}
-float target_spawn_cancreate()
-{SELFPARAM();
+bool target_spawn_cancreate(entity this)
+{
float c;
entity e;
- c = self.count;
+ c = this.count;
if(c == 0) // no limit?
- return 1;
+ return true;
++c; // increase count to not include MYSELF
- for(e = world; (e = findfloat(e, target_spawn_id, self.target_spawn_id)); --c)
+ for(e = world; (e = findfloat(e, target_spawn_id, this.target_spawn_id)); --c)
;
// if c now is 0, we have AT LEAST the given count (maybe more), so don't spawn any more
if(c == 0)
- return 0;
- return 1;
+ return false;
+ return true;
}
-void target_spawn_use()
-{SELFPARAM();
- entity e;
-
- if(self.target == "")
+void target_spawn_use(entity this, entity actor, entity trigger)
+{
+ if(this.target == "")
{
// spawn new entity
- if(!target_spawn_cancreate())
+ if(!target_spawn_cancreate(this))
return;
- e = spawn();
+ entity e = spawn();
e.spawnfunc_checked = true;
- target_spawn_useon(e);
- e.target_spawn_id = self.target_spawn_id;
+ target_spawn_useon(e, this, actor, trigger);
+ e.target_spawn_id = this.target_spawn_id;
}
- else if(self.target == "*activator")
+ else if(this.target == "*activator")
{
// edit entity
- if(activator)
- target_spawn_useon(activator);
+ if(actor)
+ target_spawn_useon(actor, this, actor, trigger);
}
else
{
// edit entity
- for(e = world; (e = find(e, targetname, self.target)); )
- target_spawn_useon(e);
+ for(entity e = world; (e = find(e, targetname, this.target)); )
+ target_spawn_useon(e, this, actor, trigger);
}
}
- void target_spawn_spawnfirst()
- {SELFPARAM();
- entity act = self.target_spawn_activator;
- if(self.spawnflags & 2)
+ void target_spawn_spawnfirst(entity this)
+ {
- activator = self.target_spawn_activator;
- if(self.spawnflags & 2)
- target_spawn_use();
++ entity act = this.target_spawn_activator;
++ if(this.spawnflags & 2)
+ target_spawn_use(this, act, NULL);
}
void initialize_field_db()
spawnfunc(target_spawn)
{
initialize_field_db();
- self.use = target_spawn_use;
+ self.use1 = target_spawn_use;
self.message = strzone(strreplace("'", "\"", self.message));
self.target_spawn_id = ++target_spawn_count;
InitializeEntity(self, target_spawn_spawnfirst, INITPRIO_LAST);
void Teleport_Touch ();
- void teleport_findtarget();
+ void teleport_findtarget(entity this);
entity Teleport_Find(vector mi, vector ma);
#ifdef SVQC
-void trigger_teleport_use();
+void trigger_teleport_use(entity this, entity actor, entity trigger);
#define TDEATHLOOP(o) \
entity head; \
#include "jumppads.qh"
#include <common/physics/movetypes/movetypes.qh>
-void trigger_push_use()
-{SELFPARAM();
+void trigger_push_use(entity this, entity actor, entity trigger)
+{
if(teamplay)
{
- self.team = activator.team;
- self.SendFlags |= 2;
+ this.team = actor.team;
+ this.SendFlags |= 2;
}
}
#endif
}
if(this.enemy.target)
- {
- activator = other;
- WITHSELF(this.enemy, SUB_UseTargets());
- }
+ SUB_UseTargets(this.enemy, other, other); // TODO: do we need other as trigger too?
if (other.flags & FL_PROJECTILE)
{
#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;
}
trigger_init(this);
this.active = ACTIVE_ACTIVE;
- this.use = trigger_push_use;
+ this.use1 = trigger_push_use;
this.touch = trigger_push_touch;
// normal push setup
float trigger_push_calculatevelocity_flighttime;
#ifdef SVQC
-void() SUB_UseTargets;
-void trigger_push_use();
+void SUB_UseTargets(entity this, entity actor, entity trigger);
+void trigger_push_use(entity this, entity actor, entity trigger);
#endif
/*
void trigger_push_touch();
.vector dest;
- void trigger_push_findtarget();
+ void trigger_push_findtarget(entity this);
/*
* ENTITY PARAMETERS:
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;
}
this.velocity = this.velocity + vforce;
if (this.health <= 0)
- WITHSELF(this, W_PrepareExplosionByDamage(this.owner, walker_rocket_explode));
+ W_PrepareExplosionByDamage(this, this.owner, walker_rocket_explode);
}
#define WALKER_ROCKET_MOVE movelib_move_simple(self, newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(self)
if (self.pathgoal)
{
- if (self.pathgoal.use)
- self.pathgoal.use();
+ if (self.pathgoal.use1)
+ self.pathgoal.use1(self, NULL, NULL);
if (self.pathgoal.enemy)
{
#endif
// Step 6: Remove SELFPARAM in favor of a parameter
-.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) 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)
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)
IS_CHEAT(0, argc, 0);
setself(spawn());
self.target = argv(1);
- activator = this;
- SUB_UseTargets();
+ SUB_UseTargets(self, this, NULL);
remove(self);
setself(this);
DID_CHEAT();
IS_CHEAT(0, argc, 0);
setself(spawn());
self.killtarget = argv(1);
- activator = this;
- SUB_UseTargets();
+ SUB_UseTargets(self, this, NULL);
remove(self);
setself(this);
DID_CHEAT();
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");
self.think = dynlight_think;
self.nextthink = time + 0.1;
}
-void dynlight_use()
+void dynlight_use(entity this, entity actor, entity trigger)
{
- SELFPARAM();
- if (self.light_lev == 0)
- self.light_lev = self.lefty;
+ if (this.light_lev == 0)
+ this.light_lev = this.lefty;
else
- self.light_lev = 0;
+ this.light_lev = 0;
}
spawnfunc(dynlight)
{
if (!self.color)
self.color = '1 1 1';
self.lefty = self.light_lev;
- self.use = dynlight_use;
+ self.use1 = dynlight_use;
setsize (self, '0 0 0', '0 0 0');
setorigin (self, self.origin);
//self.pflags = PFLAGS_FULLDYNAMIC;
.float modelscale;
-void g_model_setcolormaptoactivator ()
-{SELFPARAM();
+void g_model_setcolormaptoactivator(entity this, entity actor, entity trigger)
+{
if(teamplay)
{
- if(activator.team)
- self.colormap = (activator.team - 1) * 0x11;
+ if(actor.team)
+ this.colormap = (actor.team - 1) * 0x11;
else
- self.colormap = 0x00;
+ this.colormap = 0x00;
}
else
- self.colormap = floor(random() * 256);
- self.colormap |= BIT(10); // RENDER_COLORMAPPED
+ this.colormap = floor(random() * 256);
+ this.colormap |= BIT(10); // RENDER_COLORMAPPED
}
-void g_clientmodel_setcolormaptoactivator ()
-{SELFPARAM();
- g_model_setcolormaptoactivator();
- self.SendFlags |= (BIT(3) | BIT(0));
+void g_clientmodel_setcolormaptoactivator(entity this, entity actor, entity trigger)
+{
+ g_model_setcolormaptoactivator(this, actor, trigger);
+ this.SendFlags |= (BIT(3) | BIT(0));
}
-void g_clientmodel_use()
-{SELFPARAM();
- if (self.antiwall_flag == 1)
+void g_clientmodel_use(entity this, entity actor, entity trigger)
+{
+ if (this.antiwall_flag == 1)
{
- self.inactive = 1;
- self.solid = SOLID_NOT;
+ this.inactive = 1;
+ this.solid = SOLID_NOT;
}
- else if (self.antiwall_flag == 2)
+ else if (this.antiwall_flag == 2)
{
- self.inactive = 0;
- self.solid = self.default_solid;
+ this.inactive = 0;
+ this.solid = this.default_solid;
}
- g_clientmodel_setcolormaptoactivator();
+ g_clientmodel_setcolormaptoactivator(this, actor, trigger);
}
- 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;
}
if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
if(!self.scale) self.scale = self.modelscale; \
SetBrushEntityModel(); \
- self.use = g_model_setcolormaptoactivator; \
+ self.use1 = g_model_setcolormaptoactivator; \
InitializeEntity(self, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT;
if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
if(!self.scale) self.scale = self.modelscale; \
SetBrushEntityModel(); \
- self.use = g_clientmodel_use; \
+ self.use1 = g_clientmodel_use; \
InitializeEntity(self, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \
if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \
void() SUB_CalcMoveDone;
void() SUB_CalcAngleMoveDone;
-//void() SUB_UseTargets;
spawnfunc(info_null);
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
{
void adaptor_think2use()
{SELFPARAM();
- entity o, a;
- o = other;
- a = activator;
- activator = world;
- other = world;
- self.use();
- other = o;
- activator = a;
+ if(this.use1)
+ this.use1(this, NULL, NULL);
}
void adaptor_think2use_hittype_splash() // for timed projectile detonation
{SELFPARAM();
- if(!(IS_ONGROUND(self))) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING
- self.projectiledeathtype |= HITTYPE_SPLASH;
- adaptor_think2use();
+ if(!(IS_ONGROUND(this))) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING
+ this.projectiledeathtype |= HITTYPE_SPLASH;
+ WITHSELF(this, adaptor_think2use());
}
// deferred dropping
- void DropToFloor_Handler()
- {SELFPARAM();
+ void DropToFloor_Handler(entity this)
+ {
builtin_droptofloor();
self.dropped_origin = self.origin;
}
const float SP_ASSAULT_OBJECTIVES = 4;
// predefined spawnfuncs
-void target_objective_decrease_activate();
+void target_objective_decrease_activate(entity this);
#endif
#ifdef IMPLEMENTATION
.entity sprite;
// random functions
-void assault_objective_use()
-{SELFPARAM();
+void assault_objective_use(entity this, entity actor, entity trigger)
+{
// activate objective
- self.health = 100;
- //print("^2Activated objective ", self.targetname, "=", etos(self), "\n");
- //print("Activator is ", activator.classname, "\n");
+ this.health = 100;
+ //print("^2Activated objective ", this.targetname, "=", etos(this), "\n");
+ //print("Activator is ", actor.classname, "\n");
for (entity e = world; (e = find(e, target, this.targetname)); )
{
if (e.classname == "target_objective_decrease")
{
- WITHSELF(e, target_objective_decrease_activate());
+ target_objective_decrease_activate(e);
}
}
-
- setself(this);
}
vector target_objective_spawn_evalfunc(entity player, entity spot, vector current)
}
// decrease the health of targeted objectives
-void assault_objective_decrease_use()
-{SELFPARAM();
- if(activator.team != assault_attacker_team)
+void assault_objective_decrease_use(entity this, entity actor, entity trigger)
+{
+ if(actor.team != assault_attacker_team)
{
// wrong team triggered decrease
return;
{
if(self.enemy.health - self.dmg > 0.5)
{
- PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.dmg);
+ PlayerTeamScore_Add(actor, SP_SCORE, ST_SCORE, self.dmg);
self.enemy.health = self.enemy.health - self.dmg;
}
else
{
- PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.enemy.health);
- PlayerTeamScore_Add(activator, SP_ASSAULT_OBJECTIVES, ST_ASSAULT_OBJECTIVES, 1);
+ PlayerTeamScore_Add(actor, SP_SCORE, ST_SCORE, self.enemy.health);
+ PlayerTeamScore_Add(actor, SP_ASSAULT_OBJECTIVES, ST_ASSAULT_OBJECTIVES, 1);
self.enemy.health = -1;
- entity oldactivator;
+ if(this.enemy.message)
+ FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(centerprint(it, this.enemy.message)));
- setself(this.enemy);
- if(self.message)
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(centerprint(it, self.message)));
-
- oldactivator = activator;
- activator = this;
- SUB_UseTargets();
- activator = oldactivator;
- setself(this);
+ SUB_UseTargets(this.enemy, this, trigger);
}
}
}
- void assault_setenemytoobjective()
- {SELFPARAM();
+ void assault_setenemytoobjective(entity this)
+ {
entity objective;
for(objective = world; (objective = find(objective, targetname, self.target)); )
{
return true;
}
-void target_objective_decrease_activate()
-{SELFPARAM();
+void target_objective_decrease_activate(entity this)
+{
entity ent, spr;
- self.owner = world;
- for(ent = world; (ent = find(ent, target, self.targetname)); )
+ this.owner = world;
+ for(ent = world; (ent = find(ent, target, this.targetname)); )
{
if(ent.assault_sprite != world)
{
}
spr = WaypointSprite_SpawnFixed(WP_Assault, 0.5 * (ent.absmin + ent.absmax), ent, assault_sprite, RADARICON_OBJECTIVE);
- spr.assault_decreaser = self;
+ spr.assault_decreaser = this;
spr.waypointsprite_visible_for_player = assault_decreaser_sprite_visible;
spr.classname = "sprite_waypoint";
WaypointSprite_UpdateRule(spr, assault_attacker_team, SPRITERULE_TEAMPLAY);
}
}
- void target_objective_decrease_findtarget()
+ void target_objective_decrease_findtarget(entity this)
{
- assault_setenemytoobjective();
+ assault_setenemytoobjective(this);
}
void target_assault_roundend_reset(entity this)
this.winning = false; // up round
}
-void target_assault_roundend_use()
-{SELFPARAM();
- self.winning = 1; // round has been won by attackers
+void target_assault_roundend_use(entity this, entity actor, entity trigger)
+{
+ this.winning = 1; // round has been won by attackers
}
-void assault_roundstart_use(entity this)
+void assault_roundstart_use(entity this, entity actor, entity trigger)
{
- activator = self;
- SUB_UseTargets();
+ SUB_UseTargets(this, this, trigger);
//(Re)spawn all turrets
FOREACH_ENTITY_CLASS("turret_main", true, LAMBDA(
WITHSELF(it, turret_respawn());
));
}
- assault_roundstart_use(this);
+ void assault_roundstart_use_self()
+ {
+ SELFPARAM();
++ assault_roundstart_use(this, NULL, NULL);
+ }
void assault_wall_think()
{SELFPARAM();
if (!g_assault) { remove(this); return; }
this.classname = "target_objective";
- this.use = assault_objective_use;
+ this.use1 = assault_objective_use;
this.reset = assault_objective_reset;
this.reset(this);
this.spawn_evalfunc = target_objective_spawn_evalfunc;
if(!self.dmg)
self.dmg = 101;
- self.use = assault_objective_decrease_use;
+ self.use1 = assault_objective_decrease_use;
self.health = ASSAULT_VALUE_INACTIVE;
self.max_health = ASSAULT_VALUE_INACTIVE;
self.enemy = world;
self.winning = 0; // round not yet won by attackers
self.classname = "target_assault_roundend";
- self.use = target_assault_roundend_use;
+ self.use1 = target_assault_roundend_use;
self.cnt = 0; // first round
self.reset = target_assault_roundend_reset;
}
assault_attacker_team = NUM_TEAM_1;
self.classname = "target_assault_roundstart";
- self.use1 = assault_roundstart_use;
- self.reset2 = adaptor_think2use;
- InitializeEntity(self, adaptor_think2use, INITPRIO_FINDTARGET);
- self.use = assault_roundstart_use_self;
++ self.use = assault_roundstart_use;
+ self.reset2 = assault_roundstart_use_self;
- InitializeEntity(self, assault_roundstart_use, INITPRIO_FINDTARGET);
++ InitializeEntity(self, assault_roundstart_use_self, INITPRIO_FINDTARGET);
}
// legacy bot code
old_team = self.team;
self.team = real_team;
self.delay = 0;
- activator = self;
- SUB_UseTargets ();
+ SUB_UseTargets (self, self, NULL);
self.delay = old_delay;
self.team = old_team;
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)
*/
if (!((self.spawnflags & 2) && (IS_PLAYER(other))))
{
- activator = other;
oldmsg = self.message;
self.message = "";
- SUB_UseTargets();
+ SUB_UseTargets(self, other, other); // TODO: should we be using other for the trigger here?
self.message = oldmsg;
}
*/
if(self.spawnflags & 2)
{
- activator = other;
oldmsg = self.message;
self.message = "";
- SUB_UseTargets();
+ SUB_UseTargets(self, other, other); // TODO: should we be using other for the trigger here?
self.message = oldmsg;
}
checkpoint_passed();
}
-void checkpoint_use()
+void checkpoint_use(entity this, entity actor, entity trigger)
{
- if(other.classname == "info_player_deathmatch") // a spawn, a spawn
+ if(trigger.classname == "info_player_deathmatch") // a spawn, a spawn
return;
- other = activator;
+ other = actor;
checkpoint_passed();
}
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)
EXACTTRIGGER_INIT;
- self.use = checkpoint_use;
+ self.use1 = checkpoint_use;
if (!(self.spawnflags & 1))
self.touch = checkpoint_touch;
EXACTTRIGGER_INIT;
- self.use = checkpoint_use;
+ self.use1 = checkpoint_use;
if (!(self.spawnflags & 1))
self.touch = checkpoint_touch;
}
}
-void penalty_use()
-{SELFPARAM();
- race_ImposePenaltyTime(activator, self.race_penalty, self.race_penalty_reason);
+void penalty_use(entity this, entity actor, entity trigger)
+{
+ race_ImposePenaltyTime(actor, this.race_penalty, this.race_penalty_reason);
}
spawnfunc(trigger_race_penalty)
EXACTTRIGGER_INIT;
- self.use = penalty_use;
+ self.use1 = penalty_use;
if (!(self.spawnflags & 1))
self.touch = penalty_touch;