Trykz Posted July 11, 2016 Posted July 11, 2016 If anyone who knows papyrus could help, I need a special script: What I need is a script that I can attach to a special chair, that will auto-add and auto-equip 5 armor pieces to the player when they use it. However, it doesn't end there..... I also need it to lock the armor parts onto the player (so they can't be removed, and nothing else equipped in those slots) until they use that chair again, at which time it automatically removes the pieces from the player and their inventory. I would do it myself, but I have neither the time nor inclination to add learning papyrus to the plethora of stuff I already have in progress A huge thanks in advance to whoever can get this hashed out for me Trykz
Guest Posted July 11, 2016 Posted July 11, 2016 Just a generic piece of code to give you a first help. Scriptname mySpecialChair extend ObejctReference Armor Property armorPart1 Auto Armor Property armorPart2 Auto Armor Property armorPart3 Auto Armor Property armorPart4 Auto Armor Property armorPart5 Auto Actor Property PlayerRef Auto Event OnActivate(ObjectReference akActionRef) if akActionRef==PlayerRef if PlayerRef.getItemCount(armorPart1)==0 PlayerRef.addItem(armorPart1, 1) endIf PlayerRef.equipItem(armorPart1, true) if PlayerRef.getItemCount(armorPart2)==0 PlayerRef.addItem(armorPart2, 1) endIf PlayerRef.equipItem(armorPart2, true) if PlayerRef.getItemCount(armorPart3)==0 PlayerRef.addItem(armorPart3, 1) endIf PlayerRef.equipItem(armorPart3, true) if PlayerRef.getItemCount(armorPart4)==0 PlayerRef.addItem(armorPart4, 1) endIf PlayerRef.equipItem(armorPart4, true) if PlayerRef.getItemCount(armorPart5)==0 PlayerRef.addItem(armorPart5, 1) endIf PlayerRef.equipItem(armorPart5, true) endIf EndEvent
Kit Kitten Posted July 11, 2016 Posted July 11, 2016 One thing I want to note from my own tests of trying to do something similar, is that while you can get a script alone to make an item unequippable, they'll still be able to be moved out of the player's inventory (and as a result unequipped anyways) either manually, or by a mod that makes the player lose their inventory such as a couple death alternative mods out there. The only way I've seen to prevent that is to make the items quest items as well so they can't be removed from the inventory.
zax Posted July 11, 2016 Posted July 11, 2016 I would do it myself, but I have neither the time nor inclination to add learning papyrus (...) I would write you a complete script, but I have neither the time nor inclination to do so.
ag12 Posted July 11, 2016 Posted July 11, 2016 If anyone who knows papyrus could help, I need a special script: What I need is a script that I can attach to a special chair, that will auto-add and auto-equip 5 armor pieces to the player when they use it. However, it doesn't end there..... I also need it to lock the armor parts onto the player (so they can't be removed, and nothing else equipped in those slots) until they use that chair again, at which time it automatically removes the pieces from the player and their inventory. I would do it myself, but I have neither the time nor inclination to add learning papyrus to the plethora of stuff I already have in progress A huge thanks in advance to whoever can get this hashed out for me Trykz Alright, here you go. Put this on the chair - this only works for the player, not for any NPCs. Armor Property armor01 Auto Armor Property armor02 Auto Armor Property armor03 Auto Armor Property armor04 Auto Armor Property armor05 Auto event OnActivate(ObjectReference akActivator) Actor playerRef = Game.GetPlayer() ; the GetSitState() is experimental, I have not used that function before. It should ensure that the script only fires when the player sits down, not when he wants to stand up again. if akActivator == playerRef && playerRef.GetSitState() == 0 if playerRef.IsEquipped(Armor01) || playerRef.IsEquipped(Armor02) || playerRef.IsEquipped(Armor03) || playerRef.IsEquipped(Armor04) || playerRef.IsEquipped(Armor05) activate(playerRef, true) utility.wait(2) ; if the player has any of the equipment pieces in question equipped, remove them and unequip them ; unequip the items silently (change to (Armor01, false, false) to display the unequip messages) playerRef.UnequipItem(Armor01, false, true) playerRef.UnequipItem(Armor02, false, true) playerRef.UnequipItem(Armor03, false, true) playerRef.UnequipItem(Armor04, false, true) playerRef.UnequipItem(Armor05, false, true) ; now remove the items in question (using -1 for the count to remove ALL of the items in case of some sort of duplication) playerRef.RemoveItem(Armor01, -1, true) playerRef.RemoveItem(Armor02, -1, true) playerRef.RemoveItem(Armor03, -1, true) playerRef.RemoveItem(Armor04, -1, true) playerRef.RemoveItem(Armor05, -1, true) ; done return else ; make the player sit on the chair by using default activation procedure and wait 2 seconds activate(playerRef, true) utility.wait(2) ; the player doesnt have any of the items in question equipped, so add them and equip them. ; add the items playerRef.AddItem(Armor01, 1, true) playerRef.AddItem(Armor02, 1, true) playerRef.AddItem(Armor03, 1, true) playerRef.AddItem(Armor04, 1, true) playerRef.AddItem(Armor05, 1, true) ; equip the items playerRef.EquipItem(Armor01, true, true) playerRef.EquipItem(Armor02, true, true) playerRef.EquipItem(Armor03, true, true) playerRef.EquipItem(Armor04, true, true) playerRef.EquipItem(Armor05, true, true) ; done return endif else activate(akActivator, true) endif endEvent Just create a new script on your chair, name it whatever you want and make sure it says Scriptname myScriptName extends ObjectReference at the top of the script. I excluded that line, because the CK will generate that automatically and it must match the file name. So after you created your script, paste the code below that header line and set the properties. This script checks for any of the items in question - if the player already has at least one equipped, the script will unequip all of them and remove all instances of the items from the inventory. If the player doesn't have any of the items in question equipped, the script adds them and equips them. All display messages are toggled off for immersion. Enjoy.
Trykz Posted July 11, 2016 Author Posted July 11, 2016 I would do it myself, but I have neither the time nor inclination to add learning papyrus (...) I would write you a complete script, but I have neither the time nor inclination to do so. Funny.... in any event, thank you CPU And thank YOU ag12...... you just saved me about a week's worth of reading and experimentation Trykz
ag12 Posted July 11, 2016 Posted July 11, 2016 I would do it myself, but I have neither the time nor inclination to add learning papyrus (...)I would write you a complete script, but I have neither the time nor inclination to do so. Funny.... in any event, thank you CPU And thank YOU ag12...... you just saved me about a week's worth of reading and experimentation Trykz No worries. As stated in the script comments, the whole GetSitState thingy is experimental. If it doesn't work as intended, let me know - I didn't actually test it in any way, but wrote it from the back of my head - so no guarantees. However, if issues occur, tell me and I'll have 'em sorted.
Guest Posted July 11, 2016 Posted July 11, 2016 No worries. As stated in the script comments, the whole GetSitState thingy is experimental.If it doesn't work as intended, let me know - I didn't actually test it in any way, but wrote it from the back of my head - so no guarantees. However, if issues occur, tell me and I'll have 'em sorted. Getsitstate works fine for NPCs, but has incorrect results for the player. Exactly like Skyrim.
ag12 Posted July 11, 2016 Posted July 11, 2016 There you have it. Thanks CPU! 'but retired' ... more like 'all but retired'! =)
Guest Posted July 11, 2016 Posted July 11, 2016 There you have it. Thanks CPU! 'but retired' ... more like 'all but retired'! =) Do I have to change my title to: "Addicted Modder and Helper - but Retarded"?
ag12 Posted July 11, 2016 Posted July 11, 2016 There you have it. Thanks CPU! 'but retired' ... more like 'all but retired'! =) Do I have to change my title to: "Addicted Modder and Helper - but Retarded"? While not true, quite funny indeed.
Kit Kitten Posted July 12, 2016 Posted July 12, 2016 Ok, after some trial and error, but mostly just McGuyvering ag12's and ChaptainChaos' (from the Craftable/Playable Institute Reclamation Chair thread) scripts together I have produced a version that gives you a dialogue prompt after you sit in the chair, as well as allow it to work on any NPCs you tell to sit in it. Just for the sake of variety and maybe as a potential resource for something else. Have fun: Message Property ChairMenu Auto Armor Property armor01 Auto Armor Property armor02 Auto Armor Property armor03 Auto Armor Property armor04 Auto Armor Property armor05 Auto ObjectReference Property CCWhoisChair Auto Event OnActivate(ObjectReference akActionRef) CCWhoisChair = akActionRef Utility.Wait(4.0) Menu() EndEvent Function Menu(int aiButton = 0) aiButton = ChairMenu.show() If aiButton == 0 ElseIf aiButton == 1 if game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor01) || game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor02) || game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor03) || game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor04) || game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor05) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor01, false, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor02, false, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor03, false, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor04, false, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor05, false, true) ; now remove the items in question (using -1 for the count to remove ALL of the items in case of some sort of duplication) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor01, -1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor02, -1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor03, -1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor04, -1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor05, -1, true) else game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor01, 1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor02, 1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor03, 1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor04, 1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor05, 1, true) ; equip the items game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor01, true, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor02, true, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor03, true, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor04, true, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor05, true, true) EndIf EndIf EndFunction I do apologize if it is poorly cobbled together, I have very very little experience with Papyrus or coding in general and basically just made this by combining elements from both scripts until it worked. It does work though, I did test it in my game for both the player and an NPC.
Guest Posted July 12, 2016 Posted July 12, 2016 Ok, after some trial and error, but mostly just McGuyvering ag12's and ChaptainChaos' (from the Craftable/Playable Institute Reclamation Chair thread) scripts together I have produced a version that gives you a dialogue prompt after you sit in the chair, as well as allow it to work on any NPCs you tell to sit in it. Just for the sake of variety and maybe as a potential resource for something else. Have fun: Message Property ChairMenu Auto Armor Property armor01 Auto Armor Property armor02 Auto Armor Property armor03 Auto Armor Property armor04 Auto Armor Property armor05 Auto ObjectReference Property CCWhoisChair Auto Event OnActivate(ObjectReference akActionRef) CCWhoisChair = akActionRef Utility.Wait(4.0) Menu() EndEvent Function Menu(int aiButton = 0) aiButton = ChairMenu.show() If aiButton == 0 ElseIf aiButton == 1 if game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor01) || game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor02) || game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor03) || game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor04) || game.FindClosestActorFromRef(CCWhoisChair, 1.0).IsEquipped(Armor05) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor01, false, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor02, false, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor03, false, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor04, false, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).UnequipItem(Armor05, false, true) ; now remove the items in question (using -1 for the count to remove ALL of the items in case of some sort of duplication) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor01, -1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor02, -1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor03, -1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor04, -1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).RemoveItem(Armor05, -1, true) else game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor01, 1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor02, 1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor03, 1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor04, 1, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).AddItem(Armor05, 1, true) ; equip the items game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor01, true, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor02, true, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor03, true, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor04, true, true) game.FindClosestActorFromRef(CCWhoisChair, 1.0).EquipItem(Armor05, true, true) EndIf EndIf EndFunction I do apologize if it is poorly cobbled together, I have very very little experience with Papyrus or coding in general and basically just made this by combining elements from both scripts until it worked. It does work though, I did test it in my game for both the player and an NPC. Thank you for this. But do you realize that it is really inefficient? You start with the event OnActivate, that gives you the actual Actor (as ObjectReference) sitting on the chair. And then you use a really expensive function like FindClosestActor, that actually may fail to find the actor using the chair if the idle is already completed.
Halstrom Posted July 12, 2016 Posted July 12, 2016 Let the games begin !! I'm getting all sorts of devious ideas from this script and learning stuff too, especially if we get it working for NPC's
Kit Kitten Posted July 12, 2016 Posted July 12, 2016 Let the games begin !! I'm getting all sorts of devious ideas from this script and learning stuff too, especially if we get it working for NPC's Yeah my Frankenscript works on NPC's that you can get to sit in the chair but CPU says it's inefficient. I'm brand new to Papyrus, my only other scripting experience being an introduction course my first year in college, which was just a bit of Python, and then later LSL in Second Life which I didn't get very far with either. I've been going over the functions in the creationkit.com/fallout4 site but I have yet to come up with a way to streamline the script and keep it working for NPCs. Hopefully someone else with more experience and fresh eyes might be able to figure it out. Oh a thing to note about that script. I would recommend only putting it on chairs that NPCs won't sandbox onto otherwise you're probably going to get the message prompt no matter where you are.
Guest Posted July 12, 2016 Posted July 12, 2016 Nope, had no idea. How would you improve it? Message Property ChairMenu Auto Armor Property armor01 Auto Armor Property armor02 Auto Armor Property armor03 Auto Armor Property armor04 Auto Armor Property armor05 Auto Actor Property CCWhoisChair Auto Event OnActivate(ObjectReference akActionRef) CCWhoisChair = akActionRef as Actor Utility.Wait(4.0) Menu() EndEvent Function Menu() int aiButton = ChairMenu.show() If aiButton == 1 if CCWhoisChair.IsEquipped(Armor01) || CCWhoisChair.IsEquipped(Armor02) || CCWhoisChair.IsEquipped(Armor03) || CCWhoisChair.IsEquipped(Armor04) || CCWhoisChair.IsEquipped(Armor05) CCWhoisChair.UnequipItem(Armor01, false, true) CCWhoisChair.UnequipItem(Armor02, false, true) CCWhoisChair.UnequipItem(Armor03, false, true) CCWhoisChair.UnequipItem(Armor04, false, true) CCWhoisChair.UnequipItem(Armor05, false, true) ; now remove the items in question (using -1 for the count to remove ALL of the items in case of some sort of duplication) CCWhoisChair.RemoveItem(Armor01, -1, true) CCWhoisChair.RemoveItem(Armor02, -1, true) CCWhoisChair.RemoveItem(Armor03, -1, true) CCWhoisChair.RemoveItem(Armor04, -1, true) CCWhoisChair.RemoveItem(Armor05, -1, true) else CCWhoisChair.AddItem(Armor01, 1, true) CCWhoisChair.AddItem(Armor02, 1, true) CCWhoisChair.AddItem(Armor03, 1, true) CCWhoisChair.AddItem(Armor04, 1, true) CCWhoisChair.AddItem(Armor05, 1, true) ; equip the items CCWhoisChair.EquipItem(Armor01, true, true) CCWhoisChair.EquipItem(Armor02, true, true) CCWhoisChair.EquipItem(Armor03, true, true) CCWhoisChair.EquipItem(Armor04, true, true) CCWhoisChair.EquipItem(Armor05, true, true) EndIf EndIf EndFunction
Trykz Posted July 12, 2016 Author Posted July 12, 2016 Couldn't get any of these to work...... pretty sure I did something wrong Anyway, this is the last attempt I attached to the placed chair in the cell: Scriptname myArmorChairScript extends ObjectReference Message Property ChairMenu Auto Armor Property Armor_iHumanLeftArmMod Auto Armor Property Armor_iHumanLeftLegMod Auto Armor Property Armor_iHumanRightArmMod Auto Armor Property Armor_iHumanRightLegMod Auto Armor Property Armor_iHumanTorsoModA Auto Actor Property CCWhoisChair Auto Event OnActivate(ObjectReference akActionRef) CCWhoisChair = akActionRef as Actor Utility.Wait(4.0) Menu() EndEvent Function Menu() int aiButton = ChairMenu.show() If aiButton == 1 if CCWhoisChair.IsEquipped(Armor_iHumanLeftArmMod) || CCWhoisChair.IsEquipped(Armor_iHumanLeftLegMod) || CCWhoisChair.IsEquipped(Armor_iHumanRightArmMod) || CCWhoisChair.IsEquipped(Armor_iHumanRightLegMod) || CCWhoisChair.IsEquipped(Armor_iHumanTorsoModA) CCWhoisChair.UnequipItem(Armor_iHumanLeftArmMod, false, true) CCWhoisChair.UnequipItem(Armor_iHumanLeftLegMod, false, true) CCWhoisChair.UnequipItem(Armor_iHumanRightArmMod, false, true) CCWhoisChair.UnequipItem(Armor_iHumanRightLegMod, false, true) CCWhoisChair.UnequipItem(Armor_iHumanTorsoModA, false, true) ; now remove the items in question (using -1 for the count to remove ALL of the items in case of some sort of duplication) CCWhoisChair.RemoveItem(Armor_iHumanLeftArmMod, -1, true) CCWhoisChair.RemoveItem(Armor_iHumanLeftLegMod, -1, true) CCWhoisChair.RemoveItem(Armor_iHumanRightArmMod, -1, true) CCWhoisChair.RemoveItem(Armor_iHumanRightLegMod, -1, true) CCWhoisChair.RemoveItem(Armor_iHumanTorsoModA, -1, true) else CCWhoisChair.AddItem(Armor_iHumanLeftArmMod, 1, true) CCWhoisChair.AddItem(Armor_iHumanLeftLegMod, 1, true) CCWhoisChair.AddItem(Armor_iHumanRightArmMod, 1, true) CCWhoisChair.AddItem(Armor_iHumanRightLegMod, 1, true) CCWhoisChair.AddItem(Armor_iHumanTorsoModA, 1, true) ; equip the items CCWhoisChair.EquipItem(Armor_iHumanLeftArmMod, true, true) CCWhoisChair.EquipItem(Armor_iHumanLeftLegMod, true, true) CCWhoisChair.EquipItem(Armor_iHumanRightArmMod, true, true) CCWhoisChair.EquipItem(Armor_iHumanRightLegMod, true, true) CCWhoisChair.EquipItem(Armor_iHumanTorsoModA, true, true) EndIf EndIf EndFunction It successfully compiles and saves, but sitting in the chair does nothing. I think I recall something about scripts can't (or shouldn't) be attached to base objects(?). Which is why I placed the chair in the cell, and attached the script to that. Sorry if I'm being illiterate here, but my mind is racing about a thousand miles an hour at the moment trying too keep track of all the stuff i want to accomplish with this mod LOL Trykz
Kit Kitten Posted July 12, 2016 Posted July 12, 2016 For that script you also need to make a message entry with 2 options. The first one for doing nothing but sitting there, and the second option being the prompt to add or remove the armor then link it to the Message Property in the script. Also as long as the base object is unique and not used elsewhere I see no reason not to attach the script to it.
Trykz Posted July 12, 2016 Author Posted July 12, 2016 For that script you also need to make a message entry with 2 options. The first one for doing nothing but sitting there, and the second option being the prompt to add or remove the armor then link it to the Message Property in the script. Also as long as the base object is unique and not used elsewhere I see no reason not to attach the script to it. I see..... 2 questions then: 1) Can I remove the message part? It's not really needed. 2) I'm actually creating 4 different chairs, with each chair loading in one of four different torso pieces. However, I want to use the same base object with slightly different scripts attached (the torso property being the only difference), which is why I attached it to the placed chair. Thanks for the help...... and the patience LOL Trykz
Kit Kitten Posted July 12, 2016 Posted July 12, 2016 For that script you also need to make a message entry with 2 options. The first one for doing nothing but sitting there, and the second option being the prompt to add or remove the armor then link it to the Message Property in the script. Also as long as the base object is unique and not used elsewhere I see no reason not to attach the script to it. I see..... 2 questions then: 1) Can I remove the message part? It's not really needed. 2) I'm actually creating 4 different chairs, with each chair loading in one of four different torso pieces. However, I want to use the same base object with slightly different scripts attached (the torso property being the only difference), which is why I attached it to the placed chair. Thanks for the help...... and the patience LOL Trykz Well for 1, the script would have to be rewritten to something closer to CPU's or ag12's scripts earlier in the thread, though the reason I stitched this version together with the message box was because I couldn't get ag12's script to work. The chair would add the items when activated but it wouldn't let the player actually sit down in the chair. As for 2, I don't know of any reason why that approach should cause an issue, so either way. However as I've said earlier, I am super new at this so I might be wrong. This is the first Papyrus script I've ever even tried to mess with, so I should be thanking you for your patience instead of the other way around (and thanks to shakrum for refining the script). I'll have to see if I can come up with something new without a message box, though that might be a little while as I do research and experiment.
ag12 Posted July 12, 2016 Posted July 12, 2016 Armor Property armor01 Auto Armor Property armor02 Auto Armor Property armor03 Auto Armor Property armor04 Auto Armor Property armor05 Auto event OnActivate(ObjectReference akActivator) Actor playerRef = Game.GetPlayer() ; the GetSitState() is experimental, I have not used that function before. It should ensure that the script only fires when the player sits down, not when he wants to stand up again. if akActivator == playerRef && playerRef.GetSitState() == 0 if playerRef.IsEquipped(Armor01) || playerRef.IsEquipped(Armor02) || playerRef.IsEquipped(Armor03) || playerRef.IsEquipped(Armor04) || playerRef.IsEquipped(Armor05) utility.wait(2) ; if the player has any of the equipment pieces in question equipped, remove them and unequip them ; unequip the items silently (change to (Armor01, false, false) to display the unequip messages) playerRef.UnequipItem(Armor01, false, true) playerRef.UnequipItem(Armor02, false, true) playerRef.UnequipItem(Armor03, false, true) playerRef.UnequipItem(Armor04, false, true) playerRef.UnequipItem(Armor05, false, true) ; now remove the items in question (using -1 for the count to remove ALL of the items in case of some sort of duplication) playerRef.RemoveItem(Armor01, -1, true) playerRef.RemoveItem(Armor02, -1, true) playerRef.RemoveItem(Armor03, -1, true) playerRef.RemoveItem(Armor04, -1, true) playerRef.RemoveItem(Armor05, -1, true) ; done return else ; make the player sit on the chair by using default activation procedure and wait 2 seconds utility.wait(2) ; the player doesnt have any of the items in question equipped, so add them and equip them. ; add the items playerRef.AddItem(Armor01, 1, true) playerRef.AddItem(Armor02, 1, true) playerRef.AddItem(Armor03, 1, true) playerRef.AddItem(Armor04, 1, true) playerRef.AddItem(Armor05, 1, true) ; equip the items playerRef.EquipItem(Armor01, true, true) playerRef.EquipItem(Armor02, true, true) playerRef.EquipItem(Armor03, true, true) playerRef.EquipItem(Armor04, true, true) playerRef.EquipItem(Armor05, true, true) ; done return endif endif endEvent Slightly changed the code, I'm so used to blocking default activation on everything I work with to have more control that I included activate() triggers, but since the default activation isn't actually blocked in this case that makes it trigger twice in quick succession, basically sitting the player down and having him stand up again in the same frame, thus not doing anything. Don't attach this script to the Base Object, attach it to the References in the Render Window, then you can use the same base chair four times (if you wanted to) and simply reference the Armor01-Armor05 properties to different items for each chair, hence making them equip/unquip different sets. There may be some incompatibility though, Player could go to Chair 1 and equip set 1 - then go to Chair 2 which equips Set 2 but doesn't remove Chair 1. If you want to work around that, we'll need to expand the script quite a bit. Should work now. If you have any questions, ask here or PM me.
Guest Posted July 12, 2016 Posted July 12, 2016 2) I'm actually creating 4 different chairs, with each chair loading in one of four different torso pieces. However, I want to use the same base object with slightly different scripts attached (the torso property being the only difference), which is why I attached it to the placed chair. OK, slight improvement from @ag12 code. Described after the code: Scriptname abcdEquipArmoritemOnSitting extends ObjectReference Armor Property armor01 Auto Armor Property armor02 Auto Armor Property armor03 Auto Armor Property armor04 Auto Armor Property armor05 Auto Armor Property armorToEquip Auto Actor Property PlayerRef Auto event OnActivate(ObjectReference akActivator) if akActivator == playerRef && playerRef.GetSitState() == 0 if playerRef.IsEquipped(Armor01) || playerRef.IsEquipped(Armor02) || playerRef.IsEquipped(Armor03) || playerRef.IsEquipped(Armor04) || playerRef.IsEquipped(Armor05) utility.wait(2.0) ; "if the player has any of the equipment pieces in question equipped, remove them and unequip them unequip the items silently (change to (Armor01, false, false) to display the unequip messages)" ; "All items are removed, no matter which one was equipped" playerRef.UnequipItem(Armor01, false, true) playerRef.UnequipItem(Armor02, false, true) playerRef.UnequipItem(Armor03, false, true) playerRef.UnequipItem(Armor04, false, true) playerRef.UnequipItem(Armor05, false, true) ; "now remove the items in question (using -1 for the count to remove ALL of the items in case of some sort of duplication)" playerRef.RemoveItem(Armor01, -1, true) playerRef.RemoveItem(Armor02, -1, true) playerRef.RemoveItem(Armor03, -1, true) playerRef.RemoveItem(Armor04, -1, true) playerRef.RemoveItem(Armor05, -1, true) else utility.wait(2) ; "Equip ONLY the item that is defined in as property (specific for each chair, so for each object reference)" if PlayerRef.getItemCount(armorToEquip)==0 PlayerRef.AddItem(armorToEquip, 1, true) endif PlayerRef.EquipItem(armorToEquip, true, true) ; Actually equip the item" endif endif endEvent The script is for an object reference, so a chair INSIDE a cell, not the base object. The 5 properties should be filled with the possible 5 pieces in all cases. The specific property armorToEquip should be filled with a different piece for each different chair.
Trykz Posted July 18, 2016 Author Posted July 18, 2016 Thank you CPU, AG12, Shakrum, and Buddy42 for all your help. Got this working as I intended and ready for when I update my i Human Mod Couldn't have done it without you guys Trykz
Recommended Posts
Archived
This topic is now archived and is closed to further replies.