Added a blinking icon to force_encounter/with_flags functions

* currently an icon is always shown for scripted force encounters.
This commit is contained in:
NovaRain
2020-01-20 11:51:17 +08:00
parent f2670deb6f
commit 9f140cf3ca
9 changed files with 34 additions and 9 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
#define below_equal(a, b) (unsigned_comp(a, b) <= 0)
procedure unsigned_comp(variable a, variable b) begin
if (a bwxor b) then return 0;
if ((a bwxor b) == 0) then return 0; // a == b
if (b == 0) then return 1;
return 1 if (a / b) else -1;
end
+1
View File
@@ -61,6 +61,7 @@
//Valid flags for force_encounter_with_flags
#define ENCOUNTER_FLAG_NO_CAR (1)
#define ENCOUNTER_FLAG_LOCK (2) // block new forced encounter by the next function call until the current specified encounter occurs
#define ENCOUNTER_FLAG_SPECIAL (4) // special blinking icon
//The attack types returned by get_attack_type
#define ATKTYPE_LWEP1 (0)
+1 -1
View File
@@ -137,7 +137,7 @@ array - array ID to be used with array-related functions (actually an integer)
- The player will not get an outdoorsman skill check.
> void force_encounter_with_flags(int map, int flags)
- does the same thing as force_encounter, but allows the specification of some extra options.
- does the same thing as force_encounter, but allows the specification of some extra options (see sfall.h for available flags).
- Forcing a random encounter on a map that is not normally used for random encounters may cause the player to lose the car, if they have it.
- In this case use force_encounter_with_flags with the ENCOUNTER_FLAG_NO_CAR flag set.
+6
View File
@@ -276,6 +276,7 @@ const DWORD attack_crit_success_ = 0x423EB4;
const DWORD automap_ = 0x41B8BC;
const DWORD barter_compute_value_ = 0x474B2C;
const DWORD barter_inventory_ = 0x4757F0;
const DWORD block_for_tocks_ = 0x4C93B8;
const DWORD buf_to_buf_ = 0x4D36D4;
const DWORD cai_attempt_w_reload_ = 0x42AECC;
const DWORD check_death_ = 0x410814;
@@ -709,6 +710,7 @@ const DWORD windowHide_ = 0x4B7610;
const DWORD windowShow_ = 0x4B7648;
const DWORD windowWidth_ = 0x4B7734;
const DWORD wmFindCurSubTileFromPos_ = 0x4C0C00;
const DWORD wmInterfaceRefresh_ = 0x4C3830;
const DWORD wmInterfaceScrollTabsStart_ = 0x4C219C;
const DWORD wmMapIsSaveable_ = 0x4BFA64;
const DWORD wmMarkSubTileRadiusVisited_ = 0x4C3550;
@@ -1175,6 +1177,10 @@ long __stdcall WindowWidth() {
WRAP_WATCOM_CALL0(windowWidth_)
}
long __stdcall BlockForTocks(long ticks) {
WRAP_WATCOM_CALL1(block_for_tocks_, ticks)
}
void __fastcall DisplayInventory(long inventoryOffset, long visibleOffset, long mode) {
WRAP_WATCOM_FCALL3(display_inventory_, inventoryOffset, visibleOffset, mode)
}
+6
View File
@@ -254,8 +254,10 @@
#define _wd_obj 0x59E98C
#define _window 0x6ADE58
#define _wmAreaInfoList 0x51DDF8
#define _wmEncounterIconShow 0x672E48
#define _wmLastRndTime 0x51DEA0
#define _wmMaxMapNum 0x51DE10
#define _wmRndCursorFid 0x672E58
#define _wmWorldOffsetX 0x51DE2C
#define _wmWorldOffsetY 0x51DE30
#define _wmYesNoStrs 0x51DD90
@@ -517,6 +519,7 @@ extern const DWORD attack_crit_success_;
extern const DWORD automap_;
extern const DWORD barter_compute_value_;
extern const DWORD barter_inventory_;
extern const DWORD block_for_tocks_;
extern const DWORD buf_to_buf_;
extern const DWORD cai_attempt_w_reload_;
extern const DWORD check_death_;
@@ -958,6 +961,7 @@ extern const DWORD windowHide_;
extern const DWORD windowShow_;
extern const DWORD windowWidth_;
extern const DWORD wmFindCurSubTileFromPos_;
extern const DWORD wmInterfaceRefresh_;
extern const DWORD wmInterfaceScrollTabsStart_;
extern const DWORD wmMapIsSaveable_;
extern const DWORD wmMarkSubTileRadiusVisited_;
@@ -1176,6 +1180,8 @@ void __stdcall WinDelete(DWORD winRef);
long __stdcall WindowWidth();
long __stdcall BlockForTocks(long ticks);
void __fastcall DisplayInventory(long inventoryOffset, long visibleOffset, long mode);
void __fastcall DisplayTargetInventory(long inventoryOffset, long visibleOffset, DWORD* targetInventory, long mode);
+1 -1
View File
@@ -204,7 +204,7 @@ static void SpeedInterfaceCounterAnimsPatch() {
}
static bool IFACE_BAR_MODE = false;
static long __stdcall gmouse_handle_event_hook() {
static long gmouse_handle_event_hook() {
long countWin = *(DWORD*)_num_windows;
long ifaceWin = *ptr_interfaceWindow;
WINinfo* win = nullptr;
+1 -1
View File
@@ -1286,7 +1286,7 @@ skip:
}
}
static void _stdcall ClearEventsOnMapExit() {
static void ClearEventsOnMapExit() {
__asm {
mov eax, explode_event; // type
mov edx, queue_explode_exit_; // func
+1 -1
View File
@@ -66,7 +66,7 @@ void SetAppearanceGlobals(int race, int style);
void GetAppearanceGlobals(int *race, int *style);
void _stdcall RegAnimCombatCheck(DWORD newValue);
DWORD _stdcall ForceEncounterRestore();
DWORD ForceEncounterRestore();
bool _stdcall ScriptHasLoaded(DWORD script);
// finds procedure ID for given script program pointer and procedure name
+16 -4
View File
@@ -26,7 +26,7 @@
static DWORD ForceEncounterMapID = -1;
static DWORD ForceEncounterFlags;
DWORD _stdcall ForceEncounterRestore() {
DWORD ForceEncounterRestore() {
long long data = 0x672E043D83; // cmp ds:_Meet_Frank_Horrigan, 0
SafeWriteBytes(0x4C06D1, (BYTE*)&data, 5);
ForceEncounterFlags = 0;
@@ -35,6 +35,20 @@ DWORD _stdcall ForceEncounterRestore() {
return mapID;
}
// implements a blinking encounter icon
static void ForceEncounterIcon() {
long iconType = (ForceEncounterFlags & 4) ? 3 : 1; // icon type flag (special: 0-3, normal: 0-1)
*(DWORD*)_wmEncounterIconShow = 1;
*(DWORD*)_wmRndCursorFid = 0;
for (size_t n = 0; n < 7; ++n) {
long iconFidIndex = iconType - *(DWORD*)_wmRndCursorFid;
*(DWORD*)_wmRndCursorFid = iconFidIndex;
__asm call wmInterfaceRefresh_;
BlockForTocks(200);
}
*(DWORD*)_wmEncounterIconShow = 0;
}
static void __declspec(naked) wmRndEncounterOccurred_hack() {
__asm {
test ForceEncounterFlags, 0x1; // _NoCar flag
@@ -45,10 +59,8 @@ static void __declspec(naked) wmRndEncounterOccurred_hack() {
mov eax, ForceEncounterMapID;
call wmMatchAreaContainingMapIdx_;
noCar:
//push ecx;
// TODO: implement a blinking red icon
call ForceEncounterIcon;
call ForceEncounterRestore;
//pop ecx;
push 0x4C0721; // return addr
jmp map_load_idx_; // eax - mapID
}