From f982d7d13bd0a38d06f4f9d9dcf90adf2606be3e Mon Sep 17 00:00:00 2001 From: Lyberta Date: Wed, 23 Aug 2017 00:56:09 +0300 Subject: [PATCH] Survival: Use player templates for weapon dropping. --- .../mutators/mutator/gamemode_survival.qc | 33 ++++++------------- survival.cfg | 4 +-- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/qcsrc/server/mutators/mutator/gamemode_survival.qc b/qcsrc/server/mutators/mutator/gamemode_survival.qc index 31867f7693..09c0ba8527 100644 --- a/qcsrc/server/mutators/mutator/gamemode_survival.qc +++ b/qcsrc/server/mutators/mutator/gamemode_survival.qc @@ -104,9 +104,6 @@ int autocvar_g_surv_defender_cannon_fodder_frag_rockets; /// \brief How many cells do defenders get when they frag cannon fodder. int autocvar_g_surv_defender_cannon_fodder_frag_cells; -/// \brief Whether defenders drop weapons after death. -int autocvar_g_surv_defender_drop_weapons; - /// \brief A stat that is used to track the time left in the round. .float surv_round_time_stat = _STAT(SURV_ROUND_TIME); /// \brief A stat that is used to track defender team. @@ -1910,6 +1907,14 @@ MUTATOR_HOOKFUNCTION(surv, FixPlayermodel) M_ARGV(0, string) = player.surv_playermodel; } +/// \brief Hook which is called when the player tries to throw their weapon. +MUTATOR_HOOKFUNCTION(surv, ForbidThrowCurrentWeapon) +{ + entity player = M_ARGV(0, entity); + return PlayerTemplate_ForbidThrowCurrentWeapon(player, + Surv_GetPlayerTemplate(player)); +} + /// \brief Hook that is called every frame to determine how player health should /// regenerate. MUTATOR_HOOKFUNCTION(surv, PlayerRegen) @@ -1978,16 +1983,6 @@ MUTATOR_HOOKFUNCTION(surv, ItemTouch) return MUT_ITEMTOUCH_CONTINUE; } -/// \brief Hook which is called when the player tries to throw their weapon. -MUTATOR_HOOKFUNCTION(surv, ForbidThrowCurrentWeapon) -{ - entity player = M_ARGV(0, entity); - if (player.team == surv_defenderteam) - { - return true; - } -} - /// \brief Hook which is called when the damage amount must be determined. MUTATOR_HOOKFUNCTION(surv, Damage_Calculate) { @@ -2042,11 +2037,12 @@ MUTATOR_HOOKFUNCTION(surv, PlayerDamaged) } /// \brief Hook which is called when the player dies. -MUTATOR_HOOKFUNCTION(surv, PlayerDies) +MUTATOR_HOOKFUNCTION(surv, PlayerDies, CBC_ORDER_FIRST) { //DebugPrintToChatAll("PlayerDies"); entity attacker = M_ARGV(1, entity); entity victim = M_ARGV(2, entity); + PlayerTemplate_PlayerDies(victim, Surv_GetPlayerTemplate(victim)); if ((attacker.team == surv_defenderteam) && (victim.team == surv_attackerteam)) { @@ -2086,15 +2082,6 @@ MUTATOR_HOOKFUNCTION(surv, PlayerDies) } } } - if ((victim.team == surv_defenderteam) && - (autocvar_g_surv_defender_drop_weapons == false)) - { - for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) - { - .entity went = weaponentities[slot]; - victim.(went).m_weapon = WEP_Null; - } - } if (!Surv_CanPlayerSpawn(victim)) { victim.respawn_flags = RESPAWN_SILENT; diff --git a/survival.cfg b/survival.cfg index 700eae498a..1b0fd9237e 100644 --- a/survival.cfg +++ b/survival.cfg @@ -47,6 +47,8 @@ set g_player_template_surv_cannon_fodder_unlimited_ammo 1 "Whether to give canno set g_player_template_surv_cannon_fodder_random_start_weapons_count 2 "Number of weapons that can be randomly given to cannon fodder during spawn" set g_player_template_surv_cannon_fodder_random_start_weapons "machinegun mortar electro crylink vortex hagar devastator" "Weapons that can be randomly given to cannon fodder during spawn" +set g_player_template_surv_defender_drop_weapons 0 "Whether defenders can drop weapons by throwing them or by dying" + set g_player_template_surv_attacker_pickup_item_shells "add 25 25" "What items do attackers get when they pickup shells" set g_player_template_surv_attacker_pickup_item_bullets "add 25 25" "What items do attackers get when they pickup bullets" set g_player_template_surv_attacker_pickup_item_rockets "add 25 25" "What items do attackers get when they pickup rockets" @@ -119,5 +121,3 @@ set g_surv_defender_cannon_fodder_frag_shells 0 "How many shells do defenders ge set g_surv_defender_cannon_fodder_frag_bullets 0 "How many bullets do defenders get when they frag cannon fodder" set g_surv_defender_cannon_fodder_frag_rockets 0 "How many rockets do defenders get when they frag cannon fodder" set g_surv_defender_cannon_fodder_frag_cells 0 "How many cells do defenders get when they frag cannon fodder" - -set g_surv_defender_drop_weapons 0 "Whether defenders drop weapons after death" -- 2.39.5