From: Lyberta Date: Sun, 30 Jul 2017 05:04:20 +0000 (+0300) Subject: Player templates: Added health regeneration. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6e11f52aa2a35bdf148e9ea9698bb2c9e881f317;p=xonotic%2Fxonotic-data.pk3dir.git Player templates: Added health regeneration. --- diff --git a/qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qc b/qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qc index eda6b8683b..a375d82af8 100644 --- a/qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qc +++ b/qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qc @@ -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") diff --git a/qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qh b/qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qh index 3242690cb0..5d93700acc 100644 --- a/qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qh +++ b/qcsrc/common/mutators/mutator/playertemplates/sv_playertemplates.qh @@ -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.