@@ -48,12 +48,14 @@ public RandomItemsTable(int[] listWeight, ItemsTable itemsTable)
48
48
}
49
49
public class ReferenceTable
50
50
{
51
- public int [ ] Ids { get ; }
52
- public string [ ] Refs { get ; }
53
- public ReferenceTable ( string [ ] refs , int [ ] ids )
51
+ public string DefaultTable { get ; }
52
+ public Dictionary < int , string > Ids { get ; }
53
+ public Dictionary < int , string > Tiers { get ; }
54
+ public ReferenceTable ( string defaultTable , Dictionary < int , string > ids , Dictionary < int , string > tiers )
54
55
{
56
+ DefaultTable = defaultTable ;
55
57
Ids = ids ;
56
- Refs = refs ;
58
+ Tiers = tiers ;
57
59
}
58
60
}
59
61
public class LootTable
@@ -158,6 +160,7 @@ public static void InjectLootScripts()
158
160
var min_lvl = scr_globaltile_dungeon_get(""mob_lvl_min"");
159
161
var max_lvl = scr_globaltile_dungeon_get(""mob_lvl_max"");
160
162
var tier = floor(((max_lvl + min_lvl) / 2));
163
+ scr_actionsLogUpdate(""current tier: "" + string(tier));
161
164
162
165
if (!variable_struct_exists(refData, objectName))
163
166
{
@@ -168,46 +171,64 @@ public static void InjectLootScripts()
168
171
var refStruct = variable_struct_get(refData, objectName);
169
172
var referenceLootTableIndex = -1;
170
173
174
+ if (!variable_struct_exists(refStruct, ""DefaultTable""))
175
+ {
176
+ scr_actionsLogUpdate(""cant find DefaultTable"");
177
+ file_text_close(refFile);
178
+ return -4;
179
+ }
180
+ var defaultTable = variable_struct_get(refStruct, ""DefaultTable"");
181
+
171
182
if (!variable_struct_exists(refStruct, ""Ids""))
172
183
{
173
184
scr_actionsLogUpdate(""cant find Ids"");
174
185
file_text_close(refFile);
175
186
return -4;
176
187
}
177
- var idsArray = variable_struct_get(refStruct, ""Ids"");
188
+ var idsStruct = variable_struct_get(refStruct, ""Ids"");
178
189
179
- for (var i = 0; i < array_length(idsArray); i += 1 )
190
+ if (variable_struct_exists(idsStruct, argument0.id) )
180
191
{
181
- if (idsArray[i] == argument0.id)
182
- {
183
- referenceLootTableIndex = i;
184
- break;
185
- }
192
+ var referenceLootTable = variable_struct_get(idsStruct, argument0.id);
193
+ scr_actionsLogUpdate(""ref: "" + referenceLootTable);
194
+ file_text_close(refFile);
195
+ return referenceLootTable;
186
196
}
187
- scr_actionsLogUpdate(""id ref: "" + string(referenceLootTableIndex));
188
197
189
- if (!variable_struct_exists(refStruct, ""Refs ""))
198
+ if (!variable_struct_exists(refStruct, ""Tiers ""))
190
199
{
191
- scr_actionsLogUpdate(""cant find Refs "");
200
+ scr_actionsLogUpdate(""cant find Tiers "");
192
201
file_text_close(refFile);
193
202
return -4;
194
203
}
195
- var refsTable = variable_struct_get(refStruct, ""Refs"");
196
- var referenceLootTable = refsTable[referenceLootTableIndex + 1];
204
+ var tiersStruct = variable_struct_get(refStruct, ""Tiers"");
205
+ var tiers = variable_struct_get_names(tiersStruct);
206
+ var indexTier = -1;
197
207
198
- scr_actionsLogUpdate(""ref: "" + referenceLootTable);
199
-
200
- if (!variable_struct_exists(refStruct, ""Refs""))
208
+ for (var i = 0; i < array_length(tiers); i++;)
201
209
{
202
- scr_actionsLogUpdate(""cant find Refs"");
203
- file_text_close(refFile);
204
- return -4;
210
+ if (tier < tiers[i])
211
+ {
212
+ indexTier = i - 1;
213
+ break;
214
+ }
215
+ else
216
+ {
217
+ indexTier = i;
218
+ }
205
219
}
206
- var refsTable = variable_struct_get(refStruct, ""Refs"");
207
- var referenceLootTable = refsTable[referenceLootTableIndex + 1];
208
220
221
+ if (indexTier == -1)
222
+ {
223
+ var referenceLootTable = defaultTable;
224
+ }
225
+ else
226
+ {
227
+ var referenceLootTable = variable_struct_get(tiersStruct, tiers[indexTier]);
228
+ }
229
+
230
+ scr_actionsLogUpdate(""ref: "" + referenceLootTable);
209
231
file_text_close(refFile);
210
-
211
232
return referenceLootTable;
212
233
}" ;
213
234
@@ -416,11 +437,20 @@ public static void AddLootTable(string lootTableID, ItemsTable guaranteedItems,
416
437
LootTable lootTable = new ( guaranteedItems , randomLootMin , randomLootMax , emptyWeight , randomItemsTable ) ;
417
438
LootUtils . LootTables . Add ( lootTableID , lootTable ) ;
418
439
}
419
- public static void AddReferenceTable ( string nameObject , string [ ] refs , int [ ] ? ids = null )
440
+ public static void AddReferenceTable ( string nameObject , string table )
441
+ {
442
+ LootUtils . ReferenceTables . Add ( nameObject , new ReferenceTable ( table , new Dictionary < int , string > ( ) , new Dictionary < int , string > ( ) ) ) ;
443
+ }
444
+ public static void AddReferenceTable ( string nameObject , string table , Dictionary < int , string > ? ids , Dictionary < int , string > ? tiers )
420
445
{
421
- ids ??= Array . Empty < int > ( ) ;
422
- ReferenceTable referenceTable = new ( refs , ids ) ;
423
- LootUtils . ReferenceTables . Add ( nameObject , referenceTable ) ;
446
+ LootUtils . ReferenceTables . Add ( nameObject , new ReferenceTable ( table , ids ?? new Dictionary < int , string > ( ) , tiers ?? new Dictionary < int , string > ( ) ) ) ;
447
+ }
448
+ public static void AddReferenceTableForMultipleObjects ( string table , params string [ ] nameObjects )
449
+ {
450
+ foreach ( string nameObject in nameObjects )
451
+ {
452
+ LootUtils . ReferenceTables . Add ( nameObject , new ReferenceTable ( table , new Dictionary < int , string > ( ) , new Dictionary < int , string > ( ) ) ) ;
453
+ }
424
454
}
425
455
}
426
456
}
0 commit comments