Skip to content

Commit a1c0388

Browse files
committed
Changed HOOK_DESCRIPTIONOBJ to run for all types of objects (#293)
1 parent ef0bdf1 commit a1c0388

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

artifacts/scripting/hookscripts.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,11 @@ int ret1 - overrides the result of engine calculation: 0/1 - failure, 2/3 -
563563

564564
HOOK_DESCRIPTIONOBJ (hs_descriptionobj.int)
565565

566-
Runs when using the examine action icon to display item description. You can override the description of the item.
566+
Runs when using the examine action icon to display the description of an object. You can override the description text.
567567
An example usage would be to add an additional description to the item based on player's stats/skills.
568+
Does not run if the script of the object overrides the description.
568569

569-
Obj arg0 - the item
570+
Obj arg0 - the object
570571

571572
int ret0 - a pointer to the new text received by using "get_string_pointer" function
572573

@@ -731,7 +732,7 @@ int arg0 - event type:
731732
3 - checks the chance when using skills (not listed below)
732733
4 - check the chance of using Repair skill
733734
5 - check the chance of using Doctor skill
734-
6 - check the chance of using Steal skill for the thief
735+
6 - check the chance of using Steal skill for the thief (usually the player)
735736
7 - the second Steal skill chance check for the target to catch the thief, in which the target's failure is the thief's success result
736737
int arg1 - the value of roll result (see ROLL_* constants), which is calculated as:
737738
for ROLL_CRITICAL_SUCCESS: random(1, 100) <= (random_chance / 10) + bonus

sfall/CheckAddress.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ std::multimap<long, long> writeAddress;
1111

1212
static std::vector<long> excludeWarning = {
1313
0x44E949, 0x44E94A, 0x44E937, 0x4F5F40, 0x44E932, // from movies.cpp
14-
0x42D21C, // CritterPoison.cpp
14+
0x42D21C, // CritterPoison.cpp
1515
};
1616

1717
static std::vector<long> excludeConflict = {
@@ -107,6 +107,7 @@ static std::vector<HackPair> hackAddr = {
107107
// module: Skills
108108
{0x4AA59D, 5}, {0x4AA738, 5}, {0x4AA940, 5},
109109
{0x4AA9E1, 1}, {0x4AA9E2, 4}, {0x4AA9F1, 1}, {0x4AA9F2, 4}, {0x4AA9EC, 1}, {0x4AA9ED, 4}, // hookcalls
110+
{0x4AA60E, 2}, {0x4AA612, 1},
110111
// module: Stats
111112
{0x4AF6FC, 5},
112113
// module: Worldmap
@@ -116,6 +117,10 @@ static std::vector<HackPair> hackAddr = {
116117
{0x49952C, 1}, {0x497557, 1}, {0x42E587, 1}, {0x42E588, 4}, {0x499FD4, 2}, {0x499E93, 2},
117118
// module: MiscPatches
118119
{0x41276A, 1}, {0x480AAA, 4}, {0x444BA5, 4}, {0x444BCA, 4},
120+
121+
// Called from engine
122+
// MiscHS.cpp (HOOK_ROLLCHECK)
123+
{0x42388E, 5}, {0x4234D1, 5}, {0x42356C, 5}, {0x4AAB29, 5}, {0x4AB3B6, 5}, {0x4AB8B5, 5}, {0x4ABC9F, 5}, {0x4ABCE6, 5},
119124
};
120125

121126
//static std::vector<long> jumpAddr = {

sfall/Modules/HookScripts/ObjectHs.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void __declspec(naked) UseAnimateObjHook() {
134134
}
135135
}
136136

137-
static DWORD __stdcall DescriptionObjHook_Script(DWORD object) {
137+
static DWORD __fastcall DescriptionObjHook_Script(DWORD object) {
138138
BeginHook();
139139
argCount = 1;
140140

@@ -150,20 +150,18 @@ static DWORD __stdcall DescriptionObjHook_Script(DWORD object) {
150150

151151
static void __declspec(naked) DescriptionObjHook() {
152152
__asm {
153-
push eax;
154-
push edx;
155153
push ecx;
156-
push eax; // object
154+
push edx;
155+
mov ecx, eax; // object
157156
call DescriptionObjHook_Script;
158-
pop ecx;
159157
pop edx;
160-
test eax, eax; // pointer to text
161-
jz skip;
162-
add esp, 4; // destroy push eax
163-
retn;
158+
pop ecx;
159+
test eax, eax; // pointer to text
160+
jnz skip;
161+
mov eax, ebp;
162+
jmp fo::funcoffs::object_description_;
164163
skip:
165-
pop eax;
166-
jmp fo::funcoffs::item_description_;
164+
retn;
167165
}
168166
}
169167

@@ -387,7 +385,7 @@ void Inject_UseAnimateObjHook() {
387385
}
388386

389387
void Inject_DescriptionObjHook() {
390-
HookCall(0x48C925, DescriptionObjHook);
388+
HookCall(0x49AE28, DescriptionObjHook);
391389
}
392390

393391
void Inject_SetLightingHook() {

0 commit comments

Comments
 (0)