BerzerkerKidd Posted June 17, 2020 Share Posted June 17, 2020 I'm learning papyrus from immersion, and I can't figure out why this won't work, even after searching other topics of similar kinds. Any help would be awesome, but please try to put it simply, and educate me if you have the patience! My script is meant to make my bow act similarly to a bound bow, spawning in and equipping special arrows when equipped, and removing them when unequipped. here's my script Scriptname DoveCustomArrowScript extends ObjectReference Ammo Property DoveCustomArrow auto Event OnEquipped(Actor akActor) if akActor == Game.GetPlayer() Game.GetPlayer().AddItem(DoveCustomArrow,100,TRUE) Game.GetPlayer().EquipItem(DoveCustomArrow,TRUE,TRUE) endIf endEvent Event OnUnequipped(Actor akActor) if akActor == Game.GetPlayer() Game.GetPlayer().RemoveItem(DoveCustomArrow,akActor.getitemcount(DoveCustomArrow),TRUE) endIf endEvent Repost cuz I'm dumb, thank you all for being cool <3 Link to comment Share on other sites More sharing options...
Ghaunadaur Posted June 17, 2020 Share Posted June 17, 2020 (edited) I think the problem is with the bow being in a container/inventory, so the script will not receive events, unless the bow was made persistent in some way. But you can do this by using an enchantment, and a spell ability that will be added by the enchantment. 1. Create the spell: type ability / casting constant effect / delivery self.2. Add a magic effect to the spell: effect archetype script / casting type constant effect / delivery self.3. Create a new enchantment and add it to the bow: type enchantment / casting fire and forget / delivery contact.4. Make another magic effect and add it to the enchantment: casting type fire and forget / delivery contact. In the 'Equip Ability' dropdown, choose the ability you just created.5. Add this script to the ability effect: Scriptname DoveCustomArrowScript extends ActiveMagicEffect Ammo Property DoveCustomArrow auto Event OnEffectStart(Actor akTarget, Actor akCaster) if akTarget == Game.GetPlayer() akTarget.AddItem(DoveCustomArrow,100,TRUE) akTarget.EquipItem(DoveCustomArrow,TRUE,TRUE) endIf endEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) if akTarget == Game.GetPlayer() akTarget.RemoveItem(DoveCustomArrow,akTarget.GetItemCount(DoveCustomArrow),TRUE) endIf endEvent Obviously the script works only for the player. If you want it to work with all NPC, remove the conditions. Edited June 17, 2020 by Ghaunadaur Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 17, 2020 Share Posted June 17, 2020 Before re-writing how your mod behaves, test it out on a new game. Chances are that if the game you are working with already had that bow in the player inventory, the added script was not recognized by that particular instance. A new instance would have the script, however. Link to comment Share on other sites More sharing options...
BerzerkerKidd Posted June 17, 2020 Author Share Posted June 17, 2020 (edited) Before re-writing how your mod behaves, test it out on a new game. Chances are that if the game you are working with already had that bow in the player inventory, the added script was not recognized by that particular instance. A new instance would have the script, however.Don't worry, I always use coc from the menu to test :smile: I think the problem is with the bow being in a container/inventory, so the script will not receive events, unless the bow was made persistent in some way. But you can do this by using an enchantment, and a spell ability that will be added by the enchantment. 1. Create the spell: type ability / casting constant effect / delivery self.2. Add a magic effect to the spell: effect archetype script / casting type constant effect / delivery self.3. Create a new enchantment and add it to the bow: type enchantment / casting fire and forget / delivery contact.4. Make another magic effect and add it to the enchantment: casting type fire and forget / delivery contact. In the 'Equip Ability' dropdown, choose the ability you just created.5. Add this script to the ability effect: Scriptname DoveCustomArrowScript extends ActiveMagicEffect Ammo Property DoveCustomArrow auto Event OnEffectStart(Actor akTarget, Actor akCaster) if akTarget == Game.GetPlayer() akTarget.AddItem(DoveCustomArrow,100,TRUE) akTarget.EquipItem(DoveCustomArrow,TRUE,TRUE) endIf endEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) if akTarget == Game.GetPlayer() akTarget.RemoveItem(DoveCustomArrow,akTarget.GetItemCount(DoveCustomArrow),TRUE) endIf endEvent Obviously the script works only for the player. If you want it to work with all NPC, remove the conditions. Trying this, still not working. I should say that I already have an enchantment on the bow, so I did what you said, made an ability that would apply the script, but I just added it to the already existing spell on the enchantment. The abiliity shows in my active effects tab on equip and disappears when unequipped, so that part worked, but the script still won't run :sad: Edited June 17, 2020 by BerzerkerKidd Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 18, 2020 Share Posted June 18, 2020 Try akCaster instead of akTarget for the player. Link to comment Share on other sites More sharing options...
Ghaunadaur Posted June 18, 2020 Share Posted June 18, 2020 I just tested it, and I can confirm that both methods are working. Adding the script to the weapon itself will not work, if it's already in the inventory. In that case the solution I posted would be preferrable as it will work in all scenarios. Maybe dumb question, but did you fill the property? Link to comment Share on other sites More sharing options...
BerzerkerKidd Posted June 18, 2020 Author Share Posted June 18, 2020 (edited) I got it to work, I didn't even have to link it to an enchantment... I just forgot to set the properties of the script in ck hahahaha I should really stress how new I am to this, I had literally just started practicing the day of posting lmao but here's the code that worked, just attached it to the bow n messed with the properties, and bam! 100 magic arrows on equip, and then removed when unequipped Scriptname DoveMagicBowScript extends ObjectReference Ammo Property DoveCustomArrow auto Event OnEquipped(Actor akActor) akActor.AddItem(DoveCustomArrow,100,TRUE) akActor.EquipItem(DoveCustomArrow,TRUE,TRUE) debug.notification("Changed For Funsies") endEvent Event OnUnequipped(Actor akActor) akActor.RemoveItem(DoveCustomArrow,akActor.getitemcount(DoveCustomArrow),TRUE) debug.notification("Changed For Funsies.") endEvent Edited June 18, 2020 by BerzerkerKidd Link to comment Share on other sites More sharing options...
BerzerkerKidd Posted June 18, 2020 Author Share Posted June 18, 2020 But, now I have a new problem, I don't want it to just be in the world from the start, so I wanna have an event happen at a certain level, say level 40. so now I have a whole new scripting journey ahead of me lmao if you guys wanna keep helping me out, I made the bow's crafting recipe require an ability that I bound to a book, so that's all working, but I want the book to appear with the summoned FX after a certain level and entering whiterun (example) Link to comment Share on other sites More sharing options...
BerzerkerKidd Posted June 18, 2020 Author Share Posted June 18, 2020 Oh, and thank you guys for being so helpful, even if I couldn't personally get those methods to work at the time (through my own stupidity, nonetheless hahaha), you guys got me further than any tutorial I've found has lol Link to comment Share on other sites More sharing options...
Ghaunadaur Posted June 18, 2020 Share Posted June 18, 2020 (edited) An easy solution to this would be to place a trigger box at the entrance of Whiterun and add a script to it, that checks for the player level. Example: Actor Property PlayerRef auto Book Property BookToAdd auto Event OnTriggerEnter(ObjectReference akActionRef) if (akActionRef as Actor == PlayerRef) if (PlayerRef.GetLevel() >= 40) GotoState("Done") PlayerRef.AddItem(BookToAdd, 1) Debug.Notification("Book added to player") endif endif endEvent State done ;done EndState Edited June 18, 2020 by Ghaunadaur Link to comment Share on other sites More sharing options...
Recommended Posts