Help for a novice modder
SirK8
Member Posts: 527
Hail and well met. I'm looking for a bit of help on some customization I'm doing to the game for a friend of mine. Basically I've created an innate shapeshifting ability for him so his barbarian can turn into a bear. I've figured out how to grant an innate ability on shift and how to remove it (so that shifting back and forth works properly).
What I can't figure out though is how to clear a memorized instance of an innate ability. What I want to do is give an ability only usable while he is in bear form. I can grant it as an innate ability when he shifts into a bear, but the problem is, even if I set it to be removed when he shifts back into natural form, the memorization is not removed. Meaning he can then use it in human form, and just as bad if he keeps shifting back and forth w/out using it up it stacks memorizations.
Does anyone know how I can force the memorization to be cleared on the shift back to natural form, or an alternative approach to granting the ability only while in bear form. I can post my files if anyone is interested. Thanks.
What I can't figure out though is how to clear a memorized instance of an innate ability. What I want to do is give an ability only usable while he is in bear form. I can grant it as an innate ability when he shifts into a bear, but the problem is, even if I set it to be removed when he shifts back into natural form, the memorization is not removed. Meaning he can then use it in human form, and just as bad if he keeps shifting back and forth w/out using it up it stacks memorizations.
Does anyone know how I can force the memorization to be cleared on the shift back to natural form, or an alternative approach to granting the ability only while in bear form. I can post my files if anyone is interested. Thanks.
Post edited by SirK8 on
0
Comments
If you upload the files it would help a lot since right now I am only guessing.
I couldn't find the opcode for remove innate ability, just remove spell, which I have added to the shapeshift to natural spell. It seems to work, it does remove the innate ability (meaning if I expend it in bear form, shift back and rest, I don't get it refreshed). However, it does not remove the memorization of the ability. So what happens is if the "roar" isn't used in bear form, then it remains usable in human form. Even though technically the innate ability was removed, the memorization of that ability is still available (checking in EEKeeper also confirms that the innate ability is removed, even if it is still "memorized" and available to cast). If you shift back into bear, it gives the ability back and stacks another memorization.
Edit: I'm using DLTCEP to do the edits btw.
1) add your custom innate spell to SPELL.IDS
2) use opcode 265 or opcode 309 to modify a global or local variable based on whether the innate ability should be available or not
3) check the variable from (2) in a script and eventually use RemoveSpell().
From IESDP (slightly edited by me for clarity):
Created with Weidu, it will remove 1 used-up instance of the given ability per use. This is fine if it needs to remove just 1 instance of itself, since it will remove the instance that was just used, without affecting any remaining uses of it. However, it doesn't work when removing other abilities, or when you need to remove all instances of the ability from someone.
This is what your's is doing, it will remove the Natural Form just fine, as long as you only have 1 instance of it, but it will remove 1 instance of the Roar ability only if you have a spent use of it. If you haven't used the Roar before reverting it will just keep stacking the memorization's, and never be able to fully remove it.
Created with Near Infinity, it will remove all instances of the given ability, regardless of whether they've been used or not. I just wish I knew why it does this.
Another option: You could just make the Roar an Item-slot Magical Ability for the bear claws. No extra ability to add or remove.
Opcode 172 should remove 1 instance of the referenced spell (i.e., if you want to remove 3 instances, you need to invoke it 3 times), including the memorised spell. That's how it's used in the vanilla back-to-human spells used in shapeshifting.
@SirK8
You may want to create a Avenger or something and see if you are having the same problems with e.g., the salamander shape and its fire-breathing innates. If you don't, have a look at spin127.spl and spin122.spl (or the spells used by whatever vanilla shapeshifting you test).
My proposed solution was based on what the IESDP site says about RemoveSpell() and RemoveSpellRES(): and about Opcode 172: but, as I said, I never actually tested it.
(And on further thought, I'm uncertain if opcode 172 only removes a single instance or really removes all instances.)
@Wisp - thanks for the tip on the Avenger, I've never played any of the druid classes (aside from Jaheira) so I didn't realize there was an existing example of what I want to do!
Next I started looking at the spell.ids (thanks @Erg for pointing me to this file), even though @Wisp mentioned it wasn't needed (which is true), I was frustrated that my simple edits didn't result in the same behavior, so I was going to try putting the spell in the spell.ids just in case, which led me to this link - http://www.pocketplane.net/tutorials/simscript.html (since I googled on how to add spells to the spell.ids). At the top of that page it talks about spell naming conventions, which to be honest I had no idea mattered so much. I updated my spells to use those conventions and now it is working.
I did all of my edits in NearInfinity based on @kjeron's post above, but I don't know if it was necessary in the end (I'll have to test the same thing in DLTCEP). Thank you again everyone for your help on this!
I still have some things I want to do with this mod that I'll likely need to ask for help on, but I'll open separate threads for those if needed.
I think I've figured out what determines what type of spell removal effect it applies to innate abilities. My previous statement was just a coincidence resulting from different naming conventions I use when creating items through Weidu or Near Infinity, they have nothing to do with the outcome.
Opcode 172 : Remove Spell:
Target spell filename 8 characters long = remove only spent instances of spell
Target spell filename <8 characters long = remove all, remaining or spent
Certainly an interesting way to decide the effect, but a shame too.
I can't imagine it's intentional (it's pretty damn silly), but IIRC I've read elsewhere that the length of the resref matters, so you are probably right that it is the exhibited behaviour.
I've finished the kit mod now, and it seems to be working ok so far, I have some kinks to work out and somethings I might do differently. With that info about the length of the spell name I will probably go back and rename those spells to avoid potential conflict with other mods.
@Wisp - is there a (relatively) easy way to use WeiDU to patch all my existing spells and update references? I can do it through DLTCEP manually, but if there's an automated way that would be nice.
Thanks again to everyone for helping me with this. This is an awesome community. I've attached the mod if anyone wants to take a peek and offer feedback.
With new names I was hoping there was some easier way than manually updating each spell, something like a search and replace - search for X in these files and replace it with Y. I've read through the WeiDU readme, but I'm not much of a programmer, and pretty inexperienced with the application so if it's in there I've missed it.
For a literal search and replace solution, you can use
COPY ~yourmod/some.spl~ ~override/new.spl~ REPLACE_TEXTUALLY old_ref new_ref (8)
This will place the fixed files in the override for as long as the mod is installed. If you wish to update the files in your mod folder, you can copy them from the override before you uninstall the mod. There are numerous other ways of doing it, but this is perhaps straightforward enough.
For a lighter touch you can walk the file structure and only replace the bits you want, but it doesn't sound like you need that.
I have this vanilla item that I want to give an ability when it's equipped, with all the mods that modify items around I can't just add an equipped effect to grant the ability so I went with an extension of baldur.bcs.
When the item is equipped it runs a block that casts a spell on the character equipping the item to grant him an innate ability through opcode 171. Until now all is working fine, character equips the weapon, he gets the innate (for testing purpose only 1 use, many uses in final form). Then the script has more blocks to remove to remove the ability but RemoveSpellRES does nothing.
So what is going on? What's the point of using RESREF if I have to add the spell to the spell.ids file as IESDP states? Or as @Wisp suggested that's not needed but then why is it not working? I can tell the block is running because it sets a var back to 0 (set to 1 when item is equipped).
Am I stuck with using another spell using opcode 172 while making my spell name less than 8 characters? EDIT : Not working with custom spell with opcode 172 either apparently... Also 171 only adds 1 charge to the ability no matter how many I set in the actual ability (which is not working anyway). Any good spell making tutorials around?
See this topic at G3: http://gibberlings3.net/forums/index.php?showtopic=3596
Gonna check how Refinements does this as suggested in the thread Astro linked.
Looks like I can't cound, opcode 172 works with max 7 characters spell name. Now I need to get that spell working~