Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Egg Spider #301

Merged
merged 7 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ private void OnInit(EntityUid uid, MindSwapPowerComponent component, ComponentIn

_actions.AddAction(uid, ref component.MindSwapPowerAction, ActionMindSwap);

#if !DEBUG
#if !DEBUG
if (_actions.TryGetActionData(component.MindSwapPowerAction, out var action) && action?.UseDelay != null)
_actions.SetCooldown(component.MindSwapPowerAction, _gameTiming.CurTime,
_gameTiming.CurTime + (TimeSpan) action?.UseDelay!);
#endif
#endif
if (TryComp<PsionicComponent>(uid, out var psionic) && psionic.PsionicAbility == null)
psionic.PsionicAbility = component.MindSwapPowerAction;

Expand Down
133 changes: 133 additions & 0 deletions Content.Server/Backmen/Spider/SpiderVampireSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
using Content.Shared.Backmen.Spider.Components;
using Robust.Shared.Prototypes;
using Content.Server.Actions;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Mobs.Systems;
using Content.Server.Popups;
using Robust.Shared.GameObjects;
using Content.Shared.DoAfter;
using Robust.Shared.Audio;
using Content.Shared.Nutrition.AnimalHusbandry;
using Content.Shared.Nutrition.Components;
using Content.Server.Administration.Logs;
using Robust.Shared.Random;
using Robust.Shared.Player;
using Content.Shared.Database;
using Content.Shared.IdentityManagement;
using Robust.Shared.Timing;

namespace Content.Server.Backmen.Spider;

public sealed class SpiderVampireSystem : EntitySystem
{
[Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly HungerSystem _hunger = default!;
[Dependency] private readonly IAdminLogManager _adminLog = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SpiderVampireComponent, SpiderVampireEggActionEvent>(OnActionEggUsed);
SubscribeLocalEvent<SpiderVampireComponent, SpiderVampireEggDoAfterEvent>(OnActionEggUsedAfter);

SubscribeLocalEvent<SpiderVampireComponent, MapInitEvent>(OnMapInit);
}

#region Добавить скилл

[ValidatePrototypeId<EntityPrototype>] private const string SpiderVampireEggAction = "ActionSpiderVampireEgg";

private void OnMapInit(EntityUid uid, SpiderVampireComponent component, MapInitEvent args)
{
_action.AddAction(uid, ref component.SpiderVampireEggAction, SpiderVampireEggAction);
//_action.SetCooldown(component.SpiderVampireEggAction, _gameTiming.CurTime,
// _gameTiming.CurTime + (TimeSpan) component.InitCooldown);
_action.SetCharges(component.SpiderVampireEggAction, component.Charges);
}

#endregion

#region Нажали на кнопку

private static readonly SoundSpecifier HairballPlay =
new SoundPathSpecifier("/Audio/Backmen/Effects/Species/hairball.ogg", AudioParams.Default.WithVariation(0.15f));

private void OnActionEggUsed(EntityUid uid, SpiderVampireComponent component, SpiderVampireEggActionEvent args)
{
if (args.Handled)
return;

if (HasComp<InfantComponent>(uid))
{
_popupSystem.PopupEntity("Еще не дорос", uid, uid);
return;
}

if (_mobState.IsIncapacitated(uid))
{
_popupSystem.PopupEntity("хуйня какая-то", uid, uid);
return;
}

if (TryComp<HungerComponent>(uid, out var hunger) && _hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay)
{
_popupSystem.PopupEntity("жрать хочу", uid, uid);
return;
}

if (TryComp<ThirstComponent>(uid, out var thirst) && thirst.CurrentThirstThreshold < ThirstThreshold.Okay)
{
_popupSystem.PopupEntity("пить хочу", uid, uid);
return;
}

_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, uid, component.UsingEggTime,
new SpiderVampireEggDoAfterEvent(), uid, used: uid)
{
BreakOnUserMove = true,
BreakOnDamage = true,
});

_audio.Play(HairballPlay, Filter.Pvs(uid, entityManager: EntityManager), Transform(uid).Coordinates, true,
AudioParams.Default.WithVariation(0.025f));
args.Handled = true;
}

#endregion

#region После каста

private void OnActionEggUsedAfter(EntityUid uid, SpiderVampireComponent component,
SpiderVampireEggDoAfterEvent args)
{
if (args.Handled)
return;
if (args.Cancelled)
{
if (_action.TryGetActionData(component.SpiderVampireEggAction, out var data))
{
_action.SetCharges(component.SpiderVampireEggAction, data.Charges+1);
_action.SetCooldown(component.SpiderVampireEggAction, _gameTiming.CurTime,
_gameTiming.CurTime + TimeSpan.FromSeconds(1));
_action.SetEnabled(component.SpiderVampireEggAction, true);
}
return;
}

var xform = Transform(uid);
var offspring = Spawn(component.SpawnEgg, xform.Coordinates.Offset(_random.NextVector2(0.3f)));
_hunger.ModifyHunger(uid, -component.HungerPerBirth);
_adminLog.Add(LogType.Action, $"{ToPrettyString(uid)} gave birth to {ToPrettyString(offspring)}.");
_popupSystem.PopupEntity(
Loc.GetString("reproductive-birth-popup", ("parent", Identity.Entity(uid, EntityManager))), uid);
}

#endregion
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Content.Shared.Backmen.Spider;
namespace Content.Shared.Backmen.Spider.Components;

[RegisterComponent]
public sealed partial class IgnoreSpiderWebArachneClassicComponent : Component
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

using Robust.Shared.GameStates;
using Content.Shared.DoAfter;
using Content.Shared.FixedPoint;
using Robust.Shared.Serialization;
using Robust.Shared.Prototypes;

namespace Content.Shared.Backmen.Spider.Components;


[RegisterComponent, NetworkedComponent]
public sealed partial class SpiderVampireComponent : Component
{
public EntityUid? SpiderVampireEggAction;
[DataField]
public float UsingEggTime = 20;

[DataField("charges")]
public int Charges = 1;

[DataField]
public TimeSpan InitCooldown = TimeSpan.FromMinutes(5);

[DataField("spawnEgg")]
public EntProtoId SpawnEgg = "FoodEggSpiderVampire";

/// <summary>
/// How much hunger is consumed when an entity
/// gives birth. A balancing tool to require feeding.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float HungerPerBirth = 75f;
}

[Serializable, NetSerializable]
public sealed partial class SpiderVampireEggDoAfterEvent : SimpleDoAfterEvent
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared.Actions;

namespace Content.Shared.Backmen.Spider.Components;

public sealed partial class SpiderVampireEggActionEvent : InstantActionEvent {}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
ent-SpiderWebArachneClassicAction = Сплести паутину
.desc = Вы сплетаете паутину под собой.
ent-ActionSpiderVampireEgg = Снести яйцо
.desc = Снесите яйцо для продолжения потомства
13 changes: 13 additions & 0 deletions Resources/Prototypes/Backmen/Actions/arachne.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@
useDelay: 180
icon: Interface/Actions/web.png
event: !type:SpiderWebActionEvent

- type: entity
id: ActionSpiderVampireEgg
name: name-Spider-Vampire-Egg
description: description-Spider-Vampire-Egg
noSpawn: true
components:
- type: InstantAction
icon: { sprite: Backmen/Objects/Misc/eggspider.rsi, state: icon }
priority: -10
event: !type:SpiderVampireEggActionEvent
charges: 1
useDelay: 30
Empty file.
5 changes: 5 additions & 0 deletions Resources/Prototypes/Backmen/Entities/Mobs/NPC/mutants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@
whitelist:
tags:
- ArachneWeb
- type: SpiderVampire
spawnEgg: FoodEggSpiderVampire

- type: entity
name: Чёрная вдова
Expand Down Expand Up @@ -394,3 +396,6 @@
description: ghost-role-information-giant-spider-vampire-description
rules: No antagonist restrictions. Just don't talk in emote; you have telepathic chat.
- type: GhostTakeoverAvailable
- type: SpiderVampire
spawnEgg: FoodEggSpiderVampire
charges: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
- type: entity
parent: [FoodInjectableBase, ItemHeftyBase]
id: FoodEggBaseVampire
description: An egg!
abstract: true
components:
- type: Food
trash: Eggshells
- type: Sprite
sprite: Backmen/Objects/Misc/eggspider.rsi
- type: Item
sprite: Backmen/Objects/Misc/eggspider.rsi
size: Tiny
- type: SolutionContainerManager
solutions:
food:
maxVol: 6
reagents:
- ReagentId: Egg
Quantity: 6
- type: SolutionSpiker
sourceSolution: food
ignoreEmpty: true
popup: spike-solution-egg
- type: DeleteOnTrigger
- type: DamageOnHighSpeedImpact
minimumSpeed: 0.1
damage:
types:
Blunt: 1
- type: Damageable
damageContainer: Biological
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 1
behaviors:
- !type:PlaySoundBehavior
sound:
collection: desecration
- !type:SpillBehavior
solution: food
- !type:SpawnEntitiesBehavior
spawn:
Eggshells:
min: 1
max: 1
# Wow double-yolk you're so lucky!
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: PointLight
radius: 1.5
energy: 3
color: "#4faffb"

- type: entity
parent: FoodEggBaseVampire
id: FoodEggSpiderVampire
name: Яйцо паука
suffix: Vampire
components:
- type: Sprite
sprite: Backmen/Objects/Misc/eggspider.rsi
layers:
- state: icon
map: [ "enum.DamageStateVisualLayers.Base" ]
- type: PointLight
radius: 1.5
energy: 3
color: "#4faffb"
- type: Timer
- type: TimedSpawner
prototypes:
- MobGiantSpiderVampireAngry
intervalSeconds: 300
minimumEntitiesSpawned: 1
maximumEntitiesSpawned: 1
- type: TimedDespawn
lifetime: 301

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- type: entity
name: Saber of the Leader of the Red Order
name: Saber of the Leader of the Red Orden
parent: BaseItem
id: OrdenSabre
description: Unusual saber. Instead of a blade, this weapon uses the teeth of a space dragon, which cut and cling to the victim's flesh, tearing open wounds. Nightmare weapon.
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Backmen/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@
- type: Tag
id: MagazinePistolTopSubMachineGun


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions Resources/Textures/Backmen/Objects/Misc/eggspider.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Made by Nimfar11 (github) for SS14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "blue-inhand-right",
"directions": 4
},
{
"name": "blue-inhand-left",
"directions": 4
}
]
}
Loading