Add an option to always show item re-spawn waypoints in overkill
authorMario <mario@smbclan.net>
Mon, 13 Mar 2017 20:53:07 +0000 (06:53 +1000)
committerMario <mario@smbclan.net>
Mon, 13 Mar 2017 20:53:25 +0000 (06:53 +1000)
mutators.cfg
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/common/t_items.qc
qcsrc/common/t_items.qh
qcsrc/server/mutators/events.qh

index f619308..229fd3a 100644 (file)
@@ -51,6 +51,7 @@ set g_instagib_friendlypush 1 "allow pushing teammates with the vaporizer primar
 set g_overkill 0 "enable overkill"
 
 set g_overkill_powerups_replace 1
+set g_overkill_itemwaypoints 1
 set g_overkill_filter_healthmega 0
 set g_overkill_filter_armormedium 0
 set g_overkill_filter_armorbig 0
index 5d938f3..82df487 100644 (file)
@@ -5,6 +5,8 @@
 
 bool autocvar_g_overkill_powerups_replace;
 
+bool autocvar_g_overkill_itemwaypoints = true;
+
 bool autocvar_g_overkill_filter_healthmega;
 bool autocvar_g_overkill_filter_armormedium;
 bool autocvar_g_overkill_filter_armorbig;
@@ -223,6 +225,34 @@ MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
        }
 }
 
+bool ok_HandleItemWaypoints(entity e)
+{
+       if(!autocvar_g_overkill_itemwaypoints)
+               return false; // don't handle it
+
+       switch(e.itemdef)
+       {
+               case ITEM_HealthMega: return true;
+               case ITEM_ArmorMedium: return true;
+               case ITEM_ArmorBig: return true;
+               case ITEM_ArmorMega: return true;
+       }
+
+       return false;
+}
+
+MUTATOR_HOOKFUNCTION(ok, Item_RespawnCountdown)
+{
+       entity item = M_ARGV(0, entity);
+       return ok_HandleItemWaypoints(item);
+}
+
+MUTATOR_HOOKFUNCTION(ok, Item_ScheduleRespawn)
+{
+       entity item = M_ARGV(0, entity);
+       return ok_HandleItemWaypoints(item);
+}
+
 MUTATOR_HOOKFUNCTION(ok, FilterItem)
 {
        entity item = M_ARGV(0, entity);
index 19e404a..5490478 100644 (file)
@@ -537,7 +537,6 @@ void Item_RespawnCountdown (entity this)
                this.count += 1;
                if(this.count == 1)
                {
-                       MUTATOR_CALLHOOK(Item_RespawnCountdown, string_null, '0 0 0');
                        do {
                                {
                                        entity wi = Weapons_from(this.weapon);
@@ -556,10 +555,11 @@ void Item_RespawnCountdown (entity this)
                                        }
                                }
                        } while (0);
+                       bool mutator_returnvalue = MUTATOR_CALLHOOK(Item_RespawnCountdown, this);
             if(this.waypointsprite_attached)
             {
                 GameItem def = this.itemdef;
-                if (Item_ItemsTime_SpectatorOnly(def))
+                if (Item_ItemsTime_SpectatorOnly(def) && !mutator_returnvalue)
                     WaypointSprite_UpdateRule(this.waypointsprite_attached, 0, SPRITERULE_SPECTATOR);
                 WaypointSprite_UpdateBuildFinished(this.waypointsprite_attached, time + ITEM_RESPAWN_TICKS);
             }
@@ -594,15 +594,18 @@ void Item_RespawnThink(entity this)
 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)
+       if ((Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS) || MUTATOR_CALLHOOK(Item_ScheduleRespawn, e, t)) && (t - ITEM_RESPAWN_TICKS) > 0)
        {
                setthink(e, Item_RespawnCountdown);
                e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
                e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
                e.count = 0;
-               t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);
-               Item_ItemsTime_SetTime(e, t);
-               Item_ItemsTime_SetTimesForAllPlayers();
+               if(Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS))
+               {
+                       t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);
+                       Item_ItemsTime_SetTime(e, t);
+                       Item_ItemsTime_SetTimesForAllPlayers();
+               }
        }
        else
        {
index 198bd0f..1b2293b 100644 (file)
@@ -63,9 +63,9 @@ bool have_pickup_item(entity this);
 
 const float ITEM_RESPAWN_TICKS = 10;
 
-#define ITEM_RESPAWNTIME(i)         ((i).respawntime + (crandom() * (i).respawntimejitter))
+#define ITEM_RESPAWNTIME(i)         ((i).respawntime + crandom() * (i).respawntimejitter)
        // range: respawntime - respawntimejitter .. respawntime + respawntimejitter
-#define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + (random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS)))
+#define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS))
        // range: 10 .. respawntime + respawntimejitter
 
 .float max_armorvalue;
index 7523b3a..b6d31c1 100644 (file)
@@ -532,10 +532,7 @@ MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace);
 
 /** called when an item is about to respawn */
 #define EV_Item_RespawnCountdown(i, o) \
-    /** item name */   i(string, MUTATOR_ARGV_0_string) \
-    /**/               o(string, MUTATOR_ARGV_0_string) \
-    /** item colour */ i(vector, MUTATOR_ARGV_1_vector) \
-    /**/               o(vector, MUTATOR_ARGV_1_vector) \
+    /** item */   i(entity, MUTATOR_ARGV_0_entity) \
     /**/
 MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_Item_RespawnCountdown);
 
@@ -948,3 +945,10 @@ enum {
     /** player */ i(entity, MUTATOR_ARGV_0_entity) \
     /**/
 MUTATOR_HOOKABLE(HideTeamNagger, EV_HideTeamNagger);
+
+/** return true to show a waypoint while the item is spawning */
+#define EV_Item_ScheduleRespawn(i, o) \
+    /** item */             i(entity, MUTATOR_ARGV_0_entity) \
+    /** respawn time */     i(float, MUTATOR_ARGV_1_float) \
+    /**/
+MUTATOR_HOOKABLE(Item_ScheduleRespawn, EV_Item_ScheduleRespawn);