Skip to content

Commit

Permalink
BuildSfxHook: remove first arg, rename hook
Browse files Browse the repository at this point in the history
  • Loading branch information
phobos2077 committed Jul 18, 2024
1 parent 5d75394 commit 196c727
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
3 changes: 2 additions & 1 deletion artifacts/scripting/headers/sfall.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
#define HOOK_ROLLCHECK (46)
#define HOOK_BESTWEAPON (47)
#define HOOK_CANUSEWEAPON (48)
#define HOOK_BUILDSFXNAME (57)
// RESERVED 49..60
#define HOOK_BUILDSFXWEAPON (61)

// Valid arguments to list_begin
#define LIST_CRITTERS (0)
Expand Down
6 changes: 5 additions & 1 deletion sfall/Modules/HookScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ static HooksInjectInfo injectHooks[] = {
{HOOK_CANUSEWEAPON, Inject_CanUseWeaponHook, 0},
{-1}, // RESERVED
{-1}, // RESERVED
{-1}, // HOOK_MOUSEWHEEL
{-1}, // RESERVED
{-1}, // RESERVED
{-1}, // RESERVED
{-1}, // HOOK_COMBATATTACK
{-1}, // RESERVED
{-1}, // RESERVED
{-1}, // RESERVED
{HOOK_BUILDSFXNAME, Inject_BuildSfxNameHook, 0},
{-1}, // RESERVED
{-1}, // RESERVED
{HOOK_BUILDSFXWEAPON, Inject_BuildSfxWeaponHook, 0},
};

void HookScripts::InjectingHook(int hookId) {
Expand Down
4 changes: 2 additions & 2 deletions sfall/Modules/HookScripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ enum HookType
HOOK_ROLLCHECK = 46,
HOOK_BESTWEAPON = 47,
HOOK_CANUSEWEAPON = 48,
// RESERVED 49 to 56
HOOK_BUILDSFXNAME = 57,
// RESERVED 49 to 60
HOOK_BUILDSFXWEAPON = 61,
HOOK_COUNT
};

Expand Down
17 changes: 8 additions & 9 deletions sfall/Modules/HookScripts/SoundHs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ namespace sfall
static DWORD __fastcall BuildSfxNameHook_Script(long effectType, fo::GameObject* weapon, long hitMode, fo::GameObject* target) {
BeginHook();
allowNonIntReturn = true;
argCount = 5;
argCount = 4;

args[0] = 1; // weapon_sfx
args[1] = effectType;
args[2] = (DWORD)weapon;
args[3] = (DWORD)hitMode;
args[4] = (DWORD)target;
args[0] = effectType;
args[1] = (DWORD)weapon;
args[2] = (DWORD)hitMode;
args[3] = (DWORD)target;

RunHookScript(HOOK_BUILDSFXNAME);
RunHookScript(HOOK_BUILDSFXWEAPON);

DWORD textPtr = cRet > 0 && retTypes[0] == DataType::STR
? rets[0]
Expand Down Expand Up @@ -55,7 +54,7 @@ static __declspec(naked) void gsnd_build_weapon_sfx_name_hook() {
}


void Inject_BuildSfxNameHook() {
void Inject_BuildSfxWeaponHook() {
HookCalls(gsnd_build_weapon_sfx_name_hook, {
0x410DB3, // show_damage_to_object
0x411397, 0x411538, // action_melee
Expand All @@ -70,7 +69,7 @@ void Inject_BuildSfxNameHook() {
}

void InitSoundHookScripts() {
HookScripts::LoadHookScript("hs_buildsfxname", HOOK_BUILDSFXNAME);
HookScripts::LoadHookScript("hs_buildsfxweapon", HOOK_BUILDSFXWEAPON);
}

}
2 changes: 1 addition & 1 deletion sfall/Modules/HookScripts/SoundHs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace sfall

void InitSoundHookScripts();

void Inject_BuildSfxNameHook();
void Inject_BuildSfxWeaponHook();

}

0 comments on commit 196c727

Please sign in to comment.