pdmoerman Posted April 13, 2017 Share Posted April 13, 2017 Hello, I've been working on a mod to add a new race. I've got most things working how I want to, but I'm having trouble with one very important aspect. I can't prevent the race from equipping weapons or armor. (There's a reason for it) I've unchecked all the weapon types in the race menu, yet they can still equip weapons that I've unchecked. I based the race off of a Nord, and modified things from there. It was only showing a head originally, so I put NordRace in the "Armor Copy" thingamajig. Does that have something to do with it? If so, how do I get the body to show up with the Nord appearance, yet not copy everything from the Nord race? The race SHOULD be able to equip clothing, but NOT light or heavy armor. I've tried writing a script to just zero out any armor rating if they equip armor, but it didn't work. I can't find anything on google. The results talk about preventing unequip, but I have the opposite problem, and I can't seem to find a way to do it. Is that not possible with Creation Kit/Papyrus? Thanks. Link to comment Share on other sites More sharing options...
Surilindur Posted April 13, 2017 Share Posted April 13, 2017 (edited) How would something like OnObjectEquipped work, combined with UnequipItem? A completely untested idea: ScriptName _YourPrefix_ArmourEquipPrevention Extends Actor Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) If ( akBaseObject as Armor ) ; fails if the item is not armour, assuming clothing is not armour UnequipItem(akBaseObject, False, True) EndIf EndEvent However an actual game-managed solution like a tickbox in the Creation Kit would always be better if there exists one. Papyrus should be the last resort if there are other solutions available, at least when trying to keep the amount of scripting to a minimum. Also, if an actor equips a hundred items (or, for some reason, if there exists another script that keeps spamming an equip command), then the Papyrus event might be called quite a few times, so avoiding that sort of things would usually be best. A state could be used to prevent Papyrus overload (if tha happens), but it would also result in the script skipping some items. At least that is what I would think. If someone has a better idea, I would love to hear it. :smile: Is clothing also classified as Armour in Skyrim? If so, thet that will obviously not work (oops! :blush:). However you could then try adding in a keyword check and assume every piece if armour would have a specific keyword on it. But that would add a bit more to the amount of script processing, and would make an actual game-managed solution even better in comparison? Edited April 13, 2017 by Contrathetix Link to comment Share on other sites More sharing options...
pdmoerman Posted April 13, 2017 Author Share Posted April 13, 2017 From what I could see in the CK wiki, yes, clothing is classified as an Armor object, however, there is a method I can use to distinguish between clothing and non-clothing armor. There's a function that returns the type of armor the object is. Thank you for your reply. That actually makes a bunch of sense. I'm not used the using Events, so I'm not always sure which event is the best one to use. Another question for you though, how do I apply the script to only the new race I'm creating? What I had tried previously was making a scripted constant magic effect, which is hidden in the UI, and then adding that to the racial ability for the new race. Also, any idea on how to prevent the equip of weapons? Do I do the same thing, but using Weapon objects (is that even an object type)? I ask because, as I mentioned, I unchecked every single box in the race menu for weapon equips except H2H and torch, but I was still able to equip a weapon after beginning a new game using Alternate Start mod. (The race is a human like race that transforms into a beast for 10 minutes to enter combat...it's based off another favorite video game race, and that race hates man made weapons and armor and relies on their natural bestial strength.) Link to comment Share on other sites More sharing options...
Surilindur Posted April 14, 2017 Share Posted April 14, 2017 (edited) The example script snippet on the OnObjectEquipped page does handle weapons with a cast, so it should work. To be honest I have not done anything with races, so I have no idea how they work. :blush: If there exists a system to prevent a race from equipping some items, then that one should definitely be used as long as it works. If it works for races already in-game, it probably should also work for custom races? As for the scripting solution, the IsLightArmor and IsHeavyArmor functions apparently (according to the wiki) use the HasKeywordString function internally. So maybe you could even use a direct check for actual keywords if they would somehow magically be faster? Unless the HasKeywordString commands itself is faster. I have no idea. If you want to prevent any weapon from being equipped, and only armour items that have a heavy or light armour keyword, then maybe something like the following would be a decent starting point? If some out there knows a better way to do equip prevention with Papyrus, I would also appreciate any tips or tricks on how to better achieve it. I am still not sure if InObjectEquipped is the best way, it seems a bit... suspicious. ScriptName _YourPrefix_EquipPreventionHandler Extends ActiveMagicEffect ; properties to fill with the appropriate keywords in the property editor in CK Keyword Property HeavyArmourKW Auto Keyword Property LightArmourKW Auto ; if ActiveMagicEffect receives events from Actor script, then it should receive this event as well? Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) If ( (akBaseObject as Weapon) || ( (akBaseObject as Armor) && ( akBaseObject.HasKeyword(HeavyArmourKW) || akBaseObject.HasKeyword(LightArmourKW) ) ) ) (Self as Actor).UnequipItem(akBaseObject, False, True) EndIf EndEvent That one extends ActiveMagicEffect, and assumes Self refers to the actual actor the effect is running on. The wiki says that ActiveMagicEffect should receive events from the actor it is attached to, so if you manage to find a way to attach an ActiveMagicEffect to an effect that runs on the actor, then a script like that might work for preventing armour and weapon equips as long as the effect is active. But again, if there is a system already in the game to prevent a race from equipping some items, then that one might be a better solution. Hopefully someone else can help you more. Especially with that Creation Kit race part. :thumbsup: Edit: I am not sure of OnObjectEquipped is the best event, either, assuming it really filters every single equip event. If you have other ideas, feel free to use them. Everything I wrote here is just the first thing that came in mind. There seem to be so many ways to do the same thing in Skyrim that there might even be a better event somewhere. But again, the game-managed system for races that you mentioned (for preventing them from using items) would probably be something better than anything that involves scripting. At least it might be faster. Oh well. Hopefully someone with more knowledge will chime in and save the day. :happy: Edited April 14, 2017 by Contrathetix Link to comment Share on other sites More sharing options...
Recommended Posts