add new salv loot into the vgroid procgen (#31290)

add new loot into vgroid procgen
This commit is contained in:
Nemanja
2024-08-23 22:06:37 -04:00
committed by GitHub
parent 8f4ee7ac96
commit c31ffff9ac
5 changed files with 304 additions and 171 deletions

View File

@@ -0,0 +1,59 @@
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Ghost.Roles.Components;
using Content.Server.NPC.Systems;
using Content.Shared.EntityTable;
using Content.Shared.Physics;
using Content.Shared.Procedural;
using Content.Shared.Procedural.DungeonLayers;
using Robust.Shared.Collections;
namespace Content.Server.Procedural.DungeonJob;
public sealed partial class DungeonJob
{
private async Task PostGen(
EntityTableDunGen gen,
Dungeon dungeon,
Random random)
{
var availableRooms = new ValueList<DungeonRoom>();
availableRooms.AddRange(dungeon.Rooms);
var availableTiles = new ValueList<Vector2i>(dungeon.AllTiles);
var count = random.Next(gen.MinCount, gen.MaxCount + 1);
var npcs = _entManager.System<NPCSystem>();
for (var i = 0; i < count; i++)
{
while (availableTiles.Count > 0)
{
var tile = availableTiles.RemoveSwap(random.Next(availableTiles.Count));
if (!_anchorable.TileFree(_grid,
tile,
(int) CollisionGroup.MachineLayer,
(int) CollisionGroup.MachineLayer))
{
continue;
}
var entities = _entManager.System<EntityTableSystem>().GetSpawns(gen.Table, random).ToList();
foreach (var ent in entities)
{
var uid = _entManager.SpawnAtPosition(ent, _maps.GridTileToLocal(_gridUid, _grid, tile));
_entManager.RemoveComponent<GhostRoleComponent>(uid);
_entManager.RemoveComponent<GhostTakeoverAvailableComponent>(uid);
npcs.SleepNPC(uid);
}
break;
}
await SuspendDungeon();
if (!ValidateResume())
return;
}
}
}

View File

@@ -239,6 +239,9 @@ public sealed partial class DungeonJob : Job<List<Dungeon>>
case MobsDunGen mob: case MobsDunGen mob:
await PostGen(mob, dungeons[^1], random); await PostGen(mob, dungeons[^1], random);
break; break;
case EntityTableDunGen entityTable:
await PostGen(entityTable, dungeons[^1], random);
break;
case NoiseDistanceDunGen distance: case NoiseDistanceDunGen distance:
dungeons.Add(await GenerateNoiseDistanceDunGen(position, distance, reservedTiles, seed, random)); dungeons.Add(await GenerateNoiseDistanceDunGen(position, distance, reservedTiles, seed, random));
break; break;

View File

@@ -0,0 +1,21 @@
using Content.Shared.EntityTable.EntitySelectors;
namespace Content.Shared.Procedural.DungeonLayers;
/// <summary>
/// Spawns entities inside of the dungeon randomly.
/// </summary>
public sealed partial class EntityTableDunGen : IDunGenLayer
{
// Counts separate to config to avoid some duplication.
[DataField]
public int MinCount = 1;
[DataField]
public int MaxCount = 1;
[DataField(required: true)]
public EntityTableSelector Table;
}

View File

@@ -121,6 +121,54 @@
tableId: SalvageScrapSpawnerValuable tableId: SalvageScrapSpawnerValuable
prob: 0.75 prob: 0.75
- type: entityTable
id: SalvageTreasureSpawnerCommon
table: !type:GroupSelector
children:
# 80% chance of some treasure
- !type:GroupSelector
weight: 80
children:
- !type:NestedSelector
tableId: SalvageTreasureCommon
weight: 60
- !type:NestedSelector
tableId: SalvageTreasureUncommon
weight: 30
- !type:NestedSelector
tableId: SalvageTreasureRare
weight: 9
- !type:NestedSelector
tableId: SalvageTreasureLegendary
weight: 1
# 10% chance of low-level equipment
- !type:GroupSelector
weight: 10
children:
- !type:NestedSelector
tableId: SalvageEquipmentCommon
weight: 60
- !type:NestedSelector
tableId: SalvageEquipmentUncommon
weight: 40
# 5% chance of moderate scrap
- !type:GroupSelector
weight: 5
children:
- !type:NestedSelector
tableId: SalvageScrapLowValue
weight: 60
- !type:NestedSelector
tableId: SalvageScrapHighValue
weight: 30
- !type:NestedSelector
tableId: SalvageScrapLarge
weight: 10
# 5% chance of maintenance fluff
- !type:NestedSelector
tableId: MaintFluffTable
weight: 5
- type: entity - type: entity
parent: MarkerBase parent: MarkerBase
id: SalvageSpawnerTreasure id: SalvageSpawnerTreasure
@@ -134,52 +182,62 @@
state: diamond state: diamond
- type: EntityTableSpawner - type: EntityTableSpawner
offset: 0.4 offset: 0.4
table: !type:GroupSelector table: !type:NestedSelector
tableId: SalvageTreasureSpawnerCommon
prob: 0.75 prob: 0.75
- type: entityTable
id: SalvageTreasureSpawnerValuable
table: !type:GroupSelector
children:
# 80% chance of some treasure
- !type:GroupSelector
weight: 80
children: children:
# 80% chance of some treasure
- !type:GroupSelector
weight: 80
children:
- !type:NestedSelector
tableId: SalvageTreasureCommon
weight: 60
- !type:NestedSelector
tableId: SalvageTreasureUncommon
weight: 30
- !type:NestedSelector
tableId: SalvageTreasureRare
weight: 9
- !type:NestedSelector
tableId: SalvageTreasureLegendary
weight: 1
# 10% chance of low-level equipment
- !type:GroupSelector
weight: 10
children:
- !type:NestedSelector
tableId: SalvageEquipmentCommon
weight: 60
- !type:NestedSelector
tableId: SalvageEquipmentUncommon
weight: 40
# 5% chance of moderate scrap
- !type:GroupSelector
weight: 5
children:
- !type:NestedSelector
tableId: SalvageScrapLowValue
weight: 60
- !type:NestedSelector
tableId: SalvageScrapHighValue
weight: 30
- !type:NestedSelector
tableId: SalvageScrapLarge
weight: 10
# 5% chance of maintenance fluff
- !type:NestedSelector - !type:NestedSelector
tableId: MaintFluffTable tableId: SalvageTreasureCommon
weight: 45
- !type:NestedSelector
tableId: SalvageTreasureUncommon
weight: 35
- !type:NestedSelector
tableId: SalvageTreasureRare
weight: 15
- !type:NestedSelector
tableId: SalvageTreasureLegendary
weight: 5 weight: 5
# 10% chance of low-level equipment
- !type:GroupSelector
weight: 10
children:
- !type:NestedSelector
tableId: SalvageEquipmentCommon
weight: 50
- !type:NestedSelector
tableId: SalvageEquipmentUncommon
weight: 40
- !type:NestedSelector
tableId: SalvageEquipmentUncommon
weight: 10
# 5% chance of moderate scrap
- !type:GroupSelector
weight: 5
children:
- !type:NestedSelector
tableId: SalvageScrapLowValue
weight: 30
- !type:NestedSelector
tableId: SalvageScrapHighValue
weight: 45
- !type:NestedSelector
tableId: SalvageScrapLarge
weight: 25
# 5% chance of maintenance fluff
- !type:NestedSelector
tableId: MaintFluffTable
weight: 5
rolls: !type:RangeNumberSelector
range: 1, 2
- type: entity - type: entity
parent: MarkerBase parent: MarkerBase
@@ -194,57 +252,51 @@
state: diamond state: diamond
- type: EntityTableSpawner - type: EntityTableSpawner
offset: 0.4 offset: 0.4
table: !type:GroupSelector table: !type:NestedSelector
tableId: SalvageTreasureSpawnerValuable
prob: 0.75 prob: 0.75
- type: entityTable
id: SalvageEquipmentSpawnerCommon
table: !type:GroupSelector
children:
# 80% chance of equipment item
- !type:GroupSelector
weight: 80
children: children:
# 80% chance of some treasure - !type:NestedSelector
- !type:GroupSelector tableId: SalvageEquipmentCommon
weight: 80 weight: 60
children: - !type:NestedSelector
- !type:NestedSelector tableId: SalvageEquipmentUncommon
tableId: SalvageTreasureCommon weight: 30
weight: 45 - !type:NestedSelector
- !type:NestedSelector tableId: SalvageEquipmentRare
tableId: SalvageTreasureUncommon weight: 9
weight: 35 - !type:NestedSelector
- !type:NestedSelector tableId: SalvageEquipmentLegendary
tableId: SalvageTreasureRare weight: 1
weight: 15 # 15% chance of decent-ish treasure
- !type:NestedSelector - !type:GroupSelector
tableId: SalvageTreasureLegendary weight: 15
weight: 5 children:
# 10% chance of low-level equipment - !type:NestedSelector
- !type:GroupSelector tableId: SalvageTreasureCommon
weight: 10 weight: 75
children: - !type:NestedSelector
- !type:NestedSelector tableId: SalvageTreasureUncommon
tableId: SalvageEquipmentCommon weight: 20
weight: 50 - !type:NestedSelector
- !type:NestedSelector tableId: SalvageTreasureRare
tableId: SalvageEquipmentUncommon
weight: 40
- !type:NestedSelector
tableId: SalvageEquipmentUncommon
weight: 10
# 5% chance of moderate scrap
- !type:GroupSelector
weight: 5 weight: 5
children: # 5% chance of decent maintenance loot
- !type:NestedSelector - !type:GroupSelector
tableId: SalvageScrapLowValue weight: 5
weight: 30 children:
- !type:NestedSelector - !type:NestedSelector
tableId: SalvageScrapHighValue tableId: MaintToolsTable
weight: 45
- !type:NestedSelector
tableId: SalvageScrapLarge
weight: 25
# 5% chance of maintenance fluff
- !type:NestedSelector - !type:NestedSelector
tableId: MaintFluffTable tableId: MaintFluffTable
weight: 5
rolls: !type:RangeNumberSelector
range: 1, 2
- type: entity - type: entity
parent: MarkerBase parent: MarkerBase
@@ -259,46 +311,57 @@
state: walkietalkie state: walkietalkie
- type: EntityTableSpawner - type: EntityTableSpawner
offset: 0.4 offset: 0.4
table: !type:GroupSelector table: !type:NestedSelector
tableId: SalvageEquipmentSpawnerCommon
prob: 0.75 prob: 0.75
- type: entityTable
id: SalvageEquipmentSpawnerValuable
table: !type:GroupSelector
children:
# 80% chance of equipment item
- !type:GroupSelector
weight: 80
children: children:
# 80% chance of equipment item - !type:NestedSelector
- !type:GroupSelector tableId: SalvageEquipmentCommon
weight: 80 weight: 45
children: - !type:NestedSelector
- !type:NestedSelector tableId: SalvageEquipmentUncommon
tableId: SalvageEquipmentCommon weight: 35
weight: 60 - !type:NestedSelector
- !type:NestedSelector tableId: SalvageEquipmentRare
tableId: SalvageEquipmentUncommon
weight: 30
- !type:NestedSelector
tableId: SalvageEquipmentRare
weight: 9
- !type:NestedSelector
tableId: SalvageEquipmentLegendary
weight: 1
# 15% chance of decent-ish treasure
- !type:GroupSelector
weight: 15 weight: 15
children: - !type:NestedSelector
- !type:NestedSelector tableId: SalvageEquipmentLegendary
tableId: SalvageTreasureCommon
weight: 75
- !type:NestedSelector
tableId: SalvageTreasureUncommon
weight: 20
- !type:NestedSelector
tableId: SalvageTreasureRare
weight: 5
# 5% chance of decent maintenance loot
- !type:GroupSelector
weight: 5 weight: 5
children: # 14% chance of decent-ish treasure
- !type:NestedSelector - !type:GroupSelector
tableId: MaintToolsTable weight: 14
- !type:NestedSelector children:
tableId: MaintFluffTable - !type:NestedSelector
tableId: SalvageTreasureCommon
weight: 60
- !type:NestedSelector
tableId: SalvageTreasureUncommon
weight: 30
- !type:NestedSelector
tableId: SalvageTreasureRare
weight: 10
# 5% chance of decent maintenance loot
- !type:GroupSelector
weight: 5
children:
- !type:NestedSelector
tableId: MaintToolsTable
- !type:NestedSelector
tableId: MaintFluffTable
# 1% chance of syndie maintenance loot
- !type:GroupSelector
weight: 1
children:
- !type:NestedSelector
tableId: SyndieMaintLoot
- type: entity - type: entity
parent: MarkerBase parent: MarkerBase
@@ -313,52 +376,9 @@
state: walkietalkie state: walkietalkie
- type: EntityTableSpawner - type: EntityTableSpawner
offset: 0.4 offset: 0.4
table: !type:GroupSelector table: !type:NestedSelector
tableId: SalvageEquipmentSpawnerValuable
prob: 0.75 prob: 0.75
children:
# 80% chance of equipment item
- !type:GroupSelector
weight: 80
children:
- !type:NestedSelector
tableId: SalvageEquipmentCommon
weight: 45
- !type:NestedSelector
tableId: SalvageEquipmentUncommon
weight: 35
- !type:NestedSelector
tableId: SalvageEquipmentRare
weight: 15
- !type:NestedSelector
tableId: SalvageEquipmentLegendary
weight: 5
# 14% chance of decent-ish treasure
- !type:GroupSelector
weight: 14
children:
- !type:NestedSelector
tableId: SalvageTreasureCommon
weight: 60
- !type:NestedSelector
tableId: SalvageTreasureUncommon
weight: 30
- !type:NestedSelector
tableId: SalvageTreasureRare
weight: 10
# 5% chance of decent maintenance loot
- !type:GroupSelector
weight: 5
children:
- !type:NestedSelector
tableId: MaintToolsTable
- !type:NestedSelector
tableId: MaintFluffTable
# 1% chance of syndie maintenance loot
- !type:GroupSelector
weight: 1
children:
- !type:NestedSelector
tableId: SyndieMaintLoot
- type: entity - type: entity
name: Salvage Canister Spawner name: Salvage Canister Spawner

View File

@@ -141,9 +141,39 @@
layers: layers:
- !type:ExteriorDunGen - !type:ExteriorDunGen
proto: Experiment proto: Experiment
- !type:EntityTableDunGen
minCount: 25
maxCount: 40
table: !type:NestedSelector
tableId: SalvageScrapSpawnerCommon
- !type:EntityTableDunGen
minCount: 30
maxCount: 40
table: !type:NestedSelector
tableId: SalvageScrapSpawnerValuable
- !type:EntityTableDunGen
minCount: 15
maxCount: 25
table: !type:NestedSelector
tableId: SalvageTreasureSpawnerCommon
- !type:EntityTableDunGen
minCount: 15
maxCount: 25
table: !type:NestedSelector
tableId: SalvageEquipmentSpawnerCommon
- !type:EntityTableDunGen
minCount: 15
maxCount: 20
table: !type:NestedSelector
tableId: SalvageTreasureSpawnerValuable
- !type:EntityTableDunGen
minCount: 15
maxCount: 20
table: !type:NestedSelector
tableId: SalvageEquipmentSpawnerValuable
- !type:MobsDunGen - !type:MobsDunGen
minCount: 5 minCount: 8
maxCount: 8 maxCount: 15
groups: groups:
- id: MobGoliath - id: MobGoliath
amount: 1 amount: 1