Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
cf29196
first commit
ze-dom Apr 30, 2026
7be1f3e
Merge branch 'master' into DK_master_tree_finishup
ze-dom May 2, 2026
d21e5fd
Double wield damage fix
ze-dom May 6, 2026
722e876
Finished rageful blow mastery durability reduction effect
ze-dom May 6, 2026
25da2be
Added update plugins
ze-dom May 7, 2026
c65ef5a
Updated plugins
ze-dom May 7, 2026
6022df1
Small fix
ze-dom May 7, 2026
47aa81d
small improvement
ze-dom May 8, 2026
b70dfd5
update plugin fix
ze-dom May 8, 2026
05440a9
Corrected chance equality comparison
ze-dom May 8, 2026
894924f
Requested changes
ze-dom May 14, 2026
c951f2c
minor changes
ze-dom May 14, 2026
f8c0142
Changed parameter name
ze-dom May 14, 2026
92e3139
Updated update plugins
ze-dom May 18, 2026
7f60b27
Added some tests, fixed others
ze-dom May 19, 2026
0107e04
Minor tweaks
ze-dom May 19, 2026
5e6bb5a
Merge branch 'master' into DK_master_tree_finishup
ze-dom May 25, 2026
2afe07a
Merge branch 'master' into DK_master_tree_finishup
ze-dom May 28, 2026
2f0883a
reverted remaining changes
ze-dom May 28, 2026
b18206c
Merge branch 'master' into DK_master_tree_finishup
ze-dom May 31, 2026
5765ca0
Added missing doc tag
ze-dom Jun 3, 2026
6f094d3
Merge branch 'master' into DK_master_tree_finishup
ze-dom Jun 12, 2026
96a0006
upgrade web admin to bootstrap 5.3.8
eduardosmaniotto Jun 15, 2026
a3081c0
chore: style cleanup and fixes
eduardosmaniotto Jun 16, 2026
ccc6aba
fix nav link and table lines
eduardosmaniotto Jun 16, 2026
fa73bfc
chore: convert theme.css to Theme.scss
eduardosmaniotto Jun 16, 2026
c0cce58
build scss quiently
eduardosmaniotto Jun 16, 2026
b4e1187
include min version in sass build
eduardosmaniotto Jun 16, 2026
48047b1
chore: add sticky to popup form-actions
eduardosmaniotto Jun 16, 2026
f3c43ed
fix offlevel command reconnecting due to client and player count
eduardosmaniotto Jun 18, 2026
ed0982d
fix(/offlevel): send close-game packet and let PlayerDisconnected eve…
eduardosmaniotto Jun 18, 2026
8ed2813
Merge branch 'chore/warnings-part2' into bugfix/offlevel-reconnect
eduardosmaniotto Jun 21, 2026
5967073
bugfix: offlevel jewel pickup
eduardosmaniotto Jun 21, 2026
4800abd
fix: cross-context entity corruption in offline player
eduardosmaniotto Jun 21, 2026
ba5f643
Merge branch 'master' into DK_master_tree_finishup
ze-dom Jun 22, 2026
59b0a34
Adjusted to merged movement speed factor changes
ze-dom Jun 22, 2026
0230e00
Retrieve stun effect locally
ze-dom Jun 22, 2026
42a71da
Updated plugin date
ze-dom Jun 22, 2026
ea28501
Bugfix
ze-dom Jun 22, 2026
2b4f9c1
Gemini review fixes
ze-dom Jun 22, 2026
2a5198e
Merge branch 'master' into bugfix/offlevel-reconnect
eduardosmaniotto Jun 23, 2026
4234ff1
chore: minor code review adjustments
eduardosmaniotto Jun 23, 2026
a9f84e9
Merge branch 'master' into chore/bootstrap-5
eduardosmaniotto Jun 23, 2026
c7cf76a
chore: minor code review adjustments
eduardosmaniotto Jun 23, 2026
305fdff
delete shared.css.map
eduardosmaniotto Jun 23, 2026
a6dfec8
Fix Rage Fighter buff skills in offline player helper
Rhefew Jun 24, 2026
ad600ed
fix(npc): give Christine the General Goods Merchant a store
nolt Jun 17, 2026
92ef5d2
feat(npc): make Market Union Member Julia warp to/from the Loren Market
nolt Jun 24, 2026
b4d9e6b
fix offline helper races, disposal ordering, and Zen-exhaustion ghost…
eduardosmaniotto Jun 24, 2026
afd5cb1
feature: allow multi-select on map object filters
eduardosmaniotto Jun 25, 2026
7a79be6
feature: copy client MuHelper behaviour on repair
eduardosmaniotto Jun 25, 2026
aac6033
feature: appy map images to MapEditor; refactor: unify Gate and Monst…
eduardosmaniotto Jun 26, 2026
1430a76
fix: zoom behavior
eduardosmaniotto Jun 26, 2026
33aff5a
revert new map images and use nicer colors instead
eduardosmaniotto Jun 26, 2026
2f56efb
feature: implement livemap follow player
eduardosmaniotto Jun 27, 2026
bc32e42
fix: livemap layout
eduardosmaniotto Jun 27, 2026
08ca9ee
feature: shift click to cycle overlapping object in map editor
eduardosmaniotto Jun 27, 2026
02a3d38
Fix Golden Invasion announcement to point at the dragon's real map
nolt Jun 27, 2026
e5f130a
feature: export/import map spawns + replace Blazored Modal with custo…
eduardosmaniotto Jun 28, 2026
ad1bdbf
codacy: minor code fixes
eduardosmaniotto Jun 28, 2026
3b2be48
fix: btn-close in dark mode
eduardosmaniotto Jun 28, 2026
edaf262
chore: reduce custom theme code and replace with boostrap 5 defaults
eduardosmaniotto Jun 28, 2026
12f0c9d
Restrict Golden Dragon spawn maps to Lorencia, Noria, Devias
nolt Jun 29, 2026
a6ee03c
normalize back and warning button
eduardosmaniotto Jun 30, 2026
c91db29
remove duplicate css class
eduardosmaniotto Jul 2, 2026
a2b3ca5
fix(npc): set Quantity=1 on Julia's Lorencia warp spawn
nolt Jul 2, 2026
a67553a
normalize edit button
eduardosmaniotto Jul 3, 2026
c1afecc
delete unused boostrap lib files
eduardosmaniotto Jul 3, 2026
6339f6f
Fix async self-deadlock in MuHelper on Zen depletion
Rhefew Jul 3, 2026
8562794
Catch JSDisconnectedException in JsViewPlugInBase to prevent log spam…
Rhefew Jul 3, 2026
fda5d3b
feat(skills): allow self and party buff casting in safezones, allow s…
Rhefew Jul 5, 2026
918101e
fix(docs): rename QuestProgressExtended packet definition to C2 forma…
Rhefew Jul 5, 2026
fefed4f
feat(security): implement walk and attack speedhack anti-cheat checks…
Rhefew Jul 5, 2026
24ee47f
fix(network): address code review feedback on IP resolver factory
Rhefew Jul 5, 2026
ac9a52f
Merge remote-tracking branch 'origin/feature/skills-safezone-fixes'
Rhefew Jul 5, 2026
b2a08e5
Merge remote-tracking branch 'origin/feature/speedhack-anti-cheat'
Rhefew Jul 5, 2026
e74744a
Merge remote-tracking branch 'origin/fix/packet-docs-and-ip-resolver'
Rhefew Jul 5, 2026
6e5150d
Fix player disconnection ghost hangs and configure TCP keep-alive
Rhefew Jul 5, 2026
1298e7d
Merge pull request #803 from nolt/fix-empty-merchant-stores
sven-n Jul 5, 2026
7922ff3
Merge pull request #808 from eduardosmaniotto/chore/bootstrap-5
sven-n Jul 5, 2026
4b9c4f5
Merge branch 'master' into bugfix/offlevel-reconnect
eduardosmaniotto Jul 5, 2026
3afa7e2
add missing item constant for jewels, implement code review changes t…
eduardosmaniotto Jul 5, 2026
2d83199
removed unused imports
eduardosmaniotto Jul 5, 2026
b399ea7
Merge branch 'master' into feature/map-editor2
eduardosmaniotto Jul 5, 2026
ab437c2
Merge pull request #810 from nolt/fix-golden-invasion-announce-map
sven-n Jul 5, 2026
808b469
udpate shared.min.css
eduardosmaniotto Jul 5, 2026
e3e4db9
Merge pull request #806 from eduardosmaniotto/bugfix/offlevel-reconnect
sven-n Jul 5, 2026
bb20680
Merge branch 'master' into feature/map-editor2
eduardosmaniotto Jul 5, 2026
71cfe6f
fix js return block identation
eduardosmaniotto Jul 5, 2026
dea1756
code review: apply code suggestions
eduardosmaniotto Jul 5, 2026
c09c040
Merge branch 'feature/map-editor2' into feature/map-editor-export
eduardosmaniotto Jul 5, 2026
98b9c08
remove gates from import. normalize z-index
eduardosmaniotto Jul 5, 2026
dbb8242
remove Blazored.Modal package references
eduardosmaniotto Jul 5, 2026
e6e6a99
reduce codacy warnings
eduardosmaniotto Jul 5, 2026
2486973
feature: create white wizard invasion
eduardosmaniotto Jul 6, 2026
1c7daf2
feature: limit white wizard ring in inventory
eduardosmaniotto Jul 6, 2026
8b6d282
review: fix potential race condition
eduardosmaniotto Jul 6, 2026
0e2c8be
replace bless with ItemConstants
eduardosmaniotto Jul 6, 2026
5ece735
fix BroadcastMonsterDeathAsync and add localized message
eduardosmaniotto Jul 6, 2026
0ceeeba
fix codacy warning by using InvasionGameServerState
eduardosmaniotto Jul 6, 2026
e73ace1
standarize invasion non-required config using override
eduardosmaniotto Jul 6, 2026
bdee688
apply missing attributes to white wizard invasion monsters
eduardosmaniotto Jul 6, 2026
4601991
Merge branch 'master' into DK_master_tree_finishup
sven-n Jul 7, 2026
54240dd
Merge pull request #766 from ze-dom/DK_master_tree_finishup
sven-n Jul 7, 2026
3fe6f89
Merge branch 'master' into feature/white-wizard
sven-n Jul 7, 2026
79cb55f
Merge pull request #815 from eduardosmaniotto/feature/white-wizard
sven-n Jul 7, 2026
416a3b0
Merge branch 'master' into feature/map-editor2
eduardosmaniotto Jul 7, 2026
3e36275
refactor(market): move Julia warp logic into GameLogic action
nolt Jul 7, 2026
ec13525
Merge upstream/master into julia-warp-bidirectional
nolt Jul 7, 2026
2bc8b42
Merge pull request #809 from nolt/julia-warp-bidirectional
sven-n Jul 7, 2026
b2bdbe2
Merge pull request #811 from eduardosmaniotto/feature/map-editor2
sven-n Jul 7, 2026
817b201
Merge branch 'master' into feature/map-editor-export
eduardosmaniotto Jul 7, 2026
91d7038
bugfix: replace duplicate GUID
eduardosmaniotto Jul 7, 2026
b67b7d1
Merge branch 'bugfix/duplicate-guid' into feature/map-editor-export
eduardosmaniotto Jul 7, 2026
5958922
fix build warnings
eduardosmaniotto Jul 7, 2026
33a773d
appy code review changes
eduardosmaniotto Jul 7, 2026
a3d46f3
create Yes/No Resource and loading theme variables
eduardosmaniotto Jul 7, 2026
f1b33a8
Merge pull request #812 from eduardosmaniotto/feature/map-editor-export
sven-n Jul 7, 2026
1c3f2f4
Merge remote-tracking branch 'origin/feature/skills-safezone-fixes' i…
Rhefew Jul 9, 2026
f97b5ed
Merge remote-tracking branch 'origin/feature/speedhack-anti-cheat' in…
Rhefew Jul 9, 2026
604cdd4
Merge remote-tracking branch 'origin/fix/muhelper-deadlock' into merg…
Rhefew Jul 9, 2026
52e1710
Merge remote-tracking branch 'origin/fix/packet-docs-and-ip-resolver'…
Rhefew Jul 9, 2026
4df2faf
Merge remote-tracking branch 'origin/fix/player-disconnect-hang' into…
Rhefew Jul 9, 2026
3840d00
feat(security): make speedhack anti-cheat checks configurable via Spe…
Rhefew Jul 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ paket-files/

# VS Code
.vscode/
*.lscache

# CodeRush
.cr/
Expand Down Expand Up @@ -319,3 +320,6 @@ src/AdminPanel/wwwroot/content/js/app.js.map

# Mac OS filesystem files
.DS_Store

# AI
.opencode/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# C1 F6 0C - QuestProgressExtended (by server)
# C2 F6 0C - QuestProgressExtended (by server)

## Is sent when

Expand All @@ -12,10 +12,10 @@ The client shows the quest progress accordingly.

| Index | Length | Data Type | Value | Description |
|-------|--------|-----------|-------|-------------|
| 0 | 1 | Byte | 0xC1 | [Packet type](PacketTypes.md) |
| 1 | 1 | Byte | 272 | Packet header - length of the packet |
| 2 | 1 | Byte | 0xF6 | Packet header - packet type identifier |
| 3 | 1 | Byte | 0x0C | Packet header - sub packet type identifier |
| 0 | 1 | Byte | 0xC2 | [Packet type](PacketTypes.md) |
| 1 | 2 | Short | 272 | Packet header - length of the packet |
| 3 | 1 | Byte | 0xF6 | Packet header - packet type identifier |
| 4 | 1 | Byte | 0x0C | Packet header - sub packet type identifier |
| 5 | 1 | Byte | | ConditionCount |
| 6 | 1 | Byte | | RewardCount |
| 7 | 1 | Byte | | RandomRewardCount |
Expand Down
2 changes: 1 addition & 1 deletion docs/Packets/ServerToClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
* [C1 F6 0A - AvailableQuests (by server)](C1-F6-0A-AvailableQuests_by-server.md)
* [C1 F6 0B - QuestStepInfo (by server)](C1-F6-0B-QuestStepInfo_by-server.md)
* [C1 F6 0C - QuestProgress (by server)](C1-F6-0C-QuestProgress_by-server.md)
* [C1 F6 0C - QuestProgressExtended (by server)](C1-F6-0C-QuestProgressExtended_by-server.md)
* [C2 F6 0C - QuestProgressExtended (by server)](C2-F6-0C-QuestProgressExtended_by-server.md)
* [C1 F6 0D - QuestCompletionResponse (by server)](C1-F6-0D-QuestCompletionResponse_by-server.md)
* [C1 F6 0F - QuestCancelled (by server)](C1-F6-0F-QuestCancelled_by-server.md)
* [C1 F6 1A - QuestStateList (by server)](C1-F6-1A-QuestStateList_by-server.md)
Expand Down
10 changes: 1 addition & 9 deletions src/AttributeSystem/ComposableAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,10 @@ private float GetAndCacheValue()
var maxValues = this.Elements.Where(e => e.AggregateType == AggregateType.Maximum).MaxBy(e => e.Value)?.Value ?? 0;
rawValues += maxValues;

if (multiValues == 0 && this.Elements.All(e => e.AggregateType != AggregateType.Multiplicate))
{
multiValues = 1;
}
else if (rawValues == 0 && multiValues != 0 && this.Elements.All(e => e.AggregateType != AggregateType.AddRaw))
if (this.Elements.All(e => e.AggregateType == AggregateType.Multiplicate))
{
rawValues = 1;
}
else
{
// nothing to do
}

var newValue = (rawValues * multiValues) + finalValues;
if (this._maximumValue.HasValue)
Expand Down
20 changes: 10 additions & 10 deletions src/Dapr/GameServer.Host/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
@using MUnique.OpenMU.DataModel.Configuration
@using MUnique.OpenMU.Persistence;

<nav>
<div>
<a href="">OpenMU</a>
<button @onclick="ToggleNavMenu">
<span></span>
<nav class="rounded-bottom shadow-lg">
<div class="top-row ps-4 navbar navbar-dark">
<a class="navbar-brand" href="">OpenMU</a>
<button class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>

<!-- Hiding it programmatically is not a good idea here, because we want to hide it based on the width of the device/window. -->
<div class="@NavMenuCssClass">
<ul>
<ul class="nav flex-column">

<li>
<NavLink href="" Match="NavLinkMatch.All">
<li class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</li>
<li>
<NavLink href="maps">
<li class="nav-item px-3">
<NavLink class="nav-link" href="maps">
<span class="oi oi-project" aria-hidden="true"></span> Maps
</NavLink>
</li>
Expand Down
8 changes: 4 additions & 4 deletions src/Dapr/GameServer.Host/Layout/ReconnectModal.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


#components-reconnect-modal {
background-color: white;
background-color: var(--omu-bg);
width: 20rem;
margin: 20vh auto;
padding: 2rem;
Expand Down Expand Up @@ -90,18 +90,18 @@

#components-reconnect-modal button {
border: 0;
background-color: #6b9ed2;
background-color: var(--omu-link-primary);
color: white;
padding: 4px 24px;
border-radius: 4px;
}

#components-reconnect-modal button:hover {
background-color: #3b6ea2;
background-color: var(--omu-link-primary-border);
}

#components-reconnect-modal button:active {
background-color: #6b9ed2;
background-color: var(--omu-link-primary);
}

.components-rejoining-animation {
Expand Down
4 changes: 2 additions & 2 deletions src/Dapr/GameServer.Host/Layout/Routes.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Router AppAssembly="@typeof(Program).Assembly" NotFoundPage="@typeof(Pages.NotFound)">
<Found Context="routeData">
<CascadingBlazoredModal>
<ModalContainer>
<RouteView RouteData="routeData" DefaultLayout="@typeof(Layout.MainLayout)"/>
<FocusOnNavigate RouteData="routeData" Selector="h1"/>
</CascadingBlazoredModal>
</ModalContainer>
</Found>
</Router>
4 changes: 1 addition & 3 deletions src/Dapr/GameServer.Host/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop

@using Blazored
@using Blazored.Modal
@using Blazored.Modal.Services
@using Blazored.Toast
@using Blazored.Toast.Services

@using BlazorInputFile

@using MUnique.OpenMU.Web.Shared
@using MUnique.OpenMU.Web.Shared.Components
@using MUnique.OpenMU.Web.Shared.Components.Modal
@using MUnique.OpenMU.Web.Shared.Components.Form
@using MUnique.OpenMU.Web.Shared.Services
4 changes: 2 additions & 2 deletions src/DataModel/Configuration/Gate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="Gate.cs" company="MUnique">
// <copyright file="Gate.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

Expand All @@ -10,7 +10,7 @@ namespace MUnique.OpenMU.DataModel.Configuration;
/// Defines a gate through which a player can exit or enter to other maps.
/// </summary>
[Cloneable]
public partial class Gate
public partial class Gate : IMapArea
{
/// <summary>
/// Gets or sets the upper left corner, x-coordinate.
Expand Down
31 changes: 31 additions & 0 deletions src/DataModel/Configuration/IMapArea.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// <copyright file="IMapArea.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.DataModel.Configuration;

/// <summary>
/// Represents a rectangular area on a map, defined by two corner coordinates.
/// </summary>
public interface IMapArea
{
/// <summary>
/// Gets or sets the upper-left corner X coordinate.
/// </summary>
byte X1 { get; set; }

/// <summary>
/// Gets or sets the upper-left corner Y coordinate.
/// </summary>
byte Y1 { get; set; }

/// <summary>
/// Gets or sets the bottom-right corner X coordinate.
/// </summary>
byte X2 { get; set; }

/// <summary>
/// Gets or sets the bottom-right corner Y coordinate.
/// </summary>
byte Y2 { get; set; }
}
6 changes: 3 additions & 3 deletions src/DataModel/Configuration/MonsterSpawnArea.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="MonsterSpawnArea.cs" company="MUnique">
// <copyright file="MonsterSpawnArea.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

Expand Down Expand Up @@ -65,10 +65,10 @@ public enum SpawnTrigger
}

/// <summary>
/// Defines an monster spawn area.
/// Defines a monster spawn area.
/// </summary>
[Cloneable]
public partial class MonsterSpawnArea
public partial class MonsterSpawnArea : IMapArea
{
/// <summary>
/// Gets or sets the monster definition.
Expand Down
1 change: 0 additions & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<PackageVersion Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
<PackageVersion Include="BlazorInputFile" Version="0.2.0" />
<PackageVersion Include="Blazored.Modal" Version="7.3.1" />
<PackageVersion Include="Blazored.Toast" Version="4.2.1" />
<PackageVersion Include="BuildWebCompiler2022" Version="1.14.15" />
<PackageVersion Include="DG.AdvancedDataGridView" Version="1.2.30115.18" />
Expand Down
21 changes: 18 additions & 3 deletions src/GameLogic/AttackableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace MUnique.OpenMU.GameLogic;
public static class AttackableExtensions
{
private const short ExplosionMagicEffectNumber = 75; // 0x4B
private const short StunnedMagicEffectNumber = 61; // 0x3D

private static readonly IDictionary<AttributeDefinition, AttributeDefinition> ReductionModifiers =
new Dictionary<AttributeDefinition, AttributeDefinition>
Expand Down Expand Up @@ -345,7 +346,7 @@ public static async ValueTask ApplyMagicEffectAsync(this IAttackable target, IAt
}

float chance = target is Player ? skillEntry.PowerUpChancePvp!.Value : skillEntry.PowerUpChance!.Value;
if (!Rand.NextRandomBool(Convert.ToDouble(chance)))
if (!Rand.NextRandomBool(chance))
{
return;
}
Expand Down Expand Up @@ -613,6 +614,20 @@ public static double CalculateBaseExperience(this IAttackable killedObject, floa
return Math.Max(tempExperience, 0) * 1.25;
}

/// <summary>
/// Applies the mace mastery stun effect to the specified attackable.
/// </summary>
/// <param name="attacker">The attacker.</param>
/// <param name="attackable">The attackable.</param>
/// <returns>A task representing the asynchronous operation.</returns>
public static async ValueTask ApplyMaceMasteryStunEffectAsync(this Player attacker, IAttackable attackable)
{
var stunEffectDefinition = attacker.GameContext.Configuration.MagicEffects.First(m => m.Number == StunnedMagicEffectNumber);
var powerUp = attackable.Attributes.CreateElement(stunEffectDefinition.PowerUpDefinitions.First(pu => pu.TargetAttribute == Stats.IsStunned));
var magicEffect = new MagicEffect(TimeSpan.FromSeconds(2), stunEffectDefinition, [new MagicEffect.ElementWithTarget(powerUp, Stats.IsStunned)]);
await attackable.MagicEffectList.AddEffectAsync(magicEffect).ConfigureAwait(false);
}

private static bool IsAttackSuccessfulTo(this IAttacker attacker, IAttackable defender)
{
var hitChance = attacker.GetHitChanceTo(defender);
Expand Down Expand Up @@ -879,8 +894,8 @@ private static async ValueTask ApplyMagicEffectAsync(this IAttackable target, IA
}
else if (magicEffectDefinition.PowerUpDefinitions.Any(e => e.TargetAttribute == Stats.IsStunned))
{
var stunChancePowerUp = powerUps.FirstOrDefault(p => p.Target == Stats.StunChance);
if (stunChancePowerUp.Boost is null || !Rand.NextRandomBool(Convert.ToDouble(stunChancePowerUp.Boost.Value)))
var stunChancePowerUp = powerUps.FirstOrDefault(p => p.Target == Stats.MasteryStunChance);
if (stunChancePowerUp.Boost is null || !Rand.NextRandomBool(stunChancePowerUp.Boost.Value))
{
return;
}
Expand Down
23 changes: 15 additions & 8 deletions src/GameLogic/Attributes/PowerUpWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public sealed class PowerUpWrapper : IElement, IDisposable
{
private readonly IElement _element;

private readonly AggregateType? _aggregateType;

private ComposableAttribute? _parentAttribute;

/// <summary>
Expand All @@ -22,7 +24,8 @@ public sealed class PowerUpWrapper : IElement, IDisposable
/// <param name="element">The element.</param>
/// <param name="targetAttribute">The target attribute.</param>
/// <param name="attributeHolder">The attribute holder.</param>
public PowerUpWrapper(IElement element, AttributeDefinition targetAttribute, AttributeSystem attributeHolder)
/// <param name="aggregateType">The aggregate type that should override the <paramref name="element"/>'s.</param>
public PowerUpWrapper(IElement element, AttributeDefinition targetAttribute, AttributeSystem attributeHolder, AggregateType? aggregateType = null)
{
this._parentAttribute = attributeHolder.GetComposableAttribute(targetAttribute);
if (this._parentAttribute is null)
Expand All @@ -31,6 +34,7 @@ public PowerUpWrapper(IElement element, AttributeDefinition targetAttribute, Att
}

this._element = element;
this._aggregateType = aggregateType;
this._parentAttribute.AddElement(this);
this._element.ValueChanged += this.OnValueChanged;
}
Expand All @@ -42,33 +46,36 @@ public PowerUpWrapper(IElement element, AttributeDefinition targetAttribute, Att
public float Value => this._element.Value;

/// <inheritdoc/>
public AggregateType AggregateType => this._element.AggregateType;
public AggregateType AggregateType => this._aggregateType ?? this._element.AggregateType;

/// <summary>
/// Creates elements by a <see cref="PowerUpDefinition"/>.
/// </summary>
/// <param name="powerUpDef">The power up definition.</param>
/// <param name="attributeHolder">The attribute holder.</param>
/// <param name="aggregateType">The specific aggregate type. If not specified, the aggregate type of the <paramref name="powerUpDef"/>'s constant value will be used.</param>
/// <returns>The elements which represent the power-up.</returns>
public static IEnumerable<PowerUpWrapper> CreateByPowerUpDefinition(PowerUpDefinition powerUpDef, AttributeSystem attributeHolder)
public static IEnumerable<PowerUpWrapper> CreateByPowerUpDefinition(PowerUpDefinition powerUpDef, AttributeSystem attributeHolder, AggregateType? aggregateType = null)
{
if (powerUpDef.Boost?.ConstantValue != null)
{
yield return new PowerUpWrapper(
powerUpDef.Boost.ConstantValue,
powerUpDef.TargetAttribute ?? throw Error.NotInitializedProperty(powerUpDef, nameof(PowerUpDefinition.TargetAttribute)),
attributeHolder);
attributeHolder,
aggregateType);
}

if (powerUpDef.Boost?.RelatedValues != null)
{
foreach (var relationship in powerUpDef.Boost.RelatedValues)
{
var aggregateType = powerUpDef.Boost?.ConstantValue.AggregateType ?? AggregateType.AddRaw;
var aggregType = powerUpDef.Boost?.ConstantValue.AggregateType ?? AggregateType.AddRaw;
yield return new PowerUpWrapper(
attributeHolder.CreateRelatedAttribute(relationship, attributeHolder, aggregateType),
attributeHolder.CreateRelatedAttribute(relationship, attributeHolder, aggregType),
powerUpDef.TargetAttribute ?? throw Error.NotInitializedProperty(powerUpDef, nameof(PowerUpDefinition.TargetAttribute)),
attributeHolder);
attributeHolder,
aggregateType);
}
}
}
Expand All @@ -88,7 +95,7 @@ public void Dispose()
/// <inheritdoc/>
public override string? ToString()
{
return $"{this._parentAttribute?.Definition.Designation}: {this._element}";
return $"{this._parentAttribute?.Definition.Designation}: {this._element}{(this._aggregateType is { } aggreg ? $"->({aggreg})" : string.Empty)}";
}

private void OnValueChanged(object? sender, EventArgs eventArgs)
Expand Down
Loading
Loading