hidconsp Posted January 27, 2013 Share Posted January 27, 2013 (edited) I have been trying to make a script that works when1.Player is equipping certain item2.Player uses a spell So what I came up with is. Scriptname castSpell extends ObjectReference Event OnSpellCast(Form akSpell) debug.MessageBox("Player used a spell") endEvent But I have a hard time where to attach this script. From what I have read in tutorials, it looks like I have to make a blank quest, add player as quest alias, then attach the script on the "Reference Alias" tab. This works, but not when I attach this script to the item... And I think it would be best to keep things neat, without using quest. Plus I want npcs to use the item, but I cannot add all npcs to quest aliases... Can anyone help me please? Edited January 27, 2013 by hidconsp Link to comment Share on other sites More sharing options...
Korodic Posted January 27, 2013 Share Posted January 27, 2013 You are trying to technically catch two events. When something is equipped and when something is cast. To do that you'd want to do this... Scriptname castSpell extends ObjectReference Event OnSpellCast(Form akSpell) debug.MessageBox("Player used a spell") endEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) if akBaseObject as Weapon Debug.MessageBox("This actor just equipped a weapon!") endIf endEvent yes a blank quest to run this is how you'd do it. ... actually im confused. Is this script mean to be on the item or player? Link to comment Share on other sites More sharing options...
hidconsp Posted January 27, 2013 Author Share Posted January 27, 2013 Thanks a lot Korodic, I really need a person to confirm that I was doing the right way. But what I want to do is not checking whether the player equipped a weapon... It is like this: A magical amulet that gives you 10 magicka when casting a spell Well, but if there is no way to attach only 1 script to the item, I am satisfied, and ready to do tedious works... Link to comment Share on other sites More sharing options...
hidconsp Posted January 27, 2013 Author Share Posted January 27, 2013 You are trying to technically catch two events. When something is equipped and when something is cast. To do that you'd want to do this... Scriptname castSpell extends ObjectReference Event OnSpellCast(Form akSpell) debug.MessageBox("Player used a spell") endEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) if akBaseObject as Weapon Debug.MessageBox("This actor just equipped a weapon!") endIf endEvent yes a blank quest to run this is how you'd do it. ... actually im confused. Is this script mean to be on the item or player? That's what I am confused, too. I have made a script to be attached to the player, but how can I modify it to be attached to the item? Link to comment Share on other sites More sharing options...
hidconsp Posted January 27, 2013 Author Share Posted January 27, 2013 Well, now I don't think I want to attach the script to the item anymore... but I've got another problem. This, Scriptname castSpell extends ReferenceAlias actor property player auto armor property amulet auto Event OnSpellCast(Form akSpell) If (player.getAV("Magicka") < 50) && (player.getequipped amulet == 1) player.restoreAV("Magicka", 30) endIf endEvent failes to be compiled. There seems to be a problem with "player.getequipped amulet == 1" This is frustrating.... Link to comment Share on other sites More sharing options...
hidconsp Posted January 27, 2013 Author Share Posted January 27, 2013 Never mind bool Function IsEquipped(Form akItem) Link to comment Share on other sites More sharing options...
Korodic Posted January 27, 2013 Share Posted January 27, 2013 yep yep. Usually if you hit a wall, it's a misuse, or lack there of, of a certain function or even from the Skyrim Scripting Bible: http://www.creationkit.com/Category:Papyrus :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts