Merge pull request #80 from FakelsHub/3.8-PCStat_fix

Fixed bugs for negative SPECIAL values in character creation (from Crafty)
This commit is contained in:
NovaRain
2017-03-12 20:53:53 +08:00
committed by GitHub
3 changed files with 55 additions and 0 deletions
+52
View File
@@ -964,6 +964,51 @@ void __declspec(naked) ItemCountFix() {
}
}
static void __declspec(naked) PrintBasicStat_hack() {
__asm {
test eax, eax
jle skip
cmp eax, 10
jg end
pop ebx
push 0x434C21
retn
skip:
xor eax, eax
end:
retn
}
}
static void __declspec(naked) StatButtonUp_hook() {
__asm {
call inc_stat_
test eax, eax
jl end
test ebx, ebx
jge end
sub ds:[_character_points], esi
xor esi, esi
mov [esp+0xC+0x4], esi
end:
retn
}
}
static void __declspec(naked) StatButtonDown_hook() {
__asm {
call stat_level_
cmp eax, 1
jg end
pop eax
xor eax, eax
inc eax
mov [esp+0xC], eax
push 0x437B41
end:
retn
}
}
void BugsInit()
{
@@ -1045,6 +1090,13 @@ void BugsInit()
SafeWrite8(0x4AC377, 0x7F); // jg
dlogr(" Done", DL_INIT);
//Fix negative value SPECIAL when creation character, when Trait influences with negative values on basic parameters SPECIAL.
dlog("Applying fix for negative values SPECIAL when creation character.", DL_INIT);
MakeCall(0x434BFF, &PrintBasicStat_hack, false);
HookCall(0x437AB4, &StatButtonUp_hook);
HookCall(0x437B26, &StatButtonDown_hook);
dlogr(" Done", DL_INIT);
// Fix for not counting in the weight of equipped items on NPC when stealing or bartering
//if (GetPrivateProfileIntA("Misc", "NPCWeightFix", 1, ini)) {
dlog("Applying fix for not counting in weight of equipped items on NPC.", DL_INIT);
+1
View File
@@ -343,6 +343,7 @@ const DWORD gsnd_build_weapon_sfx_name_ = 0x451760;
const DWORD gsound_play_sfx_file_ = 0x4519A8;
const DWORD handle_inventory_ = 0x46E7B0;
const DWORD inc_game_time_ = 0x4A34CC;
const DWORD inc_stat_ = 0x4AF5D4;
const DWORD insert_withdrawal_ = 0x47A290;
const DWORD interpret_ = 0x46CCA4;
const DWORD interpretAddString_ = 0x467A80; // edx = ptr to string, eax = script
+2
View File
@@ -41,6 +41,7 @@
#define _btable 0x59E944
#define _btncnt 0x43EA1C
#define _CarCurrArea 0x672E68
#define _character_points 0x518538
#define _cmap 0x51DF34
#define _colorTable 0x6A38D0
#define _combat_free_move 0x56D39C
@@ -514,6 +515,7 @@ extern const DWORD gsnd_build_weapon_sfx_name_;
extern const DWORD gsound_play_sfx_file_;
extern const DWORD handle_inventory_;
extern const DWORD inc_game_time_;
extern const DWORD inc_stat_;
extern const DWORD insert_withdrawal_;
extern const DWORD interpret_; // <eax> - programPtr, <edx> - ??? (-1)
extern const DWORD interpretAddString_;