Xander9009 Posted October 31, 2013 Share Posted October 31, 2013 This is a bit old, but I see the OP doesn't seem to have gotten it uploaded. If it's because you didn't manage to get the chain spell working, perhaps you could try giving the spell a perk boost. Use a new perk which is added and removed by the quest script when you do/don't have enough items. To do that, make the effect obscenely expensive so the player can never cast it using magicka and give it a unique keyword. Then, make a new perk. Check the Hidden box, then at the bottom in Perk Entries, add a new entry. Switch to "Entry Point", change "Activate" to "Mod Spell Cost", then change "Absolute Value" to "Multiply Value". In the bottom left pane, switch to the Spell tab, add a new entry there. Change "GetIsID" to "EPMagic_SpellHasKeyword", change "INVALID" to the unique keyword you used, and then click "Ok" until all the dialogues are closed. Finally, in the quest you made earlier, add a new script to the end which looks something like this. Scriptname SoulTrap_Script extends Quest SoulGem Property SoulGemPetty Auto Perk Property PerkName Auto Event OnInit() RegisterForSingleUpdate(5.0) EndEvent Event OnUpdate() RegisterForSingleUpdate(5.0) If ( Game.GetPlayer().GetItemCount(SoulGemPetty) >= 1 ) Game.GetPlayer().AddPerk(PerkName) Else Game.GetPlayer().RemovePerk(PerkName) EndIf EndEvent Also, make sure the quest isn't set to only run once and that it starts enabled. I don't know for sure if the only running once will matter, but it won't hurt, either. Link to comment Share on other sites More sharing options...
Clyybber Posted February 26, 2017 Share Posted February 26, 2017 I've been able to do this by creating two spells. SPELL2 is the eventual effect that I want cast, and I give it a 0 mana cost. The SPELL1 contains only a single MagicEffect, which is a script: MiscObject property ITEMCOST auto ;THIS IS THE ITEM THAT GETS REMOVEDSpell property SPELL2 auto ;THIS IS THE SPELL THAT I ACTUALLY WANT CAST Event OnEffectStart(Actor myTarget, Actor myCaster) If(Game.GetPlayer().GetItemCount(ITEMCOST) >= 5) Game.GetPlayer().RemoveItem(ITEMCOST, 5) SPELL2.Cast(myCaster, myTarget) Else Debug.Notification("You don't have the items required to cast this spell") EndIfEndEventSry to bump this old thread, but i cant figure out how to use a script as a MagicEffect. Could you tell me how you did that? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 26, 2017 Share Posted February 26, 2017 Create a magic effect of the script archetype and add the script to the magic effect. Link to comment Share on other sites More sharing options...
morrowind1979 Posted February 11, 2019 Share Posted February 11, 2019 http://www.creationkit.com/Category:Papyrus -- read the pages linked on the right hand side to get an understanding of the individual parts that make up scripts. There is no specific walkthrough tutorial that is only about scripting. Since scripts have to be applied to an object, most tutorials will have you create the associated object(s) first and then discuss the script part (and only within the confines of that situation). Papyrus scripting has a basic structure which you can learn (see link above) but each situation is different and usually requires a different approach. At any rate, you misunderstood what I stated. You wanted an item to be taken from the player when the player casts a spell. Normally for a single target spell you could apply a script to the effect as you have tried. Since your spell is an AOE, the effect is triggered once for each affected actor. That is undesirable (which you have stated). While it might be possible to interrupt the effect process as I originally suggested, it may be better to use the OnSpellCast event. Since OnSpellCast is on the ObjectReference script that means that actors inherit the ability to use this event. The event has to be called on an object that does the casting (i.e. an actor, a trap, etc) rather than the effect of the spell. Therefore an alias for the player character needs to be created on a dummy quest (see quote below) Excerpt from: http://www.creationkit.com/Dynamically_Attaching_Scripts In the Object Window, navigate to Quest under the Character category. Create a new quest by right-clicking on the list and choosing 'New'. For this tutorial we will be naming the quest mymodQuest. Make sure that Start Game Enabled in the Quest Data tab is checked. Click on the Quest Alias tab, then right-click in the empty list and choose 'New Reference Alias'. We will name this alias PlayerAlias. In the Reference Alias window, under Fill Type, select the Specific Reference option and click the 'Select Forced Reference' button. Under Cell choose (any), and Ref should default to PlayerRef (Player). If not, select it from the dropdown menu. Your script may end up being something as follows. Scriptname SomeScript Extends ReferenceAlias Spell Property SpellCasted Auto SoulGem Property GemToTake Auto Actor Property PlayerRef Auto Int Property QtyToTake Auto Event OnSpellCast(Form akSpell) If akSpell == SpellCasted PlayerRef.RemoveItem(GemToTake,QtyToTake) EndIf EndEventThe only concern is: Preventing the spell from being cast when player does not have the appropriate quantity of the item. I do not know if spells can have conditions on them that prevent casting. If they can, then that is great. If not, then you are back to the drawing board as the script above removes the item when the spell has been cast. Any checks in this script would not prevent the spell from being cast as it is the casting of the spell that triggers it. I suppose you could do a "chain cast"... where the player casts a spell which is caught by the script. If the player has the necessary items, then the real spell is cast. If the player does not have the items, then notification of failure is displayed.This does not work. I am having a similar issue except all I want to do is damage the players health when they cast a magelight scroll. I followed your instructions to a tee and adapted the script to this: EFFECTSHADER PROPERTY effect AUTO KEYWORD PROPERTY NSKW AUTO SCROLL PROPERTY MLS AUTO Actor Property PlayerRef Auto Event OnSpellCast(Form akSpell) If akSpell == MLS effect.play(PlayerRef) PlayerRef.damageAV("health",200) effect.stop(PlayerRef) EndIf EndEvent When the player casts a magelight scroll nothing happens his health is not damaged. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 11, 2019 Share Posted February 11, 2019 Of course it fails. You are comparing the inherited spell from the OnSpellCast event's akSpell parameter variable to a scroll property variable. Those two will never match. Scrolls, if I am not mistaken, end up casting the actual spell itself. So if you compared the akSpell parameter against the actual magelight spell, then it might work. But if you only want it to work when using a scroll rather than any time the spell is cast, I do not know. Sorry. Link to comment Share on other sites More sharing options...
morrowind1979 Posted February 12, 2019 Share Posted February 12, 2019 Of course it fails. You are comparing the inherited spell from the OnSpellCast event's akSpell parameter variable to a scroll property variable. Those two will never match. Scrolls, if I am not mistaken, end up casting the actual spell itself. So if you compared the akSpell parameter against the actual magelight spell, then it might work. But if you only want it to work when using a scroll rather than any time the spell is cast, I do not know. Sorry.Yeah i figured that out after hours of messing around on the CK and google. I already setup up a script that damages the player when they cast the magelight spell but unfortunately the effect does not carry over to the scroll, there doesn't seem to be anyway possible to make this happen for the scroll. Another problem i'm having is to make the placed light hazard damage the player from the magelight spell. through trial and error I have found that the light hazard placed when the player casts the spell is a completely different hazard to the one that can be placed in the CK or is cast by NPC's. I can get the CK/NPC light hazard to damage the player but not the light hazard that is generated when the player casts the spell. It has a different form index and I cant find it anywhere in the CK. If I can solve these 2 issues I would be all set but truthfully I think its beyond the Creation Kits ability. Link to comment Share on other sites More sharing options...
skaybestrog Posted March 6, 2019 Share Posted March 6, 2019 (edited) @morrowind1979 So in essence you want "Scroll of Magelight" to damage the player's health, just like your modded Magelight spell does, am I reading that correctly? Instead of Managing this via script, wouldn't it be possible to simply make a new spell, give it the Magelight effect and add in a MGEF with Value Modifier / Health / Detrimental / on Self, then link that new spell with both effects to the scroll? Hopefully this is helpful, or maybe I'm getting your problem wrong :smile: Edited March 6, 2019 by skaybestrog Link to comment Share on other sites More sharing options...
Recommended Posts