コード例 #1
0
        public void TargetHit(IBattleEntity target, TargetHitType hitType, Skill skill, short?skillEffect = null, short?mapX = null, short?mapY = null, ComboDTO skillCombo = null, bool showTargetAnimation = false, bool isPvp = false)
        {
            if (!target.IsTargetable(Entity.SessionType(), isPvp) || (target.Faction == Entity.Faction && ServerManager.Instance.Act4Maps.Any(m => m == Entity.MapInstance)))
            {
                if (Session is Character cha)
                {
                    cha.Session.SendPacket($"cancel 2 {target.GetId()}");
                }
                return;
            }

            MapInstance mapInstance = target.MapInstance;
            int         hitmode     = 0;
            bool        onyxWings   = false;
            ushort      damage      = GenerateDamage(target, skill, ref hitmode, ref onyxWings);

            if (Session is Character charact && onyxWings && mapInstance != null)
            {
                short onyxX  = (short)(charact.PositionX + 2);
                short onyxY  = (short)(charact.PositionY + 2);
                int   onyxId = mapInstance.GetNextId();
                var   onyx   = new MapMonster
                {
                    MonsterVNum   = 2371,
                    MapX          = onyxX,
                    MapY          = onyxY,
                    MapMonsterId  = onyxId,
                    IsHostile     = false,
                    IsMoving      = false,
                    ShouldRespawn = false
                };
                mapInstance.Broadcast($"guri 31 1 {charact.CharacterId} {onyxX} {onyxY}");
                onyx.Initialize(mapInstance);
                mapInstance.AddMonster(onyx);
                mapInstance.Broadcast(onyx.GenerateIn());
                target.GetDamage(damage / 2, Entity, false);
                Observable.Timer(TimeSpan.FromMilliseconds(350)).Subscribe(o =>
                {
                    mapInstance.Broadcast($"su 3 {onyxId} 3 {target.GetId()} -1 0 -1 {skill.Effect} -1 -1 1 {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {damage / 2} 0 0");
                    mapInstance.RemoveMonster(onyx);
                    mapInstance.Broadcast(onyx.GenerateOut());
                });
            }

            if (target.GetSession() is Character character)
            {
                damage = (ushort)(character.HasGodMode ? 0 : damage);
                if (character.IsSitting)
                {
                    character.IsSitting = false;
                    character.MapInstance.Broadcast(character.GenerateRest());
                }
            }
            else if (target.GetSession() is Mate mate)
            {
                if (mate.IsSitting)
                {
                    mate.IsSitting = false;
                    mate.Owner.MapInstance.Broadcast(mate.GenerateRest());
                }
            }

            int castTime = 0;

            if (skill != null && skill.CastEffect != 0)
            {
                Entity.MapInstance.Broadcast(Entity.GenerateEff(skill.CastEffect), Entity.GetPos().X, Entity.GetPos().Y);
                castTime = skill.CastTime * 100;
            }
            Observable.Timer(TimeSpan.FromMilliseconds(castTime)).Subscribe(o => TargetHit2(target, hitType, skill, damage, hitmode, skillEffect, mapX, mapY, skillCombo, showTargetAnimation, isPvp));
        }
コード例 #2
0
        private void TargetHit2(IBattleEntity target, TargetHitType hitType, Skill skill, int damage, int hitmode, short?skillEffect = null, short?mapX = null, short?mapY = null, ComboDTO skillCombo = null, bool showTargetAnimation = false, bool isPvp = false, bool isRange = false)
        {
            target.GetDamage(damage, Entity, !(Session is MapMonster mon && mon.IsInvicible));
            string str = $"su {(byte)Entity.SessionType()} {Entity.GetId()} {(byte)target.SessionType()} {target.GetId()} {skill?.SkillVNum ?? 0} {skill?.Cooldown ?? 0}";

            switch (hitType)
            {
            case TargetHitType.SingleTargetHit:
                str += $" {skill?.AttackAnimation ?? 11} {skill?.Effect ?? skillEffect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {damage} {hitmode} {skill?.SkillType - 1 ?? 0}";
                break;

            case TargetHitType.SingleTargetHitCombo:
                str += $" {skillCombo?.Animation ?? 0} {skillCombo?.Effect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {damage} {hitmode} {skill.SkillType - 1}";
                break;

            case TargetHitType.SingleAOETargetHit:
                switch (hitmode)
                {
                case 1:
                    hitmode = 4;
                    break;

                case 3:
                    hitmode = 6;
                    break;

                default:
                    hitmode = 5;
                    break;
                }
                if (showTargetAnimation)
                {
                    Entity.MapInstance.Broadcast($" {skill?.AttackAnimation ?? 0} {skill?.Effect ?? 0} 0 0 {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} 0 0 {skill.SkillType - 1}");
                }
                str += $" {skill?.AttackAnimation ?? 0} {skill?.Effect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {damage} {hitmode} {skill.SkillType - 1}";
                break;

            case TargetHitType.AOETargetHit:
                switch (hitmode)
                {
                case 1:
                    hitmode = 4;
                    break;

                case 3:
                    hitmode = 6;
                    break;

                default:
                    hitmode = 5;
                    break;
                }
                str += $" {skill?.AttackAnimation ?? 0} {skill?.Effect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {damage} {hitmode} {skill.SkillType - 1}";
                break;

            case TargetHitType.ZoneHit:
                str += $" {skill?.AttackAnimation ?? 0} {skillEffect ?? 0} {mapX ?? Entity.GetPos().X} {mapY ?? Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {damage} 5 {skill.SkillType - 1}";
                break;

            case TargetHitType.SpecialZoneHit:
                str += $" {skill?.AttackAnimation ?? 0} {skillEffect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {damage} 0 {skill.SkillType - 1}";
                break;
            }
            Entity.MapInstance.Broadcast(str);

            bool isBoss = false;

            if (Entity.GetSession() is Character character)
            {
                character.LastSkillUse = DateTime.Now;
                RemoveBuff(85); // Hideout
            }
            else if (Entity.GetSession() is Mate mate)
            {
                mate.LastSkillUse = DateTime.Now;
            }
            if (target.GetSession() is MapMonster monster)
            {
                if (monster.Target == null)
                {
                    monster.LastSkill = DateTime.Now;
                }
                monster.Target = Entity;
                isBoss         = monster.IsBoss;
                if (isBoss)
                {
                    Entity.MapInstance?.Broadcast(monster.GenerateBoss());
                }
                monster.DamageList.AddOrUpdate(Entity, damage, (key, oldValue) => oldValue + damage);
            }

            if (!isBoss && skill != null)
            {
                foreach (BCard bcard in skill.BCards.Where(b => b != null))
                {
                    switch ((CardType)bcard.Type)
                    {
                    case CardType.Buff:
                        Buff.Buff b = new Buff.Buff(bcard.SecondData);
                        switch (b.Card?.BuffType)
                        {
                        case BuffType.Bad:
                            bcard.ApplyBCards(target, Entity);
                            break;

                        case BuffType.Good:
                        case BuffType.Neutral:
                            bcard.ApplyBCards(Entity, Entity);
                            break;
                        }
                        break;

                    case CardType.HealingBurningAndCasting:
                        switch ((AdditionalTypes.HealingBurningAndCasting)bcard.SubType)
                        {
                        case AdditionalTypes.HealingBurningAndCasting.RestoreHP:
                        case AdditionalTypes.HealingBurningAndCasting.RestoreHPWhenCasting:
                            bcard.ApplyBCards(Entity, Entity);
                            break;

                        default:
                            bcard.ApplyBCards(target, Entity);
                            break;
                        }
                        break;

                    case CardType.MeditationSkill:
                        bcard.ApplyBCards(Entity);
                        break;

                    default:
                        bcard.ApplyBCards(target, Entity);
                        break;
                    }
                }
            }

            if (skill == null || (skill.Range <= 0 && skill.TargetRange <= 0) || isRange || !(Entity.GetSession() is MapMonster))
            {
                return;
            }

            foreach (IBattleEntity entitiesInRange in Entity.MapInstance?.GetBattleEntitiesInRange(Entity.GetPos(), skill.TargetRange).Where(e => e != target && e.IsTargetable(Entity.SessionType())))
            {
                TargetHit2(entitiesInRange, TargetHitType.SingleTargetHit, skill, damage, hitmode, isRange: true);
            }
        }
コード例 #3
0
        public void TargetHit(IBattleEntity target, TargetHitType hitType, Skill skill, short?skillEffect = null,
                              short?mapX = null, short?mapY = null, ComboDTO skillCombo = null, bool showTargetAnimation = false,
                              bool isPvp = false)
        {
            if (target == null || Entity == null)
            {
                return;
            }

            if (!target.IsTargetable(Entity.SessionType(), isPvp) ||
                target.Faction == Entity.Faction && ServerManager.Instance.Act4Maps.Any(m => m == Entity.MapInstance))
            {
                if (Session is Character cha)
                {
                    cha.Session.SendPacket($"cancel 2 {target.GetId()}");
                }

                return;
            }

            MapInstance mapInstance = target.MapInstance;
            int         hitmode     = 0;
            bool        onyxWings   = false;
            int         damage      = DamageHelper.Instance.GenerateDamage(this, target, skill, ref hitmode, ref onyxWings);

            if (skill != null && SkillHelper.Instance.NoDamageSkills != null)
            {
                if (SkillHelper.Instance.NoDamageSkills.Any(s => s == skill.SkillVNum))
                {
                    target.DealtDamage = 0;
                    damage             = 0;
                }
            }

            if (Session is Character charact && mapInstance != null && hitmode != 1)
            {
                target.RemoveBuff(548);
                if (onyxWings)
                {
                    short onyxX  = (short)(charact.PositionX + 2);
                    short onyxY  = (short)(charact.PositionY + 2);
                    int   onyxId = mapInstance.GetNextId();
                    var   onyx   = new MapMonster
                    {
                        MonsterVNum   = 2371,
                        MapX          = onyxX,
                        MapY          = onyxY,
                        MapMonsterId  = onyxId,
                        IsHostile     = false,
                        IsMoving      = false,
                        ShouldRespawn = false
                    };
                    mapInstance.Broadcast($"guri 31 1 {charact.CharacterId} {onyxX} {onyxY}");
                    onyx.Initialize(mapInstance);
                    mapInstance.AddMonster(onyx);
                    mapInstance.Broadcast(onyx.GenerateIn());
                    target.GetDamage(target.DealtDamage / 2, Entity, false);
                    Observable.Timer(TimeSpan.FromMilliseconds(350)).Subscribe(o =>
                    {
                        mapInstance.Broadcast(
                            $"su 3 {onyxId} {(target is Character ? "1" : "3")} {target.GetId()} -1 0 -1 {skill.Effect} -1 -1 1 {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {(target.BattleEntity.IsReflecting ? 0 : target.DealtDamage) / 2} 0 0");
                        mapInstance.RemoveMonster(onyx);
                        mapInstance.Broadcast(onyx.GenerateOut());
                    });
                }

                if (target is Character tchar)
                {
                    if (tchar.ReflectiveBuffs.Any())
                    {
                        int?multiplier = 0;

                        foreach (KeyValuePair <short, int?> entry in tchar.ReflectiveBuffs)
                        {
                            multiplier += entry.Value;
                        }
                        ushort damaged = (ushort)(damage > tchar.Level * multiplier ? tchar.Level * multiplier : damage);
                        mapInstance.Broadcast(
                            $"su 1 {tchar.GetId()} 1 {charact.GetId()} -1 0 -1 {skill.Effect} -1 -1 1 {(int)(tchar.Hp / (double)target.MaxHp * 100)} {damaged} 0 1");
                        charact.Hp = charact.Hp - damaged <= 0 ? 1 : charact.Hp - damaged;
                        charact.Session.SendPacket(charact.GenerateStat());
                        target.DealtDamage = 0;
                    }
                }
                else if (target is MapMonster tmon)
                {
                    if (tmon.ReflectiveBuffs.Any())
                    {
                        int?multiplier = 0;

                        foreach (KeyValuePair <short, int?> entry in tmon.ReflectiveBuffs)
                        {
                            multiplier += entry.Value;
                        }

                        ushort damaged = (ushort)(damage > tmon.Monster.Level * multiplier ? tmon.Monster.Level * multiplier : damage);
                        charact.Hp -= charact.Hp - damaged <= 0 ? 1 : charact.Hp - damaged;
                        charact.Session.SendPacket(charact.GenerateStat());
                        mapInstance.Broadcast(
                            $"su 3 {tmon.GetId()} 1 {charact.GetId()} -1 0 -1 {skill.Effect} -1 -1 1 {(int)(tmon.CurrentHp / (double)target.MaxHp * 100)} {damaged} 0 1");
                        target.DealtDamage = 0;
                    }
                }
            }

            if (target.GetSession() is Character character)
            {
                damage             = (ushort)(character.HasGodMode ? 0 : damage);
                target.DealtDamage = (ushort)(character.HasGodMode ? 0 : damage);
                if (character.IsSitting)
                {
                    character.IsSitting = false;
                    character.MapInstance.Broadcast(character.GenerateRest());
                }
            }
            else if (target.GetSession() is Mate mate)
            {
                if (mate.IsSitting)
                {
                    mate.IsSitting = false;
                    mate.Owner.MapInstance.Broadcast(mate.GenerateRest());
                }
            }

            int castTime = 0;

            if (skill != null && skill.CastEffect != 0)
            {
                Entity.MapInstance.Broadcast(Entity.GenerateEff(skill.CastEffect), Entity.GetPos().X,
                                             Entity.GetPos().Y);
                castTime = skill.CastTime * 100;
            }

            Observable.Timer(TimeSpan.FromMilliseconds(castTime)).Subscribe(o => TargetHit2(target, hitType, skill,
                                                                                            damage, hitmode, skillEffect, mapX, mapY, skillCombo, showTargetAnimation, isPvp));
        }