]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Player templates: Better instagib support.
authorLyberta <lyberta@lyberta.net>
Thu, 5 Oct 2017 18:53:18 +0000 (21:53 +0300)
committerLyberta <lyberta@lyberta.net>
Thu, 5 Oct 2017 18:53:18 +0000 (21:53 +0300)
player-template-example.cfg
qcsrc/server/playertemplates.qc

index e9fe45cfd6e2c52191c89e694d22bb7c566f8d06..679725581cc3366337f7793f55093b6376c342c4 100644 (file)
@@ -27,6 +27,8 @@ set g_player_template_example_random_start_bullets "default" "How much bullets d
 set g_player_template_example_random_start_rockets "default" "How much rockets does the player get with random start rocket-based weapon."
 set g_player_template_example_random_start_cells "default" "How much cells does the player get with random start cell-based weapon."
 set g_player_template_example_random_start_plasma "default" "How much plasma does the player get with random start cell-based weapon."
+set g_player_template_example_start_extra_lives "default" "How many extra lives does the player get during spawn in instagib."
+set g_player_template_example_start_ammo_vaporizer_cells "default" "How many vaporizer cells does the player get during spawn in instagib."
 
 set g_player_template_example_drop_weapons "default" "Whether the player can drop weapons by throwing them or by dying."
 
index 0b67eb611f1b713f2a35641018fc4b2d9244767e..7528df13b814e9c170490b6006b69a69d52442ba 100644 (file)
@@ -80,6 +80,10 @@ string PlayerTemplate_GetDefaultCvarName(string variable)
                {
                        return "g_random_start_plasma";
                }
+               case "start_ammo_vaporizer_cells":
+               {
+                       return "g_instagib_ammo_start";
+               }
                case "drop_weapons":
                {
                        return "g_weapon_throwable";
@@ -134,6 +138,7 @@ float PlayerTemplate_GetDefaultFloatValue(string variable)
                case "random_start_rockets":
                case "random_start_cells":
                case "random_start_plasma":
+               case "start_ammo_vaporizer_cells":
                case "drop_weapons":
                case "health_regen_factor":
                case "health_regen_linear":
@@ -152,6 +157,10 @@ float PlayerTemplate_GetDefaultFloatValue(string variable)
                {
                        return 1;
                }
+               case "start_extra_lives":
+               {
+                       return 0;
+               }
                case "attack_scale":
                case "defense_scale":
                {
@@ -310,6 +319,19 @@ void PlayerTemplateHook_PlayerSpawn(entity player, string template)
        {
                return;
        }
+       if (autocvar_g_instagib)
+       {
+               SetResourceAmount(player, RESOURCE_ARMOR,
+                       PlayerTemplate_GetFloatValue(template, "start_extra_lives"));
+               SetResourceAmount(player, RESOURCE_CELLS,
+                       PlayerTemplate_GetFloatValue(template,
+                       "start_ammo_vaporizer_cells"));
+               if (PlayerTemplate_GetFloatValue(template, "unlimited_ammo"))
+               {
+                       player.items |= IT_UNLIMITED_AMMO;
+               }
+               return;
+       }
        // Give health, armor and ammo.
        SetResourceAmount(player, RESOURCE_HEALTH,
                PlayerTemplate_GetFloatValue(template, "start_health"));
@@ -334,10 +356,6 @@ void PlayerTemplateHook_PlayerSpawn(entity player, string template)
                SetResourceAmount(player, RESOURCE_FUEL,
                        PlayerTemplate_GetFloatValue(template, "start_ammo_fuel"));
        }
-       if (autocvar_g_instagib == 1)
-       {
-               return;
-       }
        // Give weapons.
        if (PlayerTemplate_GetFloatValue(template, "default_start_weapons"))
        {