@@ -314,7 +314,8 @@ public static HitInfo GetHitInfo(this IAttackable defender, uint damage, DamageA
314314 /// <param name="target">The target.</param>
315315 /// <param name="attacker">The attacker.</param>
316316 /// <param name="skillEntry">The skill entry.</param>
317- public static async ValueTask ApplyMagicEffectAsync ( this IAttackable target , IAttacker attacker , SkillEntry skillEntry )
317+ /// <param name="hitInfo">The hit information.</param>
318+ public static async ValueTask ApplyMagicEffectAsync ( this IAttackable target , IAttacker attacker , SkillEntry skillEntry , HitInfo ? hitInfo = null )
318319 {
319320 if ( skillEntry . PowerUps is null && attacker is Player player )
320321 {
@@ -329,7 +330,7 @@ public static async ValueTask ApplyMagicEffectAsync(this IAttackable target, IAt
329330
330331 var duration = target is Player ? skillEntry . PowerUpDurationPvp ! : skillEntry . PowerUpDuration ! ;
331332 var powerUps = target is Player ? skillEntry . PowerUpsPvp ! : skillEntry . PowerUps ! ;
332- await target . ApplyMagicEffectAsync ( attacker , skillEntry . Skill ! . MagicEffectDef ! , duration , powerUps ) . ConfigureAwait ( false ) ;
333+ await target . ApplyMagicEffectAsync ( attacker , skillEntry . Skill ! . MagicEffectDef ! , duration , hitInfo , powerUps ) . ConfigureAwait ( false ) ;
333334 }
334335
335336 /// <summary>
@@ -373,8 +374,9 @@ public static async ValueTask ApplyRegenerationAsync(this IAttackable target, Pl
373374 /// <param name="target">The target.</param>
374375 /// <param name="attacker">The attacker.</param>
375376 /// <param name="skillEntry">The skill entry.</param>
377+ /// <param name="hitInfo">The hit information.</param>
376378 /// <returns>The success of the appliance.</returns>
377- public static async ValueTask < bool > TryApplyElementalEffectsAsync ( this IAttackable target , IAttacker attacker , SkillEntry skillEntry )
379+ public static async ValueTask < bool > TryApplyElementalEffectsAsync ( this IAttackable target , IAttacker attacker , SkillEntry skillEntry , HitInfo ? hitInfo = null )
378380 {
379381 if ( ! target . IsAlive )
380382 {
@@ -383,15 +385,15 @@ public static async ValueTask<bool> TryApplyElementalEffectsAsync(this IAttackab
383385
384386 skillEntry . ThrowNotInitializedProperty ( skillEntry . Skill is null , nameof ( skillEntry . Skill ) ) ;
385387 var modifier = skillEntry . Skill . ElementalModifierTarget ;
386- if ( modifier is null )
387- {
388- return false ;
389- }
388+ var skipModifier = skillEntry . Skill . SkipElementalModifier ;
390389
391- var resistance = target . Attributes [ modifier ] ;
392- if ( resistance >= 255 || ! Rand . NextRandomBool ( 1 / ( resistance + 1 ) ) )
390+ if ( modifier is not null && ! skipModifier )
393391 {
394- return false ;
392+ var resistance = target . Attributes [ modifier ] ;
393+ if ( resistance >= 255 || ! Rand . NextRandomBool ( 1 / ( resistance + 1 ) ) )
394+ {
395+ return false ;
396+ }
395397 }
396398
397399 var applied = false ;
@@ -400,11 +402,11 @@ public static async ValueTask<bool> TryApplyElementalEffectsAsync(this IAttackab
400402 && ! target . MagicEffectList . ActiveEffects . ContainsKey ( effectDefinition . Number ) )
401403 {
402404 // power-up is the wrong term here... it's more like a power-down ;-)
403- await target . ApplyMagicEffectAsync ( attacker , skillEntry ) . ConfigureAwait ( false ) ;
405+ await target . ApplyMagicEffectAsync ( attacker , skillEntry , hitInfo ) . ConfigureAwait ( false ) ;
404406 applied = true ;
405407 }
406408
407- if ( modifier == Stats . LightningResistance )
409+ if ( modifier == Stats . LightningResistance && ! skipModifier )
408410 {
409411 await target . MoveRandomlyAsync ( ) . ConfigureAwait ( false ) ;
410412 applied = true ;
@@ -422,10 +424,9 @@ public static async ValueTask<bool> TryApplyElementalEffectsAsync(this IAttackab
422424 /// <param name="powerUp">The power up.</param>
423425 /// <param name="duration">The duration.</param>
424426 /// <param name="targetAttribute">The target attribute.</param>
425- /// <returns>
426- /// The success of the appliance.
427- /// </returns>
428- public static async ValueTask < bool > TryApplyElementalEffectsAsync ( this IAttackable target , IAttacker attacker , Skill skill , IElement ? powerUp , IElement ? duration , AttributeDefinition ? targetAttribute )
427+ /// <param name="hitInfo">The hit information.</param>
428+ /// <returns>The success of the appliance.</returns>
429+ public static async ValueTask < bool > TryApplyElementalEffectsAsync ( this IAttackable target , IAttacker attacker , Skill skill , IElement ? powerUp , IElement ? duration , AttributeDefinition ? targetAttribute , HitInfo ? hitInfo )
429430 {
430431 if ( ! target . IsAlive )
431432 {
@@ -453,7 +454,7 @@ public static async ValueTask<bool> TryApplyElementalEffectsAsync(this IAttackab
453454 && targetAttribute is not null )
454455 {
455456 // power-up is the wrong term here... it's more like a power-down ;-)
456- await target . ApplyMagicEffectAsync ( attacker , effectDefinition , duration , ( targetAttribute , powerUp ) ) . ConfigureAwait ( false ) ;
457+ await target . ApplyMagicEffectAsync ( attacker , effectDefinition , duration , hitInfo , ( targetAttribute , powerUp ) ) . ConfigureAwait ( false ) ;
457458 applied = true ;
458459 }
459460
@@ -819,8 +820,9 @@ private static void GetBaseDmg(this IAttacker attacker, SkillEntry? skill, out i
819820 /// <param name="attacker">The attacker.</param>
820821 /// <param name="magicEffectDefinition">The magic effect definition.</param>
821822 /// <param name="duration">The duration.</param>
823+ /// <param name="hitInfo">The hit information.</param>
822824 /// <param name="powerUps">The power ups of the effect.</param>
823- private static async ValueTask ApplyMagicEffectAsync ( this IAttackable target , IAttacker attacker , MagicEffectDefinition magicEffectDefinition , IElement duration , params ( AttributeDefinition Target , IElement Boost ) [ ] powerUps )
825+ private static async ValueTask ApplyMagicEffectAsync ( this IAttackable target , IAttacker attacker , MagicEffectDefinition magicEffectDefinition , IElement duration , HitInfo ? hitInfo , params ( AttributeDefinition Target , IElement Boost ) [ ] powerUps )
824826 {
825827 float finalDuration = duration . Value ;
826828
@@ -839,10 +841,24 @@ private static async ValueTask ApplyMagicEffectAsync(this IAttackable target, IA
839841 return ;
840842 }
841843
842- var isPoisonEffect = magicEffectDefinition . PowerUpDefinitions . Any ( e => e . TargetAttribute == Stats . IsPoisoned ) ;
843- var magicEffect = isPoisonEffect
844- ? new PoisonMagicEffect ( powerUps [ 0 ] . Boost , magicEffectDefinition , durationSpan , attacker , target )
845- : new MagicEffect ( durationSpan , magicEffectDefinition , powerUps . Select ( p => new MagicEffect . ElementWithTarget ( p . Boost , p . Target ) ) . ToArray ( ) ) ;
844+ MagicEffect magicEffect ;
845+ if ( magicEffectDefinition . PowerUpDefinitions . Any ( e => e . TargetAttribute == Stats . IsPoisoned ) )
846+ {
847+ magicEffect = new PoisonMagicEffect ( powerUps [ 0 ] . Boost , magicEffectDefinition , durationSpan , attacker , target ) ;
848+ }
849+ else if ( magicEffectDefinition . PowerUpDefinitions . Any ( e => e . TargetAttribute == Stats . IsBleeding ) )
850+ {
851+ if ( hitInfo is not { } hit || hit . HealthDamage + hit . ShieldDamage < 1 )
852+ {
853+ return ;
854+ }
855+
856+ magicEffect = new BleedingMagicEffect ( powerUps [ 0 ] . Boost , magicEffectDefinition , durationSpan , attacker , target , hit . HealthDamage + hit . ShieldDamage ) ;
857+ }
858+ else
859+ {
860+ magicEffect = new MagicEffect ( durationSpan , magicEffectDefinition , powerUps . Select ( p => new MagicEffect . ElementWithTarget ( p . Boost , p . Target ) ) . ToArray ( ) ) ;
861+ }
846862
847863 await target . MagicEffectList . AddEffectAsync ( magicEffect ) . ConfigureAwait ( false ) ;
848864 if ( target is ISupportWalk walkSupporter
0 commit comments