public override SkillResults UseCombat(MabiCreature attacker, ulong targetId, MabiSkill skill)
        {
            var target = WorldManager.Instance.GetCreatureById(targetId);
            if (target == null)
                return SkillResults.InvalidTarget;

            if (attacker.Inventory.Magazine == null || attacker.Inventory.Magazine.Count < 1)
                return SkillResults.Failure;

            var rnd = RandomProvider.Get();

            attacker.StopMove();

            var factory = new CombatFactory();
            factory.SetAttackerAction(attacker, CombatActionType.RangeHit, skill.Id, targetId);
            factory.SetAttackerOptions(AttackerOptions.Result);
            factory.SetAttackerStun(AfterUseStun);

            bool hit = false;

            if (attacker.GetAimPercent(attacker.Skills.Get(SkillConst.RangedCombatMastery).RankInfo.Var3, attacker.ActiveSkillStacks == 5 ? skill.RankInfo.Var3 : 0) > rnd.NextDouble())
            {
                target.StopMove();

                factory.AddTargetAction(target, CombatActionType.TakeHit);
                factory.SetTargetOptions(TargetOptions.Result);
                factory.SetTargetStun(StunTime);

                hit = true;
            }
            else
            {
                factory.AddTargetAction(target, CombatActionType.None);
            }

            Send.SkillUse(attacker.Client, attacker, skill.Id, AfterUseStun, 1);

            SkillHelper.DecStack(attacker, skill);

            attacker.Client.Send(new MabiPacket(Op.CombatTargetSet, attacker.Id).PutLong(0));

            factory.ExecuteDamage(new System.Func<MabiCreature, MabiCreature, float>((a, t) =>
                {
                    var dmg = attacker.GetRndRangeDamage();

                    switch (5 - a.ActiveSkillStacks)
                    {
                        case 1:
                            dmg *= (95 + skill.RankInfo.Var1) / 100f;
                            break;
                        case 2:
                            dmg *= (105 + skill.RankInfo.Var1) / 100f;
                            break;
                        case 3:
                            dmg *= (110 + skill.RankInfo.Var1) / 100f;
                            break;
                        case 4:
                            dmg *= (130 + skill.RankInfo.Var1) / 100f;
                            break;
                        default:
                            dmg *= (160 + skill.RankInfo.Var2) / 100f;
                            break;
                    }

                    return dmg;
                }));
            factory.ExecuteStun();
            factory.ExecuteKnockback(40f);

            WorldManager.Instance.HandleCombatActionPack(factory.GetCap());

            if (hit)
                CombatHelper.SetAggro(attacker, target);

            SkillHelper.GiveSkillExp(attacker, skill, 20);

            return SkillResults.Okay;
        }
Exemple #2
0
        public override SkillResults UseCombat(MabiCreature attacker, ulong targetId, MabiSkill skill)
        {
            var target = WorldManager.Instance.GetCreatureById(targetId);
            if (target == null)
                return SkillResults.InvalidTarget;

            if (attacker.Magazine == null || attacker.Magazine.Count < 1)
                return SkillResults.Failure;

            var rnd = RandomProvider.Get();

            attacker.StopMove();

            var factory = new CombatFactory();
            factory.SetAttackerAction(attacker, CombatActionType.RangeHit, skill.Id, targetId);
            factory.SetAttackerOptions(AttackerOptions.Result);
            factory.SetAttackerStun(AfterUseStun);

            bool hit = false;

            if (attacker.GetAimPercent(1) > rnd.NextDouble())
            {
                target.StopMove();

                factory.AddTargetAction(target, CombatActionType.TakeHit);
                factory.SetTargetOptions(TargetOptions.Result);
                factory.SetTargetStun(StunTime);

                hit = true;
            }
            else
            {
                factory.AddTargetAction(target, CombatActionType.None);
            }

            Send.SkillUse(attacker.Client, attacker, skill.Id, AfterUseStun, 1);

            SkillHelper.ClearStack(attacker, skill);

            attacker.Client.Send(new MabiPacket(Op.CombatTargetSet, attacker.Id).PutLong(0));

            factory.ExecuteDamage(new System.Func<MabiCreature, MabiCreature, float>((a, t) =>
                {
                    var damage = attacker.GetRndRangeDamage();
                    damage *= skill.RankInfo.Var1 / 100f;
                    return damage;
                }));
            factory.ExecuteStun();
            factory.ExecuteKnockback(CombatHelper.MaxKnockBack);

            WorldManager.Instance.HandleCombatActionPack(factory.GetCap());

            if (hit)
                CombatHelper.SetAggro(attacker, target);

            SkillHelper.GiveSkillExp(attacker, skill, 20);

            return SkillResults.Okay;
        }
        public override SkillResults UseCombat(MabiCreature attacker, ulong targetId, MabiSkill skill)
        {
            var target = WorldManager.Instance.GetCreatureById(targetId);
            if (target == null)
                return SkillResults.InvalidTarget;

            if (attacker.Magazine == null || attacker.Magazine.Count < 1)
                return SkillResults.Failure;

            var rnd = RandomProvider.Get();

            attacker.StopMove();

            var factory = new CombatFactory();
            factory.SetAttackerAction(attacker, CombatActionType.RangeHit, skill.Id, targetId);
            factory.SetAttackerOptions(AttackerOptions.Result);
            factory.SetAttackerStun(AfterUseStun);

            bool hit = false;

            if (attacker.GetAimPercent(attacker.Skills.Get(SkillConst.RangedCombatMastery).RankInfo.Var3) > rnd.NextDouble())
            {
                target.StopMove();

                factory.AddTargetAction(target, CombatActionType.TakeHit);
                factory.SetTargetOptions(TargetOptions.Result);
                factory.SetTargetStun(StunTime);

                hit = true;
            }
            else
            {
                factory.AddTargetAction(target, CombatActionType.None);
            }

            Send.SkillUse(attacker.Client, attacker, skill.Id, AfterUseStun, 1);

            SkillHelper.ClearStack(attacker, skill);

            attacker.Client.Send(new MabiPacket(Op.CombatTargetSet, attacker.Id).PutLong(0));

            factory.ExecuteDamage(new System.Func<MabiCreature, MabiCreature, float>((a, t) =>
                {
                    var damage = attacker.GetRndRangeDamage();
                    return damage * .8f;
                }));
            factory.ExecuteStun();
            factory.ExecuteKnockback(0f);

            WorldManager.Instance.HandleCombatActionPack(factory.GetCap());

            if (!target.IsDead && hit)
            {
                // TODO: debuff

                WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, target.Id).PutInt(Effect.SupportShot).PutByte(1), SendTargets.Range, target);

                System.Threading.Thread t = new System.Threading.Thread(() =>
                {
                    System.Threading.Thread.Sleep(3000);
                    WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, target.Id).PutInt(Effect.SupportShot).PutByte(0), SendTargets.Range, target);
                });

                t.Start();

                CombatHelper.SetAggro(attacker, target);
            }

            SkillHelper.GiveSkillExp(attacker, skill, 20);

            return SkillResults.Okay;
        }