nokou Posted March 14, 2018 Posted March 14, 2018 I've made a new outfit but I want to add a script that adds a spell to the player and removes the spell when unequipped. The only problem is I've never done scripts before. any help would be appreciated.
Azazellz Posted March 14, 2018 Posted March 14, 2018 You can look on vanilla dragonborn rings from Azidal quest (one of them add fire spell when equipped). So you can just look how it work there and make same things for your item.
Guest Posted March 14, 2018 Posted March 14, 2018 Create a quest. Create an alias inside the quest. Set the alias forced to the player Add a script with the following code. Maybe you want to correctly name the script, and the two properties (myArmor and mySpell) with the actual names Fill the properties after compiling the script and you should be good to go. Scriptname myOutfitSpell extends ReferenceAlias Armor Property myArmor Auto Spell Property mySpell Auto Evnet OnObjectEquipped(Form akBaseObject, ObjectReference akReference) if akBaseObject==myArmor (Self as Actor).addSpell(mySpell, true) endIf endEvent Evnet OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) if akBaseObject==myArmor (Self as Actor).removeSpell(mySpell) endIf endEvent
nokou Posted March 14, 2018 Author Posted March 14, 2018 9 hours ago, Azazellz said: You can look on vanilla dragonborn rings from Azidal quest (one of them add fire spell when equipped). So you can just look how it work there and make same things for your item. 9 hours ago, CPU said: Create a quest. Create an alias inside the quest. Set the alias forced to the player Add a script with the following code. Maybe you want to correctly name the script, and the two properties (myArmor and mySpell) with the actual names Fill the properties after compiling the script and you should be good to go. Awesome, Thank you guys.. i'll give it a go now
nokou Posted March 14, 2018 Author Posted March 14, 2018 sorry it didnt work.. im still trying to figure it out as this is new to me... just curious but here's what I done {Scriptname myOutfitSpell extends ReferenceAlias Armor Property Cyber_AngelOutfit Auto Spell Property Cyber_ElectricDischarge Auto Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) if akBaseObject==Cyber_AngelOutfit (Self as Actor).addSpell(Cyber_ElectricDischarge, true) endIf endEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) if akBaseObject==Cyber_AngelOutfit (Self as Actor).removeSpell(Cyber_ElectricDischarge) endIf endEvent}
Guest Posted March 15, 2018 Posted March 15, 2018 You put all the code between { and }. So you transformed it to just a comment.
nokou Posted March 15, 2018 Author Posted March 15, 2018 ahh... so, yes... i think i know what you mean.. i'll try it again. Thanks
nokou Posted March 15, 2018 Author Posted March 15, 2018 ok, so I started over again but now Im getting "cannot cast Cyber_ElectroDischarge to actor, types are incompatable" here's my script.. well the one you gave me Scriptname ElectroDischarge extends ReferenceAlias {Electro Discharge} Armor Property Cyber_AngelOutfit Auto Spell Property Cyber_ElectroDischarge Auto Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) if akBaseObject==Cyber_AngelOutfit (Self as Actor).addSpell(Cyber_ElectroDischarge, true) endIf endEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) if akBaseObject==Cyber_AngelOutfit (Self as Actor).removeSpell(Cyber_ElectroDischarge) endIf endEvent
Guest Posted March 16, 2018 Posted March 16, 2018 Try to replace "(Self as Actor)" with "(Self as ReferenceAlias).getActorReference()" It is there twice in the code.
nokou Posted March 16, 2018 Author Posted March 16, 2018 it let me save and compile but did nothing when the outfit was worn so i went back to ck and added it to the outfit (pics shown) sadly that didn't work either...
Guest Posted March 16, 2018 Posted March 16, 2018 OK, let's put some debug traces in the code, and let's see what is going on. Scriptname ElectroDischarge extends ReferenceAlias {Electro Discharge} Armor Property Cyber_AngelOutfit Auto Spell Property Cyber_ElectroDischarge Auto Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) if akBaseObject==Cyber_AngelOutfit debug.trace("---> Angel Outfit equipped") debug.trace("---> Applying to: " + (Self as ReferenceAlias).getActorReference()) (Self as ReferenceAlias).getActorReference().addSpell(Cyber_ElectroDischarge, true) endIf endEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) if akBaseObject==Cyber_AngelOutfit debug.trace("---> Angel Outfit removed") debug.trace("---> Removing spell from to: " + (Self as ReferenceAlias).getActorReference().getDisplayName()) (Self as ReferenceAlias).getActorReference().removeSpell(Cyber_ElectroDischarge) endIf endEvent
nokou Posted March 17, 2018 Author Posted March 17, 2018 I dont know if this how to add debug traces but I enable papyrus logging and started a new game, I ran it for a while and i found this "[03/17/2018 - 01:46:22AM] Error: Unable to bind script ElectricDischarge to Item 1 in container (00000014) because their base types do not match" That first script i did ElectroDischarge was deleted and redone to ElectricDischarge, this new one compiled and saved but the above problem is what im getting i can send the Papyrus.0.log file if needed.
Guest Posted March 17, 2018 Posted March 17, 2018 Wait, did you attach the script directly to the player? You have to put it to a ReferenceAlias inside a quest, and the refalias has to point to the player.
nokou Posted March 17, 2018 Author Posted March 17, 2018 I did because it didn't work the first time, it's removed now and still wont work.
Guest Posted March 18, 2018 Posted March 18, 2018 OK, try to compile the script now, try to run it , and let's check the traces in the papyrus log.
nokou Posted March 18, 2018 Author Posted March 18, 2018 ok, I added the extra commands, saved and compiled it.. checked the papyrus log, nothing.. then I tried adding debug.trace("---> Cyber_AngelOutfit Outfit equipped") instead of debug.trace("---> Angel Outfit equipped") and still nothing.
Guest Posted March 18, 2018 Posted March 18, 2018 Probably there are problems on the quest. Later or tomorrow i will try to give you more help.
nokou Posted March 18, 2018 Author Posted March 18, 2018 3 hours ago, CPU said: Probably there are problems on the quest. Later or tomorrow i will try to give you more help. Thank you very much so far.. i do appreciate it
Recommended Posts
Archived
This topic is now archived and is closed to further replies.