diff --git a/publish.gradle b/publish.gradle index 504e7dd..47b0709 100644 --- a/publish.gradle +++ b/publish.gradle @@ -24,7 +24,7 @@ task publishPrepareFiles << { //project.file('publish/publishRoot/reapi/addons/amxmodx/scripting/include').mkdirs() _copyFileToDir('publish/reapi_amxx.dll', 'publish/publishRoot/reapi/addons/amxmodx/modules/') - _copyFileToDir('publish/reapi_amxx.pdb', 'publish/publishRoot/reapi/addons/amxmodx/modules/') + //_copyFileToDir('publish/reapi_amxx.pdb', 'publish/publishRoot/reapi/addons/amxmodx/modules/') _copyFile('publish/libreapi_amxx_i386.so', 'publish/publishRoot/reapi/addons/amxmodx/modules/reapi_amxx_i386.so') copy { diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 9b7a5de..27fbf45 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -403,3 +403,14 @@ native rg_reset_user_model(const index); * */ native rg_transfer_c4(const index, const receiver = 0); + +/* +* Instant reload weapons +* +* @param index Client index +* @param weapon Entity weapons, if 0 then all the weapons +* +* @return 1 if successfully, 0 otherwise +* +*/ +native rg_instant_reload_weapons(const index, const weapon = 0); diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 318c575..ff0c652 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -24,6 +24,7 @@ #define RG_CSGameRules_CheckMapConditions RG_CSGameRules_CheckMapCond #define RG_CSGameRules_CheckWinConditions RG_CSGameRules_CheckWinCond #define RG_CBasePlayer_SetClientUserInfoModel RG_CBasePlayer_SetUserInfoModel + #define RG_CBasePlayer_SetClientUserInfoName RG_CBasePlayer_SetUserInfoName #endif enum AccountSet { AS_SET, AS_ADD }; @@ -361,6 +362,12 @@ enum GamedllFunc_CBasePlayer */ RG_CBasePlayer_SetClientUserInfoModel, + /* + * Description: - + * Params: (const this, infobuffer[], szNewName[]) + */ + RG_CBasePlayer_SetClientUserInfoName, + /* * Description: - * Params: (const this, iPlayerIndex, bool:bSameTeam) diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index a5e4630..21a9d0f 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -30,6 +30,8 @@ #include "regamedll_interfaces.h" #include "hookchains.h" #include "interface.h" +#include "player.h" +#include "gamerules.h" #define REGAMEDLL_API_VERSION_MAJOR 2 #define REGAMEDLL_API_VERSION_MINOR 1 @@ -140,8 +142,8 @@ typedef IVoidHookChain IReGameHook_CBasePlayer_GiveNamedItem; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveNamedItem; // CBasePlayer::AddAccount hook -typedef IVoidHookChain IReGameHook_CBasePlayer_AddAccount; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddAccount; +typedef IVoidHookChain IReGameHook_CBasePlayer_AddAccount; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddAccount; // CBasePlayer::GiveShield hook typedef IVoidHookChain IReGameHook_CBasePlayer_GiveShield; @@ -151,6 +153,9 @@ typedef IVoidHookChainRegistryClass IReGameHookRegistry typedef IVoidHookChain IReGameHook_CBasePlayer_SetClientUserInfoModel; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel; +// CBasePlayer:SetClientUserInfoName hook +typedef IVoidHookChain IReGameHook_CBasePlayer_SetClientUserInfoName; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoName; // CBaseAnimating::ResetSequenceInfo hook typedef IVoidHookChain<> IReGameHook_CBaseAnimating_ResetSequenceInfo; @@ -173,8 +178,8 @@ typedef IVoidHookChain IReGameHookRegistry_RadiusFlash_TraceLine; // RoundEnd hook -typedef IHookChain IReGameHook_RoundEnd; -typedef IHookChainRegistry IReGameHookRegistry_RoundEnd; +typedef IHookChain IReGameHook_RoundEnd; +typedef IHookChainRegistry IReGameHookRegistry_RoundEnd; // CanBuyThis hook typedef IHookChain IReGameHook_CanBuyThis; @@ -373,6 +378,8 @@ public: virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0; virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0; + // later sort them on the positions and change the major version + virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName() = 0; }; struct ReGameFuncs_t { diff --git a/reapi/include/cssdk/dlls/regamedll_interfaces.h b/reapi/include/cssdk/dlls/regamedll_interfaces.h index 5945a10..adbeea0 100644 --- a/reapi/include/cssdk/dlls/regamedll_interfaces.h +++ b/reapi/include/cssdk/dlls/regamedll_interfaces.h @@ -73,7 +73,10 @@ public: virtual void SetProgressBarTime(int time); virtual void SetProgressBarTime2(int time, float timeElapsed); virtual struct edict_s *EntSelectSpawnPoint(); + virtual void SetBombIcon(bool bFlash = false); + virtual void SetScoreAttrib(CBasePlayer *dest); virtual void SendItemStatus(); + virtual void ReloadWeapons(CBasePlayerItem *pWeapon = nullptr); CBasePlayer *BasePlayer() const; public: diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 63f10c0..ddfec61 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -644,6 +644,16 @@ void CBasePlayer_SetClientUserInfoModel(IReGameHook_CBasePlayer_SetClientUserInf callVoidForward(RG_CBasePlayer_SetClientUserInfoModel, original, indexOfEdict(pthis->pev), infobuffer, szNewModel); } +void CBasePlayer_SetClientUserInfoName(IReGameHook_CBasePlayer_SetClientUserInfoName *chain, CBasePlayer *pthis, char *infobuffer, char *szNewName) +{ + auto original = [chain](int _pthis, char *_infobuffer, char *_szNewName) + { + chain->callNext(_infobuffer, _szNewName); + }; + + callVoidForward(RG_CBasePlayer_SetClientUserInfoName, original, indexOfEdict(pthis->pev), infobuffer, szNewName); +} + void HandleMenu_ChooseAppearance(IReGameHook_HandleMenu_ChooseAppearance *chain, CBasePlayer *pPlayer, int slot) { auto original = [chain](int _pPlayer, int _slot) diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 56f14b0..245b731 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -271,6 +271,8 @@ void CSGameRules_GoToIntermission(IReGameHook_CSGameRules_GoToIntermission *chai void CSGameRules_BalanceTeams(IReGameHook_CSGameRules_BalanceTeams *chain); void CBasePlayer_SetClientUserInfoModel(IReGameHook_CBasePlayer_SetClientUserInfoModel *chain, CBasePlayer *pthis, char *infobuffer, char *szNewModel); +void CBasePlayer_SetClientUserInfoName(IReGameHook_CBasePlayer_SetClientUserInfoName *chain, CBasePlayer *pthis, char *infobuffer, char *szNewName); + void HandleMenu_ChooseAppearance(IReGameHook_HandleMenu_ChooseAppearance *chain, CBasePlayer *pPlayer, int slot); BOOL HandleMenu_ChooseTeam(IReGameHook_HandleMenu_ChooseTeam *chain, CBasePlayer *pPlayer, int slot); void ShowMenu(IReGameHook_ShowMenu *chain, CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText); diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index 8d25268..16415ae 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -113,6 +113,7 @@ hook_t hooklist_player[] = { DLL(CBasePlayer_RoundRespawn), DLL(CBasePlayer_Blind), DLL(CBasePlayer_SetClientUserInfoModel), + DLL(CBasePlayer_SetClientUserInfoName), DLL(CBasePlayer_Observer_IsValidTarget), DLL(CBasePlayer_SetAnimation), diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index 1f91cf5..e887075 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -131,6 +131,7 @@ enum GamedllFunc_CBasePlayer RG_CBasePlayer_Blind, RG_CBasePlayer_SetClientUserInfoModel, + RG_CBasePlayer_SetClientUserInfoName, RG_CBasePlayer_Observer_IsValidTarget, RG_CBasePlayer_SetAnimation, RG_CBasePlayer_GiveDefaultItems, diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 3aa5413..4b11926 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -978,12 +978,8 @@ cell AMX_NATIVE_CALL rg_set_user_team(AMX *amx, cell *params) if (CSGameRules()->m_iNumTerrorist > 0 && pPlayer->CSPlayer()->RemovePlayerItem("weapon_c4")) { pPlayer->m_bHasC4 = false; pPlayer->pev->body = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("c4"); - MESSAGE_END(); - + pPlayer->CSPlayer()->SetBombIcon(); + pPlayer->CSPlayer()->SetProgressBarTime(0); CSGameRules()->GiveC4(); } else if (pPlayer->IsAlive()) {// are still alive pPlayer->CSPlayer()->DropPlayerItem("weapon_c4"); @@ -1121,13 +1117,10 @@ cell AMX_NATIVE_CALL rg_transfer_c4(AMX *amx, cell *params) if (!pPlayer->m_bHasC4 || !pPlayer->CSPlayer()->RemovePlayerItem("weapon_c4")) return FALSE; - pPlayer->m_bHasC4 = false; pPlayer->pev->body = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("c4"); - MESSAGE_END(); + pPlayer->m_bHasC4 = false; + pPlayer->CSPlayer()->SetBombIcon(); + pPlayer->CSPlayer()->SetProgressBarTime(0); if (params[arg_receiver] != 0 && params[arg_receiver] <= gpGlobals->maxClients) { CBasePlayer *pReceiver = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_receiver]); @@ -1137,16 +1130,9 @@ cell AMX_NATIVE_CALL rg_transfer_c4(AMX *amx, cell *params) } pReceiver->m_bHasC4 = true; - pReceiver->pev->body = 1; pReceiver->CSPlayer()->GiveNamedItemEx("weapon_c4"); - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pReceiver->pev); - WRITE_BYTE(STATUSICON_SHOW); - WRITE_STRING("c4"); - WRITE_BYTE(0); - WRITE_BYTE(160); - WRITE_BYTE(0); - MESSAGE_END(); + pReceiver->CSPlayer()->SetBombIcon(); + pReceiver->pev->body = 1; } else { auto flags = pPlayer->pev->flags; pPlayer->pev->flags |= FL_DORMANT; @@ -1157,6 +1143,38 @@ cell AMX_NATIVE_CALL rg_transfer_c4(AMX *amx, cell *params) return TRUE; } +/* +* Instant reload weapons +* +* @param index Client index +* @param weapon Entity weapons, if 0 then all the weapons +* +* @return 1 if successfully, 0 otherwise +* +* native rg_instant_reload_weapons(const index, const weapon = 0); +*/ +cell AMX_NATIVE_CALL rg_instant_reload_weapons(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index, arg_weapon }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]); + if (pPlayer == nullptr || pPlayer->has_disconnected) { + MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]); + return FALSE; + } + + auto pWeapon = getPrivate(params[arg_weapon]); + if (params[arg_weapon] != 0 && pWeapon == nullptr) { + MF_LogError(amx, AMX_ERR_NATIVE, "%s: Invalid entity weapon", __FUNCTION__); + return FALSE; + } + + pPlayer->CSPlayer()->ReloadWeapons(pWeapon); + return TRUE; +} + AMX_NATIVE_INFO Misc_Natives_RG[] = { { "rg_set_animation", rg_set_animation }, @@ -1200,6 +1218,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_reset_user_model", rg_reset_user_model }, { "rg_transfer_c4", rg_transfer_c4 }, + { "rg_instant_reload_weapons", rg_instant_reload_weapons }, { nullptr, nullptr } };