scn DecQuantumChanceScriptref NukaContainershort SpawnChanceshort PlayerLuckbegin OnOpen set NukaContainer to GetParentRef if IsActionRef player set PlayerLuck to player.GetAv Luck if PlayerLuck == 1 set SpawnChance to 0 elseif PlayerLuck == 2 set SpawnChance to 5 elseif PlayerLuck == 3 set SpawnChance to 10 elseif PlayerLuck == 4 set SpawnChance to 15 elseif PlayerLuck == 5 set SpawnChance to 20 elseif PlayerLuck == 6 set SpawnChance to 30 elseif PlayerLuck == 7 set SpawnChance to 45 elseif PlayerLuck == 8 set SpawnChance to 65 elseif PlayerLuck == 9 set SpawnChance to 90 elseif PlayerLuck == 10 set SpawnChance to 95 endif endif if GetRandomPercent <= SpawnChance NukaContainer.AddItem MS05NukaColaQtm 1 endifend
In the Object Window, I went World Objects > Container > Clutter > VendingMachine and then double-clicked NukaVendingMachine. I removed the "ClutterNukaColaQuantum10" from the Item List and attached the above script to the container so that each time the player opens an unopenedNuka-Cola vending machine, the script will trigger and calculate the spawn probability for a Quantum and spawn it if the random calculated probability is less than or equal to the ghost variable "SpawnChance" which depends on the player's luck attribute.
Also, as written in italics, I want the script to run only on unopened vending machines to emulate vanilla behavior where the vending machines never respawn.
Thanks in advance.