Mornedil Posted July 12, 2016 Share Posted July 12, 2016 (edited) I have a custom staff which is supposed to randomly cast an ice, fire or electric spell.the effects of the staff are randomly applied to the enemy. Sometimes they burn, sometimes they freeze, and sometimes they get electrocuted.The problem is that the staff shows the lightning bolt FX every time, no matter what magic effect it actually fires.Is there a way to dynamically change the graphical effect when the spell is cast? Edited July 12, 2016 by Mornedil Link to comment Share on other sites More sharing options...
Mornedil Posted July 12, 2016 Author Share Posted July 12, 2016 (edited) I figured out one way of doing it - by randomly changing between multiple different enchantments rather than using a single enchantment with multiple magic effects.(using the SetEnchantment function) Here's a basic test I made to just change the enchantment when the weapon is equipped:Scriptname MM01_RandomWeaponEnchantment extends ObjectReference Enchantment[] Property enchList Auto ;an array containing 3 different enchantments Weapon Property thisWeapon Auto ;reference to this weapon base object Event OnEquipped(Actor akActor) thisWeapon.SetEnchantment(enchList[Utility.RandomInt(0, 2)]) ;ignore the hard-coded array size when choosing, it's just for testing endEvent A problem with this however is that it will change the enchantment on ALL of the weapons of the same type. I read the following on the wiki: When an object is equipped it is inside a container, which means that you cannot call native functions on it. (Unless it is a persistent reference) what exactly does that mean? That I can't apply code directly to the player's currently equipped item without applying code to all items of that type? Edited July 12, 2016 by Mornedil Link to comment Share on other sites More sharing options...
Mornedil Posted July 12, 2016 Author Share Posted July 12, 2016 (edited) Edit: sorry, accidental double post Edited July 12, 2016 by Mornedil Link to comment Share on other sites More sharing options...
Hoamaii Posted July 16, 2016 Share Posted July 16, 2016 I've often wondered about that wiki statement too. My understanding is that when an objectReference is in a container (or is equipped, since equipped objects are in a container too) you can't call function on that specific objectReference - only on the BaseObject itself. Which is what your script does, calling SetEnchantment to a Form. So yes, it means that whatever function you call will thus affect all ObjectReferences of the same form - SetEnchantment(...) can only be called on forms anyway. Why is that an issue for what you intend to do? You've created a custom weapon for this, right? Link to comment Share on other sites More sharing options...
Recommended Posts