Elementargewalt Posted July 10, 2022 Share Posted July 10, 2022 Hey folks, i want to make it so, that for heavy weapons, there is no way for the player to take/ pick up/ equip/ or use these items in any way.There is this mod called "Weapon Requirements" which kind of does this, but not exactly how i want it. As an example, with thementioned mod you can still pick up the weapon or transfer it to your inventory via the menu, it just prevents you from equipping the weapon. So i want to implement the idea but in a more realistic and logical way.But i need help with the scripting because i cannot script at all. So a complete base script for this would be absolutely awesome.Anyone here who has an idea and is willing to help me? Thanks in advance Link to comment Share on other sites More sharing options...
LarannKiar Posted July 10, 2022 Share Posted July 10, 2022 (edited) If you uncheck the checkbox "Playable" on the weapon records, the weapon won't show up in the Player's inventory and it can't be equipped either. Create a Quest, add a Reference Alias, fill the alias with the Player reference, then attach this script to the alias: Scriptname YOUSCRIPTNAME extends ReferenceAlias Const Weapon[] Property UnplayableWeapons Auto Const {Array of weapons that can't be used by the Player ("unplayable"). Add weapons to this array using the Script Property editor.} Event OnAliasInit() AddCustomInventoryEventFilters() EndEvent Function AddCustomInventoryEventFilters() RemoveAllInventoryEventFilters() Int Index While UnplayableWeapons.Length > Index Weapon LoopWeapon = UnplayableWeapons[Index] If LoopWeapon AddInventoryEventFilter(LoopWeapon) EndIf Index = Index + 1 EndWhile EndFunction Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as Weapon && UnplayableWeapons.Find(akBaseItem as Weapon) >= 0 Actor PlayerRef = Game.GetPlayer() Int ItemCount = PlayerRef.GetItemCount(akBaseItem) PlayerRef.RemoveItem(akBaseItem, ItemCount) EndIf EndEvent This script removes all weapons you add to UnplayableWeapons from the Player's inventory right after the Player picks them up. Edited July 10, 2022 by LarannKiar Link to comment Share on other sites More sharing options...
Elementargewalt Posted July 10, 2022 Author Share Posted July 10, 2022 Oh hey thanks for replying and your effort!But i think you misunderstand my intentions, as i don´t want to make those weapons unplayable in general, but to make them require a certain strength level and/ or a specific perk to pick them up or transfer them into the inventory. But i think you are on the right way- would be awesome if you could refine this script by implementing my ideas. Thanks again Link to comment Share on other sites More sharing options...
LarannKiar Posted July 10, 2022 Share Posted July 10, 2022 (edited) Oh hey thanks for replying and your effort!But i think you misunderstand my intentions, as i don´t want to make those weapons unplayable in general, but to make them require a certain strength level and/ or a specific perk to pick them up or transfer them into the inventory. But i think you are on the right way- would be awesome if you could refine this script by implementing my ideas. Thanks again Sorry I misunderstood it then. :smile: Here's an updated version. It drops the weapon from the Player's inventory if the Player doesn't have the required perk or the required S.P.E.C.I.A.L. stat with the minimum value. Scriptname YOURSCRIPTNAME extends ReferenceAlias Const Weapon[] Property HeavyWeapons Auto Const {Array of heavy weapons this script handles.} Perk Property RequiredPerk Auto Const {Required perk.} ActorValue Property RequiredSPECIALStat Auto Const {S.P.E.C.I.A.L. stats are Actor Values. Fill this property with a S.P.E.C.I.A.L. stat, e.g., Strength.} Int Property RequiredSPECIALStatValue Auto Const {Value of RequiredSPECIALStat. E.g., if RequiredSPECIALStat = Strength and RequiredSPECIALStatValue = 5, you would need to have at least 5 Strength to be able use a weapon from HeavyWeapons.} Event OnAliasInit() AddCustomInventoryEventFilters() EndEvent Function AddCustomInventoryEventFilters() RemoveAllInventoryEventFilters() Int Index While HeavyWeapons.Length > Index Weapon LoopWeapon = HeavyWeapons[Index] If LoopWeapon AddInventoryEventFilter(LoopWeapon) EndIf Index = Index + 1 EndWhile EndFunction Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as Weapon && HeavyWeapons.Find(akBaseItem as Weapon) >= 0 Actor PlayerRef = Game.GetPlayer() If PlayerRef.HasPerk(RequiredPerk) == 0 && PlayerRef.GetValue(RequiredSPECIALStat) >= RequiredSPECIALStatValue ; Player can use the weapon Else Int ItemCount = PlayerRef.GetItemCount(akBaseItem) PlayerRef.DropObject(akBaseItem, ItemCount) EndIf EndIf EndEvent Edited July 10, 2022 by LarannKiar Link to comment Share on other sites More sharing options...
Elementargewalt Posted July 10, 2022 Author Share Posted July 10, 2022 Thank you very much for the help- i will try it out! Link to comment Share on other sites More sharing options...
Recommended Posts