Skip to content

Commit

Permalink
Merge pull request #485 from Timfa2112/gladiabot
Browse files Browse the repository at this point in the history
Port Gladiabot From EE PR
  • Loading branch information
FoxxoTrystan authored Jan 16, 2025
2 parents f2e51a6 + cc30b09 commit 66fa9f3
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Content.Server/NPC/FactionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace Content.Server.NPC;
/// </summary>
public sealed class FactionData
{
[ViewVariables]
public bool IsHostileToSelf;

[ViewVariables]
public HashSet<string> Friendly = new();

Expand Down
5 changes: 5 additions & 0 deletions Content.Server/NPC/Systems/NPCCombatSystem.Melee.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Numerics;
using Content.Server.NPC.Components;
using Content.Server.NPC.HTN;
using Content.Shared.CombatMode;
using Content.Shared.NPC;
using Robust.Shared.Map;
Expand All @@ -10,6 +11,7 @@ namespace Content.Server.NPC.Systems;

public sealed partial class NPCCombatSystem
{
[Dependency] private readonly IRobustRandom _rng = default!;
private const float TargetMeleeLostRange = 14f;

private void InitializeMelee()
Expand Down Expand Up @@ -114,5 +116,8 @@ private void Attack(EntityUid uid, NPCMeleeCombatComponent component, TimeSpan c
{
_melee.AttemptLightAttack(uid, weaponUid, weapon, component.Target);
}

if (Comp<HTNComponent>(uid).Blackboard.TryGetValue<float>("AttackDelayDeviation", out var dev, EntityManager))
weapon.NextAttack += TimeSpan.FromSeconds(_rng.NextFloat(-dev, dev));
}
}
9 changes: 7 additions & 2 deletions Content.Server/NPC/Systems/NpcFactionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ public bool IsEntityFriendly(EntityUid uidA, EntityUid uidB, NpcFactionMemberCom
if (!Resolve(uidA, ref factionA, false) || !Resolve(uidB, ref factionB, false))
return false;

return factionA.Factions.Overlaps(factionB.Factions) || factionA.FriendlyFactions.Overlaps(factionB.Factions);
var intersect = factionA.Factions.Intersect(factionB.Factions); // factions which have both ent and other as members
foreach (var faction in intersect)
if (_factions[faction].IsHostileToSelf)
return false;

return intersect.Count() > 0 || factionA.FriendlyFactions.Overlaps(factionB.Factions);
}

public bool IsFactionFriendly(string target, string with)
Expand Down Expand Up @@ -234,9 +239,9 @@ private void RefreshFactions()
faction => faction.ID,
faction => new FactionData
{
IsHostileToSelf = faction.Hostile.Contains(faction.ID),
Friendly = faction.Friendly.ToHashSet(),
Hostile = faction.Hostile.ToHashSet()

});

foreach (var comp in EntityQuery<NpcFactionMemberComponent>(true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ petting-success-mimebot = You pet {THE($target)} on {POSS-ADJ($target)} cold met
petting-success-cleanbot = You pet {THE($target)} on {POSS-ADJ($target)} damp metal head.
petting-success-medibot = You pet {THE($target)} on {POSS-ADJ($target)} sterile metal head.
petting-success-recycler = You pet {THE($target)} on {POSS-ADJ($target)} mildly threatening steel exterior.
petting-success-gladiabot = You pet {THE($target)} on {POSS-ADJ($target)} vicious cardboard head.
petting-failure-honkbot = You reach out to pet {THE($target)}, but {SUBJECT($target)} honks in refusal!
petting-failure-cleanbot = You reach out to pet {THE($target)}, but {SUBJECT($target)} {CONJUGATE-BE($target)} busy mopping!
petting-failure-mimebot = You reach out to pet {THE($target)}, but {SUBJECT($target)} {CONJUGATE-BE($target)} busy miming!
petting-failure-medibot = You reach out to pet {THE($target)}, but {POSS-ADJ($target)} syringe nearly stabs your hand!
petting-failure-gladiabot = You reach out to pet {THE($target)}, but {SUBJECT($target)} {CONJUGATE-BE($target)} only wants to fight!
## Rattling fences

Expand Down
70 changes: 70 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/gladiabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
- type: entity
parent: MobSiliconBase
id: MobGladiaBot
name: gladiabot
description: For glory!
components:
- type: Sprite
sprite: Mobs/Silicon/Bots/gladiabot.rsi
state: gladiabot
- type: Construction
graph: GladiaBot
node: bot
- type: SentienceTarget
flavorKind: station-event-random-sentience-flavor-mechanical
- type: UseDelay
delay: 1
- type: NpcFactionMember
factions:
- GladiabotFFA
- type: CombatMode
- type: MeleeWeapon
altDisarm: false
soundHit:
path: /Audio/Weapons/bladeslice.ogg
angle: 0
animation: WeaponArcPunch
damage:
types:
Slash: 3
- type: MobThresholds
thresholds:
0: Alive
40: Dead
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 30
behaviors:
- !type:TriggerBehavior
- trigger:
!type:DamageTrigger
damage: 40
behaviors:
- !type:SpawnEntitiesBehavior
spawn:
ProximitySensor:
min: 1
max: 1
- !type:SpawnEntitiesBehavior
spawn:
MaterialCloth1:
min: 1
max: 1
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: MovementSpeedModifier
baseWalkSpeed: 2
baseSprintSpeed: 3
- type: HTN
rootTask:
task: GladiabotCompound
blackboard:
AttackDelayDeviation: !type:Single
0.3
- type: InteractionPopup
interactSuccessString: petting-success-gladiabot
interactFailureString: petting-failure-gladiabot
interactSuccessSound:
path: /Audio/Ambience/Objects/periodic_beep.ogg
12 changes: 12 additions & 0 deletions Resources/Prototypes/NPCs/gladiabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- type: htnCompound
id: GladiabotCompound
branches:
- tasks:
- !type:HTNPrimitiveTask
operator: !type:UtilityOperator
proto: NearbyMeleeTargets
- !type:HTNCompoundTask
task: MeleeAttackTargetCompound
- tasks:
- !type:HTNCompoundTask
task: IdleCompound
25 changes: 25 additions & 0 deletions Resources/Prototypes/Recipes/Crafting/Graphs/bots/gladiabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- type: constructionGraph
id: GladiaBot
start: start
graph:
- node: start
edges:
- to: bot
steps:
- material: Cardboard
amount: 1
doAfter: 2
- tag: ProximitySensor
icon:
sprite: Objects/Misc/proximity_sensor.rsi
state: icon
name: proximity sensor
doAfter: 2
- tag: Shiv
icon:
sprite: Objects/Weapons/Melee/shiv.rsi
state: icon
name: shiv
doAfter: 2
- node: bot
entity: MobGladiaBot
13 changes: 13 additions & 0 deletions Resources/Prototypes/Recipes/Crafting/bots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,16 @@
icon:
sprite: Mobs/Silicon/Bots/supplybot.rsi
state: supplybot

- type: construction
name: gladiabot
id: gladiabot
graph: GladiaBot
startNode: start
targetNode: bot
category: construction-category-utilities
objectType: Item
description: This bot fights for honour and glory!
icon:
sprite: Mobs/Silicon/Bots/gladiabot.rsi
state: gladiabot
5 changes: 5 additions & 0 deletions Resources/Prototypes/ai_factions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@

- type: npcFaction
id: AnimalFriend

- type: npcFaction
id: GladiabotFFA
hostile:
- GladiabotFFA
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions Resources/Textures/Mobs/Silicon/Bots/gladiabot.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"license": "CC-BY-SA-3.0",
"copyright": "Tim Falken",
"states": [
{
"name": "gladiabot",
"delays": [
[
0.5,
0.2
]
]
}
]
}

0 comments on commit 66fa9f3

Please sign in to comment.