Skip to content

Commit

Permalink
Merge branch 'stutter-work' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubb13 committed Feb 16, 2024
2 parents f2dc994 + bc83d8a commit ea7d082
Show file tree
Hide file tree
Showing 58 changed files with 4,666 additions and 2,974 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@
!/EEex/copy/*.*
!/EEex/loader
!/EEex/loader/*.*
!/EEex/loader/Lua52
!/EEex/loader/Lua52/*.*
!/EEex/loader/LuaJIT
!/EEex/loader/LuaJIT/*.*
!/EEex/patch
!/EEex/patch/*.*
!/pdb
!/pdb/*.*
!/pdb/Lua52
!/pdb/Lua52/*.*
!/pdb/LuaJIT
!/pdb/LuaJIT/*.*
!/style
!/style/*.*
!/.gitattributes
Expand Down
34 changes: 23 additions & 11 deletions EEex/EEex.tp2
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ AUTHOR ~Bubb~
VERSION ~master~
README ~EEex/readme-EEex.html~

BEGIN ~EEex~
BEGIN ~EEex~ LABEL ~B3-EEex-Main~
REQUIRE_PREDICATE (GAME_IS ~bgee bg2ee eet iwdee~ AND FILE_EXISTS ~data/PATCH26.BIF~) ~Game not supported.~

ACTION_FOR_EACH file IN ACTION OBJECT TRIGGER BEGIN
COPY ~EEex\patch\%file%.IDS~ ~EEex\patch~
COPY ~EEex/patch/%file%.IDS~ ~EEex/patch~
COUNT_2DA_ROWS 2 rows
FOR (i = 0; i <= rows; ++i) BEGIN
READ_2DA_ENTRY i 0 2 "col1"
Expand Down Expand Up @@ -44,59 +44,71 @@ REQUIRE_PREDICATE (GAME_IS ~bgee bg2ee eet iwdee~ AND FILE_EXISTS ~data/PATCH26.
APPEND ~%data%.IDS~ ~%data_1% %data_2%~ UNLESS ~^[ %TAB%]*%data_1_escaped%[ %TAB%]+%data_2_escaped%[ %TAB%]*%MNL%*$~
END

COPY ~EEex/loader~ ~.~ IF_EXISTS
COPY ~EEex/copy~ ~override~ IF_EXISTS
COPY ~EEex/loader~ ~.~
COPY ~EEex/loader/Lua52~ ~.~
COPY ~EEex/copy~ ~override~


BEGIN ~Enable effect menu module - LShift-on-hover to view spells affecting creature~
BEGIN ~Experimental - Use LuaJIT (can help stuttering)~ LABEL ~B3-EEex-LuaJIT~
REQUIRE_COMPONENT ~EEex.tp2~ ~0~ ~This component requires the main component to be installed.~

COPY ~InfinityLoader.ini~ ~.~
REPLACE_TEXTUALLY ~^\(LuaLibrary=\).*~ ~\1lua51.dll~
REPLACE_TEXTUALLY ~^\(LuaPatchMode=\).*~ ~\1REPLACE_INTERNAL_WITH_EXTERNAL~
BUT_ONLY

COPY ~EEex/loader/LuaJIT~ ~.~


BEGIN ~Enable effect menu module - LShift-on-hover to view spells affecting creature~ LABEL ~B3-EEex-Module-Effect-Menu~
REQUIRE_COMPONENT ~EEex.tp2~ ~0~ ~This component requires the main component to be installed.~

COPY ~override/EEex_Modules.lua~ ~override~
REPLACE_TEXTUALLY ~^\([ %TAB%]+\["B3EffMen"\][ %TAB%]+=[ %TAB%]+\)false~ ~\1true~
BUT_ONLY


BEGIN ~Enable timer module - Visual indicators for modal actions, contingencies, and spell/item cooldowns~
BEGIN ~Enable timer module - Visual indicators for modal actions, contingencies, and spell/item cooldowns~ LABEL ~B3-EEex-Module-Timer-Main~
REQUIRE_COMPONENT ~EEex.tp2~ ~0~ ~This component requires the main component to be installed.~

COPY ~override/EEex_Modules.lua~ ~override~
REPLACE_TEXTUALLY ~^\([ %TAB%]+\["B3Timer"\][ %TAB%]+=[ %TAB%]+\)false~ ~\1true~
BUT_ONLY


BEGIN ~Timer module - Show modal actions (red bar)~
BEGIN ~Timer module - Show modal actions (red bar)~ LABEL ~B3-EEex-Module-Timer-Modal~
REQUIRE_COMPONENT ~EEex.tp2~ ~2~ ~This component requires the "Enable timer module" component to be installed.~

COPY ~override/B3Timer.lua~ ~override~
REPLACE_TEXTUALLY ~^\(B3Timer_ShowModalTimer = \)[^ %TAB%%WNL%]+~ ~\1true~
BUT_ONLY


BEGIN ~Timer module - Show contingencies (green bar)~
BEGIN ~Timer module - Show contingencies (green bar)~ LABEL ~B3-EEex-Module-Timer-Contingency~
REQUIRE_COMPONENT ~EEex.tp2~ ~2~ ~This component requires the "Enable timer module" component to be installed.~

COPY ~override/B3Timer.lua~ ~override~
REPLACE_TEXTUALLY ~^\(B3Timer_ShowContingencyTimer = \)[^ %TAB%%WNL%]+~ ~\1true~
BUT_ONLY


BEGIN ~Timer module - Show spell/item cooldowns (cyan bar)~
BEGIN ~Timer module - Show spell/item cooldowns (cyan bar)~ LABEL ~B3-EEex-Module-Timer-Aura~
REQUIRE_COMPONENT ~EEex.tp2~ ~2~ ~This component requires the "Enable timer module" component to be installed.~

COPY ~override/B3Timer.lua~ ~override~
REPLACE_TEXTUALLY ~^\(B3Timer_ShowCastTimer = \)[^ %TAB%%WNL%]+~ ~\1true~
BUT_ONLY


BEGIN ~Time step module - Advance 1 game tick on keypress~
BEGIN ~Time step module - Advance 1 game tick on keypress~ LABEL ~B3-EEex-Module-Time-Step~
REQUIRE_COMPONENT ~EEex.tp2~ ~0~ ~This component requires the main component to be installed.~

COPY ~override/EEex_Modules.lua~ ~override~
REPLACE_TEXTUALLY ~^\([ %TAB%]+\["B3TimeStep"\][ %TAB%]+=[ %TAB%]+\)false~ ~\1true~
BUT_ONLY


BEGIN ~Hotkey module - Edit override/B3Hotkey.lua to create advanced spell hotkeys~
BEGIN ~Hotkey module - Edit override/B3Hotkey.lua to create advanced spell hotkeys~ LABEL ~B3-EEex-Module-Hotkey~
REQUIRE_COMPONENT ~EEex.tp2~ ~0~ ~This component requires the main component to be installed.~

COPY ~override/EEex_Modules.lua~ ~override~
Expand Down
240 changes: 163 additions & 77 deletions EEex/copy/B3Invis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,92 +24,178 @@ end

EEex_DisableCodeProtection()

for _, address in ipairs({
EEex_Label("Hook-CGameSprite::IsOver()-B3Invis"),
EEex_Label("Hook-CGameSprite::RenderMarkers()-B3Invis1")
}) do

EEex_HookJumpOnFail(address, 7, EEex_FlattenTable({[[
#MAKE_SHADOW_SPACE(32)
]], EEex_GenLuaCall("B3Invis_Hook_CanSeeInvisible", {
--[[
+------------------------------------------------------------------------------------------------------+
| Allow cursor to interact with invisible creatures if a selected creature has op193 |
+------------------------------------------------------------------------------------------------------+
| [Lua] B3Invis_Hook_CanSeeInvisible() -> boolean |
| return: |
| -> false - Don't alter engine behavior |
| -> true - Allow the cursor to interact with the creature regardless of it being invisible |
+------------------------------------------------------------------------------------------------------+
--]]

EEex_HookConditionalJumpOnFailWithLabels(EEex_Label("Hook-CGameSprite::IsOver()-B3Invis"), 7, {
{"hook_integrity_watchdog_ignore_registers", {
EEex_HookIntegrityWatchdogRegister.RAX, EEex_HookIntegrityWatchdogRegister.RCX, EEex_HookIntegrityWatchdogRegister.RDX,
EEex_HookIntegrityWatchdogRegister.R8, EEex_HookIntegrityWatchdogRegister.R9, EEex_HookIntegrityWatchdogRegister.R10,
EEex_HookIntegrityWatchdogRegister.R11
}}},
EEex_FlattenTable({
{[[
#MAKE_SHADOW_SPACE(32)
]]},
EEex_GenLuaCall("B3Invis_Hook_CanSeeInvisible", {
["returnType"] = EEex_LuaCallReturnType.Boolean,
}), [[
}),
{[[
jmp no_error
call_error:
xor rax, rax
no_error:
test rax, rax
#DESTROY_SHADOW_SPACE
jnz #L(jmp_success)
]]},
})
)

--[[
+---------------------------------------------------------------------------------------+
| Allow invisible creature markers to render if a selected creature has op193 |
+---------------------------------------------------------------------------------------+
| [Lua] B3Invis_Hook_CanSeeInvisible() -> boolean |
| return: |
| -> false - Don't alter engine behavior |
| -> true - Force the creature's marker to not be hidden due to invisibility |
+---------------------------------------------------------------------------------------+
--]]

EEex_HookConditionalJumpOnFailWithLabels(EEex_Label("Hook-CGameSprite::RenderMarkers()-B3Invis1"), 7, {
{"hook_integrity_watchdog_ignore_registers", {
EEex_HookIntegrityWatchdogRegister.RAX, EEex_HookIntegrityWatchdogRegister.RCX, EEex_HookIntegrityWatchdogRegister.RDX,
EEex_HookIntegrityWatchdogRegister.R8, EEex_HookIntegrityWatchdogRegister.R10, EEex_HookIntegrityWatchdogRegister.R11
}}},
EEex_FlattenTable({
{[[
#MAKE_SHADOW_SPACE(40)
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)], r9
]]},
EEex_GenLuaCall("B3Invis_Hook_CanSeeInvisible", {
["returnType"] = EEex_LuaCallReturnType.Boolean,
}),
{[[
jmp no_error
jmp no_error
call_error:
xor rax, rax
call_error:
xor rax, rax
no_error:
test rax, rax
no_error:
test rax, rax
#DESTROY_SHADOW_SPACE
jnz #L(jmp_success)
jmp jmp_fail
]]}))
end
mov r9, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)]
#DESTROY_SHADOW_SPACE
jnz #L(jmp_success)
]]},
})
)

if B3Invis_RenderAsInvisible then

EEex_HookJumpOnSuccess(EEex_Label("Hook-CGameSprite::Render()-B3Invis"), 6, EEex_FlattenTable({[[
#MAKE_SHADOW_SPACE(48)
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)], rcx
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-16)], rdx
]], EEex_GenLuaCall("B3Invis_Hook_CanSeeInvisible", {
["returnType"] = EEex_LuaCallReturnType.Boolean,
}), [[
jmp no_error
call_error:
xor rax, rax
no_error:
test rax, rax
mov rdx, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-16)]
mov rcx, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)]
#DESTROY_SHADOW_SPACE
jnz jmp_fail
jmp #L(jmp_success)
]]}))
--[[
+---------------------------------------------------------------------------------------------------------------------+
| (Option #1) Render invisible creatures as transparent (like improved invisibility) if a selected creature has op193 |
+---------------------------------------------------------------------------------------------------------------------+
| [Lua] B3Invis_Hook_CanSeeInvisible() -> boolean |
| return: |
| -> false - Don't alter engine behavior |
| -> true - Force the creature to be rendered as transparent |
+---------------------------------------------------------------------------------------------------------------------+
--]]

EEex_HookConditionalJumpOnSuccessWithLabels(EEex_Label("Hook-CGameSprite::Render()-B3Invis"), 6, {
{"hook_integrity_watchdog_ignore_registers", {
EEex_HookIntegrityWatchdogRegister.RAX, EEex_HookIntegrityWatchdogRegister.R8, EEex_HookIntegrityWatchdogRegister.R9,
EEex_HookIntegrityWatchdogRegister.R10, EEex_HookIntegrityWatchdogRegister.R11
}}},
EEex_FlattenTable({
{[[
#MAKE_SHADOW_SPACE(48)
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)], rcx
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-16)], rdx
]]},
EEex_GenLuaCall("B3Invis_Hook_CanSeeInvisible", {
["returnType"] = EEex_LuaCallReturnType.Boolean,
}),
{[[
jmp no_error
call_error:
xor rax, rax
no_error:
test rax, rax
mov rdx, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-16)]
mov rcx, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)]
#DESTROY_SHADOW_SPACE
jnz #L(jmp_fail)
]]},
})
)
else
-- Force circle
EEex_HookAfterRestore(EEex_Label("Hook-CGameSprite::RenderMarkers()-B3Invis2"), 0, 6, 6, EEex_FlattenTable({[[
jnz #L(return)
#MAKE_SHADOW_SPACE(64)
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)], rax
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-16)], rcx
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-24)], rdx
]], EEex_GenLuaCall("B3Invis_Hook_ForceCircle", {
["args"] = {
function(rspOffset) return {[[
mov qword ptr ss:[rsp+#$(1)], rsi
]], {rspOffset}}, "CGameSprite" end,
},
["returnType"] = EEex_LuaCallReturnType.Boolean,
}), [[
jmp no_error
call_error:
xor rax, rax
no_error:
test rax, rax

mov rdx, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-24)]
mov rcx, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-16)]
mov rax, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)]
#DESTROY_SHADOW_SPACE
]]}))
--[[
+-------------------------------------------------------------------------------------------------------+
| (Option #2) Render invisible creatures with an always-visible marker if a selected creature has op193 |
+-------------------------------------------------------------------------------------------------------+
| [Lua] B3Invis_Hook_ForceCircle(sprite: CGameSprite) -> boolean |
| return: |
| -> false - Don't alter engine behavior |
| -> true - Force the creature's marker to render |
+-------------------------------------------------------------------------------------------------------+
--]]

EEex_HookAfterRestoreWithLabels(EEex_Label("Hook-CGameSprite::RenderMarkers()-B3Invis2"), 0, 6, 6, {
{"hook_integrity_watchdog_ignore_registers", {
EEex_HookIntegrityWatchdogRegister.R8, EEex_HookIntegrityWatchdogRegister.R10, EEex_HookIntegrityWatchdogRegister.R11
}}},
EEex_FlattenTable({
{[[
jnz #L(return)
#MAKE_SHADOW_SPACE(72)
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)], rax
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-16)], rcx
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-24)], rdx
mov qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-32)], r9
]]},
EEex_GenLuaCall("B3Invis_Hook_ForceCircle", {
["args"] = {
function(rspOffset) return {"mov qword ptr ss:[rsp+#$(1)], rsi #ENDL", {rspOffset}}, "CGameSprite" end,
},
["returnType"] = EEex_LuaCallReturnType.Boolean,
}),
{[[
jmp no_error
call_error:
xor rax, rax
no_error:
test rax, rax
mov r9, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-32)]
mov rdx, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-24)]
mov rcx, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-16)]
mov rax, qword ptr ss:[rsp+#SHADOW_SPACE_BOTTOM(-8)]
#DESTROY_SHADOW_SPACE
]]},
})
)
end

EEex_EnableCodeProtection()
Expand Down
23 changes: 17 additions & 6 deletions EEex/copy/B3Scale.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,23 @@ end

EEex_DisableCodeProtection()

EEex_HookAfterCall(EEex_Label("Hook-CChitin::OnResizeWindow()-B3Scale"), EEex_FlattenTable({[[
#MAKE_SHADOW_SPACE(32)
]], EEex_GenLuaCall("B3Scale_Hook_DoSizeChange"), [[
call_error:
#DESTROY_SHADOW_SPACE
]]}))
--[[
+---------------------------------------------------+
| Tweak the UI scale whenever the window is resized |
+---------------------------------------------------+
| [Lua] B3Scale_Hook_DoSizeChange() |
+---------------------------------------------------+
--]]

EEex_HookAfterCallWithLabels(EEex_Label("Hook-CChitin::OnResizeWindow()-B3Scale"), {
{"hook_integrity_watchdog_ignore_registers", {EEex_HookIntegrityWatchdogRegister.RAX}}},
EEex_FlattenTable({[[
#MAKE_SHADOW_SPACE(32)
]], EEex_GenLuaCall("B3Scale_Hook_DoSizeChange"), [[
call_error:
#DESTROY_SHADOW_SPACE
]]})
)

EEex_EnableCodeProtection()

Expand Down
Loading

0 comments on commit ea7d082

Please sign in to comment.