sockit2me66 Posted May 28, 2012 Share Posted May 28, 2012 I know how kind and receptive the community can be, so I'm hoping for some advice. I am currently seeking aid in creating a script for an object. The script in question would cause the object to cast an area of effect spell when dropped from the player's inventory.I am familiar with the new scripting language and conceptually understand what is going on. But I can't seem to get a working script for this particular effect. If anyone can help me write the script or point me in the right direction that would be wonderful. I will give kudos for any help :). Link to comment Share on other sites More sharing options...
ddmlink Posted May 28, 2012 Share Posted May 28, 2012 (edited) It should go something like this: ObjectReference Property ObjectName AutoSPELL Property SpellName Auto Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)if !akDestContainer ;Use an exclamation mark as something similar to "does not have." In this case, the object is not being placed in a container, but the open world. SpellName.Cast(ObjectName)else ReturnendifendEvent That will at least get it to compile, but I believe that should work. :thumbsup: Do remember to fill in the properties in the object you attach the script to; sometimes I forget.Also, I saw your pictures of the armors you are making (ironically, before I came to the forums here). Very nice. Good luck! If it helps, here's the wiki page where I got the event from: http://www.creationk...ObjectReference Edit for grammar correction. :tongue: Edited May 28, 2012 by ddmlink Link to comment Share on other sites More sharing options...
sockit2me66 Posted May 28, 2012 Author Share Posted May 28, 2012 Thank you! I tried something very similar and for whatever reason it did not work at all. It compiled fine but the spell did not cast.Your script seemed to also compile fine but nothing was cast. It seems that it could be due to the object not being an object exactly but a miscitem as far as the creation kit is concerned.Other than that, the script seems to register no effect when removed from the players inventory into the worldspace. But thank you for trying, I'm curious at this point as to why the script isn't working. Thanks for the help and the kind words about the armor conversions :).Here's a kudos! Link to comment Share on other sites More sharing options...
ddmlink Posted May 28, 2012 Share Posted May 28, 2012 Okay, I actually tested this one in-game for you. If you are planning on the Player to pick up the object from a room, then the DoOnce integer will prevent your object from firing the spell when the room it is in is first loaded. After that, it will fire every time it is loaded. Do check the wiki for details, as objects aren't loaded every time a cell is loaded. ( http://www.creationkit.com/OnLoad_-_ObjectReference ). For now, that is the best I can give you, but I can work on it a bit more you need me to. ScriptName Name extends ObjectReference ObjectReference Property ObjectName AutoSPELL Property SpellName Autoint Property DoOnce = 0 Auto Event OnLoad()if (DoOnce == 0) DoOnce = 1elseif (DoOnce == 1) SpellName.Cast(ObjectName) ;debug.Notification("Spell Cast")endif endEvent Link to comment Share on other sites More sharing options...
steve40 Posted May 29, 2012 Share Posted May 29, 2012 (edited) @ddmlink: OnItemRemoved won't work because it must be called on the container, not on the object. Using OnLoad is a strange way to do this. Try OnContainerChanged. @sickit2me66: try this: ScriptName MyScriptName extends ObjectReference {cast spell "MySpellName" when I am dropped} ;********************************************** Spell Property MySpellName Auto ;********************************************** Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akOldContainer && !akNewContainer ; Debug.Notification("We have been dropped!") MySpellName.Cast(Self) ; Self.Disable() ;uncomment this line if you want me to disappear after being dropped ElseIf akNewContainer && !akOldContainer ; Debug.Notification("We have been picked up!") Else ; Debug.Notification("We have switched containers!") EndIf EndEvent ;********************************************** If you want to limit the number of times that the item can be dropped/cast a spell, then you could do something like this: ScriptName MyScriptName extends ObjectReference {cast spell "MySpellName" when I am dropped. Item can be used "maxUses" times and then it will disappear.} ;********************************************** Spell Property MySpellName Auto int Uses = 0 int maxUses = 10 ; max number of times this item can cast the spell ;********************************************** Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akOldContainer && !akNewContainer && Uses < maxUses ; Debug.Notification("We have been dropped!") MySpellName.Cast(Self) Uses += 1 If Uses = maxUses Self.Disable() ; My spell charge is used up, disable me EndIf EndIf EndEvent ;********************************************** Cheers :cool: Edited May 29, 2012 by steve40 Link to comment Share on other sites More sharing options...
sockit2me66 Posted May 29, 2012 Author Share Posted May 29, 2012 Thank you both so much, with your script steve40, I was able to get the spell to cast perfectly when the item in question is dropped. I made a video to show that it worked like a charm.Here's a kudos for your help!Thank you both so much. Link to comment Share on other sites More sharing options...
Recommended Posts