Jump to content

Trying to fix Treasury issue, rather minor


Recommended Posts

Just having an issue where the first piece of my treasury isn't disappearing. It's set up with 16 chests that are set as initially disabled, meaning they aren't visible. When I add more treasure, they appear one-by-one when you hit a set amount along with whatever treasure is connected to them. For some reason the very first chest isn't disappearing. I have it set to initially disabled, but it's not going away.

Here's the script i used for it, maybe the problem is there? It saved fine.

Scriptname EW_TreasuryScript extends ObjectReference

ObjectReference property Vaultloot01 auto
ObjectReference property Vaultloot02 auto
ObjectReference property Vaultloot03 auto
ObjectReference property Vaultloot04 auto
ObjectReference property Vaultloot05 auto
ObjectReference property Vaultloot06 auto
ObjectReference property VaultLoot07 auto
ObjectReference property VaultLoot08 auto
ObjectReference property VaultLoot09 auto
ObjectReference property Vaultloot10 auto
ObjectReference property Vaultloot11 auto
ObjectReference property Vaultloot12 auto
ObjectReference property Vaultloot13 auto
ObjectReference property Vaultloot14 auto
ObjectReference property Vaultloot15 auto
ObjectReference property Vaultloot16 auto

ObjectReference property GoldVault auto

MiscObject Property gold001 Auto
ObjectReference[] VaultLoot

Int[] MaxValue

int count = 0

Event OnInit()
    VaultLoot = new ObjectReference[16]
    VaultLoot[0] = Vaultloot01
    VaultLoot[1] = Vaultloot02
    VaultLoot[2] = Vaultloot03
    VaultLoot[3] = Vaultloot04
    VaultLoot[4] = Vaultloot05
    VaultLoot[5] = Vaultloot06
    VaultLoot[6] = Vaultloot07
    VaultLoot[7] = Vaultloot08
    VaultLoot[8] = Vaultloot09
    VaultLoot[9] = Vaultloot10
    VaultLoot[10] = Vaultloot11
    VaultLoot[11] = Vaultloot12
    VaultLoot[12] = Vaultloot13
    VaultLoot[13] = Vaultloot14
    VaultLoot[14] = Vaultloot15
    VaultLoot[15] = Vaultloot16

    MaxValue = new Int[16]
    MaxValue[0] = 999
    MaxValue[1] = 4999
    MaxValue[2] = 9999
    MaxValue[3] = 24999
    MaxValue[4] = 49999
    MaxValue[5] = 99999
    MaxValue[6] = 199999
    MaxValue[7] = 299999
    MaxValue[8] = 399999
    MaxValue[9] = 499999
    MaxValue[10] = 649999
    MaxValue[11] = 749999
    MaxValue[12] = 999999
    MaxValue[13] = 1249999
    MaxValue[14] = 1499999
    MaxValue[15] = 1999999
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If akBaseItem == gold001
        count += aiItemCount
        DisplayPiles(count)
    EndIf
Endevent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
    If akBaseItem == gold001
        count -= aiItemCount
        DisplayPiles(count)
    EndIf
Endevent

Function DisplayPiles(Int value)
    Int index = MaxValue.Length
    While index >= 0 
        ; scan from end to beginning (i.e. largest to smallest)
        index -= 1
        If (value > MaxValue[index])
            VaultLoot[index].enable()
        Else
            ; disable all other entries if previously enabled
            If VaultLoot[index].isEnabled()
                VaultLoot[index].disable()
            EndIf
        EndIf
    EndWhile
EndFunction


 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...