Added new game mode COUNTERWIN.

Improved add_extra_msg_file function to use "English" as the fallback
language for loading msg files (#256)
This commit is contained in:
NovaRain
2019-08-17 20:44:41 +08:00
parent 2dfbe903e7
commit 2b93bf6045
8 changed files with 41 additions and 13 deletions
+1 -1
View File
@@ -31,7 +31,7 @@
#define WEAPON_BIGGUN 256 // 0x00000100 - Big Gun #define WEAPON_BIGGUN 256 // 0x00000100 - Big Gun
#define WEAPON_2HAND 512 // 0x00000200 - 2Hnd (weapon is two-handed) #define WEAPON_2HAND 512 // 0x00000200 - 2Hnd (weapon is two-handed)
#define WEAPON_ENERGYWEAPON 1024 // 0x00000400 - Energy Weapon (forces weapon to use Energy Weapons skill) #define WEAPON_ENERGY 1024 // 0x00000400 - Energy Weapon (forces weapon to use Energy Weapons skill)
#define ATKMODE_PRI_NONE 0 #define ATKMODE_PRI_NONE 0
#define ATKMODE_PRI_PUNCH 1 // 0001 #define ATKMODE_PRI_PUNCH 1 // 0001
+1
View File
@@ -19,6 +19,7 @@
#define BARTER (0x20000) #define BARTER (0x20000)
#define HEROWIN (0x40000) #define HEROWIN (0x40000)
#define DIALOGVIEW (0x80000) #define DIALOGVIEW (0x80000)
#define COUNTERWIN (0x100000) // counter window for moving multiple items or setting a timer
//Valid arguments to register_hook //Valid arguments to register_hook
#define HOOK_TOHIT (0) #define HOOK_TOHIT (0)
@@ -613,6 +613,7 @@ optional arguments:
> int sfall_func2("add_extra_msg_file", string fileName, int fileNumber) > int sfall_func2("add_extra_msg_file", string fileName, int fileNumber)
- loads the custom message file, and returns the file ID number assigned to it in range from 0x3000 to 0x3FFF for the message_str_game function to get messages from the file - loads the custom message file, and returns the file ID number assigned to it in range from 0x3000 to 0x3FFF for the message_str_game function to get messages from the file
- fileName: the name of the custom message file (including the .msg extension) in "text\<language>\game\" directory - fileName: the name of the custom message file (including the .msg extension) in "text\<language>\game\" directory
- NOTE: if the msg file does not exist in the current language directory, the function will try to load it from "text\English\game\" directory
optional argument: optional argument:
- fileNumber: the file ID number for the message_str_game function. The available range is from 0x2000 to 0x2FFF (see ExtraGameMsgFileList setting in ddraw.ini) - fileNumber: the file ID number for the message_str_game function. The available range is from 0x2000 to 0x2FFF (see ExtraGameMsgFileList setting in ddraw.ini)
use fileNumber only if you want to add a message file without editing ddraw.ini or existing scripts to support the old way use fileNumber only if you want to add a message file without editing ddraw.ini or existing scripts to support the old way
+4 -1
View File
@@ -274,7 +274,10 @@ enum ProtoId : long
PID_JESSE_CONTAINER = 467, PID_JESSE_CONTAINER = 467,
PID_Player = 16777216, PID_Player = 16777216,
PID_DRIVABLE_CAR = 33555441 PID_DRIVABLE_CAR = 33555441,
// misc type
PID_CORPSE_BLOOD = 0x05000004,
}; };
//XXXXXXXXXXXXXXXXXXXXX //XXXXXXXXXXXXXXXXXXXXX
+20 -2
View File
@@ -417,7 +417,7 @@ static void __declspec(naked) game_close_hook() {
static void __declspec(naked) WorldMapHook() { static void __declspec(naked) WorldMapHook() {
__asm { __asm {
_InLoop(1, WORLDMAP); _InLoop(1, WORLDMAP);
xor eax, eax; xor eax, eax; // unused
call fo::funcoffs::wmWorldMapFunc_; call fo::funcoffs::wmWorldMapFunc_;
_InLoop(0, WORLDMAP); _InLoop(0, WORLDMAP);
retn; retn;
@@ -617,6 +617,22 @@ static void __declspec(naked) DialogReviewExitHook() {
} }
} }
static void __declspec(naked) setup_move_timer_win_Hook() {
__asm {
_InLoop2(1, COUNTERWIN);
jmp fo::funcoffs::text_curr_;
}
}
static void __declspec(naked) exit_move_timer_win_Hook() {
__asm {
push eax;
_InLoop2(0, COUNTERWIN);
pop eax;
jmp fo::funcoffs::win_delete_;
}
}
void LoadGameHook::init() { void LoadGameHook::init() {
saveInCombatFix = GetConfigInt("Misc", "SaveInCombatFix", 1); saveInCombatFix = GetConfigInt("Misc", "SaveInCombatFix", 1);
if (saveInCombatFix > 2) saveInCombatFix = 0; if (saveInCombatFix > 2) saveInCombatFix = 0;
@@ -650,7 +666,7 @@ void LoadGameHook::init() {
0x480CA7, // gnw_main_ 0x480CA7, // gnw_main_
//0x480D45 // main_exit_system_ (never called) //0x480D45 // main_exit_system_ (never called)
}); });
// game modes
HookCalls(WorldMapHook, {0x483668, 0x4A4073}); HookCalls(WorldMapHook, {0x483668, 0x4A4073});
HookCalls(WorldMapHook2, {0x4C4855}); HookCalls(WorldMapHook2, {0x4C4855});
HookCalls(CombatHook, {0x426A29, 0x4432BE, 0x45F6D2, 0x4A4020, 0x4A403D}); HookCalls(CombatHook, {0x426A29, 0x4432BE, 0x45F6D2, 0x4A4020, 0x4A403D});
@@ -673,6 +689,8 @@ void LoadGameHook::init() {
HookCalls(AutomapHook, {0x44396D, 0x479519}); HookCalls(AutomapHook, {0x44396D, 0x479519});
HookCall(0x445CA7, DialogReviewInitHook); HookCall(0x445CA7, DialogReviewInitHook);
HookCall(0x445D30, DialogReviewExitHook); HookCall(0x445D30, DialogReviewExitHook);
HookCall(0x476AC6, setup_move_timer_win_Hook); // before init win
HookCall(0x477067, exit_move_timer_win_Hook);
} }
Delegate<>& LoadGameHook::OnGameInit() { Delegate<>& LoadGameHook::OnGameInit() {
+1
View File
@@ -89,6 +89,7 @@ enum LoopFlag : unsigned long {
BARTER = 1 << 17, // 0x20000 BARTER = 1 << 17, // 0x20000
HEROWIN = 1 << 18, // 0x40000 Hero Appearance mod HEROWIN = 1 << 18, // 0x40000 Hero Appearance mod
DIALOGVIEW = 1 << 19, // 0x80000 DIALOGVIEW = 1 << 19, // 0x80000
COUNTERWIN = 1 << 20, // 0x100000 Counter window for moving multiple items or setting a timer
// RESERVED = 1 << 31 // RESERVED = 1 << 31
}; };
+9 -6
View File
@@ -105,7 +105,7 @@ static void ReadExtraGameMsgFiles() {
} }
path += ".msg"; path += ".msg";
fo::MessageList* list = new fo::MessageList(); fo::MessageList* list = new fo::MessageList();
if (fo::func::message_load(list, (char*)path.data()) == 1) { if (fo::func::message_load(list, path.c_str()) == 1) {
gExtraGameMsgLists.insert(std::make_pair(0x2000 + number, list)); gExtraGameMsgLists.insert(std::make_pair(0x2000 + number, list));
} else { } else {
delete list; delete list;
@@ -125,13 +125,16 @@ long Message::AddExtraMsgFile(const char* msgName, long msgNumber) {
std::string path("game\\"); std::string path("game\\");
path += msgName; path += msgName;
fo::MessageList* list = new fo::MessageList(); fo::MessageList* list = new fo::MessageList();
if (fo::func::message_load(list, path.c_str())) { if (!fo::func::message_load(list, path.c_str())) {
// change current language folder
path.insert(0, "..\\english\\");
if (!fo::func::message_load(list, path.c_str())) {
delete list;
return -2;
}
}
if (msgNumber == 0) msgNumber = msgNumCounter++; if (msgNumber == 0) msgNumber = msgNumCounter++;
gExtraGameMsgLists.emplace(msgNumber, list); gExtraGameMsgLists.emplace(msgNumber, list);
} else {
delete list;
msgNumber = -2;
}
return msgNumber; return msgNumber;
} }
+3 -2
View File
@@ -199,7 +199,8 @@ void Objects::LoadProtoAutoMaxLimit() {
} }
static void __declspec(naked) obj_insert_hack() { static void __declspec(naked) obj_insert_hack() {
using namespace fo::Fields; using namespace fo;
using namespace Fields;
__asm { __asm {
mov edi, [ebx]; mov edi, [ebx];
mov [esp + 0x38 - 0x1C + 4], esi; // 0 mov [esp + 0x38 - 0x1C + 4], esi; // 0
@@ -208,7 +209,7 @@ static void __declspec(naked) obj_insert_hack() {
retn; retn;
insert: insert:
mov esi, [ecx]; // esi - inserted object mov esi, [ecx]; // esi - inserted object
cmp dword ptr [esi + protoId], 0x5000004; // corpse blood pid cmp dword ptr [esi + protoId], PID_CORPSE_BLOOD;
jnz skip; jnz skip;
xor edi, edi; xor edi, edi;
skip: skip: