diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs index 8d1b1e3..e285b1e 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs @@ -652,29 +652,34 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem //var Anim = (DiIiS_NA.Core.MPQ.FileFormats.Anim)DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.Anim][animationSNO].Data; World.BroadcastIfRevealed(plr => new PlayAnimationMessage - { - ActorID = DynamicID(plr), - AnimReason = 9, - UnitAniimStartTime = 0, - tAnim = new PlayAnimationMessageSpec[] { - new PlayAnimationMessageSpec + ActorID = DynamicID(plr), + AnimReason = 9, + UnitAniimStartTime = 0, + tAnim = new PlayAnimationMessageSpec[] { - Duration = -2, - AnimationSNO = (int)animationSNO, - PermutationIndex = 0x0, - AnimationTag = 0, - Speed = 1.0f, + new PlayAnimationMessageSpec + { + Duration = -2, + AnimationSNO = (int)animationSNO, + PermutationIndex = 0x0, + AnimationTag = 0, + Speed = 1.0f, + } } - } }, this); - } } + } - public void PlayAnimation(int animationType, AnimationSno animationSNO, float speed = 1.0f, int? ticksToPlay = null, int type2 = 0) + public void PlayAnimation(int animationType, AnimationSno animationSNO, float speed = 1.0f, int? ticksToPlay = null, int type2 = 0) { - if (this.World == null || animationSNO == AnimationSno._NONE) return; + if (animationSNO == AnimationSno._NONE) + { + Logger.Warn($"PlayAnimation: {(int)animationSNO} is not a valid animation"); + return; + } + if (this.World == null) return; World.BroadcastIfRevealed(plr => new PlayAnimationMessage { diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/ComboSkill.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/ComboSkill.cs index 0790dbd..e87407e 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/ComboSkill.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/ComboSkill.cs @@ -10,13 +10,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem { public abstract class ComboSkill : Skill { - public int ComboIndex - { - get - { - return TargetMessage.ComboLevel; - } - } + public int ComboIndex => TargetMessage.ComboLevel; public override AnimationSno GetActionAnimationSNO() { diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Implementations/HeroSkills/Necromancer.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Implementations/HeroSkills/Necromancer.cs index 0d8c231..872df2d 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Implementations/HeroSkills/Necromancer.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Implementations/HeroSkills/Necromancer.cs @@ -2650,7 +2650,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations { if (Rune_C > 0) { - int[] Effects = new int[] { 47400, 474402, 474435, 474437, 474453, 474455, 474464, 474466 }; + int[] Effects = new[] { 47400, 474402, 474435, 474437, 474453, 474455, 474464, 474466 }; Tar.PlayEffectGroup(Effects[RandomHelper.Next(0, 7)]); yield return WaitSeconds(0.5f); WeaponDamage(Tar, damage, damageType); @@ -2661,8 +2661,10 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations Point.UpdateDelay = 0.2f; Point.OnUpdate = () => { - AttackPayload attack = new AttackPayload(this); - attack.Targets = GetEnemiesInRadius(Point.Position, range); + AttackPayload attack = new AttackPayload(this) + { + Targets = GetEnemiesInRadius(Point.Position, range) + }; attack.AddWeaponDamage(damage, damageType); attack.OnHit = hitPayload => diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/AttackPayload.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/AttackPayload.cs index 9c7c58a..acd9f46 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/AttackPayload.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/AttackPayload.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using DiIiS_NA.GameServer.GSSystem.AISystem.Brains; namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads { @@ -80,7 +81,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads public void Apply() { - if (Targets == null) Targets = new TargetList(); + Targets ??= new TargetList(); if (Target.World != null) { if (!Target.World.Game.Working) return; @@ -92,20 +93,25 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads { return; } - if (Target is Player && DamageEntries.Count > 0) - { - Player player = (Player)Target; - foreach (Actor extra in Targets.ExtraActors) - if (extra is DesctructibleLootContainer) - extra.OnTargeted(player, null); + { + if (Target is Player player && DamageEntries.Count > 0) + { + foreach (Actor extra in Targets.ExtraActors) + if (extra is DesctructibleLootContainer) + extra.OnTargeted(player, null); + + } } - if (Context.User is Player && Context.Target is Monster && Context.Target.GBHandle.Type == 1) - { - (Context.User as Player).ExpBonusData.MonsterAttacked((Context.User as Player).InGameClient.Game.TickCounter); - ((Context.Target as Monster).Brain as AISystem.Brains.MonsterBrain).AttackedBy = Context.User; - } - + { + if (Context.User is Player player && Context.Target is Monster monster && monster.GBHandle.Type == 1) + { + player.ExpBonusData.MonsterAttacked(player.InGameClient.Game + .TickCounter); + ((MonsterBrain)monster.Brain).AttackedBy = player; + } + } + foreach (Actor target in Targets.Actors) { if (target == null || target.World == null || target.World != null && target.World.PowerManager.IsDeletingActor(target)) diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/HitPayload.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/HitPayload.cs index 6a0b3ed..fdc746f 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/HitPayload.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/HitPayload.cs @@ -51,27 +51,17 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads { IsCriticalHit = criticalHit; IsDodged = false; - IsWeaponDamage = (attackPayload.DamageEntries.Count > 0 ? attackPayload.DamageEntries.First().IsWeaponBasedDamage : false); + IsWeaponDamage = (attackPayload.DamageEntries.Count > 0 && attackPayload.DamageEntries.First().IsWeaponBasedDamage); - if (Context.User == null) - Context.User = target; + Context.User ??= target; + Target ??= target; - - - if (Target == null) - Target = target; - - if (Target == null) return; - - if (Target.World == null) return; - - if (!Target.World.Game.Working) return; - - if (Target.World.Game.Paused) return; - - if (!Target.Visible) return; - - if (Target.Dead) return; + if (Target?.World == null || + !Target.World.Game.Working || + Target.World.Game.Paused || + !Target.Visible || + Target.Dead) + return; if (Context.User is Monster && Context.Target is Player) if (!Context.User.IsRevealedToPlayer(Context.Target as Player)) @@ -448,123 +438,117 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads } - if (Target is Player) //check for passives here (incoming damage) + if (Target is Player playerTarget) //check for passives here (incoming damage) { - var plr = Target as Player; - - if (!plr.Attributes[GameAttribute.Cannot_Dodge] && FastRandom.Instance.NextDouble() < plr.DodgeChance) + if (!playerTarget.Attributes[GameAttribute.Cannot_Dodge] && FastRandom.Instance.NextDouble() < playerTarget.DodgeChance) IsDodged = true; - if (plr.Toon.Class == ToonClass.Monk) //Monk defensive passives + if (playerTarget.Toon.Class == ToonClass.Monk) //Monk defensive passives { TotalDamage *= 0.7f; //Class damage reduction bonus - if (plr.World.BuffManager.HasBuff(plr)) //Tempest rush -> Slipstream - if (plr.World.BuffManager.GetFirstBuff(plr)._slipStream) + if (playerTarget.World.BuffManager.HasBuff(playerTarget)) //Tempest rush -> Slipstream + if (playerTarget.World.BuffManager.GetFirstBuff(playerTarget)._slipStream) TotalDamage *= 0.8f; - if (plr.World.BuffManager.HasBuff(plr)) //Epiphany -> Desert Shroud - if (plr.World.BuffManager.GetFirstBuff(plr).DesertShroud) + if (playerTarget.World.BuffManager.HasBuff(playerTarget)) //Epiphany -> Desert Shroud + if (playerTarget.World.BuffManager.GetFirstBuff(playerTarget).DesertShroud) TotalDamage *= 0.5f; if (IsDodged) //Mantra of Evasion -> Backlash - if (plr.World.BuffManager.HasBuff(plr)) - if (plr.World.BuffManager.GetFirstBuff(plr).Backlash) - plr.World.BuffManager.GetFirstBuff(plr).BacklashTrigger = true; + if (playerTarget.World.BuffManager.HasBuff(playerTarget)) + if (playerTarget.World.BuffManager.GetFirstBuff(playerTarget).Backlash) + playerTarget.World.BuffManager.GetFirstBuff(playerTarget).BacklashTrigger = true; } - if (plr.Toon.Class == ToonClass.Barbarian) //Barb defensive passives + if (playerTarget.Toon.Class == ToonClass.Barbarian) //Barb defensive passives { TotalDamage *= 0.7f; //Class damage reduction bonus - if (plr.SkillSet.HasPassive(205491) && PowerMath.Distance2D(Context.User.Position, plr.Position) > 6f) //Superstition (barbarian) + if (playerTarget.SkillSet.HasPassive(205491) && PowerMath.Distance2D(Context.User.Position, playerTarget.Position) > 6f) //Superstition (barbarian) if (FastRandom.Instance.NextDouble() < Context.GetProcCoefficient()) - plr.GeneratePrimaryResource(2f); + playerTarget.GeneratePrimaryResource(2f); - if (plr.SkillSet.HasPassive(205398) && (plr.Attributes[GameAttribute.Hitpoints_Cur] - TotalDamage) < (plr.Attributes[GameAttribute.Hitpoints_Max_Total] * 0.2f)) //Relentless (barbarian) + if (playerTarget.SkillSet.HasPassive(205398) && (playerTarget.Attributes[GameAttribute.Hitpoints_Cur] - TotalDamage) < (playerTarget.Attributes[GameAttribute.Hitpoints_Max_Total] * 0.2f)) //Relentless (barbarian) TotalDamage *= 0.5f; } - if (plr.Toon.Class == ToonClass.Wizard) //Wizard defensive passives + if (playerTarget.Toon.Class == ToonClass.Wizard) //Wizard defensive passives { - if (plr.SkillSet.HasPassive(208471)) //GlassCannon (Wizard) + if (playerTarget.SkillSet.HasPassive(208471)) //GlassCannon (Wizard) TotalDamage *= 1.1f; - if (plr.SkillSet.HasPassive(208547) && TotalDamage > (plr.Attributes[GameAttribute.Hitpoints_Max_Total] * 0.15f)) //Illusionist (Wizard) + if (playerTarget.SkillSet.HasPassive(208547) && TotalDamage > (playerTarget.Attributes[GameAttribute.Hitpoints_Max_Total] * 0.15f)) //Illusionist (Wizard) { - foreach (var cdBuff in plr.World.BuffManager.GetBuffs(plr)) + foreach (var cdBuff in playerTarget.World.BuffManager.GetBuffs(playerTarget)) if (cdBuff.TargetPowerSNO == 1769 || cdBuff.TargetPowerSNO == 168344) cdBuff.Remove(); } - if (plr.SkillSet.HasPassive(208474) && (plr.Attributes[GameAttribute.Hitpoints_Cur] - TotalDamage) <= 0) //UnstableAnomaly (wizard) + if (playerTarget.SkillSet.HasPassive(208474) && (playerTarget.Attributes[GameAttribute.Hitpoints_Cur] - TotalDamage) <= 0) //UnstableAnomaly (wizard) { - if (plr.World.BuffManager.GetFirstBuff(plr) == null) + if (playerTarget.World.BuffManager.GetFirstBuff(playerTarget) == null) { - plr.AddPercentageHP(45); - plr.World.BuffManager.AddBuff(plr, plr, new UnstableAnomalyCooldownBuff()); - plr.World.PowerManager.RunPower(plr, 30796); - plr.GenerateSecondaryResource(25f); - foreach (var cdBuff in plr.World.BuffManager.GetBuffs(plr)) + playerTarget.AddPercentageHP(45); + playerTarget.World.BuffManager.AddBuff(playerTarget, playerTarget, new UnstableAnomalyCooldownBuff()); + playerTarget.World.PowerManager.RunPower(playerTarget, 30796); + playerTarget.GenerateSecondaryResource(25f); + foreach (var cdBuff in playerTarget.World.BuffManager.GetBuffs(playerTarget)) if (cdBuff.TargetPowerSNO == 30796) cdBuff.Remove(); } } } - if (plr.Toon.Class == ToonClass.WitchDoctor) //Witch Doctor defensive passives + if (playerTarget.Toon.Class == ToonClass.WitchDoctor) //Witch Doctor defensive passives { - if (plr.SkillSet.HasPassive(217968)) //JungleFortitude (WD) + if (playerTarget.SkillSet.HasPassive(217968)) //JungleFortitude (WD) TotalDamage *= 0.85f; } - if (plr.Toon.Class == ToonClass.DemonHunter) //DH defensive passives + if (playerTarget.Toon.Class == ToonClass.DemonHunter) //DH defensive passives { - if (plr.SkillSet.HasPassive(210801) && plr.World.BuffManager.GetFirstBuff(plr) == null) //Brooding (DH) - plr.World.BuffManager.AddBuff(plr, plr, new BroodingCooldownBuff()); + if (playerTarget.SkillSet.HasPassive(210801) && playerTarget.World.BuffManager.GetFirstBuff(playerTarget) == null) //Brooding (DH) + playerTarget.World.BuffManager.AddBuff(playerTarget, playerTarget, new BroodingCooldownBuff()); } - if (plr.Toon.Class == ToonClass.Crusader) //Crusader defensive passives + if (playerTarget.Toon.Class == ToonClass.Crusader) //Crusader defensive passives { TotalDamage *= 0.7f; //Class damage reduction bonus - if (plr.SkillSet.HasPassive(310626)) //Vigilant - if (!(DominantDamageType == DamageType.Physical)) + if (playerTarget.SkillSet.HasPassive(310626)) //Vigilant + if (DominantDamageType != DamageType.Physical) TotalDamage *= 0.95f; - if (plr.World.BuffManager.HasBuff(plr)) //AkaratChampion resurrect once - if (plr.World.BuffManager.GetFirstBuff(plr).resurrectActive) - if ((plr.Attributes[GameAttribute.Hitpoints_Cur] - TotalDamage) <= 0) + if (playerTarget.World.BuffManager.HasBuff(playerTarget)) //AkaratChampion resurrect once + if (playerTarget.World.BuffManager.GetFirstBuff(playerTarget).resurrectActive) + if ((playerTarget.Attributes[GameAttribute.Hitpoints_Cur] - TotalDamage) <= 0) { - plr.World.BuffManager.GetFirstBuff(plr).resurrectActive = false; - plr.AddPercentageHP(100); + playerTarget.World.BuffManager.GetFirstBuff(playerTarget).resurrectActive = false; + playerTarget.AddPercentageHP(100); } - if (plr.World.BuffManager.HasBuff(plr)) //Protect the Innocent - if (!plr.World.BuffManager.GetFirstBuff(plr).Primary) - if (plr.World.BuffManager.GetFirstBuff(plr).Redirect) + if (playerTarget.World.BuffManager.HasBuff(playerTarget)) //Protect the Innocent + if (!playerTarget.World.BuffManager.GetFirstBuff(playerTarget).Primary) + if (playerTarget.World.BuffManager.GetFirstBuff(playerTarget).Redirect) TotalDamage *= 0.8f; } TotalDamage *= 0.1f; } - else if (Target is Minion) //check for passives here (incoming damage, minions) + else if (Target is Minion { Master: Player playerOwner }) //check for passives here (incoming damage, minions) { - var minion = Target as Minion; - if (minion.Master != null && minion.Master is Player) - { - var plr = minion.Master as Player; + var plr = playerOwner; - var masterArmor = plr.Attributes[GameAttribute.Armor_Total]; - var attackLevel = attackPayload.Context.User.Attributes[GameAttribute.Level]; + var masterArmor = plr.Attributes[GameAttribute.Armor_Total]; + var attackLevel = attackPayload.Context.User.Attributes[GameAttribute.Level]; - TotalDamage *= ReductionFromArmor(masterArmor, attackLevel); + TotalDamage *= ReductionFromArmor(masterArmor, attackLevel); - if (plr.SkillSet.HasPassive(217968)) //JungleFortitude (WD) - TotalDamage *= 0.85f; + if (plr.SkillSet.HasPassive(217968)) //JungleFortitude (WD) + TotalDamage *= 0.85f; - TotalDamage *= 0.1f; //hack for unkillable minions - } + TotalDamage *= 0.1f; //hack for unkillable minions } } @@ -580,11 +564,11 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads private void CheckItemProcs(Player user) { - if (user.Attributes[GameAttribute.Item_Power_Passive, 247724] == 1 && FastRandom.Instance.NextDouble() < 0.2) + if (Math.Abs(user.Attributes[GameAttribute.Item_Power_Passive, 247724] - 1) < 0.001 && FastRandom.Instance.NextDouble() < 0.2) { user.PlayEffectGroup(247770); } - if (user.Attributes[GameAttribute.Item_Power_Passive, 245741] == 1 && FastRandom.Instance.NextDouble() < 0.2) + if (Math.Abs(user.Attributes[GameAttribute.Item_Power_Passive, 245741] - 1) < 0.001 && FastRandom.Instance.NextDouble() < 0.2) { user.PlayEffectGroup(245747); } @@ -601,9 +585,9 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads if (!Target.Visible) return; - if ((Target.Attributes[GameAttribute.Invulnerable] == true || Target.Attributes[GameAttribute.Immunity] == true) && Target.World != null) + if ((Target.Attributes[GameAttribute.Invulnerable] || Target.Attributes[GameAttribute.Immunity]) && Target.World != null) { - if (!(Target is Minion)) + if (Target is not Minion) Target.World.BroadcastIfRevealed(plr => new FloatingNumberMessage() { ActorID = Target.DynamicID(plr), @@ -618,74 +602,77 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads return; } - if (Target is Player) + switch (Target) { - var plr = (Target as Player); - if (plr.Dead) return; - - if (IsDodged) + case Player playerActor: { - Target.World.BroadcastIfRevealed(plr => new FloatingNumberMessage() + var plr = playerActor; + if (plr.Dead) return; + + if (IsDodged) { - ActorID = Target.DynamicID(plr), - Number = 0f, - Type = FloatingNumberMessage.FloatType.Dodge - }, Target); - plr.DodgesInARow++; - if (plr.Toon.Class == ToonClass.Monk && plr.DodgesInARow >= 15) + playerActor.World.BroadcastIfRevealed(plr2 => new FloatingNumberMessage() + { + ActorID = Target.DynamicID(plr2), + Number = 0f, + Type = FloatingNumberMessage.FloatType.Dodge + }, playerActor); + plr.DodgesInARow++; + if (plr.Toon.Class == ToonClass.Monk && plr.DodgesInARow >= 15) + { + plr.GrantAchievement(74987243307548); + } + + else if (plr.Toon.Class == ToonClass.DemonHunter) //Awareness + { + plr.AddTimedAction(1f, new Action((q) => plr.World.BuffManager.RemoveBuffs(plr, 324770))); + plr.AddTimedAction(2f, new Action((q) => + { + if (plr.SkillSet.HasPassive(324770)) + plr.World.BuffManager.AddBuff(plr, plr, new AwarenessBuff()); + })); + } + return; + } + plr.DodgesInARow = 0; + + if (FastRandom.Instance.NextDouble() < playerActor.Attributes[GameAttribute.Block_Chance_Capped_Total]) { - plr.GrantAchievement(74987243307548); + TotalDamage -= (float)FastRandom.Instance.NextDouble((double)playerActor.Attributes[GameAttribute.Block_Amount_Total_Min], (double)playerActor.Attributes[GameAttribute.Block_Amount_Total_Max]); + if (TotalDamage < 0f) TotalDamage = 0f; + playerActor.World.BroadcastIfRevealed(plr3 => new FloatingNumberMessage() + { + ActorID = Target.DynamicID(plr3), + Number = TotalDamage, + Type = FloatingNumberMessage.FloatType.Block + }, playerActor); + + Blocked = true; + plr.BlocksInARow++; + if (plr.Toon.Class == ToonClass.Barbarian) + { + if (plr.BlocksInARow >= 5) + plr.GrantAchievement(74987243307048); + if (plr.SkillSet.HasPassive(340877)) //Sword and Board + if (FastRandom.Instance.NextDouble() < 0.3f) + plr.GeneratePrimaryResource(6f); + } + } + else + { + plr.BlocksInARow = 0; } - else if (plr.Toon.Class == ToonClass.DemonHunter) //Awareness - { - plr.AddTimedAction(1f, new Action((q) => plr.World.BuffManager.RemoveBuffs(plr, 324770))); - plr.AddTimedAction(2f, new Action((q) => - { - if (plr.SkillSet.HasPassive(324770)) - plr.World.BuffManager.AddBuff(plr, plr, new AwarenessBuff()); - })); - } + break; + } + case DesctructibleLootContainer container: + { + container.ReceiveDamage(container, 100); + if (Context.User is Player plrAddAchievement + && Context.PowerSNO == 96296) + plrAddAchievement.AddAchievementCounter(74987243307049, 1); return; } - else - { - plr.DodgesInARow = 0; - } - - if (FastRandom.Instance.NextDouble() < Target.Attributes[GameAttribute.Block_Chance_Capped_Total]) - { - TotalDamage -= (float)FastRandom.Instance.NextDouble((double)Target.Attributes[GameAttribute.Block_Amount_Total_Min], (double)Target.Attributes[GameAttribute.Block_Amount_Total_Max]); - if (TotalDamage < 0f) TotalDamage = 0f; - Target.World.BroadcastIfRevealed(plr => new FloatingNumberMessage() - { - ActorID = Target.DynamicID(plr), - Number = TotalDamage, - Type = FloatingNumberMessage.FloatType.Block - }, Target); - - Blocked = true; - plr.BlocksInARow++; - if (plr.Toon.Class == ToonClass.Barbarian) - { - if (plr.BlocksInARow >= 5) - plr.GrantAchievement(74987243307048); - if (plr.SkillSet.HasPassive(340877)) //Sword and Board - if (FastRandom.Instance.NextDouble() < 0.3f) - plr.GeneratePrimaryResource(6f); - } - } - else - { - plr.BlocksInARow = 0; - } - } - if (Target is DesctructibleLootContainer) - { - (Target as DesctructibleLootContainer).ReceiveDamage(Target, 100); - if (Context.PowerSNO == 96296) - (Context.User as Player).AddAchievementCounter(74987243307049, 1); - return; } if (Target.World != null) @@ -695,25 +682,25 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads if (Target == null || Target.World == null) return; //in case Target was killed in OnPayload - if (Context.User is Player) + if (Context.User is Player player) { - CheckItemProcs(Context.User as Player); - if (Context.User.Attributes[GameAttribute.Steal_Health_Percent] > 0) - (Context.User as Player).AddHP(TotalDamage * Context.User.Attributes[GameAttribute.Steal_Health_Percent]); + CheckItemProcs(player); + if (player.Attributes[GameAttribute.Steal_Health_Percent] > 0) + player.AddHP(TotalDamage * Context.User.Attributes[GameAttribute.Steal_Health_Percent]); if (Context.User.Attributes[GameAttribute.Hitpoints_On_Hit] > 0) - (Context.User as Player).AddHP(Context.User.Attributes[GameAttribute.Hitpoints_On_Hit]); + player.AddHP(Context.User.Attributes[GameAttribute.Hitpoints_On_Hit]); if (IsCriticalHit) - if ((Context.User as Player).Toon.Class == ToonClass.Wizard) + if (player.Toon.Class == ToonClass.Wizard) if (FastRandom.Instance.NextDouble() < Context.GetProcCoefficient()) - (Context.User as Player).GeneratePrimaryResource(Context.User.Attributes[GameAttribute.Resource_On_Hit, 1]); + player.GeneratePrimaryResource(Context.User.Attributes[GameAttribute.Resource_On_Hit, 1]); } - if (Context.User is Hireling) + if (Context.User is Hireling hireling) { - if (Context.User.Attributes[GameAttribute.Steal_Health_Percent] > 0) - (Context.User as Hireling).AddHP(TotalDamage * Context.User.Attributes[GameAttribute.Steal_Health_Percent]); - if (Context.User.Attributes[GameAttribute.Hitpoints_On_Hit] > 0) - (Context.User as Hireling).AddHP(Context.User.Attributes[GameAttribute.Hitpoints_On_Hit]); + if (hireling.Attributes[GameAttribute.Steal_Health_Percent] > 0) + hireling.AddHP(TotalDamage * hireling.Attributes[GameAttribute.Steal_Health_Percent]); + if (hireling.Attributes[GameAttribute.Hitpoints_On_Hit] > 0) + hireling.AddHP(hireling.Attributes[GameAttribute.Hitpoints_On_Hit]); } @@ -796,7 +783,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads deathload.Apply(); } } - else if (AutomaticHitEffects && Target.World != null && !(Target is Player)) + else if (AutomaticHitEffects && Target.World != null && Target is not Player) { // target didn't die, so play hit animation if the actor has one if (Target.World.BuffManager.GetFirstBuff(Target) == null && diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/PowerContext.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/PowerContext.cs index dd7f2d6..5699932 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/PowerContext.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/PowerContext.cs @@ -150,8 +150,10 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem public void WeaponDamage(TargetList targets, float damageMultiplier, DamageType damageType) { - AttackPayload payload = new AttackPayload(this); - payload.Targets = targets; + AttackPayload payload = new AttackPayload(this) + { + Targets = targets + }; payload.AddWeaponDamage(damageMultiplier, damageType); payload.Apply(); } @@ -166,15 +168,17 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem public void Damage(TargetList targets, float minDamage, float damageDelta, DamageType damageType) { - AttackPayload payload = new AttackPayload(this); - payload.Targets = targets; + AttackPayload payload = new AttackPayload(this) + { + Targets = targets + }; payload.AddDamage(minDamage, damageDelta, damageType); payload.Apply(); } public EffectActor SpawnEffect(ActorSno actorSNO, Vector3D position, float angle = 0, TickTimer timeout = null) { - if (angle == -1) + if (Math.Abs(angle - (-1)) < 0.0001) angle = (float)(Rand.NextDouble() * (Math.PI * 2)); if (timeout == null) { diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Skill.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Skill.cs index 58fef03..bb55a99 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Skill.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Skill.cs @@ -53,13 +53,12 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem try { int tag = EvalTag(PowerKeys.AnimationTag); - if (User.AnimationSet == null) + if (User.AnimationSet != null) { if (User.AnimationSet.Animations.ContainsKey(tag)) return User.AnimationSet.Animations[tag]; - else return (AnimationSno)User.AnimationSet.GetAnimationTag(AnimationTags.Attack2); - - } + return (AnimationSno)User.AnimationSet.GetAnimationTag(AnimationTags.Attack2); + } } catch (Exception e) { @@ -103,17 +102,17 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem var animationSNO = GetActionAnimationSNO(); #region Патч анимаций if(animationSNO == AnimationSno._NONE) - switch (this.User.SNO) - { - case ActorSno._x1_skeletonarcher_westmarch_a: //x1_SkeletonArcher_Westmarch_A - if (this.PowerSNO == 30334) + switch (this.User.SNO) + { + case ActorSno._x1_skeletonarcher_westmarch_a: //x1_SkeletonArcher_Westmarch_A + if (this.PowerSNO == 30334) + animationSNO = AnimationSno.x1_skeletonarcher_westmarch_attack_01; + break; + case ActorSno._p6_necro_skeletonmage_f_archer: //p6_necro_skeletonMage_F_archer animationSNO = AnimationSno.x1_skeletonarcher_westmarch_attack_01; - break; - case ActorSno._p6_necro_skeletonmage_f_archer: //p6_necro_skeletonMage_F_archer - animationSNO = AnimationSno.x1_skeletonarcher_westmarch_attack_01; - speed = 2f; - break; - } + speed = 2f; + break; + } #endregion if (animationSNO != AnimationSno._NONE && speed > 0f) diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/QuestSystem/QuestEvents/Implementations/Act III/Transformation/Line11.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/QuestSystem/QuestEvents/Implementations/Act III/Transformation/Line11.cs index 02b3da4..d096fb9 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/QuestSystem/QuestEvents/Implementations/Act III/Transformation/Line11.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/QuestSystem/QuestEvents/Implementations/Act III/Transformation/Line11.cs @@ -15,8 +15,8 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem.QuestEvents.Implementations public override void Execute(MapSystem.World world) { StartConversation(world, 195767); - var Leah = world.GetActorBySNO(ActorSno._leah_event47); - Leah.PlayActionAnimation(AnimationSno.leah_bss_event_lvlup); + var leah = world.GetActorBySNO(ActorSno._leah_event47); + leah.PlayActionAnimation(AnimationSno.leah_bss_event_lvlup); } private bool StartConversation(MapSystem.World world, Int32 conversationId)