ClarkWasHere Posted January 11, 2014 Share Posted January 11, 2014 So, I've been thinking and trying to implement a mod that adds an item to anyone if they were killed by a magical effect with a specific keyword Scriptname CrispyBaconAdding extends Actor Potion Property CrispyBacon Auto Keyword Property MagicFireDamage Auto Actor Property akVictim Auto Event OnDying(Actor akKiller) If (akVictim.HasMagicEffectWithKeyword(MagicFireDamage) == 1) akVictim.AddItem(CrispyBacon, 1, true) Endif EndEventThis is how it looks. It compiles, but I'm not sure what I need to do with the akVictim Property to make it apply to anyone and anything who is viciously murdered by the Player. Any help would be appreciated. Link to comment Share on other sites More sharing options...
skibo25 Posted January 11, 2014 Share Posted January 11, 2014 (edited) A few things... 1. Add an if to akkiller if you want ONLY the player making the script fire. Leave it off if you want other npcs to be able to make the script fire as well. 2. ondeath should be used so the actor is dead. 3. Define akvictim as the npc you have the script attached to in properties. (NPCdan will be killed then crispy bacon will be added to him. So I should add this script to dan.. then I should go into properties and define him as akvictim) Potion Property CrispyBacon AutoKeyword Property MagicFireDamage AutoActor Property akVictim AutoEvent Ondeath(Actor akKiller)if akkiller == game.getplayer()If (akVictim.HasMagicEffectWithKeyword(MagicFireDamage) == 1)akVictim.AddItem(CrispyBacon, 1, true)EndifEndifEndEvent Not sure if you can add items to dead npcs. ondying as you originally had instead of ondeath would prevent this. Give it a try. Edited January 12, 2014 by skibo25 Link to comment Share on other sites More sharing options...
ClarkWasHere Posted January 12, 2014 Author Share Posted January 12, 2014 (edited) Yes, but I want this script to run whenever anyone dies, not when one specific actor dies. If they die by magic, which could be casted by anyone, that has that defined keyword, that item should be added. But I am not sure about how to make the Creation Kit or the scripting constantly check for actors dying, and how to properly set the victim with the "akVictim" property I have set up. I should also clarify that I am using a quest to enact this script. Edited January 12, 2014 by ClarkWasHere Link to comment Share on other sites More sharing options...
skibo25 Posted January 12, 2014 Share Posted January 12, 2014 (edited) We need to rewrite your script. The way you have it setup is for it to be used with a specific actor. Scriptname CrispyBaconAdding extends (Actor) MAKE SURE YOUR NEW SCRIPT EXTENDS activemagiceffect, not actor.... Lets write a script and attach it to the effect. For instance if I was writing this script for cure disease. I would find curediseaseeffect. open it and attach the script there... We no longer need If (aktarget.HasMagicEffectWithKeyword(MagicFireDamage) == 1).. Because it now is applied to that specific effect inside of itself. This would be a great script for custom spells. However, you will have to add in these new changes to vanilla spells without overwriting the original script, simple.. Event OnEffectStart(Actor akTarget, Actor akCaster)aktarget.AddItem(CrispyBacon, 1, true)endifendevent As soon as the NPC is hit with the specific magic spell the potion will be added. This will be the best way to run this script. If you can find a condition with something like... "isdying" it would be good also but I don't think there is one like that. Odds are if the player hits the NPC with the spell, they will have to kill them before they can see the inventory anyways. So it will work just fine. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- EX Say the original script for fireball is something like.. Event OnEffectStart(Actor akTarget, Actor akCaster)if akcaster == game.getplayer()debug.messagebox("ouch that looks hot")endifendevent I want to add in my changes for crispy bacon but I want to make sure I do not change the vanilla script. so I would simply add my new properties Potion Property CrispyBacon AutoKeyword Property MagicFireDamage Auto then my new script would read Event OnEffectStart(Actor akTarget, Actor akCaster)if akcaster == game.getplayer()debug.messagebox("ouch that looks hot")aktarget.AddItem(CrispyBacon, 1, true)endifendevent Now Npcs hit with fireball will have the potion in their inventory and I have made no harmful changes to the vanilla script. say stage 10 of your quest finally allows the player to use the spell. Add a getstage condition to the script so it can not be used till the quest allows it. myquest.getstage() >= 10 Our final script should read this, be placed inside the spelleffect, and we need to make sure the script is set as extends activemagiceffectPotion Property CrispyBacon Auto quest property myquest auto Event OnEffectStart(Actor akTarget, Actor akCaster) if myquest.getstage() >= 10 aktarget.AddItem(CrispyBacon, 1, true) endif endevent the player now hits the npc and potion is added but not until the stage of the quest is set and passed with the specific spell. Edited January 13, 2014 by skibo25 Link to comment Share on other sites More sharing options...
Recommended Posts