Skip to content

Commit

Permalink
Fixed bad loot drop import
Browse files Browse the repository at this point in the history
  • Loading branch information
thommcgrath committed Nov 13, 2023
1 parent 2c0bfed commit 2c0a040
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 133 deletions.
6 changes: 3 additions & 3 deletions Project/Beacon.xojo_project
Original file line number Diff line number Diff line change
Expand Up @@ -881,11 +881,11 @@ AppMenuBar=MainMenuBar
MajorVersion=2
MinorVersion=0
SubVersion=0
NonRelease=2
NonRelease=3
Release=2
InfoVersion=Beacon
LongVersion=Beacon 2.0.0b2 ©2016-2023 The ZAZ Studios
ShortVersion=2.0.0b2
LongVersion=Beacon 2.0.0b3 ©2016-2023 The ZAZ Studios
ShortVersion=2.0.0b3
WinCompanyName=The ZAZ Studios
WinInternalName=
WinProductName=Beacon
Expand Down
10 changes: 5 additions & 5 deletions Project/Modules/Game Support/Ark/Configs/LootDrops.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,18 @@ Implements Iterable
Continue
End If

Var Container As Ark.LootContainer
Var Override As Ark.LootDropOverride
Try
Container = Ark.LootContainer.ImportFromConfig(Dictionary(Member.ObjectValue), Difficulty, ContentPacks)
Override = Ark.LootDropOverride.ImportFromConfig(Dictionary(Member.ObjectValue), Difficulty, ContentPacks)
Catch Err As RuntimeException
App.Log(Err, CurrentMethodName, "Importing override from ini")
Continue
End Try

If Container Is Nil Then
If Override Is Nil Then
Continue
End If

LootDrops.Add(Container)
LootDrops.Add(Override)
Next
If LootDrops.Count > 0 Then
Return LootDrops
Expand Down
60 changes: 0 additions & 60 deletions Project/Modules/Game Support/Ark/LootContainer.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -322,66 +322,6 @@ Implements Ark.Blueprint,Beacon.Countable,Iterable,Beacon.Validateable,Beacon.Di
End Function
#tag EndMethod

#tag Method, Flags = &h0
Shared Function ImportFromConfig(Dict As Dictionary, Difficulty As Double, ContentPacks As Beacon.StringList) As Ark.LootContainer
Var ClassString As String
If Dict.HasKey("SupplyCrateClassString") Then
ClassString = Dict.Value("SupplyCrateClassString")
End If

Var Containers() As Ark.LootContainer = Ark.DataSource.Pool.Get(False).GetLootContainersByClass(ClassString, ContentPacks)
Var Container As Ark.MutableLootContainer
If Containers.Count > 0 Then
Container = New Ark.MutableLootContainer(Containers(0))
Else
Var Path As String = Ark.UnknownBlueprintPath("LootContainers", ClassString)
Var UUID As String = Beacon.UUID.v5(Ark.UserContentPackId.Lowercase + ":" + Path.Lowercase)
Var UIColor As String = Dict.Lookup("UIColor", "FFFFFF00")

Container = New Ark.MutableLootContainer(Path, UUID)
Container.Multipliers = New Beacon.Range(Dict.Lookup("Multiplier_Min", 1), Dict.Lookup("Multiplier_Max", 1))
Container.Availability = Ark.Maps.UniversalMask
Container.UIColor = Color.RGB(Integer.FromHex(UIColor.Middle(0, 2)), Integer.FromHex(UIColor.Middle(2, 2)), Integer.FromHex(UIColor.Middle(4, 2)), Integer.FromHex(UIColor.Middle(6, 2)))
Container.SortValue = Dict.Lookup("SortValue", 999).IntegerValue
Container.Label = Dict.Lookup("Label", ClassString).StringValue
Container.RequiredItemSetCount = Dict.Lookup("RequiredItemSets", 1).IntegerValue
Container.Experimental = Dict.Lookup("Experimental", False).BooleanValue
Container.Notes = Dict.Lookup("Notes", "").StringValue
Container.ContentPackId = Ark.UserContentPackId
End If

Var Children() As Dictionary
If Dict.HasKey("ItemSets") Then
Children = Dict.Value("ItemSets").DictionaryArrayValue
End If
Var AddedHashes As New Dictionary
For Each Child As Dictionary In Children
Var Set As Ark.LootItemSet = Ark.LootItemSet.ImportFromConfig(Child, Container.Multipliers, Difficulty, ContentPacks)
Var Hash As String = Set.Hash
If (Set Is Nil) = False And AddedHashes.HasKey(Hash) = False Then
Call Container.Add(Set)
AddedHashes.Value(Hash) = True
End If
Next

If Dict.HasKey("MaxItemSets") Then
Container.MaxItemSets = Dict.Value("MaxItemSets")
End If
If Dict.HasKey("MinItemSets") Then
Container.MinItemSets = Dict.Value("MinItemSets")
End If
If Dict.HasKey("bSetsRandomWithoutReplacement") Then
Container.PreventDuplicates = Dict.Value("bSetsRandomWithoutReplacement")
End If
If Dict.HasKey("bAppendItemSets") Then
Container.AppendMode = Dict.Value("bAppendItemSets")
End If

Container.Modified = False
Return Container
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function IndexOf(ItemSet As Ark.LootItemSet) As Integer
For Idx As Integer = 0 To Self.mItemSets.LastIndex
Expand Down
63 changes: 63 additions & 0 deletions Project/Modules/Game Support/Ark/LootDropOverride.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,69 @@ Implements Beacon.Validateable,Iterable,Beacon.Countable,Beacon.NamedItem,Beacon
End Function
#tag EndMethod

#tag Method, Flags = &h0
Shared Function ImportFromConfig(Dict As Dictionary, Difficulty As Double, ContentPacks As Beacon.StringList) As Ark.LootDropOverride
Var ClassString As String
If Dict.HasKey("SupplyCrateClassString") Then
ClassString = Dict.Value("SupplyCrateClassString")
End If

Var Containers() As Ark.LootContainer = Ark.DataSource.Pool.Get(False).GetLootContainersByClass(ClassString, ContentPacks)
Var Container As Ark.LootContainer
If Containers.Count > 0 Then
Container = Containers(0)
Else
Var Path As String = Ark.UnknownBlueprintPath("LootContainers", ClassString)
Var UUID As String = Beacon.UUID.v5(Ark.UserContentPackId.Lowercase + ":" + Path.Lowercase)
Var UIColor As String = Dict.Lookup("UIColor", "FFFFFF00")

Var Mutable As New Ark.MutableLootContainer(Path, UUID)
Mutable.Multipliers = New Beacon.Range(Dict.Lookup("Multiplier_Min", 1), Dict.Lookup("Multiplier_Max", 1))
Mutable.Availability = Ark.Maps.UniversalMask
Mutable.UIColor = Color.RGB(Integer.FromHex(UIColor.Middle(0, 2)), Integer.FromHex(UIColor.Middle(2, 2)), Integer.FromHex(UIColor.Middle(4, 2)), Integer.FromHex(UIColor.Middle(6, 2)))
Mutable.SortValue = Dict.Lookup("SortValue", 999).IntegerValue
Mutable.Label = Dict.Lookup("Label", ClassString).StringValue
Mutable.RequiredItemSetCount = Dict.Lookup("RequiredItemSets", 1).IntegerValue
Mutable.Experimental = Dict.Lookup("Experimental", False).BooleanValue
Mutable.Notes = Dict.Lookup("Notes", "").StringValue
Mutable.ContentPackId = Ark.UserContentPackId
Container = Mutable
End If

Var Override As New Ark.MutableLootDropOverride(Container)

Var Children() As Dictionary
If Dict.HasKey("ItemSets") Then
Children = Dict.Value("ItemSets").DictionaryArrayValue
End If
Var AddedHashes As New Dictionary
For Each Child As Dictionary In Children
Var Set As Ark.LootItemSet = Ark.LootItemSet.ImportFromConfig(Child, Container.Multipliers, Difficulty, ContentPacks)
Var Hash As String = Set.Hash
If (Set Is Nil) = False And AddedHashes.HasKey(Hash) = False Then
Override.Add(Set)
AddedHashes.Value(Hash) = True
End If
Next

If Dict.HasKey("MaxItemSets") Then
Override.MaxItemSets = Dict.Value("MaxItemSets")
End If
If Dict.HasKey("MinItemSets") Then
Override.MinItemSets = Dict.Value("MinItemSets")
End If
If Dict.HasKey("bSetsRandomWithoutReplacement") Then
Override.PreventDuplicates = Dict.Value("bSetsRandomWithoutReplacement")
End If
If Dict.HasKey("bAppendItemSets") Then
Override.AddToDefaults = Dict.Value("bAppendItemSets")
End If

Override.Modified = False
Return Override.ImmutableVersion
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function IndexOf(Set As Ark.LootItemSet) As Integer
If Set Is Nil Then
Expand Down
10 changes: 5 additions & 5 deletions Project/Modules/Game Support/ArkSA/Configs/LootDrops.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,18 @@ Implements Iterable
Continue
End If

Var Container As ArkSA.LootContainer
Var Override As ArkSA.LootDropOverride
Try
Container = ArkSA.LootContainer.ImportFromConfig(Dictionary(Member.ObjectValue), Difficulty, ContentPacks)
Override = ArkSA.LootDropOverride.ImportFromConfig(Dictionary(Member.ObjectValue), Difficulty, ContentPacks)
Catch Err As RuntimeException
App.Log(Err, CurrentMethodName, "Importing override from ini")
Continue
End Try

If Container Is Nil Then
If Override Is Nil Then
Continue
End If

LootDrops.Add(Container)
LootDrops.Add(Override)
Next
If LootDrops.Count > 0 Then
Return LootDrops
Expand Down
60 changes: 0 additions & 60 deletions Project/Modules/Game Support/ArkSA/LootContainer.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -322,66 +322,6 @@ Implements ArkSA.Blueprint,Beacon.Countable,Iterable,Beacon.Validateable,Beacon.
End Function
#tag EndMethod

#tag Method, Flags = &h0
Shared Function ImportFromConfig(Dict As Dictionary, Difficulty As Double, ContentPacks As Beacon.StringList) As ArkSA.LootContainer
Var ClassString As String
If Dict.HasKey("SupplyCrateClassString") Then
ClassString = Dict.Value("SupplyCrateClassString")
End If

Var Containers() As ArkSA.LootContainer = ArkSA.DataSource.Pool.Get(False).GetLootContainersByClass(ClassString, ContentPacks)
Var Container As ArkSA.MutableLootContainer
If Containers.Count > 0 Then
Container = New ArkSA.MutableLootContainer(Containers(0))
Else
Var Path As String = ArkSA.UnknownBlueprintPath("LootContainers", ClassString)
Var UUID As String = Beacon.UUID.v5(ArkSA.UserContentPackId.Lowercase + ":" + Path.Lowercase)
Var UIColor As String = Dict.Lookup("UIColor", "FFFFFF00")

Container = New ArkSA.MutableLootContainer(Path, UUID)
Container.Multipliers = New Beacon.Range(Dict.Lookup("Multiplier_Min", 1), Dict.Lookup("Multiplier_Max", 1))
Container.Availability = ArkSA.Maps.UniversalMask
Container.UIColor = Color.RGB(Integer.FromHex(UIColor.Middle(0, 2)), Integer.FromHex(UIColor.Middle(2, 2)), Integer.FromHex(UIColor.Middle(4, 2)), Integer.FromHex(UIColor.Middle(6, 2)))
Container.SortValue = Dict.Lookup("SortValue", 999).IntegerValue
Container.Label = Dict.Lookup("Label", ClassString).StringValue
Container.RequiredItemSetCount = Dict.Lookup("RequiredItemSets", 1).IntegerValue
Container.Experimental = Dict.Lookup("Experimental", False).BooleanValue
Container.Notes = Dict.Lookup("Notes", "").StringValue
Container.ContentPackId = ArkSA.UserContentPackId
End If

Var Children() As Dictionary
If Dict.HasKey("ItemSets") Then
Children = Dict.Value("ItemSets").DictionaryArrayValue
End If
Var AddedHashes As New Dictionary
For Each Child As Dictionary In Children
Var Set As ArkSA.LootItemSet = ArkSA.LootItemSet.ImportFromConfig(Child, Container.Multipliers, Difficulty, ContentPacks)
Var Hash As String = Set.Hash
If (Set Is Nil) = False And AddedHashes.HasKey(Hash) = False Then
Call Container.Add(Set)
AddedHashes.Value(Hash) = True
End If
Next

If Dict.HasKey("MaxItemSets") Then
Container.MaxItemSets = Dict.Value("MaxItemSets")
End If
If Dict.HasKey("MinItemSets") Then
Container.MinItemSets = Dict.Value("MinItemSets")
End If
If Dict.HasKey("bSetsRandomWithoutReplacement") Then
Container.PreventDuplicates = Dict.Value("bSetsRandomWithoutReplacement")
End If
If Dict.HasKey("bAppendItemSets") Then
Container.AppendMode = Dict.Value("bAppendItemSets")
End If

Container.Modified = False
Return Container
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function IndexOf(ItemSet As ArkSA.LootItemSet) As Integer
For Idx As Integer = 0 To Self.mItemSets.LastIndex
Expand Down
63 changes: 63 additions & 0 deletions Project/Modules/Game Support/ArkSA/LootDropOverride.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,69 @@ Implements Beacon.Validateable,Iterable,Beacon.Countable,Beacon.NamedItem,Beacon
End Function
#tag EndMethod

#tag Method, Flags = &h0
Shared Function ImportFromConfig(Dict As Dictionary, Difficulty As Double, ContentPacks As Beacon.StringList) As ArkSA.LootDropOverride
Var ClassString As String
If Dict.HasKey("SupplyCrateClassString") Then
ClassString = Dict.Value("SupplyCrateClassString")
End If

Var Containers() As ArkSA.LootContainer = ArkSA.DataSource.Pool.Get(False).GetLootContainersByClass(ClassString, ContentPacks)
Var Container As ArkSA.LootContainer
If Containers.Count > 0 Then
Container = Containers(0)
Else
Var Path As String = ArkSA.UnknownBlueprintPath("LootContainers", ClassString)
Var UUID As String = Beacon.UUID.v5(ArkSA.UserContentPackId.Lowercase + ":" + Path.Lowercase)
Var UIColor As String = Dict.Lookup("UIColor", "FFFFFF00")

Var Mutable As New ArkSA.MutableLootContainer(Path, UUID)
Mutable.Multipliers = New Beacon.Range(Dict.Lookup("Multiplier_Min", 1), Dict.Lookup("Multiplier_Max", 1))
Mutable.Availability = ArkSA.Maps.UniversalMask
Mutable.UIColor = Color.RGB(Integer.FromHex(UIColor.Middle(0, 2)), Integer.FromHex(UIColor.Middle(2, 2)), Integer.FromHex(UIColor.Middle(4, 2)), Integer.FromHex(UIColor.Middle(6, 2)))
Mutable.SortValue = Dict.Lookup("SortValue", 999).IntegerValue
Mutable.Label = Dict.Lookup("Label", ClassString).StringValue
Mutable.RequiredItemSetCount = Dict.Lookup("RequiredItemSets", 1).IntegerValue
Mutable.Experimental = Dict.Lookup("Experimental", False).BooleanValue
Mutable.Notes = Dict.Lookup("Notes", "").StringValue
Mutable.ContentPackId = ArkSA.UserContentPackId
Container = Mutable
End If

Var Override As New ArkSA.MutableLootDropOverride(Container)

Var Children() As Dictionary
If Dict.HasKey("ItemSets") Then
Children = Dict.Value("ItemSets").DictionaryArrayValue
End If
Var AddedHashes As New Dictionary
For Each Child As Dictionary In Children
Var Set As ArkSA.LootItemSet = ArkSA.LootItemSet.ImportFromConfig(Child, Container.Multipliers, Difficulty, ContentPacks)
Var Hash As String = Set.Hash
If (Set Is Nil) = False And AddedHashes.HasKey(Hash) = False Then
Override.Add(Set)
AddedHashes.Value(Hash) = True
End If
Next

If Dict.HasKey("MaxItemSets") Then
Override.MaxItemSets = Dict.Value("MaxItemSets")
End If
If Dict.HasKey("MinItemSets") Then
Override.MinItemSets = Dict.Value("MinItemSets")
End If
If Dict.HasKey("bSetsRandomWithoutReplacement") Then
Override.PreventDuplicates = Dict.Value("bSetsRandomWithoutReplacement")
End If
If Dict.HasKey("bAppendItemSets") Then
Override.AddToDefaults = Dict.Value("bAppendItemSets")
End If

Override.Modified = False
Return Override.ImmutableVersion
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function IndexOf(Set As ArkSA.LootItemSet) As Integer
If Set Is Nil Then
Expand Down

0 comments on commit 2c0a040

Please sign in to comment.