Repository navigation
feat(items): add the talisman of resurrection #1461
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // <copyright file="TalismanOfResurrectionSpawnGatePlugIn.cs" company="MUnique"> | ||
| // Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
| // </copyright> | ||
|
|
||
| namespace MUnique.OpenMU.GameLogic.PlugIns; | ||
|
|
||
| using System.Runtime.InteropServices; | ||
| using MUnique.OpenMU.GameLogic.CastleSiege; | ||
| using MUnique.OpenMU.GameLogic.PlayerActions; | ||
| using MUnique.OpenMU.GameLogic.Views.Inventory; | ||
| using MUnique.OpenMU.PlugIns; | ||
|
|
||
| /// <summary> | ||
| /// A plugin which respawns a dead player at the place of its death, when it carries a Talisman of Resurrection | ||
| /// in its inventory. One talisman is used up by it. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// It doesn't apply in mini games, duels, guild wars and to the participants of a running castle siege, | ||
| /// which have their own spawn gates. It also doesn't apply when the player doesn't fulfill the requirements | ||
| /// of the map anymore, e.g. when it lost its wings on Icarus, so that it's evacuated to the safezone. | ||
| /// The item is configurable, by default it's the Talisman of Resurrection (13/69). | ||
| /// </remarks> | ||
| [PlugIn] | ||
| [Display(Name = nameof(MUnique.OpenMU.GameLogic.Properties.PlugInResources.TalismanOfResurrectionSpawnGatePlugIn_Name), Description = nameof(MUnique.OpenMU.GameLogic.Properties.PlugInResources.TalismanOfResurrectionSpawnGatePlugIn_Description), ResourceType = typeof(MUnique.OpenMU.GameLogic.Properties.PlugInResources))] | ||
| [Guid("5C057E6E-FECF-4216-AB78-1918AB00224E")] | ||
| public class TalismanOfResurrectionSpawnGatePlugIn : IPlayerSpawnGateSelectionPlugIn, ISupportCustomConfiguration<TalismanOfResurrectionSpawnGatePlugInConfiguration>, ISupportDefaultCustomConfiguration | ||
| { | ||
| /// <inheritdoc /> | ||
| public TalismanOfResurrectionSpawnGatePlugInConfiguration? Configuration { get; set; } | ||
|
|
||
| /// <inheritdoc /> | ||
| public async ValueTask SelectSpawnGateAsync(Player player, SpawnGateSelectionArgs args) | ||
| { | ||
| if (args.Gate is not null | ||
| || player.IsAlive | ||
| || player.CurrentMap is not { } map | ||
| || player.CurrentMiniGame is not null | ||
| || player.DuelRoom is not null | ||
| || player.GuildWarContext is not null | ||
|
Comment on lines
+37
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
During an active Castle Siege, participants use a separate Useful? React with 👍 / 👎. |
||
| || IsCastleSiegeParticipant(player) | ||
| || map.Definition.TryGetRequirementError(player, out _) | ||
| || player.Inventory is not { } inventory | ||
| || inventory.Items.FirstOrDefault(this.IsTalismanOfResurrection) is not { } talisman) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var position = player.Position; | ||
| args.Gate = new ExitGate | ||
| { | ||
| Map = map.Definition, | ||
|
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a lethal hit destroys a character's only flying mount on Icarus, Useful? React with 👍 / 👎. |
||
| X1 = position.X, | ||
| X2 = position.X, | ||
| Y1 = position.Y, | ||
| Y2 = position.Y, | ||
| }; | ||
|
|
||
| var slot = talisman.ItemSlot; | ||
| await inventory.RemoveItemAsync(talisman).ConfigureAwait(false); | ||
| await player.PersistenceContext.DeleteAsync(talisman).ConfigureAwait(false); | ||
|
Comment on lines
+59
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If a player disconnects during the three-second death delay on an ordinary map, Useful? React with 👍 / 👎.
Comment on lines
+59
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an operator enables stacking for the talisman by increasing its definition's durability, or configures another stackable resurrection item, these calls delete the entire stack for one resurrection. Useful? React with 👍 / 👎. |
||
| await player.InvokeViewPlugInAsync<IItemRemovedPlugIn>(p => p.RemoveItemAsync(slot)).ConfigureAwait(false); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public object CreateDefaultConfig() | ||
| { | ||
| return new TalismanOfResurrectionSpawnGatePlugInConfiguration(); | ||
| } | ||
|
|
||
| private static bool IsCastleSiegeParticipant(Player player) | ||
| { | ||
| return CastleSiegeContextResolver.GetContext(player) is { CurrentState: CastleSiegeState.Start } context | ||
| && context.GetPlayerJoinSide(player) != CastleSiegeJoinSide.None; | ||
| } | ||
|
|
||
| private bool IsTalismanOfResurrection(Item item) | ||
| { | ||
| var configuration = this.Configuration ??= new TalismanOfResurrectionSpawnGatePlugInConfiguration(); | ||
| return item.Definition is { } definition | ||
| && definition.Group == configuration.ItemGroup | ||
| && definition.Number == configuration.ItemNumber; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // <copyright file="TalismanOfResurrectionSpawnGatePlugInConfiguration.cs" company="MUnique"> | ||
| // Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
| // </copyright> | ||
|
|
||
| namespace MUnique.OpenMU.GameLogic.PlugIns; | ||
|
|
||
| /// <summary> | ||
| /// Configuration for the <see cref="TalismanOfResurrectionSpawnGatePlugIn"/>. | ||
| /// </summary> | ||
| public class TalismanOfResurrectionSpawnGatePlugInConfiguration | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the group of the item which respawns a dead player at the place of its death. | ||
| /// </summary> | ||
| [Display(ResourceType = typeof(PlugInResources), Name = nameof(PlugInResources.TalismanOfResurrectionSpawnGatePlugInConfiguration_ItemGroup_Caption))] | ||
| public byte ItemGroup { get; set; } = ItemConstants.TalismanOfResurrection.Group; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the number of the item which respawns a dead player at the place of its death. | ||
| /// </summary> | ||
| [Display(ResourceType = typeof(PlugInResources), Name = nameof(PlugInResources.TalismanOfResurrectionSpawnGatePlugInConfiguration_ItemNumber_Caption))] | ||
| public short ItemNumber { get; set; } = ItemConstants.TalismanOfResurrection.Number!.Value; | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.