From 8e66b82f76a5e11156413d2b46664b910f7ee05c Mon Sep 17 00:00:00 2001 From: NovaRain Date: Wed, 20 Jan 2021 10:21:48 +0800 Subject: [PATCH] Added a new example mod gl_auto_closebox Updated gl_highlighting_lite example mod. Updated engine structs. --- artifacts/ddraw.ini | 2 +- .../AutoCloseBox/gl_auto_closebox.int | Bin 0 -> 508 bytes .../AutoCloseBox/gl_auto_closebox.ssl | 33 ++++++++++++++++ .../example_mods/AutoCloseBox/readme.txt | 9 +++++ artifacts/example_mods/AutoDoors/readme.txt | 2 +- .../gl_highlighting_lite.int | Bin 3582 -> 3754 bytes .../gl_highlighting_lite.ssl | 11 +++++- .../example_mods/ItemHighlight_Lite/main.h | 1 + sfall/BugFixes.cpp | 2 +- sfall/FalloutStructs.h | 36 ++++++++++++++---- 10 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 artifacts/example_mods/AutoCloseBox/gl_auto_closebox.int create mode 100644 artifacts/example_mods/AutoCloseBox/gl_auto_closebox.ssl create mode 100644 artifacts/example_mods/AutoCloseBox/readme.txt diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 3c12e1a5..8bd3d726 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -638,8 +638,8 @@ PipboyTimeAnimDelay=50 ;Set to 0 to disable ;Set to 1 to control all critters in combat ;Set to 2 to control all party members -;If you want to control only specific critters, uncomment the ControlCombatPIDList line and set a comma delimited list of PIDs ControlCombat=0 +;If you want to control only specific critters, uncomment the ControlCombatPIDList line and set a comma delimited list of PIDs ;ControlCombatPIDList=62,89,97,107,160,161 ;Set to 1 to stack empty identical weapons, no matter what type of ammo was loaded before diff --git a/artifacts/example_mods/AutoCloseBox/gl_auto_closebox.int b/artifacts/example_mods/AutoCloseBox/gl_auto_closebox.int new file mode 100644 index 0000000000000000000000000000000000000000..a308c257e141bfa6599f868556278e3c07cfaccb GIT binary patch literal 508 zcmZo*I>5-lz#!DX3#PXkqqroosDy!mCnrC@#6Kx3HMxX=;s5{t{}~t<6d1TbqVf4j zSs-_%r154w25Q~AK!4O02+hF2zz=5eOafC3j0u~S7_}Jr z+!J$Cee+XNoih^i(o;7(F|jZ)@l2ZR!Q#Ti$}qW)MV#^7&W;MyP!VzYjmyoS}6F=+BHR)6OPkO%`qgAqiI?N)u}@@N zH2DO(uXGbsozVnPVwlua)?m`04-(^Om~6md&-tT)1;pdrGr5Apo^j9Q9UQ*Wb3h^t zAlLqevY@tb7EM;*)MT7B*?>cRav`S#t`;TOcCbO(1#k9S|M^1Jo{v{o5uNaGP21s6hpx0nYsc z65x&N4={p~dxHZc*ibd|sDLyJ@l>H|=1H5pgWE}kZ&G6lBzky2(XHPg)g%B`$kJdA zF^%WUWH}yj#&46&c=VWf)h4HbsIbY?Kvdi0V?6qd+a`bG(Pw-zS&dhPiH~Qp53e2* kpV{OZUJWL`gvrZz&Bf)xCUP_-foTaa$=Q@NIe=XP0O{Su(*OVf delta 942 zcmZ1_`%hY+f$0Dv0|SFl122eX{xeZPww{ZDfq{(y1+aKQxmr*fN`b{$7#J9ApaM{e zk$vH3d( zfJ7J=8jK)vY^xe18uS~az@m%@J!~xv5)H0!8P*0Nm}zXQChuWWHH4VM+#m!s=N6JV zAk$AmO*Dqcv$ISVV%KD}m~6wY$rvy>jeR0x(c~ZOzS2QZbw(3Fu|27&tihx~A0);R zFgbz4p7TTl3y8M`-`m}~-~UQABm)n}BLJcU=E p(QWb(UKJ+ZyveV4^_X~POqSx)VB$SA*@e%XT>@+e$K(loQUE*3xZVH& diff --git a/artifacts/example_mods/ItemHighlight_Lite/gl_highlighting_lite.ssl b/artifacts/example_mods/ItemHighlight_Lite/gl_highlighting_lite.ssl index 8ec71524..46a2a178 100644 --- a/artifacts/example_mods/ItemHighlight_Lite/gl_highlighting_lite.ssl +++ b/artifacts/example_mods/ItemHighlight_Lite/gl_highlighting_lite.ssl @@ -100,8 +100,16 @@ procedure KeyPressHandler begin end end +// visual glitch fix - for 3.8.29+ +procedure GameModeChangeHandler begin + if isHighlight and (get_game_mode bwand (INTFACELOOT bwor BARTER)) then begin + isHighlight := false; + call ToggleHighlight(false); + end +end + procedure InventoryMoveHandler begin - // remove item outline when player picks up the item + // remove item outline when player picks up the item - for 3.8.18+ if (isHighlight and get_sfall_arg == 7) then set_outline(get_sfall_arg, 0); end @@ -121,6 +129,7 @@ procedure start begin highlightFailMsg2 := Translate("HighlightFail2", "Your motion sensor is out of charge."); register_hook_proc(HOOK_KEYPRESS, KeyPressHandler); + register_hook_proc(HOOK_GAMEMODECHANGE, GameModeChangeHandler); register_hook_proc(HOOK_INVENTORYMOVE, InventoryMoveHandler); end end diff --git a/artifacts/example_mods/ItemHighlight_Lite/main.h b/artifacts/example_mods/ItemHighlight_Lite/main.h index 16223ad9..28c719f3 100644 --- a/artifacts/example_mods/ItemHighlight_Lite/main.h +++ b/artifacts/example_mods/ItemHighlight_Lite/main.h @@ -4,6 +4,7 @@ #include "..\scripting\headers\sfall.h" #include "..\scripting\headers\define_lite.h" #include "..\scripting\headers\define_extra.h" +#include "..\scripting\headers\command_lite.h" #include "..\scripting\headers\dik.h" /* #include "..\scripting\headers\lib.arrays.h" diff --git a/sfall/BugFixes.cpp b/sfall/BugFixes.cpp index d66515c6..eac9c9f9 100644 --- a/sfall/BugFixes.cpp +++ b/sfall/BugFixes.cpp @@ -3593,7 +3593,7 @@ void BugFixes_Init() // Fix broken Print() script function HookCall(0x461AD4, (void*)windowOutput_); - // Fix obj_close/open functions setting/unsetting incorrect flags for non-door objects + // Fix for the flags of non-door objects being set/unset when opening/closing objects (e.g. using obj_close/open functions) MakeCall(0x49CBF7, check_door_state_hack_close, 2); MakeCall(0x49CB30, check_door_state_hack_open, 1); } diff --git a/sfall/FalloutStructs.h b/sfall/FalloutStructs.h index 9f3f5a24..16b2d186 100644 --- a/sfall/FalloutStructs.h +++ b/sfall/FalloutStructs.h @@ -70,7 +70,7 @@ struct TGameObj { long y; long sx; long sy; - long frm; + long frm; // current frame long rotation; long artFid; long flags; @@ -84,15 +84,15 @@ struct TGameObj { union { struct { - char updatedFlags[4]; + long updatedFlags; // for weapons - ammo in magazine, for ammo - amount of ammo in last ammo pack long charges; // current type of ammo loaded in magazine long ammoPid; - char gap_44[32]; + long unused[8]; // offset 0x44 } item; struct { - long reaction; + long reaction; // unused? // 1 - combat, 2 - enemies out of sight, 4 - running away long combatState; // aka action points @@ -105,14 +105,27 @@ struct TGameObj { long health; long rads; long poison; + + inline bool IsDead() { + return ((damageFlags & DAM_DEAD) != 0); + } + inline bool IsNotDead() { + return ((damageFlags & DAM_DEAD) == 0); + } + inline bool IsActive() { + return ((damageFlags & (DAM_KNOCKED_OUT | DAM_LOSE_TURN)) == 0); + } + inline bool IsNotActive() { + return ((damageFlags & (DAM_KNOCKED_OUT | DAM_LOSE_TURN)) != 0); + } } critter; }; - DWORD protoId; - long cid; + DWORD protoId; // object PID + long cid; // combat ID long lightDistance; long lightIntensity; DWORD outline; - long scriptId; + long scriptId; // SID 0x0Y00XXXX: Y - type: 0=s_system, 1=s_spatial, 2=s_time, 3=s_item, 4=s_critter; XXXX - index in scripts.lst; 0xFFFFFFFF no attached script TGameObj* owner; long scriptIndex; @@ -122,6 +135,13 @@ struct TGameObj { inline char TypeFid() { return ((artFid >> 24) & 0x0F); } + + inline bool IsItem() { + return (Type() == OBJ_TYPE_ITEM); + } + inline bool IsCritter() { + return (Type() == OBJ_TYPE_CRITTER); + } }; // Results of compute_attack_() function. @@ -664,7 +684,7 @@ struct AudioFile { long length; long sample_rate; long channels; - long tell; + long position; }; #pragma pack(pop)