bisquits Posted July 5, 2012 Share Posted July 5, 2012 I am trying to find an example object script which will cast or cause the player to cast a spell when the object is added to the player or equipped on the player. I have a mod I am trying to modify to cast a spell at a certain thresh hold. I have managed to get it to add various items to the player as tokens. I have tried adding clothing items and equipping them. The spell works fine when I manually add it to the player and cast it so I know the spell works. But I can not get the player to cast the spell with an activator or even with a ring added and equipped, That is the latest thing I have tried. This sounds so simple but I just cannot get it to work. **scn Equipedringscript** short isEquipped begin onEquip player set isEquipped to 1 player.addspell 02014faa player.Cast 02014faa player End Link to comment Share on other sites More sharing options...
DrakeTheDragon Posted July 5, 2012 Share Posted July 5, 2012 Hmm, I for one would never use these numbers instead of an actual spell ID. The first two digits "02" are depending on the plugin or masterfile's position in load order and will no longer be valid when this changes. The value they have while in the CS is often totally wrong and bogus to begin with, as it is then determined by the list of plugins/masterfiles you gave the CS to load at once, which of course is totally different to your actual load order, or anybody else's for that matter. "player.cast MyFancyRangeSelfSpell player" should actually work fine, according to the WiKi, even without adding it to the player's spell list previously. Keep in mind though, when OnEquip triggers you will likely be in the inventory or something, and I doubt the spell casting will work during this time. I would try something along that line: scn EquippedRingScript short isEquipped begin OnEquip player set isEquipped to 1 end begin GameMode if isEquipped == 1 set isEquipped to 0 player.cast MyFancyRangeSelfSpell player endif end and see if that works out. If it doesn't, you could work around it with an invisible activator as your caster, "persistent reference" id ("MyCaster"), which warps to the player ("MyCaster.moveto player"), positions at his place ("set playerposX to player.getPos X; MyCaster.setPos X playerposX" etc.) and casts a ranged spell onto him ("MyCaster.cast MyFancyRangedSpell player"). Link to comment Share on other sites More sharing options...
bisquits Posted July 7, 2012 Author Share Posted July 7, 2012 Thanks Drake I got it working just had to use an object script instead of a spell to move an activator to my character and it casts the spell just fine thanks. Link to comment Share on other sites More sharing options...
Recommended Posts