Code:
//////////////////////////////////////////////////
// 90000: LevelUp
// X1 - hero who got a level
//////////////////////////////////////////////////
PROCEDURE HookTrigger_LevelUp; ASSEMBLER; {$FRAME-}
ASM
// Restore default code
MOV DataTemp, $59A890
CALL DataTemp
MOV EAX, DWORD PTR DS:[$69959C]
MOVSX ECX, AX
// Push all registers
PUSHAD
// Move hero number to X1
MOV EAX, [LevelUp_HeroNumber]
ADD EAX, 4
MOV EAX, [EAX]
MOV ECX, VAR_X
MOV [ECX], EAX
// Move level to X2
MOV EAX, [LevelUp_HeroLevel]
MOV ECX, VAR_X+4
MOV [ECX], EAX
// Call ERM function
PUSH 90000
MOV EAX, ERMFunction
CALL EAX
ADD ESP, 4
// Restore all registers
POPAD // Restore all registers
// Return
PUSH $4DACA7
END; // .PROCEDURE HookTrigger_LevelUp
//////////////////////////////////////////////////
// 90001: AfterLevelUp
// X1 - hero who got a level
//////////////////////////////////////////////////
PROCEDURE HookTrigger_AfterLevelUp; ASSEMBLER; {$FRAME-}
ASM
// Restore default code
MOV EDX, DWORD PTR SS:[EBP-10]
MOVSX ECX, AX
CMP ECX, EDX
// Push all registers
PUSHAD
// Move hero number to X1
MOV EAX, [LevelUp_HeroNumber]
ADD EAX, 4
MOV EAX, [EAX]
MOV ECX, VAR_X
MOV [ECX], EAX
// Move level to X2
MOV EAX, [LevelUp_HeroLevel]
MOV ECX, VAR_X+4
MOV [ECX], EAX
// Call ERM function
PUSH 90001
MOV EAX, ERMFunction
CALL EAX
ADD ESP, 4
// Restore all registers
POPAD // Restore all registers
// Return
PUSH $4DAF12
END; // .PROCEDURE HookTrigger_AfterLevelUp
BEGIN
HookCode(POINTER($4DAC9B), @HookTrigger_LevelUp, C_HOOKTYPE_JUMP); // 90000
HookCode(POINTER($4DAF0A), @HookTrigger_AfterLevelUp, C_HOOKTYPE_JUMP); // 90001
END.