Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
0.9.46
Browse files Browse the repository at this point in the history
semi_spont v10.5
  • Loading branch information
subtledoctor committed Feb 6, 2023
1 parent 8f459b1 commit 9b47cdf
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TomeAndBlood/TomeAndBlood.tp2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BACKUP ~weidu_external/backup/TomeAndBlood~
AUTHOR ~aquadrizzt~
VERSION ~0.9.45~
VERSION ~0.9.46~

ALWAYS

Expand Down
74 changes: 74 additions & 0 deletions TomeAndBlood/lib/semi_spont/misc_functions.tpa
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,80 @@ END
////////////////////////////////////////////////////////////////////////


// Automatically fixes missing column entries in 2da files. Can be used as both patch and action function

DEFINE_ACTION_FUNCTION 2DA_MISSING_COLS
INT_VAR
cols = 0 //minimum amount of columns that should have values (if not set function will automatically read max number of columns in file)
STR_VAR
2da = ~~ //2da file that should be patched, e.g. kitlist
entry = ~~ //what entry should be set in missing columns (if not set function will automatically read default entry from loaded 2da, e.g. *)
BEGIN
ACTION_IF ~%2da%~ STR_EQ ~~ BEGIN
FAIL ~2DA_MISSING_COLS: %2da% STR_VAR not set~
END
COPY_EXISTING ~%2da%.2da~ ~override~
PRETTY_PRINT_2DA
PATCH_IF ~%entry%~ STR_EQ ~~ BEGIN
READ_2DA_ENTRY 1 0 1 "entry"
END
PATCH_IF cols = 0 BEGIN
COUNT_2DA_COLS "cols"
END
SET cnt = 0
REPLACE_EVALUATE ~^\(.+\)$~ BEGIN
PATCH_IF cnt >= 3 BEGIN
INNER_PATCH_SAVE MATCH1 ~%MATCH1%~ BEGIN
COUNT_REGEXP_INSTANCES ~ +~ num_matches
WHILE (num_matches < (cols - 1)) BEGIN
REPLACE_TEXTUALLY ~$~ ~ %entry%~
SET num_matches = num_matches + 1
END
END
END ELSE BEGIN
SET cnt = cnt + 1
END
END ~%MATCH1%~
PRETTY_PRINT_2DA
BUT_ONLY
END

DEFINE_PATCH_FUNCTION 2DA_MISSING_COLS
INT_VAR
cols = 0 //minimum amount of columns that should have values (if not set function will automatically read max number of columns in file)
STR_VAR
entry = ~~ //what entry should be used in missing columns (if not set function will automatically read default entry from loaded 2da, e.g. *)
BEGIN
PRETTY_PRINT_2DA
PATCH_IF ~%entry%~ STR_EQ ~~ BEGIN
READ_2DA_ENTRY 1 0 1 "entry"
END
PATCH_IF cols = 0 BEGIN
COUNT_2DA_COLS "cols"
END
SET cnt = 0
REPLACE_EVALUATE ~^\(.+\)$~ BEGIN
PATCH_IF cnt >= 3 BEGIN
INNER_PATCH_SAVE MATCH1 ~%MATCH1%~ BEGIN
COUNT_REGEXP_INSTANCES ~ +~ num_matches
WHILE (num_matches < (cols - 1)) BEGIN
REPLACE_TEXTUALLY ~$~ ~ %entry%~
SET num_matches = num_matches + 1
END
END
END ELSE BEGIN
SET cnt = cnt + 1
END
END ~%MATCH1%~
PRETTY_PRINT_2DA
END


////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////


/* do this in the code...??
OUTER_INNER_PATCH ~1~ BEGIN
WRITE_BYTE 0 0x09
Expand Down
94 changes: 93 additions & 1 deletion TomeAndBlood/lib/semi_spontaneous.tpa
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// v10.4 - fixed semi_innate
// v10.5 - fixed semi_innate

/*
functions in this file:
Expand Down Expand Up @@ -1850,6 +1850,52 @@ ACTION_IF (FILE_EXISTS_IN_GAME ~d5zclons.2da~) BEGIN
END

END // end FnP

COPY_EXISTING ~kitlist.2da~ ~override~
READ_2DA_ENTRIES_NOW ~r2en_kitlist~ 10
FOR (row = 2; row < r2en_kitlist; row += 1) BEGIN
READ_2DA_ENTRY_FORMER ~r2en_kitlist~ row 5 kit_clab
SPRINT $clabs_to_check(~%kit_clab%~)~1~
END
BUT_ONLY

ACTION_PHP_EACH clabs_to_check AS clab => ind BEGIN
ACTION_IF (FILE_EXISTS_IN_GAME ~%clab%.2da~) BEGIN
COPY_EXISTING ~%clab%.2da~ ~override~
LPF 2DA_MISSING_COLS STR_VAR entry = ~****~ END
BUT_ONLY
COPY_EXISTING ~%clab%.2da~ ~override~
COUNT_2DA_COLS cols
READ_2DA_ENTRIES_NOW r2en_clab cols
FOR (col = 1; col < cols; ++col) BEGIN
FOR (row = 0; row < r2en_clab; ++row) BEGIN
READ_2DA_ENTRY_FORMER r2en_clab row col kit_abil
PATCH_IF (~%kit_abil%~ STRING_CONTAINS_REGEXP ~GA_~) = 0 BEGIN
SPRINT $ga_abils(~%kit_abil%~)~1~
END
END
END
BUT_ONLY
END
END

ACTION_PHP_EACH ga_abils AS abil => ind BEGIN
OUTER_INNER_PATCH_SAVE abil ~%abil%~ BEGIN
REPLACE_TEXTUALLY ~GA_~ ~~
END
ACTION_IF (FILE_EXISTS_IN_GAME ~%abil%.spl~) BEGIN
COPY_EXISTING ~%abil%.spl~ ~override~
READ_BYTE 0x1c spl_type
PATCH_IF (spl_type = 2) BEGIN // if a priest spell
INNER_ACTION BEGIN
OUTER_SET high_ind = high_ind + 1
OUTER_SET spl_ind = high_ind
APPEND ~d5zclons.2da~ ~%spl_ind% %abil% %abil% divine no ~ UNLESS ~%abil%~
END
END
BUT_ONLY
END
END

COPY ~%MOD_FOLDER%/lib/semi_spont/d5_marker.d5~ ~override/d5__5E_casting_divine.d5~

Expand Down Expand Up @@ -2060,6 +2106,52 @@ ACTION_IF (FILE_EXISTS_IN_GAME ~d5zclons.2da~) BEGIN
END
END

COPY_EXISTING ~kitlist.2da~ ~override~
READ_2DA_ENTRIES_NOW ~r2en_kitlist~ 10
FOR (row = 2; row < r2en_kitlist; row += 1) BEGIN
READ_2DA_ENTRY_FORMER ~r2en_kitlist~ row 5 kit_clab
SPRINT $clabs_to_check(~%kit_clab%~)~1~
END
BUT_ONLY

ACTION_PHP_EACH clabs_to_check AS clab => ind BEGIN
ACTION_IF (FILE_EXISTS_IN_GAME ~%clab%.2da~) BEGIN
COPY_EXISTING ~%clab%.2da~ ~override~
LPF 2DA_MISSING_COLS STR_VAR entry = ~****~ END
BUT_ONLY
COPY_EXISTING ~%clab%.2da~ ~override~
COUNT_2DA_COLS cols
READ_2DA_ENTRIES_NOW r2en_clab cols
FOR (col = 1; col < cols; ++col) BEGIN
FOR (row = 0; row < r2en_clab; ++row) BEGIN
READ_2DA_ENTRY_FORMER r2en_clab row col kit_abil
PATCH_IF (~%kit_abil%~ STRING_CONTAINS_REGEXP ~GA_~) = 0 BEGIN
SPRINT $ga_abils(~%kit_abil%~)~1~
END
END
END
BUT_ONLY
END
END

ACTION_PHP_EACH ga_abils AS abil => ind BEGIN
OUTER_INNER_PATCH_SAVE abil ~%abil%~ BEGIN
REPLACE_TEXTUALLY ~GA_~ ~~
END
ACTION_IF (FILE_EXISTS_IN_GAME ~%abil%.spl~) BEGIN
COPY_EXISTING ~%abil%.spl~ ~override~
READ_BYTE 0x1c spl_type
PATCH_IF (spl_type = 1) BEGIN // if a wizard spell
INNER_ACTION BEGIN
OUTER_SET high_ind = high_ind + 1
OUTER_SET spl_ind = high_ind
APPEND ~d5zclons.2da~ ~%spl_ind% %abil% %abil% divine no ~ UNLESS ~%abil%~
END
END
BUT_ONLY
END
END

LAF semi_armor_casting END

COPY ~%MOD_FOLDER%/lib/semi_spont/d5_marker.d5~ ~override/d5__5E_casting_arcane.d5~
Expand Down

0 comments on commit 9b47cdf

Please sign in to comment.