Skip to content

Commit

Permalink
API: New gamedll hookchains (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
dystopm authored Sep 5, 2023
1 parent 4ef1955 commit 2142208
Show file tree
Hide file tree
Showing 8 changed files with 719 additions and 11 deletions.
117 changes: 114 additions & 3 deletions reapi/extra/amxmodx/scripting/include/cssdk_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
* global_get(glb_trace_flags) values
* @note Custom flags that we can retrieve in pfnShouldCollide/TraceLine/TraceHull
*/
#define FTRACE_BULLET (1<<16)
#define FTRACE_FLASH (1<<17)
#define FTRACE_KNIFE (1<<18)
#define FTRACE_BULLET (1<<16)
#define FTRACE_FLASH (1<<17)
#define FTRACE_KNIFE (1<<18)

/**
* get_entvar(entity, var_movetype) values
Expand Down Expand Up @@ -1368,3 +1368,114 @@ enum InfoMapBuyParam
#define SCORE_STATUS_BOMB (1<<1)
#define SCORE_STATUS_VIP (1<<2)
#define SCORE_STATUS_DEFKIT (1<<3)

/**
* For RG_CBotManager_OnEvent
*/
enum GameEventType
{
EVENT_INVALID = 0,
EVENT_WEAPON_FIRED, // tell bots the player is attack (argumens: 1 = attacker, 2 = NULL)
EVENT_WEAPON_FIRED_ON_EMPTY, // tell bots the player is attack without clip ammo (argumens: 1 = attacker, 2 = NULL)
EVENT_WEAPON_RELOADED, // tell bots the player is reloading his weapon (argumens: 1 = reloader, 2 = NULL)

EVENT_HE_GRENADE_EXPLODED, // tell bots the HE grenade is exploded (argumens: 1 = grenade thrower, 2 = NULL)
EVENT_FLASHBANG_GRENADE_EXPLODED, // tell bots the flashbang grenade is exploded (argumens: 1 = grenade thrower, 2 = explosion origin)
EVENT_SMOKE_GRENADE_EXPLODED, // tell bots the smoke grenade is exploded (argumens: 1 = grenade thrower, 2 = NULL)
EVENT_GRENADE_BOUNCED,

EVENT_BEING_SHOT_AT,
EVENT_PLAYER_BLINDED_BY_FLASHBANG, // tell bots the player is flashed (argumens: 1 = flashed player, 2 = NULL)
EVENT_PLAYER_FOOTSTEP, // tell bots the player is running (argumens: 1 = runner, 2 = NULL)
EVENT_PLAYER_JUMPED, // tell bots the player is jumped (argumens: 1 = jumper, 2 = NULL)
EVENT_PLAYER_DIED, // tell bots the player is killed (argumens: 1 = victim, 2 = killer)
EVENT_PLAYER_LANDED_FROM_HEIGHT, // tell bots the player is fell with some damage (argumens: 1 = felled player, 2 = NULL)
EVENT_PLAYER_TOOK_DAMAGE, // tell bots the player is take damage (argumens: 1 = victim, 2 = attacker)
EVENT_HOSTAGE_DAMAGED, // tell bots the player has injured a hostage (argumens: 1 = hostage, 2 = injurer)
EVENT_HOSTAGE_KILLED, // tell bots the player has killed a hostage (argumens: 1 = hostage, 2 = killer)

EVENT_DOOR, // tell bots the door is moving (argumens: 1 = door, 2 = NULL)
EVENT_BREAK_GLASS, // tell bots the glass has break (argumens: 1 = glass, 2 = NULL)
EVENT_BREAK_WOOD, // tell bots the wood has break (argumens: 1 = wood, 2 = NULL)
EVENT_BREAK_METAL, // tell bots the metal/computer has break (argumens: 1 = metal/computer, 2 = NULL)
EVENT_BREAK_FLESH, // tell bots the flesh has break (argumens: 1 = flesh, 2 = NULL)
EVENT_BREAK_CONCRETE, // tell bots the concrete has break (argumens: 1 = concrete, 2 = NULL)

EVENT_BOMB_PLANTED, // tell bots the bomb has been planted (argumens: 1 = planter, 2 = NULL)
EVENT_BOMB_DROPPED, // tell bots the bomb has been dropped (argumens: 1 = NULL, 2 = NULL)
EVENT_BOMB_PICKED_UP, // let the bots hear the bomb pickup (argumens: 1 = player that pickup c4, 2 = NULL)
EVENT_BOMB_BEEP, // let the bots hear the bomb beeping (argumens: 1 = c4, 2 = NULL)
EVENT_BOMB_DEFUSING, // tell the bots someone has started defusing (argumens: 1 = defuser, 2 = NULL)
EVENT_BOMB_DEFUSE_ABORTED, // tell the bots someone has aborted defusing (argumens: 1 = NULL, 2 = NULL)
EVENT_BOMB_DEFUSED, // tell the bots the bomb is defused (argumens: 1 = defuser, 2 = NULL)
EVENT_BOMB_EXPLODED, // let the bots hear the bomb exploding (argumens: 1 = NULL, 2 = NULL)

EVENT_HOSTAGE_USED, // tell bots the hostage is used (argumens: 1 = user, 2 = NULL)
EVENT_HOSTAGE_RESCUED, // tell bots the hostage is rescued (argumens: 1 = rescuer (CBasePlayer *), 2 = hostage (CHostage *))
EVENT_ALL_HOSTAGES_RESCUED, // tell bots the all hostages are rescued (argumens: 1 = NULL, 2 = NULL)

EVENT_VIP_ESCAPED, // tell bots the VIP is escaped (argumens: 1 = NULL, 2 = NULL)
EVENT_VIP_ASSASSINATED, // tell bots the VIP is assassinated (argumens: 1 = NULL, 2 = NULL)
EVENT_TERRORISTS_WIN, // tell bots the terrorists won the round (argumens: 1 = NULL, 2 = NULL)
EVENT_CTS_WIN, // tell bots the CTs won the round (argumens: 1 = NULL, 2 = NULL)
EVENT_ROUND_DRAW, // tell bots the round was a draw (argumens: 1 = NULL, 2 = NULL)
EVENT_ROUND_WIN, // tell carreer the round was a win (argumens: 1 = NULL, 2 = NULL)
EVENT_ROUND_LOSS, // tell carreer the round was a loss (argumens: 1 = NULL, 2 = NULL)
EVENT_ROUND_START, // tell bots the round was started (when freeze period is expired) (argumens: 1 = NULL, 2 = NULL)
EVENT_PLAYER_SPAWNED, // tell bots the player is spawned (argumens: 1 = spawned player, 2 = NULL)
EVENT_CLIENT_CORPSE_SPAWNED,
EVENT_BUY_TIME_START,
EVENT_PLAYER_LEFT_BUY_ZONE,
EVENT_DEATH_CAMERA_START,
EVENT_KILL_ALL,
EVENT_ROUND_TIME,
EVENT_DIE,
EVENT_KILL,
EVENT_HEADSHOT,
EVENT_KILL_FLASHBANGED,
EVENT_TUTOR_BUY_MENU_OPENNED,
EVENT_TUTOR_AUTOBUY,
EVENT_PLAYER_BOUGHT_SOMETHING,
EVENT_TUTOR_NOT_BUYING_ANYTHING,
EVENT_TUTOR_NEED_TO_BUY_PRIMARY_WEAPON,
EVENT_TUTOR_NEED_TO_BUY_PRIMARY_AMMO,
EVENT_TUTOR_NEED_TO_BUY_SECONDARY_AMMO,
EVENT_TUTOR_NEED_TO_BUY_ARMOR,
EVENT_TUTOR_NEED_TO_BUY_DEFUSE_KIT,
EVENT_TUTOR_NEED_TO_BUY_GRENADE,
EVENT_CAREER_TASK_DONE,

EVENT_START_RADIO_1,
EVENT_RADIO_COVER_ME,
EVENT_RADIO_YOU_TAKE_THE_POINT,
EVENT_RADIO_HOLD_THIS_POSITION,
EVENT_RADIO_REGROUP_TEAM,
EVENT_RADIO_FOLLOW_ME,
EVENT_RADIO_TAKING_FIRE,
EVENT_START_RADIO_2,
EVENT_RADIO_GO_GO_GO,
EVENT_RADIO_TEAM_FALL_BACK,
EVENT_RADIO_STICK_TOGETHER_TEAM,
EVENT_RADIO_GET_IN_POSITION_AND_WAIT,
EVENT_RADIO_STORM_THE_FRONT,
EVENT_RADIO_REPORT_IN_TEAM,
EVENT_START_RADIO_3,
EVENT_RADIO_AFFIRMATIVE,
EVENT_RADIO_ENEMY_SPOTTED,
EVENT_RADIO_NEED_BACKUP,
EVENT_RADIO_SECTOR_CLEAR,
EVENT_RADIO_IN_POSITION,
EVENT_RADIO_REPORTING_IN,
EVENT_RADIO_GET_OUT_OF_THERE,
EVENT_RADIO_NEGATIVE,
EVENT_RADIO_ENEMY_DOWN,
EVENT_END_RADIO,

EVENT_NEW_MATCH, // tell bots the game is new (argumens: 1 = NULL, 2 = NULL)
EVENT_PLAYER_CHANGED_TEAM, // tell bots the player is switch his team (also called from ClientPutInServer()) (argumens: 1 = switcher, 2 = NULL)
EVENT_BULLET_IMPACT, // tell bots the player is shoot at wall (argumens: 1 = shooter, 2 = shoot trace end position)
EVENT_GAME_COMMENCE, // tell bots the game is commencing (argumens: 1 = NULL, 2 = NULL)
EVENT_WEAPON_ZOOMED, // tell bots the player is switch weapon zoom (argumens: 1 = zoom switcher, 2 = NULL)
EVENT_HOSTAGE_CALLED_FOR_HELP, // tell bots the hostage is talking (argumens: 1 = listener, 2 = NULL)
NUM_GAME_EVENTS,
};
9 changes: 6 additions & 3 deletions reapi/extra/amxmodx/scripting/include/reapi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ enum hooks_tables_e
ht_weaponbox,
ht_weapon,
ht_gib,
ht_cbaseentity
ht_cbaseentity,
ht_botmanager
};

enum members_tables_e
Expand Down Expand Up @@ -81,6 +82,8 @@ enum members_tables_e
mt_gib
};

#define ReAPIFunc {EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon, GamedllFunc_CGib, GamedllFunc_CBaseEntity, GamedllFunc_CBotManager}

// Is like FNullEnt
#define is_nullent(%0) (%0 == 0 || is_entity(%0) == false)

Expand Down Expand Up @@ -149,7 +152,7 @@ enum HookChain
*
* @return Returns a hook handle. Use EnableHookChain/DisableHookChain to toggle the forward on or off
*/
native HookChain:RegisterHookChain({EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon, GamedllFunc_CGib, GamedllFunc_CBaseEntity}:function_id, const callback[], post = 0);
native HookChain:RegisterHookChain(ReAPIFunc:function_id, const callback[], post = 0);

/*
* Stops a hook from triggering.
Expand Down Expand Up @@ -210,7 +213,7 @@ native SetHookChainArg(number, AType:type, any:...);
*
* @return Returns true if the original function was called, otherwise false
*/
native bool:IsReapiHookOriginalWasCalled({EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon, GamedllFunc_CGib}:function_id);
native bool:IsReapiHookOriginalWasCalled(ReAPIFunc:function_id);

/*
* Returns the current hookchain handle.
Expand Down
144 changes: 144 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,72 @@ enum GamedllFunc
* Params: (const pLadder, const playerIndex)
*/
RG_PM_LadderMove,

/*
* Description: Called on every frame after a player jumps on water for a short period of time
* Params: (const playerIndex)
*/
RG_PM_WaterJump,

/*
* Description: Called when a player jumps on water for the first time
* Params: (const playerIndex)
*/
RG_PM_CheckWaterJump,

/*
* Description: Called on every frame while player presses jump button
* Params: (const playerIndex)
*/
RG_PM_Jump,

/*
* Description: Called on every frame to check player ducking
* Params: (const playerIndex)
*/
RG_PM_Duck,

/*
* Description: Called whenever player tries to unduck
* Params: (const playerIndex)
*/
RG_PM_UnDuck,

/*
* Description: Called whenever player emits an step sound
* Params: (step, Float:fvol, const playerIndex)
*/
RG_PM_PlayStepSound,

/*
* Description: Called whenever player is on air (not touching floor)
* Params: (Float:wishdir[3], Float:wishspeed, Float:accel, const playerIndex)
*/
RG_PM_AirAccelerate,

/*
* Description: Called when game clears multidamage data (before TraceAttack)
* Params: ()
*/
RG_ClearMultiDamage,

/*
* Description: Called inside TraceAttack to store entity damage to multidamage data
* Params: (const pevInflictor, const pEntity, Float:flDamage, bitsDamageType)
*/
RG_AddMultiDamage,

/*
* Description: Called after game finished a bullet tracing for applying damage cached on multidamage data
* Params: (const pevInflictor, const pevAttacker)
*/
RG_ApplyMultiDamage,

/*
* Description: Called when player buys an item from buy menu (Nightvision, Kevlar, etc.)
* Params: (const pPlayer, iSlot)
*/
RG_BuyItem,
};

/**
Expand Down Expand Up @@ -834,6 +900,20 @@ enum GamedllFunc_CBasePlayer
* Params: (const this)
*/
RG_CBasePlayer_JoiningThink,

/*
* Description: Called every client frame to check time based damage
* Return type: void
* Params: (const this)
*/
RG_CBasePlayer_CheckTimeBasedDamage,

/*
* Description: Called when game selects a spawn point (info_player_start/deathmatch) to position the player
* Return type: edict_t * (Entity index of selected spawn point)
* Params: (const this)
*/
RG_CBasePlayer_EntSelectSpawnPoint,
};

/**
Expand Down Expand Up @@ -868,6 +948,29 @@ enum GamedllFunc_CBasePlayerWeapon
* Params: (const this, iAnim, iStartAnim, Float:fDelay, Float:fStartDelay, const pszReloadSound1[], const pszReloadSound2[])
*/
RG_CBasePlayerWeapon_DefaultShotgunReload,

/*
* Description: Called every client frame (PlayerPostThink) for the player's active weapon
* Return type: void
* Params: (const this)
*/
RG_CBasePlayerWeapon_ItemPostFrame,

/*
* Description: Called whenever player fires a weapon and shakes player screen (punchangles altering)
* @note Weapons that use KickBack: AK47, AUG, FAMAS, GALIL, M249, M4A1, MAC10, MP5NAVY, P90, SG552, TMP, UMP45
* Return type: void
* Params: (const this, Float:up_base, Float:lateral_base, Float:up_modifier, Float:lateral_modifier, Float:p_max, Float:lateral_max, direction_change)
*/
RG_CBasePlayerWeapon_KickBack,

/*
* Description: Called whenever game sends an animation to his current holder (player)
* @note This is often called for all animations in exception of "fire" and "idle" sequences (both called via client prediction)
* Return type: void
* Params: (const this, iAnim, skiplocal)
*/
RG_CBasePlayerWeapon_SendWeaponAnim,
};

/**
Expand Down Expand Up @@ -922,6 +1025,21 @@ enum GamedllFunc_CBaseEntity
RG_CBaseEntity_FireBullets3,
};

/**
* GamedllFunc CBotManager
*/
enum GamedllFunc_CBotManager
{
/*
* Description: Called on each improved bot event
* Return type: void
* Params: (GameEventType:event, const pEntity, const pOther)
*/
RG_CBotManager_OnEvent = BEGIN_FUNC_REGION(botmanager),
}


/**
* GamedllFunc CSGameRules
*/
Expand Down Expand Up @@ -1081,6 +1199,32 @@ enum GamedllFunc_CSGameRules
* Params: (const listener, const sender)
*/
RG_CSGameRules_CanPlayerHearPlayer,

/*
* Description: Called every server frame to process game rules
* Params: ()
*/
RG_CSGameRules_Think,

/*
* Description: Called each time player tries to join a team to ensure availability
* Return type: bool
* Params: (team_id)
*/
RG_CSGameRules_TeamFull,

/*
* Description: Called each time player tries to join a team to ensure a fair distribution of players (based on mp_limitteams cvar)
* Return type: bool
* Params: (newTeam_id, curTeam_id)
*/
RG_CSGameRules_TeamStacked,

/*
* Description: Called each time player gets a weapon linked to his inventory
* Params: (const pPlayer, const pWeapon)
*/
RG_CSGameRules_PlayerGotWeapon,
};

/**
Expand Down
Loading

0 comments on commit 2142208

Please sign in to comment.