]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
Merge branch 'master' into Mario/strength_stat_field
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / buffs / sv_buffs.qc
index 97df48106dcbc935fa4e38c0720f42b8cc3a0854..5ec00e1253008e57e4c330e7ccb0ee82d171260e 100644 (file)
@@ -203,6 +203,7 @@ void buff_Touch(entity this, entity toucher)
        Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
        sound(toucher, CH_TRIGGER, SND_SHIELD_RESPAWN, VOL_BASE, ATTN_NORM);
        STAT(BUFFS, toucher) |= (STAT(BUFFS, this));
+       STAT(LAST_PICKUP, toucher) = time;
        float bufftime = ((this.count) ? this.count : thebuff.m_time(thebuff));
        if(bufftime)
                STAT(BUFF_TIME, toucher) = min(time + bufftime, max(STAT(BUFF_TIME, toucher), time) + bufftime);
@@ -212,7 +213,7 @@ float buff_Available(entity buff)
 {
        if (buff == BUFF_Null)
                return false;
-       if (buff == BUFF_AMMO && ((start_items & IT_UNLIMITED_WEAPON_AMMO) || (start_items & IT_UNLIMITED_AMMO) || (cvar("g_melee_only"))))
+       if (buff == BUFF_AMMO && ((start_items & IT_UNLIMITED_AMMO) || cvar("g_melee_only")))
                return false;
        if (buff == BUFF_VAMPIRE && cvar("g_vampire"))
                return false;
@@ -227,7 +228,8 @@ void buff_NewType(entity ent)
        FOREACH(Buffs, buff_Available(it),
        {
                // if it's already been chosen, give it a lower priority
-               RandomSelection_AddEnt(it, max(0.2, 1 / it.buff_seencount), 1);
+               float myseencount = (it.buff_seencount > 0) ? it.buff_seencount : 1; // no division by zero please!
+               RandomSelection_AddEnt(it, max(0.2, 1 / myseencount), 1);
        });
        entity newbuff = RandomSelection_chosen_ent;
        newbuff.buff_seencount += 1; // lower chances of seeing this buff again soon
@@ -271,7 +273,7 @@ void buff_Think(entity this)
        {
                buff_SetCooldown(this, autocvar_g_buffs_cooldown_respawn + frametime);
                this.owner = NULL;
-               if(autocvar_g_buffs_randomize)
+               if(autocvar_g_buffs_randomize && (!teamplay || autocvar_g_buffs_randomize_teamplay))
                        buff_NewType(this);
 
                if(autocvar_g_buffs_random_location || (this.spawnflags & 64))
@@ -315,7 +317,7 @@ void buff_Waypoint_Reset(entity this)
 
 void buff_Reset(entity this)
 {
-       if(autocvar_g_buffs_randomize)
+       if(autocvar_g_buffs_randomize && (!teamplay || autocvar_g_buffs_randomize_teamplay))
                buff_NewType(this);
        this.owner = NULL;
        buff_SetCooldown(this, autocvar_g_buffs_cooldown_activate);
@@ -576,7 +578,6 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerSpawn)
        entity player = M_ARGV(0, entity);
 
        player.oldbuffs = 0;
-       PS(player).buff_shield = time + 0.5; // prevent picking up buffs immediately
        // reset timers here to prevent them continuing after re-spawn
        player.buff_disability_time = 0;
        player.buff_disability_effect_time = 0;
@@ -918,8 +919,8 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
 
                BUFF_ONADD(BUFF_AMMO)
                {
-                       player.buff_ammo_prev_infitems = (player.items & IT_UNLIMITED_WEAPON_AMMO);
-                       player.items |= IT_UNLIMITED_WEAPON_AMMO;
+                       player.buff_ammo_prev_infitems = (player.items & IT_UNLIMITED_AMMO);
+                       player.items |= IT_UNLIMITED_AMMO;
 
                        if(STAT(BUFFS, player) & BUFF_AMMO.m_itemid)
                        {
@@ -937,9 +938,9 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
                BUFF_ONREM(BUFF_AMMO)
                {
                        if(player.buff_ammo_prev_infitems)
-                               player.items |= IT_UNLIMITED_WEAPON_AMMO;
+                               player.items |= IT_UNLIMITED_AMMO;
                        else
-                               player.items &= ~IT_UNLIMITED_WEAPON_AMMO;
+                               player.items &= ~IT_UNLIMITED_AMMO;
 
                        if(STAT(BUFFS, player) & BUFF_AMMO.m_itemid)
                        {
@@ -954,7 +955,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
 
                BUFF_ONADD(BUFF_INVISIBLE)
                {
-                       if(time < player.strength_finished && MUTATOR_IS_ENABLED(mutator_instagib))
+                       if(time < STAT(STRENGTH_FINISHED, player) && MUTATOR_IS_ENABLED(mutator_instagib))
                                player.buff_invisible_prev_alpha = default_player_alpha; // we don't want to save the powerup's alpha, as player may lose the powerup while holding the buff
                        else
                                player.buff_invisible_prev_alpha = player.alpha;
@@ -963,7 +964,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
 
                BUFF_ONREM(BUFF_INVISIBLE)
                {
-                       if(time < player.strength_finished && MUTATOR_IS_ENABLED(mutator_instagib))
+                       if(time < STAT(STRENGTH_FINISHED, player) && MUTATOR_IS_ENABLED(mutator_instagib))
                                player.alpha = autocvar_g_instagib_invis_alpha;
                        else
                                player.alpha = player.buff_invisible_prev_alpha;