Skip to content

Commit

Permalink
Merge pull request #31 from Giferns/model_v
Browse files Browse the repository at this point in the history
Model v
  • Loading branch information
Giferns committed Sep 11, 2024
2 parents 7c24ce2 + a4057eb commit bb4ed18
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 28 deletions.
3 changes: 2 additions & 1 deletion addons/amxmodx/configs/plugins-rt.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ rt_restrictions.amxx
rt_timer.amxx
rt_effects.amxx
rt_sounds.amxx
rt_bonus.amxx
rt_bonus.amxx
rt_revive_model.amxx
7 changes: 7 additions & 0 deletions addons/amxmodx/configs/rt_configs/rt_revive_model.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Использовать указанную v_ модель для подмены модели оружия возрождающего игрока
// Задайте значение пустым, т.е. "" чтобы отключить модель.
// При использовании модели рекомендуется установить в rt_restrictions.cfg квар rt_no_move "1", а так же
// уменьшить значение rt_search_radius до "48".
//
// Default: "models/rt/v_kit_sp.mdl"
rt_revive_model_v "models/rt/v_kit_sp.mdl"
61 changes: 36 additions & 25 deletions addons/amxmodx/scripting/include/rt_api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif
#define _rt_api_included

public stock const VERSION[] = "2.2.12";
public stock const VERSION[] = "2.3.14";
public stock const AUTHORS[] = "DEV-CS.RU Community";

/**
Expand Down Expand Up @@ -54,7 +54,7 @@ enum Modes {
new const DEAD_BODY_CLASSNAME[] = "rt_corpse_empty";

/**
* Called after the activator starts resurrection/planting (on press USE - `E`)
* [PRE] Called after the activator starts resurrection/planting (on press USE - `E`)
*
* @param iEnt Corpse entity index
* @param iPlayer Player id who can be ressurected
Expand All @@ -66,6 +66,20 @@ new const DEAD_BODY_CLASSNAME[] = "rt_corpse_empty";
*/
forward rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:eMode);

/**
* [POST] Called after the activator starts resurrection/planting (on press USE - `E`)
*
* @note This forward will not be called if something was blocked attempt in rt_revive_start()
*
* @param iEnt Corpse entity index
* @param iPlayer Player id who can be ressurected
* @param iActivator Player id who ressurect
* @param eMode MODE_REVIVE - started the resurrection, MODE_PLANT - started planting
*
* @noreturn
*/
forward rt_revive_start_post(const iEnt, const iPlayer, const iActivator, const Modes:eMode);

/**
* PreThink on resurrection/planting
*
Expand Down Expand Up @@ -143,6 +157,26 @@ forward rt_creating_corpse_start(const iEnt, const iPlayer);
*/
forward rt_creating_corpse_end(const iEnt, const iPlayer, const Float:fVecOrigin[3]);

/**
* Returns current user mode
*
* @note In rt_revive_cancelled() and rt_revive_end() always return MODE_NONE
*
* @param iPlayer Client index
*
* @return see 'Modes' enum
*/
native Modes:rt_get_user_mode(iPlayer);

/**
* Will interrupt the current process
*
* @param iPlayer Client index
*
* @return true if success, false otherwise
*/
native bool:rt_reset_use(iPlayer);

/**
* Removal of corpses
*
Expand Down Expand Up @@ -175,29 +209,6 @@ stock RemoveCorpses(const iPlayer = 0, const szClassName[] = DEAD_BODY_CLASSNAME
return iActivator;
}

/**
* Reset entity think
*
* @param eForward Forward type
* @param iEnt Corpse entity index
* @param iPlayer Player id whose corpse
* @param iActivator Player id who ressurect
* @param eMode MODE_REVIVE - stopped the resurrection, MODE_PLANT - stopped planting
*
* @noreturn
*/
stock ResetCorpseThink(const eForward, const iEnt, iPlayer, iActivator, const Modes:eMode) {
if(!is_nullent(iEnt)) {
set_entvar(iEnt, var_nextthink, get_gametime() + 1.0);
set_entvar(iEnt, var_iuser1, 0);
}

iPlayer = is_user_connected(iPlayer) ? iPlayer : RT_NULLENT;
iActivator = is_user_connected(iActivator) ? iActivator : RT_NULLENT;

ExecuteForward(eForward, _, iEnt, iPlayer, iActivator, eMode);
}

/**
* Notifying players in chat
*
Expand Down
85 changes: 84 additions & 1 deletion addons/amxmodx/scripting/rt_core.sma
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ new g_eCvars[CVARS];

enum Forwards {
ReviveStart,
ReviveStart_Post,
ReviveLoop_Pre,
ReviveLoop_Post,
ReviveEnd,
Expand All @@ -41,6 +42,7 @@ new Float:g_fLastUse[MAX_PLAYERS + 1], g_iTimeUntil[MAX_PLAYERS + 1];
new Float:g_fVecSpawnOrigin[3];
new HookChain:g_pHook_GetPlayerSpawnSpot;
new g_szModel[MAX_PLAYERS + 1][64];
new Modes:g_iCurrentMode[MAX_PLAYERS + 1] = { MODE_NONE, ... };

public plugin_precache() {
CreateCvars();
Expand All @@ -63,6 +65,7 @@ public plugin_init() {
RegisterHookChain(RG_CBasePlayer_SetClientUserInfoModel, "CBasePlayer_SetClientUserInfoModel_Pre");

g_eForwards[ReviveStart] = CreateMultiForward("rt_revive_start", ET_STOP, FP_CELL, FP_CELL, FP_CELL, FP_CELL);
g_eForwards[ReviveStart_Post] = CreateMultiForward("rt_revive_start_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL);
g_eForwards[ReviveLoop_Pre] = CreateMultiForward("rt_revive_loop_pre", ET_STOP, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL);
g_eForwards[ReviveLoop_Post] = CreateMultiForward("rt_revive_loop_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL);
g_eForwards[ReviveEnd] = CreateMultiForward("rt_revive_end", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL);
Expand All @@ -79,7 +82,12 @@ public client_disconnected(iPlayer) {
PlayerSpawnOrDisconnect(iPlayer);
}

public client_remove(iPlayer) {
g_iCurrentMode[iPlayer] = MODE_NONE;
}

public CSGameRules_CleanUpMap_Post() {
arrayset(g_iCurrentMode, MODE_NONE, sizeof(g_iCurrentMode));
RemoveCorpses(0, DEAD_BODY_CLASSNAME);
}

Expand Down Expand Up @@ -193,6 +201,10 @@ public Corpse_Use(const iEnt, const iActivator) {
set_entvar(iEnt, var_fuser1, fGameTime + g_eCvars[REVIVE_TIME]);
set_entvar(iEnt, var_fuser3, g_eCvars[REVIVE_TIME]);
set_entvar(iEnt, var_nextthink, fGameTime + 0.1);

g_iCurrentMode[iActivator] = eCurrentMode;

ExecuteForward(g_eForwards[ReviveStart_Post], _, iEnt, iPlayer, iActivator, eCurrentMode);
}

public Corpse_Think(const iEnt) {
Expand Down Expand Up @@ -236,7 +248,12 @@ public Corpse_Think(const iEnt) {
g_iTimeUntil[iActivator]++;

if(g_iTimeUntil[iActivator] == 10 || g_eCvars[FORCE_FWD_MODE]) {
fTimeUntil[1] -= 1.0;
if(g_eCvars[FORCE_FWD_MODE]) {
fTimeUntil[1] -= 0.1;
}
else {
fTimeUntil[1] -= 1.0;
}

if(!is_user_alive(iActivator)) {
ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode);
Expand Down Expand Up @@ -276,6 +293,8 @@ public Corpse_Think(const iEnt) {
return;
}

g_iCurrentMode[iActivator] = MODE_NONE;

ExecuteForward(g_eForwards[ReviveEnd], _, iEnt, iPlayer, iActivator, eCurrentMode);

return;
Expand Down Expand Up @@ -387,6 +406,9 @@ stock PlayerSpawnOrDisconnect(const iPlayer) {
NotifyClient(iActivator, print_team_red, "RT_DISCONNECTED");

ResetCorpseThink(g_eForwards[ReviveCancelled], RT_NULLENT, iPlayer, iActivator, MODE_NONE);

// TODO need to handle corpse user respawn
//if(g_iCurrentMode[iPlayer]) { }
}

public CreateCvars() {
Expand Down Expand Up @@ -439,8 +461,69 @@ public CreateCvars() {
);
}

/**
* Reset entity think
*
* @param eForward Forward type
* @param iEnt Corpse entity index
* @param iPlayer Player id whose corpse
* @param iActivator Player id who ressurect
* @param eMode MODE_REVIVE - stopped the resurrection, MODE_PLANT - stopped planting
*
* @noreturn
*/
ResetCorpseThink(const eForward, const iEnt, iPlayer, iActivator, const Modes:eMode) {
if(!is_nullent(iEnt)) {
set_entvar(iEnt, var_nextthink, get_gametime() + 1.0);
set_entvar(iEnt, var_iuser1, 0);
}

if(iActivator != RT_NULLENT) {
g_iCurrentMode[iActivator] = MODE_NONE;
}

iPlayer = is_user_connected(iPlayer) ? iPlayer : RT_NULLENT;
iActivator = is_user_connected(iActivator) ? iActivator : RT_NULLENT;

ExecuteForward(eForward, _, iEnt, iPlayer, iActivator, eMode);
}

public plugin_natives() {
set_native_filter("native_filter");
register_native("rt_get_user_mode", "_rt_get_user_mode");
register_native("rt_reset_use", "_rt_reset_use");
}

public Modes:_rt_get_user_mode() {
enum { arg_user = 1 };

return g_iCurrentMode[ get_param(arg_user) ];
}

public bool:_rt_reset_use() {
enum { arg_user = 1 };

new pPlayer = get_param(arg_user);

if(g_iCurrentMode[pPlayer] == MODE_NONE) {
return false;
}

new iEnt = RT_NULLENT;

while((iEnt = rg_find_ent_by_class(iEnt, DEAD_BODY_CLASSNAME)) > 0) {
if(!is_entity(iEnt)) {
continue;
}

if(pPlayer == get_entvar(iEnt, var_iuser1)) {
ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, get_entvar(iEnt, var_owner), pPlayer, get_entvar(iEnt, var_iuser2));
return true;
}
}

g_iCurrentMode[pPlayer] = MODE_NONE;
return false;
}

public native_filter(const szNativeName[], iNativeID, iTrapMode) {
Expand Down
4 changes: 3 additions & 1 deletion addons/amxmodx/scripting/rt_effects.sma
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ public rt_creating_corpse_end(const iEnt, const iPlayer, const Float:fVecOrigin[
}

public CorpseSprite_Think(const iEnt) {
if(is_nullent(get_entvar(iEnt, var_iuser1))) {
new iHostEnt = get_entvar(iEnt, var_iuser1);

if(is_nullent(iHostEnt) || !FClassnameIs(iHostEnt, DEAD_BODY_CLASSNAME)) {
RemoveCorpses(get_entvar(iEnt, var_owner), CORPSE_SPRITE_CLASSNAME);
return;
}
Expand Down
Loading

0 comments on commit bb4ed18

Please sign in to comment.