Any tips on how to improve the code?

I am looking for and will gladly accept any code critic, suggestions for improvement and advice on what direction to take. At the moment Verse is my first language and I started learning it from the moment it was released.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Random }
using {SFX_Module}
using {HUD_Module}
using {XP_Module}

ChestLevelSettings := class<concrete>:

    @editable Conditional : conditional_button_device = conditional_button_device{}
    @editable Name : string = "Level 1"
    @editable Default : float = 80.0
    @editable Rare : float = 10.0
    @editable Legendary : float = 5.0
    @editable NumberOfDefaultGrant : int = 1
    @editable NumberOfRareGrant : int = 1
    @editable NumberOfLegendaryGrant : int = 1
    @editable DamagedTimesForGrant : int = 3
    @editable Name0 : string = "item name 0"
    @editable Cost0 : int = 10
    @editable Name1 : string = "item name 1"
    @editable Cost1 : int = 20
    @editable Name2 : string = "item name 2"
    @editable Cost2 : int = 30

ResourceChestController := class(creative_device):

    @editable UpgradeButton : button_device = button_device{}
    @editable Manipulator : prop_manipulator_device = prop_manipulator_device{}
    @editable UpgradeDialog : popup_dialog_device = popup_dialog_device{}
    @editable DialogDescription : string = "Upgrade Chest Description"
    @editable DialogBuyDescription : string = "Upgrade Chest Description"
    @editable ButtonText : []string = array{}
    @editable Spawners : []item_spawner_device = array{}
    @editable LevelSettings : []ChestLevelSettings = array{}
    var ChestLevel : int = 0
    var ChestActivated : logic = false
    var DamagedAmount : int = 0

    OnBegin<override>()<suspends>:void=
        Sleep(1.0)
        Init()

    Init<private>():void=
        UpgradeButton.InteractedWithEvent.Subscribe(OpenDialog)
        Manipulator.DamagedEvent.Subscribe(ChestDamaged)
        UpgradeDialog.RespondingButtonEvent.Subscribe(DialogAnswer)
        for(Level : LevelSettings):
            Level.Conditional.ActivatedEvent.Subscribe(SuccessEvent)
            Level.Conditional.NotEnoughItemsEvent.Subscribe(NotEnoughItem)
        SetCurrentCost()
        ApplyDialogInformation()
        Print("Init passed")

    OpenDialog<private>(Agent : agent):void=
        UpgradeDialog.Show(Agent)

    DialogAnswer<private>(Data : tuple(agent, int)):void=
        Print("Answer")
        if(Data(1) = 0, Conditional := LevelSettings[ChestLevel].Conditional):
            Print("Upgrade Chest")
            Conditional.Activate(Data(0))

    SuccessEvent<private>(Agent : agent):void=
        set ChestLevel += 1
        Print("Chest upgraded {ChestLevel}, {LevelSettings.Length}")
        ApplyDialogInformation()
        if(ChestLevel = LevelSettings.Length):
            Print("Max Level reached")
            ApplyMaxLevelDialogInformation()
        ChestUpgradeSFX(Agent)
        ShowHUDTop(Agent, "</><Intro>You have successfully upgraded your chest to {ChestLevel}", 5.0)

    NotEnoughItem<private>(Agent : agent):void=
        Print("Not Enough item for upgrade")
        NotEnoughItemSFX(Agent)
        ShowHUDTop(Agent, "</><Enemy>You don't have enough items to improve...", 5.0)

    ApplyDialogInformation():void=
        if:
            ItemName0 := LevelSettings[ChestLevel].Name0
            ItemCost0 := LevelSettings[ChestLevel].Cost0
            ItemName1 := LevelSettings[ChestLevel].Name1
            ItemCost1 := LevelSettings[ChestLevel].Cost1
            ItemName2 := LevelSettings[ChestLevel].Name2
            ItemCost2 := LevelSettings[ChestLevel].Cost2
        then:
            UpgradeDialog.SetDescriptionText(ToMessage("{DialogDescription}\rChest Level: {ChestLevel}\rUpgradeCost:\r{ItemCost0} {ItemName0}\r{ItemCost1} {ItemName1}\r{ItemCost2} {ItemName2}"))

    ApplyMaxLevelDialogInformation():void=
        Print("Apply Max level Information")
        if:
            DefaultChance := Int[LevelSettings[ChestLevel - 1].Default]
            RareChance := Int[LevelSettings[ChestLevel - 1].Rare]
            LegendaryChance := Int[LevelSettings[ChestLevel - 1].Legendary]
        then:
            UpgradeDialog.SetDescriptionText(ToMessage("Chest reached maximum level!\rDefault Item: {DefaultChance} %\rRare item: {RareChance} %\rLegendaryItem: {LegendaryChance} % "))
            UpgradeDialog.SetButtonCount(1)
            UpgradeDialog.SetButtonText(ToMessage("Exit"), 0)
        else:
            Print("Couldn't find level")

    SetCurrentCost<private>():void=
        for(I -> Level :LevelSettings):
            if:
                ItemCost0 := LevelSettings[I].Cost0
                ItemCost1 := LevelSettings[I].Cost1
                ItemCost2 := LevelSettings[I].Cost2
            then:
                Level.Conditional.SetItemCountRequired(0, ItemCost0)
                Level.Conditional.SetItemCountRequired(1, ItemCost1)
                Level.Conditional.SetItemCountRequired(2, ItemCost2)
                ###Print("Set conditional cost passed {ItemCost0}")

####
    ChestDamaged<private>(Agent : agent):void=
        Print("Chest Damaged")
        set DamagedAmount += 1
        if(DamagedTimesForGrant := LevelSettings[ChestLevel].DamagedTimesForGrant):
            if(DamagedAmount = DamagedTimesForGrant):
                Print("Grant Item")
                set DamagedAmount = 0
                CalculateChances(Agent)

    CalculateChances<private>(Agent : agent):void=
        if:
            DefaultChance := LevelSettings[ChestLevel].Default
            RareChance := LevelSettings[ChestLevel].Rare
            LegendaryChance := LevelSettings[ChestLevel].Legendary

            NumberOfDefaultGrant := LevelSettings[ChestLevel].NumberOfDefaultGrant
            NumberOfRareGrant := LevelSettings[ChestLevel].NumberOfRareGrant
            NumberOfLegendaryGrant := LevelSettings[ChestLevel].NumberOfLegendaryGrant

            DefaultSpawner := Spawners[0]
            RareSpawner := Spawners[1]
            LegendarySpawner := Spawners[2]
        then:
            RandomNumber := GetRandomFloat(0.0, 100.0)
            if(RandomNumber <= DefaultChance):
                Print("Grant Default item")
                for(I := 0..NumberOfDefaultGrant):
                    DefaultSpawner.SpawnItem()
            if(RandomNumber <= RareChance):
                Print("Grant Rare item")
                for(I := 0..NumberOfRareGrant):
                    RareSpawner.SpawnItem()
            if(RandomNumber <= LegendaryChance):
                Print("Grant Legendary item")
                for(I := 0..NumberOfLegendaryGrant):
                    LegendarySpawner.SpawnItem()

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Simulation/Tags }
using { /Verse.org/Random }
using {Quest_Module}
using {HUD_Module}
using {SFX_Module}
using {XP_Module}

QuestRarirySettings := enum{None, Default, Rare, Legendary}

GranterSettings := struct<concrete>:

    @editable Default : item_granter_device = item_granter_device{}
    @editable Rare : item_granter_device = item_granter_device{}
    @editable Legendary : item_granter_device = item_granter_device{}

QuestBaseSettings := class<concrete>:

    @editable Name : string = ""
    @editable Description : string = ""
    @editable Tracker : tracker_device = tracker_device{}
    @editable AchievementSwitch : switch_device = switch_device{}
    @editable XP : float = 10.0
    @editable Target : int = 1
    @editable StartQuest : logic = false
    @editable RewardRarity : QuestRarirySettings = QuestRarirySettings.Default
    @editable ShowMessage : logic = false
    var ID : int = 0
    var RewardRarityName : string = ""
    var MaybeGranters : ?GranterSettings = false

    Init<internal>():void=
        Tracker.SetTitleText(ToMessage(Name))
        Tracker.SetDescriptionText(ToMessage(Description))
        Tracker.SetTarget(Target)
        Tracker.CompleteEvent.Subscribe(CompleteEvent)
        if(StartQuest?):
            Tracker.AssignToAll()
        SetQuestRewardName()

    Assign<public>(Agent : agent):void=
        if(GetPlayerQuestAmount[Agent] < GetMaxQuestPerPlayer[]):
            QuestAcceptSFX(Agent)
            Tracker.Assign(Agent)
            IncreasePlayerQuestAmount(Agent)
            AddQuestToCompletedMap(Agent, ID)
            ShowHUDTop(Agent, "</><Heist>You have received a quest </><Intro>{Name}", 5.0)
        else ShowHUDTop(Agent, "</><Enemy>You have many accepted quests.</>\r<Enemy>Complete existing ones.", 5.0)

    CompleteEvent<private>(Agent : agent):void=
        Print("{Name} quest completed")
        DecreasePlayerQuestAmount(Agent)
        AchievementSwitch.TurnOn(Agent)
        AddXP(Agent, XP)
        QuestCompleteSFX(Agent)
        GrantItem(Agent)
        if(ShowMessage?):
            ShowHUDTop(Agent, "Quest </><Ally>{Name}</><Score> is complete!</>\r<Score>You received the {RewardRarityName}", 5.0)

    GrantItem<private>(Agent : agent):void=
        if(Granters := MaybeGranters?):
            if(RewardRarity = QuestRarirySettings.Default, Granter := Granters.Default):
                Print("Default Reward")
                Granter.CycleToRandomItem(Agent)
            else if(RewardRarity = QuestRarirySettings.Rare, Granter := Granters.Rare):
                Print("Rare Reward")
                Granter.CycleToRandomItem(Agent)
            else if(RewardRarity = QuestRarirySettings.Legendary, Granter := Granters.Legendary):
                Print("Legendary Reward")
                Granter.CycleToRandomItem(Agent)

    SetQuestRewardName<private>():void=
        if(RewardRarity = QuestRarirySettings.Default):
            set RewardRarityName = "Default reward"
        else if(RewardRarity = QuestRarirySettings.Rare):
            set RewardRarityName = "Rare reward"
        else if(RewardRarity = QuestRarirySettings.Legendary):
            set RewardRarityName = "Legendary reward"


QuestBoardSettings := class<concrete>:

    @editable DialogButton : button_device = button_device{}
    @editable Dialog : popup_dialog_device = popup_dialog_device{}
    @editable QuestCountToShow : int = 3
    @editable DialogDescription : string = "You can take the quest you need. For its completion you will receive a reward depending on the level of the quest."
    @editable NotQuestDialogDescription : string = "You have completed all the quests!"
    var Opened : logic = false
    var AvalaibleQuests : []int = array{}

    Init<internal>():void=
        DialogButton.InteractedWithEvent.Subscribe(OpenDialog)
        Dialog.DismissedEvent.Subscribe(DialogClosedEvent)
        Dialog.RespondingButtonEvent.Subscribe(DialogAnswer)
        Dialog.SetButtonCount(QuestCountToShow + 1)
        Dialog.SetButtonText(ToMessage("Exit"), QuestCountToShow)
        Dialog.SetDescriptionText(ToMessage(DialogDescription))

    OpenDialog<private>(Agent : agent):void=
        set Opened = true
        SetupDialog(Agent)
        spawn {Sleep(Agent)}

    Sleep(Agent : agent)<suspends>:void=
        CheckButtons()
        Sleep(1.0)
        Dialog.Show(Agent)
        
    DialogClosedEvent<private>(Agent : agent):void=
        set Opened = false
        Print("Dialog closed")
        CheckButtons()
        set AvalaibleQuests = array{}

    DialogAnswer<private>(Data : tuple(agent, int)):void=
        if(QuestID := AvalaibleQuests[Data(1)], Data(1) < QuestCountToShow):
            AssignQuest(Data(0), QuestID)
            
    SetupDialog<private>(Agent : agent):void=
        GetAvalaibleQuest(Agent)
        for(I := 0..QuestCountToShow - 1):
            if:
                AllQuests := GetAllQuests[]
                Element := AvalaibleQuests[I]
                QuestName := AllQuests[Element].Name
            then:
                Dialog.SetButtonText(ToMessage(QuestName), I)

    GetAvalaibleQuest<private>(Agent : agent):void=
        var QuestArray : []int = array{}
        if(AllQuests := GetAllQuests[], CompletedQuest := GetPlayerCompletedQuest[Agent]):
            Print("Get")
            for(I -> Quest : AllQuests):
                if(not CompletedQuest.Find[I]):
                    Print("Quest not completed")
                    set QuestArray += array{I}

            set AvalaibleQuests = Shuffle(QuestArray)

    CheckButtons<private>():void=
        Print("Buttons")
        if(AvalaibleQuests.Length < QuestCountToShow):
            Dialog.SetButtonCount(AvalaibleQuests.Length + 1)
            Dialog.SetButtonText(ToMessage("Exit"), AvalaibleQuests.Length)
            if(AvalaibleQuests.Length = 0):
                Dialog.SetDescriptionText(ToMessage(NotQuestDialogDescription))


QuestController := class(creative_device):

    @editable Quests : []QuestBaseSettings = array{}
    @editable Granters : GranterSettings = GranterSettings{}
    @editable QuestBoard : QuestBoardSettings = QuestBoardSettings{}
    @editable MaxQuestPerPlayer : int = 2
    var PlayerQuestAmountMap : [player]int = map{}
    var PlayerCompletedQuestMap : [player][]int = map{}

    OnBegin<override>()<suspends>:void=
        Init()

    Init<private>():void=
        for(Player : GetPlayspace().GetPlayers()):
            AddToQuestAmountMap(Player)
        GetPlayspace().PlayerAddedEvent().Subscribe(AddToQuestAmountMap)
        for(I -> Quest : Quests):
            set Quest.MaybeGranters = option{Granters}
            Quest.Init()
            set Quest.ID = I
        QuestBoard.Init()

    AddToQuestAmountMap<private>(Agent : agent):void=
        if(set PlayerQuestAmountMap[player[Agent]] = 0):
            Print("Player add to Quest amount map")
        if(set PlayerCompletedQuestMap[player[Agent]] = array{}):
            Print("Set Completed Quest Map")