Skip to content

Commit

Permalink
Merge branch 's1lentq:master' into nostalgia
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeperezz16 authored Mar 16, 2024
2 parents 8d9a726 + a7043d1 commit a736d6e
Show file tree
Hide file tree
Showing 14 changed files with 282 additions and 55 deletions.
12 changes: 12 additions & 0 deletions reapi/extra/amxmodx/scripting/include/cssdk_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1539,3 +1539,15 @@ enum Decal
DECAL_MOMMABIRTH, // Big momma birth splatter
DECAL_MOMMASPLAT,
};

/**
* Player relationship return codes
*/
enum
{
GR_NOTTEAMMATE = 0,
GR_TEAMMATE,
GR_ENEMY,
GR_ALLY,
GR_NEUTRAL,
};
28 changes: 22 additions & 6 deletions reapi/extra/amxmodx/scripting/include/reapi_engine.inc
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ native GetAttachment(const entity, const attachment, Float:vecOrigin[3], Float:v
* @return 1 on success, 0 otherwise
* @error If the index is not within the range of 1 to maxEntities or
* the entity is not valid, an error will be thrown.
*
*/
*
*/
native SetBodygroup(const entity, const group, const value);

/*
Expand All @@ -146,8 +146,8 @@ native SetBodygroup(const entity, const group, const value);
* @return Body group value
* @error If the index is not within the range of 1 to maxEntities or
* the entity is not valid, an error will be thrown.
*
*/
*
*/
native GetBodygroup(const entity, const group);

/*
Expand All @@ -161,10 +161,26 @@ native GetBodygroup(const entity, const group);
* @return True on success, false otherwise
* @error If the index is not within the range of 1 to maxEntities or
* the entity is not valid, an error will be thrown.
*
*/
*
*/
native bool:GetSequenceInfo(const entity, &piFlags, &Float:pflFrameRate, &Float:pflGroundSpeed);

/*
* Test visibility of an entity from a given origin using either PVS or PAS
*
* @param entity Entity index
* @param origin Vector representing the origin from which visibility is checked
* @param type Type of visibility check: VisibilityInPVS (Potentially Visible Set) or VisibilityInPAS (Potentially Audible Set)
*
* @return 0 - Not visible
* 1 - Visible, passed by a leafnum
* 2 - Visible, passed by a headnode
*
* @remarks This function checks the visibility of the specified entity from the given origin, using either
* the Potentially Visible Set (PVS) or the Potentially Audible Set (PAS) depending on the provided type
*/
native CheckVisibilityInOrigin(const ent, Float:origin[3], CheckVisibilityType:type = VisibilityInPVS);

/*
* Sets the name of the map.
*
Expand Down
21 changes: 15 additions & 6 deletions reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ enum MapNameType
MNT_SET // return the name of the current map
};

/**
* For native CheckVisibilityInOrigin
*/
enum CheckVisibilityType
{
VisibilityInPVS = 0, // Check in Potentially Visible Set (PVS)
VisibilityInPAS // Check in Potentially Audible Set (PAS)
};

/*
* For RH_SV_AddResource hook
*/
Expand Down Expand Up @@ -162,19 +171,19 @@ enum EngineFunc
*/
RH_SV_ClientPrintf,

/*
* Description: Called when a command is being sent to server.
* Params: (const cmd[], source, id)
*/
RH_ExecuteServerStringCmd,

/*
* Description: Called before adding an entity to the physents of a player.
* Return type: bool
* Params: (const entity, const client)
*/
RH_SV_AllowPhysent,

/*
* Description: Called when a command is being sent to server.
* Params: (const cmd[], source, id)
*/
RH_ExecuteServerStringCmd,

};

/**
Expand Down
22 changes: 16 additions & 6 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,12 @@ native rg_find_ent_by_class(start_index, const classname[], const bool:useHashTa
/*
* Finds an entity in the world using Counter-Strike's custom FindEntityByString wrapper, matching by owner.
*
* @param start_index Entity index to start searching from. -1 to start from the first entity
* @param start_index Entity index to start searching from. AMX_NULLENT (-1) to start from the first entity
* @param classname Classname to search for
*
* @return 1 if found, 0 otherwise
* @return true if found, false otherwise
*/
native rg_find_ent_by_owner(&start_index, const classname[], owner);
native bool:rg_find_ent_by_owner(&start_index, const classname[], owner);

/*
* Finds the weapon by name in the player's inventory.
Expand Down Expand Up @@ -1077,7 +1077,7 @@ native rg_emit_texture_sound(const ptr, Float:vecSrc[3], Float:vecEnd[3], Bullet
* @note To see a visual effect, WeaponList message should be sent using the custom ammo name,
* where ammo icon HUD will be the one listed in "sprites/weapon_<name>.txt" file.
*
* @param szAmmoname Ammo name to create.
* @param szAmmoname Ammo name to create.
*
* @note Maximum ammo index is 31, after that every ammo instantiation will start from 1 overriding existing ones.
* @return New ammo index. If name already exists, will return the matched index from memory.
Expand All @@ -1100,7 +1100,7 @@ native rg_remove_ammo_registry(const szAmmoname[]);
* @param szViewModel Weapon view model name ("models/v_*.mdl")
* @param szWeaponModel Weapon world model bame ("models/p_*.mdl")
* @param iAnim Weapon view model animation to play (often "deploy", use HLMV to see anim index)
* @param szAnimExt Player anim extension name to assign. Examples: "carbine", "shotgun", "knife", etc.
* @param szAnimExt Player anim extension name to assign. Examples: "carbine", "shotgun", "knife", etc.
* Use HLMV on a player model to see animext names.
* @param skiplocal If 0, weapon animation will be forced to play on client ignoring active client prediction.
*
Expand Down Expand Up @@ -1184,7 +1184,7 @@ native rg_switch_best_weapon(const player, const currentWeapon = 0);
native rg_disappear(const player);

/*
* Sets player current Observer mode.
* Sets player current Observer mode.
* @note Player must be a valid observer (m_afPhysicsFlags & PFLAG_OBSERVER).
*
* @param player Player index.
Expand All @@ -1204,3 +1204,13 @@ native rg_set_observer_mode(const player, const mode);
* @noreturn
*/
native rg_death_notice(const pVictim, const pKiller, const pevInflictor);

/*
* Checks a player relationship with another reference
*
* @param player Player index
* @param target Target index
*
* @return Match player relationship, see GR_* constants in cssdk_const.inc
*/
native rg_player_relationship(const player, const target);
22 changes: 21 additions & 1 deletion reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,15 @@ enum WpnInfo
* Get params: rg_get_weapon_info(const weapon_id, WI_NAME, const output[], maxlenght);
* Set params: -
*/
WI_NAME
WI_NAME,

/*
* Description: -
* Return type: enum InventorySlotType
* Get params: rg_get_weapon_info(const weapon_id, WI_SLOT);
* Set params: rg_set_weapon_info(const weapon_id, WI_SLOT, const value);
*/
WI_SLOT,
};

/**
Expand Down Expand Up @@ -914,6 +922,18 @@ enum GamedllFunc_CBasePlayer
* Params: (const this)
*/
RG_CBasePlayer_EntSelectSpawnPoint,

/*
* Description: -
* Params: (const this)
*/
RG_CBasePlayer_PlayerDeathThink,

/*
* Description: -
* Params: (const this)
*/
RG_CBasePlayer_Observer_Think,
};

/**
Expand Down
6 changes: 6 additions & 0 deletions reapi/include/cssdk/dlls/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ typedef IHookChainRegistry<void, class CBaseEntity *, class CBasePlayer *, class
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_PlayerDeathThink;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_PlayerDeathThink;

// CBasePlayer::Observer_Think hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Observer_Think;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_Observer_Think;

class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
Expand Down Expand Up @@ -782,6 +786,8 @@ class IReGameHookchains {
virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage() = 0;

virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0;

};

struct ReGameFuncs_t {
Expand Down
23 changes: 21 additions & 2 deletions reapi/src/hook_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ void PM_LadderMove_AMXX(IReGameHook_PM_LadderMove *chain, physent_t *pLadder, in

void PM_LadderMove(IReGameHook_PM_LadderMove *chain, physent_t *pLadder)
{
PM_LadderMove_AMXX(chain, pLadder, pLadder->player + 1);
PM_LadderMove_AMXX(chain, pLadder, g_pMove->player_index + 1);
}

void PM_WaterJump_AMXX(IReGameHook_PM_WaterJump *chain, int playerIndex)
Expand Down Expand Up @@ -1607,7 +1607,7 @@ void BuyItem(IReGameHook_BuyItem *chain, CBasePlayer *pPlayer, int iSlot)
chain->callNext(getPrivate<CBasePlayer>(_pPlayer), _iSlot);
};

callVoidForward(RG_AddMultiDamage, original, indexOfEdict(pPlayer->pev), iSlot);
callVoidForward(RG_BuyItem, original, indexOfEdict(pPlayer->pev), iSlot);
}

void CSGameRules_Think(IReGameHook_CSGameRules_Think *chain)
Expand Down Expand Up @@ -1710,6 +1710,25 @@ void CBasePlayerWeapon_SendWeaponAnim(IReGameHook_CBasePlayerWeapon_SendWeaponAn
callVoidForward(RG_CBasePlayerWeapon_SendWeaponAnim, original, indexOfEdict(pthis->pev), iAnim, skiplocal);
}

void CBasePlayer_PlayerDeathThink(IReGameHook_CBasePlayer_PlayerDeathThink *chain, CBasePlayer *pthis)
{
auto original = [chain](int _pthis)
{
chain->callNext(getPrivate<CBasePlayer>(_pthis));
};

callVoidForward(RG_CBasePlayer_PlayerDeathThink, original, indexOfEdict(pthis->pev));
}

void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, CBasePlayer *pthis)
{
auto original = [chain](int _pthis)
{
chain->callNext(getPrivate<CBasePlayer>(_pthis));
};

callVoidForward(RG_CBasePlayer_Observer_Think, original, indexOfEdict(pthis->pev));
}

/*
* VTC functions
Expand Down
2 changes: 2 additions & 0 deletions reapi/src/hook_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ edict_t *CBasePlayer_EntSelectSpawnPoint(IReGameHook_CBasePlayer_EntSelectSpawnP
void CBasePlayerWeapon_ItemPostFrame(IReGameHook_CBasePlayerWeapon_ItemPostFrame *chain, CBasePlayerWeapon *pthis);
void CBasePlayerWeapon_KickBack(IReGameHook_CBasePlayerWeapon_KickBack *chain, CBasePlayerWeapon *pthis, float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change);
void CBasePlayerWeapon_SendWeaponAnim(IReGameHook_CBasePlayerWeapon_SendWeaponAnim *chain, CBasePlayerWeapon *pthis, int iAnim, int skiplocal);
void CBasePlayer_PlayerDeathThink(IReGameHook_CBasePlayer_PlayerDeathThink *chain, CBasePlayer *pthis);
void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, CBasePlayer *pthis);

/*
* VTC functions
Expand Down
3 changes: 3 additions & 0 deletions reapi/src/hook_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ hook_t hooklist_player[] = {

DLL(CBasePlayer_CheckTimeBasedDamage),
DLL(CBasePlayer_EntSelectSpawnPoint),

DLL(CBasePlayer_PlayerDeathThink),
DLL(CBasePlayer_Observer_Think),
};

hook_t hooklist_gamerules[] = {
Expand Down
3 changes: 3 additions & 0 deletions reapi/src/hook_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ enum GamedllFunc_CBasePlayer
RG_CBasePlayer_CheckTimeBasedDamage,
RG_CBasePlayer_EntSelectSpawnPoint,

RG_CBasePlayer_PlayerDeathThink,
RG_CBasePlayer_Observer_Think,

// [...]
};

Expand Down
66 changes: 60 additions & 6 deletions reapi/src/natives/natives_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ cell AMX_NATIVE_CALL amx_GetAttachment(AMX *amx, cell *params)
* @return 1 on success, 0 otherwise
* @error If the index is not within the range of 1 to maxEntities or
* the entity is not valid, an error will be thrown.
*
*/
*
*/
cell AMX_NATIVE_CALL amx_GetBodygroup(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_group };
Expand Down Expand Up @@ -353,8 +353,8 @@ cell AMX_NATIVE_CALL amx_GetBodygroup(AMX *amx, cell *params)
* @return Body group value
* @error If the index is not within the range of 1 to maxEntities or
* the entity is not valid, an error will be thrown.
*
*/
*
*/
cell AMX_NATIVE_CALL amx_SetBodygroup(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_group, arg_value };
Expand Down Expand Up @@ -387,8 +387,8 @@ cell AMX_NATIVE_CALL amx_SetBodygroup(AMX *amx, cell *params)
* @return True on success, false otherwise
* @error If the index is not within the range of 1 to maxEntities or
* the entity is not valid, an error will be thrown.
*
*/
*
*/
cell AMX_NATIVE_CALL amx_GetSequenceInfo(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_flags, arg_framerate, arg_groundspeed };
Expand Down Expand Up @@ -634,6 +634,58 @@ cell AMX_NATIVE_CALL amx_SetMoveDone(AMX *amx, cell *params)
return (cell)EntityCallbackDispatcher().SetMoveDone(amx, pEntity, funcname, pParams, params[arg_len]);
}

enum class CheckVisibilityType {
PVS = 0, // Check in Potentially Visible Set (PVS)
PAS // Check in Potentially Audible Set (PAS)
};

/*
* Test visibility of an entity from a given origin using either PVS or PAS
*
* @param entity Entity index
* @param origin Vector representing the origin from which visibility is checked
* @param type Type of visibility check: VisibilityInPVS (Potentially Visible Set) or VisibilityInPAS (Potentially Audible Set)
*
* @return 0 - Not visible
* 1 - Visible, passed by a leafnum
* 2 - Visible, passed by a headnode
*
* @remarks This function checks the visibility of the specified entity from the given origin, using either
* the Potentially Visible Set (PVS) or the Potentially Audible Set (PAS) depending on the provided type
*
* native CheckVisibilityInOrigin(const ent, Float:origin[3], CheckVisibilityType:type = VisibilityInPVS);
*/
cell AMX_NATIVE_CALL amx_CheckVisibilityInOrigin(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_origin, arg_type };

CHECK_ISENTITY(arg_index);

CBaseEntity *pEntity = getPrivate<CBaseEntity>(params[arg_index]);
if (unlikely(pEntity == nullptr)) {
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: invalid or uninitialized entity", __FUNCTION__);
return FALSE;
}

CheckVisibilityType type = static_cast<CheckVisibilityType>(params[arg_type]);
if (type < CheckVisibilityType::PVS || type > CheckVisibilityType::PAS) {
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: invalid visibility check type %d. Use either VisibilityInPVS or VisibilityInPAS.", __FUNCTION__, params[arg_type]);
return FALSE;
}

Vector &origin = *(Vector *)getAmxAddr(amx, params[arg_origin]);

unsigned char *pSet = NULL;
switch (type)
{
case CheckVisibilityType::PVS: pSet = ENGINE_SET_PVS(origin); break;
case CheckVisibilityType::PAS: pSet = ENGINE_SET_PAS(origin); break;
default: break;
}

return ENGINE_CHECK_VISIBILITY(pEntity->edict(), pSet);
}

AMX_NATIVE_INFO Natives_Common[] =
{
{ "FClassnameIs", amx_FClassnameIs },
Expand All @@ -655,6 +707,8 @@ AMX_NATIVE_INFO Natives_Common[] =
{ "SetBlocked", amx_SetBlocked },
{ "SetMoveDone", amx_SetMoveDone },

{ "CheckVisibilityInOrigin", amx_CheckVisibilityInOrigin },

{ nullptr, nullptr }
};

Expand Down
Loading

0 comments on commit a736d6e

Please sign in to comment.