Added CorpseDeleteTime option (from Mr.Stalin)

Fixed some code in Perks.cpp.
This commit is contained in:
NovaRain
2019-03-15 19:17:37 +08:00
parent 04eba05e53
commit 1fd93ba13f
4 changed files with 34 additions and 11 deletions
+5
View File
@@ -352,6 +352,11 @@ PlayIdleAnimOnReload=0
;Set to 1 to prevent corpses from blocking line of fire
CorpseLineOfFireFix=0
;Changes the timer (in days) for deleting corpses on a map after you leave (valid range: 0..13)
;Default is 6. Set to 0 for a 12-hour timer
;The corpses of critters with 'Ages' flag or on maps with 'dead_bodies_age=No' set in maps.txt will not disappear
CorpseDeleteTime=6
;Set a number of milliseconds to idle each input loop
;Set to -1 to disable
;Set to 0 to idle only if other processes are waiting for processor time
+1
View File
@@ -1956,6 +1956,7 @@ isDead:
cmp eax, -1;
je noBlood;
mov eax, [esp - 4]; // object
// mov [eax + frm], 3; // set frame
mov ebx, [esi + elevation];
mov edx, [esi + tile];
xor ecx, ecx;
+15 -1
View File
@@ -351,7 +351,7 @@ fail:
static void __declspec(naked) op_obj_can_see_obj_hook() {
__asm {
push fo::funcoffs::obj_shoot_blocking_at_; // check hex objects func pointer
push 0x20; // flags, 0x20 = check shootthru
push 0x20; // flags, 0x20 = check ShootThru
mov ecx, dword ptr [esp + 0x0C]; // buf **ret_objStruct
push ecx;
xor ecx, ecx;
@@ -910,6 +910,20 @@ void MiscPatches::init() {
dlogr(" Done", DL_INIT);
}
int time = GetConfigInt("Misc", "CorpseDeleteTime", 6); // time in days
if (time != 6) {
dlog("Applying corpse deletion time patch.", DL_INIT);
if (time <= 0) {
time = 12; // hours
} else if (time > 13) {
time = 13 * 24;
} else {
time *= 24;
}
SafeWrite32(0x483348, time);
dlogr(" Done", DL_INIT);
}
LoadGameHook::OnBeforeGameStart() += BodypartHitChances; // set on start & load
CombatProcFix();
+13 -10
View File
@@ -30,7 +30,7 @@ using namespace fo;
constexpr int maxNameLen = 64; // don't change size
constexpr int maxDescLen = 512; // don't change size
const int descLen = 256; // maximum text length for interface
static const int descLen = 256; // maximum text length for interface
static char perksFile[MAX_PATH] = {0};
@@ -206,7 +206,8 @@ void _stdcall SetSelectablePerk(char* name, int active, int image, char* desc) {
if (!strcmp(name, fakeSelectablePerks[i].Name)) {
fakeSelectablePerks[i].Level = active;
fakeSelectablePerks[i].Image = image;
strncpy_s(fakeSelectablePerks[i].Desc, desc, _TRUNCATE);
strncpy(fakeSelectablePerks[i].Desc, desc, descLen - 1);
fakeSelectablePerks[i].Desc[descLen - 1] = 0;
return;
}
}
@@ -230,7 +231,8 @@ void _stdcall SetFakePerk(char* name, int level, int image, char* desc) {
if (!strcmp(name, fakePerks[i].Name)) {
fakePerks[i].Level = level;
fakePerks[i].Image = image;
strncpy_s(fakePerks[i].Desc, desc, _TRUNCATE);
strncpy(fakePerks[i].Desc, desc, descLen - 1);
fakePerks[i].Desc[descLen - 1] = 0;
return;
}
}
@@ -254,7 +256,8 @@ void _stdcall SetFakeTrait(char* name, int active, int image, char* desc) {
if (!strcmp(name, fakeTraits[i].Name)) {
fakeTraits[i].Level = active;
fakeTraits[i].Image = image;
strncpy_s(fakeTraits[i].Desc, desc, _TRUNCATE);
strncpy(fakeTraits[i].Desc, desc, descLen - 1);
fakeTraits[i].Desc[descLen - 1] = 0;
return;
}
}
@@ -806,9 +809,15 @@ static void PerkEngineInit() {
// perk_owed hooks
MakeCall(0x4AFB2F, LevelUpHack, 1); // replaces 'mov edx, ds:[PlayerLevel]'
SafeWrite8(0x43C2EC, 0xEB); // skip the block of code which checks if the player has gained a perk (now handled in level up code)
// Disable losing unused perks
SafeWrite16(0x43C369, 0x0DFE); // dec byte ptr ds:_free_perk
SafeWrite8(0x43C370, 0xB1); // jmp 0x43C322
}
static void PerkSetup() {
memcpy(perks, var::perk_data, sizeof(PerkInfo) * PERK_count); // copy vanilla data
if (!perksReInit) {
// _perk_data
SafeWriteBatch<DWORD>((DWORD)perks, {0x496669, 0x496837, 0x496BAD, 0x496C41, 0x496D25});
@@ -817,8 +826,6 @@ static void PerkSetup() {
SafeWrite32(0x496BF5, (DWORD)perks + 8);
SafeWrite32(0x496AD4, (DWORD)perks + 12);
}
memcpy(perks, var::perk_data, sizeof(PerkInfo) * PERK_count); // copy vanilla data
if (perksFile[0] != '\0') {
char num[4];
for (int i = 0; i < PERK_count; i++) {
@@ -925,10 +932,6 @@ static void PerkSetup() {
}
}
perksReInit = false;
// Disable losing unused perks
SafeWrite16(0x43C369, 0x0DFE); // dec byte ptr ds:_free_perk
SafeWrite8(0x43C370, 0xB1); // jmp 0x43C322
}
static __declspec(naked) void PerkInitWrapper() {