Skip to content

Commit

Permalink
Merge pull request #17 from Giferns/patch-1
Browse files Browse the repository at this point in the history
Models from constants to cvars
  • Loading branch information
Giferns authored Sep 30, 2024
2 parents 2afefc2 + da41396 commit 63ab222
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 13 deletions.
111 changes: 111 additions & 0 deletions amxmodx/configs/plugins/HealthNade.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Cvars for plugin "[ReAPI] Healthnade" by "DEV-CS.RU Community" (reapi_healthnade.amxx)

// Grenade explosion radius.
// -
// Default: "300.0"
// Minimum: "1.000000"
HealthNade_ExplodeRadius "300.0"

// The amount of HP restored from a grenade explosion.
// -
// Default: "20.0"
HealthNade_ThrowHealingAmount "20.0"

// The number of HP replenished from the grenade explosion. (For players with an access flag)
// -
// Default: "40.0"
HealthNade_ThrowHealingAmount_With_Flags "40.0"

// The amount of HP restored from a grenade drinking.
// -
// Default: "35.0"
HealthNade_DrinkHealingAmount "35.0"

// The number of HP replenished from drinking a grenade. (For players with an access flag)
// -
// Default: "60.0"
HealthNade_DrinkHealingAmount_With_Flags "60.0"

// How many grenades to give out at spawn.
// -
// Default: "1"
HealthNade_Give "1"

// Access flags for giving a grenade when spawn. Leave blank to share with everyone.
// -
// Default: "t"
HealthNade_Give_AccessFlags "t"

// An access flag for changing health replenishment from a grenade explosion.
// -
// Default: "t"
HealthNade_Override_AccessFlags "t"

// Access flags for drinkability.
// -
// Default: "t"
HealthNade_Drink_AccessFlags "t"

// From which round will the grenade be given.
// -
// Default: "1"
// Minimum: "1.000000"
HealthNade_Give_MinRound "1"

// Equip delay (in seconds)
// -
// Default: "0.0"
// Minimum: "0.000000"
HealthNade_EquipDelay "0.0"

// Replace smoke grenade?
// -
// Default: "0.0"
// Minimum: "0.000000"
// Maximum: "1.000000"
HealthNade_ReplaceSmokegren "0.0"

// Show a tooltip for using a grenade.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
HealthNade_Msg_UsageHint "1"

// Show message when trying to heal with full HP.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
HealthNade_Msg_FullHp "1"

// Drop type
// 0 - off | 1 - on | 2 - allow cvar `mp_nade drops`
// -
// Default: "2"
// Minimum: "0.000000"
// Maximum: "2.000000"
HealthNade_NadeDrop "2"

// Number of the slot in which the grenade will be (1-5).
// -
// Default: "4"
// Minimum: "1.000000"
// Maximum: "5.000000"
HealthNade_SlotId "4"

// 1st person model (v_)
// -
// Default: "models/reapi_healthnade/v_drink9.mdl"
HealthNade_ViewModel "models/reapi_healthnade/v_drink9.mdl"

// 3rd person model (p_)
// -
// Default: "models/reapi_healthnade/p_healthnade.mdl"
HealthNade_PlayerModel "models/reapi_healthnade/p_healthnade.mdl"

// World model (w_)
// -
// Default: "models/reapi_healthnade/w_healthnade.mdl"
HealthNade_WorldModel "models/reapi_healthnade/w_healthnade.mdl"

50 changes: 37 additions & 13 deletions amxmodx/scripting/reapi_healthnade.sma
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@
give_healthnade %id% кол-во
0.0.19f (12.09.2024)
* Исправление положения функции srvcmd_GiveHealthnade
0.0.20f (30.09.2024)
* Конфиг переведён на константный (больше не создаётся автоматически)
* Пути к моделям переведены с констант на квары
*/

new const PLUGIN_VERSION[] = "0.0.19f";
new const PLUGIN_VERSION[] = "0.0.20f";

#pragma semicolon 1

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <reapi>
Expand Down Expand Up @@ -104,10 +108,14 @@ enum E_Cvars {
bool:Cvar_Msg_UsageHint,
E_NadeDropType:Cvar_NadeDrop,
InventorySlotType:Cvar_SlotId,
Cvar_ViewModel[96],
Cvar_PlayerModel[96],
Cvar_WorldModel[96]
}
new gCvars[E_Cvars];
#define Cvar(%1) gCvars[Cvar_%1]

new const CFG_FILENAME[] = "plugins/HealthNade.cfg"; // comment to disable .cfg loading
new const DICTIONARY_FILENAME[] = "HealthNade.ini";

#define LangS(%1) fmt("%l", %1)
Expand All @@ -123,9 +131,6 @@ new const GRENADE_CLASSNAME[] = "healthnade";
const AMMO_ID = 16;
const InventorySlotType:ITEM_SLOT = GRENADE_SLOT;

new const VIEWMODEL[] = "models/reapi_healthnade/v_drink9.mdl";
new const WEAPONMODEL[] = "models/reapi_healthnade/p_healthnade.mdl";
new const WORLDMODEL[] = "models/reapi_healthnade/w_healthnade.mdl";
new const SOUND_PULLPIN[] = "weapons/holywater_pinpul.wav";
new const SOUND_DEPLOY[] = "weapons/holywater_deploy.wav";
new const SOUND_DRINK[] = "weapons/holywater_drink.wav";
Expand All @@ -150,13 +155,19 @@ public plugin_precache() {
register_dictionary(DICTIONARY_FILENAME);

InitCvars();
#if defined CFG_FILENAME
new szPath[240];
get_configsdir(szPath, charsmax(szPath));
server_cmd("exec %s/%s", szPath, CFG_FILENAME);
server_exec();
#endif

precache_generic("sprites/reapi_healthnade/weapon_healthnade.txt");
precache_generic("sprites/reapi_healthnade/640hud128.spr");

precache_model(VIEWMODEL);
precache_model(WEAPONMODEL);
precache_model(WORLDMODEL);
precache_model(Cvar(ViewModel));
precache_model(Cvar(PlayerModel));
precache_model(Cvar(WorldModel));

precache_sound(SOUND_PULLPIN);
precache_sound(SOUND_DEPLOY);
Expand Down Expand Up @@ -352,7 +363,7 @@ public CBasePlayer_Killed_Pre(const id) {
engfunc(EngFunc_SetOrigin, eEnt, fOrigin);
set_entvar(eEnt, var_movetype, MOVETYPE_TOSS);
set_entvar(eEnt, var_solid, SOLID_TRIGGER);
engfunc(EngFunc_SetModel, eEnt, WORLDMODEL);
engfunc(EngFunc_SetModel, eEnt, Cvar(WorldModel));
engfunc(EngFunc_SetSize, eEnt, Float:{-6.0, -6.0, -1.0}, Float:{6.0, 6.0, 1.0});

set_entvar(eEnt, var_velocity, fVelocity);
Expand Down Expand Up @@ -437,8 +448,8 @@ public CBasePlayerWeapon_DefaultDeploy_Pre(const item, const szViewModel[], cons
new UserId = get_member(item, m_pPlayer);

if (FClassnameIs(item, ITEM_CLASSNAME)) {
SetHookChainArg(2, ATYPE_STRING, VIEWMODEL);
SetHookChainArg(3, ATYPE_STRING, WEAPONMODEL);
SetHookChainArg(2, ATYPE_STRING, Cvar(ViewModel));
SetHookChainArg(3, ATYPE_STRING, Cvar(PlayerModel));

if (Cvar(Msg_UsageHint)) {
client_print(UserId, print_center, "%L", UserId, "HEALTHNADE_USAGE_HINT");
Expand Down Expand Up @@ -756,7 +767,7 @@ throwNade(const id, const item, const Float:vecSrc[3], const Float:vecThrow[3],
set_entvar(grenade, var_framerate, 1.0);
set_entvar(grenade, var_gravity, 0.5);
set_entvar(grenade, var_friction, 0.8);
engfunc(EngFunc_SetModel, grenade, WORLDMODEL);
engfunc(EngFunc_SetModel, grenade, Cvar(WorldModel));

copy_entvar(item, grenade, var_HealthNade_Radius);
copy_entvar(item, grenade, var_HealthNade_ThrowHealingAmount);
Expand Down Expand Up @@ -908,8 +919,21 @@ InitCvars() {
LangS("HEALTHNADE_CVAR_SLOT_ID"),
true, 1.0, true, 5.0
), Cvar(SlotId));

AutoExecConfig(true, "HealthNade");

bind_pcvar_string(create_cvar(
"HealthNade_ViewModel", "", FCVAR_NONE,
"1st person model (v_)"
), Cvar(ViewModel), charsmax(Cvar(ViewModel)));

bind_pcvar_string(create_cvar(
"HealthNade_PlayerModel", "", FCVAR_NONE,
"3rd person model (p_)"
), Cvar(PlayerModel), charsmax(Cvar(PlayerModel)));

bind_pcvar_string(create_cvar(
"HealthNade_WorldModel", "", FCVAR_NONE,
"World model (w_)"
), Cvar(WorldModel), charsmax(Cvar(WorldModel)));

bind_pcvar_num(get_cvar_pointer("mp_nadedrops"), g_iCvarNadeDrops);
}
Expand Down

0 comments on commit 63ab222

Please sign in to comment.