Hooking FireBullets
Posted: Wed May 04, 2016 4:38 pm
Since HL2DM doesn't have the 'weapon_fire' event, hooking FireBullets seemed like the way to go.
Here's the offset:And here's the code:
The hook works, I've tested it by adding print(), but I have no idea how to handle the FireBulletsInfo that's passed to the FireBullets hook.
Also, how can I add virtual offsets outside of core data files?
At the moment I'm adding the offsets into the core SP data files (source-python/data/source-python/entities/orangebox/hl2mp in this case), so every time there's an update, I have to add them again.
Here's the offset:
Code: Select all
#CHL2MP_Player::FireBullets(FireBulletsInfo_t const&)
[[fire_bullets]]
offset_linux = 113
offset_windows = 112
arguments = POINTER
return_type = INT
Syntax: Select all
from memory import make_object
from players.entity import Player
from entities.hooks import EntityPreHook, EntityCondition
@EntityPreHook(EntityCondition.is_player, 'fire_bullets')
def fire_bullets_hook(args):
player = make_object(Player, args[0])
# FireBulletsInfo??
info = make_object(????, args[1])
Also, how can I add virtual offsets outside of core data files?
At the moment I'm adding the offsets into the core SP data files (source-python/data/source-python/entities/orangebox/hl2mp in this case), so every time there's an update, I have to add them again.