Smooth selection change in the weapons panel, optionally with a nice lens effect
See merge request !321
entity announcer_countdown;
-void Announcer_Countdown()
+void Announcer_Countdown(entity this)
{
- SELFPARAM();
float starttime = STAT(GAMESTARTTIME);
float roundstarttime = STAT(ROUNDSTARTTIME);
if(roundstarttime == -1)
if (!announcer_countdown)
{
announcer_countdown = new(announcer_countdown);
- announcer_countdown.think = Announcer_Countdown;
+ setthink(announcer_countdown, Announcer_Countdown);
}
if(time + 5.0 < startTime) // if connecting to server while restart was active don't always play prepareforbattle
float autocvar_cl_hitsound_nom_damage = 25;
float autocvar_cl_hitsound_antispam_time;
int autocvar_cl_eventchase_death = 1;
-int autocvar_cl_eventchase_nexball = 1;
vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
float autocvar_cl_eventchase_generator_distance = 400;
float autocvar_cl_eventchase_distance = 140;
return false;
}
-void Playerchecker_Think()
+void Playerchecker_Think(entity this)
{
- SELFPARAM();
int i;
entity e;
for(i = 0; i < maxclients; ++i)
void PostInit()
{
entity playerchecker = new_pure(playerchecker);
- playerchecker.think = Playerchecker_Think;
+ setthink(playerchecker, Playerchecker_Think);
playerchecker.nextthink = time + 0.2;
TrueAim_Init();
// --------------------------------------------------------------------------
// BEGIN OPTIONAL CSQC FUNCTIONS
-.void(entity) predraw_qc;
-void PreDraw_self()
-{
- SELFPARAM();
- if (this.predraw_qc) this.predraw_qc(this);
-}
-
-void setpredraw(entity this, void(entity) pdfunc)
-{
- this.predraw = PreDraw_self;
- this.predraw_qc = pdfunc;
-}
-
void Ent_Remove(entity this);
void Ent_RemovePlayerScore(entity this)
keys = db_get(binddb, command);
if (keys == "")
{
+ bool joy_detected = cvar("joy_detected");
n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
for(j = 0; j < n; ++j)
{
k = stof(argv(j));
if(k != -1)
{
- if ("" == keys)
- keys = keynumtostring(k);
+ string key = keynumtostring(k);
+ if(!joy_detected && substring(key, 0, 3) == "JOY")
+ continue;
+
+ if (keys == "")
+ keys = key;
else
- keys = strcat(keys, ", ", keynumtostring(k));
+ keys = strcat(keys, ", ", key);
++l;
if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
// --------------------------------------------------------------------------
// MENU Functionality
-void setpredraw(entity this, void(entity) pdfunc);
-
// --------------------------------------------------------------------------
// Onslaught
void Draw_ShowNames_All()
{
- SELFPARAM();
if (!autocvar_hud_shownames) return;
LL_EACH(shownames_ent, true, {
entity entcs = entcs_receiver(i);
continue;
}
make_impure(it);
- assert(entcs.think, eprint(entcs));
- WITHSELF(entcs, entcs.think());
+ assert(getthink(entcs), eprint(entcs));
+ WITHSELF(entcs, getthink(entcs)(entcs));
if (!entcs.has_origin) continue;
if (entcs.m_entcs_private)
{
return true;
if(MUTATOR_CALLHOOK(WantEventchase, this))
return true;
- if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL)))
- return true;
if(autocvar_cl_eventchase_death && (STAT(HEALTH) <= 0))
{
if(autocvar_cl_eventchase_death == 2)
return wcross_color;
}
-void HUD_Crosshair()
-{SELFPARAM();
- entity e = this;
+void HUD_Crosshair(entity this)
+{
float f, i, j;
vector v;
if(!scoreboard_active && !camera_active && intermission != 2 &&
string wcross_name = "";
float wcross_scale, wcross_blur;
+ entity e = this; // wtf?
if(autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1))
{
e = switchingweapon;
}
}
-void HUD_Draw()
+void HUD_Draw(entity this)
{
if(!intermission)
if (MUTATOR_CALLHOOK(HUD_Draw_overlay))
// crosshair goes VERY LAST
UpdateDamage();
- HUD_Crosshair();
+ HUD_Crosshair(this);
HitSound();
}
float vh_notice_time;
void WaypointSprite_Load();
void CSQC_UpdateView(float w, float h)
-{SELFPARAM();
+{
+ SELFPARAM();
TC(int, w); TC(int, h);
entity e;
float fov;
scoreboard_active = HUD_WouldDrawScoreboard();
- HUD_Draw();
+ HUD_Draw(this);
if(NextFrameCommand)
{
this.move_movetype = MOVETYPE_NONE;
}
-void SUB_Stop_self()
-{
- SELFPARAM();
- SUB_Stop(this);
-}
-
void Projectile_ResetTrail(entity this, vector to)
{
this.trail_oldorigin = to;
this.mins = '0 0 0';
this.maxs = '0 0 0';
this.colormod = '0 0 0';
- this.move_touch = SUB_Stop_self;
+ settouch(this, SUB_Stop);
this.move_movetype = MOVETYPE_TOSS;
this.alphamod = 1;
this.mins = '0 0 -4';
this.maxs = '0 0 -4';
this.move_movetype = MOVETYPE_BOUNCE;
- this.move_touch = func_null;
+ settouch(this, func_null);
this.move_bounce_factor = WEP_CVAR_SEC(electro, bouncefactor);
this.move_bounce_stopspeed = WEP_CVAR_SEC(electro, bouncestop);
break;
this.mins = '-3 -3 -3';
this.maxs = '3 3 3';
this.move_movetype = MOVETYPE_BOUNCE;
- this.move_touch = func_null;
+ settouch(this, func_null);
this.move_bounce_factor = WEP_CVAR(mortar, bouncefactor);
this.move_bounce_stopspeed = WEP_CVAR(mortar, bouncestop);
break;
this.colormod = '2 1 1';
this.alphamod = 0.5;
this.move_movetype = MOVETYPE_BOUNCE;
- this.move_touch = func_null;
+ settouch(this, func_null);
break;
case PROJECTILE_PORTO_BLUE:
this.colormod = '1 1 2';
this.alphamod = 0.5;
this.move_movetype = MOVETYPE_BOUNCE;
- this.move_touch = func_null;
+ settouch(this, func_null);
break;
case PROJECTILE_HAGAR_BOUNCING:
this.move_movetype = MOVETYPE_BOUNCE;
- this.move_touch = func_null;
+ settouch(this, func_null);
break;
case PROJECTILE_CRYLINK_BOUNCING:
this.move_movetype = MOVETYPE_BOUNCE;
- this.move_touch = func_null;
+ settouch(this, func_null);
break;
case PROJECTILE_FIREBALL:
loopsound(this, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
case PROJECTILE_FIREMINE:
loopsound(this, CH_SHOTS_SINGLE, SND(FIREBALL_FLY), VOL_BASE, ATTEN_NORM);
this.move_movetype = MOVETYPE_BOUNCE;
- this.move_touch = func_null;
+ settouch(this, func_null);
this.mins = '-4 -4 -4';
this.maxs = '4 4 4';
break;
#ifdef SVQC
void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner)
-{SELFPARAM();
+{
.entity weaponentity = weaponentities[0]; // TODO: parameter
- entity wep = self.(weaponentity);
- vector org = self.origin + self.view_ofs + wep.spawnorigin.x * v_forward - wep.spawnorigin.y * v_right + wep.spawnorigin.z * v_up;
+ entity wep = casingowner.(weaponentity);
+ vector org = casingowner.origin + casingowner.view_ofs + wep.spawnorigin.x * v_forward - wep.spawnorigin.y * v_right + wep.spawnorigin.z * v_up;
if (!sound_allowed(MSG_BROADCAST, casingowner))
casingtype |= 0x80;
return Sounds_from(SND_CASINGS1.m_id + floor(prandom() * 3));
}
-void Casing_Touch()
-{SELFPARAM();
+void Casing_Touch(entity this)
+{
if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
{
Casing_Delete(self);
casing.move_angles = casing.angles;
casing.move_avelocity = '0 250 0' + 100 * prandomvec();
casing.move_movetype = MOVETYPE_BOUNCE;
- casing.move_touch = Casing_Touch;
+ settouch(casing, Casing_Touch);
casing.move_time = time;
casing.event_damage = Casing_Damage;
casing.solid = SOLID_TRIGGER;
bool Damage_DamageInfo_SendEntity(entity this, entity to, int sf)
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_DAMAGEINFO);
- WriteShort(MSG_ENTITY, self.projectiledeathtype);
- WriteCoord(MSG_ENTITY, floor(self.origin.x));
- WriteCoord(MSG_ENTITY, floor(self.origin.y));
- WriteCoord(MSG_ENTITY, floor(self.origin.z));
- WriteByte(MSG_ENTITY, bound(1, self.dmg, 255));
- WriteByte(MSG_ENTITY, bound(0, self.dmg_radius, 255));
- WriteByte(MSG_ENTITY, bound(1, self.dmg_edge, 255));
- WriteShort(MSG_ENTITY, self.oldorigin.x);
- WriteByte(MSG_ENTITY, self.species);
+ WriteShort(MSG_ENTITY, this.projectiledeathtype);
+ WriteCoord(MSG_ENTITY, floor(this.origin.x));
+ WriteCoord(MSG_ENTITY, floor(this.origin.y));
+ WriteCoord(MSG_ENTITY, floor(this.origin.z));
+ WriteByte(MSG_ENTITY, bound(1, this.dmg, 255));
+ WriteByte(MSG_ENTITY, bound(0, this.dmg_radius, 255));
+ WriteByte(MSG_ENTITY, bound(1, this.dmg_edge, 255));
+ WriteShort(MSG_ENTITY, this.oldorigin.x);
+ WriteByte(MSG_ENTITY, this.species);
return true;
}
.int state;
.bool isplayermodel;
-void DamageEffect_Think()
-{SELFPARAM();
+void DamageEffect_Think(entity this)
+{
// if particle distribution is enabled, slow ticrate by total number of damages
if(autocvar_cl_damageeffect_distribute)
this.nextthink = time + autocvar_cl_damageeffect_ticrate * this.owner.total_damages;
e.owner = this;
e.cnt = time + life;
e.team = _particleeffectnum(effectname);
- e.think = DamageEffect_Think;
+ setthink(e, DamageEffect_Think);
e.nextthink = time;
this.total_damages += 1;
}
if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
{
if(!MUTATOR_CALLHOOK(Weapon_ImpactEffect, hitwep))
- hitwep.wr_impacteffect(hitwep);
+ hitwep.wr_impacteffect(hitwep, this);
}
}
}
__pointparticles(ef, org, randomvec() * explosionspeed, howmany / 50);
}
-void SUB_RemoveOnNoImpact()
+void SUB_RemoveOnNoImpact(entity this)
{
- SELFPARAM();
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
Gib_Delete(self);
}
-void Gib_Touch()
-{SELFPARAM();
+void Gib_Touch(entity this)
+{
// TODO maybe bounce of walls, make more gibs, etc.
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
if(wasfreed(this))
return;
- if(this.touch == Gib_Touch) // don't do this for the "chunk" thingie...
+ if(gettouch(this) == Gib_Touch) // don't do this for the "chunk" thingie...
// TODO somehow make it spray in a direction dependent on this.angles
__trailparticles(this, _particleeffectnum(strcat(species_prefix(this.cnt), EFFECT_TR_SLIGHTBLOOD.eent_eff_name)), oldorg, this.origin);
else
gib.draw = Gib_Draw;
if(destroyontouch)
- gib.move_touch = Gib_Touch;
+ settouch(gib, Gib_Touch);
else
- gib.move_touch = SUB_RemoveOnNoImpact;
+ settouch(gib, SUB_RemoveOnNoImpact);
// don't spawn gibs inside solid - just don't
if(org != safeorg)
WriteHeader(MSG_ENTITY, ENT_CLIENT_MODELEFFECT);
f = 0;
- if(self.velocity != '0 0 0')
+ if(this.velocity != '0 0 0')
f |= 1;
- if(self.angles != '0 0 0')
+ if(this.angles != '0 0 0')
f |= 2;
- if(self.avelocity != '0 0 0')
+ if(this.avelocity != '0 0 0')
f |= 4;
WriteByte(MSG_ENTITY, f);
- WriteShort(MSG_ENTITY, self.modelindex);
- WriteByte(MSG_ENTITY, self.skin);
- WriteByte(MSG_ENTITY, self.frame);
- WriteCoord(MSG_ENTITY, self.origin.x);
- WriteCoord(MSG_ENTITY, self.origin.y);
- WriteCoord(MSG_ENTITY, self.origin.z);
+ WriteShort(MSG_ENTITY, this.modelindex);
+ WriteByte(MSG_ENTITY, this.skin);
+ WriteByte(MSG_ENTITY, this.frame);
+ WriteCoord(MSG_ENTITY, this.origin.x);
+ WriteCoord(MSG_ENTITY, this.origin.y);
+ WriteCoord(MSG_ENTITY, this.origin.z);
if(f & 1)
{
- WriteCoord(MSG_ENTITY, self.velocity.x);
- WriteCoord(MSG_ENTITY, self.velocity.y);
- WriteCoord(MSG_ENTITY, self.velocity.z);
+ WriteCoord(MSG_ENTITY, this.velocity.x);
+ WriteCoord(MSG_ENTITY, this.velocity.y);
+ WriteCoord(MSG_ENTITY, this.velocity.z);
}
if(f & 2)
{
- WriteCoord(MSG_ENTITY, self.angles.x);
- WriteCoord(MSG_ENTITY, self.angles.y);
- WriteCoord(MSG_ENTITY, self.angles.z);
+ WriteCoord(MSG_ENTITY, this.angles.x);
+ WriteCoord(MSG_ENTITY, this.angles.y);
+ WriteCoord(MSG_ENTITY, this.angles.z);
}
if(f & 4)
{
- WriteCoord(MSG_ENTITY, self.avelocity.x);
- WriteCoord(MSG_ENTITY, self.avelocity.y);
- WriteCoord(MSG_ENTITY, self.avelocity.z);
+ WriteCoord(MSG_ENTITY, this.avelocity.x);
+ WriteCoord(MSG_ENTITY, this.avelocity.y);
+ WriteCoord(MSG_ENTITY, this.avelocity.z);
}
- WriteShort(MSG_ENTITY, self.scale * 256.0);
- WriteShort(MSG_ENTITY, self.scale2 * 256.0);
- WriteByte(MSG_ENTITY, self.teleport_time * 100.0);
- WriteByte(MSG_ENTITY, self.fade_time * 100.0);
- WriteByte(MSG_ENTITY, self.alpha * 255.0);
+ WriteShort(MSG_ENTITY, this.scale * 256.0);
+ WriteShort(MSG_ENTITY, this.scale2 * 256.0);
+ WriteByte(MSG_ENTITY, this.teleport_time * 100.0);
+ WriteByte(MSG_ENTITY, this.fade_time * 100.0);
+ WriteByte(MSG_ENTITY, this.alpha * 255.0);
return true;
}
return _entcs_send(this, to, sf, MSG_ENTITY);
}
- void entcs_think()
+ void entcs_think(entity this)
{
- SELFPARAM();
this.nextthink = time + 0.033333333333; // TODO: increase this to like 0.15 once the client can do smoothing
entity o = this.owner;
int i = 1;
{
entity e = player.entcs = new(entcs_sender);
e.owner = player;
- e.think = entcs_think;
+ setthink(e, entcs_think);
e.nextthink = time;
Net_LinkEntity(e, false, 0, entcs_send);
if (!IS_REAL_CLIENT(player)) return;
if (e != this) remove(e);
}
- void entcs_think()
+ void entcs_think(entity this)
{
- SELFPARAM();
entity e = CSQCModel_server2csqc(this.sv_entnum);
if (e == NULL)
{
make_pure(e);
}
e.sv_entnum = n;
- e.think = entcs_think;
+ setthink(e, entcs_think);
entcs_receiver(n, e);
}
else if (this && e != this)
#undef X
this.iflags |= IFLAG_ORIGIN;
InterpolateOrigin_Note(this);
- WITHSELF(this, this.think());
+ WITHSELF(this, getthink(this)(this));
return true;
}
bool entcs_send(entity this, entity to, int sf);
- void entcs_think();
+ void entcs_think(entity this);
void entcs_attach(entity e);
#include "nexball.qh"
#ifdef IMPLEMENTATION
+#ifdef CSQC
+int autocvar_cl_eventchase_nexball = 1;
+
+REGISTER_MUTATOR(cl_nb, true);
+
+MUTATOR_HOOKFUNCTION(cl_nb, WantEventchase)
+{
+ if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL)))
+ return true;
+ return false;
+}
+#endif
#ifdef SVQC
.float metertime = _STAT(NB_METERSTART);
float autocvar_g_balance_nexball_secondary_refire;
float autocvar_g_balance_nexball_secondary_speed;
-void basketball_touch();
-void football_touch();
-void ResetBall();
+void basketball_touch(entity this);
+void football_touch(entity this);
+void ResetBall(entity this);
const int NBM_NONE = 0;
const int NBM_FOOTBALL = 2;
const int NBM_BASKETBALL = 4;
{
if(this.owner)
DropBall(this, this.owner.origin, '0 0 0');
- ResetBall();
+ ResetBall(this);
}
-void nexball_setstatus()
-{SELFPARAM();
- self.items &= ~IT_KEY1;
- if(self.ballcarried)
+void nexball_setstatus(entity this)
+{
+ this.items &= ~IT_KEY1;
+ if(this.ballcarried)
{
- if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
+ if(this.ballcarried.teamtime && (this.ballcarried.teamtime < time))
{
- bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
- setself(self.ballcarried);
- DropBall(self, self.owner.origin, '0 0 0');
- ResetBall();
- setself(this);
+ bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
+ DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
+ entity e = this.ballcarried;
+ WITHSELF(e, ResetBall(e));
}
else
- self.items |= IT_KEY1;
+ this.items |= IT_KEY1;
}
}
-void relocate_nexball()
-{SELFPARAM();
- tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
+void relocate_nexball(entity this)
+{
+ tracebox(this.origin, BALL_MINS, BALL_MAXS, this.origin, true, this);
if(trace_startsolid)
{
vector o;
- o = self.origin;
- if(!move_out_of_solid(self))
+ o = this.origin;
+ if(!move_out_of_solid(this))
objerror("could not get out of solid at all!");
- LOG_INFO("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
- LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
- LOG_INFO(" ", ftos(self.origin.y - o.y));
- LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
- self.origin = o;
+ LOG_INFO("^1NOTE: this map needs FIXING. ", this.classname, " at ", vtos(o - '0 0 1'));
+ LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(this.origin.x - o.x));
+ LOG_INFO(" ", ftos(this.origin.y - o.y));
+ LOG_INFO(" ", ftos(this.origin.z - o.z), "'\n");
+ this.origin = o;
}
}
-void DropOwner()
-{SELFPARAM();
+void DropOwner(entity this)
+{
entity ownr;
- ownr = self.owner;
- DropBall(self, ownr.origin, ownr.velocity);
+ ownr = this.owner;
+ DropBall(this, ownr.origin, ownr.velocity);
makevectors(ownr.v_angle.y * '0 1 0');
ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
UNSET_ONGROUND(ownr);
}
void GiveBall(entity plyr, entity ball)
-{SELFPARAM();
+{
.entity weaponentity = weaponentities[0]; // TODO: find ballstealer
entity ownr = ball.owner;
if(ownr)
ball.velocity = '0 0 0';
ball.movetype = MOVETYPE_NONE;
- ball.touch = func_null;
+ settouch(ball, func_null);
ball.effects |= EF_NOSHADOW;
ball.scale = 1; // scale down.
if(autocvar_g_nexball_basketball_delay_hold)
{
- ball.think = DropOwner;
+ setthink(ball, DropOwner);
ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
}
plyr.(weaponentity).weapons = plyr.weapons;
plyr.(weaponentity).m_switchweapon = PS(plyr).m_weapon;
plyr.weapons = WEPSET(NEXBALL);
- setself(plyr);
Weapon w = WEP_NEXBALL;
- w.wr_resetplayer(w);
+ WITHSELF(plyr, w.wr_resetplayer(w, plyr));
PS(plyr).m_switchweapon = WEP_NEXBALL;
- W_SwitchWeapon(WEP_NEXBALL);
- setself(this);
+ WITHSELF(plyr, W_SwitchWeapon(plyr, WEP_NEXBALL));
}
void DropBall(entity ball, vector org, vector vel)
ball.scale = ball_scale;
ball.velocity = vel;
ball.nb_droptime = time;
- ball.touch = basketball_touch;
- ball.think = ResetBall;
+ settouch(ball, basketball_touch);
+ setthink(ball, ResetBall);
ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
if(ball.owner.metertime)
ball.owner = world;
}
-void InitBall()
-{SELFPARAM();
+void InitBall(entity this)
+{
if(gameover) return;
- UNSET_ONGROUND(self);
- self.movetype = MOVETYPE_BOUNCE;
- if(self.classname == "nexball_basketball")
- self.touch = basketball_touch;
- else if(self.classname == "nexball_football")
- self.touch = football_touch;
- self.cnt = 0;
- self.think = ResetBall;
- self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
- self.teamtime = 0;
- self.pusher = world;
- self.team = false;
- _sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
- WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
+ UNSET_ONGROUND(this);
+ this.movetype = MOVETYPE_BOUNCE;
+ if(this.classname == "nexball_basketball")
+ settouch(this, basketball_touch);
+ else if(this.classname == "nexball_football")
+ settouch(this, football_touch);
+ this.cnt = 0;
+ setthink(this, ResetBall);
+ this.nextthink = time + autocvar_g_nexball_delay_idle + 3;
+ this.teamtime = 0;
+ this.pusher = world;
+ this.team = false;
+ _sound(this, CH_TRIGGER, this.noise1, VOL_BASE, ATTEN_NORM);
+ WaypointSprite_Ping(this.waypointsprite_attachedforcarrier);
LogNB("init", world);
}
-void ResetBall()
-{SELFPARAM();
- if(self.cnt < 2) // step 1
+void ResetBall(entity this)
+{
+ if(this.cnt < 2) // step 1
{
- if(time == self.teamtime)
- bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
+ if(time == this.teamtime)
+ bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
- self.touch = func_null;
- self.movetype = MOVETYPE_NOCLIP;
- self.velocity = '0 0 0'; // just in case?
- if(!self.cnt)
+ settouch(this, func_null);
+ this.movetype = MOVETYPE_NOCLIP;
+ this.velocity = '0 0 0'; // just in case?
+ if(!this.cnt)
LogNB("resetidle", world);
- self.cnt = 2;
- self.nextthink = time;
+ this.cnt = 2;
+ this.nextthink = time;
}
- else if(self.cnt < 4) // step 2 and 3
+ else if(this.cnt < 4) // step 2 and 3
{
-// dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
- self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
- self.nextthink = time + 0.5;
- self.cnt += 1;
+// dprint("Step ", ftos(this.cnt), ": Calculated velocity: ", vtos(this.spawnorigin - this.origin), ", time: ", ftos(time), "\n");
+ this.velocity = (this.spawnorigin - this.origin) * (this.cnt - 1); // 1 or 0.5 second movement
+ this.nextthink = time + 0.5;
+ this.cnt += 1;
}
else // step 4
{
// dprint("Step 4: time: ", ftos(time), "\n");
- if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
+ if(vlen(this.origin - this.spawnorigin) > 10) // should not happen anymore
LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
- vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
- self.velocity = '0 0 0';
- setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
- self.movetype = MOVETYPE_NONE;
- self.think = InitBall;
- self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
+ vtos(this.origin - this.spawnorigin), " Velocity: ", vtos(this.velocity), "\n");
+ this.velocity = '0 0 0';
+ setorigin(this, this.spawnorigin); // make sure it's positioned correctly anyway
+ this.movetype = MOVETYPE_NONE;
+ setthink(this, InitBall);
+ this.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
}
}
-void football_touch()
-{SELFPARAM();
+void football_touch(entity this)
+{
if(other.solid == SOLID_BSP)
{
if(time > self.lastground + 0.1)
self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
}
-void basketball_touch()
-{SELFPARAM();
+void basketball_touch(entity this)
+{
if(other.ballcarried)
{
- football_touch();
+ football_touch(this);
return;
}
if(!self.cnt && IS_PLAYER(other) && !STAT(FROZEN, other) && !IS_DEAD(other) && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
}
}
-void GoalTouch()
-{SELFPARAM();
+void GoalTouch(entity this)
+{
entity ball;
float isclient, pscore, otherteam;
string pname;
WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
ball.cnt = 1;
- ball.think = ResetBall;
+ setthink(ball, ResetBall);
if(ball.classname == "nexball_basketball")
- ball.touch = football_touch; // better than func_null: football control until the ball gets reset
+ settouch(ball, football_touch); // better than func_null: football control until the ball gets reset
ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
}
{
if(!g_nexball)
{
- remove(self);
+ remove(this);
return;
}
- self.team = self.cnt + 1;
+ this.team = this.cnt + 1;
}
void nb_spawnteam(string teamname, float teamcolor)
// spawnfuncs //
//=======================//
-void SpawnBall()
-{SELFPARAM();
- if(!g_nexball) { remove(self); return; }
+void SpawnBall(entity this)
+{
+ if(!g_nexball) { remove(this); return; }
// balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
- if(self.model == "")
+ if(this.model == "")
{
- self.model = "models/nexball/ball.md3";
- self.scale = 1.3;
+ this.model = "models/nexball/ball.md3";
+ this.scale = 1.3;
}
- precache_model(self.model);
- _setmodel(self, self.model);
- setsize(self, BALL_MINS, BALL_MAXS);
- ball_scale = self.scale;
+ precache_model(this.model);
+ _setmodel(this, this.model);
+ setsize(this, BALL_MINS, BALL_MAXS);
+ ball_scale = this.scale;
- relocate_nexball();
- self.spawnorigin = self.origin;
+ relocate_nexball(this);
+ this.spawnorigin = this.origin;
- self.effects = self.effects | EF_LOWPRECISION;
+ this.effects = this.effects | EF_LOWPRECISION;
- if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
+ if(cvar(strcat("g_", this.classname, "_trail"))) //nexball_basketball :p
{
- self.glow_color = autocvar_g_nexball_trail_color;
- self.glow_trail = true;
+ this.glow_color = autocvar_g_nexball_trail_color;
+ this.glow_trail = true;
}
- self.movetype = MOVETYPE_FLY;
+ this.movetype = MOVETYPE_FLY;
if(!autocvar_g_nexball_sound_bounce)
- self.noise = "";
- else if(self.noise == "")
- self.noise = strzone(SND(NB_BOUNCE));
+ this.noise = "";
+ else if(this.noise == "")
+ this.noise = strzone(SND(NB_BOUNCE));
//bounce sound placeholder (FIXME)
- if(self.noise1 == "")
- self.noise1 = strzone(SND(NB_DROP));
+ if(this.noise1 == "")
+ this.noise1 = strzone(SND(NB_DROP));
//ball drop sound placeholder (FIXME)
- if(self.noise2 == "")
- self.noise2 = strzone(SND(NB_STEAL));
+ if(this.noise2 == "")
+ this.noise2 = strzone(SND(NB_STEAL));
//stealing sound placeholder (FIXME)
- if(self.noise) precache_sound(self.noise);
- precache_sound(self.noise1);
- precache_sound(self.noise2);
+ if(this.noise) precache_sound(this.noise);
+ precache_sound(this.noise1);
+ precache_sound(this.noise2);
- WaypointSprite_AttachCarrier(WP_NbBall, self, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
+ WaypointSprite_AttachCarrier(WP_NbBall, this, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
- self.reset = ball_restart;
- self.think = InitBall;
- self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
+ this.reset = ball_restart;
+ setthink(this, InitBall);
+ this.nextthink = game_starttime + autocvar_g_nexball_delay_start;
}
spawnfunc(nexball_basketball)
{
nexball_mode |= NBM_BASKETBALL;
- self.classname = "nexball_basketball";
+ this.classname = "nexball_basketball";
if (!(balls & BALL_BASKET))
{
/*
*/
autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
}
- if(!self.effects)
- self.effects = autocvar_g_nexball_basketball_effects_default;
- self.solid = SOLID_TRIGGER;
- self.pushable = autocvar_g_nexball_basketball_jumppad;
+ if(!this.effects)
+ this.effects = autocvar_g_nexball_basketball_effects_default;
+ this.solid = SOLID_TRIGGER;
+ this.pushable = autocvar_g_nexball_basketball_jumppad;
balls |= BALL_BASKET;
- self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
- self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
- SpawnBall();
+ this.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
+ this.bouncestop = autocvar_g_nexball_basketball_bouncestop;
+ SpawnBall(this);
}
spawnfunc(nexball_football)
{
nexball_mode |= NBM_FOOTBALL;
- self.classname = "nexball_football";
- self.solid = SOLID_TRIGGER;
+ this.classname = "nexball_football";
+ this.solid = SOLID_TRIGGER;
balls |= BALL_FOOT;
- self.pushable = autocvar_g_nexball_football_jumppad;
- self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
- self.bouncestop = autocvar_g_nexball_football_bouncestop;
- SpawnBall();
+ this.pushable = autocvar_g_nexball_football_jumppad;
+ this.bouncefactor = autocvar_g_nexball_football_bouncefactor;
+ this.bouncestop = autocvar_g_nexball_football_bouncestop;
+ SpawnBall(this);
}
float nb_Goal_Customize()
return true;
}
-void SpawnGoal()
-{SELFPARAM();
- if(!g_nexball) { remove(self); return; }
+void SpawnGoal(entity this)
+{
+ if(!g_nexball) { remove(this); return; }
EXACTTRIGGER_INIT;
- if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
+ if(this.team != GOAL_OUT && Team_TeamToNumber(this.team) != -1)
{
- entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE);
- wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0');
- self.sprite.customizeentityforclient = nb_Goal_Customize;
+ entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (this.absmin + this.absmax) * 0.5, this, sprite, RADARICON_NONE);
+ wp.colormod = ((this.team) ? Team_ColorRGB(this.team) : '1 0.5 0');
+ this.sprite.customizeentityforclient = nb_Goal_Customize;
}
- self.classname = "nexball_goal";
- if(self.noise == "")
- self.noise = "ctf/respawn.wav";
- precache_sound(self.noise);
- self.touch = GoalTouch;
+ this.classname = "nexball_goal";
+ if(this.noise == "")
+ this.noise = "ctf/respawn.wav";
+ precache_sound(this.noise);
+ settouch(this, GoalTouch);
}
spawnfunc(nexball_redgoal)
{
- self.team = NUM_TEAM_1;
- SpawnGoal();
+ this.team = NUM_TEAM_1;
+ SpawnGoal(this);
}
spawnfunc(nexball_bluegoal)
{
- self.team = NUM_TEAM_2;
- SpawnGoal();
+ this.team = NUM_TEAM_2;
+ SpawnGoal(this);
}
spawnfunc(nexball_yellowgoal)
{
- self.team = NUM_TEAM_3;
- SpawnGoal();
+ this.team = NUM_TEAM_3;
+ SpawnGoal(this);
}
spawnfunc(nexball_pinkgoal)
{
- self.team = NUM_TEAM_4;
- SpawnGoal();
+ this.team = NUM_TEAM_4;
+ SpawnGoal(this);
}
spawnfunc(nexball_fault)
{
- self.team = GOAL_FAULT;
- if(self.noise == "")
- self.noise = strzone(SND(TYPEHIT));
- SpawnGoal();
+ this.team = GOAL_FAULT;
+ if(this.noise == "")
+ this.noise = strzone(SND(TYPEHIT));
+ SpawnGoal(this);
}
spawnfunc(nexball_out)
{
- self.team = GOAL_OUT;
- if(self.noise == "")
- self.noise = strzone(SND(TYPEHIT));
- SpawnGoal();
+ this.team = GOAL_OUT;
+ if(this.noise == "")
+ this.noise = strzone(SND(TYPEHIT));
+ SpawnGoal(this);
}
//
//=======================//
-void W_Nexball_Think()
-{SELFPARAM();
+void W_Nexball_Think(entity this)
+{
//dprint("W_Nexball_Think\n");
- //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
- vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
- vector old_dir = normalize(self.velocity);
- float _speed = vlen(self.velocity);
+ //vector new_dir = steerlib_arrive(this.enemy.origin, 2500);
+ vector new_dir = normalize(this.enemy.origin + '0 0 50' - this.origin);
+ vector old_dir = normalize(this.velocity);
+ float _speed = vlen(this.velocity);
vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
//vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
- self.velocity = new_vel;
+ this.velocity = new_vel;
- self.nextthink = time;
+ this.nextthink = time;
}
-void W_Nexball_Touch()
-{SELFPARAM();
+void W_Nexball_Touch(entity this)
+{
entity ball, attacker;
- attacker = self.owner;
- //self.think = func_null;
- //self.enemy = world;
+ attacker = this.owner;
+ //this.think = func_null;
+ //this.enemy = world;
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
if((ball = other.ballcarried) && !STAT(FROZEN, other) && !IS_DEAD(other) && (IS_PLAYER(attacker)))
{
- other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
+ other.velocity = other.velocity + normalize(this.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
UNSET_ONGROUND(other);
if(!attacker.ballcarried)
{
GiveBall(attacker, other.ballcarried);
}
}
- remove(self);
+ remove(this);
}
-void W_Nexball_Attack(float t)
-{SELFPARAM();
+void W_Nexball_Attack(entity actor, float t)
+{
entity ball;
float mul, mi, ma;
- if(!(ball = self.ballcarried))
+ if(!(ball = actor.ballcarried))
return;
- W_SetupShot(self, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
+ W_SetupShot(actor, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
if(trace_startsolid)
{
- if(self.metertime)
- self.metertime = 0; // Shot failed, hide the power meter
+ if(actor.metertime)
+ actor.metertime = 0; // Shot failed, hide the power meter
return;
}
mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
}
- DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
+ DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(actor.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
//TODO: use the speed_up cvar too ??
vector trigger_push_calculatevelocity(vector org, entity tgt, float ht);
-void W_Nexball_Attack2()
-{SELFPARAM();
- if(self.ballcarried.enemy)
+void W_Nexball_Attack2(entity actor)
+{
+ if(actor.ballcarried.enemy)
{
- entity _ball = self.ballcarried;
- W_SetupShot(self, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
+ entity _ball = actor.ballcarried;
+ W_SetupShot(actor, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
- _ball.think = W_Nexball_Think;
+ setthink(_ball, W_Nexball_Think);
_ball.nextthink = time;
return;
}
if(!autocvar_g_nexball_tackling)
return;
- W_SetupShot(self, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0);
+ W_SetupShot(actor, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0);
entity missile = new(ballstealer);
- missile.owner = self;
+ missile.owner = actor;
missile.movetype = MOVETYPE_FLY;
PROJECTILE_MAKETRIGGER(missile);
W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
missile.angles = vectoangles(missile.velocity);
- missile.touch = W_Nexball_Touch;
- missile.think = SUB_Remove_self;
+ settouch(missile, W_Nexball_Touch);
+ setthink(missile, SUB_Remove);
missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire))
{
- SELFPARAM();
TC(BallStealer, thiswep);
if(fire & 1)
if(weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_balance_nexball_primary_refire))
if(autocvar_g_nexball_basketball_meter)
{
- if(self.ballcarried && !self.metertime)
- self.metertime = time;
+ if(actor.ballcarried && !actor.metertime)
+ actor.metertime = time;
else
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
}
else
{
- W_Nexball_Attack(-1);
+ W_Nexball_Attack(actor, -1);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
}
if(fire & 2)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire))
{
- W_Nexball_Attack2();
+ W_Nexball_Attack2(actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
}
- if(!(fire & 1) && self.metertime && self.ballcarried)
+ if(!(fire & 1) && actor.metertime && actor.ballcarried)
{
- W_Nexball_Attack(time - self.metertime);
+ W_Nexball_Attack(actor, time - actor.metertime);
// DropBall or stealing will set metertime back to 0
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
}
}
-METHOD(BallStealer, wr_setup, void(BallStealer this))
+METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor))
{
TC(BallStealer, this);
//weapon_setup(WEP_PORTO.m_id);
}
-METHOD(BallStealer, wr_checkammo1, bool(BallStealer this))
+METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor))
{
TC(BallStealer, this);
return true;
}
-METHOD(BallStealer, wr_checkammo2, bool(BallStealer this))
+METHOD(BallStealer, wr_checkammo2, bool(BallStealer this, entity actor))
{
TC(BallStealer, this);
return true;
{
self.weapons = self.(weaponentity).weapons;
Weapon w = WEP_NEXBALL;
- w.wr_resetplayer(w);
+ w.wr_resetplayer(w, self);
PS(self).m_switchweapon = self.(weaponentity).m_switchweapon;
- W_SwitchWeapon(PS(self).m_switchweapon);
+ W_SwitchWeapon(self, PS(self).m_switchweapon);
self.(weaponentity).weapons = '0 0 0';
}
}
- nexball_setstatus();
+ nexball_setstatus(self);
return false;
}
return true;
}
-void ons_CaptureShield_Touch()
-{SELFPARAM();
+void ons_CaptureShield_Touch(entity this)
+{
if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, other.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return; }
if(!IS_PLAYER(other)) { return; }
if(SAME_TEAM(other, self)) { return; }
shield.team = generator.team;
shield.colormap = generator.colormap;
shield.reset = ons_CaptureShield_Reset;
- shield.touch = ons_CaptureShield_Touch;
+ settouch(shield, ons_CaptureShield_Touch);
shield.customizeentityforclient = ons_CaptureShield_Customize;
shield.effects = EF_ADDITIVE;
shield.movetype = MOVETYPE_NOCLIP;
return true;
}
-void ons_Link_CheckUpdate()
-{SELFPARAM();
+void ons_Link_CheckUpdate(entity this)
+{
// TODO check if the two sides have moved (currently they won't move anyway)
float cc = 0, cc1 = 0, cc2 = 0;
- if(self.goalentity.islinked || self.goalentity.iscaptured) { cc1 = (self.goalentity.team - 1) * 0x01; }
- if(self.enemy.islinked || self.enemy.iscaptured) { cc2 = (self.enemy.team - 1) * 0x10; }
+ if(this.goalentity.islinked || this.goalentity.iscaptured) { cc1 = (this.goalentity.team - 1) * 0x01; }
+ if(this.enemy.islinked || this.enemy.iscaptured) { cc2 = (this.enemy.team - 1) * 0x10; }
cc = cc1 + cc2;
- if(cc != self.clientcolors)
+ if(cc != this.clientcolors)
{
- self.clientcolors = cc;
- self.SendFlags |= 4;
+ this.clientcolors = cc;
+ this.SendFlags |= 4;
}
- self.nextthink = time;
+ this.nextthink = time;
}
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"); }
- if(!self.enemy) { objerror("can not find target2\n"); }
+ this.goalentity = find(world, targetname, this.target);
+ this.enemy = find(world, targetname, this.target2);
+ if(!this.goalentity) { objerror("can not find target\n"); }
+ if(!this.enemy) { objerror("can not find target2\n"); }
- LOG_DEBUG(strcat(etos(self.goalentity), " linked with ", etos(self.enemy), "\n"));
- self.SendFlags |= 3;
- self.think = ons_Link_CheckUpdate;
- self.nextthink = time;
+ LOG_DEBUG(strcat(etos(this.goalentity), " linked with ", etos(this.enemy), "\n"));
+ this.SendFlags |= 3;
+ setthink(this, ons_Link_CheckUpdate);
+ this.nextthink = time;
}
this.SendFlags |= CPSF_STATUS;
}
-void ons_ControlPoint_Icon_Think()
-{SELFPARAM();
- self.nextthink = time + ONS_CP_THINKRATE;
+void ons_ControlPoint_Icon_Think(entity this)
+{
+ this.nextthink = time + ONS_CP_THINKRATE;
if(autocvar_g_onslaught_cp_proxydecap)
{
int _friendly_count = 0;
FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), {
- if(vdist(it.origin - self.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
+ if(vdist(it.origin - this.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
{
- if(SAME_TEAM(it, self))
+ if(SAME_TEAM(it, this))
++_friendly_count;
else
++_enemy_count;
_friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
_enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
- self.health = bound(0, self.health + (_friendly_count - _enemy_count), self.max_health);
- self.SendFlags |= CPSF_STATUS;
- if(self.health <= 0)
+ this.health = bound(0, this.health + (_friendly_count - _enemy_count), this.max_health);
+ this.SendFlags |= CPSF_STATUS;
+ if(this.health <= 0)
{
- ons_ControlPoint_Icon_Damage(self, self, self, 1, 0, self.origin, '0 0 0');
+ ons_ControlPoint_Icon_Damage(this, this, this, 1, 0, this.origin, '0 0 0');
return;
}
}
- if (time > self.pain_finished + 5)
+ if (time > this.pain_finished + 5)
{
- if(self.health < self.max_health)
+ if(this.health < this.max_health)
{
- self.health = self.health + self.count;
- if (self.health >= self.max_health)
- self.health = self.max_health;
- WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
+ this.health = this.health + this.count;
+ if (this.health >= this.max_health)
+ this.health = this.max_health;
+ WaypointSprite_UpdateHealth(this.owner.sprite, this.health);
}
}
- if(self.owner.islinked != self.owner.waslinked)
+ if(this.owner.islinked != this.owner.waslinked)
{
// unteam the spawnpoint if needed
- int t = self.owner.team;
- if(!self.owner.islinked)
- self.owner.team = 0;
+ int t = this.owner.team;
+ if(!this.owner.islinked)
+ this.owner.team = 0;
- SUB_UseTargets(self.owner, self, NULL);
+ SUB_UseTargets(this.owner, this, NULL);
- self.owner.team = t;
+ this.owner.team = t;
- self.owner.waslinked = self.owner.islinked;
+ this.owner.waslinked = this.owner.islinked;
}
// damaged fx
- if(random() < 0.6 - self.health / self.max_health)
+ if(random() < 0.6 - this.health / this.max_health)
{
- Send_Effect(EFFECT_ELECTRIC_SPARKS, self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
+ Send_Effect(EFFECT_ELECTRIC_SPARKS, this.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
if(random() > 0.8)
- sound(self, CH_PAIN, SND_ONS_SPARK1, VOL_BASE, ATTEN_NORM);
+ sound(this, CH_PAIN, SND_ONS_SPARK1, VOL_BASE, ATTEN_NORM);
else if (random() > 0.5)
- sound(self, CH_PAIN, SND_ONS_SPARK2, VOL_BASE, ATTEN_NORM);
+ sound(this, CH_PAIN, SND_ONS_SPARK2, VOL_BASE, ATTEN_NORM);
}
}
-void ons_ControlPoint_Icon_BuildThink()
-{SELFPARAM();
+void ons_ControlPoint_Icon_BuildThink(entity this)
+{
int a;
- self.nextthink = time + ONS_CP_THINKRATE;
+ this.nextthink = time + ONS_CP_THINKRATE;
// only do this if there is power
- a = ons_ControlPoint_CanBeLinked(self.owner, self.owner.team);
+ a = ons_ControlPoint_CanBeLinked(this.owner, this.owner.team);
if(!a)
return;
- self.health = self.health + self.count;
+ this.health = this.health + this.count;
- self.SendFlags |= CPSF_STATUS;
+ this.SendFlags |= CPSF_STATUS;
- if (self.health >= self.max_health)
+ if (this.health >= this.max_health)
{
- self.health = self.max_health;
- self.count = autocvar_g_onslaught_cp_regen * ONS_CP_THINKRATE; // slow repair rate from now on
- self.think = ons_ControlPoint_Icon_Think;
- sound(self, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILT, VOL_BASE, ATTEN_NORM);
- self.owner.iscaptured = true;
- self.solid = SOLID_BBOX;
+ this.health = this.max_health;
+ this.count = autocvar_g_onslaught_cp_regen * ONS_CP_THINKRATE; // slow repair rate from now on
+ setthink(this, ons_ControlPoint_Icon_Think);
+ sound(this, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILT, VOL_BASE, ATTEN_NORM);
+ this.owner.iscaptured = true;
+ this.solid = SOLID_BBOX;
- Send_Effect(EFFECT_CAP(self.owner.team), self.owner.origin, '0 0 0', 1);
+ Send_Effect(EFFECT_CAP(this.owner.team), this.owner.origin, '0 0 0', 1);
- WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health);
- WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
+ WaypointSprite_UpdateMaxHealth(this.owner.sprite, this.max_health);
+ WaypointSprite_UpdateHealth(this.owner.sprite, this.health);
- if(IS_PLAYER(self.owner.ons_toucher))
+ if(IS_PLAYER(this.owner.ons_toucher))
{
- Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, self.owner.ons_toucher.netname, self.owner.message);
- Send_Notification(NOTIF_ALL_EXCEPT, self.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(self.owner.ons_toucher.team, CENTER_ONS_CAPTURE), self.owner.message);
- Send_Notification(NOTIF_ONE, self.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, self.owner.message);
- PlayerScore_Add(self.owner.ons_toucher, SP_ONS_CAPS, 1);
- PlayerTeamScore_AddScore(self.owner.ons_toucher, 10);
+ Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, this.owner.ons_toucher.netname, this.owner.message);
+ Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE), this.owner.message);
+ Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message);
+ PlayerScore_Add(this.owner.ons_toucher, SP_ONS_CAPS, 1);
+ PlayerTeamScore_AddScore(this.owner.ons_toucher, 10);
}
- self.owner.ons_toucher = world;
+ this.owner.ons_toucher = world;
onslaught_updatelinks();
// Use targets now (somebody make sure this is in the right place..)
- SUB_UseTargets(self.owner, self, NULL);
+ SUB_UseTargets(this.owner, this, NULL);
- self.SendFlags |= CPSF_SETUP;
+ this.SendFlags |= CPSF_SETUP;
}
- if(self.owner.model != MDL_ONS_CP_PAD2.model_str())
- setmodel_fixsize(self.owner, MDL_ONS_CP_PAD2);
+ if(this.owner.model != MDL_ONS_CP_PAD2.model_str())
+ setmodel_fixsize(this.owner, MDL_ONS_CP_PAD2);
- if(random() < 0.9 - self.health / self.max_health)
- Send_Effect(EFFECT_RAGE, self.origin + 10 * randomvec(), '0 0 -1', 1);
+ if(random() < 0.9 - this.health / this.max_health)
+ Send_Effect(EFFECT_RAGE, this.origin + 10 * randomvec(), '0 0 -1', 1);
}
-void onslaught_controlpoint_icon_link(entity e, void() spawnproc);
+void onslaught_controlpoint_icon_link(entity e, void(entity this) spawnproc);
void ons_ControlPoint_Icon_Spawn(entity cp, entity player)
{
}
}
-void ons_ControlPoint_Touch()
-{SELFPARAM();
+void ons_ControlPoint_Touch(entity this)
+{
entity toucher = other;
int attackable;
onslaught_updatelinks();
}
-void ons_ControlPoint_Think()
-{SELFPARAM();
+void ons_ControlPoint_Think(entity this)
+{
self.nextthink = time + ONS_CP_THINKRATE;
CSQCMODEL_AUTOUPDATE(self);
}
this.iscaptured = false;
this.islinked = false;
this.isshielded = true;
- this.think = ons_ControlPoint_Think;
+ setthink(this, ons_ControlPoint_Think);
this.ons_toucher = world;
this.nextthink = time + ONS_CP_THINKRATE;
setmodel_fixsize(this, MDL_ONS_CP_PAD1);
onslaught_updatelinks();
// captureshield setup
- ons_CaptureShield_Spawn(self, false);
+ ons_CaptureShield_Spawn(this, false);
- CSQCMODEL_AUTOINIT(self);
+ CSQCMODEL_AUTOINIT(this);
}
void ons_ControlPoint_Setup(entity cp)
-{SELFPARAM();
- // declarations
- setself(cp); // for later usage with droptofloor()
-
+{
// main setup
cp.ons_worldcpnext = ons_worldcplist; // link control point into ons_worldcplist
ons_worldcplist = cp;
cp.team = 0;
cp.solid = SOLID_BBOX;
cp.movetype = MOVETYPE_NONE;
- cp.touch = ons_ControlPoint_Touch;
- cp.think = ons_ControlPoint_Think;
+ settouch(cp, ons_ControlPoint_Touch);
+ setthink(cp, ons_ControlPoint_Think);
cp.nextthink = time + ONS_CP_THINKRATE;
cp.reset = ons_ControlPoint_Reset;
cp.colormap = 1024;
{
setorigin(cp, cp.origin + '0 0 20');
cp.noalign = false;
- setself(cp);
- droptofloor();
+ WITHSELF(cp, droptofloor());
cp.movetype = MOVETYPE_TOSS;
}
// waypointsprites
- WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
- WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
+ WaypointSprite_SpawnFixed(WP_Null, cp.origin + CPGEN_WAYPOINT_OFFSET, cp, sprite, RADARICON_NONE);
+ WaypointSprite_UpdateRule(cp.sprite, cp.team, SPRITERULE_TEAMPLAY);
InitializeEntity(cp, ons_DelayedControlPoint_Setup, INITPRIO_SETLOCATION);
}
this.takedamage = DAMAGE_NO; // can't be hurt anymore
this.event_damage = func_null; // won't do anything if hurt
this.count = 0; // reset counter
- this.think = func_null;
+ setthink(this, func_null);
this.nextthink = 0;
//this.think(); // do the first explosion now
this.SendFlags |= GSF_STATUS;
}
-void ons_GeneratorThink()
-{SELFPARAM();
- self.nextthink = time + GEN_THINKRATE;
+void ons_GeneratorThink(entity this)
+{
+ this.nextthink = time + GEN_THINKRATE;
if (!gameover)
{
- if(!self.isshielded && self.wait < time)
+ if(!this.isshielded && this.wait < time)
{
- self.wait = time + 5;
+ this.wait = time + 5;
FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
- if(SAME_TEAM(it, self))
+ if(SAME_TEAM(it, this))
{
Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_ONS_NOTSHIELDED_TEAM);
soundto(MSG_ONE, it, CHAN_AUTO, SND(KH_ALARM), VOL_BASE, ATTEN_NONE); // FIXME: unique sound?
}
else
- Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(self.team, CENTER_ONS_NOTSHIELDED));
+ Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(this.team, CENTER_ONS_NOTSHIELDED));
});
}
}
this.islinked = true;
this.isshielded = true;
this.event_damage = ons_GeneratorDamage;
- this.think = ons_GeneratorThink;
+ setthink(this, ons_GeneratorThink);
this.nextthink = time + GEN_THINKRATE;
Net_LinkEntity(this, false, 0, generator_send);
}
-void onslaught_generator_touch()
-{SELFPARAM();
+void onslaught_generator_touch(entity this)
+{
if ( IS_PLAYER(other) )
if ( SAME_TEAM(self,other) )
if ( self.iscaptured )
}
void ons_GeneratorSetup(entity gen) // called when spawning a generator entity on the map as a spawnfunc
-{SELFPARAM();
+{
// declarations
int teamnumber = gen.team;
- setself(gen); // for later usage with droptofloor()
// main setup
gen.ons_worldgeneratornext = ons_worldgeneratorlist; // link generator into ons_worldgeneratorlist
gen.bot_attack = true;
gen.event_damage = ons_GeneratorDamage;
gen.reset = ons_GeneratorReset;
- gen.think = ons_GeneratorThink;
+ setthink(gen, ons_GeneratorThink);
gen.nextthink = time + GEN_THINKRATE;
gen.iscaptured = true;
gen.islinked = true;
gen.isshielded = true;
- gen.touch = onslaught_generator_touch;
+ settouch(gen, onslaught_generator_touch);
// appearence
// model handled by CSQC
gen.colormap = 1024 + (teamnumber - 1) * 17;
// generator placement
- setself(gen);
- droptofloor();
+ WITHSELF(gen, droptofloor());
// waypointsprites
- WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
- WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
- WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
- WaypointSprite_UpdateHealth(self.sprite, self.health);
+ WaypointSprite_SpawnFixed(WP_Null, gen.origin + CPGEN_WAYPOINT_OFFSET, gen, sprite, RADARICON_NONE);
+ WaypointSprite_UpdateRule(gen.sprite, gen.team, SPRITERULE_TEAMPLAY);
+ WaypointSprite_UpdateMaxHealth(gen.sprite, gen.max_health);
+ WaypointSprite_UpdateHealth(gen.sprite, gen.health);
InitializeEntity(gen, ons_DelayedGeneratorSetup, INITPRIO_SETLOCATION);
}
// ==============
MUTATOR_HOOKFUNCTION(ons, reset_map_global)
-{SELFPARAM();
+{
FOREACH_CLIENT(IS_PLAYER(it), {
it.ons_roundlost = false;
it.ons_deathloc = '0 0 0';
}
if(self.team != self.tur_head.team)
- turret_respawn();
+ turret_respawn(self);
return false;
}
*/
spawnfunc(onslaught_link)
{
- if(!g_onslaught) { remove(self); return; }
+ if(!g_onslaught) { remove(this); return; }
- if (self.target == "" || self.target2 == "")
+ if (this.target == "" || this.target2 == "")
objerror("target and target2 must be set\n");
- self.ons_worldlinknext = ons_worldlinklist; // link into ons_worldlinklist
- ons_worldlinklist = self;
+ this.ons_worldlinknext = ons_worldlinklist; // link into ons_worldlinklist
+ ons_worldlinklist = this;
- InitializeEntity(self, ons_DelayedLinkSetup, INITPRIO_FINDTARGET);
- Net_LinkEntity(self, false, 0, ons_Link_Send);
+ InitializeEntity(this, ons_DelayedLinkSetup, INITPRIO_FINDTARGET);
+ Net_LinkEntity(this, false, 0, ons_Link_Send);
}
/*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
spawnfunc(onslaught_controlpoint)
{
- if(!g_onslaught) { remove(self); return; }
+ if(!g_onslaught) { remove(this); return; }
- ons_ControlPoint_Setup(self);
+ ons_ControlPoint_Setup(this);
}
/*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
*/
spawnfunc(onslaught_generator)
{
- if(!g_onslaught) { remove(self); return; }
- if(!self.team) { objerror("team must be set"); }
+ if(!g_onslaught) { remove(this); return; }
+ if(!this.team) { objerror("team must be set"); }
- ons_GeneratorSetup(self);
+ ons_GeneratorSetup(this);
}
// scoreboard setup
return true;
}
-void onslaught_controlpoint_icon_link(entity e, void() spawnproc)
+void onslaught_controlpoint_icon_link(entity e, void(entity this) spawnproc)
{
Net_LinkEntity(e, true, 0, cpicon_send);
- e.think = spawnproc;
+ setthink(e, spawnproc);
e.nextthink = time * sys_frametime;
}
return true;
}
-void generator_link(void() spawnproc)
+void generator_link(void(entity this) spawnproc)
{SELFPARAM();
Net_LinkEntity(self, true, 0, generator_send);
- self.think = spawnproc;
+ setthink(self, spawnproc);
self.nextthink = time;
}
string() ReadString_Raw = #366;
string ReadString_Zoned() { return strzone(ReadString_Raw()); }
#define ReadString ReadString_Zoned
-#define FIELD(Flags, Type,Name) if ( sf & (Flags) ) self.Name = Read##Type();
+#define FIELD(Flags, Type,Name) if ( sf & (Flags) ) this.Name = Read##Type();
#define MSLE(Name,Fields) \
- else if ( self.classname == #Name ) { \
+ else if ( this.classname == #Name ) { \
if ( sf & MINIG_SF_CREATE ) { \
minigame_read_owner(); \
- self.entremove = msle_entremove_##Name; \
+ this.entremove = msle_entremove_##Name; \
} \
- minigame_ent = self.owner; \
+ minigame_ent = this.owner; \
Fields \
}
void minigame_read_owner()
{SELFPARAM();
string owner_name = ReadString_Raw();
- self.owner = world;
+ this.owner = world;
do
- self.owner = find(self.owner,netname,owner_name);
- while ( self.owner && self.owner.classname != "minigame" );
- if ( !self.owner )
+ this.owner = find(this.owner,netname,owner_name);
+ while ( this.owner && this.owner.classname != "minigame" );
+ if ( !this.owner )
LOG_TRACE("Got a minigame entity without a minigame!\n");
}
NET_HANDLE(ENT_CLIENT_MINIGAME, bool isnew)
float sf = ReadByte();
if ( sf & MINIG_SF_CREATE )
{
- self.classname = msle_classname(ReadShort());
- self.netname = ReadString_Zoned();
+ this.classname = msle_classname(ReadShort());
+ this.netname = ReadString_Zoned();
}
entity minigame_ent = world;
- if ( self.classname == "minigame" )
+ if ( this.classname == "minigame" )
{
- minigame_ent = self;
+ minigame_ent = this;
if ( sf & MINIG_SF_CREATE )
{
- self.entremove = minigame_entremove;
- self.descriptor = minigame_get_descriptor(ReadString_Raw());
- if ( !self.descriptor )
+ this.entremove = minigame_entremove;
+ this.descriptor = minigame_get_descriptor(ReadString_Raw());
+ if ( !this.descriptor )
LOG_TRACE("Got a minigame without a client-side descriptor!\n");
else
- self.minigame_event = self.descriptor.minigame_event;
+ this.minigame_event = this.descriptor.minigame_event;
}
if ( sf & MINIG_SF_UPDATE )
- self.minigame_flags = ReadLong();
+ this.minigame_flags = ReadLong();
}
- else if ( self.classname == "minigame_player" )
+ else if ( this.classname == "minigame_player" )
{
float activate = 0;
if ( sf & MINIG_SF_CREATE )
{
- self.entremove = minigame_player_entremove;
+ this.entremove = minigame_player_entremove;
minigame_read_owner();
float ent = ReadLong();
- self.minigame_playerslot = ent;
+ this.minigame_playerslot = ent;
LOG_DEBUG("Player: ",entcs_GetName(ent-1),"\n");
- activate = (ent == player_localnum+1 && self.owner && self.owner != active_minigame);
+ activate = (ent == player_localnum+1 && this.owner && this.owner != active_minigame);
}
- minigame_ent = self.owner;
+ minigame_ent = this.owner;
if ( sf & MINIG_SF_UPDATE )
- self.team = ReadByte();
+ this.team = ReadByte();
if ( activate )
{
- minigame_self = self;
- activate_minigame(self.owner);
+ minigame_self = this;
+ activate_minigame(this.owner);
}
}
MINIGAME_SIMPLELINKED_ENTITIES
if ( minigame_ent )
- minigame_ent.minigame_event(minigame_ent,"network_receive",self,sf);
+ minigame_ent.minigame_event(minigame_ent,"network_receive",this,sf);
if ( sf & MINIG_SF_CREATE )
{
- LOG_DEBUG("CL Reading entity: ",ftos(etof(self)),
- " classname:",self.classname," enttype:",ftos(self.enttype) );
- LOG_DEBUG(" sf:",ftos(sf)," netname:",self.netname,"\n\n");
+ LOG_DEBUG("CL Reading entity: ",ftos(etof(this)),
+ " classname:",this.classname," enttype:",ftos(this.enttype) );
+ LOG_DEBUG(" sf:",ftos(sf)," netname:",this.netname,"\n\n");
}
return true;
}
float autocvar_sv_minigames_pong_ai_thinkspeed;
float autocvar_sv_minigames_pong_ai_tolerance;
-void pong_ball_think();
+void pong_ball_think(entity this);
// Throws a ball in a random direction and sets the think function
void pong_ball_throw(entity ball)
while ( fabs(sin(angle)) < 0.17 || fabs(cos(angle)) < 0.17 );
ball.velocity_x = cos(angle)*autocvar_sv_minigames_pong_ball_speed;
ball.velocity_y = sin(angle)*autocvar_sv_minigames_pong_ball_speed;
- ball.think = pong_ball_think;
+ setthink(ball, pong_ball_think);
ball.nextthink = time;
ball.team = 0;
ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
}
// Think equivalent of pong_ball_throw, used to delay throws
-void pong_ball_throwthink()
-{SELFPARAM();
+void pong_ball_throwthink(entity this)
+{
pong_ball_throw(self);
}
{
ball.velocity = '0 0 0';
ball.origin = '0.5 0.5 0';
- ball.think = SUB_NullThink;
+ setthink(ball, SUB_NullThink);
ball.team = 0;
ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
- ball.think = pong_ball_throwthink;
+ setthink(ball, pong_ball_throwthink);
ball.nextthink = time + autocvar_sv_minigames_pong_ball_wait;
}
}
// Moves the ball around
-void pong_ball_think()
-{SELFPARAM();
+void pong_ball_think(entity this)
+{
float think_speed = autocvar_sys_ticrate;
- self.nextthink = time + think_speed;
+ this.nextthink = time + think_speed;
- self.origin_x += self.velocity_x * think_speed;
- self.origin_y += self.velocity_y * think_speed;
- self.SendFlags |= MINIG_SF_UPDATE;
+ this.origin_x += this.velocity_x * think_speed;
+ this.origin_y += this.velocity_y * think_speed;
+ this.SendFlags |= MINIG_SF_UPDATE;
int i;
for ( i = 1; i <= PONG_MAX_PLAYERS; i++ )
- if ( pong_paddle_hit(self, i) )
+ if ( pong_paddle_hit(this, i) )
{
- pong_paddle_bounce(self,i);
- self.team = i;
- self.SendFlags |= PONG_SF_BALLTEAM;
+ pong_paddle_bounce(this,i);
+ this.team = i;
+ this.SendFlags |= PONG_SF_BALLTEAM;
return;
}
- if ( self.origin_y <= self.pong_length )
+ if ( this.origin_y <= this.pong_length )
{
- if ( !pong_goal(self,3) )
+ if ( !pong_goal(this,3) )
{
- self.origin_y = self.pong_length;
- self.velocity_y *= -1;
+ this.origin_y = this.pong_length;
+ this.velocity_y *= -1;
}
}
- else if ( self.origin_y >= 1-self.pong_length )
+ else if ( this.origin_y >= 1-this.pong_length )
{
- if ( !pong_goal(self,4) )
+ if ( !pong_goal(this,4) )
{
- self.origin_y = 1-self.pong_length;
- self.velocity_y *= -1;
+ this.origin_y = 1-this.pong_length;
+ this.velocity_y *= -1;
}
}
- if ( self.origin_x <= self.pong_length )
+ if ( this.origin_x <= this.pong_length )
{
- if ( !pong_goal(self,2) )
+ if ( !pong_goal(this,2) )
{
- self.origin_x = self.pong_length;
- self.velocity_x *= -1;
+ this.origin_x = this.pong_length;
+ this.velocity_x *= -1;
}
}
- else if ( self.origin_x >= 1-self.pong_length )
+ else if ( this.origin_x >= 1-this.pong_length )
{
- if ( !pong_goal(self,1) )
+ if ( !pong_goal(this,1) )
{
- self.origin_x = 1-self.pong_length;
- self.velocity_x *= -1;
+ this.origin_x = 1-this.pong_length;
+ this.velocity_x *= -1;
}
}
}
// AI action
-void pong_ai_think()
-{SELFPARAM();
+void pong_ai_think(entity this)
+{
float think_speed = autocvar_sv_minigames_pong_ai_thinkspeed;
- self.nextthink = time + think_speed;
+ this.nextthink = time + think_speed;
float distance;
float next_distance;
float min_distance = 1;
entity ball = world;
entity mayball = world;
- while ( ( mayball = findentity(mayball,owner,self.owner) ) )
+ while ( ( mayball = findentity(mayball,owner,this.owner) ) )
if ( mayball.classname == "pong_ball" )
{
- distance = vlen(mayball.origin-self.pong_ai_paddle.origin);
- next_distance = vlen(mayball.origin+mayball.velocity-self.pong_ai_paddle.origin);
+ distance = vlen(mayball.origin-this.pong_ai_paddle.origin);
+ next_distance = vlen(mayball.origin+mayball.velocity-this.pong_ai_paddle.origin);
if ( distance < min_distance && ( distance < 0.5 || next_distance < distance ) )
{
min_distance = distance;
}
float target = 0.5;
- float self_pos;
+ float my_pos;
- if ( self.team <= 2 )
+ if ( this.team <= 2 )
{
if ( ball )
target = ball.origin_y + ball.velocity_y*think_speed;
- self_pos = self.pong_ai_paddle.origin_y;
+ my_pos = this.pong_ai_paddle.origin_y;
}
else
{
if ( ball )
target = ball.origin_x + ball.velocity_x*think_speed;
- self_pos = self.pong_ai_paddle.origin_x;
+ my_pos = this.pong_ai_paddle.origin_x;
}
- distance = self.pong_length/2 * autocvar_sv_minigames_pong_ai_tolerance
+ distance = this.pong_length/2 * autocvar_sv_minigames_pong_ai_tolerance
+ autocvar_sv_minigames_pong_paddle_speed * think_speed;
- if (target < self_pos - distance)
- self.pong_keys = PONG_KEY_DECREASE;
- else if (target > self_pos + distance)
- self.pong_keys = PONG_KEY_INCREASE;
+ if (target < my_pos - distance)
+ this.pong_keys = PONG_KEY_DECREASE;
+ else if (target > my_pos + distance)
+ this.pong_keys = PONG_KEY_INCREASE;
else
- self.pong_keys = 0;
+ this.pong_keys = 0;
}
entity pong_ai_spawn(entity paddle)
entity ai = msle_spawn(paddle.owner,"pong_ai");
ai.minigame_players = ai;
ai.team = paddle.team;
- ai.think = pong_ai_think;
+ setthink(ai, pong_ai_think);
ai.nextthink = time;
ai.pong_ai_paddle = paddle;
}
// Moves the paddle
-void pong_paddle_think()
-{SELFPARAM();
+void pong_paddle_think(entity this)
+{
float think_speed = autocvar_sys_ticrate;
- self.nextthink = time + think_speed;
+ this.nextthink = time + think_speed;
- if ( self.realowner.minigame_players.pong_keys == PONG_KEY_INCREASE ||
- self.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
+ if ( this.realowner.minigame_players.pong_keys == PONG_KEY_INCREASE ||
+ this.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
{
float movement = autocvar_sv_minigames_pong_paddle_speed * think_speed;
- float halflen = self.pong_length/2;
+ float halflen = this.pong_length/2;
- if ( self.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
+ if ( this.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
movement *= -1;
- if ( self.team > 2 )
- self.origin_x = bound(halflen, self.origin_x+movement, 1-halflen);
+ if ( this.team > 2 )
+ this.origin_x = bound(halflen, this.origin_x+movement, 1-halflen);
else
- self.origin_y = bound(halflen, self.origin_y+movement, 1-halflen);
+ this.origin_y = bound(halflen, this.origin_y+movement, 1-halflen);
- self.SendFlags |= MINIG_SF_UPDATE;
+ this.SendFlags |= MINIG_SF_UPDATE;
}
}
entity paddle = msle_spawn(minigame,"pong_paddle");
paddle.pong_length = autocvar_sv_minigames_pong_paddle_size;
paddle.origin = pong_team_to_paddlepos(pl_team);
- paddle.think = pong_paddle_think;
+ setthink(paddle, pong_paddle_think);
paddle.nextthink = time;
paddle.team = pl_team;
paddle.mins = pong_team_to_box_halfsize(pl_team,-paddle.pong_length,-1/16);
}
void snake_move_head(entity minigame, entity head);
-void snake_head_think()
+void snake_head_think(entity this)
{
- SELFPARAM();
- entity minigame = self.owner;
+ entity minigame = this.owner;
if(minigame.minigame_flags & SNAKE_TURN_MOVE)
- snake_move_head(minigame, self);
+ snake_move_head(minigame, this);
snake_check_winner(minigame);
- self.nextthink = time + self.snake_delay;
+ this.nextthink = time + this.snake_delay;
}
void minigame_setup_snake(entity minigame, int pteam)
piece.snake_next = world;
piece.snake_prev = world;
piece.snake_last = piece;
- piece.think = snake_head_think;
+ setthink(piece, snake_head_think);
piece.snake_delay = autocvar_sv_minigames_snake_delay_initial;
piece.nextthink = time + 0.1;
minigame_server_sendflags(piece,MINIG_SF_ALL);
if ( sf & MINIG_SF_CREATE )
{
- WriteShort(MSG_ENTITY,msle_id(self.classname));
- WriteString(MSG_ENTITY,self.netname);
+ WriteShort(MSG_ENTITY,msle_id(this.classname));
+ WriteString(MSG_ENTITY,this.netname);
}
- entity minigame_ent = self.owner;
+ entity minigame_ent = this.owner;
- if ( self.classname == "minigame" )
+ if ( this.classname == "minigame" )
{
- minigame_ent = self;
+ minigame_ent = this;
if ( sf & MINIG_SF_CREATE )
- WriteString(MSG_ENTITY,self.descriptor.netname);
+ WriteString(MSG_ENTITY,this.descriptor.netname);
if ( sf & MINIG_SF_UPDATE )
- WriteLong(MSG_ENTITY,self.minigame_flags);
+ WriteLong(MSG_ENTITY,this.minigame_flags);
}
- else if ( self.classname == "minigame_player" )
+ else if ( this.classname == "minigame_player" )
{
if ( sf & MINIG_SF_CREATE )
{
- WriteString(MSG_ENTITY,self.owner.netname);
- WriteLong(MSG_ENTITY,etof(self.minigame_players));
+ WriteString(MSG_ENTITY,this.owner.netname);
+ WriteLong(MSG_ENTITY,etof(this.minigame_players));
}
if ( sf & MINIG_SF_UPDATE )
- WriteByte(MSG_ENTITY,self.team);
+ WriteByte(MSG_ENTITY,this.team);
}
MINIGAME_SIMPLELINKED_ENTITIES
- minigame_ent.minigame_event(minigame_ent,"network_send",self,sf);
+ minigame_ent.minigame_event(minigame_ent,"network_send",this,sf);
return true;
}
int minigame_addplayer(entity minigame_session, entity player)
-{SELFPARAM();
+{
if ( player.active_minigame )
{
if ( player.active_minigame == minigame_session )
remove (this);
}
-void M_Mage_Attack_Spike_Touch()
+void M_Mage_Attack_Spike_Touch(entity this)
{
- SELFPARAM();
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
M_Mage_Attack_Spike_Explode(self);
}
.float wait;
// copied from W_Seeker_Think
-void M_Mage_Attack_Spike_Think()
-{SELFPARAM();
- if (time > self.ltime || (self.enemy && self.enemy.health <= 0) || self.owner.health <= 0) {
- self.projectiledeathtype |= HITTYPE_SPLASH;
- M_Mage_Attack_Spike_Explode(self);
+void M_Mage_Attack_Spike_Think(entity this)
+{
+ if (time > this.ltime || (this.enemy && this.enemy.health <= 0) || this.owner.health <= 0) {
+ this.projectiledeathtype |= HITTYPE_SPLASH;
+ M_Mage_Attack_Spike_Explode(this);
}
- float spd = vlen(self.velocity);
+ float spd = vlen(this.velocity);
spd = bound(
spd - (autocvar_g_monster_mage_attack_spike_decel) * frametime,
(autocvar_g_monster_mage_attack_spike_speed_max),
spd + (autocvar_g_monster_mage_attack_spike_accel) * frametime
);
- if (self.enemy != world)
- if (self.enemy.takedamage != DAMAGE_AIM || IS_DEAD(self.enemy))
- self.enemy = world;
+ if (this.enemy != world)
+ if (this.enemy.takedamage != DAMAGE_AIM || IS_DEAD(this.enemy))
+ this.enemy = world;
- if (self.enemy != world)
+ if (this.enemy != world)
{
- entity e = self.enemy;
+ entity e = this.enemy;
vector eorg = 0.5 * (e.absmin + e.absmax);
float turnrate = (autocvar_g_monster_mage_attack_spike_turnrate); // how fast to turn
- vector desireddir = normalize(eorg - self.origin);
- vector olddir = normalize(self.velocity); // get my current direction
+ vector desireddir = normalize(eorg - this.origin);
+ vector olddir = normalize(this.velocity); // get my current direction
// Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
- if ((autocvar_g_monster_mage_attack_spike_smart) && vdist(eorg - self.origin, >, autocvar_g_monster_mage_attack_spike_smart_mindist))
+ if ((autocvar_g_monster_mage_attack_spike_smart) && vdist(eorg - this.origin, >, autocvar_g_monster_mage_attack_spike_smart_mindist))
{
- // Is it a better idea (shorter distance) to trace to the target itself?
- if ( vlen2(self.origin + olddir * self.wait) < vlen2(eorg - self.origin))
- traceline(self.origin, self.origin + olddir * self.wait, false, self);
+ // Is it a better idea (shorter distance) to trace to the target itthis?
+ if ( vlen2(this.origin + olddir * this.wait) < vlen2(eorg - this.origin))
+ traceline(this.origin, this.origin + olddir * this.wait, false, this);
else
- traceline(self.origin, eorg, false, self);
+ traceline(this.origin, eorg, false, this);
// Setup adaptive tracelength
- self.wait = bound((autocvar_g_monster_mage_attack_spike_smart_trace_min), vlen(self.origin - trace_endpos), self.wait = (autocvar_g_monster_mage_attack_spike_smart_trace_max));
+ this.wait = bound((autocvar_g_monster_mage_attack_spike_smart_trace_min), vlen(this.origin - trace_endpos), this.wait = (autocvar_g_monster_mage_attack_spike_smart_trace_max));
// Calc how important it is that we turn and add this to the desierd (enemy) dir.
desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
}
vector newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
- self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
+ this.velocity = newdir * spd; // make me fly in the new direction at my flight speed
}
///////////////
- //self.angles = vectoangles(self.velocity); // turn model in the new flight direction
- self.nextthink = time;// + 0.05; // csqc projectiles
- UpdateCSQCProjectile(self);
+ //this.angles = vectoangles(this.velocity); // turn model in the new flight direction
+ this.nextthink = time;// + 0.05; // csqc projectiles
+ UpdateCSQCProjectile(this);
}
void M_Mage_Attack_Spike(entity this, vector dir)
entity missile = spawn();
missile.owner = missile.realowner = this;
- missile.think = M_Mage_Attack_Spike_Think;
+ setthink(missile, M_Mage_Attack_Spike_Think);
missile.ltime = time + 7;
missile.nextthink = time;
missile.solid = SOLID_BBOX;
missile.velocity = dir * 400;
missile.avelocity = '300 300 300';
missile.enemy = this.enemy;
- missile.touch = M_Mage_Attack_Spike_Touch;
+ settouch(missile, M_Mage_Attack_Spike_Touch);
this.mage_spike = missile;
#include <common/effects/qc/all.qh>
-void M_Shambler_Attack_Lightning_Explode()
-{SELFPARAM();
+void M_Shambler_Attack_Lightning_Explode(entity this)
+{
entity head;
- sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
- Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1);
+ sound(this, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
+ Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
- self.event_damage = func_null;
- self.takedamage = DAMAGE_NO;
- self.movetype = MOVETYPE_NONE;
- self.velocity = '0 0 0';
+ this.event_damage = func_null;
+ this.takedamage = DAMAGE_NO;
+ this.movetype = MOVETYPE_NONE;
+ this.velocity = '0 0 0';
- if(self.movetype == MOVETYPE_NONE)
- self.velocity = self.oldvelocity;
+ if(this.movetype == MOVETYPE_NONE)
+ this.velocity = this.oldvelocity;
- RadiusDamage (self, self.realowner, (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_radius), world, world, (autocvar_g_monster_shambler_attack_lightning_force), self.projectiledeathtype, other);
+ RadiusDamage (this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_radius), world, world, (autocvar_g_monster_shambler_attack_lightning_force), this.projectiledeathtype, other);
- for(head = findradius(self.origin, (autocvar_g_monster_shambler_attack_lightning_radius_zap)); head; head = head.chain) if(head != self.realowner) if(head.takedamage)
+ for(head = findradius(this.origin, (autocvar_g_monster_shambler_attack_lightning_radius_zap)); head; head = head.chain) if(head != this.realowner) if(head.takedamage)
{
- te_csqc_lightningarc(self.origin, head.origin);
- Damage(head, self, self.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(self), DEATH_MONSTER_SHAMBLER_ZAP.m_id, head.origin, '0 0 0');
+ te_csqc_lightningarc(this.origin, head.origin);
+ Damage(head, this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_ZAP.m_id, head.origin, '0 0 0');
}
- self.think = SUB_Remove_self;
- self.nextthink = time + 0.2;
+ setthink(this, SUB_Remove);
+ this.nextthink = time + 0.2;
}
void M_Shambler_Attack_Lightning_Explode_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, M_Shambler_Attack_Lightning_Explode());
+ M_Shambler_Attack_Lightning_Explode(this);
}
void M_Shambler_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
}
-void M_Shambler_Attack_Lightning_Touch()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void M_Shambler_Attack_Lightning_Touch(entity this)
+{
+ PROJECTILE_TOUCH(this);
self.use(this, NULL, NULL);
}
-void M_Shambler_Attack_Lightning_Think()
-{SELFPARAM();
- self.nextthink = time;
- if (time > self.cnt)
+void M_Shambler_Attack_Lightning_Think(entity this)
+{
+ this.nextthink = time;
+ if (time > this.cnt)
{
other = world;
- M_Shambler_Attack_Lightning_Explode();
+ M_Shambler_Attack_Lightning_Explode(this);
return;
}
}
gren.cnt = time + 5;
gren.nextthink = time;
- gren.think = M_Shambler_Attack_Lightning_Think;
+ setthink(gren, M_Shambler_Attack_Lightning_Think);
gren.use = M_Shambler_Attack_Lightning_Explode_use;
- gren.touch = M_Shambler_Attack_Lightning_Touch;
+ settouch(gren, M_Shambler_Attack_Lightning_Touch);
gren.takedamage = DAMAGE_YES;
gren.health = 50;
WITHSELF(this, M_Spider_Attack_Web_Explode());
}
-void M_Spider_Attack_Web_Touch()
+void M_Spider_Attack_Web_Touch(entity this)
{
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
M_Spider_Attack_Web_Explode();
}
-void adaptor_think2use_hittype_splash();
+void adaptor_think2use_hittype_splash(entity this);
void M_Spider_Attack_Web(entity this)
{
entity proj = new(plasma);
proj.owner = proj.realowner = this;
proj.use = M_Spider_Attack_Web_Explode_use;
- proj.think = adaptor_think2use_hittype_splash;
+ setthink(proj, adaptor_think2use_hittype_splash);
proj.bot_dodge = true;
proj.bot_dodgerating = 0;
proj.nextthink = time + 5;
//proj.glow_color = 45;
proj.movetype = MOVETYPE_BOUNCE;
W_SetupProjVelocity_Explicit(proj, v_forward, v_up, (autocvar_g_monster_spider_attack_web_speed), (autocvar_g_monster_spider_attack_web_speed_up), 0, 0, false);
- proj.touch = M_Spider_Attack_Web_Touch;
+ settouch(proj, M_Spider_Attack_Web_Touch);
setsize(proj, '-4 -4 -4', '4 4 4');
proj.takedamage = DAMAGE_NO;
proj.damageforcescale = 0;
float autocvar_g_monster_wyvern_attack_fireball_radius;
float autocvar_g_monster_wyvern_attack_fireball_speed;
-void M_Wyvern_Attack_Fireball_Explode();
-void M_Wyvern_Attack_Fireball_Touch();
+void M_Wyvern_Attack_Fireball_Explode(entity this);
+void M_Wyvern_Attack_Fireball_Touch(entity this);
SOUND(WyvernAttack_FIRE, W_Sound("electro_fire"));
METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire))
missile.velocity = w_shotdir * (autocvar_g_monster_wyvern_attack_fireball_speed);
missile.avelocity = '300 300 300';
missile.nextthink = time + 5;
- missile.think = M_Wyvern_Attack_Fireball_Explode;
- missile.touch = M_Wyvern_Attack_Fireball_Touch;
+ setthink(missile, M_Wyvern_Attack_Fireball_Explode);
+ settouch(missile, M_Wyvern_Attack_Fireball_Touch);
CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
}
}
-METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this)) {
+METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor)) {
TC(WyvernAttack, this);
return true;
}
const float wyvern_anim_death = 4;
*/
-void M_Wyvern_Attack_Fireball_Explode()
+void M_Wyvern_Attack_Fireball_Explode(entity this)
{
- SELFPARAM();
- Send_Effect(EFFECT_FIREBALL_EXPLODE, self.origin, '0 0 0', 1);
+ Send_Effect(EFFECT_FIREBALL_EXPLODE, this.origin, '0 0 0', 1);
- entity own = self.realowner;
+ entity own = this.realowner;
- RadiusDamage(self, own, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force, world, world, autocvar_g_monster_wyvern_attack_fireball_radius, self.projectiledeathtype, world);
+ RadiusDamage(this, own, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force, world, world, autocvar_g_monster_wyvern_attack_fireball_radius, this.projectiledeathtype, world);
FOREACH_ENTITY_FLOAT(takedamage, DAMAGE_AIM,
{
- if(vdist(it.origin - self.origin, <=, autocvar_g_monster_wyvern_attack_fireball_radius))
- Fire_AddDamage(it, own, 5 * MONSTER_SKILLMOD(own), autocvar_g_monster_wyvern_attack_fireball_damagetime, self.projectiledeathtype);
+ if(vdist(it.origin - this.origin, <=, autocvar_g_monster_wyvern_attack_fireball_radius))
+ Fire_AddDamage(it, own, 5 * MONSTER_SKILLMOD(own), autocvar_g_monster_wyvern_attack_fireball_damagetime, this.projectiledeathtype);
});
- remove(self);
+ remove(this);
}
-void M_Wyvern_Attack_Fireball_Touch()
+void M_Wyvern_Attack_Fireball_Touch(entity this)
{
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
- M_Wyvern_Attack_Fireball_Explode();
+ M_Wyvern_Attack_Fireball_Explode(this);
}
bool M_Wyvern_Attack(int attack_type, entity actor, entity targ)
.vector moveto;
-void M_Zombie_Attack_Leap_Touch()
-{SELFPARAM();
+void M_Zombie_Attack_Leap_Touch(entity this)
+{
if (self.health <= 0)
return;
angles_face = vectoangles(self.moveto - self.origin);
angles_face = normalize(angles_face) * (autocvar_g_monster_zombie_attack_leap_force);
Damage(other, self, self, (autocvar_g_monster_zombie_attack_leap_damage) * MONSTER_SKILLMOD(self), DEATH_MONSTER_ZOMBIE_JUMP.m_id, other.origin, angles_face);
- self.touch = Monster_Touch; // instantly turn it off to stop damage spam
+ settouch(self, Monster_Touch); // instantly turn it off to stop damage spam
self.state = 0;
}
if (trace_dphitcontents)
{
self.state = 0;
- self.touch = Monster_Touch;
+ settouch(self, Monster_Touch);
}
}
}
.void(entity) monster_delayedfunc;
-void Monster_Delay_Action_self();
void Monster_Delay_Action(entity this)
{
if(Monster_ValidTarget(this.owner, this.owner.enemy)) { this.monster_delayedfunc(this.owner); }
if(this.cnt > 1)
{
this.cnt -= 1;
- this.think = Monster_Delay_Action_self;
+ setthink(this, Monster_Delay_Action);
this.nextthink = time + this.count;
}
else
{
- this.think = SUB_Remove_self;
+ setthink(this, SUB_Remove);
this.nextthink = time;
}
}
-void Monster_Delay_Action_self()
-{
- SELFPARAM();
- Monster_Delay_Action(self);
-}
-
void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func)
{
// deferred attacking, checks if monster is still alive and target is still valid before attacking
entity e = spawn();
- e.think = Monster_Delay_Action_self;
+ setthink(e, Monster_Delay_Action);
e.nextthink = time + defer_amnt;
e.count = defer_amnt;
e.owner = this;
return true;
}
-bool Monster_Attack_Leap(entity this, vector anm, void() touchfunc, vector vel, float animtime)
+bool Monster_Attack_Leap(entity this, vector anm, void(entity this) touchfunc, vector vel, float animtime)
{
if(!Monster_Attack_Leap_Check(this, vel))
return false;
if(this.flags & FL_MONSTER)
this.state = MONSTER_ATTACK_RANGED;
- this.touch = touchfunc;
+ settouch(this, touchfunc);
this.origin_z += 1;
this.velocity = vel;
UNSET_ONGROUND(this);
mon.mr_anim(mon, this);
}
-void Monster_Touch()
-{SELFPARAM();
+void Monster_Touch(entity this)
+{
if(other == world) { return; }
if(other.monster_attack)
return true;
}
-void Monster_Respawn() { SELFPARAM(); Monster_Spawn(this, this.monsterid); }
+void Monster_Respawn(entity this) { Monster_Spawn(this, this.monsterid); }
void Monster_Dead_Fade(entity this)
{
if(Monster_Respawn_Check(this))
{
this.spawnflags |= MONSTERFLAG_RESPAWNED;
- this.think = Monster_Respawn;
+ setthink(this, Monster_Respawn);
this.nextthink = time + this.respawntime;
this.monster_lifetime = 0;
this.deadflag = DEAD_RESPAWNING;
if(this.state == MONSTER_ATTACK_RANGED && IS_ONGROUND(this))
{
this.state = 0;
- this.touch = Monster_Touch;
+ settouch(this, Monster_Touch);
}
if(this.state && time >= this.attack_finished_single[0])
remove(this);
}
-void Monster_Dead_Think()
-{SELFPARAM();
+void Monster_Dead_Think(entity this)
+{
this.nextthink = time + this.ticrate;
if(this.monster_lifetime != 0)
if(!(this.spawnflags & MONSTERFLAG_APPEAR))
return false;
- this.think = func_null;
+ setthink(this, func_null);
this.monsterid = monster_id; // set so this monster is properly registered (otherwise, normal initialization is used)
this.nextthink = 0;
this.use = Monster_Appear;
// number of monsters spawned with mobspawn command
totalspawned -= 1;
- this.think = SUB_Remove_self;
+ setthink(this, SUB_Remove);
this.nextthink = time + 0.1;
this.event_damage = func_null;
}
void Monster_Dead(entity this, entity attacker, float gibbed)
{
- this.think = Monster_Dead_Think;
+ setthink(this, Monster_Dead_Think);
this.nextthink = time;
this.monster_lifetime = time + 5;
this.enemy = world;
this.movetype = MOVETYPE_TOSS;
this.moveto = this.origin;
- this.touch = Monster_Touch; // reset incase monster was pouncing
+ settouch(this, Monster_Touch); // reset incase monster was pouncing
this.reset = func_null;
this.state = 0;
this.attack_finished_single[0] = 0;
{
Violence_GibSplash(this, 1, 0.5, attacker);
- this.think = SUB_Remove_self;
+ setthink(this, SUB_Remove);
this.nextthink = time + 0.1;
}
}
*/
}
-void Monster_Think()
-{SELFPARAM();
- this.think = Monster_Think;
+void Monster_Think(entity this)
+{
+ setthink(this, Monster_Think);
this.nextthink = this.ticrate;
if(this.monster_lifetime)
}
}
- this.think = Monster_Think;
+ setthink(this, Monster_Think);
this.nextthink = time + this.ticrate;
if(MUTATOR_CALLHOOK(MonsterSpawn, this))
this.damagedbycontents = true;
this.monsterid = mon_id;
this.event_damage = Monster_Damage;
- this.touch = Monster_Touch;
+ settouch(this, Monster_Touch);
this.use = Monster_Use;
this.solid = SOLID_BBOX;
this.movetype = MOVETYPE_WALK;
void monster_setupcolors(entity this);
-void Monster_Touch();
+void Monster_Touch(entity this);
void Monster_Move_2D(entity this, float mspeed, float allow_jumpoff);
float Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, float dostop);
-bool Monster_Attack_Leap(entity this, vector anm, void() touchfunc, vector vel, float animtime);
+bool Monster_Attack_Leap(entity this, vector anm, void(entity this) touchfunc, vector vel, float animtime);
entity Monster_FindTarget(entity this);
void buff_Init(entity ent);
void buff_Init_Compat(entity ent, entity replacement);
#define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
- self.buffs = b.m_itemid; \
- self.team = t; \
- buff_Init(self); \
+ this.buffs = b.m_itemid; \
+ this.team = t; \
+ buff_Init(this); \
}
#define BUFF_SPAWNFUNCS(e, b) \
BUFF_SPAWNFUNC(e, b, 0) \
BUFF_SPAWNFUNC(e##_team2, b, NUM_TEAM_2) \
BUFF_SPAWNFUNC(e##_team3, b, NUM_TEAM_3) \
BUFF_SPAWNFUNC(e##_team4, b, NUM_TEAM_4)
- #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(self, r); }
+ #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(this, r); }
#else
#define BUFF_SPAWNFUNC(e, b, t)
#define BUFF_SPAWNFUNCS(e, b)
}
// buff item
-float buff_Waypoint_visible_for_player(entity plr)
-{SELFPARAM();
- if(!self.owner.buff_active && !self.owner.buff_activetime)
+bool buff_Waypoint_visible_for_player(entity this, entity player, entity view)
+{
+ if(!this.owner.buff_active && !this.owner.buff_activetime)
return false;
- if (plr.buffs)
+ if (view.buffs)
{
- return plr.cvar_cl_buffs_autoreplace == false || plr.buffs != self.owner.buffs;
+ return view.cvar_cl_buffs_autoreplace == false || view.buffs != this.owner.buffs;
}
- return WaypointSprite_visible_for_player(plr);
+ return WaypointSprite_visible_for_player(this, player, view);
}
void buff_Waypoint_Spawn(entity e)
e.buff_waypoint.waypointsprite_visible_for_player = buff_Waypoint_visible_for_player;
}
-void buff_SetCooldown(float cd)
-{SELFPARAM();
+void buff_SetCooldown(entity this, float cd)
+{
cd = max(0, cd);
- if(!self.buff_waypoint)
- buff_Waypoint_Spawn(self);
+ if(!this.buff_waypoint)
+ buff_Waypoint_Spawn(this);
- WaypointSprite_UpdateBuildFinished(self.buff_waypoint, time + cd);
- self.buff_activetime = cd;
- self.buff_active = !cd;
+ WaypointSprite_UpdateBuildFinished(this.buff_waypoint, time + cd);
+ this.buff_activetime = cd;
+ this.buff_active = !cd;
}
void buff_Respawn(entity this)
if(!MoveToRandomMapLocation(this, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY,
((autocvar_g_buffs_random_location_attempts > 0) ? autocvar_g_buffs_random_location_attempts : 10), 1024, 256))
{
- entity spot = SelectSpawnPoint(true);
+ entity spot = SelectSpawnPoint(this, true);
setorigin(this, spot.origin);
this.velocity = ((randomvec() * 100) + '0 0 200');
this.angles = spot.angles;
sound(this, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
}
-void buff_Touch()
-{SELFPARAM();
+void buff_Touch(entity this)
+{
if(gameover) { return; }
if(ITEM_TOUCH_NEEDKILL())
ent.buffs = RandomSelection_chosen_float;
}
-void buff_Think()
-{SELFPARAM();
- if(self.buffs != self.oldbuffs)
+void buff_Think(entity this)
+{
+ if(this.buffs != this.oldbuffs)
{
- entity buff = buff_FirstFromFlags(self.buffs);
- self.color = buff.m_color;
- self.glowmod = buff_GlowColor(buff);
- self.skin = buff.m_skin;
+ entity buff = buff_FirstFromFlags(this.buffs);
+ this.color = buff.m_color;
+ this.glowmod = buff_GlowColor(buff);
+ this.skin = buff.m_skin;
- setmodel(self, MDL_BUFF);
+ setmodel(this, MDL_BUFF);
- if(self.buff_waypoint)
+ if(this.buff_waypoint)
{
- //WaypointSprite_Disown(self.buff_waypoint, 1);
- WaypointSprite_Kill(self.buff_waypoint);
- buff_Waypoint_Spawn(self);
- if(self.buff_activetime)
- WaypointSprite_UpdateBuildFinished(self.buff_waypoint, time + self.buff_activetime - frametime);
+ //WaypointSprite_Disown(this.buff_waypoint, 1);
+ WaypointSprite_Kill(this.buff_waypoint);
+ buff_Waypoint_Spawn(this);
+ if(this.buff_activetime)
+ WaypointSprite_UpdateBuildFinished(this.buff_waypoint, time + this.buff_activetime - frametime);
}
- self.oldbuffs = self.buffs;
+ this.oldbuffs = this.buffs;
}
if(!gameover)
if((round_handler_IsActive() && !round_handler_IsRoundStarted()) || time >= game_starttime)
- if(!self.buff_activetime_updated)
+ if(!this.buff_activetime_updated)
{
- buff_SetCooldown(self.buff_activetime);
- self.buff_activetime_updated = true;
+ buff_SetCooldown(this, this.buff_activetime);
+ this.buff_activetime_updated = true;
}
- if(!self.buff_active && !self.buff_activetime)
- if(!self.owner || STAT(FROZEN, self.owner) || IS_DEAD(self.owner) || !self.owner.iscreature || !(self.owner.buffs & self.buffs))
+ if(!this.buff_active && !this.buff_activetime)
+ if(!this.owner || STAT(FROZEN, this.owner) || IS_DEAD(this.owner) || !this.owner.iscreature || !(this.owner.buffs & this.buffs))
{
- buff_SetCooldown(autocvar_g_buffs_cooldown_respawn + frametime);
- self.owner = world;
+ buff_SetCooldown(this, autocvar_g_buffs_cooldown_respawn + frametime);
+ this.owner = world;
if(autocvar_g_buffs_randomize)
- buff_NewType(self, self.buffs);
+ buff_NewType(this, this.buffs);
- if(autocvar_g_buffs_random_location || (self.spawnflags & 64))
- buff_Respawn(self);
+ if(autocvar_g_buffs_random_location || (this.spawnflags & 64))
+ buff_Respawn(this);
}
- if(self.buff_activetime)
+ if(this.buff_activetime)
if(!gameover)
if((round_handler_IsActive() && !round_handler_IsRoundStarted()) || time >= game_starttime)
{
- self.buff_activetime = max(0, self.buff_activetime - frametime);
+ this.buff_activetime = max(0, this.buff_activetime - frametime);
- if(!self.buff_activetime)
+ if(!this.buff_activetime)
{
- self.buff_active = true;
- sound(self, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTN_NORM);
- Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
+ this.buff_active = true;
+ sound(this, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTN_NORM);
+ Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
}
}
- if(self.buff_active)
+ if(this.buff_active)
{
- if(self.team && !self.buff_waypoint)
- buff_Waypoint_Spawn(self);
+ if(this.team && !this.buff_waypoint)
+ buff_Waypoint_Spawn(this);
- if(self.lifetime)
- if(time >= self.lifetime)
- buff_Respawn(self);
+ if(this.lifetime)
+ if(time >= this.lifetime)
+ buff_Respawn(this);
}
- self.nextthink = time;
- //self.angles_y = time * 110.1;
+ this.nextthink = time;
+ //this.angles_y = time * 110.1;
}
-void buff_Waypoint_Reset()
-{SELFPARAM();
- WaypointSprite_Kill(self.buff_waypoint);
+void buff_Waypoint_Reset(entity this)
+{
+ WaypointSprite_Kill(this.buff_waypoint);
- if(self.buff_activetime) { buff_Waypoint_Spawn(self); }
+ if(this.buff_activetime) { buff_Waypoint_Spawn(this); }
}
void buff_Reset(entity this)
if(autocvar_g_buffs_randomize)
buff_NewType(this, this.buffs);
this.owner = world;
- buff_SetCooldown(autocvar_g_buffs_cooldown_activate);
- buff_Waypoint_Reset();
+ buff_SetCooldown(this, autocvar_g_buffs_cooldown_activate);
+ buff_Waypoint_Reset(this);
this.buff_activetime_updated = false;
if(autocvar_g_buffs_random_location || (this.spawnflags & 64))
float buff_Customize()
{SELFPARAM();
entity player = WaypointSprite_getviewentity(other);
- if(!self.buff_active || (self.team && DIFF_TEAM(player, self)))
+ if(!this.buff_active || (this.team && DIFF_TEAM(player, this)))
{
- self.alpha = 0.3;
- if(self.effects & EF_FULLBRIGHT) { self.effects &= ~(EF_FULLBRIGHT); }
- self.pflags = 0;
+ this.alpha = 0.3;
+ if(this.effects & EF_FULLBRIGHT) { this.effects &= ~(EF_FULLBRIGHT); }
+ this.pflags = 0;
}
else
{
- self.alpha = 1;
- if(!(self.effects & EF_FULLBRIGHT)) { self.effects |= EF_FULLBRIGHT; }
- self.light_lev = 220 + 36 * sin(time);
- self.pflags = PFLAGS_FULLDYNAMIC;
+ this.alpha = 1;
+ if(!(this.effects & EF_FULLBRIGHT)) { this.effects |= EF_FULLBRIGHT; }
+ this.light_lev = 220 + 36 * sin(time);
+ this.pflags = PFLAGS_FULLDYNAMIC;
}
return true;
}
-void buff_Init(entity ent)
-{SELFPARAM();
- if(!cvar("g_buffs")) { remove(ent); return; }
-
- if(!teamplay && ent.team) { ent.team = 0; }
-
- entity buff = buff_FirstFromFlags(self.buffs);
-
- setself(ent);
- if(!self.buffs || buff_Available(buff))
- buff_NewType(self, 0);
-
- self.classname = "item_buff";
- self.solid = SOLID_TRIGGER;
- self.flags = FL_ITEM;
- self.think = buff_Think;
- self.touch = buff_Touch;
- self.reset = buff_Reset;
- self.nextthink = time + 0.1;
- self.gravity = 1;
- self.movetype = MOVETYPE_TOSS;
- self.scale = 1;
- self.skin = buff.m_skin;
- self.effects = EF_FULLBRIGHT | EF_STARDUST | EF_NOSHADOW;
- self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
- self.customizeentityforclient = buff_Customize;
- //self.gravity = 100;
- self.color = buff.m_color;
- self.glowmod = buff_GlowColor(self);
- buff_SetCooldown(autocvar_g_buffs_cooldown_activate + game_starttime);
- self.buff_active = !self.buff_activetime;
- self.pflags = PFLAGS_FULLDYNAMIC;
-
- if(self.spawnflags & 1)
- self.noalign = true;
-
- if(self.noalign)
- self.movetype = MOVETYPE_NONE; // reset by random location
-
- setmodel(self, MDL_BUFF);
- setsize(self, BUFF_MIN, BUFF_MAX);
-
- if(cvar("g_buffs_random_location") || (self.spawnflags & 64))
- buff_Respawn(self);
+void buff_Init(entity this)
+{
+ if(!cvar("g_buffs")) { remove(this); return; }
+
+ if(!teamplay && this.team) { this.team = 0; }
+
+ entity buff = buff_FirstFromFlags(this.buffs);
- setself(this);
+ if(!this.buffs || buff_Available(buff))
+ buff_NewType(this, 0);
+
+ this.classname = "item_buff";
+ this.solid = SOLID_TRIGGER;
+ this.flags = FL_ITEM;
+ setthink(this, buff_Think);
+ settouch(this, buff_Touch);
+ this.reset = buff_Reset;
+ this.nextthink = time + 0.1;
+ this.gravity = 1;
+ this.movetype = MOVETYPE_TOSS;
+ this.scale = 1;
+ this.skin = buff.m_skin;
+ this.effects = EF_FULLBRIGHT | EF_STARDUST | EF_NOSHADOW;
+ this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
+ this.customizeentityforclient = buff_Customize;
+ //this.gravity = 100;
+ this.color = buff.m_color;
+ this.glowmod = buff_GlowColor(this);
+ buff_SetCooldown(this, autocvar_g_buffs_cooldown_activate + game_starttime);
+ this.buff_active = !this.buff_activetime;
+ this.pflags = PFLAGS_FULLDYNAMIC;
+
+ if(this.spawnflags & 1)
+ this.noalign = true;
+
+ if(this.noalign)
+ this.movetype = MOVETYPE_NONE; // reset by random location
+
+ setmodel(this, MDL_BUFF);
+ setsize(this, BUFF_MIN, BUFF_MAX);
+
+ if(cvar("g_buffs_random_location") || (this.spawnflags & 64))
+ buff_Respawn(this);
}
void buff_Init_Compat(entity ent, entity replacement)
buff_Init(ent);
}
-void buff_Vengeance_DelayedDamage()
-{SELFPARAM();
- if(self.enemy)
- Damage(self.enemy, self.owner, self.owner, self.dmg, DEATH_BUFF.m_id, self.enemy.origin, '0 0 0');
+void buff_Vengeance_DelayedDamage(entity this)
+{
+ if(this.enemy)
+ Damage(this.enemy, this.owner, this.owner, this.dmg, DEATH_BUFF.m_id, this.enemy.origin, '0 0 0');
- remove(self);
+ remove(this);
return;
}
dmgent.dmg = frag_damage * autocvar_g_buffs_vengeance_damage_multiplier;
dmgent.enemy = frag_attacker;
dmgent.owner = frag_target;
- dmgent.think = buff_Vengeance_DelayedDamage;
+ setthink(dmgent, buff_Vengeance_DelayedDamage);
dmgent.nextthink = time + 0.1;
}
if(boxesoverlap(self.absmin - pickup_size, self.absmax + pickup_size, it.absmin, it.absmax))
{
- if(it.touch)
+ if(gettouch(it))
{
entity oldother = other;
other = self;
- WITHSELF(it, it.touch());
-
+ WITHSELF(it, gettouch(it)(it));
other = oldother;
}
}
spawnfunc(item_minst_cells)
{
- if (!g_instagib) { remove(self); return; }
- if (!self.ammo_cells) self.ammo_cells = autocvar_g_instagib_ammo_drop;
+ if (!g_instagib) { remove(this); return; }
+ if (!this.ammo_cells) this.ammo_cells = autocvar_g_instagib_ammo_drop;
StartItem(this, ITEM_VaporizerCells);
}
-void instagib_invisibility()
-{SELFPARAM();
- self.strength_finished = autocvar_g_balance_powerup_strength_time;
+void instagib_invisibility(entity this)
+{
+ this.strength_finished = autocvar_g_balance_powerup_strength_time;
StartItem(this, ITEM_Invisibility);
}
-void instagib_extralife()
-{SELFPARAM();
+void instagib_extralife(entity this)
+{
StartItem(this, ITEM_ExtraLife);
}
-void instagib_speed()
-{SELFPARAM();
- self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
+void instagib_speed(entity this)
+{
+ this.invincible_finished = autocvar_g_balance_powerup_invincible_time;
StartItem(this, ITEM_Speed);
}
Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_INSTAGIB_FINDAMMO);
e.instagib_needammo = false;
}
-void instagib_ammocheck()
-{SELFPARAM();
- if(time < self.instagib_nextthink)
+void instagib_ammocheck(entity this)
+{
+ if(time < this.instagib_nextthink)
return;
- if(!IS_PLAYER(self))
+ if(!IS_PLAYER(this))
return; // not a player
- if(IS_DEAD(self) || gameover)
- instagib_stop_countdown(self);
- else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
- instagib_stop_countdown(self);
+ if(IS_DEAD(this) || gameover)
+ instagib_stop_countdown(this);
+ else if (this.ammo_cells > 0 || (this.items & IT_UNLIMITED_WEAPON_AMMO) || (this.flags & FL_GODMODE))
+ instagib_stop_countdown(this);
else if(autocvar_g_rm && autocvar_g_rm_laser)
{
- if(!self.instagib_needammo)
+ if(!this.instagib_needammo)
{
- Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
- self.instagib_needammo = true;
+ Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
+ this.instagib_needammo = true;
}
}
else
{
- self.instagib_needammo = true;
- if (self.health <= 5)
+ this.instagib_needammo = true;
+ if (this.health <= 5)
{
- Damage(self, self, self, 5, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
+ Damage(this, this, this, 5, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
}
- else if (self.health <= 10)
+ else if (this.health <= 10)
{
- Damage(self, self, self, 5, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
+ Damage(this, this, this, 5, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_1);
}
- else if (self.health <= 20)
+ else if (this.health <= 20)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_2);
}
- else if (self.health <= 30)
+ else if (this.health <= 30)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_3);
}
- else if (self.health <= 40)
+ else if (this.health <= 40)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_4);
}
- else if (self.health <= 50)
+ else if (this.health <= 50)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_5);
}
- else if (self.health <= 60)
+ else if (this.health <= 60)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_6);
}
- else if (self.health <= 70)
+ else if (this.health <= 70)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_7);
}
- else if (self.health <= 80)
+ else if (this.health <= 80)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_8);
}
- else if (self.health <= 90)
+ else if (this.health <= 90)
{
- Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
+ Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_9);
}
else
{
- Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE_ONLY, this, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
}
}
- self.instagib_nextthink = time + 1;
+ this.instagib_nextthink = time + 1;
}
MUTATOR_HOOKFUNCTION(mutator_instagib, MatchEnd)
}
MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPreThink)
-{
- instagib_ammocheck();
+{SELFPARAM();
+ instagib_ammocheck(self);
return false;
}
float r = random();
if (r < 0.3)
- e.think = instagib_invisibility;
+ setthink(e, instagib_invisibility);
else if (r < 0.6)
- e.think = instagib_extralife;
+ setthink(e, instagib_extralife);
else
- e.think = instagib_speed;
+ setthink(e, instagib_speed);
e.nextthink = time + 0.1;
e.spawnflags = self.spawnflags;
}
self.colormod = nade_type.m_color;
self.move_movetype = MOVETYPE_BOUNCE;
- self.move_touch = func_null;
+ settouch(self, func_null);
self.scale = 1.5;
self.avelocity = randomvec() * 720;
.entity nade_spawnloc;
-void nade_timer_think()
-{SELFPARAM();
- self.skin = 8 - (self.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
- self.nextthink = time;
- if(!self.owner || wasfreed(self.owner))
- remove(self);
+void nade_timer_think(entity this)
+{
+ this.skin = 8 - (this.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
+ this.nextthink = time;
+ if(!this.owner || wasfreed(this.owner))
+ remove(this);
}
void nade_burn_spawn(entity _nade)
setattachment(timer, _nade, "");
timer.colormap = _nade.colormap;
timer.glowmod = _nade.glowmod;
- timer.think = nade_timer_think;
+ setthink(timer, nade_timer_think);
timer.nextthink = time;
timer.wait = _nade.wait;
timer.owner = _nade;
CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[false], true);
}
-void napalm_damage(float dist, float damage, float edgedamage, float burntime)
-{SELFPARAM();
+void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
+{
entity e;
float d;
vector p;
return;
RandomSelection_Init();
- for(e = WarpZone_FindRadius(self.origin, dist, true); e; e = e.chain)
+ for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
if(e.takedamage == DAMAGE_AIM)
- if(self.realowner != e || autocvar_g_nades_napalm_selfdamage)
- if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
+ if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
+ if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
if(!STAT(FROZEN, e))
{
p = e.origin;
p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
- d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
+ d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
if(d < dist)
{
e.fireball_impactvec = p;
}
if(RandomSelection_chosen_ent)
{
- d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
+ d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
d = damage + (edgedamage - damage) * (d / dist);
- Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
- //trailparticles(self, particleeffectnum(EFFECT_FIREBALL_LASER), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
- Send_Effect(EFFECT_FIREBALL_LASER, self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
+ Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype | HITTYPE_BOUNCE);
+ //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
+ Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
}
}
-void napalm_ball_think()
-{SELFPARAM();
+void napalm_ball_think(entity this)
+{
if(round_handler_IsActive())
if(!round_handler_IsRoundStarted())
{
- remove(self);
+ remove(this);
return;
}
- if(time > self.pushltime)
+ if(time > this.pushltime)
{
- remove(self);
+ remove(this);
return;
}
- vector midpoint = ((self.absmin + self.absmax) * 0.5);
+ vector midpoint = ((this.absmin + this.absmax) * 0.5);
if(pointcontents(midpoint) == CONTENT_WATER)
{
- self.velocity = self.velocity * 0.5;
+ this.velocity = this.velocity * 0.5;
if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
- { self.velocity_z = 200; }
+ { this.velocity_z = 200; }
}
- self.angles = vectoangles(self.velocity);
+ this.angles = vectoangles(this.velocity);
- napalm_damage(autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
+ napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
- self.nextthink = time + 0.1;
+ this.nextthink = time + 0.1;
}
-void nade_napalm_ball()
-{SELFPARAM();
+void nade_napalm_ball(entity this)
+{
entity proj;
vector kick;
- spamsound(self, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
+ spamsound(this, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
proj = new(grenade);
- proj.owner = self.owner;
- proj.realowner = self.realowner;
- proj.team = self.owner.team;
+ proj.owner = this.owner;
+ proj.realowner = this.realowner;
+ proj.team = this.owner.team;
proj.bot_dodge = true;
proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
proj.movetype = MOVETYPE_BOUNCE;
setmodel(proj, MDL_Null);
proj.scale = 1;//0.5;
setsize(proj, '-4 -4 -4', '4 4 4');
- setorigin(proj, self.origin);
- proj.think = napalm_ball_think;
+ setorigin(proj, this.origin);
+ setthink(proj, napalm_ball_think);
proj.nextthink = time;
proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
proj.effects = EF_LOWPRECISION | EF_FLAME;
}
-void napalm_fountain_think()
-{SELFPARAM();
+void napalm_fountain_think(entity this)
+{
if(round_handler_IsActive())
if(!round_handler_IsRoundStarted())
{
- remove(self);
+ remove(this);
return;
}
- if(time >= self.ltime)
+ if(time >= this.ltime)
{
- remove(self);
+ remove(this);
return;
}
- vector midpoint = ((self.absmin + self.absmax) * 0.5);
+ vector midpoint = ((this.absmin + this.absmax) * 0.5);
if(pointcontents(midpoint) == CONTENT_WATER)
{
- self.velocity = self.velocity * 0.5;
+ this.velocity = this.velocity * 0.5;
if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
- { self.velocity_z = 200; }
+ { this.velocity_z = 200; }
- UpdateCSQCProjectile(self);
+ UpdateCSQCProjectile(this);
}
- napalm_damage(autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
+ napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
- self.nextthink = time + 0.1;
- if(time >= self.nade_special_time)
+ this.nextthink = time + 0.1;
+ if(time >= this.nade_special_time)
{
- self.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
- nade_napalm_ball();
+ this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
+ nade_napalm_ball(this);
}
}
-void nade_napalm_boom()
-{SELFPARAM();
+void nade_napalm_boom(entity this)
+{
entity fountain;
int c;
for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
- nade_napalm_ball();
+ nade_napalm_ball(this);
fountain = spawn();
fountain.realowner = self.realowner;
fountain.origin = self.origin;
setorigin(fountain, fountain.origin);
- fountain.think = napalm_fountain_think;
+ setthink(fountain, napalm_fountain_think);
fountain.nextthink = time;
fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
fountain.pushltime = fountain.ltime;
Drop_Special_Items(frost_target);
}
-void nade_ice_think()
-{SELFPARAM();
+void nade_ice_think(entity this)
+{
if(round_handler_IsActive())
if(!round_handler_IsRoundStarted())
nade_ice_freeze(self, e, current_freeze_time);
}
-void nade_ice_boom()
-{SELFPARAM();
+void nade_ice_boom(entity this)
+{
entity fountain;
fountain = spawn();
- fountain.owner = self.owner;
- fountain.realowner = self.realowner;
- fountain.origin = self.origin;
+ fountain.owner = this.owner;
+ fountain.realowner = this.realowner;
+ fountain.origin = this.origin;
setorigin(fountain, fountain.origin);
- fountain.think = nade_ice_think;
+ setthink(fountain, nade_ice_think);
fountain.nextthink = time;
fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
fountain.pushltime = fountain.wait = fountain.ltime;
- fountain.team = self.team;
+ fountain.team = this.team;
fountain.movetype = MOVETYPE_TOSS;
fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
fountain.bot_dodge = false;
setsize(fountain, '-16 -16 -16', '16 16 16');
fountain.nade_special_time = time+0.3;
- fountain.angles = self.angles;
+ fountain.angles = this.angles;
if ( autocvar_g_nades_ice_explode )
{
entity timer = new(nade_timer);
setmodel(timer, MDL_NADE_TIMER);
setattachment(timer, fountain, "");
- timer.colormap = self.colormap;
- timer.glowmod = self.glowmod;
- timer.think = nade_timer_think;
+ timer.colormap = this.colormap;
+ timer.glowmod = this.glowmod;
+ setthink(timer, nade_timer_think);
timer.nextthink = time;
timer.wait = fountain.ltime;
timer.owner = fountain;
setmodel(fountain, MDL_Null);
}
-void nade_translocate_boom()
-{SELFPARAM();
- if(self.realowner.vehicle)
+void nade_translocate_boom(entity this)
+{
+ if(this.realowner.vehicle)
return;
- vector locout = self.origin + '0 0 1' * (1 - self.realowner.mins.z - 24);
- tracebox(locout, self.realowner.mins, self.realowner.maxs, locout, MOVE_NOMONSTERS, self.realowner);
+ vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
+ tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
locout = trace_endpos;
- makevectors(self.realowner.angles);
+ makevectors(this.realowner.angles);
- MUTATOR_CALLHOOK(PortalTeleport, self.realowner);
+ MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
- TeleportPlayer(self, self.realowner, locout, self.realowner.angles, v_forward * vlen(self.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+ TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
}
-void nade_spawn_boom()
-{SELFPARAM();
+void nade_spawn_boom(entity this)
+{
entity spawnloc = spawn();
- setorigin(spawnloc, self.origin);
- setsize(spawnloc, self.realowner.mins, self.realowner.maxs);
+ setorigin(spawnloc, this.origin);
+ setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
spawnloc.movetype = MOVETYPE_NONE;
spawnloc.solid = SOLID_NOT;
- spawnloc.drawonlytoclient = self.realowner;
+ spawnloc.drawonlytoclient = this.realowner;
spawnloc.effects = EF_STARDUST;
spawnloc.cnt = autocvar_g_nades_spawn_count;
- if(self.realowner.nade_spawnloc)
+ if(this.realowner.nade_spawnloc)
{
- remove(self.realowner.nade_spawnloc);
- self.realowner.nade_spawnloc = world;
+ remove(this.realowner.nade_spawnloc);
+ this.realowner.nade_spawnloc = world;
}
- self.realowner.nade_spawnloc = spawnloc;
+ this.realowner.nade_spawnloc = spawnloc;
}
-void nade_heal_think()
-{SELFPARAM();
+void nade_heal_think(entity this)
+{
if(time >= self.ltime)
{
remove(self);
self.nade_show_particles = 0;
}
-void nade_heal_touch()
-{SELFPARAM();
+void nade_heal_touch(entity this)
+{
float maxhealth;
float health_factor;
if(IS_PLAYER(other) || IS_MONSTER(other))
}
}
-void nade_heal_boom()
-{SELFPARAM();
+void nade_heal_boom(entity this)
+{
entity healer;
healer = spawn();
- healer.owner = self.owner;
- healer.realowner = self.realowner;
- setorigin(healer, self.origin);
+ healer.owner = this.owner;
+ healer.realowner = this.realowner;
+ setorigin(healer, this.origin);
healer.healer_lifetime = autocvar_g_nades_heal_time; // save the cvar
healer.ltime = time + healer.healer_lifetime;
- healer.team = self.realowner.team;
+ healer.team = this.realowner.team;
healer.bot_dodge = false;
healer.solid = SOLID_TRIGGER;
- healer.touch = nade_heal_touch;
+ settouch(healer, nade_heal_touch);
setmodel(healer, MDL_NADE_HEAL);
healer.healer_radius = autocvar_g_nades_nade_radius;
Net_LinkEntity(healer, true, 0, healer_send);
- healer.think = nade_heal_think;
+ setthink(healer, nade_heal_think);
healer.nextthink = time;
healer.SendFlags |= 1;
}
-void nade_monster_boom()
-{SELFPARAM();
- entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, false, false, 1);
+void nade_monster_boom(entity this)
+{
+ entity e = spawnmonster(this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
if(autocvar_g_nades_pokenade_monster_lifetime > 0)
e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
e.monster_skill = MONSTER_SKILL_INSANE;
}
-void nade_boom()
-{SELFPARAM();
+void nade_boom(entity this)
+{
entity expef = NULL;
bool nade_blast = true;
- switch ( Nades_from(self.nade_type) )
+ switch ( Nades_from(this.nade_type) )
{
case NADE_TYPE_NAPALM:
nade_blast = autocvar_g_nades_napalm_blast;
case NADE_TYPE_MONSTER:
case NADE_TYPE_SPAWN:
nade_blast = false;
- switch(self.realowner.team)
+ switch(this.realowner.team)
{
case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
default:
case NADE_TYPE_NORMAL:
- expef = EFFECT_NADE_EXPLODE(self.realowner.team);
+ expef = EFFECT_NADE_EXPLODE(this.realowner.team);
break;
}
if(expef)
- Send_Effect(expef, findbetterlocation(self.origin, 8), '0 0 0', 1);
+ Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
- sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
- sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+ sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
+ sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
- self.event_damage = func_null; // prevent somehow calling damage in the next call
+ this.event_damage = func_null; // prevent somehow calling damage in the next call
if(nade_blast)
{
- RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
- autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
- Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self);
+ RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
+ autocvar_g_nades_nade_radius, this, world, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy);
+ Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
}
- if(self.takedamage)
- switch ( Nades_from(self.nade_type) )
+ if(this.takedamage)
+ switch ( Nades_from(this.nade_type) )
{
- case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
- case NADE_TYPE_ICE: nade_ice_boom(); break;
- case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(); break;
- case NADE_TYPE_SPAWN: nade_spawn_boom(); break;
- case NADE_TYPE_HEAL: nade_heal_boom(); break;
- case NADE_TYPE_MONSTER: nade_monster_boom(); break;
+ case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
+ case NADE_TYPE_ICE: nade_ice_boom(this); break;
+ case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
+ case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
+ case NADE_TYPE_HEAL: nade_heal_boom(this); break;
+ case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
}
- FOREACH_ENTITY_ENT(aiment, self,
+ FOREACH_ENTITY_ENT(aiment, this,
{
if(it.classname == "grapplinghook")
RemoveGrapplingHook(it.realowner);
});
- remove(self);
+ remove(this);
}
void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
}
bool CanThrowNade(entity this);
-void nade_touch()
-{SELFPARAM();
+void nade_touch(entity this)
+{
if(other)
UpdateCSQCProjectile(self);
return;
}
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
//setsize(self, '-2 -2 -2', '2 2 2');
//UpdateCSQCProjectile(self);
}
self.enemy = other;
- nade_boom();
+ nade_boom(self);
}
-void nade_beep()
-{SELFPARAM();
- sound(self, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
- self.think = nade_boom;
- self.nextthink = max(self.wait, time);
+void nade_beep(entity this)
+{
+ sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
+ setthink(this, nade_boom);
+ this.nextthink = max(this.wait, time);
}
void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
if(ITEM_DAMAGE_NEEDKILL(deathtype))
{
this.takedamage = DAMAGE_NO;
- WITHSELF(this, nade_boom());
+ WITHSELF(this, nade_boom(this));
return;
}
{
sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
this.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
- this.think = nade_beep;
+ setthink(this, nade_beep);
}
this.health -= damage;
if(set_owner)
_nade.realowner = e;
- _nade.touch = nade_touch;
+ settouch(_nade, nade_touch);
_nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
_nade.health = autocvar_g_nades_nade_health;
_nade.max_health = _nade.health;
if(_time)
{
- _nade.think = nade_boom;
+ setthink(_nade, nade_boom);
_nade.nextthink = _time;
}
n.glowmod = player.glowmod;
n.wait = time + max(0, ntime);
n.nade_time_primed = time;
- n.think = nade_beep;
+ setthink(n, nade_beep);
n.nextthink = max(n.wait - 3, time);
n.projectiledeathtype = DEATH_NADE.m_id;
fn.colormod = Nades_from(n.nade_type).m_color;
fn.colormap = player.colormap;
fn.glowmod = player.glowmod;
- fn.think = SUB_Remove_self;
+ setthink(fn, SUB_Remove);
fn.nextthink = n.wait;
player.nade = n;
else
Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_NEWWEAPON, nix_weapon);
- e.wr_resetplayer(e);
+ e.wr_resetplayer(e, self);
// all weapons must be fully loaded when we spawn
if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
if(!client_hasweapon(self, PS(self).m_switchweapon, true, false))
{
if(client_hasweapon(self, w, true, false))
- W_SwitchWeapon(w);
+ W_SwitchWeapon(self, w);
}
}
return;
}
- if(!thiswep.wr_checkammo1(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
- W_MachineGun_MuzzleFlash();
+ W_MachineGun_MuzzleFlash(actor);
W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0');
if (autocvar_g_casings >= 2) // casing code
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto);
}
-METHOD(HeavyMachineGun, wr_aim, void(entity thiswep))
+METHOD(HeavyMachineGun, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ 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);
else
}
}
-METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep))
+METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo);
+ float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
if(autocvar_g_balance_hmg_reload_ammo)
- ammo_amount += self.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
return ammo_amount;
}
-METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep))
+METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo);
+ float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
if(autocvar_g_balance_hmg_reload_ammo)
- ammo_amount += self.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
return ammo_amount;
}
#endif
#ifdef CSQC
-METHOD(HeavyMachineGun, wr_impacteffect, void(entity thiswep))
+METHOD(HeavyMachineGun, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 2;
pointparticles(EFFECT_MACHINEGUN_IMPACT, org2, w_backoff * 1000, 1);
return false;
}
-void self_spawnfunc_weapon_hmg() { SELFPARAM(); spawnfunc_weapon_hmg(this); }
-void self_spawnfunc_weapon_rpc() { SELFPARAM(); spawnfunc_weapon_rpc(this); }
+void self_spawnfunc_weapon_hmg(entity this) { spawnfunc_weapon_hmg(this); }
+void self_spawnfunc_weapon_rpc(entity this) { spawnfunc_weapon_rpc(this); }
MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
{SELFPARAM();
wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
wep.pickup_anyway = true;
wep.spawnfunc_checked = true;
- wep.think = self_spawnfunc_weapon_hmg;
+ setthink(wep, self_spawnfunc_weapon_hmg);
wep.nextthink = time + 0.1;
return true;
}
wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
wep.pickup_anyway = true;
wep.spawnfunc_checked = true;
- wep.think = self_spawnfunc_weapon_rpc;
+ setthink(wep, self_spawnfunc_weapon_rpc);
wep.nextthink = time + 0.1;
return true;
}
#ifdef SVQC
spawnfunc(weapon_rpc) { weapon_defaultspawnfunc(this, WEP_RPC); }
-void W_RocketPropelledChainsaw_Explode()
-{SELFPARAM();
+void W_RocketPropelledChainsaw_Explode(entity this)
+{
self.event_damage = func_null;
self.takedamage = DAMAGE_NO;
remove (self);
}
-void W_RocketPropelledChainsaw_Touch ()
-{SELFPARAM();
- if(WarpZone_Projectile_Touch())
- if(wasfreed(self))
+void W_RocketPropelledChainsaw_Touch (entity this)
+{
+ if(WarpZone_Projectile_Touch(this))
+ if(wasfreed(this))
return;
- W_RocketPropelledChainsaw_Explode();
+ W_RocketPropelledChainsaw_Explode(this);
}
void W_RocketPropelledChainsaw_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
W_PrepareExplosionByDamage(this, attacker, W_RocketPropelledChainsaw_Explode);
}
-void W_RocketPropelledChainsaw_Think()
-{SELFPARAM();
+void W_RocketPropelledChainsaw_Think(entity this)
+{
if(self.cnt <= time)
{
remove(self);
setorigin (missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
W_SetupProjVelocity_Basic(missile, WEP_CVAR(rpc, speed), 0);
- missile.touch = W_RocketPropelledChainsaw_Touch;
+ settouch(missile, W_RocketPropelledChainsaw_Touch);
- missile.think = W_RocketPropelledChainsaw_Think;
+ setthink(missile, W_RocketPropelledChainsaw_Think);
missile.cnt = time + WEP_CVAR(rpc, lifetime);
missile.nextthink = time;
missile.flags = FL_PROJECTILE;
MUTATOR_CALLHOOK(EditProjectile, self, missile);
}
-METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false);
}
}
}
-METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
- ammo_amount += self.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
+ ammo_amount += actor.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
return ammo_amount;
}
-METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor))
{
return false;
}
#ifdef CSQC
-METHOD(RocketPropelledChainsaw, wr_impacteffect, void(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 12;
pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
.vector spawn_origin, spawn_angles;
-void physical_item_think()
-{SELFPARAM();
+void physical_item_think(entity this)
+{
self.nextthink = time;
self.alpha = self.owner.alpha; // apply fading and ghosting
remove(self); // the real item is gone, remove this
}
-void physical_item_touch()
-{SELFPARAM();
+void physical_item_touch(entity this)
+{
if(!self.cnt) // not for dropped items
if (ITEM_TOUCH_NEEDKILL())
{
wep.dphitcontentsmask = self.dphitcontentsmask;
wep.cnt = (self.owner != world);
- wep.think = physical_item_think;
+ setthink(wep, physical_item_think);
wep.nextthink = time;
- wep.touch = physical_item_touch;
+ settouch(wep, physical_item_touch);
wep.event_damage = physical_item_damage;
if(!wep.cnt)
FOREACH(Weapons, it != WEP_Null, LAMBDA(
if(frag_target.weapons & WepSet_FromWeapon(it))
if(PS(frag_target).m_switchweapon != it)
- if(W_IsWeaponThrowable(it.m_id))
+ if(W_IsWeaponThrowable(frag_target, it.m_id))
W_ThrowNewWeapon(frag_target, it.m_id, false, CENTER_OR_VIEWOFS(frag_target), randomvec() * 175 + '0 0 325');
));
.string material;
.float touch_timer;
-void sandbox_ObjectFunction_Touch()
-{SELFPARAM();
+void sandbox_ObjectFunction_Touch(entity this)
+{
// apply material impact effects
if(!self.material)
Send_Effect_(strcat("impact_", self.material), self.origin, '0 0 0', ceil(intensity * 10)); // allow a count from 1 to 10
}
-void sandbox_ObjectFunction_Think()
-{SELFPARAM();
+void sandbox_ObjectFunction_Think(entity this)
+{
// decide if and how this object can be grabbed
if(autocvar_g_sandbox_readonly)
self.grab = 0; // no grabbing
e.frame = 0;
e.skin = 0;
e.material = string_null;
- e.touch = sandbox_ObjectFunction_Touch;
- e.think = sandbox_ObjectFunction_Think;
+ settouch(e, sandbox_ObjectFunction_Touch);
+ setthink(e, sandbox_ObjectFunction_Think);
e.nextthink = time;
//e.effects |= EF_SELECTABLE; // don't do this all the time, maybe just when editing objects?
FOREACH_CLIENT(true, LAMBDA(
if(!IS_SPEC(it) && !IS_OBSERVER(it))
continue;
- setself(it);
- if(self.superspec_flags & SSF_ITEMMSG)
- if(superspec_filteritem(self, _item))
+ if(it.superspec_flags & SSF_ITEMMSG)
+ if(superspec_filteritem(it, _item))
{
- if(self.superspec_flags & SSF_VERBOSE)
- superspec_msg("", "", self, sprintf("Player %s^7 just picked up ^3%s\n", other.netname, _item.netname), 1);
+ if(it.superspec_flags & SSF_VERBOSE)
+ superspec_msg("", "", it, sprintf("Player %s^7 just picked up ^3%s\n", other.netname, _item.netname), 1);
else
- superspec_msg("", "", self, sprintf("Player %s^7 just picked up ^3%s\n^8(%s^8)\n", other.netname, _item.netname, _item.classname), 1);
- if((self.autospec_flags & ASF_SSIM) && self.enemy != other)
+ superspec_msg("", "", it, sprintf("Player %s^7 just picked up ^3%s\n^8(%s^8)\n", other.netname, _item.netname, _item.classname), 1);
+ if((it.autospec_flags & ASF_SSIM) && it.enemy != other)
{
- superspec_Spectate(other);
-
- setself(this);
+ WITHSELF(it, superspec_Spectate(other));
return MUT_ITEMTOUCH_CONTINUE;
}
}
- if((self.autospec_flags & ASF_SHIELD && _item.invincible_finished) ||
- (self.autospec_flags & ASF_STRENGTH && _item.strength_finished) ||
- (self.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorMega) ||
- (self.autospec_flags & ASF_MEGA_HP && _item.itemdef == ITEM_HealthMega) ||
- (self.autospec_flags & ASF_FLAG_GRAB && _item.classname == "item_flag_team"))
+ if((it.autospec_flags & ASF_SHIELD && _item.invincible_finished) ||
+ (it.autospec_flags & ASF_STRENGTH && _item.strength_finished) ||
+ (it.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorMega) ||
+ (it.autospec_flags & ASF_MEGA_HP && _item.itemdef == ITEM_HealthMega) ||
+ (it.autospec_flags & ASF_FLAG_GRAB && _item.classname == "item_flag_team"))
{
- if((self.enemy != other) || IS_OBSERVER(self))
+ if((it.enemy != other) || IS_OBSERVER(it))
{
- if(self.autospec_flags & ASF_OBSERVER_ONLY && !IS_OBSERVER(self))
+ if(it.autospec_flags & ASF_OBSERVER_ONLY && !IS_OBSERVER(it))
{
- if(self.superspec_flags & SSF_VERBOSE)
- superspec_msg("", "", self, sprintf("^8Ignored that ^7%s^8 grabbed %s^8 since the observer_only option is ON\n", other.netname, _item.netname), 2);
+ if(it.superspec_flags & SSF_VERBOSE)
+ superspec_msg("", "", it, sprintf("^8Ignored that ^7%s^8 grabbed %s^8 since the observer_only option is ON\n", other.netname, _item.netname), 2);
}
else
{
- if(self.autospec_flags & ASF_SHOWWHAT)
- superspec_msg("", "", self, sprintf("^7Following %s^7 due to picking up %s\n", other.netname, _item.netname), 2);
+ if(it.autospec_flags & ASF_SHOWWHAT)
+ superspec_msg("", "", it, sprintf("^7Following %s^7 due to picking up %s\n", other.netname, _item.netname), 2);
- superspec_Spectate(other);
+ WITHSELF(it, superspec_Spectate(other));
}
}
}
));
- setself(this);
-
return MUT_ITEMTOUCH_CONTINUE;
}
return 0;
}
-void superspec_hello()
-{SELFPARAM();
+void superspec_hello(entity this)
+{
if(self.enemy.crypto_idfp == "")
Send_Notification(NOTIF_ONE_ONLY, self.enemy, MSG_INFO, INFO_SUPERSPEC_MISSING_UID);
entity _hello = spawn();
_hello.enemy = self;
- _hello.think = superspec_hello;
+ setthink(_hello, superspec_hello);
_hello.nextthink = time + 5;
if (!_ISLOCAL)
MUTATOR_HOOKFUNCTION(superspec, PlayerDies)
{
- SELFPARAM();
FOREACH_CLIENT(IS_SPEC(it), LAMBDA(
- setself(it);
- if(self.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && self.enemy == frag_target)
+ if(it.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && it.enemy == frag_target)
{
- if(self.autospec_flags & ASF_SHOWWHAT)
- superspec_msg("", "", self, sprintf("^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
+ if(it.autospec_flags & ASF_SHOWWHAT)
+ superspec_msg("", "", it, sprintf("^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
- superspec_Spectate(frag_attacker);
+ WITHSELF(it, superspec_Spectate(frag_attacker));
}
));
- setself(frag_target);
return false;
}
sendflags = sendflags & 0x7F;
- if (self.max_health || (self.pain_finished && (time < self.pain_finished + 0.25)))
+ if (this.max_health || (this.pain_finished && (time < this.pain_finished + 0.25)))
sendflags |= 0x80;
int f = 0;
- if(self.currentammo)
+ if(this.currentammo)
f |= 1; // hideable
- if(self.exteriormodeltoclient == to)
+ if(this.exteriormodeltoclient == to)
f |= 2; // my own
MUTATOR_CALLHOOK(SendWaypoint, this, to, sendflags, f);
WriteByte(MSG_ENTITY, sendflags);
- WriteByte(MSG_ENTITY, self.wp_extra);
+ WriteByte(MSG_ENTITY, this.wp_extra);
if (sendflags & 0x80)
{
- if (self.max_health)
+ if (this.max_health)
{
- WriteByte(MSG_ENTITY, (self.health / self.max_health) * 191.0);
+ WriteByte(MSG_ENTITY, (this.health / this.max_health) * 191.0);
}
else
{
- float dt = self.pain_finished - time;
+ float dt = this.pain_finished - time;
dt = bound(0, dt * 32, 16383);
WriteByte(MSG_ENTITY, (dt & 0xFF00) / 256 + 192);
WriteByte(MSG_ENTITY, (dt & 0x00FF));
if (sendflags & 64)
{
- WriteCoord(MSG_ENTITY, self.origin.x);
- WriteCoord(MSG_ENTITY, self.origin.y);
- WriteCoord(MSG_ENTITY, self.origin.z);
+ WriteCoord(MSG_ENTITY, this.origin.x);
+ WriteCoord(MSG_ENTITY, this.origin.y);
+ WriteCoord(MSG_ENTITY, this.origin.z);
}
if (sendflags & 1)
{
- WriteByte(MSG_ENTITY, self.team);
- WriteByte(MSG_ENTITY, self.rule);
+ WriteByte(MSG_ENTITY, this.team);
+ WriteByte(MSG_ENTITY, this.rule);
}
if (sendflags & 2)
- WriteString(MSG_ENTITY, self.model1);
+ WriteString(MSG_ENTITY, this.model1);
if (sendflags & 4)
- WriteString(MSG_ENTITY, self.model2);
+ WriteString(MSG_ENTITY, this.model2);
if (sendflags & 8)
- WriteString(MSG_ENTITY, self.model3);
+ WriteString(MSG_ENTITY, this.model3);
if (sendflags & 16)
{
- WriteCoord(MSG_ENTITY, self.fade_time);
- WriteCoord(MSG_ENTITY, self.teleport_time);
- WriteShort(MSG_ENTITY, self.fade_rate); // maxdist
+ WriteCoord(MSG_ENTITY, this.fade_time);
+ WriteCoord(MSG_ENTITY, this.teleport_time);
+ WriteShort(MSG_ENTITY, this.fade_rate); // maxdist
WriteByte(MSG_ENTITY, f);
}
if (sendflags & 32)
{
- WriteByte(MSG_ENTITY, self.cnt); // icon on radar
- WriteByte(MSG_ENTITY, self.colormod.x * 255.0);
- WriteByte(MSG_ENTITY, self.colormod.y * 255.0);
- WriteByte(MSG_ENTITY, self.colormod.z * 255.0);
+ WriteByte(MSG_ENTITY, this.cnt); // icon on radar
+ WriteByte(MSG_ENTITY, this.colormod.x * 255.0);
+ WriteByte(MSG_ENTITY, this.colormod.y * 255.0);
+ WriteByte(MSG_ENTITY, this.colormod.z * 255.0);
- if (WaypointSprite_isteammate(self.owner, WaypointSprite_getviewentity(to)))
+ if (WaypointSprite_isteammate(this.owner, WaypointSprite_getviewentity(to)))
{
- float dt = (self.waypointsprite_helpmetime - time) / 0.1;
+ float dt = (this.waypointsprite_helpmetime - time) / 0.1;
if (dt < 0)
dt = 0;
if (dt > 255)
}
}
-void WaypointSprite_Think()
-{SELFPARAM();
+void WaypointSprite_Think(entity this)
+{
bool doremove = false;
if (self.fade_time && time >= self.teleport_time)
self.nextthink = time; // WHY?!?
}
-float WaypointSprite_visible_for_player(entity e)
-{SELFPARAM();
+bool WaypointSprite_visible_for_player(entity this, entity player, entity view)
+{
// personal waypoints
- if (self.enemy && self.enemy != e)
+ if (this.enemy && this.enemy != view)
return false;
// team waypoints
- if (self.rule == SPRITERULE_SPECTATOR)
+ if (this.rule == SPRITERULE_SPECTATOR)
{
if (!autocvar_sv_itemstime)
return false;
- if (!warmup_stage && IS_PLAYER(e))
+ if (!warmup_stage && IS_PLAYER(view))
return false;
}
- else if (self.team && self.rule == SPRITERULE_DEFAULT)
+ else if (this.team && this.rule == SPRITERULE_DEFAULT)
{
- if (self.team != e.team)
+ if (this.team != view.team)
return false;
- if (!IS_PLAYER(e))
+ if (!IS_PLAYER(view))
return false;
}
if (MUTATOR_CALLHOOK(CustomizeWaypoint, self, other))
return false;
- return self.waypointsprite_visible_for_player(e);
+ return self.waypointsprite_visible_for_player(self, other, e);
}
bool WaypointSprite_SendEntity(entity this, entity to, float sendflags);
wp.owned_by_field = ownfield;
}
wp.fade_rate = maxdistance;
- wp.think = WaypointSprite_Think;
+ setthink(wp, WaypointSprite_Think);
wp.nextthink = time;
wp.model1 = spr.netname;
wp.customizeentityforclient = WaypointSprite_Customize;
.string model2;
.string model3;
-.float(entity) waypointsprite_visible_for_player;
+.bool(entity, entity, entity) waypointsprite_visible_for_player;
void WaypointSprite_UpdateSprites(entity e, entity m1, entity m2, entity m3);
void WaypointSprite_Disown(entity wp, float fadetime);
-void WaypointSprite_Think();
+void WaypointSprite_Think(entity this);
-float WaypointSprite_visible_for_player(entity e);
+bool WaypointSprite_visible_for_player(entity this, entity player, entity view);
entity WaypointSprite_getviewentity(entity e);
#endif
#ifdef SVQC
-void Net_Notification_Remove()
+void Net_Notification_Remove(entity this)
{
- SELFPARAM();
#ifdef NOTIFICATIONS_DEBUG
Debug_Notification(sprintf(
"Net_Notification_Remove() at %f: %s '%s - %s' notification\n",
net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float);
}
- net_notif.think = Net_Notification_Remove;
+ setthink(net_notif, Net_Notification_Remove);
net_notif.nextthink = (time > autocvar_notification_lifetime_mapload)
? (time + autocvar_notification_lifetime_runtime)
: autocvar_notification_lifetime_mapload;
/**
Simulate drag
- self.velocity = movelib_dragvec(self.velocity,0.02,0.5);
+ this.velocity = movelib_dragvec(this.velocity,0.02,0.5);
**/
-vector movelib_dragvec(float drag, float exp_)
-{SELFPARAM();
+vector movelib_dragvec(entity this, float drag, float exp_)
+{
float lspeed,ldrag;
- lspeed = vlen(self.velocity);
+ lspeed = vlen(this.velocity);
ldrag = lspeed * drag;
ldrag = ldrag * (drag * exp_);
ldrag = 1 - (ldrag / lspeed);
- return self.velocity * ldrag;
+ return this.velocity * ldrag;
}
/**
Simulate drag
- self.velocity *= movelib_dragflt(somespeed,0.01,0.7);
+ this.velocity *= movelib_dragflt(somespeed,0.01,0.7);
**/
float movelib_dragflt(float fspeed,float drag,float exp_)
{
/**
Do a inertia simulation based on velocity.
Basicaly, this allows you to simulate loss of steering with higher speed.
- self.velocity = movelib_inertmove_byspeed(self.velocity,newvel,1000,0.1,0.9);
+ this.velocity = movelib_inertmove_byspeed(this.velocity,newvel,1000,0.1,0.9);
**/
-vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,float oldmax)
-{SELFPARAM();
+vector movelib_inertmove_byspeed(entity this, vector vel_new, float vel_max,float newmin,float oldmax)
+{
float influense;
- influense = vlen(self.velocity) * (1 / vel_max);
+ influense = vlen(this.velocity) * (1 / vel_max);
influense = bound(newmin,influense,oldmax);
- return (vel_new * (1 - influense)) + (self.velocity * influense);
+ return (vel_new * (1 - influense)) + (this.velocity * influense);
}
-vector movelib_inertmove(vector new_vel,float new_bias)
-{SELFPARAM();
- return new_vel * new_bias + self.velocity * (1-new_bias);
+vector movelib_inertmove(entity this, vector new_vel,float new_bias)
+{
+ return new_vel * new_bias + this.velocity * (1-new_bias);
}
-void movelib_move(vector force,float max_velocity,float drag,float theMass,float breakforce)
-{SELFPARAM();
+void movelib_move(entity this, vector force,float max_velocity,float drag,float theMass,float breakforce)
+{
float deltatime;
float acceleration;
float mspeed;
vector breakvec;
- deltatime = time - self.movelib_lastupdate;
+ deltatime = time - this.movelib_lastupdate;
if (deltatime > 0.15) deltatime = 0;
- self.movelib_lastupdate = time;
+ this.movelib_lastupdate = time;
if (!deltatime) return;
- mspeed = vlen(self.velocity);
+ mspeed = vlen(this.velocity);
if (theMass)
acceleration = vlen(force) / theMass;
else
acceleration = vlen(force);
- if (IS_ONGROUND(self))
+ if (IS_ONGROUND(this))
{
if (breakforce)
{
- breakvec = (normalize(self.velocity) * (breakforce / theMass) * deltatime);
- self.velocity = self.velocity - breakvec;
+ breakvec = (normalize(this.velocity) * (breakforce / theMass) * deltatime);
+ this.velocity = this.velocity - breakvec;
}
- self.velocity = self.velocity + force * (acceleration * deltatime);
+ this.velocity = this.velocity + force * (acceleration * deltatime);
}
if (drag)
- self.velocity = movelib_dragvec(drag, 1);
+ this.velocity = movelib_dragvec(this, drag, 1);
- if (self.waterlevel > 1)
+ if (this.waterlevel > 1)
{
- self.velocity = self.velocity + force * (acceleration * deltatime);
- self.velocity = self.velocity + '0 0 0.05' * autocvar_sv_gravity * deltatime;
+ this.velocity = this.velocity + force * (acceleration * deltatime);
+ this.velocity = this.velocity + '0 0 0.05' * autocvar_sv_gravity * deltatime;
}
else
- self.velocity = self.velocity + '0 0 -1' * autocvar_sv_gravity * deltatime;
+ this.velocity = this.velocity + '0 0 -1' * autocvar_sv_gravity * deltatime;
- mspeed = vlen(self.velocity);
+ mspeed = vlen(this.velocity);
if (max_velocity)
if (mspeed > max_velocity)
- self.velocity = normalize(self.velocity) * (mspeed - 50);//* max_velocity;
+ this.velocity = normalize(this.velocity) * (mspeed - 50);//* max_velocity;
}
/*
.float buoyancy;
float movelib_deltatime;
-void movelib_startupdate()
+void movelib_startupdate(entity this)
{
- movelib_deltatime = time - self.movelib_lastupdate;
+ movelib_deltatime = time - this.movelib_lastupdate;
if (movelib_deltatime > 0.5)
movelib_deltatime = 0;
- self.movelib_lastupdate = time;
+ this.movelib_lastupdate = time;
}
-void movelib_update(vector dir,float force)
+void movelib_update(entity this, vector dir,float force)
{
vector acceleration;
float old_speed;
if(!movelib_deltatime)
return;
- v_z = self.velocity_z;
- old_speed = vlen(self.velocity);
- old_dir = normalize(self.velocity);
+ v_z = this.velocity_z;
+ old_speed = vlen(this.velocity);
+ old_dir = normalize(this.velocity);
- //ggravity = (autocvar_sv_gravity / self.mass) * '0 0 100';
- acceleration = (force / self.mass) * dir;
- //acceleration -= old_dir * (old_speed / self.mass);
+ //ggravity = (autocvar_sv_gravity / this.mass) * '0 0 100';
+ acceleration = (force / this.mass) * dir;
+ //acceleration -= old_dir * (old_speed / this.mass);
acceleration -= ggravity;
- if(self.waterlevel > 1)
+ if(this.waterlevel > 1)
{
- ffriction = self.water_friction;
- acceleration += self.buoyancy * '0 0 1';
+ ffriction = this.water_friction;
+ acceleration += this.buoyancy * '0 0 1';
}
else
- if(IS_ONGROUND(self))
- ffriction = self.ground_friction;
+ if(IS_ONGROUND(this))
+ ffriction = this.ground_friction;
else
- ffriction = self.air_friction;
+ ffriction = this.air_friction;
acceleration *= ffriction;
- //self.velocity = self.velocity * (ffriction * movelib_deltatime);
- self.velocity += acceleration * movelib_deltatime;
- self.velocity_z = v_z;
+ //this.velocity = this.velocity * (ffriction * movelib_deltatime);
+ this.velocity += acceleration * movelib_deltatime;
+ this.velocity_z = v_z;
}
*/
Simulate drag
self.velocity = movelib_dragvec(self.velocity,0.02,0.5);
**/
-vector movelib_dragvec(float drag, float exp_);
+vector movelib_dragvec(entity this, float drag, float exp_);
/**
Simulate drag
Basicaly, this allows you to simulate loss of steering with higher speed.
self.velocity = movelib_inertmove_byspeed(self.velocity,newvel,1000,0.1,0.9);
**/
-vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,float oldmax);
+vector movelib_inertmove_byspeed(entity this, vector vel_new, float vel_max, float newmin, float oldmax);
-vector movelib_inertmove(vector new_vel,float new_bias);
+vector movelib_inertmove(entity this, vector new_vel, float new_bias);
.float movelib_lastupdate;
-void movelib_move(vector force,float max_velocity,float drag,float theMass,float breakforce);
+void movelib_move(entity this, vector force, float max_velocity, float drag, float theMass, float breakforce);
/*
void movelib_move_simple(vector newdir,float velo,float blendrate)
{
entity oldother = other;
- if(this.move_touch)
+ if(gettouch(this))
{
other = oth;
- WITHSELF(this, this.move_touch());
+ WITHSELF(this, gettouch(this)(this));
other = oldother;
}
- if(oth.move_touch)
+ if(gettouch(oth))
{
other = this;
- WITHSELF(oth, oth.move_touch());
+ WITHSELF(oth, gettouch(oth)(oth));
other = oldother;
}
FOREACH_ENTITY_RADIUS(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin), true, {
if (it.solid == SOLID_TRIGGER && it != this)
if (it.move_nomonsters != MOVE_NOMONSTERS && it.move_nomonsters != MOVE_WORLDONLY)
- if (it.move_touch && boxesoverlap(it.absmin, it.absmax, this.absmin, this.absmax))
+ if (gettouch(it) && boxesoverlap(it.absmin, it.absmax, this.absmin, this.absmax))
{
other = this;
trace_plane_dist = 0;
trace_ent = this;
- WITHSELF(it, it.move_touch());
+ WITHSELF(it, gettouch(it)(it));
}
});
#define UNSET_ONGROUND(s) ((s).flags &= ~FL_ONGROUND)
.float move_ltime;
-.void()move_think;
+.void(entity this) move_think;
.float move_nextthink;
.void()move_blocked;
.int move_flags;
.int move_watertype;
.int move_waterlevel;
-.void()move_touch;
.void(float, float)contentstransition;
.float move_bounce_factor;
.float move_bounce_stopspeed;
this.move_nextthink = 0;
this.move_time = time;
other = world;
- WITHSELF(this, this.move_think());
+ WITHSELF(this, this.move_think(this));
}
}
string specialcommand = "xwxwxsxsxaxdxaxdx1x ";
.float specialcommand_pos;
-void SpecialCommand()
+void SpecialCommand(entity this)
{
#ifdef SVQC
- if (!CheatImpulse(CHIMPULSE_GIVE_ALL.impulse))
+ if (!CheatImpulse(this, CHIMPULSE_GIVE_ALL.impulse))
LOG_INFO("A hollow voice says \"Plugh\".\n");
#endif
}
-float PM_check_specialcommand(entity this, float buttons)
+bool PM_check_specialcommand(entity this, int buttons)
{
#ifdef SVQC
string c;
if (this.specialcommand_pos >= strlen(specialcommand))
{
this.specialcommand_pos = 0;
- SpecialCommand();
+ SpecialCommand(this);
return true;
}
}
auto = true; \
__chan = fabs(__chan); \
entity tmp = __e = new(csqc_autochannel); \
- tmp.think = SUB_Remove_self; \
+ setthink(tmp, SUB_Remove); \
tmp.nextthink = time + soundlength(__samp); \
} \
vector old_origin = __e.origin; \
void bot_clientdisconnect(entity this);
void W_HitPlotClose(entity this);
void anticheat_report(entity this);
-void playerdemo_shutdown();
+void playerdemo_shutdown(entity this);
void entcs_detach(entity this);
void accuracy_free(entity this);
void ClientData_Detach(entity this);
W_HitPlotClose(this);
anticheat_report(this);
- playerdemo_shutdown();
+ playerdemo_shutdown(this);
entcs_detach(this);
- accuracy_free(self);
+ accuracy_free(this);
ClientData_Detach(this);
- PlayerScore_Detach(self);
+ PlayerScore_Detach(this);
}
if(sf & ISF_LOCATION)
{
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- setorigin(self, self.origin);
- self.oldorigin = self.origin;
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+ setorigin(this, this.origin);
+ this.oldorigin = this.origin;
}
if(sf & ISF_ANGLES)
{
- self.angles_x = ReadAngle();
- self.angles_y = ReadAngle();
- self.angles_z = ReadAngle();
- self.move_angles = self.angles;
+ this.angles_x = ReadAngle();
+ this.angles_y = ReadAngle();
+ this.angles_z = ReadAngle();
+ this.move_angles = this.angles;
}
if(sf & ISF_SIZE)
{
float use_bigsize = ReadByte();
- setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
+ setsize(this, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
}
if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc.
{
- self.ItemStatus = ReadByte();
+ this.ItemStatus = ReadByte();
- Item_SetAlpha(self);
+ Item_SetAlpha(this);
if(autocvar_cl_fullbright_items)
- if(self.ItemStatus & ITS_ALLOWFB)
- self.effects |= EF_FULLBRIGHT;
+ if(this.ItemStatus & ITS_ALLOWFB)
+ this.effects |= EF_FULLBRIGHT;
- if(self.ItemStatus & ITS_POWERUP)
+ if(this.ItemStatus & ITS_POWERUP)
{
- if(self.ItemStatus & ITS_AVAILABLE)
- self.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
+ if(this.ItemStatus & ITS_AVAILABLE)
+ this.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
else
- self.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT);
+ this.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT);
}
}
if(sf & ISF_MODEL)
{
- self.drawmask = MASK_NORMAL;
- self.move_movetype = MOVETYPE_TOSS;
- self.draw = ItemDraw;
- self.solid = SOLID_TRIGGER;
- //self.move_flags |= FL_ITEM;
+ this.drawmask = MASK_NORMAL;
+ this.move_movetype = MOVETYPE_TOSS;
+ this.draw = ItemDraw;
+ this.solid = SOLID_TRIGGER;
+ //this.move_flags |= FL_ITEM;
bool use_bigsize = ReadByte();
- self.fade_end = ReadShort();
- self.fade_start = ReadShort();
- if(self.fade_start && !autocvar_cl_items_nofade)
- setpredraw(self, Item_PreDraw);
+ this.fade_end = ReadShort();
+ this.fade_start = ReadShort();
+ if(this.fade_start && !autocvar_cl_items_nofade)
+ setpredraw(this, Item_PreDraw);
- if(self.mdl)
- strunzone(self.mdl);
+ if(this.mdl)
+ strunzone(this.mdl);
- self.mdl = "";
+ this.mdl = "";
string _fn = ReadString();
- if(autocvar_cl_simple_items && (self.ItemStatus & ITS_ALLOWSI))
+ if(autocvar_cl_simple_items && (this.ItemStatus & ITS_ALLOWSI))
{
string _fn2 = substring(_fn, 0 , strlen(_fn) -4);
- self.draw = ItemDrawSimple;
+ this.draw = ItemDrawSimple;
if(fexists(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix)))
- self.mdl = strzone(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix));
+ this.mdl = strzone(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix));
else if(fexists(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix)))
- self.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
+ this.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
else if(fexists(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix)))
- self.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
+ this.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
else if(fexists(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix)))
- self.mdl = strzone(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix));
+ this.mdl = strzone(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix));
else
{
- self.draw = ItemDraw;
+ this.draw = ItemDraw;
LOG_TRACE("Simple item requested for ", _fn, " but no model exists for it\n");
}
}
- if(self.draw != ItemDrawSimple)
- self.mdl = strzone(_fn);
+ if(this.draw != ItemDrawSimple)
+ this.mdl = strzone(_fn);
- if(self.mdl == "")
- LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, ", tell tZork about this!\n");
+ if(this.mdl == "")
+ LOG_TRACE("^1WARNING!^7 this.mdl is unset for item ", this.classname, ", tell tZork about this!\n");
- precache_model(self.mdl);
- _setmodel(self, self.mdl);
+ precache_model(this.mdl);
+ _setmodel(this, this.mdl);
- setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
+ setsize(this, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
}
if(sf & ISF_COLORMAP)
- self.colormap = ReadShort();
+ this.colormap = ReadShort();
if(sf & ISF_DROP)
{
- self.gravity = 1;
- self.pushable = true;
- //self.move_angles = '0 0 0';
- self.move_movetype = MOVETYPE_TOSS;
- self.move_velocity_x = ReadCoord();
- self.move_velocity_y = ReadCoord();
- self.move_velocity_z = ReadCoord();
- self.velocity = self.move_velocity;
- self.move_origin = self.oldorigin;
-
- if(!self.move_time)
+ this.gravity = 1;
+ this.pushable = true;
+ //this.move_angles = '0 0 0';
+ this.move_movetype = MOVETYPE_TOSS;
+ this.move_velocity_x = ReadCoord();
+ this.move_velocity_y = ReadCoord();
+ this.move_velocity_z = ReadCoord();
+ this.velocity = this.move_velocity;
+ this.move_origin = this.oldorigin;
+
+ if(!this.move_time)
{
- self.move_time = time;
- self.spawntime = time;
+ this.move_time = time;
+ this.spawntime = time;
}
else
- self.move_time = max(self.move_time, time);
+ this.move_time = max(this.move_time, time);
}
if(autocvar_cl_animate_items)
{
- if(self.ItemStatus & ITS_ANIMATE1)
- self.move_avelocity = '0 180 0';
+ if(this.ItemStatus & ITS_ANIMATE1)
+ this.move_avelocity = '0 180 0';
- if(self.ItemStatus & ITS_ANIMATE2)
- self.move_avelocity = '0 -90 0';
+ if(this.ItemStatus & ITS_ANIMATE2)
+ this.move_avelocity = '0 -90 0';
}
- self.entremove = ItemRemove;
+ this.entremove = ItemRemove;
return true;
}
e.SendFlags |= ISF_STATUS;
}
-void Item_Think()
-{SELFPARAM();
+void Item_Think(entity this)
+{
self.nextthink = time;
if(self.origin != self.oldorigin)
ItemUpdate(self);
void Item_ItemsTime_SetTime(entity e, float t);
void Item_ItemsTime_SetTimesForAllPlayers();
-void Item_Respawn ()
-{SELFPARAM();
+void Item_Respawn (entity this)
+{
Item_Show(self, 1);
// this is ugly...
if(self.items == ITEM_Strength.m_itemid)
Item_ItemsTime_SetTimesForAllPlayers();
}
- self.think = Item_Think;
+ setthink(self, Item_Think);
self.nextthink = time;
//Send_Effect(EFFECT_ITEM_RESPAWN, self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
}
-void Item_RespawnCountdown ()
-{SELFPARAM();
+void Item_RespawnCountdown (entity this)
+{
if(self.count >= ITEM_RESPAWN_TICKS)
{
if(self.waypointsprite_attached)
WaypointSprite_Kill(self.waypointsprite_attached);
- Item_Respawn();
+ Item_Respawn(self);
}
else
{
if(self.waypointsprite_attached)
{
- setself(self.waypointsprite_attached);
FOREACH_CLIENT(IS_REAL_CLIENT(it), {
- if(self.waypointsprite_visible_for_player(it))
+ if(self.waypointsprite_attached.waypointsprite_visible_for_player(self.waypointsprite_attached, it, it))
{
msg_entity = it;
soundto(MSG_ONE, this, CH_TRIGGER, SND(ITEMRESPAWNCOUNTDOWN), VOL_BASE, ATTEN_NORM); // play respawn sound
}
});
- setself(this);
WaypointSprite_Ping(self.waypointsprite_attached);
//WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count);
}
}
-void Item_RespawnThink()
-{SELFPARAM();
+void Item_RespawnThink(entity this)
+{
self.nextthink = time;
if(self.origin != self.oldorigin)
ItemUpdate(self);
if(time >= self.wait)
- Item_Respawn();
+ Item_Respawn(self);
}
void Item_ScheduleRespawnIn(entity e, float t)
// if the respawn time is longer than 10 seconds, show a waypoint, otherwise, just respawn normally
if ((Item_ItemsTime_Allow(e.itemdef) || e.weapons & WEPSET_SUPERWEAPONS) && (t - ITEM_RESPAWN_TICKS) > 0)
{
- e.think = Item_RespawnCountdown;
+ setthink(e, Item_RespawnCountdown);
e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
e.count = 0;
}
else
{
- e.think = Item_RespawnThink;
+ setthink(e, Item_RespawnThink);
e.nextthink = time;
e.scheduledrespawntime = time + t;
e.wait = time + t;
return 1;
}
-void Item_Touch()
+void Item_Touch(entity this)
{
- SELFPARAM();
// remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
if (this.classname == "droppedweapon")
if (this.classname != "droppedweapon")
{
- this.think = Item_Think;
+ setthink(this, Item_Think);
this.nextthink = time;
if (this.waypointsprite_attached)
Item_ScheduleInitialRespawn(this);
}
}
-void Item_Reset_self() { SELFPARAM(); Item_Reset(this); }
void Item_FindTeam(entity this)
{
}
// Savage: used for item garbage-collection
-void RemoveItem()
-{SELFPARAM();
+void RemoveItem(entity this)
+{
if(wasfreed(self) || !self) { return; }
Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
remove(self);
void Item_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
{
if(ITEM_DAMAGE_NEEDKILL(deathtype))
- WITHSELF(this, RemoveItem());
+ WITHSELF(this, RemoveItem(this));
}
void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter)
this.movetype = MOVETYPE_TOSS;
// Savage: remove thrown items after a certain period of time ("garbage collection")
- this.think = RemoveItem;
+ setthink(this, RemoveItem);
this.nextthink = time + 20;
this.takedamage = DAMAGE_YES;
this.bot_pickupbasevalue = pickupbasevalue;
this.mdl = this.model ? this.model : strzone(this.item_model_ent.model_str());
this.netname = itemname;
- this.touch = Item_Touch;
+ settouch(this, Item_Touch);
setmodel(this, MDL_Null); // precision set below
//this.effects |= EF_LOWPRECISION;
e.(regenfield) = max(e.(regenfield), time + regentime);
}
float GiveItems(entity e, float beginarg, float endarg)
-{SELFPARAM();
+{
float got, i, val, op;
float _switchweapon;
string cmd;
POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND_MEGAHEALTH, SND_Null);
if(e.superweapons_finished <= 0)
- if(self.weapons & WEPSET_SUPERWEAPONS)
+ if(e.weapons & WEPSET_SUPERWEAPONS)
e.superweapons_finished = autocvar_g_balance_superweapons_time;
if(e.strength_finished <= 0)
void Item_Show (entity e, float mode);
-void Item_Respawn ();
+void Item_Respawn (entity this);
-void Item_RespawnCountdown ();
+void Item_RespawnCountdown(entity this);
void Item_ScheduleRespawnIn(entity e, float t);
void Item_ScheduleRespawn(entity e);
float Item_GiveTo(entity item, entity player);
-void Item_Touch();
+void Item_Touch(entity this);
void Item_Reset(entity this);
#ifdef SVQC
.float height;
-void func_bobbing_controller_think()
-{SELFPARAM();
+void func_bobbing_controller_think(entity this)
+{
vector v;
self.nextthink = time + 0.1;
spawnfunc(func_bobbing)
{
entity controller;
- if (self.noise != "")
+ if (this.noise != "")
{
- precache_sound(self.noise);
- soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
+ precache_sound(this.noise);
+ soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
}
- if (!self.speed)
- self.speed = 4;
- if (!self.height)
- self.height = 32;
+ if (!this.speed)
+ this.speed = 4;
+ if (!this.height)
+ this.height = 32;
// center of bobbing motion
- self.destvec = self.origin;
+ this.destvec = this.origin;
// time scale to get degrees
- self.cnt = 360 / self.speed;
+ this.cnt = 360 / this.speed;
- self.active = ACTIVE_ACTIVE;
+ this.active = ACTIVE_ACTIVE;
// damage when blocked
- self.blocked = generic_plat_blocked;
- if(self.dmg && (self.message == ""))
- self.message = " was squished";
- if(self.dmg && (self.message2 == ""))
- self.message2 = "was squished by";
- if(self.dmg && (!self.dmgtime))
- self.dmgtime = 0.25;
- self.dmgtime2 = time;
+ this.blocked = generic_plat_blocked;
+ if(this.dmg && (this.message == ""))
+ this.message = " was squished";
+ if(this.dmg && (this.message2 == ""))
+ this.message2 = "was squished by";
+ if(this.dmg && (!this.dmgtime))
+ this.dmgtime = 0.25;
+ this.dmgtime2 = time;
// how far to bob
- if (self.spawnflags & 1) // X
- self.movedir = '1 0 0' * self.height;
- else if (self.spawnflags & 2) // Y
- self.movedir = '0 1 0' * self.height;
+ if (this.spawnflags & 1) // X
+ this.movedir = '1 0 0' * this.height;
+ else if (this.spawnflags & 2) // Y
+ this.movedir = '0 1 0' * this.height;
else // Z
- self.movedir = '0 0 1' * self.height;
+ this.movedir = '0 0 1' * this.height;
- if (!InitMovingBrushTrigger())
+ if (!InitMovingBrushTrigger(this))
return;
// wait for targets to spawn
controller = new(func_bobbing_controller);
- controller.owner = self;
+ controller.owner = this;
controller.nextthink = time + 1;
- controller.think = func_bobbing_controller_think;
- self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
- self.SUB_THINK = SUB_NullThink;
+ setthink(controller, func_bobbing_controller_think);
+ this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
+ SUB_THINK(this, SUB_NullThink);
// Savage: Reduce bandwith, critical on e.g. nexdm02
- self.effects |= EF_LOWPRECISION;
+ this.effects |= EF_LOWPRECISION;
// TODO make a reset function for this one
}
CSQCMODEL_AUTOUPDATE(this);
}
-void func_breakable_restore_self()
-{SELFPARAM();
+void func_breakable_restore_self(entity this)
+{
func_breakable_restore(this, NULL, NULL);
}
if(this.respawntime)
{
- this.think = func_breakable_restore_self;
+ setthink(this, func_breakable_restore_self);
this.nextthink = time + this.respawntime + crandom() * this.respawntimejitter;
}
this.message = oldmsg;
}
-void func_breakable_destroy_self()
-{SELFPARAM();
+void func_breakable_destroy_self(entity this)
+{
func_breakable_destroy(this, NULL, NULL);
}
// do not explode NOW but in the NEXT FRAME!
// because recursive calls to RadiusDamage are not allowed
this.nextthink = time;
- this.think = func_breakable_destroy_self;
+ setthink(this, func_breakable_destroy_self);
}
}
this.dmg_force = 200;
this.mdl = this.model;
- SetBrushEntityModel();
+ WITHSELF(this, SetBrushEntityModel());
if(this.spawnflags & 4)
this.use = func_breakable_destroy;
#ifdef SVQC
// button and multiple button
-void() button_wait;
-void() button_return;
+void button_wait(entity this);
+void button_return(entity this);
-void button_wait()
-{SELFPARAM();
+void button_wait(entity this)
+{
self.state = STATE_TOP;
self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
- self.SUB_THINK = button_return;
+ SUB_THINK(self, button_return);
SUB_UseTargets(self, self.enemy, NULL);
self.frame = 1; // use alternate textures
}
-void button_done()
-{SELFPARAM();
+void button_done(entity this)
+{
self.state = STATE_BOTTOM;
}
-void button_return()
-{SELFPARAM();
+void button_return(entity this)
+{
self.state = STATE_DOWN;
SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, button_done);
self.frame = 0; // use normal textures
SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, button_wait);
}
-void button_reset()
-{SELFPARAM();
- self.health = self.max_health;
- setorigin(self, self.pos1);
- self.frame = 0; // use normal textures
- self.state = STATE_BOTTOM;
- if (self.health)
- self.takedamage = DAMAGE_YES; // can be shot again
+void button_reset(entity this)
+{
+ this.health = this.max_health;
+ setorigin(this, this.pos1);
+ this.frame = 0; // use normal textures
+ this.state = STATE_BOTTOM;
+ if (this.health)
+ this.takedamage = DAMAGE_YES; // can be shot again
}
void button_use(entity this, entity actor, entity trigger)
WITHSELF(this, button_fire());
}
-void button_touch()
-{SELFPARAM();
+void button_touch(entity this)
+{
if (!other)
return;
if (!other.iscreature)
*/
spawnfunc(func_button)
{
- SetMovedir(self);
+ SetMovedir(this);
- if (!InitMovingBrushTrigger())
+ if (!InitMovingBrushTrigger(this))
return;
- self.effects |= EF_LOWPRECISION;
+ this.effects |= EF_LOWPRECISION;
- self.blocked = button_blocked;
- self.use = button_use;
+ this.blocked = button_blocked;
+ this.use = button_use;
-// if (self.health == 0) // all buttons are now shootable
-// self.health = 10;
- if (self.health)
+// if (this.health == 0) // all buttons are now shootable
+// this.health = 10;
+ if (this.health)
{
- self.max_health = self.health;
- self.event_damage = button_damage;
- self.takedamage = DAMAGE_YES;
+ this.max_health = this.health;
+ this.event_damage = button_damage;
+ this.takedamage = DAMAGE_YES;
}
else
- self.touch = button_touch;
+ settouch(this, button_touch);
- if (!self.speed)
- self.speed = 40;
- if (!self.wait)
- self.wait = 1;
- if (!self.lip)
- self.lip = 4;
+ if (!this.speed)
+ this.speed = 40;
+ if (!this.wait)
+ this.wait = 1;
+ if (!this.lip)
+ this.lip = 4;
- if(self.noise != "")
- precache_sound(self.noise);
+ if(this.noise != "")
+ precache_sound(this.noise);
- self.active = ACTIVE_ACTIVE;
+ this.active = ACTIVE_ACTIVE;
- self.pos1 = self.origin;
- self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
- self.flags |= FL_NOTARGET;
+ this.pos1 = this.origin;
+ this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
+ this.flags |= FL_NOTARGET;
- button_reset();
+ button_reset(this);
}
#endif
REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR)
-void conveyor_think()
-{SELFPARAM();
+void conveyor_think(entity this)
+{
#ifdef CSQC
// TODO: check if this is what is causing the glitchiness when switching between them
float dt = time - self.move_time;
return true;
}
-void conveyor_init()
-{SELFPARAM();
+void conveyor_init(entity this)
+{
if (!this.speed) this.speed = 200;
this.movedir *= this.speed;
- this.think = conveyor_think;
+ setthink(this, conveyor_think);
this.nextthink = time;
IFTARGETED
{
spawnfunc(trigger_conveyor)
{
- SetMovedir(self);
+ SetMovedir(this);
EXACTTRIGGER_INIT;
- conveyor_init();
+ conveyor_init(this);
}
spawnfunc(func_conveyor)
{
- SetMovedir(self);
- InitMovingBrushTrigger();
- self.movetype = MOVETYPE_NONE;
- conveyor_init();
+ SetMovedir(this);
+ InitMovingBrushTrigger(this);
+ this.movetype = MOVETYPE_NONE;
+ conveyor_init(this);
}
#elif defined(CSQC)
-void conveyor_draw(entity this) { WITHSELF(this, conveyor_think()); }
-
-void conveyor_init()
-{SELFPARAM();
- self.draw = conveyor_draw;
- self.drawmask = MASK_NORMAL;
+void conveyor_draw(entity this) { WITHSELF(this, conveyor_think(this)); }
- self.movetype = MOVETYPE_NONE;
- self.model = "";
- self.solid = SOLID_TRIGGER;
- self.move_origin = self.origin;
- self.move_time = time;
+void conveyor_init(entity this)
+{
+ this.draw = conveyor_draw;
+ this.drawmask = MASK_NORMAL;
+
+ this.movetype = MOVETYPE_NONE;
+ this.model = "";
+ this.solid = SOLID_TRIGGER;
+ this.move_origin = this.origin;
+ this.move_time = time;
}
NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
{
- float sf = ReadByte();
+ int sf = ReadByte();
if(sf & 1)
{
- self.warpzone_isboxy = ReadByte();
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- setorigin(self, self.origin);
-
- self.mins_x = ReadCoord();
- self.mins_y = ReadCoord();
- self.mins_z = ReadCoord();
- self.maxs_x = ReadCoord();
- self.maxs_y = ReadCoord();
- self.maxs_z = ReadCoord();
- setsize(self, self.mins, self.maxs);
-
- self.movedir_x = ReadCoord();
- self.movedir_y = ReadCoord();
- self.movedir_z = ReadCoord();
-
- self.speed = ReadByte();
- self.state = ReadByte();
-
- self.targetname = strzone(ReadString());
- self.target = strzone(ReadString());
-
- conveyor_init();
+ this.warpzone_isboxy = ReadByte();
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+ setorigin(this, this.origin);
+
+ this.mins_x = ReadCoord();
+ this.mins_y = ReadCoord();
+ this.mins_z = ReadCoord();
+ this.maxs_x = ReadCoord();
+ this.maxs_y = ReadCoord();
+ this.maxs_z = ReadCoord();
+ setsize(this, this.mins, this.maxs);
+
+ this.movedir_x = ReadCoord();
+ this.movedir_y = ReadCoord();
+ this.movedir_z = ReadCoord();
+
+ this.speed = ReadByte();
+ this.state = ReadByte();
+
+ this.targetname = strzone(ReadString());
+ this.target = strzone(ReadString());
+
+ conveyor_init(this);
}
if(sf & 2)
- self.state = ReadByte();
+ this.state = ReadByte();
return true;
}
=============================================================================
*/
-void() door_go_down;
+void door_go_down(entity this);
void() door_go_up;
-void() door_rotating_go_down;
+void door_rotating_go_down(entity this);
void() door_rotating_go_up;
void door_blocked()
else
if (self.classname == "door")
{
- door_go_down ();
+ door_go_down (self);
} else
{
- door_rotating_go_down ();
+ door_rotating_go_down (self);
}
}
}
}
}
-void door_hit_top()
-{SELFPARAM();
+void door_hit_top(entity this)
+{
if (self.noise1 != "")
_sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
self.state = STATE_TOP;
return; // don't come down automatically
if (self.classname == "door")
{
- self.SUB_THINK = door_go_down;
+ SUB_THINK(self, door_go_down);
} else
{
- self.SUB_THINK = door_rotating_go_down;
+ SUB_THINK(self, door_rotating_go_down);
}
self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
}
-void door_hit_bottom()
-{SELFPARAM();
+void door_hit_bottom(entity this)
+{
if (self.noise1 != "")
_sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
self.state = STATE_BOTTOM;
}
-void door_go_down()
-{SELFPARAM();
+void door_go_down(entity this)
+{
if (self.noise2 != "")
_sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
if (self.max_health)
void door_fire(entity this, entity actor, entity trigger)
{
- entity starte;
if (this.owner != this)
objerror ("door_fire: this.owner != this");
{
if (this.state == STATE_UP || this.state == STATE_TOP)
{
- starte = self;
- do
- {
- if (self.classname == "door")
- {
- door_go_down ();
- }
- else
- {
- door_rotating_go_down ();
+ entity e = this;
+ do {
+ if (e.classname == "door") {
+ WITHSELF(e, door_go_down(e));
+ } else {
+ WITHSELF(e, door_rotating_go_down(e));
}
- setself(self.enemy);
- } while ( (self != starte) && (self != world) );
- setself(this);
+ e = e.enemy;
+ } while ((e != this) && (e != NULL));
return;
}
}
// trigger all paired doors
- starte = self;
- do
- {
- if (self.classname == "door")
- {
- door_go_up ();
- } else
- {
+ entity e = this;
+ do {
+ if (e.classname == "door") {
+ WITHSELF(e, door_go_up());
+ } else {
// if the BIDIR spawnflag (==2) is set and the trigger has set trigger_reverse, reverse the opening direction
- if ((self.spawnflags & 2) && other.trigger_reverse!=0 && self.lip!=666 && self.state == STATE_BOTTOM)
- {
- self.lip = 666; // self.lip is used to remember reverse opening direction for door_rotating
- self.pos2 = '0 0 0' - self.pos2;
+ if ((e.spawnflags & 2) && other.trigger_reverse!=0 && e.lip != 666 && e.state == STATE_BOTTOM) {
+ e.lip = 666; // e.lip is used to remember reverse opening direction for door_rotating
+ e.pos2 = '0 0 0' - e.pos2;
}
// if BIDIR_IN_DOWN (==8) is set, prevent the door from reoping during closing if it is triggered from the wrong side
- if (!((self.spawnflags & 2) && (self.spawnflags & 8) && self.state == STATE_DOWN
- && (((self.lip==666) && (other.trigger_reverse==0)) || ((self.lip!=666) && (other.trigger_reverse!=0)))))
+ if (!((e.spawnflags & 2) && (e.spawnflags & 8) && e.state == STATE_DOWN
+ && (((e.lip == 666) && (other.trigger_reverse == 0)) || ((e.lip != 666) && (other.trigger_reverse != 0)))))
{
- door_rotating_go_up ();
+ WITHSELF(e, door_rotating_go_up());
}
}
- setself(self.enemy);
- } while ( (self != starte) && (self != world) );
- setself(this);
+ e = e.enemy;
+ } while ((e != this) && (e != NULL));
}
void door_use(entity this, entity actor, entity trigger)
================
*/
-void door_touch()
-{SELFPARAM();
+void door_touch(entity this)
+{
if (!IS_PLAYER(other))
return;
if (self.owner.door_finished > time)
if (self.state == STATE_DOWN)
door_rotating_go_up ();
else
- door_rotating_go_down ();
+ door_rotating_go_down (self);
}
}
#ifdef SVQC
}
}
-void door_rotating_hit_top()
-{SELFPARAM();
+void door_rotating_hit_top(entity this)
+{
if (self.noise1 != "")
_sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
self.state = STATE_TOP;
if (self.spawnflags & DOOR_TOGGLE)
return; // don't come down automatically
- self.SUB_THINK = door_rotating_go_down;
+ SUB_THINK(self, door_rotating_go_down);
self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
}
-void door_rotating_hit_bottom()
-{SELFPARAM();
+void door_rotating_hit_bottom(entity this)
+{
if (self.noise1 != "")
_sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
if (self.lip==666) // self.lip is used to remember reverse opening direction for door_rotating
self.state = STATE_BOTTOM;
}
-void door_rotating_go_down()
-{SELFPARAM();
+void door_rotating_go_down(entity this)
+{
if (self.noise2 != "")
_sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
if (self.max_health)
=========================================
*/
-void door_trigger_touch()
-{SELFPARAM();
+void door_trigger_touch(entity this)
+{
if (other.health < 1)
#ifdef SVQC
if (!((other.iscreature || (other.flags & FL_PROJECTILE)) && !IS_DEAD(other)))
trigger.solid = SOLID_TRIGGER;
trigger.owner = self;
#ifdef SVQC
- trigger.touch = door_trigger_touch;
-#elif defined(CSQC)
- trigger.trigger_touch = door_trigger_touch;
- trigger.draw = trigger_draw_generic;
- trigger.drawmask = MASK_NORMAL;
+ settouch(trigger, door_trigger_touch);
#endif
setsize (trigger, t1 - '60 60 8', t2 + '60 60 8');
SUB_SETORIGIN(this, this.pos1);
this.SUB_VELOCITY = '0 0 0';
this.state = STATE_BOTTOM;
- this.SUB_THINK = func_null;
+ SUB_THINK(this, func_null);
this.SUB_NEXTTHINK = 0;
#ifdef SVQC
spawnfunc(func_door)
{
// Quake 1 keys compatibility
- if (self.spawnflags & SPAWNFLAGS_GOLD_KEY)
- self.itemkeys |= ITEM_KEY_BIT(0);
- if (self.spawnflags & SPAWNFLAGS_SILVER_KEY)
- self.itemkeys |= ITEM_KEY_BIT(1);
+ if (this.spawnflags & SPAWNFLAGS_GOLD_KEY)
+ this.itemkeys |= ITEM_KEY_BIT(0);
+ if (this.spawnflags & SPAWNFLAGS_SILVER_KEY)
+ this.itemkeys |= ITEM_KEY_BIT(1);
- SetMovedir(self);
+ SetMovedir(this);
- self.max_health = self.health;
- if (!InitMovingBrushTrigger())
+ this.max_health = this.health;
+ if (!InitMovingBrushTrigger(this))
return;
- self.effects |= EF_LOWPRECISION;
- self.classname = "door";
+ this.effects |= EF_LOWPRECISION;
+ this.classname = "door";
- if(self.noise == "")
- self.noise = "misc/talk.wav";
- if(self.noise3 == "")
- self.noise3 = "misc/talk.wav";
- precache_sound(self.noise);
- precache_sound(self.noise3);
+ if(this.noise == "")
+ this.noise = "misc/talk.wav";
+ if(this.noise3 == "")
+ this.noise3 = "misc/talk.wav";
+ precache_sound(this.noise);
+ precache_sound(this.noise3);
- self.blocked = door_blocked;
- self.use = door_use;
+ this.blocked = door_blocked;
+ this.use = door_use;
- if(self.dmg && (self.message == ""))
- self.message = "was squished";
- if(self.dmg && (self.message2 == ""))
- self.message2 = "was squished by";
+ if(this.dmg && (this.message == ""))
+ this.message = "was squished";
+ if(this.dmg && (this.message2 == ""))
+ this.message2 = "was squished by";
- if (self.sounds > 0)
+ if (this.sounds > 0)
{
precache_sound ("plats/medplat1.wav");
precache_sound ("plats/medplat2.wav");
- self.noise2 = "plats/medplat1.wav";
- self.noise1 = "plats/medplat2.wav";
+ this.noise2 = "plats/medplat1.wav";
+ this.noise1 = "plats/medplat2.wav";
}
- if (!self.speed)
- self.speed = 100;
- if (!self.wait)
- self.wait = 3;
- if (!self.lip)
- self.lip = 8;
+ if (!this.speed)
+ this.speed = 100;
+ if (!this.wait)
+ this.wait = 3;
+ if (!this.lip)
+ this.lip = 8;
- self.pos1 = self.SUB_ORIGIN;
- self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
+ this.pos1 = this.SUB_ORIGIN;
+ this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
- if(self.spawnflags & DOOR_NONSOLID)
- self.solid = SOLID_NOT;
+ if(this.spawnflags & DOOR_NONSOLID)
+ this.solid = SOLID_NOT;
// DOOR_START_OPEN is to allow an entity to be lighted in the closed position
// but spawn in the open position
- if (self.spawnflags & DOOR_START_OPEN)
- InitializeEntity(self, door_init_startopen, INITPRIO_SETLOCATION);
+ if (this.spawnflags & DOOR_START_OPEN)
+ InitializeEntity(this, door_init_startopen, INITPRIO_SETLOCATION);
- self.state = STATE_BOTTOM;
+ this.state = STATE_BOTTOM;
- if (self.health)
+ if (this.health)
{
- self.takedamage = DAMAGE_YES;
- self.event_damage = door_damage;
+ this.takedamage = DAMAGE_YES;
+ this.event_damage = door_damage;
}
- if (self.items)
- self.wait = -1;
+ if (this.items)
+ this.wait = -1;
- self.touch = door_touch;
+ settouch(this, door_touch);
// LinkDoors can't be done until all of the doors have been spawned, so
// the sizes can be detected properly.
- InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS);
+ InitializeEntity(this, LinkDoors, INITPRIO_LINKDOORS);
- self.reset = door_reset;
+ this.reset = door_reset;
}
#elif defined(CSQC)
-void door_draw(entity this)
-{
- Movetype_Physics_NoMatchServer(this);
-
- trigger_draw_generic(this);
-}
-
NET_HANDLE(ENT_CLIENT_DOOR, bool isnew)
{
- float sf = ReadByte();
+ int sf = ReadByte();
if(sf & SF_TRIGGER_INIT)
{
this.mdl = strzone(ReadString());
_setmodel(this, this.mdl);
- trigger_common_read(true);
+ trigger_common_read(this, true);
vector v;
this.solid = SOLID_BSP;
this.movetype = MOVETYPE_PUSH;
- this.trigger_touch = door_touch;
- this.draw = door_draw;
- this.drawmask = MASK_NORMAL;
this.use = door_use;
LinkDoors(this);
this.angles = this.pos1;
this.avelocity = '0 0 0';
this.state = STATE_BOTTOM;
- this.think = func_null;
+ setthink(this, func_null);
this.nextthink = 0;
}
spawnfunc(func_door_rotating)
{
- //if (!self.deathtype) // map makers can override this
- // self.deathtype = " got in the way";
+ //if (!this.deathtype) // map makers can override this
+ // this.deathtype = " got in the way";
// I abuse "movedir" for denoting the axis for now
- if (self.spawnflags & 64) // X (untested)
- self.movedir = '0 0 1';
- else if (self.spawnflags & 128) // Y (untested)
- self.movedir = '1 0 0';
+ if (this.spawnflags & 64) // X (untested)
+ this.movedir = '0 0 1';
+ else if (this.spawnflags & 128) // Y (untested)
+ this.movedir = '1 0 0';
else // Z
- self.movedir = '0 1 0';
+ this.movedir = '0 1 0';
- if (self.angles_y==0) self.angles_y = 90;
+ if (this.angles_y==0) this.angles_y = 90;
- self.movedir = self.movedir * self.angles_y;
- self.angles = '0 0 0';
+ this.movedir = this.movedir * this.angles_y;
+ this.angles = '0 0 0';
- self.max_health = self.health;
- self.avelocity = self.movedir;
- if (!InitMovingBrushTrigger())
+ this.max_health = this.health;
+ this.avelocity = this.movedir;
+ if (!InitMovingBrushTrigger(this))
return;
- self.velocity = '0 0 0';
- //self.effects |= EF_LOWPRECISION;
- self.classname = "door_rotating";
+ this.velocity = '0 0 0';
+ //this.effects |= EF_LOWPRECISION;
+ this.classname = "door_rotating";
- self.blocked = door_blocked;
- self.use = door_use;
+ this.blocked = door_blocked;
+ this.use = door_use;
- if(self.spawnflags & 8)
- self.dmg = 10000;
+ if(this.spawnflags & 8)
+ this.dmg = 10000;
- if(self.dmg && (self.message == ""))
- self.message = "was squished";
- if(self.dmg && (self.message2 == ""))
- self.message2 = "was squished by";
+ if(this.dmg && (this.message == ""))
+ this.message = "was squished";
+ if(this.dmg && (this.message2 == ""))
+ this.message2 = "was squished by";
- if (self.sounds > 0)
+ if (this.sounds > 0)
{
precache_sound ("plats/medplat1.wav");
precache_sound ("plats/medplat2.wav");
- self.noise2 = "plats/medplat1.wav";
- self.noise1 = "plats/medplat2.wav";
+ this.noise2 = "plats/medplat1.wav";
+ this.noise1 = "plats/medplat2.wav";
}
- if (!self.speed)
- self.speed = 50;
- if (!self.wait)
- self.wait = 1;
- self.lip = 0; // self.lip is used to remember reverse opening direction for door_rotating
+ if (!this.speed)
+ this.speed = 50;
+ if (!this.wait)
+ this.wait = 1;
+ this.lip = 0; // this.lip is used to remember reverse opening direction for door_rotating
- self.pos1 = '0 0 0';
- self.pos2 = self.movedir;
+ this.pos1 = '0 0 0';
+ this.pos2 = this.movedir;
// DOOR_START_OPEN is to allow an entity to be lighted in the closed position
// but spawn in the open position
- if (self.spawnflags & DOOR_START_OPEN)
- InitializeEntity(self, door_rotating_init_startopen, INITPRIO_SETLOCATION);
+ if (this.spawnflags & DOOR_START_OPEN)
+ InitializeEntity(this, door_rotating_init_startopen, INITPRIO_SETLOCATION);
- self.state = STATE_BOTTOM;
+ this.state = STATE_BOTTOM;
- if (self.health)
+ if (this.health)
{
- self.takedamage = DAMAGE_YES;
- self.event_damage = door_damage;
+ this.takedamage = DAMAGE_YES;
+ this.event_damage = door_damage;
}
- if (self.items)
- self.wait = -1;
+ if (this.items)
+ this.wait = -1;
- self.touch = door_touch;
+ settouch(this, door_touch);
// LinkDoors can't be done until all of the doors have been spawned, so
// the sizes can be detected properly.
- InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS);
+ InitializeEntity(this, LinkDoors, INITPRIO_LINKDOORS);
- self.reset = door_rotating_reset;
+ this.reset = door_rotating_reset;
}
#endif
#ifdef SVQC
-void() fd_secret_move1;
-void() fd_secret_move2;
-void() fd_secret_move3;
-void() fd_secret_move4;
-void() fd_secret_move5;
-void() fd_secret_move6;
-void() fd_secret_done;
+void fd_secret_move1(entity this);
+void fd_secret_move2(entity this);
+void fd_secret_move3(entity this);
+void fd_secret_move4(entity this);
+void fd_secret_move5(entity this);
+void fd_secret_move6(entity this);
+void fd_secret_done(entity this);
const float SECRET_OPEN_ONCE = 1; // stays open
const float SECRET_1ST_LEFT = 2; // 1st move is left of arrow
}
// Wait after first movement...
-void fd_secret_move1()
-{SELFPARAM();
+void fd_secret_move1(entity this)
+{
self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
- self.think = fd_secret_move2;
+ setthink(self, fd_secret_move2);
if (self.noise3 != "")
_sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
}
// Start moving sideways w/sound...
-void fd_secret_move2()
-{SELFPARAM();
+void fd_secret_move2(entity this)
+{
if (self.noise2 != "")
_sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
SUB_CalcMove(self.dest2, TSPEED_LINEAR, self.speed, fd_secret_move3);
}
// Wait here until time to go back...
-void fd_secret_move3()
-{SELFPARAM();
+void fd_secret_move3(entity this)
+{
if (self.noise3 != "")
_sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
if (!(self.spawnflags & SECRET_OPEN_ONCE))
{
self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
- self.think = fd_secret_move4;
+ setthink(self, fd_secret_move4);
}
}
// Move backward...
-void fd_secret_move4()
-{SELFPARAM();
+void fd_secret_move4(entity this)
+{
if (self.noise2 != "")
_sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
SUB_CalcMove(self.dest1, TSPEED_LINEAR, self.speed, fd_secret_move5);
}
// Wait 1 second...
-void fd_secret_move5()
-{SELFPARAM();
+void fd_secret_move5(entity this)
+{
self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
- self.think = fd_secret_move6;
+ setthink(self, fd_secret_move6);
if (self.noise3 != "")
_sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
}
-void fd_secret_move6()
-{SELFPARAM();
+void fd_secret_move6(entity this)
+{
if (self.noise2 != "")
_sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
SUB_CalcMove(self.oldorigin, TSPEED_LINEAR, self.speed, fd_secret_done);
}
-void fd_secret_done()
-{SELFPARAM();
+void fd_secret_done(entity this)
+{
if (self.spawnflags&SECRET_YES_SHOOT)
{
self.health = 10000;
Prints messages
================
*/
-void secret_touch()
-{SELFPARAM();
+void secret_touch(entity this)
+{
if (!other.iscreature)
return;
if (self.door_finished > time)
this.takedamage = DAMAGE_YES;
}
setorigin(this, this.oldorigin);
- this.think = func_null;
+ setthink(this, func_null);
this.SUB_NEXTTHINK = 0;
}
this.mangle = this.angles;
this.angles = '0 0 0';
this.classname = "door";
- if (!InitMovingBrushTrigger()) return;
+ if (!InitMovingBrushTrigger(this)) return;
this.effects |= EF_LOWPRECISION;
if (this.noise == "") this.noise = "misc/talk.wav";
precache_sound(this.noise);
- this.touch = secret_touch;
+ settouch(this, secret_touch);
this.blocked = secret_blocked;
this.speed = 50;
this.use = fd_secret_use;
dmgtime: See above.
*/
-void func_fourier_controller_think()
-{SELFPARAM();
+void func_fourier_controller_think(entity this)
+{
vector v;
float n, i, t;
spawnfunc(func_fourier)
{
entity controller;
- if (self.noise != "")
+ if (this.noise != "")
{
- precache_sound(self.noise);
- soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
+ precache_sound(this.noise);
+ soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
}
- if (!self.speed)
- self.speed = 4;
- if (!self.height)
- self.height = 32;
- self.destvec = self.origin;
- self.cnt = 360 / self.speed;
-
- self.blocked = generic_plat_blocked;
- if(self.dmg && (self.message == ""))
- self.message = " was squished";
- if(self.dmg && (self.message2 == ""))
- self.message2 = "was squished by";
- if(self.dmg && (!self.dmgtime))
- self.dmgtime = 0.25;
- self.dmgtime2 = time;
-
- if(self.netname == "")
- self.netname = "1 0 0 0 1";
-
- if (!InitMovingBrushTrigger())
+ if (!this.speed)
+ this.speed = 4;
+ if (!this.height)
+ this.height = 32;
+ this.destvec = this.origin;
+ this.cnt = 360 / this.speed;
+
+ this.blocked = generic_plat_blocked;
+ if(this.dmg && (this.message == ""))
+ this.message = " was squished";
+ if(this.dmg && (this.message2 == ""))
+ this.message2 = "was squished by";
+ if(this.dmg && (!this.dmgtime))
+ this.dmgtime = 0.25;
+ this.dmgtime2 = time;
+
+ if(this.netname == "")
+ this.netname = "1 0 0 0 1";
+
+ if (!InitMovingBrushTrigger(this))
return;
- self.active = ACTIVE_ACTIVE;
+ this.active = ACTIVE_ACTIVE;
// wait for targets to spawn
controller = new(func_fourier_controller);
- controller.owner = self;
+ controller.owner = this;
controller.nextthink = time + 1;
- controller.think = func_fourier_controller_think;
- self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
- self.SUB_THINK = SUB_NullThink; // for PushMove
+ setthink(controller, func_fourier_controller_think);
+ this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
+ SUB_THINK(this, SUB_NullThink); // for PushMove
// Savage: Reduce bandwith, critical on e.g. nexdm02
- self.effects |= EF_LOWPRECISION;
+ this.effects |= EF_LOWPRECISION;
// TODO make a reset function for this one
}
REGISTER_NET_LINKED(ENT_CLIENT_LADDER)
-void func_ladder_touch()
-{SELFPARAM();
+void func_ladder_touch(entity this)
+{
#ifdef SVQC
if (!other.iscreature)
return;
return true;
}
-void func_ladder_link()
+void func_ladder_link(entity this)
{
- SELFPARAM();
- self.SendEntity = func_ladder_send;
- self.SendFlags = 0xFFFFFF;
- //self.model = "null";
+ this.SendEntity = func_ladder_send;
+ this.SendFlags = 0xFFFFFF;
+ //this.model = "null";
}
-void func_ladder_init()
+void func_ladder_init(entity this)
{
- SELFPARAM();
- self.touch = func_ladder_touch;
+ settouch(this, func_ladder_touch);
- trigger_init(self);
- func_ladder_link();
+ trigger_init(this);
+ func_ladder_link(this);
}
spawnfunc(func_ladder)
{
- func_ladder_init();
+ func_ladder_init(this);
}
spawnfunc(func_water)
{
- func_ladder_init();
+ func_ladder_init(this);
}
#elif defined(CSQC)
NET_HANDLE(ENT_CLIENT_LADDER, bool isnew)
{
- self.classname = strzone(ReadString());
- self.skin = ReadByte();
- self.speed = ReadCoord();
+ this.classname = strzone(ReadString());
+ this.skin = ReadByte();
+ this.speed = ReadCoord();
- trigger_common_read(false);
+ trigger_common_read(this, false);
- self.solid = SOLID_TRIGGER;
- self.move_touch = func_ladder_touch;
- self.drawmask = MASK_NORMAL;
- self.move_time = time;
- self.entremove = func_ladder_remove;
+ this.solid = SOLID_TRIGGER;
+ settouch(this, func_ladder_touch);
+ this.drawmask = MASK_NORMAL;
+ this.move_time = time;
+ this.entremove = func_ladder_remove;
return true;
}
#ifdef SVQC
.float freq;
-void func_pendulum_controller_think()
-{SELFPARAM();
+void func_pendulum_controller_think(entity this)
+{
float v;
self.nextthink = time + 0.1;
spawnfunc(func_pendulum)
{
entity controller;
- if (self.noise != "")
+ if (this.noise != "")
{
- precache_sound(self.noise);
- soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
+ precache_sound(this.noise);
+ soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
}
- self.active = ACTIVE_ACTIVE;
+ this.active = ACTIVE_ACTIVE;
// keys: angle, speed, phase, noise, freq
- if(!self.speed)
- self.speed = 30;
- // not initializing self.dmg to 2, to allow damageless pendulum
+ if(!this.speed)
+ this.speed = 30;
+ // not initializing this.dmg to 2, to allow damageless pendulum
- if(self.dmg && (self.message == ""))
- self.message = " was squished";
- if(self.dmg && (self.message2 == ""))
- self.message2 = "was squished by";
- if(self.dmg && (!self.dmgtime))
- self.dmgtime = 0.25;
- self.dmgtime2 = time;
+ if(this.dmg && (this.message == ""))
+ this.message = " was squished";
+ if(this.dmg && (this.message2 == ""))
+ this.message2 = "was squished by";
+ if(this.dmg && (!this.dmgtime))
+ this.dmgtime = 0.25;
+ this.dmgtime2 = time;
- self.blocked = generic_plat_blocked;
+ this.blocked = generic_plat_blocked;
- self.avelocity_z = 0.0000001;
- if (!InitMovingBrushTrigger())
+ this.avelocity_z = 0.0000001;
+ if (!InitMovingBrushTrigger(this))
return;
- if(!self.freq)
+ if(!this.freq)
{
// find pendulum length (same formula as Q3A)
- self.freq = 1 / (M_PI * 2) * sqrt(autocvar_sv_gravity / (3 * max(8, fabs(self.mins_z))));
+ this.freq = 1 / (M_PI * 2) * sqrt(autocvar_sv_gravity / (3 * max(8, fabs(this.mins_z))));
}
// copy initial angle
- self.cnt = self.angles_z;
+ this.cnt = this.angles_z;
// wait for targets to spawn
controller = new(func_pendulum_controller);
- controller.owner = self;
+ controller.owner = this;
controller.nextthink = time + 1;
- controller.think = func_pendulum_controller_think;
- self.nextthink = self.SUB_LTIME + 999999999;
- self.SUB_THINK = SUB_NullThink; // for PushMove
+ setthink(controller, func_pendulum_controller_think);
+ this.nextthink = this.SUB_LTIME + 999999999;
+ SUB_THINK(this, SUB_NullThink); // for PushMove
- //self.effects |= EF_LOWPRECISION;
+ //this.effects |= EF_LOWPRECISION;
// TODO make a reset function for this one
}
this.angles = '0 0 0';
this.classname = "plat";
- if (!InitMovingBrushTrigger())
+ if (!InitMovingBrushTrigger(this))
return;
this.effects |= EF_LOWPRECISION;
setsize (this, this.mins , this.maxs);
this.model = strzone(ReadString());
_setmodel(this, this.model);
- trigger_common_read(true);
+ trigger_common_read(this, true);
this.pos1_x = ReadCoord();
this.pos1_y = ReadCoord();
this.SendFlags |= 2;
}
-void pointparticles_think()
-{SELFPARAM();
+void pointparticles_think(entity this)
+{
if(self.origin != self.oldorigin)
{
self.SendFlags |= 4;
}
else
this.state = 1;
- this.think = pointparticles_think;
+ setthink(this, pointparticles_think);
this.nextthink = time;
}
vector p;
vector sz;
vector o;
- o = self.origin;
- sz = self.maxs - self.mins;
- n = doBGMScript(self);
- if(self.absolute == 2)
+ o = this.origin;
+ sz = this.maxs - this.mins;
+ n = doBGMScript(this);
+ if(this.absolute == 2)
{
if(n >= 0)
- n = self.just_toggled ? self.impulse : 0;
+ n = this.just_toggled ? this.impulse : 0;
else
- n = self.impulse * drawframetime;
+ n = this.impulse * drawframetime;
}
else
{
- n *= self.impulse * drawframetime;
- if(self.just_toggled)
+ n *= this.impulse * drawframetime;
+ if(this.just_toggled)
if(n < 1)
n = 1;
}
fail = 0;
for(i = random(); i <= n && fail <= 64*n; ++i)
{
- p = o + self.mins;
+ p = o + this.mins;
p.x += random() * sz.x;
p.y += random() * sz.y;
p.z += random() * sz.z;
- if(WarpZoneLib_BoxTouchesBrush(p, p, self, world))
+ if(WarpZoneLib_BoxTouchesBrush(p, p, this, world))
{
- if(self.movedir != '0 0 0')
+ if(this.movedir != '0 0 0')
{
- traceline(p, p + normalize(self.movedir) * 4096, 0, world);
+ traceline(p, p + normalize(this.movedir) * 4096, 0, world);
p = trace_endpos;
int eff_num;
- if(self.cnt)
- eff_num = self.cnt;
+ if(this.cnt)
+ eff_num = this.cnt;
else
- eff_num = _particleeffectnum(self.mdl);
- __pointparticles(eff_num, p, trace_plane_normal * vlen(self.movedir) + self.velocity + randomvec() * self.waterlevel, self.count);
+ eff_num = _particleeffectnum(this.mdl);
+ __pointparticles(eff_num, p, trace_plane_normal * vlen(this.movedir) + this.velocity + randomvec() * this.waterlevel, this.count);
}
else
{
int eff_num;
- if(self.cnt)
- eff_num = self.cnt;
+ if(this.cnt)
+ eff_num = this.cnt;
else
- eff_num = _particleeffectnum(self.mdl);
- __pointparticles(eff_num, p, self.velocity + randomvec() * self.waterlevel, self.count);
+ eff_num = _particleeffectnum(this.mdl);
+ __pointparticles(eff_num, p, this.velocity + randomvec() * this.waterlevel, this.count);
}
- if(self.noise != "")
+ if(this.noise != "")
{
- setorigin(self, p);
- _sound(self, CH_AMBIENT, self.noise, VOL_BASE * self.volume, self.atten);
+ setorigin(this, p);
+ _sound(this, CH_AMBIENT, this.noise, VOL_BASE * this.volume, this.atten);
}
- self.just_toggled = 0;
+ this.just_toggled = 0;
}
- else if(self.absolute)
+ else if(this.absolute)
{
++fail;
--i;
}
}
- setorigin(self, o);
+ setorigin(this, o);
}
void Ent_PointParticles_Remove(entity this)
if(f & 2)
{
i = ReadCoord(); // density (<0: point, >0: volume)
- if(i && !self.impulse && (self.cnt || self.mdl)) // self.cnt check is so it only happens if the ent already existed
- self.just_toggled = 1;
- self.impulse = i;
+ if(i && !this.impulse && (this.cnt || this.mdl)) // this.cnt check is so it only happens if the ent already existed
+ this.just_toggled = 1;
+ this.impulse = i;
}
if(f & 4)
{
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
}
if(f & 1)
{
- self.modelindex = ReadShort();
+ this.modelindex = ReadShort();
if(f & 0x80)
{
- if(self.modelindex)
+ if(this.modelindex)
{
- self.mins_x = ReadCoord();
- self.mins_y = ReadCoord();
- self.mins_z = ReadCoord();
- self.maxs_x = ReadCoord();
- self.maxs_y = ReadCoord();
- self.maxs_z = ReadCoord();
+ this.mins_x = ReadCoord();
+ this.mins_y = ReadCoord();
+ this.mins_z = ReadCoord();
+ this.maxs_x = ReadCoord();
+ this.maxs_y = ReadCoord();
+ this.maxs_z = ReadCoord();
}
else
{
- self.mins = '0 0 0';
- self.maxs_x = ReadCoord();
- self.maxs_y = ReadCoord();
- self.maxs_z = ReadCoord();
+ this.mins = '0 0 0';
+ this.maxs_x = ReadCoord();
+ this.maxs_y = ReadCoord();
+ this.maxs_z = ReadCoord();
}
}
else
{
- self.mins = self.maxs = '0 0 0';
+ this.mins = this.maxs = '0 0 0';
}
- self.cnt = ReadShort(); // effect number
- self.mdl = strzone(ReadString()); // effect string
+ this.cnt = ReadShort(); // effect number
+ this.mdl = strzone(ReadString()); // effect string
if(f & 0x20)
{
- self.velocity = decompressShortVector(ReadShort());
- self.movedir = decompressShortVector(ReadShort());
+ this.velocity = decompressShortVector(ReadShort());
+ this.movedir = decompressShortVector(ReadShort());
}
else
{
- self.velocity = self.movedir = '0 0 0';
+ this.velocity = this.movedir = '0 0 0';
}
if(f & 0x40)
{
- self.waterlevel = ReadShort() / 16.0;
- self.count = ReadByte() / 16.0;
+ this.waterlevel = ReadShort() / 16.0;
+ this.count = ReadByte() / 16.0;
}
else
{
- self.waterlevel = 0;
- self.count = 1;
+ this.waterlevel = 0;
+ this.count = 1;
}
- if(self.noise)
- strunzone(self.noise);
- if(self.bgmscript)
- strunzone(self.bgmscript);
- self.noise = strzone(ReadString());
- if(self.noise != "")
+ if(this.noise)
+ strunzone(this.noise);
+ if(this.bgmscript)
+ strunzone(this.bgmscript);
+ this.noise = strzone(ReadString());
+ if(this.noise != "")
{
- self.atten = ReadByte() / 64.0;
- self.volume = ReadByte() / 255.0;
+ this.atten = ReadByte() / 64.0;
+ this.volume = ReadByte() / 255.0;
}
- self.bgmscript = strzone(ReadString());
- if(self.bgmscript != "")
+ this.bgmscript = strzone(ReadString());
+ if(this.bgmscript != "")
{
- self.bgmscriptattack = ReadByte() / 64.0;
- self.bgmscriptdecay = ReadByte() / 64.0;
- self.bgmscriptsustain = ReadByte() / 255.0;
- self.bgmscriptrelease = ReadByte() / 64.0;
+ this.bgmscriptattack = ReadByte() / 64.0;
+ this.bgmscriptdecay = ReadByte() / 64.0;
+ this.bgmscriptsustain = ReadByte() / 255.0;
+ this.bgmscriptrelease = ReadByte() / 64.0;
}
- BGMScript_InitEntity(self);
+ BGMScript_InitEntity(this);
}
return = true;
if(f & 2)
{
- self.absolute = (self.impulse >= 0);
- if(!self.absolute)
+ this.absolute = (this.impulse >= 0);
+ if(!this.absolute)
{
- v = self.maxs - self.mins;
- self.impulse *= -v.x * v.y * v.z / 262144; // relative: particles per 64^3 cube
+ v = this.maxs - this.mins;
+ this.impulse *= -v.x * v.y * v.z / 262144; // relative: particles per 64^3 cube
}
}
if(f & 0x10)
- self.absolute = 2;
+ this.absolute = 2;
- setorigin(self, self.origin);
- setsize(self, self.mins, self.maxs);
- self.solid = SOLID_NOT;
- self.draw = Draw_PointParticles;
- self.entremove = Ent_PointParticles_Remove;
+ setorigin(this, this.origin);
+ setsize(this, this.mins, this.maxs);
+ this.solid = SOLID_NOT;
+ this.draw = Draw_PointParticles;
+ this.entremove = Ent_PointParticles_Remove;
}
#endif
bool rainsnow_SendEntity(entity this, entity to, float sf)
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_RAINSNOW);
- WriteByte(MSG_ENTITY, self.state);
- WriteCoord(MSG_ENTITY, self.origin_x + self.mins_x);
- WriteCoord(MSG_ENTITY, self.origin_y + self.mins_y);
- WriteCoord(MSG_ENTITY, self.origin_z + self.mins_z);
- WriteCoord(MSG_ENTITY, self.maxs_x - self.mins_x);
- WriteCoord(MSG_ENTITY, self.maxs_y - self.mins_y);
- WriteCoord(MSG_ENTITY, self.maxs_z - self.mins_z);
- WriteShort(MSG_ENTITY, compressShortVector(self.dest));
- WriteShort(MSG_ENTITY, self.count);
- WriteByte(MSG_ENTITY, self.cnt);
+ WriteByte(MSG_ENTITY, this.state);
+ WriteCoord(MSG_ENTITY, this.origin_x + this.mins_x);
+ WriteCoord(MSG_ENTITY, this.origin_y + this.mins_y);
+ WriteCoord(MSG_ENTITY, this.origin_z + this.mins_z);
+ WriteCoord(MSG_ENTITY, this.maxs_x - this.mins_x);
+ WriteCoord(MSG_ENTITY, this.maxs_y - this.mins_y);
+ WriteCoord(MSG_ENTITY, this.maxs_z - this.mins_z);
+ WriteShort(MSG_ENTITY, compressShortVector(this.dest));
+ WriteShort(MSG_ENTITY, this.count);
+ WriteByte(MSG_ENTITY, this.cnt);
return true;
}
*/
spawnfunc(func_rain)
{
- self.dest = self.velocity;
- self.velocity = '0 0 0';
- if (!self.dest)
- self.dest = '0 0 -700';
- self.angles = '0 0 0';
- self.movetype = MOVETYPE_NONE;
- self.solid = SOLID_NOT;
+ this.dest = this.velocity;
+ this.velocity = '0 0 0';
+ if (!this.dest)
+ this.dest = '0 0 -700';
+ this.angles = '0 0 0';
+ this.movetype = MOVETYPE_NONE;
+ this.solid = SOLID_NOT;
SetBrushEntityModel();
- if (!self.cnt)
- self.cnt = 12;
- if (!self.count)
- self.count = 2000;
- self.count = 0.01 * self.count * (self.size_x / 1024) * (self.size_y / 1024);
- if (self.count < 1)
- self.count = 1;
- if(self.count > 65535)
- self.count = 65535;
+ if (!this.cnt)
+ this.cnt = 12;
+ if (!this.count)
+ this.count = 2000;
+ this.count = 0.01 * this.count * (this.size_x / 1024) * (this.size_y / 1024);
+ if (this.count < 1)
+ this.count = 1;
+ if(this.count > 65535)
+ this.count = 65535;
- self.state = 1; // 1 is rain, 0 is snow
- self.Version = 1;
+ this.state = 1; // 1 is rain, 0 is snow
+ this.Version = 1;
- Net_LinkEntity(self, false, 0, rainsnow_SendEntity);
+ Net_LinkEntity(this, false, 0, rainsnow_SendEntity);
}
*/
spawnfunc(func_snow)
{
- self.dest = self.velocity;
- self.velocity = '0 0 0';
- if (!self.dest)
- self.dest = '0 0 -300';
- self.angles = '0 0 0';
- self.movetype = MOVETYPE_NONE;
- self.solid = SOLID_NOT;
+ this.dest = this.velocity;
+ this.velocity = '0 0 0';
+ if (!this.dest)
+ this.dest = '0 0 -300';
+ this.angles = '0 0 0';
+ this.movetype = MOVETYPE_NONE;
+ this.solid = SOLID_NOT;
SetBrushEntityModel();
- if (!self.cnt)
- self.cnt = 12;
- if (!self.count)
- self.count = 2000;
- self.count = 0.01 * self.count * (self.size_x / 1024) * (self.size_y / 1024);
- if (self.count < 1)
- self.count = 1;
- if(self.count > 65535)
- self.count = 65535;
+ if (!this.cnt)
+ this.cnt = 12;
+ if (!this.count)
+ this.count = 2000;
+ this.count = 0.01 * this.count * (this.size_x / 1024) * (this.size_y / 1024);
+ if (this.count < 1)
+ this.count = 1;
+ if(this.count > 65535)
+ this.count = 65535;
- self.state = 0; // 1 is rain, 0 is snow
- self.Version = 1;
+ this.state = 0; // 1 is rain, 0 is snow
+ this.Version = 1;
- Net_LinkEntity(self, false, 0, rainsnow_SendEntity);
+ Net_LinkEntity(this, false, 0, rainsnow_SendEntity);
}
#elif defined(CSQC)
void Draw_Rain(entity this)
NET_HANDLE(ENT_CLIENT_RAINSNOW, bool isnew)
{
- self.impulse = ReadByte(); // Rain, Snow, or Whatever
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- self.maxs_x = ReadCoord();
- self.maxs_y = ReadCoord();
- self.maxs_z = ReadCoord();
- self.velocity = decompressShortVector(ReadShort());
- self.count = ReadShort() * 10;
- self.glow_color = ReadByte(); // color
+ this.impulse = ReadByte(); // Rain, Snow, or Whatever
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+ this.maxs_x = ReadCoord();
+ this.maxs_y = ReadCoord();
+ this.maxs_z = ReadCoord();
+ this.velocity = decompressShortVector(ReadShort());
+ this.count = ReadShort() * 10;
+ this.glow_color = ReadByte(); // color
return = true;
- self.mins = -0.5 * self.maxs;
- self.maxs = 0.5 * self.maxs;
- self.origin = self.origin - self.mins;
+ this.mins = -0.5 * this.maxs;
+ this.maxs = 0.5 * this.maxs;
+ this.origin = this.origin - this.mins;
- setorigin(self, self.origin);
- setsize(self, self.mins, self.maxs);
- self.solid = SOLID_NOT;
- if(self.impulse)
- self.draw = Draw_Rain;
+ setorigin(this, this.origin);
+ setsize(this, this.mins, this.maxs);
+ this.solid = SOLID_NOT;
+ if(this.impulse)
+ this.draw = Draw_Rain;
else
- self.draw = Draw_Snow;
+ this.draw = Draw_Snow;
}
#endif
spawnfunc(func_rotating)
{
- if (self.noise != "")
+ if (this.noise != "")
{
- precache_sound(self.noise);
- ambientsound(self.origin, self.noise, VOL_BASE, ATTEN_IDLE);
+ precache_sound(this.noise);
+ ambientsound(this.origin, this.noise, VOL_BASE, ATTEN_IDLE);
}
- self.active = ACTIVE_ACTIVE;
- self.setactive = func_rotating_setactive;
+ this.active = ACTIVE_ACTIVE;
+ this.setactive = func_rotating_setactive;
- if (!self.speed)
- self.speed = 100;
+ if (!this.speed)
+ this.speed = 100;
// FIXME: test if this turns the right way, then remove this comment (negate as needed)
- if (self.spawnflags & 4) // X (untested)
- self.avelocity = '0 0 1' * self.speed;
+ if (this.spawnflags & 4) // X (untested)
+ this.avelocity = '0 0 1' * this.speed;
// FIXME: test if this turns the right way, then remove this comment (negate as needed)
- else if (self.spawnflags & 8) // Y (untested)
- self.avelocity = '1 0 0' * self.speed;
+ else if (this.spawnflags & 8) // Y (untested)
+ this.avelocity = '1 0 0' * this.speed;
// FIXME: test if this turns the right way, then remove this comment (negate as needed)
else // Z
- self.avelocity = '0 1 0' * self.speed;
+ this.avelocity = '0 1 0' * this.speed;
- self.pos1 = self.avelocity;
+ this.pos1 = this.avelocity;
- if(self.dmg && (self.message == ""))
- self.message = " was squished";
- if(self.dmg && (self.message2 == ""))
- self.message2 = "was squished by";
+ if(this.dmg && (this.message == ""))
+ this.message = " was squished";
+ if(this.dmg && (this.message2 == ""))
+ this.message2 = "was squished by";
- if(self.dmg && (!self.dmgtime))
- self.dmgtime = 0.25;
+ if(this.dmg && (!this.dmgtime))
+ this.dmgtime = 0.25;
- self.dmgtime2 = time;
+ this.dmgtime2 = time;
- if (!InitMovingBrushTrigger())
+ if (!InitMovingBrushTrigger(this))
return;
// no EF_LOWPRECISION here, as rounding angles is bad
- self.blocked = generic_plat_blocked;
+ this.blocked = generic_plat_blocked;
// wait for targets to spawn
- self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
- self.SUB_THINK = SUB_NullThink; // for PushMove
+ this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
+ SUB_THINK(this, SUB_NullThink); // for PushMove
// TODO make a reset function for this one
}
#ifdef SVQC
spawnfunc(func_stardust)
{
- self.effects = EF_STARDUST;
+ this.effects = EF_STARDUST;
- CSQCMODEL_AUTOINIT(self);
+ CSQCMODEL_AUTOINIT(this);
}
#endif
.float train_wait_turning;
-void() train_next;
+void train_next(entity this);
#ifdef SVQC
void train_use(entity this, entity actor, entity trigger);
#endif
-void train_wait()
-{SELFPARAM();
+void train_wait(entity this)
+{
SUB_UseTargets(this.enemy, NULL, NULL);
self.enemy = world;
if(tg.spawnflags & 4)
{
self.use = train_use;
- self.SUB_THINK = func_null;
+ SUB_THINK(self, func_null);
self.SUB_NEXTTHINK = 0;
}
else
if(self.wait < 0 || self.train_wait_turning) // no waiting or we already waited while turning
{
self.train_wait_turning = false;
- train_next();
+ train_next(self);
}
else
{
- self.SUB_THINK = train_next;
+ SUB_THINK(self, train_next);
self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
}
}
-void train_next()
-{SELFPARAM();
+void train_next(entity this)
+{
entity targ, cp = world;
vector cp_org = '0 0 0';
void train_use(entity this, entity actor, entity trigger)
{
this.SUB_NEXTTHINK = this.SUB_LTIME + 1;
- this.SUB_THINK = train_next;
+ SUB_THINK(this, train_next);
this.use = func_null; // not again
}
if(!(self.spawnflags & 4))
{
self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
- self.SUB_THINK = train_next;
+ SUB_THINK(self, train_next);
}
train_link();
#ifdef SVQC
spawnfunc(func_train)
{
- if (self.noise != "")
- precache_sound(self.noise);
+ if (this.noise != "")
+ precache_sound(this.noise);
- if (self.target == "")
+ if (this.target == "")
objerror("func_train without a target");
- if (!self.speed)
- self.speed = 100;
+ if (!this.speed)
+ this.speed = 100;
- if (!InitMovingBrushTrigger())
+ if (!InitMovingBrushTrigger(this))
return;
- self.effects |= EF_LOWPRECISION;
+ this.effects |= EF_LOWPRECISION;
- if(self.spawnflags & 4)
- self.use = train_use;
+ if(this.spawnflags & 4)
+ this.use = train_use;
- if (self.spawnflags & 2)
+ if (this.spawnflags & 2)
{
- self.platmovetype_turn = true;
- self.view_ofs = '0 0 0'; // don't offset a rotating train, origin works differently now
+ this.platmovetype_turn = true;
+ this.view_ofs = '0 0 0'; // don't offset a rotating train, origin works differently now
}
else
- self.view_ofs = self.mins;
+ this.view_ofs = this.mins;
// wait for targets to spawn
- InitializeEntity(self, func_train_find, INITPRIO_FINDTARGET);
-
- self.blocked = generic_plat_blocked;
- if(self.dmg && (self.message == ""))
- self.message = " was squished";
- if(self.dmg && (self.message2 == ""))
- self.message2 = "was squished by";
- if(self.dmg && (!self.dmgtime))
- self.dmgtime = 0.25;
- self.dmgtime2 = time;
-
- if(!set_platmovetype(self, self.platmovetype))
+ InitializeEntity(this, func_train_find, INITPRIO_FINDTARGET);
+
+ this.blocked = generic_plat_blocked;
+ if(this.dmg && (this.message == ""))
+ this.message = " was squished";
+ if(this.dmg && (this.message2 == ""))
+ this.message2 = "was squished by";
+ if(this.dmg && (!this.dmgtime))
+ this.dmgtime = 0.25;
+ this.dmgtime2 = time;
+
+ if(!set_platmovetype(this, this.platmovetype))
return;
- self.platmovetype_start_default = self.platmovetype_start;
- self.platmovetype_end_default = self.platmovetype_end;
+ this.platmovetype_start_default = this.platmovetype_start;
+ this.platmovetype_end_default = this.platmovetype_end;
// TODO make a reset function for this one
}
if(sf & SF_TRIGGER_INIT)
{
- self.platmovetype = strzone(ReadString());
- self.platmovetype_turn = ReadByte();
- self.spawnflags = ReadByte();
+ this.platmovetype = strzone(ReadString());
+ this.platmovetype_turn = ReadByte();
+ this.spawnflags = ReadByte();
- self.model = strzone(ReadString());
- _setmodel(self, self.model);
+ this.model = strzone(ReadString());
+ _setmodel(this, this.model);
- trigger_common_read(true);
+ trigger_common_read(this, true);
- self.curvetarget = strzone(ReadString());
+ this.curvetarget = strzone(ReadString());
- self.pos1_x = ReadCoord();
- self.pos1_y = ReadCoord();
- self.pos1_z = ReadCoord();
- self.pos2_x = ReadCoord();
- self.pos2_y = ReadCoord();
- self.pos2_z = ReadCoord();
+ this.pos1_x = ReadCoord();
+ this.pos1_y = ReadCoord();
+ this.pos1_z = ReadCoord();
+ this.pos2_x = ReadCoord();
+ this.pos2_y = ReadCoord();
+ this.pos2_z = ReadCoord();
- self.size_x = ReadCoord();
- self.size_y = ReadCoord();
- self.size_z = ReadCoord();
+ this.size_x = ReadCoord();
+ this.size_y = ReadCoord();
+ this.size_z = ReadCoord();
- self.view_ofs_x = ReadCoord();
- self.view_ofs_y = ReadCoord();
- self.view_ofs_z = ReadCoord();
+ this.view_ofs_x = ReadCoord();
+ this.view_ofs_y = ReadCoord();
+ this.view_ofs_z = ReadCoord();
- self.mangle_x = ReadAngle();
- self.mangle_y = ReadAngle();
- self.mangle_z = ReadAngle();
+ this.mangle_x = ReadAngle();
+ this.mangle_y = ReadAngle();
+ this.mangle_z = ReadAngle();
- self.speed = ReadShort();
- self.height = ReadShort();
- self.lip = ReadByte();
- self.state = ReadByte();
- self.wait = ReadByte();
+ this.speed = ReadShort();
+ this.height = ReadShort();
+ this.lip = ReadByte();
+ this.state = ReadByte();
+ this.wait = ReadByte();
- self.dmg = ReadShort();
- self.dmgtime = ReadByte();
+ this.dmg = ReadShort();
+ this.dmgtime = ReadByte();
- self.classname = "func_train";
- self.solid = SOLID_BSP;
- self.movetype = MOVETYPE_PUSH;
- self.drawmask = MASK_NORMAL;
- self.draw = train_draw;
- self.entremove = trigger_remove_generic;
+ this.classname = "func_train";
+ this.solid = SOLID_BSP;
+ this.movetype = MOVETYPE_PUSH;
+ this.drawmask = MASK_NORMAL;
+ this.draw = train_draw;
+ this.entremove = trigger_remove_generic;
- if(set_platmovetype(self, self.platmovetype))
+ if(set_platmovetype(this, this.platmovetype))
{
- self.platmovetype_start_default = self.platmovetype_start;
- self.platmovetype_end_default = self.platmovetype_end;
+ this.platmovetype_start_default = this.platmovetype_start;
+ this.platmovetype_end_default = this.platmovetype_end;
}
// everything is set up by the time the train is linked, we shouldn't need this
//func_train_find();
// but we will need these
- //self.move_nextthink = self.move_ltime + 0.1;
- //self.move_think = train_next;
- train_next();
-
- self.move_movetype = MOVETYPE_PUSH;
- self.move_origin = self.origin;
- self.move_angles = self.angles;
- self.move_time = time;
+ //this.move_nextthink = this.move_ltime + 0.1;
+ //this.move_think = train_next;
+ WITHSELF(this, train_next(this));
+
+ this.move_movetype = MOVETYPE_PUSH;
+ this.move_origin = this.origin;
+ this.move_angles = this.angles;
+ this.move_time = time;
}
if(sf & SF_TRIGGER_RESET)
return v;
}
-void func_vectormamamam_controller_think()
-{SELFPARAM();
+void func_vectormamamam_controller_think(entity this)
+{
self.nextthink = time + 0.1;
if(self.owner.active != ACTIVE_ACTIVE)
void func_vectormamamam_findtarget(entity this)
{
- if(self.target != "")
- self.wp00 = find(world, targetname, self.target);
+ if(this.target != "")
+ this.wp00 = find(world, targetname, this.target);
- if(self.target2 != "")
- self.wp01 = find(world, targetname, self.target2);
+ if(this.target2 != "")
+ this.wp01 = find(world, targetname, this.target2);
- if(self.target3 != "")
- self.wp02 = find(world, targetname, self.target3);
+ if(this.target3 != "")
+ this.wp02 = find(world, targetname, this.target3);
- if(self.target4 != "")
- self.wp03 = find(world, targetname, self.target4);
+ if(this.target4 != "")
+ this.wp03 = find(world, targetname, this.target4);
- if(!self.wp00 && !self.wp01 && !self.wp02 && !self.wp03)
+ if(!this.wp00 && !this.wp01 && !this.wp02 && !this.wp03)
objerror("No reference entity found, so there is nothing to move. Aborting.");
- self.destvec = self.origin - func_vectormamamam_origin(self, 0);
+ this.destvec = this.origin - func_vectormamamam_origin(this, 0);
entity controller;
controller = new(func_vectormamamam_controller);
- controller.owner = self;
+ controller.owner = this;
controller.nextthink = time + 1;
- controller.think = func_vectormamamam_controller_think;
+ setthink(controller, func_vectormamamam_controller_think);
}
spawnfunc(func_vectormamamam)
{
- if (self.noise != "")
+ if (this.noise != "")
{
- precache_sound(self.noise);
- soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
+ precache_sound(this.noise);
+ soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
}
- if(!self.targetfactor)
- self.targetfactor = 1;
+ if(!this.targetfactor)
+ this.targetfactor = 1;
- if(!self.target2factor)
- self.target2factor = 1;
+ if(!this.target2factor)
+ this.target2factor = 1;
- if(!self.target3factor)
- self.target3factor = 1;
+ if(!this.target3factor)
+ this.target3factor = 1;
- if(!self.target4factor)
- self.target4factor = 1;
+ if(!this.target4factor)
+ this.target4factor = 1;
- if(vlen(self.targetnormal))
- self.targetnormal = normalize(self.targetnormal);
+ if(vlen(this.targetnormal))
+ this.targetnormal = normalize(this.targetnormal);
- if(vlen(self.target2normal))
- self.target2normal = normalize(self.target2normal);
+ if(vlen(this.target2normal))
+ this.target2normal = normalize(this.target2normal);
- if(vlen(self.target3normal))
- self.target3normal = normalize(self.target3normal);
+ if(vlen(this.target3normal))
+ this.target3normal = normalize(this.target3normal);
- if(vlen(self.target4normal))
- self.target4normal = normalize(self.target4normal);
+ if(vlen(this.target4normal))
+ this.target4normal = normalize(this.target4normal);
- self.blocked = generic_plat_blocked;
- if(self.dmg && (self.message == ""))
- self.message = " was squished";
- if(self.dmg && (self.message == ""))
- self.message2 = "was squished by";
- if(self.dmg && (!self.dmgtime))
- self.dmgtime = 0.25;
- self.dmgtime2 = time;
+ this.blocked = generic_plat_blocked;
+ if(this.dmg && (this.message == ""))
+ this.message = " was squished";
+ if(this.dmg && (this.message == ""))
+ this.message2 = "was squished by";
+ if(this.dmg && (!this.dmgtime))
+ this.dmgtime = 0.25;
+ this.dmgtime2 = time;
- if(self.netname == "")
- self.netname = "1 0 0 0 1";
+ if(this.netname == "")
+ this.netname = "1 0 0 0 1";
- if (!InitMovingBrushTrigger())
+ if (!InitMovingBrushTrigger(this))
return;
// wait for targets to spawn
- self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
- self.SUB_THINK = SUB_NullThink; // for PushMove
+ this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
+ SUB_THINK(this, SUB_NullThink); // for PushMove
// Savage: Reduce bandwith, critical on e.g. nexdm02
- self.effects |= EF_LOWPRECISION;
+ this.effects |= EF_LOWPRECISION;
- self.active = ACTIVE_ACTIVE;
+ this.active = ACTIVE_ACTIVE;
- InitializeEntity(self, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
+ InitializeEntity(this, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
}
#endif
REGISTER_NET_LINKED(ENT_CLIENT_CORNER)
#ifdef SVQC
-bool corner_send(entity to, int sf)
-{SELFPARAM();
+bool corner_send(entity this, entity to, int sf)
+{
WriteHeader(MSG_ENTITY, ENT_CLIENT_CORNER);
- WriteString(MSG_ENTITY, self.platmovetype);
+ WriteString(MSG_ENTITY, this.platmovetype);
- WriteCoord(MSG_ENTITY, self.origin_x);
- WriteCoord(MSG_ENTITY, self.origin_y);
- WriteCoord(MSG_ENTITY, self.origin_z);
+ WriteCoord(MSG_ENTITY, this.origin_x);
+ WriteCoord(MSG_ENTITY, this.origin_y);
+ WriteCoord(MSG_ENTITY, this.origin_z);
- WriteString(MSG_ENTITY, self.target);
- WriteString(MSG_ENTITY, self.target2);
- WriteString(MSG_ENTITY, self.target3);
- WriteString(MSG_ENTITY, self.target4);
- WriteString(MSG_ENTITY, self.targetname);
- WriteByte(MSG_ENTITY, self.target_random);
+ WriteString(MSG_ENTITY, this.target);
+ WriteString(MSG_ENTITY, this.target2);
+ WriteString(MSG_ENTITY, this.target3);
+ WriteString(MSG_ENTITY, this.target4);
+ WriteString(MSG_ENTITY, this.targetname);
+ WriteByte(MSG_ENTITY, this.target_random);
- WriteByte(MSG_ENTITY, self.wait);
+ WriteByte(MSG_ENTITY, this.wait);
return true;
}
-void corner_link()
+void corner_link(entity this)
{
- //Net_LinkEntity(self, false, 0, corner_send);
+ //Net_LinkEntity(this, false, 0, corner_send);
}
spawnfunc(path_corner)
{
// setup values for overriding train movement
// if a second value does not exist, both start and end speeds are the single value specified
- set_platmovetype(self, self.platmovetype);
+ set_platmovetype(this, this.platmovetype);
- corner_link();
+ corner_link(this);
}
#elif defined(CSQC)
NET_HANDLE(ENT_CLIENT_CORNER, bool isnew)
{
- self.platmovetype = strzone(ReadString());
+ this.platmovetype = strzone(ReadString());
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- setorigin(self, self.origin);
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+ setorigin(this, this.origin);
- self.target = strzone(ReadString());
- self.target2 = strzone(ReadString());
- self.target3 = strzone(ReadString());
- self.target4 = strzone(ReadString());
- self.targetname = strzone(ReadString());
- self.target_random = ReadByte();
+ this.target = strzone(ReadString());
+ this.target2 = strzone(ReadString());
+ this.target3 = strzone(ReadString());
+ this.target4 = strzone(ReadString());
+ this.targetname = strzone(ReadString());
+ this.target_random = ReadByte();
- self.wait = ReadByte();
+ this.wait = ReadByte();
return = true;
- self.classname = "path_corner";
- self.drawmask = MASK_NORMAL;
- self.entremove = corner_remove;
+ this.classname = "path_corner";
+ this.drawmask = MASK_NORMAL;
+ this.entremove = corner_remove;
- set_platmovetype(self, self.platmovetype);
+ set_platmovetype(this, this.platmovetype);
}
#endif
entity src, dst;
src = world;
dst = world;
- if(self.killtarget != "")
- src = find(world, targetname, self.killtarget);
- if(self.target != "")
- dst = find(world, targetname, self.target);
+ if(this.killtarget != "")
+ src = find(world, targetname, this.killtarget);
+ if(this.target != "")
+ dst = find(world, targetname, this.target);
if(!src && !dst)
{
return;
}
- if(self.jointtype)
+ if(this.jointtype)
{
// already done :P entity must stay
- self.aiment = src;
- self.enemy = dst;
+ this.aiment = src;
+ this.enemy = dst;
}
else if(!src || !dst)
{
objerror("follow: could not find target/killtarget");
return;
}
- else if(self.spawnflags & 1)
+ else if(this.spawnflags & 1)
{
// attach
- if(self.spawnflags & 2)
+ if(this.spawnflags & 2)
{
- setattachment(dst, src, self.message);
+ setattachment(dst, src, this.message);
}
else
{
- attach_sameorigin(dst, src, self.message);
+ attach_sameorigin(dst, src, this.message);
}
dst.solid = SOLID_NOT; // solid doesn't work with attachment
- remove(self);
+ remove(this);
}
else
{
- if(self.spawnflags & 2)
+ if(this.spawnflags & 2)
{
dst.movetype = MOVETYPE_FOLLOW;
dst.aiment = src;
follow_sameorigin(dst, src);
}
- remove(self);
+ remove(this);
}
}
spawnfunc(misc_follow)
{
- InitializeEntity(self, follow_init, INITPRIO_FINDTARGET);
+ InitializeEntity(this, follow_init, INITPRIO_FINDTARGET);
}
#endif
}
.entity pusher;
-void misc_laser_think()
-{SELFPARAM();
+void misc_laser_think(entity this)
+{
vector o;
entity hitent;
vector hitloc;
if(!this.scale) this.scale = 1;
if(!this.modelscale) this.modelscale = 1;
else if(this.modelscale < 0) this.modelscale = 0;
- this.think = misc_laser_think;
+ setthink(this, misc_laser_think);
this.nextthink = time;
InitializeEntity(this, misc_laser_init, INITPRIO_FINDTARGET);
NET_HANDLE(ENT_CLIENT_LASER, bool isnew)
{
- InterpolateOrigin_Undo(self);
+ InterpolateOrigin_Undo(this);
// 30 bytes, or 13 bytes for just moving
int f = ReadByte();
- self.count = (f & 0xF0);
+ this.count = (f & 0xF0);
- if(self.count & 0x80)
- self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
+ if(this.count & 0x80)
+ this.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
else
- self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
+ this.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
if(f & 1)
{
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- setorigin(self, self.origin);
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+ setorigin(this, this.origin);
}
if(f & 8)
{
- self.colormod_x = ReadByte() / 255.0;
- self.colormod_y = ReadByte() / 255.0;
- self.colormod_z = ReadByte() / 255.0;
+ this.colormod_x = ReadByte() / 255.0;
+ this.colormod_y = ReadByte() / 255.0;
+ this.colormod_z = ReadByte() / 255.0;
if(f & 0x40)
- self.alpha = ReadByte() / 255.0;
+ this.alpha = ReadByte() / 255.0;
else
- self.alpha = 0;
- self.scale = 2;
- self.modelscale = 50;
+ this.alpha = 0;
+ this.scale = 2;
+ this.modelscale = 50;
if(f & 0x20)
{
- self.scale *= ReadByte() / 16.0; // beam radius
- self.modelscale *= ReadByte() / 16.0; // dlight radius
+ this.scale *= ReadByte() / 16.0; // beam radius
+ this.modelscale *= ReadByte() / 16.0; // dlight radius
}
if((f & 0x80) || !(f & 0x10))
- self.cnt = ReadShort() - 1; // effect number
+ this.cnt = ReadShort() - 1; // effect number
else
- self.cnt = 0;
+ this.cnt = 0;
}
if(f & 2)
{
if(f & 0x80)
{
- self.velocity_x = ReadCoord();
- self.velocity_y = ReadCoord();
- self.velocity_z = ReadCoord();
+ this.velocity_x = ReadCoord();
+ this.velocity_y = ReadCoord();
+ this.velocity_z = ReadCoord();
}
else
{
- self.angles_x = ReadAngle();
- self.angles_y = ReadAngle();
+ this.angles_x = ReadAngle();
+ this.angles_y = ReadAngle();
}
}
if(f & 4)
- self.state = ReadByte();
+ this.state = ReadByte();
return = true;
InterpolateOrigin_Note(this);
- self.draw = Draw_Laser;
+ this.draw = Draw_Laser;
}
#endif
return true;
}
-void teleport_dest_link()
-{SELFPARAM();
- Net_LinkEntity(self, false, 0, teleport_dest_send);
- self.SendFlags |= 1; // update
+void teleport_dest_link(entity this)
+{
+ Net_LinkEntity(this, false, 0, teleport_dest_send);
+ this.SendFlags |= 1; // update
}
spawnfunc(info_teleport_destination)
{
- self.classname = "info_teleport_destination";
+ this.classname = "info_teleport_destination";
- self.mangle = self.angles;
- self.angles = '0 0 0';
+ this.mangle = this.angles;
+ this.angles = '0 0 0';
- //setorigin (self, self.origin + '0 0 27'); // To fix a mappers' habit as old as Quake
- setorigin (self, self.origin);
+ //setorigin (this, this.origin + '0 0 27'); // To fix a mappers' habit as old as Quake
+ setorigin (this, this.origin);
IFTARGETED
{
else
objerror ("^3Teleport destination without a targetname");
- teleport_dest_link();
+ teleport_dest_link(this);
}
spawnfunc(misc_teleporter_dest)
void teleport_dest_remove(entity this)
{
- //if(self.classname)
- //strunzone(self.classname);
- //self.classname = string_null;
+ //if(this.classname)
+ //strunzone(this.classname);
+ //this.classname = string_null;
if(this.targetname)
strunzone(this.targetname);
if(sf & 1)
{
- self.classname = "info_teleport_destination";
- self.cnt = ReadByte();
- self.speed = ReadCoord();
- self.targetname = strzone(ReadString());
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
-
- self.mangle_x = ReadAngle();
- self.mangle_y = ReadAngle();
- self.mangle_z = ReadAngle();
-
- setorigin(self, self.origin);
-
- self.drawmask = MASK_NORMAL;
- self.entremove = teleport_dest_remove;
+ this.classname = "info_teleport_destination";
+ this.cnt = ReadByte();
+ this.speed = ReadCoord();
+ this.targetname = strzone(ReadString());
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+
+ this.mangle_x = ReadAngle();
+ this.mangle_y = ReadAngle();
+ this.mangle_z = ReadAngle();
+
+ setorigin(this, this.origin);
+
+ this.drawmask = MASK_NORMAL;
+ this.entremove = teleport_dest_remove;
}
return = true;
vector tmin, tmax;
trigger = spawn();
- trigger.touch = plat_center_touch;
+ settouch(trigger, plat_center_touch);
trigger.movetype = MOVETYPE_NONE;
trigger.solid = SOLID_TRIGGER;
trigger.enemy = self;
-#ifdef CSQC
- trigger.drawmask = MASK_NORMAL;
- trigger.trigger_touch = plat_center_touch;
- trigger.draw = trigger_draw_generic;
-#endif
-
tmin = self.absmin + '25 25 0';
tmax = self.absmax - '25 25 -8';
tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8);
objerror("plat_spawn_inside_trigger: platform has odd size or lip, can't spawn");
}
-void plat_hit_top()
-{SELFPARAM();
+void plat_hit_top(entity this)
+{
_sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
self.state = 1;
- self.SUB_THINK = plat_go_down;
+ SUB_THINK(self, plat_go_down);
self.SUB_NEXTTHINK = self.SUB_LTIME + 3;
}
-void plat_hit_bottom()
-{SELFPARAM();
+void plat_hit_bottom(entity this)
+{
_sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
self.state = 2;
}
-void plat_go_down()
-{SELFPARAM();
+void plat_go_down(entity this)
+{
_sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
self.state = 3;
SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, plat_hit_bottom);
SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, plat_hit_top);
}
-void plat_center_touch()
-{SELFPARAM();
+void plat_center_touch(entity this)
+{
#ifdef SVQC
if (!other.iscreature)
return;
return;
#endif
- setself(self.enemy);
- if (self.state == 2)
- plat_go_up ();
- else if (self.state == 1)
- self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
+ if (self.enemy.state == 2)
+ WITHSELF(self.enemy, plat_go_up());
+ else if (self.enemy.state == 1)
+ self.enemy.SUB_NEXTTHINK = self.enemy.SUB_LTIME + 1;
}
-void plat_outside_touch()
-{SELFPARAM();
+void plat_outside_touch(entity this)
+{
#ifdef SVQC
if (!other.iscreature)
return;
return;
#endif
- setself(self.enemy);
- if (self.state == 1)
- plat_go_down ();
+ if (self.enemy.state == 1) {
+ entity e = self.enemy;
+ WITHSELF(e, plat_go_down(e));
+ }
}
void plat_trigger_use(entity this, entity actor, entity trigger)
{
#ifdef SVQC
- if (this.think)
+ if (getthink(this))
return; // already activated
#elif defined(CSQC)
if(this.move_think)
return;
#endif
- WITHSELF(this, plat_go_down());
+ WITHSELF(this, plat_go_down(this));
}
#endif
if (self.state == 4)
- plat_go_down ();
+ plat_go_down (self);
else if (self.state == 3)
plat_go_up ();
// when in other states, then the plat_crush event came delayed after
this.use = func_null;
if (this.state != 4)
objerror ("plat_use: not in up state");
- WITHSELF(this, plat_go_down());
+ WITHSELF(this, plat_go_down(this));
}
.string sound1, sound2;
.float dmgtime2;
-void() plat_center_touch;
-void() plat_outside_touch;
+void plat_center_touch(entity this);
+void plat_outside_touch(entity this);
void plat_trigger_use(entity this, entity actor, entity trigger);
void() plat_go_up;
-void() plat_go_down;
+void plat_go_down(entity this);
void() plat_crush;
const float PLAT_LOW_TRIGGER = 1;
-void SUB_NullThink() { }
+void SUB_NullThink(entity this) { }
-void() SUB_CalcMoveDone;
-void() SUB_CalcAngleMoveDone;
+void SUB_CalcMoveDone(entity this);
+void SUB_CalcAngleMoveDone(entity this);
/*
==================
}
}
-void SUB_SetFade_Think ()
-{SELFPARAM();
+void SUB_SetFade_Think (entity this)
+{
if(this.alpha == 0)
this.alpha = 1;
- this.SUB_THINK = SUB_SetFade_Think;
+ SUB_THINK(this, SUB_SetFade_Think);
this.SUB_NEXTTHINK = time;
this.alpha -= frametime * this.fade_rate;
if (this.alpha < 0.01)
void SUB_SetFade (entity ent, float when, float fading_time)
{
ent.fade_rate = 1/fading_time;
- ent.SUB_THINK = SUB_SetFade_Think;
+ SUB_THINK(ent, SUB_SetFade_Think);
ent.SUB_NEXTTHINK = when;
}
self.SUB_ORIGIN traveling at speed
===============
*/
-void SUB_CalcMoveDone ()
-{SELFPARAM();
+void SUB_CalcMoveDone(entity this)
+{
// After moving, set origin to exact final destination
SUB_SETORIGIN (self, self.finaldest);
self.SUB_VELOCITY = '0 0 0';
self.SUB_NEXTTHINK = -1;
if (self.think1)
- self.think1 ();
+ self.think1 (self);
}
.float platmovetype_turn;
-void SUB_CalcMove_controller_think ()
-{SELFPARAM();
- entity oldself;
+void SUB_CalcMove_controller_think (entity this)
+{
float traveltime;
float phasepos;
float nexttick;
else
{
// derivative: delta + 2 * delta2 (e.g. for angle positioning)
- oldself = self;
- self.owner.SUB_THINK = self.think1;
- setself(self.owner);
- remove(oldself);
- self.SUB_THINK();
+ entity own = self.owner;
+ SUB_THINK(own, self.think1);
+ remove(self);
+ WITHSELF(own, SUB_THUNK(own)(own));
}
}
float TSPEED_END = 2;
// TODO average too?
-void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void() func)
+void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
{SELFPARAM();
float traveltime;
entity controller;
self.think1 = func;
self.finaldest = tdest;
- self.SUB_THINK = SUB_CalcMoveDone;
+ SUB_THINK(self, SUB_CalcMoveDone);
switch(tspeedtype)
{
controller.finaldest = (tdest + '0 0 0.125'); // where do we want to end? Offset to overshoot a bit.
controller.animstate_starttime = time;
controller.animstate_endtime = time + traveltime;
- controller.think = SUB_CalcMove_controller_think;
- controller.think1 = self.SUB_THINK;
+ setthink(controller, SUB_CalcMove_controller_think);
+ controller.think1 = SUB_THUNK(self);
// the thinking is now done by the controller
- self.SUB_THINK = SUB_NullThink; // for PushMove
+ SUB_THINK(self, SUB_NullThink); // for PushMove
self.SUB_NEXTTHINK = self.SUB_LTIME + traveltime;
// invoke controller
- setself(controller);
- self.think();
- setself(self.owner);
+ WITHSELF(controller, getthink(controller)(controller));
}
-void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func)
+void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void(entity this) func)
{SELFPARAM();
vector delta;
float traveltime;
self.think1 = func;
self.finaldest = tdest;
- self.SUB_THINK = SUB_CalcMoveDone;
+ SUB_THINK(self, SUB_CalcMoveDone);
if (tdest == self.SUB_ORIGIN)
{
SUB_CalcMove_Bezier((self.SUB_ORIGIN + tdest) * 0.5, tdest, tspeedtype, tspeed, func);
}
-void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void() func)
-{SELFPARAM();
+void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
+{
WITHSELF(ent, SUB_CalcMove(tdest, tspeedtype, tspeed, func));
}
The calling function should make sure self.SUB_THINK is valid
===============
*/
-void SUB_CalcAngleMoveDone ()
-{SELFPARAM();
+void SUB_CalcAngleMoveDone(entity this)
+{
// After rotating, set angle to exact final angle
self.angles = self.finalangle;
self.SUB_AVELOCITY = '0 0 0';
self.SUB_NEXTTHINK = -1;
if (self.think1)
- self.think1 ();
+ self.think1 (self);
}
// FIXME: I fixed this function only for rotation around the main axes
-void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void() func)
+void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void(entity this) func)
{SELFPARAM();
vector delta;
float traveltime;
self.think1 = func;
self.finalangle = destangle;
- self.SUB_THINK = SUB_CalcAngleMoveDone;
+ SUB_THINK(self, SUB_CalcAngleMoveDone);
if (traveltime < 0.1)
{
self.SUB_NEXTTHINK = self.SUB_LTIME + traveltime;
}
-void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void() func)
-{SELFPARAM();
+void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void(entity this) func)
+{
WITHSELF(ent, SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func));
}
#define SUB_ORIGIN origin
#define SUB_SETORIGIN(s,v) setorigin((s), (v))
#define SUB_NEXTTHINK nextthink
- #define SUB_THINK think
+ #define SUB_THINK(e, f) setthink(e, f)
+ #define SUB_THUNK(e) getthink(e)
#define SUB_LTIME ltime
#define SUB_FLAGS flags
#define SUB_AVELOCITY move_avelocity
#define SUB_ORIGIN move_origin
#define SUB_NEXTTHINK move_nextthink
- #define SUB_THINK move_think
+ #define SUB_THINK(e, f) ((e).move_think = (f))
+ #define SUB_THUNK(e) ((e).move_think)
#define SUB_LTIME move_ltime
#define SUB_FLAGS move_flags
void SUB_VanishOrRemove (entity ent);
.vector finaldest, finalangle; //plat.qc stuff
-.void() think1;
+.void(entity this) think1;
.float state;
.float t_length, t_width;
spawnfunc(target_location)
{
- self.classname = "target_location";
+ this.classname = "target_location";
// location name in netname
// eventually support: count, teamgame selectors, line of sight?
// fade_rate
// when triggered, the music is overridden for activator until lifetime (or forever, if lifetime is 0)
// when targetname is not set, THIS ONE is default
-void target_music_sendto(float to, float is)
-{SELFPARAM();
+void target_music_sendto(entity this, int to, bool is)
+{
WriteHeader(to, TE_CSQC_TARGET_MUSIC);
- WriteShort(to, etof(self));
- WriteByte(to, self.volume * 255.0 * is);
- WriteByte(to, self.fade_time * 16.0);
- WriteByte(to, self.fade_rate * 16.0);
- WriteByte(to, self.lifetime);
- WriteString(to, self.noise);
+ WriteShort(to, etof(this));
+ WriteByte(to, this.volume * 255.0 * is);
+ WriteByte(to, this.fade_time * 16.0);
+ WriteByte(to, this.fade_rate * 16.0);
+ WriteByte(to, this.lifetime);
+ WriteString(to, this.noise);
}
void target_music_reset(entity this)
{
- if (this.targetname == "") target_music_sendto(MSG_ALL, 1);
+ if (this.targetname == "") target_music_sendto(this, MSG_ALL, 1);
}
void target_music_kill()
{
FOREACH_ENTITY_CLASS("target_music", true, {
it.volume = 0;
if (it.targetname == "")
- WITHSELF(it, target_music_sendto(MSG_ALL, 1));
+ WITHSELF(it, target_music_sendto(it, MSG_ALL, 1));
else
- WITHSELF(it, target_music_sendto(MSG_ALL, 0));
+ WITHSELF(it, target_music_sendto(it, MSG_ALL, 0));
});
}
void target_music_use(entity this, entity actor, entity trigger)
if(IS_REAL_CLIENT(actor))
{
msg_entity = actor;
- target_music_sendto(MSG_ONE, 1);
+ target_music_sendto(this, MSG_ONE, 1);
}
FOREACH_CLIENT(IS_SPEC(it) && it.enemy == actor, {
msg_entity = it;
- target_music_sendto(MSG_ONE, 1);
+ target_music_sendto(this, MSG_ONE, 1);
});
}
spawnfunc(target_music)
{
- self.use = target_music_use;
- self.reset = target_music_reset;
- if(!self.volume)
- self.volume = 1;
- if(self.targetname == "")
- target_music_sendto(MSG_INIT, 1);
+ this.use = target_music_use;
+ this.reset = target_music_reset;
+ if(!this.volume)
+ this.volume = 1;
+ if(this.targetname == "")
+ target_music_sendto(this, MSG_INIT, 1);
else
- target_music_sendto(MSG_INIT, 0);
+ target_music_sendto(this, MSG_INIT, 0);
}
void TargetMusic_RestoreGame()
-{SELFPARAM();
+{
for(entity e = world; (e = find(e, classname, "target_music")); )
{
- setself(e);
- if(self.targetname == "")
- target_music_sendto(MSG_INIT, 1);
+ if(e.targetname == "")
+ target_music_sendto(e, MSG_INIT, 1);
else
- target_music_sendto(MSG_INIT, 0);
+ target_music_sendto(e, MSG_INIT, 0);
}
}
// values:
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_MUSIC);
sf &= ~0x80;
- if(self.cnt)
+ if(this.cnt)
sf |= 0x80;
WriteByte(MSG_ENTITY, sf);
if(sf & 4)
{
- WriteCoord(MSG_ENTITY, self.origin.x);
- WriteCoord(MSG_ENTITY, self.origin.y);
- WriteCoord(MSG_ENTITY, self.origin.z);
+ WriteCoord(MSG_ENTITY, this.origin.x);
+ WriteCoord(MSG_ENTITY, this.origin.y);
+ WriteCoord(MSG_ENTITY, this.origin.z);
}
if(sf & 1)
{
- if(self.model != "null")
+ if(this.model != "null")
{
- WriteShort(MSG_ENTITY, self.modelindex);
- WriteCoord(MSG_ENTITY, self.mins.x);
- WriteCoord(MSG_ENTITY, self.mins.y);
- WriteCoord(MSG_ENTITY, self.mins.z);
- WriteCoord(MSG_ENTITY, self.maxs.x);
- WriteCoord(MSG_ENTITY, self.maxs.y);
- WriteCoord(MSG_ENTITY, self.maxs.z);
+ WriteShort(MSG_ENTITY, this.modelindex);
+ WriteCoord(MSG_ENTITY, this.mins.x);
+ WriteCoord(MSG_ENTITY, this.mins.y);
+ WriteCoord(MSG_ENTITY, this.mins.z);
+ WriteCoord(MSG_ENTITY, this.maxs.x);
+ WriteCoord(MSG_ENTITY, this.maxs.y);
+ WriteCoord(MSG_ENTITY, this.maxs.z);
}
else
{
WriteShort(MSG_ENTITY, 0);
- WriteCoord(MSG_ENTITY, self.maxs.x);
- WriteCoord(MSG_ENTITY, self.maxs.y);
- WriteCoord(MSG_ENTITY, self.maxs.z);
+ WriteCoord(MSG_ENTITY, this.maxs.x);
+ WriteCoord(MSG_ENTITY, this.maxs.y);
+ WriteCoord(MSG_ENTITY, this.maxs.z);
}
- WriteByte(MSG_ENTITY, self.volume * 255.0);
- WriteByte(MSG_ENTITY, self.fade_time * 16.0);
- WriteByte(MSG_ENTITY, self.fade_rate * 16.0);
- WriteString(MSG_ENTITY, self.noise);
+ WriteByte(MSG_ENTITY, this.volume * 255.0);
+ WriteByte(MSG_ENTITY, this.fade_time * 16.0);
+ WriteByte(MSG_ENTITY, this.fade_rate * 16.0);
+ WriteString(MSG_ENTITY, this.noise);
}
return 1;
}
}
}
-void Ent_TriggerMusic_Think()
-{SELFPARAM();
+void Ent_TriggerMusic_Think(entity this)
+{
if(WarpZoneLib_BoxTouchesBrush(view_origin, view_origin, self, world))
{
music_trigger = self;
int f = ReadByte();
if(f & 4)
{
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
}
if(f & 1)
{
- self.modelindex = ReadShort();
- if(self.modelindex)
+ this.modelindex = ReadShort();
+ if(this.modelindex)
{
- self.mins_x = ReadCoord();
- self.mins_y = ReadCoord();
- self.mins_z = ReadCoord();
- self.maxs_x = ReadCoord();
- self.maxs_y = ReadCoord();
- self.maxs_z = ReadCoord();
+ this.mins_x = ReadCoord();
+ this.mins_y = ReadCoord();
+ this.mins_z = ReadCoord();
+ this.maxs_x = ReadCoord();
+ this.maxs_y = ReadCoord();
+ this.maxs_z = ReadCoord();
}
else
{
- self.mins = '0 0 0';
- self.maxs_x = ReadCoord();
- self.maxs_y = ReadCoord();
- self.maxs_z = ReadCoord();
+ this.mins = '0 0 0';
+ this.maxs_x = ReadCoord();
+ this.maxs_y = ReadCoord();
+ this.maxs_z = ReadCoord();
}
- self.volume = ReadByte() / 255.0;
- self.fade_time = ReadByte() / 16.0;
- self.fade_rate = ReadByte() / 16.0;
- string s = self.noise;
- if(self.noise)
- strunzone(self.noise);
- self.noise = strzone(ReadString());
- if(self.noise != s)
+ this.volume = ReadByte() / 255.0;
+ this.fade_time = ReadByte() / 16.0;
+ this.fade_rate = ReadByte() / 16.0;
+ string s = this.noise;
+ if(this.noise)
+ strunzone(this.noise);
+ this.noise = strzone(ReadString());
+ if(this.noise != s)
{
- precache_sound(self.noise);
- _sound(self, CH_BGM_SINGLE, self.noise, 0, ATTEN_NONE);
- if(getsoundtime(self, CH_BGM_SINGLE) < 0)
+ precache_sound(this.noise);
+ _sound(this, CH_BGM_SINGLE, this.noise, 0, ATTEN_NONE);
+ if(getsoundtime(this, CH_BGM_SINGLE) < 0)
{
- LOG_TRACEF("Cannot initialize sound %s\n", self.noise);
- strunzone(self.noise);
- self.noise = string_null;
+ LOG_TRACEF("Cannot initialize sound %s\n", this.noise);
+ strunzone(this.noise);
+ this.noise = string_null;
}
}
}
- setorigin(self, self.origin);
- setsize(self, self.mins, self.maxs);
- self.cnt = 1;
- self.think = Ent_TriggerMusic_Think;
- self.nextthink = time;
+ setorigin(this, this.origin);
+ setsize(this, this.mins, this.maxs);
+ this.cnt = 1;
+ setthink(this, Ent_TriggerMusic_Think);
+ this.nextthink = time;
return true;
}
void Net_TargetMusic();
-void Ent_TriggerMusic_Think();
+void Ent_TriggerMusic_Think(entity this);
void Ent_TriggerMusic_Remove();
spawnfunc(target_spawn)
{
initialize_field_db();
- self.use = target_spawn_use;
- self.message = strzone(strreplace("'", "\"", self.message));
- self.target_spawn_id = ++target_spawn_count;
- InitializeEntity(self, target_spawn_spawnfirst, INITPRIO_LAST);
+ this.use = target_spawn_use;
+ this.message = strzone(strreplace("'", "\"", this.message));
+ this.target_spawn_id = ++target_spawn_count;
+ InitializeEntity(this, target_spawn_spawnfirst, INITPRIO_LAST);
}
#endif
{
// TODO: "*" prefix to sound file name
// TODO: wait and random (just, HOW? random is not a field)
- if(self.noise)
- precache_sound (self.noise);
+ if(this.noise)
+ precache_sound (this.noise);
- if(!self.atten && !(self.spawnflags & 4))
+ if(!this.atten && !(this.spawnflags & 4))
{
IFTARGETED
- self.atten = ATTEN_NORM;
+ this.atten = ATTEN_NORM;
else
- self.atten = ATTEN_STATIC;
+ this.atten = ATTEN_STATIC;
}
- else if(self.atten < 0)
- self.atten = 0;
+ else if(this.atten < 0)
+ this.atten = 0;
- if(!self.volume)
- self.volume = 1;
+ if(!this.volume)
+ this.volume = 1;
IFTARGETED
{
- if(self.spawnflags & 8) // ACTIVATOR
- self.use = target_speaker_use_activator;
- else if(self.spawnflags & 1) // LOOPED_ON
+ if(this.spawnflags & 8) // ACTIVATOR
+ this.use = target_speaker_use_activator;
+ else if(this.spawnflags & 1) // LOOPED_ON
{
- target_speaker_use_on(self, NULL, NULL);
- self.reset = target_speaker_reset;
+ target_speaker_use_on(this, NULL, NULL);
+ this.reset = target_speaker_reset;
}
- else if(self.spawnflags & 2) // LOOPED_OFF
+ else if(this.spawnflags & 2) // LOOPED_OFF
{
- self.use = target_speaker_use_on;
- self.reset = target_speaker_reset;
+ this.use = target_speaker_use_on;
+ this.reset = target_speaker_reset;
}
else
- self.use = target_speaker_use_on;
+ this.use = target_speaker_use_on;
}
- else if(self.spawnflags & 1) // LOOPED_ON
+ else if(this.spawnflags & 1) // LOOPED_ON
{
- ambientsound (self.origin, self.noise, VOL_BASE * self.volume, self.atten);
- remove(self);
+ ambientsound (this.origin, this.noise, VOL_BASE * this.volume, this.atten);
+ remove(this);
}
- else if(self.spawnflags & 2) // LOOPED_OFF
+ else if(this.spawnflags & 2) // LOOPED_OFF
{
objerror("This sound entity can never be activated");
}
else
{
// Quake/Nexuiz fallback
- ambientsound (self.origin, self.noise, VOL_BASE * self.volume, self.atten);
- remove(self);
+ ambientsound (this.origin, this.noise, VOL_BASE * this.volume, this.atten);
+ remove(this);
}
}
#endif
// delay: initial delay before the first message
float i, n;
- self.use = target_voicescript_use;
+ this.use = target_voicescript_use;
- n = tokenize_console(self.message);
- self.cnt = n / 2;
+ n = tokenize_console(this.message);
+ this.cnt = n / 2;
for(i = 0; i+1 < n; i += 2)
{
if(argv(i) == "*")
{
- self.cnt = i / 2;
+ this.cnt = i / 2;
++i;
}
- precache_sound(strcat(self.netname, "/", argv(i), ".wav"));
+ precache_sound(strcat(this.netname, "/", argv(i), ".wav"));
}
}
#endif
{
int n = 0;
entity e;
- for(e = world; (e = find(e, targetname, self.target)); )
+ for(e = world; (e = find(e, targetname, this.target)); )
{
++n;
#ifdef SVQC
if(e.movetype == MOVETYPE_NONE)
- waypoint_spawnforteleporter(self, e.origin, 0);
+ waypoint_spawnforteleporter(this, e.origin, 0);
if(e.classname != "info_teleport_destination")
LOG_INFO("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work.\n");
#endif
else if(n == 1)
{
// exactly one dest - bots love that
- self.enemy = find(e, targetname, self.target);
+ this.enemy = find(e, targetname, this.target);
}
else
{
// have to use random selection every single time
- self.enemy = world;
+ this.enemy = world;
}
// now enable touch
+ settouch(this, Teleport_Touch);
#ifdef SVQC
- self.touch = Teleport_Touch;
-
- trigger_teleport_link(self);
-#elif defined(CSQC)
- self.move_touch = Teleport_Touch;
+ trigger_teleport_link(this);
#endif
}
entity Simple_TeleportPlayer(entity teleporter, entity player);
-void Teleport_Touch ();
+void Teleport_Touch (entity this);
void teleport_findtarget(entity this);
Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COMPLETED);
this.enemy = actor;
- WITHSELF(this, multi_trigger ());
+ multi_trigger(this);
}
else
{
*/
spawnfunc(trigger_counter)
{
- self.wait = -1;
- if (!self.count)
- self.count = 2;
- self.cnt = self.count;
+ this.wait = -1;
+ if (!this.count)
+ this.count = 2;
+ this.cnt = this.count;
- self.use = counter_use;
- self.reset = counter_reset;
+ this.use = counter_use;
+ this.reset = counter_reset;
}
#endif
#ifdef SVQC
void delay_use(entity this, entity actor, entity trigger)
{
- this.think = SUB_UseTargets_self;
+ setthink(this, SUB_UseTargets_self);
this.nextthink = this.wait;
}
void delay_reset(entity this)
{
- this.think = func_null;
+ setthink(this, func_null);
this.nextthink = 0;
}
spawnfunc(trigger_delay)
{
- if(!self.wait)
- self.wait = 1;
+ if(!this.wait)
+ this.wait = 1;
- self.use = delay_use;
- self.reset = delay_reset;
+ this.use = delay_use;
+ this.reset = delay_reset;
}
#endif
if(this.wait)
{
- this.think = adaptor_think2use;
+ setthink(this, adaptor_think2use);
this.nextthink = game_starttime + this.wait;
}
else
backtrace("Removing a trigger_gravity_check with no valid owner");
own.trigger_gravity_check = world;
}
-void trigger_gravity_check_think()
-{SELFPARAM();
+void trigger_gravity_check_think(entity this)
+{
// This spawns when a player enters the gravity zone and checks if he left.
// Each frame, self.count is set to 2 by trigger_gravity_touch() and decreased by 1 here.
// It the player has left the gravity trigger, this will be allowed to reach 0 and indicate that.
this.state = !this.state;
}
-void trigger_gravity_touch()
-{SELFPARAM();
+void trigger_gravity_touch(entity this)
+{
float g;
if(self.state != true)
other.trigger_gravity_check.enemy = self;
other.trigger_gravity_check.owner = other;
other.trigger_gravity_check.gravity = other.gravity;
- other.trigger_gravity_check.think = trigger_gravity_check_think;
+ setthink(other.trigger_gravity_check, trigger_gravity_check_think);
other.trigger_gravity_check.nextthink = time;
other.trigger_gravity_check.count = 2;
if(other.gravity)
spawnfunc(trigger_gravity)
{
- if(self.gravity == 1)
+ if(this.gravity == 1)
return;
EXACTTRIGGER_INIT;
- self.touch = trigger_gravity_touch;
- if(self.noise != "")
- precache_sound(self.noise);
+ settouch(this, trigger_gravity_touch);
+ if(this.noise != "")
+ precache_sound(this.noise);
- self.state = true;
+ this.state = true;
IFTARGETED
{
- self.use = trigger_gravity_use;
- if(self.spawnflags & 2)
- self.state = false;
+ this.use = trigger_gravity_use;
+ if(this.spawnflags & 2)
+ this.state = false;
}
}
#endif
#ifdef SVQC
.float triggerhealtime;
-void trigger_heal_touch()
-{SELFPARAM();
+void trigger_heal_touch(entity this)
+{
if (self.active != ACTIVE_ACTIVE)
return;
spawnfunc(trigger_heal)
{
- self.active = ACTIVE_ACTIVE;
+ this.active = ACTIVE_ACTIVE;
EXACTTRIGGER_INIT;
- self.touch = trigger_heal_touch;
- if (!self.health)
- self.health = 10;
- if (!self.max_health)
- self.max_health = 200; //Max health topoff for field
- if(self.noise == "")
- self.noise = "misc/mediumhealth.wav";
- precache_sound(self.noise);
+ settouch(this, trigger_heal_touch);
+ if (!this.health)
+ this.health = 10;
+ if (!this.max_health)
+ this.max_health = 200; //Max health topoff for field
+ if(this.noise == "")
+ this.noise = "misc/mediumhealth.wav";
+ precache_sound(this.noise);
}
#endif
}
.float triggerhurttime;
-void trigger_hurt_touch()
-{SELFPARAM();
+void trigger_hurt_touch(entity this)
+{
if (self.active != ACTIVE_ACTIVE)
return;
spawnfunc(trigger_hurt)
{
EXACTTRIGGER_INIT;
- self.active = ACTIVE_ACTIVE;
- self.touch = trigger_hurt_touch;
- self.use = trigger_hurt_use;
- self.enemy = world; // I hate you all
- if (!self.dmg)
- self.dmg = 1000;
- if (self.message == "")
- self.message = "was in the wrong place";
- if (self.message2 == "")
- self.message2 = "was thrown into a world of hurt by";
- // self.message = "someone like %s always gets wrongplaced";
+ this.active = ACTIVE_ACTIVE;
+ settouch(this, trigger_hurt_touch);
+ this.use = trigger_hurt_use;
+ this.enemy = world; // I hate you all
+ if (!this.dmg)
+ this.dmg = 1000;
+ if (this.message == "")
+ this.message = "was in the wrong place";
+ if (this.message2 == "")
+ this.message2 = "was thrown into a world of hurt by";
+ // this.message = "someone like %s always gets wrongplaced";
if(!trigger_hurt_first)
- trigger_hurt_first = self;
+ trigger_hurt_first = this;
if(trigger_hurt_last)
- trigger_hurt_last.trigger_hurt_next = self;
- trigger_hurt_last = self;
+ trigger_hurt_last.trigger_hurt_next = this;
+ trigger_hurt_last = this;
}
float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end)
// targeted (directional) mode
-void trigger_impulse_touch1()
-{SELFPARAM();
+void trigger_impulse_touch1(entity this)
+{
entity targ;
float pushdeltatime;
float str;
}
// Directionless (accelerator/decelerator) mode
-void trigger_impulse_touch2()
-{SELFPARAM();
+void trigger_impulse_touch2(entity this)
+{
float pushdeltatime;
if (self.active != ACTIVE_ACTIVE)
}
// Spherical (gravity/repulsor) mode
-void trigger_impulse_touch3()
-{SELFPARAM();
+void trigger_impulse_touch3(entity this)
+{
float pushdeltatime;
float str;
return true;
}
-void trigger_impulse_link()
+void trigger_impulse_link(entity this)
{
- SELFPARAM();
- trigger_link(self, trigger_impulse_send);
+ trigger_link(this, trigger_impulse_send);
}
spawnfunc(trigger_impulse)
{
- self.active = ACTIVE_ACTIVE;
+ this.active = ACTIVE_ACTIVE;
- trigger_init(self);
+ trigger_init(this);
- if(self.radius)
+ if(this.radius)
{
- if(!self.strength) self.strength = 2000 * autocvar_g_triggerimpulse_radial_multiplier;
- setorigin(self, self.origin);
- setsize(self, '-1 -1 -1' * self.radius,'1 1 1' * self.radius);
- self.touch = trigger_impulse_touch3;
+ if(!this.strength) this.strength = 2000 * autocvar_g_triggerimpulse_radial_multiplier;
+ setorigin(this, this.origin);
+ setsize(this, '-1 -1 -1' * this.radius,'1 1 1' * this.radius);
+ settouch(this, trigger_impulse_touch3);
}
else
{
- if(self.target)
+ if(this.target)
{
- if(!self.strength) self.strength = 950 * autocvar_g_triggerimpulse_directional_multiplier;
- self.touch = trigger_impulse_touch1;
+ if(!this.strength) this.strength = 950 * autocvar_g_triggerimpulse_directional_multiplier;
+ settouch(this, trigger_impulse_touch1);
}
else
{
- if(!self.strength) self.strength = 0.9;
- self.strength = pow(self.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
- self.touch = trigger_impulse_touch2;
+ if(!this.strength) this.strength = 0.9;
+ this.strength = pow(this.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
+ settouch(this, trigger_impulse_touch2);
}
}
- trigger_impulse_link();
+ trigger_impulse_link(this);
}
#elif defined(CSQC)
NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew)
this.falloff = ReadByte();
this.active = ReadByte();
- trigger_common_read(true);
+ trigger_common_read(this, true);
return = true;
this.classname = "trigger_impulse";
this.solid = SOLID_TRIGGER;
this.entremove = trigger_remove_generic;
- //this.draw = trigger_draw_generic;
- this.drawmask = MASK_NORMAL;
this.move_time = time;
- if(this.radius) { this.move_touch = trigger_impulse_touch3; }
- else if(this.target) { this.move_touch = trigger_impulse_touch1; }
- else { this.move_touch = trigger_impulse_touch2; }
+ if (this.radius) { settouch(this, trigger_impulse_touch3); }
+ else if (this.target) { settouch(this, trigger_impulse_touch1); }
+ else { settouch(this, trigger_impulse_touch2); }
}
#endif
return sdir * vs + '0 0 1' * vz;
}
-void trigger_push_touch()
-{SELFPARAM();
+void trigger_push_touch(entity this)
+{
if (this.active == ACTIVE_NOT)
return;
if (this.spawnflags & PUSH_ONCE)
{
- this.touch = func_null;
- this.think = SUB_Remove_self;
+ settouch(this, func_null);
+ setthink(this, SUB_Remove);
this.nextthink = time;
}
#endif
this.active = ACTIVE_ACTIVE;
this.use = trigger_push_use;
- this.touch = trigger_push_touch;
+ settouch(this, trigger_push_touch);
// normal push setup
if (!this.speed)
this.active = ReadByte();
this.height = ReadCoord();
- trigger_common_read(true);
+ trigger_common_read(this, true);
this.entremove = trigger_remove_generic;
this.solid = SOLID_TRIGGER;
- //this.draw = trigger_draw_generic;
- this.move_touch = trigger_push_touch;
- this.drawmask = MASK_NORMAL;
+ settouch(this, trigger_push_touch);
this.move_time = time;
defer(this, 0.25, trigger_push_findtarget);
vector trigger_push_calculatevelocity(vector org, entity tgt, float ht);
-void trigger_push_touch();
+void trigger_push_touch(entity this);
.vector dest;
void trigger_push_findtarget(entity this);
remove(t);
}
-void trigger_keylock_touch()
-{SELFPARAM();
+void trigger_keylock_touch(entity this)
+{
bool key_used = false;
bool started_delay = false;
REGISTER_NET_LINKED(ENT_CLIENT_KEYLOCK)
#ifdef SVQC
-bool trigger_keylock_send(entity to, int sf)
-{SELFPARAM();
+bool trigger_keylock_send(entity this, entity to, int sf)
+{
WriteHeader(MSG_ENTITY, ENT_CLIENT_KEYLOCK);
- WriteInt24_t(MSG_ENTITY, self.itemkeys);
- WriteByte(MSG_ENTITY, self.height);
+ WriteInt24_t(MSG_ENTITY, this.itemkeys);
+ WriteByte(MSG_ENTITY, this.height);
- trigger_common_write(self, true);
+ trigger_common_write(this, true);
return true;
}
-void trigger_keylock_link()
+void trigger_keylock_link(entity this)
{
// uncomment to network keylocks
- //Net_LinkEntity(self, false, 0, trigger_keylock_send);
+ //Net_LinkEntity(this, false, 0, trigger_keylock_send);
}
/*QUAKED trigger_keylock (.0 .5 .8) ?
*/
spawnfunc(trigger_keylock)
{
- if(!self.itemkeys) { remove(self); return; }
+ if(!this.itemkeys) { remove(this); return; }
// set unlocked message
- if(self.message == "")
- self.message = "Unlocked!";
+ if(this.message == "")
+ this.message = "Unlocked!";
// set default unlock noise
- if(self.noise == "")
+ if(this.noise == "")
{
- if(self.sounds == 1)
- self.noise = "misc/secret.wav";
- else if(self.sounds == 2)
- self.noise = strzone(SND(TALK));
- else //if (self.sounds == 3) {
- self.noise = "misc/trigger1.wav";
+ if(this.sounds == 1)
+ this.noise = "misc/secret.wav";
+ else if(this.sounds == 2)
+ this.noise = strzone(SND(TALK));
+ else //if (this.sounds == 3) {
+ this.noise = "misc/trigger1.wav";
}
// set default use key sound
- if(self.noise1 == "")
- self.noise1 = "misc/decreasevalue.wav";
+ if(this.noise1 == "")
+ this.noise1 = "misc/decreasevalue.wav";
// set closed sourd
- if(self.noise2 == "")
- self.noise2 = SND(TALK);
+ if(this.noise2 == "")
+ this.noise2 = SND(TALK);
// delay between triggering message2 and trigger2
- if(!self.wait) { self.wait = 5; }
+ if(!this.wait) { this.wait = 5; }
// precache sounds
- precache_sound(self.noise);
- precache_sound(self.noise1);
- precache_sound(self.noise2);
+ precache_sound(this.noise);
+ precache_sound(this.noise1);
+ precache_sound(this.noise2);
EXACTTRIGGER_INIT;
- self.touch = trigger_keylock_touch;
+ settouch(this, trigger_keylock_touch);
- trigger_keylock_link();
+ trigger_keylock_link(this);
}
#elif defined(CSQC)
void keylock_remove(entity this)
NET_HANDLE(ENT_CLIENT_KEYLOCK, bool isnew)
{
- self.itemkeys = ReadInt24_t();
- self.height = ReadByte();
+ this.itemkeys = ReadInt24_t();
+ this.height = ReadByte();
- trigger_common_read(true);
+ trigger_common_read(this, true);
return = true;
- self.classname = "trigger_keylock";
- self.drawmask = MASK_NORMAL;
- self.draw = trigger_draw_generic;
- self.trigger_touch = trigger_keylock_touch;
- self.entremove = keylock_remove;
+ this.classname = "trigger_keylock";
+ this.entremove = keylock_remove;
}
#endif
spawnfunc(trigger_magicear)
{
- self.enemy = magicears;
- magicears = self;
+ this.enemy = magicears;
+ magicears = this;
// actually handled in "say" processing
// spawnflags:
// movedir:
// for spawnflags 256, defines 'instrument+1 mintempo maxtempo' (zero component doesn't matter)
- self.movedir_x -= 1; // map to tuba instrument numbers
+ this.movedir_x -= 1; // map to tuba instrument numbers
}
#endif
SUB_UseTargets(this, actor, trigger);
}
-void monoflop_think()
-{SELFPARAM();
+void monoflop_think(entity this)
+{
this.state = 0;
SUB_UseTargets(this, this.enemy, NULL);
}
this.use = monoflop_fixed_use;
else
this.use = monoflop_use;
- this.think = monoflop_think;
+ setthink(this, monoflop_think);
this.state = 0;
this.reset = monoflop_reset;
}
#ifdef SVQC
// the wait time has passed, so set back up for another activation
-void multi_wait()
-{SELFPARAM();
- if (self.max_health)
+void multi_wait(entity this)
+{
+ if (this.max_health)
{
- self.health = self.max_health;
- self.takedamage = DAMAGE_YES;
- self.solid = SOLID_BBOX;
+ this.health = this.max_health;
+ this.takedamage = DAMAGE_YES;
+ this.solid = SOLID_BBOX;
}
}
// the trigger was just touched/killed/used
-// self.enemy should be set to the activator so it can be held through a delay
+// this.enemy should be set to the activator so it can be held through a delay
// so wait for the delay time before firing
-void multi_trigger()
-{SELFPARAM();
- if (self.nextthink > time)
+void multi_trigger(entity this)
+{
+ if (this.nextthink > time)
{
return; // allready been triggered
}
- if(self.spawnflags & 16384)
- if(!IS_PLAYER(self.enemy))
+ if(this.spawnflags & 16384)
+ if(!IS_PLAYER(this.enemy))
return; // only players
- if (self.classname == "trigger_secret")
+ if (this.classname == "trigger_secret")
{
- if (!IS_PLAYER(self.enemy))
+ if (!IS_PLAYER(this.enemy))
return;
found_secrets = found_secrets + 1;
WriteByte (MSG_ALL, SVC_FOUNDSECRET);
}
- if (self.noise)
- _sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+ if (this.noise)
+ _sound (this.enemy, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
// don't trigger again until reset
- self.takedamage = DAMAGE_NO;
+ this.takedamage = DAMAGE_NO;
- SUB_UseTargets(self, self.enemy, self.goalentity);
+ SUB_UseTargets(this, this.enemy, this.goalentity);
- if (self.wait > 0)
+ if (this.wait > 0)
{
- self.think = multi_wait;
- self.nextthink = time + self.wait;
+ setthink(this, multi_wait);
+ this.nextthink = time + this.wait;
}
- else if (self.wait == 0)
+ else if (this.wait == 0)
{
- multi_wait(); // waiting finished
+ WITHSELF(this, multi_wait(this)); // waiting finished
}
else
- { // we can't just remove (self) here, because this is a touch function
+ { // we can't just remove (this) here, because this is a touch function
// called wheil C code is looping through area links...
- self.touch = func_null;
+ settouch(this, func_null);
}
}
{
this.goalentity = trigger;
this.enemy = actor;
- WITHSELF(this, multi_trigger());
+ multi_trigger(this);
}
-void multi_touch()
-{SELFPARAM();
+void multi_touch(entity this)
+{
if(!(self.spawnflags & 2))
if(!other.iscreature)
return;
self.enemy = other;
self.goalentity = other;
- multi_trigger ();
+ multi_trigger(self);
}
void multi_eventdamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
{
this.enemy = attacker;
this.goalentity = inflictor;
- WITHSELF(this, multi_trigger());
+ multi_trigger(this);
}
}
void multi_reset(entity this)
{
if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) )
- this.touch = multi_touch;
+ settouch(this, multi_touch);
if (this.max_health)
{
this.health = this.max_health;
this.takedamage = DAMAGE_YES;
this.solid = SOLID_BBOX;
}
- this.think = func_null;
+ setthink(this, func_null);
this.nextthink = 0;
this.team = this.team_saved;
}
*/
spawnfunc(trigger_multiple)
{
- self.reset = multi_reset;
- if (self.sounds == 1)
- self.noise = "misc/secret.wav";
- else if (self.sounds == 2)
- self.noise = strzone(SND(TALK));
- else if (self.sounds == 3)
- self.noise = "misc/trigger1.wav";
-
- if(self.noise)
- precache_sound(self.noise);
-
- if (!self.wait)
- self.wait = 0.2;
- else if(self.wait < -1)
- self.wait = 0;
- self.use = multi_use;
+ this.reset = multi_reset;
+ if (this.sounds == 1)
+ this.noise = "misc/secret.wav";
+ else if (this.sounds == 2)
+ this.noise = strzone(SND(TALK));
+ else if (this.sounds == 3)
+ this.noise = "misc/trigger1.wav";
+
+ if(this.noise)
+ precache_sound(this.noise);
+
+ if (!this.wait)
+ this.wait = 0.2;
+ else if(this.wait < -1)
+ this.wait = 0;
+ this.use = multi_use;
EXACTTRIGGER_INIT;
- self.team_saved = self.team;
+ this.team_saved = this.team;
- if (self.health)
+ if (this.health)
{
- if (self.spawnflags & SPAWNFLAG_NOTOUCH)
+ if (this.spawnflags & SPAWNFLAG_NOTOUCH)
objerror ("health and notouch don't make sense\n");
- self.max_health = self.health;
- self.event_damage = multi_eventdamage;
- self.takedamage = DAMAGE_YES;
- self.solid = SOLID_BBOX;
- setorigin (self, self.origin); // make sure it links into the world
+ this.max_health = this.health;
+ this.event_damage = multi_eventdamage;
+ this.takedamage = DAMAGE_YES;
+ this.solid = SOLID_BBOX;
+ setorigin (this, this.origin); // make sure it links into the world
}
else
{
- if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
+ if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) )
{
- self.touch = multi_touch;
- setorigin (self, self.origin); // make sure it links into the world
+ settouch(this, multi_touch);
+ setorigin (this, this.origin); // make sure it links into the world
}
}
}
#pragma once
#ifdef SVQC
-void multi_trigger();
+void multi_trigger(entity this);
void multi_reset(entity this);
spawnfunc(trigger_once);
#ifdef SVQC
-void multivibrator_send()
-{SELFPARAM();
+void multivibrator_send(entity this)
+{
float newstate;
float cyclestart;
- cyclestart = floor((time + self.phase) / (self.wait + self.respawntime)) * (self.wait + self.respawntime) - self.phase;
+ cyclestart = floor((time + this.phase) / (this.wait + this.respawntime)) * (this.wait + this.respawntime) - this.phase;
- newstate = (time < cyclestart + self.wait);
+ newstate = (time < cyclestart + this.wait);
- if(self.state != newstate)
- SUB_UseTargets(self, self, NULL);
- self.state = newstate;
+ if(this.state != newstate)
+ SUB_UseTargets(this, this, NULL);
+ this.state = newstate;
- if(self.state)
- self.nextthink = cyclestart + self.wait + 0.01;
+ if(this.state)
+ this.nextthink = cyclestart + this.wait + 0.01;
else
- self.nextthink = cyclestart + self.wait + self.respawntime + 0.01;
+ this.nextthink = cyclestart + this.wait + this.respawntime + 0.01;
+}
+
+void multivibrator_send_think(entity this)
+{
+ multivibrator_send(this);
}
void multivibrator_toggle(entity this, entity actor, entity trigger)
{
if(this.nextthink == 0)
{
- WITHSELF(this, multivibrator_send());
+ multivibrator_send(this);
}
else
{
}
}
-void multivibrator_reset()
-{SELFPARAM();
- if(!(self.spawnflags & 1))
- self.nextthink = 0; // wait for a trigger event
+void multivibrator_reset(entity this)
+{
+ if(!(this.spawnflags & 1))
+ this.nextthink = 0; // wait for a trigger event
else
- self.nextthink = max(1, time);
+ this.nextthink = max(1, time);
}
/*QUAKED trigger_multivibrator (.5 .5 .5) (-8 -8 -8) (8 8 8) START_ON
*/
spawnfunc(trigger_multivibrator)
{
- if(!self.wait)
- self.wait = 1;
- if(!self.respawntime)
- self.respawntime = self.wait;
+ if(!this.wait)
+ this.wait = 1;
+ if(!this.respawntime)
+ this.respawntime = this.wait;
- self.state = 0;
- self.use = multivibrator_toggle;
- self.think = multivibrator_send;
- self.nextthink = max(1, time);
+ this.state = 0;
+ this.use = multivibrator_toggle;
+ setthink(this, multivibrator_send_think);
+ this.nextthink = max(1, time);
IFTARGETED
- multivibrator_reset();
+ multivibrator_reset(this);
}
#endif
/**
* A secret has been found (maybe :P)
*/
-void trigger_secret_touch()
-{SELFPARAM();
+void trigger_secret_touch(entity this)
+{
// only a player can trigger this
if (!IS_PLAYER(other))
return;
self.message = "";
// handle normal trigger features
- multi_touch();
+ multi_touch(self);
remove(self);
}
secrets_total += 1;
// add default message
- if (self.message == "")
- self.message = "You found a secret!";
+ if (this.message == "")
+ this.message = "You found a secret!";
// set default sound
- if (self.noise == "")
- if (!self.sounds)
- self.sounds = 1; // misc/secret.wav
+ if (this.noise == "")
+ if (!this.sounds)
+ this.sounds = 1; // misc/secret.wav
// this entity can't be a target itself!!!!
- self.targetname = "";
+ this.targetname = "";
// you can't just shoot a room to find it, can you?
- self.health = 0;
+ this.health = 0;
// a secret can not be delayed
- self.delay = 0;
+ this.delay = 0;
// convert this trigger to trigger_once
- self.classname = "trigger_once";
+ this.classname = "trigger_once";
spawnfunc_trigger_once(this);
// take over the touch() function, so we can mark secret as found
- self.touch = trigger_secret_touch;
+ settouch(this, trigger_secret_touch);
// ignore triggering;
- self.use = func_null;
+ this.use = func_null;
}
#endif
#ifdef SVQC
spawnfunc(trigger_swamp);
#endif
-void swamp_touch();
-void swampslug_think();
+void swamp_touch(entity this);
+void swampslug_think(entity this);
/*
*
* I do it this way becuz there is no "untouch" event.
*/
-void swampslug_think()
-{SELFPARAM();
+void swampslug_think(entity this)
+{
//Slowly kill the slug
self.health = self.health - 1;
self.nextthink = time + self.swamp_interval;
}
-void swamp_touch()
-{SELFPARAM();
+void swamp_touch(entity this)
+{
// If whatever thats touching the swamp is not a player
// or if its a dead player, just dont care abt it.
if(!IS_PLAYER(other) || IS_DEAD(other))
//centerprint(other,"Entering swamp!\n");
other.swampslug = spawn();
other.swampslug.health = 2;
- other.swampslug.think = swampslug_think;
+ setthink(other.swampslug, swampslug_think);
other.swampslug.nextthink = time;
other.swampslug.owner = other;
other.swampslug.dmg = self.dmg;
return true;
}
-void swamp_link()
-{SELFPARAM();
- trigger_link(self, swamp_send);
+void swamp_link(entity this)
+{
+ trigger_link(this, swamp_send);
}
/*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
spawnfunc(trigger_swamp)
{
// Init stuff
- trigger_init(self);
- self.touch = swamp_touch;
+ trigger_init(this);
+ settouch(this, swamp_touch);
// Setup default keys, if missing
- if(self.dmg <= 0)
- self.dmg = 5;
- if(self.swamp_interval <= 0)
- self.swamp_interval = 1;
- if(self.swamp_slowdown <= 0)
- self.swamp_slowdown = 0.5;
-
- swamp_link();
+ if(this.dmg <= 0)
+ this.dmg = 5;
+ if(this.swamp_interval <= 0)
+ this.swamp_interval = 1;
+ if(this.swamp_slowdown <= 0)
+ this.swamp_slowdown = 0.5;
+
+ swamp_link(this);
}
#elif defined(CSQC)
NET_HANDLE(ENT_CLIENT_SWAMP, bool isnew)
{
- self.dmg = ReadByte();
- self.swamp_slowdown = ReadByte();
- self.swamp_interval = ReadByte();
+ this.dmg = ReadByte();
+ this.swamp_slowdown = ReadByte();
+ this.swamp_interval = ReadByte();
- trigger_common_read(false);
+ trigger_common_read(this, false);
return = true;
- self.classname = "trigger_swamp";
- self.solid = SOLID_TRIGGER;
- self.move_touch = swamp_touch;
- self.drawmask = MASK_NORMAL;
- self.move_time = time;
- self.entremove = trigger_remove_generic;
+ this.classname = "trigger_swamp";
+ this.solid = SOLID_TRIGGER;
+ settouch(this, swamp_touch);
+ this.drawmask = MASK_NORMAL;
+ this.move_time = time;
+ this.entremove = trigger_remove_generic;
}
#endif
}
#endif
-void Teleport_Touch ()
-{SELFPARAM();
+void Teleport_Touch (entity this)
+{
if (self.active != ACTIVE_ACTIVE)
return;
spawnfunc(trigger_teleport)
{
- self.angles = '0 0 0';
+ this.angles = '0 0 0';
- self.active = ACTIVE_ACTIVE;
- //trigger_init(self); // only for predicted triggers?
+ this.active = ACTIVE_ACTIVE;
+ //trigger_init(this); // only for predicted triggers?
EXACTTRIGGER_INIT;
- self.use = trigger_teleport_use;
+ this.use = trigger_teleport_use;
- if(self.noise != "")
- FOREACH_WORD(self.noise, true, precache_sound(it));
+ if(this.noise != "")
+ FOREACH_WORD(this.noise, true, precache_sound(it));
// this must be called to spawn the teleport waypoints for bots
- InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET);
+ InitializeEntity(this, teleport_findtarget, INITPRIO_FINDTARGET);
- if (self.target == "")
+ if (this.target == "")
{
objerror ("Teleporter with no target");
return;
}
- self.teleport_next = teleport_first;
- teleport_first = self;
+ this.teleport_next = teleport_first;
+ teleport_first = this;
}
#elif defined(CSQC)
NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
{
- self.classname = "trigger_teleport";
- int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
- self.spawnflags = ReadInt24_t();
- self.active = ReadByte();
- self.speed = ReadCoord();
-
- trigger_common_read(true);
-
- self.entremove = trigger_remove_generic;
- self.solid = SOLID_TRIGGER;
- //self.draw = trigger_draw_generic;
- //self.move_touch = trigger_push_touch;
- self.drawmask = MASK_NORMAL;
- self.move_time = time;
- defer(self, 0.25, teleport_findtarget);
-
- self.teleport_next = teleport_first;
- teleport_first = self;
+ this.classname = "trigger_teleport";
+ int mytm = ReadByte(); if(mytm) { this.team = mytm - 1; }
+ this.spawnflags = ReadInt24_t();
+ this.active = ReadByte();
+ this.speed = ReadCoord();
+
+ trigger_common_read(this, true);
+
+ this.entremove = trigger_remove_generic;
+ this.solid = SOLID_TRIGGER;
+ //this.move_touch = trigger_push_touch;
+ this.move_time = time;
+ defer(this, 0.25, teleport_findtarget);
+
+ this.teleport_next = teleport_first;
+ teleport_first = this;
return true;
}
#ifdef SVQC
-void viewloc_think()
-{SELFPARAM();
+void viewloc_think(entity this)
+{
entity e;
// we abuse this method, rather than using normal .touch, because touch isn't reliable with multiple clients inside the same trigger, and can't "untouch" entities
// CSQC doesn't need to know our origin (yet), as we're only available for referencing
WriteHeader(MSG_ENTITY, ENT_CLIENT_VIEWLOC_TRIGGER);
- WriteEntity(MSG_ENTITY, self.enemy);
- WriteEntity(MSG_ENTITY, self.goalentity);
+ WriteEntity(MSG_ENTITY, this.enemy);
+ WriteEntity(MSG_ENTITY, this.goalentity);
- WriteCoord(MSG_ENTITY, self.origin_x);
- WriteCoord(MSG_ENTITY, self.origin_y);
- WriteCoord(MSG_ENTITY, self.origin_z);
+ WriteCoord(MSG_ENTITY, this.origin_x);
+ WriteCoord(MSG_ENTITY, this.origin_y);
+ WriteCoord(MSG_ENTITY, this.origin_z);
return true;
}
void viewloc_init(entity this)
{
entity e;
- for(e = world; (e = find(e, targetname, self.target)); )
+ for(e = world; (e = find(e, targetname, this.target)); )
if(e.classname == "target_viewlocation_start")
{
- self.enemy = e;
+ this.enemy = e;
break;
}
- for(e = world; (e = find(e, targetname, self.target2)); )
+ for(e = world; (e = find(e, targetname, this.target2)); )
if(e.classname == "target_viewlocation_end")
{
- self.goalentity = e;
+ this.goalentity = e;
break;
}
- if(!self.enemy) { LOG_INFO("^1FAIL!\n"); remove(self); return; }
+ if(!this.enemy) { LOG_INFO("^1FAIL!\n"); remove(this); return; }
- if(!self.goalentity)
- self.goalentity = self.enemy; // make them match so CSQC knows what to do
+ if(!this.goalentity)
+ this.goalentity = this.enemy; // make them match so CSQC knows what to do
- Net_LinkEntity(self, false, 0, trigger_viewloc_send);
+ Net_LinkEntity(this, false, 0, trigger_viewloc_send);
- self.think = viewloc_think;
- self.nextthink = time;
+ setthink(this, viewloc_think);
+ this.nextthink = time;
}
spawnfunc(trigger_viewlocation)
{
// we won't check target2 here yet, as it may not even need to exist
- if(self.target == "") { LOG_INFO("^1FAIL!\n"); remove(self); return; }
+ if(this.target == "") { LOG_INFO("^1FAIL!\n"); remove(this); return; }
EXACTTRIGGER_INIT;
- InitializeEntity(self, viewloc_init, INITPRIO_FINDTARGET);
+ InitializeEntity(this, viewloc_init, INITPRIO_FINDTARGET);
}
bool viewloc_send(entity this, entity to, int sf)
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_VIEWLOC);
- WriteByte(MSG_ENTITY, self.cnt);
+ WriteByte(MSG_ENTITY, this.cnt);
- WriteCoord(MSG_ENTITY, self.origin_x);
- WriteCoord(MSG_ENTITY, self.origin_y);
- WriteCoord(MSG_ENTITY, self.origin_z);
+ WriteCoord(MSG_ENTITY, this.origin_x);
+ WriteCoord(MSG_ENTITY, this.origin_y);
+ WriteCoord(MSG_ENTITY, this.origin_z);
- WriteCoord(MSG_ENTITY, self.angles_x);
- WriteCoord(MSG_ENTITY, self.angles_y);
- WriteCoord(MSG_ENTITY, self.angles_z);
+ WriteCoord(MSG_ENTITY, this.angles_x);
+ WriteCoord(MSG_ENTITY, this.angles_y);
+ WriteCoord(MSG_ENTITY, this.angles_z);
return true;
}
.float angle;
-void viewloc_link()
-{SELFPARAM();
- if(self.angle)
- self.angles_y = self.angle;
- Net_LinkEntity(self, false, 0, viewloc_send);
+void viewloc_link(entity this)
+{
+ if(this.angle)
+ this.angles_y = this.angle;
+ Net_LinkEntity(this, false, 0, viewloc_send);
}
spawnfunc(target_viewlocation_start)
{
- self.classname = "target_viewlocation_start";
- self.cnt = 1;
- viewloc_link();
+ this.classname = "target_viewlocation_start";
+ this.cnt = 1;
+ viewloc_link(this);
}
spawnfunc(target_viewlocation_end)
{
- self.classname = "target_viewlocation_end";
- self.cnt = 2;
- viewloc_link();
+ this.classname = "target_viewlocation_end";
+ this.cnt = 2;
+ viewloc_link(this);
}
// compatibility
#elif defined(CSQC)
-void trigger_viewloc_updatelink()
-{SELFPARAM();
+void trigger_viewloc_updatelink(entity this)
+{
self.enemy = findfloat(world, entnum, self.cnt);
self.goalentity = findfloat(world, entnum, self.count);
}
float point1 = ReadShort();
float point2 = ReadShort();
- self.enemy = findfloat(world, entnum, point1);
- self.goalentity = findfloat(world, entnum, point2);
+ this.enemy = findfloat(world, entnum, point1);
+ this.goalentity = findfloat(world, entnum, point2);
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
return = true;
- setorigin(self, self.origin);
+ setorigin(this, this.origin);
- self.cnt = point1;
- self.count = point2;
+ this.cnt = point1;
+ this.count = point2;
- self.think = trigger_viewloc_updatelink;
- self.nextthink = time + 1; // we need to delay this or else
+ setthink(this, trigger_viewloc_updatelink);
+ this.nextthink = time + 1; // we need to delay this or else
- self.classname = "trigger_viewlocation";
- self.drawmask = MASK_NORMAL; // not so concerned, but better keep it alive
+ this.classname = "trigger_viewlocation";
+ this.drawmask = MASK_NORMAL; // not so concerned, but better keep it alive
}
NET_HANDLE(ENT_CLIENT_VIEWLOC, bool isnew)
{
- self.cnt = ReadByte();
+ this.cnt = ReadByte();
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- setorigin(self, self.origin);
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+ setorigin(this, this.origin);
- self.movedir_x = ReadCoord();
- self.movedir_y = ReadCoord();
- self.movedir_z = ReadCoord();
+ this.movedir_x = ReadCoord();
+ this.movedir_y = ReadCoord();
+ this.movedir_z = ReadCoord();
return = true;
- self.classname = ((self.cnt == 2) ? "target_viewlocation_end" : "target_viewlocation_start");
- self.drawmask = MASK_NORMAL; // don't cull it
+ this.classname = ((this.cnt == 2) ? "target_viewlocation_end" : "target_viewlocation_start");
+ this.drawmask = MASK_NORMAL; // don't cull it
}
#endif
void SUB_UseTargets(entity this, entity actor, entity trigger);
-void DelayThink()
-{SELFPARAM();
+void DelayThink(entity this)
+{
SUB_UseTargets (this, this.enemy, NULL);
remove(this);
}
void trigger_init(entity this)
{
string m = this.model;
- WITHSELF(this, WarpZoneLib_ExactTrigger_Init());
+ EXACTTRIGGER_INIT;
if(m != "")
{
precache_model(m);
#elif defined(CSQC)
-void trigger_common_read(bool withtarget)
-{SELFPARAM();
+void trigger_common_read(entity this, bool withtarget)
+{
int f = ReadByte();
this.warpzone_isboxy = (f & 1);
// create a temp object to fire at a later time
entity t = new(DelayedUse);
t.nextthink = time + this.delay;
- t.think = DelayThink;
+ setthink(t, DelayThink);
t.enemy = actor;
t.message = this.message;
t.killtarget = this.killtarget;
RandomSelection_chosen_ent.use(RandomSelection_chosen_ent, actor, this);
}
-void SUB_UseTargets_self()
-{SELFPARAM();
- SUB_UseTargets(this, NULL, NULL);
-}
-
-#ifdef CSQC
-void trigger_touch_generic(entity this, void() touchfunc)
-{
- entity e;
- for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain)
- if(e.classname == "csqcprojectile")
- {
- vector emin = e.absmin, emax = e.absmax;
- if(this.solid == SOLID_BSP)
- {
- emin -= '1 1 1';
- emax += '1 1 1';
- }
- if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
- if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate
- {
- other = e;
- WITHSELF(this, touchfunc());
- }
- }
-}
-void trigger_draw_generic(entity this)
+void SUB_UseTargets_self(entity this)
{
- float dt = time - this.move_time;
- this.move_time = time;
- if(dt <= 0) { return; }
-
- if(this.trigger_touch) { trigger_touch_generic(this, this.trigger_touch); }
+ SUB_UseTargets(this, NULL, NULL);
}
-#endif
const float SPAWNFLAG_NOMESSAGE = 1;
const float SPAWNFLAG_NOTOUCH = 1;
-.void() trigger_touch;
-
.bool pushable;
.float antiwall_flag; // Variable to define what to do with func_clientwall
void FixSize(entity e);
#ifdef CSQC
-void trigger_common_read(bool withtarget);
+void trigger_common_read(entity this, bool withtarget);
void trigger_remove_generic(entity this);
.float active;
If the checkpoint chain in not looped, the unit will go "Roaming" when the last point is reached.
*/
//float tc_acum;
-void turret_checkpoint_init()
-{SELFPARAM();
+void turret_checkpoint_init(entity this)
+{
traceline(self.origin + '0 0 16', self.origin - '0 0 1024', MOVE_WORLDONLY, self);
setorigin(self, trace_endpos + '0 0 32');
spawnfunc(turret_checkpoint)
{
- setorigin(self,self.origin);
- self.think = turret_checkpoint_init;
- self.nextthink = time + 0.2;
+ setorigin(this,this.origin);
+ setthink(this, turret_checkpoint_init);
+ this.nextthink = time + 0.2;
}
// Compat.
spawnfunc(walker_checkpoint)
{
- self.classname = "turret_checkpoint";
+ this.classname = "turret_checkpoint";
spawnfunc_turret_checkpoint(this);
}
}
.vector glowmod;
-void turret_changeteam()
-{SELFPARAM();
- self.glowmod = Team_ColorRGB(self.team - 1) * 2;
- self.teamradar_color = Team_ColorRGB(self.team - 1);
+void turret_changeteam(entity this)
+{
+ this.glowmod = Team_ColorRGB(this.team - 1) * 2;
+ this.teamradar_color = Team_ColorRGB(this.team - 1);
- if(self.team)
- self.colormap = 1024 + (self.team - 1) * 17;
+ if(this.team)
+ this.colormap = 1024 + (this.team - 1) * 17;
- self.tur_head.colormap = self.colormap;
- self.tur_head.glowmod = self.glowmod;
+ this.tur_head.colormap = this.colormap;
+ this.tur_head.glowmod = this.glowmod;
}
return gib;
}
-void turret_die()
-{SELFPARAM();
+void turret_die(entity this)
+{
sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
pointparticles(EFFECT_ROCKET_EXPLODE, self.origin, '0 0 0', 1);
if (!autocvar_cl_nogibs)
if(sf & TNSF_SETUP)
{
- self.m_id = ReadByte();
+ this.m_id = ReadByte();
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- setorigin(self, self.origin);
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+ setorigin(this, this.origin);
- self.angles_x = ReadAngle();
- self.angles_y = ReadAngle();
+ this.angles_x = ReadAngle();
+ this.angles_y = ReadAngle();
turret_construct();
- self.colormap = 1024;
- self.glowmod = '0 1 1';
- self.tur_head.colormap = self.colormap;
- self.tur_head.glowmod = self.glowmod;
+ this.colormap = 1024;
+ this.glowmod = '0 1 1';
+ this.tur_head.colormap = this.colormap;
+ this.tur_head.glowmod = this.glowmod;
}
if(sf & TNSF_ANG)
{
- if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
- self.tur_head = spawn();
+ if(this.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
+ this.tur_head = spawn();
- self.tur_head.move_angles_x = ReadShort();
- self.tur_head.move_angles_y = ReadShort();
- //self.tur_head.angles = self.angles + self.tur_head.move_angles;
- self.tur_head.angles = self.tur_head.move_angles;
+ this.tur_head.move_angles_x = ReadShort();
+ this.tur_head.move_angles_y = ReadShort();
+ //this.tur_head.angles = this.angles + this.tur_head.move_angles;
+ this.tur_head.angles = this.tur_head.move_angles;
}
if(sf & TNSF_AVEL)
{
- if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
- self.tur_head = spawn();
+ if(this.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
+ this.tur_head = spawn();
- self.tur_head.move_avelocity_x = ReadShort();
- self.tur_head.move_avelocity_y = ReadShort();
+ this.tur_head.move_avelocity_x = ReadShort();
+ this.tur_head.move_avelocity_y = ReadShort();
}
if(sf & TNSF_MOVE)
{
- self.origin_x = ReadShort();
- self.origin_y = ReadShort();
- self.origin_z = ReadShort();
- setorigin(self, self.origin);
+ this.origin_x = ReadShort();
+ this.origin_y = ReadShort();
+ this.origin_z = ReadShort();
+ setorigin(this, this.origin);
- self.velocity_x = ReadShort();
- self.velocity_y = ReadShort();
- self.velocity_z = ReadShort();
+ this.velocity_x = ReadShort();
+ this.velocity_y = ReadShort();
+ this.velocity_z = ReadShort();
- self.move_angles_y = ReadShort();
+ this.move_angles_y = ReadShort();
- self.move_time = time;
- self.move_velocity = self.velocity;
- self.move_origin = self.origin;
+ this.move_time = time;
+ this.move_velocity = this.velocity;
+ this.move_origin = this.origin;
}
if(sf & TNSF_ANIM)
{
- self.frame1time = ReadCoord();
- self.frame = ReadByte();
+ this.frame1time = ReadCoord();
+ this.frame = ReadByte();
}
if(sf & TNSF_STATUS)
{
float _tmp;
_tmp = ReadByte();
- if(_tmp != self.team)
+ if(_tmp != this.team)
{
- self.team = _tmp;
- turret_changeteam();
+ this.team = _tmp;
+ turret_changeteam(this);
}
_tmp = ReadByte();
- if(_tmp == 0 && self.health != 0)
- turret_die();
- else if(self.health && self.health != _tmp)
- self.helpme = servertime + 10;
+ if(_tmp == 0 && this.health != 0)
+ turret_die(this);
+ else if(this.health && this.health != _tmp)
+ this.helpme = servertime + 10;
- self.health = _tmp;
+ this.health = _tmp;
}
- //self.enemy.health = self.health / 255;
+ //this.enemy.health = this.health / 255;
return true;
}
}
// Generic damage handling
-void turret_hide()
-{SELFPARAM();
+void turret_hide(entity this)
+{
self.effects |= EF_NODRAW;
self.nextthink = time + self.respawntime - 0.2;
- self.think = turret_respawn;
+ setthink(self, turret_respawn);
}
-void turret_die()
-{SELFPARAM();
+void turret_die(entity this)
+{
self.deadflag = DEAD_DEAD;
self.tur_head.deadflag = self.deadflag;
// Setup respawn
self.SendFlags |= TNSF_STATUS;
self.nextthink = time + 0.2;
- self.think = turret_hide;
+ setthink(self, turret_hide);
tur.tr_death(tur, self);
}
this.tur_head.event_damage = func_null;
this.takedamage = DAMAGE_NO;
this.nextthink = time;
- this.think = turret_die;
+ setthink(this, turret_die);
}
this.SendFlags |= TNSF_STATUS;
}
-void() turret_think;
-void turret_respawn()
-{SELFPARAM();
+void turret_think(entity this);
+void turret_respawn(entity this)
+{
// Make sure all parts belong to the same team since
// this function doubles as "teamchange" function.
self.tur_head.team = self.team;
self.ammo = self.ammo_max;
self.nextthink = time + self.ticrate;
- self.think = turret_think;
+ setthink(self, turret_think);
self.SendFlags = TNSF_FULL_UPDATE;
}
}
-void turret_projectile_explode()
-{SELFPARAM();
+void turret_projectile_explode(entity this)
+{
self.takedamage = DAMAGE_NO;
self.event_damage = func_null;
remove(self);
}
-void turret_projectile_touch()
+void turret_projectile_touch(entity this)
{
- PROJECTILE_TOUCH;
- turret_projectile_explode();
+ PROJECTILE_TOUCH(this);
+ turret_projectile_explode(this);
}
void turret_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
proj.realowner = self;
proj.bot_dodge = true;
proj.bot_dodgerating = self.shot_dmg;
- proj.think = turret_projectile_explode;
- proj.touch = turret_projectile_touch;
+ setthink(proj, turret_projectile_explode);
+ settouch(proj, turret_projectile_touch);
proj.nextthink = time + 9;
proj.movetype = MOVETYPE_FLYMISSILE;
proj.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
** and updated aim<->predict impact distance.
**/
void turret_do_updates(entity t_turret)
-{SELFPARAM();
- vector enemy_pos;
-
- setself(t_turret);
-
- enemy_pos = real_origin(self.enemy);
+{
+ vector enemy_pos = real_origin(t_turret.enemy);
- turret_tag_fire_update();
+ WITHSELF(t_turret, turret_tag_fire_update());
- self.tur_shotdir_updated = v_forward;
- self.tur_dist_enemy = vlen(self.tur_shotorg - enemy_pos);
- self.tur_dist_aimpos = vlen(self.tur_shotorg - self.tur_aimpos);
+ t_turret.tur_shotdir_updated = v_forward;
+ t_turret.tur_dist_enemy = vlen(t_turret.tur_shotorg - enemy_pos);
+ t_turret.tur_dist_aimpos = vlen(t_turret.tur_shotorg - t_turret.tur_aimpos);
- /*if((self.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (self.enemy))
+ /*if((t_turret.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (t_turret.enemy))
{
- oldpos = self.enemy.origin;
- setorigin(self.enemy, self.tur_aimpos);
- tracebox(self.tur_shotorg, '-1 -1 -1', '1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
- setorigin(self.enemy, oldpos);
+ oldpos = t_turret.enemy.origin;
+ setorigin(t_turret.enemy, t_turret.tur_aimpos);
+ tracebox(t_turret.tur_shotorg, '-1 -1 -1', '1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret);
+ setorigin(t_turret.enemy, oldpos);
- if(trace_ent == self.enemy)
- self.tur_dist_impact_to_aimpos = 0;
+ if(trace_ent == t_turret.enemy)
+ t_turret.tur_dist_impact_to_aimpos = 0;
else
- self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos);
+ t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos);
}
else*/
- tracebox(self.tur_shotorg, '-1 -1 -1','1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
-
- self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos) - (vlen(self.enemy.maxs - self.enemy.mins) * 0.5);
- self.tur_impactent = trace_ent;
- self.tur_impacttime = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
+ tracebox(t_turret.tur_shotorg, '-1 -1 -1','1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret);
- setself(this);
+ t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos) - (vlen(t_turret.enemy.maxs - t_turret.enemy.mins) * 0.5);
+ t_turret.tur_impactent = trace_ent;
+ t_turret.tur_impacttime = vlen(t_turret.tur_shotorg - trace_endpos) / t_turret.shot_speed;
}
/**
#endif
}
-void turret_think()
-{SELFPARAM();
+void turret_think(entity this)
+{
self.nextthink = time + self.ticrate;
MUTATOR_CALLHOOK(TurretThink, self);
void turret_link()
{SELFPARAM();
Net_LinkEntity(self, true, 0, turret_send);
- self.think = turret_think;
+ setthink(self, turret_think);
self.nextthink = time;
self.tur_head.effects = EF_NODRAW;
}
-void turrets_manager_think()
+void turrets_manager_think(entity this)
{
- SELFPARAM();
this.nextthink = time + 1;
if (autocvar_g_turrets_reloadcvars == 1)
if(!e)
{
e = new(turret_manager);
- e.think = turrets_manager_think;
+ setthink(e, turrets_manager_think);
e.nextthink = time + 2;
}
#endif
turret_link();
- turret_respawn();
+ turret_respawn(self);
turret_tag_fire_update();
tur.tr_setup(tur, self);
#define SV_TURRETS_H
entity turret_projectile(Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim);
-void turret_projectile_explode();
+void turret_projectile_explode(entity this);
float turret_validate_target(entity e_turret, entity e_target, float validate_flags);
float turret_firecheck();
entity turret_select_target();
.float track_accel_rotate;
.float track_blendrate;
-void() turret_respawn;
+void turret_respawn(entity this);
/// updates aim org, shot org, shot dir and enemy org for selected turret
void turret_do_updates(entity e_turret);
spawnfunc(turret_targettrigger);
-void turret_targettrigger_touch();
+void turret_targettrigger_touch(entity this);
-void turret_targettrigger_touch()
-{SELFPARAM();
- entity e;
- if (self.cnt > time) return;
- entity oldself = this;
-
- e = find(world, targetname, self.target);
- while (e)
- {
- if (e.turret_flags & TUR_FLAG_RECIEVETARGETS)
- {
- setself(e);
- if(e.turret_addtarget)
- e.turret_addtarget(other,oldself);
- }
-
- e = find(e, targetname, oldself.target);
- }
-
- oldself.cnt = time + 0.5;
-
- setself(this);
+void turret_targettrigger_touch(entity this)
+{
+ if (this.cnt > time) return;
+ FOREACH_ENTITY_STRING_ORDERED(targetname, this.target, {
+ if (!(it.turret_flags & TUR_FLAG_RECIEVETARGETS)) continue;
+ if (!it.turret_addtarget) continue;
+ WITHSELF(it, it.turret_addtarget(other, this));
+ });
+ this.cnt = time + 0.5;
}
/*QUAKED turret_targettrigger (.5 .5 .5) ?
*/
spawnfunc(turret_targettrigger)
{
- if(!autocvar_g_turrets) { remove(self); return; }
+ if(!autocvar_g_turrets) { remove(this); return; }
- InitTrigger ();
+ WITHSELF(this, InitTrigger());
- self.touch = turret_targettrigger_touch;
+ settouch(this, turret_targettrigger_touch);
}
if (self.pathgoal.enemy)
{
- self.pathcurrent = pathlib_astar(self.pathgoal.origin,self.pathgoal.enemy.origin);
+ self.pathcurrent = pathlib_astar(self, self.pathgoal.origin,self.pathgoal.enemy.origin);
self.pathgoal = self.pathgoal.enemy;
}
}
{SELFPARAM();
float newframe;
- self.steerto = steerlib_arrive(self.enemy.origin,self.target_range_optimal);
+ self.steerto = steerlib_arrive(self, self.enemy.origin,self.target_range_optimal);
self.moveto = self.origin + self.steerto * 128;
movelib_brake_simple(self, (autocvar_g_turrets_unit_ewheel_speed_stop));
}
-spawnfunc(turret_ewheel) { if(!turret_initialize(TUR_EWHEEL)) remove(self); }
+spawnfunc(turret_ewheel) { if(!turret_initialize(TUR_EWHEEL)) remove(this); }
METHOD(EWheel, tr_think, void(EWheel thistur, entity it))
{
{
#ifdef EWHEEL_FANCYPATH
- it.pathcurrent = WALKER_PATH(it.origin,e.origin);
+ it.pathcurrent = WALKER_PATH(it, it.origin, e.origin);
it.pathgoal = e;
#else
it.pathcurrent = e;
#ifdef SVQC
-spawnfunc(turret_flac) { if (!turret_initialize(TUR_FLAC)) remove(self); }
+spawnfunc(turret_flac) { if (!turret_initialize(TUR_FLAC)) remove(this); }
METHOD(Flac, tr_setup, void(Flac this, entity it))
{
#ifdef SVQC
-void turret_flac_projectile_think_explode();
+void turret_flac_projectile_think_explode(entity this);
SOUND(FlacAttack_FIRE, W_Sound("electro_fire"));
METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
bool isPlayer = IS_PLAYER(actor);
entity proj = turret_projectile(SND_HAGAR_FIRE, 5, 0, DEATH_TURRET_FLAC.m_id, PROJECTILE_HAGAR, true, true);
proj.missile_flags = MIF_SPLASH | MIF_PROXY;
- proj.think = turret_flac_projectile_think_explode;
+ setthink(proj, turret_flac_projectile_think_explode);
proj.nextthink = time + actor.tur_impacttime + (random() * 0.01 - random() * 0.01);
Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1);
}
}
-void turret_flac_projectile_think_explode()
+void turret_flac_projectile_think_explode(entity this)
{
- SELFPARAM();
if(self.enemy != world)
if(vdist(self.origin - self.enemy.origin, <, self.owner.shot_radius * 3))
setorigin(self,self.enemy.origin + randomvec() * self.owner.shot_radius);
return true;
}
-spawnfunc(turret_fusionreactor) { if (!turret_initialize(TUR_FUSIONREACTOR)) remove(self); }
+spawnfunc(turret_fusionreactor) { if (!turret_initialize(TUR_FUSIONREACTOR)) remove(this); }
METHOD(FusionReactor, tr_attack, void(FusionReactor this, entity it))
{
#ifdef SVQC
-spawnfunc(turret_hellion) { if (!turret_initialize(TUR_HELLION)) remove(self); }
+spawnfunc(turret_hellion) { if (!turret_initialize(TUR_HELLION)) remove(this); }
METHOD(Hellion, tr_think, void(Hellion thistur, entity it))
{
float autocvar_g_turrets_unit_hellion_shot_speed_gain;
float autocvar_g_turrets_unit_hellion_shot_speed_max;
-void turret_hellion_missile_think();
+void turret_hellion_missile_think(entity this);
SOUND(HellionAttack_FIRE, W_Sound("electro_fire"));
METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
bool isPlayer = IS_PLAYER(actor);
entity missile = turret_projectile(SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, false, false);
te_explosion (missile.origin);
- missile.think = turret_hellion_missile_think;
+ setthink(missile, turret_hellion_missile_think);
missile.nextthink = time;
missile.flags = FL_PROJECTILE;
missile.max_health = time + 9;
}
}
-void turret_hellion_missile_think()
-{SELFPARAM();
+void turret_hellion_missile_think(entity this)
+{
vector olddir,newdir;
vector pre_pos;
float itime;
olddir = normalize(self.velocity);
if(self.max_health < time)
- turret_projectile_explode();
+ turret_projectile_explode(self);
// Enemy dead? just keep on the current heading then.
if ((self.enemy == world) || (IS_DEAD(self.enemy)))
self.angles = vectoangles(self.velocity);
if(vdist(self.origin - self.owner.origin, >, (self.owner.shot_radius * 5)))
- turret_projectile_explode();
+ turret_projectile_explode(self);
// Accelerate
self.velocity = olddir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
// Enemy in range?
if(vdist(self.origin - self.enemy.origin, <, self.owner.shot_radius * 0.2))
- turret_projectile_explode();
+ turret_projectile_explode(self);
// Predict enemy position
itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
self.velocity = newdir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
if (itime < 0.05)
- self.think = turret_projectile_explode;
+ setthink(self, turret_projectile_explode);
UpdateCSQCProjectile(self);
}
.float atime;
#endif
-spawnfunc(turret_hk) { if(!turret_initialize(TUR_HK)) remove(self); }
+spawnfunc(turret_hk) { if(!turret_initialize(TUR_HK)) remove(this); }
METHOD(HunterKiller, tr_think, void(HunterKiller thistur, entity it))
{
float autocvar_g_turrets_unit_hk_shot_speed_max;
float autocvar_g_turrets_unit_hk_shot_speed_turnrate;
-void turret_hk_missile_think();
+void turret_hk_missile_think(entity this);
SOUND(HunterKillerAttack_FIRE, W_Sound("electro_fire"));
METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
entity missile = turret_projectile(SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HK.m_id, PROJECTILE_ROCKET, false, false);
te_explosion (missile.origin);
- missile.think = turret_hk_missile_think;
+ setthink(missile, turret_hk_missile_think);
missile.nextthink = time + 0.25;
missile.movetype = MOVETYPE_BOUNCEMISSILE;
missile.velocity = actor.tur_shotdir_updated * (actor.shot_speed * 0.75);
}
bool hk_is_valid_target(entity e_target);
-void turret_hk_missile_think()
-{SELFPARAM();
+void turret_hk_missile_think(entity this)
+{
vector vu, vd, vf, vl, vr, ve; // Vector (direction)
float fu, fd, ff, fl, fr, fe; // Fraction to solid
vector olddir,wishdir,newdir; // Final direction
// Close enougth to do decent damage?
if ( edist <= (self.owner.shot_radius * 0.25) )
{
- turret_projectile_explode();
+ turret_projectile_explode(self);
return;
}
#ifdef SVQC
-spawnfunc(turret_machinegun) { if (!turret_initialize(TUR_MACHINEGUN)) remove(self); }
+spawnfunc(turret_machinegun) { if (!turret_initialize(TUR_MACHINEGUN)) remove(this); }
METHOD(MachineGunTurret, tr_setup, void(MachineGunTurret this, entity it))
{
#ifdef SVQC
-void W_MachineGun_MuzzleFlash();
+void W_MachineGun_MuzzleFlash(entity actor);
SOUND(MachineGunTurretAttack_FIRE, W_Sound("electro_fire"));
METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
}
fireBullet (actor, actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_MACHINEGUN.m_id, 0);
- W_MachineGun_MuzzleFlash();
+ W_MachineGun_MuzzleFlash(actor);
setattachment(actor.muzzle_flash, actor.tur_head, "tag_fire");
}
}
#ifdef SVQC
-spawnfunc(turret_mlrs) { if (!turret_initialize(TUR_MLRS)) remove(self); }
+spawnfunc(turret_mlrs) { if (!turret_initialize(TUR_MLRS)) remove(this); }
METHOD(MLRSTurret, tr_think, void(MLRSTurret thistur, entity it))
{
#ifdef SVQC
-spawnfunc(turret_phaser) { if (!turret_initialize(TUR_PHASER)) remove(self); }
+spawnfunc(turret_phaser) { if (!turret_initialize(TUR_PHASER)) remove(this); }
.int fireflag;
#ifdef IMPLEMENTATION
#ifdef SVQC
-void beam_think();
+void beam_think(entity this);
.int fireflag;
SOUND(PhaserTurretAttack_FIRE, W_Sound("electro_fire"));
setmodel(beam, MDL_TUR_PHASER_BEAM);
beam.effects = EF_LOWPRECISION;
beam.solid = SOLID_NOT;
- beam.think = beam_think;
+ setthink(beam, beam_think);
beam.cnt = time + actor.shot_speed;
beam.shot_spread = time + 2;
beam.nextthink = time;
}
}
-void beam_think()
-{SELFPARAM();
+void beam_think(entity this)
+{
if ((time > self.cnt) || (IS_DEAD(self.owner)))
{
self.owner.attack_finished_single[0] = time + self.owner.shot_refire;
self.nextthink = time + self.ticrate;
self.owner.attack_finished_single[0] = time + frametime;
- setself(self.owner);
- FireImoBeam ( self.tur_shotorg,
+ FireImoBeam ( self.owner, self.tur_shotorg,
self.tur_shotorg + self.tur_shotdir_updated * self.target_range,
'-1 -1 -1' * self.shot_radius,
'1 1 1' * self.shot_radius,
this.shot_dmg,
0.75,
DEATH_TURRET_PHASER.m_id);
- setself(this);
self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;
}
#ifdef SVQC
-spawnfunc(turret_plasma) { if (!turret_initialize(TUR_PLASMA)) remove(self); }
+spawnfunc(turret_plasma) { if (!turret_initialize(TUR_PLASMA)) remove(this); }
METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this, entity it))
{
if(g_instagib)
{
- FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
+ FireRailgunBullet (self, self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
#ifdef SVQC
-spawnfunc(turret_plasma_dual) { if (!turret_initialize(TUR_PLASMA_DUAL)) remove(self); }
+spawnfunc(turret_plasma_dual) { if (!turret_initialize(TUR_PLASMA_DUAL)) remove(this); }
METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret thistur, entity it))
{
SELFPARAM();
if (g_instagib) {
- FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
+ FireRailgunBullet (self, self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
#ifdef SVQC
-spawnfunc(turret_tesla) { if (!turret_initialize(TUR_TESLA)) remove(self); }
+spawnfunc(turret_tesla) { if (!turret_initialize(TUR_TESLA)) remove(this); }
METHOD(TeslaCoil, tr_think, void(TeslaCoil thistur, entity it))
{
.float animflag;
.float idletime;
-#define WALKER_PATH(s,e) pathlib_astar(s,e)
+#define WALKER_PATH(this, s, e) pathlib_astar(this, s, e)
float walker_firecheck()
{SELFPARAM();
turrets_setframe(ANIM_NO, false);
self.animflag = self.frame;
}
-void walker_rocket_explode()
-{SELFPARAM();
+void walker_rocket_explode(entity this)
+{
RadiusDamage (self, self.owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius), self, world, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET.m_id, world);
remove (self);
}
}
#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)
-void walker_rocket_loop();
-void walker_rocket_think()
-{SELFPARAM();
+void walker_rocket_loop(entity this);
+void walker_rocket_think(entity this)
+{
vector newdir;
float edist;
float itime;
if (self.max_health < time)
{
- self.think = walker_rocket_explode;
+ setthink(self, walker_rocket_explode);
self.nextthink = time;
return;
}
if (self.shot_dmg != 1337 && random() < 0.01)
{
- walker_rocket_loop();
+ walker_rocket_loop(self);
return;
}
if (self.enemy)
{
itime = max(edist / m_speed, 1);
- newdir = steerlib_pull(self.enemy.origin + self.tur_shotorg);
+ newdir = steerlib_pull(self, self.enemy.origin + self.tur_shotorg);
}
else
newdir = normalize(self.velocity);
WALKER_ROCKET_MOVE;
}
-void walker_rocket_loop3()
-{SELFPARAM();
+void walker_rocket_loop3(entity this)
+{
vector newdir;
self.nextthink = time;
if (self.max_health < time)
{
- self.think = walker_rocket_explode;
+ setthink(self, walker_rocket_explode);
return;
}
if(vdist(self.origin - self.tur_shotorg, <, 100))
{
- self.think = walker_rocket_think;
+ setthink(self, walker_rocket_think);
return;
}
- newdir = steerlib_pull(self.tur_shotorg);
+ newdir = steerlib_pull(self, self.tur_shotorg);
WALKER_ROCKET_MOVE;
self.angles = vectoangles(self.velocity);
}
-void walker_rocket_loop2()
-{SELFPARAM();
+void walker_rocket_loop2(entity this)
+{
vector newdir;
self.nextthink = time;
if (self.max_health < time)
{
- self.think = walker_rocket_explode;
+ setthink(self, walker_rocket_explode);
return;
}
if(vdist(self.origin - self.tur_shotorg, <, 100))
{
self.tur_shotorg = self.origin - '0 0 200';
- self.think = walker_rocket_loop3;
+ setthink(self, walker_rocket_loop3);
return;
}
- newdir = steerlib_pull(self.tur_shotorg);
+ newdir = steerlib_pull(self, self.tur_shotorg);
WALKER_ROCKET_MOVE;
}
-void walker_rocket_loop()
-{SELFPARAM();
+void walker_rocket_loop(entity this)
+{
self.nextthink = time;
self.tur_shotorg = self.origin + '0 0 300';
- self.think = walker_rocket_loop2;
+ setthink(self, walker_rocket_loop2);
self.shot_dmg = 1337;
}
rocket.enemy = self.enemy;
if (random() < 0.01)
- rocket.think = walker_rocket_loop;
+ setthink(rocket, walker_rocket_loop);
else
- rocket.think = walker_rocket_think;
+ setthink(rocket, walker_rocket_think);
rocket.event_damage = walker_rocket_damage;
rocket.movetype = MOVETYPE_FLY;
rocket.velocity = normalize((v_forward + v_up * 0.5) + (randomvec() * 0.2)) * (autocvar_g_turrets_unit_walker_rocket_speed);
rocket.angles = vectoangles(rocket.velocity);
- rocket.touch = walker_rocket_explode;
+ settouch(rocket, walker_rocket_explode);
rocket.flags = FL_PROJECTILE;
rocket.solid = SOLID_BBOX;
rocket.max_health = time + 9;
if (self.pathgoal.enemy)
{
- self.pathcurrent = WALKER_PATH(self.pathgoal.origin,self.pathgoal.enemy.origin);
+ self.pathcurrent = WALKER_PATH(self, self.pathgoal.origin, self.pathgoal.enemy.origin);
self.pathgoal = self.pathgoal.enemy;
}
}
#endif
}
-spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(self); }
+spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(this); }
METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur, entity it))
{
else
{
#ifdef WALKER_FANCYPATHING
- it.pathcurrent = WALKER_PATH(it.origin, e.origin);
+ it.pathcurrent = WALKER_PATH(it, it.origin, e.origin);
it.pathgoal = e;
#else
it.pathcurrent = e;
/*
* Railgun-like beam, but has thickness and suppots slowing of target
*/
-void FireImoBeam (vector start, vector end, vector smin, vector smax,
+void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax,
float bforce, float f_dmg, float f_velfactor, int deathtype)
-{SELFPARAM();
+{
vector hitloc, force, endpoint, dir;
entity ent;
// note down which entities were hit so we can damage them later
while (1)
{
- tracebox(start, smin, smax, end, false, self);
+ tracebox(start, smin, smax, end, false, this);
// if it is world we can't hurt it so stop now
if (trace_ent == world || trace_fraction == 1)
// apply the damage
if (ent.takedamage)
{
- Damage (ent, self, self, f_dmg, deathtype, hitloc, force);
+ Damage (ent, this, this, f_dmg, deathtype, hitloc, force);
ent.velocity = ent.velocity * f_velfactor;
//ent.alpha = 0.25 + random() * 0.75;
}
if(self.cnt)
if(self.cnt < time)
{
- self.think = SUB_Remove;
+ setthink(self, SUB_Remove);
self.nextthink = time;
return;
}
setmodel(err, MDL_MARKER);
setorigin(err,where);
err.movetype = MOVETYPE_NONE;
- err.think = marker_think;
+ setthink(err, marker_think);
err.nextthink = time;
err.skin = 0;
if(lifetime)
setmodel(err, MDL_MARKER);
setorigin(err,where);
err.movetype = MOVETYPE_NONE;
- err.think = marker_think;
+ setthink(err, marker_think);
err.nextthink = time;
err.skin = 1;
if(lifetime)
setmodel(err, MDL_MARKER);
setorigin(err,where);
err.movetype = MOVETYPE_NONE;
- err.think = marker_think;
+ setthink(err, marker_think);
err.nextthink = time;
err.skin = 3;
if(lifetime)
vector shortangle_vxy(vector ang1, vector ang2);
vector angleofs(entity from, entity to);
vector angleofs3(vector from, vector from_a, entity to);
-void FireImoBeam (vector start, vector end, vector smin, vector smax, float bforce, float f_dmg, float f_velfactor, float deathtype);
+void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax, float bforce, float f_dmg, float f_velfactor, float deathtype);
#endif
#ifndef MENUQC
#ifndef CSQC
+entity _wordwrap_buffer_sprint_ent;
void wordwrap_buffer_sprint(string s)
-{SELFPARAM();
+{
wordwrap_buffer = strcat(wordwrap_buffer, s);
if(s == "\n")
{
- sprint(self, wordwrap_buffer);
+ sprint(_wordwrap_buffer_sprint_ent, wordwrap_buffer);
wordwrap_buffer = "";
}
}
-void wordwrap_sprint(string s, float l)
-{SELFPARAM();
+void wordwrap_sprint(entity to, string s, float l)
+{
wordwrap_buffer = "";
+ _wordwrap_buffer_sprint_ent = to;
wordwrap_cb(s, l, wordwrap_buffer_sprint);
+ _wordwrap_buffer_sprint_ent = NULL;
if(wordwrap_buffer != "")
- sprint(self, strcat(wordwrap_buffer, "\n"));
+ sprint(to, strcat(wordwrap_buffer, "\n"));
wordwrap_buffer = "";
return;
}
string wordwrap(string s, float l);
#ifndef MENUQC
#ifndef CSQC
-void wordwrap_sprint(string s, float l);
+void wordwrap_sprint(entity to, string s, float l);
#endif
#endif
void wordwrap_cb(string s, float l, void(string) callback);
// hud_id == 0 means we exited a vehicle, so stop alarm sound/s
if(hud_id == 0)
{
- sound(self, CH_TRIGGER_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
- sound(self, CH_PAIN_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
+ sound(this, CH_TRIGGER_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
+ sound(this, CH_PAIN_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
return;
}
{
this.takedamage = DAMAGE_NO;
this.event_damage = func_null;
- this.think = adaptor_think2use;
+ setthink(this, adaptor_think2use);
this.nextthink = time;
}
}
-void vehicles_projectile_explode()
-{SELFPARAM();
+void vehicles_projectile_explode(entity this)
+{
if(self.owner && other != world)
{
if(other == self.owner.vehicle)
return;
}
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
self.event_damage = func_null;
RadiusDamage (self, self.realowner, self.shot_dmg, 0, self.shot_radius, self, world, self.shot_force, self.totalfrags, other);
void vehicles_projectile_explode_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, vehicles_projectile_explode());
+ WITHSELF(this, vehicles_projectile_explode(this));
}
entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound,
proj.bot_dodge = true;
proj.bot_dodgerating = _dmg;
proj.velocity = _vel;
- proj.touch = vehicles_projectile_explode;
+ settouch(proj, vehicles_projectile_explode);
proj.use = vehicles_projectile_explode_use;
proj.owner = this;
proj.realowner = _owner;
- proj.think = SUB_Remove_self;
+ setthink(proj, SUB_Remove);
proj.nextthink = time + 30;
if(_health)
return proj;
}
-void vehicles_gib_explode()
-{SELFPARAM();
+void vehicles_gib_explode(entity this)
+{
sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
Send_Effect(EFFECT_EXPLOSION_SMALL, self.wp00.origin + '0 0 64', '0 0 0', 1);
remove(self);
}
-void vehicles_gib_think()
-{SELFPARAM();
+void vehicles_gib_think(entity this)
+{
self.alpha -= 0.1;
if(self.cnt >= time)
remove(self);
if(_explode)
{
- _gib.think = vehicles_gib_explode;
+ setthink(_gib, vehicles_gib_explode);
_gib.nextthink = time + random() * _explode;
- _gib.touch = vehicles_gib_explode;
+ settouch(_gib, vehicles_gib_explode);
}
else
{
_gib.cnt = time + _maxtime;
- _gib.think = vehicles_gib_think;
+ setthink(_gib, vehicles_gib_think);
_gib.nextthink = time + _maxtime - 1;
_gib.alpha = 1;
}
if(ret.wp00 == veh)
{
ret.classname = "";
- ret.think = SUB_Remove_self;
+ setthink(ret, SUB_Remove);
ret.nextthink = time + 0.1;
if(ret.waypointsprite_attached)
}
}
-void vehicles_spawn();
-void vehicles_return()
-{SELFPARAM();
+void vehicles_spawn(entity this);
+void vehicles_return(entity this)
+{
Send_Effect(EFFECT_TELEPORT, self.wp00.origin + '0 0 64', '0 0 0', 1);
- self.wp00.think = vehicles_spawn;
+ setthink(self.wp00, vehicles_spawn);
self.wp00.nextthink = time;
if(self.waypointsprite_attached)
remove(self);
}
-void vehicles_showwp_goaway()
-{SELFPARAM();
+void vehicles_showwp_goaway(entity this)
+{
if(self.waypointsprite_attached)
WaypointSprite_Kill(self.waypointsprite_attached);
}
-void vehicles_showwp()
-{SELFPARAM();
- entity oldself = world;
+void vehicles_showwp(entity this)
+{
vector rgb;
- if(self.cnt)
+ entity ent = this;
+
+ if(ent.cnt)
{
- self.think = vehicles_return;
- self.nextthink = self.cnt;
+ setthink(ent, vehicles_return);
+ ent.nextthink = ent.cnt;
}
else
{
- self.think = vehicles_return;
- self.nextthink = time +1;
-
- oldself = self;
- setself(spawn());
- setmodel(self, MDL_Null);
- self.team = oldself.wp00.team;
- self.wp00 = oldself.wp00;
- setorigin(self, oldself.wp00.pos1);
-
- self.nextthink = time + 5;
- self.think = vehicles_showwp_goaway;
+ setthink(ent, vehicles_return);
+ ent.nextthink = time + 1;
+
+ ent = spawn();
+ setmodel(ent, MDL_Null);
+ ent.team = this.wp00.team;
+ ent.wp00 = this.wp00;
+ setorigin(ent, this.wp00.pos1);
+
+ ent.nextthink = time + 5;
+ setthink(ent, vehicles_showwp_goaway);
}
- if(teamplay && self.team)
- rgb = Team_ColorRGB(self.team);
+ if(teamplay && ent.team)
+ rgb = Team_ColorRGB(ent.team);
else
rgb = '1 1 1';
- entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Vehicle);
+ entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, ent, '0 0 64', world, 0, ent, waypointsprite_attached, true, RADARICON_Vehicle);
wp.colormod = rgb;
- if(self.waypointsprite_attached)
+ if(ent.waypointsprite_attached)
{
- WaypointSprite_UpdateRule(self.waypointsprite_attached, self.wp00.team, SPRITERULE_DEFAULT);
+ WaypointSprite_UpdateRule(ent.waypointsprite_attached, ent.wp00.team, SPRITERULE_DEFAULT);
if(this == NULL)
- WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);
- WaypointSprite_Ping(self.waypointsprite_attached);
+ WaypointSprite_UpdateBuildFinished(ent.waypointsprite_attached, ent.nextthink);
+ WaypointSprite_Ping(ent.waypointsprite_attached);
}
-
- if(this)
- setself(this);
}
void vehicles_setreturn(entity veh)
ret = new(vehicle_return);
ret.wp00 = veh;
ret.team = veh.team;
- ret.think = vehicles_showwp;
+ setthink(ret, vehicles_showwp);
if(IS_DEAD(veh))
{
LOG_TRACE("Respawning vehicle: ", this.netname, "\n");
if(this.effects & EF_NODRAW)
{
- this.think = vehicles_spawn;
+ setthink(this, vehicles_spawn);
this.nextthink = time + 3;
}
else
}
}
-void shieldhit_think()
-{SELFPARAM();
+void shieldhit_think(entity this)
+{
self.alpha -= 0.1;
if (self.alpha <= 0)
{
setattachment(this.vehicle_shieldent, this, "");
setorigin(this.vehicle_shieldent, real_origin(this) - this.origin);
this.vehicle_shieldent.scale = 256 / vlen(this.maxs - this.mins);
- this.vehicle_shieldent.think = shieldhit_think;
+ setthink(this.vehicle_shieldent, shieldhit_think);
}
this.vehicle_shieldent.colormod = '1 1 1';
if (_vehicle.vehicle_flags & VHF_PLAYERSLOT)
{
_vehicle.vehicle_exit(eject);
- setself(this);
vehicles_exit_running = false;
return;
}
vehicles_exit_running = false;
}
-void vehicles_touch()
-{SELFPARAM();
+void vehicles_touch(entity this)
+{
if(MUTATOR_CALLHOOK(VehicleTouch, self, other))
return;
void vehicles_enter(entity pl, entity veh)
{
- SELFPARAM();
- entity oldself = self;
-
// Remove this when bots know how to use vehicles
if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots))
return;
MUTATOR_CALLHOOK(VehicleEnter, pl, veh);
- setself(veh);
CSQCModel_UnlinkEntity(veh);
Vehicle info = Vehicles_from(veh.vehicleid);
- info.vr_enter(info, veh);
- setself(oldself);
+ WITHSELF(veh, info.vr_enter(info, veh));
antilag_clear(pl, CS(pl));
}
-void vehicles_think()
-{SELFPARAM();
+void vehicles_think(entity this)
+{
self.nextthink = time;
if(self.owner)
}
// initialization
-void vehicles_spawn()
-{SELFPARAM();
+void vehicles_spawn(entity this)
+{
LOG_TRACE("Spawning vehicle: ", self.classname, "\n");
// disown & reset
self.vehicle_hudmodel.viewmodelforclient = self;
self.owner = world;
- self.touch = vehicles_touch;
+ settouch(self, vehicles_touch);
self.event_damage = vehicles_damage;
self.iscreature = true;
self.teleportable = false; // no teleporting for vehicles, too buggy
self.flags = FL_NOTARGET;
self.avelocity = '0 0 0';
self.velocity = '0 0 0';
- self.think = vehicles_think;
+ setthink(self, vehicles_think);
self.nextthink = time;
// Reset locking
this.vehicleid = info.vehicleid;
this.PlayerPhysplug = info.PlayerPhysplug;
this.event_damage = func_null;
- this.touch = vehicles_touch;
- this.think = vehicles_spawn;
+ settouch(this, vehicles_touch);
+ setthink(this, vehicles_spawn);
this.nextthink = time;
this.effects = EF_NODRAW;
this.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID;
return true;
}
-void bumblebee_touch()
-{SELFPARAM();
+void bumblebee_touch(entity this)
+{
if(autocvar_g_vehicles_enter) { return; }
if(self.gunner1 != world && self.gunner2 != world)
{
- vehicles_touch();
+ vehicles_touch(self);
return;
}
return;
}
- vehicles_touch();
+ vehicles_touch(self);
}
void bumblebee_regen(entity this)
PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
}
-void bumblebee_land()
-{SELFPARAM();
+void bumblebee_land(entity this)
+{
float hgt;
hgt = raptor_altitude(512);
self.angles_z *= 0.95;
if(hgt < 16)
- self.think = vehicles_think;
+ setthink(self, vehicles_think);
self.nextthink = time;
return;
}
- self.touch = vehicles_touch;
+ settouch(self, vehicles_touch);
if(!IS_DEAD(self))
{
- self.think = bumblebee_land;
+ setthink(self, bumblebee_land);
self.nextthink = time;
}
self.owner = world;
}
-void bumblebee_blowup()
-{SELFPARAM();
+void bumblebee_blowup(entity this)
+{
RadiusDamage(self, self.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
autocvar_g_vehicle_bumblebee_blowup_edgedamage,
autocvar_g_vehicle_bumblebee_blowup_radius, self, world,
remove(self);
}
-void bumblebee_diethink()
-{SELFPARAM();
+void bumblebee_diethink(entity this)
+{
if(time >= self.wait)
- self.think = bumblebee_blowup;
+ setthink(self, bumblebee_blowup);
if(random() < 0.1)
{
METHOD(Bumblebee, vr_enter, void(Bumblebee thisveh, entity instance))
{
SELFPARAM();
- self.touch = bumblebee_touch;
+ settouch(self, bumblebee_touch);
self.nextthink = 0;
self.movetype = MOVETYPE_BOUNCEMISSILE;
}
if(!self.owner)
{
- entity oldself = self;
if(self.gunner1)
{
- setself(self.gunner1);
- oldself.gun1.vehicle_exit(VHEF_EJECT);
- entity oldother = other;
- other = self;
- setself(oldself);
- self.phase = 0;
- self.touch();
- other = oldother;
- return;
+ entity e = self.gunner1;
+ WITHSELF(e, self.gun1.vehicle_exit(VHEF_EJECT));
+ entity oldother = other;
+ other = e;
+ self.phase = 0;
+ gettouch(self)(self);
+ other = oldother;
+ return;
}
if(self.gunner2)
{
- setself(self.gunner2);
- oldself.gun2.vehicle_exit(VHEF_EJECT);
- entity oldother = other;
- other = self;
- setself(oldself);
- self.phase = 0;
- self.touch();
- other = oldother;
+ entity e = self.gunner2;
+ WITHSELF(e, self.gun2.vehicle_exit(VHEF_EJECT));
+ entity oldother = other;
+ other = e;
+ self.phase = 0;
+ gettouch(self)(self);
+ other = oldother;
return;
}
}
}
METHOD(Bumblebee, vr_death, void(Bumblebee thisveh, entity instance))
{
- SELFPARAM();
- entity oldself = self;
- setself(instance);
+ CSQCModel_UnlinkEntity(instance);
- CSQCModel_UnlinkEntity(self);
+ // hide beam
+ if(instance.gun3.enemy || !wasfreed(instance.gun3.enemy))
+ instance.gun3.enemy.effects |= EF_NODRAW;
- // Hide beam
- if(self.gun3.enemy || !wasfreed(self.gun3.enemy))
- self.gun3.enemy.effects |= EF_NODRAW;
+ if(instance.gunner1)
+ WITHSELF(instance.gunner1, instance.gun1.vehicle_exit(VHEF_EJECT));
- if(self.gunner1)
- {
- setself(self.gunner1);
- oldself.gun1.vehicle_exit(VHEF_EJECT);
- setself(oldself);
- }
-
- if(self.gunner2)
- {
- setself(self.gunner2);
- oldself.gun2.vehicle_exit(VHEF_EJECT);
- setself(oldself);
- }
+ if(instance.gunner2)
+ WITHSELF(instance.gunner2, instance.gun2.vehicle_exit(VHEF_EJECT));
- self.vehicle_exit(VHEF_EJECT);
+ WITHSELF(instance, instance.vehicle_exit(VHEF_EJECT));
- fixedmakevectors(self.angles);
- vehicle_tossgib(instance, self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
- vehicle_tossgib(instance, self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
- vehicle_tossgib(instance, self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
+ fixedmakevectors(instance.angles);
+ vehicle_tossgib(instance, instance.gun1, instance.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
+ vehicle_tossgib(instance, instance.gun2, instance.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
+ vehicle_tossgib(instance, instance.gun3, instance.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
- entity _body = vehicle_tossgib(instance, self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
+ entity _body = vehicle_tossgib(instance, instance, instance.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
if(random() > 0.5)
- _body.touch = bumblebee_blowup;
+ settouch(_body, bumblebee_blowup);
else
- _body.touch = func_null;
+ settouch(_body, func_null);
- _body.think = bumblebee_diethink;
+ setthink(_body, bumblebee_diethink);
_body.nextthink = time;
_body.wait = time + 2 + (random() * 8);
- _body.owner = self;
- _body.enemy = self.enemy;
+ _body.owner = instance;
+ _body.enemy = instance.enemy;
_body.scale = 1.5;
- _body.angles = self.angles;
-
- Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(self.origin, 16), '0 0 0', 1);
-
- self.health = 0;
- self.event_damage = func_null;
- self.solid = SOLID_NOT;
- self.takedamage = DAMAGE_NO;
- self.deadflag = DEAD_DYING;
- self.movetype = MOVETYPE_NONE;
- self.effects = EF_NODRAW;
- self.colormod = '0 0 0';
- self.avelocity = '0 0 0';
- self.velocity = '0 0 0';
- self.touch = func_null;
- self.nextthink = 0;
-
- setorigin(self, self.pos1);
-
- setself(oldself);
+ _body.angles = instance.angles;
+
+ Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(instance.origin, 16), '0 0 0', 1);
+
+ instance.health = 0;
+ instance.event_damage = func_null;
+ instance.solid = SOLID_NOT;
+ instance.takedamage = DAMAGE_NO;
+ instance.deadflag = DEAD_DYING;
+ instance.movetype = MOVETYPE_NONE;
+ instance.effects = EF_NODRAW;
+ instance.colormod = '0 0 0';
+ instance.avelocity = '0 0 0';
+ instance.velocity = '0 0 0';
+ settouch(instance, func_null);
+ instance.nextthink = 0;
+
+ setorigin(instance, instance.pos1);
}
METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh, entity instance))
{
setattachment(self.vehicle_shieldent, self, "");
setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
self.vehicle_shieldent.scale = 512 / vlen(self.maxs - self.mins);
- self.vehicle_shieldent.think = shieldhit_think;
+ setthink(self.vehicle_shieldent, shieldhit_think);
self.vehicle_shieldent.alpha = -1;
self.vehicle_shieldent.effects = EF_LOWPRECISION | EF_NODRAW;
if(sf & BRG_SETUP)
{
- self.cnt = ReadByte();
- self.team = ReadByte();
- self.cnt = ReadByte();
+ this.cnt = ReadByte();
+ this.team = ReadByte();
+ this.cnt = ReadByte();
- if(self.cnt)
- self.colormod = '1 0 0';
+ if(this.cnt)
+ this.colormod = '1 0 0';
else
- self.colormod = '0 1 0';
+ this.colormod = '0 1 0';
- self.traileffect = EFFECT_BUMBLEBEE_HEAL_MUZZLEFLASH.m_id;
- self.lip = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_IMPACT);
+ this.traileffect = EFFECT_BUMBLEBEE_HEAL_MUZZLEFLASH.m_id;
+ this.lip = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_IMPACT);
- self.draw = bumble_raygun_draw;
+ this.draw = bumble_raygun_draw;
}
if(sf & BRG_START)
{
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- setorigin(self, self.origin);
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+ setorigin(this, this.origin);
}
if(sf & BRG_END)
{
- self.move_origin_x = ReadCoord();
- self.move_origin_y = ReadCoord();
- self.move_origin_z = ReadCoord();
+ this.move_origin_x = ReadCoord();
+ this.move_origin_y = ReadCoord();
+ this.move_origin_z = ReadCoord();
}
return true;
}
this.movement = vehic.velocity += df * PHYS_INPUT_TIMELENGTH;
#ifdef SVQC
- setself(vehic);
Weapon wep1 = WEP_RACER;
if (!forbidWeaponUse(this))
if (PHYS_INPUT_BUTTON_ATCK(this))
- if (wep1.wr_checkammo1(wep1))
+ if (wep1.wr_checkammo1(wep1, vehic))
{
string tagname = (vehic.cnt)
? (vehic.cnt = 0, "tag_fire1")
crosshair_trace(this);
w_shotdir.z = normalize(trace_endpos - org).z * 0.5;
.entity weaponentity = weaponentities[0];
- wep1.wr_think(wep1, vehic, weaponentity, 1);
+ WITHSELF(vehic, wep1.wr_think(wep1, vehic, weaponentity, 1));
}
- setself(this);
-
if(autocvar_g_vehicle_racer_rocket_locktarget)
{
if(vehic.vehicle_last_trace == time + autocvar_g_vehicle_racer_thinkrate)
this.velocity = vehic.velocity;
}
-void racer_think()
-{SELFPARAM();
+void racer_think(entity this)
+{
this.nextthink = time + autocvar_g_vehicle_racer_thinkrate;
tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * autocvar_g_vehicle_racer_springlength), MOVE_NOMONSTERS, this);
{SELFPARAM();
vector spot;
- self.think = racer_think;
+ setthink(self, racer_think);
self.nextthink = time;
self.movetype = MOVETYPE_BOUNCE;
sound (self.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
DEATH_VH_WAKI_DEATH.m_id, world);
self.nextthink = time + autocvar_g_vehicle_racer_respawntime;
- self.think = vehicles_spawn;
+ setthink(self, vehicles_spawn);
self.movetype = MOVETYPE_NONE;
self.effects = EF_NODRAW;
self.solid = SOLID_NOT;
setorigin(self, self.pos1);
}
-void racer_blowup_think()
-{SELFPARAM();
+void racer_blowup_think(entity this)
+{
self.nextthink = time;
if(time >= self.delay)
CSQCMODEL_AUTOUPDATE(self);
}
-void racer_deadtouch()
-{SELFPARAM();
+void racer_deadtouch(entity this)
+{
self.avelocity_x *= 0.7;
self.cnt -= 1;
if(self.cnt <= 0)
self.mass = 900;
}
- self.think = racer_think;
+ setthink(self, racer_think);
self.nextthink = time;
self.vehicle_health = autocvar_g_vehicle_racer_health;
self.vehicle_shield = autocvar_g_vehicle_racer_shield;
instance.wait = time;
instance.delay = 2 + time + random() * 3;
instance.cnt = 1 + random() * 2;
- instance.touch = racer_deadtouch;
+ settouch(instance, racer_deadtouch);
Send_Effect(EFFECT_EXPLOSION_MEDIUM, instance.origin, '0 0 0', 1);
instance.velocity += '0 0 700';
instance.colormod = '-0.5 -0.5 -0.5';
- instance.think = racer_blowup_think;
+ setthink(instance, racer_blowup_think);
instance.nextthink = time;
#endif
}
}
}
-METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep))
+METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep, entity actor))
{
- SELFPARAM();
- bool isPlayer = IS_PLAYER(self);
- entity player = isPlayer ? self : self.owner;
+ bool isPlayer = IS_PLAYER(actor);
+ entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
return isPlayer || veh.vehicle_energy >= autocvar_g_vehicle_racer_cannon_cost;
}
-void racer_rocket_tracker();
-void racer_rocket_groundhugger();
+void racer_rocket_tracker(entity this);
+void racer_rocket_groundhugger(entity this);
void racer_fire_rocket(entity player, vector org, vector dir, entity trg)
{
rocket.cnt = time + 15;
if(trg)
- rocket.think = racer_rocket_tracker;
+ setthink(rocket, racer_rocket_tracker);
else
- rocket.think = racer_rocket_groundhugger;
+ setthink(rocket, racer_rocket_groundhugger);
}
-void racer_rocket_tracker()
-{SELFPARAM();
+void racer_rocket_tracker(entity this)
+{
vector olddir, newdir;
float oldvel, newvel;
{
//bprint("Target lost!\n");
//dprint("OF:", ftos(vlen(newdir - v_forward)), "\n");
- self.think = racer_rocket_groundhugger;
+ setthink(self, racer_rocket_groundhugger);
return;
}
return;
}
-void racer_rocket_groundhugger()
-{SELFPARAM();
+void racer_rocket_groundhugger(entity this)
+{
vector olddir, newdir;
float oldvel, newvel;
return vlen(self.origin - trace_endpos);
}
-void raptor_land()
-{SELFPARAM();
+void raptor_land(entity this)
+{
float hgt;
hgt = raptor_altitude(512);
if(hgt < 16)
{
self.movetype = MOVETYPE_TOSS;
- self.think = vehicles_think;
+ setthink(self, vehicles_think);
self.frame = 0;
}
if(!IS_DEAD(self))
{
- self.think = raptor_land;
+ setthink(self, raptor_land);
self.nextthink = time;
}
UpdateAuxiliaryXhair(this, trace_endpos, '0 1 0', 0);
*/
- // TODO: fix wr_checkammo and its use of self!
setself(vehic);
Weapon wep1 = WEP_RAPTOR;
if(!forbidWeaponUse(this))
if(PHYS_INPUT_BUTTON_ATCK(this))
- if (wep1.wr_checkammo1(wep1))
+ if (wep1.wr_checkammo1(wep1, vehic))
{
.entity weaponentity = weaponentities[0];
wep1.wr_think(wep1, vehic, weaponentity, 1);
PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
}
-void raptor_blowup()
-{SELFPARAM();
+void raptor_blowup(entity this)
+{
self.deadflag = DEAD_DEAD;
self.vehicle_exit(VHEF_NORMAL);
RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_RAPT_DEATH.m_id, world);
self.velocity = '0 0 0';
setorigin(self, self.pos1);
- self.touch = func_null;
+ settouch(self, func_null);
self.nextthink = 0;
}
-void raptor_diethink()
-{SELFPARAM();
+void raptor_diethink(entity this)
+{
if(time >= self.wait)
- self.think = raptor_blowup;
+ setthink(self, raptor_blowup);
if(random() < 0.05)
{
// If we dont do this ever now and then, the raptors rotors
// stop working, presumably due to angle overflow. cute.
-void raptor_rotor_anglefix()
-{SELFPARAM();
+void raptor_rotor_anglefix(entity this)
+{
self.gun1.angles_y = anglemods(self.gun1.angles_y);
self.gun2.angles_y = anglemods(self.gun2.angles_y);
self.nextthink = time + 15;
instance.takedamage = DAMAGE_NO;
instance.deadflag = DEAD_DYING;
instance.movetype = MOVETYPE_BOUNCE;
- instance.think = raptor_diethink;
+ setthink(instance, raptor_diethink);
instance.nextthink = time;
instance.wait = time + 5 + (random() * 5);
instance.avelocity -= '0 0.5 1' * (random() * 400);
instance.colormod = '-0.5 -0.5 -0.5';
- instance.touch = raptor_blowup;
+ settouch(instance, raptor_blowup);
}
METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
{
self.bomb1.gun2 = spinner;
// Sigh.
- self.bomb1.think = raptor_rotor_anglefix;
+ setthink(self.bomb1, raptor_rotor_anglefix);
self.bomb1.nextthink = time;
self.mass = 1 ;
weapon_thinkf(player, weaponentity, WFRAME_FIRE1, 0, w_ready);
}
}
-METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep)) {
- SELFPARAM();
- bool isPlayer = IS_PLAYER(self);
- entity player = isPlayer ? self : self.owner;
+METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep, entity actor)) {
+ bool isPlayer = IS_PLAYER(actor);
+ entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
return isPlayer || veh.vehicle_energy >= autocvar_g_vehicle_raptor_cannon_cost;
}
entity veh = player.vehicle;
if (fire & 2)
if (!isPlayer || weapon_prepareattack(thiswep, player, weaponentity, true, autocvar_g_vehicle_raptor_bombs_refire)) {
- if (veh) setself(veh);
- raptor_bombdrop();
+ entity e = (veh) ? veh : player;
+ WITHSELF(e, raptor_bombdrop());
weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready);
}
}
-void raptor_flare_think();
+void raptor_flare_think(entity this);
void raptor_flare_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force);
-void raptor_flare_touch();
+void raptor_flare_touch(entity this);
METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
bool isPlayer = IS_PLAYER(actor);
_flare.movetype = MOVETYPE_TOSS;
_flare.gravity = 0.15;
_flare.velocity = 0.25 * actor.velocity + (v_forward + randomvec() * 0.25)* -500;
- _flare.think = raptor_flare_think;
+ setthink(_flare, raptor_flare_think);
_flare.nextthink = time;
_flare.owner = veh ? veh : player;
_flare.solid = SOLID_CORPSE;
_flare.event_damage = raptor_flare_damage;
_flare.health = 20;
_flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime;
- _flare.touch = raptor_flare_touch;
+ settouch(_flare, raptor_flare_touch);
}
weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready);
}
}
-void raptor_bomblet_boom()
-{SELFPARAM();
+void raptor_bomblet_boom(entity this)
+{
RadiusDamage (self, self.realowner, autocvar_g_vehicle_raptor_bomblet_damage,
autocvar_g_vehicle_raptor_bomblet_edgedamage,
autocvar_g_vehicle_raptor_bomblet_radius, world, world,
remove(self);
}
-void raptor_bomblet_touch()
-{SELFPARAM();
+void raptor_bomblet_touch(entity this)
+{
if(other == self.owner)
return;
- PROJECTILE_TOUCH;
- self.think = raptor_bomblet_boom;
+ PROJECTILE_TOUCH(this);
+ setthink(self, raptor_bomblet_boom);
self.nextthink = time + random() * autocvar_g_vehicle_raptor_bomblet_explode_delay;
}
-void raptor_bomb_burst()
-{SELFPARAM();
+void raptor_bomb_burst(entity this)
+{
if(self.cnt > time)
if(autocvar_g_vehicle_raptor_bomblet_alt)
{
setorigin(bomblet, self.origin);
bomblet.movetype = MOVETYPE_TOSS;
- bomblet.touch = raptor_bomblet_touch;
- bomblet.think = raptor_bomblet_boom;
+ settouch(bomblet, raptor_bomblet_touch);
+ setthink(bomblet, raptor_bomblet_boom);
bomblet.nextthink = time + 5;
bomblet.owner = self.owner;
bomblet.realowner = self.realowner;
bomb_1.movetype = bomb_2.movetype = MOVETYPE_BOUNCE;
bomb_1.velocity = bomb_2.velocity = self.velocity;
- bomb_1.touch = bomb_2.touch = raptor_bomb_burst;
- bomb_1.think = bomb_2.think = raptor_bomb_burst;
+ settouch(bomb_1, raptor_bomb_burst);
+ settouch(bomb_2, raptor_bomb_burst);
+ setthink(bomb_1, raptor_bomb_burst);
+ setthink(bomb_2, raptor_bomb_burst);
bomb_1.cnt = bomb_2.cnt = time + 10;
if(autocvar_g_vehicle_raptor_bomblet_alt)
CSQCProjectile(bomb_2, true, PROJECTILE_RAPTORBOMB, true);
}
-void raptor_flare_touch()
-{SELFPARAM();
+void raptor_flare_touch(entity this)
+{
remove(self);
}
remove(this);
}
-void raptor_flare_think()
-{SELFPARAM();
+void raptor_flare_think(entity this)
+{
self.nextthink = time + 0.1;
entity _missile = findchainentity(enemy, self.owner);
while(_missile)
e = e.chain;
}
- self.think = vehicles_think;
+ setthink(self, vehicles_think);
self.nextthink = time;
self.frame = 5;
self.movetype = MOVETYPE_WALK;
self.owner = world;
}
-void spiderbot_headfade()
-{SELFPARAM();
- self.think = spiderbot_headfade;
+void spiderbot_headfade(entity this)
+{
+ setthink(self, spiderbot_headfade);
self.nextthink = self.fade_time;
self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
}
}
-void spiderbot_blowup()
-{SELFPARAM();
+void spiderbot_blowup(entity this)
+{
if(self.cnt > time)
{
if(random() < 0.1)
h.cnt = time + (3.5 * random());
h.fade_rate = 1 / min(self.respawntime, 10);
h.fade_time = time;
- h.think = spiderbot_headfade;
+ setthink(h, spiderbot_headfade);
h.nextthink = time;
org = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01"));
instance.health = 0;
instance.event_damage = func_null;
instance.takedamage = DAMAGE_NO;
- instance.touch = func_null;
+ settouch(instance, func_null);
instance.cnt = 3.4 + time + random() * 2;
- instance.think = spiderbot_blowup;
+ setthink(instance, spiderbot_blowup);
instance.nextthink = time;
instance.deadflag = DEAD_DYING;
instance.frame = 5;
UpdateCSQCProjectile(self);
}
-void spiderbot_rocket_unguided()
-{SELFPARAM();
+void spiderbot_rocket_unguided(entity this)
+{
vector newdir, olddir;
self.nextthink = time;
self.use(self, NULL, NULL);
}
-void spiderbot_rocket_guided()
-{SELFPARAM();
+void spiderbot_rocket_guided(entity this)
+{
vector newdir, olddir;
self.nextthink = time;
if(!self.realowner.vehicle)
- self.think = spiderbot_rocket_unguided;
+ setthink(self, spiderbot_rocket_unguided);
crosshair_trace(self.realowner);
olddir = normalize(self.velocity);
crosshair_trace(this.owner);
while(rkt)
{
- if(rkt.think == spiderbot_rocket_guided)
+ if(getthink(rkt) == spiderbot_rocket_guided)
{
rkt.pos1 = trace_endpos;
- rkt.think = spiderbot_rocket_unguided;
+ setthink(rkt, spiderbot_rocket_unguided);
}
rkt = rkt.chain;
}
float _dist = (random() * autocvar_g_vehicle_spiderbot_rocket_radius) + vlen(v - trace_endpos);
_dist -= (random() * autocvar_g_vehicle_spiderbot_rocket_radius) ;
rocket.nextthink = time + (_dist / autocvar_g_vehicle_spiderbot_rocket_speed);
- rocket.think = vehicles_projectile_explode;
+ setthink(rocket, vehicles_projectile_explode);
if(PHYS_INPUT_BUTTON_ATCK2(this.owner) && this.tur_head.frame == 1)
this.wait = -10;
crosshair_trace(this.owner);
rocket.pos1 = trace_endpos;
rocket.nextthink = time;
- rocket.think = spiderbot_rocket_guided;
+ setthink(rocket, spiderbot_rocket_guided);
break;
if (f) f(it, chan);
});
}
-void W_PROP_think()
+void W_PROP_think(entity this)
{
W_PROP_reload(MSG_ALL, NULL);
}
STATIC_INIT_LATE(W_PROP_reloader)
{
- SELFPARAM();
entity e = W_PROP_reloader = new_pure(W_PROP_reloader);
- WITHSELF(e, (e.think = W_PROP_think)());
+ WITHSELF(e, (setthink(e, W_PROP_think))(e));
}
#endif
ATTRIB(Weapon, m_pickup, entity, NULL);
/** (SERVER) setup weapon data */
- METHOD(Weapon, wr_setup, void(Weapon this)) {}
+ METHOD(Weapon, wr_setup, void(Weapon this, entity actor)) {}
/** (SERVER) logic to run every frame */
METHOD(Weapon, wr_think, void(Weapon this, entity actor, .entity weaponentity, int fire)) {}
/** (SERVER) checks ammo for weapon primary */
- METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;}
+ METHOD(Weapon, wr_checkammo1, bool(Weapon this, entity actor)) {return false;}
/** (SERVER) checks ammo for weapon second */
- METHOD(Weapon, wr_checkammo2, bool(Weapon this)) {return false;}
+ METHOD(Weapon, wr_checkammo2, bool(Weapon this, entity actor)) {return false;}
/** (SERVER) runs bot aiming code for this weapon */
- METHOD(Weapon, wr_aim, void(Weapon this)) {}
+ METHOD(Weapon, wr_aim, void(Weapon this, entity actor)) {}
/** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
METHOD(Weapon, wr_init, void(Weapon this)) {}
/** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
/** (SERVER) handles reloading for weapon */
METHOD(Weapon, wr_reload, void(Weapon this, entity actor, .entity weaponentity)) {}
/** (SERVER) clears fields that the weapon may use */
- METHOD(Weapon, wr_resetplayer, void(Weapon this)) {}
+ METHOD(Weapon, wr_resetplayer, void(Weapon this, entity actor)) {}
/** (CLIENT) impact effect for weapon explosion */
- METHOD(Weapon, wr_impacteffect, void(Weapon this)) {}
+ METHOD(Weapon, wr_impacteffect, void(Weapon this, entity actor)) {}
/** (SERVER) called whenever a player dies */
- METHOD(Weapon, wr_playerdeath, void(Weapon this)) {}
+ METHOD(Weapon, wr_playerdeath, void(Weapon this, entity actor)) {}
/** (SERVER) logic to run when weapon is lost */
- METHOD(Weapon, wr_gonethink, void(Weapon this)) {}
+ METHOD(Weapon, wr_gonethink, void(Weapon this, entity actor)) {}
/** (ALL) dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
METHOD(Weapon, wr_config, void(Weapon this)) {}
/** (CLIENT) weapon specific zoom reticle */
/** (CLIENT) weapon specific glow */
METHOD(Weapon, wr_glow, vector(Weapon this)) { return '0 0 0'; }
/** (SERVER) the weapon is dropped */
- METHOD(Weapon, wr_drop, void(Weapon this)) {}
+ METHOD(Weapon, wr_drop, void(Weapon this, entity actor)) {}
/** (SERVER) a weapon is picked up */
- METHOD(Weapon, wr_pickup, void(Weapon this)) {}
+ METHOD(Weapon, wr_pickup, void(Weapon this, entity actor)) {}
/** (SERVER) update cvar based properties */
METHOD(Weapon, wr_update, void(Weapon this)) {}
METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
//dprint("Heat: ",ftos(player.arc_heat_percent*100),"%\n");
}
-void W_Arc_Bolt_Explode()
-{SELFPARAM();
+void W_Arc_Bolt_Explode(entity this)
+{
self.event_damage = func_null;
RadiusDamage(self, self.realowner, WEP_CVAR(arc, bolt_damage), WEP_CVAR(arc, bolt_edgedamage), WEP_CVAR(arc, bolt_radius), world, world, WEP_CVAR(arc, bolt_force), self.projectiledeathtype, other);
void W_Arc_Bolt_Explode_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_Arc_Bolt_Explode());
+ WITHSELF(this, W_Arc_Bolt_Explode(this));
}
void W_Arc_Bolt_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
this.angles = vectoangles(this.velocity);
if(this.health <= 0)
- W_PrepareExplosionByDamage(this, attacker, this.think);
+ W_PrepareExplosionByDamage(this, attacker, getthink(this));
}
-void W_Arc_Bolt_Touch()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_Arc_Bolt_Touch(entity this)
+{
+ PROJECTILE_TOUCH(this);
self.use(this, NULL, NULL);
}
-void W_Arc_Attack_Bolt(Weapon thiswep)
-{SELFPARAM();
+void W_Arc_Attack_Bolt(Weapon thiswep, entity actor)
+{
+ entity this = actor;
entity missile;
W_DecreaseAmmo(thiswep, self, WEP_CVAR(arc, bolt_ammo));
missile.event_damage = W_Arc_Bolt_Damage;
missile.damagedbycontents = true;
- missile.touch = W_Arc_Bolt_Touch;
+ settouch(missile, W_Arc_Bolt_Touch);
missile.use = W_Arc_Bolt_Explode_use;
- missile.think = adaptor_think2use_hittype_splash;
+ setthink(missile, adaptor_think2use_hittype_splash);
missile.nextthink = time + WEP_CVAR(arc, bolt_lifetime);
PROJECTILE_MAKETRIGGER(missile);
missile.projectiledeathtype = WEP_ARC.m_id | HITTYPE_SECONDARY;
MUTATOR_CALLHOOK(EditProjectile, self, missile);
}
-void W_Arc_Beam_Think()
-{SELFPARAM();
+void W_Arc_Beam_Think(entity this)
+{
if(self != self.owner.arc_beam)
{
remove(self);
}
if(self == self.owner.arc_beam) { self.owner.arc_beam = world; }
- setself(self.owner);
+ entity own = self.owner;
Weapon w = WEP_ARC;
- if(!w.wr_checkammo1(w) && !w.wr_checkammo2(w))
- if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
+ if(!w.wr_checkammo1(w, own) && !w.wr_checkammo2(w, own))
+ if(!(own.items & IT_UNLIMITED_WEAPON_AMMO))
{
// note: this doesn't force the switch
- W_SwitchToOtherWeapon(self);
+ W_SwitchToOtherWeapon(own);
}
- setself(this);
remove(self);
return;
}
self.nextthink = time;
}
-void W_Arc_Beam(float burst)
-{SELFPARAM();
+void W_Arc_Beam(float burst, entity actor)
+{entity this = actor;
// only play fire sound if 1 sec has passed since player let go the fire button
if(time - self.beam_prev > 1)
entity beam = self.arc_beam = new(W_Arc_Beam);
beam.solid = SOLID_NOT;
- beam.think = W_Arc_Beam_Think;
+ setthink(beam, W_Arc_Beam_Think);
beam.owner = self;
beam.movetype = MOVETYPE_NONE;
beam.bot_dodge = true;
beam.beam_bursting = burst;
Net_LinkEntity(beam, false, 0, W_Arc_Beam_Send);
- WITHSELF(beam, beam.think());
+ WITHSELF(beam, getthink(beam)(beam));
}
-
-void Arc_Smoke()
-{SELFPARAM();
+void Arc_Smoke(entity actor)
+{entity this = actor;
makevectors(self.v_angle);
W_SetupShot_Range(self,true,0,SND_Null,0,0,0);
}
}
-METHOD(Arc, wr_aim, void(entity thiswep))
+METHOD(Arc, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(WEP_CVAR(arc, beam_botaimspeed))
{
PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(
METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
Arc_Player_SetHeat(actor);
- Arc_Smoke();
+ Arc_Smoke(actor);
bool beam_fire2 = ((fire & 2) && !WEP_CVAR(arc, bolt));
{
if(weapon_prepareattack(thiswep, actor, weaponentity, boolean(beam_fire2), 0))
{
- W_Arc_Beam(boolean(beam_fire2));
+ W_Arc_Beam(boolean(beam_fire2), actor);
if(!actor.arc_BUTTON_ATCK_prev)
{
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(arc, bolt_refire)))
{
- W_Arc_Attack_Bolt(thiswep);
+ W_Arc_Attack_Bolt(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, bolt_refire), w_ready);
}
}
arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 4);
}
}
-METHOD(Arc, wr_checkammo1, bool(entity thiswep))
+METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- return ((!WEP_CVAR(arc, beam_ammo)) || (self.(thiswep.ammo_field) > 0));
+ return ((!WEP_CVAR(arc, beam_ammo)) || (actor.(thiswep.ammo_field) > 0));
}
-METHOD(Arc, wr_checkammo2, bool(entity thiswep))
+METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
if(WEP_CVAR(arc, bolt))
{
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(arc, bolt_ammo);
- ammo_amount += self.(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(arc, bolt_ammo);
+ ammo_amount += actor.(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo);
return ammo_amount;
}
else
return WEP_CVAR(arc, overheat_max) > 0 &&
- ((!WEP_CVAR(arc, burst_ammo)) || (self.(thiswep.ammo_field) > 0));
+ ((!WEP_CVAR(arc, burst_ammo)) || (actor.(thiswep.ammo_field) > 0));
}
METHOD(Arc, wr_killmessage, Notification(entity thiswep))
{
else
return WEAPON_ARC_MURDER;
}
-METHOD(Arc, wr_drop, void(entity thiswep))
+METHOD(Arc, wr_drop, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
weapon_dropevent_item.arc_overheat = self.arc_overheat;
weapon_dropevent_item.arc_cooldown = self.arc_cooldown;
self.arc_overheat = 0;
self.arc_cooldown = 0;
}
-METHOD(Arc, wr_pickup, void(entity thiswep))
+METHOD(Arc, wr_pickup, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if ( !client_hasweapon(self, thiswep, false, false) &&
weapon_dropevent_item.arc_overheat > time )
{
#ifdef CSQC
bool autocvar_cl_arcbeam_teamcolor = true;
-METHOD(Arc, wr_impacteffect, void(entity thiswep))
+METHOD(Arc, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(w_deathtype & HITTYPE_SECONDARY)
{
vector org2;
{
int gunalign = W_GetGunAlignment(world);
- self.beam_shotorigin = arc_shotorigin[gunalign];
+ this.beam_shotorigin = arc_shotorigin[gunalign];
// set other main attributes of the beam
- self.draw = Draw_ArcBeam;
- self.entremove = Remove_ArcBeam;
- self.move_time = time;
- loopsound(self, CH_SHOTS_SINGLE, SND(ARC_LOOP), VOL_BASE, ATTEN_NORM);
+ this.draw = Draw_ArcBeam;
+ this.entremove = Remove_ArcBeam;
+ this.move_time = time;
+ loopsound(this, CH_SHOTS_SINGLE, SND(ARC_LOOP), VOL_BASE, ATTEN_NORM);
flash = spawn();
- flash.owner = self;
+ flash.owner = this;
flash.effects = EF_ADDITIVE | EF_FULLBRIGHT;
flash.drawmask = MASK_NORMAL;
flash.solid = SOLID_NOT;
flash.avelocity_z = 5000;
- setattachment(flash, self, "");
+ setattachment(flash, this, "");
setorigin(flash, '0 0 0');
- self.beam_muzzleentity = flash;
+ this.beam_muzzleentity = flash;
}
else
{
- flash = self.beam_muzzleentity;
+ flash = this.beam_muzzleentity;
}
if(sf & ARC_SF_SETTINGS) // settings information
{
- self.beam_degreespersegment = ReadShort();
- self.beam_distancepersegment = ReadShort();
- self.beam_maxangle = ReadShort();
- self.beam_range = ReadCoord();
- self.beam_returnspeed = ReadShort();
- self.beam_tightness = (ReadByte() / 10);
+ this.beam_degreespersegment = ReadShort();
+ this.beam_distancepersegment = ReadShort();
+ this.beam_maxangle = ReadShort();
+ this.beam_range = ReadCoord();
+ this.beam_returnspeed = ReadShort();
+ this.beam_tightness = (ReadByte() / 10);
if(ReadByte())
{
if(autocvar_chase_active)
- { self.beam_usevieworigin = 1; }
+ { this.beam_usevieworigin = 1; }
else // use view origin
- { self.beam_usevieworigin = 2; }
+ { this.beam_usevieworigin = 2; }
}
else
{
- self.beam_usevieworigin = 0;
+ this.beam_usevieworigin = 0;
}
- self.sv_entnum = ReadByte();
+ this.sv_entnum = ReadByte();
}
- if(!self.beam_usevieworigin)
+ if(!this.beam_usevieworigin)
{
- // self.iflags = IFLAG_ORIGIN | IFLAG_ANGLES | IFLAG_V_ANGLE; // why doesn't this work?
- self.iflags = IFLAG_ORIGIN;
+ // this.iflags = IFLAG_ORIGIN | IFLAG_ANGLES | IFLAG_V_ANGLE; // why doesn't this work?
+ this.iflags = IFLAG_ORIGIN;
- InterpolateOrigin_Undo(self);
+ InterpolateOrigin_Undo(this);
}
if(sf & ARC_SF_START) // starting location
{
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
}
- else if(self.beam_usevieworigin) // infer the location from player location
+ else if(this.beam_usevieworigin) // infer the location from player location
{
- if(self.beam_usevieworigin == 2)
+ if(this.beam_usevieworigin == 2)
{
// use view origin
- self.origin = view_origin;
+ this.origin = view_origin;
}
else
{
// use player origin so that third person display still works
- self.origin = entcs_receiver(player_localnum).origin + ('0 0 1' * STAT(VIEWHEIGHT));
+ this.origin = entcs_receiver(player_localnum).origin + ('0 0 1' * STAT(VIEWHEIGHT));
}
}
- setorigin(self, self.origin);
+ setorigin(this, this.origin);
if(sf & ARC_SF_WANTDIR) // want/aim direction
{
- self.v_angle_x = ReadCoord();
- self.v_angle_y = ReadCoord();
- self.v_angle_z = ReadCoord();
+ this.v_angle_x = ReadCoord();
+ this.v_angle_y = ReadCoord();
+ this.v_angle_z = ReadCoord();
}
if(sf & ARC_SF_BEAMDIR) // beam direction
{
- self.angles_x = ReadCoord();
- self.angles_y = ReadCoord();
- self.angles_z = ReadCoord();
+ this.angles_x = ReadCoord();
+ this.angles_y = ReadCoord();
+ this.angles_z = ReadCoord();
}
if(sf & ARC_SF_BEAMTYPE) // beam type
{
- self.beam_type = ReadByte();
+ this.beam_type = ReadByte();
- vector beamcolor = ((autocvar_cl_arcbeam_teamcolor) ? colormapPaletteColor(stof(getplayerkeyvalue(self.sv_entnum - 1, "colors")) & 0x0F, true) : '1 1 1');
- switch(self.beam_type)
+ vector beamcolor = ((autocvar_cl_arcbeam_teamcolor) ? colormapPaletteColor(stof(getplayerkeyvalue(this.sv_entnum - 1, "colors")) & 0x0F, true) : '1 1 1');
+ switch(this.beam_type)
{
case ARC_BT_MISS:
{
- self.beam_color = beamcolor;
- self.beam_alpha = 0.5;
- self.beam_thickness = 8;
- self.beam_traileffect = (EFFECT_ARC_BEAM);
- self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
- self.beam_hitlight[0] = 0;
- self.beam_hitlight[1] = 1;
- self.beam_hitlight[2] = 1;
- self.beam_hitlight[3] = 1;
- self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
- self.beam_muzzlelight[0] = 0;
- self.beam_muzzlelight[1] = 1;
- self.beam_muzzlelight[2] = 1;
- self.beam_muzzlelight[3] = 1;
- if(self.beam_muzzleeffect)
+ this.beam_color = beamcolor;
+ this.beam_alpha = 0.5;
+ this.beam_thickness = 8;
+ this.beam_traileffect = (EFFECT_ARC_BEAM);
+ this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+ this.beam_hitlight[0] = 0;
+ this.beam_hitlight[1] = 1;
+ this.beam_hitlight[2] = 1;
+ this.beam_hitlight[3] = 1;
+ this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+ this.beam_muzzlelight[0] = 0;
+ this.beam_muzzlelight[1] = 1;
+ this.beam_muzzlelight[2] = 1;
+ this.beam_muzzlelight[3] = 1;
+ if(this.beam_muzzleeffect)
{
setmodel(flash, MDL_ARC_MUZZLEFLASH);
- flash.alpha = self.beam_alpha;
- flash.colormod = self.beam_color;
+ flash.alpha = this.beam_alpha;
+ flash.colormod = this.beam_color;
flash.scale = 0.5;
}
break;
}
case ARC_BT_WALL: // grenadelauncher_muzzleflash healray_muzzleflash
{
- self.beam_color = beamcolor;
- self.beam_alpha = 0.5;
- self.beam_thickness = 8;
- self.beam_traileffect = (EFFECT_ARC_BEAM);
- self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
- self.beam_hitlight[0] = 0;
- self.beam_hitlight[1] = 1;
- self.beam_hitlight[2] = 1;
- self.beam_hitlight[3] = 1;
- self.beam_muzzleeffect = NULL; // (EFFECT_GRENADE_MUZZLEFLASH);
- self.beam_muzzlelight[0] = 0;
- self.beam_muzzlelight[1] = 1;
- self.beam_muzzlelight[2] = 1;
- self.beam_muzzlelight[3] = 1;
- self.beam_image = "particles/lgbeam";
- if(self.beam_muzzleeffect)
+ this.beam_color = beamcolor;
+ this.beam_alpha = 0.5;
+ this.beam_thickness = 8;
+ this.beam_traileffect = (EFFECT_ARC_BEAM);
+ this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+ this.beam_hitlight[0] = 0;
+ this.beam_hitlight[1] = 1;
+ this.beam_hitlight[2] = 1;
+ this.beam_hitlight[3] = 1;
+ this.beam_muzzleeffect = NULL; // (EFFECT_GRENADE_MUZZLEFLASH);
+ this.beam_muzzlelight[0] = 0;
+ this.beam_muzzlelight[1] = 1;
+ this.beam_muzzlelight[2] = 1;
+ this.beam_muzzlelight[3] = 1;
+ this.beam_image = "particles/lgbeam";
+ if(this.beam_muzzleeffect)
{
setmodel(flash, MDL_ARC_MUZZLEFLASH);
- flash.alpha = self.beam_alpha;
- flash.colormod = self.beam_color;
+ flash.alpha = this.beam_alpha;
+ flash.colormod = this.beam_color;
flash.scale = 0.5;
}
break;
}
case ARC_BT_HEAL:
{
- self.beam_color = beamcolor;
- self.beam_alpha = 0.5;
- self.beam_thickness = 8;
- self.beam_traileffect = (EFFECT_ARC_BEAM_HEAL);
- self.beam_hiteffect = (EFFECT_ARC_BEAM_HEAL_IMPACT);
- self.beam_hitlight[0] = 0;
- self.beam_hitlight[1] = 1;
- self.beam_hitlight[2] = 1;
- self.beam_hitlight[3] = 1;
- self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
- self.beam_muzzlelight[0] = 0;
- self.beam_muzzlelight[1] = 1;
- self.beam_muzzlelight[2] = 1;
- self.beam_muzzlelight[3] = 1;
- self.beam_image = "particles/lgbeam";
- if(self.beam_muzzleeffect)
+ this.beam_color = beamcolor;
+ this.beam_alpha = 0.5;
+ this.beam_thickness = 8;
+ this.beam_traileffect = (EFFECT_ARC_BEAM_HEAL);
+ this.beam_hiteffect = (EFFECT_ARC_BEAM_HEAL_IMPACT);
+ this.beam_hitlight[0] = 0;
+ this.beam_hitlight[1] = 1;
+ this.beam_hitlight[2] = 1;
+ this.beam_hitlight[3] = 1;
+ this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+ this.beam_muzzlelight[0] = 0;
+ this.beam_muzzlelight[1] = 1;
+ this.beam_muzzlelight[2] = 1;
+ this.beam_muzzlelight[3] = 1;
+ this.beam_image = "particles/lgbeam";
+ if(this.beam_muzzleeffect)
{
setmodel(flash, MDL_ARC_MUZZLEFLASH);
- flash.alpha = self.beam_alpha;
- flash.colormod = self.beam_color;
+ flash.alpha = this.beam_alpha;
+ flash.colormod = this.beam_color;
flash.scale = 0.5;
}
break;
}
case ARC_BT_HIT:
{
- self.beam_color = beamcolor;
- self.beam_alpha = 0.5;
- self.beam_thickness = 8;
- self.beam_traileffect = (EFFECT_ARC_BEAM);
- self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
- self.beam_hitlight[0] = 20;
- self.beam_hitlight[1] = 1;
- self.beam_hitlight[2] = 0;
- self.beam_hitlight[3] = 0;
- self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
- self.beam_muzzlelight[0] = 50;
- self.beam_muzzlelight[1] = 1;
- self.beam_muzzlelight[2] = 0;
- self.beam_muzzlelight[3] = 0;
- self.beam_image = "particles/lgbeam";
- if(self.beam_muzzleeffect)
+ this.beam_color = beamcolor;
+ this.beam_alpha = 0.5;
+ this.beam_thickness = 8;
+ this.beam_traileffect = (EFFECT_ARC_BEAM);
+ this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+ this.beam_hitlight[0] = 20;
+ this.beam_hitlight[1] = 1;
+ this.beam_hitlight[2] = 0;
+ this.beam_hitlight[3] = 0;
+ this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+ this.beam_muzzlelight[0] = 50;
+ this.beam_muzzlelight[1] = 1;
+ this.beam_muzzlelight[2] = 0;
+ this.beam_muzzlelight[3] = 0;
+ this.beam_image = "particles/lgbeam";
+ if(this.beam_muzzleeffect)
{
setmodel(flash, MDL_ARC_MUZZLEFLASH);
- flash.alpha = self.beam_alpha;
- flash.colormod = self.beam_color;
+ flash.alpha = this.beam_alpha;
+ flash.colormod = this.beam_color;
flash.scale = 0.5;
}
break;
}
case ARC_BT_BURST_MISS:
{
- self.beam_color = beamcolor;
- self.beam_alpha = 0.5;
- self.beam_thickness = 14;
- self.beam_traileffect = (EFFECT_ARC_BEAM);
- self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
- self.beam_hitlight[0] = 0;
- self.beam_hitlight[1] = 1;
- self.beam_hitlight[2] = 1;
- self.beam_hitlight[3] = 1;
- self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
- self.beam_muzzlelight[0] = 0;
- self.beam_muzzlelight[1] = 1;
- self.beam_muzzlelight[2] = 1;
- self.beam_muzzlelight[3] = 1;
- self.beam_image = "particles/lgbeam";
- if(self.beam_muzzleeffect)
+ this.beam_color = beamcolor;
+ this.beam_alpha = 0.5;
+ this.beam_thickness = 14;
+ this.beam_traileffect = (EFFECT_ARC_BEAM);
+ this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+ this.beam_hitlight[0] = 0;
+ this.beam_hitlight[1] = 1;
+ this.beam_hitlight[2] = 1;
+ this.beam_hitlight[3] = 1;
+ this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+ this.beam_muzzlelight[0] = 0;
+ this.beam_muzzlelight[1] = 1;
+ this.beam_muzzlelight[2] = 1;
+ this.beam_muzzlelight[3] = 1;
+ this.beam_image = "particles/lgbeam";
+ if(this.beam_muzzleeffect)
{
setmodel(flash, MDL_ARC_MUZZLEFLASH);
- flash.alpha = self.beam_alpha;
- flash.colormod = self.beam_color;
+ flash.alpha = this.beam_alpha;
+ flash.colormod = this.beam_color;
flash.scale = 0.5;
}
break;
}
case ARC_BT_BURST_WALL:
{
- self.beam_color = beamcolor;
- self.beam_alpha = 0.5;
- self.beam_thickness = 14;
- self.beam_traileffect = (EFFECT_ARC_BEAM);
- self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
- self.beam_hitlight[0] = 0;
- self.beam_hitlight[1] = 1;
- self.beam_hitlight[2] = 1;
- self.beam_hitlight[3] = 1;
- self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
- self.beam_muzzlelight[0] = 0;
- self.beam_muzzlelight[1] = 1;
- self.beam_muzzlelight[2] = 1;
- self.beam_muzzlelight[3] = 1;
- self.beam_image = "particles/lgbeam";
- if(self.beam_muzzleeffect)
+ this.beam_color = beamcolor;
+ this.beam_alpha = 0.5;
+ this.beam_thickness = 14;
+ this.beam_traileffect = (EFFECT_ARC_BEAM);
+ this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+ this.beam_hitlight[0] = 0;
+ this.beam_hitlight[1] = 1;
+ this.beam_hitlight[2] = 1;
+ this.beam_hitlight[3] = 1;
+ this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+ this.beam_muzzlelight[0] = 0;
+ this.beam_muzzlelight[1] = 1;
+ this.beam_muzzlelight[2] = 1;
+ this.beam_muzzlelight[3] = 1;
+ this.beam_image = "particles/lgbeam";
+ if(this.beam_muzzleeffect)
{
setmodel(flash, MDL_ARC_MUZZLEFLASH);
- flash.alpha = self.beam_alpha;
- flash.colormod = self.beam_color;
+ flash.alpha = this.beam_alpha;
+ flash.colormod = this.beam_color;
flash.scale = 0.5;
}
break;
}
case ARC_BT_BURST_HEAL:
{
- self.beam_color = beamcolor;
- self.beam_alpha = 0.5;
- self.beam_thickness = 14;
- self.beam_traileffect = (EFFECT_ARC_BEAM_HEAL);
- self.beam_hiteffect = (EFFECT_ARC_BEAM_HEAL_IMPACT2);
- self.beam_hitlight[0] = 0;
- self.beam_hitlight[1] = 1;
- self.beam_hitlight[2] = 1;
- self.beam_hitlight[3] = 1;
- self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
- self.beam_muzzlelight[0] = 0;
- self.beam_muzzlelight[1] = 1;
- self.beam_muzzlelight[2] = 1;
- self.beam_muzzlelight[3] = 1;
- self.beam_image = "particles/lgbeam";
- if(self.beam_muzzleeffect)
+ this.beam_color = beamcolor;
+ this.beam_alpha = 0.5;
+ this.beam_thickness = 14;
+ this.beam_traileffect = (EFFECT_ARC_BEAM_HEAL);
+ this.beam_hiteffect = (EFFECT_ARC_BEAM_HEAL_IMPACT2);
+ this.beam_hitlight[0] = 0;
+ this.beam_hitlight[1] = 1;
+ this.beam_hitlight[2] = 1;
+ this.beam_hitlight[3] = 1;
+ this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+ this.beam_muzzlelight[0] = 0;
+ this.beam_muzzlelight[1] = 1;
+ this.beam_muzzlelight[2] = 1;
+ this.beam_muzzlelight[3] = 1;
+ this.beam_image = "particles/lgbeam";
+ if(this.beam_muzzleeffect)
{
setmodel(flash, MDL_ARC_MUZZLEFLASH);
- flash.alpha = self.beam_alpha;
- flash.colormod = self.beam_color;
+ flash.alpha = this.beam_alpha;
+ flash.colormod = this.beam_color;
flash.scale = 0.5;
}
break;
}
case ARC_BT_BURST_HIT:
{
- self.beam_color = beamcolor;
- self.beam_alpha = 0.5;
- self.beam_thickness = 14;
- self.beam_traileffect = (EFFECT_ARC_BEAM);
- self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
- self.beam_hitlight[0] = 0;
- self.beam_hitlight[1] = 1;
- self.beam_hitlight[2] = 1;
- self.beam_hitlight[3] = 1;
- self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
- self.beam_muzzlelight[0] = 0;
- self.beam_muzzlelight[1] = 1;
- self.beam_muzzlelight[2] = 1;
- self.beam_muzzlelight[3] = 1;
- self.beam_image = "particles/lgbeam";
- if(self.beam_muzzleeffect)
+ this.beam_color = beamcolor;
+ this.beam_alpha = 0.5;
+ this.beam_thickness = 14;
+ this.beam_traileffect = (EFFECT_ARC_BEAM);
+ this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+ this.beam_hitlight[0] = 0;
+ this.beam_hitlight[1] = 1;
+ this.beam_hitlight[2] = 1;
+ this.beam_hitlight[3] = 1;
+ this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+ this.beam_muzzlelight[0] = 0;
+ this.beam_muzzlelight[1] = 1;
+ this.beam_muzzlelight[2] = 1;
+ this.beam_muzzlelight[3] = 1;
+ this.beam_image = "particles/lgbeam";
+ if(this.beam_muzzleeffect)
{
setmodel(flash, MDL_ARC_MUZZLEFLASH);
- flash.alpha = self.beam_alpha;
- flash.colormod = self.beam_color;
+ flash.alpha = this.beam_alpha;
+ flash.colormod = this.beam_color;
flash.scale = 0.5;
}
break;
// shouldn't be possible, but lets make it colorful if it does :D
default:
{
- self.beam_color = randomvec();
- self.beam_alpha = 1;
- self.beam_thickness = 8;
- self.beam_traileffect = NULL;
- self.beam_hiteffect = NULL;
- self.beam_hitlight[0] = 0;
- self.beam_hitlight[1] = 1;
- self.beam_hitlight[2] = 1;
- self.beam_hitlight[3] = 1;
- self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
- self.beam_muzzlelight[0] = 0;
- self.beam_muzzlelight[1] = 1;
- self.beam_muzzlelight[2] = 1;
- self.beam_muzzlelight[3] = 1;
- self.beam_image = "particles/lgbeam";
- if(self.beam_muzzleeffect)
+ this.beam_color = randomvec();
+ this.beam_alpha = 1;
+ this.beam_thickness = 8;
+ this.beam_traileffect = NULL;
+ this.beam_hiteffect = NULL;
+ this.beam_hitlight[0] = 0;
+ this.beam_hitlight[1] = 1;
+ this.beam_hitlight[2] = 1;
+ this.beam_hitlight[3] = 1;
+ this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+ this.beam_muzzlelight[0] = 0;
+ this.beam_muzzlelight[1] = 1;
+ this.beam_muzzlelight[2] = 1;
+ this.beam_muzzlelight[3] = 1;
+ this.beam_image = "particles/lgbeam";
+ if(this.beam_muzzleeffect)
{
setmodel(flash, MDL_ARC_MUZZLEFLASH);
- flash.alpha = self.beam_alpha;
- flash.colormod = self.beam_color;
+ flash.alpha = this.beam_alpha;
+ flash.colormod = this.beam_color;
flash.scale = 0.5;
}
break;
}
}
- if(!self.beam_usevieworigin)
+ if(!this.beam_usevieworigin)
{
InterpolateOrigin_Note(this);
}
spawnfunc(weapon_blaster) { weapon_defaultspawnfunc(this, WEP_BLASTER); }
spawnfunc(weapon_laser) { spawnfunc_weapon_blaster(this); }
-void W_Blaster_Touch()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_Blaster_Touch(entity this)
+{
+ PROJECTILE_TOUCH(this);
self.event_damage = func_null;
remove(self);
}
-void W_Blaster_Think()
-{SELFPARAM();
+void W_Blaster_Think(entity this)
+{
this.movetype = MOVETYPE_FLY;
- this.think = SUB_Remove_self;
+ setthink(this, SUB_Remove);
this.nextthink = time + this.blaster_lifetime;
CSQCProjectile(this, true, PROJECTILE_BLASTER, true);
}
float atk_spread,
float atk_delay,
float atk_lifetime)
-{SELFPARAM();
+{
vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD);
W_SetupShot_Dir(actor, s_forward, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, atk_damage);
//missile.glow_color = 250; // 244, 250
//missile.glow_size = 120;
- missile.touch = W_Blaster_Touch;
+ settouch(missile, W_Blaster_Touch);
missile.flags = FL_PROJECTILE;
missile.missile_flags = MIF_SPLASH;
missile.projectiledeathtype = atk_deathtype;
- missile.think = W_Blaster_Think;
+ setthink(missile, W_Blaster_Think);
missile.nextthink = time + atk_delay;
MUTATOR_CALLHOOK(EditProjectile, actor, missile);
if (time >= missile.nextthink)
{
- WITHSELF(missile, missile.think());
+ WITHSELF(missile, getthink(missile)(missile));
}
}
-METHOD(Blaster, wr_aim, void(entity thiswep))
+METHOD(Blaster, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(WEP_CVAR(blaster, secondary))
{
if((random() * (WEP_CVAR_PRI(blaster, damage) + WEP_CVAR_SEC(blaster, damage))) > WEP_CVAR_PRI(blaster, damage))
}
}
-METHOD(Blaster, wr_setup, void(entity thiswep))
+METHOD(Blaster, wr_setup, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.ammo_field = ammo_none;
}
-METHOD(Blaster, wr_checkammo1, bool(entity thiswep))
+METHOD(Blaster, wr_checkammo1, bool(entity thiswep, entity actor))
{
return true; // infinite ammo
}
-METHOD(Blaster, wr_checkammo2, bool(entity thiswep))
+METHOD(Blaster, wr_checkammo2, bool(entity thiswep, entity actor))
{
return true; // blaster has infinite ammo
}
#endif
#ifdef CSQC
-METHOD(Blaster, wr_impacteffect, void(entity thiswep))
+METHOD(Blaster, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 6;
pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
return targ_origin;
}
-void W_Crylink_LinkJoinEffect_Think()
-{SELFPARAM();
+void W_Crylink_LinkJoinEffect_Think(entity this)
+{
// is there at least 2 projectiles very close?
entity e, p;
float n;
}
// NO bounce protection, as bounces are limited!
-void W_Crylink_Touch()
-{SELFPARAM();
+void W_Crylink_Touch(entity this)
+{
float finalhit;
float f;
float isprimary = !(self.projectiledeathtype & HITTYPE_SECONDARY);
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
float a;
a = bound(0, 1 - (time - self.fade_time) * self.fade_rate, 1);
// CSQCProjectile(proj, true, PROJECTILE_CRYLINK, true);
}
-void W_Crylink_Fadethink()
-{SELFPARAM();
+void W_Crylink_Fadethink(entity this)
+{
W_Crylink_Dequeue(self);
remove(self);
}
-void W_Crylink_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Crylink_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
float counter, shots;
entity proj, prevproj, firstproj;
vector s;
}
s = s * WEP_CVAR_PRI(crylink, spread) * g_weaponspreadfactor;
W_SetupProjVelocity_Explicit(proj, w_shotdir + right * s.y + up * s.z, v_up, WEP_CVAR_PRI(crylink, speed), 0, 0, 0, false);
- proj.touch = W_Crylink_Touch;
+ settouch(proj, W_Crylink_Touch);
- proj.think = W_Crylink_Fadethink;
+ setthink(proj, W_Crylink_Fadethink);
if(counter == 0)
{
proj.fade_time = time + WEP_CVAR_PRI(crylink, middle_lifetime);
}
}
-void W_Crylink_Attack2(Weapon thiswep)
-{SELFPARAM();
+void W_Crylink_Attack2(Weapon thiswep, entity actor)
+{entity this = actor;
float counter, shots;
entity proj, prevproj, firstproj;
vector s;
}
W_SetupProjVelocity_Explicit(proj, s, v_up, WEP_CVAR_SEC(crylink, speed), 0, 0, 0, false);
- proj.touch = W_Crylink_Touch;
- proj.think = W_Crylink_Fadethink;
+ settouch(proj, W_Crylink_Touch);
+ setthink(proj, W_Crylink_Fadethink);
if(counter == (shots - 1) / 2)
{
proj.fade_time = time + WEP_CVAR_SEC(crylink, middle_lifetime);
}
}
-METHOD(Crylink, wr_aim, void(entity thiswep))
+METHOD(Crylink, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(random() < 0.10)
PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false);
else
if(actor.crylink_waitrelease != 1)
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(crylink, refire)))
{
- W_Crylink_Attack(thiswep);
+ W_Crylink_Attack(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready);
}
}
if(actor.crylink_waitrelease != 2)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(crylink, refire)))
{
- W_Crylink_Attack2(thiswep);
+ W_Crylink_Attack2(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready);
}
}
pos = W_Crylink_LinkJoin(actor.crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed));
linkjoineffect = new(linkjoineffect);
- linkjoineffect.think = W_Crylink_LinkJoinEffect_Think;
+ setthink(linkjoineffect, W_Crylink_LinkJoinEffect_Think);
linkjoineffect.nextthink = time + w_crylink_linkjoin_time;
linkjoineffect.owner = actor;
setorigin(linkjoineffect, pos);
}
actor.crylink_waitrelease = 0;
- if(!thiswep.wr_checkammo1(thiswep) && !thiswep.wr_checkammo2(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor) && !thiswep.wr_checkammo2(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
// ran out of ammo!
}
}
}
-METHOD(Crylink, wr_checkammo1, bool(entity thiswep))
+METHOD(Crylink, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
// don't "run out of ammo" and switch weapons while waiting for release
- if(self.crylink_lastgroup && self.crylink_waitrelease)
+ if(actor.crylink_lastgroup && actor.crylink_waitrelease)
return true;
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo);
- ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo);
+ ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
return ammo_amount;
}
-METHOD(Crylink, wr_checkammo2, bool(entity thiswep))
+METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
// don't "run out of ammo" and switch weapons while waiting for release
- if(self.crylink_lastgroup && self.crylink_waitrelease)
+ if(actor.crylink_lastgroup && actor.crylink_waitrelease)
return true;
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo);
- ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo);
+ ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo);
return ammo_amount;
}
METHOD(Crylink, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND_RELOAD);
+ W_Reload(actor, min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND_RELOAD);
}
METHOD(Crylink, wr_suicidemessage, Notification(entity thiswep))
{
}
#endif
#ifdef CSQC
-METHOD(Crylink, wr_impacteffect, void(entity thiswep))
+METHOD(Crylink, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 2;
if(w_deathtype & HITTYPE_SECONDARY)
.entity lastrocket;
-void W_Devastator_Unregister()
-{SELFPARAM();
+void W_Devastator_Unregister(entity this)
+{
if(self.realowner && self.realowner.lastrocket == self)
{
self.realowner.lastrocket = world;
}
}
-void W_Devastator_Explode()
-{SELFPARAM();
- W_Devastator_Unregister();
+void W_Devastator_Explode(entity this)
+{
+ W_Devastator_Unregister(self);
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
remove(self);
}
-void W_Devastator_DoRemoteExplode(.entity weaponentity)
-{SELFPARAM();
- W_Devastator_Unregister();
+void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity)
+{
+ W_Devastator_Unregister(self);
self.event_damage = func_null;
self.takedamage = DAMAGE_NO;
remove(self);
}
-void W_Devastator_RemoteExplode(.entity weaponentity)
-{SELFPARAM();
+void W_Devastator_RemoteExplode(entity this, .entity weaponentity)
+{
if(!IS_DEAD(self.realowner))
if(self.realowner.lastrocket)
{
: (vdist(NearestPointOnBox(self.realowner, self.origin) - self.origin, >, WEP_CVAR(devastator, remote_radius))) // safety device
)
{
- W_Devastator_DoRemoteExplode(weaponentity);
+ W_Devastator_DoRemoteExplode(self, weaponentity);
}
}
}
// normalize(thisdir + goaldir)
// normalize(0)
-void W_Devastator_Think()
-{SELFPARAM();
+void W_Devastator_Think(entity this)
+{
vector desireddir, olddir, newdir, desiredorigin, goal;
float velspeed, f;
self.nextthink = time;
{
other = world;
self.projectiledeathtype |= HITTYPE_BOUNCE;
- W_Devastator_Explode();
+ W_Devastator_Explode(self);
return;
}
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
if(self.rl_detonate_later)
- W_Devastator_RemoteExplode(weaponentity);
+ W_Devastator_RemoteExplode(self, weaponentity);
}
if(self.csqcprojectile_clientanimate == 0)
UpdateCSQCProjectile(self);
}
-void W_Devastator_Touch()
-{SELFPARAM();
- if(WarpZone_Projectile_Touch())
+void W_Devastator_Touch(entity this)
+{
+ if(WarpZone_Projectile_Touch(this))
{
- if(wasfreed(self))
- W_Devastator_Unregister();
+ if(wasfreed(this))
+ W_Devastator_Unregister(this);
return;
}
- W_Devastator_Unregister();
- W_Devastator_Explode();
+ W_Devastator_Unregister(this);
+ W_Devastator_Explode(this);
}
void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode);
}
-void W_Devastator_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Devastator_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
entity missile;
entity flash;
W_SetupProjVelocity_Basic(missile, WEP_CVAR(devastator, speedstart), 0);
missile.angles = vectoangles(missile.velocity);
- missile.touch = W_Devastator_Touch;
- missile.think = W_Devastator_Think;
+ settouch(missile, W_Devastator_Touch);
+ setthink(missile, W_Devastator_Think);
missile.nextthink = time;
missile.cnt = time + WEP_CVAR(devastator, lifetime);
missile.flags = FL_PROJECTILE;
}
#if 0
-METHOD(Devastator, wr_aim, void(entity thiswep))
+METHOD(Devastator, wr_aim, void(entity thiswep, entity actor))
{
+ entity this = actor;
// aim and decide to fire if appropriate
PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
if(skill >= 2) // skill 0 and 1 bots won't detonate rockets!
}
}
#else
-METHOD(Devastator, wr_aim, void(entity thiswep))
+METHOD(Devastator, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
// aim and decide to fire if appropriate
PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
if(skill >= 2) // skill 0 and 1 bots won't detonate rockets!
if(actor.rl_release || WEP_CVAR(devastator, guidestop))
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire)))
{
- W_Devastator_Attack(thiswep);
+ W_Devastator_Attack(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
actor.rl_release = 0;
}
}
}
}
-METHOD(Devastator, wr_setup, void(entity thiswep))
+METHOD(Devastator, wr_setup, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.rl_release = 1;
}
-METHOD(Devastator, wr_checkammo1, bool(entity thiswep))
+METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
#if 0
// don't switch while guiding a missile
- if(ATTACK_FINISHED(self, slot) <= time || PS(self).m_weapon != WEP_DEVASTATOR)
+ if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_DEVASTATOR)
{
ammo_amount = false;
if(WEP_CVAR(devastator, reload_ammo))
{
- if(self.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && self.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
+ if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && actor.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
ammo_amount = true;
}
- else if(self.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
+ else if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
ammo_amount = true;
return !ammo_amount;
}
#endif
#if 0
- if(self.rl_release == 0)
+ if(actor.rl_release == 0)
{
- LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE\n", self.rl_release, self.(thiswep.ammo_field), WEP_CVAR(devastator, ammo));
+ LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo));
return true;
}
else
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
- ammo_amount += self.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
- LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", self.rl_release, self.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
+ ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
+ LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
return ammo_amount;
}
#else
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
- ammo_amount += self.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
+ ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
return ammo_amount;
#endif
}
-METHOD(Devastator, wr_checkammo2, bool(entity thiswep))
+METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor))
{
return false;
}
-METHOD(Devastator, wr_resetplayer, void(entity thiswep))
+METHOD(Devastator, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.lastrocket = NULL; // stop rocket guiding, no revenge from the grave!
self.rl_release = 0;
}
METHOD(Devastator, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, WEP_CVAR(devastator, ammo), SND_RELOAD);
+ W_Reload(actor, WEP_CVAR(devastator, ammo), SND_RELOAD);
}
METHOD(Devastator, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(Devastator, wr_impacteffect, void(entity thiswep))
+METHOD(Devastator, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 12;
pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
#ifdef SVQC
.float electro_count;
.float electro_secondarytime;
-void W_Electro_ExplodeCombo();
+void W_Electro_ExplodeCombo(entity this);
#endif
#endif
#ifdef IMPLEMENTATION
e.classname = "electro_orb_chain";
// now set the next one to trigger as well
- e.think = W_Electro_ExplodeCombo;
+ setthink(e, W_Electro_ExplodeCombo);
// delay combo chains, looks cooler
e.nextthink =
}
}
-void W_Electro_ExplodeCombo()
-{SELFPARAM();
+void W_Electro_ExplodeCombo(entity this)
+{
W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
self.event_damage = func_null;
remove(self);
}
-void W_Electro_Explode()
-{SELFPARAM();
+void W_Electro_Explode(entity this)
+{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
if(DIFF_TEAM(self.realowner, other))
void W_Electro_Explode_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_Electro_Explode());
+ WITHSELF(this, W_Electro_Explode(this));
}
-void W_Electro_TouchExplode()
+void W_Electro_TouchExplode(entity this)
{
- PROJECTILE_TOUCH;
- W_Electro_Explode();
+ PROJECTILE_TOUCH(this);
+ W_Electro_Explode(this);
}
-void W_Electro_Bolt_Think()
-{SELFPARAM();
+void W_Electro_Bolt_Think(entity this)
+{
if(time >= self.ltime)
{
this.use(this, NULL, NULL);
e.classname = "electro_orb_chain";
// now set the next one to trigger as well
- e.think = W_Electro_ExplodeCombo;
+ setthink(e, W_Electro_ExplodeCombo);
// delay combo chains, looks cooler
e.nextthink =
else { self.nextthink = self.ltime; }
}
-void W_Electro_Attack_Bolt(Weapon thiswep)
-{SELFPARAM();
+void W_Electro_Attack_Bolt(Weapon thiswep, entity actor)
+{entity this = actor;
entity proj;
W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(electro, ammo));
proj.bot_dodge = true;
proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
proj.use = W_Electro_Explode_use;
- proj.think = W_Electro_Bolt_Think;
+ setthink(proj, W_Electro_Bolt_Think);
proj.nextthink = time;
proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
PROJECTILE_MAKETRIGGER(proj);
proj.movetype = MOVETYPE_FLY;
W_SetupProjVelocity_PRI(proj, electro);
proj.angles = vectoangles(proj.velocity);
- proj.touch = W_Electro_TouchExplode;
+ settouch(proj, W_Electro_TouchExplode);
setsize(proj, '0 0 -3', '0 0 -3');
proj.flags = FL_PROJECTILE;
proj.missile_flags = MIF_SPLASH;
MUTATOR_CALLHOOK(EditProjectile, self, proj);
}
-void W_Electro_Orb_Touch()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_Electro_Orb_Touch(entity this)
+{
+ PROJECTILE_TOUCH(this);
if(other.takedamage == DAMAGE_AIM)
- { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
+ { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(self); } }
else
{
//UpdateCSQCProjectile(self);
// change owner to whoever caused the combo explosion
this.realowner = inflictor.realowner;
this.classname = "electro_orb_chain";
- this.think = W_Electro_ExplodeCombo;
+ setthink(this, W_Electro_ExplodeCombo);
this.nextthink = time +
(
// bound the length, inflictor may be in a galaxy far far away (warpzones)
else
{
this.use = W_Electro_Explode_use;
- this.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
+ setthink(this, adaptor_think2use); // not _hittype_splash, as this runs "immediately"
}
}
}
-void W_Electro_Attack_Orb(Weapon thiswep)
-{SELFPARAM();
+void W_Electro_Attack_Orb(Weapon thiswep, entity actor)
+{entity this = actor;
W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(electro, ammo));
W_SetupShot_ProjectileSize(
entity proj = new(electro_orb);
proj.owner = proj.realowner = self;
proj.use = W_Electro_Explode_use;
- proj.think = adaptor_think2use_hittype_splash;
+ setthink(proj, adaptor_think2use_hittype_splash);
proj.bot_dodge = true;
proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
//proj.glow_color = 45;
proj.movetype = MOVETYPE_BOUNCE;
W_SetupProjVelocity_UP_SEC(proj, electro);
- proj.touch = W_Electro_Orb_Touch;
+ settouch(proj, W_Electro_Orb_Touch);
setsize(proj, '0 0 -4', '0 0 -4');
proj.takedamage = DAMAGE_YES;
proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
}
void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
-{SELFPARAM();
+{entity this = actor;
if(self.electro_count > 1)
if(PHYS_INPUT_BUTTON_ATCK2(self))
if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
{
- W_Electro_Attack_Orb(WEP_ELECTRO);
+ W_Electro_Attack_Orb(WEP_ELECTRO, actor);
self.electro_count -= 1;
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
return;
.float bot_secondary_electromooth;
-METHOD(Electro, wr_aim, void(entity thiswep))
+METHOD(Electro, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
PHYS_INPUT_BUTTON_ATCK(self) = PHYS_INPUT_BUTTON_ATCK2(self) = false;
if(vdist(self.origin - self.enemy.origin, >, 1000)) { self.bot_secondary_electromooth = 0; }
if(self.bot_secondary_electromooth == 0)
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
{
- W_Electro_Attack_Bolt(thiswep);
+ W_Electro_Attack_Bolt(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
}
}
if(time >= actor.electro_secondarytime)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
{
- W_Electro_Attack_Orb(thiswep);
+ W_Electro_Attack_Orb(thiswep, actor);
actor.electro_count = WEP_CVAR_SEC(electro, count);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
}
}
}
-METHOD(Electro, wr_checkammo1, bool(entity thiswep))
+METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
- ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
+ ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
return ammo_amount;
}
-METHOD(Electro, wr_checkammo2, bool(entity thiswep))
+METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
- ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+ ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
}
else
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo);
- ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo);
+ ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
}
return ammo_amount;
}
-METHOD(Electro, wr_resetplayer, void(entity thiswep))
+METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.electro_secondarytime = time;
}
METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
+ W_Reload(actor, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
}
METHOD(Electro, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(Electro, wr_impacteffect, void(entity thiswep))
+METHOD(Electro, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 6;
if(w_deathtype & HITTYPE_SECONDARY)
#ifdef SVQC
spawnfunc(weapon_fireball) { weapon_defaultspawnfunc(this, WEP_FIREBALL); }
-void W_Fireball_Explode()
-{SELFPARAM();
+void W_Fireball_Explode(entity this)
+{
entity e;
float dist;
float points;
void W_Fireball_Explode_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_Fireball_Explode());
+ WITHSELF(this, W_Fireball_Explode(this));
}
-void W_Fireball_TouchExplode()
+void W_Fireball_TouchExplode(entity this)
{
- PROJECTILE_TOUCH;
- W_Fireball_Explode();
+ PROJECTILE_TOUCH(this);
+ W_Fireball_Explode(this);
}
-void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
-{SELFPARAM();
+void W_Fireball_LaserPlay(entity this, float dt, float dist, float damage, float edgedamage, float burntime)
+{
entity e;
float d;
vector p;
}
}
-void W_Fireball_Think()
-{SELFPARAM();
+void W_Fireball_Think(entity this)
+{
if(time > self.pushltime)
{
self.cnt = 1;
self.projectiledeathtype |= HITTYPE_SPLASH;
- W_Fireball_Explode();
+ W_Fireball_Explode(this);
return;
}
- W_Fireball_LaserPlay(0.1, WEP_CVAR_PRI(fireball, laserradius), WEP_CVAR_PRI(fireball, laserdamage), WEP_CVAR_PRI(fireball, laseredgedamage), WEP_CVAR_PRI(fireball, laserburntime));
+ W_Fireball_LaserPlay(self, 0.1, WEP_CVAR_PRI(fireball, laserradius), WEP_CVAR_PRI(fireball, laserdamage), WEP_CVAR_PRI(fireball, laseredgedamage), WEP_CVAR_PRI(fireball, laserburntime));
self.nextthink = time + 0.1;
}
}
}
-void W_Fireball_Attack1()
-{SELFPARAM();
+void W_Fireball_Attack1(entity actor)
+{entity this = actor;
entity proj;
W_SetupShot_ProjectileSize(self, '-16 -16 -16', '16 16 16', false, 2, SND_FIREBALL_FIRE2, CH_WEAPON_A, WEP_CVAR_PRI(fireball, damage) + WEP_CVAR_PRI(fireball, bfgdamage));
proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
proj.use = W_Fireball_Explode_use;
- proj.think = W_Fireball_Think;
+ setthink(proj, W_Fireball_Think);
proj.nextthink = time;
proj.health = WEP_CVAR_PRI(fireball, health);
proj.team = self.team;
proj.movetype = MOVETYPE_FLY;
W_SetupProjVelocity_PRI(proj, fireball);
proj.angles = vectoangles(proj.velocity);
- proj.touch = W_Fireball_TouchExplode;
+ settouch(proj, W_Fireball_TouchExplode);
setsize(proj, '-16 -16 -16', '16 16 16');
proj.flags = FL_PROJECTILE;
proj.missile_flags = MIF_SPLASH | MIF_PROXY;
MUTATOR_CALLHOOK(EditProjectile, self, proj);
}
-void W_Fireball_AttackEffect(float i, vector f_diff)
-{SELFPARAM();
- W_SetupShot_ProjectileSize(self, '-16 -16 -16', '16 16 16', false, 0, SND_Null, 0, 0);
+void W_Fireball_AttackEffect(entity actor, float i, vector f_diff)
+{
+ W_SetupShot_ProjectileSize(actor, '-16 -16 -16', '16 16 16', false, 0, SND_Null, 0, 0);
w_shotorg += f_diff.x * v_up + f_diff.y * v_right;
Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
}
void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- W_Fireball_Attack1();
+ W_Fireball_Attack1(actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
}
void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
+ W_Fireball_AttackEffect(actor, 0, '+1.25 +3.75 0');
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
}
void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
+ W_Fireball_AttackEffect(actor, 0, '-1.25 +3.75 0');
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
}
void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
+ W_Fireball_AttackEffect(actor, 1, '+1.25 -3.75 0');
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
}
void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, .entity weaponentity, int fire)
-{SELFPARAM();
- W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
- sound(self, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM);
+{
+ W_Fireball_AttackEffect(actor, 0, '-1.25 -3.75 0');
+ sound(actor, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
}
-void W_Fireball_Firemine_Think()
-{SELFPARAM();
+void W_Fireball_Firemine_Think(entity this)
+{
if(time > self.pushltime)
{
remove(self);
self.cnt = 0;
}
- W_Fireball_LaserPlay(0.1, WEP_CVAR_SEC(fireball, laserradius), WEP_CVAR_SEC(fireball, laserdamage), WEP_CVAR_SEC(fireball, laseredgedamage), WEP_CVAR_SEC(fireball, laserburntime));
+ W_Fireball_LaserPlay(self, 0.1, WEP_CVAR_SEC(fireball, laserradius), WEP_CVAR_SEC(fireball, laserdamage), WEP_CVAR_SEC(fireball, laseredgedamage), WEP_CVAR_SEC(fireball, laserburntime));
self.nextthink = time + 0.1;
}
-void W_Fireball_Firemine_Touch()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_Fireball_Firemine_Touch(entity this)
+{
+ PROJECTILE_TOUCH(this);
if(other.takedamage == DAMAGE_AIM)
if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
{
self.projectiledeathtype |= HITTYPE_BOUNCE;
}
-void W_Fireball_Attack2()
-{SELFPARAM();
+void W_Fireball_Attack2(entity actor)
+{entity this = actor;
entity proj;
vector f_diff;
float c;
proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
proj.movetype = MOVETYPE_BOUNCE;
proj.projectiledeathtype = WEP_FIREBALL.m_id | HITTYPE_SECONDARY;
- proj.touch = W_Fireball_Firemine_Touch;
+ settouch(proj, W_Fireball_Firemine_Touch);
PROJECTILE_MAKETRIGGER(proj);
setsize(proj, '-4 -4 -4', '4 4 4');
setorigin(proj, w_shotorg);
- proj.think = W_Fireball_Firemine_Think;
+ setthink(proj, W_Fireball_Firemine_Think);
proj.nextthink = time;
proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
MUTATOR_CALLHOOK(EditProjectile, self, proj);
}
-METHOD(Fireball, wr_aim, void(entity thiswep))
+METHOD(Fireball, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
PHYS_INPUT_BUTTON_ATCK(self) = false;
PHYS_INPUT_BUTTON_ATCK2(self) = false;
if(self.bot_primary_fireballmooth == 0)
{
if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(fireball, refire)))
{
- W_Fireball_Attack2();
+ W_Fireball_Attack2(actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
}
}
}
-METHOD(Fireball, wr_setup, void(entity thiswep))
+METHOD(Fireball, wr_setup, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.ammo_field = ammo_none;
}
-METHOD(Fireball, wr_checkammo1, bool(entity thiswep))
+METHOD(Fireball, wr_checkammo1, bool(entity thiswep, entity actor))
{
return true; // infinite ammo
}
-METHOD(Fireball, wr_checkammo2, bool(entity thiswep))
+METHOD(Fireball, wr_checkammo2, bool(entity thiswep, entity actor))
{
return true; // fireball has infinite ammo
}
-METHOD(Fireball, wr_resetplayer, void(entity thiswep))
+METHOD(Fireball, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.fireball_primarytime = time;
}
METHOD(Fireball, wr_suicidemessage, Notification(entity thiswep))
#endif
#ifdef CSQC
-METHOD(Fireball, wr_impacteffect, void(entity thiswep))
+METHOD(Fireball, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
if(w_deathtype & HITTYPE_SECONDARY)
{
// NO bounce protection, as bounces are limited!
-void W_Hagar_Explode()
-{SELFPARAM();
+void W_Hagar_Explode(entity this)
+{
self.event_damage = func_null;
RadiusDamage(self, self.realowner, WEP_CVAR_PRI(hagar, damage), WEP_CVAR_PRI(hagar, edgedamage), WEP_CVAR_PRI(hagar, radius), world, world, WEP_CVAR_PRI(hagar, force), self.projectiledeathtype, other);
void W_Hagar_Explode_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_Hagar_Explode());
+ WITHSELF(this, W_Hagar_Explode(this));
}
-void W_Hagar_Explode2()
-{SELFPARAM();
+void W_Hagar_Explode2(entity this)
+{
self.event_damage = func_null;
RadiusDamage(self, self.realowner, WEP_CVAR_SEC(hagar, damage), WEP_CVAR_SEC(hagar, edgedamage), WEP_CVAR_SEC(hagar, radius), world, world, WEP_CVAR_SEC(hagar, force), self.projectiledeathtype, other);
void W_Hagar_Explode2_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_Hagar_Explode2());
+ WITHSELF(this, W_Hagar_Explode2(this));
}
void W_Hagar_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
this.angles = vectoangles(this.velocity);
if(this.health <= 0)
- W_PrepareExplosionByDamage(this, attacker, this.think);
+ W_PrepareExplosionByDamage(this, attacker, getthink(this));
}
-void W_Hagar_Touch()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_Hagar_Touch(entity this)
+{
+ PROJECTILE_TOUCH(this);
this.use(this, NULL, NULL);
}
-void W_Hagar_Touch2()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_Hagar_Touch2(entity this)
+{
+ PROJECTILE_TOUCH(this);
if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
this.use(this, NULL, NULL);
}
}
-void W_Hagar_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Hagar_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
entity missile;
W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(hagar, ammo));
missile.event_damage = W_Hagar_Damage;
missile.damagedbycontents = true;
- missile.touch = W_Hagar_Touch;
+ settouch(missile, W_Hagar_Touch);
missile.use = W_Hagar_Explode_use;
- missile.think = adaptor_think2use_hittype_splash;
+ setthink(missile, adaptor_think2use_hittype_splash);
missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
PROJECTILE_MAKETRIGGER(missile);
missile.projectiledeathtype = WEP_HAGAR.m_id;
MUTATOR_CALLHOOK(EditProjectile, self, missile);
}
-void W_Hagar_Attack2(Weapon thiswep)
-{SELFPARAM();
+void W_Hagar_Attack2(Weapon thiswep, entity actor)
+{entity this = actor;
entity missile;
W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hagar, ammo));
missile.event_damage = W_Hagar_Damage;
missile.damagedbycontents = true;
- missile.touch = W_Hagar_Touch2;
+ settouch(missile, W_Hagar_Touch2);
missile.cnt = 0;
missile.use = W_Hagar_Explode2_use;
- missile.think = adaptor_think2use_hittype_splash;
+ setthink(missile, adaptor_think2use_hittype_splash);
missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
PROJECTILE_MAKETRIGGER(missile);
missile.projectiledeathtype = WEP_HAGAR.m_id | HITTYPE_SECONDARY;
}
.float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
-void W_Hagar_Attack2_Load_Release(.entity weaponentity)
-{SELFPARAM();
+void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity)
+{entity this = actor;
// time to release the rockets we've loaded
entity missile;
missile.event_damage = W_Hagar_Damage;
missile.damagedbycontents = true;
- missile.touch = W_Hagar_Touch; // not bouncy
+ settouch(missile, W_Hagar_Touch); // not bouncy
missile.use = W_Hagar_Explode2_use;
- missile.think = adaptor_think2use_hittype_splash;
+ setthink(missile, adaptor_think2use_hittype_splash);
missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
PROJECTILE_MAKETRIGGER(missile);
missile.projectiledeathtype = WEP_HAGAR.m_id | HITTYPE_SECONDARY;
self.hagar_load = 0;
}
-void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity)
-{SELFPARAM();
+void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity)
+{entity this = actor;
// loadable hagar secondary attack, must always run each frame
if(time < game_starttime)
if(!PHYS_INPUT_BUTTON_ATCK2(self) || (stopped && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
{
self.(weaponentity).state = WS_READY;
- W_Hagar_Attack2_Load_Release(weaponentity);
+ W_Hagar_Attack2_Load_Release(self, weaponentity);
}
}
else
self.hagar_warning = false;
// we aren't checking ammo during an attack, so we must do it here
- if(!(thiswep.wr_checkammo1(thiswep) + thiswep.wr_checkammo2(thiswep)))
+ if(!(thiswep.wr_checkammo1(thiswep, self) + thiswep.wr_checkammo2(thiswep, self)))
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
// note: this doesn't force the switch
return;
}
- if(!thiswep.wr_checkammo1(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
return;
}
- W_Hagar_Attack(thiswep);
+ W_Hagar_Attack(thiswep, actor);
int slot = weaponslot(weaponentity);
ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor();
weapon_thinkf(actor, weaponentity, theframe, WEP_CVAR_PRI(hagar, refire), W_Hagar_Attack_Auto);
}
-METHOD(Hagar, wr_aim, void(entity thiswep))
+METHOD(Hagar, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(random()>0.15)
PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false);
else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
if(loadable_secondary)
- W_Hagar_Attack2_Load(thiswep, weaponentity); // must always run each frame
+ W_Hagar_Attack2_Load(thiswep, actor, weaponentity); // must always run each frame
if(autocvar_g_balance_hagar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload
thiswep.wr_reload(thiswep, actor, weaponentity);
}
{
if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hagar, refire)))
{
- W_Hagar_Attack2(thiswep);
+ W_Hagar_Attack2(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
}
}
}
-METHOD(Hagar, wr_gonethink, void(entity thiswep))
+METHOD(Hagar, wr_gonethink, void(entity thiswep, entity actor))
{
- SELFPARAM();
// we lost the weapon and want to prepare switching away
- if(self.hagar_load)
+ if(actor.hagar_load)
{
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
- self.(weaponentity).state = WS_READY;
- W_Hagar_Attack2_Load_Release(weaponentity);
+ actor.(weaponentity).state = WS_READY;
+ W_Hagar_Attack2_Load_Release(actor, weaponentity);
}
}
-METHOD(Hagar, wr_setup, void(entity thiswep))
+METHOD(Hagar, wr_setup, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.hagar_loadblock = false;
if(self.hagar_load)
self.hagar_load = 0;
}
}
-METHOD(Hagar, wr_checkammo1, bool(entity thiswep))
+METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo);
- ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
return ammo_amount;
}
-METHOD(Hagar, wr_checkammo2, bool(entity thiswep))
+METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
- ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
return ammo_amount;
}
-METHOD(Hagar, wr_resetplayer, void(entity thiswep))
+METHOD(Hagar, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.hagar_load = 0;
}
-METHOD(Hagar, wr_playerdeath, void(entity thiswep))
+METHOD(Hagar, wr_playerdeath, void(entity thiswep, entity actor))
{
- SELFPARAM();
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
// if we have any rockets loaded when we die, release them
- if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
- W_Hagar_Attack2_Load_Release(weaponentity);
+ if(actor.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
+ W_Hagar_Attack2_Load_Release(actor, weaponentity);
}
METHOD(Hagar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
+ entity this = actor;
if(!self.hagar_load) // require releasing loaded rockets first
W_Reload(self, min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND_RELOAD);
}
#endif
#ifdef CSQC
-METHOD(Hagar, wr_impacteffect, void(entity thiswep))
+METHOD(Hagar, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 6;
pointparticles(EFFECT_HAGAR_EXPLODE, org2, '0 0 0', 1);
#ifdef SVQC
spawnfunc(weapon_hlac) { weapon_defaultspawnfunc(this, WEP_HLAC); }
-void W_HLAC_Touch()
-{SELFPARAM();
+void W_HLAC_Touch(entity this)
+{
float isprimary;
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
self.event_damage = func_null;
remove(self);
}
-void W_HLAC_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_HLAC_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
entity missile;
float spread;
W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(hlac, speed), spread);
//missile.angles = vectoangles(missile.velocity); // csqc
- missile.touch = W_HLAC_Touch;
- missile.think = SUB_Remove_self;
+ settouch(missile, W_HLAC_Touch);
+ setthink(missile, SUB_Remove);
missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
MUTATOR_CALLHOOK(EditProjectile, self, missile);
}
-void W_HLAC_Attack2()
-{SELFPARAM();
+void W_HLAC_Attack2(entity actor)
+{entity this = actor;
entity missile;
float spread;
W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
//missile.angles = vectoangles(missile.velocity); // csqc
- missile.touch = W_HLAC_Touch;
- missile.think = SUB_Remove_self;
+ settouch(missile, W_HLAC_Touch);
+ setthink(missile, SUB_Remove);
missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
if(PHYS_INPUT_BUTTON_ATCK(actor))
{
- if(!thiswep.wr_checkammo1(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
int slot = weaponslot(weaponentity);
ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor();
- W_HLAC_Attack(WEP_HLAC);
+ W_HLAC_Attack(WEP_HLAC, actor);
actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
}
}
}
-void W_HLAC_Attack2_Frame(Weapon thiswep)
-{SELFPARAM();
+void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor)
+{entity this = actor;
float i;
W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hlac, ammo));
for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
- W_HLAC_Attack2();
+ W_HLAC_Attack2(actor);
if(!autocvar_g_norecoil)
{
}
}
-METHOD(HLAC, wr_aim, void(entity thiswep))
+METHOD(HLAC, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
}
METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
{
actor.misc_bulletcounter = 0;
- W_HLAC_Attack(thiswep);
+ W_HLAC_Attack(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
}
}
{
if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hlac, refire)))
{
- W_HLAC_Attack2_Frame(thiswep);
+ W_HLAC_Attack2_Frame(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
}
}
}
-METHOD(HLAC, wr_checkammo1, bool(entity thiswep))
+METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
- ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
return ammo_amount;
}
-METHOD(HLAC, wr_checkammo2, bool(entity thiswep))
+METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
- ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
return ammo_amount;
}
METHOD(HLAC, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD);
+ W_Reload(actor, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD);
}
METHOD(HLAC, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(HLAC, wr_impacteffect, void(entity thiswep))
+METHOD(HLAC, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 6;
pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
spawnfunc(weapon_hook) { weapon_defaultspawnfunc(this, WEP_HOOK); }
-void W_Hook_ExplodeThink()
-{SELFPARAM();
+void W_Hook_ExplodeThink(entity this)
+{
float dt, dmg_remaining_next, f;
dt = time - self.teleport_time;
remove(self);
}
-void W_Hook_Explode2()
-{SELFPARAM();
+void W_Hook_Explode2(entity this)
+{
self.event_damage = func_null;
- self.touch = func_null;
+ settouch(self, func_null);
self.effects |= EF_NODRAW;
- self.think = W_Hook_ExplodeThink;
+ setthink(self, W_Hook_ExplodeThink);
self.nextthink = time;
self.dmg = WEP_CVAR_SEC(hook, damage);
self.dmg_edge = WEP_CVAR_SEC(hook, edgedamage);
void W_Hook_Explode2_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_Hook_Explode2());
+ WITHSELF(this, W_Hook_Explode2(this));
}
void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
W_PrepareExplosionByDamage(this, this.realowner, W_Hook_Explode2);
}
-void W_Hook_Touch2()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_Hook_Touch2(entity this)
+{
+ PROJECTILE_TOUCH(this);
this.use(this, NULL, NULL);
}
setsize(gren, '0 0 0', '0 0 0');
gren.nextthink = time + WEP_CVAR_SEC(hook, lifetime);
- gren.think = adaptor_think2use_hittype_splash;
+ setthink(gren, adaptor_think2use_hittype_splash);
gren.use = W_Hook_Explode2_use;
- gren.touch = W_Hook_Touch2;
+ settouch(gren, W_Hook_Touch2);
gren.takedamage = DAMAGE_YES;
gren.health = WEP_CVAR_SEC(hook, health);
METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
- SELFPARAM();
if (fire & 1) {
if(!actor.hook)
if(!(actor.hook_state & HOOK_WAITING_FOR_RELEASE))
actor.hook_state &= ~HOOK_REMOVING;
}
}
-METHOD(Hook, wr_setup, void(entity thiswep))
+METHOD(Hook, wr_setup, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
}
-METHOD(Hook, wr_checkammo1, bool(Hook thiswep))
+METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor))
{
- SELFPARAM();
if (!thiswep.ammo_factor) return true;
- if(self.hook)
- return self.ammo_fuel > 0;
+ if(actor.hook)
+ return actor.ammo_fuel > 0;
else
- return self.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
+ return actor.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
}
-METHOD(Hook, wr_checkammo2, bool(Hook thiswep))
+METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor))
{
// infinite ammo for now
- return true; // self.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
+ return true; // actor.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
}
-METHOD(Hook, wr_resetplayer, void(entity thiswep))
+METHOD(Hook, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
RemoveGrapplingHook(self);
self.hook_time = 0;
self.hook_refire = time;
#endif
#ifdef CSQC
-METHOD(Hook, wr_impacteffect, void(entity thiswep))
+METHOD(Hook, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 2;
pointparticles(EFFECT_HOOK_EXPLODE, org2, '0 0 0', 1);
NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
{
- self.HookType = NET_ENT_CLIENT_HOOK;
+ this.HookType = NET_ENT_CLIENT_HOOK;
int sf = ReadByte();
- self.HookSilent = (sf & 0x80);
- self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
+ this.HookSilent = (sf & 0x80);
+ this.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
- InterpolateOrigin_Undo(self);
+ InterpolateOrigin_Undo(this);
if(sf & 1)
{
int myowner = ReadByte();
- self.owner = playerslots[myowner - 1];
- self.sv_entnum = myowner;
+ this.owner = playerslots[myowner - 1];
+ this.sv_entnum = myowner;
if(csqcplayer && myowner == player_localentnum)
- csqcplayer.hook = self;
- switch(self.HookType)
+ csqcplayer.hook = this;
+ switch(this.HookType)
{
default:
case NET_ENT_CLIENT_HOOK:
- self.HookRange = 0;
+ this.HookRange = 0;
break;
case NET_ENT_CLIENT_ARC_BEAM:
- self.HookRange = ReadCoord();
+ this.HookRange = ReadCoord();
break;
}
}
if(sf & 2)
{
- self.origin_x = ReadCoord();
- self.origin_y = ReadCoord();
- self.origin_z = ReadCoord();
- setorigin(self, self.origin);
+ this.origin_x = ReadCoord();
+ this.origin_y = ReadCoord();
+ this.origin_z = ReadCoord();
+ setorigin(this, this.origin);
}
if(sf & 4)
{
- self.velocity_x = ReadCoord();
- self.velocity_y = ReadCoord();
- self.velocity_z = ReadCoord();
+ this.velocity_x = ReadCoord();
+ this.velocity_y = ReadCoord();
+ this.velocity_z = ReadCoord();
}
InterpolateOrigin_Note(this);
- if(bIsNew || !self.teleport_time)
+ if(bIsNew || !this.teleport_time)
{
- self.draw = Draw_GrapplingHook;
- self.entremove = Remove_GrapplingHook;
+ this.draw = Draw_GrapplingHook;
+ this.entremove = Remove_GrapplingHook;
- switch(self.HookType)
+ switch(this.HookType)
{
default:
case NET_ENT_CLIENT_HOOK:
// for the model
- setmodel(self, MDL_HOOK);
- self.drawmask = MASK_NORMAL;
+ setmodel(this, MDL_HOOK);
+ this.drawmask = MASK_NORMAL;
break;
case NET_ENT_CLIENT_ARC_BEAM:
- sound (self, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM);
+ sound (this, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM);
break;
}
}
- self.teleport_time = time + 10;
+ this.teleport_time = time + 10;
return true;
}
-// TODO: hook: temporarily transform self.origin for drawing the model along warpzones!
+// TODO: hook: temporarily transform this.origin for drawing the model along warpzones!
#endif
#endif
spawnfunc(weapon_machinegun)
{
if(autocvar_sv_q3acompat_machineshotgunswap)
- if(self.classname != "droppedweapon")
+ if(this.classname != "droppedweapon")
{
weapon_defaultspawnfunc(this, WEP_SHOCKWAVE);
return;
}
spawnfunc(weapon_uzi) { spawnfunc_weapon_machinegun(this); }
-void W_MachineGun_MuzzleFlash_Think()
-{SELFPARAM();
+void W_MachineGun_MuzzleFlash_Think(entity this)
+{
this.frame += 2;
this.scale *= 0.5;
this.alpha -= 0.25;
if(this.alpha <= 0)
{
- this.think = SUB_Remove_self;
+ setthink(this, SUB_Remove);
this.nextthink = time;
this.realowner.muzzle_flash = world;
return;
}
-void W_MachineGun_MuzzleFlash()
-{SELFPARAM();
+void W_MachineGun_MuzzleFlash(entity actor)
+{entity this = actor;
if(self.muzzle_flash == world)
self.muzzle_flash = spawn();
setmodel(self.muzzle_flash, MDL_MACHINEGUN_MUZZLEFLASH); // precision set below
self.muzzle_flash.scale = 0.75;
- self.muzzle_flash.think = W_MachineGun_MuzzleFlash_Think;
+ setthink(self.muzzle_flash, W_MachineGun_MuzzleFlash_Think);
self.muzzle_flash.nextthink = time + 0.02;
self.muzzle_flash.frame = 2;
self.muzzle_flash.alpha = 0.75;
self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
}
-void W_MachineGun_Attack(Weapon thiswep, int deathtype, .entity weaponentity)
-{SELFPARAM();
+void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity weaponentity)
+{entity this = actor;
W_SetupShot(self, true, 0, SND_UZI_FIRE, CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage)));
if(!autocvar_g_norecoil)
{
Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
- W_MachineGun_MuzzleFlash();
+ W_MachineGun_MuzzleFlash(self);
W_AttachToShotorg(self, self.muzzle_flash, '5 0 0');
// casing code
}
if(PHYS_INPUT_BUTTON_ATCK(actor))
{
- if(!thiswep.wr_checkammo2(thiswep))
+ if(!thiswep.wr_checkammo2(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
return;
}
actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
- W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, weaponentity);
+ W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, actor, weaponentity);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
}
else
return;
}
- if(!thiswep.wr_checkammo1(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
- W_MachineGun_MuzzleFlash();
+ W_MachineGun_MuzzleFlash(actor);
W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0');
if(autocvar_g_casings >= 2) // casing code
Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
- W_MachineGun_MuzzleFlash();
+ W_MachineGun_MuzzleFlash(actor);
W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0');
if(autocvar_g_casings >= 2) // casing code
}
-METHOD(MachineGun, wr_aim, void(entity thiswep))
+METHOD(MachineGun, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ 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);
else
if(fire & 2)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
{
- if(!thiswep.wr_checkammo2(thiswep))
+ if(!thiswep.wr_checkammo2(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
{
actor.misc_bulletcounter = 1;
- W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, weaponentity); // sets attack_finished
+ W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, actor, weaponentity); // sets attack_finished
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
}
if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
{
actor.misc_bulletcounter = 1;
- W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY, weaponentity); // sets attack_finished
+ W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY, actor, weaponentity); // sets attack_finished
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready);
}
}
}
-METHOD(MachineGun, wr_checkammo1, bool(entity thiswep))
+METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, sustained_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, sustained_ammo);
else
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
if(WEP_CVAR(machinegun, reload_ammo))
{
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, sustained_ammo);
+ ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, sustained_ammo);
else
- ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
}
return ammo_amount;
}
-METHOD(MachineGun, wr_checkammo2, bool(entity thiswep))
+METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, burst_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, burst_ammo);
else
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
if(WEP_CVAR(machinegun, reload_ammo))
{
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, burst_ammo);
+ ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, burst_ammo);
else
- ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
}
return ammo_amount;
}
METHOD(MachineGun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)), SND_RELOAD);
+ W_Reload(actor, min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)), SND_RELOAD);
}
METHOD(MachineGun, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(MachineGun, wr_impacteffect, void(entity thiswep))
+METHOD(MachineGun, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 2;
pointparticles(EFFECT_MACHINEGUN_IMPACT, org2, w_backoff * 1000, 1);
REGISTER_WEAPON(MINE_LAYER, minelayer, NEW(MineLayer));
#ifdef SVQC
-void W_MineLayer_Think();
+void W_MineLayer_Think(entity this);
.float minelayer_detonate, mine_explodeanyway;
.float mine_time;
.vector mine_orientation;
#ifdef SVQC
spawnfunc(weapon_minelayer) { weapon_defaultspawnfunc(this, WEP_MINE_LAYER); }
-void W_MineLayer_Stick(entity to)
-{SELFPARAM();
+void W_MineLayer_Stick(entity this, entity to)
+{
spamsound(self, CH_SHOTS, SND(MINE_STICK), VOL_BASE, ATTN_NORM);
// in order for mines to face properly when sticking to the ground, they must be a server side entity rather than a csqc projectile
newmine.mine_time = self.mine_time;
- newmine.touch = func_null;
- newmine.think = W_MineLayer_Think;
+ settouch(newmine, func_null);
+ setthink(newmine, W_MineLayer_Think);
newmine.nextthink = time;
newmine.cnt = self.cnt;
newmine.flags = self.flags;
remove(self);
- setself(newmine);
if(to)
- SetMovetypeFollow(self, to);
+ SetMovetypeFollow(newmine, to);
}
-void W_MineLayer_Explode()
-{SELFPARAM();
+void W_MineLayer_Explode(entity this)
+{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
if(DIFF_TEAM(self.realowner, other))
if(PS(self.realowner).m_weapon == WEP_MINE_LAYER)
{
- setself(self.realowner);
+ entity own = this.realowner;
Weapon w = WEP_MINE_LAYER;
- if(!w.wr_checkammo1(w))
+ if(!w.wr_checkammo1(w, own))
{
- self.cnt = WEP_MINE_LAYER.m_id;
+ own.cnt = WEP_MINE_LAYER.m_id;
int slot = 0; // TODO: unhardcode
- ATTACK_FINISHED(self, slot) = time;
- PS(self).m_switchweapon = w_getbestweapon(self);
+ ATTACK_FINISHED(own, slot) = time;
+ PS(own).m_switchweapon = w_getbestweapon(own);
}
- setself(this);
}
self.realowner.minelayer_mines -= 1;
remove(self);
}
-void W_MineLayer_DoRemoteExplode()
-{SELFPARAM();
+void W_MineLayer_DoRemoteExplode(entity this)
+{
self.event_damage = func_null;
self.takedamage = DAMAGE_NO;
if(PS(self.realowner).m_weapon == WEP_MINE_LAYER)
{
- setself(self.realowner);
+ entity own = this.realowner;
Weapon w = WEP_MINE_LAYER;
- if(!w.wr_checkammo1(w))
+ if(!w.wr_checkammo1(w, own))
{
- self.cnt = WEP_MINE_LAYER.m_id;
+ own.cnt = WEP_MINE_LAYER.m_id;
int slot = 0; // TODO: unhardcode
- ATTACK_FINISHED(self, slot) = time;
- PS(self).m_switchweapon = w_getbestweapon(self);
+ ATTACK_FINISHED(own, slot) = time;
+ PS(own).m_switchweapon = w_getbestweapon(own);
}
- setself(this);
}
- self.realowner.minelayer_mines -= 1;
+ this.realowner.minelayer_mines -= 1;
remove(self);
}
-void W_MineLayer_RemoteExplode()
-{SELFPARAM();
+void W_MineLayer_RemoteExplode(entity this)
+{
if(!IS_DEAD(self.realowner))
if((self.spawnshieldtime >= 0)
? (time >= self.spawnshieldtime) // timer
: (vdist(NearestPointOnBox(self.realowner, self.origin) - self.origin, >, WEP_CVAR(minelayer, remote_radius))) // safety device
)
{
- W_MineLayer_DoRemoteExplode();
+ W_MineLayer_DoRemoteExplode(self);
}
}
-void W_MineLayer_ProximityExplode()
-{SELFPARAM();
+void W_MineLayer_ProximityExplode(entity this)
+{
// make sure no friend is in the mine's radius. If there is any, explosion is delayed until he's at a safe distance
if(WEP_CVAR(minelayer, protection) && self.mine_explodeanyway == 0)
{
}
self.mine_time = 0;
- W_MineLayer_Explode();
+ W_MineLayer_Explode(self);
}
int W_MineLayer_Count(entity e)
return minecount;
}
-void W_MineLayer_Think()
-{SELFPARAM();
+void W_MineLayer_Think(entity this)
+{
entity head;
self.nextthink = time;
{
other = world;
self.projectiledeathtype |= HITTYPE_BOUNCE;
- W_MineLayer_Explode();
+ W_MineLayer_Explode(self);
return;
}
// explode if it's time to
if(self.mine_time && time >= self.mine_time)
{
- W_MineLayer_ProximityExplode();
+ W_MineLayer_ProximityExplode(self);
return;
}
if(PS(self.realowner).m_weapon == WEP_MINE_LAYER)
if(!IS_DEAD(self.realowner))
if(self.minelayer_detonate)
- W_MineLayer_RemoteExplode();
+ W_MineLayer_RemoteExplode(self);
}
-void W_MineLayer_Touch()
-{SELFPARAM();
+void W_MineLayer_Touch(entity this)
+{
if(self.movetype == MOVETYPE_NONE || self.movetype == MOVETYPE_FOLLOW)
return; // we're already a stuck mine, why do we get called? TODO does this even happen?
- if(WarpZone_Projectile_Touch())
+ if(WarpZone_Projectile_Touch(self))
{
if(wasfreed(self))
self.realowner.minelayer_mines -= 1;
}
else
{
- W_MineLayer_Stick(other);
+ W_MineLayer_Stick(self, other);
}
}
W_PrepareExplosionByDamage(this, attacker, W_MineLayer_Explode);
}
-void W_MineLayer_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_MineLayer_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
entity mine;
entity flash;
W_SetupProjVelocity_Basic(mine, WEP_CVAR(minelayer, speed), 0);
mine.angles = vectoangles(mine.velocity);
- mine.touch = W_MineLayer_Touch;
- mine.think = W_MineLayer_Think;
+ settouch(mine, W_MineLayer_Touch);
+ setthink(mine, W_MineLayer_Think);
mine.nextthink = time;
mine.cnt = (WEP_CVAR(minelayer, lifetime) - WEP_CVAR(minelayer, lifetime_countdown));
mine.flags = FL_PROJECTILE;
self.minelayer_mines = W_MineLayer_Count(self);
}
-float W_MineLayer_PlacedMines(float detonate)
-{SELFPARAM();
+float W_MineLayer_PlacedMines(entity this, float detonate)
+{
entity mine;
float minfound = 0;
- for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == self)
+ for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == this)
{
if(detonate)
{
return minfound;
}
-METHOD(MineLayer, wr_aim, void(entity thiswep))
+METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
// aim and decide to fire if appropriate
if(self.minelayer_mines >= WEP_CVAR(minelayer, limit))
PHYS_INPUT_BUTTON_ATCK(self) = false;
if(autocvar_g_balance_minelayer_reload_ammo && actor.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
{
// not if we're holding the minelayer without enough ammo, but can detonate existing mines
- if(!(W_MineLayer_PlacedMines(false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
+ if(!(W_MineLayer_PlacedMines(actor, false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
thiswep.wr_reload(thiswep, actor, weaponentity);
}
}
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(minelayer, refire)))
{
- W_MineLayer_Attack(thiswep);
+ W_MineLayer_Attack(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
}
}
if(fire & 2)
{
- if(W_MineLayer_PlacedMines(true))
+ if(W_MineLayer_PlacedMines(actor, true))
sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
}
}
-METHOD(MineLayer, wr_checkammo1, bool(entity thiswep))
+METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
//int slot = 0; // TODO: unhardcode
// actually do // don't switch while placing a mine
- //if(ATTACK_FINISHED(self, slot) <= time || PS(self).m_weapon != WEP_MINE_LAYER)
+ //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
//{
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo);
- ammo_amount += self.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo);
+ ammo_amount += actor.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo);
return ammo_amount;
//}
//return true;
}
-METHOD(MineLayer, wr_checkammo2, bool(entity thiswep))
+METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor))
{
- if(W_MineLayer_PlacedMines(false))
+ if(W_MineLayer_PlacedMines(actor, false))
return true;
else
return false;
}
-METHOD(MineLayer, wr_resetplayers, void(entity thiswep))
+METHOD(MineLayer, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
- self.minelayer_mines = 0;
+ actor.minelayer_mines = 0;
}
METHOD(MineLayer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, WEP_CVAR(minelayer, ammo), SND_RELOAD);
+ W_Reload(actor, WEP_CVAR(minelayer, ammo), SND_RELOAD);
}
METHOD(MineLayer, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(MineLayer, wr_impacteffect, void(entity thiswep))
+METHOD(MineLayer, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 12;
pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
spawnfunc(weapon_mortar) { weapon_defaultspawnfunc(this, WEP_MORTAR); }
spawnfunc(weapon_grenadelauncher) { spawnfunc_weapon_mortar(this); }
-void W_Mortar_Grenade_Explode()
-{SELFPARAM();
+void W_Mortar_Grenade_Explode(entity this)
+{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
if(DIFF_TEAM(self.realowner, other))
void W_Mortar_Grenade_Explode_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_Mortar_Grenade_Explode());
+ WITHSELF(this, W_Mortar_Grenade_Explode(this));
}
-void W_Mortar_Grenade_Explode2()
-{SELFPARAM();
+void W_Mortar_Grenade_Explode2(entity this)
+{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
if(DIFF_TEAM(self.realowner, other))
void W_Mortar_Grenade_Explode2_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_Mortar_Grenade_Explode2());
+ WITHSELF(this, W_Mortar_Grenade_Explode2(this));
}
void W_Mortar_Grenade_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
}
-void W_Mortar_Grenade_Think1()
-{SELFPARAM();
+void W_Mortar_Grenade_Think1(entity this)
+{
self.nextthink = time;
if(time > self.cnt)
{
other = world;
self.projectiledeathtype |= HITTYPE_BOUNCE;
- W_Mortar_Grenade_Explode();
+ W_Mortar_Grenade_Explode(self);
return;
}
if(self.gl_detonate_later && self.gl_bouncecnt >= WEP_CVAR_PRI(mortar, remote_minbouncecnt))
- W_Mortar_Grenade_Explode();
+ W_Mortar_Grenade_Explode(self);
}
-void W_Mortar_Grenade_Touch1()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_Mortar_Grenade_Touch1(entity this)
+{
+ PROJECTILE_TOUCH(this);
if(other.takedamage == DAMAGE_AIM || WEP_CVAR_PRI(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile
{
this.use(this, NULL, NULL);
}
}
-void W_Mortar_Grenade_Touch2()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_Mortar_Grenade_Touch2(entity this)
+{
+ PROJECTILE_TOUCH(this);
if(other.takedamage == DAMAGE_AIM || WEP_CVAR_SEC(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile
{
this.use(this, NULL, NULL);
}
}
-void W_Mortar_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Mortar_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
entity gren;
W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(mortar, ammo));
gren.cnt = time + WEP_CVAR_PRI(mortar, lifetime);
gren.nextthink = time;
- gren.think = W_Mortar_Grenade_Think1;
+ setthink(gren, W_Mortar_Grenade_Think1);
gren.use = W_Mortar_Grenade_Explode_use;
- gren.touch = W_Mortar_Grenade_Touch1;
+ settouch(gren, W_Mortar_Grenade_Touch1);
gren.takedamage = DAMAGE_YES;
gren.health = WEP_CVAR_PRI(mortar, health);
MUTATOR_CALLHOOK(EditProjectile, self, gren);
}
-void W_Mortar_Attack2(Weapon thiswep)
-{SELFPARAM();
+void W_Mortar_Attack2(Weapon thiswep, entity actor)
+{entity this = actor;
entity gren;
W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(mortar, ammo));
setsize(gren, '-3 -3 -3', '3 3 3');
gren.nextthink = time + WEP_CVAR_SEC(mortar, lifetime);
- gren.think = adaptor_think2use_hittype_splash;
+ setthink(gren, adaptor_think2use_hittype_splash);
gren.use = W_Mortar_Grenade_Explode2_use;
- gren.touch = W_Mortar_Grenade_Touch2;
+ settouch(gren, W_Mortar_Grenade_Touch2);
gren.takedamage = DAMAGE_YES;
gren.health = WEP_CVAR_SEC(mortar, health);
.float bot_secondary_grenademooth;
-METHOD(Mortar, wr_aim, void(entity thiswep))
+METHOD(Mortar, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
PHYS_INPUT_BUTTON_ATCK(self) = false;
PHYS_INPUT_BUTTON_ATCK2(self) = false;
if(self.bot_secondary_grenademooth == 0) // WEAPONTODO: merge this into using WEP_CVAR_BOTH
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(mortar, refire)))
{
- W_Mortar_Attack(thiswep);
+ W_Mortar_Attack(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready);
}
}
}
else if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(mortar, refire)))
{
- W_Mortar_Attack2(thiswep);
+ W_Mortar_Attack2(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready);
}
}
}
-METHOD(Mortar, wr_checkammo1, bool(entity thiswep))
+METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo);
- ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo);
+ ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
return ammo_amount;
}
-METHOD(Mortar, wr_checkammo2, bool(entity thiswep))
+METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo);
- ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo);
+ ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
return ammo_amount;
}
METHOD(Mortar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND_RELOAD); // WEAPONTODO
+ W_Reload(actor, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND_RELOAD); // WEAPONTODO
}
METHOD(Mortar, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(Mortar, wr_impacteffect, void(entity thiswep))
+METHOD(Mortar, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 12;
pointparticles(EFFECT_GRENADE_EXPLODE, org2, '0 0 0', 1);
FOREACH_CLIENT(IS_PLAYER(it), it.porto_forbidden = max(0, it.porto_forbidden - 1));
}
-void W_Porto_Success()
-{SELFPARAM();
+void W_Porto_Success(entity this)
+{
if(self.realowner == world)
{
objerror("Cannot succeed successfully: no owner\n");
}
string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
-void W_Porto_Fail(float failhard)
-{SELFPARAM();
- if(self.realowner == world)
+void W_Porto_Fail(entity this, float failhard)
+{
+ if(this.realowner == world)
{
objerror("Cannot fail successfully: no owner\n");
return;
}
// no portals here!
- if(self.cnt < 0)
+ if(this.cnt < 0)
{
- Portal_ClearWithID(self.realowner, self.portal_id);
+ Portal_ClearWithID(this.realowner, this.portal_id);
}
- self.realowner.porto_current = world;
+ this.realowner.porto_current = world;
- if(self.cnt < 0 && !failhard && self.realowner.playerid == self.playerid && !IS_DEAD(self.realowner) && !(self.realowner.weapons & WEPSET(PORTO)))
+ if(this.cnt < 0 && !failhard && this.realowner.playerid == this.playerid && !IS_DEAD(this.realowner) && !(this.realowner.weapons & WEPSET(PORTO)))
{
- setsize(self, '-16 -16 0', '16 16 32');
- setorigin(self, self.origin + trace_plane_normal);
- if(move_out_of_solid(self))
+ setsize(this, '-16 -16 0', '16 16 32');
+ setorigin(this, this.origin + trace_plane_normal);
+ if(move_out_of_solid(this))
{
- self.flags = FL_ITEM;
- self.velocity = trigger_push_calculatevelocity(self.origin, self.realowner, 128);
- tracetoss(self, self);
- if(vdist(trace_endpos - self.realowner.origin, <, 128))
+ this.flags = FL_ITEM;
+ this.velocity = trigger_push_calculatevelocity(this.origin, this.realowner, 128);
+ tracetoss(this, this);
+ if(vdist(trace_endpos - this.realowner.origin, <, 128))
{
- W_ThrowNewWeapon(self.realowner, WEP_PORTO.m_id, 0, self.origin, self.velocity);
- Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_FAILED);
+ W_ThrowNewWeapon(this.realowner, WEP_PORTO.m_id, 0, this.origin, this.velocity);
+ Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_FAILED);
}
}
}
- remove(self);
+ remove(this);
}
void W_Porto_Remove(entity p)
-{SELFPARAM();
+{
if(p.porto_current.realowner == p && p.porto_current.classname == "porto")
{
- WITHSELF(p.porto_current, W_Porto_Fail(1));
+ WITHSELF(p.porto_current, W_Porto_Fail(p.porto_current, 1));
}
}
-void W_Porto_Think()
-{SELFPARAM();
+void W_Porto_Think(entity this)
+{
trace_plane_normal = '0 0 0';
if(self.realowner.playerid != self.playerid)
remove(self);
else
- W_Porto_Fail(0);
+ W_Porto_Fail(self, 0);
}
-void W_Porto_Touch()
-{SELFPARAM();
+void W_Porto_Touch(entity this)
+{
vector norm;
// do not use PROJECTILE_TOUCH here
else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
{
sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
- W_Porto_Fail(0);
+ W_Porto_Fail(self, 0);
if(self.cnt < 0)
Portal_ClearAll_PortalsOnly(self.realowner);
}
sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM);
trace_plane_normal = norm;
Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN);
- W_Porto_Success();
+ W_Porto_Success(self);
}
else
{
sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
trace_plane_normal = norm;
- W_Porto_Fail(0);
+ W_Porto_Fail(self, 0);
}
}
else if(self.cnt == 1)
sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM);
trace_plane_normal = norm;
Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT);
- W_Porto_Success();
+ W_Porto_Success(self);
}
else
{
sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
trace_plane_normal = norm;
- W_Porto_Fail(0);
+ W_Porto_Fail(self, 0);
}
}
else if(self.effects & EF_RED)
sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
trace_plane_normal = norm;
Portal_ClearAll_PortalsOnly(self.realowner);
- W_Porto_Fail(0);
+ W_Porto_Fail(self, 0);
}
}
else
sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM);
trace_plane_normal = norm;
Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT);
- W_Porto_Success();
+ W_Porto_Success(self);
}
else
{
sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
Portal_ClearAll_PortalsOnly(self.realowner);
- W_Porto_Fail(0);
+ W_Porto_Fail(self, 0);
}
}
else
{
sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
Portal_ClearAll_PortalsOnly(self.realowner);
- W_Porto_Fail(0);
+ W_Porto_Fail(self, 0);
}
}
}
-void W_Porto_Attack(float type)
-{SELFPARAM();
+void W_Porto_Attack(entity actor, float type)
+{entity this = actor;
entity gren;
W_SetupShot(self, false, 4, SND_PORTO_FIRE, CH_WEAPON_A, 0);
setsize(gren, '0 0 0', '0 0 0');
gren.nextthink = time + WEP_CVAR_BOTH(porto, (type <= 0), lifetime);
- gren.think = W_Porto_Think;
- gren.touch = W_Porto_Touch;
+ setthink(gren, W_Porto_Think);
+ settouch(gren, W_Porto_Touch);
if(self.items & ITEM_Strength.m_itemid)
W_SetupProjVelocity_Basic(gren, WEP_CVAR_BOTH(porto, (type <= 0), speed) * autocvar_g_balance_powerup_strength_force, 0);
MUTATOR_CALLHOOK(EditProjectile, self, gren);
}
-METHOD(PortoLaunch, wr_aim, void(entity thiswep))
+METHOD(PortoLaunch, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
PHYS_INPUT_BUTTON_ATCK(self) = false;
PHYS_INPUT_BUTTON_ATCK2(self) = false;
if(!WEP_CVAR(porto, secondary))
if(!actor.porto_forbidden)
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire)))
{
- W_Porto_Attack(0);
+ W_Porto_Attack(actor, 0);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
}
if(!actor.porto_forbidden)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(porto, refire)))
{
- W_Porto_Attack(1);
+ W_Porto_Attack(actor, 1);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready);
}
}
if(!actor.porto_forbidden)
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire)))
{
- W_Porto_Attack(-1);
+ W_Porto_Attack(actor, -1);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
}
}
}
-METHOD(PortoLaunch, wr_checkammo1, bool(entity this))
+METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this))
{
// always allow infinite ammo
return true;
}
-METHOD(PortoLaunch, wr_checkammo2, bool(entity this))
+METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this))
{
// always allow infinite ammo
return true;
}
-METHOD(PortoLaunch, wr_setup, void(entity thiswep))
+METHOD(PortoLaunch, wr_setup, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.ammo_field = ammo_none;
}
-METHOD(PortoLaunch, wr_resetplayer, void(entity thiswep))
+METHOD(PortoLaunch, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.porto_current = world;
}
#endif
#ifdef CSQC
-METHOD(PortoLaunch, wr_impacteffect, void(entity this)) {
+METHOD(PortoLaunch, wr_impacteffect, void(entity this, entity actor)) {
LOG_WARNING("Since when does Porto send DamageInfo?\n");
}
#endif
spawnfunc(weapon_campingrifle) { spawnfunc_weapon_rifle(this); }
spawnfunc(weapon_sniperrifle) { spawnfunc_weapon_rifle(this); }
-void W_Rifle_FireBullet(Weapon thiswep, float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, Sound pSound)
-{SELFPARAM();
+void W_Rifle_FireBullet(Weapon thiswep, float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, Sound pSound, entity actor)
+{entity this = actor;
float i;
W_DecreaseAmmo(thiswep, self, pAmmo);
SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
}
-void W_Rifle_Attack()
+void W_Rifle_Attack(entity actor)
{
- W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), WEP_RIFLE.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND_CAMPINGRIFLE_FIRE);
+ W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), WEP_RIFLE.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND_CAMPINGRIFLE_FIRE, actor);
}
-void W_Rifle_Attack2()
+void W_Rifle_Attack2(entity actor)
{
- W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), WEP_RIFLE.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND_CAMPINGRIFLE_FIRE2);
+ W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), WEP_RIFLE.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND_CAMPINGRIFLE_FIRE2, actor);
}
-.void() rifle_bullethail_attackfunc;
+.void(entity actor) rifle_bullethail_attackfunc;
.WFRAME rifle_bullethail_frame;
.float rifle_bullethail_animtime;
.float rifle_bullethail_refire;
PS(actor).m_switchweapon = sw;
if(r)
{
- actor.rifle_bullethail_attackfunc();
+ actor.rifle_bullethail_attackfunc(actor);
weapon_thinkf(actor, weaponentity, actor.rifle_bullethail_frame, actor.rifle_bullethail_animtime, W_Rifle_BulletHail_Continue);
}
else
}
}
-void W_Rifle_BulletHail(.entity weaponentity, float mode, void() AttackFunc, WFRAME fr, float animtime, float refire)
-{SELFPARAM();
+void W_Rifle_BulletHail(entity actor, .entity weaponentity, float mode, void(entity actor) AttackFunc, WFRAME fr, float animtime, float refire)
+{entity this = actor;
// if we get here, we have at least one bullet to fire
- AttackFunc();
+ AttackFunc(actor);
if(mode)
{
// continue hail
.float bot_secondary_riflemooth;
-METHOD(Rifle, wr_aim, void(entity thiswep))
+METHOD(Rifle, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
PHYS_INPUT_BUTTON_ATCK(self) = false;
PHYS_INPUT_BUTTON_ATCK2(self) = false;
if(vdist(self.origin - self.enemy.origin, >, 1000))
if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost))
{
weapon_prepareattack_do(actor, weaponentity, false, WEP_CVAR_PRI(rifle, refire));
- W_Rifle_BulletHail(weaponentity, WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+ W_Rifle_BulletHail(actor, weaponentity, WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
actor.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost);
}
if(fire & 2)
if(time >= actor.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost))
{
weapon_prepareattack_do(actor, weaponentity, true, WEP_CVAR_SEC(rifle, refire));
- W_Rifle_BulletHail(weaponentity, WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+ W_Rifle_BulletHail(actor, weaponentity, WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
actor.rifle_accumulator += WEP_CVAR_SEC(rifle, burstcost);
}
}
}
}
}
-METHOD(Rifle, wr_checkammo1, bool(entity thiswep))
+METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
- ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
+ ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
return ammo_amount;
}
-METHOD(Rifle, wr_checkammo2, bool(entity thiswep))
+METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
- ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
+ ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
return ammo_amount;
}
-METHOD(Rifle, wr_resetplayer, void(entity thiswep))
+METHOD(Rifle, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.rifle_accumulator = time - WEP_CVAR(rifle, bursttime);
}
METHOD(Rifle, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND_RELOAD);
+ W_Reload(actor, min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND_RELOAD);
}
METHOD(Rifle, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(Rifle, wr_impacteffect, void(entity thiswep))
+METHOD(Rifle, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 2;
pointparticles(EFFECT_RIFLE_IMPACT, org2, w_backoff * 1000, 1);
// ============================
// Begin: Missile functions, these are general functions to be manipulated by other code
// ============================
-void W_Seeker_Missile_Explode()
-{SELFPARAM();
+void W_Seeker_Missile_Explode(entity this)
+{
self.event_damage = func_null;
RadiusDamage(self, self.realowner, WEP_CVAR(seeker, missile_damage), WEP_CVAR(seeker, missile_edgedamage), WEP_CVAR(seeker, missile_radius), world, world, WEP_CVAR(seeker, missile_force), self.projectiledeathtype, other);
remove(self);
}
-void W_Seeker_Missile_Touch()
+void W_Seeker_Missile_Touch(entity this)
{
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
- W_Seeker_Missile_Explode();
+ W_Seeker_Missile_Explode(this);
}
-void W_Seeker_Missile_Think()
-{SELFPARAM();
+void W_Seeker_Missile_Think(entity this)
+{
entity e;
vector desireddir, olddir, newdir, eorg;
float turnrate;
if(time > self.cnt)
{
self.projectiledeathtype |= HITTYPE_SPLASH;
- W_Seeker_Missile_Explode();
+ W_Seeker_Missile_Explode(self);
}
spd = vlen(self.velocity);
{
if(self.autoswitch <= time)
{
- W_Seeker_Missile_Explode();
+ W_Seeker_Missile_Explode(self);
self.autoswitch = 0;
}
}
}
*/
-void W_Seeker_Fire_Missile(Weapon thiswep, vector f_diff, entity m_target)
-{SELFPARAM();
+void W_Seeker_Fire_Missile(Weapon thiswep, entity actor, vector f_diff, entity m_target)
+{entity this = actor;
entity missile;
W_DecreaseAmmo(thiswep, self, WEP_CVAR(seeker, missile_ammo));
missile.bot_dodge = true;
missile.bot_dodgerating = WEP_CVAR(seeker, missile_damage);
- missile.think = W_Seeker_Missile_Think;
- missile.touch = W_Seeker_Missile_Touch;
+ setthink(missile, W_Seeker_Missile_Think);
+ settouch(missile, W_Seeker_Missile_Touch);
missile.event_damage = W_Seeker_Missile_Damage;
missile.nextthink = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
missile.cnt = time + WEP_CVAR(seeker, missile_lifetime);
// ============================
// Begin: FLAC, close range attack meant for defeating rockets which are coming at you.
// ============================
-void W_Seeker_Flac_Explode()
-{SELFPARAM();
+void W_Seeker_Flac_Explode(entity this)
+{
self.event_damage = func_null;
RadiusDamage(self, self.realowner, WEP_CVAR(seeker, flac_damage), WEP_CVAR(seeker, flac_edgedamage), WEP_CVAR(seeker, flac_radius), world, world, WEP_CVAR(seeker, flac_force), self.projectiledeathtype, other);
void W_Seeker_Flac_Explode_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_Seeker_Flac_Explode());
-}
-
-void W_Seeker_Flac_Touch()
-{
- PROJECTILE_TOUCH;
-
- W_Seeker_Flac_Explode();
+ WITHSELF(this, W_Seeker_Flac_Explode(this));
}
-void W_Seeker_Fire_Flac(Weapon thiswep)
-{SELFPARAM();
+void W_Seeker_Fire_Flac(Weapon thiswep, entity actor)
+{entity this = actor;
entity missile;
vector f_diff;
float c;
missile.owner = missile.realowner = self;
missile.bot_dodge = true;
missile.bot_dodgerating = WEP_CVAR(seeker, flac_damage);
- missile.touch = W_Seeker_Flac_Explode;
+ settouch(missile, W_Seeker_Flac_Explode);
missile.use = W_Seeker_Flac_Explode_use;
- missile.think = adaptor_think2use_hittype_splash;
+ setthink(missile, adaptor_think2use_hittype_splash);
missile.nextthink = time + WEP_CVAR(seeker, flac_lifetime) + WEP_CVAR(seeker, flac_lifetime_rand);
missile.solid = SOLID_BBOX;
missile.movetype = MOVETYPE_FLY;
return world;
}
-void W_Seeker_Attack()
-{SELFPARAM();
+void W_Seeker_Attack(entity actor)
+{entity this = actor;
entity tracker, closest_target;
closest_target = world;
if((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target)))
closest_target = world;
- W_Seeker_Fire_Missile(WEP_SEEKER, '0 0 0', closest_target);
+ W_Seeker_Fire_Missile(WEP_SEEKER, actor, '0 0 0', closest_target);
}
-void W_Seeker_Vollycontroller_Think() // TODO: Merge this with W_Seeker_Attack
-{SELFPARAM();
+void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seeker_Attack
+{
float c;
entity oldenemy;
- self.cnt = self.cnt - 1;
+ this.cnt = this.cnt - 1;
Weapon thiswep = WEP_SEEKER;
- if((!(self.realowner.items & IT_UNLIMITED_AMMO) && self.realowner.(thiswep.ammo_field) < WEP_CVAR(seeker, missile_ammo)) || (self.cnt <= -1) || (IS_DEAD(self.realowner)) || (PS(self.realowner).m_switchweapon != WEP_SEEKER))
+ if((!(this.realowner.items & IT_UNLIMITED_AMMO) && this.realowner.(thiswep.ammo_field) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (PS(this.realowner).m_switchweapon != WEP_SEEKER))
{
- remove(self);
+ remove(this);
return;
}
- self.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor();
+ this.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor();
- setself(self.realowner);
+ entity own = this.realowner;
- oldenemy = self.enemy;
- self.enemy = this.enemy;
+ oldenemy = own.enemy;
+ own.enemy = this.enemy;
- c = self.cnt % 4;
+ c = own.cnt % 4;
switch(c)
{
case 0:
- W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 -3.75 0', self.enemy);
+ WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, own, '-1.25 -3.75 0', own.enemy));
break;
case 1:
- W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 -3.75 0', self.enemy);
+ WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, own, '+1.25 -3.75 0', own.enemy));
break;
case 2:
- W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 +3.75 0', self.enemy);
+ WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, own, '-1.25 +3.75 0', own.enemy));
break;
case 3:
default:
- W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 +3.75 0', self.enemy);
+ WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, own, '+1.25 +3.75 0', own.enemy));
break;
}
- self.enemy = oldenemy;
- setself(this);
+ own.enemy = oldenemy;
}
-void W_Seeker_Tracker_Think()
-{SELFPARAM();
+void W_Seeker_Tracker_Think(entity this)
+{
// commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up
if((IS_DEAD(self.realowner)) || (IS_DEAD(self.tag_target)) || (PS(self.realowner).m_switchweapon != WEP_SEEKER)
|| (time > self.tag_time + WEP_CVAR(seeker, tag_tracker_lifetime)))
W_Seeker_Tag_Explode(this);
}
-void W_Seeker_Tag_Touch()
-{SELFPARAM();
+void W_Seeker_Tag_Touch(entity this)
+{
vector dir;
vector org2;
entity e;
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
dir = normalize(self.realowner.origin - self.origin);
org2 = findbetterlocation(self.origin, 8);
{
e.tag_target = other;
e.tag_time = time;
- e.think = W_Seeker_Tracker_Think;
+ setthink(e, W_Seeker_Tracker_Think);
}
else
{
e.enemy = other;
- e.think = W_Seeker_Vollycontroller_Think;
+ setthink(e, W_Seeker_Vollycontroller_Think);
}
e.nextthink = time;
return;
}
-void W_Seeker_Fire_Tag(Weapon thiswep)
-{SELFPARAM();
+void W_Seeker_Fire_Tag(Weapon thiswep, entity actor)
+{entity this = actor;
entity missile;
W_DecreaseAmmo(thiswep, self, WEP_CVAR(seeker, tag_ammo));
missile.owner = missile.realowner = self;
missile.bot_dodge = true;
missile.bot_dodgerating = 50;
- missile.touch = W_Seeker_Tag_Touch;
- missile.think = SUB_Remove_self;
+ settouch(missile, W_Seeker_Tag_Touch);
+ setthink(missile, SUB_Remove);
missile.nextthink = time + WEP_CVAR(seeker, tag_lifetime);
missile.movetype = MOVETYPE_FLY;
missile.solid = SOLID_BBOX;
// Begin: Genereal weapon functions
// ============================
-METHOD(Seeker, wr_aim, void(entity thiswep))
+METHOD(Seeker, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(WEP_CVAR(seeker, type) == 1)
if(W_Seeker_Tagged_Info(self, self.enemy) != world)
PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false);
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, missile_refire)))
{
- W_Seeker_Attack();
+ W_Seeker_Attack(actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready);
}
}
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
{
- W_Seeker_Fire_Tag(thiswep);
+ W_Seeker_Fire_Tag(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
}
}
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
{
- W_Seeker_Fire_Tag(thiswep);
+ W_Seeker_Fire_Tag(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
}
}
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, flac_refire)))
{
- W_Seeker_Fire_Flac(thiswep);
+ W_Seeker_Fire_Flac(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready);
}
}
}
}
-METHOD(Seeker, wr_checkammo1, bool(entity thiswep))
+METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(seeker, type) == 1)
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo);
- ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo);
+ ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo);
}
else
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
- ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
}
return ammo_amount;
}
-METHOD(Seeker, wr_checkammo2, bool(entity thiswep))
+METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(seeker, type) == 1)
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
- ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
}
else
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo);
- ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo);
+ ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo);
}
return ammo_amount;
}
METHOD(Seeker, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND_RELOAD);
+ W_Reload(actor, min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND_RELOAD);
}
METHOD(Seeker, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(Seeker, wr_impacteffect, void(entity thiswep))
+METHOD(Seeker, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 6;
if(w_deathtype & HITTYPE_BOUNCE)
vector shockwave_hit_force[MAX_SHOCKWAVE_HITS];
// MELEE ATTACK MODE
-void W_Shockwave_Melee_Think()
-{SELFPARAM();
+void W_Shockwave_Melee_Think(entity this)
+{
// declarations
float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
entity target_victim;
entity meleetemp = new_pure(meleetemp);
meleetemp.owner = meleetemp.realowner = actor;
- meleetemp.think = W_Shockwave_Melee_Think;
+ setthink(meleetemp, W_Shockwave_Melee_Think);
meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
W_SetupShot_Range(actor, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
}
}
float W_Shockwave_Attack_IsVisible(
+ entity actor,
entity head,
vector nearest_on_line,
vector sw_shotorg,
vector attack_endpos)
-{SELFPARAM();
+{entity this = actor;
vector nearest_to_attacker = head.WarpZone_findradius_nearest;
vector center = (head.origin + (head.mins + head.maxs) * 0.5);
vector corner;
return true;
}
-void W_Shockwave_Send()
-{SELFPARAM();
+void W_Shockwave_Send(entity actor)
+{
WriteHeader(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE);
WriteCoord(MSG_BROADCAST, w_shotorg.x);
WriteCoord(MSG_BROADCAST, w_shotorg.y);
WriteShort(MSG_BROADCAST, WEP_CVAR(shockwave, blast_distance));
WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_max), 255));
WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_min), 255));
- WriteByte(MSG_BROADCAST, etof(self));
+ WriteByte(MSG_BROADCAST, etof(actor));
}
-void W_Shockwave_Attack()
-{SELFPARAM();
+void W_Shockwave_Attack(entity actor)
+{entity this = actor;
// declarations
float multiplier, multiplier_from_accuracy, multiplier_from_distance;
float final_damage;
//entity transform = WarpZone_trace_transform;
// do the firing effect now
- W_Shockwave_Send();
+ W_Shockwave_Send(self);
Damage_DamageInfo(
attack_hitpos,
WEP_CVAR(shockwave, blast_splash_damage),
vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
if((vlen(head.WarpZone_findradius_dist) <= WEP_CVAR(shockwave, blast_distance))
- && (W_Shockwave_Attack_IsVisible(head, nearest_on_line, w_shotorg, attack_endpos)))
+ && (W_Shockwave_Attack_IsVisible(self, head, nearest_on_line, w_shotorg, attack_endpos)))
{
// calculate importance of distance and accuracy for this attack
multiplier_from_accuracy = (1 -
}
}
-METHOD(Shockwave, wr_aim, void(entity thiswep))
+METHOD(Shockwave, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
{ PHYS_INPUT_BUTTON_ATCK2(self) = bot_aim(self, 1000000, 0, 0.001, false); }
else
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(shockwave, blast_animtime)))
{
- W_Shockwave_Attack();
+ W_Shockwave_Attack(actor);
actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
}
}
}
}
-METHOD(Shockwave, wr_checkammo1, bool(entity thiswep))
+METHOD(Shockwave, wr_checkammo1, bool(entity thiswep, entity actor))
{
return true; // infinite ammo
}
-METHOD(Shockwave, wr_checkammo2, bool(entity thiswep))
+METHOD(Shockwave, wr_checkammo2, bool(entity thiswep, entity actor))
{
// shockwave has infinite ammo
return true;
shockwave.sw_time = time;
}
-METHOD(Shockwave, wr_impacteffect, void(entity thiswep))
+METHOD(Shockwave, wr_impacteffect, void(entity thiswep, entity actor))
{
// handled by Net_ReadShockwaveParticle
//vector org2;
#ifdef SVQC
spawnfunc(weapon_shotgun) { weapon_defaultspawnfunc(this, WEP_SHOTGUN); }
-void W_Shotgun_Attack(Weapon thiswep, float isprimary)
-{SELFPARAM();
+void W_Shotgun_Attack(Weapon thiswep, entity actor, float isprimary)
+{entity this = actor;
float sc;
entity flash;
// muzzle flash for 1st person view
flash = spawn();
setmodel(flash, MDL_SHOTGUN_MUZZLEFLASH); // precision set below
- flash.think = SUB_Remove_self;
+ setthink(flash, SUB_Remove);
flash.nextthink = time + 0.06;
flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
W_AttachToShotorg(self, flash, '5 0 0');
.float swing_prev;
.entity swing_alreadyhit;
-void W_Shotgun_Melee_Think()
-{SELFPARAM();
+void W_Shotgun_Melee_Think(entity this)
+{
// declarations
float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
entity target_victim;
entity meleetemp = new_pure(meleetemp);
meleetemp.realowner = actor;
- meleetemp.think = W_Shotgun_Melee_Think;
+ setthink(meleetemp, W_Shotgun_Melee_Think);
meleetemp.nextthink = time + WEP_CVAR_SEC(shotgun, melee_delay) * W_WeaponRateFactor();
W_SetupShot_Range(actor, true, 0, SND_Null, 0, WEP_CVAR_SEC(shotgun, damage), WEP_CVAR_SEC(shotgun, melee_range));
}
// alternate secondary weapon frames
void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- if (!thiswep.wr_checkammo2(thiswep))
+ if (!thiswep.wr_checkammo2(thiswep, actor))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
}
sound(actor, CH_WEAPON_SINGLE, SND_Null, VOL_BASE, ATTN_NORM); // kill previous sound
- W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound
+ W_Shotgun_Attack(WEP_SHOTGUN, actor, true); // actually is secondary, but we trick the last shot into playing full reload sound
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready);
}
void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- if (!thiswep.wr_checkammo2(thiswep))
+ if (!thiswep.wr_checkammo2(thiswep, actor))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
return;
}
- W_Shotgun_Attack(WEP_SHOTGUN, false);
+ W_Shotgun_Attack(WEP_SHOTGUN, actor, false);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame2);
}
.float shotgun_primarytime;
-METHOD(Shotgun, wr_aim, void(entity thiswep))
+METHOD(Shotgun, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(vdist(self.origin - self.enemy.origin, <=, WEP_CVAR_SEC(shotgun, melee_range)))
PHYS_INPUT_BUTTON_ATCK2(self) = bot_aim(self, 1000000, 0, 0.001, false);
else
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(shotgun, animtime)))
{
- W_Shotgun_Attack(thiswep, true);
+ W_Shotgun_Attack(thiswep, actor, true);
actor.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor();
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready);
}
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(shotgun, alt_animtime)))
{
- W_Shotgun_Attack(thiswep, false);
+ W_Shotgun_Attack(thiswep, actor, false);
actor.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor();
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1);
}
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, W_Shotgun_Attack2);
}
}
-METHOD(Shotgun, wr_setup, void(entity thiswep))
+METHOD(Shotgun, wr_setup, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.ammo_field = ammo_none;
}
-METHOD(Shotgun, wr_checkammo1, bool(entity thiswep))
+METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
- ammo_amount += self.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
+ ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
return ammo_amount;
}
-METHOD(Shotgun, wr_checkammo2, bool(entity thiswep))
+METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- if(IS_BOT_CLIENT(self))
- if(vdist(self.origin - self.enemy.origin, >, WEP_CVAR_SEC(shotgun, melee_range)))
+ if(IS_BOT_CLIENT(actor))
+ if(vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_SEC(shotgun, melee_range)))
return false; // bots cannot use secondary out of range (fixes constant melee when out of ammo)
switch(WEP_CVAR(shotgun, secondary))
{
case 1: return true; // melee does not use ammo
case 2: // secondary triple shot
{
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
- ammo_amount += self.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
+ ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
return ammo_amount;
}
default: return false; // secondary unavailable
}
METHOD(Shotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, WEP_CVAR_PRI(shotgun, ammo), SND_RELOAD); // WEAPONTODO
+ W_Reload(actor, WEP_CVAR_PRI(shotgun, ammo), SND_RELOAD); // WEAPONTODO
}
METHOD(Shotgun, wr_suicidemessage, Notification(entity thiswep))
{
#ifdef CSQC
.float prevric;
-METHOD(Shotgun, wr_impacteffect, void(entity thiswep))
+METHOD(Shotgun, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2 = w_org + w_backoff * 2;
pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
if(!w_issilent && time - self.prevric > 0.25)
return true;
}
-void W_Tuba_NoteThink()
-{SELFPARAM();
+void W_Tuba_NoteThink(entity this)
+{
float dist_mult;
float vol0, vol1;
vector dir0, dir1;
});
}
-void W_Tuba_NoteOn(float hittype)
-{SELFPARAM();
+void W_Tuba_NoteOn(entity actor, float hittype)
+{entity this = actor;
vector o;
float n;
self.tuba_note.owner = self.tuba_note.realowner = self;
self.tuba_note.cnt = n;
self.tuba_note.tuba_instrument = self.tuba_instrument;
- self.tuba_note.think = W_Tuba_NoteThink;
+ setthink(self.tuba_note, W_Tuba_NoteThink);
self.tuba_note.nextthink = time;
self.tuba_note.spawnshieldtime = time;
Net_LinkEntity(self.tuba_note, false, 0, W_Tuba_NoteSendEntity);
#endif
#ifdef SVQC
-METHOD(Tuba, wr_aim, void(Tuba this))
+METHOD(Tuba, wr_aim, void(Tuba this, entity actor))
{
- entity actor = self;
// bots cannot play the Tuba well yet
// I think they should start with the recorder first
if (vdist((actor.origin - actor.enemy.origin), <, WEP_CVAR(tuba, radius)))
if (fire & 1)
if (weapon_prepareattack(this, actor, weaponentity, false, WEP_CVAR(tuba, refire)))
{
- W_Tuba_NoteOn(0);
+ W_Tuba_NoteOn(actor, 0);
weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
}
if (fire & 2)
if (weapon_prepareattack(this, actor, weaponentity, true, WEP_CVAR(tuba, refire)))
{
- W_Tuba_NoteOn(HITTYPE_SECONDARY);
+ W_Tuba_NoteOn(actor, HITTYPE_SECONDARY);
weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
}
if (actor.tuba_note)
}
}
-METHOD(Tuba, wr_setup, void(Tuba this))
+METHOD(Tuba, wr_setup, void(Tuba this, entity actor))
{
- entity actor = self;
actor.ammo_field = ammo_none;
actor.tuba_instrument = 0;
}
#ifdef SVQC
// infinite ammo
-METHOD(Tuba, wr_checkammo1, bool(Tuba this)) { return true; }
-METHOD(Tuba, wr_checkammo2, bool(Tuba this)) { return true; }
+METHOD(Tuba, wr_checkammo1, bool(Tuba this, entity actor)) { return true; }
+METHOD(Tuba, wr_checkammo2, bool(Tuba this, entity actor)) { return true; }
METHOD(Tuba, wr_suicidemessage, Notification(Tuba this))
{
}
}
-void Ent_TubaNote_Think()
-{SELFPARAM();
+void Ent_TubaNote_Think(entity this)
+{
float f = autocvar_g_balance_tuba_fadetime;
if (f > 0) {
this.tuba_volume -= frametime * this.tuba_volume_initial / f;
this.enemy = NULL;
}
-void Ent_TubaNote_StopSound_self() { SELFPARAM(); Ent_TubaNote_StopSound(self); }
-
NET_HANDLE(ENT_CLIENT_TUBANOTE, bool isNew)
{
bool upd = false;
}
}
- this.think = Ent_TubaNote_StopSound_self;
+ setthink(this, Ent_TubaNote_StopSound);
this.entremove = Ent_TubaNote_StopSound;
- this.enemy.think = Ent_TubaNote_Think;
+ setthink(this.enemy, Ent_TubaNote_Think);
this.enemy.nextthink = time + 10;
if (upd) {
NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew)
{
Net_Accept(vortex_beam);
- this.think = SUB_Remove_self;
+ setthink(this, SUB_Remove);
this.nextthink = time + bound(0, autocvar_cl_vaporizerbeam_lifetime, 10);
this.draw = VaporizerBeam_Draw;
this.drawmask = MASK_NORMAL;
spawnfunc(weapon_vaporizer) { weapon_defaultspawnfunc(this, WEP_VAPORIZER); }
spawnfunc(weapon_minstanex) { spawnfunc_weapon_vaporizer(this); }
-void W_RocketMinsta_Explosion(vector loc)
-{SELFPARAM();
+void W_RocketMinsta_Explosion(entity actor, vector loc)
+{entity this = actor;
if(accuracy_canbegooddamage(self))
accuracy_add(self, WEP_DEVASTATOR.m_id, autocvar_g_rm_damage, 0);
entity dmgent = spawn();
remove(dmgent);
}
-void W_Vaporizer_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Vaporizer_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
bool flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000);
yoda = 0;
damage_goodhits = 0;
- FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
+ FireRailgunBullet(self, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
// do this now, as goodhits is disabled below
SendCSQCVaporizerBeamParticle(self, damage_goodhits);
if(autocvar_g_rm)
if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
- W_RocketMinsta_Explosion(trace_endpos);
+ W_RocketMinsta_Explosion(self, trace_endpos);
W_DecreaseAmmo(thiswep, self, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)));
}
-void W_RocketMinsta_Laser_Explode ()
-{SELFPARAM();
+void W_RocketMinsta_Laser_Explode (entity this)
+{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
if(DIFF_TEAM(self.realowner, other))
void W_RocketMinsta_Laser_Explode_use(entity this, entity actor, entity trigger)
{
- WITHSELF(this, W_RocketMinsta_Laser_Explode());
+ WITHSELF(this, W_RocketMinsta_Laser_Explode(this));
}
-void W_RocketMinsta_Laser_Touch ()
-{SELFPARAM();
- PROJECTILE_TOUCH;
+void W_RocketMinsta_Laser_Touch (entity this)
+{
+ PROJECTILE_TOUCH(this);
//W_RocketMinsta_Laser_Explode ();
RadiusDamage (self, self.realowner, self.rm_damage, self.rm_edmg, autocvar_g_rm_laser_radius, world, world, self.rm_force, self.projectiledeathtype, other);
remove(self);
}
-void W_RocketMinsta_Attack2()
-{SELFPARAM();
+void W_RocketMinsta_Attack2(entity actor)
+{entity this = actor;
makevectors(self.v_angle);
entity proj;
proj.bot_dodge = true;
proj.bot_dodgerating = autocvar_g_rm_laser_damage;
proj.use = W_RocketMinsta_Laser_Explode_use;
- proj.think = adaptor_think2use_hittype_splash;
+ setthink(proj, adaptor_think2use_hittype_splash);
proj.nextthink = time + autocvar_g_rm_laser_lifetime;
PROJECTILE_MAKETRIGGER(proj);
proj.projectiledeathtype = WEP_ELECTRO.m_id;
proj.velocity_z = proj.velocity_z + cvar("g_rm_laser_zspread") * (random() - 0.5);
proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true);
proj.angles = vectoangles(proj.velocity);
- proj.touch = W_RocketMinsta_Laser_Touch;
+ settouch(proj, W_RocketMinsta_Laser_Touch);
setsize(proj, '0 0 -3', '0 0 -3');
proj.flags = FL_PROJECTILE;
proj.missile_flags = MIF_SPLASH;
}
}
-void W_RocketMinsta_Attack3 ()
-{SELFPARAM();
+void W_RocketMinsta_Attack3 (entity actor)
+{entity this = actor;
makevectors(self.v_angle);
entity proj;
proj.bot_dodge = true;
proj.bot_dodgerating = autocvar_g_rm_laser_damage;
proj.use = W_RocketMinsta_Laser_Explode_use;
- proj.think = adaptor_think2use_hittype_splash;
+ setthink(proj, adaptor_think2use_hittype_splash);
proj.nextthink = time + autocvar_g_rm_laser_lifetime;
PROJECTILE_MAKETRIGGER(proj);
proj.projectiledeathtype = WEP_ELECTRO.m_id;
proj.velocity = w_shotdir * autocvar_g_rm_laser_speed;
proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true);
proj.angles = vectoangles(proj.velocity);
- proj.touch = W_RocketMinsta_Laser_Touch;
+ settouch(proj, W_RocketMinsta_Laser_Touch);
setsize(proj, '0 0 -3', '0 0 -3');
proj.flags = FL_PROJECTILE;
proj.missile_flags = MIF_SPLASH;
}
}
-METHOD(Vaporizer, wr_aim, void(entity thiswep))
+METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(self.(thiswep.ammo_field) > 0)
PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, 1000000, 0, 1, false);
else
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire)))
{
- W_Vaporizer_Attack(thiswep);
+ W_Vaporizer_Attack(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
}
}
actor.jump_interval = time + autocvar_g_rm_laser_refire;
actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay;
damage_goodhits = 0;
- W_RocketMinsta_Attack2();
+ W_RocketMinsta_Attack2(actor);
}
else if(rapid && actor.jump_interval2 <= time && actor.held_down)
{
actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire;
damage_goodhits = 0;
- W_RocketMinsta_Attack3();
+ W_RocketMinsta_Attack3(actor);
//weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready);
}
}
else
actor.held_down = false;
}
-METHOD(Vaporizer, wr_setup, void(entity thiswep))
+METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.ammo_field = (thiswep.ammo_field);
self.vaporizer_lasthit = 0;
}
-METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep))
+METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
- float ammo_amount = self.(thiswep.ammo_field) >= vaporizer_ammo;
- ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
+ float ammo_amount = actor.(thiswep.ammo_field) >= vaporizer_ammo;
+ ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
return ammo_amount;
}
-METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep))
+METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
if(!WEP_CVAR_SEC(vaporizer, ammo))
return true;
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo);
- ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo);
+ ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
return ammo_amount;
}
-METHOD(Vaporizer, wr_resetplayer, void(entity thiswep))
+METHOD(Vaporizer, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
self.vaporizer_lasthit = 0;
}
METHOD(Vaporizer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
float used_ammo;
if(WEP_CVAR_SEC(vaporizer, ammo))
else
used_ammo = vaporizer_ammo;
- W_Reload(self, used_ammo, SND_RELOAD);
+ W_Reload(actor, used_ammo, SND_RELOAD);
}
METHOD(Vaporizer, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(Vaporizer, wr_impacteffect, void(entity thiswep))
+METHOD(Vaporizer, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2 = w_org + w_backoff * 6;
if(w_deathtype & HITTYPE_SECONDARY)
{
}
}
-void W_Vortex_Attack(Weapon thiswep, float issecondary)
-{SELFPARAM();
+void W_Vortex_Attack(Weapon thiswep, entity actor, float issecondary)
+{entity this = actor;
float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
mydmg = WEP_CVAR_BOTH(vortex, !issecondary, damage);
yoda = 0;
damage_goodhits = 0;
- FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
+ FireRailgunBullet(self, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
if(yoda && flying)
Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
.float vortex_chargepool_pauseregen_finished;
-METHOD(Vortex, wr_aim, void(entity thiswep))
+METHOD(Vortex, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if(bot_aim(self, 1000000, 0, 1, false))
PHYS_INPUT_BUTTON_ATCK(self) = true;
else
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vortex, refire)))
{
- W_Vortex_Attack(thiswep, 0);
+ W_Vortex_Attack(thiswep, actor, 0);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready);
}
}
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(vortex, refire)))
{
- W_Vortex_Attack(thiswep, 1);
+ W_Vortex_Attack(thiswep, actor, 1);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready);
}
}
}
}
}
-METHOD(Vortex, wr_setup, void(entity thiswep))
+METHOD(Vortex, wr_setup, void(entity thiswep, entity actor))
{
- SELFPARAM();
- self.vortex_lasthit = 0;
+ actor.vortex_lasthit = 0;
}
-METHOD(Vortex, wr_checkammo1, bool(entity thiswep))
+METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo);
- ammo_amount += (autocvar_g_balance_vortex_reload_ammo && self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo);
+ ammo_amount += (autocvar_g_balance_vortex_reload_ammo && actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
return ammo_amount;
}
-METHOD(Vortex, wr_checkammo2, bool(entity thiswep))
+METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
if(WEP_CVAR(vortex, secondary))
{
// don't allow charging if we don't have enough ammo
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(vortex, ammo);
- ammo_amount += self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vortex, ammo);
+ ammo_amount += actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
return ammo_amount;
}
else
return false; // zoom is not a fire mode
}
}
-METHOD(Vortex, wr_resetplayer, void(entity thiswep))
+METHOD(Vortex, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
if (WEP_CVAR(vortex, charge)) {
if (WEP_CVAR_SEC(vortex, chargepool)) {
self.vortex_chargepool_ammo = 1;
}
METHOD(Vortex, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND_RELOAD);
+ W_Reload(actor, min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND_RELOAD);
}
METHOD(Vortex, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(Vortex, wr_impacteffect, void(entity thiswep))
+METHOD(Vortex, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2 = w_org + w_backoff * 6;
pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
if(!w_issilent)
#define use use1
.void(entity this, entity actor, entity trigger) use;
+#define touch move_touch
#endif
if (view.csqcmodel_teleported) refdefflags |= REFDEFFLAG_TELEPORTED;
if (input_buttons & BIT(1)) refdefflags |= REFDEFFLAG_JUMPING;
// note: these two only work in WIP2, but are harmless in WIP1
- if (STAT(HEALTH) <= 0) refdefflags |= REFDEFFLAG_DEAD;
+ if (STAT(HEALTH) <= 0 && STAT(HEALTH) != -666 && STAT(HEALTH) != -2342) refdefflags |= REFDEFFLAG_DEAD;
if (intermission) refdefflags |= REFDEFFLAG_INTERMISSION;
V_CalcRefdef(view, refdefflags);
}
// generic CSQC model code
-bool CSQCModel_Send(entity to, int sf)
+bool CSQCModel_Send(entity this, entity to, int sf)
{
- SELFPARAM();
// some nice flags for CSQCMODEL_IF
noref bool isplayer = IS_CLIENT(this);
noref bool islocalplayer = (this == to);
void CSQCModel_LinkEntity(entity e)
{
- e.SendEntity = CSQCModel_Send;
+ e.SendEntity = SendEntity_self;
+ e.SendEntity3 = CSQCModel_Send;
e.SendFlags = 0xFFFFFF;
CSQCModel_CheckUpdate(e);
}
void CSQCModel_UnlinkEntity(entity e)
{
e.SendEntity = func_null;
+ e.SendEntity3 = func_null;
}
entityclass(Defer);
class(Defer).entity owner;
- class(Defer).void() think;
- class(Defer).float nextthink;
class(Defer).void(entity) defer_func;
/** Remove self */
remove(this);
}
- /** Remove self */
- void SUB_Remove_self()
- {
- SELFPARAM();
- remove(this);
- }
-
- void defer_think()
+ void defer_think(entity this)
{
- SELFPARAM();
- this.think = SUB_Remove_self;
+ setthink(this, SUB_Remove);
this.nextthink = time;
this.defer_func(this.owner);
}
entity e = new_pure(deferred);
e.owner = this;
e.defer_func = func;
- e.think = defer_think;
+ setthink(e, defer_think);
e.nextthink = time + fdelay;
}
if (dt)
{
e.nextthink = time + dt;
- e.think = SUB_Remove_self;
+ setthink(e, SUB_Remove);
}
}
#if 1
#undef self
#define self (this, self)
+ #undef SELFPARAM
+ #define SELFPARAM() const entity this = __self
#endif
// Step 4: kill unstructured setself
// Step 5: this should work
#if 0
+ #undef self
#define self (0, this)
#endif
-// Step 6: Remove SELFPARAM in favor of a parameter
+// Step 6: remove SELFPARAM, add parameters
+#if 0
+ #undef SELFPARAM
+#endif
+
+// Step 7: remove WITHSELF, no replacement
+#if 0
+ #undef WITHSELF
+ #define WITHSELF(value, block) block
+#endif
+
+#define SELFWRAP(T, R, args, forward) \
+ .R() T; \
+ .R() __##T = T; \
+ .R args self##T; \
+ R T##_self() { SELFPARAM(); return this.self##T forward; }
+
+noref entity _selftemp;
+#define SELFWRAP_SET(T, e, f) \
+ (_selftemp = (e), _selftemp.__##T = ((f) ? T##_self : func_null), _selftemp.self##T = (f))
+#define SELFWRAP_GET(T, e) \
+ (0, (e).self##T)
+#define _SELFWRAP_SET(T, e, f) \
+ ((e).__##T = (f))
+#define _SELFWRAP_GET(T, e) \
+ (0, (e).__##T)
-.void(entity this) selftouch;
-void touch_self() { SELFPARAM(); this.selftouch(this); }
-#define settouch(e, f) (e.touch = touch_self, e.selftouch = f)
+SELFWRAP(think, void, (entity this), (this))
+#define setthink(e, f) SELFWRAP_SET(think, e, f)
+#define getthink(e) SELFWRAP_GET(think, e)
-//.void(entity this) selfuse;
-//void use_self() { SELFPARAM(); this.selfuse(this); }
-//#define setuse(e, f) (e.use = use_self, e.selfuse = f)
+SELFWRAP(touch, void, (entity this), (this))
+#define settouch(e, f) SELFWRAP_SET(touch, e, f)
+#define gettouch(e) SELFWRAP_GET(touch, e)
-.void(entity this) selfthink;
-void think_self() { SELFPARAM(); this.selfthink(this); }
-#define setthink(e, f) (e.think = think_self, e.selfthink = f)
+SELFWRAP(predraw, void, (entity this), (this))
+#define setpredraw(e, f) SELFWRAP_SET(predraw, e, f)
+
+#ifndef MENUQC
+void adaptor_think2touch(entity this) { WITH(entity, other, NULL, gettouch(this)(this)); }
+void adaptor_think2use(entity this) { if (this.use) this.use(this, NULL, NULL); }
+#endif
this.drawmask = MASK_NORMAL;
}
-void WarpZone_Touch ();
+void WarpZone_Touch (entity this);
NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew)
{
warpzone_warpzones_exist = 1;
{
entity e;
vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
- float f;
warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
WarpZone_View_Outside();
#ifndef KEEP_ROLL
- float rick;
- if(autocvar_cl_rollkillspeed)
- f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
- else
- f = 0;
-
- rick = getproperty(VF_CL_VIEWANGLES_Z);
- rick *= f;
- setproperty(VF_CL_VIEWANGLES_Z, rick);
- ang.z *= f;
+ static float rollkill;
+ if (STAT(HEALTH) <= 0 && STAT(HEALTH) != -666 && STAT(HEALTH) != -2342)
+ {
+ if(autocvar_cl_rollkillspeed)
+ {
+ rollkill += frametime * autocvar_cl_rollkillspeed;
+ rollkill = min(1, rollkill);
+ }
+ float rick;
+ rick = getproperty(VF_CL_VIEWANGLES_Z) * rollkill;
+ setproperty(VF_CL_VIEWANGLES_Z, rick);
+ ang.z *= rollkill;
+ }
+ else if(rollkill)
+ rollkill = 0;
#endif
setproperty(VF_ORIGIN, org);
}
.entity WarpZone_refsys;
-void WarpZone_RefSys_GC()
-{SELFPARAM();
+void WarpZone_RefSys_GC(entity this)
+{
// garbage collect unused reference systems
this.nextthink = time + 1;
if(this.owner.WarpZone_refsys != this)
{
me.WarpZone_refsys = new(warpzone_refsys);
me.WarpZone_refsys.owner = me;
- me.WarpZone_refsys.think = WarpZone_RefSys_GC;
+ setthink(me.WarpZone_refsys, WarpZone_RefSys_GC);
me.WarpZone_refsys.nextthink = time + 1;
WarpZone_Accumulator_Clear(me.WarpZone_refsys);
}
return e;
}
-float WarpZoneLib_ExactTrigger_Touch()
-{SELFPARAM();
- return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, this, other);
+float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
+{
+ return !WarpZoneLib_BoxTouchesBrush(toucher.absmin, toucher.absmax, this, toucher);
}
float WarpZoneLib_MoveOutOfSolid(entity e);
#define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
-float WarpZoneLib_ExactTrigger_Touch();
-void WarpZoneLib_ExactTrigger_Init();
+float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
+void WarpZoneLib_ExactTrigger_Init(entity this);
// WARNING: this kills the trace globals
-#define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch()) return
-#define EXACTTRIGGER_INIT WarpZoneLib_ExactTrigger_Init()
+#define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch(this, other)) return
+#define EXACTTRIGGER_INIT WarpZoneLib_ExactTrigger_Init(this)
#endif
ts.SendEntity3 = WarpZone_Teleported_Send;
ts.SendFlags = 0xFFFFFF;
ts.drawonlytoclient = player;
- ts.think = SUB_Remove_self;
+ setthink(ts, SUB_Remove);
ts.nextthink = time + 1;
ts.owner = player;
ts.enemy = wz;
return 1;
}
-void WarpZone_Touch ()
-{SELFPARAM();
+void WarpZone_Touch (entity this)
+{
if(other.classname == "trigger_warpzone")
return;
#endif
return;
- if(WarpZoneLib_ExactTrigger_Touch())
+ if(WarpZoneLib_ExactTrigger_Touch(self, other))
return;
#ifdef SVQC
#ifdef WARPZONELIB_KEEPDEBUG
float WarpZone_CheckProjectileImpact(entity player)
-{SELFPARAM();
+{
vector o0, v0;
.vector orgvec, velvec;
#endif
#endif
-float WarpZone_Projectile_Touch()
-{SELFPARAM();
+float WarpZone_Projectile_Touch(entity this)
+{
if(other.classname == "trigger_warpzone")
return true;
save_ent = trace_ent;
save_inopen = trace_inopen;
save_inwater = trace_inwater;
- float f;
- if((f = WarpZone_CheckProjectileImpact(this)) != 0)
- return (f > 0);
+ float f = WarpZone_CheckProjectileImpact(this);
+ if (f) return (f > 0);
trace_dpstartcontents = save_dpstartcontents;
trace_dphitcontents = save_dphitcontents;
trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
this.enemy.aiment = this;
}
-void WarpZoneCamera_Think()
-{SELFPARAM();
+void WarpZoneCamera_Think(entity this)
+{
if(this.warpzone_save_origin != this.origin
|| this.warpzone_save_angles != this.angles
|| this.warpzone_save_eorigin != this.enemy.origin
this.SendFlags = 0xFFFFFF;
if(this.spawnflags & 1)
{
- this.think = WarpZoneCamera_Think;
+ setthink(this, WarpZoneCamera_Think);
this.nextthink = time;
}
else
}
}
-void WarpZone_Think();
+void WarpZone_Think(entity this);
void WarpZone_InitStep_FinalizeTransform(entity this)
{
if(!this.enemy || this.enemy.enemy != this)
warpzone_warpzones_exist = 1;
WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles);
- this.touch = WarpZone_Touch;
+ settouch(this, WarpZone_Touch);
this.SendFlags = 0xFFFFFF;
if(this.spawnflags & 1)
{
- this.think = WarpZone_Think;
+ setthink(this, WarpZone_Think);
this.nextthink = time;
}
else
this.scale = 1;
string m;
m = this.model;
- WarpZoneLib_ExactTrigger_Init();
+ WarpZoneLib_ExactTrigger_Init(this);
if(m != "")
{
precache_model(m);
WarpZone_InitStep_FinalizeTransform(e);
}
-void WarpZone_Think()
-{SELFPARAM();
+void WarpZone_Think(entity this)
+{
if(this.warpzone_save_origin != this.origin
|| this.warpzone_save_angles != this.angles
|| this.warpzone_save_eorigin != this.enemy.origin
void WarpZone_StartFrame()
{
- SELFPARAM();
if (!warpzone_initialized)
{
warpzone_initialized = true;
// warpzones
if (warpzone_warpzones_exist) {
- setself(WarpZone_Find(it.origin + it.mins, it.origin + it.maxs));
- if (self)
- if (!WarpZoneLib_ExactTrigger_Touch())
- if (WarpZone_PlaneDist(self, it.origin + it.view_ofs) <= 0)
- WarpZone_Teleport(self, it, -1, 0); // NOT triggering targets by this!
+ entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
+ if (e)
+ if (!WarpZoneLib_ExactTrigger_Touch(e, other))
+ if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
+ WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
}
// teleporters
if(other.teleportable)
{
- setself(Teleport_Find(it.origin + it.mins, it.origin + it.maxs));
- if (self)
- if (!WarpZoneLib_ExactTrigger_Touch())
- Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
+ entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
+ if (ent)
+ if (!WarpZoneLib_ExactTrigger_Touch(ent, other))
+ Simple_TeleportPlayer(ent, other); // NOT triggering targets by this!
}
}
});
- setself(this);
other = oldother;
}
#ifdef SVQC
void WarpZone_StartFrame();
-float WarpZone_Projectile_Touch();
+float WarpZone_Projectile_Touch(entity this);
// THESE must be defined by calling QC code:
void WarpZone_PostTeleportPlayer_Callback(entity pl);
#endif
#include "common.qh"
-void WarpZoneLib_ExactTrigger_Init()
-{SELFPARAM();
+void WarpZoneLib_ExactTrigger_Init(entity this)
+{
vector mi, ma;
if (this.movedir == '0 0 0')
if (this.angles != '0 0 0')
#define LIB_WARPZONE_UTIL_SERVER_H
float WarpZoneLib_MoveOutOfSolid(entity e);
-float WarpZoneLib_ExactTrigger_Touch();
+float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
#ifdef SVQC
-void WarpZoneLib_ExactTrigger_Init();
+void WarpZoneLib_ExactTrigger_Init(entity this);
#endif
#endif
if(this.weapons)
{
Weapon w = PS(this).m_weapon;
- w.wr_aim(w);
+ w.wr_aim(w, this);
if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(this))
{
PHYS_INPUT_BUTTON_ATCK(this) = false;
this.aistatus |= AI_STATUS_DANGER_AHEAD;
}
- dodge = havocbot_dodge();
+ dodge = havocbot_dodge(this);
dodge = dodge * bound(0,0.5+(skill+this.bot_dodgeskill)*0.1,1);
evadelava = evadelava * bound(1,3-(skill+this.bot_dodgeskill),3); //Noobs fear lava a lot and take more distance from it
traceline(this.origin, ( ( this.enemy.absmin + this.enemy.absmax ) * 0.5 ), true, world);
{
bool other_weapon_available = false;
FOREACH(Weapons, it != WEP_Null, LAMBDA(
- if(it.wr_checkammo1(it) + it.wr_checkammo2(it))
+ if(it.wr_checkammo1(it, this) + it.wr_checkammo2(it, this))
other_weapon_available = true;
));
if(other_weapon_available)
havocbot_chooserole(this);
}
-vector havocbot_dodge()
+vector havocbot_dodge(entity this)
{
// LordHavoc: disabled because this is too expensive
return '0 0 0';
#if 0
-SELFPARAM();
entity head;
vector dodge, v, n;
float danger, bestdanger, vl, d;
float havocbot_moveto(entity this, vector pos);
float havocbot_moveto_refresh_route(entity this);
-vector havocbot_dodge();
+vector havocbot_dodge(entity this);
.void(entity this) havocbot_role;
.void(entity this) havocbot_previous_role;
// relink this spawnfunc_waypoint
// (precompile a list of all reachable waypoints from this spawnfunc_waypoint)
// (SLOW!)
-void waypoint_think()
-{SELFPARAM();
+void waypoint_think(entity this)
+{
entity e;
vector sv, sm1, sm2, ev, em1, em2, dv;
if (!(wp.wpflags & WAYPOINTFLAG_NORELINK))
waypoint_clearlinks(wp);
// schedule an actual relink on next frame
- wp.think = waypoint_think;
+ setthink(wp, waypoint_think);
wp.nextthink = time;
wp.effects = EF_LOWPRECISION;
}
spawnfunc(waypoint);
void waypoint_addlink(entity from, entity to);
-void waypoint_think();
+void waypoint_think(entity this);
void waypoint_clearlinks(entity wp);
void waypoint_schedulerelink(entity wp);
#ifdef NOCHEATS
-float CheatImpulse(int imp) { return 0; }
-float CheatCommand(float argc) { return 0; }
+float CheatImpulse(entity this, int imp) { return 0; }
+float CheatCommand(entity this, int argc) { return 0; }
float CheatFrame() { return 0; }
void CheatInit() { cheatcount_total = world.cheatcount; }
void CheatShutdown() { }
{
}
-float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as argument for possible future ACL checking
-{SELFPARAM();
+float CheatsAllowed(entity this, float i, float argc, float fr) // the cheat gets passed as argument for possible future ACL checking
+{
// dead people cannot cheat
- if(IS_DEAD(self))
+ if(IS_DEAD(this))
return 0;
- if(gamestart_sv_cheats < 2 && !IS_PLAYER(self))
+ if(gamestart_sv_cheats < 2 && !IS_PLAYER(this))
return 0;
// sv_clones
if(i == CHIMPULSE_CLONE_MOVING.impulse || i == CHIMPULSE_CLONE_STANDING.impulse)
- if(self.lip < sv_clones)
+ if(this.lip < sv_clones)
return 1;
// haha
- if(self.maycheat)
+ if(this.maycheat)
return 1;
// sv_cheats
// if we get here, player is not allowed to cheat. Log it.
if(i)
- bprintf("Player %s^7 tried to use cheat 'impulse %d'\n", self.netname, i);
+ bprintf("Player %s^7 tried to use cheat 'impulse %d'\n", this.netname, i);
else if(argc)
- bprintf("Player %s^7 tried to use cheat '%s'\n", self.netname, argv(0));
+ bprintf("Player %s^7 tried to use cheat '%s'\n", this.netname, argv(0));
else if(fr)
- bprintf("Player %s^7 tried to use cheat frame %d\n", self.netname, fr);
+ bprintf("Player %s^7 tried to use cheat frame %d\n", this.netname, fr);
else
- bprintf("Player %s^7 tried to use an unknown cheat\n", self.netname);
+ bprintf("Player %s^7 tried to use an unknown cheat\n", this.netname);
return 0;
}
#define END_CHEAT_FUNCTION() \
ADD_CHEATS(this, cheating); \
return attempting
-#define IS_CHEAT(i,argc,fr) \
- if((++attempting, !CheatsAllowed(i,argc,fr))) \
+#define IS_CHEAT(ent,i,argc,fr) \
+ if((++attempting, !CheatsAllowed(ent,i,argc,fr))) \
break
float num_autoscreenshot;
void info_autoscreenshot_findtarget(entity this)
{
entity e;
- e = find(world, targetname, self.target);
+ e = find(world, targetname, this.target);
if(!e)
{
objerror("Missing target. FAIL!");
return;
}
- vector a = vectoangles(e.origin - self.origin);
+ vector a = vectoangles(e.origin - this.origin);
a.x = -a.x; // don't ask
- self.angles_x = a.x;
- self.angles_y = a.y;
+ this.angles_x = a.x;
+ this.angles_y = a.y;
// we leave Rick Roll alone
}
spawnfunc(info_autoscreenshot)
objerror("Too many info_autoscreenshot entitites. FAIL!");
return;
}
- if(self.target != "")
- InitializeEntity(self, info_autoscreenshot_findtarget, INITPRIO_FINDTARGET);
+ if(this.target != "")
+ InitializeEntity(this, info_autoscreenshot_findtarget, INITPRIO_FINDTARGET);
// this one just has to exist
}
-float CheatImpulse(int imp)
-{SELFPARAM();
+float CheatImpulse(entity this, int imp)
+{
BEGIN_CHEAT_FUNCTION();
switch(imp)
{
case CHIMPULSE_SPEEDRUN_INIT.impulse: // deploy personal waypoint
// shared with regular waypoint init, so this is not a cheat by itself
- if(!self.personal)
+ if(!this.personal)
{
- self.personal = new(personal_wp);
+ this.personal = new(personal_wp);
}
- self.personal.origin = self.origin;
- self.personal.v_angle = self.v_angle;
- self.personal.velocity = self.velocity;
- self.personal.ammo_rockets = self.ammo_rockets;
- self.personal.ammo_nails = self.ammo_nails;
- self.personal.ammo_cells = self.ammo_cells;
- self.personal.ammo_plasma = self.ammo_plasma;
- self.personal.ammo_shells = self.ammo_shells;
- self.personal.ammo_fuel = self.ammo_fuel;
- self.personal.health = self.health;
- self.personal.armorvalue = self.armorvalue;
- self.personal.weapons = self.weapons;
- self.personal.items = self.items;
- self.personal.pauserotarmor_finished = self.pauserotarmor_finished;
- self.personal.pauserothealth_finished = self.pauserothealth_finished;
- self.personal.pauserotfuel_finished = self.pauserotfuel_finished;
- self.personal.pauseregen_finished = self.pauseregen_finished;
- self.personal.strength_finished = self.strength_finished;
- self.personal.invincible_finished = self.invincible_finished;
- self.personal.teleport_time = time;
- break; // this part itself doesn't cheat, so let's not count this
+ this.personal.origin = this.origin;
+ this.personal.v_angle = this.v_angle;
+ this.personal.velocity = this.velocity;
+ this.personal.ammo_rockets = this.ammo_rockets;
+ this.personal.ammo_nails = this.ammo_nails;
+ this.personal.ammo_cells = this.ammo_cells;
+ this.personal.ammo_plasma = this.ammo_plasma;
+ this.personal.ammo_shells = this.ammo_shells;
+ this.personal.ammo_fuel = this.ammo_fuel;
+ this.personal.health = this.health;
+ this.personal.armorvalue = this.armorvalue;
+ this.personal.weapons = this.weapons;
+ this.personal.items = this.items;
+ this.personal.pauserotarmor_finished = this.pauserotarmor_finished;
+ this.personal.pauserothealth_finished = this.pauserothealth_finished;
+ this.personal.pauserotfuel_finished = this.pauserotfuel_finished;
+ this.personal.pauseregen_finished = this.pauseregen_finished;
+ this.personal.strength_finished = this.strength_finished;
+ this.personal.invincible_finished = this.invincible_finished;
+ this.personal.teleport_time = time;
+ break; // this part itthis doesn't cheat, so let's not count this
case CHIMPULSE_CLONE_MOVING.impulse:
- IS_CHEAT(imp, 0, 0);
- makevectors (self.v_angle);
- self.velocity = self.velocity + v_forward * 300;
- CopyBody(self, 1);
- self.lip += 1;
- self.velocity = self.velocity - v_forward * 300;
+ IS_CHEAT(this, imp, 0, 0);
+ makevectors (this.v_angle);
+ this.velocity = this.velocity + v_forward * 300;
+ CopyBody(this, 1);
+ this.lip += 1;
+ this.velocity = this.velocity - v_forward * 300;
DID_CHEAT();
break;
case CHIMPULSE_CLONE_STANDING.impulse:
- IS_CHEAT(imp, 0, 0);
- CopyBody(self, 0);
- self.lip += 1;
+ IS_CHEAT(this, imp, 0, 0);
+ CopyBody(this, 0);
+ this.lip += 1;
DID_CHEAT();
break;
case CHIMPULSE_GIVE_ALL.impulse:
- IS_CHEAT(imp, 0, 0);
- CheatCommand(tokenize_console("give all"));
+ IS_CHEAT(this, imp, 0, 0);
+ CheatCommand(this, tokenize_console("give all"));
break; // already counted as cheat
case CHIMPULSE_SPEEDRUN.impulse:
- IS_CHEAT(imp, 0, 0);
- if(self.personal)
+ IS_CHEAT(this, imp, 0, 0);
+ if(this.personal)
{
- self.speedrunning = true;
- tracebox(self.personal.origin, self.mins, self.maxs, self.personal.origin, MOVE_WORLDONLY, self);
+ this.speedrunning = true;
+ tracebox(this.personal.origin, this.mins, this.maxs, this.personal.origin, MOVE_WORLDONLY, this);
if(trace_startsolid)
{
- sprint(self, "Cannot move there, cheater - only waypoints set using g_waypointsprite_personal work\n");
+ sprint(this, "Cannot move there, cheater - only waypoints set using g_waypointsprite_personal work\n");
}
else
{
// Abort speedrun, teleport back
- setorigin(self, self.personal.origin);
- self.oldvelocity = self.velocity = self.personal.velocity;
- self.angles = self.personal.v_angle;
- self.fixangle = true;
+ setorigin(this, this.personal.origin);
+ this.oldvelocity = this.velocity = this.personal.velocity;
+ this.angles = this.personal.v_angle;
+ this.fixangle = true;
- MUTATOR_CALLHOOK(AbortSpeedrun, self);
+ MUTATOR_CALLHOOK(AbortSpeedrun, this);
}
- self.ammo_rockets = self.personal.ammo_rockets;
- self.ammo_nails = self.personal.ammo_nails;
- self.ammo_cells = self.personal.ammo_cells;
- self.ammo_plasma = self.personal.ammo_plasma;
- self.ammo_shells = self.personal.ammo_shells;
- self.ammo_fuel = self.personal.ammo_fuel;
- self.health = self.personal.health;
- self.armorvalue = self.personal.armorvalue;
- self.weapons = self.personal.weapons;
- self.items = self.personal.items;
- self.pauserotarmor_finished = time + self.personal.pauserotarmor_finished - self.personal.teleport_time;
- self.pauserothealth_finished = time + self.personal.pauserothealth_finished - self.personal.teleport_time;
- self.pauserotfuel_finished = time + self.personal.pauserotfuel_finished - self.personal.teleport_time;
- self.pauseregen_finished = time + self.personal.pauseregen_finished - self.personal.teleport_time;
- self.strength_finished = time + self.personal.strength_finished - self.personal.teleport_time;
- self.invincible_finished = time + self.personal.invincible_finished - self.personal.teleport_time;
+ this.ammo_rockets = this.personal.ammo_rockets;
+ this.ammo_nails = this.personal.ammo_nails;
+ this.ammo_cells = this.personal.ammo_cells;
+ this.ammo_plasma = this.personal.ammo_plasma;
+ this.ammo_shells = this.personal.ammo_shells;
+ this.ammo_fuel = this.personal.ammo_fuel;
+ this.health = this.personal.health;
+ this.armorvalue = this.personal.armorvalue;
+ this.weapons = this.personal.weapons;
+ this.items = this.personal.items;
+ this.pauserotarmor_finished = time + this.personal.pauserotarmor_finished - this.personal.teleport_time;
+ this.pauserothealth_finished = time + this.personal.pauserothealth_finished - this.personal.teleport_time;
+ this.pauserotfuel_finished = time + this.personal.pauserotfuel_finished - this.personal.teleport_time;
+ this.pauseregen_finished = time + this.personal.pauseregen_finished - this.personal.teleport_time;
+ this.strength_finished = time + this.personal.strength_finished - this.personal.teleport_time;
+ this.invincible_finished = time + this.personal.invincible_finished - this.personal.teleport_time;
DID_CHEAT();
break;
}
- if(IS_DEAD(self))
- sprint(self, "UR DEAD AHAHAH))\n");
+ if(IS_DEAD(this))
+ sprint(this, "UR DEAD AHAHAH))\n");
else
- sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
+ sprint(this, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
break;
case CHIMPULSE_TELEPORT.impulse:
- IS_CHEAT(imp, 0, 0);
- if(self.movetype == MOVETYPE_NOCLIP)
+ IS_CHEAT(this, imp, 0, 0);
+ if(this.movetype == MOVETYPE_NOCLIP)
{
e = find(world, classname, "info_autoscreenshot");
if(e)
{
- sprint(self, "Emergency teleport used info_autoscreenshot location\n");
- setorigin(self, e.origin);
- self.angles = e.angles;
+ sprint(this, "Emergency teleport used info_autoscreenshot location\n");
+ setorigin(this, e.origin);
+ this.angles = e.angles;
remove(e);
- // should we? self.angles_x = -self.angles_x;
- self.fixangle = true;
- self.velocity = '0 0 0';
+ // should we? this.angles_x = -this.angles_x;
+ this.fixangle = true;
+ this.velocity = '0 0 0';
DID_CHEAT();
break;
}
}
- if(MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((gamestart_sv_cheats < 2) ? 100 : 100000), 384, 384))
+ if(MoveToRandomMapLocation(this, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((gamestart_sv_cheats < 2) ? 100 : 100000), 384, 384))
{
- sprint(self, "Emergency teleport used random location\n");
- self.angles_x = -self.angles.x;
- self.fixangle = true;
- self.velocity = '0 0 0';
+ sprint(this, "Emergency teleport used random location\n");
+ this.angles_x = -this.angles.x;
+ this.fixangle = true;
+ this.velocity = '0 0 0';
DID_CHEAT();
break;
}
- sprint(self, "Emergency teleport could not find a good location, forget it!\n");
+ sprint(this, "Emergency teleport could not find a good location, forget it!\n");
break;
case CHIMPULSE_R00T.impulse:
- IS_CHEAT(imp, 0, 0);
+ IS_CHEAT(this, imp, 0, 0);
RandomSelection_Init();
- FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it) && DIFF_TEAM(it, self), LAMBDA(RandomSelection_Add(it, 0, string_null, 1, 1)));
+ FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it) && DIFF_TEAM(it, this), LAMBDA(RandomSelection_Add(it, 0, string_null, 1, 1)));
if(RandomSelection_chosen_ent)
e = RandomSelection_chosen_ent;
else
- e = self;
+ e = this;
Send_Effect(EFFECT_ROCKET_EXPLODE, e.origin, '0 0 0', 1);
sound(e, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
e2 = spawn();
setorigin(e2, e.origin);
- RadiusDamage(e2, self, 1000, 0, 128, world, world, 500, DEATH_CHEAT.m_id, e);
+ RadiusDamage(e2, this, 1000, 0, 128, world, world, 500, DEATH_CHEAT.m_id, e);
remove(e2);
LOG_INFO("404 Sportsmanship not found.\n");
END_CHEAT_FUNCTION();
}
-void DragBox_Think();
+void DragBox_Think(entity this);
float drag_lastcnt;
-float CheatCommand(float argc)
-{SELFPARAM();
+float CheatCommand(entity this, int argc)
+{
BEGIN_CHEAT_FUNCTION();
string cmd;
cmd = argv(0);
entity oldself;
case "pointparticles":
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
if(argc == 5)
{
// arguments:
// velocity
// howmany
f = stof(argv(2));
- crosshair_trace(self);
- start = (1-f) * self.origin + f * trace_endpos;
+ crosshair_trace(this);
+ start = (1-f) * this.origin + f * trace_endpos;
end = stov(argv(3));
f = stof(argv(4));
Send_Effect_(argv(1), start, end, f);
DID_CHEAT();
break;
}
- sprint(self, "Usage: sv_cheats 1; restart; cmd pointparticles effectname position(0..1) velocityvector multiplier\n");
+ sprint(this, "Usage: sv_cheats 1; restart; cmd pointparticles effectname position(0..1) velocityvector multiplier\n");
break;
case "trailparticles":
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
if(argc == 2)
{
// arguments:
// effectname
effectnum = _particleeffectnum(argv(1));
- W_SetupShot(self, false, false, SND_Null, CH_WEAPON_A, 0);
- traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
- __trailparticles(self, effectnum, w_shotorg, trace_endpos);
+ W_SetupShot(this, false, false, SND_Null, CH_WEAPON_A, 0);
+ traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, this);
+ __trailparticles(this, effectnum, w_shotorg, trace_endpos);
DID_CHEAT();
break;
}
- sprint(self, "Usage: sv_cheats 1; restart; cmd trailparticles effectname\n");
+ sprint(this, "Usage: sv_cheats 1; restart; cmd trailparticles effectname\n");
break;
case "make":
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
if(argc == 3)
{
// arguments:
// modelname mode
f = stof(argv(2));
- W_SetupShot(self, false, false, SND_Null, CH_WEAPON_A, 0);
- traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, self);
+ W_SetupShot(this, false, false, SND_Null, CH_WEAPON_A, 0);
+ traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, this);
if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) || trace_fraction == 1)
{
- sprint(self, "cannot make stuff there (bad surface)\n");
+ sprint(this, "cannot make stuff there (bad surface)\n");
}
else
{
if(trace_startsolid)
{
remove(e);
- sprint(self, "cannot make stuff there (no space)\n");
+ sprint(this, "cannot make stuff there (no space)\n");
}
else
DID_CHEAT();
}
}
else
- sprint(self, "Usage: sv_cheats 1; restart; cmd make models/... 0/1/2\n");
+ sprint(this, "Usage: sv_cheats 1; restart; cmd make models/... 0/1/2\n");
break;
case "penalty":
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
if(argc == 3)
{
- race_ImposePenaltyTime(self, stof(argv(1)), argv(2));
+ race_ImposePenaltyTime(this, stof(argv(1)), argv(2));
DID_CHEAT();
break;
}
- sprint(self, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
+ sprint(this, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
break;
case "dragbox_spawn": {
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
entity e = new(dragbox_box);
- e.think = DragBox_Think;
+ setthink(e, DragBox_Think);
e.nextthink = time;
e.solid = -1; // black
setmodel(e, MDL_Null); // network it
setorigin(e.aiment, stov(argv(2)));
else
{
- crosshair_trace(self);
+ crosshair_trace(this);
setorigin(e.aiment, trace_endpos);
}
setmodel(e.enemy, MDL_MARKER);
e.enemy.skin = 1;
setsize(e.enemy, '0 0 0', '0 0 0');
- end = normalize(self.origin + self.view_ofs - e.aiment.origin);
+ end = normalize(this.origin + this.view_ofs - e.aiment.origin);
end.x = (end.x > 0) * 2 - 1;
end.y = (end.y > 0) * 2 - 1;
end.z = (end.z > 0) * 2 - 1;
break;
}
case "dragpoint_spawn": {
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
entity e = new(dragpoint);
- e.think = DragBox_Think;
+ setthink(e, DragBox_Think);
e.nextthink = time;
e.solid = 0; // nothing special
setmodel(e, MDL_MARKER);
setorigin(e, stov(argv(2)));
else
{
- crosshair_trace(self);
- setorigin(e, trace_endpos + normalize(self.origin + self.view_ofs - trace_endpos));
+ crosshair_trace(this);
+ setorigin(e, trace_endpos + normalize(this.origin + this.view_ofs - trace_endpos));
move_out_of_solid(e);
}
break;
}
case "drag_remove":
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
RandomSelection_Init();
- crosshair_trace(self);
+ crosshair_trace(this);
for(entity e = world; (e = find(e, classname, "dragbox_box")); )
RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
for(entity e = world; (e = find(e, classname, "dragpoint")); )
DID_CHEAT();
break;
case "drag_setcnt":
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
if(argc == 2)
{
RandomSelection_Init();
- crosshair_trace(self);
+ crosshair_trace(this);
for(entity e = world; (e = find(e, classname, "dragbox_box")); )
RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
for(entity e = world; (e = find(e, classname, "dragpoint")); )
DID_CHEAT();
break;
}
- sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_setcnt cnt\n");
+ sprint(this, "Usage: sv_cheats 1; restart; cmd dragbox_setcnt cnt\n");
break;
case "drag_save":
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
if(argc == 2)
{
f = fopen(argv(1), FILE_WRITE);
DID_CHEAT();
break;
}
- sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
+ sprint(this, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
break;
case "drag_saveraceent":
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
if(argc == 2)
{
f = fopen(argv(1), FILE_WRITE);
DID_CHEAT();
break;
}
- sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
+ sprint(this, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
break;
case "drag_clear":
- IS_CHEAT(0, argc, 0);
+ IS_CHEAT(this, 0, argc, 0);
for(entity e = world; (e = find(e, classname, "dragbox_box")); )
remove(e);
for(entity e = world; (e = find(e, classname, "dragbox_corner_1")); )
DID_CHEAT();
break;
case "god":
- IS_CHEAT(0, argc, 0);
- BITXOR_ASSIGN(self.flags, FL_GODMODE);
- if(self.flags & FL_GODMODE)
+ IS_CHEAT(this, 0, argc, 0);
+ BITXOR_ASSIGN(this.flags, FL_GODMODE);
+ if(this.flags & FL_GODMODE)
{
- sprint(self, "godmode ON\n");
+ sprint(this, "godmode ON\n");
DID_CHEAT();
}
else
- sprint(self, "godmode OFF\n");
+ sprint(this, "godmode OFF\n");
break;
case "notarget":
- IS_CHEAT(0, argc, 0);
- BITXOR_ASSIGN(self.flags, FL_NOTARGET);
- if(self.flags & FL_NOTARGET)
+ IS_CHEAT(this, 0, argc, 0);
+ BITXOR_ASSIGN(this.flags, FL_NOTARGET);
+ if(this.flags & FL_NOTARGET)
{
- sprint(self, "notarget ON\n");
+ sprint(this, "notarget ON\n");
DID_CHEAT();
}
else
- sprint(self, "notarget OFF\n");
+ sprint(this, "notarget OFF\n");
break;
case "noclip":
- IS_CHEAT(0, argc, 0);
- if(self.movetype != MOVETYPE_NOCLIP)
+ IS_CHEAT(this, 0, argc, 0);
+ if(this.movetype != MOVETYPE_NOCLIP)
{
- self.movetype = MOVETYPE_NOCLIP;
- sprint(self, "noclip ON\n");
+ this.movetype = MOVETYPE_NOCLIP;
+ sprint(this, "noclip ON\n");
DID_CHEAT();
}
else
{
- self.movetype = MOVETYPE_WALK;
- sprint(self, "noclip OFF\n");
+ this.movetype = MOVETYPE_WALK;
+ sprint(this, "noclip OFF\n");
}
break;
case "fly":
- IS_CHEAT(0, argc, 0);
- if(self.movetype != MOVETYPE_FLY)
+ IS_CHEAT(this, 0, argc, 0);
+ if(this.movetype != MOVETYPE_FLY)
{
- self.movetype = MOVETYPE_FLY;
- sprint(self, "flymode ON\n");
+ this.movetype = MOVETYPE_FLY;
+ sprint(this, "flymode ON\n");
DID_CHEAT();
}
else
{
- self.movetype = MOVETYPE_WALK;
- sprint(self, "flymode OFF\n");
+ this.movetype = MOVETYPE_WALK;
+ sprint(this, "flymode OFF\n");
}
break;
case "give":
- IS_CHEAT(0, argc, 0);
- if(GiveItems(self, 1, argc))
+ IS_CHEAT(this, 0, argc, 0);
+ if(GiveItems(this, 1, argc))
DID_CHEAT();
break;
case "usetarget":
- IS_CHEAT(0, argc, 0);
- setself(spawn());
- self.target = argv(1);
- SUB_UseTargets(self, this, NULL);
- remove(self);
- setself(this);
+ IS_CHEAT(this, 0, argc, 0);
+ entity e = spawn();
+ e.target = argv(1);
+ SUB_UseTargets(e, this, NULL);
+ remove(e);
DID_CHEAT();
break;
case "killtarget":
- IS_CHEAT(0, argc, 0);
- setself(spawn());
- self.killtarget = argv(1);
- SUB_UseTargets(self, this, NULL);
- remove(self);
- setself(this);
+ IS_CHEAT(this, 0, argc, 0);
+ entity e2 = spawn();
+ e2.killtarget = argv(1);
+ SUB_UseTargets(e2, this, NULL);
+ remove(e2);
DID_CHEAT();
break;
case "teleporttotarget":
- IS_CHEAT(0, argc, 0);
- setself(new(cheattriggerteleport));
- setorigin(self, self.origin);
- self.target = argv(1);
- teleport_findtarget(self);
- if(!wasfreed(self))
+ IS_CHEAT(this, 0, argc, 0);
+ entity ent = new(cheattriggerteleport);
+ setorigin(ent, ent.origin);
+ ent.target = argv(1);
+ teleport_findtarget(ent);
+ if(!wasfreed(ent))
{
- Simple_TeleportPlayer(self, this);
- remove(self);
+ Simple_TeleportPlayer(ent, this);
+ remove(ent);
DID_CHEAT();
}
- setself(this);
break;
}
END_CHEAT_FUNCTION();
}
-float Drag(float force_allow_pick, float ischeat);
+float Drag(entity this, float force_allow_pick, float ischeat);
void Drag_Begin(entity dragger, entity draggee, vector touchpoint);
void Drag_Finish(entity dragger);
float Drag_IsDraggable(entity draggee);
{
// use cheat dragging if cheats are enabled
crosshair_trace_plusvisibletriggers(this);
- Drag(true, true);
+ Drag(this, true, true);
}
else
{
- Drag(false, false); // execute dragging
+ Drag(this, false, false); // execute dragging
}
break;
}
.entity draggedby;
.float dragmovetype;
-float Drag(float force_allow_pick, float ischeat)
-{SELFPARAM();
+float Drag(entity this, float force_allow_pick, float ischeat)
+{
BEGIN_CHEAT_FUNCTION();
// returns true when an entity has been picked up
if(Drag_IsDraggable(e))
{
if(ischeat)
- IS_CHEAT(0, 0, CHRAME_DRAG);
+ IS_CHEAT(this, 0, 0, CHRAME_DRAG);
if(e.draggedby)
Drag_Finish(e.draggedby);
if(e.tag_entity)
}
}
-void DragBox_Think()
-{SELFPARAM();
+void DragBox_Think(entity this)
+{
if(this.aiment && this.enemy)
{
this.origin_x = (this.aiment.origin.x + this.enemy.origin.x) * 0.5;
.float cheatcount;
void CheatInit();
void CheatShutdown();
-float CheatImpulse(int imp);
-float CheatCommand(float argc);
+float CheatImpulse(entity this, int imp);
+float CheatCommand(entity this, int argc);
float CheatFrame();
const float CHRAME_DRAG = 8;
}
{
- entity spot = SelectSpawnPoint(true);
+ entity spot = SelectSpawnPoint(this, true);
if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
this.angles = spot.angles;
this.angles_z = 0;
this.superweapons_finished = 0;
this.pushltime = 0;
this.istypefrag = 0;
- this.think = func_null;
+ setthink(this, func_null);
this.nextthink = 0;
this.hook_time = 0;
this.deadflag = DEAD_NO;
if (this.team < 0)
JoinBestTeam(this, false, true);
- entity spot = SelectSpawnPoint(false);
+ entity spot = SelectSpawnPoint(this, false);
if (!spot) {
Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_NOSPAWNS);
return; // spawn failed
this.pain_frame = 0;
this.pain_finished = 0;
this.pushltime = 0;
- this.think = func_null; // players have no think function
+ setthink(this, func_null); // players have no think function
this.nextthink = 0;
this.dmg_team = 0;
this.ballistics_density = autocvar_g_ballistics_density_player;
// reset fields the weapons may use
FOREACH(Weapons, true, LAMBDA(
- it.wr_resetplayer(it);
+ it.wr_resetplayer(it, this);
// reload all reloadable weapons
if (it.spawnflags & WEP_FLAG_RELOADABLE) {
this.weapon_load[it.m_id] = it.reloading_ammo;
}
}
-void ClientInit_misc();
+void ClientInit_misc(entity this);
.float ebouncefactor, ebouncestop; // electro's values
// TODO do we need all these fields, or should we stop autodetecting runtime
// TODO: make easier to use
Registry_send_all();
W_PROP_reload(MSG_ONE, to);
- ClientInit_misc();
+ ClientInit_misc(this);
MUTATOR_CALLHOOK(Ent_Init);
}
-void ClientInit_misc()
+void ClientInit_misc(entity this)
{
- SELFPARAM();
int channel = MSG_ONE;
WriteHeader(channel, ENT_CLIENT_INIT);
WriteByte(channel, g_nexball_meter_period * 32);
WriteCoord(channel, autocvar_g_trueaim_minrange);
}
-void ClientInit_CheckUpdate()
-{SELFPARAM();
+void ClientInit_CheckUpdate(entity this)
+{
this.nextthink = time;
if(this.count != autocvar_g_balance_armor_blockpercent)
{
}
void ClientInit_Spawn()
-{SELFPARAM();
-
+{
entity e = new_pure(clientinit);
- e.think = ClientInit_CheckUpdate;
+ setthink(e, ClientInit_CheckUpdate);
Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
- WITHSELF(e, ClientInit_CheckUpdate());
+ WITHSELF(e, ClientInit_CheckUpdate(e));
}
/*
// now I am sure the player IS dead
}
-void KillIndicator_Think()
-{SELFPARAM();
+void KillIndicator_Think(entity this)
+{
if (gameover)
{
this.owner.killindicator = world;
this.killindicator.scale = 0.5;
setattachment(this.killindicator, this, "");
setorigin(this.killindicator, '0 0 52');
- this.killindicator.think = KillIndicator_Think;
+ setthink(this.killindicator, KillIndicator_Think);
this.killindicator.nextthink = starttime + (this.lip) * 0.05;
clientkilltime = max(clientkilltime, this.killindicator.nextthink + 0.05);
this.killindicator.cnt = ceil(killtime);
e.killindicator.scale = 0.5;
setattachment(e.killindicator, e, "");
setorigin(e.killindicator, '0 0 52');
- e.killindicator.think = KillIndicator_Think;
+ setthink(e.killindicator, KillIndicator_Think);
e.killindicator.nextthink = starttime + (e.lip) * 0.05;
clientkilltime = max(clientkilltime, e.killindicator.nextthink + 0.05);
e.killindicator.cnt = ceil(killtime);
if (!autocvar_g_campaign)
{
this.motd_actived_time = -1;
- Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage());
+ Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this));
}
if (g_weaponarena_weapons == WEPSET(TUBA))
if (vote_called && IS_REAL_CLIENT(this)) VoteCount(false);
}
-void ChatBubbleThink()
-{SELFPARAM();
+void ChatBubbleThink(entity this)
+{
this.nextthink = time;
if ((this.owner.alpha < 0) || this.owner.chatbubbleentity != this)
{
this.chatbubbleentity = new(chatbubbleentity);
this.chatbubbleentity.owner = this;
this.chatbubbleentity.exteriormodeltoclient = this;
- this.chatbubbleentity.think = ChatBubbleThink;
+ setthink(this.chatbubbleentity, ChatBubbleThink);
this.chatbubbleentity.nextthink = time;
setmodel(this.chatbubbleentity, MDL_CHAT); // precision set below
//setorigin(this.chatbubbleentity, this.origin + '0 0 15' + this.maxs_z * '0 0 1');
} else {
if (PHYS_INPUT_BUTTON_INFO(this)) {
this.motd_actived_time = time;
- Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage());
+ Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this));
}
}
}
=============
*/
.float usekeypressed;
-void() nexball_setstatus;
.float last_vehiclecheck;
.int items_added;
void PlayerPreThink ()
bool button_pressed = (PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_ATCK2(this) || PHYS_INPUT_BUTTON_HOOK(this) || PHYS_INPUT_BUTTON_USE(this));
if (this.deadflag == DEAD_DYING) {
- if ((this.respawn_flags & RESPAWN_FORCE) && !autocvar_g_respawn_delay_max) {
+ if ((this.respawn_flags & RESPAWN_FORCE) && !(this.respawn_time < this.respawn_time_max)) {
this.deadflag = DEAD_RESPAWNING;
} else if (!button_pressed) {
this.deadflag = DEAD_DEAD;
if (this.respawn_flags & RESPAWN_SILENT)
STAT(RESPAWN_TIME, this) = 0;
- else if ((this.respawn_flags & RESPAWN_FORCE) && autocvar_g_respawn_delay_max)
- STAT(RESPAWN_TIME, this) = this.respawn_time_max;
+ else if ((this.respawn_flags & RESPAWN_FORCE) && this.respawn_time < this.respawn_time_max)
+ {
+ if (time < this.respawn_time)
+ STAT(RESPAWN_TIME, this) = this.respawn_time;
+ else if (this.deadflag != DEAD_RESPAWNING)
+ STAT(RESPAWN_TIME, this) = -this.respawn_time_max;
+ }
else
STAT(RESPAWN_TIME, this) = this.respawn_time;
}
this.impulse = IMP_weapon_group_##slot.impulse; \
return; \
} \
- W_NextWeaponOnImpulse(slot); \
+ W_NextWeaponOnImpulse(this, slot); \
}
X(1)
X(2)
noref int prev = -1; \
noref int best = 0; \
noref int next = +1; \
- W_CycleWeapon(this.cvar_cl_weaponpriorities[slot], dir); \
+ W_CycleWeapon(this, this.cvar_cl_weaponpriorities[slot], dir); \
}
X(0, prev)
X(1, prev)
this.impulse = IMP_weapon_byid_##i.impulse; \
return; \
} \
- W_SwitchWeapon(Weapons_from(WEP_FIRST + i)); \
+ W_SwitchWeapon(this, Weapons_from(WEP_FIRST + i)); \
}
X(0)
X(1)
this.impulse = IMP_weapon_next_byid.impulse;
return;
}
- W_NextWeapon(0);
+ W_NextWeapon(this, 0);
}
IMPULSE(weapon_prev_byid)
this.impulse = IMP_weapon_prev_byid.impulse;
return;
}
- W_PreviousWeapon(0);
+ W_PreviousWeapon(this, 0);
}
IMPULSE(weapon_next_bygroup)
this.impulse = IMP_weapon_next_bygroup.impulse;
return;
}
- W_NextWeapon(1);
+ W_NextWeapon(this, 1);
}
IMPULSE(weapon_prev_bygroup)
this.impulse = IMP_weapon_prev_bygroup.impulse;
return;
}
- W_PreviousWeapon(1);
+ W_PreviousWeapon(this, 1);
}
IMPULSE(weapon_next_bypriority)
this.impulse = IMP_weapon_next_bypriority.impulse;
return;
}
- W_NextWeapon(2);
+ W_NextWeapon(this, 2);
}
IMPULSE(weapon_prev_bypriority)
this.impulse = IMP_weapon_prev_bypriority.impulse;
return;
}
- W_PreviousWeapon(2);
+ W_PreviousWeapon(this, 2);
}
IMPULSE(weapon_last)
{
if (this.vehicle) return;
if (IS_DEAD(this)) return;
- W_SwitchWeapon(w_getbestweapon(this));
+ W_SwitchWeapon(this, w_getbestweapon(this));
}
IMPULSE(weapon_drop)
{
if (this.vehicle) return;
if (IS_DEAD(this)) return;
- W_ThrowWeapon(W_CalculateProjectileVelocity(this.velocity, v_forward * 750, false), '0 0 0', true);
+ W_ThrowWeapon(this, W_CalculateProjectileVelocity(this.velocity, v_forward * 750, false), '0 0 0', true);
}
IMPULSE(weapon_reload)
if (vehicle_impulse(this, imp)) return;
- if (CheatImpulse(imp)) return;
+ if (CheatImpulse(this, imp)) return;
FOREACH(IMPULSES, it.impulse == imp, {
void(entity) f = it.impulse_handle;
MUTATOR_CALLHOOK(DropSpecialItems, player);
}
-void CopyBody_Think()
-{SELFPARAM();
+void CopyBody_Think(entity this)
+{
if(this.CopyBody_nextthink && time > this.CopyBody_nextthink)
{
- this.CopyBody_think();
+ this.CopyBody_think(this);
if(wasfreed(this))
return;
this.CopyBody_nextthink = this.nextthink;
- this.CopyBody_think = this.think;
- this.think = CopyBody_Think;
+ this.CopyBody_think = getthink(this);
+ setthink(this, CopyBody_Think);
}
CSQCMODEL_AUTOUPDATE(this);
this.nextthink = time;
CSQCMODEL_AUTOINIT(clone);
clone.CopyBody_nextthink = this.nextthink;
- clone.CopyBody_think = this.think;
+ clone.CopyBody_think = getthink(this);
clone.nextthink = time;
- clone.think = CopyBody_Think;
+ setthink(clone, CopyBody_Think);
// "bake" the current animation frame for clones (they don't get clientside animation)
animdecide_load_if_needed(clone);
animdecide_setframes(clone, false, frame, frame1time, frame2, frame2time);
excess = frag_damage;
Weapon wep = PS(this).m_weapon;
- WITHSELF(this, wep.wr_playerdeath(wep));
+ WITHSELF(this, wep.wr_playerdeath(wep, this));
RemoveGrapplingHook(this);
// set up to fade out later
SUB_SetFade (this, time + 6 + random (), 1);
// reset body think wrapper broken by SUB_SetFade
- if(this.classname == "body" && this.think != CopyBody_Think) {
- this.CopyBody_think = this.think;
+ if(this.classname == "body" && getthink(this) != CopyBody_Think) {
+ this.CopyBody_think = getthink(this);
this.CopyBody_nextthink = this.nextthink;
- this.think = CopyBody_Think;
+ setthink(this, CopyBody_Think);
this.nextthink = time;
}
// reset fields the weapons may use just in case
FOREACH(Weapons, it != WEP_Null, LAMBDA(
- WITHSELF(this, it.wr_resetplayer(it));
+ WITHSELF(this, it.wr_resetplayer(it, this));
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
ATTACK_FINISHED_FOR(this, it.m_id, slot) = 0;
.float istypefrag;
.float CopyBody_nextthink;
-.void() CopyBody_think;
-void CopyBody_Think();
+.void(entity this) CopyBody_think;
+void CopyBody_Think(entity this);
void CopyBody(entity this, float keepvelocity);
void player_setupanimsformodel();
{
return; // handled by a mutator
}
- else if (CheatCommand(argc))
+ else if (CheatCommand(this, argc))
{
return; // handled by server/cheats.qc
}
// ==========================================
// used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such.
-void timeout_handler_reset()
+void timeout_handler_reset(entity this)
{
- SELFPARAM();
- timeout_caller = world;
+ timeout_caller = NULL;
timeout_time = 0;
timeout_leadtime = 0;
- remove(self);
+ remove(this);
}
-void timeout_handler_think()
+void timeout_handler_think(entity this)
{
- SELFPARAM();
switch (timeout_status)
{
case TIMEOUT_ACTIVE:
it.fixangle = false;
));
- timeout_handler_reset();
+ timeout_handler_reset(this);
}
return;
case TIMEOUT_INACTIVE:
default:
{
- timeout_handler_reset();
+ timeout_handler_reset(this);
return;
}
}
{
string command = builtin_cvar_string(strcat("sv_info_", argv(1)));
- if (command) wordwrap_sprint(command, 1000);
+ if (command) wordwrap_sprint(caller, command, 1000);
else print_to(caller, "ERROR: unsupported info command");
return; // never fall through to usage
timeout_leadtime = autocvar_sv_timeout_leadtime;
timeout_handler = spawn();
- timeout_handler.think = timeout_handler_think;
+ setthink(timeout_handler, timeout_handler_think);
timeout_handler.nextthink = time; // always let the entity think asap
Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_TIMEOUT);
.vector lastV_angle; // used when pausing the game in order to force the player to keep his old view angle fixed
// allow functions to be used in other code like g_world.qc and teamplay.qc
-void timeout_handler_think();
+void timeout_handler_think(entity this);
// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
void CommonCommand_macro_write_aliases(float fh);
// ==========================================
// used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such.
-void timeout_handler_reset();
+void timeout_handler_reset(entity this);
-void timeout_handler_think();
+void timeout_handler_think(entity this);
// ===================================================
// Common commands used in both sv_cmd.qc and cmd.qc
remove(radarmapper);
radarmapper = world;
}
-void RadarMap_Think()
+void RadarMap_Think(entity this)
{
- SELFPARAM();
// rough map entity
// cnt: current line
// size: pixel width/height
if (!radarmapper)
{
radarmapper = new(radarmapper);
- radarmapper.think = RadarMap_Think;
+ setthink(radarmapper, RadarMap_Think);
radarmapper.nextthink = time;
radarmapper.count = 8; // default to the --trace method, as it is faster now
radarmapper.ltime = 1;
// =====================================================
// used by GameCommand_make_mapinfo()
-void make_mapinfo_Think()
+void make_mapinfo_Think(entity this)
{
- SELFPARAM();
if (MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
{
LOG_INFO("Done rebuiling mapinfos.\n");
}
else
{
- self.think = make_mapinfo_Think;
+ setthink(self, make_mapinfo_Think);
self.nextthink = time;
}
}
void GameCommand_allspec(float request, float argc)
{
- SELFPARAM();
switch (request)
{
case CMD_REQUEST_COMMAND:
entity tmp_entity;
tmp_entity = new(make_mapinfo);
- tmp_entity.think = make_mapinfo_Think;
+ setthink(tmp_entity, make_mapinfo_Think);
tmp_entity.nextthink = time;
MapInfo_Enumerate();
return;
void GameCommand_moveplayer(float request, float argc)
{
- SELFPARAM();
switch (request)
{
case CMD_REQUEST_COMMAND:
void GameCommand_playerdemo(float request, float argc)
{
- SELFPARAM();
switch (request)
{
case CMD_REQUEST_COMMAND:
return;
}
- WITHSELF(client, playerdemo_open_read(argv(next_token)));
+ playerdemo_open_read(client, argv(next_token));
return;
}
return;
}
- WITHSELF(client, playerdemo_open_write(argv(next_token)));
+ playerdemo_open_write(client, argv(next_token));
return;
}
void GameCommand_shuffleteams(float request)
{
- SELFPARAM();
switch (request)
{
case CMD_REQUEST_COMMAND:
{
if (!(shuffleteams_players[z])) continue; // not a player, move on to next random slot
- if (VerifyClientNumber(shuffleteams_players[z])) setself(edict_num(shuffleteams_players[z]));
+ entity e = NULL;
+ if(VerifyClientNumber(shuffleteams_players[z]))
+ e = edict_num(shuffleteams_players[z]);
- if (self.team != team_color) MoveToTeam(self, team_color, 6);
+ if(!e) continue; // unverified
+
+ if (e.team != team_color) MoveToTeam(e, team_color, 6);
shuffleteams_players[z] = 0;
shuffleteams_teams[i] = shuffleteams_teams[i] + 1;
// Resets the state of all clients, items, weapons, waypoints, ... of the map.
void reset_map(bool dorespawn)
{
- SELFPARAM();
-
if (time <= game_starttime && round_handler_IsActive()) round_handler_Reset(game_starttime);
MUTATOR_CALLHOOK(reset_map_global);
if (!MUTATOR_CALLHOOK(reset_map_players))
{
FOREACH_CLIENT(true, LAMBDA(
- setself(it);
/*
only reset players if a restart countdown is active
this can either be due to cvar sv_ready_restart_after_countdown having set
if (restart_mapalreadyrestarted || (time < game_starttime))
{
// NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
- if (IS_PLAYER(self))
+ if (IS_PLAYER(it))
{
- // PlayerScore_Clear(self);
- self.killcount = 0;
+ // PlayerScore_Clear(it);
+ it.killcount = 0;
// stop the player from moving so that he stands still once he gets respawned
- self.velocity = '0 0 0';
- self.avelocity = '0 0 0';
- self.movement = '0 0 0';
- PutClientInServer();
+ it.velocity = '0 0 0';
+ it.avelocity = '0 0 0';
+ it.movement = '0 0 0';
+ WITHSELF(it, PutClientInServer());
}
}
));
-
- setself(this);
}
}
}
// Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown is set)
-void ReadyRestart_think()
+void ReadyRestart_think(entity this)
{
- SELFPARAM();
restart_mapalreadyrestarted = true;
reset_map(true);
Score_ClearAll();
if (autocvar_sv_ready_restart_after_countdown)
{
entity restart_timer = new_pure(restart_timer);
- restart_timer.think = ReadyRestart_think;
+ setthink(restart_timer, ReadyRestart_think);
restart_timer.nextthink = game_starttime;
}
// WEAPONTODO
.float autoswitch;
-bool client_hasweapon(entity cl, Weapon wpn, float andammo, bool complain);
+bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain);
void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire);
void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire);
// VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
void PlayerUseKey();
-USING(spawn_evalfunc_t, vector(entity player, entity spot, vector current));
+USING(spawn_evalfunc_t, vector(entity this, entity player, entity spot, vector current));
.spawn_evalfunc_t spawn_evalfunc;
string modname;
if(targ.killcount) { targ.killcount = 0; }
}
-void Ice_Think()
-{SELFPARAM();
+void Ice_Think(entity this)
+{
if(!STAT(FROZEN, self.owner) || self.owner.iceblock != self)
{
remove(self);
entity ice = new(ice);
ice.owner = targ;
ice.scale = targ.scale;
- ice.think = Ice_Think;
+ setthink(ice, Ice_Think);
ice.nextthink = time;
ice.frame = floor(random() * 21); // ice model has 20 different looking frames
setmodel(ice, MDL_ICE);
targ.iceblock = ice;
targ.revival_time = 0;
- WITHSELF(ice, Ice_Think());
+ WITHSELF(ice, Ice_Think(ice));
RemoveGrapplingHook(targ);
}
void Damage (entity targ, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
+{
float mirrordamage;
float mirrorforce;
float complainteamdamage = 0;
if (gameover || targ.killcount == FRAGS_SPECTATOR)
return;
- setself(targ);
- damage_targ = targ;
- damage_inflictor = inflictor;
- damage_attacker = attacker;
- attacker_save = attacker;
+ damage_targ = targ;
+ damage_inflictor = inflictor;
+ damage_attacker = attacker;
+ attacker_save = attacker;
if(IS_PLAYER(targ))
if(targ.hook)
// special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
if(DEATH_ISWEAPON(deathtype, WEP_HOOK) || DEATH_ISWEAPON(deathtype, WEP_TUBA))
{
- if(IS_PLAYER(targ))
- if(SAME_TEAM(targ, attacker))
- {
- setself(this);
- return;
- }
+ if(IS_PLAYER(targ) && SAME_TEAM(targ, attacker))
+ {
+ return;
+ }
}
if(deathtype == DEATH_KILL.m_id || deathtype == DEATH_TEAMCHANGE.m_id || deathtype == DEATH_AUTOTEAMCHANGE.m_id)
{
// exit the vehicle before killing (fixes a crash)
if(IS_PLAYER(targ) && targ.vehicle)
- vehicles_exit(VHEF_RELEASE);
+ WITHSELF(targ, vehicles_exit(VHEF_RELEASE));
// These are ALWAYS lethal
// No damage modification here
{
Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
- setself(targ);
- entity spot = SelectSpawnPoint (false);
+ entity spot = SelectSpawnPoint (targ, false);
if(spot)
{
damage = 0;
- self.deadflag = DEAD_NO;
+ targ.deadflag = DEAD_NO;
- self.angles = spot.angles;
+ targ.angles = spot.angles;
- self.effects = 0;
- self.effects |= EF_TELEPORT_BIT;
+ targ.effects = 0;
+ targ.effects |= EF_TELEPORT_BIT;
- self.angles_z = 0; // never spawn tilted even if the spot says to
- self.fixangle = true; // turn this way immediately
- self.velocity = '0 0 0';
- self.avelocity = '0 0 0';
- self.punchangle = '0 0 0';
- self.punchvector = '0 0 0';
- self.oldvelocity = self.velocity;
+ targ.angles_z = 0; // never spawn tilted even if the spot says to
+ targ.fixangle = true; // turn this way immediately
+ targ.velocity = '0 0 0';
+ targ.avelocity = '0 0 0';
+ targ.punchangle = '0 0 0';
+ targ.punchvector = '0 0 0';
+ targ.oldvelocity = targ.velocity;
- self.spawnorigin = spot.origin;
- setorigin (self, spot.origin + '0 0 1' * (1 - self.mins.z - 24));
+ targ.spawnorigin = spot.origin;
+ setorigin (targ, spot.origin + '0 0 1' * (1 - targ.mins.z - 24));
// don't reset back to last position, even if new position is stuck in solid
- self.oldorigin = self.origin;
- self.prevorigin = self.origin;
+ targ.oldorigin = targ.origin;
+ targ.prevorigin = targ.origin;
- Send_Effect(EFFECT_TELEPORT, self.origin, '0 0 0', 1);
+ Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
}
-
- setself(this);
}
if(!g_instagib)
}
// apply push
- if (self.damageforcescale)
+ if (targ.damageforcescale)
if (vlen(force))
- if (!IS_PLAYER(self) || time >= self.spawnshieldtime || self == attacker)
+ if (!IS_PLAYER(targ) || time >= targ.spawnshieldtime || targ == attacker)
{
- vector farce = damage_explosion_calcpush(self.damageforcescale * force, self.velocity, autocvar_g_balance_damagepush_speedfactor);
- if(self.movetype == MOVETYPE_PHYSICS)
+ vector farce = damage_explosion_calcpush(targ.damageforcescale * force, targ.velocity, autocvar_g_balance_damagepush_speedfactor);
+ if(targ.movetype == MOVETYPE_PHYSICS)
{
entity farcent = new(farce);
- farcent.enemy = self;
+ farcent.enemy = targ;
farcent.movedir = farce * 10;
- if(self.mass)
- farcent.movedir = farcent.movedir * self.mass;
+ if(targ.mass)
+ farcent.movedir = farcent.movedir * targ.mass;
farcent.origin = hitloc;
farcent.forcetype = FORCETYPE_FORCEATPOS;
farcent.nextthink = time + 0.1;
- farcent.think = SUB_Remove_self;
+ setthink(farcent, SUB_Remove);
}
else
{
- self.velocity = self.velocity + farce;
- self.move_velocity = self.velocity;
+ targ.velocity = targ.velocity + farce;
+ targ.move_velocity = targ.velocity;
}
- UNSET_ONGROUND(self);
- self.move_flags &= ~FL_ONGROUND;
- UpdateCSQCProjectile(self);
+ UNSET_ONGROUND(targ);
+ targ.move_flags &= ~FL_ONGROUND;
+ UpdateCSQCProjectile(targ);
}
// apply damage
- if (damage != 0 || (self.damageforcescale && vlen(force)))
- if (self.event_damage)
- self.event_damage (self, inflictor, attacker, damage, deathtype, hitloc, force);
- setself(this);
+ if (damage != 0 || (targ.damageforcescale && vlen(force)))
+ if (targ.event_damage)
+ targ.event_damage (targ, inflictor, attacker, damage, deathtype, hitloc, force);
// apply mirror damage if any
if(!autocvar_g_mirrordamage_onlyweapons || DEATH_WEAPONOF(deathtype) != WEP_Null)
{
// print("adding a fire burner to ", e.classname, "\n");
e.fire_burner = new(fireburner);
- e.fire_burner.think = fireburner_think;
+ setthink(e.fire_burner, fireburner_think);
e.fire_burner.nextthink = time;
e.fire_burner.owner = e;
}
e.effects &= ~EF_FLAME;
}
-void fireburner_think()
-{SELFPARAM();
+void fireburner_think(entity this)
+{
// for players, this is done in the regular loop
if(wasfreed(self.owner))
{
void Obituary(entity attacker, entity inflictor, entity targ, int deathtype);
-void Ice_Think();
+void Ice_Think(entity this);
void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypoint);
.float fire_hitsound;
.entity fire_burner;
-void fireburner_think();
+void fireburner_think(entity this);
float Fire_IsBurning(entity e);
void Fire_ApplyDamage(entity e);
void Fire_ApplyEffect(entity e);
-
-void fireburner_think();
remove(this);
}
-void GrapplingHookThink();
+void GrapplingHookThink(entity this);
void GrapplingHook_Stop()
{SELFPARAM();
Send_Effect(EFFECT_HOOK_IMPACT, self.origin, '0 0 0', 1);
sound (self, CH_SHOTS, SND_HOOK_IMPACT, VOL_BASE, ATTEN_NORM);
self.state = 1;
- self.think = GrapplingHookThink;
+ setthink(self, GrapplingHookThink);
self.nextthink = time;
- self.touch = func_null;
+ settouch(self, func_null);
self.velocity = '0 0 0';
self.movetype = MOVETYPE_NONE;
self.hook_length = -1;
int autocvar_g_grappling_hook_tarzan;
-void GrapplingHookThink()
-{SELFPARAM();
+void GrapplingHookThink(entity this)
+{
float spd, dist, minlength, pullspeed, ropestretch, ropeairfriction, rubberforce, newlength, rubberforce_overstretch;
vector dir, org, end, v0, dv, v, myorg, vs;
if(self.realowner.hook != self) // how did that happen?
}
}
-void GrapplingHookTouch ()
-{SELFPARAM();
+void GrapplingHookTouch (entity this)
+{
if(other.movetype == MOVETYPE_FOLLOW)
return;
- PROJECTILE_TOUCH;
+ PROJECTILE_TOUCH(this);
GrapplingHook_Stop();
missile.angles = vectoangles (missile.velocity);
//missile.glow_color = 250; // 244, 250
//missile.glow_size = 120;
- missile.touch = GrapplingHookTouch;
- missile.think = GrapplingHookThink;
+ settouch(missile, GrapplingHookTouch);
+ setthink(missile, GrapplingHookThink);
missile.nextthink = time;
missile.effects = /*EF_FULLBRIGHT | EF_ADDITIVE |*/ EF_LOWPRECISION;
#include "g_lights.qh"
-void train_next();
+void train_next(entity this);
const float LOOP = 1;
"NOSHADOW" will not cast shadows in realtime lighting mode
"FOLLOW" will follow the entity which "targetname" matches "target"
*/
-void dynlight_think()
+void dynlight_think(entity this)
{
- SELFPARAM();
if(!self.owner)
remove(self);
self.punchangle = targ.angles;
self.view_ofs = self.origin - targ.origin;
self.v_angle = self.angles - targ.angles;
- self.think = dynlight_think;
+ setthink(self, dynlight_think);
self.nextthink = time + 0.1;
}
void dynlight_find_path(entity this)
targ = find(world, targetname, self.target);
self.target = targ.target;
setorigin (self, targ.origin);
- self.think = train_next;
+ setthink(self, train_next);
self.nextthink = time + 0.1;
}
void dynlight_find_target(entity this)
targ = find(world, targetname, self.target);
setattachment(self, targ, self.dtagname);
self.owner = targ;
- self.think = dynlight_think;
+ setthink(self, dynlight_think);
self.nextthink = time + 0.1;
}
void dynlight_use(entity this, entity actor, entity trigger)
}
spawnfunc(dynlight)
{
- if (!self.light_lev)
- self.light_lev = 200;
- if (!self.color)
- self.color = '1 1 1';
- self.lefty = self.light_lev;
- self.use = dynlight_use;
- setsize (self, '0 0 0', '0 0 0');
- setorigin (self, self.origin);
- //self.pflags = PFLAGS_FULLDYNAMIC;
- self.solid = SOLID_NOT;
- //self.blocked = func_null;
- //if (self.spawnflags & DNOSHADOW)
- // self.pflags = self.pflags + PFLAGS_NOSHADOW;
- //if (self.spawnflags & START_OFF)
- // self.light_lev = 0;
+ if (!this.light_lev)
+ this.light_lev = 200;
+ if (!this.color)
+ this.color = '1 1 1';
+ this.lefty = this.light_lev;
+ this.use = dynlight_use;
+ setsize (this, '0 0 0', '0 0 0');
+ setorigin (this, this.origin);
+ //this.pflags = PFLAGS_FULLDYNAMIC;
+ this.solid = SOLID_NOT;
+ //this.blocked = func_null;
+ //if (this.spawnflags & DNOSHADOW)
+ // this.pflags = this.pflags + PFLAGS_NOSHADOW;
+ //if (this.spawnflags & START_OFF)
+ // this.light_lev = 0;
//tag attaching
- if (self.dtagname)
+ if (this.dtagname)
{
- InitializeEntity(self, dynlight_find_target, INITPRIO_FINDTARGET);
+ InitializeEntity(this, dynlight_find_target, INITPRIO_FINDTARGET);
return;
}
// entity following
- if (self.spawnflags & DFOLLOW)
+ if (this.spawnflags & DFOLLOW)
{
- InitializeEntity(self, dynlight_find_aiment, INITPRIO_FINDTARGET);
+ InitializeEntity(this, dynlight_find_aiment, INITPRIO_FINDTARGET);
return;
}
// path following
- if (self.target)
-// if (!(self.spawnflags & DFOLLOW))
+ if (this.target)
+// if (!(this.spawnflags & DFOLLOW))
{
- self.movetype = MOVETYPE_NOCLIP;
- if (!self.speed)
- self.speed = 100;
- InitializeEntity(self, dynlight_find_path, INITPRIO_FINDTARGET);
+ this.movetype = MOVETYPE_NOCLIP;
+ if (!this.speed)
+ this.speed = 100;
+ InitializeEntity(this, dynlight_find_path, INITPRIO_FINDTARGET);
return;
}
}
void g_model_dropbyspawnflags(entity this)
{
- if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
+ if((this.spawnflags & 3) == 1) // ALIGN_ORIGIN
{
- traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
- setorigin(self, trace_endpos);
+ traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this);
+ setorigin(this, trace_endpos);
}
- else if((self.spawnflags & 3) == 2) // ALIGN_BOTTOM
+ else if((this.spawnflags & 3) == 2) // ALIGN_BOTTOM
{
- tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
- setorigin(self, trace_endpos);
+ tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 4096', MOVE_NOMONSTERS, this);
+ setorigin(this, trace_endpos);
}
- else if((self.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
+ else if((this.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
{
- traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
- setorigin(self, trace_endpos - '0 0 1' * self.mins.z);
+ traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this);
+ setorigin(this, trace_endpos - '0 0 1' * this.mins.z);
}
}
void g_clientmodel_dropbyspawnflags(entity this)
{
vector o0;
- o0 = self.origin;
- g_model_dropbyspawnflags(self);
- if(self.origin != o0)
- self.SendFlags |= 2;
+ o0 = this.origin;
+ g_model_dropbyspawnflags(this);
+ if(this.origin != o0)
+ this.SendFlags |= 2;
}
bool g_clientmodel_genericsendentity(entity this, entity to, int sf)
{
sf = sf & 0x0F;
- if(self.angles != '0 0 0')
+ if(this.angles != '0 0 0')
sf |= 0x10;
- if(self.mins != '0 0 0' || self.maxs != '0 0 0')
+ if(this.mins != '0 0 0' || this.maxs != '0 0 0')
sf |= 0x20;
- if(self.colormap != 0)
+ if(this.colormap != 0)
sf |= 0x40;
- if(self.lodmodelindex1)
+ if(this.lodmodelindex1)
sf |= 0x80;
WriteHeader(MSG_ENTITY, ENT_CLIENT_WALL);
if(sf & BIT(0))
{
if(sf & 0x40)
- WriteShort(MSG_ENTITY, self.colormap);
+ WriteShort(MSG_ENTITY, this.colormap);
}
if(sf & BIT(1))
{
- WriteCoord(MSG_ENTITY, self.origin.x);
- WriteCoord(MSG_ENTITY, self.origin.y);
- WriteCoord(MSG_ENTITY, self.origin.z);
+ WriteCoord(MSG_ENTITY, this.origin.x);
+ WriteCoord(MSG_ENTITY, this.origin.y);
+ WriteCoord(MSG_ENTITY, this.origin.z);
}
if(sf & BIT(2))
{
if(sf & 0x10)
{
- WriteAngle(MSG_ENTITY, self.angles.x);
- WriteAngle(MSG_ENTITY, self.angles.y);
- WriteAngle(MSG_ENTITY, self.angles.z);
+ WriteAngle(MSG_ENTITY, this.angles.x);
+ WriteAngle(MSG_ENTITY, this.angles.y);
+ WriteAngle(MSG_ENTITY, this.angles.z);
}
}
{
if(sf & 0x80)
{
- WriteShort(MSG_ENTITY, self.lodmodelindex0);
- WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535));
- WriteShort(MSG_ENTITY, self.lodmodelindex1);
- WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535));
- WriteShort(MSG_ENTITY, self.lodmodelindex2);
+ WriteShort(MSG_ENTITY, this.lodmodelindex0);
+ WriteShort(MSG_ENTITY, bound(0, this.loddistance1, 65535));
+ WriteShort(MSG_ENTITY, this.lodmodelindex1);
+ WriteShort(MSG_ENTITY, bound(0, this.loddistance2, 65535));
+ WriteShort(MSG_ENTITY, this.lodmodelindex2);
}
else
- WriteShort(MSG_ENTITY, self.modelindex);
- WriteByte(MSG_ENTITY, self.solid);
- WriteShort(MSG_ENTITY, floor(self.scale * 256));
+ WriteShort(MSG_ENTITY, this.modelindex);
+ WriteByte(MSG_ENTITY, this.solid);
+ WriteShort(MSG_ENTITY, floor(this.scale * 256));
if(sf & 0x20)
{
- WriteCoord(MSG_ENTITY, self.mins.x);
- WriteCoord(MSG_ENTITY, self.mins.y);
- WriteCoord(MSG_ENTITY, self.mins.z);
- WriteCoord(MSG_ENTITY, self.maxs.x);
- WriteCoord(MSG_ENTITY, self.maxs.y);
- WriteCoord(MSG_ENTITY, self.maxs.z);
+ WriteCoord(MSG_ENTITY, this.mins.x);
+ WriteCoord(MSG_ENTITY, this.mins.y);
+ WriteCoord(MSG_ENTITY, this.mins.z);
+ WriteCoord(MSG_ENTITY, this.maxs.x);
+ WriteCoord(MSG_ENTITY, this.maxs.y);
+ WriteCoord(MSG_ENTITY, this.maxs.z);
}
- WriteString(MSG_ENTITY, self.bgmscript);
- if(self.bgmscript != "")
+ WriteString(MSG_ENTITY, this.bgmscript);
+ if(this.bgmscript != "")
{
- WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
- WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
- WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
- WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
- WriteCoord(MSG_ENTITY, self.movedir.x);
- WriteCoord(MSG_ENTITY, self.movedir.y);
- WriteCoord(MSG_ENTITY, self.movedir.z);
- WriteByte(MSG_ENTITY, floor(self.lip * 255));
+ WriteByte(MSG_ENTITY, floor(this.bgmscriptattack * 64));
+ WriteByte(MSG_ENTITY, floor(this.bgmscriptdecay * 64));
+ WriteByte(MSG_ENTITY, floor(this.bgmscriptsustain * 255));
+ WriteByte(MSG_ENTITY, floor(this.bgmscriptrelease * 64));
+ WriteCoord(MSG_ENTITY, this.movedir.x);
+ WriteCoord(MSG_ENTITY, this.movedir.y);
+ WriteCoord(MSG_ENTITY, this.movedir.z);
+ WriteByte(MSG_ENTITY, floor(this.lip * 255));
}
- WriteShort(MSG_ENTITY, self.fade_start);
- WriteShort(MSG_ENTITY, self.fade_end);
- WriteShort(MSG_ENTITY, self.alpha_max);
- WriteShort(MSG_ENTITY, self.alpha_min);
- WriteShort(MSG_ENTITY, self.inactive);
- WriteShort(MSG_ENTITY, self.fade_vertical_offset);
+ WriteShort(MSG_ENTITY, this.fade_start);
+ WriteShort(MSG_ENTITY, this.fade_end);
+ WriteShort(MSG_ENTITY, this.alpha_max);
+ WriteShort(MSG_ENTITY, this.alpha_min);
+ WriteShort(MSG_ENTITY, this.inactive);
+ WriteShort(MSG_ENTITY, this.fade_vertical_offset);
}
return true;
}
-#define G_MODEL_INIT(sol) \
- if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
- if(!self.scale) self.scale = self.modelscale; \
+#define G_MODEL_INIT(ent,sol) \
+ if(ent.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) ent.movetype = MOVETYPE_PHYSICS; \
+ if(!ent.scale) ent.scale = ent.modelscale; \
SetBrushEntityModel(); \
- self.use = 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;
+ ent.use = g_model_setcolormaptoactivator; \
+ InitializeEntity(ent, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
+ if(!ent.solid) ent.solid = (sol); else if(ent.solid < 0) ent.solid = SOLID_NOT;
-#define G_CLIENTMODEL_INIT(sol) \
- if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
- if(!self.scale) self.scale = self.modelscale; \
+#define G_CLIENTMODEL_INIT(ent,sol) \
+ if(ent.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) ent.movetype = MOVETYPE_PHYSICS; \
+ if(!ent.scale) ent.scale = ent.modelscale; \
SetBrushEntityModel(); \
- self.use = 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; \
- Net_LinkEntity(self, true, 0, g_clientmodel_genericsendentity); \
- self.default_solid = sol;
+ ent.use = g_clientmodel_use; \
+ InitializeEntity(ent, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
+ if(!ent.solid) ent.solid = (sol); else if(ent.solid < 0) ent.solid = SOLID_NOT; \
+ if(!ent.bgmscriptsustain) ent.bgmscriptsustain = 1; else if(ent.bgmscriptsustain < 0) ent.bgmscriptsustain = 0; \
+ Net_LinkEntity(ent, true, 0, g_clientmodel_genericsendentity); \
+ ent.default_solid = sol;
// non-solid model entities:
-spawnfunc(misc_gamemodel) { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // model entity
-spawnfunc(misc_clientmodel) { self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
-spawnfunc(misc_models) { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
+spawnfunc(misc_gamemodel) { this.angles_x = -this.angles.x; G_MODEL_INIT (this, SOLID_NOT) } // model entity
+spawnfunc(misc_clientmodel) { this.angles_x = -this.angles.x; G_CLIENTMODEL_INIT(this, SOLID_NOT) } // model entity
+spawnfunc(misc_models) { this.angles_x = -this.angles.x; G_MODEL_INIT (this, SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
// non-solid brush entities:
-spawnfunc(func_illusionary) { G_MODEL_INIT (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
-spawnfunc(func_clientillusionary) { G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
-spawnfunc(func_static) { G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old alias name from some other game
+spawnfunc(func_illusionary) { G_MODEL_INIT (this, SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
+spawnfunc(func_clientillusionary) { G_CLIENTMODEL_INIT(this, SOLID_NOT) } // brush entity
+spawnfunc(func_static) { G_MODEL_INIT (this, SOLID_NOT) } // DEPRECATED old alias name from some other game
// solid brush entities
-spawnfunc(func_wall) { G_MODEL_INIT (SOLID_BSP) } // Q1 name
-spawnfunc(func_clientwall) { G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)
+spawnfunc(func_wall) { G_MODEL_INIT (this, SOLID_BSP) } // Q1 name
+spawnfunc(func_clientwall) { G_CLIENTMODEL_INIT(this, SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)
spawnfunc(info_null)
{
- remove(self);
+ remove(this);
// if anything breaks, tell the mapper to fix his map! info_null is meant to remove itself immediately.
}
self.model = "";
}
-float InitMovingBrushTrigger()
-{SELFPARAM();
+bool InitMovingBrushTrigger(entity this)
+{
// trigger angles are used for one-way touches. An angle of 0 is assumed
// to mean no restrictions, so use a yaw of 360 instead.
- self.solid = SOLID_BSP;
- SetBrushEntityModel();
- self.movetype = MOVETYPE_PUSH;
- if(self.modelindex == 0)
+ this.solid = SOLID_BSP;
+ WITHSELF(this, SetBrushEntityModel());
+ this.movetype = MOVETYPE_PUSH;
+ if(this.modelindex == 0)
{
objerror("InitMovingBrushTrigger: no brushes found!");
- return 0;
+ return false;
}
- return 1;
+ return true;
}
#pragma once
-void SUB_NullThink();
+void SUB_NullThink(entity this);
-void() SUB_CalcMoveDone;
-void() SUB_CalcAngleMoveDone;
+void SUB_CalcMoveDone(entity this);
+void SUB_CalcAngleMoveDone(entity this);
spawnfunc(info_null);
*/
void SUB_VanishOrRemove (entity ent);
-void SUB_SetFade_Think ();
+void SUB_SetFade_Think (entity this);
/*
==================
self.origin traveling at speed
===============
*/
-void SUB_CalcMoveDone ();
+void SUB_CalcMoveDone(entity this);
.float platmovetype_turn;
-void SUB_CalcMove_controller_think ();
+void SUB_CalcMove_controller_think (entity this);
void SUB_CalcMove_controller_setbezier (entity controller, vector org, vector control, vector dest);
void SUB_CalcMove_controller_setlinear (entity controller, vector org, vector dest);
-void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void() func);
+void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void(entity this) func);
-void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func);
+void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void(entity this) func);
-void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void() func);
+void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void(entity this) func);
/*
=============
The calling function should make sure self.think is valid
===============
*/
-void SUB_CalcAngleMoveDone ();
+void SUB_CalcAngleMoveDone (entity this);
// FIXME: I fixed this function only for rotation around the main axes
-void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void() func);
+void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void(entity this) func);
-void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void() func);
+void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void(entity this) func);
/*
==================
void InitSolidBSPTrigger();
-float InitMovingBrushTrigger();
+bool InitMovingBrushTrigger(entity this);
.float latency_cnt;
.float latency_time;
entity pingplreport;
-void PingPLReport_Think()
-{SELFPARAM();
+void PingPLReport_Think(entity this)
+{
float delta;
entity e;
void PingPLReport_Spawn()
{
pingplreport = new_pure(pingplreport);
- pingplreport.think = PingPLReport_Think;
+ setthink(pingplreport, PingPLReport_Think);
pingplreport.nextthink = time;
}
}
}
-void GotoFirstMap()
-{SELFPARAM();
+void GotoFirstMap(entity this)
+{
float n;
if(autocvar__sv_init)
{
WriteShort(MSG_ENTITY, this.cnt);
return true;
}
-void RandomSeed_Think()
-{SELFPARAM();
+void RandomSeed_Think(entity this)
+{
this.cnt = bound(0, floor(random() * 65536), 65535);
this.nextthink = time + 5;
this.SendFlags |= 1;
}
void RandomSeed_Spawn()
-{SELFPARAM();
+{
randomseed = new_pure(randomseed);
- randomseed.think = RandomSeed_Think;
+ setthink(randomseed, RandomSeed_Think);
Net_LinkEntity(randomseed, false, 0, RandomSeed_Send);
- WITHSELF(randomseed, randomseed.think()); // sets random seed and nextthink
+ WITHSELF(randomseed, getthink(randomseed)(randomseed)); // sets random seed and nextthink
}
spawnfunc(__init_dedicated_server)
remove = remove_unsafely;
entity e = spawn();
- e.think = GotoFirstMap;
+ setthink(e, GotoFirstMap);
e.nextthink = time; // this is usually 1 at this point
e = new(info_player_deathmatch); // safeguard against player joining
spawnfunc(light)
{
//makestatic (self); // Who the f___ did that?
- remove(self);
+ remove(this);
}
string GetGametype()
*/
void NextLevel()
{
- SELFPARAM();
gameover = true;
intermission_running = 1;
float redirection_timeout;
float redirection_nextthink;
float RedirectionThink()
-{SELFPARAM();
+{
float clients_found;
if(redirection_target == "")
clients_found = 0;
FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
- setself(it);
// TODO add timer
- LOG_INFO("Redirecting: sending connect command to ", self.netname, "\n");
+ LOG_INFO("Redirecting: sending connect command to ", it.netname, "\n");
if(redirection_target == "self")
- stuffcmd(self, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
+ stuffcmd(it, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
else
- stuffcmd(self, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
+ stuffcmd(it, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
++clients_found;
));
}
}
-void OnlineBanList_Think()
-{SELFPARAM();
+void OnlineBanList_Think(entity this)
+{
float argc;
string uri;
float i, n;
}
entity e = new(bansyncer);
- e.think = OnlineBanList_Think;
+ setthink(e, OnlineBanList_Think);
e.nextthink = time + 1;
}
/**
* Key touch handler.
*/
-void item_key_touch()
-{SELFPARAM();
+void item_key_touch(entity this)
+{
if (!IS_PLAYER(other))
return;
/**
* Spawn a key with given model, key code and color.
*/
-void spawn_item_key()
-{SELFPARAM();
- precache_model(self.model);
+void spawn_item_key(entity this)
+{
+ precache_model(this.model);
- if (self.spawnflags & 1) // FLOATING
- self.noalign = 1;
+ if (this.spawnflags & 1) // FLOATING
+ this.noalign = 1;
- if (self.noalign)
- self.movetype = MOVETYPE_NONE;
+ if (this.noalign)
+ this.movetype = MOVETYPE_NONE;
else
- self.movetype = MOVETYPE_TOSS;
+ this.movetype = MOVETYPE_TOSS;
- precache_sound(self.noise);
+ precache_sound(this.noise);
- self.mdl = self.model;
- self.effects = EF_LOWPRECISION;
- _setmodel(self, self.model);
- //setsize(self, '-16 -16 -24', '16 16 32');
- setorigin(self, self.origin + '0 0 32');
- setsize(self, '-16 -16 -56', '16 16 0');
- self.modelflags |= MF_ROTATE;
- self.solid = SOLID_TRIGGER;
+ this.mdl = this.model;
+ this.effects = EF_LOWPRECISION;
+ _setmodel(this, this.model);
+ //setsize(this, '-16 -16 -24', '16 16 32');
+ setorigin(this, this.origin + '0 0 32');
+ setsize(this, '-16 -16 -56', '16 16 0');
+ this.modelflags |= MF_ROTATE;
+ this.solid = SOLID_TRIGGER;
- if (!self.noalign)
+ if (!this.noalign)
{
// first nudge it off the floor a little bit to avoid math errors
- setorigin(self, self.origin + '0 0 1');
+ setorigin(this, this.origin + '0 0 1');
// note droptofloor returns false if stuck/or would fall too far
- droptofloor();
+ WITHSELF(this, droptofloor());
}
- self.touch = item_key_touch;
+ settouch(this, item_key_touch);
};
vector _colormod;
// reject this entity if more than one key was set!
- if (self.itemkeys>0 && (self.itemkeys & (self.itemkeys-1)) != 0) {
+ if (this.itemkeys>0 && (this.itemkeys & (this.itemkeys-1)) != 0) {
objerror("item_key.itemkeys must contain only 1 bit set specifying the key it represents!");
- remove(self);
+ remove(this);
return;
}
// find default netname and colormod
- switch(self.itemkeys) {
+ switch(this.itemkeys) {
case BIT(0):
_netname = "GOLD key";
_colormod = '1 .9 0';
_netname = "FLUFFY PINK keycard";
_colormod = '1 1 1';
- if (self.netname == "") {
+ if (this.netname == "") {
objerror("item_key doesn't have a default name for this key and a custom one was not specified!");
- remove(self);
+ remove(this);
return;
}
break;
// find default model
string _model = string_null;
- if (self.itemkeys <= ITEM_KEY_BIT(2)) {
+ if (this.itemkeys <= ITEM_KEY_BIT(2)) {
_model = "models/keys/key.md3";
- } else if (self.itemkeys >= ITEM_KEY_BIT(3) && self.itemkeys <= ITEM_KEY_BIT(5)) {
+ } else if (this.itemkeys >= ITEM_KEY_BIT(3) && this.itemkeys <= ITEM_KEY_BIT(5)) {
_model = "models/keys/key.md3"; // FIXME: replace it by a keycard model!
- } else if (self.model == "") {
+ } else if (this.model == "") {
objerror("item_key doesn't have a default model for this key and a custom one was not specified!");
- remove(self);
+ remove(this);
return;
}
// set defailt netname
- if (self.netname == "")
- self.netname = _netname;
+ if (this.netname == "")
+ this.netname = _netname;
// set default colormod
- if (!self.colormod)
- self.colormod = _colormod;
+ if (!this.colormod)
+ this.colormod = _colormod;
// set default model
- if (self.model == "")
- self.model = _model;
+ if (this.model == "")
+ this.model = _model;
// set default pickup message
- if (self.message == "")
- self.message = strzone(strcat("You've picked up the ", self.netname, "!"));
+ if (this.message == "")
+ this.message = strzone(strcat("You've picked up the ", this.netname, "!"));
- if (self.noise == "")
- self.noise = strzone(SND(ITEMPICKUP));
+ if (this.noise == "")
+ this.noise = strzone(SND(ITEMPICKUP));
// save the name for later
- item_keys_names[lowestbit(self.itemkeys)] = self.netname;
+ item_keys_names[lowestbit(this.itemkeys)] = this.netname;
// put the key on the map
- spawn_item_key();
+ spawn_item_key(this);
}
/*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32) FLOATING
}
-void adaptor_think2touch()
-{SELFPARAM();
- entity o;
- o = other;
- other = world;
- self.touch();
- other = o;
-}
-void adaptor_think2use()
-{SELFPARAM();
- if(this.use)
- this.use(this, NULL, NULL);
-}
-void adaptor_think2use_hittype_splash() // for timed projectile detonation
-{SELFPARAM();
+void adaptor_think2use_hittype_splash(entity this) // for timed projectile detonation
+{
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());
+ WITHSELF(this, adaptor_think2use(this));
}
// deferred dropping
void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
-void adaptor_think2use();
-
#define IS_DEAD(s) ((s).deadflag != DEAD_NO)
#define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
#define ITEM_DAMAGE_NEEDKILL(dt) (((dt) == DEATH_HURTTRIGGER.m_id) || ((dt) == DEATH_SLIME.m_id) || ((dt) == DEATH_LAVA.m_id) || ((dt) == DEATH_SWAMP.m_id))
-#define PROJECTILE_TOUCH if(WarpZone_Projectile_Touch()) return
+#define PROJECTILE_TOUCH(this) MACRO_BEGIN if (WarpZone_Projectile_Touch(this)) return; MACRO_END
#define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5)))
MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
/** returns true if throwing the current weapon shall not be allowed */
-MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_NO_ARGS);
+#define EV_ForbidThrowCurrentWeapon(i, o) \
+ /**/ i(entity, __self) \
+ /**/
+MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
/** returns true if dropping the current weapon shall not be allowed at any time including death */
-MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_NO_ARGS);
+#define EV_ForbidDropCurrentWeapon(i, o) \
+ /**/ i(entity, __self) \
+ /**/
+MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
/** */
MUTATOR_HOOKABLE(SetDefaultAlpha, EV_NO_ARGS);
MUTATOR_HOOKABLE(Turret_CheckFire, EV_Turret_CheckFire);
/** return error to prevent entity spawn, or modify the entity */
-MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_NO_ARGS);
+#define EV_OnEntityPreSpawn(i, o) \
+ /** turret */ i(entity, __self) \
+ /**/
+MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_OnEntityPreSpawn);
/** runs in the event loop for players; is called for ALL player entities, also bots, also the dead, or spectators */
MUTATOR_HOOKABLE(PlayerPreThink, EV_NO_ARGS);
}
}
-vector target_objective_spawn_evalfunc(entity player, entity spot, vector current)
-{SELFPARAM();
- if(self.health < 0 || self.health >= ASSAULT_VALUE_INACTIVE)
+vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
+{
+ if(this.health < 0 || this.health >= ASSAULT_VALUE_INACTIVE)
return '-1 0 0';
return current;
}
objerror("no objective as target - fix the map!");
}
-float assault_decreaser_sprite_visible(entity e)
-{SELFPARAM();
- entity decreaser;
-
- decreaser = self.assault_decreaser;
-
- if(decreaser.enemy.health >= ASSAULT_VALUE_INACTIVE)
+bool assault_decreaser_sprite_visible(entity this, entity player, entity view)
+{
+ if(this.assault_decreaser.enemy.health >= ASSAULT_VALUE_INACTIVE)
return false;
return true;
it.team = NUM_TEAM_1;
// Dubbles as teamchange
- WITHSELF(it, turret_respawn());
+ WITHSELF(it, turret_respawn(it));
));
}
void assault_roundstart_use_this(entity this)
assault_roundstart_use(this, NULL, NULL);
}
-void assault_wall_think()
-{SELFPARAM();
+void assault_wall_think(entity this)
+{
if(self.enemy.health < 0)
{
self.model = "";
// trigger new round
// reset objectives, toggle spawnpoints, reset triggers, ...
void vehicles_clearreturn(entity veh);
-void vehicles_spawn();
+void vehicles_spawn(entity this);
void assault_new_round()
{SELFPARAM();
//bprint("ASSAULT: new round\n");
FOREACH_ENTITY_FLAGS(vehicle_flags, VHF_ISVEHICLE, LAMBDA(
vehicles_clearreturn(it);
- WITHSELF(it, vehicles_spawn());
+ WITHSELF(it, vehicles_spawn(it));
));
// up round counter
// they win. Otherwise the defending team wins once the timelimit passes.
int WinningCondition_Assault()
{
- SELFPARAM();
WinningConditionHelper(); // set worldstatus
int status = WINNING_NO;
this.mdl = this.model;
_setmodel(this, this.mdl);
this.solid = SOLID_BSP;
- this.think = assault_wall_think;
+ setthink(this, assault_wall_think);
this.nextthink = time;
InitializeEntity(this, assault_setenemytoobjective, INITPRIO_FINDTARGET);
}
MUTATOR_HOOKFUNCTION(ca, reset_map_players)
{
- SELFPARAM();
FOREACH_CLIENT(true, {
it.killcount = 0;
if (!it.caplayer && IS_BOT_CLIENT(it))
return true;
}
-void ctf_CaptureShield_Touch()
-{SELFPARAM();
+void ctf_CaptureShield_Touch(entity this)
+{
if(!other.ctf_captureshielded) { return; }
if(CTF_SAMETEAM(self, other)) { return; }
shield.enemy = self;
shield.team = self.team;
- shield.touch = ctf_CaptureShield_Touch;
+ settouch(shield, ctf_CaptureShield_Touch);
shield.customizeentityforclient = ctf_CaptureShield_Customize;
shield.effects = EF_ADDITIVE;
shield.movetype = MOVETYPE_NOCLIP;
}
}
-void ctf_FlagThink()
-{SELFPARAM();
+void ctf_FlagThink(entity this)
+{
// declarations
entity tmp_entity;
self.health = 0;
ctf_CheckFlagReturn(self, RETURN_SPEEDRUN);
- setself(self.owner);
- self.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
- ImpulseCommands(self);
- setself(this);
+ self.owner.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
+ ImpulseCommands(self.owner);
}
if(autocvar_g_ctf_stalemate)
{
void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
{
- // declarations
- setself(flag); // for later usage with droptofloor()
-
// main setup
flag.ctf_worldflagnext = ctf_worldflaglist; // link flag into ctf_worldflaglist
ctf_worldflaglist = flag;
flag.velocity = '0 0 0';
flag.mangle = flag.angles;
flag.reset = ctf_Reset;
- flag.touch = ctf_FlagTouch;
- flag.think = ctf_FlagThink;
+ settouch(flag, ctf_FlagTouch);
+ setthink(flag, ctf_FlagThink);
flag.nextthink = time + FLAG_THINKRATE;
flag.ctf_status = FLAG_BASE;
else // drop to floor, automatically find a platform and set that as spawn origin
{
flag.noalign = false;
- setself(flag);
- droptofloor();
+ WITHSELF(flag, droptofloor());
flag.movetype = MOVETYPE_TOSS;
}
"noise5" sound played when flag touches the ground... */
spawnfunc(item_flag_team1)
{
- if(!g_ctf) { remove(self); return; }
+ if(!g_ctf) { remove(this); return; }
- ctf_FlagSetup(NUM_TEAM_1, self);
+ ctf_FlagSetup(NUM_TEAM_1, this);
}
/*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
"noise5" sound played when flag touches the ground... */
spawnfunc(item_flag_team2)
{
- if(!g_ctf) { remove(self); return; }
+ if(!g_ctf) { remove(this); return; }
- ctf_FlagSetup(NUM_TEAM_2, self);
+ ctf_FlagSetup(NUM_TEAM_2, this);
}
/*QUAKED spawnfunc_item_flag_team3 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
"noise5" sound played when flag touches the ground... */
spawnfunc(item_flag_team3)
{
- if(!g_ctf) { remove(self); return; }
+ if(!g_ctf) { remove(this); return; }
- ctf_FlagSetup(NUM_TEAM_3, self);
+ ctf_FlagSetup(NUM_TEAM_3, this);
}
/*QUAKED spawnfunc_item_flag_team4 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
"noise5" sound played when flag touches the ground... */
spawnfunc(item_flag_team4)
{
- if(!g_ctf) { remove(self); return; }
+ if(!g_ctf) { remove(this); return; }
- ctf_FlagSetup(NUM_TEAM_4, self);
+ ctf_FlagSetup(NUM_TEAM_4, this);
}
/*QUAKED spawnfunc_item_flag_neutral (0 0.5 0.8) (-48 -48 -37) (48 48 37)
"noise5" sound played when flag touches the ground... */
spawnfunc(item_flag_neutral)
{
- if(!g_ctf) { remove(self); return; }
- if(!cvar("g_ctf_oneflag")) { remove(self); return; }
+ if(!g_ctf) { remove(this); return; }
+ if(!cvar("g_ctf_oneflag")) { remove(this); return; }
- ctf_FlagSetup(0, self);
+ ctf_FlagSetup(0, this);
}
/*QUAKED spawnfunc_ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
"cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
spawnfunc(ctf_team)
{
- if(!g_ctf) { remove(self); return; }
+ if(!g_ctf) { remove(this); return; }
- self.classname = "ctf_team";
- self.team = self.cnt + 1;
+ this.classname = "ctf_team";
+ this.team = this.cnt + 1;
}
// compatibility for quake maps
ATTRIB(Flag, m_maxs, vector, PL_MAX_CONST + '0 0 -13')
ENDCLASS(Flag)
Flag CTF_FLAG; STATIC_INIT(Flag) { CTF_FLAG = NEW(Flag); }
-void ctf_FlagTouch() { SELFPARAM(); ITEM_HANDLE(Pickup, CTF_FLAG, this, other); }
+void ctf_FlagTouch(entity this) { ITEM_HANDLE(Pickup, CTF_FLAG, this, other); }
// flag constants // for most of these, there is just one question to be asked: WHYYYYY?
GameLogEcho(strcat(":cts:", mode, ":", ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
}
-void KillIndicator_Think();
+void KillIndicator_Think(entity this);
void CTS_ClientKill(entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed
{
e.killindicator = spawn();
e.killindicator.owner = e;
- e.killindicator.think = KillIndicator_Think;
+ setthink(e.killindicator, KillIndicator_Think);
e.killindicator.nextthink = time + (e.lip) * 0.05;
e.killindicator.cnt = ceil(autocvar_g_cts_finish_kill_delay);
e.killindicator.health = 1; // this is used to indicate that it should be silent
MUTATOR_HOOKFUNCTION(cts, ClientConnect)
{SELFPARAM();
- race_PreparePlayer();
+ race_PreparePlayer(this);
self.race_checkpoint = -1;
if(IS_REAL_CLIENT(self))
else
self.frags = FRAGS_SPECTATOR;
- race_PreparePlayer();
+ race_PreparePlayer(this);
self.race_checkpoint = -1;
return false;
{SELFPARAM();
if(spawn_spot.target == "")
// Emergency: this wasn't a real spawnpoint. Can this ever happen?
- race_PreparePlayer();
+ race_PreparePlayer(this);
// if we need to respawn, do it right
self.race_respawn_checkpoint = self.race_checkpoint;
if(!gameover)
{
if(self.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn
- race_PreparePlayer();
+ race_PreparePlayer(this);
else // respawn
- race_RetractPlayer();
+ race_RetractPlayer(this);
race_AbandonRaceCheck(self);
}
self.frame = 0;
}
-void dompointthink()
-{SELFPARAM();
+void dompointthink(entity this)
+{
float fragamt;
self.nextthink = time + 0.1;
}
}
-void dompointtouch()
-{SELFPARAM();
+void dompointtouch(entity this)
+{
entity head;
if (!IS_PLAYER(other))
return;
dompoint_captured();
}
-void dom_controlpoint_setup(entity this);
-void dom_controlpoint_setup_self() { SELFPARAM(); dom_controlpoint_setup(this); }
void dom_controlpoint_setup(entity this)
{
entity head;
if(!self.t_length)
self.t_length = 239; // maximum frame
- self.think = dompointthink;
+ setthink(self, dompointthink);
self.nextthink = time;
- self.touch = dompointtouch;
+ settouch(self, dompointtouch);
self.solid = SOLID_TRIGGER;
self.flags = FL_ITEM;
setsize(self, '-32 -32 -32', '32 32 32');
}
MUTATOR_HOOKFUNCTION(dom, reset_map_players)
-{SELFPARAM();
+{
total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
- setself(it);
- PutClientInServer();
+ WITHSELF(it, PutClientInServer());
if(domination_roundbased)
- self.player_blocked = 1;
- if(IS_REAL_CLIENT(self))
- set_dom_state(self);
+ it.player_blocked = 1;
+ if(IS_REAL_CLIENT(it))
+ set_dom_state(it);
));
return 1;
}
{
if(!g_domination)
{
- remove(self);
+ remove(this);
return;
}
- self.think = dom_controlpoint_setup_self;
- self.nextthink = time + 0.1;
- self.reset = dom_controlpoint_setup;
+ setthink(this, dom_controlpoint_setup);
+ this.nextthink = time + 0.1;
+ this.reset = dom_controlpoint_setup;
- if(!self.scale)
- self.scale = 0.6;
+ if(!this.scale)
+ this.scale = 0.6;
- self.effects = self.effects | EF_LOWPRECISION;
+ this.effects = this.effects | EF_LOWPRECISION;
if (autocvar_g_domination_point_fullbright)
- self.effects |= EF_FULLBRIGHT;
+ this.effects |= EF_FULLBRIGHT;
}
/*QUAKED spawnfunc_dom_team (0 .5 .8) (-32 -32 -24) (32 32 32)
{
if(!g_domination || autocvar_g_domination_teams_override >= 2)
{
- remove(self);
+ remove(this);
return;
}
- precache_model(self.model);
- if (self.noise != "")
- precache_sound(self.noise);
- if (self.noise1 != "")
- precache_sound(self.noise1);
- self.classname = "dom_team";
- _setmodel(self, self.model); // precision not needed
- self.mdl = self.model;
- self.dmg = self.modelindex;
- self.model = "";
- self.modelindex = 0;
+ precache_model(this.model);
+ if (this.noise != "")
+ precache_sound(this.noise);
+ if (this.noise1 != "")
+ precache_sound(this.noise1);
+ this.classname = "dom_team";
+ _setmodel(this, this.model); // precision not needed
+ this.mdl = this.model;
+ this.dmg = this.modelindex;
+ this.model = "";
+ this.modelindex = 0;
// this would have to be changed if used in quakeworld
- if(self.cnt)
- self.team = self.cnt + 1; // WHY are these different anyway?
+ if(this.cnt)
+ this.team = this.cnt + 1; // WHY are these different anyway?
}
// scoreboard setup
// code from here on is just to support maps that don't have control point and team entities
void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, Sound capsound, string capnarration, string capmessage)
-{SELFPARAM();
+{
TC(Sound, capsound);
- setself(spawn());
- self.classname = "dom_team";
- self.netname = strzone(teamname);
- self.cnt = teamcolor;
- self.model = pointmodel;
- self.skin = pointskin;
- self.noise = strzone(Sound_fixpath(capsound));
- self.noise1 = strzone(capnarration);
- self.message = strzone(capmessage);
+ entity e = new_pure(dom_team);
+ e.netname = strzone(teamname);
+ e.cnt = teamcolor;
+ e.model = pointmodel;
+ e.skin = pointskin;
+ e.noise = strzone(Sound_fixpath(capsound));
+ e.noise1 = strzone(capnarration);
+ e.message = strzone(capmessage);
// this code is identical to spawnfunc_dom_team
- _setmodel(self, self.model); // precision not needed
- self.mdl = self.model;
- self.dmg = self.modelindex;
- self.model = "";
- self.modelindex = 0;
+ _setmodel(e, e.model); // precision not needed
+ e.mdl = e.model;
+ e.dmg = e.modelindex;
+ e.model = "";
+ e.modelindex = 0;
// this would have to be changed if used in quakeworld
- self.team = self.cnt + 1;
+ e.team = e.cnt + 1;
- //eprint(self);
- setself(this);
+ //eprint(e);
}
-void self_spawnfunc_dom_controlpoint() { SELFPARAM(); spawnfunc_dom_controlpoint(self); }
void dom_spawnpoint(vector org)
-{SELFPARAM();
- setself(spawn());
- self.classname = "dom_controlpoint";
- self.think = self_spawnfunc_dom_controlpoint;
- self.nextthink = time;
- setorigin(self, org);
- spawnfunc_dom_controlpoint(this);
- setself(this);
+{
+ entity e = spawn();
+ e.classname = "dom_controlpoint";
+ setthink(e, spawnfunc_dom_controlpoint);
+ e.nextthink = time;
+ setorigin(e, org);
+ spawnfunc_dom_controlpoint(e);
}
// spawn some default teams if the map is not set up for domination
MUTATOR_HOOKFUNCTION(ft, PlayerDies)
{
- SELFPARAM();
if(round_handler_IsActive())
if(round_handler_CountdownRunning())
{
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
it.killcount = 0;
it.freezetag_frozen_timeout = -1;
- setself(it);
- PutClientInServer();
+ WITHSELF(it, PutClientInServer());
it.freezetag_frozen_timeout = 0;
));
freezetag_count_alive_players();
spawnfunc(invasion_spawnpoint)
{
- if(!g_invasion) { remove(self); return; }
+ if(!g_invasion) { remove(this); return; }
- self.classname = "invasion_spawnpoint";
+ this.classname = "invasion_spawnpoint";
if(autocvar_g_invasion_zombies_only) // precache only if it hasn't been already
- if(self.monsterid) {
- Monster mon = get_monsterinfo(self.monsterid);
+ if(this.monsterid) {
+ Monster mon = get_monsterinfo(this.monsterid);
mon.mr_precache(mon);
}
}
monster = spawnmonster("", mon, world, world, e.origin, false, false, 2);
else return;
- e.think = SUB_Remove_self;
+ setthink(e, SUB_Remove);
e.nextthink = time + 0.1;
}
else
float autocvar_g_keepawayball_respawntime;
int autocvar_g_keepawayball_trail_color;
-float ka_ballcarrier_waypointsprite_visible_for_player(entity e) // runs on waypoints which are attached to ballcarriers, updates once per frame
+bool ka_ballcarrier_waypointsprite_visible_for_player(entity this, entity player, entity view) // runs on waypoints which are attached to ballcarriers, updates once per frame
{
- if(e.ballcarried)
- if(IS_SPEC(other))
+ if(view.ballcarried)
+ if(IS_SPEC(player))
return false; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen
// TODO: Make the ballcarrier lack a waypointsprite whenever they have the invisibility powerup
GameLogEcho(strcat(":ka:", mode, ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
}
-void ka_TouchEvent();
+void ka_TouchEvent(entity this);
+void ka_RespawnBall(entity this);
void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
{
if(gameover) { return; }
if(!MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
{
- entity spot = SelectSpawnPoint(true);
+ entity spot = SelectSpawnPoint(this, true);
setorigin(self, spot.origin);
self.angles = spot.angles;
}
self.velocity = '0 0 200';
self.angles = '0 0 0';
self.effects = autocvar_g_keepawayball_effects;
- self.touch = ka_TouchEvent;
+ settouch(self, ka_TouchEvent);
setthink(self, ka_RespawnBall);
self.nextthink = time + autocvar_g_keepawayball_respawntime;
sound(self, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
}
-void ka_TimeScoring()
-{SELFPARAM();
+void ka_TimeScoring(entity this)
+{
if(self.owner.ballcarried)
{ // add points for holding the ball after a certain amount of time
if(autocvar_g_keepaway_score_timepoints)
}
}
-void ka_TouchEvent() // runs any time that the ball comes in contact with something
-{SELFPARAM();
+void ka_TouchEvent(entity this) // runs any time that the ball comes in contact with something
+{
if(gameover) { return; }
if(!self) { return; }
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
self.velocity = '0 0 0';
self.movetype = MOVETYPE_NONE;
self.effects |= EF_NODRAW;
- self.touch = func_null;
- self.think = ka_TimeScoring;
+ settouch(self, func_null);
+ setthink(self, ka_TimeScoring);
self.nextthink = time + autocvar_g_keepaway_score_timeinterval;
self.takedamage = DAMAGE_NO;
setattachment(ball, world, "");
ball.movetype = MOVETYPE_BOUNCE;
ball.wait = time + 1;
- ball.touch = ka_TouchEvent;
+ settouch(ball, ka_TouchEvent);
setthink(ball, ka_RespawnBall);
ball.nextthink = time + autocvar_g_keepawayball_respawntime;
ball.takedamage = DAMAGE_YES;
if(time < game_starttime)
{
setthink(this, ka_RespawnBall);
- this.touch = func_null;
+ settouch(this, func_null);
this.nextthink = game_starttime;
}
else
e.flags = FL_ITEM;
e.pushable = true;
e.reset = ka_Reset;
- e.touch = ka_TouchEvent;
+ settouch(e, ka_TouchEvent);
e.owner = world;
ka_ball = e;
ScoreRules_basics_end();
}
-float kh_KeyCarrier_waypointsprite_visible_for_player(entity e) // runs all the time
-{SELFPARAM();
- if(!IS_PLAYER(e) || DIFF_TEAM(self, e))
+bool kh_KeyCarrier_waypointsprite_visible_for_player(entity this, entity player, entity view) // runs all the time
+{
+ if(!IS_PLAYER(view) || DIFF_TEAM(this, view))
if(!kh_tracking_enabled)
return false;
return true;
}
-float kh_Key_waypointsprite_visible_for_player(entity e) // ??
-{SELFPARAM();
+bool kh_Key_waypointsprite_visible_for_player(entity this, entity player, entity view)
+{
if(!kh_tracking_enabled)
return false;
- if(!self.owner)
+ if(!this.owner)
return true;
- if(!self.owner.owner)
+ if(!this.owner.owner)
return true;
return false; // draw only when key is not owned
}
kh_controller.nextthink = time; // force
}
void kh_WaitForPlayers();
-void kh_Controller_Think() // called a lot
-{SELFPARAM();
+void kh_Controller_Think(entity this) // called a lot
+{
if(intermission_running)
return;
if(self.cnt > 0)
- { if(self.think != kh_WaitForPlayers) { self.cnt -= 1; } }
+ { if(getthink(self) != kh_WaitForPlayers) { self.cnt -= 1; } }
else if(self.cnt == 0)
{
self.cnt -= 1;
kh_Key_AssignTo(key, player); // this also updates .kh_state
}
-void kh_Key_Touch() // runs many, many times when a key has been dropped and can be picked up
-{SELFPARAM();
+void kh_Key_Touch(entity this) // runs many, many times when a key has been dropped and can be picked up
+{
if(intermission_running)
return;
kh_FinishRound();
}
-void kh_Key_Think() // runs all the time
-{SELFPARAM();
+void kh_Key_Think(entity this) // runs all the time
+{
if(intermission_running)
return;
entity key = spawn();
key.count = i;
key.classname = STR_ITEM_KH_KEY;
- key.touch = kh_Key_Touch;
- key.think = kh_Key_Think;
+ settouch(key, kh_Key_Touch);
+ setthink(key, kh_Key_Think);
key.nextthink = time;
key.items = IT_KEY1 | IT_KEY2;
key.cnt = _angle;
// make a KH entity for controlling the game
kh_controller = spawn();
- kh_controller.think = kh_Controller_Think;
+ setthink(kh_controller, kh_Controller_Think);
kh_Controller_SetThink(0, kh_WaitForPlayers);
setmodel(kh_controller, MDL_KH_KEY);
return true;
}
-void lms_extralife()
-{SELFPARAM();
+void lms_extralife(entity this)
+{
StartItem(this, ITEM_ExtraLife);
}
if (self.classname != "item_health_mega") return false;
entity e = spawn();
- e.think = lms_extralife;
+ setthink(e, lms_extralife);
e.nextthink = time + 0.1;
e.spawnflags = self.spawnflags;
MUTATOR_HOOKFUNCTION(rc, ClientConnect)
{SELFPARAM();
- race_PreparePlayer();
+ race_PreparePlayer(this);
self.race_checkpoint = -1;
string rr = RACE_RECORD;
else
self.frags = FRAGS_SPECTATOR;
- race_PreparePlayer();
+ race_PreparePlayer(this);
self.race_checkpoint = -1;
return false;
{SELFPARAM();
if(spawn_spot.target == "")
// Emergency: this wasn't a real spawnpoint. Can this ever happen?
- race_PreparePlayer();
+ race_PreparePlayer(this);
// if we need to respawn, do it right
self.race_respawn_checkpoint = self.race_checkpoint;
if(!gameover)
{
if(self.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn
- race_PreparePlayer();
+ race_PreparePlayer(this);
else // respawn
- race_RetractPlayer();
+ race_RetractPlayer(this);
race_AbandonRaceCheck(self);
}
"cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
spawnfunc(tdm_team)
{
- if(!g_tdm || !self.cnt) { remove(self); return; }
+ if(!g_tdm || !this.cnt) { remove(this); return; }
- self.classname = "tdm_team";
- self.team = self.cnt + 1;
+ this.classname = "tdm_team";
+ this.team = this.cnt + 1;
}
// code from here on is just to support maps that don't have team entities
}
}
-void path_dbg_think()
-{SELFPARAM();
- pathlib_showpath(self);
- self.nextthink = time + 1;
+void path_dbg_think(entity this)
+{
+ pathlib_showpath(this);
+ this.nextthink = time + 1;
}
-void __showpath2_think()
-{SELFPARAM();
+void __showpath2_think(entity this)
+{
#ifdef TURRET_DEBUG
mark_info(self.origin,1);
#endif
if(self.path_next)
{
- self.path_next.think = __showpath2_think;
+ setthink(self.path_next, __showpath2_think);
self.path_next.nextthink = time + 0.15;
}
else
{
- self.owner.think = __showpath2_think;
+ setthink(self.owner, __showpath2_think);
self.owner.nextthink = time + 0.15;
}
}
void pathlib_showpath2(entity path)
{
- path.think = __showpath2_think;
+ setthink(path, __showpath2_think);
path.nextthink = time;
}
s = spawn();
s.alpha = 0.25;
- s.think = SUB_Remove_self;
+ setthink(s, SUB_Remove);
s.nextthink = _lifetime;
s.scale = pathlib_gridsize / 512.001;
s.solid = SOLID_NOT;
e = spawn();
e.alpha = 0.25;
- e.think = SUB_Remove_self;
+ setthink(e, SUB_Remove);
e.nextthink = _lifetime;
e.scale = pathlib_gridsize / 512;
e.solid = SOLID_NOT;
r = PLIB_RIGHT * pathlib_gridsize;
if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
- node.pathlib_node_edgeflags = tile_check_plus2(node.origin);
+ node.pathlib_node_edgeflags = tile_check_plus2(node, node.origin);
if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
{
e = findchainentity(owner, start);
while(e)
{
- e.think = SUB_Remove_self;
+ setthink(e, SUB_Remove);
e.nextthink = time;
e = e.chain;
}
void dumpnode(entity n)
{
n.is_path_node = false;
- n.think = SUB_Remove_self;
+ setthink(n, SUB_Remove);
n.nextthink = time;
}
node = spawn();
- node.think = SUB_Remove_self;
+ setthink(node, SUB_Remove);
node.nextthink = time + PATHLIB_NODEEXPIRE;
node.is_path_node = true;
node.owner = openlist;
return 1;
}
- where = pathlib_movenode(parent.origin, to, 0);
+ where = pathlib_movenode(parent, parent.origin, to, 0);
if (!pathlib_movenode_goodnode)
{
if(doedge)
- if (!tile_check(where))
+ if (!tile_check(parent, where))
{
LOG_TRACE("tile_check fail\n");
#if DEBUGPATHING
{
if(node.pathlib_node_g > g)
{
- //pathlib_movenode(where,node.origin,0);
+ //pathlib_movenode(node, where,node.origin,0);
//if(pathlib_movenode_goodnode)
//{
//mark_error(node.origin + '0 0 128',30);
node.owner = closedlist;
- if(vlen(node.origin - goal) <= pathlib_gridsize)
+ if(vdist(node.origin - goal, <=, pathlib_gridsize))
{
vector goalmove;
- goalmove = pathlib_walknode(node.origin,goal,1);
+ goalmove = pathlib_walknode(node, node.origin, goal, 1);
if(pathlib_movenode_goodnode)
{
goal_node = node;
return 0;
}
-float buildpath_nodefilter_moveskip(vector n,vector c,vector p)
+float buildpath_nodefilter_moveskip(entity this, vector n,vector c,vector p)
{
- pathlib_walknode(p,n,1);
+ pathlib_walknode(this, p, n, 1);
if(pathlib_movenode_goodnode)
return 1;
return path;
}
-entity pathlib_astar(vector from,vector to)
-{SELFPARAM();
+entity pathlib_astar(entity this, vector from,vector to)
+{
entity path, start, end, open, n, ln;
float ptime, ftime, ctime;
pathlib_movecost_waterfactor = 25000000;
pathlib_foundgoal = 0;
- movenode_boxmax = self.maxs * 1.1;
- movenode_boxmin = self.mins * 1.1;
+ movenode_boxmax = this.maxs * 1.1;
+ movenode_boxmin = this.mins * 1.1;
movenode_stepsize = pathlib_gridsize * 0.25;
.vector pos1, pos2;
-vector pathlib_wateroutnode(vector start,vector end, float doedge)
-{SELFPARAM();
+vector pathlib_wateroutnode(entity this, vector start, vector end, float doedge)
+{
vector surface;
pathlib_movenode_goodnode = 0;
end.x = fsnap(end.x, pathlib_gridsize);
end.y = fsnap(end.y, pathlib_gridsize);
- traceline(end + ('0 0 0.25' * pathlib_gridsize),end - ('0 0 1' * pathlib_gridsize),MOVE_WORLDONLY,self);
+ traceline(end + ('0 0 0.25' * pathlib_gridsize),end - ('0 0 1' * pathlib_gridsize),MOVE_WORLDONLY,this);
end = trace_endpos;
if (!(pointcontents(end - '0 0 1') == CONTENT_SOLID))
if(pointcontents(surface + '0 0 1') != CONTENT_EMPTY)
return end;
- tracebox(start + '0 0 64', movenode_boxmin,movenode_boxmax, end + '0 0 64', MOVE_WORLDONLY, self);
+ tracebox(start + '0 0 64', movenode_boxmin,movenode_boxmax, end + '0 0 64', MOVE_WORLDONLY, this);
if(trace_fraction == 1)
pathlib_movenode_goodnode = 1;
return end;
}
-vector pathlib_swimnode(vector start,vector end, float doedge)
-{SELFPARAM();
+vector pathlib_swimnode(entity this, vector start, vector end, float doedge)
+{
pathlib_movenode_goodnode = 0;
if(pointcontents(start) != CONTENT_WATER)
end.y = fsnap(end.y, pathlib_gridsize);
if(pointcontents(end) == CONTENT_EMPTY)
- return pathlib_wateroutnode( start, end, doedge);
+ return pathlib_wateroutnode(this, start, end, doedge);
- tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, self);
+ tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
if(trace_fraction == 1)
pathlib_movenode_goodnode = 1;
return end;
}
-vector pathlib_flynode(vector start,vector end, float doedge)
-{SELFPARAM();
+vector pathlib_flynode(entity this, vector start, vector end, float doedge)
+{
pathlib_movenode_goodnode = 0;
end.x = fsnap(end.x, pathlib_gridsize);
end.y = fsnap(end.y, pathlib_gridsize);
- tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, self);
+ tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
if(trace_fraction == 1)
pathlib_movenode_goodnode = 1;
return end;
}
-void a_think()
-{SELFPARAM();
- te_lightning1(self,self.origin, self.pos1);
- if(self.cnt < time)
- remove(self);
+void a_think(entity this)
+{
+ te_lightning1(this,this.origin, this.pos1);
+ if(this.cnt < time)
+ remove(this);
else
- self.nextthink = time + 0.2;
+ this.nextthink = time + 0.2;
}
-vector pathlib_walknode(vector start,vector end,float doedge)
-{SELFPARAM();
+vector pathlib_walknode(entity this, vector start, vector end, float doedge)
+{
vector direction,point,last_point,s,e;
float steps, distance, i;
start.y = fsnap(start.y,pathlib_gridsize);
// Find the floor
- traceline(start + movenode_stepup, start - movenode_maxdrop, MOVE_WORLDONLY, self);
+ traceline(start + movenode_stepup, start - movenode_maxdrop, MOVE_WORLDONLY, this);
if(trace_fraction == 1.0)
{
entity a;
a = spawn();
- a.think = a_think;
+ setthink(a, a_think);
a.nextthink = time;
setorigin(a,start + movenode_stepup);
a.pos1 = trace_endpos;
for(i = 1; i < steps; ++i)
{
point = last_point + (direction * movenode_stepsize);
- traceline(point + movenode_stepup,point - movenode_maxdrop,MOVE_WORLDONLY,self);
+ traceline(point + movenode_stepup,point - movenode_maxdrop,MOVE_WORLDONLY,this);
if(trace_fraction == 1.0)
return trace_endpos;
//dprint("end_x: ",ftos(end_x), " end_y: ",ftos(end_y),"\n");
//dprint("point_x:",ftos(point_x)," point_y:",ftos(point_y),"\n\n");
- traceline(point + movenode_stepup, point - movenode_maxdrop,MOVE_WORLDONLY,self);
+ traceline(point + movenode_stepup, point - movenode_maxdrop,MOVE_WORLDONLY,this);
if(trace_fraction == 1.0)
return trace_endpos;
last_point = trace_endpos;
- tracebox(start + movenode_boxup, movenode_boxmin,movenode_boxmax, last_point + movenode_boxup, MOVE_WORLDONLY, self);
+ tracebox(start + movenode_boxup, movenode_boxmin,movenode_boxmax, last_point + movenode_boxup, MOVE_WORLDONLY, this);
if(trace_fraction != 1.0)
return trace_endpos;
return world;
}
-void plas_think()
-{SELFPARAM();
+void plas_think(entity this)
+{
pathlib_waypointpath_step();
if(pathlib_foundgoal)
return;
- self.nextthink = time + 0.1;
+ this.nextthink = time + 0.1;
}
void pathlib_waypointpath_autostep()
{
entity n;
n = spawn();
- n.think = plas_think;
+ setthink(n, plas_think);
n.nextthink = time + 0.1;
}
vector tile_check_up;
vector tile_check_down;
float tile_check_size;
-float tile_check_cross(vector where);
-float tile_check_plus(vector where);
-float tile_check_star(vector where);
-var float tile_check(vector where);
+float tile_check_cross(entity this, vector where);
+float tile_check_plus(entity this, vector where);
+float tile_check_star(entity this, vector where);
+var float tile_check(entity this, vector where);
float movenode_stepsize;
vector movenode_stepup;
vector movenode_boxmin;
float pathlib_movenode_goodnode;
-vector pathlib_wateroutnode(vector start, vector end, float doedge);
-vector pathlib_swimnode(vector start, vector end, float doedge);
-vector pathlib_flynode(vector start, vector end, float doedge);
-vector pathlib_walknode(vector start, vector end, float doedge);
-var vector pathlib_movenode(vector start, vector end, float doedge);
+vector pathlib_wateroutnode(entity this, vector start, vector end, float doedge);
+vector pathlib_swimnode(entity this, vector start, vector end, float doedge);
+vector pathlib_flynode(entity this, vector start, vector end, float doedge);
+vector pathlib_walknode(entity this, vector start, vector end, float doedge);
+var vector pathlib_movenode(entity this, vector start, vector end, float doedge);
float pathlib_expandnode_star(entity node, vector start, vector goal);
float pathlib_expandnode_box(entity node, vector start, vector goal);
return world;
}
-float tile_check_cross(vector where)
-{SELFPARAM();
+float tile_check_cross(entity this, vector where)
+{
vector p,f,r;
f = PLIB_FORWARD * tile_check_size;
// forward-right
p = where + f + r;
- traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+ traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (!location_isok(trace_endpos, 1, 0))
return 0;
// Forward-left
p = where + f - r;
- traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+ traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (!location_isok(trace_endpos, 1, 0))
return 0;
// Back-right
p = where - f + r;
- traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+ traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (!location_isok(trace_endpos, 1 ,0))
return 0;
//Back-left
p = where - f - r;
- traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+ traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (!location_isok(trace_endpos, 1, 0))
return 0;
return 1;
}
-float tile_check_plus(vector where)
-{SELFPARAM();
+float tile_check_plus(entity this, vector where)
+{
vector p,f,r;
f = PLIB_FORWARD * tile_check_size;
// forward
p = where + f;
- traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+ traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (!location_isok(trace_endpos,1,0))
return 0;
//left
p = where - r;
- traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+ traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (!location_isok(trace_endpos,1,0))
return 0;
// Right
p = where + r;
- traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+ traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (!location_isok(trace_endpos,1,0))
return 0;
//Back
p = where - f;
- traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+ traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (!location_isok(trace_endpos,1,0))
return 0;
return 1;
}
-float tile_check_plus2(vector where)
-{SELFPARAM();
+float tile_check_plus2(entity this, vector where)
+{
vector p,f,r;
float i = 0, e = 0;
// forward
p = where + f;
- traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+ traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (location_isok(trace_endpos,1,0))
{
++i;
//left
p = where - r;
- traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+ traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (location_isok(trace_endpos,1,0))
{
++i;
// Right
p = where + r;
- traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+ traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (location_isok(trace_endpos,1,0))
{
++i;
//Back
p = where - f;
- traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+ traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (location_isok(trace_endpos,1,0))
{
++i;
// forward-right
p = where + f + r;
- traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+ traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (location_isok(trace_endpos, 1, 0))
{
++i;
// Forward-left
p = where + f - r;
- traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+ traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (location_isok(trace_endpos, 1, 0))
{
++i;
// Back-right
p = where - f + r;
- traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+ traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (location_isok(trace_endpos, 1 ,0))
{
++i;
//Back-left
p = where - f - r;
- traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+ traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (location_isok(trace_endpos, 1, 0))
{
++i;
return e;
}
-float tile_check_star(vector where)
+float tile_check_star(entity this, vector where)
{
- if(tile_check_plus(where))
- return tile_check_cross(where);
+ if(tile_check_plus(this, where))
+ return tile_check_cross(this, where);
return 0;
}
float fsnap(float val,float fsize);
entity pathlib_nodeatpoint(vector where);
-float tile_check_plus2(vector where);
+float tile_check_plus2(entity this, vector where);
{
this.playerdemo_mode = PLAYERDEMO_MODE_OFF;
}
-void playerdemo_shutdown()
-{SELFPARAM();
- if(self.playerdemo_mode != PLAYERDEMO_MODE_OFF)
+void playerdemo_shutdown(entity this)
+{
+ if(this.playerdemo_mode != PLAYERDEMO_MODE_OFF)
{
- LOG_INFO("playerdemo: ", self.netname, " closed\n");
- fclose(self.playerdemo_fh);
+ LOG_INFO("playerdemo: ", this.netname, " closed\n");
+ fclose(this.playerdemo_fh);
}
- self.playerdemo_mode = 0;
+ this.playerdemo_mode = 0;
}
-void playerdemo_open_read(string f)
-{SELFPARAM();
- playerdemo_shutdown();
- self.playerdemo_mode = PLAYERDEMO_MODE_READING;
- self.playerdemo_fh = fopen(f, FILE_READ);
- self.playerdemo_starttime = time - 1;
- self.playerdemo_time = stof(fgets(self.playerdemo_fh));
- self.playerdemo_time += self.playerdemo_starttime;
- self.movetype = MOVETYPE_NONE;
- LOG_INFO("playerdemo: ", self.netname, " reading from ", f, "\n");
-}
-void playerdemo_open_write(string f)
-{SELFPARAM();
- playerdemo_shutdown();
- self.playerdemo_mode = PLAYERDEMO_MODE_WRITING;
- self.playerdemo_fh = fopen(f, FILE_WRITE);
- self.playerdemo_starttime = time - 1;
- LOG_INFO("playerdemo: ", self.netname, " writing to ", f, "\n");
+void playerdemo_open_read(entity this, string f)
+{
+ playerdemo_shutdown(this);
+ this.playerdemo_mode = PLAYERDEMO_MODE_READING;
+ this.playerdemo_fh = fopen(f, FILE_READ);
+ this.playerdemo_starttime = time - 1;
+ this.playerdemo_time = stof(fgets(this.playerdemo_fh));
+ this.playerdemo_time += this.playerdemo_starttime;
+ this.movetype = MOVETYPE_NONE;
+ LOG_INFO("playerdemo: ", this.netname, " reading from ", f, "\n");
+}
+void playerdemo_open_write(entity this, string f)
+{
+ playerdemo_shutdown(this);
+ this.playerdemo_mode = PLAYERDEMO_MODE_WRITING;
+ this.playerdemo_fh = fopen(f, FILE_WRITE);
+ this.playerdemo_starttime = time - 1;
+ LOG_INFO("playerdemo: ", this.netname, " writing to ", f, "\n");
LOG_INFO("WARNING: playerdemo file format is incomplete and not stable yet. DO NOT RELY ON IT!\n");
}
#define PLAYERDEMO_FIELD(func,t,f) func##t(f,#f);
#pragma once
void playerdemo_init(entity this);
-void playerdemo_shutdown();
+void playerdemo_shutdown(entity this);
void playerdemo_write();
float playerdemo_read(entity this);
-void playerdemo_open_read(string f);
-void playerdemo_open_write(string f);
+void playerdemo_open_read(entity this, string f);
+void playerdemo_open_write(entity this, string f);
#endif
}
-void Portal_Touch()
-{SELFPARAM();
+void Portal_Touch(entity this)
+{
vector g;
#ifdef PORTALS_ARE_NOT_SOLID
// portal is being removed?
- if(self.solid != SOLID_TRIGGER)
+ if(this.solid != SOLID_TRIGGER)
return; // possibly engine bug
if(IS_PLAYER(other))
if(other.vehicle_flags & VHF_ISVEHICLE)
return; // no teleporting vehicles?
- if(!self.enemy)
+ if(!this.enemy)
error("Portal_Touch called for a broken portal\n");
#ifdef PORTALS_ARE_NOT_SOLID
if(other.classname == "porto")
{
- if(other.portal_id == self.portal_id)
+ if(other.portal_id == this.portal_id)
return;
}
- if(time < self.portal_activatetime)
- if(other == self.aiment)
+ if(time < this.portal_activatetime)
+ if(other == this.aiment)
{
- self.portal_activatetime = time + 0.1;
+ this.portal_activatetime = time + 0.1;
return;
}
- if(other != self.aiment)
+ if(other != this.aiment)
if(IS_PLAYER(other))
- if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(self.aiment))
+ if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(this.aiment))
return; // cannot go through someone else's portal
- if(other.aiment != self.aiment)
+ if(other.aiment != this.aiment)
if(IS_PLAYER(other.aiment))
- if(IS_INDEPENDENT_PLAYER(other.aiment) || IS_INDEPENDENT_PLAYER(self.aiment))
+ if(IS_INDEPENDENT_PLAYER(other.aiment) || IS_INDEPENDENT_PLAYER(this.aiment))
return; // cannot go through someone else's portal
- fixedmakevectors(self.mangle);
+ fixedmakevectors(this.mangle);
g = frametime * '0 0 -1' * autocvar_sv_gravity;
- if(!Portal_WillHitPlane(other.origin, other.mins, other.maxs, other.velocity + g, self.origin, v_forward, self.maxs.x))
+ if(!Portal_WillHitPlane(other.origin, other.mins, other.maxs, other.velocity + g, this.origin, v_forward, this.maxs.x))
return;
/*
}
*/
- if(Portal_TeleportPlayer(self, other))
+ if(Portal_TeleportPlayer(this, other))
if(other.classname == "porto")
if(other.effects & EF_RED)
other.effects += EF_BLUE - EF_RED;
}
-void Portal_Think();
+void Portal_Think(entity this);
void Portal_MakeBrokenPortal(entity portal)
{
portal.skin = 2;
portal.solid = SOLID_NOT;
- portal.touch = func_null;
- portal.think = func_null;
+ settouch(portal, func_null);
+ setthink(portal, func_null);
portal.effects = 0;
portal.nextthink = 0;
portal.takedamage = DAMAGE_NO;
{
portal.skin = 2;
portal.solid = SOLID_NOT;
- portal.touch = func_null;
- portal.think = func_null;
+ settouch(portal, func_null);
+ setthink(portal, func_null);
portal.effects = EF_ADDITIVE;
portal.nextthink = 0;
portal.takedamage = DAMAGE_YES;
{
portal.skin = 0;
portal.solid = SOLID_NOT; // this is done when connecting them!
- portal.touch = Portal_Touch;
- portal.think = Portal_Think;
+ settouch(portal, Portal_Touch);
+ setthink(portal, Portal_Think);
portal.effects = EF_RED;
portal.nextthink = time;
portal.takedamage = DAMAGE_NO;
{
portal.skin = 1;
portal.solid = SOLID_NOT;
- portal.touch = func_null;
- portal.think = func_null;
+ settouch(portal, func_null);
+ setthink(portal, func_null);
portal.effects = EF_STARDUST | EF_BLUE;
portal.nextthink = 0;
portal.takedamage = DAMAGE_YES;
Portal_Remove(this, 1);
}
-void Portal_Think_TryTeleportPlayer(entity e, vector g)
-{SELFPARAM();
- if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, self.origin, v_forward, self.maxs.x))
+void Portal_Think_TryTeleportPlayer(entity this, entity e, vector g)
+{
+ if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, this.origin, v_forward, this.maxs.x))
return;
// if e would hit the portal in a frame...
// already teleport him
tracebox(e.origin, e.mins, e.maxs, e.origin + e.velocity * 2 * frametime, MOVE_NORMAL, e);
- if(trace_ent == self)
- Portal_TeleportPlayer(self, e);
+ if(trace_ent == this)
+ Portal_TeleportPlayer(this, e);
}
-void Portal_Think()
-{SELFPARAM();
+void Portal_Think(entity this)
+{
entity o;
vector g;
#ifdef PORTALS_ARE_NOT_SOLID
// portal is being removed?
- if(self.solid != SOLID_TRIGGER)
+ if(this.solid != SOLID_TRIGGER)
return; // possibly engine bug
- if(!self.enemy)
+ if(!this.enemy)
error("Portal_Think called for a broken portal\n");
- o = self.aiment;
- self.solid = SOLID_BBOX;
- self.aiment = world;
+ o = this.aiment;
+ this.solid = SOLID_BBOX;
+ this.aiment = world;
g = frametime * '0 0 -1' * autocvar_sv_gravity;
- fixedmakevectors(self.mangle);
+ fixedmakevectors(this.mangle);
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
if(it != o)
if(IS_INDEPENDENT_PLAYER(it) || IS_INDEPENDENT_PLAYER(o))
continue; // cannot go through someone else's portal
- if(it != o || time >= self.portal_activatetime)
- Portal_Think_TryTeleportPlayer(it, g);
+ if(it != o || time >= this.portal_activatetime)
+ Portal_Think_TryTeleportPlayer(this, it, g);
if(it.hook)
- Portal_Think_TryTeleportPlayer(it.hook, g);
+ Portal_Think_TryTeleportPlayer(this, it.hook, g);
));
- self.solid = SOLID_TRIGGER;
- self.aiment = o;
+ this.solid = SOLID_TRIGGER;
+ this.aiment = o;
#endif
- self.nextthink = time;
+ this.nextthink = time;
- if(time > self.fade_time)
- Portal_Remove(self, 0);
+ if(time > this.fade_time)
+ Portal_Remove(this, 0);
}
float Portal_Customize()
{SELFPARAM();
if(IS_SPEC(other))
other = other.enemy;
- if(other == self.aiment)
+ if(other == this.aiment)
{
- self.modelindex = self.savemodelindex;
+ this.modelindex = this.savemodelindex;
}
- else if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(self.aiment))
+ else if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(this.aiment))
{
- self.modelindex = 0;
+ this.modelindex = 0;
}
else
{
- self.modelindex = self.savemodelindex;
+ this.modelindex = this.savemodelindex;
}
return true;
}
Portal_ClearAll_PortalsOnly(own);
W_Porto_Remove(own);
}
-void Portal_RemoveLater_Think()
-{SELFPARAM();
- Portal_Remove(self, self.cnt);
+void Portal_RemoveLater_Think(entity this)
+{
+ Portal_Remove(this, this.cnt);
}
void Portal_RemoveLater(entity portal, float kill)
{
Portal_MakeBrokenPortal(portal);
portal.cnt = kill;
- portal.think = Portal_RemoveLater_Think;
+ setthink(portal, Portal_RemoveLater_Think);
portal.nextthink = time;
}
void Portal_ClearAllLater_PortalsOnly(entity own)
portal.mangle = ang;
portal.angles = ang;
portal.angles_x = -portal.angles.x; // is a bmodel
- portal.think = Portal_Think;
+ setthink(portal, Portal_Think);
portal.nextthink = 0;
portal.portal_activatetime = time + 0.1;
portal.takedamage = DAMAGE_AIM;
race_SendNextCheckpoint(msg_entity.enemy, 1);
}
-void W_Porto_Fail(float failhard);
+void W_Porto_Fail(entity this, float failhard);
float race_readTime(string map, float pos)
{
}
}
-void checkpoint_passed()
-{SELFPARAM();
+void checkpoint_passed(entity this, entity player)
+{
string oldmsg;
entity cp;
- if(other.classname == "porto")
+ if(player.classname == "porto")
{
// do not allow portalling through checkpoints
- trace_plane_normal = normalize(-1 * other.velocity);
- setself(other);
- W_Porto_Fail(0);
+ trace_plane_normal = normalize(-1 * player.velocity);
+ W_Porto_Fail(player, 0);
return;
}
/*
* Trigger targets
*/
- if (!((self.spawnflags & 2) && (IS_PLAYER(other))))
+ if (!((this.spawnflags & 2) && (IS_PLAYER(player))))
{
- oldmsg = self.message;
- self.message = "";
- SUB_UseTargets(self, other, other); // TODO: should we be using other for the trigger here?
- self.message = oldmsg;
+ oldmsg = this.message;
+ this.message = "";
+ SUB_UseTargets(this, player, player);
+ this.message = oldmsg;
}
- if (!IS_PLAYER(other))
+ if (!IS_PLAYER(player))
return;
/*
* Remove unauthorized equipment
*/
- Portal_ClearAll(other);
+ Portal_ClearAll(player);
- other.porto_forbidden = 2; // decreased by 1 each StartFrame
+ player.porto_forbidden = 2; // decreased by 1 each StartFrame
if(defrag_ents)
{
- if(self.race_checkpoint == -2)
+ if(this.race_checkpoint == -2)
{
- self.race_checkpoint = other.race_checkpoint;
+ this.race_checkpoint = player.race_checkpoint;
}
float largest_cp_id = 0;
}
}
- if((other.race_checkpoint == -1 && self.race_checkpoint == 0) || (other.race_checkpoint == self.race_checkpoint))
+ if((player.race_checkpoint == -1 && this.race_checkpoint == 0) || (player.race_checkpoint == this.race_checkpoint))
{
- if(self.race_penalty)
+ if(this.race_penalty)
{
- if(other.race_lastpenalty != self)
+ if(player.race_lastpenalty != this)
{
- other.race_lastpenalty = self;
- race_ImposePenaltyTime(other, self.race_penalty, self.race_penalty_reason);
+ player.race_lastpenalty = this;
+ race_ImposePenaltyTime(player, this.race_penalty, this.race_penalty_reason);
}
}
- if(other.race_penalty)
+ if(player.race_penalty)
return;
/*
* Trigger targets
*/
- if(self.spawnflags & 2)
+ if(this.spawnflags & 2)
{
- oldmsg = self.message;
- self.message = "";
- SUB_UseTargets(self, other, other); // TODO: should we be using other for the trigger here?
- self.message = oldmsg;
+ oldmsg = this.message;
+ this.message = "";
+ SUB_UseTargets(this, player, player); // TODO: should we be using other for the trigger here?
+ this.message = oldmsg;
}
- if(other.race_respawn_checkpoint != self.race_checkpoint || !other.race_started)
- other.race_respawn_spotref = self; // this is not a spot but a CP, but spawnpoint selection will deal with that
- other.race_respawn_checkpoint = self.race_checkpoint;
- other.race_checkpoint = race_NextCheckpoint(self.race_checkpoint);
- other.race_started = 1;
+ if(player.race_respawn_checkpoint != this.race_checkpoint || !player.race_started)
+ player.race_respawn_spotref = this; // this is not a spot but a CP, but spawnpoint selection will deal with that
+ player.race_respawn_checkpoint = this.race_checkpoint;
+ player.race_checkpoint = race_NextCheckpoint(this.race_checkpoint);
+ player.race_started = 1;
- race_SendTime(other, self.race_checkpoint, other.race_movetime, boolean(other.race_laptime));
+ race_SendTime(player, this.race_checkpoint, player.race_movetime, boolean(player.race_laptime));
- if(!self.race_checkpoint) // start line
+ if(!this.race_checkpoint) // start line
{
- other.race_laptime = time;
- other.race_movetime = other.race_movetime_frac = other.race_movetime_count = 0;
- other.race_penalty_accumulator = 0;
- other.race_lastpenalty = world;
+ player.race_laptime = time;
+ player.race_movetime = player.race_movetime_frac = player.race_movetime_count = 0;
+ player.race_penalty_accumulator = 0;
+ player.race_lastpenalty = world;
}
if(g_race_qualifying)
- race_SendNextCheckpoint(other, 0);
+ race_SendNextCheckpoint(player, 0);
- if(defrag_ents && defragcpexists < 0 && self.classname == "target_stopTimer")
+ if(defrag_ents && defragcpexists < 0 && this.classname == "target_stopTimer")
{
float fh;
defragcpexists = fh = fopen(strcat("maps/", GetMapname(), ".defragcp"), FILE_WRITE);
fclose(fh);
}
}
- else if(other.race_checkpoint == race_NextCheckpoint(self.race_checkpoint))
+ else if(player.race_checkpoint == race_NextCheckpoint(this.race_checkpoint))
{
// ignored
}
else
{
- if(self.spawnflags & 4)
- Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0');
+ if(this.spawnflags & 4)
+ Damage (player, this, this, 10000, DEATH_HURTTRIGGER.m_id, player.origin, '0 0 0');
}
}
-void checkpoint_touch()
+void checkpoint_touch(entity this)
{
EXACTTRIGGER_TOUCH;
- checkpoint_passed();
+ checkpoint_passed(this, other);
}
void checkpoint_use(entity this, entity actor, entity trigger)
if(trigger.classname == "info_player_deathmatch") // a spawn, a spawn
return;
- other = actor;
- checkpoint_passed();
+ checkpoint_passed(this, actor);
}
-float race_waypointsprite_visible_for_player(entity e)
-{SELFPARAM();
- if(e.race_checkpoint == -1 || self.owner.race_checkpoint == -2)
+bool race_waypointsprite_visible_for_player(entity this, entity player, entity view)
+{
+ if(view.race_checkpoint == -1 || this.owner.race_checkpoint == -2)
return true;
- else if(e.race_checkpoint == self.owner.race_checkpoint)
+ else if(view.race_checkpoint == this.owner.race_checkpoint)
return true;
else
return false;
// race only (middle of the race)
g_race_qualifying = false;
pl_race_place = 0;
- if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ if (!Spawn_FilterOutBadSpots(this, 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"));
}
// qualifying only
g_race_qualifying = 1;
pl_race_place = race_lowest_place_spawn;
- if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ if (!Spawn_FilterOutBadSpots(this, 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"));
}
g_race_qualifying = 0;
for (int p = 1; p <= race_highest_place_spawn; ++p) {
pl_race_place = p;
- if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ if (!Spawn_FilterOutBadSpots(this, 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"));
}
}
pl_race_checkpoint = race_NextCheckpoint(0);
g_race_qualifying = 1;
pl_race_place = race_lowest_place_spawn;
- if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ if (!Spawn_FilterOutBadSpots(this, 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 {
}
}
-vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current)
-{SELFPARAM();
+vector trigger_race_checkpoint_spawn_evalfunc(entity this, entity player, entity spot, vector current)
+{
if(g_race_qualifying)
{
// spawn at first
- if(self.race_checkpoint != 0)
+ if(this.race_checkpoint != 0)
return '-1 0 0';
if(spot.race_place != race_lowest_place_spawn)
return '-1 0 0';
}
else
{
- if(self.race_checkpoint != player.race_respawn_checkpoint)
+ if(this.race_checkpoint != player.race_respawn_checkpoint)
return '-1 0 0';
// try reusing the previous spawn
- if(self == player.race_respawn_spotref || spot == player.race_respawn_spotref)
+ if(this == player.race_respawn_spotref || spot == player.race_respawn_spotref)
current.x += SPAWN_PRIO_RACE_PREVIOUS_SPAWN;
- if(self.race_checkpoint == 0)
+ if(this.race_checkpoint == 0)
{
- float pl;
- pl = player.race_place;
+ int pl = player.race_place;
if(pl > race_highest_place_spawn)
pl = 0;
if(pl == 0 && !player.race_started)
spawnfunc(trigger_race_checkpoint)
{
vector o;
- if(!g_race && !g_cts) { remove(self); return; }
+ if(!g_race && !g_cts) { remove(this); return; }
EXACTTRIGGER_INIT;
- self.use = checkpoint_use;
- if (!(self.spawnflags & 1))
- self.touch = checkpoint_touch;
+ this.use = checkpoint_use;
+ if (!(this.spawnflags & 1))
+ settouch(this, checkpoint_touch);
- o = (self.absmin + self.absmax) * 0.5;
- tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self);
- waypoint_spawnforitem_force(self, trace_endpos);
- self.nearestwaypointtimeout = time + 1000000000;
+ o = (this.absmin + this.absmax) * 0.5;
+ tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - this.absmin.z), MOVE_NORMAL, this);
+ waypoint_spawnforitem_force(this, trace_endpos);
+ this.nearestwaypointtimeout = time + 1000000000;
- if(self.message == "")
- self.message = "went backwards";
- if (self.message2 == "")
- self.message2 = "was pushed backwards by";
- if (self.race_penalty_reason == "")
- self.race_penalty_reason = "missing a checkpoint";
+ if(this.message == "")
+ this.message = "went backwards";
+ if (this.message2 == "")
+ this.message2 = "was pushed backwards by";
+ if (this.race_penalty_reason == "")
+ this.race_penalty_reason = "missing a checkpoint";
- self.race_checkpoint = self.cnt;
+ this.race_checkpoint = this.cnt;
- if(self.race_checkpoint > race_highest_checkpoint)
+ if(this.race_checkpoint > race_highest_checkpoint)
{
- race_highest_checkpoint = self.race_checkpoint;
- if(self.spawnflags & 8)
- race_timed_checkpoint = self.race_checkpoint;
+ race_highest_checkpoint = this.race_checkpoint;
+ if(this.spawnflags & 8)
+ race_timed_checkpoint = this.race_checkpoint;
else
race_timed_checkpoint = 0;
}
- if(!self.race_penalty)
+ if(!this.race_penalty)
{
- if(self.race_checkpoint)
- WaypointSprite_SpawnFixed(WP_RaceCheckpoint, o, self, sprite, RADARICON_NONE);
+ if(this.race_checkpoint)
+ WaypointSprite_SpawnFixed(WP_RaceCheckpoint, o, this, sprite, RADARICON_NONE);
else
- WaypointSprite_SpawnFixed(WP_RaceStartFinish, o, self, sprite, RADARICON_NONE);
+ WaypointSprite_SpawnFixed(WP_RaceStartFinish, o, this, sprite, RADARICON_NONE);
}
- self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
- self.spawn_evalfunc = trigger_race_checkpoint_spawn_evalfunc;
+ this.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
+ this.spawn_evalfunc = trigger_race_checkpoint_spawn_evalfunc;
- InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
+ InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
}
spawnfunc(target_checkpoint) // defrag entity
{
vector o;
- if(!g_race && !g_cts) { remove(self); return; }
+ if(!g_race && !g_cts) { remove(this); return; }
defrag_ents = 1;
EXACTTRIGGER_INIT;
- self.use = checkpoint_use;
- if (!(self.spawnflags & 1))
- self.touch = checkpoint_touch;
+ this.use = checkpoint_use;
+ if (!(this.spawnflags & 1))
+ settouch(this, checkpoint_touch);
- o = (self.absmin + self.absmax) * 0.5;
- tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self);
- waypoint_spawnforitem_force(self, trace_endpos);
- self.nearestwaypointtimeout = time + 1000000000;
+ o = (this.absmin + this.absmax) * 0.5;
+ tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - this.absmin.z), MOVE_NORMAL, this);
+ waypoint_spawnforitem_force(this, trace_endpos);
+ this.nearestwaypointtimeout = time + 1000000000;
- if(self.message == "")
- self.message = "went backwards";
- if (self.message2 == "")
- self.message2 = "was pushed backwards by";
- if (self.race_penalty_reason == "")
- self.race_penalty_reason = "missing a checkpoint";
+ if(this.message == "")
+ this.message = "went backwards";
+ if (this.message2 == "")
+ this.message2 = "was pushed backwards by";
+ if (this.race_penalty_reason == "")
+ this.race_penalty_reason = "missing a checkpoint";
- if(self.classname == "target_startTimer")
- self.race_checkpoint = 0;
+ if(this.classname == "target_startTimer")
+ this.race_checkpoint = 0;
else
- self.race_checkpoint = -2;
+ this.race_checkpoint = -2;
race_timed_checkpoint = 1;
- if(self.race_checkpoint == 0)
- WaypointSprite_SpawnFixed(WP_RaceStart, o, self, sprite, RADARICON_NONE);
+ if(this.race_checkpoint == 0)
+ WaypointSprite_SpawnFixed(WP_RaceStart, o, this, sprite, RADARICON_NONE);
else
- WaypointSprite_SpawnFixed(WP_RaceCheckpoint, o, self, sprite, RADARICON_NONE);
+ WaypointSprite_SpawnFixed(WP_RaceCheckpoint, o, this, sprite, RADARICON_NONE);
- self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
+ this.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
- InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
+ InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
}
spawnfunc(target_startTimer) { spawnfunc_target_checkpoint(this); }
FOREACH_CLIENT(IS_PLAYER(it) && IS_DEAD(it), LAMBDA(race_AbandonRaceCheck(it)));
}
-void race_PreparePlayer()
-{SELFPARAM();
- race_ClearTime(self);
- self.race_place = 0;
- self.race_started = 0;
- self.race_respawn_checkpoint = 0;
- self.race_respawn_spotref = world;
+void race_PreparePlayer(entity this)
+{
+ race_ClearTime(this);
+ this.race_place = 0;
+ this.race_started = 0;
+ this.race_respawn_checkpoint = 0;
+ this.race_respawn_spotref = world;
}
-void race_RetractPlayer()
-{SELFPARAM();
+void race_RetractPlayer(entity this)
+{
if(!g_race && !g_cts)
return;
- if(self.race_respawn_checkpoint == 0 || self.race_respawn_checkpoint == race_timed_checkpoint)
- race_ClearTime(self);
- self.race_checkpoint = self.race_respawn_checkpoint;
+ if(this.race_respawn_checkpoint == 0 || this.race_respawn_checkpoint == race_timed_checkpoint)
+ race_ClearTime(this);
+ this.race_checkpoint = this.race_respawn_checkpoint;
}
spawnfunc(info_player_race)
{
- if(!g_race && !g_cts) { remove(self); return; }
+ if(!g_race && !g_cts) { remove(this); return; }
++race_spawns;
spawnfunc_info_player_deathmatch(this);
- if(self.race_place > race_highest_place_spawn)
- race_highest_place_spawn = self.race_place;
- if(self.race_place < race_lowest_place_spawn)
- race_lowest_place_spawn = self.race_place;
+ if(this.race_place > race_highest_place_spawn)
+ race_highest_place_spawn = this.race_place;
+ if(this.race_place < race_lowest_place_spawn)
+ race_lowest_place_spawn = this.race_place;
}
void race_ClearRecords()
-{SELFPARAM();
+{
float i;
for(i = 0; i < MAX_CHECKPOINTS; ++i)
FOREACH_CLIENT(true, LAMBDA(
float p = it.race_place;
- WITHSELF(it, race_PreparePlayer());
+ race_PreparePlayer(it);
it.race_place = p;
));
}
}
}
-void penalty_touch()
-{SELFPARAM();
+void penalty_touch(entity this)
+{
EXACTTRIGGER_TOUCH;
- if(other.race_lastpenalty != self)
+ if(other.race_lastpenalty != this)
{
- other.race_lastpenalty = self;
- race_ImposePenaltyTime(other, self.race_penalty, self.race_penalty_reason);
+ other.race_lastpenalty = this;
+ race_ImposePenaltyTime(other, this.race_penalty, this.race_penalty_reason);
}
}
spawnfunc(trigger_race_penalty)
{
// TODO: find out why this wasnt done:
- //if(!g_cts && !g_race) { remove(self); return; }
+ //if(!g_cts && !g_race) { remove(this); return; }
EXACTTRIGGER_INIT;
- self.use = penalty_use;
- if (!(self.spawnflags & 1))
- self.touch = penalty_touch;
+ this.use = penalty_use;
+ if (!(this.spawnflags & 1))
+ settouch(this, penalty_touch);
- if (self.race_penalty_reason == "")
- self.race_penalty_reason = "missing a checkpoint";
- if (!self.race_penalty)
- self.race_penalty = 5;
+ if (this.race_penalty_reason == "")
+ this.race_penalty_reason = "missing a checkpoint";
+ if (!this.race_penalty)
+ this.race_penalty = 5;
}
float race_GetFractionalLapCount(entity e)
string race_readName(string map, float pos);
void race_ClearRecords();
void race_SendNextCheckpoint(entity e, float spec);
-void race_PreparePlayer();
+void race_PreparePlayer(entity this);
void race_send_recordtime(float msg);
void race_send_speedaward(float msg);
void race_SendRankings(float pos, float prevpos, float del, float msg);
-void race_RetractPlayer();
+void race_RetractPlayer(entity this);
void race_InitSpectator();
#include "command/vote.qh"
#include "../common/util.qh"
-void round_handler_Think()
+void round_handler_Think(entity this)
{
- SELFPARAM();
-
if (time < game_starttime)
{
round_handler_Reset(game_starttime);
// NOTE: this is only needed because if round_handler spawns at time 1
// gamestarttime isn't initialized yet
-void round_handler_FirstThink()
+void round_handler_FirstThink(entity this)
{
- SELFPARAM();
round_starttime = max(time, game_starttime) + this.count;
- this.think = round_handler_Think;
+ setthink(this, round_handler_Think);
this.nextthink = max(time, game_starttime);
}
}
entity this = round_handler = new(round_handler);
- this.think = round_handler_FirstThink;
+ setthink(this, round_handler_FirstThink);
this.canRoundStart = canRoundStart_func;
this.canRoundEnd = canRoundEnd_func;
this.roundStart = roundStart_func;
longflags = 0;
for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
- if(self.(teamscores[i]) > 127 || self.(teamscores[i]) <= -128)
+ if(this.(teamscores[i]) > 127 || this.(teamscores[i]) <= -128)
longflags |= p;
#if MAX_TEAMSCORE <= 8
if(sendflags & p)
{
if(longflags & p)
- WriteInt24_t(MSG_ENTITY, self.(teamscores[i]));
+ WriteInt24_t(MSG_ENTITY, this.(teamscores[i]));
else
- WriteChar(MSG_ENTITY, self.(teamscores[i]));
+ WriteChar(MSG_ENTITY, this.(teamscores[i]));
}
return true;
float i, p, longflags;
WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES);
- WriteByte(MSG_ENTITY, etof(self.owner));
+ WriteByte(MSG_ENTITY, etof(this.owner));
longflags = 0;
for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
- if(self.(scores[i]) > 127 || self.(scores[i]) <= -128)
+ if(this.(scores[i]) > 127 || this.(scores[i]) <= -128)
longflags |= p;
#if MAX_SCORE <= 8
if(sendflags & p)
{
if(longflags & p)
- WriteInt24_t(MSG_ENTITY, self.(scores[i]));
+ WriteInt24_t(MSG_ENTITY, this.(scores[i]));
else
- WriteChar(MSG_ENTITY, self.(scores[i]));
+ WriteChar(MSG_ENTITY, this.(scores[i]));
}
return true;
s = GetGametype();
s = strcat(s, ":", autocvar_g_xonoticversion);
s = strcat(s, ":P", ftos(cvar_purechanges_count));
- s = strcat(s, ":S", ftos(nJoinAllowed(self, world)));
+ s = strcat(s, ":S", ftos(nJoinAllowed(this, world))); // note: self/this is most likely world in this case
s = strcat(s, ":F", ftos(serverflags));
s = strcat(s, ":M", modname);
s = strcat(s, "::", GetPlayerScoreString(world, (fullstatus ? 1 : 2)));
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT);
- WriteByte(MSG_ENTITY, self.team);
- WriteCoord(MSG_ENTITY, self.origin.x);
- WriteCoord(MSG_ENTITY, self.origin.y);
- WriteCoord(MSG_ENTITY, self.origin.z);
+ WriteByte(MSG_ENTITY, this.team);
+ WriteCoord(MSG_ENTITY, this.origin.x);
+ WriteCoord(MSG_ENTITY, this.origin.y);
+ WriteCoord(MSG_ENTITY, this.origin.z);
return true;
}
}
.vector spawnpoint_prevorigin;
-void spawnpoint_think()
+void spawnpoint_think(entity this)
{
- SELFPARAM();
this.nextthink = time + 0.1;
if(this.origin != this.spawnpoint_prevorigin)
{
//LOG_INFO("spawnpoint was used!\n");
}
-void relocate_spawnpoint()
-{SELFPARAM();
+void relocate_spawnpoint(entity this)
+{
// nudge off the floor
- setorigin(self, self.origin + '0 0 1');
+ setorigin(this, this.origin + '0 0 1');
- tracebox(self.origin, PL_MIN_CONST, PL_MAX_CONST, self.origin, true, self);
+ tracebox(this.origin, PL_MIN_CONST, PL_MAX_CONST, this.origin, true, this);
if (trace_startsolid)
{
vector o;
- o = self.origin;
- self.mins = PL_MIN_CONST;
- self.maxs = PL_MAX_CONST;
- if (!move_out_of_solid(self))
+ o = this.origin;
+ this.mins = PL_MIN_CONST;
+ this.maxs = PL_MAX_CONST;
+ if (!move_out_of_solid(this))
objerror("could not get out of solid at all!");
LOG_INFO("^1NOTE: this map needs FIXING. Spawnpoint at ", vtos(o - '0 0 1'));
- LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
- LOG_INFO(" ", ftos(self.origin.y - o.y));
- LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
+ LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(this.origin.x - o.x));
+ LOG_INFO(" ", ftos(this.origin.y - o.y));
+ LOG_INFO(" ", ftos(this.origin.z - o.z), "'\n");
if (autocvar_g_spawnpoints_auto_move_out_of_solid)
{
if (!spawnpoint_nag)
}
else
{
- setorigin(self, o);
- self.mins = self.maxs = '0 0 0';
+ setorigin(this, o);
+ this.mins = this.maxs = '0 0 0';
objerror("player spawn point in solid, mapper sucks!\n");
return;
}
}
- self.use = spawnpoint_use;
- self.think = spawnpoint_think;
- self.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second
- self.team_saved = self.team;
- if (!self.cnt)
- self.cnt = 1;
+ this.use = spawnpoint_use;
+ setthink(this, spawnpoint_think);
+ this.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second
+ this.team_saved = this.team;
+ if (!this.cnt)
+ this.cnt = 1;
if (have_team_spawns != 0)
- if (self.team)
+ if (this.team)
have_team_spawns = 1;
- have_team_spawns_forteam[self.team] = 1;
+ have_team_spawns_forteam[this.team] = 1;
if (autocvar_r_showbboxes)
{
// show where spawnpoints point at too
- makevectors(self.angles);
+ makevectors(this.angles);
entity e = new(info_player_foo);
- setorigin(e, self.origin + v_forward * 24);
+ setorigin(e, this.origin + v_forward * 24);
setsize(e, '-8 -8 -8', '8 8 8');
e.solid = SOLID_TRIGGER;
}
!(
( // if this passes, there is a DM spawn on a team match
teamplay
- && (self.team != NUM_TEAM_1)
- && (self.team != NUM_TEAM_2)
- && (self.team != NUM_TEAM_3)
- && (self.team != NUM_TEAM_4)
+ && (this.team != NUM_TEAM_1)
+ && (this.team != NUM_TEAM_2)
+ && (this.team != NUM_TEAM_3)
+ && (this.team != NUM_TEAM_4)
)
||
( // if this passes, there is a team spawn on a DM match
!teamplay
&&
(
- (self.team == NUM_TEAM_1)
- || (self.team == NUM_TEAM_2)
- || (self.team == NUM_TEAM_3)
- || (self.team == NUM_TEAM_4)
+ (this.team == NUM_TEAM_1)
+ || (this.team == NUM_TEAM_2)
+ || (this.team == NUM_TEAM_3)
+ || (this.team == NUM_TEAM_4)
)
)
)
||
autocvar_g_spawn_useallspawns
)
- { Net_LinkEntity(self, false, 0, SpawnPoint_Send); }
+ { Net_LinkEntity(this, false, 0, SpawnPoint_Send); }
}
spawnfunc(info_player_survivor)
spawnfunc(info_player_deathmatch)
{
- self.classname = "info_player_deathmatch";
- relocate_spawnpoint();
+ this.classname = "info_player_deathmatch";
+ relocate_spawnpoint(this);
}
/*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
// Returns:
// _x: prio (-1 if unusable)
// _y: weight
-vector Spawn_Score(entity spot, float mindist, float teamcheck)
-{SELFPARAM();
+vector Spawn_Score(entity this, entity spot, float mindist, float teamcheck)
+{
float shortest, thisdist;
float prio;
if(spot.target == "")
return '-1 0 0';
- if(IS_REAL_CLIENT(self))
+ if(IS_REAL_CLIENT(this))
{
if(spot.restriction == 1)
return '-1 0 0';
}
shortest = vlen(world.maxs - world.mins);
- FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
thisdist = vlen(it.origin - spot.origin);
if (thisdist < shortest)
shortest = thisdist;
++found;
if(ent.spawn_evalfunc)
{
- WITHSELF(ent, spawn_score = ent.spawn_evalfunc(this, spot, spawn_score));
+ spawn_score = ent.spawn_evalfunc(ent, this, spot, spawn_score);
if(spawn_score.x < 0)
return spawn_score;
}
}
}
- MUTATOR_CALLHOOK(Spawn_Score, self, spawn_spot, spawn_score);
+ MUTATOR_CALLHOOK(Spawn_Score, this, spawn_spot, spawn_score);
return spawn_score;
}
-void Spawn_ScoreAll(entity firstspot, float mindist, float teamcheck)
+void Spawn_ScoreAll(entity this, entity firstspot, float mindist, float teamcheck)
{
entity spot;
for(spot = firstspot; spot; spot = spot.chain)
- spot.spawnpoint_score = Spawn_Score(spot, mindist, teamcheck);
+ spot.spawnpoint_score = Spawn_Score(this, spot, mindist, teamcheck);
}
-entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck)
+entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck)
{
entity spot, spotlist, spotlistend;
spotlist = world;
spotlistend = world;
- Spawn_ScoreAll(firstspot, mindist, teamcheck);
+ Spawn_ScoreAll(this, firstspot, mindist, teamcheck);
for(spot = firstspot; spot; spot = spot.chain)
{
Finds a point to respawn
=============
*/
-entity SelectSpawnPoint (float anypoint)
-{SELFPARAM();
+entity SelectSpawnPoint(entity this, bool anypoint)
+{
float teamcheck;
entity spot, firstspot;
teamcheck = -1;
else if(have_team_spawns > 0)
{
- if(have_team_spawns_forteam[self.team] == 0)
+ if(have_team_spawns_forteam[this.team] == 0)
{
// we request a spawn for a team, and we have team
// spawns, but that team has no spawns?
teamcheck = -1;
}
else
- teamcheck = self.team; // MUST be team
+ teamcheck = this.team; // MUST be team
}
else if(have_team_spawns == 0 && have_team_spawns_forteam[0])
teamcheck = 0; // MUST be noteam
}
else
{
- firstspot = Spawn_FilterOutBadSpots(firstspot, 100, teamcheck);
+ firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck);
// there is 50/50 chance of choosing a random spot or the furthest spot
// (this means that roughly every other spawn will be furthest, so you
.vector spawnpoint_score;
float spawnpoint_nag;
bool SpawnEvent_Send(entity this, entity to, int sf);
-entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck);
-entity SelectSpawnPoint (float anypoint);
+entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck);
+entity SelectSpawnPoint(entity this, bool anypoint);
spawnfunc(info_player_deathmatch);
void spawnpoint_use(entity this, entity actor, entity trigger);
/**
Uniform pull towards a point
**/
-vector steerlib_pull(vector point)
-{SELFPARAM();
- return normalize(point - self.origin);
+vector steerlib_pull(entity this, vector point)
+{
+ return normalize(point - this.origin);
}
/**
Uniform push from a point
**/
-#define steerlib_push(point) normalize(self.origin - point)
+#define steerlib_push(ent,point) normalize(ent.origin - point)
/*
-vector steerlib_push(vector point)
+vector steerlib_push(entity this, vector point)
{
- return normalize(self.origin - point);
+ return normalize(this.origin - point);
}
*/
/**
Pull toward a point, The further away, the stronger the pull.
**/
-vector steerlib_arrive(vector point,float maximal_distance)
-{SELFPARAM();
+vector steerlib_arrive(entity this, vector point, float maximal_distance)
+{
float distance;
vector direction;
- distance = bound(0.001,vlen(self.origin - point),maximal_distance);
- direction = normalize(point - self.origin);
+ distance = bound(0.001,vlen(this.origin - point),maximal_distance);
+ direction = normalize(point - this.origin);
return direction * (distance / maximal_distance);
}
/**
Pull toward a point increasing the pull the closer we get
**/
-vector steerlib_attract(vector point, float maximal_distance)
-{SELFPARAM();
+vector steerlib_attract(entity this, vector point, float maximal_distance)
+{
float distance;
vector direction;
- distance = bound(0.001,vlen(self.origin - point),maximal_distance);
- direction = normalize(point - self.origin);
+ distance = bound(0.001,vlen(this.origin - point),maximal_distance);
+ direction = normalize(point - this.origin);
return direction * (1-(distance / maximal_distance));
}
float i_target,i_current;
if(!distance)
- distance = vlen(self.origin - point);
+ distance = vlen(this.origin - point);
distance = bound(0.001,distance,maximal_distance);
- target_direction = normalize(point - self.origin);
- current_direction = normalize(self.velocity);
+ target_direction = normalize(point - this.origin);
+ current_direction = normalize(this.velocity);
i_target = bound(min_influense,(1-(distance / maximal_distance)),max_influense);
i_current = 1 - i_target;
/**
Move away from a point.
**/
-vector steerlib_repell(vector point,float maximal_distance)
-{SELFPARAM();
+vector steerlib_repell(entity this, vector point,float maximal_distance)
+{
float distance;
vector direction;
- distance = bound(0.001,vlen(self.origin - point),maximal_distance);
- direction = normalize(self.origin - point);
+ distance = bound(0.001,vlen(this.origin - point),maximal_distance);
+ direction = normalize(this.origin - point);
return direction * (1-(distance / maximal_distance));
}
/**
Try to keep at ideal_distance away from point
**/
-vector steerlib_standoff(vector point,float ideal_distance)
-{SELFPARAM();
+vector steerlib_standoff(entity this, vector point,float ideal_distance)
+{
float distance;
vector direction;
- distance = vlen(self.origin - point);
+ distance = vlen(this.origin - point);
if(distance < ideal_distance)
{
- direction = normalize(self.origin - point);
+ direction = normalize(this.origin - point);
return direction * (distance / ideal_distance);
}
- direction = normalize(point - self.origin);
+ direction = normalize(point - this.origin);
return direction * (ideal_distance / distance);
}
A random heading in a forward halfcicrle
use like:
- self.target = steerlib_wander(256,32,self.target)
+ this.target = steerlib_wander(256,32,this.target)
where range is the cicrle radius and tresh is how close we need to be to pick a new heading.
**/
-vector steerlib_wander(float range,float tresh,vector oldpoint)
-{SELFPARAM();
+vector steerlib_wander(entity this, float range, float tresh, vector oldpoint)
+{
vector wander_point;
wander_point = v_forward - oldpoint;
range = bound(0,range,1);
- wander_point = self.origin + v_forward * 128;
+ wander_point = this.origin + v_forward * 128;
wander_point = wander_point + randomvec() * (range * 128) - randomvec() * (range * 128);
- return normalize(wander_point - self.origin);
+ return normalize(wander_point - this.origin);
}
/**
Dodge a point. dont work to well.
**/
-vector steerlib_dodge(vector point,vector dodge_dir,float min_distance)
-{SELFPARAM();
+vector steerlib_dodge(entity this, vector point, vector dodge_dir, float min_distance)
+{
float distance;
- distance = max(vlen(self.origin - point),min_distance);
+ distance = max(vlen(this.origin - point),min_distance);
if (min_distance < distance)
return '0 0 0';
Group will move towards the unified direction while keeping close to eachother.
**/
.float flock_id;
-vector steerlib_flock(float _radius, float standoff,float separation_force,float flock_force)
-{SELFPARAM();
+vector steerlib_flock(entity this, float _radius, float standoff,float separation_force,float flock_force)
+{
entity flock_member;
vector push = '0 0 0', pull = '0 0 0';
float ccount = 0;
- flock_member = findradius(self.origin, _radius);
+ flock_member = findradius(this.origin, _radius);
while(flock_member)
{
- if(flock_member != self)
- if(flock_member.flock_id == self.flock_id)
+ if(flock_member != this)
+ if(flock_member.flock_id == this.flock_id)
{
++ccount;
- push = push + (steerlib_repell(flock_member.origin,standoff) * separation_force);
- pull = pull + (steerlib_arrive(flock_member.origin + flock_member.velocity, _radius) * flock_force);
+ push = push + (steerlib_repell(this, flock_member.origin,standoff) * separation_force);
+ pull = pull + (steerlib_arrive(this, flock_member.origin + flock_member.velocity, _radius) * flock_force);
}
flock_member = flock_member.chain;
}
Group will move towards the unified direction while keeping close to eachother.
xy only version (for ground movers).
**/
-vector steerlib_flock2d(float _radius, float standoff,float separation_force,float flock_force)
-{SELFPARAM();
+vector steerlib_flock2d(entity this, float _radius, float standoff,float separation_force,float flock_force)
+{
entity flock_member;
vector push = '0 0 0', pull = '0 0 0';
float ccount = 0;
- flock_member = findradius(self.origin,_radius);
+ flock_member = findradius(this.origin,_radius);
while(flock_member)
{
- if(flock_member != self)
- if(flock_member.flock_id == self.flock_id)
+ if(flock_member != this)
+ if(flock_member.flock_id == this.flock_id)
{
++ccount;
- push = push + (steerlib_repell(flock_member.origin, standoff) * separation_force);
- pull = pull + (steerlib_arrive(flock_member.origin + flock_member.velocity, _radius) * flock_force);
+ push = push + (steerlib_repell(this, flock_member.origin, standoff) * separation_force);
+ pull = pull + (steerlib_arrive(this, flock_member.origin + flock_member.velocity, _radius) * flock_force);
}
flock_member = flock_member.chain;
}
This results in a aligned movement (?!) much like flocking.
**/
-vector steerlib_swarm(float _radius, float standoff,float separation_force,float swarm_force)
-{SELFPARAM();
+vector steerlib_swarm(entity this, float _radius, float standoff,float separation_force,float swarm_force)
+{
entity swarm_member;
vector force = '0 0 0', center = '0 0 0';
float ccount = 0;
- swarm_member = findradius(self.origin,_radius);
+ swarm_member = findradius(this.origin,_radius);
while(swarm_member)
{
- if(swarm_member.flock_id == self.flock_id)
+ if(swarm_member.flock_id == this.flock_id)
{
++ccount;
center = center + swarm_member.origin;
- force = force + (steerlib_repell(swarm_member.origin,standoff) * separation_force);
+ force = force + (steerlib_repell(this, swarm_member.origin,standoff) * separation_force);
}
swarm_member = swarm_member.chain;
}
center = center * (1 / ccount);
- force = force + (steerlib_arrive(center,_radius) * swarm_force);
+ force = force + (steerlib_arrive(this, center,_radius) * swarm_force);
return force;
}
Run four tracelines in a forward funnel, bias each diretion negative if something is found there.
You need to call makevectors() (or equivalent) before this function to set v_forward and v_right
**/
-vector steerlib_traceavoid(float pitch,float length)
-{SELFPARAM();
+vector steerlib_traceavoid(entity this, float pitch,float length)
+{
vector vup_left,vup_right,vdown_left,vdown_right;
float fup_left,fup_right,fdown_left,fdown_right;
vector upwish,downwish,leftwish,rightwish;
v_down = v_up * -1;
vup_left = (v_forward + (v_left * pitch + v_up * pitch)) * length;
- traceline(self.origin, self.origin + vup_left,MOVE_NOMONSTERS,self);
+ traceline(this.origin, this.origin + vup_left,MOVE_NOMONSTERS,this);
fup_left = trace_fraction;
- //te_lightning1(world,self.origin, trace_endpos);
+ //te_lightning1(world,this.origin, trace_endpos);
vup_right = (v_forward + (v_right * pitch + v_up * pitch)) * length;
- traceline(self.origin,self.origin + vup_right ,MOVE_NOMONSTERS,self);
+ traceline(this.origin,this.origin + vup_right ,MOVE_NOMONSTERS,this);
fup_right = trace_fraction;
- //te_lightning1(world,self.origin, trace_endpos);
+ //te_lightning1(world,this.origin, trace_endpos);
vdown_left = (v_forward + (v_left * pitch + v_down * pitch)) * length;
- traceline(self.origin,self.origin + vdown_left,MOVE_NOMONSTERS,self);
+ traceline(this.origin,this.origin + vdown_left,MOVE_NOMONSTERS,this);
fdown_left = trace_fraction;
- //te_lightning1(world,self.origin, trace_endpos);
+ //te_lightning1(world,this.origin, trace_endpos);
vdown_right = (v_forward + (v_right * pitch + v_down * pitch)) * length;
- traceline(self.origin,self.origin + vdown_right,MOVE_NOMONSTERS,self);
+ traceline(this.origin,this.origin + vdown_right,MOVE_NOMONSTERS,this);
fdown_right = trace_fraction;
- //te_lightning1(world,self.origin, trace_endpos);
+ //te_lightning1(world,this.origin, trace_endpos);
upwish = v_up * (fup_left + fup_right);
downwish = v_down * (fdown_left + fdown_right);
leftwish = v_left * (fup_left + fdown_left);
Steer towards the direction least obstructed.
Run tracelines in a forward trident, bias each direction negative if something is found there.
**/
-vector steerlib_traceavoid_flat(float pitch, float length, vector vofs)
-{SELFPARAM();
+vector steerlib_traceavoid_flat(entity this, float pitch, float length, vector vofs)
+{
vector vt_left, vt_right,vt_front;
float f_left, f_right,f_front;
vector leftwish, rightwish,frontwish, v_left;
vt_front = v_forward * length;
- traceline(self.origin + vofs, self.origin + vofs + vt_front,MOVE_NOMONSTERS,self);
+ traceline(this.origin + vofs, this.origin + vofs + vt_front,MOVE_NOMONSTERS,this);
f_front = trace_fraction;
vt_left = (v_forward + (v_left * pitch)) * length;
- traceline(self.origin + vofs, self.origin + vofs + vt_left,MOVE_NOMONSTERS,self);
+ traceline(this.origin + vofs, this.origin + vofs + vt_left,MOVE_NOMONSTERS,this);
f_left = trace_fraction;
- //te_lightning1(world,self.origin, trace_endpos);
+ //te_lightning1(world,this.origin, trace_endpos);
vt_right = (v_forward + (v_right * pitch)) * length;
- traceline(self.origin + vofs, self.origin + vofs + vt_right ,MOVE_NOMONSTERS,self);
+ traceline(this.origin + vofs, this.origin + vofs + vt_right ,MOVE_NOMONSTERS,this);
f_right = trace_fraction;
- //te_lightning1(world,self.origin, trace_endpos);
+ //te_lightning1(world,this.origin, trace_endpos);
leftwish = v_left * f_left;
rightwish = v_right * f_right;
}
//#define BEAMSTEER_VISUAL
-float beamsweep(vector from, vector dir,float length, float step,float step_up, float step_down)
-{SELFPARAM();
+float beamsweep(entity this, vector from, vector dir,float length, float step,float step_up, float step_down)
+{
float i;
vector a,b,u,d;
u = '0 0 1' * step_up;
d = '0 0 1' * step_down;
- traceline(from + u, from - d,MOVE_NORMAL,self);
+ traceline(from + u, from - d,MOVE_NORMAL,this);
if(trace_fraction == 1.0)
return 0;
{
b = a + dir * step;
- tracebox(a + u,'-4 -4 -4','4 4 4', b + u,MOVE_NORMAL,self);
+ tracebox(a + u,'-4 -4 -4','4 4 4', b + u,MOVE_NORMAL,this);
if(trace_fraction != 1.0)
return i / length;
- traceline(b + u, b - d,MOVE_NORMAL,self);
+ traceline(b + u, b - d,MOVE_NORMAL,this);
if(trace_fraction == 1.0)
return i / length;
return 1;
}
-vector steerlib_beamsteer(vector dir, float length, float step, float step_up, float step_down)
-{SELFPARAM();
+vector steerlib_beamsteer(entity this, vector dir, float length, float step, float step_up, float step_down)
+{
float bm_forward, bm_right, bm_left,p;
vector vr,vl;
vr = vectoangles(dir);
//vr_x *= -1;
- tracebox(self.origin + '0 0 1' * step_up, self.mins, self.maxs, ('0 0 1' * step_up) + self.origin + (dir * length), MOVE_NOMONSTERS, self);
+ tracebox(this.origin + '0 0 1' * step_up, this.mins, this.maxs, ('0 0 1' * step_up) + this.origin + (dir * length), MOVE_NOMONSTERS, this);
if(trace_fraction == 1.0)
{
- //te_lightning1(self,self.origin,self.origin + (dir * length));
+ //te_lightning1(this,this.origin,this.origin + (dir * length));
return dir;
}
-
-
-
makevectors(vr);
- bm_forward = beamsweep(self.origin, v_forward, length, step, step_up, step_down);
+ bm_forward = beamsweep(this, this.origin, v_forward, length, step, step_up, step_down);
vr = normalize(v_forward + v_right * 0.125);
vl = normalize(v_forward - v_right * 0.125);
- bm_right = beamsweep(self.origin, vr, length, step, step_up, step_down);
- bm_left = beamsweep(self.origin, vl, length, step, step_up, step_down);
+ bm_right = beamsweep(this, this.origin, vr, length, step, step_up, step_down);
+ bm_left = beamsweep(this, this.origin, vl, length, step, step_up, step_down);
p = bm_left + bm_right;
if(p == 2)
{
- //te_lightning1(self,self.origin + '0 0 32',self.origin + '0 0 32' + vr * length);
- //te_lightning1(self.tur_head,self.origin + '0 0 32',self.origin + '0 0 32' + vl * length);
+ //te_lightning1(this,this.origin + '0 0 32',this.origin + '0 0 32' + vr * length);
+ //te_lightning1(this.tur_head,this.origin + '0 0 32',this.origin + '0 0 32' + vl * length);
return v_forward;
}
vr = normalize(v_forward + v_right * p);
vl = normalize(v_forward - v_right * p);
- bm_right = beamsweep(self.origin, vr, length, step, step_up, step_down);
- bm_left = beamsweep(self.origin, vl, length, step, step_up, step_down);
+ bm_right = beamsweep(this, this.origin, vr, length, step, step_up, step_down);
+ bm_left = beamsweep(this, this.origin, vl, length, step, step_up, step_down);
if(bm_left + bm_right < 0.15)
vr = normalize((v_forward*-1) + v_right * 0.75);
vl = normalize((v_forward*-1) - v_right * 0.75);
- bm_right = beamsweep(self.origin, vr, length, step, step_up, step_down);
- bm_left = beamsweep(self.origin, vl, length, step, step_up, step_down);
+ bm_right = beamsweep(this, this.origin, vr, length, step, step_up, step_down);
+ bm_left = beamsweep(this, this.origin, vl, length, step, step_up, step_down);
}
- //te_lightning1(self,self.origin + '0 0 32',self.origin + '0 0 32' + vr * length);
- //te_lightning1(self.tur_head,self.origin + '0 0 32',self.origin + '0 0 32' + vl * length);
+ //te_lightning1(this,this.origin + '0 0 32',this.origin + '0 0 32' + vr * length);
+ //te_lightning1(this.tur_head,this.origin + '0 0 32',this.origin + '0 0 32' + vl * length);
bm_forward *= bm_forward;
bm_right *= bm_right;
//////////////////////////////////////////////
//#define TLIBS_TETSLIBS
#ifdef TLIBS_TETSLIBS
-void flocker_die()
-{SELFPARAM();
- Send_Effect(EFFECT_ROCKET_EXPLODE, self.origin, '0 0 0', 1);
+void flocker_die(entity this)
+{
+ Send_Effect(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1);
- self.owner.cnt += 1;
- self.owner = world;
+ this.owner.cnt += 1;
+ this.owner = world;
- self.nextthink = time;
- self.think = SUB_Remove;
+ this.nextthink = time;
+ setthink(this, SUB_Remove);
}
vector dodgemove,swarmmove;
vector reprellmove,wandermove,newmove;
- self.angles_x = self.angles.x * -1;
- makevectors(self.angles);
- self.angles_x = self.angles.x * -1;
+ this.angles_x = this.angles.x * -1;
+ makevectors(this.angles);
+ this.angles_x = this.angles.x * -1;
- dodgemove = steerlib_traceavoid(0.35,1000);
- swarmmove = steerlib_flock(500,75,700,500);
- reprellmove = steerlib_repell(self.owner.enemy.origin+self.enemy.velocity,2000) * 700;
+ dodgemove = steerlib_traceavoid(this, 0.35,1000);
+ swarmmove = steerlib_flock(this, 500,75,700,500);
+ reprellmove = steerlib_repell(this, this.owner.enemy.origin+this.enemy.velocity,2000) * 700;
- if(vlen(dodgemove) == 0)
+ if(dodgemove == '0 0 0')
{
- self.pos1 = steerlib_wander(0.5,0.1,self.pos1);
- wandermove = self.pos1 * 50;
+ this.pos1 = steerlib_wander(this, 0.5,0.1,this.pos1);
+ wandermove = this.pos1 * 50;
}
else
- self.pos1 = normalize(self.velocity);
+ this.pos1 = normalize(this.velocity);
- dodgemove = dodgemove * vlen(self.velocity) * 5;
+ dodgemove = dodgemove * vlen(this.velocity) * 5;
newmove = swarmmove + reprellmove + wandermove + dodgemove;
- self.velocity = movelib_inertmove_byspeed(newmove,300,0.2,0.9);
- //self.velocity = movelib_inertmove(dodgemove,0.65);
+ this.velocity = movelib_inertmove_byspeed(this, newmove,300,0.2,0.9);
+ //this.velocity = movelib_inertmove(this, dodgemove,0.65);
- self.velocity = movelib_dragvec(0.01,0.6);
+ this.velocity = movelib_dragvec(this, 0.01,0.6);
- self.angles = vectoangles(self.velocity);
+ this.angles = vectoangles(this.velocity);
- if(self.health <= 0)
- flocker_die();
+ if(this.health <= 0)
+ flocker_die(this);
else
- self.nextthink = time + 0.1;
+ this.nextthink = time + 0.1;
}
MODEL(FLOCKER, "models/turrets/rocket.md3");
-void spawn_flocker()
-{SELFPARAM();
+void spawn_flocker(entity this)
+{
entity flocker = new(flocker);
- setorigin(flocker, self.origin + '0 0 32');
+ setorigin(flocker, this.origin + '0 0 32');
setmodel (flocker, MDL_FLOCKER);
setsize (flocker, '-3 -3 -3', '3 3 3');
- flocker.flock_id = self.flock_id;
- flocker.owner = self;
- flocker.think = flocker_think;
+ flocker.flock_id = this.flock_id;
+ flocker.owner = this;
+ setthink(flocker, flocker_think);
flocker.nextthink = time + random() * 5;
PROJECTILE_MAKETRIGGER(flocker);
flocker.movetype = MOVETYPE_BOUNCEMISSILE;
flocker.health = 10;
flocker.pos1 = normalize(flocker.velocity + randomvec() * 0.1);
- self.cnt = self.cnt -1;
+ this.cnt = this.cnt -1;
}
void flockerspawn_think()
{SELFPARAM();
+ if(this.cnt > 0)
+ spawn_flocker(this);
-
- if(self.cnt > 0)
- spawn_flocker();
-
- self.nextthink = time + self.delay;
+ this.nextthink = time + this.delay;
}
entity e,ee;
float d,bd;
- self.angles_x = self.angles.x * -1;
- makevectors(self.angles);
- self.angles_x = self.angles.x * -1;
+ this.angles_x = this.angles.x * -1;
+ makevectors(this.angles);
+ this.angles_x = this.angles.x * -1;
- if(self.enemy)
- if(vdist(self.enemy.origin - self.origin, <, 64))
+ if(this.enemy)
+ if(vdist(this.enemy.origin - this.origin, <, 64))
{
- ee = self.enemy;
+ ee = this.enemy;
ee.health = -1;
- self.enemy = world;
+ this.enemy = world;
}
- if(!self.enemy)
+ if(!this.enemy)
{
- e = findchainfloat(flock_id,self.flock_id);
+ e = findchainfloat(flock_id,this.flock_id);
while(e)
{
- d = vlen(self.origin - e.origin);
+ d = vlen(this.origin - e.origin);
- if(e != self.owner)
+ if(e != this.owner)
if(e != ee)
if(d > bd)
{
- self.enemy = e;
+ this.enemy = e;
bd = d;
}
e = e.chain;
}
}
- if(self.enemy)
- attractmove = steerlib_attract(self.enemy.origin+self.enemy.velocity * 0.1,5000) * 1250;
+ if(this.enemy)
+ attractmove = steerlib_attract(this, this.enemy.origin+this.enemy.velocity * 0.1,5000) * 1250;
else
- attractmove = normalize(self.velocity) * 200;
+ attractmove = normalize(this.velocity) * 200;
- dodgemove = steerlib_traceavoid(0.35,1500) * vlen(self.velocity);
+ dodgemove = steerlib_traceavoid(this, 0.35,1500) * vlen(this.velocity);
newmove = dodgemove + attractmove;
- self.velocity = movelib_inertmove_byspeed(newmove,1250,0.3,0.7);
- self.velocity = movelib_dragvec(0.01,0.5);
+ this.velocity = movelib_inertmove_byspeed(this, newmove,1250,0.3,0.7);
+ this.velocity = movelib_dragvec(this, 0.01,0.5);
- self.angles = vectoangles(self.velocity);
- self.nextthink = time + 0.1;
+ this.angles = vectoangles(this.velocity);
+ this.nextthink = time + 0.1;
}
float globflockcnt;
spawnfunc(flockerspawn)
-{SELFPARAM();
+{
++globflockcnt;
- if(!self.cnt) self.cnt = 20;
- if(!self.delay) self.delay = 0.25;
- if(!self.flock_id) self.flock_id = globflockcnt;
+ if(!this.cnt) this.cnt = 20;
+ if(!this.delay) this.delay = 0.25;
+ if(!this.flock_id) this.flock_id = globflockcnt;
- self.think = flockerspawn_think;
- self.nextthink = time + 0.25;
+ setthink(this, flockerspawn_think);
+ this.nextthink = time + 0.25;
- self.enemy = new(FLock Hunter);
+ this.enemy = new(FLock Hunter);
- setmodel(self.enemy, MDL_FLOCKER);
- setorigin(self.enemy,self.origin + '0 0 768' + (randomvec() * 128));
+ setmodel(this.enemy, MDL_FLOCKER);
+ setorigin(this.enemy,this.origin + '0 0 768' + (randomvec() * 128));
- self.enemy.scale = 3;
- self.enemy.effects = EF_LOWPRECISION;
- self.enemy.movetype = MOVETYPE_BOUNCEMISSILE;
- PROJECTILE_MAKETRIGGER(self.enemy);
- self.enemy.think = flocker_hunter_think;
- self.enemy.nextthink = time + 10;
- self.enemy.flock_id = self.flock_id;
- self.enemy.owner = self;
+ this.enemy.scale = 3;
+ this.enemy.effects = EF_LOWPRECISION;
+ this.enemy.movetype = MOVETYPE_BOUNCEMISSILE;
+ PROJECTILE_MAKETRIGGER(this.enemy);
+ setthink(this.enemy, flocker_hunter_think);
+ this.enemy.nextthink = time + 10;
+ this.enemy.flock_id = this.flock_id;
+ this.enemy.owner = this;
}
#endif
.vector steerto;
-vector steerlib_arrive(vector point,float maximal_distance);
-vector steerlib_attract2(entity this, vector point, float min_influense,float max_distance,float max_influense);
-vector steerlib_pull(vector point);
+vector steerlib_arrive(entity this, vector point, float maximal_distance);
+vector steerlib_attract2(entity this, vector point, float min_influense, float max_distance, float max_influense);
+vector steerlib_pull(entity this, vector point);
.float anglejitter;
.string gametypefilter;
.string cvarfilter;
-float DoesQ3ARemoveThisEntity();
+bool DoesQ3ARemoveThisEntity(entity this);
void SV_OnEntityPreSpawnFunction()
{SELFPARAM();
__spawnfunc_expect = this;
- if (self)
- if (self.gametypefilter != "")
- if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, self.gametypefilter))
+ if (this)
+ if (this.gametypefilter != "")
+ if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, this.gametypefilter))
{
- remove(self);
+ remove(this);
return;
}
- if(self.cvarfilter != "")
+ if(this.cvarfilter != "")
{
float n, i, o, inv;
string s, k, v;
inv = 0;
- s = self.cvarfilter;
+ s = this.cvarfilter;
if(substring(s, 0, 1) == "+")
{
s = substring(s, 1, -1);
if (!inv)
{
//print("cvarfilter fail\n");
- remove(self);
+ remove(this);
return;
}
}
- if(DoesQ3ARemoveThisEntity())
+ if(DoesQ3ARemoveThisEntity(this))
{
- remove(self);
+ remove(this);
return;
}
// support special -1 and -2 angle from radiant
- if (self.angles == '0 -1 0')
- self.angles = '-90 0 0';
- else if (self.angles == '0 -2 0')
- self.angles = '+90 0 0';
-
- if(self.originjitter.x != 0)
- self.origin_x = self.origin.x + (random() * 2 - 1) * self.originjitter.x;
- if(self.originjitter.y != 0)
- self.origin_y = self.origin.y + (random() * 2 - 1) * self.originjitter.y;
- if(self.originjitter.z != 0)
- self.origin_z = self.origin.z + (random() * 2 - 1) * self.originjitter.z;
- if(self.anglesjitter.x != 0)
- self.angles_x = self.angles.x + (random() * 2 - 1) * self.anglesjitter.x;
- if(self.anglesjitter.y != 0)
- self.angles_y = self.angles.y + (random() * 2 - 1) * self.anglesjitter.y;
- if(self.anglesjitter.z != 0)
- self.angles_z = self.angles.z + (random() * 2 - 1) * self.anglesjitter.z;
- if(self.anglejitter != 0)
- self.angles_y = self.angles.y + (random() * 2 - 1) * self.anglejitter;
-
- if(MUTATOR_CALLHOOK(OnEntityPreSpawn))
+ if (this.angles == '0 -1 0')
+ this.angles = '-90 0 0';
+ else if (this.angles == '0 -2 0')
+ this.angles = '+90 0 0';
+
+ if(this.originjitter.x != 0)
+ this.origin_x = this.origin.x + (random() * 2 - 1) * this.originjitter.x;
+ if(this.originjitter.y != 0)
+ this.origin_y = this.origin.y + (random() * 2 - 1) * this.originjitter.y;
+ if(this.originjitter.z != 0)
+ this.origin_z = this.origin.z + (random() * 2 - 1) * this.originjitter.z;
+ if(this.anglesjitter.x != 0)
+ this.angles_x = this.angles.x + (random() * 2 - 1) * this.anglesjitter.x;
+ if(this.anglesjitter.y != 0)
+ this.angles_y = this.angles.y + (random() * 2 - 1) * this.anglesjitter.y;
+ if(this.anglesjitter.z != 0)
+ this.angles_z = this.angles.z + (random() * 2 - 1) * this.anglesjitter.z;
+ if(this.anglejitter != 0)
+ this.angles_y = this.angles.y + (random() * 2 - 1) * this.anglejitter;
+
+ if(MUTATOR_CALLHOOK(OnEntityPreSpawn, this))
{
- remove(self);
+ remove(this);
return;
}
}
spawnfunc(item_spikes) {spawnfunc_item_bullets(this);}
//spawnfunc(item_armor1) {spawnfunc_item_armor_medium(this);} // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
spawnfunc(item_armor2) {spawnfunc_item_armor_large(this);}
-void item_armorInv() {SELFPARAM();spawnfunc_item_armor_large(self);}
-spawnfunc(item_health) {if (self.spawnflags & 2) spawnfunc_item_health_mega(this);else spawnfunc_item_health_medium(this);}
+void item_armorInv() {SELFPARAM();spawnfunc_item_armor_large(this);} // FIXME: we require spawnfunc_ prefix for functions to be map entities
+spawnfunc(item_health) {if (this.spawnflags & 2) spawnfunc_item_health_mega(this);else spawnfunc_item_health_medium(this);}
//spawnfunc_item_spikes
//spawnfunc_item_health
spawnfunc(target_init)
{
- self.spawnflags = 0; // remove all weapons except the ones listed below
- self.netname = "shotgun"; // keep these weapons through the remove trigger
+ this.spawnflags = 0; // remove all weapons except the ones listed below
+ this.netname = "shotgun"; // keep these weapons through the remove trigger
spawnfunc_target_items(this);
- InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
+ InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
}
// weapon give ent from defrag
void target_give_init(entity this)
{
entity targ;
- for (targ = world; (targ = find(targ, targetname, self.target)); ) {
+ for (targ = world; (targ = find(targ, targetname, this.target)); ) {
if (targ.classname == "weapon_rocketlauncher" || targ.classname == "weapon_devastator") {
- self.ammo_rockets += targ.count * WEP_CVAR(devastator, ammo);
- self.netname = "devastator";
+ this.ammo_rockets += targ.count * WEP_CVAR(devastator, ammo);
+ this.netname = "devastator";
}
else if (targ.classname == "weapon_plasmagun") {
- self.ammo_rockets += targ.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
- if(self.netname == "")
- self.netname = "hagar";
+ this.ammo_rockets += targ.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
+ if(this.netname == "")
+ this.netname = "hagar";
else
- self.netname = strcat(self.netname, " hagar");
+ this.netname = strcat(this.netname, " hagar");
}
else if (targ.classname == "weapon_bfg") {
- self.ammo_cells += targ.count * WEP_CVAR_PRI(crylink, ammo);
- if(self.netname == "")
- self.netname = "crylink";
+ this.ammo_cells += targ.count * WEP_CVAR_PRI(crylink, ammo);
+ if(this.netname == "")
+ this.netname = "crylink";
else
- self.netname = strcat(self.netname, " crylink");
+ this.netname = strcat(this.netname, " crylink");
}
else if (targ.classname == "weapon_grenadelauncher" || targ.classname == "weapon_mortar") {
- self.ammo_rockets += targ.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
- if(self.netname == "")
- self.netname = "mortar";
+ this.ammo_rockets += targ.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
+ if(this.netname == "")
+ this.netname = "mortar";
else
- self.netname = strcat(self.netname, " mortar");
+ this.netname = strcat(this.netname, " mortar");
}
else if (targ.classname == "item_armor_body")
- self.armorvalue = 100;
+ this.armorvalue = 100;
else if (targ.classname == "item_health_mega")
- self.health = 200;
+ this.health = 200;
//remove(targ); // removing ents in init functions causes havoc, workaround:
- targ.think = SUB_Remove_self;
+ setthink(targ, SUB_Remove);
targ.nextthink = time;
}
- self.spawnflags = 2;
+ this.spawnflags = 2;
spawnfunc_target_items(this);
- InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
+ InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
}
spawnfunc(target_give)
{
- InitializeEntity(self, target_give_init, INITPRIO_FINDTARGET);
+ InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
}
//spawnfunc(item_flight) /* handled by jetpack */
.float notq3a;
.float notta;
.string gametype;
-float DoesQ3ARemoveThisEntity()
-{SELFPARAM();
+bool DoesQ3ARemoveThisEntity(entity this)
+{
// Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
- if(self.notq3a)
+ if(this.notq3a)
if(!teamplay || g_tdm || g_ctf)
- return 1;
+ return true;
- if(self.notta)
+ if(this.notta)
if (!(!teamplay || g_tdm || g_ctf))
- return 1;
+ return true;
- if(self.notsingle)
+ if(this.notsingle)
if(maxclients == 1)
- return 1;
+ return true;
- if(self.notteam)
+ if(this.notteam)
if(teamplay)
- return 1;
+ return true;
- if(self.notfree)
+ if(this.notfree)
if(!teamplay)
- return 1;
+ return true;
- if(self.gametype)
+ if(this.gametype)
{
string gametypename;
// static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
if(maxclients == 1)
gametypename = "single";
// we do not have the other types (oneflag, obelisk, harvester, teamtournament)
- if(strstrofs(self.gametype, gametypename, 0) < 0)
- return 1;
+ if(strstrofs(this.gametype, gametypename, 0) < 0)
+ return true;
}
- return 0;
+ return false;
}
InitializeEntity(world, default_delayedinit, INITPRIO_GAMETYPE_FALLBACK);
}
-string GetClientVersionMessage()
-{SELFPARAM();
+string GetClientVersionMessage(entity this)
+{
string versionmsg;
- if (self.version_mismatch) {
- if(self.version < autocvar_gameversion) {
+ if (this.version_mismatch) {
+ if(this.version < autocvar_gameversion) {
versionmsg = "^3Your client version is outdated.\n\n\n### YOU WON'T BE ABLE TO PLAY ON THIS SERVER ###\n\n\nPlease update!!!^8";
} else {
versionmsg = "^3This server is using an outdated Xonotic version.\n\n\n ### THIS SERVER IS INCOMPATIBLE AND THUS YOU CANNOT JOIN ###.^8";
return versionmsg;
}
-string getwelcomemessage()
+string getwelcomemessage(entity this)
{
string s, modifications, motd;
modifications = strcat(modifications, ", Powerups");
modifications = substring(modifications, 2, strlen(modifications) - 2);
- string versionmessage;
- versionmessage = GetClientVersionMessage();
+ string versionmessage = GetClientVersionMessage(this);
s = strcat("This is Xonotic ", autocvar_g_xonoticversion, "\n", versionmessage);
s = strcat(s, "^8\n\nmatch type is ^1", gamemode_name, "^8\n");
// set c1...c4 to show what teams are allowed
void CheckAllowedTeams (entity for_whom)
-{SELFPARAM();
+{
int dm = 0;
c1 = c2 = c3 = c4 = -1;
}
}
+ if(!for_whom)
+ return;
+
// if player has a forced team, ONLY allow that one
- if(self.team_forced == NUM_TEAM_1 && c1 >= 0)
+ if(for_whom.team_forced == NUM_TEAM_1 && c1 >= 0)
c2 = c3 = c4 = -1;
- else if(self.team_forced == NUM_TEAM_2 && c2 >= 0)
+ else if(for_whom.team_forced == NUM_TEAM_2 && c2 >= 0)
c1 = c3 = c4 = -1;
- else if(self.team_forced == NUM_TEAM_3 && c3 >= 0)
+ else if(for_whom.team_forced == NUM_TEAM_3 && c3 >= 0)
c1 = c2 = c4 = -1;
- else if(self.team_forced == NUM_TEAM_4 && c4 >= 0)
+ else if(for_whom.team_forced == NUM_TEAM_4 && c4 >= 0)
c1 = c2 = c3 = -1;
}
return RandomSelection_chosen_float;
}
-int JoinBestTeam(entity pl, bool only_return_best, bool forcebestteam)
-{SELFPARAM();
+int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam)
+{
float smallest, selectedteam;
// don't join a team if we're not playing a team game
return 0;
// find out what teams are available
- CheckAllowedTeams(pl);
+ CheckAllowedTeams(this);
// if we don't care what team he ends up on, put him on whatever team he entered as.
// if he's not on a valid team, then let other code put him on the smallest team
if(!forcebestteam)
{
- if( c1 >= 0 && pl.team == NUM_TEAM_1)
- selectedteam = pl.team;
- else if(c2 >= 0 && pl.team == NUM_TEAM_2)
- selectedteam = pl.team;
- else if(c3 >= 0 && pl.team == NUM_TEAM_3)
- selectedteam = pl.team;
- else if(c4 >= 0 && pl.team == NUM_TEAM_4)
- selectedteam = pl.team;
+ if( c1 >= 0 && this.team == NUM_TEAM_1)
+ selectedteam = this.team;
+ else if(c2 >= 0 && this.team == NUM_TEAM_2)
+ selectedteam = this.team;
+ else if(c3 >= 0 && this.team == NUM_TEAM_3)
+ selectedteam = this.team;
+ else if(c4 >= 0 && this.team == NUM_TEAM_4)
+ selectedteam = this.team;
else
selectedteam = -1;
{
if(!only_return_best)
{
- SetPlayerColors(pl, selectedteam - 1);
+ SetPlayerColors(this, selectedteam - 1);
// when JoinBestTeam is called by client.qc/ClientKill_Now_TeamChange the players team is -1 and thus skipped
// when JoinBestTeam is called by cl_client.qc/ClientConnect the player_id is 0 the log attempt is rejected
- LogTeamchange(pl.playerid, pl.team, 99);
+ LogTeamchange(this.playerid, this.team, 99);
}
return selectedteam;
}
// otherwise end up on the smallest team (handled below)
}
- smallest = FindSmallestTeam(pl, true);
+ smallest = FindSmallestTeam(this, true);
- if(!only_return_best && !pl.bot_forced_team)
+ if(!only_return_best && !this.bot_forced_team)
{
- TeamchangeFrags(self);
+ TeamchangeFrags(this);
if(smallest == 1)
{
- SetPlayerColors(pl, NUM_TEAM_1 - 1);
+ SetPlayerColors(this, NUM_TEAM_1 - 1);
}
else if(smallest == 2)
{
- SetPlayerColors(pl, NUM_TEAM_2 - 1);
+ SetPlayerColors(this, NUM_TEAM_2 - 1);
}
else if(smallest == 3)
{
- SetPlayerColors(pl, NUM_TEAM_3 - 1);
+ SetPlayerColors(this, NUM_TEAM_3 - 1);
}
else if(smallest == 4)
{
- SetPlayerColors(pl, NUM_TEAM_4 - 1);
+ SetPlayerColors(this, NUM_TEAM_4 - 1);
}
else
{
error("smallest team: invalid team\n");
}
- LogTeamchange(pl.playerid, pl.team, 2); // log auto join
+ LogTeamchange(this.playerid, this.team, 2); // log auto join
- if(!IS_DEAD(pl))
- Damage(pl, pl, pl, 100000, DEATH_TEAMCHANGE.m_id, pl.origin, '0 0 0');
+ if(!IS_DEAD(this))
+ Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0');
}
return smallest;
// in normal deathmatch we can just apply the color and we're done
if(!teamplay)
- SetPlayerColors(self, _color);
+ SetPlayerColors(this, _color);
- if(!IS_CLIENT(self))
+ if(!IS_CLIENT(this))
{
// since this is an engine function, and gamecode doesn't have any calls earlier than this, do the connecting message here
- Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_CONNECTING, self.netname);
+ Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_CONNECTING, this.netname);
return;
}
if(!teamplay)
return;
- scolor = self.clientcolors & 0x0F;
+ scolor = this.clientcolors & 0x0F;
dcolor = _color & 0x0F;
if(scolor == NUM_TEAM_1 - 1)
else // if(dcolor == NUM_TEAM_4 - 1)
dteam = 4;
- CheckAllowedTeams(self);
+ CheckAllowedTeams(this);
if(dteam == 1 && c1 < 0) dteam = 4;
if(dteam == 4 && c4 < 0) dteam = 3;
if(scolor == dcolor)
{
//bprint("same team change\n");
- SetPlayerTeam(self, dteam, steam, true);
+ SetPlayerTeam(this, dteam, steam, true);
return;
}
- if((autocvar_g_campaign) || (autocvar_g_changeteam_banned && self.wasplayer)) {
- Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_TEAMCHANGE_NOTALLOWED);
+ if((autocvar_g_campaign) || (autocvar_g_changeteam_banned && this.wasplayer)) {
+ Send_Notification(NOTIF_ONE, this, MSG_INFO, INFO_TEAMCHANGE_NOTALLOWED);
return; // changing teams is not allowed
}
// autocvar_g_balance_teams_prevent_imbalance only makes sense if autocvar_g_balance_teams is on, as it makes the team selection dialog pointless
if(autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance)
{
- GetTeamCounts(self);
- if(!TeamSmallerEqThanTeam(dteam, steam, self))
+ GetTeamCounts(this);
+ if(!TeamSmallerEqThanTeam(dteam, steam, this))
{
- Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM);
+ Send_Notification(NOTIF_ONE, this, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM);
return;
}
}
// bprint("allow change teams from ", ftos(steam), " to ", ftos(dteam), "\n");
- if(IS_PLAYER(self) && steam != dteam)
+ if(IS_PLAYER(this) && steam != dteam)
{
// reduce frags during a team change
- TeamchangeFrags(self);
+ TeamchangeFrags(this);
}
- MUTATOR_CALLHOOK(Player_ChangeTeam, self, steam, dteam);
+ MUTATOR_CALLHOOK(Player_ChangeTeam, this, steam, dteam);
- SetPlayerTeam(self, dteam, steam, !IS_CLIENT(self));
+ SetPlayerTeam(this, dteam, steam, !IS_CLIENT(this));
- if(IS_PLAYER(self) && steam != dteam)
+ if(IS_PLAYER(this) && steam != dteam)
{
// kill player when changing teams
- if(!IS_DEAD(self))
- Damage(self, self, self, 100000, DEATH_TEAMCHANGE.m_id, self.origin, '0 0 0');
+ if(!IS_DEAD(this))
+ Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0');
}
}
void InitGameplayMode();
-string GetClientVersionMessage();
+string GetClientVersionMessage(entity this);
-string getwelcomemessage();
+string getwelcomemessage(entity this);
void SetPlayerColors(entity pl, float _color);
// NOTE: Assumes CheckAllowedTeams has already been called!
float FindSmallestTeam(entity pl, float ignore_pl);
-int JoinBestTeam(entity pl, bool only_return_best, bool forcebestteam);
+int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam);
//void() ctf_playerchanged;
void SV_ChangeTeam(float _color);
return true; // if none of these return, then allow damage anyway.
}
-void W_PrepareExplosionByDamage(entity this, entity attacker, void() explode)
+void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) explode)
{
this.takedamage = DAMAGE_NO;
this.event_damage = func_null;
// do not explode NOW but in the NEXT FRAME!
// because recursive calls to RadiusDamage are not allowed
this.nextthink = time;
- this.think = explode;
+ setthink(this, explode);
}
.float prevstrengthsoundattempt;
void W_PlayStrengthSound(entity player);
float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype, float exception);
-void W_PrepareExplosionByDamage(entity this, entity attacker, void() explode);
+void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) explode);
// note: flag 0x08 = no trail please (teleport bit)
sf = sf & 0x0F;
- if(self.csqcprojectile_clientanimate)
+ if(this.csqcprojectile_clientanimate)
sf |= 0x80; // client animated, not interpolated
- if(IS_ONGROUND(self))
+ if(IS_ONGROUND(this))
sf |= 0x40;
ft = fr = 0;
- if(self.fade_time != 0 || self.fade_rate != 0)
+ if(this.fade_time != 0 || this.fade_rate != 0)
{
- ft = (self.fade_time - time) / sys_frametime;
- fr = (1 / self.fade_rate) / sys_frametime;
+ ft = (this.fade_time - time) / sys_frametime;
+ fr = (1 / this.fade_rate) / sys_frametime;
if(ft <= 255 && fr <= 255 && fr >= 1)
sf |= 0x20;
}
- if(self.gravity != 0)
+ if(this.gravity != 0)
sf |= 0x10;
WriteHeader(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
if(sf & 1)
{
- WriteCoord(MSG_ENTITY, self.origin.x);
- WriteCoord(MSG_ENTITY, self.origin.y);
- WriteCoord(MSG_ENTITY, self.origin.z);
+ WriteCoord(MSG_ENTITY, this.origin.x);
+ WriteCoord(MSG_ENTITY, this.origin.y);
+ WriteCoord(MSG_ENTITY, this.origin.z);
if(sf & 0x80)
{
- WriteCoord(MSG_ENTITY, self.velocity.x);
- WriteCoord(MSG_ENTITY, self.velocity.y);
- WriteCoord(MSG_ENTITY, self.velocity.z);
+ WriteCoord(MSG_ENTITY, this.velocity.x);
+ WriteCoord(MSG_ENTITY, this.velocity.y);
+ WriteCoord(MSG_ENTITY, this.velocity.z);
if(sf & 0x10)
- WriteCoord(MSG_ENTITY, self.gravity);
+ WriteCoord(MSG_ENTITY, this.gravity);
}
if(sf & 0x20)
WriteByte(MSG_ENTITY, fr);
}
- WriteByte(MSG_ENTITY, self.realowner.team);
+ WriteByte(MSG_ENTITY, this.realowner.team);
}
if(sf & 2)
- WriteByte(MSG_ENTITY, self.csqcprojectile_type); // TODO maybe put this into sf?
+ WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
return true;
}
}
}
-bool client_hasweapon(entity cl, Weapon wpn, float andammo, bool complain)
+bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain)
{
- SELFPARAM();
float f = 0;
- if (time < cl.hasweapon_complain_spam)
+ if (time < this.hasweapon_complain_spam)
complain = 0;
// ignore hook button when using other offhand equipment
- if (cl.offhand != OFFHAND_HOOK)
- if (wpn == WEP_HOOK && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
+ if (this.offhand != OFFHAND_HOOK)
+ if (wpn == WEP_HOOK && !((this.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
complain = 0;
if (complain)
- cl.hasweapon_complain_spam = time + 0.2;
+ this.hasweapon_complain_spam = time + 0.2;
if (wpn == WEP_Null)
{
if (complain)
- sprint(cl, "Invalid weapon\n");
+ sprint(this, "Invalid weapon\n");
return false;
}
- if (cl.weapons & WepSet_FromWeapon(wpn))
+ if (this.weapons & WepSet_FromWeapon(wpn))
{
if (andammo)
{
- if(cl.items & IT_UNLIMITED_WEAPON_AMMO)
+ if(this.items & IT_UNLIMITED_WEAPON_AMMO)
{
f = 1;
}
else
{
- WITHSELF(cl, f = wpn.wr_checkammo1(wpn) + wpn.wr_checkammo2(wpn));
+ f = wpn.wr_checkammo1(wpn, this) + wpn.wr_checkammo2(wpn, this);
// always allow selecting the Mine Layer if we placed mines, so that we can detonate them
if(wpn == WEP_MINE_LAYER)
- FOREACH_ENTITY_CLASS("mine", it.owner == cl,
+ FOREACH_ENTITY_CLASS("mine", it.owner == this,
{
f = 1;
break; // no need to continue
if (!f)
{
if (complain)
- if(IS_REAL_CLIENT(cl))
+ if(IS_REAL_CLIENT(this))
{
- play2(cl, SND(UNAVAILABLE));
- Send_WeaponComplain (cl, wpn.m_id, 0);
+ play2(this, SND(UNAVAILABLE));
+ Send_WeaponComplain (this, wpn.m_id, 0);
}
return false;
}
// Report Proper Weapon Status / Modified Weapon Ownership Message
if (weaponsInMap & WepSet_FromWeapon(wpn))
{
- Send_WeaponComplain(cl, wpn.m_id, 1);
- Weapon_whereis(wpn, cl);
+ Send_WeaponComplain(this, wpn.m_id, 1);
+ Weapon_whereis(wpn, this);
}
else
{
- Send_WeaponComplain (cl, wpn.m_id, 2);
+ Send_WeaponComplain (this, wpn.m_id, 2);
}
- play2(cl, SND(UNAVAILABLE));
+ play2(this, SND(UNAVAILABLE));
}
return false;
}
-float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing)
-{SELFPARAM();
+float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing)
+{
// We cannot tokenize in this function, as GiveItems calls this
// function. Thus we must use car/cdr.
float weaponwant, first_valid, prev_valid, switchtonext, switchtolast;
float weaponcur;
entity wep;
- if(skipmissing || pl.selectweapon == 0)
- weaponcur = PS(pl).m_switchweapon.m_id;
+ if(skipmissing || this.selectweapon == 0)
+ weaponcur = PS(this).m_switchweapon.m_id;
else
- weaponcur = pl.selectweapon;
+ weaponcur = this.selectweapon;
if(dir == 0)
switchtonext = 1;
FOREACH(Weapons, it != WEP_Null, {
if(i != weaponwant)
if(it.impulse == imp || imp < 0)
- if((pl.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
+ if((this.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
have_other = true;
});
// skip weapons we don't own that aren't normal and aren't in the map
- if(!(pl.weapons & wepset))
+ if(!(this.weapons & wepset))
if(!(weaponsInMap & wepset))
if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other)
continue;
++c;
- if(!skipmissing || client_hasweapon(pl, wep, true, false))
+ if(!skipmissing || client_hasweapon(this, wep, true, false))
{
if(switchtonext)
return weaponwant;
// complain (but only for one weapon on the button that has been pressed)
if(complain)
{
- self.weaponcomplainindex += 1;
- c = (self.weaponcomplainindex % c) + 1;
+ this.weaponcomplainindex += 1;
+ c = (this.weaponcomplainindex % c) + 1;
rest = weaponorder;
while(rest != "")
{
FOREACH(Weapons, it != WEP_Null, {
if(i != weaponwant)
if(it.impulse == imp || imp < 0)
- if((pl.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
+ if((this.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
have_other = true;
});
// skip weapons we don't own that aren't normal and aren't in the map
- if(!(pl.weapons & wepset))
+ if(!(this.weapons & wepset))
if(!(weaponsInMap & wepset))
if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other)
continue;
--c;
if(c == 0)
{
- client_hasweapon(pl, wep, true, true);
+ client_hasweapon(this, wep, true, true);
break;
}
}
}
// perform weapon to attack (weaponstate and attack_finished check is here)
-void W_SwitchToOtherWeapon(entity pl)
+void W_SwitchToOtherWeapon(entity this)
{
// hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)
Weapon ww;
- WepSet set = WepSet_FromWeapon(PS(pl).m_weapon);
- if (pl.weapons & set)
+ WepSet set = WepSet_FromWeapon(PS(this).m_weapon);
+ if (this.weapons & set)
{
- pl.weapons &= ~set;
- ww = w_getbestweapon(pl);
- pl.weapons |= set;
+ this.weapons &= ~set;
+ ww = w_getbestweapon(this);
+ this.weapons |= set;
}
else
{
- ww = w_getbestweapon(pl);
+ ww = w_getbestweapon(this);
}
if (ww == WEP_Null) return;
- W_SwitchWeapon_Force(pl, ww);
+ W_SwitchWeapon_Force(this, ww);
}
-void W_SwitchWeapon(Weapon w)
-{SELFPARAM();
- if (PS(self).m_switchweapon != w)
+void W_SwitchWeapon(entity this, Weapon w)
+{
+ if (PS(this).m_switchweapon != w)
{
- if (client_hasweapon(self, w, true, true))
- W_SwitchWeapon_Force(self, w);
+ if (client_hasweapon(this, w, true, true))
+ W_SwitchWeapon_Force(this, w);
else
- self.selectweapon = w.m_id; // update selectweapon ANYWAY
+ this.selectweapon = w.m_id; // update selectweapon ANYWAY
}
- else if(!forbidWeaponUse(self)) {
+ else if(!forbidWeaponUse(this)) {
entity actor = this;
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
w.wr_reload(w, actor, weaponentity);
}
}
-void W_CycleWeapon(string weaponorder, float dir)
-{SELFPARAM();
+void W_CycleWeapon(entity this, string weaponorder, float dir)
+{
float w;
- w = W_GetCycleWeapon(self, weaponorder, dir, -1, 1, true);
+ w = W_GetCycleWeapon(this, weaponorder, dir, -1, 1, true);
if(w > 0)
- W_SwitchWeapon(Weapons_from(w));
+ W_SwitchWeapon(this, Weapons_from(w));
}
-void W_NextWeaponOnImpulse(float imp)
-{SELFPARAM();
+void W_NextWeaponOnImpulse(entity this, float imp)
+{
float w;
- w = W_GetCycleWeapon(self, self.cvar_cl_weaponpriority, +1, imp, 1, (self.cvar_cl_weaponimpulsemode == 0));
+ w = W_GetCycleWeapon(this, this.cvar_cl_weaponpriority, +1, imp, 1, (this.cvar_cl_weaponimpulsemode == 0));
if(w > 0)
- W_SwitchWeapon(Weapons_from(w));
+ W_SwitchWeapon(this, Weapons_from(w));
}
// next weapon
-void W_NextWeapon(float list)
-{SELFPARAM();
+void W_NextWeapon(entity this, int list)
+{
if(list == 0)
- W_CycleWeapon(weaponorder_byid, -1);
+ W_CycleWeapon(this, weaponorder_byid, -1);
else if(list == 1)
- W_CycleWeapon(self.weaponorder_byimpulse, -1);
+ W_CycleWeapon(this, this.weaponorder_byimpulse, -1);
else if(list == 2)
- W_CycleWeapon(self.cvar_cl_weaponpriority, -1);
+ W_CycleWeapon(this, this.cvar_cl_weaponpriority, -1);
}
// prev weapon
-void W_PreviousWeapon(float list)
-{SELFPARAM();
+void W_PreviousWeapon(entity this, float list)
+{
if(list == 0)
- W_CycleWeapon(weaponorder_byid, +1);
+ W_CycleWeapon(this, weaponorder_byid, +1);
else if(list == 1)
- W_CycleWeapon(self.weaponorder_byimpulse, +1);
+ W_CycleWeapon(this, this.weaponorder_byimpulse, +1);
else if(list == 2)
- W_CycleWeapon(self.cvar_cl_weaponpriority, +1);
+ W_CycleWeapon(this, this.cvar_cl_weaponpriority, +1);
}
// previously used if exists and has ammo, (second) best otherwise
{
Weapon wep = Weapons_from(this.cnt);
if (client_hasweapon(this, wep, true, false))
- W_SwitchWeapon(wep);
+ W_SwitchWeapon(this, wep);
else
W_SwitchToOtherWeapon(this);
}
void Send_WeaponComplain(entity e, float wpn, float type);
.float hasweapon_complain_spam;
-bool client_hasweapon(entity cl, Weapon wpn, float andammo, bool complain);
+bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain);
.int weaponcomplainindex;
-float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing);
+float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing);
#define w_getbestweapon(ent) Weapons_from(W_GetCycleWeapon(ent, ent.cvar_cl_weaponpriority, 0, -1, false, true))
void W_SwitchWeapon_Force(Player this, Weapon w);
// perform weapon to attack (weaponstate and attack_finished check is here)
-void W_SwitchToOtherWeapon(entity pl);
-void W_SwitchWeapon(Weapon imp);
+void W_SwitchToOtherWeapon(entity this);
+void W_SwitchWeapon(entity this, Weapon imp);
-void W_CycleWeapon(string weaponorder, float dir);
+void W_CycleWeapon(entity this, string weaponorder, float dir);
-void W_NextWeaponOnImpulse(float imp);
+void W_NextWeaponOnImpulse(entity this, float imp);
// next weapon
-void W_NextWeapon(float list);
+void W_NextWeapon(entity this, float list);
// prev weapon
-void W_PreviousWeapon(float list);
+void W_PreviousWeapon(entity this, float list);
// previously used if exists and has ammo, (second) best otherwise
void W_LastWeapon(entity this);
#include <common/weapons/all.qh>
#include <common/state.qh>
-void thrown_wep_think()
-{SELFPARAM();
- self.nextthink = time;
- if(self.oldorigin != self.origin)
+void thrown_wep_think(entity this)
+{
+ this.nextthink = time;
+ if(this.oldorigin != this.origin)
{
- self.SendFlags |= ISF_LOCATION;
- self.oldorigin = self.origin;
+ this.SendFlags |= ISF_LOCATION;
+ this.oldorigin = this.origin;
}
- self.owner = world;
- float timeleft = self.savenextthink - time;
+ this.owner = world;
+ float timeleft = this.savenextthink - time;
if(timeleft > 1)
- SUB_SetFade(self, self.savenextthink - 1, 1);
+ SUB_SetFade(this, this.savenextthink - 1, 1);
else if(timeleft > 0)
- SUB_SetFade(self, time, timeleft);
+ SUB_SetFade(this, time, timeleft);
else
- SUB_VanishOrRemove(self);
+ SUB_VanishOrRemove(this);
}
// returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo)
-{SELFPARAM();
+{
float thisammo;
string s;
Weapon info = Weapons_from(wpn);
if(startitem_failed)
return string_null;
wep.glowmod = weaponentity_glowmod(info, own.clientcolors);
- wep.think = thrown_wep_think;
+ setthink(wep, thrown_wep_think);
wep.savenextthink = wep.nextthink;
wep.nextthink = min(wep.nextthink, time + 0.5);
wep.pickup_anyway = true; // these are ALWAYS pickable
if(doreduce && g_weapon_stay == 2)
{
// if our weapon is loaded, give its load back to the player
- int i = PS(self).m_weapon.m_id;
- if(self.(weapon_load[i]) > 0)
+ int i = PS(own).m_weapon.m_id;
+ if(own.(weapon_load[i]) > 0)
{
- own.(ammotype) += self.(weapon_load[i]);
- self.(weapon_load[i]) = -1; // schedule the weapon for reloading
+ own.(ammotype) += own.(weapon_load[i]);
+ own.(weapon_load[i]) = -1; // schedule the weapon for reloading
}
wep.(ammotype) = 0;
else if(doreduce)
{
// if our weapon is loaded, give its load back to the player
- int i = PS(self).m_weapon.m_id;
- if(self.(weapon_load[i]) > 0)
+ int i = PS(own).m_weapon.m_id;
+ if(own.(weapon_load[i]) > 0)
{
- own.(ammotype) += self.(weapon_load[i]);
- self.(weapon_load[i]) = -1; // schedule the weapon for reloading
+ own.(ammotype) += own.(weapon_load[i]);
+ own.(weapon_load[i]) = -1; // schedule the weapon for reloading
}
thisammo = min(own.(ammotype), wep.(ammotype));
}
}
-bool W_IsWeaponThrowable(bool w)
+bool W_IsWeaponThrowable(entity this, int w)
{
- if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon))
+ if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon, this))
return false;
if (!autocvar_g_pickup_items)
return false;
}
// toss current weapon
-void W_ThrowWeapon(vector velo, vector delta, float doreduce)
-{SELFPARAM();
- Weapon w = PS(self).m_weapon;
+void W_ThrowWeapon(entity this, vector velo, vector delta, float doreduce)
+{
+ Weapon w = PS(this).m_weapon;
if (w == WEP_Null)
return; // just in case
- if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon))
+ if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon, this))
return;
if(!autocvar_g_weapon_throwable)
return;
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
- if(self.(weaponentity).state != WS_READY)
+ if(this.(weaponentity).state != WS_READY)
return;
- if(!W_IsWeaponThrowable(w.m_id))
+ if(!W_IsWeaponThrowable(this, w.m_id))
return;
WepSet set = WepSet_FromWeapon(w);
- if(!(self.weapons & set)) return;
- self.weapons &= ~set;
+ if(!(this.weapons & set)) return;
+ this.weapons &= ~set;
- W_SwitchWeapon_Force(self, w_getbestweapon(self));
- string a = W_ThrowNewWeapon(self, w.m_id, doreduce, self.origin + delta, velo);
+ W_SwitchWeapon_Force(this, w_getbestweapon(this));
+ string a = W_ThrowNewWeapon(this, w.m_id, doreduce, this.origin + delta, velo);
if(!a) return;
- Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_WEAPON_DROP, a, w.m_id);
+ Send_Notification(NOTIF_ONE, this, MSG_MULTI, ITEM_WEAPON_DROP, a, w.m_id);
}
void SpawnThrownWeapon(entity this, vector org, float w)
{
if(this.weapons & WepSet_FromWeapon(PS(this).m_weapon))
- if(W_IsWeaponThrowable(PS(this).m_weapon.m_id))
+ if(W_IsWeaponThrowable(this, PS(this).m_weapon.m_id))
W_ThrowNewWeapon(this, PS(this).m_weapon.m_id, false, org, randomvec() * 125 + '0 0 200');
}
#pragma once
.float savenextthink;
-void thrown_wep_think();
+void thrown_wep_think(entity this);
// returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
-float W_IsWeaponThrowable(float w);
+bool W_IsWeaponThrowable(entity this, int w);
// toss current weapon
-void W_ThrowWeapon(vector velo, vector delta, float doreduce);
+void W_ThrowWeapon(entity this, vector velo, vector delta, float doreduce);
void SpawnThrownWeapon(entity this, vector org, float w);
// Ballistics Tracing
// ====================
-void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype)
-{SELFPARAM();
+void FireRailgunBullet (entity this, vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype)
+{
vector hitloc, force, endpoint, dir;
entity ent, endent;
float endq3surfaceflags;
// trace multiple times until we hit a wall, each obstacle will be made
// non-solid so we can hit the next, while doing this we spawn effects and
// note down which entities were hit so we can damage them later
- o = self;
+ o = this;
while (1)
{
- if(CS(self).antilag_debug)
- WarpZone_traceline_antilag (self, start, end, false, o, CS(self).antilag_debug);
+ if(CS(this).antilag_debug)
+ WarpZone_traceline_antilag (this, start, end, false, o, CS(this).antilag_debug);
else
- WarpZone_traceline_antilag (self, start, end, false, o, ANTILAG_LATENCY(self));
+ WarpZone_traceline_antilag (this, start, end, false, o, ANTILAG_LATENCY(this));
if(o && WarpZone_trace_firstzone)
{
o = world;
}
if(trace_ent.solid == SOLID_BSP || trace_ent.solid == SOLID_SLIDEBOX)
- Damage_DamageInfo(trace_endpos, bdamage, 0, 0, force, deathtype, trace_ent.species, self);
+ Damage_DamageInfo(trace_endpos, bdamage, 0, 0, force, deathtype, trace_ent.species, this);
// if it is world we can't hurt it so stop now
if (trace_ent == world || trace_fraction == 1)
// Find all non-hit players the beam passed close by
if(deathtype == WEP_VAPORIZER.m_id || deathtype == WEP_VORTEX.m_id)
{
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != self, LAMBDA(
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != this, LAMBDA(
if(!it.railgunhit)
- if(!(IS_SPEC(it) && it.enemy == self))
+ if(!(IS_SPEC(it) && it.enemy == this))
{
msg_entity = it;
// nearest point on the beam
f = ExponentialFalloff(mindist, maxdist, halflifedist, ent.railgundistance);
ffs = ExponentialFalloff(mindist, maxdist, forcehalflifedist, ent.railgundistance);
- if(accuracy_isgooddamage(self, ent))
+ if(accuracy_isgooddamage(this, ent))
totaldmg += bdamage * f;
// apply the damage
if (ent.takedamage)
- Damage (ent, self, self, bdamage * f, deathtype, hitloc, ent.railgunforce * ffs);
+ Damage (ent, this, this, bdamage * f, deathtype, hitloc, ent.railgunforce * ffs);
// create a small explosion to throw gibs around (if applicable)
//setorigin (explosion, hitloc);
- //RadiusDamage (explosion, self, 10, 0, 50, world, world, 300, deathtype);
+ //RadiusDamage (explosion, this, 10, 0, 50, world, world, 300, deathtype);
ent.railgunhitloc = '0 0 0';
ent.railgunhitsolidbackup = SOLID_NOT;
}
// calculate hits and fired shots for hitscan
- accuracy_add(self, PS(self).m_weapon.m_id, 0, min(bdamage, totaldmg));
+ accuracy_add(this, PS(this).m_weapon.m_id, 0, min(bdamage, totaldmg));
trace_endpos = endpoint;
trace_ent = endent;
.float railgundistance;
.vector railgunforce;
-void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype);
+void FireRailgunBullet (entity this, vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype);
entity fireBullet_trace_callback_eff;
entity fireBullet_last_hit;
..entity weaponentity_fld;
.float m_alpha;
-void CL_Weaponentity_Think()
+void CL_Weaponentity_Think(entity this)
{
- SELFPARAM();
this.nextthink = time;
if (intermission_running) this.frame = this.anim_idle.x;
.entity weaponentity = this.weaponentity_fld;
}
}
-void CL_ExteriorWeaponentity_Think()
+void CL_ExteriorWeaponentity_Think(entity this)
{
- SELFPARAM();
this.nextthink = time;
if (this.owner.exteriorweaponentity != this)
{
setmodel(view, MDL_Null); // precision set when changed
setorigin(view, '0 0 0');
view.weaponentity_fld = weaponentity;
- view.think = CL_Weaponentity_Think;
+ setthink(view, CL_Weaponentity_Think);
view.nextthink = time;
view.viewmodelforclient = actor;
view.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
exterior.solid = SOLID_NOT;
exterior.owner = actor;
setorigin(exterior, '0 0 0');
- exterior.think = CL_ExteriorWeaponentity_Think;
+ setthink(exterior, CL_ExteriorWeaponentity_Think);
exterior.nextthink = time;
CSQCMODEL_AUTOINIT(exterior);
.float prevwarntime;
bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary)
{
- SELFPARAM();
if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
bool ammo = false;
- if (secondary) WITHSELF(actor, ammo = thiswep.wr_checkammo2(thiswep));
- else WITHSELF(actor, ammo = thiswep.wr_checkammo1(thiswep));
+ if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor);
+ else ammo = thiswep.wr_checkammo1(thiswep, actor);
if (ammo) return true;
// always keep the Mine Layer if we placed mines, so that we can detonate them
if (thiswep == WEP_MINE_LAYER)
// check if the other firing mode has enough ammo
bool ammo_other = false;
- if (secondary) WITHSELF(actor, ammo_other = thiswep.wr_checkammo1(thiswep));
- else WITHSELF(actor, ammo_other = thiswep.wr_checkammo2(thiswep));
+ if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor);
+ else ammo_other = thiswep.wr_checkammo2(thiswep, actor);
if (ammo_other)
{
if (time - actor.prevwarntime > 1)
actor.weaponname = newwep.mdl;
actor.bulletcounter = 0;
actor.ammo_field = newwep.ammo_field;
- newwep.wr_setup(newwep);
+ newwep.wr_setup(newwep, actor);
this.state = WS_RAISE;
// set our clip load to the load of the weapon we switched to, if it's reloadable
else
{
if (key_pressed && PS(actor).m_switchweapon != WEP_HOOK && !actor.hook_switchweapon)
- W_SwitchWeapon(WEP_HOOK);
+ W_SwitchWeapon(actor, WEP_HOOK);
actor.hook_switchweapon = key_pressed;
Weapon h = WEP_HOOK;
block_weapon = (PS(actor).m_weapon == h && (PHYS_INPUT_BUTTON_ATCK(actor) || key_pressed));
}
else if (e)
{
- e.wr_gonethink(e);
+ e.wr_gonethink(e, actor);
}
}
}
// switch away if the amount of ammo is not enough to keep using this weapon
Weapon w = PS(actor).m_weapon;
- if (!(w.wr_checkammo1(w) + w.wr_checkammo2(w)))
+ if (!(w.wr_checkammo1(w, actor) + w.wr_checkammo2(w, actor)))
{
actor.clip_load = -1; // reload later
W_SwitchToOtherWeapon(actor);
actor.clip_load = actor.(weapon_load[PS(actor).m_weapon.m_id]) = -1;
}
-void W_DropEvent(.void(Weapon) event, entity player, float weapon_type, entity weapon_item)
+void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item)
{
- SELFPARAM();
Weapon w = Weapons_from(weapon_type);
weapon_dropevent_item = weapon_item;
- WITHSELF(player, w.event(w));
+ WITHSELF(player, w.event(w, player));
}
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use);
-void W_DropEvent(.void(Weapon) event, entity player, float weapon_type, entity weapon_item);
+void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item);
void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound);