mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed the script attached to an object not running upon object creation (#359)
This commit is contained in:
@@ -346,13 +346,14 @@ To add proper check for ammo before shooting and proper calculation of number of
|
|||||||
Item arg0 - The weapon
|
Item arg0 - The weapon
|
||||||
int arg1 - Number of bullets in burst or 1 for single shots
|
int arg1 - Number of bullets in burst or 1 for single shots
|
||||||
int arg2 - The amount of ammo that will be consumed, calculated by the original ammo cost function (this is basically 2 for Super Cattle Prod and Mega Power Fist)
|
int arg2 - The amount of ammo that will be consumed, calculated by the original ammo cost function (this is basically 2 for Super Cattle Prod and Mega Power Fist)
|
||||||
|
NOTE: for hook type 2, this value is the ammo cost per round (default is always 1)
|
||||||
int arg3 - Type of hook:
|
int arg3 - Type of hook:
|
||||||
0 - when subtracting ammo after single shot attack
|
0 - when subtracting ammo after single shot attack
|
||||||
1 - when checking for "out of ammo" before attack
|
1 - when checking for "out of ammo" before attack
|
||||||
2 - when calculating number of burst rounds
|
2 - when calculating number of burst rounds
|
||||||
3 - when subtracting ammo after burst attack
|
3 - when subtracting ammo after burst attack
|
||||||
|
|
||||||
int ret0 - The new amount of ammo to be consumed, or ammo cost of each round for hook type 2 (set to 0 for unlimited ammo)
|
int ret0 - The new amount of ammo to be consumed, or ammo cost per round for hook type 2 (set to 0 for unlimited ammo)
|
||||||
|
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
|
||||||
|
|||||||
+20
-5
@@ -1542,11 +1542,11 @@ end:
|
|||||||
|
|
||||||
static void __declspec(naked) ai_combat_turn_run_hook() {
|
static void __declspec(naked) ai_combat_turn_run_hook() {
|
||||||
__asm {
|
__asm {
|
||||||
call combat_turn_run_;
|
call combat_turn_run_;
|
||||||
movzx dx, word ptr [esi + damageFlags]; // combat_data.results
|
mov edx, [esi + damageFlags]; // combat_data.results
|
||||||
test dx, DAM_DEAD or DAM_KNOCKED_OUT or DAM_LOSE_TURN;
|
test edx, DAM_DEAD or DAM_KNOCKED_OUT or DAM_LOSE_TURN;
|
||||||
jz end;
|
jz end;
|
||||||
mov [esi + movePoints], 0; // pobj.curr_mp (source reset ap)
|
mov [esi + movePoints], 0; // pobj.curr_mp (source reset ap)
|
||||||
end:
|
end:
|
||||||
retn;
|
retn;
|
||||||
}
|
}
|
||||||
@@ -2864,6 +2864,18 @@ skip:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __declspec(naked) op_create_object_sid_hack() {
|
||||||
|
__asm {
|
||||||
|
mov ebx, [esp + 0x50 - 0x20 + 4]; // createObj
|
||||||
|
mov edx, 1; // 'start' procedure
|
||||||
|
mov eax, [ebx + scriptId];
|
||||||
|
call exec_script_proc_;
|
||||||
|
mov edx, ebx;
|
||||||
|
mov eax, esi;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BugFixes_OnGameLoad() {
|
void BugFixes_OnGameLoad() {
|
||||||
dudeIsAnimDeath = false;
|
dudeIsAnimDeath = false;
|
||||||
}
|
}
|
||||||
@@ -3630,4 +3642,7 @@ void BugFixes_Init()
|
|||||||
// Fix for the "Leave" event procedure of the window region not being triggered when the cursor moves to a non-scripted window
|
// Fix for the "Leave" event procedure of the window region not being triggered when the cursor moves to a non-scripted window
|
||||||
MakeJump(0x4B6C3B, checkAllRegions_hack);
|
MakeJump(0x4B6C3B, checkAllRegions_hack);
|
||||||
HookCall(0x4B6C13, checkAllRegions_hook);
|
HookCall(0x4B6C13, checkAllRegions_hook);
|
||||||
|
|
||||||
|
// Fix for the script attached to an object not running upon object creation
|
||||||
|
MakeCall(0x4551C0, op_create_object_sid_hack, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -690,8 +690,10 @@ static void EngineOptimizationPatches() {
|
|||||||
// Speed up display_msg script function
|
// Speed up display_msg script function
|
||||||
HookCall(0x455404, op_display_msg_hook);
|
HookCall(0x455404, op_display_msg_hook);
|
||||||
|
|
||||||
// Remove duplicate code from intface_redraw_ engine function
|
// Remove redundant/duplicate code
|
||||||
BlockCall(0x45EBBF);
|
BlockCall(0x45EBBF); // intface_redraw_
|
||||||
|
BlockCall(0x4A4859); // exec_script_proc_
|
||||||
|
SafeMemSet(0x455189, CODETYPE_Nop, 11); // op_create_object_sid_
|
||||||
|
|
||||||
// Improve performance of the data conversion of script interpreter
|
// Improve performance of the data conversion of script interpreter
|
||||||
// mov eax, [edx+eax]; bswap eax; ret;
|
// mov eax, [edx+eax]; bswap eax; ret;
|
||||||
|
|||||||
+4
-2
@@ -1,12 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T SimplePatch(DWORD addr, const char* iniSection, const char* iniKey, T defaultValue, T minValue = 0, T maxValue = INT_MAX) {
|
T SimplePatch(DWORD addr, const char* iniSection, const char* iniKey, T defaultValue, T minValue = 0, T maxValue = INT_MAX)
|
||||||
|
{
|
||||||
return SimplePatch<T>(&addr, 1, iniSection, iniKey, defaultValue, minValue, maxValue);
|
return SimplePatch<T>(&addr, 1, iniSection, iniKey, defaultValue, minValue, maxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T SimplePatch(DWORD *addrs, int numAddrs, const char* iniSection, const char* iniKey, T defaultValue, T minValue = 0, T maxValue = INT_MAX) {
|
T SimplePatch(DWORD *addrs, int numAddrs, const char* iniSection, const char* iniKey, T defaultValue, T minValue = 0, T maxValue = INT_MAX)
|
||||||
|
{
|
||||||
T value;
|
T value;
|
||||||
char msg[255];
|
char msg[255];
|
||||||
value = (T)GetConfigInt(iniSection, iniKey, defaultValue);
|
value = (T)GetConfigInt(iniSection, iniKey, defaultValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user