X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fwaypointsprites.qc;h=0e6f2168b863b50c94a7c49dd20659a9315ed879;hb=8f4d064a1d62a040e788fc0634baf93e888ba2f6;hp=24fdcb336729c9ed81f9731a67fcfc20167e85e7;hpb=06244ad48a6bd57ce8a5fbcf4a11672861f063b3;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/waypointsprites.qc b/qcsrc/server/waypointsprites.qc index 24fdcb336..0e6f2168b 100644 --- a/qcsrc/server/waypointsprites.qc +++ b/qcsrc/server/waypointsprites.qc @@ -82,6 +82,7 @@ void WaypointSprite_UpdateTeamRadar(entity e, float icon, vector col) } .float waypointsprite_pingtime; +.float waypointsprite_helpmetime; void WaypointSprite_Ping(entity e) { // anti spam @@ -93,6 +94,15 @@ void WaypointSprite_Ping(entity e) e.SendFlags |= 32; } +float waypointsprite_limitedrange, waypointsprite_deployed_lifetime, waypointsprite_deadlifetime; + +void WaypointSprite_HelpMePing(entity e) +{ + WaypointSprite_Ping(e); + e.waypointsprite_helpmetime = time + waypointsprite_deployed_lifetime; + e.SendFlags |= 32; +} + void WaypointSprite_FadeOutIn(entity e, float t) { if(!e.fade_time) @@ -115,12 +125,11 @@ void WaypointSprite_FadeOutIn(entity e, float t) e.SendFlags |= 16; } -float waypointsprite_limitedrange, waypointsprite_deployed_lifetime, waypointsprite_deadlifetime; void WaypointSprite_Init() { - waypointsprite_limitedrange = autocvar_g_waypointsprite_limitedrange; - waypointsprite_deployed_lifetime = autocvar_g_waypointsprite_deployed_lifetime; - waypointsprite_deadlifetime = autocvar_g_waypointsprite_deadlifetime; + waypointsprite_limitedrange = autocvar_sv_waypointsprite_limitedrange; + waypointsprite_deployed_lifetime = autocvar_sv_waypointsprite_deployed_lifetime; + waypointsprite_deadlifetime = autocvar_sv_waypointsprite_deadlifetime; } void WaypointSprite_InitClient(entity e) { @@ -180,30 +189,63 @@ float WaypointSprite_visible_for_player(entity e) { // personal waypoints if(self.enemy) - if(self.enemy != other) + if(self.enemy != e) return FALSE; // team waypoints if(self.team && self.rule == SPRITERULE_DEFAULT) { - if(self.team != other.team) + if(self.team != e.team) return FALSE; - if(other.classname != "player") + if(e.classname != "player") return FALSE; } return TRUE; } +entity WaypointSprite_getviewentity(entity e) +{ + if(e.classname == "spectator") + e = e.enemy; + /* TODO idea (check this breaks nothing) + else if(e.classname == "observer") + e = world; + */ + return e; +} + +float WaypointSprite_isteammate(entity e, entity e2) +{ + if(teamplay) + { + if(e2.team != e.team) + return FALSE; + } + else + { + if(e2 != e) + return FALSE; + } + return TRUE; +} + float WaypointSprite_Customize() { // this is not in SendEntity because it shall run every frame, not just every update // make spectators see what the player would see entity e; - e = other; - if(e.classname == "spectator") - e = e.enemy; + e = WaypointSprite_getviewentity(other); + + // as a GENERAL rule: + // if you have the invisibility powerup, sprites ALWAYS are restricted to your team + // but only apply this to real players, not to spectators + if(g_minstagib && (self.owner.flags & FL_CLIENT) && (self.owner.items & IT_STRENGTH) && (e == other)) + { + if(!WaypointSprite_isteammate(self.owner, e)) + return FALSE; + } return self.waypointsprite_visible_for_player(e); } @@ -280,6 +322,18 @@ float WaypointSprite_SendEntity(entity to, float sendflags) WriteByte(MSG_ENTITY, self.colormod_x * 255.0); WriteByte(MSG_ENTITY, self.colormod_y * 255.0); WriteByte(MSG_ENTITY, self.colormod_z * 255.0); + + if(WaypointSprite_isteammate(self.owner, WaypointSprite_getviewentity(to))) + { + dt = (self.waypointsprite_helpmetime - time) / 0.1; + if(dt < 0) + dt = 0; + if(dt > 255) + dt = 255; + WriteByte(MSG_ENTITY, dt); + } + else + WriteByte(MSG_ENTITY, 0); } return TRUE; @@ -299,7 +353,8 @@ entity WaypointSprite_Spawn( entity ref, vector ofs, // position entity showto, float t, // show to whom? Use a flag to indicate a team entity own, .entity ownfield, // remove when own gets killed - float hideable // true when it should be controlled by cl_hidewaypoints + float hideable, // true when it should be controlled by cl_hidewaypoints + float icon, vector rgb // initial icon and color ) { entity wp; @@ -333,6 +388,8 @@ entity WaypointSprite_Spawn( wp.customizeentityforclient = WaypointSprite_Customize; wp.waypointsprite_visible_for_player = WaypointSprite_visible_for_player; wp.reset2 = WaypointSprite_Reset; + wp.cnt = icon; + wp.colormod = rgb; Net_LinkEntity(wp, FALSE, 0, WaypointSprite_SendEntity); return wp; } @@ -341,17 +398,19 @@ entity WaypointSprite_SpawnFixed( string spr, vector ofs, entity own, - .entity ownfield + .entity ownfield, + float icon, vector rgb // initial icon and color ) { - return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, own, ownfield, TRUE); + return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, own, ownfield, TRUE, icon, rgb); } .entity waypointsprite_deployed_fixed; entity WaypointSprite_DeployFixed( string spr, float limited_range, - vector ofs + vector ofs, + float icon, vector rgb // initial icon and color ) { float t, maxdistance; @@ -363,23 +422,25 @@ entity WaypointSprite_DeployFixed( maxdistance = waypointsprite_limitedrange; else maxdistance = 0; - return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, world, ofs, world, t, self, waypointsprite_deployed_fixed, FALSE); + return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, world, ofs, world, t, self, waypointsprite_deployed_fixed, FALSE, icon, rgb); } .entity waypointsprite_deployed_personal; entity WaypointSprite_DeployPersonal( string spr, - vector ofs + vector ofs, + float icon, vector rgb // initial icon and color ) { - return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, self, waypointsprite_deployed_personal, FALSE); + return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, self, waypointsprite_deployed_personal, FALSE, icon, rgb); } .entity waypointsprite_attached; .entity waypointsprite_attachedforcarrier; entity WaypointSprite_Attach( string spr, - float limited_range + float limited_range, + float icon, vector rgb // initial icon and color ) { float t, maxdistance; @@ -393,17 +454,18 @@ entity WaypointSprite_Attach( maxdistance = waypointsprite_limitedrange; else maxdistance = 0; - return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, self, '0 0 64', world, t, self, waypointsprite_attached, FALSE); + return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, self, '0 0 64', world, t, self, waypointsprite_attached, FALSE, icon, rgb); } entity WaypointSprite_AttachCarrier( string spr, - entity carrier + entity carrier, + float icon, vector rgb // initial icon and color ) { entity e; WaypointSprite_Kill(carrier.waypointsprite_attached); // FC overrides attached - e = WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', world, carrier.team, carrier, waypointsprite_attachedforcarrier, FALSE); + e = WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', world, carrier.team, carrier, waypointsprite_attachedforcarrier, FALSE, icon, rgb); if(e) { WaypointSprite_UpdateMaxHealth(e, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent) * 2);