noktrum666 Posted September 30, 2017 Share Posted September 30, 2017 Hi there!Can any one help me with writing a script that will add a weapon to players inventory after a specific piece of armour was equipped (not just a piece that sits in player inventory, but actually equipped on the player)? I have absolutely zero knowledge and experience in scripting and the mod that I’m working on requires that particular functionality... in few places. I have already studied CK wiki for the script commands, I know that the base for my script will be additem and onequipped… but I have no idea what so ever how to forge that in to a working script. No clue how or where to paste the code. Will it be attached to a magic effect, that will be attached to the armour piece, or maybe the weapon itself? Also… will it be possible to remove this particular weapon from player inventory when the armour piece is unequipped? I believe there is a command in papyrus for that – onunequipped, but I’m not sure if this is for that or is it only my wishfully thinking. Any help on this will be much appreciated. Thank you! Link to comment Share on other sites More sharing options...
JonathanOstrus Posted October 1, 2017 Share Posted October 1, 2017 There's 2 ways to accomplish this.OnItemEquipped triggered on an actor when items are equipped. Then check for the item you want to handle and proceed accordingly. This has to be placed on any actor you want to effect. OnEquipped triggered on the armor itself. This is a script that would be placed on the armor record in CK. If it will be a new unique item this might be preferable to hooking the actor equip.Whichever method you choose there is an equivalent UnEquip event for it. If you want to support alternative actors besides the player then the script on the armor itself would be the only realistically viable method. Though it will only work properly for new spawns of an item after you place the script on the armor record. If you only want to support the player you can use a reference alias and then don't have to worry about whether it's a pre-existing spawned item or a new one or whatever:Make a questOn the quest add a reference alias for the playerMake a script on the reference alias for an OnItemEquipped eventin the OnItemEquipped event check for the armor you want to trigger on and then fire the equipitem for the weapon of your choice.In the same script you can put an OnItemUnequipped to check for removal of the armor and then removeitem/unequip the weapon. Link to comment Share on other sites More sharing options...
noktrum666 Posted October 1, 2017 Author Share Posted October 1, 2017 Yes, it is a new, custom weapon and a new custom armour on a new custom - non human race, fully controllable by the player. I will see what I can cook with this. Thanks Link to comment Share on other sites More sharing options...
noktrum666 Posted October 1, 2017 Author Share Posted October 1, 2017 Right... cant comply this script for some reason. Can any one look and see if there is an error in this code? (Probably is, this is my first script ever) Scriptname YV_WristBladesP1Script extends ObjectReference {Adding Blades to Right hand Guantlet Item}Event OnEquipped(Actor akActor) If (akActor == Game.GetPlayer()) Game.GetPlayer().AddItem(YautjaWristBlades2) EndIfEndEventEvent OnUnequipped(Actor akActor) If (akActor == Game.GetPlayer()) Game.GetPlayer().RemoveItem(YautjaWristBlades2) EndIfEndEvent Link to comment Share on other sites More sharing options...
noktrum666 Posted October 1, 2017 Author Share Posted October 1, 2017 Ok! I figure out that my custom blades are undefined! But how the hell am I suposse to do thaht :( ? Link to comment Share on other sites More sharing options...
noktrum666 Posted October 1, 2017 Author Share Posted October 1, 2017 Right! Its done and working fine in game. Just for any one else who is working on the same feature - here is the working script (I know this is probably basic stuff, but hey ho! I did not have a clue 24 hours ago, I'm sure theres more out there like me ;) ) Scriptname AddingWeaponScript extends ObjectReference {Adding Blades to Right hand Guantlet Item}Weapon Property YourWeapon autoEvent OnEquipped(Actor akActor) If (akActor == Game.GetPlayer()) Game.GetPlayer().AddItem(YourWeapon) EndIfEndEventEvent OnUnequipped(Actor akActor) If (akActor == Game.GetPlayer()) Game.GetPlayer().RemoveItem(YourWeapon) EndIfEndEvent Basically, just put this code in notepad, save as psc file, drop it in your data/scripts/source/user , open CK, select the script in Script Manager, compile it and add it in script section of your armor item. Remember to edit weapon property and select the weapon you desire. Done! Link to comment Share on other sites More sharing options...
deadbeeftffn Posted October 1, 2017 Share Posted October 1, 2017 So, what will happen, if i put the weapon into a box before unequipping the armor? ;-)(it will still be in this box, of course) Link to comment Share on other sites More sharing options...
noktrum666 Posted October 1, 2017 Author Share Posted October 1, 2017 A! U see, thats the next thing I'm trying to do now... make this particular weapon "not droppable"... unfortunetly the "cant drop" box in CK armor properties is not doing its job, or at least its not doing that specific thing, so this item can by dupicated just by reequiping the armor and droping the blades all the time. I will try to make it as a quest/legendary item. This is how some vanilla weapons are not droppable in the game. It might work. We will see ;) Unlease ofcourse, some one already knows the way and will be kind enough to share his knowlage :D Link to comment Share on other sites More sharing options...
JonathanOstrus Posted October 1, 2017 Share Posted October 1, 2017 So there's a couple options available here.If you can ensure only one of the armor is ever made. Use a quest whose Reference Alias creates the weapon in a container somewhere (probabaly a hidden holding cell). Have that reference flagged as quest. Then have your armor script do the AddItem with the QuestReferenceAlias.GetReference() so it gets the exact instance of the weapon. Now it is not droppable. You'll need to change your unequip to put it back in the container using the same method instead of outright deleting it. If it is possible to have multiple armor and by extension multiple weapons you can use a reference collection. Instead of using the alias to create the item your armor script would have to spawn the item somewhere, add it to the reference collection which has the quest flag on, and then move it to the actor inventory. Now it's marked as quest and cannot be dropped. When removing you'd need to remove it from the reference collection and then from the inventory. Instead of making it non droppable you could just make it force equipped and then it can only be removed by unequipping the armor. This may be undesirable by some users though. See the wiki page for EquipItem. The quick and dirty ActorRef.EquipItem(Weapon, true) Link to comment Share on other sites More sharing options...
noktrum666 Posted October 2, 2017 Author Share Posted October 2, 2017 Thanks for the idea! I was not even considering the last possibility… I will give it a shoot or two tonight and see what can be accomplished. Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts