From: z411 Date: Wed, 24 Nov 2021 21:44:50 +0000 (-0300) Subject: powerups_dropondeath: Added dropped waypoint X-Git-Tag: xonotic-v0.8.5~273^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=473dc5f95b6b40df65fc2ae5d841fde806063d29;p=xonotic%2Fxonotic-data.pk3dir.git powerups_dropondeath: Added dropped waypoint --- diff --git a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc index 7bf005f91..181c56834 100644 --- a/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc +++ b/qcsrc/common/mutators/mutator/powerups/sv_powerups.qc @@ -108,6 +108,20 @@ void powerups_DropItem(entity this, StatusEffects effect) if(autocvar_g_powerups_dropondeath != 2) Item_SetExpiring(e, true); + + // Create expiring waypoint + entity wp = WaypointSprite_Spawn(WP_Item, time_to_live * -1, 0, e, '0 0 1' * e.maxs.z, NULL, 0, e, waypointsprite_attached, true, RADARICON_Item); + wp.wp_extra = item.m_id; + wp.wp_reverse = 1; + WaypointSprite_UpdateBuildFinished(e.waypointsprite_attached, time + time_to_live); + WaypointSprite_Ping(this.waypointsprite_attached); +} + +MUTATOR_HOOKFUNCTION(powerups, ItemTouched) +{ + entity e = M_ARGV(0, entity); + if(e.waypointsprite_attached) + WaypointSprite_Kill(e.waypointsprite_attached); } MUTATOR_HOOKFUNCTION(powerups, PlayerDies) diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 97c26f360..b6c4f5558 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -38,6 +38,7 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags) dt = bound(0, dt * 32, 16383); WriteByte(MSG_ENTITY, (dt & 0xFF00) / 256 + 192); WriteByte(MSG_ENTITY, (dt & 0x00FF)); + WriteByte(MSG_ENTITY, this.wp_reverse); } } @@ -137,6 +138,7 @@ void Ent_WaypointSprite(entity this, bool isnew) else this.build_starthealth = 0; this.build_finished = servertime + t / 32; + this.build_reverse = ReadByte(); } } else @@ -538,7 +540,12 @@ void Draw_WaypointSprite(entity this) a *= (bound(0, (this.maxdistance - dist) / (this.maxdistance - maxnormdistance), 1) ** waypointsprite_distancealphaexponent); } - vector rgb = spritelookupcolor(this, spriteimage, this.teamradar_color); + vector rgb; + if(this.build_reverse) + rgb = '1 0 0'; + else + rgb = spritelookupcolor(this, spriteimage, this.teamradar_color); + if (rgb == '0 0 0') { this.teamradar_color = '1 0 1'; @@ -648,12 +655,20 @@ void Draw_WaypointSprite(entity this) { if (time < this.build_finished + 0.25) { + float vhealth; + if (time < this.build_started) - SetResourceExplicit(this, RES_HEALTH, this.build_starthealth); + vhealth = this.build_starthealth; else if (time < this.build_finished) - SetResourceExplicit(this, RES_HEALTH, (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth); + vhealth = (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth; else - SetResourceExplicit(this, RES_HEALTH, 1); + vhealth = 1; + + if (this.build_reverse) + vhealth = 1 - vhealth; + + LOG_INFOF( "Setting health to %f (%f)", vhealth, this.build_starthealth); + SetResourceExplicit(this, RES_HEALTH, vhealth); } else SetResourceExplicit(this, RES_HEALTH, -1); diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh index 2274da336..cd3181707 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh @@ -4,6 +4,7 @@ /** Additional networked waypoint state, used for items, weapons, buffs */ .int wp_extra; +.int wp_reverse; const int SPRITERULE_DEFAULT = 0; const int SPRITERULE_TEAMPLAY = 1; @@ -26,6 +27,7 @@ classfield(WaypointSprite) .float health; classfield(WaypointSprite) .float build_started; classfield(WaypointSprite) .float build_starthealth; classfield(WaypointSprite) .float build_finished; +classfield(WaypointSprite) .int build_reverse; bool autocvar_cl_hidewaypoints; diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 250086222..a9db6df52 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -199,7 +199,7 @@ set g_weapon_stay 0 "1: ghost weapons can be picked up but give no ammo, thrown set g_weapon_throwable 1 "if set to 1, weapons can be dropped" set g_powerups -1 "if set to 0 no powerups will spawn, if 1 they will spawn in all game modes, -1 is game mode default" set g_powerups_dropondeath 0 "players will drop their powerups on death (1 = timer continues, 2 = timer freezes until picked up)" -set g_powerups_dropondeath_ttl 20 "seconds before a dropped powerup disappears if dropondeath is set to 2" +set g_powerups_dropondeath_ttl 20 "seconds before a dropped powerup disappears if g_powerups_dropondeath is set to 2" set g_powerups_stack 0 "enables stacking of powerup timers when picking up a powerup you already have; otherwise timer is reset to the time granted by the item, if greater than the time you currently have" set g_powerups_strength 1 "allow strength powerups to spawn" set g_powerups_shield 1 "allow shield powerups to spawn"