mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
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:
@@ -31,7 +31,7 @@
|
||||
|
||||
#define WEAPON_BIGGUN 256 // 0x00000100 - Big Gun
|
||||
#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_PUNCH 1 // 0001
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define BARTER (0x20000)
|
||||
#define HEROWIN (0x40000)
|
||||
#define DIALOGVIEW (0x80000)
|
||||
#define COUNTERWIN (0x100000) // counter window for moving multiple items or setting a timer
|
||||
|
||||
//Valid arguments to register_hook
|
||||
#define HOOK_TOHIT (0)
|
||||
|
||||
@@ -613,6 +613,7 @@ optional arguments:
|
||||
> 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
|
||||
- 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:
|
||||
- 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
|
||||
|
||||
@@ -274,7 +274,10 @@ enum ProtoId : long
|
||||
PID_JESSE_CONTAINER = 467,
|
||||
|
||||
PID_Player = 16777216,
|
||||
PID_DRIVABLE_CAR = 33555441
|
||||
PID_DRIVABLE_CAR = 33555441,
|
||||
|
||||
// misc type
|
||||
PID_CORPSE_BLOOD = 0x05000004,
|
||||
};
|
||||
|
||||
//XXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
@@ -417,7 +417,7 @@ static void __declspec(naked) game_close_hook() {
|
||||
static void __declspec(naked) WorldMapHook() {
|
||||
__asm {
|
||||
_InLoop(1, WORLDMAP);
|
||||
xor eax, eax;
|
||||
xor eax, eax; // unused
|
||||
call fo::funcoffs::wmWorldMapFunc_;
|
||||
_InLoop(0, WORLDMAP);
|
||||
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() {
|
||||
saveInCombatFix = GetConfigInt("Misc", "SaveInCombatFix", 1);
|
||||
if (saveInCombatFix > 2) saveInCombatFix = 0;
|
||||
@@ -650,7 +666,7 @@ void LoadGameHook::init() {
|
||||
0x480CA7, // gnw_main_
|
||||
//0x480D45 // main_exit_system_ (never called)
|
||||
});
|
||||
|
||||
// game modes
|
||||
HookCalls(WorldMapHook, {0x483668, 0x4A4073});
|
||||
HookCalls(WorldMapHook2, {0x4C4855});
|
||||
HookCalls(CombatHook, {0x426A29, 0x4432BE, 0x45F6D2, 0x4A4020, 0x4A403D});
|
||||
@@ -673,6 +689,8 @@ void LoadGameHook::init() {
|
||||
HookCalls(AutomapHook, {0x44396D, 0x479519});
|
||||
HookCall(0x445CA7, DialogReviewInitHook);
|
||||
HookCall(0x445D30, DialogReviewExitHook);
|
||||
HookCall(0x476AC6, setup_move_timer_win_Hook); // before init win
|
||||
HookCall(0x477067, exit_move_timer_win_Hook);
|
||||
}
|
||||
|
||||
Delegate<>& LoadGameHook::OnGameInit() {
|
||||
|
||||
@@ -89,6 +89,7 @@ enum LoopFlag : unsigned long {
|
||||
BARTER = 1 << 17, // 0x20000
|
||||
HEROWIN = 1 << 18, // 0x40000 Hero Appearance mod
|
||||
DIALOGVIEW = 1 << 19, // 0x80000
|
||||
COUNTERWIN = 1 << 20, // 0x100000 Counter window for moving multiple items or setting a timer
|
||||
|
||||
// RESERVED = 1 << 31
|
||||
};
|
||||
|
||||
@@ -105,7 +105,7 @@ static void ReadExtraGameMsgFiles() {
|
||||
}
|
||||
path += ".msg";
|
||||
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));
|
||||
} else {
|
||||
delete list;
|
||||
@@ -125,13 +125,16 @@ long Message::AddExtraMsgFile(const char* msgName, long msgNumber) {
|
||||
std::string path("game\\");
|
||||
path += msgName;
|
||||
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++;
|
||||
gExtraGameMsgLists.emplace(msgNumber, list);
|
||||
} else {
|
||||
delete list;
|
||||
msgNumber = -2;
|
||||
}
|
||||
return msgNumber;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,8 @@ void Objects::LoadProtoAutoMaxLimit() {
|
||||
}
|
||||
|
||||
static void __declspec(naked) obj_insert_hack() {
|
||||
using namespace fo::Fields;
|
||||
using namespace fo;
|
||||
using namespace Fields;
|
||||
__asm {
|
||||
mov edi, [ebx];
|
||||
mov [esp + 0x38 - 0x1C + 4], esi; // 0
|
||||
@@ -208,7 +209,7 @@ static void __declspec(naked) obj_insert_hack() {
|
||||
retn;
|
||||
insert:
|
||||
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;
|
||||
xor edi, edi;
|
||||
skip:
|
||||
|
||||
Reference in New Issue
Block a user