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

Wizard Summon Guns/Magic (#32692) #8

Merged
merged 2 commits into from
Nov 17, 2024
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 @@ -53,7 +53,7 @@ private void OnPersonAssigned(EntityUid uid, PickRandomPersonComponent comp, ref
return;

// no other humans to kill
var allHumans = _mind.GetAliveHumansExcept(args.MindId);
var allHumans = _mind.GetAliveHumans(args.MindId);
if (allHumans.Count == 0)
{
args.Cancelled = true;
Expand All @@ -77,14 +77,14 @@ private void OnHeadAssigned(EntityUid uid, PickRandomHeadComponent comp, ref Obj
return;

// no other humans to kill
var allHumans = _mind.GetAliveHumansExcept(args.MindId);
var allHumans = _mind.GetAliveHumans(args.MindId);
if (allHumans.Count == 0)
{
args.Cancelled = true;
return;
}

var allHeads = new List<EntityUid>();
var allHeads = new HashSet<Entity<MindComponent>>();
foreach (var person in allHumans)
{
if (TryComp<MindComponent>(person, out var mind) && mind.OwnedEntity is { } ent && HasComp<CommandStaffComponent>(ent))
Expand Down
5 changes: 5 additions & 0 deletions Content.Server/Store/Systems/StoreSystem.Ui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ private void OnBuyRequest(EntityUid uid, StoreComponent component, StoreBuyListi
RaiseLocalEvent(buyer, listing.ProductEvent);
}

if (listing.DisableRefund)
{
component.RefundAllowed = false;
}

//log dat shit.
_admin.Add(LogType.StorePurchase,
LogImpact.Low,
Expand Down
23 changes: 23 additions & 0 deletions Content.Shared/Magic/Events/RandomGlobalSpawnSpellEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Content.Shared.Actions;
using Content.Shared.Storage;
using Robust.Shared.Audio;

namespace Content.Shared.Magic.Events;

public sealed partial class RandomGlobalSpawnSpellEvent : InstantActionEvent, ISpeakSpell
{
/// <summary>
/// The list of prototypes this spell can spawn, will select one randomly
/// </summary>
[DataField]
public List<EntitySpawnEntry> Spawns = new();

/// <summary>
/// Sound that will play globally when cast
/// </summary>
[DataField]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Magic/staff_animation.ogg");

[DataField]
public string? Speech { get; private set; }
}
43 changes: 42 additions & 1 deletion Content.Shared/Magic/SharedMagicSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using Content.Shared.Actions;
using Content.Shared.Body.Components;
using Content.Shared.Body.Systems;
Expand All @@ -7,19 +7,25 @@
using Content.Shared.Doors.Systems;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Humanoid;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Lock;
using Content.Shared.Magic.Components;
using Content.Shared.Magic.Events;
using Content.Shared.Maps;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Speech.Muting;
using Content.Shared.Storage;
using Content.Shared.Tag;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Network;
Expand Down Expand Up @@ -53,6 +59,9 @@ public abstract class SharedMagicSystem : EntitySystem
[Dependency] private readonly LockSystem _lock = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;

public override void Initialize()
{
Expand All @@ -67,6 +76,7 @@ public override void Initialize()
SubscribeLocalEvent<SmiteSpellEvent>(OnSmiteSpell);
SubscribeLocalEvent<KnockSpellEvent>(OnKnockSpell);
SubscribeLocalEvent<ChargeSpellEvent>(OnChargeSpell);
SubscribeLocalEvent<RandomGlobalSpawnSpellEvent>(OnRandomGlobalSpawnSpell);

// Spell wishlist
// A wishlish of spells that I'd like to implement or planning on implementing in a future PR
Expand Down Expand Up @@ -501,6 +511,37 @@ private void OnChargeSpell(ChargeSpellEvent ev)
_gunSystem.UpdateBasicEntityAmmoCount(wand.Value, basicAmmoComp.Count.Value + ev.Charge, basicAmmoComp);
}
// End Charge Spells
#endregion
#region Global Spells

private void OnRandomGlobalSpawnSpell(RandomGlobalSpawnSpellEvent ev)
{
if (!_net.IsServer || ev.Handled || !PassesSpellPrerequisites(ev.Action, ev.Performer) || ev.Spawns is not { } spawns)
return;

ev.Handled = true;
Speak(ev);

var allHumans = _mind.GetAliveHumans();

foreach (var human in allHumans)
{
if (!human.Comp.OwnedEntity.HasValue)
continue;

var ent = human.Comp.OwnedEntity.Value;

var mapCoords = _transform.GetMapCoordinates(ent);
foreach (var spawn in EntitySpawnCollection.GetSpawns(spawns, _random))
{
var spawned = Spawn(spawn, mapCoords);
_hands.PickupOrDrop(ent, spawned);
}
}

_audio.PlayGlobal(ev.Sound, ev.Performer);
}

#endregion
// End Spells
#endregion
Expand Down
19 changes: 8 additions & 11 deletions Content.Shared/Mind/SharedMindSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,22 +532,19 @@ public string MindOwnerLoggingString(MindComponent mind)
/// <summary>
/// Returns a list of every living humanoid player's minds, except for a single one which is exluded.
/// </summary>
public List<EntityUid> GetAliveHumansExcept(EntityUid exclude)
public HashSet<Entity<MindComponent>> GetAliveHumans(EntityUid? exclude = null)
{
var mindQuery = EntityQuery<MindComponent>();

var allHumans = new List<EntityUid>();
var allHumans = new HashSet<Entity<MindComponent>>();
// HumanoidAppearanceComponent is used to prevent mice, pAIs, etc from being chosen
var query = EntityQueryEnumerator<MindContainerComponent, MobStateComponent, HumanoidAppearanceComponent>();
while (query.MoveNext(out var uid, out var mc, out var mobState, out _))
var query = EntityQueryEnumerator<MobStateComponent, HumanoidAppearanceComponent>();
while (query.MoveNext(out var uid, out var mobState, out _))
{
// the player needs to have a mind and not be the excluded one
if (mc.Mind == null || mc.Mind == exclude)
// the player needs to have a mind and not be the excluded one +
// the player has to be alive
if (!TryGetMind(uid, out var mind, out var mindComp) || mind == exclude || !_mobState.IsAlive(uid, mobState))
continue;

// the player has to be alive
if (_mobState.IsAlive(uid, mobState))
allHumans.Add(mc.Mind.Value);
allHumans.Add(new Entity<MindComponent>(mind, mindComp));
}

return allHumans;
Expand Down
16 changes: 13 additions & 3 deletions Content.Shared/Store/ListingPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public ListingData(ListingData other) : this(
other.Categories,
other.OriginalCost,
other.RestockTime,
other.DiscountDownTo
other.DiscountDownTo,
other.DisableRefund
)
{

Expand All @@ -63,7 +64,8 @@ public ListingData(
HashSet<ProtoId<StoreCategoryPrototype>> categories,
IReadOnlyDictionary<ProtoId<CurrencyPrototype>, FixedPoint2> originalCost,
TimeSpan restockTime,
Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> dataDiscountDownTo
Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> dataDiscountDownTo,
bool disableRefund
)
{
Name = name;
Expand All @@ -84,6 +86,7 @@ Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> dataDiscountDownTo
OriginalCost = originalCost;
RestockTime = restockTime;
DiscountDownTo = new Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2>(dataDiscountDownTo);
DisableRefund = disableRefund;
}

[ViewVariables]
Expand Down Expand Up @@ -194,6 +197,12 @@ Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> dataDiscountDownTo
[DataField]
public Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> DiscountDownTo = new();

/// <summary>
/// Whether or not to disable refunding for the store when the listing is purchased from it.
/// </summary>
[DataField]
public bool DisableRefund = false;

public bool Equals(ListingData? listing)
{
if (listing == null)
Expand Down Expand Up @@ -287,7 +296,8 @@ public ListingDataWithCostModifiers(ListingData listingData)
listingData.Categories,
listingData.OriginalCost,
listingData.RestockTime,
listingData.DiscountDownTo
listingData.DiscountDownTo,
listingData.DisableRefund
)
{
}
Expand Down
4 changes: 3 additions & 1 deletion Resources/Locale/en-US/magic/spells-actions.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
action-speech-spell-forcewall = TARCOL MINTI ZHERI
action-speech-spell-forcewall = TARCOL MINTI ZHERI
action-speech-spell-knock = AULIE OXIN FIERA
action-speech-spell-smite = EI NATH!
action-speech-spell-summon-magicarp = AIE KHUSE EU
action-speech-spell-fireball = ONI'SOMA!
action-speech-spell-summon-guns = YOR'NEE VES-KORFA
action-speech-spell-summon-magic = RYGOIN FEMA-VERECO
8 changes: 7 additions & 1 deletion Resources/Locale/en-US/store/spellbook-catalog.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Spells
# Spells
spellbook-fireball-name = Fireball
spellbook-fireball-desc = Get most crew exploding with rage when they see this fireball heading toward them!

Expand Down Expand Up @@ -33,6 +33,12 @@ spellbook-wand-polymorph-carp-description = For when you need a carp filet quick
spellbook-event-summon-ghosts-name = Summon Ghosts
spellbook-event-summon-ghosts-description = Who ya gonna call?

spellbook-event-summon-guns-name = Summon Guns
spellbook-event-summon-guns-description = AK47s for everyone! Places a random gun in front of everybody. Disables refunds when bought!

spellbook-event-summon-magic-name = Summon Magic
spellbook-event-summon-magic-description = Places a random magical item in front of everybody. Nothing could go wrong! Disables refunds when bought!

# Upgrades
spellbook-upgrade-fireball-name = Upgrade Fireball
spellbook-upgrade-fireball-description = Upgrades Fireball to a maximum of level 3!
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Catalog/Fills/Boxes/syndicate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
amount: 2
- id: WeaponBaguette
- id: SyndicateMicrowaveMachineCircuitboard
- id: PaperWrittenCombatBakeryKit
- id: PaperWrittenCombatBakeryKit
30 changes: 29 additions & 1 deletion Resources/Prototypes/Catalog/spellbook_catalog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Offensive
# Offensive
- type: listing
id: SpellbookFireball
name: spellbook-fireball-name
Expand Down Expand Up @@ -132,6 +132,34 @@
- !type:ListingLimitedStockCondition
stock: 1

- type: listing
id: SpellbookEventSummonGuns
name: spellbook-event-summon-guns-name
description: spellbook-event-summon-guns-description
productAction: ActionSummonGuns
cost:
WizCoin: 2
categories:
- SpellbookEvents
conditions:
- !type:ListingLimitedStockCondition
stock: 1
disableRefund: true

- type: listing
id: SpellbookEventSummonMagic
name: spellbook-event-summon-magic-name
description: spellbook-event-summon-magic-description
productAction: ActionSummonMagic
cost:
WizCoin: 2
categories:
- SpellbookEvents
conditions:
- !type:ListingLimitedStockCondition
stock: 1
disableRefund: true

# Upgrades
- type: listing
id: SpellbookFireballUpgrade
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@
id: SyringeStimulants
components:
- type: Label
currentLabel: reagent-name-hyperzine
currentLabel: reagent-name-stimulants
- type: SolutionContainerManager
solutions:
injector:
Expand Down
Loading
Loading