mirror of
https://github.com/rehlds/reapi.git
synced 2025-03-13 05:50:16 +03:00
Added natives set_movevar/get_movevar
Added forwards RG_PM_Move/RG_PM_AirMove and some functions of a CSGameRules
This commit is contained in:
parent
979b5a9ebe
commit
1674a3a124
@ -35,7 +35,8 @@ enum AType
|
||||
ATYPE_INTEGER = 0,
|
||||
ATYPE_FLOAT,
|
||||
ATYPE_STRING,
|
||||
ATYPE_CLASSPTR
|
||||
ATYPE_CLASSPTR,
|
||||
ATYPE_EDICT
|
||||
};
|
||||
|
||||
enum HookChain
|
||||
@ -78,25 +79,25 @@ native bool:EnableHookChain(HookChain:hook);
|
||||
* Sets the return value of a hookchain.
|
||||
* This needs to be used in conjunction with RH_OVERRIDE or RH_SUPERCEDE.
|
||||
*
|
||||
* @param type To specify the type RHV_*, look at the enum HookChainReturn
|
||||
* @param type To specify the type ATYPE_*, look at the enum AType
|
||||
* @param value The value to set the return to.
|
||||
*
|
||||
*/
|
||||
native SetHookChainReturn(AType:type, any:...);
|
||||
|
||||
/*
|
||||
* Gets the return value of a hookchain.
|
||||
* This needs to be used in conjunction with RH_OVERRIDE or RH_SUPERCEDE.
|
||||
* Gets the return value of the current hookchain.
|
||||
* This has no effect in pre hookchain.
|
||||
*
|
||||
* @param type To specify the type RHV_*, look at the enum HookChainReturn
|
||||
* @param value The value to set the return to.
|
||||
* @param [maxlen] Max length of string (optional)
|
||||
* @return If an integer or boolean or one byte or float, array or everything else is passed via 1rd argument and more
|
||||
*
|
||||
*/
|
||||
native GetHookChainReturn(AType:type, any:...);
|
||||
native any:GetHookChainReturn(any:...);
|
||||
|
||||
/*
|
||||
* Set hookchain argument.
|
||||
* This needs to be used in conjunction with RH_OVERRIDE or RH_SUPERCEDE.
|
||||
* This has no effect in post hookchain.
|
||||
*
|
||||
* @param number Number of argument
|
||||
* @param value New value
|
||||
|
@ -45,6 +45,24 @@ native set_member(const index, any:member, any:...);
|
||||
*/
|
||||
native any:get_member(const index, any:member, any:...);
|
||||
|
||||
/*
|
||||
* Sets a movevars value to an playermove
|
||||
*
|
||||
* @param var The specified mvar, look at the enum's MoveVars
|
||||
*
|
||||
* @return 1 on success.
|
||||
*/
|
||||
native set_movevar(const MoveVars:var, any:...);
|
||||
|
||||
/*
|
||||
* Returns a movevars value from an playermove
|
||||
*
|
||||
* @param var The specified mvar, look at the enum's MoveVars
|
||||
*
|
||||
* @return If an integer or boolean or one byte, array or everything else is passed via 3rd argument and more, look at argument list for specified mvar
|
||||
*/
|
||||
native any:get_movevar(const MoveVars:var, any:...);
|
||||
|
||||
/*
|
||||
* Assign the number of the player animations.
|
||||
*
|
||||
|
@ -20,6 +20,17 @@
|
||||
#define ROUND_ESCAPING_TERRORISTS_NEUTRALIZED ROUND_ESCAPING_TERRORISTS_NEUTR
|
||||
#define RG_CBaseAnimating_ResetSequenceInfo RG_CBaseAnimating_ResetSequence
|
||||
#define RG_CBasePlayer_Observer_IsValidTarget RG_CBasePlayer_Observer_IsValid
|
||||
#define RG_CSGameRules_FShouldSwitchWeapon RG_CSGameRules_ShouldSwitchWpn
|
||||
#define RG_CSGameRules_GetNextBestWeapon RG_CSGameRules_GetNextBestWpn
|
||||
#define RG_CSGameRules_FlPlayerFallDamage RG_CSGameRules_PlayerFallDmg
|
||||
#define RG_CSGameRules_FPlayerCanTakeDamage RG_CSGameRules_PlayerCanTakeDmg
|
||||
#define RG_CSGameRules_FPlayerCanRespawn RG_CSGameRules_PlayerCanRespawn
|
||||
#define RG_CSGameRules_GetPlayerSpawnSpot RG_CSGameRules_PlayerSpawnSpot
|
||||
#define RG_CSGameRules_ClientUserInfoChanged RG_CSGameRules_UserInfoChanged
|
||||
#define RG_CSGameRules_CanHavePlayerItem RG_CSGameRules_CanPlayerItem
|
||||
#define RG_CSGameRules_DeadPlayerWeapons RG_CSGameRules_DeadPlayerWpn
|
||||
#define RG_CSGameRules_CheckMapConditions RG_CSGameRules_CheckMapCond
|
||||
#define RG_CSGameRules_CheckWinConditions RG_CSGameRules_CheckWinCond
|
||||
#endif
|
||||
|
||||
// use with rg_give_item
|
||||
@ -37,6 +48,23 @@ enum ArmorType
|
||||
ARMOR_VESTHELM, // vest and helmet
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GR_NONE = 0,
|
||||
GR_WEAPON_RESPAWN_YES,
|
||||
GR_WEAPON_RESPAWN_NO,
|
||||
GR_AMMO_RESPAWN_YES,
|
||||
GR_AMMO_RESPAWN_NO,
|
||||
GR_ITEM_RESPAWN_YES,
|
||||
GR_ITEM_RESPAWN_NO,
|
||||
GR_PLR_DROP_GUN_ALL,
|
||||
GR_PLR_DROP_GUN_ACTIVE,
|
||||
GR_PLR_DROP_GUN_NO,
|
||||
GR_PLR_DROP_AMMO_ALL,
|
||||
GR_PLR_DROP_AMMO_ACTIVE,
|
||||
GR_PLR_DROP_AMMO_NO
|
||||
};
|
||||
|
||||
enum WeaponIdType
|
||||
{
|
||||
WEAPON_NONE,
|
||||
@ -163,6 +191,18 @@ enum GamedllFunc
|
||||
*/
|
||||
RG_CanBuyThis,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const PlayerMove:ppmove, const server)
|
||||
*/
|
||||
RG_PM_Move,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const playerIndex)
|
||||
*/
|
||||
RG_PM_AirMove,
|
||||
|
||||
// [...]
|
||||
RG_End
|
||||
};
|
||||
@ -329,6 +369,144 @@ enum GamedllFunc_CBasePlayer
|
||||
RG_CBasePlayer_End
|
||||
};
|
||||
|
||||
enum GamedllFunc_CSGameRules
|
||||
{
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index, const weapon)
|
||||
*/
|
||||
RG_CSGameRules_FShouldSwitchWeapon = 4096,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index, const currentWeapon)
|
||||
*/
|
||||
RG_CSGameRules_GetNextBestWeapon,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index)
|
||||
*/
|
||||
RG_CSGameRules_FlPlayerFallDamage,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index, const attacker)
|
||||
*/
|
||||
RG_CSGameRules_FPlayerCanTakeDamage,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index)
|
||||
*/
|
||||
RG_CSGameRules_PlayerSpawn,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index)
|
||||
*/
|
||||
RG_CSGameRules_FPlayerCanRespawn,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index)
|
||||
*/
|
||||
RG_CSGameRules_GetPlayerSpawnSpot,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index, infobuffer[])
|
||||
*/
|
||||
RG_CSGameRules_ClientUserInfoChanged,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const victim, const killer, const inflictor)
|
||||
*/
|
||||
RG_CSGameRules_PlayerKilled,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const victim, const killer, const inflictor)
|
||||
*/
|
||||
RG_CSGameRules_DeathNotice,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index, const item)
|
||||
*/
|
||||
RG_CSGameRules_CanHavePlayerItem,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const index)
|
||||
*/
|
||||
RG_CSGameRules_DeadPlayerWeapons,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_ServerDeactivate,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_CheckMapConditions,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_CleanUpMap,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_RestartRound,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_CheckWinConditions,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_RemoveGuns,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_GiveC4,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_ChangeLevel,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_GoToIntermission,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: ()
|
||||
*/
|
||||
RG_CSGameRules_BalanceTeams,
|
||||
|
||||
// [...]
|
||||
RG_CSGameRules_End
|
||||
};
|
||||
|
||||
// CSGameRules
|
||||
enum CSGameRules_Members
|
||||
{
|
||||
@ -2721,3 +2899,214 @@ enum CBasePlayer_Members
|
||||
*/
|
||||
m_flLastCommandTime
|
||||
};
|
||||
|
||||
enum MoveVars
|
||||
{
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_gravity = 5120,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_stopspeed,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_maxspeed,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_spectatormaxspeed,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_accelerate,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_airaccelerate,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_wateraccelerate,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_friction,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_edgefriction,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_waterfriction,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_entgravity,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_bounce,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_stepsize,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_maxvelocity,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_zmax,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_waveHeight,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: BOOL
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_footsteps,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: char [32]
|
||||
* Get params: Float:get_mvar(const MoveVars:var, dest[], const lenght);
|
||||
* Set params: set_mvar(const MoveVars:var, const source[]);
|
||||
*/
|
||||
mv_skyName,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_rollangle,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_rollspeed,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_skycolor_r,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_skycolor_g,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_skycolor_b,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_skyvec_x,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_skyvec_y,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_mvar(const MoveVars:var);
|
||||
* Set params: set_mvar(const MoveVars:var, Float:value);
|
||||
*/
|
||||
mv_skyvec_z
|
||||
};
|
||||
|
@ -191,8 +191,8 @@ typedef IVoidHookChain<struct playermove_s *, int> IReGameHook_PM_Move;
|
||||
typedef IVoidHookChainRegistry<struct playermove_s *, int> IReGameHookRegistry_PM_Move;
|
||||
|
||||
// PM_AirMove hook
|
||||
typedef IVoidHookChain<> IReGameHook_PM_AirMove;
|
||||
typedef IVoidHookChainRegistry<> IReGameHookRegistry_PM_AirMove;
|
||||
typedef IVoidHookChain<int> IReGameHook_PM_AirMove;
|
||||
typedef IVoidHookChainRegistry<int> IReGameHookRegistry_PM_AirMove;
|
||||
|
||||
// CHalfLifeMultiplay::FShouldSwitchWeapon hook
|
||||
typedef IHookChain<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHook_CSGameRules_FShouldSwitchWeapon;
|
||||
|
@ -69,7 +69,7 @@ static struct funcreq_t
|
||||
//DECLARE_REQ(IsPlayerValid),
|
||||
//DECLARE_REQ(GetPlayerName),
|
||||
//DECLARE_REQ(GetPlayerIP),
|
||||
//DECLARE_REQ(IsPlayerIngame),
|
||||
//DECLARE_REQ(IsPlayerInGame),
|
||||
//DECLARE_REQ(IsPlayerBot),
|
||||
//DECLARE_REQ(IsPlayerAuthorized),
|
||||
//DECLARE_REQ(GetPlayerTime),
|
||||
|
@ -440,7 +440,7 @@ struct amxxapi_t
|
||||
PFN_IS_PLAYER_VALID IsPlayerValid;
|
||||
PFN_GET_PLAYER_NAME GetPlayerName;
|
||||
PFN_GET_PLAYER_IP GetPlayerIP;
|
||||
PFN_IS_PLAYER_INGAME IsPlayerIngame;
|
||||
PFN_IS_PLAYER_INGAME IsPlayerInGame;
|
||||
PFN_IS_PLAYER_BOT IsPlayerBot;
|
||||
PFN_IS_PLAYER_AUTHORIZED IsPlayerAuthorized;
|
||||
PFN_GET_PLAYER_TIME GetPlayerTime;
|
||||
|
@ -1,9 +1,10 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
DLL_FUNCTIONS *g_pFunctionTable;
|
||||
DLL_FUNCTIONS gFunctionTable =
|
||||
{
|
||||
NULL, // pfnGameInit
|
||||
NULL, // pfnSpawn
|
||||
Spawn, // pfnSpawn
|
||||
NULL, // pfnThink
|
||||
NULL, // pfnUse
|
||||
NULL, // pfnTouch
|
||||
@ -125,6 +126,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
|
||||
}
|
||||
|
||||
memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
|
||||
g_pFunctionTable = pFunctionTable;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
hookctx_t* g_hookCtx;
|
||||
hookctx_t* g_hookCtx = nullptr;
|
||||
|
||||
/*
|
||||
* ReHLDS functions
|
||||
@ -394,6 +394,246 @@ bool CanBuyThis(IReGameHook_CanBuyThis *chain, CBasePlayer *pPlayer, int iWeapon
|
||||
return callForward<bool>(RG_CanBuyThis, original, indexOfEdict(pPlayer->pev), iWeapon);
|
||||
}
|
||||
|
||||
void PM_Move(IReGameHook_PM_Move *chain, playermove_t *ppmove, int server)
|
||||
{
|
||||
auto original = [chain](playermove_t *_ppmove, int _server)
|
||||
{
|
||||
chain->callNext(_ppmove, _server);
|
||||
};
|
||||
|
||||
callVoidForward(RG_PM_Move, original, ppmove, server);
|
||||
}
|
||||
|
||||
void PM_AirMove(IReGameHook_PM_AirMove *chain, int playerIndex)
|
||||
{
|
||||
auto original = [chain](int _playerIndex)
|
||||
{
|
||||
chain->callNext(_playerIndex);
|
||||
};
|
||||
|
||||
callVoidForward(RG_PM_AirMove, original, playerIndex);
|
||||
}
|
||||
|
||||
BOOL CSGameRules_FShouldSwitchWeapon(IReGameHook_CSGameRules_FShouldSwitchWeapon *chain, CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
|
||||
{
|
||||
auto original = [chain](int _pPlayer, int _pWeapon)
|
||||
{
|
||||
return chain->callNext(getPrivate<CBasePlayer>(_pPlayer), getPrivate<CBasePlayerItem>(_pWeapon));
|
||||
};
|
||||
|
||||
return callForward<BOOL>(RG_CSGameRules_FShouldSwitchWeapon, original, indexOfEdict(pPlayer->pev), indexOfEdict(pWeapon->pev));
|
||||
}
|
||||
|
||||
BOOL CSGameRules_GetNextBestWeapon(IReGameHook_CSGameRules_GetNextBestWeapon *chain, CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon)
|
||||
{
|
||||
auto original = [chain](int _pPlayer, int _pCurrentWeapon)
|
||||
{
|
||||
return chain->callNext(getPrivate<CBasePlayer>(_pPlayer), getPrivate<CBasePlayerItem>(_pCurrentWeapon));
|
||||
};
|
||||
|
||||
return callForward<BOOL>(RG_CSGameRules_GetNextBestWeapon, original, indexOfEdict(pPlayer->pev), indexOfEdict(pCurrentWeapon->pev));
|
||||
}
|
||||
|
||||
float CSGameRules_FlPlayerFallDamage(IReGameHook_CSGameRules_FlPlayerFallDamage *chain, CBasePlayer *pPlayer)
|
||||
{
|
||||
auto original = [chain](int _pPlayer)
|
||||
{
|
||||
return chain->callNext(getPrivate<CBasePlayer>(_pPlayer));
|
||||
};
|
||||
|
||||
return callForward<float>(RG_CSGameRules_FlPlayerFallDamage, original, indexOfEdict(pPlayer->pev));
|
||||
}
|
||||
|
||||
BOOL CSGameRules_FPlayerCanTakeDamage(IReGameHook_CSGameRules_FPlayerCanTakeDamage *chain, CBasePlayer *pPlayer, CBaseEntity *pAttacker)
|
||||
{
|
||||
auto original = [chain](int _pPlayer, int _pAttacker)
|
||||
{
|
||||
return chain->callNext(getPrivate<CBasePlayer>(_pPlayer), getPrivate<CBaseEntity>(_pAttacker));
|
||||
};
|
||||
|
||||
return callForward<BOOL>(RG_CSGameRules_FPlayerCanTakeDamage, original, indexOfEdict(pPlayer->pev), indexOfEdict(pAttacker->pev));
|
||||
}
|
||||
|
||||
void CSGameRules_PlayerSpawn(IReGameHook_CSGameRules_PlayerSpawn *chain, CBasePlayer *pPlayer)
|
||||
{
|
||||
auto original = [chain](int _pPlayer)
|
||||
{
|
||||
chain->callNext(getPrivate<CBasePlayer>(_pPlayer));
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_PlayerSpawn, original, indexOfEdict(pPlayer->pev));
|
||||
}
|
||||
|
||||
BOOL CSGameRules_FPlayerCanRespawn(IReGameHook_CSGameRules_FPlayerCanRespawn *chain, CBasePlayer *pPlayer)
|
||||
{
|
||||
auto original = [chain](int _pPlayer)
|
||||
{
|
||||
return chain->callNext(getPrivate<CBasePlayer>(_pPlayer));
|
||||
};
|
||||
|
||||
return callForward<BOOL>(RG_CSGameRules_FPlayerCanRespawn, original, indexOfEdict(pPlayer->pev));
|
||||
}
|
||||
|
||||
edict_t *CSGameRules_GetPlayerSpawnSpot(IReGameHook_CSGameRules_GetPlayerSpawnSpot *chain, CBasePlayer *pPlayer)
|
||||
{
|
||||
auto original = [chain](int _pPlayer)
|
||||
{
|
||||
return chain->callNext(getPrivate<CBasePlayer>(_pPlayer));
|
||||
};
|
||||
|
||||
return callForward<edict_t *>(RG_CSGameRules_GetPlayerSpawnSpot, original, indexOfEdict(pPlayer->pev));
|
||||
}
|
||||
|
||||
void CSGameRules_ClientUserInfoChanged(IReGameHook_CSGameRules_ClientUserInfoChanged *chain, CBasePlayer *pPlayer, char *infobuffer)
|
||||
{
|
||||
auto original = [chain](int _pPlayer, char *infobuffer)
|
||||
{
|
||||
chain->callNext(getPrivate<CBasePlayer>(_pPlayer), infobuffer);
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_ClientUserInfoChanged, original, indexOfEdict(pPlayer->pev), infobuffer);
|
||||
}
|
||||
|
||||
void CSGameRules_PlayerKilled(IReGameHook_CSGameRules_PlayerKilled *chain, CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor)
|
||||
{
|
||||
auto original = [chain](int _pVictim, int _pKiller, int _pInflictor)
|
||||
{
|
||||
chain->callNext(getPrivate<CBasePlayer>(_pVictim), PEV(_pKiller), PEV(_pInflictor));
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_ClientUserInfoChanged, original, indexOfEdict(pVictim->pev), indexOfEdict(pKiller), indexOfEdict(pInflictor));
|
||||
}
|
||||
|
||||
void CSGameRules_DeathNotice(IReGameHook_CSGameRules_DeathNotice *chain, CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor)
|
||||
{
|
||||
auto original = [chain](int _pVictim, int _pKiller, int _pevInflictor)
|
||||
{
|
||||
chain->callNext(getPrivate<CBasePlayer>(_pVictim), PEV(_pKiller), PEV(_pevInflictor));
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_DeathNotice, original, indexOfEdict(pVictim->pev), indexOfEdict(pKiller), indexOfEdict(pevInflictor));
|
||||
}
|
||||
|
||||
int CSGameRules_CanHavePlayerItem(IReGameHook_CSGameRules_CanHavePlayerItem *chain, CBasePlayer *pPlayer, CBasePlayerItem *pItem)
|
||||
{
|
||||
auto original = [chain](int _pPlayer, int _pItem)
|
||||
{
|
||||
return chain->callNext(getPrivate<CBasePlayer>(_pPlayer), getPrivate<CBasePlayerItem>(_pItem));
|
||||
};
|
||||
|
||||
return callForward<int>(RG_CSGameRules_CanHavePlayerItem, original, indexOfEdict(pPlayer->pev), indexOfEdict(pItem->pev));
|
||||
}
|
||||
|
||||
int CSGameRules_DeadPlayerWeapons(IReGameHook_CSGameRules_DeadPlayerWeapons *chain, CBasePlayer *pPlayer)
|
||||
{
|
||||
auto original = [chain](int _pPlayer)
|
||||
{
|
||||
return chain->callNext(getPrivate<CBasePlayer>(_pPlayer));
|
||||
};
|
||||
|
||||
return callForward<int>(RG_CSGameRules_DeadPlayerWeapons, original, indexOfEdict(pPlayer->pev));
|
||||
}
|
||||
|
||||
void CSGameRules_ServerDeactivate(IReGameHook_CSGameRules_ServerDeactivate *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_ServerDeactivate, original);
|
||||
}
|
||||
|
||||
void CSGameRules_CheckMapConditions(IReGameHook_CSGameRules_CheckMapConditions *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_CheckMapConditions, original);
|
||||
}
|
||||
|
||||
void CSGameRules_CleanUpMap(IReGameHook_CSGameRules_CleanUpMap *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_CleanUpMap, original);
|
||||
}
|
||||
|
||||
void CSGameRules_RestartRound(IReGameHook_CSGameRules_RestartRound *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_RestartRound, original);
|
||||
}
|
||||
|
||||
void CSGameRules_CheckWinConditions(IReGameHook_CSGameRules_CheckWinConditions *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_CheckWinConditions, original);
|
||||
}
|
||||
|
||||
void CSGameRules_RemoveGuns(IReGameHook_CSGameRules_RemoveGuns *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_RemoveGuns, original);
|
||||
}
|
||||
|
||||
void CSGameRules_GiveC4(IReGameHook_CSGameRules_GiveC4 *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_GiveC4, original);
|
||||
}
|
||||
|
||||
void CSGameRules_ChangeLevel(IReGameHook_CSGameRules_ChangeLevel *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_ChangeLevel, original);
|
||||
}
|
||||
|
||||
void CSGameRules_GoToIntermission(IReGameHook_CSGameRules_GoToIntermission *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_GoToIntermission, original);
|
||||
}
|
||||
|
||||
void CSGameRules_BalanceTeams(IReGameHook_CSGameRules_BalanceTeams *chain)
|
||||
{
|
||||
auto original = [chain]()
|
||||
{
|
||||
chain->callNext();
|
||||
};
|
||||
|
||||
callVoidForward(RG_CSGameRules_BalanceTeams, original);
|
||||
}
|
||||
|
||||
int g_iClientStartSpeak, g_iClientStopSpeak;
|
||||
|
||||
void ClientStartSpeak(size_t clientIndex)
|
||||
|
@ -15,7 +15,9 @@ enum AType : uint8
|
||||
ATYPE_INTEGER = 0,
|
||||
ATYPE_FLOAT,
|
||||
ATYPE_STRING,
|
||||
ATYPE_CLASSPTR
|
||||
ATYPE_CLASSPTR,
|
||||
ATYPE_EDICT,
|
||||
ATYPE_EVARS
|
||||
};
|
||||
|
||||
struct retval_t
|
||||
@ -29,6 +31,8 @@ struct retval_t
|
||||
float _float;
|
||||
int _interger;
|
||||
CBaseEntity* _classptr;
|
||||
edict_t* _edict;
|
||||
entvars_t* _pev;
|
||||
};
|
||||
};
|
||||
|
||||
@ -37,13 +41,15 @@ inline AType getApiType(unsigned) { return ATYPE_INTEGER; }
|
||||
inline AType getApiType(float) { return ATYPE_FLOAT; }
|
||||
inline AType getApiType(const char *) { return ATYPE_STRING; }
|
||||
inline AType getApiType(CBaseEntity *) { return ATYPE_CLASSPTR; }
|
||||
inline AType getApiType(edict_t *) { return ATYPE_CLASSPTR; }
|
||||
inline AType getApiType(entvars_t *) { return ATYPE_EVARS; }
|
||||
|
||||
template<typename T>
|
||||
inline AType getApiType(T *) { return ATYPE_INTEGER; }
|
||||
|
||||
#define MAX_ARGS 12u
|
||||
|
||||
template<size_t current>
|
||||
template<size_t current = 0>
|
||||
void setupArgTypes(AType args_type[MAX_ARGS])
|
||||
{
|
||||
}
|
||||
@ -160,7 +166,6 @@ NOINLINE R DLLEXPORT _callForward(const hook_t* hook, original_t original, volat
|
||||
if (hc_state != HC_SUPERCEDE)
|
||||
{
|
||||
auto retVal = original(args...);
|
||||
|
||||
if (hc_state != HC_OVERRIDE)
|
||||
hookCtx.retVal._interger = *(int *)&retVal;
|
||||
}
|
||||
@ -238,6 +243,32 @@ void CBasePlayer_GiveShield(IReGameHook_CBasePlayer_GiveShield *chain, CBasePlay
|
||||
|
||||
void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis);
|
||||
|
||||
void PM_Move(IReGameHook_PM_Move *chain, playermove_t *ppmove, int server);
|
||||
void PM_AirMove(IReGameHook_PM_AirMove *chain, int playerIndex);
|
||||
|
||||
BOOL CSGameRules_FShouldSwitchWeapon(IReGameHook_CSGameRules_FShouldSwitchWeapon *chain, CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
BOOL CSGameRules_GetNextBestWeapon(IReGameHook_CSGameRules_GetNextBestWeapon *chain, CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon);
|
||||
float CSGameRules_FlPlayerFallDamage(IReGameHook_CSGameRules_FlPlayerFallDamage *chain, CBasePlayer *pPlayer);
|
||||
BOOL CSGameRules_FPlayerCanTakeDamage(IReGameHook_CSGameRules_FPlayerCanTakeDamage *chain, CBasePlayer *pPlayer, CBaseEntity *pAttacker);
|
||||
void CSGameRules_PlayerSpawn(IReGameHook_CSGameRules_PlayerSpawn *chain, CBasePlayer *pPlayer);
|
||||
BOOL CSGameRules_FPlayerCanRespawn(IReGameHook_CSGameRules_FPlayerCanRespawn *chain, CBasePlayer *pPlayer);
|
||||
edict_t *CSGameRules_GetPlayerSpawnSpot(IReGameHook_CSGameRules_GetPlayerSpawnSpot *chain, CBasePlayer *pPlayer);
|
||||
void CSGameRules_ClientUserInfoChanged(IReGameHook_CSGameRules_ClientUserInfoChanged *chain, CBasePlayer *pPlayer, char *infobuffer);
|
||||
void CSGameRules_PlayerKilled(IReGameHook_CSGameRules_PlayerKilled *chain, CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor);
|
||||
void CSGameRules_DeathNotice(IReGameHook_CSGameRules_DeathNotice *chain, CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor);
|
||||
int CSGameRules_CanHavePlayerItem(IReGameHook_CSGameRules_CanHavePlayerItem *chain, CBasePlayer *pPlayer, CBasePlayerItem *pItem);
|
||||
int CSGameRules_DeadPlayerWeapons(IReGameHook_CSGameRules_DeadPlayerWeapons *chain, CBasePlayer *pPlayer);
|
||||
void CSGameRules_ServerDeactivate(IReGameHook_CSGameRules_ServerDeactivate *chain);
|
||||
void CSGameRules_CheckMapConditions(IReGameHook_CSGameRules_CheckMapConditions *chain);
|
||||
void CSGameRules_CleanUpMap(IReGameHook_CSGameRules_CleanUpMap *chain);
|
||||
void CSGameRules_RestartRound(IReGameHook_CSGameRules_RestartRound *chain);
|
||||
void CSGameRules_CheckWinConditions(IReGameHook_CSGameRules_CheckWinConditions *chain);
|
||||
void CSGameRules_RemoveGuns(IReGameHook_CSGameRules_RemoveGuns *chain);
|
||||
void CSGameRules_GiveC4(IReGameHook_CSGameRules_GiveC4 *chain);
|
||||
void CSGameRules_ChangeLevel(IReGameHook_CSGameRules_ChangeLevel *chain);
|
||||
void CSGameRules_GoToIntermission(IReGameHook_CSGameRules_GoToIntermission *chain);
|
||||
void CSGameRules_BalanceTeams(IReGameHook_CSGameRules_BalanceTeams *chain);
|
||||
|
||||
extern int g_iClientStartSpeak;
|
||||
extern int g_iClientStopSpeak;
|
||||
|
||||
|
@ -75,7 +75,9 @@ hook_t hooklist_gamedll[] = {
|
||||
DLL(PlayerBlind),
|
||||
DLL(RadiusFlash_TraceLine),
|
||||
DLL(RoundEnd),
|
||||
DLL(CanBuyThis)
|
||||
DLL(CanBuyThis),
|
||||
DLL(PM_Move),
|
||||
DLL(PM_AirMove),
|
||||
};
|
||||
|
||||
hook_t hooklist_animating[] = {
|
||||
@ -114,6 +116,31 @@ hook_t hooklist_player[] = {
|
||||
DLL(CBasePlayer_GiveShield),
|
||||
};
|
||||
|
||||
hook_t hooklist_gamerules[] = {
|
||||
DLL(CSGameRules_FShouldSwitchWeapon),
|
||||
DLL(CSGameRules_GetNextBestWeapon),
|
||||
DLL(CSGameRules_FlPlayerFallDamage),
|
||||
DLL(CSGameRules_FPlayerCanTakeDamage),
|
||||
DLL(CSGameRules_PlayerSpawn),
|
||||
DLL(CSGameRules_FPlayerCanRespawn),
|
||||
DLL(CSGameRules_GetPlayerSpawnSpot),
|
||||
DLL(CSGameRules_ClientUserInfoChanged),
|
||||
DLL(CSGameRules_PlayerKilled),
|
||||
DLL(CSGameRules_DeathNotice),
|
||||
DLL(CSGameRules_CanHavePlayerItem),
|
||||
DLL(CSGameRules_DeadPlayerWeapons),
|
||||
DLL(CSGameRules_ServerDeactivate),
|
||||
DLL(CSGameRules_CheckMapConditions),
|
||||
DLL(CSGameRules_CleanUpMap),
|
||||
DLL(CSGameRules_RestartRound),
|
||||
DLL(CSGameRules_CheckWinConditions),
|
||||
DLL(CSGameRules_RemoveGuns),
|
||||
DLL(CSGameRules_GiveC4),
|
||||
DLL(CSGameRules_ChangeLevel),
|
||||
DLL(CSGameRules_GoToIntermission),
|
||||
DLL(CSGameRules_BalanceTeams),
|
||||
};
|
||||
|
||||
hook_t* hooklist_t::getHookSafe(size_t hook)
|
||||
{
|
||||
#define CASE(h) case ht_##h: if (index < arraysize(hooklist_##h)) return &hooklist_##h[index]; else break;
|
||||
@ -126,6 +153,7 @@ hook_t* hooklist_t::getHookSafe(size_t hook)
|
||||
CASE(gamedll)
|
||||
CASE(animating)
|
||||
CASE(player)
|
||||
CASE(gamerules)
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -139,6 +167,7 @@ void hooklist_t::clear()
|
||||
FOREACH_CLEAR(gamedll);
|
||||
FOREACH_CLEAR(animating);
|
||||
FOREACH_CLEAR(player);
|
||||
FOREACH_CLEAR(gamerules);
|
||||
}
|
||||
|
||||
void hook_t::clear()
|
||||
|
@ -29,6 +29,7 @@ extern hook_t hooklist_engine[];
|
||||
extern hook_t hooklist_gamedll[];
|
||||
extern hook_t hooklist_animating[];
|
||||
extern hook_t hooklist_player[];
|
||||
extern hook_t hooklist_gamerules[];
|
||||
|
||||
struct hooklist_t
|
||||
{
|
||||
@ -44,6 +45,7 @@ struct hooklist_t
|
||||
CASE(gamedll)
|
||||
CASE(animating)
|
||||
CASE(player)
|
||||
CASE(gamerules)
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -58,6 +60,7 @@ struct hooklist_t
|
||||
ht_gamedll,
|
||||
ht_animating,
|
||||
ht_player,
|
||||
ht_gamerules,
|
||||
|
||||
ht_end
|
||||
};
|
||||
@ -82,6 +85,9 @@ enum GamedllFunc
|
||||
RG_RoundEnd,
|
||||
RG_CanBuyThis,
|
||||
|
||||
RG_PM_Move,
|
||||
RG_PM_AirMove,
|
||||
|
||||
// [...]
|
||||
RG_End
|
||||
};
|
||||
@ -130,3 +136,34 @@ enum GamedllFunc_CBasePlayer
|
||||
// [...]
|
||||
RG_CBasePlayer_End
|
||||
};
|
||||
|
||||
enum GamedllFunc_CSGameRules
|
||||
{
|
||||
// CSGameRules virtual
|
||||
RG_CSGameRules_FShouldSwitchWeapon = BEGIN_FUNC_REGION(gamerules),
|
||||
RG_CSGameRules_GetNextBestWeapon,
|
||||
RG_CSGameRules_FlPlayerFallDamage,
|
||||
RG_CSGameRules_FPlayerCanTakeDamage,
|
||||
RG_CSGameRules_PlayerSpawn,
|
||||
RG_CSGameRules_FPlayerCanRespawn,
|
||||
RG_CSGameRules_GetPlayerSpawnSpot,
|
||||
RG_CSGameRules_ClientUserInfoChanged,
|
||||
RG_CSGameRules_PlayerKilled,
|
||||
RG_CSGameRules_DeathNotice,
|
||||
RG_CSGameRules_CanHavePlayerItem,
|
||||
RG_CSGameRules_DeadPlayerWeapons,
|
||||
RG_CSGameRules_ServerDeactivate,
|
||||
RG_CSGameRules_CheckMapConditions,
|
||||
RG_CSGameRules_CleanUpMap,
|
||||
RG_CSGameRules_RestartRound,
|
||||
RG_CSGameRules_CheckWinConditions,
|
||||
RG_CSGameRules_RemoveGuns,
|
||||
RG_CSGameRules_GiveC4,
|
||||
RG_CSGameRules_ChangeLevel,
|
||||
RG_CSGameRules_GoToIntermission,
|
||||
|
||||
RG_CSGameRules_BalanceTeams,
|
||||
|
||||
// [...]
|
||||
RG_CSGameRules_End
|
||||
};
|
||||
|
@ -31,8 +31,6 @@ void OnMetaDetach()
|
||||
|
||||
void ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
|
||||
{
|
||||
g_pEdicts = pEdictList;
|
||||
|
||||
gmsgSendAudio = GET_USER_MSG_ID(PLID, "SendAudio", NULL);
|
||||
gmsgTeamScore = GET_USER_MSG_ID(PLID, "TeamScore", NULL);
|
||||
gmsgStatusIcon = GET_USER_MSG_ID(PLID, "StatusIcon", NULL);
|
||||
@ -45,6 +43,7 @@ void ServerDeactivate_Post()
|
||||
{
|
||||
api_cfg.ServerDeactivate();
|
||||
g_hookManager.clearHandlers();
|
||||
g_pFunctionTable->pfnSpawn = Spawn;
|
||||
|
||||
SET_META_RESULT(MRES_IGNORED);
|
||||
}
|
||||
@ -53,3 +52,11 @@ CGameRules *InstallGameRules(IReGameHook_InstallGameRules *chain)
|
||||
{
|
||||
return g_pGameRules = chain->callNext();
|
||||
}
|
||||
|
||||
int Spawn(edict_t* pEntity)
|
||||
{
|
||||
g_pEdicts = g_engfuncs.pfnPEntityOfEntIndex(0);
|
||||
g_pFunctionTable->pfnSpawn = nullptr;
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
@ -12,4 +12,6 @@ void OnMetaDetach();
|
||||
|
||||
void ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax);
|
||||
void ServerDeactivate_Post();
|
||||
int Spawn(edict_t* pEntity);
|
||||
|
||||
CGameRules *InstallGameRules(IReGameHook_InstallGameRules *chain);
|
||||
|
@ -1,13 +1,15 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#define CLASS_MEMBERS(cx, mx) ((!(mx & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (mx & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltype(##cx::##mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(##cx, ##mx);ptr->type = getMemberType(f);}) : regmember(#mx)
|
||||
#define CLASS_MEMBERS(cx, enmx, mx) ((!(enmx & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (enmx & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltype(##cx::##mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(##cx, ##mx);ptr->type = getMemberType(f);}) : regmember(#enmx)
|
||||
#define CLASS_MEMBERS_DEF(cx, mx) CLASS_MEMBERS(cx, mx, mx)
|
||||
|
||||
#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx)
|
||||
#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(CVoiceGameMgr, mx)
|
||||
#define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx)
|
||||
#define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx)
|
||||
#define PL_MEMBERS(mx) CLASS_MEMBERS(CBasePlayer, mx)
|
||||
#define EVAR_MEMBERS(mx) CLASS_MEMBERS(com_entvars, mx)
|
||||
#define GM_MEMBERS(mx) CLASS_MEMBERS_DEF(CHalfLifeMultiplay, mx)
|
||||
#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS_DEF(CVoiceGameMgr, mx)
|
||||
#define BASE_MEMBERS(mx) CLASS_MEMBERS_DEF(CBaseEntity, mx)
|
||||
#define ANIM_MEMBERS(mx) CLASS_MEMBERS_DEF(CBaseAnimating, mx)
|
||||
#define PL_MEMBERS(mx) CLASS_MEMBERS_DEF(CBasePlayer, mx)
|
||||
#define EVAR_MEMBERS(mx) CLASS_MEMBERS_DEF(com_entvars, mx)
|
||||
#define MOVEVAR_MEMBERS(mx) CLASS_MEMBERS(movevars_t, MoveVars::##mx, mx)
|
||||
|
||||
inline MType getMemberType(float*) { return MEMBER_FLOAT; }
|
||||
inline MType getMemberType(float) { return MEMBER_FLOAT; }
|
||||
@ -510,6 +512,34 @@ member_t memberlist_entvars[] = {
|
||||
EVAR_MEMBERS(euser4)
|
||||
};
|
||||
|
||||
member_t memberlist_movevars[] = {
|
||||
MOVEVAR_MEMBERS(gravity),
|
||||
MOVEVAR_MEMBERS(stopspeed),
|
||||
MOVEVAR_MEMBERS(maxspeed),
|
||||
MOVEVAR_MEMBERS(spectatormaxspeed),
|
||||
MOVEVAR_MEMBERS(accelerate),
|
||||
MOVEVAR_MEMBERS(airaccelerate),
|
||||
MOVEVAR_MEMBERS(wateraccelerate),
|
||||
MOVEVAR_MEMBERS(friction),
|
||||
MOVEVAR_MEMBERS(edgefriction),
|
||||
MOVEVAR_MEMBERS(waterfriction),
|
||||
MOVEVAR_MEMBERS(entgravity),
|
||||
MOVEVAR_MEMBERS(bounce),
|
||||
MOVEVAR_MEMBERS(stepsize),
|
||||
MOVEVAR_MEMBERS(maxvelocity),
|
||||
MOVEVAR_MEMBERS(zmax),
|
||||
MOVEVAR_MEMBERS(waveHeight),
|
||||
MOVEVAR_MEMBERS(footsteps),
|
||||
MOVEVAR_MEMBERS(skyName),
|
||||
MOVEVAR_MEMBERS(rollangle),
|
||||
MOVEVAR_MEMBERS(rollspeed),
|
||||
MOVEVAR_MEMBERS(skycolor_r),
|
||||
MOVEVAR_MEMBERS(skycolor_g),
|
||||
MOVEVAR_MEMBERS(skycolor_b),
|
||||
MOVEVAR_MEMBERS(skyvec_x),
|
||||
MOVEVAR_MEMBERS(skyvec_y),
|
||||
MOVEVAR_MEMBERS(skyvec_z),
|
||||
};
|
||||
|
||||
memberlist_t memberlist;
|
||||
|
||||
@ -526,6 +556,7 @@ member_t *memberlist_t::operator[](size_t members) const
|
||||
CASE(animating)
|
||||
CASE(player)
|
||||
CASE(entvars)
|
||||
CASE(movevars)
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -43,6 +43,7 @@ struct memberlist_t
|
||||
ht_animating,
|
||||
ht_player,
|
||||
ht_entvars,
|
||||
ht_movevars
|
||||
};
|
||||
};
|
||||
|
||||
@ -497,3 +498,36 @@ enum EntVars
|
||||
euser3,
|
||||
euser4
|
||||
};
|
||||
|
||||
// in order to avoid problems with redefinition enumerator
|
||||
namespace MoveVars {
|
||||
enum MoveVars
|
||||
{
|
||||
gravity = BEGIN_MEMBER_REGION(movevars),
|
||||
stopspeed,
|
||||
maxspeed,
|
||||
spectatormaxspeed,
|
||||
accelerate,
|
||||
airaccelerate,
|
||||
wateraccelerate,
|
||||
friction,
|
||||
edgefriction,
|
||||
waterfriction,
|
||||
entgravity,
|
||||
bounce,
|
||||
stepsize,
|
||||
maxvelocity,
|
||||
zmax,
|
||||
waveHeight,
|
||||
footsteps,
|
||||
skyName,
|
||||
rollangle,
|
||||
rollspeed,
|
||||
skycolor_r,
|
||||
skycolor_g,
|
||||
skycolor_b,
|
||||
skyvec_x,
|
||||
skyvec_y,
|
||||
skyvec_z,
|
||||
};
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ META_FUNCTIONS gMetaFunctionTable =
|
||||
{
|
||||
NULL, // pfnGetEntityAPI HL SDK; called before game DLL
|
||||
NULL, // pfnGetEntityAPI_Post META; called after game DLL
|
||||
NULL, // pfnGetEntityAPI2 HL SDK2; called before game DLL
|
||||
GetEntityAPI2, // pfnGetEntityAPI2 HL SDK2; called before game DLL
|
||||
GetEntityAPI2_Post, // pfnGetEntityAPI2_Post META; called after game DLL
|
||||
NULL, // pfnGetNewDLLFunctions HL SDK2; called before game DLL
|
||||
NULL, // pfnGetNewDLLFunctions_Post META; called after game DLL
|
||||
|
@ -102,7 +102,7 @@ cell AMX_NATIVE_CALL DisableHookChain(AMX *amx, cell *params)
|
||||
* Sets the return value of a hookchain.
|
||||
* This needs to be used in conjunction with RH_OVERRIDE or RH_SUPERCEDE.
|
||||
*
|
||||
* @param type To specify the type RHV_*, look at the enum AType
|
||||
* @param type To specify the type ATYPE_*, look at the enum AType
|
||||
* @param value The value to set the return to.
|
||||
*
|
||||
* native SetHookChainReturn(AType:type, any:...);
|
||||
@ -146,6 +146,12 @@ cell AMX_NATIVE_CALL SetHookChainReturn(AMX *amx, cell *params)
|
||||
case ATYPE_CLASSPTR:
|
||||
retVal._classptr = getPrivate<CBaseEntity>(*srcAddr);
|
||||
break;
|
||||
case ATYPE_EDICT:
|
||||
retVal._edict = edictByIndexAmx(*srcAddr);
|
||||
break;
|
||||
case ATYPE_EVARS:
|
||||
retVal._pev = PEV(*srcAddr);
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
@ -155,14 +161,13 @@ cell AMX_NATIVE_CALL SetHookChainReturn(AMX *amx, cell *params)
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the return value of a hookchain.
|
||||
* This needs to be used in conjunction with RH_OVERRIDE or RH_SUPERCEDE.
|
||||
* Gets the return value of the current hookchain.
|
||||
* This has no effect in pre hookchain.
|
||||
*
|
||||
* @param value The value to set the return to.
|
||||
* @param [maxlen] Max length of string (optional)
|
||||
* @return Returns if the function is successful executed true otherwise false
|
||||
* @return If an integer or boolean or one byte or float, array or everything else is passed via 1rd argument and more
|
||||
*
|
||||
* native GetHookChainReturn(AType:type, any:...);
|
||||
* native any:GetHookChainReturn(any:...);
|
||||
*/
|
||||
cell AMX_NATIVE_CALL GetHookChainReturn(AMX *amx, cell *params)
|
||||
{
|
||||
@ -181,8 +186,7 @@ cell AMX_NATIVE_CALL GetHookChainReturn(AMX *amx, cell *params)
|
||||
{
|
||||
case ATYPE_INTEGER:
|
||||
case ATYPE_FLOAT:
|
||||
*dstAddr = retVal._interger;
|
||||
break;
|
||||
return retVal._interger;
|
||||
case ATYPE_STRING:
|
||||
{
|
||||
if (PARAMS_COUNT != 2)
|
||||
@ -192,8 +196,11 @@ cell AMX_NATIVE_CALL GetHookChainReturn(AMX *amx, cell *params)
|
||||
break;
|
||||
}
|
||||
case ATYPE_CLASSPTR:
|
||||
*dstAddr = indexOfEdict(retVal._classptr->pev);
|
||||
break;
|
||||
return indexOfEdict(retVal._classptr->pev);
|
||||
case ATYPE_EDICT:
|
||||
return indexOfEdict(retVal._edict);
|
||||
case ATYPE_EVARS:
|
||||
return indexOfEdict(retVal._pev);
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
@ -203,7 +210,7 @@ cell AMX_NATIVE_CALL GetHookChainReturn(AMX *amx, cell *params)
|
||||
|
||||
/*
|
||||
* Set hookchain argument.
|
||||
* This needs to be used in conjunction with RH_OVERRIDE or RH_SUPERCEDE.
|
||||
* This has no effect in post hookchain.
|
||||
*
|
||||
* @param number Number of argument
|
||||
* @param value New value
|
||||
@ -254,6 +261,12 @@ cell AMX_NATIVE_CALL SetHookChainArg(AMX *amx, cell *params)
|
||||
case ATYPE_CLASSPTR:
|
||||
*(CBaseEntity **)destAddr = getPrivate<CBaseEntity>(*srcAddr);
|
||||
break;
|
||||
case ATYPE_EDICT:
|
||||
*(edict_t **)destAddr = edictByIndexAmx(*srcAddr);
|
||||
break;
|
||||
case ATYPE_EVARS:
|
||||
*(entvars_t **)destAddr = PEV(*srcAddr);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -129,7 +129,15 @@ cell AMX_NATIVE_CALL get_member_game(AMX *amx, cell *params)
|
||||
element = 0;
|
||||
}
|
||||
|
||||
return get_member(g_pGameRules, member, element, dest);
|
||||
void* data;
|
||||
// members of m_VoiceGameMgr
|
||||
if (params[arg_member] >= m_msgPlayerVoiceMask && params[arg_member] <= m_UpdateInterval) {
|
||||
data = &CSGameRules()->m_VoiceGameMgr;
|
||||
} else {
|
||||
data = g_pGameRules;
|
||||
}
|
||||
|
||||
return get_member(data, member, element, dest);
|
||||
}
|
||||
|
||||
// native set_entvar(const index, const EntVars:var, any:...);
|
||||
@ -170,7 +178,7 @@ cell AMX_NATIVE_CALL get_entvar(AMX *amx, cell *params)
|
||||
CHECK_ISENTITY(arg_index);
|
||||
|
||||
edict_t *pEdict = edictByIndexAmx(params[arg_index]);
|
||||
if (pEdict == nullptr || pEdict->pvPrivateData == nullptr) {
|
||||
if (pEdict == nullptr || &pEdict->v == nullptr) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid or uninitialized entity", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
@ -202,6 +210,59 @@ cell AMX_NATIVE_CALL get_entvar(AMX *amx, cell *params)
|
||||
return get_member(&pEdict->v, member, element, dest);
|
||||
}
|
||||
|
||||
// native set_movevar(const MoveVars:var, any:...);
|
||||
cell AMX_NATIVE_CALL set_movevar(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_var, arg_value };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
auto& movevars = g_ReGameApi->GetPlayerMove()->movevars;
|
||||
if (movevars == nullptr) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: movevars not initialized", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
cell* value = getAmxAddr(amx, params[arg_value]);
|
||||
return set_member(movevars, member, 0, value);
|
||||
}
|
||||
|
||||
// native any:get_movevar(const MoveVars:var, any:...);
|
||||
cell AMX_NATIVE_CALL get_movevar(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_var, arg_2, arg_3 };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
cell* dest;
|
||||
size_t element;
|
||||
|
||||
auto& movevars = g_ReGameApi->GetPlayerMove()->movevars;
|
||||
if (movevars == nullptr) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: movevars not initialized", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (PARAMS_COUNT == 3) {
|
||||
dest = getAmxAddr(amx, params[arg_2]);
|
||||
element = *getAmxAddr(amx, params[arg_3]);
|
||||
}
|
||||
else {
|
||||
dest = nullptr;
|
||||
element = 0;
|
||||
}
|
||||
|
||||
return get_member(movevars, member, element, dest);
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO EntVars_Natives[] =
|
||||
{
|
||||
{ "set_entvar", set_entvar },
|
||||
@ -218,6 +279,9 @@ AMX_NATIVE_INFO Member_Natives[] =
|
||||
{ "set_member_game", set_member_game },
|
||||
{ "get_member_game", get_member_game },
|
||||
|
||||
{ "set_movevar", set_movevar },
|
||||
{ "get_movevar", get_movevar },
|
||||
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include "amxxmodule.h"
|
||||
#include "osconfig.h"
|
||||
|
||||
#include "pm_defs.h"
|
||||
#include "pm_movevars.h"
|
||||
|
||||
// regamedll API
|
||||
#include "gamerules.h"
|
||||
#include "regamedll_api.h"
|
||||
|
@ -12,6 +12,7 @@ char(&ArraySizeHelper(T(&array)[N]))[N];
|
||||
#endif
|
||||
|
||||
extern enginefuncs_t* g_pengfuncsTable;
|
||||
extern DLL_FUNCTIONS *g_pFunctionTable;
|
||||
|
||||
inline size_t indexOfEdict(edict_t* ed)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user