]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Survival: Use player templates for weapon dropping.
authorLyberta <lyberta@lyberta.net>
Tue, 22 Aug 2017 21:56:09 +0000 (00:56 +0300)
committerLyberta <lyberta@lyberta.net>
Tue, 22 Aug 2017 21:56:09 +0000 (00:56 +0300)
qcsrc/server/mutators/mutator/gamemode_survival.qc
survival.cfg

index 31867f7693cebac2b53da9a2191d0ad6c276d82c..09c0ba85277d36e3f265350bc9273580eb420404 100644 (file)
@@ -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;
index 700eae498af60065cefa09f23846fc7257a13943..1b0fd9237e14d2b3798bd71b56a56f2412babab5 100644 (file)
@@ -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"