From: Lyberta Date: Wed, 30 Aug 2017 05:07:32 +0000 (+0300) Subject: Merge branch 'Lyberta/URS2' into Lyberta/RandomStartWeapons X-Git-Tag: xonotic-v0.8.5~2459^2~10 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=d032c6d2d46fb6f1eab6329e75fe9f2330a42597;hp=3369a05c91e8508a103a5ecadc37fd6520f71bf9 Merge branch 'Lyberta/URS2' into Lyberta/RandomStartWeapons --- diff --git a/qcsrc/Makefile b/qcsrc/Makefile index bd17dad6aa..bfea08b5f9 100644 --- a/qcsrc/Makefile +++ b/qcsrc/Makefile @@ -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 diff --git a/qcsrc/client/defs.qh b/qcsrc/client/defs.qh index d36994ec3d..9a5335eff0 100644 --- a/qcsrc/client/defs.qh +++ b/qcsrc/client/defs.qh @@ -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 diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 7038f01ff8..e039a96b95 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc index 53042b8ef2..bafe8c4607 100644 --- a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc @@ -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, { diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index d667c0cbf4..0c446952d0 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -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 ) { diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index ba168fd6f5..454965ed65 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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; } diff --git a/qcsrc/server/resources.qc b/qcsrc/server/resources.qc index 6526e2f11d..c5bbe75e1e 100644 --- a/qcsrc/server/resources.qc +++ b/qcsrc/server/resources.qc @@ -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) diff --git a/qcsrc/server/resources.qh b/qcsrc/server/resources.qh index 97f49485d9..522ff5b68d 100644 --- a/qcsrc/server/resources.qh +++ b/qcsrc/server/resources.qh @@ -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.