Skip to content

Commit

Permalink
Added component that applies improved Shamanic Dance behavior to avai…
Browse files Browse the repository at this point in the history
…lable Shaman kits
  • Loading branch information
Argent77 committed Dec 2, 2017
1 parent 5dc929c commit 94db204
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 0 deletions.
1 change: 1 addition & 0 deletions A7#ImprovedShamanicDance/language/english/setup.tra
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@1 = ~Improved Shamanic Dance~
@2 = ~Expanded Shamanic Dance for high level characters~
@3 = ~Add spell "Shamanic Pact"~
@4 = ~Apply Shamanic Dance improvements to Shaman kits~

@50 = ~Enhanced Edition game is required.~
@51 = ~No shaman class available.~
Expand Down
1 change: 1 addition & 0 deletions A7#ImprovedShamanicDance/language/french/setup.tra
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@1 = ~Danse Chamanique amelioree~
@2 = ~Danse Chamanique etendue pour les personnages de haut niveau~
@3 = ~Ajouter le sort "Pacte chamanique"~
@4 = ~Apply Shamanic Dance improvements to Shaman kits~

@50 = ~Jeu en version Enhanced Edition requis.~
@51 = ~Pas de classe de Chaman disponible.~
Expand Down
1 change: 1 addition & 0 deletions A7#ImprovedShamanicDance/language/german/setup.tra
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@1 = ~Verbesserter Schamanentanz~
@2 = ~Schamanentanz f�r hochstufige Schamanen erweitern~
@3 = ~Neuer Zauber "Shamanischer Pakt"~
@4 = ~Verbesserten Schamanentanz auf alle Schamanenklassen anwenden~

@50 = ~Diese Komponente ben�tigt ein Enhanced Edition-Spiel.~
@51 = ~Die Schamanenklasse konnte nicht gefunden werden.~
Expand Down
1 change: 1 addition & 0 deletions A7#ImprovedShamanicDance/language/italian/setup.tra
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@1 = ~Danza Sciamanica Migliorata~
@2 = ~Potenzia la Danza Sciamanica per personaggi di alto livello~
@3 = ~Aggiungi l'incantesimo "Patto Sciamanico"~
@4 = ~Apply Shamanic Dance improvements to Shaman kits~

@50 = ~� richiesta la versione Enhanced Edition.~
@51 = ~La classe dello sciamano non � disponibile.~
Expand Down
1 change: 1 addition & 0 deletions A7#ImprovedShamanicDance/language/polish/setup.tra
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@1 = ~Ulepszony szamanski taniec~
@2 = ~Rozbudowany szamanski taniec dla wysokopoziomowych postaci~
@3 = ~Dodaj zaklecie "Szamanski pakt"~
@4 = ~Apply Shamanic Dance improvements to Shaman kits~

@50 = ~Modyfikacja ta wymaga wersji Enhanced Edition.~
@51 = ~Klasa szamana niedostepna.~
Expand Down
112 changes: 112 additions & 0 deletions A7#ImprovedShamanicDance/lib/consistent_dance.tph
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// *** Installs component "Apply Shamanic Dance improvements to Shaman kits" ***

// getting class id for Shaman
COPY_EXISTING ~clastext.2da~ ~override~
LPF FIND_2DA_VALUE
INT_VAR
column = 1
search_column = 0
STR_VAR
search_text = ~SHAMAN~
RET
row
value
END
BUT_ONLY

ACTION_IF (IS_AN_INT ~value~ && value > 0) BEGIN
OUTER_SET classID = value

// getting CLAB files from available Shaman kits
OUTER_SET kitlist = 0
COPY_EXISTING ~kitlist.2da~ ~override~
SET row = 0
WHILE (row >= 0) BEGIN
LPF FIND_2DA_VALUE
INT_VAR
start_row = row
column = 5
search_column = 8
STR_VAR
search_text = EVAL ~%classID%~
RET
row
value
END

PATCH_IF (row >= 0) BEGIN
PATCH_IF (FILE_EXISTS_IN_GAME ~%value%.2DA~) BEGIN
TEXT_SPRINT EVAL ~kitlist_%kitlist%~ ~%value%~
SET kitlist += 1
END
SET row += 1
END
END
BUT_ONLY

// updating Shaman Dance behavior
OUTER_FOR (idx = 0; idx < kitlist; ++idx) BEGIN
OUTER_TEXT_SPRINT table_resref EVAL ~%kitlist_%idx%%~
COPY_EXISTING ~%table_resref%.2DA~ ~override~
COUNT_2DA_COLS numCols
COUNT_2DA_ROWS numCols numRows
// scanning CLAB table for AP_ entries
FOR (row = 0; row < numRows; ++row) BEGIN
TEXT_SPRINT spl_resref ~~
READ_2DA_ENTRY row 1 numCols value
PATCH_IF (~%value%~ STRING_MATCHES_REGEXP ~AP_.*~ = 0) BEGIN
INNER_PATCH_SAVE resref ~%value%~ BEGIN REPLACE_TEXTUALLY ~AP_~ ~~ END
PATCH_IF (FILE_EXISTS_IN_GAME ~%resref%.SPL~) BEGIN
INNER_ACTION BEGIN
// scanning AP_ spell for "Change Bard Song" resref
COPY_EXISTING ~%resref%.SPL~ ~override~
READ_LONG 0x64 ofsAbils
READ_SHORT 0x68 numAbils
READ_LONG 0x6a ofsFx
READ_SHORT 0x6e firstFxGlobal
READ_SHORT 0x70 numFxGlobal

FOR (idxFx = 0; idxFx < numFxGlobal; ++idxFx) BEGIN
SET ofs = ofsFx + (firstFxGlobal + idxFx) * 0x30
READ_SHORT ofs opcode
PATCH_IF (opcode = 251) BEGIN // Change Bard Song
READ_ASCII (ofs + 0x14) spl_resref (8) NULL
SET idxFx = numFxGlobal
END
END

PATCH_IF (~%spl_resref%~ STR_EQ ~~) BEGIN
FOR (idxAbil = 0; idxAbil < numAbils; ++idxAbil) BEGIN
SET ofs = ofsAbils + idxAbil * 0x28
READ_SHORT (ofs + 0x1e) numFx
READ_SHORT (ofs + 0x20) firstFx
FOR (idxFx = 0; idxFx < numFx; ++idxFx) BEGIN
SET ofs2 = ofsFx + (firstFx + idxFx) * 0x30
READ_SHORT ofs2 opcode
PATCH_IF (opcode = 251) BEGIN // Change Bard Song
READ_ASCII (ofs2 + 0x14) spl_resref (8) NULL
SET idxFx = numFx
SET idxAbil = numAbils
END
END
END
END
BUT_ONLY
END
END

PATCH_IF (FILE_EXISTS_IN_GAME ~%spl_resref%.SPL~) BEGIN
INNER_ACTION BEGIN
// updating Shaman Dance behavior
COPY_EXISTING ~%spl_resref%.SPL~ ~override~
LPF DELETE_SPELL_EFFECT
INT_VAR opcode_to_delete = 363 // Movement rate check
END
BUT_ONLY
END
END
END
END
BUT_ONLY
END
END
42 changes: 42 additions & 0 deletions A7#ImprovedShamanicDance/lib/functions.tph
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,45 @@ BEGIN
END
END
END


/**
* Attempts to return a specific entry found in the same row as another entry matching a search string.
* INT_VAR start_row The row to start the search. 2DA header rows are automatically skipped. (Default: 0)
* INT_VAR column The column containing the content to return.
* INT_VAR search_column The column to search for "search_text".
* STR_VAR search_text The search text.
* RET row The row index where a match has been found, -1 otherwise. Does not include 2DA header rows.
* RET value The content found at the specified column if a match has been found, empty string otherwise.
*/
DEFINE_PATCH_FUNCTION FIND_2DA_VALUE
INT_VAR
start_row = 0
column = 1
search_column = 0
STR_VAR
search_text = ~~
RET
row
value
BEGIN
SET row = "-1"
TEXT_SPRINT value ~~

PATCH_IF (NOT ~%search_text%~ STR_EQ ~~ && column >= 0 && search_column >= 0) BEGIN
COUNT_2DA_COLS numCols
COUNT_2DA_ROWS numCols numRows
PATCH_IF (column < numCols && search_column < numCols) BEGIN
SET offset = (numCols > 2) ? 0 : 2
SET idx = start_row + offset
FOR (idx = idx; idx < numRows; ++idx) BEGIN
READ_2DA_ENTRY idx search_column numCols entry
PATCH_IF (~%entry%~ STR_EQ ~%search_text%~) BEGIN
READ_2DA_ENTRY idx column numCols value
SET row = idx - offset
SET idx = numRows
END
END
END
END
END
12 changes: 12 additions & 0 deletions A7#ImprovedShamanicDance/readme/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ Note: The spell will be added to the unkitted shaman class as well as any shaman
the time of installation.


4. Apply Shamanic Dance improvements to Shaman kits (requires main component)

This component can be used to modify the Shamanic Dance of available Shaman kits to behave as the
dance of the main class. It should be installed after all mods that are providing Shaman kits.

Note: Since Shamanic Dance can be expressed in multiple ways by kits it is not guaranteed that
this component will always be successful.

The following Shaman kits are confirmed to be compatible:
- Witchlight Shaman (Will of the Wisps, by Lava Del'Vortel)


Modified Shaman class description (after installing all components)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
7 changes: 7 additions & 0 deletions A7#ImprovedShamanicDance/setup-A7#ImprovedShamanicDance.tp2
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ BEGIN @3 // New spell "Shamanic Pact"
DESIGNATED 20

INCLUDE ~%MOD_FOLDER%/lib/spell.tph~


BEGIN @4 // Apply Shamanic Dance improvements to Shaman kits
REQUIRE_COMPONENT ~setup-A7#ImprovedShamanicDance.tp2~ 0 @52 // Main component required.
DESIGNATED 30

INCLUDE ~%MOD_FOLDER%/lib/consistent_dance.tph~

0 comments on commit 94db204

Please sign in to comment.