]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/t_items.qc
Merge branch 'master' into Mario/race_target_waypoint
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / t_items.qc
index b6f405fec019b5cb8ef6249b3c07a77f02c7fc32..19e404a1a4ece51beca94a7ed33ba073145f887a 100644 (file)
@@ -509,7 +509,7 @@ void Item_Respawn (entity this)
        sound(this, CH_TRIGGER, this.itemdef.m_respawnsound, VOL_BASE, ATTEN_NORM);     // play respawn sound
        setorigin(this, this.origin);
 
-    if (Item_ItemsTime_Allow(this.itemdef) || this.weapons & WEPSET_SUPERWEAPONS)
+    if (Item_ItemsTime_Allow(this.itemdef) || (this.weapons & WEPSET_SUPERWEAPONS))
        {
                float t = Item_ItemsTime_UpdateTime(this, 0);
                Item_ItemsTime_SetTime(this, t);
@@ -594,7 +594,7 @@ 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)) && (t - ITEM_RESPAWN_TICKS) > 0)
        {
                setthink(e, Item_RespawnCountdown);
                e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
@@ -610,6 +610,13 @@ void Item_ScheduleRespawnIn(entity e, float t)
                e.nextthink = time;
                e.scheduledrespawntime = time + t;
                e.wait = time + t;
+
+               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();
+               }
        }
 }
 
@@ -627,7 +634,7 @@ void Item_ScheduleRespawn(entity e)
 void Item_ScheduleInitialRespawn(entity e)
 {
        Item_Show(e, 0);
-       Item_ScheduleRespawnIn(e, game_starttime - time + ((e.respawntimestart) ? e.respawntimestart : ITEM_RESPAWNTIME_INITIAL(e)));
+       Item_ScheduleRespawnIn(e, max(0, game_starttime - time) + ((e.respawntimestart) ? e.respawntimestart : ITEM_RESPAWNTIME_INITIAL(e)));
 }
 
 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode)
@@ -873,7 +880,7 @@ LABEL(pickup)
                                }
                        });
                        e = RandomSelection_chosen_ent;
-
+                       Item_Show(e, 1); // reset its state so it is visible (extra sendflags doesn't matter, this happens anyway)
                }
                else
                        e = this;
@@ -1332,7 +1339,7 @@ void setItemGroup(entity this)
                        {
                                int grY = it.item_group;
                                // move all items of item_group Y to item_group X
-                               FOREACH_ENTITY(IS_SMALL(it.itemdef),
+                               IL_EACH(g_items, IS_SMALL(it.itemdef),
                                {
                                        if(it.item_group == grY)
                                                it.item_group = this.item_group;
@@ -1347,9 +1354,9 @@ void setItemGroupCount()
        for (int k = 1; k <= group_count; k++)
        {
                int count = 0;
-               FOREACH_ENTITY(IS_SMALL(it.itemdef) && it.item_group == k, { count++; });
+               IL_EACH(g_items, IS_SMALL(it.itemdef) && it.item_group == k, { count++; });
                if (count)
-                       FOREACH_ENTITY(IS_SMALL(it.itemdef) && it.item_group == k, { it.item_group_count = count; });
+                       IL_EACH(g_items, IS_SMALL(it.itemdef) && it.item_group == k, { it.item_group_count = count; });
        }
 }
 
@@ -1916,7 +1923,11 @@ float GiveItems(entity e, float beginarg, float endarg)
                {
                        .entity weaponentity = weaponentities[slot];
                        if(_switchweapon & BIT(slot))
-                               W_SwitchWeapon_Force(e, w_getbestweapon(e, weaponentity), weaponentity);
+                       {
+                               Weapon wep = w_getbestweapon(e, weaponentity);
+                               if(wep != e.(weaponentity).m_switchweapon)
+                                       W_SwitchWeapon_Force(e, wep, weaponentity);
+                       }
                }
        }