Skip to content

Commit

Permalink
Guardians code tweaks (#927)
Browse files Browse the repository at this point in the history
* Restore code.

* AI? No, ghost.

* Update GuardianComponent.cs
  • Loading branch information
dvir001 committed Jan 29, 2024
1 parent f9b5422 commit f41093d
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 12 deletions.
5 changes: 5 additions & 0 deletions Content.Server/Guardian/GuardianComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ public sealed partial class GuardianComponent : Component
/// </summary>
public bool GuardianLoose = false;

/// <summary>
/// If the guardian can be AI based
/// </summary>
[DataField("ai")]
public bool Ai;
}
}
11 changes: 11 additions & 0 deletions Content.Server/Guardian/GuardianSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ private void CheckGuardianMove(
RetractGuardian(hostUid, hostComponent, guardianUid, guardianComponent);
}

private bool CanRelease(EntityUid guardian)
{
return HasComp<ActorComponent>(guardian);
}

private void ReleaseGuardian(EntityUid host, GuardianHostComponent hostComponent, EntityUid guardian, GuardianComponent guardianComponent)
{
if (guardianComponent.GuardianLoose)
Expand All @@ -309,6 +314,12 @@ private void ReleaseGuardian(EntityUid host, GuardianHostComponent hostComponent
return;
}

if (!guardianComponent.Ai && !CanRelease(guardian))
{
_popupSystem.PopupEntity(Loc.GetString("guardian-no-soul"), host, host);
return;
}

DebugTools.Assert(hostComponent.GuardianContainer.Contains(guardian));
hostComponent.GuardianContainer.Remove(guardian);
DebugTools.Assert(!hostComponent.GuardianContainer.Contains(guardian));
Expand Down
27 changes: 15 additions & 12 deletions Resources/Prototypes/Entities/Mobs/Player/guardian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
# From the uplink injector
- type: entity
name: Holoparasite
suffix: Ghost # Frontier
id: MobHoloparasiteGuardian
parent: MobGuardianBase
description: A mesmerising whirl of hard-light patterns weaves a marvelous, yet oddly familiar visage. It stands proud, tuning into its owner's life to sustain itself.
Expand All @@ -129,16 +130,17 @@
map: [ "enum.DamageStateVisualLayers.BaseUnshaded" ]
color: "#40a7d7"
shader: unshaded
- type: NpcFactionMember
factions:
- Syndicate
- type: HTN
rootTask:
task: SimpleHumanoidHostileCompound
# - type: NpcFactionMember
# factions:
# - Syndicate
# - type: HTN # Frontier
# rootTask:
# task: SimpleHumanoidHostileCompound

# From Wizard deck of cards
- type: entity
name: Ifrit
suffix: Ghost # Frontier
parent: MobGuardianBase
id: MobIfritGuardian
description: A corrupted jinn, ripped from fitra to serve the wizard's petty needs. It stands wicked, tuning into it's owner's life to sustain itself.
Expand All @@ -165,6 +167,7 @@

- type: entity
name: HoloClown
suffix: Ghost # Frontier
id: MobHoloClownGuardian
parent: MobGuardianBase
description: A mesmerising whirl of hard-light patterns weaves a blue colored clown of dubious origin.
Expand Down Expand Up @@ -236,12 +239,12 @@
- type: RandomMetadata
nameSegments:
- names_clown
- type: NpcFactionMember
factions:
- Syndicate
- type: HTN
rootTask:
task: SimpleHumanoidHostileCompound
# - type: NpcFactionMember
# factions:
# - Syndicate
# - type: HTN # Frontier
# rootTask:
# task: SimpleHumanoidHostileCompound

- type: entity
id: ActionToggleGuardian
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- type: entity
name: holoparasite injector
suffix: Ghost # Frontier
id: HoloparasiteInjector
parent: BaseItem
description: A complex artwork of handheld machinery allowing the user to host a holoparasite guardian.
Expand All @@ -13,6 +14,7 @@
- type: entity
name: holoclown injector
parent: HoloparasiteInjector
suffix: Ghost # Frontier
id: HoloClownInjector
description: A complex artwork of handheld machinery allowing the user to host a holoclown guardian.
components:
Expand All @@ -22,6 +24,7 @@
- type: entity
name: magical lamp
id: MagicalLamp
suffix: Ghost # Frontier
parent: BaseItem
description: The wizard federation had to cut costs after the jinn merchandise scandal somehow.
components:
Expand All @@ -34,6 +37,7 @@

- type: entity
name: holoparasite box
suffix: Ghost # Frontier
parent: BoxCardboard
id: BoxHoloparasite
description: A box containing a holoparasite injector
Expand All @@ -52,6 +56,7 @@

- type: entity
name: holoclown box
suffix: Ghost # Frontier
parent: BoxCardboard
id: BoxHoloclown
description: A box containing a holoclown injector
Expand Down
37 changes: 37 additions & 0 deletions Resources/Prototypes/_NF/Entities/Mobs/Player/guardian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# From the uplink injector
- type: entity
id: MobHoloparasiteGuardianAI
parent: MobHoloparasiteGuardian
suffix: Ghost, AI
components:
- type: Guardian
ai: true
- type: NpcFactionMember
factions:
- Syndicate
- type: HTN
rootTask:
task: SimpleHumanoidHostileCompound

# From Wizard deck of cards
- type: entity
id: MobIfritGuardianAI
parent: MobIfritGuardian
suffix: Ghost, AI
components:
- type: Guardian
ai: true

- type: entity
id: MobHoloClownGuardianAI
parent: MobHoloClownGuardian
suffix: Ghost, AI
components:
- type: Guardian
ai: true
- type: NpcFactionMember
factions:
- Syndicate
- type: HTN
rootTask:
task: SimpleHumanoidHostileCompound
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
- type: entity
id: HoloparasiteInjectorAI
parent: HoloparasiteInjector
suffix: Ghost, AI
components:
- type: GuardianCreator
guardianProto: MobHoloparasiteGuardianAI

- type: entity
parent: HoloClownInjector
id: HoloClownInjectorAI
suffix: Ghost, AI
components:
- type: GuardianCreator
guardianProto: MobHoloClownGuardianAI

- type: entity
id: MagicalLampAI
parent: MagicalLamp
suffix: Ghost, AI
components:
- type: GuardianCreator
guardianProto: MobIfritGuardianAI

- type: entity
parent: BoxHoloparasite
id: BoxHoloparasiteAI
suffix: Ghost, AI
components:
- type: StorageFill
contents:
- id: HoloparasiteInjectorAI
- id: HoloparasiteInfo
- id: ClothingHeadHatBizarreSoft
- type: Sprite
layers:
- state: box
- state: holo
- type: StaticPrice
price: 1500

- type: entity
parent: BoxHoloclown
id: BoxHoloclownAI
suffix: Ghost, AI
components:
- type: StorageFill
contents:
- id: HoloClownInjectorAI
- id: ToyFigurineHoloClown
- id: ToyHammer
- type: Sprite
layers:
- state: box_hug
- state: holo
- type: Tag
tags:
- BoxHug
- type: StaticPrice
price: 1500

0 comments on commit f41093d

Please sign in to comment.