]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Player templates: Added health regeneration.
authorLyberta <lyberta@lyberta.net>
Sun, 30 Jul 2017 05:04:20 +0000 (08:04 +0300)
committerLyberta <lyberta@lyberta.net>
Sun, 30 Jul 2017 05:04:20 +0000 (08:04 +0300)
qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qc
qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qh

index eda6b8683bd5d9bd4a37c1ba2637ea7d67f129da..a375d82af89b9567663833ea41055958f5fa5931 100644 (file)
@@ -47,6 +47,30 @@ string PlayerTemplate_GetDefaultCvarName(string variable)
                {
                        return "g_start_ammo_fuel";
                }
+               case "health_regen_factor":
+               {
+                       return "g_balance_health_regen";
+               }
+               case "health_regen_linear":
+               {
+                       return "g_balance_health_regenlinear";
+               }
+               case "health_rot_factor":
+               {
+                       return "g_balance_health_rot";
+               }
+               case "health_rot_linear":
+               {
+                       return "g_balance_health_rotlinear";
+               }
+               case "health_regen_stable":
+               {
+                       return "g_balance_health_regenstable";
+               }
+               case "health_rot_stable":
+               {
+                       return "g_balance_health_rotstable";
+               }
                default:
                {
                        // TODO: Report error.
@@ -67,6 +91,12 @@ float PlayerTemplate_GetDefaultFloatValue(string variable)
                case "start_ammo_cells":
                case "start_ammo_plasma":
                case "start_ammo_fuel":
+               case "health_regen_factor":
+               case "health_regen_linear":
+               case "health_rot_factor":
+               case "health_rot_linear":
+               case "health_regen_stable":
+               case "health_rot_stable":
                {
                        return cvar(PlayerTemplate_GetDefaultCvarName(variable));
                }
@@ -317,6 +347,27 @@ void PlayerTemplate_PlayerSpawn(entity player, string template)
        }
 }
 
+float PlayerTemplate_PlayerRegen(entity player, string template)
+{
+       if (template == "default")
+       {
+               return false;
+       }
+       M_ARGV(5, float) = PlayerTemplate_GetFloatValue(template,
+               "health_regen_factor");
+       M_ARGV(6, float) = PlayerTemplate_GetFloatValue(template,
+               "health_regen_linear");
+       M_ARGV(7, float) = PlayerTemplate_GetFloatValue(template,
+               "health_rot_factor");
+       M_ARGV(8, float) = PlayerTemplate_GetFloatValue(template,
+               "health_rot_linear");
+       M_ARGV(9, float) = PlayerTemplate_GetFloatValue(template,
+               "health_regen_stable");
+       M_ARGV(10, float) = PlayerTemplate_GetFloatValue(template,
+               "health_rot_stable");
+       return false;
+}
+
 float PlayerTemplate_ItemTouch(entity player, entity item, string template)
 {
        if (template == "default")
index 3242690cb0f57b75642dff01f4fb204b1c1d4a8c..5d93700accdd4f1f96437fefe39ffe3a67a77529 100644 (file)
@@ -54,6 +54,12 @@ float PlayerTemplate_GivePlayerItem(entity player, string template,
 /// \return No return.
 void PlayerTemplate_PlayerSpawn(entity player, string template);
 
+/// \brief Regenerates player health according to the given template.
+/// \param[in] player Player to regenerate.
+/// \param[in] template Name of the template.
+/// \return Value to pass to mutator hook.
+float PlayerTemplate_PlayerRegen(entity player, string template);
+
 /// \brief Gives player items according to the given template.
 /// \param[in] player Player to give items to.
 /// \param[in] item Item which player has picked up.