ChestAmmo Gallery Glitched

hi @lilplumbo , @Flak

Verse and loot chests - Development / Programming & Scripting - Epic Developer Community Forums

There is a Verse program that makes custom chests which in Verse seems like a good template for Epic Engineers looking into this. My Verse skills are limited.

This would solve the seasonal problem of Chest having limited weapons

originally

RNG Update! (Custom Chests 2.0) : r/FortniteCreative

here is the Verse code extracted from paste bin


 
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Simulation/Tags }
using { Meshes }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/Diagnostics }
 
ChestTag := class(tag):
ChestContainerTag := class(tag):
 
Custom_Chests := class(creative_device):
    @editable
    Shell_guns: item_spawner_device = item_spawner_device:
    @editable
    Shells: item_spawner_device = item_spawner_device:
    @editable
    Shell_Guns_Chance: type{_X : int where 0 <= _X, _X < 100 } = 1
    @editable
    Med_Guns: item_spawner_device = item_spawner_device:
    @editable
    Med_Bullets: item_spawner_device = item_spawner_device:
    @editable
    Med_Guns_Chance: type{_X : int where 0 <= _X, _X < 100} = 1
    @editable
    Light_Guns: item_spawner_device = item_spawner_device:
    @editable
    Light_Bullets: item_spawner_device = item_spawner_device:
    @editable
    Light_Guns_Chance: type{_X : int where 0 <= _X, _X < 100} = 1
    @editable
    Heavy_Guns: item_spawner_device = item_spawner_device:
    @editable
    Heavy_Bullets: item_spawner_device = item_spawner_device:
    @editable
    Heavy_Guns_Chance: type{_X : int where 0 <= _X, _X < 100} = 1
    @editable
    Explosive_Guns: item_spawner_device = item_spawner_device:
    @editable
    Rockets: item_spawner_device = item_spawner_device:
    @editable
    Explosive_Guns_Chance: type{_X : int where 0 <= _X, _X < 100} = 1
    @editable
    Bows: item_spawner_device = item_spawner_device:
    @editable
    Arrows: item_spawner_device = item_spawner_device:
    @editable
    Bows_Chance: type{_X : int where 0 <= _X, _X < 100} = 1
    @editable
    No_Ammo_Guns: item_spawner_device = item_spawner_device:
    @editable
    No_Ammo_Guns_Chance: type{_X : int where 0 <= _X, _X < 100} = 1
    @editable
    Consumables: item_spawner_device = item_spawner_device:
    @editable
    Resources: item_spawner_device = item_spawner_device:
    var ContainerIndex : []int = array{}
    var ContainerOpen : []logic = array{}
    var ContainerArray : []creative_prop = array{}
    var ButtonIndex : []int = array{}
    var ButtonArray : []button_device = array{}
    var count : int = 0
    var countcont : int = 0
    var RNGcount : int = 0
    var loopcount : int = 0
    var RNGPool : []int = array{}
 
    OnBegin<override>()<suspends>:void=
        TaggedList := GetCreativeObjectsWithTag(ChestTag{})
        for (Index -> TaggedActor : TaggedList):
            if (Prop := button_device[TaggedActor]):
                set ButtonArray = ButtonArray + array{Prop} 
                set ButtonIndex = ButtonIndex + array{count}
                set count = count + 1
 
        set count = 0
        TaggedListC := GetCreativeObjectsWithTag(ChestContainerTag{})
        for (Index -> TaggedActors : TaggedListC):
            if(Prop := creative_prop[TaggedActors]):
                set ContainerArray = ContainerArray + array{Prop}
                set ContainerIndex = ContainerIndex + array{count}
                set ContainerOpen = ContainerOpen + array{false}
                set count = count + 1
            else:
        set count = 0
        spawn{SetRNG()}
        IdentifyChest()
        IdentifyChestContainer()
 
    SetRNG()<suspends>:void=
        loop:
            if (RNGcount < Shell_Guns_Chance):
                set RNGPool = RNGPool + array{1}
                set RNGcount = RNGcount + 1
            else:
                set RNGcount = 0
                break
        loop:
            if (RNGcount < Med_Guns_Chance):
                set RNGPool = RNGPool + array{2}
                set RNGcount = RNGcount + 1
            else:
                set RNGcount = 0
                break
        loop:
            if (RNGcount < Light_Guns_Chance):
                set RNGPool = RNGPool + array{3}
                set RNGcount = RNGcount + 1
            else:
                set RNGcount = 0
                break
        loop:
            if (RNGcount < Heavy_Guns_Chance):
                set RNGPool = RNGPool + array{4}
                set RNGcount = RNGcount + 1
            else:
                set RNGcount = 0
                break
        loop:
            if (RNGcount < Explosive_Guns_Chance):
                set RNGPool = RNGPool + array{5}
                set RNGcount = RNGcount + 1
            else:
                set RNGcount = 0
                break
        loop:
            if (RNGcount < Bows_Chance):
                set RNGPool = RNGPool + array{6}
                set RNGcount = RNGcount + 1
            else:
                set RNGcount = 0
                break
        loop:
            if (RNGcount < No_Ammo_Guns_Chance):
                set RNGPool = RNGPool + array{7}
                set RNGcount = RNGcount + 1
            else:
                set RNGcount = 0
                break
        loop:
            if(RNGcount < RNGPool.Length):
                 set RNGcount = RNGcount + 1
            else:
                break
 
 
    IdentifyChest():void=
        for(i:ButtonIndex):
            index := i
            if(Chest := ButtonArray[count]):
             Chest.InteractedWithEvent.SubscribeAgent(SpawnLoot, index)
         set count = count + 1
     set count = 0
 
    IdentifyChestContainer():void=
        for(i:ContainerIndex):
            index := i
            if(Chest := ContainerArray[count]):
             spawn{SpawnLootContainer(Chest, index)}
         set count = count + 1
     set count = 0
 
    SpawnLoot(Wgent : agent, ChestID : int):void=
        if( ChestPos := ButtonArray[ChestID].GetTransform()):
            for(i:ContainerIndex):
                index := i
                if (ContainerArray[count].GetTransform().Translation.X = ChestPos.Translation.X and ContainerArray[count].GetTransform().Translation.Y = ChestPos.Translation.Y and ContainerArray[count].GetTransform().Translation.Z = ChestPos.Translation.Z):
                    MatchingContainer := count
                    if(ContainerArray[MatchingContainer].SetMesh(Box_Open)):
                        if(set ContainerOpen[MatchingContainer] = true):
                else:
                    set count = count + 1
            set count = 0
            var RandomInt : int = GetRandomInt(0,RNGPool.Length - 1)
                if(RNGPool[RandomInt] = 1):
                    if(Shell_guns.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Shell_guns.SpawnItem()
                    if(Shells.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Shells.SpawnItem()
 
                if(RNGPool[RandomInt] = 2):
                    if(Med_Guns.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Med_Guns.SpawnItem()
                    if(Med_Bullets.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Med_Bullets.SpawnItem()
 
                if(RNGPool[RandomInt] = 3):
                    if(Light_Guns.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Light_Guns.SpawnItem()
                    if(Light_Bullets.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Light_Bullets.SpawnItem()
 
                if(RNGPool[RandomInt] = 4):
                    if(Heavy_Guns.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Heavy_Guns.SpawnItem()
                    if(Heavy_Bullets.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Heavy_Bullets.SpawnItem()
 
                if(RNGPool[RandomInt] = 5):
                    if(Explosive_Guns.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Explosive_Guns.SpawnItem()
                    if(Rockets.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Rockets.SpawnItem()
 
                if(RNGPool[RandomInt] = 6):
                    if(Bows.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Bows.SpawnItem()
                    if(Arrows.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        Arrows.SpawnItem()
 
                if(RNGPool[RandomInt] = 7):
                    if(No_Ammo_Guns.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                        No_Ammo_Guns.SpawnItem()
 
                if(Consumables.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                    Consumables.SpawnItem()
 
                if(Resources.TeleportTo[ChestPos.Translation,ChestPos.Rotation]):
                    Resources.SpawnItem()
                set count = 0
    SpawnLootContainer(Chest : creative_prop, Count : int)<suspends>:void=
        ContainerPos := Chest.GetTransform()
         for(i:ButtonIndex):
            index := i
            if (ButtonArray[countcont].GetTransform().Translation.X = ContainerPos.Translation.X and ButtonArray[countcont].GetTransform().Translation.Y = ContainerPos.Translation.Y and ButtonArray[countcont].GetTransform().Translation.Z = ContainerPos.Translation.Z):
                if(MatchingButton := ButtonArray[countcont]):
                 MatchingButtonPos := MatchingButton.GetTransform()
                 var RandomInt : int = GetRandomInt(0,RNGPool.Length - 1)
                 loop: 
                    if(ContainerOpen[Count] = false):
                        if(Chest.IsDisposed[]):
                            MatchingButton.Disable()
 
                                    if(RNGPool[RandomInt] = 1):
                                        if(Shell_guns.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Shell_guns.SpawnItem()
                                        if(Shells.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Shells.SpawnItem()
 
                                    if(RNGPool[RandomInt] = 2):
                                        if(Med_Guns.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Med_Guns.SpawnItem()
                                        if(Med_Bullets.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Med_Bullets.SpawnItem()
 
                                    if(RNGPool[RandomInt] = 3):
                                        if(Light_Guns.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Light_Guns.SpawnItem()
                                        if(Light_Bullets.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Light_Bullets.SpawnItem()
 
                                    if(RNGPool[RandomInt] = 4):
                                        if(Heavy_Guns.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Heavy_Guns.SpawnItem()
                                        if(Heavy_Bullets.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Heavy_Bullets.SpawnItem()
 
                                    if(RNGPool[RandomInt] = 5):
                                        if(Explosive_Guns.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Explosive_Guns.SpawnItem()
                                        if(Rockets.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Rockets.SpawnItem()
 
                                    if(RNGPool[RandomInt] = 6):
                                        if(Bows.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Bows.SpawnItem()
                                        if(Arrows.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            Arrows.SpawnItem()
 
                                    if(RNGPool[RandomInt] = 7):
                                        if(No_Ammo_Guns.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                            No_Ammo_Guns.SpawnItem()
 
                                    if(Consumables.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                        Consumables.SpawnItem()
 
                                    if(Resources.TeleportTo[ContainerPos.Translation,ContainerPos.Rotation]):
                                        Resources.SpawnItem()
                                    break
 
                        else:
                            Sleep(0.3)
                    else:
                        break
            else:
                set countcont = countcont + 1
 
(Listenable : listenable(agent)).SubscribeAgent(OutputFunc : tuple(agent, t)->void, ExtraData : t where t:type) : cancelable =
    Wrapper := wrapper_agent(t){ExtraData := ExtraData, OutputFunc := OutputFunc}
    Listenable.Subscribe(Wrapper.InputFunc)
 
wrapper_agent(t : type) := class():
    ExtraData : t;
    OutputFunc : tuple(agent, t) -> void
    InputFunc(Agent : agent):void = OutputFunc(Agent, ExtraData)