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 subcomponent for "No traps or locks": Remove only harmful trap effects #133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion cdtweaks/languages/english/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,9 @@ The uninstall messages above are normal and expected.

@312500 = ~Neutral Characters Make Happy Comments at Mid-Range Reputation [Luiz]~

@313000 = ~No Traps or Locks [Weimer]~
@313000 = ~No Traps or Locks [Weimer, argent77]~
@313001 = ~Remove traps completely~
@313010 = ~Remove only harmful trap effects~

@314000 = ~Faster Chapter One and Two Cutscenes and Dreams~
@314001 = ~Originals from Ease-of-Use mod [Karzak, Blucher, aVENGER, Weimer]~
Expand Down
4 changes: 3 additions & 1 deletion cdtweaks/languages/german/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ Wesen (BETA)~
@312400 = ~Verhindern Sie den Romance zwischen Aerie und Haer'Dalis am Anfang~
@312500 = ~Neutrale Charaktere machen glueckliche Bemerkungen bei
durchschnittlichem Ruf~
@313000 = ~Keine Fallen oder Schloesser (Weimer)~
@313000 = ~Keine Fallen oder Schloesser (Weimer, argent77)~
@313001 = ~Entferne Fallen komplett~
@313010 = ~Entferne nur schaedliche Effekte von Fallen~
@314000 = ~Schnellere Kapitel 1+2 Zwischensequenzen und Traeume~
@314001 = ~Originale von Ease-of-Use (Karzak, Blucher)~
@314100 = ~Nicht verrueckte Version~
Expand Down
5 changes: 5 additions & 0 deletions cdtweaks/lib/comp_3130.tpa
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\

///// \\\\\
///// Remove traps completely \\\\\
///// \\\\\


ACTION_IF game_is_iwd2 BEGIN OUTER_SET off = 0x10 END ELSE BEGIN OUTER_SET off = 0 END // outside of this, patch works for v1.0 and v9.1 areas

COPY_EXISTING_REGEXP GLOB ~^.+\.are$~ ~override~
Expand Down
140 changes: 140 additions & 0 deletions cdtweaks/lib/comp_3131.tpa
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
///// \\\\\
///// No traps or locks \\\\\
///// \\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\

///// \\\\\
///// Remove only harmful trap effects \\\\\
///// \\\\\


// Some engine variants allow disarming traps with trap difficulties > 100
OUTER_SET no_trap_limit = ENGINE_IS ~soa tob bgee bg2ee eet iwdee pstee~

// Additional search terms for irregular trap scripts
ACTION_DEFINE_ASSOCIATIVE_ARRAY special_traps BEGIN
// script resref => search terms as regular expressions
~PTALARM1~ => ~CreateCreatureObject(~
~PPSPLIT~ => ~CreateCreature(~
~ACT10~ => ~CreateCreature(~
~ACT11~ => ~CreateCreature(~
~ACT12~ => ~CreateCreature(~
~BATTLEHO~ => ~CreateCreature(~
END

// Patches the specified script resource.
DEFINE_ACTION_FUNCTION patch_trap_script
STR_VAR
script_resref = ~~ // resref of the BCS resource to patch
BEGIN
ACTION_IF (NOT ~%script_resref%~ STR_EQ ~~) BEGIN
ACTION_TO_UPPER ~script_resref~
COPY_EXISTING ~%script_resref%.BCS~ ~override~
// preparing patch operation
SET terms = 0
SPRINT $terms(~%terms%~) ~ForceSpell~ // default search term
SET terms += 1
PATCH_IF (VARIABLE_IS_SET $special_traps(~%script_resref%~)) BEGIN
SPRINT $terms(~%terms%~) $special_traps(~%script_resref%~)
SET terms += 1
END

PATCH_IF (terms > 0) BEGIN
DECOMPILE_AND_PATCH BEGIN
// first pass: remove harmful script actions
SET count_total = 0
FOR (i = 0; i < terms; ++i) BEGIN
SPRINT regex $terms(~%i%~)
REPLACE_EVALUATE ~^[ %TAB%]*\(.*%regex%.*\)$~ BEGIN
PATCH_LOG ~%SOURCE_FILE%: Removing line "%MATCH1%"~
SET count_total += 1
END ~~
END

// second pass: patch empty script blocks
PATCH_IF (count_total > 0) BEGIN
// conflate consecutive empty response blocks
REPLACE_TEXTUALLY CASE_SENSITIVE ~\(RESPONSE #[0-9]+\)\([ %TAB%%WNL%]+RESPONSE #[0-9]+\)+~ ~\1~
// add placeholder actions to empty script blocks
REPLACE_TEXTUALLY CASE_SENSITIVE ~\(RESPONSE #[0-9]+\)[ %TAB%%WNL%]+\(END\)$~ ~\1%LNL%NoAction()%LNL%\2~

PATCH_LOG ~%SOURCE_FILE%: Patched %count_total% instance(s)~
END
END
END
BUT_ONLY IF_EXISTS
END
END

// disabling locks and collecting trap scripts
COPY_EXISTING_REGEXP GLOB ~^.+\.are$~ ~override~
READ_ASCII 0x04 ver (4)
SET off = (~%ver%~ STR_EQ ~V9.1~) ? 0x10 : 0x00 // outside of this, patch works for v1.0 and v9.1 areas

GET_OFFSET_ARRAY trig (0x5c + off) 4 (0x5a + off) 2 0 0 0xc4
GET_OFFSET_ARRAY cont (0x70 + off) 4 (0x74 + off) 2 0 0 0xc0
GET_OFFSET_ARRAY door (0xa8 + off) 4 (0xa4 + off) 4 0 0 0xc8

PHP_EACH trig AS _ => trig_off BEGIN // cycle through triggers
READ_SHORT (trig_off + 0x6a) trap_diff
PATCH_IF ((trap_diff > 0) AND ((no_trap_limit AND trap_diff != 100) || (trap_diff < 100))) BEGIN
READ_ASCII (trig_off + 0x7c) script_resref (8) NULL // script
PATCH_IF (NOT ~%script_resref%~ STR_EQ ~~ && FILE_EXISTS_IN_GAME ~%script_resref%.BCS~) BEGIN
// marking script for patching
TO_UPPER ~script_resref~
SET $trap_scripts(~%script_resref%~) = 1
END
END
END

PHP_EACH cont AS _ => cont_off BEGIN // cycle through containers
READ_ASCII (cont_off + 0x78) key (8) NULL // key
PATCH_IF (("%key%" STR_EQ "") OR ("%key%" STR_EQ "None")) BEGIN
READ_SHORT (cont_off + 0x26) lock_diff // lock difficulty
PATCH_IF ((lock_diff != 0) AND (lock_diff != 100)) BEGIN
WRITE_SHORT (cont_off + 0x26) 0 // lock difficulty
END
END
READ_SHORT (cont_off + 0x2c) trap_diff // trap difficulty
PATCH_IF ((trap_diff != 0) AND (trap_diff != 100)) BEGIN
READ_ASCII (cont_off + 0x48) script_resref (8) NULL // script
PATCH_IF (NOT ~%script_resref%~ STR_EQ ~~ && FILE_EXISTS_IN_GAME ~%script_resref%.BCS~) BEGIN
// marking script for patching
TO_UPPER ~script_resref~
SET $trap_scripts(~%script_resref%~) = 1
END
END
END

PHP_EACH door AS _ => door_off BEGIN // cycle through doors
READ_LONG (door_off + 0x28) flags // door flags
PATCH_IF ((flags & BIT8) = BIT8) BEGIN // if flagged as secret door
WRITE_LONG (door_off + 0x88) 0 // detect diff (secret doors)
WRITE_LONG (door_off + 0x28) (THIS BAND BNOT BIT8) // remove secret flag
END
READ_SHORT (door_off + 0x6e) trap_diff // detect diff
PATCH_IF ((trap_diff != 0) AND (trap_diff != 100)) BEGIN
READ_ASCII (door_off + 0x80) script_resref (8) NULL // script
PATCH_IF (NOT ~%script_resref%~ STR_EQ ~~ && FILE_EXISTS_IN_GAME ~%script_resref%.BCS~) BEGIN
// marking script for patching
TO_UPPER ~script_resref~
SET $trap_scripts(~%script_resref%~) = 1
END
END
READ_ASCII (door_off + 0x78) key (8) NULL // key
PATCH_IF (("%key%" STR_EQ "") OR ("%key%" STR_EQ "None")) BEGIN
READ_LONG (door_off + 0x8c) lock_diff // lock diff
PATCH_IF ((lock_diff != 0) AND (lock_diff != 100)) BEGIN
WRITE_LONG (door_off + 0x8c) 0 // lock diff
END
END
END
BUT_ONLY

// Patching marked trap scripts
ACTION_PHP_EACH trap_scripts AS script_resref => _ BEGIN
LAF patch_trap_script STR_VAR script_resref END
END
9 changes: 7 additions & 2 deletions cdtweaks/readme-cdtweaks.html
Original file line number Diff line number Diff line change
Expand Up @@ -1113,9 +1113,14 @@ <h3> <a id="contents_convenience" name="contents_convenience"></a>Convenience Tw
<em><abbr title="Baldur's Gate: Enhanced Edition">BGEE</abbr>, <abbr title="Baldur's Gate II: Enhanced Edition">BG2EE</abbr>, <abbr title="Icewind Dale: Enhanced Edition">IWDEE</abbr>, <abbr title="Enhanced Edition Trilogy">EET</abbr>, <abbr title="Baldur's Gate">BG</abbr>, <abbr title="Baldur's Gate II">BG2</abbr>, <abbr title="Baldur's Gate Trilogy">BGT</abbr>, Tutu, <abbr title="Icewind Dale">IWD</abbr>-in-<abbr title="Baldur's Gate II">BG2</abbr></em> </p>
<p> Every joinable <abbr title="Non-Player Character">NPC</abbr> has lines they say when they&#39;re happy, ambivalent, or upset about the party&#39;s reputation. In the original tables, neutral characters could never be happy--even at mid-range reputation values, they would remain ambivalent. This component alters the reputation table so that they are now happy at middle of the road values, so you can now hear lines from neutral <abbr title="Non-Player Characters">NPCs</abbr> which were previously not available. This component is completely compatible with any variant of the Happy Patch. </p>
<p> Please note that installing Virtue with this component will essentially nullify it. </p>
<p> <strong>No Traps or Locks [Weimer]</strong><br />
<p> <strong>No Traps or Locks [Weimer, argent77]</strong><br />
<em>All games</em> </p>
<p> All floor traps that can be disarmed are removed from the game. All door and container traps are removed from the game. All locked doors and containers have their lockpick difficulty set to zero (they can be bashed open by anyone in one blow) unless they require a key. All hidden doors have their detect difficulty set to zero (anyone will detect them by standing around long enough). &quot;Special&quot; traps remain. Note that since the traps are gone entirely you cannot get <abbr title="Experience Points">XP</abbr> by disarming them. </p>
<p> This component provides two options how to deal with traps in the game: </p>
<ul>
<li> <em>Remove traps completely:</em> With this option all floor traps that can be disarmed are removed from the game. All door and container traps are removed from the game. Note that since the traps are gone entirely you cannot get <abbr title="Experience Points">XP</abbr> by disarming them. </li>
<li> <em>Remove only harmful trap effects:</em> With this option floor, door and container traps can still be triggered, but without causing any harmful effects on the target. You can still get <abbr title="Experience Points">XP</abbr> by disarming them. </li>
</ul>
<p> All locked doors and containers have their lockpick difficulty set to zero (they can be bashed open by anyone in one blow) unless they require a key. All hidden doors have their detect difficulty set to zero (anyone will detect them by standing around long enough). &quot;Special&quot; traps remain untouched in either case. </p>
<p> <strong>Faster Chapter One and Two Cutscenes and Dreams </strong><br />
<em><abbr title="Baldur's Gate II: Enhanced Edition">BG2EE</abbr>, <abbr title="Enhanced Edition Trilogy">EET</abbr>, <abbr title="Baldur's Gate II">BG2</abbr>, <abbr title="Baldur's Gate Trilogy">BGT</abbr></em> </p>
<p> If you&#39;re replaying the game for the Nth time, this component saves precious minutes. In general this skips or shortens cutscenes and dream sequences. You can also speed up your first encounter with Gaelan Bayle by saying (3) &quot;Yes, show me to your home.&quot; and then (5) &quot;Very well, I&#39;ll be back with the money.&quot; </p>
Expand Down
16 changes: 15 additions & 1 deletion cdtweaks/setup-cdtweaks.tp2
Original file line number Diff line number Diff line change
Expand Up @@ -3492,10 +3492,24 @@ LABEL ~cd_tweaks_happy_neutrals~
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\

BEGIN @313000 DESIGNATED 3130
///// \\\\\
///// Remove traps completely \\\\\
///// \\\\\

BEGIN @313001 DESIGNATED 3130
GROUP @4
SUBCOMPONENT @313000
LABEL ~cd_tweaks_no_traps_or_locks~

///// \\\\\
///// Remove only harmful trap effects \\\\\
///// \\\\\

BEGIN @313010 DESIGNATED 3131
GROUP @4
SUBCOMPONENT @313000
LABEL ~cd_tweaks_no_trap_effects_or_locks~

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