public static int GetDamage(YiObj attacker, YiObj target, MsgInteractType attackType) { if (!YiCore.Success(attacker.Dexterity)) { return(0); } var damage = 1.0d; switch (attackType) { case MsgInteractType.Physical: damage = YiCore.Random.Next(attacker.MinimumPhsyicalAttack, attacker.MaximumPhsyicalAttack); if (attacker is Monster) { damage = YiCore.Random.Next(attacker.MinimumPhsyicalAttack, attacker.MaximumPhsyicalAttack); } if (target is Monster monster) { damage = AdjustPvE((float)damage, attacker, monster); } if (attacker is Monster monster1 && target != null) { damage = AdjustEvP((float)damage, monster1, target); } if (target != null) { damage -= target.Defense; } break; case MsgInteractType.Magic: damage = attacker.MagicAttack; //if (attacker is Monster) // damage = (attacker as Monster).Base.MagicAttack; //if (attacker is YiObj && target is Monster) // damage = AdjustPvE(damage, (YiObj)attacker, (Monster)target); //if (attacker is Monster && target is YiObj) // damage = AdjustEvP(damage, (Monster)attacker, (YiObj)target); if (target != null) { damage *= (float)(100 - Math.Min(target.MagicDefense, 95)) / 100; damage -= target.MagicDefense; //MagicBlock damage *= 0.65; } else { damage *= 0.75; } break; case MsgInteractType.Archer: if (attacker == null) { return(0); } damage = YiCore.Random.Next(attacker.MinimumPhsyicalAttack, attacker.MaximumPhsyicalAttack); damage = AdjustPvE((float)damage, attacker, attacker.CurrentTarget as Monster); break; } if (target != null) { if (target.Reborn) { damage *= 0.7; } damage *= Math.Max(target.Bless, 1); } if (damage > 0) { damage = YiCore.Random.Next((int)(damage / 1.2), (int)damage); } damage *= 0.75; damage = Math.Max(1, damage); if (attacker is Player aPlayer) { if (target == null) { return((int)Math.Round(damage, 0)); } if (attacker.HasFlag(StatusEffect.SuperMan)) { damage *= 10; } } if (target != null) { TeamSystem.ShareExp(attacker, target, (uint)Math.Round(target.MaximumHp * 0.05)); } attacker.Experience += AdjustExp((int)Math.Round(damage, 0), attacker, target); return((int)Math.Round(damage, 0)); }
public static int MagicDmg(YiObj attacker, Monster target) { float damage; if (attacker.CurrentSkill.Id == 1115 || attacker.CurrentSkill.Info.WeaponSubType != 0 && attacker.CurrentSkill.Info.WeaponSubType != 500) { damage = YiCore.Random.Next(attacker.MinimumPhsyicalAttack, attacker.MaximumPhsyicalAttack); if (attacker.CurrentSkill.Info.Power > 30000) { damage *= (float)(attacker.CurrentSkill.Info.Power - 30000) / 100; } else { damage += attacker.CurrentSkill.Info.Power; } damage = AdjustPvE(damage, attacker, target); damage -= target.Defense; } else if (attacker.CurrentSkill.Info.WeaponSubType == 500) { damage = YiCore.Random.Next(attacker.MinimumPhsyicalAttack, attacker.MaximumPhsyicalAttack); if (attacker.CurrentSkill.Info.Power > 30000) { damage *= (float)(attacker.CurrentSkill.Info.Power - 30000) / 100; } else { damage += attacker.CurrentSkill.Info.Power; } damage = AdjustPvE(damage, attacker, target); } else { damage = attacker.MagicAttack; if (attacker.CurrentSkill.Info.Power > 30000) { damage *= (float)(attacker.CurrentSkill.Info.Power - 30000) / 100; } else { damage += attacker.CurrentSkill.Info.Power; } damage = AdjustPvE(damage, attacker, target); damage *= (float)(100 - target.MagicDefense) / 100; damage -= target.MagicDefense; //target.MagicBlock; damage *= 0.75f; } if (damage < 1) { damage = 1; } damage = AdjustMinPvE(damage, attacker); attacker.Experience += AdjustExp((int)Math.Round(damage, 0), attacker, target); TeamSystem.ShareExp(attacker, target, (uint)Math.Round(target.MaximumHp * 0.05)); return((int)Math.Round(damage, 0)); }