Beispiel #1
0
        protected void Explode(MabiCreature attacker, MabiCreature target, MabiSkill skill, MabiProp casterProp, float dmgModifier = 1f)
        {
            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, target.Id).PutInt(Effect.IcespearFreeze).PutByte(1).PutInt(0), SendTargets.Range, target); // Cancel freeze

            var tPos = target.GetPosition();
            var bombProp = new MabiProp(280, target.Region, tPos.X, tPos.Y, 0); //4
            WorldManager.Instance.AddProp(bombProp);

            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, bombProp.Id).PutInts(Effect.IcespearBoom, target.Region, tPos.X, tPos.Y), SendTargets.Range, bombProp);

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

            var sAction = new AttackerAction(CombatActionType.SpecialHit, attacker, skill.Id, SkillHelper.GetAreaTargetID(target.Region, tPos.X, tPos.Y));
            sAction.PropId = casterProp.Id;
            sAction.Options = AttackerOptions.KnockBackHit1 | AttackerOptions.UseEffect;

            var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Id);
            tAction.Options = TargetOptions.Result;
            tAction.StunTime = target.Stun = 2000;

            var rnd = RandomProvider.Get();

            var damage = attacker.GetMagicDamage(attacker.RightHand, rnd.Next((int)skill.RankInfo.Var1, (int)skill.RankInfo.Var2 + 1)) * dmgModifier;

            if (CombatHelper.TryAddCritical(target, ref damage, attacker.CriticalChanceAgainst(target)))
                tAction.Options |= TargetOptions.Critical;

            target.TakeDamage(tAction.Damage = damage);

            // Knock down if dead
            tAction.OldPosition = CombatHelper.KnockBack(target, bombProp);
            if (target.IsDead)
            {
                tAction.Options |= TargetOptions.FinishingKnockDown;
            }
            else
            {
                tAction.Options |= TargetOptions.KnockDown;
                CombatHelper.SetAggro(attacker, target);
            }

            var cap = new CombatActionPack(attacker, skill.Id);
            cap.Add(sAction, tAction);

            WorldManager.Instance.HandleCombatActionPack(cap);

            sAction = new AttackerAction(CombatActionType.SpecialHit, attacker, skill.Id, SkillHelper.GetAreaTargetID(target.Region, tPos.X, tPos.Y));
            sAction.PropId = bombProp.Id;
            sAction.Options = AttackerOptions.UseEffect;

            cap = new CombatActionPack(attacker, skill.Id);
            cap.Add(sAction);

            WorldManager.Instance.HandleCombatActionPack(cap);

            WorldManager.Instance.RemoveProp(bombProp);
        }