Skip to content

Commit

Permalink
Version 0.2-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed May 20, 2017
1 parent bf3d1f6 commit f246ea9
Show file tree
Hide file tree
Showing 13 changed files with 1,445 additions and 641 deletions.
92 changes: 92 additions & 0 deletions HiddenGameplayOptions/languages/english/mod.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// -*- coding: utf-8 -*-

@1000 = ~Enable Debug Console~
@1001 = ~Enabling this setting allows you to activate cheat keys and the debug console.

Use keyboard shortcut CTRL+SPACE to activate the console in the game.

Cheat keys include CTRL+Y to insta-kill creatures under the mouse cursor, CTRL+R to heal and dispel effects from characters under the mouse cursor, CTRL+J to teleport selected party members to the current cursor location, CTRL+T to advance game time by one hour, CTRL+4 to toggle visibility of interactive regions, and many more.

Console commands include ^PC:AddGold(number)^-, ^PC:CreateItem("name")^-, ^PC:SetCurrentXP(number)^-, and many more.

^NNote: You must restart the game for changes to take effect.^-~

@1100 = ~Enable UI Edit Mode~
@1101 = ~Enabling this setting allows you to use UI edit functionality in the game.

Press F11 to activate or deactivate UI edit mode. While this mode is active it is possible to drag UI elements around the screen. Press F5 to preview UI changes without restarting the game. Press TAB while hovering over an UI element shows which line number in UI.MENU defines that element.

^NNote: You must restart the game for changes to take effect.^-~

@1200 = ~Show Strrefs~
@1201 = ~Enabling this setting places string reference numbers in front of game strings.

^NNote: You must restart the game for changes to take effect.^-~

@1300 = ~Show Trigger Icons on Tab~
@1301 = ~Enable this setting to reveal additional information about interactive regions when pressing the TAB key.

^NNote: You must restart the game for changes to take effect.^-~

@1400 = ~Allow Spacebar in Dialogs~
@1401 = ~Enabling this setting allows you to continue conversations by using the spacebar.

^NNote: You must restart the game for changes to take effect.^-~

@1500 = ~Limit druidic spells for Cleric/Ranger~
@1501 = ~This setting controls the availability of druidic spells for multi- or dualclassed Cleric/Rangers.

Enable this option to limit druidic spells to level 3 - the maximum allowed spell level available to rangers. Cleric spells are not affected by this option.

^NNote: You must restart the game for changes to take effect.^-~

@1600 = ~3E Sneak Attack~
@1601 = ~Enabling this setting activates Sneak Attack and Crippling Strike, which are special abilities similar to those from Wizards of the Coast's 3rd Edition Dungeons & Dragons® rules.

^NNote: You must restart the game for changes to take effect.^-~

@1700 = ~Screen Shake on Critical Hit~
@1701 = ~Enabling this setting triggers a screen shake whenever a party member rolls a critical hit in combat.

^NNote: You must restart the game for changes to take effect.^-~

@1800 = ~Hotkeys On Tooltips~
@1801 = ~When this setting is enabled tooltips will display hotkeys when available.

^NNote: You must restart the game for changes to take effect.^-~

@1900 = ~Show Extra Combat Info~
@1901 = ~Enabling this setting allows you to see all factors that influence an attack roll.

^NNote: You must restart the game for changes to take effect.^-~

@2000 = ~Show Game Date and Time on Pause~
@2001 = ~Shows game date and time when activating pause.

^NNote: You must restart the game for changes to take effect.^-~

@2100 = ~Disable Area Map Zoom~
@2101 = ~Disables the zoom in/zoom out effect when opening or closing the area map screen.

^NNote: You must restart the game for changes to take effect.^-~

@2200 = ~Reverse Mouse Wheel Zoom~
@2201 = ~Reverses the zoom direction when using the mouse wheel.

^NNote: You must restart the game for changes to take effect.^-~

@2300 = ~Pause Game on Map Screen~
@2301 = ~Automatically pauses the game while looking at the map screen.

^NNote: You must restart the game for changes to take effect.^-~

@2400 = ~Enable Fog~
@2401 = ~Enables fog effects on maps.

^NNote: You must restart the game for changes to take effect.^-~

@2500 = ~Disable Movies~
@2501 = ~Enabling this setting disables movie playback.

^NNote: You must restart the game for changes to take effect.^-~

29 changes: 29 additions & 0 deletions HiddenGameplayOptions/languages/english/setup.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// -*- coding: us-ascii -*-

@1 = ~Install Hidden Gameplay Options~
@2 = ~All available options~
@3 = ~Selected options~

@10 = ~Add in-game option "Enable Debug Console"~
@11 = ~Add in-game option "Enable UI Edit Mode"~
@12 = ~Add in-game option "Show Strrefs"~
@13 = ~Add in-game option "Show trigger icons on tab"~
@14 = ~Add in-game option "Allow Spacebar in Dialogs"~
@15 = ~Add in-game option "Limit druidic spells for Cleric/Ranger"~
@16 = ~Add in-game option "3E Sneak Attack"~
@17 = ~Add in-game option "Critical Hit Screen Shake"~
@18 = ~Add in-game option "Hotkeys On Tooltips"~
@19 = ~Add in-game option "Show extra combat info"~
@20 = ~Add in-game option "Show Game Date and Time on Pause"~
@21 = ~Add in-game option "Disable Area Map Zoom"~
@22 = ~Add in-game option "Reverse Mouse Wheel Zoom"~
@23 = ~Add in-game option "Pause Game on Map Screen"~
@24 = ~Add in-game option "Enable Fog"~
@25 = ~Add in-game option "Disable Movies"~

@100 = ~Enhanced Edition game patched to v2.0 or higher required.~
@101 = ~Cannot patch LUA file~
@102 = ~Cannot patch UI.MENU~
@103 = ~Component "Selected options" not selected.~
@104 = ~Option not available for this game.~
@105 = ~Option already present in this game.~
122 changes: 122 additions & 0 deletions HiddenGameplayOptions/lib/functions.tph
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// *** Generic UI-related functions ***

/**
* Adds a new string variable definition into available L_xx_YY.LUA resources.
* INT_VAR traRef TRA reference number of the string to add.
* STR_VAR varName Name of the variable to add.
* RET success Returns 1 if definition has been added successfully to all available LUA files, 0 otherwise.
*/
DEFINE_ACTION_FUNCTION ADD_LUA_DEFINITION
INT_VAR
traRef = "-1"
STR_VAR
varName = ~~
RET
success
BEGIN
OUTER_SET success = 0

ACTION_IF (traRef >= 0 AND NOT ~%varName%~ STR_EQ ~~) BEGIN
COPY_EXISTING_REGEXP ~L_[a-zA-Z][a-zA-Z]_[a-zA-Z][a-zA-Z]\.LUA~ ~override~
SET startOfs = INDEX_BUFFER(~uiStrings[ %TAB%%WNL%]*=[ %TAB%%WNL%]*{~)
SET ofs1 = INDEX_BUFFER(~[ %TAB%]*[a-zA-Z_][a-zA-Z0-9_]*[ %TAB%]*=.+,~ startOfs)
SET failed = 0
PATCH_IF (ofs1 < 0) BEGIN
SET failed = 1
END
PATCH_IF (NOT failed) BEGIN
SET ofs2 = INDEX_BUFFER(~[%WNL%]~ ofs1)
PATCH_IF (ofs2 < ofs1) BEGIN
SET failed = 1
END
END

PATCH_IF (NOT failed) BEGIN
// determining variable definition type
READ_ASCII ofs1 curLine (ofs2 - ofs1)
INNER_PATCH ~%curLine%~ BEGIN
SET v = INDEX_BUFFER(~[ %TAB%]*=[ %TAB%]*"[^"]+"~)
SET isStrref = (v < 0) ? 1 : 0
END

PATCH_IF (isStrref) BEGIN
SET number = RESOLVE_STR_REF((AT traRef))
TEXT_SPRINT line ~%TAB%%varName% = %number%,%LNL%~
END ELSE BEGIN
SPRINT text (AT traRef)
INNER_PATCH_SAVE text ~%text%~ BEGIN
REPLACE_TEXTUALLY ~%MNL%?%LNL%~ ~\n~ // line break -> symbolic line break
REPLACE_TEXTUALLY ~\([^\\]\)"~ ~\1\"~ // double-quotes must be escaped
REPLACE_TEXTUALLY ~\^[0-9A-Z$]\([^^]+\)\^-~ ~\1~ // just a precaution: older games don't appear to support colored text in options menu yet
END
TEXT_SPRINT line ~%TAB%%varName% = "%text%",%LNL%~
END

// inserting text definition
SET strlen = STRING_LENGTH ~%line%~
INSERT_BYTES ofs1 strlen
WRITE_ASCIIE ofs1 ~%line%~

SET success = 1
END
END
END


/**
* Returns the value associated to the specified variable name found in L_xx_YY.LUA (where xx_YY is a language code).
* STR_VAR varName The variable name
* RET value The numeric value assigned to the variable. Returns -1 if not available.
*/
DEFINE_ACTION_FUNCTION GET_LUA_VALUE
STR_VAR
varName = ""
RET
value
BEGIN
OUTER_SET value = "-1"

OUTER_TEXT_SPRINT luaFile ~L_%EE_LANGUAGE%.LUA~
ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%luaFile%~) BEGIN
OUTER_TEXT_SPRINT luaFile ~L_EN_US.LUA~
ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%luaFile%~) BEGIN
OUTER_TEXT_SPRINT luaFile ~~
COPY_EXISTING_REGEXP - ~L_[a-zA-Z][a-zA-Z]_[a-zA-Z][a-zA-Z]\.LUA~ ~override~
PATCH_IF (~%luaFile%~ STR_EQ ~~) BEGIN
TEXT_SPRINT luaFile ~%SOURCE_FILE%~
END
END
END

ACTION_IF (FILE_EXISTS_IN_GAME ~%luaFile%~) BEGIN
COPY_EXISTING - ~%luaFile%~ ~override~
SET ofs1 = INDEX_BUFFER(~.*%varName%[ %TAB%]*=~)
PATCH_IF (ofs1 >= 0) BEGIN
SET ofs2 = INDEX_BUFFER(~[%WNL%]~ ofs1)
PATCH_IF (ofs2 > ofs1) BEGIN
READ_ASCII ofs1 line (ofs2 - ofs1)
INNER_PATCH_SAVE val ~%line%~ BEGIN REPLACE_TEXTUALLY ~.*=[ %TAB%]*\(-?[0-9]*\).*~ ~\1~ END
PATCH_IF (~%val%~ STR_EQ ~~) BEGIN
// value may be a literal string
INNER_PATCH_SAVE string ~%line%~ BEGIN REPLACE_TEXTUALLY ~.*=[ %TAB%]*"\([^"]*\)".*~ ~\1~ END
INNER_PATCH_SAVE string ~%string%~ BEGIN REPLACE_TEXTUALLY ~\\n~ ~%LNL%~ END
SET value = RESOLVE_STR_REF(~%string%~)
END ELSE PATCH_IF (IS_AN_INT "val") BEGIN
// value is a valid number
SET value = val
END
END
END
END
END

DEFINE_PATCH_FUNCTION GET_LUA_VALUE
STR_VAR
varName = ""
RET
value
BEGIN
INNER_ACTION BEGIN
LAF GET_LUA_VALUE STR_VAR varName = EVAL ~%varName%~ RET value END
END
END
Loading

0 comments on commit f246ea9

Please sign in to comment.