Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New component: Dynamic FPS Change #124

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cdtweaks/languages/english/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ Use Baldur.lua options: a7_interval_ini
@341100 = ~Mage, priest, and innate spells only~
@341200 = ~All spells (check readme)~

@344000 = ~Dynamic FPS Change [Luke (EEex)]~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
Expand Down
2 changes: 2 additions & 0 deletions cdtweaks/languages/italian/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ Usa opzioni di Baldur.lua: a7_interval_ini

@336000 = ~Ripristina la nebbia di guerra nei sotterranei di Sigil~

@344000 = ~Regola in modo automatico gli FPS [Luke (EEex)]~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
Expand Down
14 changes: 14 additions & 0 deletions cdtweaks/lib/comp_3440.tpa
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////
///// \\\\\////\\\\////
///// Dynamic FPS change \\\\\
///// \\\\\////\\\\////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\////\\\\////

WITH_SCOPE BEGIN
INCLUDE "cdtweaks\luke\misc.tph"
//
INCLUDE "cdtweaks\lib\dynamic_fps_change.tph"
LAF "DYNAMIC_FPS_CHANGE" END
END
20 changes: 20 additions & 0 deletions cdtweaks/lib/dynamic_fps_change.tph
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DEFINE_ACTION_FUNCTION "DYNAMIC_FPS_CHANGE"
BEGIN
LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks" "sourceFileSpec" = "cdtweaks\luke\lua\tweaks\dynamic_fps_change.lua" "destRes" = "m_gttwks" END
//
<<<<<<<< .../cdtweaks-inlined/dynamic_fps_change.baf
IF
True()
THEN
RESPONSE #100
EEex_LuaAction("cdtweaks_DynamicFPSChange()")
Continue()
END
>>>>>>>>
//
ACTION_FOR_EACH "world_script" IN "baldur" "baldur25" "bdbaldur" BEGIN
ACTION_IF (FILE_EXISTS_IN_GAME "%world_script%.bcs") BEGIN
EXTEND_TOP "%world_script%.bcs" ".../cdtweaks-inlined/dynamic_fps_change.baf"
END
END
END
41 changes: 41 additions & 0 deletions cdtweaks/luke/lua/tweaks/dynamic_fps_change.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--[[
+-------------------------------------------------------+
| cdtweaks: automatically change FPS during playthrough |
+-------------------------------------------------------+
--]]

-- When in cutscene, lock FPS to 30 --

EEex_Opcode_AddListsResolvedListener(function(sprite)
-- Sanity check
if not EEex_GameObject_IsSprite(sprite) then
return
end
--
if sprite.m_inCutScene == 1 then
if EEex_CChitin.TIMER_UPDATES_PER_SECOND ~= 30 then
EEex_CChitin.TIMER_UPDATES_PER_SECOND = 30
end
end
end)

-- When in combat, lock FPS to 30. Otherwise, set to 60 --

function cdtweaks_DynamicFPSChange()
-- [Bubb] Each area has its own combat counter. You can check the global script runner's area in this way...
local globalScriptRunnerId = EngineGlobals.g_pBaldurChitin.m_pObjectGame.m_nAIIndex
local globalScriptRunner = EEex_GameObject_Get(globalScriptRunnerId)
local globalScriptRunnerArea = globalScriptRunner.m_pArea
--local globalScriptRunnerAreaResref = globalScriptRunnerArea and globalScriptRunnerArea.m_resref:get() or "nil"
--Infinity_DisplayString(string.format("Global script runner area resref: \"%s\"", globalScriptRunnerAreaResref))
--
if globalScriptRunnerArea.m_nBattleSongCounter > 0 then
if EEex_CChitin.TIMER_UPDATES_PER_SECOND ~= 30 then
EEex_CChitin.TIMER_UPDATES_PER_SECOND = 30
end
else
if EEex_CChitin.TIMER_UPDATES_PER_SECOND ~= 60 then
EEex_CChitin.TIMER_UPDATES_PER_SECOND = 60
end
end
end
8 changes: 8 additions & 0 deletions cdtweaks/readme-cdtweaks.html
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,14 @@ <h3> <a id="contents_convenience" name="contents_convenience"></a>Convenience Tw
<li><em>Mage, priest, and innate spells</em> - as above, but adds spells traditionally in the innate and kit ability space such as Lay on Hands or Boon of Lathander</li>
<li><em>All spells</em> - because the game uses spells to perform a lot of different functions, such as traps or cutscene effects,this option may provide more feedback than desired or expose purely internal spell names such as &quot;just 10 damage&quot;. It is, however, the best way to guarantee that all spells from mods are caught</li>
</ul>

<p> <strong>Dynamic FPS Change</strong><br />
<em><abbr title="Baldur's Gate: Enhanced Edition">EEex</abbr></em></p>
<p>
This component will automatically adjust FPS during playthrough.<br>
When in combat or cutscene, will lock FPS to 30. Otherwise, will set them to 60.
</p>

</div>
<div class="ribbon_rectangle_h3">
<h3> <a id="contents_npc" name="contents_npc"></a>Joinable <abbr title="Non-Player Character">NPC</abbr> Tweaks </h3>
Expand Down
14 changes: 14 additions & 0 deletions cdtweaks/setup-cdtweaks.tp2
Original file line number Diff line number Diff line change
Expand Up @@ -4420,6 +4420,20 @@ GROUP @4
SUBCOMPONENT @341000
LABEL ~cd_tweaks_casting_warnings_all~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
///// Dynamic FPS Change \\\\\
///// \\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\

BEGIN @344000 DESIGNATED 3440
GROUP @4
REQUIRE_PREDICATE GAME_IS ~bgee bg2ee eet iwdee~ @25
REQUIRE_PREDICATE MOD_IS_INSTALLED "EEex.tp2" 0 @29
LABEL ~cd_tweaks_dynamic_fps_change~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
Expand Down