Skip to content

Commit

Permalink
Fixed a number of embarrassing bugs with mod loot drop and spawn poin…
Browse files Browse the repository at this point in the history
…t content editing.
  • Loading branch information
thommcgrath committed Apr 18, 2024
1 parent 9bbabf3 commit 6852253
Show file tree
Hide file tree
Showing 51 changed files with 297 additions and 162 deletions.
16 changes: 8 additions & 8 deletions Project/Modules/Game Support/Ark.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Protected Module Ark

Var Engrams(), Creatures(), SpawnPoints(), LootDrops() As Dictionary
For Each Blueprint As Ark.Blueprint In Blueprints
Var Packed As Dictionary = Blueprint.Pack
Var Packed As Dictionary = Blueprint.Pack(False)
If Packed Is Nil Then
Continue
End If
Expand Down Expand Up @@ -269,7 +269,7 @@ Protected Module Ark
Return False
End If

Var Packed As Dictionary = Source.Pack
Var Packed As Dictionary = Source.Pack(False)
Return Destination.CopyFrom(Packed)
End Function
#tag EndMethod
Expand Down Expand Up @@ -486,9 +486,9 @@ Protected Module Ark
#tag Method, Flags = &h0
Function Hash(Extends Blueprint As Ark.Blueprint) As String
#if DebugBuild
Return Beacon.GenerateJSON(Ark.PackBlueprint(Blueprint), True)
Return Beacon.GenerateJSON(Ark.PackBlueprint(Blueprint, False), True)
#else
Return EncodeHex(Crypto.SHA1(Beacon.GenerateJSON(Ark.PackBlueprint(Blueprint), False))).Lowercase
Return EncodeHex(Crypto.SHA1(Beacon.GenerateJSON(Ark.PackBlueprint(Blueprint, False), False))).Lowercase
#endif
End Function
#tag EndMethod
Expand Down Expand Up @@ -694,13 +694,13 @@ Protected Module Ark
#tag EndMethod

#tag Method, Flags = &h0
Function Pack(Extends Blueprint As Ark.Blueprint) As Dictionary
Return PackBlueprint(Blueprint)
Function Pack(Extends Blueprint As Ark.Blueprint, ForAPI As Boolean) As Dictionary
Return PackBlueprint(Blueprint, ForAPI)
End Function
#tag EndMethod

#tag Method, Flags = &h1
Protected Function PackBlueprint(Blueprint As Ark.Blueprint) As Dictionary
Protected Function PackBlueprint(Blueprint As Ark.Blueprint, ForAPI As Boolean) As Dictionary
Var Dict As New Dictionary
Var IdProperty As String

Expand Down Expand Up @@ -733,7 +733,7 @@ Protected Module Ark
Dict.Value("contentPackName") = Blueprint.ContentPackName

// Let the blueprint add whatever additional data it needs
Blueprint.Pack(Dict)
Blueprint.Pack(Dict, ForAPI)

Return Dict
End Function
Expand Down
2 changes: 1 addition & 1 deletion Project/Modules/Game Support/Ark/Blueprint.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Implements Beacon.NamedItem
#tag EndMethod

#tag Method, Flags = &h0
Sub Pack(Dict As Dictionary)
Sub Pack(Dict As Dictionary, ForAPI As Boolean)

End Sub
#tag EndMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ Inherits Ark.ConfigGroup

For Idx As Integer = 0 To Self.mOverrides.LastIndex
If Self.mOverrides(Idx).SpawnPointId = SpawnPoint.SpawnPointId And Self.mOverrides(Idx).Mode = Mode Then
Self.mOverrides(Idx) = New Ark.SpawnPointOverride(SpawnPoint, Mode)
Self.mOverrides(Idx) = New Ark.SpawnPointOverride(SpawnPoint, Mode, False)
Self.Modified = True
Return
End If
Next

Self.mOverrides.Add(New Ark.SpawnPointOverride(SpawnPoint, Mode))
Self.mOverrides.Add(New Ark.SpawnPointOverride(SpawnPoint, Mode, False))
Self.Modified = True
End Sub
#tag EndMethod
Expand Down Expand Up @@ -446,7 +446,7 @@ Inherits Ark.ConfigGroup
Var ClassString As String = Dict.Value("NPCSpawnEntriesContainerClassString")
Var SpawnPointRef As New Ark.BlueprintReference(Ark.BlueprintReference.KindSpawnPoint, "", "", ClassString, "", "")
Var SpawnPoint As Ark.SpawnPoint = Ark.SpawnPoint(SpawnPointRef.Resolve(ContentPacks))
Var Override As New Ark.MutableSpawnPointOverride(SpawnPoint, Mode)
Var Override As New Ark.MutableSpawnPointOverride(SpawnPoint, Mode, False)

// make changes
If Dict.HasKey("NPCSpawnEntries") Then
Expand Down
2 changes: 1 addition & 1 deletion Project/Modules/Game Support/Ark/CraftingCost.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Implements Beacon.NamedItem
Function Export() As Dictionary
Var Ingredients() As Dictionary
For Idx As Integer = 0 To Self.mIngredients.LastIndex
Var Resource As Dictionary = Self.mIngredients(Idx).SaveData
Var Resource As Dictionary = Self.mIngredients(Idx).SaveData(False)
If (Resource Is Nil) = False Then
Ingredients.Add(Resource)
End If
Expand Down
20 changes: 7 additions & 13 deletions Project/Modules/Game Support/Ark/CraftingCostIngredient.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,6 @@ Protected Class CraftingCostIngredient
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function Pack() As Dictionary
Var Dict As New Dictionary
Dict.Value("engramId") = Self.mEngramRef.BlueprintId
Dict.Value("quantity") = Self.mQuantity
Dict.Value("exact") = Self.mRequireExact
Return Dict
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function Quantity() As Double
Return Self.mQuantity
Expand All @@ -174,9 +164,13 @@ Protected Class CraftingCostIngredient
#tag EndMethod

#tag Method, Flags = &h0
Function SaveData() As Dictionary
Function SaveData(ForAPI As Boolean) As Dictionary
Var Dict As New Dictionary
Dict.Value("engram") = Self.mEngramRef.SaveData
If ForAPI Then
Dict.Value("engramId") = Self.mEngramRef.BlueprintId
Else
Dict.Value("engram") = Self.mEngramRef.SaveData
End If
Dict.Value("quantity") = Self.mQuantity
Dict.Value("exact") = Self.mRequireExact
Return Dict
Expand All @@ -187,7 +181,7 @@ Protected Class CraftingCostIngredient
Shared Function ToJSON(Ingredients() As Ark.CraftingCostIngredient, Pretty As Boolean = False) As String
Var Dicts() As Dictionary
For Each Ingredient As Ark.CraftingCostIngredient In Ingredients
Dicts.Add(Ingredient.Pack)
Dicts.Add(Ingredient.SaveData(False))
Next
Return Beacon.GenerateJSON(Dicts, Pretty)
End Function
Expand Down
6 changes: 4 additions & 2 deletions Project/Modules/Game Support/Ark/Creature.xojo_code
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#tag Class
Protected Class Creature
Implements Ark.Blueprint, Beacon.DisambiguationCandidate
Implements Ark.Blueprint,Beacon.DisambiguationCandidate
#tag Method, Flags = &h0
Function AllStatValues() As Ark.CreatureStatValue()
Var Values() As Ark.CreatureStatValue
Expand Down Expand Up @@ -267,7 +267,9 @@ Implements Ark.Blueprint, Beacon.DisambiguationCandidate
#tag EndMethod

#tag Method, Flags = &h0
Sub Pack(Dict As Dictionary)
Sub Pack(Dict As Dictionary, ForAPI As Boolean)
#Pragma Unused ForAPI

If Self.mIncubationTime > 0 Then
Dict.Value("incubation_time") = Self.mIncubationTime
Else
Expand Down
4 changes: 2 additions & 2 deletions Project/Modules/Game Support/Ark/Engram.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Implements Ark.Blueprint,Beacon.DisambiguationCandidate
#tag EndMethod

#tag Method, Flags = &h0
Sub Pack(Dict As Dictionary)
Sub Pack(Dict As Dictionary, ForAPI As Boolean)
// Part of the Ark.Blueprint interface.

If Self.HasUnlockDetails Then
Expand Down Expand Up @@ -352,7 +352,7 @@ Implements Ark.Blueprint,Beacon.DisambiguationCandidate
Else
Var Ingredients() As Dictionary
For Each Ingredient As Ark.CraftingCostIngredient In Self.mIngredients
Ingredients.Add(Ingredient.Pack)
Ingredients.Add(Ingredient.SaveData(ForAPI))
Next
Dict.Value("recipe") = Ingredients
End If
Expand Down
4 changes: 2 additions & 2 deletions Project/Modules/Game Support/Ark/LootContainer.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,13 @@ Implements Ark.Blueprint,Beacon.Countable,Iterable,Beacon.Validateable,Beacon.Di
#tag EndMethod

#tag Method, Flags = &h0
Sub Pack(Dict As Dictionary)
Sub Pack(Dict As Dictionary, ForAPI As Boolean)
// Part of the Ark.Blueprint interface.

Var Sets() As Dictionary
Sets.ResizeTo(Self.mItemSets.LastIndex)
For Idx As Integer = Self.mItemSets.FirstIndex To Self.mItemSets.LastIndex
Sets(Idx) = Self.mItemSets(Idx).Pack
Sets(Idx) = Self.mItemSets(Idx).Pack(ForAPI)
Next Idx

Dict.Value("multipliers") = New Dictionary("min": Self.mMultipliers.Min, "max": Self.mMultipliers.Max)
Expand Down
4 changes: 2 additions & 2 deletions Project/Modules/Game Support/Ark/LootItemSet.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,11 @@ Implements Beacon.Countable,Iterable,Ark.Weighted,Beacon.Validateable
#tag EndMethod

#tag Method, Flags = &h0
Function Pack() As Dictionary
Function Pack(ForAPI As Boolean) As Dictionary
Var Entries() As Dictionary
Entries.ResizeTo(Self.mEntries.LastIndex)
For Idx As Integer = Self.mEntries.FirstIndex To Self.mEntries.LastIndex
Entries(Idx) = Self.mEntries(Idx).Pack
Entries(Idx) = Self.mEntries(Idx).Pack(ForAPI)
Next Idx

Var Dict As New Dictionary
Expand Down
4 changes: 2 additions & 2 deletions Project/Modules/Game Support/Ark/LootItemSetEntry.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,11 @@ Implements Beacon.Countable,Iterable,Ark.Weighted,Beacon.Validateable
#tag EndMethod

#tag Method, Flags = &h0
Function Pack() As Dictionary
Function Pack(ForAPI As Boolean) As Dictionary
Var Options() As Dictionary
Options.ResizeTo(Self.mOptions.LastIndex)
For Idx As Integer = Self.mOptions.FirstIndex To Self.mOptions.LastIndex
Options(Idx) = Self.mOptions(Idx).Pack
Options(Idx) = Self.mOptions(Idx).Pack(ForAPI)
Next Idx

Var Dict As New Dictionary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ Implements Beacon.Validateable,Ark.Weighted
#tag EndMethod

#tag Method, Flags = &h0
Function Pack() As Dictionary
Function Pack(ForAPI As Boolean) As Dictionary
Var Dict As New Dictionary
Dict.Value("lootItemSetEntryOptionId") = Self.mUUID
Dict.Value("engram") = Self.mEngramRef.SaveData
If ForAPI Then
Dict.Value("engramId") = Self.mEngramRef.BlueprintId
Else
Dict.Value("engram") = Self.mEngramRef.SaveData
End If
Dict.Value("weight") = Self.mWeight
Return Dict
End Function
Expand Down
20 changes: 20 additions & 0 deletions Project/Modules/Game Support/Ark/MutableLootContainer.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,26 @@ Implements Ark.MutableBlueprint
End Sub
#tag EndMethod

#tag Method, Flags = &h0
Sub CopyFrom(Override As Ark.LootDropOverride)
Self.mMinItemSets = Override.MinItemSets
Self.mMaxItemSets = Override.MaxItemSets
Self.mAppendMode = Override.AddToDefaults
Self.mPreventDuplicates = Override.PreventDuplicates
Self.mItemSets.ResizeTo(-1)

Var SetBound As Integer = Override.Count - 1
For Idx As Integer = 0 To SetBound
Var Set As Ark.LootItemSet = Override.SetAt(Idx)
If (Set Is Nil) = False Then
Self.mItemSets.Add(Set.ImmutableVersion)
End If
Next

Self.Modified = True
End Sub
#tag EndMethod

#tag Method, Flags = &h0
Sub Experimental(Assigns Value As Boolean)
If Self.mExperimental = Value Then
Expand Down
6 changes: 3 additions & 3 deletions Project/Modules/Game Support/Ark/Project.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Inherits Beacon.Project

Var PackedBlueprints() As Dictionary
For Each Blueprint As Ark.Blueprint In Blueprints
Var Packed As Dictionary = Blueprint.Pack
Var Packed As Dictionary = Blueprint.Pack(False)
If (Packed Is Nil) = False Then
PackedBlueprints.Add(Packed)
End If
Expand Down Expand Up @@ -478,7 +478,7 @@ Inherits Beacon.Project
Continue
End If

Var SourceOverride As New Ark.MutableSpawnPointOverride(SourceSpawnPoint, Ark.SpawnPointOverride.ModeAppend)
Var SourceOverride As New Ark.MutableSpawnPointOverride(SourceSpawnPoint, Ark.SpawnPointOverride.ModeAppend, False)
SourceOverride.LoadDefaults()

Var Limit As Double = SourceOverride.Limit(ReplacedCreature)
Expand Down Expand Up @@ -517,7 +517,7 @@ Inherits Beacon.Project
If Override Is Nil Then
Override = SpawnConfig.OverrideForSpawnPoint(SourceSpawnPoint, Ark.SpawnPointOverride.ModeOverride)
If Override Is Nil Then
Override = New Ark.MutableSpawnPointOverride(SourceSpawnPoint, Ark.SpawnPointOverride.ModeAppend)
Override = New Ark.MutableSpawnPointOverride(SourceSpawnPoint, Ark.SpawnPointOverride.ModeAppend, False)
End If
End If

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ Inherits Ark.BlueprintController
Var PathComponent As String = Self.PathComponent(Task)
Var Objects() As Dictionary
For Each Blueprint As Ark.Blueprint In Blueprints
Objects.Add(Ark.PackBlueprint(Blueprint))
Objects.Add(Ark.PackBlueprint(Blueprint, True))
Next

Break
Var Request As New BeaconAPI.Request("ark/" + PathComponent, "POST", Beacon.GenerateJSON(Objects, False), "application/json")
Var Response As BeaconAPI.Response = BeaconAPI.SendSync(Request)

Expand Down
21 changes: 12 additions & 9 deletions Project/Modules/Game Support/Ark/SpawnPoint.xojo_code
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#tag Class
Protected Class SpawnPoint
Implements Ark.Blueprint,Beacon.Countable, Beacon.DisambiguationCandidate
Implements Ark.Blueprint,Beacon.Countable,Beacon.DisambiguationCandidate
#tag Method, Flags = &h0
Function AlternateLabel() As NullableString
Return Self.mAlternateLabel
Expand Down Expand Up @@ -394,11 +394,12 @@ Implements Ark.Blueprint,Beacon.Countable, Beacon.DisambiguationCandidate
#tag EndMethod

#tag Method, Flags = &h0
Sub Pack(Dict As Dictionary)
Sub Pack(Dict As Dictionary, ForAPI As Boolean)
Var Sets() As Dictionary
For Each Set As Ark.SpawnPointSet In Self.mSets
Sets.Add(Set.SaveData)
Sets.Add(Set.SaveData(ForAPI))
Next
Dict.Value("sets") = Sets

Var Limits() As Dictionary
Var References() As Ark.BlueprintReference = Self.mLimits.References
Expand All @@ -408,10 +409,12 @@ Implements Ark.Blueprint,Beacon.Countable, Beacon.DisambiguationCandidate
End If

Var Limit As Double = Self.mLimits.Value(Reference, Self.LimitAttribute)
Limits.Add(New Dictionary("creature": Reference.SaveData, "maxPercentage": Limit))
If ForAPI Then
Limits.Add(New Dictionary("creatureId": Reference.BlueprintId, "maxPercentage": Limit))
Else
Limits.Add(New Dictionary("creature": Reference.SaveData, "maxPercentage": Limit))
End If
Next

Dict.Value("sets") = Sets
Dict.Value("limits") = Limits
End Sub
#tag EndMethod
Expand All @@ -428,7 +431,7 @@ Implements Ark.Blueprint,Beacon.Countable, Beacon.DisambiguationCandidate
Function SaveData() As Dictionary
Var Children() As Variant
For Each Set As Ark.SpawnPointSet In Self.mSets
Children.Add(Set.SaveData)
Children.Add(Set.SaveData(False))
Next

Var Keys As New Dictionary
Expand All @@ -454,8 +457,8 @@ Implements Ark.Blueprint,Beacon.Countable, Beacon.DisambiguationCandidate
Function SetsString(Pretty As Boolean = False) As String
Var Objects() As Variant
For Each Set As Ark.SpawnPointSet In Self.mSets
If Set <> Nil Then
Objects.Add(Set.SaveData)
If (Set Is Nil) = False Then
Objects.Add(Set.SaveData(False))
End If
Next
Try
Expand Down
Loading

0 comments on commit 6852253

Please sign in to comment.