From a335c68a6c7f748d22aec37e7ab42afb9db7f027 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Thu, 17 May 2018 12:14:56 +0300 Subject: [PATCH] Player templates: better formatting. --- qcsrc/server/playertemplates.qc | 38 ++++++++++++++++----------------- qcsrc/server/playertemplates.qh | 12 +++++------ 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/qcsrc/server/playertemplates.qc b/qcsrc/server/playertemplates.qc index 3b04d2c60..8322d8b06 100644 --- a/qcsrc/server/playertemplates.qc +++ b/qcsrc/server/playertemplates.qc @@ -10,11 +10,11 @@ #include "resources.qh" #include "mutators/events.qh" -const string playertemplate_cvar_prefix = "g_player_template_"; +const string player_template_cvar_prefix = "g_player_template_"; string PlayerTemplate_GetFullCvarName(string template, string variable) { - return strcat(playertemplate_cvar_prefix, template, "_", variable); + return strcat(player_template_cvar_prefix, template, "_", variable); } string PlayerTemplate_GetDefaultCvarName(string variable) @@ -205,16 +205,16 @@ float PlayerTemplate_GetFloatValue(string template, string variable) { return PlayerTemplate_GetDefaultFloatValue(variable); } - string fullname = PlayerTemplate_GetFullCvarName(template, variable); - if (!(cvar_type(fullname) & CVAR_TYPEFLAG_EXISTS)) + string full_name = PlayerTemplate_GetFullCvarName(template, variable); + if (!(cvar_type(full_name) & CVAR_TYPEFLAG_EXISTS)) { return PlayerTemplate_GetDefaultFloatValue(variable); } - if (cvar_string(fullname) == "default") + if (cvar_string(full_name) == "default") { return PlayerTemplate_GetDefaultFloatValue(variable); } - return cvar(fullname); + return cvar(full_name); } string PlayerTemplate_GetStringValue(string template, string variable) @@ -223,16 +223,16 @@ string PlayerTemplate_GetStringValue(string template, string variable) { return PlayerTemplate_GetDefaultStringValue(variable); } - string fullname = PlayerTemplate_GetFullCvarName(template, variable); - if (!(cvar_type(fullname) & CVAR_TYPEFLAG_EXISTS)) + string full_name = PlayerTemplate_GetFullCvarName(template, variable); + if (!(cvar_type(full_name) & CVAR_TYPEFLAG_EXISTS)) { return PlayerTemplate_GetDefaultStringValue(variable); } - if (cvar_string(fullname) == "default") + if (cvar_string(full_name) == "default") { return PlayerTemplate_GetDefaultStringValue(variable); } - return cvar_string(fullname); + return cvar_string(full_name); } float PlayerTemplate_GivePlayerItem(entity player, string template, @@ -243,13 +243,13 @@ float PlayerTemplate_GivePlayerItem(entity player, string template, { return MUT_ITEMTOUCH_CONTINUE; } - int numfields = tokenize_console(PlayerTemplate_GetStringValue(template, + int num_fields = tokenize_console(PlayerTemplate_GetStringValue(template, variable)); - if (numfields == 0) + if (num_fields == 0) { return MUT_ITEMTOUCH_CONTINUE; } - for (int i = 1; i < numfields; ++i) + for (int i = 1; i < num_fields; ++i) { switch (i) { @@ -692,21 +692,21 @@ float PlayerTemplateHook_ItemTouch(entity player, entity item, string template) } float PlayerTemplateHook_Damage_Calculate(entity attacker, - string attackertemplate, entity victim, string victimtemplate, - float deathtype, float damage) + string attacker_template, entity victim, string victim_template, + float death_type, float damage) { if (autocvar_g_instagib == 1) { return damage; } - if ((attacker == victim) && (DEATH_ISWEAPON(deathtype, WEP_BLASTER)) && - (PlayerTemplate_GetFloatValue(victimtemplate, "blaster_self_damage") == + if ((attacker == victim) && (DEATH_ISWEAPON(death_type, WEP_BLASTER)) && + (PlayerTemplate_GetFloatValue(victim_template, "blaster_self_damage") == 0)) { return 0; } - damage *= PlayerTemplate_GetFloatValue(attackertemplate, "attack_scale"); - damage /= PlayerTemplate_GetFloatValue(victimtemplate, "defense_scale"); + damage *= PlayerTemplate_GetFloatValue(attacker_template, "attack_scale"); + damage /= PlayerTemplate_GetFloatValue(victim_template, "defense_scale"); return damage; } diff --git a/qcsrc/server/playertemplates.qh b/qcsrc/server/playertemplates.qh index d9ecb7acd..1cf87e384 100644 --- a/qcsrc/server/playertemplates.qh +++ b/qcsrc/server/playertemplates.qh @@ -53,7 +53,6 @@ float PlayerTemplate_GivePlayerItem(entity player, string template, /// \brief Setups the player during spawn according to the given template. /// \param[in,out] player Player to setup. /// \param[in] template Name of the template. -/// \return No return. void PlayerTemplateHook_PlayerSpawn(entity player, string template); /// \brief Forbids weapon dropping according to the given template. @@ -76,20 +75,19 @@ float PlayerTemplateHook_ItemTouch(entity player, entity item, string template); /// \brief Changes the damage done using templates' attack and defense scales. /// \param[in] attacke Attacker entity. -/// \param[in] attackertemplate Template of the attacker. +/// \param[in] attacker_template Template of the attacker. /// \param[in] victim Victim entity. -/// \param[in] victimtemplate Template of the victim. -/// \param[in] deathtype Type of the damage. +/// \param[in] victim_template Template of the victim. +/// \param[in] death_type Type of the damage. /// \param[in] damage Damage to adjust. /// \return Adjusted damage. float PlayerTemplateHook_Damage_Calculate(entity attacker, - string attackertemplate, entity victim, string victimtemplate, - float deathtype, float damage); + string attacker_template, entity victim, string victim_template, + float death_type, float damage); /// \brief Strips the player of their weapons if the player is not allowed to /// drop them. /// \param[in,out] player Player to work with. /// \param[in] template Name of the template. -/// \return No return. /// \note You must hook with CBC_ORDER_FIRST in order for this to be effective. void PlayerTemplateHook_PlayerDies(entity player, string template); -- 2.39.2