Added TagSkillMode option to the skills ini file

Added a fix to the radiation handling in the engine when an NPC is under
the player's control.

Code correction in Graphics.cpp.
This commit is contained in:
NovaRain
2021-01-12 12:02:17 +08:00
parent cf90437b71
commit 31af299b4a
4 changed files with 41 additions and 23 deletions
+13 -7
View File
@@ -1,16 +1,22 @@
;This file lets you set the formula for calculating skills
[skills]
;Changes the initial bonus to skill level for tagged skills
;Changes the initial bonus to skill level for tag skills
;valid range: 0..100, 20 - default bonus
TagSkillBonus=20
;Changes the behavior of tag skills
;Set to 1 to give the initial skill bonus to the fourth tag skill from "Tag!" perk (Fallout 1 behavior)
;Set to 2 to disable the double bonus of skill points for tag skills
;Set to 3 to use both modes
TagSkillMode=0
;Set to 1 to base skill costs on spent points instead of current level
BasedOnPoints=0
Skill0=s1|i2|l1.5 ;Skill 0 (small guns) is str*1 + int*2 + luck*1.5
SkillBase1=50 ;Big guns has a base of 50
SkillMulti2=10 ;Each point spent in energy weapons increases it by 10
SkillImage1=72
SkillCost0=0|0|0|0|0|300 ;Each level of small guns costs 6 skill points
;Examples
;Skill0=s1|i2|l1.5 ;Skill 0 (small guns) is str*1 + int*2 + luck*1.5
;SkillBase1=50 ;Big guns has a base of 50
;SkillMulti2=10 ;Each point spent in energy weapons increases it by 10
;SkillImage1=72
;SkillCost0=0|0|0|0|0|300 ;Each level of small guns costs 6 skill points
+7 -10
View File
@@ -889,7 +889,7 @@ public:
0x486861 movie_MVE_ShowFrame_ [c=1] (capture, never called)
*/
HRESULT __stdcall Lock(LPRECT a, LPDDSURFACEDESC b, DWORD c, HANDLE d) {
if (DeviceLost) return DDERR_SURFACELOST;
if (DeviceLost && Restore() == DD_FALSE) return DDERR_SURFACELOST; // DDERR_SURFACELOST 0x887601C2
if (isPrimary) {
lockRect = a;
if (GPUBlt) {
@@ -920,11 +920,10 @@ public:
if (d3d9Device->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
ResetDevice(false);
DeviceLost = false;
if (GPUBlt) SetGPUPalette(); // restote palette
RefreshGNW();
dlogr("D3D9 Device restored.", DL_MAIN);
if (GPUBlt) SetGPUPalette(); // restore palette
dlogr("\nD3D9 Device restored.", DL_MAIN);
}
return !DeviceLost;
return DeviceLost;
}
HRESULT __stdcall SetClipper(LPDIRECTDRAWCLIPPER) { UNUSEDFUNCTION; }
@@ -968,7 +967,7 @@ public:
*/
HRESULT __stdcall Unlock(LPVOID lockSurface) {
//dlog("\nUnlock", DL_INIT);
if ((DeviceLost && Restore() == DD_FALSE) || !isPrimary) return DD_OK;
if (!isPrimary) return DD_OK;
//dlog("\nUnlock -> primary", DL_INIT);
if (GPUBlt == 0) {
@@ -1320,13 +1319,11 @@ static __forceinline void UpdateDDSurface(BYTE* surface, int width, int height,
call ds:[_scr_blit]; // GNW95_ShowRect_(int from, int widthFrom, int heightFrom, int xFrom, int yFrom, int width, int height, int x, int y)
add esp, 9*4;
}
return;
}
if (!DeviceLost) {
} else {
DDSURFACEDESC desc;
RECT lockRect = { x, y, rect->right + 1, rect->bottom + 1 };
primaryDDSurface->Lock(&lockRect, &desc, 0, 0);
if (primaryDDSurface->Lock(&lockRect, &desc, 0, 0)) return; // lock error
if (GPUBlt == 0) desc.lpSurface = (BYTE*)desc.lpSurface + (desc.lPitch * y) + x;
BufToBuf(surface, width, height, widthFrom, (BYTE*)desc.lpSurface, desc.lPitch);
+8 -6
View File
@@ -208,9 +208,8 @@ static void __declspec(naked) skill_level_hack_bonus() {
static void __declspec(naked) skill_inc_point_hack_cost() {
static const DWORD SkillIncCostRet = 0x4AA7C1;
__asm { // eax - current skill level, ebx - current skill, ecx - num free skill points
mov edx, basedOnPoints;
test edx, edx;
jz next;
cmp basedOnPoints, 0;
je next;
mov edx, ebx;
mov eax, esi;
call skill_points_;
@@ -229,9 +228,8 @@ skip:
static void __declspec(naked) skill_dec_point_hack_cost() {
static const DWORD SkillDecCostRet = 0x4AA98D;
__asm { // ecx - current skill level, ebx - current skill, esi - num free skill points
mov edx, basedOnPoints;
test edx, edx;
jz next;
cmp basedOnPoints, 0;
je next;
mov edx, ebx;
mov eax, edi;
call skill_points_;
@@ -413,6 +411,10 @@ void Skills_Init() {
int tagBonus = iniGetInt("Skills", "TagSkillBonus", 20, file);
if (tagBonus != 20 && tagBonus >=0 && tagBonus <= 100) SafeWrite8(0x4AA61E, static_cast<BYTE>(tagBonus));
int tagMode = iniGetInt("Skills", "TagSkillMode", 0, file);
if (tagMode & 1) SafeWrite8(0x4AA612, 0xEB); // 4th tag skill can have initial skill bonus (jz > jmp)
if (tagMode & 2) SafeWrite16(0x4AA60E, 0x9090); // skill_level_ disables 2x skill points bonus for tag skills
}
}
+13
View File
@@ -272,6 +272,16 @@ void __declspec(naked) critter_adjust_poison_hack_fix() {
}
}
static void __declspec(naked) critter_check_rads_hack() {
using namespace Fields;
__asm {
mov edx, ds:[_obj_dude];
mov eax, [eax + protoId]; // critter.pid
mov ecx, PID_Player;
retn;
}
}
////////////////////////////////////////////////////////////////////////////////
static void StatsReset() {
@@ -315,6 +325,9 @@ void Stats_Init() {
MakeCall(0x42D31F, critter_check_poison_hack_fix, 1);
MakeCall(0x42D21C, critter_adjust_poison_hack_fix, 1);
SafeWrite8(0x42D223, 0xCB); // cmp eax, edx > cmp ebx, ecx
// also rads
MakeCall(0x42D4FE, critter_check_rads_hack, 1);
SafeWrite8(0x42D505, 0xC8); // cmp eax, edx > cmp eax, ecx
std::vector<std::string> xpTableList = GetConfigList("Misc", "XPTable", "", 2048);
size_t numLevels = xpTableList.size();