gamemaster76 Posted May 14, 2020 Share Posted May 14, 2020 I'm working on my first mod, a rebalancing of the Shapeshifter druid kit, and I want to incorporate a HLA that allows spellcasting in werewolf form... and I dont think theres an opcode to do what I want. What I want the HLA to do is go into the item files were the Polymorph (135) opcode is (cdbrbrp.itm/cdbrbrp2.itm/cdbrbrp3.itm* (new one ive added)) and change it to appearance only. The rest I've already done on my local copy of the mod. Otherwise I thought about having it appearance only from the get go and have Disable Button (144) to stop spellcasting, in that case I would need a way for the HLA to put Enable Button (279) on all 3 files. Non of the existing HLA seem like they do anything close to this. Is there an opcode to do this that I'm just not seeing? If not is there a way to make new opcode or modify an existing one? Quote Link to comment
subtledoctor Posted May 14, 2020 Share Posted May 14, 2020 (edited) I don't know how the existing shapeshift spell works. But something along these lines. 1) Add a new "cast while shapeshifted" spellstate. 2) Find out how the "disable spellcasting" is done. Two possible branches for this step: -- If it is in a spell, then make a new spell that only disables spellcasting. Replace the effect in the original spell with an opcode 326 effect, which conditionally casts the new spell only if the caster does not have the "cast while shapeshifted" spellstate. -- If it is an equipping effect on an item, then make a new item that is an exact clone of the original, but remove the disable casting effect. In the Shapeshift spell, replace the effect that creates the original item with two opcode 326 effects: one that creates the original item if you don't have the "cast while shapeshifted" spellstate, and one that creates your clone if you do have that spellstate. EDIT - I see it is an item. 3) Make your HLA, it only has to do one thing: use opcode 328 to permanently add the "cast while shapeshifted" spellstate. According to the DNA evidence, Robert is your parent's sibling. There's probably more than one way to skin this cat, but that's how I've been planning to do it, anyway. I figure on adding a casting speed penalty or something like that, just so there's a reason not to stay in Werewolf form for every second of every day. Or maybe limit the duration of the shapeshifts. Haven't decided on the specifics. I have code that can be adapted for most of that, will link to it when I have a bit of time. Edited May 14, 2020 by subtledoctor Quote Link to comment
subtledoctor Posted May 14, 2020 Share Posted May 14, 2020 (edited) Function to add spellstate: (paste it in the mod without changes) DEFINE_ACTION_FUNCTION resolve_state INT_VAR index=0 delete=0 STR_VAR new_state_id = ~blah~ RET new_state_ind BEGIN OUTER_SET min_new=118 COPY_EXISTING ~splstate.ids~ override new_state_ind=0 found=0 READ_2DA_ENTRIES_NOW stats 2 FOR (row=0;row<stats;row+=1) BEGIN READ_2DA_ENTRY_FORMER stats row 0 ind READ_2DA_ENTRY_FORMER stats row 1 str SET $stat("%row%") = ind PATCH_IF index BEGIN PATCH_IF ind=index BEGIN REMOVE_2DA_ROW row 2 found=1 PATCH_IF delete=0 BEGIN INSERT_2DA_ROW row 2 ~%index% %new_state_id%~ END row=stats END END ELSE BEGIN PATCH_IF ~%str%~ STRING_EQUAL_CASE ~%new_state_id%~ BEGIN new_state_ind=ind found=1 /* row=stats */ // don't stop looking, the same ID may be assigned to a greater index, which takes priority when compiling END END END PATCH_IF found=0 BEGIN new_state_ind=min_new PHP_EACH stat AS row => ind BEGIN PATCH_IF found=0 && (row+1 < stats) BEGIN // not at the end of file next_row = row+1 next_ind = EVAL $stat("%next_row%") PATCH_IF index BEGIN PATCH_IF index<next_ind && index>ind BEGIN INSERT_2DA_ROW next_row 2 ~%index% %new_state_id%~ found=1 END END ELSE BEGIN PATCH_IF new_state_ind<next_ind BEGIN PATCH_IF ind<new_state_ind BEGIN INSERT_2DA_ROW next_row 2 ~%new_state_ind% %new_state_id%~ found=1 END ELSE BEGIN new_state_ind+=1 PATCH_IF new_state_ind<next_ind BEGIN INSERT_2DA_ROW next_row 2 ~%new_state_ind% %new_state_id%~ found=1 END END END END END ELSE BEGIN // at the end of file PATCH_IF found=0 BEGIN PATCH_IF index BEGIN INSERT_2DA_ROW stats 2 ~%index% %new_state_id%~ END ELSE BEGIN PATCH_IF new_state_ind>ind BEGIN INSERT_2DA_ROW stats 2 ~%new_state_ind% %new_state_id%~ END ELSE BEGIN new_state_ind+=1 INSERT_2DA_ROW stats 2 ~%new_state_ind% %new_state_id%~ END END END END END END END Apply that function in your code: LAF resolve_state STR_VAR new_state_id = ~CAST_SHIFTED~ RET new_state_ind END OUTER_SET cast_shifted_state = %new_state_ind% Apply that state with the HLA: COPY ~your_mod/hlas/new_hla.spl~ ~override~ LPF ADD_SPELL_EFFECT INT_VAR opcode = 328 target = 1 special = 1 parameter2 = %cast_shifted_state% timing = 9 END I'll leave duplicating and modifying the CDBRBRP items to you. In opcode 326, I believe you would use parameter2 = 110 and 111 for "has spellstate" and "not spellstate," respectively. Other than that, I advise you to use your own modding prefix (the first two letter of every file you add to the game. If you add files starting with "CD," well that's Candawg's prefix, and he might add a file with the same name, and then something won't work. Note: this is EE-only stuff. It will crash the original engine. Edited May 14, 2020 by subtledoctor Quote Link to comment
gamemaster76 Posted May 15, 2020 Author Share Posted May 15, 2020 Thank you so much! Although im not quite sure how to use opcode 328 or 326. (I'm manually editing in nearinfinity first to test, then ill write the code) 19 hours ago, subtledoctor said: Apply that function in your code: LAF resolve_state STR_VAR new_state_id = ~CAST_SHIFTED~ RET new_state_ind END OUTER_SET cast_shifted_state = %new_state_ind% So I put this in the section of the code for the transformation files? 21 hours ago, subtledoctor said: In the Shapeshift spell, replace the effect that creates the original item with two opcode 326 effects: one that creates the original item if you don't have the "cast while shapeshifted" spellstate, and one that creates your clone if you do have that spellstate. Unfortunately, opcode 326 doesnt let me choose ITM files, only SPL files. 19 hours ago, subtledoctor said: I'll leave duplicating and modifying the CDBRBRP items to you. In opcode 326, I believe you would use parameter2 = 110 and 111 for "has spellstate" and "not spellstate," respectively. Both parameter 110 ad 111 ask for a "creature type" does it matter what I put here? Quote Link to comment
subtledoctor Posted May 15, 2020 Share Posted May 15, 2020 1 hour ago, gamemaster76 said: Thank you so much! Although im not quite sure how to use opcode 328 or 326. (I'm manually editing in nearinfinity first to test, then ill write the code) This is a case in which you cannot simply set up the files in NI, and learn the Weidu code later. There are a number of spellstates in the game (in SPLSTATE.IDS), and the resolve_state code above (which, by the way, is not mine... I think it might have come from Ardanis) dynamically adds a new one in the next available slot, whatever number that slot might be. Then you need to set that slot's index number into a variable in order to plug it into the 326 effects. This is fairly advanced stuff; the game engine is not really st up to do what you are proposing (choose an HLA, have it alter the way a preexisting ability works). It's a nice idea, but pretty complex for a 1st attempt at modding. Hmm, hang on, see below. 1 hour ago, gamemaster76 said: So I put this in the section of the code for the transformation files? In your Weidu code, first you define the function then you use the function to create the spellstate and get the index number (the LAF resolve_state and OUTER_SET lines) then you copy in your various spell and item files as you copy in the HLA spell file, you add a 328 effect ("apply spellstate") with the applied spellstate set to be the variable set in the OUTER_SET line (alternatively, you can create the HLA spell with a preexisting 328 effect, with the spellstate set to a dummy setting, and then use ALTER_EFFECT as you copy it in, to change the applied spellstate to the one your code just generated (and is now in the variable from the OUTER_SET line) you can modify the actual shapeshift spell to use opcode 326 (see below), and as you copy it in, you use ALTER_EFFECT to change parameter1 to the new spellstate your code just generated 1 hour ago, gamemaster76 said: Unfortunately, opcode 326 doesnt let me choose ITM files, only SPL files. Yup. You need three spells. Best to make two copies of the actual shapeshift spell, and then change each one as needed: Remove all effects from the actual shapeshift spell, and instead give it two 326 effects. They will have your new spellstate in parameter1, and either 110 or 111 in parameter2 - 111 in the effect that triggers clone #1 in the resource field, and 110 in the effect that triggers clone #2 in the resource field. For clone #1 of the shapeshift spell, do not change anything. The base shapeshift spell will cast this if you do not have the HLA spellstate; in-game, it will act exactly like the unmodified shapeshift. For clone #2 of the shapeshift spell, make a single change: instead of creating the usual shapeshift item, it will create a modified item that does not block casting. The base shapeshift spell will cast this if you have chosen your new HLA. 1 hour ago, gamemaster76 said: Both parameter 110 ad 111 ask for a "creature type" does it matter what I put here? Yes - the new spellstate. Quote Link to comment
kjeron Posted May 15, 2020 Share Posted May 15, 2020 On 5/14/2020 at 9:49 AM, subtledoctor said: 2) Find out how the "disable spellcasting" is done. Two possible branches for this step: -- If it is in a spell, then make a new spell that only disables spellcasting. Replace the effect in the original spell with an opcode 326 effect, which conditionally casts the new spell only if the caster does not have the "cast while shapeshifted" spellstate. -- If it is an equipping effect on an item, then make a new item that is an exact clone of the original, but remove the disable casting effect. In the Shapeshift spell, replace the effect that creates the original item with two opcode 326 effects: one that creates the original item if you don't have the "cast while shapeshifted" spellstate, and one that creates your clone if you do have that spellstate. EDIT - I see it is an item. The polymorph opcode itself disables spellcasting in addition to any redundant op145 effects present on the item. It also disables the Select-Spell and Quick-Spell buttons. Blocking/Removing op144/145 won't have any effect. The only spells you can cast with a true polymorph are innates located in the Special Abilities menu, and Wizard/Priest spells located in the Special Abilities menu that use Ability Target 7. To retain spellcasting you would have to use a fake polymorph (animation only). You could then switch the disabling effects for op177, targeting EFF files of those disabling effects with a shared custom parent resource, and have the HLA provide immunity to those parent resources (op318). Quote Link to comment
subtledoctor Posted May 15, 2020 Share Posted May 15, 2020 Ah. Then you'll need to modify the CDBRBRP items as well, removing the polymorph effect and instead using an animation change and a few other effects (set stats, set base AC, etc.) That will make it a bit more fiddly - though it's still possible, and in fact a bunch of my kits' "polymorph" abilities actually work that way. In particular, you should investigate what can be done about armor in this case. (I don't remember what the best way to handle it is... maybe @Luke might have a good sense of how to do it?) Quote Link to comment
gamemaster76 Posted May 15, 2020 Author Share Posted May 15, 2020 (edited) ouf... I'm starting to think it might be more trouble then its worth.... I appreciate all your help but this really is going over my head. I think I'll shelve the HLA until I have more experience. At this point I feel like im asking you to make it for me XD Edited May 15, 2020 by gamemaster76 Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.