megafauna elimination mission and fish salv faction (#16720)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Content.Server.NPC.Systems
|
|||||||
|
|
||||||
private void OnPlayerNPCDetach(EntityUid uid, NPCComponent component, PlayerDetachedEvent args)
|
private void OnPlayerNPCDetach(EntityUid uid, NPCComponent component, PlayerDetachedEvent args)
|
||||||
{
|
{
|
||||||
if (_mobState.IsIncapacitated(uid) || Deleted(uid))
|
if (_mobState.IsIncapacitated(uid) || TerminatingOrDeleted(uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WakeNPC(uid, component);
|
WakeNPC(uid, component);
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using Content.Shared.Salvage;
|
||||||
|
|
||||||
|
namespace Content.Server.Salvage.Expeditions.Structure;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tracks expedition data for <see cref="SalvageMissionType.Elimination"/>
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Access(typeof(SalvageSystem), typeof(SpawnSalvageMissionJob))]
|
||||||
|
public sealed class SalvageEliminationExpeditionComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// List of mobs that need to be killed for the mission to be complete.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("megafauna")]
|
||||||
|
public readonly List<EntityUid> Megafauna = new();
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ using Content.Server.Station.Components;
|
|||||||
using Content.Shared.Chat;
|
using Content.Shared.Chat;
|
||||||
using Content.Shared.Humanoid;
|
using Content.Shared.Humanoid;
|
||||||
using Content.Shared.Mobs.Components;
|
using Content.Shared.Mobs.Components;
|
||||||
|
using Content.Shared.Mobs.Systems;
|
||||||
using Content.Shared.Salvage;
|
using Content.Shared.Salvage;
|
||||||
using Content.Shared.Shuttles.Components;
|
using Content.Shared.Shuttles.Components;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -22,6 +23,8 @@ public sealed partial class SalvageSystem
|
|||||||
* Handles actively running a salvage expedition.
|
* Handles actively running a salvage expedition.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||||
|
|
||||||
private void InitializeRunner()
|
private void InitializeRunner()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<FTLRequestEvent>(OnFTLRequest);
|
SubscribeLocalEvent<FTLRequestEvent>(OnFTLRequest);
|
||||||
@@ -41,11 +44,15 @@ public sealed partial class SalvageSystem
|
|||||||
// TODO: This is terrible but need bluespace harnesses or something.
|
// TODO: This is terrible but need bluespace harnesses or something.
|
||||||
var query = EntityQueryEnumerator<HumanoidAppearanceComponent, MobStateComponent, TransformComponent>();
|
var query = EntityQueryEnumerator<HumanoidAppearanceComponent, MobStateComponent, TransformComponent>();
|
||||||
|
|
||||||
while (query.MoveNext(out var _, out var _, out var mobXform))
|
while (query.MoveNext(out var uid, out var _, out var mobState, out var mobXform))
|
||||||
{
|
{
|
||||||
if (mobXform.MapUid != xform.MapUid)
|
if (mobXform.MapUid != xform.MapUid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Don't count unidentified humans (loot) or anyone you murdered so you can still maroon them once dead.
|
||||||
|
if (_mobState.IsDead(uid, mobState))
|
||||||
|
continue;
|
||||||
|
|
||||||
// Okay they're on salvage, so are they on the shuttle.
|
// Okay they're on salvage, so are they on the shuttle.
|
||||||
if (mobXform.GridUid != ev.Uid)
|
if (mobXform.GridUid != ev.Uid)
|
||||||
{
|
{
|
||||||
@@ -236,5 +243,37 @@ public sealed partial class SalvageSystem
|
|||||||
Announce(uid, Loc.GetString("salvage-expedition-completed"));
|
Announce(uid, Loc.GetString("salvage-expedition-completed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Elimination missions
|
||||||
|
var eliminationQuery = EntityQueryEnumerator<SalvageEliminationExpeditionComponent, SalvageExpeditionComponent>();
|
||||||
|
while (eliminationQuery.MoveNext(out var uid, out var elimination, out var comp))
|
||||||
|
{
|
||||||
|
if (comp.Completed)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var announce = false;
|
||||||
|
|
||||||
|
for (var i = 0; i < elimination.Megafauna.Count; i++)
|
||||||
|
{
|
||||||
|
var mob = elimination.Megafauna[i];
|
||||||
|
|
||||||
|
if (Deleted(mob) || _mobState.IsDead(mob))
|
||||||
|
{
|
||||||
|
elimination.Megafauna.RemoveSwap(i);
|
||||||
|
announce = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (announce)
|
||||||
|
{
|
||||||
|
Announce(uid, Loc.GetString("salvage-expedition-megafauna-remaining", ("count", elimination.Megafauna.Count)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elimination.Megafauna.Count == 0)
|
||||||
|
{
|
||||||
|
comp.Completed = true;
|
||||||
|
Announce(uid, Loc.GetString("salvage-expedition-completed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,6 +197,9 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
|
|||||||
case SalvageMissionType.Destruction:
|
case SalvageMissionType.Destruction:
|
||||||
await SetupStructure(mission, dungeon, mapUid, grid, random);
|
await SetupStructure(mission, dungeon, mapUid, grid, random);
|
||||||
break;
|
break;
|
||||||
|
case SalvageMissionType.Elimination:
|
||||||
|
await SetupElimination(mission, dungeon, mapUid, grid, random);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -337,9 +340,34 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SpawnMobsRandomRooms(SalvageMission mission, Dungeon dungeon, SalvageFactionPrototype faction, MapGridComponent grid, Random random)
|
private async Task SetupElimination(
|
||||||
|
SalvageMission mission,
|
||||||
|
Dungeon dungeon,
|
||||||
|
EntityUid gridUid,
|
||||||
|
MapGridComponent grid,
|
||||||
|
Random random)
|
||||||
{
|
{
|
||||||
var groupSpawns = _salvage.GetSpawnCount(mission.Difficulty);
|
// spawn megafauna in a random place
|
||||||
|
var roomIndex = random.Next(dungeon.Rooms.Count);
|
||||||
|
var room = dungeon.Rooms[roomIndex];
|
||||||
|
var tile = room.Tiles.ElementAt(random.Next(room.Tiles.Count));
|
||||||
|
var position = grid.GridTileToLocal(tile);
|
||||||
|
|
||||||
|
var faction = _prototypeManager.Index<SalvageFactionPrototype>(mission.Faction);
|
||||||
|
var prototype = faction.Configs["Megafauna"];
|
||||||
|
var uid = _entManager.SpawnEntity(prototype, position);
|
||||||
|
// not removing ghost role since its 1 megafauna, expect that you won't be able to cheese it.
|
||||||
|
var eliminationComp = _entManager.EnsureComponent<SalvageEliminationExpeditionComponent>(gridUid);
|
||||||
|
eliminationComp.Megafauna.Add(uid);
|
||||||
|
|
||||||
|
// spawn less mobs than usual since there's megafauna to deal with too
|
||||||
|
await SpawnMobsRandomRooms(mission, dungeon, faction, grid, random, 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SpawnMobsRandomRooms(SalvageMission mission, Dungeon dungeon, SalvageFactionPrototype faction, MapGridComponent grid, Random random, float scale = 1f)
|
||||||
|
{
|
||||||
|
// scale affects how many groups are spawned, not the size of the groups themselves
|
||||||
|
var groupSpawns = _salvage.GetSpawnCount(mission.Difficulty) * scale;
|
||||||
var groupSum = faction.MobGroups.Sum(o => o.Prob);
|
var groupSum = faction.MobGroups.Sum(o => o.Prob);
|
||||||
|
|
||||||
for (var i = 0; i < groupSpawns; i++)
|
for (var i = 0; i < groupSpawns; i++)
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public abstract class SharedSalvageSystem : EntitySystem
|
|||||||
return Loc.GetString("salvage-expedition-desc-structure",
|
return Loc.GetString("salvage-expedition-desc-structure",
|
||||||
("count", GetStructureCount(mission.Difficulty)),
|
("count", GetStructureCount(mission.Difficulty)),
|
||||||
("structure", _loc.GetEntityData(proto).Name));
|
("structure", _loc.GetEntityData(proto).Name));
|
||||||
|
case SalvageMissionType.Elimination:
|
||||||
|
return Loc.GetString("salvage-expedition-desc-elimination");
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -219,6 +221,11 @@ public enum SalvageMissionType : byte
|
|||||||
/// Destroy the specified structures in a dungeon.
|
/// Destroy the specified structures in a dungeon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Destruction,
|
Destruction,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Kill a large creature in a dungeon.
|
||||||
|
/// </summary>
|
||||||
|
Elimination,
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ salvage-expedition-structure-remaining = {$count ->
|
|||||||
*[other] {$count} structures remaining.
|
*[other] {$count} structures remaining.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
salvage-expedition-megafauna-remaining = {$count} megafauna remaining.
|
||||||
|
|
||||||
salvage-expedition-window-title = Salvage expeditions
|
salvage-expedition-window-title = Salvage expeditions
|
||||||
salvage-expedition-window-difficulty = Difficulty:
|
salvage-expedition-window-difficulty = Difficulty:
|
||||||
salvage-expedition-window-details = Details:
|
salvage-expedition-window-details = Details:
|
||||||
@@ -25,9 +27,11 @@ salvage-expedition-desc-structure = {$count ->
|
|||||||
[one] Destroy {$count} {$structure} inside the area.
|
[one] Destroy {$count} {$structure} inside the area.
|
||||||
*[other] Destroy {$count} {$structure}s inside the area.
|
*[other] Destroy {$count} {$structure}s inside the area.
|
||||||
}
|
}
|
||||||
|
salvage-expedition-desc-elimination = Kill a large and dangerous creature inside the area.
|
||||||
|
|
||||||
salvage-expedition-type-Mining = Mining
|
salvage-expedition-type-Mining = Mining
|
||||||
salvage-expedition-type-Destruction = Destruction
|
salvage-expedition-type-Destruction = Destruction
|
||||||
|
salvage-expedition-type-Elimination = Elimination
|
||||||
|
|
||||||
salvage-expedition-difficulty-Minimal = Minimal
|
salvage-expedition-difficulty-Minimal = Minimal
|
||||||
salvage-expedition-difficulty-Minor = Minor
|
salvage-expedition-difficulty-Minor = Minor
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
- type: Clickable
|
- type: Clickable
|
||||||
- type: InteractionOutline
|
- type: InteractionOutline
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
netsync: false
|
|
||||||
sprite: Structures/Specific/xeno_building.rsi
|
sprite: Structures/Specific/xeno_building.rsi
|
||||||
layers:
|
layers:
|
||||||
- state: wardingtower
|
- state: wardingtower
|
||||||
@@ -48,3 +47,16 @@
|
|||||||
behaviors:
|
behaviors:
|
||||||
- !type:DoActsBehavior
|
- !type:DoActsBehavior
|
||||||
acts: [ "Destruction" ]
|
acts: [ "Destruction" ]
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: XenoWardingTower
|
||||||
|
id: CarpStatue
|
||||||
|
name: carp statue
|
||||||
|
description: A statue of one of the brave carp that got us where we are today. Made with real teeth!
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Structures/Specific/carp_statue.rsi
|
||||||
|
layers:
|
||||||
|
- state: statue
|
||||||
|
- state: unshaded
|
||||||
|
shader: unshaded
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
id: Xenos
|
id: Xenos
|
||||||
proto: MobXeno
|
proto: MobXeno
|
||||||
|
|
||||||
|
- type: biomeMarkerLayer
|
||||||
|
id: Carps
|
||||||
|
proto: MobCarp
|
||||||
|
|
||||||
|
|
||||||
#- type: biomeMarkerLayer
|
#- type: biomeMarkerLayer
|
||||||
# id: Experiment
|
# id: Experiment
|
||||||
|
|||||||
@@ -14,3 +14,24 @@
|
|||||||
configs:
|
configs:
|
||||||
DefenseStructure: XenoWardingTower
|
DefenseStructure: XenoWardingTower
|
||||||
Mining: Xenos
|
Mining: Xenos
|
||||||
|
Megafauna: MobXenoQueen
|
||||||
|
|
||||||
|
- type: salvageFaction
|
||||||
|
id: Carps
|
||||||
|
groups:
|
||||||
|
- entries:
|
||||||
|
- id: MobCarp
|
||||||
|
amount: 1
|
||||||
|
maxAmount: 3
|
||||||
|
- id: MobCarpMagic
|
||||||
|
amount: 1
|
||||||
|
maxAmount: 2
|
||||||
|
- entries:
|
||||||
|
- id: MobCarpHolo
|
||||||
|
amount: 1
|
||||||
|
maxAmount: 3
|
||||||
|
prob: 0.5
|
||||||
|
configs:
|
||||||
|
DefenseStructure: CarpStatue
|
||||||
|
Mining: Carps
|
||||||
|
Megafauna: MobDragon
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC0-1.0",
|
||||||
|
"copyright": "created by deltanedas (github) for SS14",
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "statue"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unshaded"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 633 B |
Reference in New Issue
Block a user