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 11:52:59 +08:00
parent c736e39f9e
commit 4535ec9e20
5 changed files with 42 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
+14
View File
@@ -104,6 +104,17 @@ void __declspec(naked) critter_adjust_poison_hack_fix() { // can also be called
}
}
static void __declspec(naked) critter_check_rads_hack() {
using namespace fo;
using namespace Fields;
__asm {
mov edx, ds:[FO_VAR_obj_dude];
mov eax, [eax + protoId]; // critter.pid
mov ecx, PID_Player;
retn;
}
}
void CritterPoison::init() {
// Allow changing the poison level for critters
MakeCall(0x42D226, critter_adjust_poison_hack);
@@ -117,6 +128,9 @@ void CritterPoison::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
}
}
+5 -6
View File
@@ -775,7 +775,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 (Graphics::GPUBlt) {
@@ -806,11 +806,10 @@ public:
if (d3d9Device->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
ResetDevice(false);
DeviceLost = false;
if (Graphics::GPUBlt) SetGPUPalette(); // restote palette
fo::RefreshGNW();
dlogr("D3D9 Device restored.", DL_MAIN);
if (Graphics::GPUBlt) SetGPUPalette(); // restore palette
dlogr("\nD3D9 Device restored.", DL_MAIN);
}
return !DeviceLost;
return DeviceLost;
}
HRESULT __stdcall SetClipper(LPDIRECTDRAWCLIPPER) { UNUSEDFUNCTION; }
@@ -854,7 +853,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 (Graphics::GPUBlt == 0) {
+2 -4
View File
@@ -101,13 +101,11 @@ public:
call ds:[FO_VAR_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 (Graphics::GPUBlt == 0) desc.lpSurface = (BYTE*)desc.lpSurface + (desc.lPitch * y) + x;
fo::func::buf_to_buf(surface, width, height, widthFrom, (BYTE*)desc.lpSurface, desc.lPitch);
+8 -6
View File
@@ -213,9 +213,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 fo::funcoffs::skill_points_;
@@ -234,9 +233,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 fo::funcoffs::skill_points_;
@@ -410,6 +408,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
}
}