Tentacus Posted May 4, 2020 Posted May 4, 2020 I'm pretty demoralized. I got everything working great and rereleased the new and improved Scavvers closet then this afternoon realize there is a pretty serious bug. The mod is supposed to check against keywords when you pick up a weapon. If it finds none it randomly assigns one. In my testing this seemed to be working perfectly but the one thing I never did was console up a bunch of the same kind of guns and try one after the other. It seems that sometimes it treats guns with no keyword as if they are owned and even sometimes ones with the broken key words. It's bad enough that if you try enough times you will pick up all the broken keyworded guns. Also for some reason the problem guns can't be clicked on in the console. Any ideas: (I know this script is kind of a mess) Scriptname Tentacus:Scavvers_Closet:_T_PlayerInventory extends ReferenceAlias Actor Property PlayerRef Auto Armor Property ClothesEyeGlasses Auto Armor Property ClothesBlackRimGlasses Auto Armor Property InstM02LiamsGlasses Auto Bool property GunSkip Auto Bool Property ClothSkip Auto Bool Property Rename Auto ObjectReference Property Backpack Auto ObjectReference Property GunREF Auto ObjectReference Property ClothREF Auto FormList Property _T_BrokeAssGunsList Auto FormList Property _T_ClothingMasterList Auto FormList Property _T_DurableGunList Auto FormList Property _T_DirtyList Auto FormList Property _T_DressList Auto FormList Property _T_GlassesList Auto FormList Property _T_ImmortalGunList Auto FormList Property _T_MasterGunList Auto FormList Property _T_MyForms Auto FormList Property _T_NormalGunList Auto FormList Property _T_Bags Auto FormList Property _T_PistolList Auto FormList Property _T_LongGunList Auto FormList Property _T_HeavyGunList Auto FormList Property _T_ModClothesList Auto GlobalVariable Property _T_Nearsighted Auto GlobalVariable Property _T_ScavverMode Auto GlobalVariable Property _T_RimJob Auto GlobalVariable Property _T_Trading Auto GlobalVariable Property _T_WearItOut Auto GlobalVariable Property _T_NoCloud Auto GlobalVariable Property _T_HCcarry Auto GlobalVariable Property _T_NoPack Auto GlobalVariable Property _T_HasPack Auto GlobalVariable Property _T_PNoPack Auto GlobalVariable Property _T_PHasPack Auto GlobalVariable Property _T_RNoPack Auto GlobalVariable Property _T_RHasPack Auto GlobalVariable Property _T_ScavPacks Auto GlobalVariable Property _T_GunScavMode Auto GlobalVariable Property _T_HeavyMetal Auto GlobalVariable Property _T_MilMinMen Auto Keyword Property WorkshopContainerKeyword Auto Keyword Property _T_Busted Auto Keyword Property _T_Owned Auto Keyword Property _T_Roached Auto Location Property DiamondCityPlayerHouseLocation Auto Message Property _T_Rally1 Auto Message Property _T_Rally2 Auto Message Property _T_Pipes1 Auto Message Property _T_Pipes2 Auto Message Property _T_Pipes3 Auto Message Property _T_Pipes4 Auto MiscObject Property c_Cloth_scrap Auto MiscObject Property c_Leather_scrap Auto MiscObject Property c_Plastic_scrap Auto MiscObject Property c_Screws_scrap Auto MiscObject Property c_Steel_scrap Auto MiscObject Property c_Wood_scrap Auto MiscObject Property c_Adhesive_Scrap Auto MiscObject Property ScrewDriver01 Auto MiscObject Property _T_WeaponParts Auto MiscObject Property _T_UnfitClothes Auto Perk Property GunNut01 Auto Perk Property Scrapper01 Auto Sound Property _T_FShit Auto Sound Property _T_FYes Auto Sound Property _T_MShit Auto Sound Property _T_MYes Auto Sound Property WPNShotgunCombatReloadBoltClose Auto Sound Property WPNShotgunCombatReloadBoltOpen Auto Sound Property UIWorkshopModeItemPutDownCloth2Medium Auto Tentacus:Scavvers_Closet:_T_QuestScript Property _T_ClosetQuest Auto Event OnInit() AddInventoryEventFilter(_T_ClothingMasterList) AddInventoryEventFilter(_T_ModClothesList) AddInventoryEventFilter(_T_MasterGunList) AddInventoryEventFilter(_T_HeavyGunList) AddInventoryEventFilter(_T_GlassesList) AddInventoryEventFilter(_T_MyForms) AddInventoryEventFilter(_T_Bags) CheckForPlugins() Utility.Wait(1.0) Debug.Notification("Scavver's Closet Installed") RegisterForMenuOpenCloseEvent("BarterMenu") EndEvent Event OnPlayerLoadGame() AddInventoryEventFilter(_T_ClothingMasterList) AddInventoryEventFilter(_T_MasterGunList) AddInventoryEventFilter(_T_ModClothesList) AddInventoryEventFilter(_T_HeavyGunList) AddInventoryEventFilter(_T_GlassesList) AddInventoryEventFilter(_T_MyForms) AddInventoryEventFilter(_T_Bags) RegisterForMenuOpenCloseEvent("BarterMenu") CheckForPlugins() EndEvent Event OnMenuOpenCloseEvent(string asMenuName, bool abOpening) If (asMenuName == "BarterMenu") && (abOpening == True) _T_Trading.SetValue(1) Elseif (asMenuName == "BarterMenu") && (abOpening == False) _T_Trading.SetValue(0) Endif EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Int FitChance = Utility.RandomInt(0, 5) Int NBDBrokeChance = Utility.RandomInt(0,2) Int ScripChance = Utility.RandomInt(0, 3) Int NPval = _T_NoPack.GetValue() as Int Int HPval = _T_HasPack.GetValue() as Int Int PNPval = _T_PNoPack.GetValue() as Int Int PHPval = _T_PHasPack.GetValue() as Int Int RNPval = _T_RNoPack.GetValue() as Int Int RHPval = _T_RHasPack.GetValue() as Int Actorbase Player = PlayerRef.GetActorBase() Form PClothes = PlayerRef.GetWornItem(3).Item Utility.Wait(0.1) GunREF = AkBaseItem as ObjectReference If _T_HeavyMetal.GetValue() == 1 If _T_HeavyGunList.HasForm(akBaseItem) PlayerRef.EquipItem(akBaseItem) PlayerRef.DrawWeapon() StartTimer(0.5) EndIf Endif If _T_ScavverMode.GetValue() == 1 && _T_ModClothesList.HasForm(akBaseItem) If ClothSkip == True ClothSkip = False Else ClothREF = PlayerRef.DropObject(akBaseItem) If ClothREF.HasKeyword(_T_Owned) == 1 ClothREF.Disable() ClothSkip = True Utility.Wait(0.3) ClothREF.Delete() PlayerRef.Additem(ClothREF, 1, abSilent = true) Utility.Wait(1) Debug.Notification("You retrieve your clothing") Elseif ClothREF.HasKeyword(_T_Owned) == 0 && FitChance > 2 || _T_Trading.GetValue() == 1 ClothREF.AddKeyword(_T_Owned) ClothSkip = True Utility.Wait(0.1) ClothREF.Disable() Yes() Utility.Wait(0.3) ClothREF.Delete() PlayerRef.Additem(ClothREF, 1, abSilent = true) Utility.Wait(1) Debug.MessageBox("To your delight, the clothing fits you quite well!") Else ClothREF.Disable() PlayerRef.RemoveItem(akBaseItem, 1) Utility.Wait(0.1) ClothREF.Delete() Shit() PlayerRef.AddItem(_T_UnfitClothes, 1) Utility.Wait(0.1) Debug.MessageBox("The clothing doesn't fit you, but it's in good enough shape to sell or scrap.") Utility.Wait(0.3) Endif Endif Endif If _T_HeavyGunList.HasForm(akBaseItem) == 0 If _T_Bags.HasForm(akBaseItem) If Backpack.GetItemCount(_T_MyForms) > HPval -2 && PlayerRef.GetItemCount(_T_MyForms) > 1 && _T_HCcarry.GetValue() == 1 If (akSourceContainer != None) PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer) Else PlayerRef.DropObject(akBaseItem, aiItemCount) Endif Utility.Wait(0.1) Debug.MessageBox("Your backpack is already full, drop the clothing you are carrying!") Elseif Backpack.GetItemCount(_T_PistolList) > PHPval -2 && PlayerRef.GetItemCount(_T_PistolList) > 1 && _T_HCcarry.GetValue() == 1 If (akSourceContainer != None) PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer) Else PlayerRef.DropObject(akBaseItem, aiItemCount) Endif Utility.Wait(0.1) Debug.MessageBox("Your backpack is already full, drop the extra pistol you are carrying!") Elseif Backpack.GetItemCount(_T_LongGunList) > RHPval -2 && PlayerRef.GetItemCount(_T_LongGunList) > 1 && _T_HCcarry.GetValue() == 1 If (akSourceContainer != None) PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer) Else PlayerRef.DropObject(akBaseItem, aiItemCount) Endif Utility.Wait(0.1) Debug.MessageBox("Your backpack is already full, drop the extra Long gun you are carrying!") Elseif _T_HCcarry.GetValue() == 1 PlayerRef.EquipItem(akBaseItem) Endif Elseif _T_MyForms.HasForm(akBaseItem) If _T_HCcarry.GetValue() == 1 && PlayerRef.IsEquipped(_T_Bags) == 0 && PlayerRef.GetItemCount(_T_MyForms) > NPval If akSourceContainer != Backpack If akSourceContainer != None PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer) Else PlayerRef.DropObject(akBaseItem, aiItemCount) Endif Utility.Wait(0.1) Debug.MessageBox("You can't carry more clothing without a backpack!") Endif Elseif _T_HCcarry.GetValue() == 1 && PlayerRef.GetItemCount(_T_MyForms) > HPval If akSourceContainer != Backpack If (akSourceContainer != None) PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer) Else PlayerRef.DropObject(akBaseItem, aiItemCount) Endif Utility.Wait(0.1) Debug.MessageBox("Your backpack is awfully full, you can't cram more clothes in there.") Endif Endif Elseif _T_HCcarry.GetValue() == 1 && PlayerRef.IsEquipped(_T_Bags) == 0 && PlayerRef.GetItemCount(_T_PistolList) > PNPval If (akSourceContainer != None) PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer) Else PlayerRef.DropObject(akBaseItem, aiItemCount) Endif Utility.Wait(0.1) Debug.MessageBox("You can't carry more pistols without a backpack!") Elseif _T_HCcarry.GetValue() == 1 && PlayerRef.GetItemCount(_T_PistolList) > PHPval If (akSourceContainer != None) PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer) Else PlayerRef.DropObject(akBaseItem, aiItemCount) Endif Utility.Wait(0.1) Debug.MessageBox("Your backpack is awfully full, you can't cram more pistols in there.") Elseif _T_HCcarry.GetValue() == 1 && PlayerRef.IsEquipped(_T_Bags) == 0 && PlayerRef.GetItemCount(_T_LongGunList) > RNPval If (akSourceContainer != None) PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer) Else PlayerRef.DropObject(akBaseItem, aiItemCount) Endif Utility.Wait(0.1) Debug.MessageBox("You can't carry more Long guns without a backpack!") Elseif _T_HCcarry.GetValue() == 1 && PlayerRef.GetItemCount(_T_LongGunList) > RHPval If (akSourceContainer != None) PlayerRef.RemoveItem(akBaseItem, aiItemCount, false, akSourceContainer) Else PlayerRef.DropObject(akBaseItem, aiItemCount) Endif Utility.Wait(0.1) Debug.MessageBox("Your backpack is awfully full, you can't cram more Long guns in there.") Else If _T_GunScavMode.GetValue() == 1 If _T_MasterGunList.HasForm(akBaseItem) If GunSkip == True GunSkip = False Else GunREF = PlayerRef.DropObject(akBaseItem) If GunREF.HasKeyword(_T_Owned) == 1 GunREF.Disable() GunSkip = True Utility.Wait(0.3) GunREF.Delete() PlayerRef.Additem(GunREF, 1, abSilent = true) Utility.Wait(1) Debug.Notification("You retrieve your weapon") Elseif GunREF.HasKeyword(_T_Busted) == 1 Shit() Utility.Wait(0.1) If PlayerRef.HasPerk(GunNut01) == 0 && PlayerRef.GetItemCount(ScrewDriver01) == 0 Utility.Wait(1) Debug.Messagebox("The weapon is broken. \n\n Even if you had tools you wouldn't know what to do with them.") Elseif PlayerRef.HasPerk(GunNut01) == 1 && PlayerRef.GetItemCount(ScrewDriver01) == 0 Utility.Wait(1) Debug.Messagebox("The weapon is broken. \n \n You might be able to do something about that if only you had a screwdriver!") Elseif PlayerRef.HasPerk(GunNut01) == 1 && PlayerRef.GetItemCount(ScrewDriver01) == 1 Utility.Wait(1) RallyVincent() Endif Elseif GunREF.HasKeyword(_T_Roached) Int JunkChance = Utility.RandomInt(0,3) WPNShotgunCombatReloadBoltOpen.Play(PlayerRef) Utility.Wait(0.1) GunREF.Disable() GunREF.Delete() If JunkChance == 0 PlayerRef.AddItem(c_Wood_Scrap, 1) PlayerRef.AddItem(c_Adhesive_Scrap, 1) Elseif JunkChance == 1 PlayerRef.AddItem(c_Steel_Scrap, 1) PlayerRef.AddItem(c_Plastic_Scrap, 1) Elseif JunkChance == 2 PlayerRef.AddItem(c_Wood_Scrap, 1) PlayerRef.AddItem(c_Screws_Scrap, 1) Elseif JunkChance == 3 PlayerRef.AddItem(c_Wood_Scrap, 1) PlayerRef.AddItem(c_Steel_Scrap, 1) Endif Utility.Wait(0.1) Debug.Notification("you stripped the makeshift weapon for meager salvage") WPNShotgunCombatReloadBoltClose.Play(PlayerRef) Else If _T_BrokeAssGunsList.HasForm(akBaseItem) && _T_Trading.GetValue() == 0 Utility.Wait(1) LayinPipe() Elseif _T_ImmortalGunList.HasForm(akBaseItem) || _T_NormalGunList.HasForm(akBaseItem) && NBDBrokeChance == 1 || _T_DurableGunList.HasForm(akBaseItem) && NBDBrokeChance < 2 || _T_Trading.GetValue() == 1 GunREF.AddKeyword(_T_Owned) GunSkip = True Utility.Wait(0.1) GunREF.Disable() Yes() Utility.Wait(0.1) Debug.Messagebox("After examining the weapon it appears functional and safe to use") Utility.Wait(0.3) GunREF.Delete() PlayerRef.Additem(GunREF, 1, abSilent = true) Utility.Wait(1) Debug.Notification("You take your new weapon") Else GunREF.AddKeyword(_T_Busted) Shit() Utility.Wait(0.1) If PlayerRef.HasPerk(GunNut01) == 0 && PlayerRef.GetItemCount(ScrewDriver01) == 0 Utility.Wait(1) Debug.Messagebox("The weapon is broken. \n\n Even if you had tools you wouldn't know what to do with them.") Elseif PlayerRef.HasPerk(GunNut01) == 1 && PlayerRef.GetItemCount(ScrewDriver01) == 0 Utility.Wait(1) Debug.Messagebox("The weapon is broken. \n\n You might be able to do something about that if only you had a screwdriver!") Elseif PlayerRef.HasPerk(GunNut01) == 1 && PlayerRef.GetItemCount(ScrewDriver01) == 1 Utility.Wait(1) RallyVincent() Endif Endif Endif Endif Endif Endif If _T_ScavverMode.GetValue() == 1 && _T_ModClothesList.HasForm(akBaseItem) == 0 If _T_NearSighted.Getvalue() == 1 && _T_GlassesList.HasForm(akBaseItem) && akBaseItem != InstM02LiamsGlasses If ScripChance == 0 || _T_Trading.GetValue() == 1 PlayerRef.EquipItem(akBaseItem) Yes() Debug.MessageBox("To your delight, the perscription is very close to your own, and the lenses are even in decent shape!") ElseIf ScripChance == 1 && _T_Trading.GetValue() == 0 PlayerRef.EquipItem(akBaseItem) Yes() Debug.MessageBox("The perscription isn't perfect, but it's close enough. \n \n Headaches are a small price to pay for the gift of sight!") Elseif ScripChance == 2 && _T_Trading.GetValue() == 0 Shit() Debug.MessageBox("The perscription is too far off from your own, if anything it'll make your vision worse! \n \n You are able to salvage some screws and a bit of plastic though.") PlayerRef.RemoveItem(AkBaseItem) PlayerRef.AddItem(c_Screws_scrap, 2) PlayerRef.AddItem(c_Plastic_scrap, 1) Elseif ScripChance == 3 && _T_Trading.GetValue() == 0 Shit() Debug.MessageBox("Upon closer inspection you find that the lenses are smashed to bits, and the frame is badly bent! \n \n You are able to salvage some screws though.") PlayerRef.RemoveItem(AkBaseItem) PlayerRef.AddItem(c_Screws_scrap, 2) Endif Elseif _T_NearSighted.Getvalue() == 1 && akBaseItem == InstM02LiamsGlasses Yes() If ScripChance < 2 Debug.MessageBox("To your delight, the perscription is very close to your own, and the lenses are even in decent shape!") Else Debug.MessageBox("The perscription isn't perfect, but it's close enough. \n \n Headaches are a small price to pay for the gift of sight!") Endif Else If _T_GlassesList.HasForm(akBaseItem) == 0 && _T_ClothingMasterList.HasForm(akBaseItem) == 1 If _T_NoCloud.GetValue() == 1 && _T_DressList.HasForm(akBaseItem) == 1 Utility.Wait(0.3) _T_ClosetQuest.SellClothes() Utility.Wait(0.3) Yes() Utility.Wait(0.1) Debug.MessageBox("You wouldn't be caught dead wearing something like this, but it might be worth something.") Else If FitChance == 0 || _T_Trading.GetValue() == 1 If _T_Trading.GetValue() == 0 WeCantSeeEm() Endif PlayerRef.EquipItem(akBaseItem) Utility.Wait(0.3) _T_ClosetQuest.MyClothes() Utility.Wait(0.3) Yes() Utility.Wait(0.1) Debug.MessageBox("To your delight, the clothing fits you quite well!") Utility.Wait(0.1) If _T_WearItOut.GetValue() == 0 PlayerRef.EquipItem(PClothes, abSilent = True) Endif Elseif FitChance == 1 || FitChance > 1 && _T_DirtyList.HasForm(akBaseItem) == 0 && _T_Trading.GetValue() == 0 || FitChance > 3 && _T_Trading.GetValue() == 0 WeCantSeeEm() PlayerRef.UnequipItem(PClothes) Utility.Wait(0.3) PlayerRef.EquipItem(akBaseItem) Utility.Wait(0.3) _T_ClosetQuest.SellClothes() Utility.Wait(0.3) Shit() Utility.Wait(0.1) Debug.MessageBox("The clothing doesn't fit you, but it's in good enough shape to sell or scrap.") Utility.Wait(0.3) PlayerRef.EquipItem(PClothes) Elseif FitChance == 2 && _T_Trading.GetValue() == 0 && _T_DirtyList.HasForm(akBaseItem) == 1 Shit() PlayerRef.RemoveItem(akBaseItem, 1) Utility.Wait(0.1) Debug.MessageBox("As you attempt to try the clothing on it tears at the seams! \n \n It's too damaged to be of any use.") ItsShoeTime() Elseif FitChance == 3 && _T_Trading.GetValue() == 0 && _T_DirtyList.HasForm(akBaseItem) == 1 Shit() PlayerRef.RemoveItem(akBaseItem, 1) Utility.Wait(0.1) Debug.MessageBox("As you inspect the clothing you find it badly soiled and giving off a repugnant odor! \n \n It's of no use to you.") ItsShoeTime() Endif Endif Endif Endif Endif Endif Endif EndEvent Event OnTimer(int aiTimerID) If _T_HeavyMetal.GetValue() == 1 Form Piece = PlayerRef.GetEquippedWeapon() as Form If _T_HeavyGunList.HasForm(Piece) If PlayerRef.IsWeaponDrawn() == False PlayerRef.DropObject(Piece) EndIf StartTimer(0.5) Endif Endif EndEvent Event OnItemUnequipped(Form akBaseObject, ObjectReference akReference) Form PClothes = PlayerRef.GetWornItem(3).Item Weapon Piece = PlayerRef.GetEquippedWeapon() If _T_Bags.HasForm(akBaseObject) && _T_HCcarry.GetValue() == 1 UIWorkshopModeItemPutDownCloth2Medium.Play(PlayerRef) Utility.Wait(0.2) Debug.Messagebox("Close your pipboy") PlayerRef.DropObject(akBaseObject) PlayerRef.EquipItem(PClothes, True, True) WPNShotgunCombatReloadBoltClose.Play(PlayerRef) Utility.Wait(0.1) PlayerRef.RemoveItem(_T_MyForms, -1, True, Backpack) PlayerRef.RemoveItem(_T_MasterGunList, -1, True, Backpack) Utility.Wait(0.1) Backpack.RemoveItem(PClothes, 1, True) UIWorkshopModeItemPutDownCloth2Medium.Play(PlayerRef) Utility.Wait(0.2) PlayerRef.EquipItem(PClothes, False, True) WPNShotgunCombatReloadBoltClose.Play(PlayerRef) Elseif _T_HeavyGunList.HasForm(akBaseObject) && _T_HeavyMetal.GetValue() == 1 PlayerRef.DropObject(akBaseObject) Endif endEvent Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) Form PClothes = PlayerRef.GetWornItem(3).Item Utility.Wait(0.1) If _T_Bags.HasForm(akBaseObject) Utility.Wait(0.1) Backpack.RemoveItem(_T_MyForms, -1, True, PlayerRef) Backpack.RemoveItem(_T_MasterGunList, -1, True, PlayerRef) WPNShotgunCombatReloadBoltClose.Play(PlayerRef) Utility.Wait(0.2) UIWorkshopModeItemPutDownCloth2Medium.Play(PlayerRef) Utility.Wait(0.2) WPNShotgunCombatReloadBoltClose.Play(PlayerRef) Endif endEvent Function ItsShoeTime() Int ShoeChance = Utility.RandomInt(0, 6) Int LineChance = Utility.RandomInt(0, 1) Armor Shoes = Game.GetFormFromFile(0x0000088D, "Commonweath Vans.esp") as Armor Utility.Wait(0.3) If Game.IsPluginInstalled("Commonweath Vans.esp") If ShoeChance == 0 Shit() Utility.Wait(0.1) Debug.MessageBox("The shoes are in better condition but are much too big for your feet.") Elseif ShoeChance == 1 Shit() Utility.Wait(0.1) Debug.MessageBox("The shoes are in better condition but are much too small for your feet.") Elseif ShoeChance == 2 Yes() Utility.Wait(0.1) If LineChance == 0 Debug.MessageBox("The shoes are in better condition and fit you well enough.") Else Debug.MessageBox("The shoes are in better condition and fit you perfectly!") Endif PlayerRef.AddItem(Shoes, 1) Endif Endif EndFunction Function WeCantSeeEm() Int DorkChance = Utility.RandomInt(0, 6) Int FrameChance = Utility.RandomInt(0, 1) If _T_Nearsighted.GetValue() == 1 If DorkChance < 3 Utility.Wait(0.1) Debug.MessageBox("You found some glasses while inspecting the clothes!") Utility.Wait(0.3) If _T_RimJob.GetValue() == 1 If FrameChance == 0 PlayerRef.AddItem(ClothesEyeGlasses, 1) Else PlayerRef.AddItem(ClothesBlackRimGlasses, 1) Endif Else PlayerRef.AddItem(ClothesEyeGlasses, 1) Endif Utility.Wait(0.3) Endif Endif EndFunction Function Yes() Int Psex = PlayerRef.GetActorBase().GetSex() If Psex == 0 _T_MYes.Play(PlayerRef) Else _T_FYes.Play(PlayerRef) EndIf EndFunction Function Shit() Int Psex = PlayerRef.GetActorBase().GetSex() If Psex == 0 _T_MShit.Play(PlayerRef) Else _T_FShit.Play(PlayerRef) EndIf EndFunction Function CheckForPlugins() Armor Bag1 = Game.GetFormFromFile(0x00000FB0, "Scavver's Backpacks.esp") as Armor Armor Bag2 = Game.GetFormFromFile(0x000035DC, "Scavver's Backpacks.esp") as Armor Armor Bag3 = Game.GetFormFromFile(0x0000F5BE, "MilitarizedMinutemen.esp") as Armor Armor MMUni = Game.GetFormFromFile(0x00000F9A, "MilitarizedMinutemen.esp") as Armor If Game.IsPluginInstalled("Scavver's Backpacks.esp") == True If _T_ScavPacks.GetValue() == 0 Utility.Wait(0.1) _T_Bags.AddForm(Bag1) Utility.Wait(0.1) _T_Bags.AddForm(Bag2) Utility.Wait(2) Debug.Notification("Scavvers Backpacks added to Scavver's Closet") _T_ScavPacks.SetValue(1) Endif Else If _T_ScavPacks.GetValue() == 1 Utility.Wait(0.1) _T_Bags.RemoveAddedForm(Bag1) Utility.Wait(0.1) _T_Bags.RemoveAddedForm(Bag1) Utility.Wait(2) Debug.MessageBox("WARNING! \n \n Scavvers Backpacks NOT FOUND! \n \n Backpacks removed from Scavver's Closet") _T_ScavPacks.SetValue(0) Endif Endif If Game.IsPluginInstalled("MilitarizedMinutemen.esp") == True If _T_MilMinMen.GetValue() == 0 _T_Bags.AddForm(Bag3) _T_ModClothesList.AddForm(MMUni) _T_MyForms.AddForm(MMUni) Debug.Notification("Militarized Minutemen added to Scavver's Closet") _T_MilMinMen.SetValue(1) Endif Else If _T_MilMinMen.GetValue() == 1 _T_Bags.RemoveAddedForm(Bag3) _T_ModClothesList.RemoveAddedForm(MMUni) _T_ModClothesList.RemoveAddedForm(MMUni) Debug.MessageBox("WARNING! \n \n Militarized Minutemen NOT FOUND! \n \n Backpacks removed from Scavver's Closet") _T_MilMinMen.SetValue(0) Endif Endif EndFunction Function RallyVincent() If PlayerRef.GetItemCount(_T_WeaponParts) < 3 && PlayerRef.GetItemCount(c_Screws_scrap) < 4 WPNShotgunCombatReloadBoltOpen.Play(PlayerRef) Utility.Wait(0.1) Int iButton = _T_Rally1.Show() ; Shows your menu. If iButton == 0 ;Strip broken gun GunREF.Disable() GunREF.Delete() PlayerRef.AddItem(_T_WeaponParts, 1) If PlayerRef.HasPerk(Scrapper01) PlayerRef.AddItem(c_Screws_scrap, 2) Endif Endif Utility.Wait(0.1) WPNShotgunCombatReloadBoltClose.Play(PlayerRef) Else Int iButton = _T_Rally2.Show() If iButton == 0 ;fix broken gun WPNShotgunCombatReloadBoltOpen.Play(PlayerRef) Utility.Wait(0.1) GunREF.RemoveKeyword(_T_Busted) GunREF.AddKeyword(_T_Owned) GunSkip = True Utility.Wait(0.1) GunREF.Disable() Yes() Utility.Wait(0.3) GunREF.Delete() PlayerRef.Additem(GunREF, 1, abSilent = true) Utility.Wait(1) Debug.Notification("You take your newly repaired weapon") Elseif iButton == 1 ;Strip broken gun GunREF.Disable() GunREF.Delete() PlayerRef.AddItem(_T_WeaponParts, 1) If PlayerRef.HasPerk(Scrapper01) PlayerRef.AddItem(c_Screws_scrap, 2) Endif Endif Utility.Wait(0.1) WPNShotgunCombatReloadBoltClose.Play(PlayerRef) Endif EndFunction Function LayinPipe() Int BABrokeChance = Utility.RandomInt(0,6) Int JunkChance = Utility.RandomInt(0,3) Message PipinHawt = _T_Pipes1 If BABrokeChance == 1 GunREF.AddKeyword(_T_Owned) GunSkip = True Utility.Wait(0.1) GunREF.Disable() Yes() Debug.MessageBox("To your shock the shoddy looking homemade gun seems like it will fire.") Utility.Wait(0.3) GunREF.Delete() PlayerRef.Additem(GunREF, 1, abSilent = true) Utility.Wait(1) Debug.Notification("You take your newly repaired weapon") Else GunREF.AddKeyword(_T_Roached) Shit() Utility.Wait(0.1) If BABrokeChance == 0 || BABrokeChance == 6 PipinHawt = _T_Pipes1 Elseif BABrokeChance == 2 || BABrokeChance == 5 PipinHawt = _T_Pipes2 Elseif BABrokeChance == 3 PipinHawt = _T_Pipes3 Elseif BABrokeChance == 4 PipinHawt = _T_Pipes4 Endif Int pButton = PipinHawt.Show() If pButton == 0 WPNShotgunCombatReloadBoltOpen.Play(PlayerRef) Utility.Wait(0.1) GunREF.Disable() GunREF.Delete() If JunkChance == 0 PlayerRef.AddItem(c_Wood_Scrap, 1) PlayerRef.AddItem(c_Adhesive_Scrap, 1) Elseif JunkChance == 1 PlayerRef.AddItem(c_Steel_Scrap, 1) PlayerRef.AddItem(c_Plastic_Scrap, 1) Elseif JunkChance == 2 PlayerRef.AddItem(c_Wood_Scrap, 1) PlayerRef.AddItem(c_Screws_Scrap, 1) Elseif JunkChance == 3 PlayerRef.AddItem(c_Wood_Scrap, 1) PlayerRef.AddItem(c_Steel_Scrap, 1) Endif Utility.Wait(0.1) WPNShotgunCombatReloadBoltClose.Play(PlayerRef) Endif EndIf EndFunction And yes it does the same with the _T_ModClotheslist items that's actually how I found the bug as I was working on that.
EgoBallistic Posted May 4, 2020 Posted May 4, 2020 5 hours ago, Tentacus said: In my testing this seemed to be working perfectly but the one thing I never did was console up a bunch of the same kind of guns and try one after the other. It seems that sometimes it treats guns with no keyword as if they are owned and even sometimes ones with the broken key words. If I understand correctly, when the player picks up a weapon, you DropObject() it to get an ObjectReference, then check it for keywords, add keywords if it has none, then put it back in inventory. If so, you have to handle the fact that if the player's inventory contains more than one of akBaseObject, calling DropObject(akBaseObject) will pick one from the inventory at random. There is no guarantee that the dropped item will be the one that was just picked up.
Tentacus Posted May 4, 2020 Posted May 4, 2020 4 hours ago, EgoBallistic said: If I understand correctly, when the player picks up a weapon, you DropObject() it to get an ObjectReference, then check it for keywords, add keywords if it has none, then put it back in inventory. If so, you have to handle the fact that if the player's inventory contains more than one of akBaseObject, calling DropObject(akBaseObject) will pick one from the inventory at random. There is no guarantee that the dropped item will be the one that was just picked up. I think I understand. This could help a lot. Thanks.
Tentacus Posted May 5, 2020 Posted May 5, 2020 16 hours ago, EgoBallistic said: If I understand correctly, when the player picks up a weapon, you DropObject() it to get an ObjectReference, then check it for keywords, add keywords if it has none, then put it back in inventory. If so, you have to handle the fact that if the player's inventory contains more than one of akBaseObject, calling DropObject(akBaseObject) will pick one from the inventory at random. There is no guarantee that the dropped item will be the one that was just picked up. Okay I am struggling with this. Any ideas?
EgoBallistic Posted May 5, 2020 Posted May 5, 2020 8 hours ago, Tentacus said: Okay I am struggling with this. Any ideas? Here's an OnItemAdded event that does a basic version of what you want to do. It puts a keyword on each item picked up to indicate it is owned by the player. If you pick up an item you've never had in your inventory, it will say "You picked up a new XYZ". If you drop an item and pick it back up it will say "You picked up your XYZ". How it works: when the player picks up an akBaseItem, we place a hidden container, and transfer all of akBaseItem from the player to the container. Then we drop each item from the container and check it for a keyword. If we don't find the keyword, we know it's a new object, so we add the keyword and do whatever else we need. Then we add the item back to the player. Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) RemoveAllInventoryEventFilters() Container TmpContainer = Game.GetFormFromFile(0x02BDE8, "Fallout4.esm") as Container ObjectReference TmpContainerRef = PlayerRef.PlaceAtMe(TmpContainer, abForcePersist = false, abInitiallyDisabled = true, abDeleteWhenAble = true) PlayerRef.RemoveItem(akBaseItem, -1, true, TmpContainerRef) Bool FoundNew = False While TmpContainerRef.GetItemCount(akBaseItem) ObjectReference DroppedObject = TmpContainerRef.DropObject(akBaseItem,1) DroppedObject.Disable() If !DroppedObject.HasKeyword(OwnedKeyword) DroppedObject.AddKeyword(OwnedKeyword) FoundNew = True Debug.Notification("You picked up a new " + DroppedObject.GetDisplayName()) EndIf PlayerRef.AddItem(DroppedObject, abSilent=True) EndWhile If !FoundNew Debug.Notification("You picked up your " + akBaseItem.GetName()) EndIf AddInventoryEventFilter(ObjectTypeWeapon) EndEvent As awful as this sounds, it's actually pretty quick and efficient. And using a container allows us to drop and pick up items without spamming "Item Added" messages.
Tentacus Posted May 5, 2020 Posted May 5, 2020 3 hours ago, EgoBallistic said: Here's an OnItemAdded event that does a basic version of what you want to do. It puts a keyword on each item picked up to indicate it is owned by the player. If you pick up an item you've never had in your inventory, it will say "You picked up a new XYZ". If you drop an item and pick it back up it will say "You picked up your XYZ". How it works: when the player picks up an akBaseItem, we place a hidden container, and transfer all of akBaseItem from the player to the container. Then we drop each item from the container and check it for a keyword. If we don't find the keyword, we know it's a new object, so we add the keyword and do whatever else we need. Then we add the item back to the player. Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) RemoveAllInventoryEventFilters() Container TmpContainer = Game.GetFormFromFile(0x02BDE8, "Fallout4.esm") as Container ObjectReference TmpContainerRef = PlayerRef.PlaceAtMe(TmpContainer, abForcePersist = false, abInitiallyDisabled = true, abDeleteWhenAble = true) PlayerRef.RemoveItem(akBaseItem, -1, true, TmpContainerRef) Bool FoundNew = False While TmpContainerRef.GetItemCount(akBaseItem) ObjectReference DroppedObject = TmpContainerRef.DropObject(akBaseItem,1) DroppedObject.Disable() If !DroppedObject.HasKeyword(OwnedKeyword) DroppedObject.AddKeyword(OwnedKeyword) FoundNew = True Debug.Notification("You picked up a new " + DroppedObject.GetDisplayName()) EndIf PlayerRef.AddItem(DroppedObject, abSilent=True) EndWhile If !FoundNew Debug.Notification("You picked up your " + akBaseItem.GetName()) EndIf AddInventoryEventFilter(ObjectTypeWeapon) EndEvent As awful as this sounds, it's actually pretty quick and efficient. And using a container allows us to drop and pick up items without spamming "Item Added" messages. You are the fucking best man. I thought about something like this but had no idea how to actually accomplish it. I tried like 6 solutions yesterday. One of them required 10x this much code and didn't even fully work. Edit: This contains the dreaded "while" which I still don't understand how to use so never think of
EgoBallistic Posted May 5, 2020 Posted May 5, 2020 4 hours ago, Tentacus said: Edit: This contains the dreaded "while" which I still don't understand how to use so never think of A While like an If that loops until the condition being tested for is false. The code I posted above boils down to Transfer items from player to container While (there are items in container) Drop one item from container Do something with the dropped item EndWhile Which you can think of as Transfer items from player to container If (there are items in container) Drop one item from container Do something with the dropped item Go back to the If and check it again EndIf If we transferred no items, then the code won't run because the condition isn't true. If we transferred one item, it will run once, then the container will be empty so it stops. And so on.
antoniut Posted May 8, 2020 Posted May 8, 2020 I'm going to try to do my first mod and I have a couple of dumb questions about the scripts folder organization, I've been watching how other mods are organized but I don't see a clear pattern First question: Is it mandatory that some scripts must go in the root folder of the scripts folder or can they all go in the folder let's say namespace? Second question: If I create my own namespace, will the scripts fragments go in the fragments folder, or will they go in the namespace fragments folder? Thank you
Carabosse Posted May 8, 2020 Posted May 8, 2020 Using a namespace is nicer when it comes to deploying your mod, or backing it up etc. I always use namespaces. Some mods you've looked at might be editing existing scripts that live in the root folder. Afaik there is no requirement for new scripts to ever be placed in the root scripts folder. Your namespace folder will have a subfolder called fragments and any script fragments (assuming you're using the namespace*) will be placed in the relevant sub folder of that fragments folder (Packages, Perks, Quests, Scenes, Terminals, TopicInfos etc). *There's a setting under scripts in preferences where you can assign a default namespace. 1
Carabosse Posted May 8, 2020 Posted May 8, 2020 @antoniut There's some useful information about scripts here. 1
antoniut Posted May 8, 2020 Posted May 8, 2020 15 minutes ago, Carabosse said: @antoniut There's some useful information about scripts here. Thanks for direct link, sometimes is difficult to find the needed information through the search function on that page.
Tentacus Posted May 8, 2020 Posted May 8, 2020 I've got another problem. Everything @EgoBallistic helped me with is working Dandy, but It appears that the keywords added to weapons won't remain after a load. So I figured I'd just do this: Event OnPlayerLoadGame() RegisterForMenuOpenCloseEvent("BarterMenu") CheckForPlugins() RemoveAllInventoryEventFilters() Container TmpContainer = Game.GetFormFromFile(0x02BDE8, "Fallout4.esm") as Container ObjectReference TmpContainerRef = PlayerRef.PlaceAtMe(TmpContainer, abForcePersist = false, abInitiallyDisabled = True, abDeleteWhenAble = True) PlayerRef.RemoveItem(ObjectTypeWeapon, -1, true, TmpContainerRef) Utility.Wait(1.0) ;Start the loop While TmpContainerRef.GetItemCount(ObjectTypeWeapon) ObjectReference DroppedObject = TmpContainerRef.DropObject(ObjectTypeWeapon, 1) DroppedObject.Disable() DroppedObject.AddKeyword(_T_Owned) PlayerRef.AddItem(DroppedObject, abSilent=True) EndWhile AddInventoryEventFilter(_T_ClothingMasterList) AddInventoryEventFilter(_T_MasterGunList) AddInventoryEventFilter(_T_HeavyGunList) AddInventoryEventFilter(_T_GlassesList) AddInventoryEventFilter(_T_MyForms) AddInventoryEventFilter(_T_Bags) EndEvent Any idea why this is not working? It removes the weapn from but it never drops it from the container. Edit: I think I figured it out, it's because I'm trying to call DropObject() on a non form property. I think I can get around this by using an on removed event and a bool.
EgoBallistic Posted May 8, 2020 Posted May 8, 2020 44 minutes ago, Tentacus said: Any idea why this is not working? It removes the weapn from but it never drops it from the container. I looked at your code and nothing jumped out at me. But It turns out DropObject() requires a base object, it doesn't work on keywords. Fortunately, you can do this instead: ObjectReference DroppedObject = TmpContainerRef.DropFirstObject() This makes the container drop whatever the "first" item is in its inventory, so the While loop will make it do that until it is empty. Fortunately the only things it can possibly contain are the weapons you transferred to it, so that is fine. Did I ever mention that the inventory system in this game is comically terrible?
Tentacus Posted May 8, 2020 Posted May 8, 2020 29 minutes ago, EgoBallistic said: I looked at your code and nothing jumped out at me. But It turns out DropObject() requires a base object, it doesn't work on keywords. Fortunately, you can do this instead: ObjectReference DroppedObject = TmpContainerRef.DropFirstObject() This makes the container drop whatever the "first" item is in its inventory, so the While loop will make it do that until it is empty. Fortunately the only things it can possibly contain are the weapons you transferred to it, so that is fine. Did I ever mention that the inventory system in this game is comically terrible? I am discovering that. Thanks I'll try it. EDIT: It worked, Thanks.
antoniut Posted May 8, 2020 Posted May 8, 2020 Another noob question, please. I'm trying to make a little mod, AAF integrated, firing AAF animations, dialogue based. The goal NPC, will be always a vanilla companion, in this case, Piper. Question is: it is "secure" to use the alias "Piper" in the Quest Aliases Tab, pointing at "Unique Actor" "CompanionPiper", like the ref alias in vanilla quests like ComPiper or ComPiperTalk, in the scripts? Thanks and sorry for the dumb question
Carabosse Posted May 8, 2020 Posted May 8, 2020 50 minutes ago, antoniut said: Another noob question, please. I'm trying to make a little mod, AAF integrated, firing AAF animations, dialogue based. The goal NPC, will be always a vanilla companion, in this case, Piper. Question is: it is "secure" to use the alias "Piper" in the Quest Aliases Tab, pointing at "Unique Actor" "CompanionPiper", like the ref alias in vanilla quests like ComPiper or ComPiperTalk, in the scripts? Thanks and sorry for the dumb question Yes. It's good practice to follow the examples set out by Bethesda. Mimicking their methods as much as possible. The alias system exists to allow efficient sharing of resources. Something else that might be useful for you in future is using the external alias option. Whereby you can inherit aliases from other quests. So for example, pointing your alias to match the companion alias in the followers quest would assign the current companion of the player whoever that might be. 1
antoniut Posted May 10, 2020 Posted May 10, 2020 Hi. I am on my personal crusade to try to make a mod. (Why haven't I decided to learn to play the flute?). I think the most important thing first, is to lay the foundations of the mod in my head well and one of the things that worries me the most, is that the mod should have the necessary "technology" to be able to self-update in a way clean and safe. That, I think it would help me a lot when testing the mod, without always having to start from scratch, since there will be quests and dialogues. I have been looking in the Creation Kit, the various mods that are available here that have this "technology", and there is none that is the same as another. One hooks the startup script to the player's actor alias, in the startup quest. Another, hook the startup script into the startup quest script tab, and so on ... I honestly have tried but can't find any information about it. Is there a method we can say "this is the good one"? Thanks
DocClox Posted May 10, 2020 Posted May 10, 2020 4 minutes ago, antoniut said: Is there a method we can say "this is the good one"? Well, the "good one" is to use the OnPLayerLoadGame event. Only that's only ever received by the player's Actor object, and it's bad form to edit that directly. So in the days of Skyrim, that mean it was pretty much always the same thing: defined an alias for the player, hand a script on the alias, and since the alias gets all the events the actor does, have the alias process the event. Now with Fallout 4, you can subscribe to events on other objects, so it doesn't have to be a player alias any more. Consequently some people think it makes more sense to have the processing on a quest ... and really it's all good. Best practice is to use the OnPlayerLoadGame event, and how you choose to catch it or process it is pretty much up to you. Hope that's helpful.
antoniut Posted May 10, 2020 Posted May 10, 2020 @DocClox I will study for several hours the advice you have given me … ??? Thanks
antoniut Posted May 15, 2020 Posted May 15, 2020 I've already managed to shoot AAF animations via dialogue, without audio yet, in the little personal mod I'm trying to do. Nice. Now I'm thinking of how to make it possible for the partner to "bother" the player from time to time with his personal needs like "I'm hungry", thirsty, sleepy, and so on. But I don't want (I'm not ready to do that) to do anything very complex: stomachs, bladders ... no Just emulate it. I have some ideas of how to do it more or less, but I don't know what would be the best option to avoid future problems. If the partner is momentarily dismissed, and is not with the player for a time, and so on. Long time hungry, thirst, sleep and so on spells (hours), gametimers, cooldowns, player cloak spells? Dunno I need some advice. Any idea or suggestion in this regard will be very welcome. Thanks in advance
antoniut Posted May 22, 2020 Posted May 22, 2020 I'm thinking of a way to get Piper to start a meal animation, anywhere, stool, table, and so meet his food needs. Am I on the right track? ReferenceAlias Property Piper Auto Const Function RegisterEvents() Actor PiperEat = Piper.GetActorRef() RegisterForAnimationEvent(PiperEat, "IdleEatStart") EndFunction Event OnAnimationEvent(ObjectReference akSource, string asEventName) Actor PiperEat = Piper.GetActorRef() if (akSource == PiperEat) && (asEventName == "IdleEatStart") Debug.Trace("Piper is eating!") endIf endEvent I have already discovered that the event "OnAnimationEvent" cannot be applied to "ReferenceAlias", it must be applied to an object, in this case "Actor". Can the code be optimized? Thanks
DocClox Posted May 22, 2020 Posted May 22, 2020 4 minutes ago, antoniut said: I'm thinking of a way to get Piper to start a meal animation, anywhere, stool, table, and so meet his food needs. Am I on the right track? Wait so ... you want to make Piper run eating animations? Or you want to detect when she does eat and run some code. What you posted looks OK for the second case, but what you described sounds like you want the first, if that makes sense.
antoniut Posted May 22, 2020 Posted May 22, 2020 12 minutes ago, DocClox said: Wait so ... you want to make Piper run eating animations? Or you want to detect when she does eat and run some code. In fact, both things (language problems...). But at the moment, the second one, which seems to be the easiest. The first, to eat anywhere, at the moment I am just investigating it.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now