]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
powerups_dropondeath: Added dropped waypoint
authorz411 <z411@omaera.org>
Wed, 24 Nov 2021 21:44:50 +0000 (18:44 -0300)
committerz411 <z411@omaera.org>
Wed, 24 Nov 2021 21:44:50 +0000 (18:44 -0300)
qcsrc/common/mutators/mutator/powerups/sv_powerups.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh
xonotic-server.cfg

index 7bf005f91248ce9661f22b0fa5eb164b5d03bb12..181c56834200782a3c101acda066846fab20ad36 100644 (file)
@@ -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)
index 97c26f360dd19d037b166ce6ff25181a59b604c1..b6c4f5558990181d1aef0c11b6446009a5318767 100644 (file)
@@ -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);
index 2274da336e926e31baeeeb46d471653c793519f1..cd3181707afde387e02017698b0cc96cb8802bb3 100644 (file)
@@ -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;
 
index 2500862223de72b9a8c8b928ac857e93a1db7adf..a9db6df52f2f48808b1ec8efad792310af1b2241 100644 (file)
@@ -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"