subtledoctor Posted July 7, 2017 Posted July 7, 2017 I'm working on some stuff to define certain kits' usability restrictions based on setting some variables in a function. At the moment the code looks like this: LAM ~COPY_EXISTING ~kitlist.2da~ ~override~ COUNT_2DA_COLS num_cols READ_2DA_ENTRIES_NOW ~r2en_kitlist~ 9 FOR (row = 3; row < r2en_kitlist; row += 1) BEGIN READ_2DA_ENTRY_FORMER ~r2en_kitlist~ row 0 kit_index READ_2DA_ENTRY_FORMER ~r2en_kitlist~ row 1 kit_label READ_2DA_ENTRY_FORMER ~r2en_kitlist~ row 5 kit_clab READ_2DA_ENTRY_FORMER ~r2en_kitlist~ row 9 kit_code PHP_EACH d5_fnp_usable AS usable => val BEGIN PATCH_IF (VARIABLE_IS_SET $d5_fnp_kit_usable_access(~%usable%~ ~%kit_clab%~)) BEGIN INNER_ACTION BEGIN COPY ~faiths_and_powers/kits/misc/d5fnpuse.spl~ ~override/d5_u%kit_index%.spl~ END SPRINT access $d5_fnp_kit_usable_access(~%usable%~ ~%kit_clab%~) PATCH_IF (IS_AN_INT access && access == 1) BEGIN PATCH_IF (~%usable%~ STRING_EQUAL_CASE ~LEATHER_ARMOR~) BEGIN INNER_ACTION BEGIN COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ READ_SHORT 0x1c item_type PATCH_IF (%item_type% = 2) BEGIN READ_LONG 0x22 appearance PATCH_IF (appearance = 16690) BEGIN // leather appearance SPRINT $leather_armors(~%SOURCE_RES%~) ~leather~ END END BUT_ONLY COPY_EXISTING ~d5_u%kit_index%.spl~ ~override~ PHP_EACH leather_armors AS item => blah BEGIN PATCH_PRINT ~%SOURCE_RES%: %item% = verboten~ LPF ADD_SPELL_EFFECT INT_VAR opcode = 180 target = 1 parameter1 = (0 - 1) parameter2 = 0 timing = 9 STR_VAR resource = EVAL ~%item%~ END END BUT_ONLY END // end inner action END // end leather armor END // end access is_an_int END // end usable variable set END // end php_each END // end for BUT_ONLY The idea is to identify all leather armors, and add them to opcode 180 effects in a spell which will will be applied during character creation. The end result should be a dynamic system to custom-tailor kit usability; for example, the Divine Remix Feywarden of Corellon kit has the usual cleric restrictions, blunt weapons only. But by setting a few variables, when our new mod is installed after DR, the Feywarden will be able to equip and use longswords and longbows. It will be great... if we can make it work. The PATCH_PRINT line in the above code works perfectly; I see stuff like this: But the spells are not being patched... no 180 effects are added. It seems to me that the variables are correctly set, if the PATCH_PRINT works... so why doesn't the ADD_SPELL_EFFECT work? Can anyone tell from looking at it? Thx as always
kjeron Posted July 7, 2017 Posted July 7, 2017 Did you forget to add ability header(s) to ~d5_u%kit_index%.spl~? ADD_SPELL_EFFECT doesn't return any warnings or errors when there are no headers to add effects.
subtledoctor Posted July 7, 2017 Author Posted July 7, 2017 The base spell (d5fnpuse.spl) has one header with one effect: a 1-second 1-point bonus to Lore. The above code gives no errors, and generates uniquely-named copies of the base spell, but each copy only has that one effect. Wait... maybe the cloning of the base spell is inside a loop and is overwriting the patched clones... EDIT - yup, that was it. Need to move the first INNER_ACTION block to before the PHP_EACH loop. That means it clones a few extra copies of the spell, but it's not the end of the world. So we're in business! Now just need to get down to the nitty-gritty specifics. The current dilemma trilemma being, opcode 180 vs. opcode 181 vs. opcode 319. EDIT2 - vs. using kit flags. Quadrulemma. EDIT3 - Ooh! Ooh! Maybe we can combine kit flags with opcode 181 effects! EDIT4 - Except, weapon restrictions due to opcode 181 probably won't be picked up by the EE engine and displayed in the item descriptions... EDIT5 - last thing and then I'll leave: this is super cool. You know how people sometimes want to give a kit access to extra weapons - let clerics of Helm use bastard swords, or clerics of Clangeddin use axes? And the answer has always been, "usability can only be restricted, not expanded, so that's not possible?" Well, that answer may no longer be true...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.