]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'Lyberta/URS2' into Lyberta/RandomStartWeapons
authorLyberta <lyberta@lyberta.net>
Wed, 30 Aug 2017 05:07:32 +0000 (08:07 +0300)
committerLyberta <lyberta@lyberta.net>
Wed, 30 Aug 2017 05:07:32 +0000 (08:07 +0300)
qcsrc/Makefile
qcsrc/client/defs.qh
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/t_items.qc
qcsrc/server/resources.qc
qcsrc/server/resources.qh

index bd17dad6aaf5e93c0c729891009cfedfa85ca258..bfea08b5f92df070fbcc59269b5ec65ed7bb3162 100644 (file)
@@ -14,17 +14,17 @@ ENABLE_DEBUGTRACE ?= 0
 BUILD_MOD ?=
 
 ifndef ZIP
-       ifneq ($(shell which zip),)
+       ifneq ($(shell which zip 2>/dev/null),)
                ZIP := zip -9
        endif
-       ifneq ($(shell which 7z),)
+       ifneq ($(shell which 7z 2>/dev/null),)
                ZIP := 7z a -tzip -mx=9
        endif
-       ifneq ($(shell which 7za),)
+       ifneq ($(shell which 7za 2>/dev/null),)
                ZIP := 7za a -tzip -mx=9
        endif
     ifndef ZIP
-        $(warning "No zip in ($(PATH))")
+        $(warning "No zip / 7z / 7za in ($(PATH))")
         ZIP := : zip_not_found
     endif
 endif
index d36994ec3d2e69bbc6849d82eaf3272686c01949..9a5335eff06b7c4ca56a73b17d3324b2a2b9618e 100644 (file)
@@ -74,6 +74,9 @@ float race_myrank;
 float nb_pb_period;
 
 // Spectating
+// -1 - observing
+// 0 - playing
+// >0 - id of spectated player
 float spectatee_status;
 
 // short mapname
index 7038f01ff85ed0a15c8478fbc913c206580eb91d..e039a96b9501a9e99900884377b625fcab16861c 100644 (file)
@@ -542,10 +542,15 @@ MUTATOR_HOOKFUNCTION(buffs, Damage_Calculate)
        if(frag_target.takedamage)
        if(DIFF_TEAM(frag_attacker, frag_target))
        {
-               float hp = GetResourceAmount(frag_attacker, RESOURCE_HEALTH);
-               SetResourceAmount(frag_attacker, RESOURCE_HEALTH, bound(0, hp + bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal, GetResourceAmount(frag_target, RESOURCE_HEALTH)), g_pickup_healthsmall_max));
-               if(frag_target.armorvalue)
-                       frag_attacker.armorvalue = bound(0, frag_attacker.armorvalue + bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal, frag_target.armorvalue), g_pickup_armorsmall_max);
+               float amount = bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal,
+                       GetResourceAmount(frag_target, RESOURCE_HEALTH));
+               GiveResourceWithLimit(frag_attacker, RESOURCE_HEALTH, amount, g_pickup_healthsmall_max);
+               if (frag_target.armorvalue)
+               {
+                       amount = bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal,
+                               GetResourceAmount(frag_target, RESOURCE_ARMOR));
+                       GiveResourceWithLimit(frag_attacker, RESOURCE_ARMOR, amount, g_pickup_armorsmall_max);
+               }
        }
 
        M_ARGV(4, float) = frag_damage;
index 53042b8ef2779199c1a8412c138eacc2ab9c59bf..bafe8c460733dae6c492706f8a8b6eb0fb405567 100644 (file)
@@ -232,7 +232,11 @@ NET_HANDLE(damagetext, bool isNew)
             }
         }
         make_impure(NEW(DamageText, server_entity_index, entcs.origin, false, health, armor, potential_damage, deathtype, friendlyfire));
-    } else if (autocvar_cl_damagetext_2d) {
+    } else if (autocvar_cl_damagetext_2d && spectatee_status != -1) {
+        // never show 2d damagetext when observing
+        // on some maps (hearth_v2, The_Yard), sometimes has_origin is false even though observers should know about all players
+        // it happens mostly with bots but occasionally also with players
+
         // screen coords only
         vector screen_pos = vec2(vid_conwidth * autocvar_cl_damagetext_2d_pos.x, vid_conheight * autocvar_cl_damagetext_2d_pos.y);
         IL_EACH(g_drawables_2d, it.instanceOfDamageText && it.m_screen_coords && it.m_group == server_entity_index, {
index d667c0cbf42a80a85b36498812bc2d048618914b..0c446952d033a60d14a52f83c4c2784cb1eaaf00 100644 (file)
@@ -626,11 +626,12 @@ void nade_heal_touch(entity this, entity toucher)
                        float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
                        if (hp < maxhealth)
                        {
-                               if ( this.nade_show_particles )
+                               if (this.nade_show_particles)
+                               {
                                        Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
-                               SetResourceAmount(toucher, RESOURCE_HEALTH, min(hp + health_factor, maxhealth));
+                               }
+                               GiveResourceWithLimit(toucher, RESOURCE_HEALTH, health_factor, maxhealth);
                        }
-                       toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
                }
                else if ( health_factor < 0 )
                {
index ba168fd6f51f64573f3cb10f7c8143f3dab27044..454965ed658e67f515f85226ecdd88a6b344fb71 100644 (file)
@@ -776,22 +776,14 @@ float Item_GiveAmmoTo(entity item, entity player, int resource_type, float ammom
                {
                        return false;
                }
-               if ((player_amount + amount) > ammomax)
-               {
-                       amount = ammomax - player_amount;
-               }
-               GiveResource(player, resource_type, amount);
+               GiveResourceWithLimit(player, resource_type, amount, ammomax);
                return true;
        }
        if (g_weapon_stay != 2)
        {
                return false;
        }
-       float mi = min(amount, ammomax);
-       if (player_amount < mi)
-       {
-               GiveResource(player, resource_type, mi - player_amount);
-       }
+       GiveResourceWithLimit(player, resource_type, amount, min(amount, ammomax));
        return true;
 }
 
index 6526e2f11d262f80dd888a66d6bfbad60a904d60..c5bbe75e1e4382d259da687c53946b2e445eb530 100644 (file)
@@ -141,6 +141,21 @@ void GiveResource(entity receiver, int resource_type, float amount)
        }
 }
 
+void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
+       float limit)
+{
+       if (amount == 0)
+       {
+               return;
+       }
+       float current_amount = GetResourceAmount(receiver, resource_type);
+       if (current_amount + amount > limit)
+       {
+               amount = limit - current_amount;
+       }
+       GiveResource(receiver, resource_type, amount);
+}
+
 int GetResourceType(.float resource_field)
 {
        switch (resource_field)
index 97f49485d90d99bb01cbb1fc6d05b772f0caeed1..522ff5b68d5ad4dd7ed52825689f328c9825da72 100644 (file)
@@ -49,6 +49,15 @@ void SetResourceAmount(entity e, int resource_type, float amount);
 /// \return No return.
 void GiveResource(entity receiver, int resource_type, float amount);
 
+/// \brief Gives an entity some resource but not more than a limit.
+/// \param[in,out] receiver Entity to give resource to.
+/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] amount Amount of resource to give.
+/// \param[in] limit Limit of resources to give.
+/// \return No return.
+void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
+       float limit);
+
 // ===================== Legacy and/or internal API ===========================
 
 /// \brief Converts an entity field to resource type.