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)
#endif
#ifdef CSQC
-void Ent_WaypointSprite();
+void Ent_WaypointSprite(entity this);
NET_HANDLE(waypointsprites, bool isnew) {
- Ent_WaypointSprite();
+ Ent_WaypointSprite(this);
return true;
}
}
/** flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable] */
-void Ent_WaypointSprite()
-{SELFPARAM();
+void Ent_WaypointSprite(entity this)
+{
int sendflags = ReadByte();
- self.wp_extra = ReadByte();
+ this.wp_extra = ReadByte();
- if (!self.spawntime)
- self.spawntime = time;
+ if (!this.spawntime)
+ this.spawntime = time;
- self.draw2d = Draw_WaypointSprite;
+ this.draw2d = Draw_WaypointSprite;
- InterpolateOrigin_Undo(self);
- self.iflags |= IFLAG_ORIGIN;
+ InterpolateOrigin_Undo(this);
+ this.iflags |= IFLAG_ORIGIN;
if (sendflags & 0x80)
{
int t = ReadByte();
if (t < 192)
{
- self.health = t / 191.0;
- self.build_finished = 0;
+ this.health = t / 191.0;
+ this.build_finished = 0;
}
else
{
t = (t - 192) * 256 + ReadByte();
- self.build_started = servertime;
- if (self.build_finished)
- self.build_starthealth = bound(0, self.health, 1);
+ this.build_started = servertime;
+ if (this.build_finished)
+ this.build_starthealth = bound(0, this.health, 1);
else
- self.build_starthealth = 0;
- self.build_finished = servertime + t / 32;
+ this.build_starthealth = 0;
+ this.build_finished = servertime + t / 32;
}
}
else
{
- self.health = -1;
- self.build_finished = 0;
+ this.health = -1;
+ this.build_finished = 0;
}
if (sendflags & 64)
{
// unfortunately, this needs to be exact (for the 3D display)
- 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 (sendflags & 1)
{
- self.team = ReadByte();
- self.rule = ReadByte();
+ this.team = ReadByte();
+ this.rule = ReadByte();
}
if (sendflags & 2)
{
- if (self.netname)
- strunzone(self.netname);
- self.netname = strzone(ReadString());
+ if (this.netname)
+ strunzone(this.netname);
+ this.netname = strzone(ReadString());
}
if (sendflags & 4)
{
- if (self.netname2)
- strunzone(self.netname2);
- self.netname2 = strzone(ReadString());
+ if (this.netname2)
+ strunzone(this.netname2);
+ this.netname2 = strzone(ReadString());
}
if (sendflags & 8)
{
- if (self.netname3)
- strunzone(self.netname3);
- self.netname3 = strzone(ReadString());
+ if (this.netname3)
+ strunzone(this.netname3);
+ this.netname3 = strzone(ReadString());
}
if (sendflags & 16)
{
- self.lifetime = ReadCoord();
- self.fadetime = ReadCoord();
- self.maxdistance = ReadShort();
- self.hideflags = ReadByte();
+ this.lifetime = ReadCoord();
+ this.fadetime = ReadCoord();
+ this.maxdistance = ReadShort();
+ this.hideflags = ReadByte();
}
if (sendflags & 32)
{
int f = ReadByte();
- self.teamradar_icon = f & BITS(7);
+ this.teamradar_icon = f & BITS(7);
if (f & BIT(7))
{
- self.(teamradar_times[self.teamradar_time_index]) = time;
- self.teamradar_time_index = (self.teamradar_time_index + 1) % MAX_TEAMRADAR_TIMES;
+ this.(teamradar_times[this.teamradar_time_index]) = time;
+ this.teamradar_time_index = (this.teamradar_time_index + 1) % MAX_TEAMRADAR_TIMES;
}
- self.teamradar_color_x = ReadByte() / 255.0;
- self.teamradar_color_y = ReadByte() / 255.0;
- self.teamradar_color_z = ReadByte() / 255.0;
- self.helpme = ReadByte() * 0.1;
- if (self.helpme > 0)
- self.helpme += servertime;
+ this.teamradar_color_x = ReadByte() / 255.0;
+ this.teamradar_color_y = ReadByte() / 255.0;
+ this.teamradar_color_z = ReadByte() / 255.0;
+ this.helpme = ReadByte() * 0.1;
+ if (this.helpme > 0)
+ this.helpme += servertime;
}
InterpolateOrigin_Note(this);
- self.entremove = Ent_RemoveWaypointSprite;
+ this.entremove = Ent_RemoveWaypointSprite;
}
#endif
#ifdef CSQC
-float spritelookupblinkvalue(string s)
-{SELFPARAM();
+float spritelookupblinkvalue(entity this, string s)
+{
if (s == WP_Weapon.netname) {
- if (Weapons_from(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
+ if (Weapons_from(this.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
return 2;
}
- if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypointblink;
+ if (s == WP_Item.netname) return Items_from(this.wp_extra).m_waypointblink;
return 1;
}
return def;
}
-string spritelookuptext(string s)
-{SELFPARAM();
+string spritelookuptext(entity this, string s)
+{
if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
- if (s == WP_Weapon.netname) return Weapons_from(self.wp_extra).m_name;
- if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypoint;
- if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;
+ if (s == WP_Weapon.netname) return Weapons_from(this.wp_extra).m_name;
+ if (s == WP_Item.netname) return Items_from(this.wp_extra).m_waypoint;
+ if (s == WP_Monster.netname) return get_monsterinfo(this.wp_extra).monster_name;
if (MUTATOR_CALLHOOK(WP_Format, this, s))
{
return MUTATOR_ARGV(0, string);
if (this.helpme && time < this.helpme)
a *= SPRITE_HELPME_BLINK;
else if (!this.lifetime) // fading out waypoints don't blink
- a *= spritelookupblinkvalue(spriteimage);
+ a *= spritelookupblinkvalue(this, spriteimage);
}
if (a > 1)
if (autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
txt = _("Spam");
else
- txt = spritelookuptext(spriteimage);
+ txt = spritelookuptext(this, spriteimage);
if (this.helpme && time < this.helpme)
txt = sprintf(_("%s needing help!"), txt);
if (autocvar_g_waypointsprite_uppercase)
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);
)
{
entity wp = new(sprite_waypoint);
- make_pure(wp);
wp.teleport_time = time + _lifetime;
wp.fade_time = _lifetime;
wp.exteriormodeltoclient = ref;
{
WaypointSprite_Kill(carrier.waypointsprite_attached); // FC overrides attached
entity e = WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', world, carrier.team, carrier, waypointsprite_attachedforcarrier, false, icon);
- if (e)
+ if (carrier.health)
{
WaypointSprite_UpdateMaxHealth(e, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id) * 2);
WaypointSprite_UpdateHealth(e, '1 0 0' * healtharmor_maxdamage(carrier.health, carrier.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id));