示例#1
0
        public override SkillResults Ready(MabiCreature creature, MabiSkill skill)
        {
            SkillHelper.FillStack(creature, skill);
            Send.SkillReady(creature.Client, creature, skill.Id);

            return SkillResults.Okay;
        }
示例#2
0
        public override SkillResults Stop(MabiCreature creature, MabiSkill skill, MabiTags tags)
        {
            creature.State &= ~CreatureStates.SitDown;
            Send.StandUp(creature);

            if (creature.Temp.SittingProp != null)
            {
                // Effect
                if (creature.Temp.CurrentChair.Effect != 0)
                    Send.Effect(Effect.CherryBlossoms, creature, false);

                // Update chair
                creature.Temp.SittingProp.ExtraData = string.Format("<xml OWNER='0' SITCHAR='0'/>");
                Send.PropUpdate(creature.Temp.SittingProp);

                Send.AssignChair(creature, 0, 0);

                // Remove chair in 1s
                creature.Temp.SittingProp.DisappearTime = DateTime.Now.AddSeconds(1);

                creature.Temp.SittingProp = null;
            }

            return SkillResults.Okay;
        }
示例#3
0
        public void AddBonuses(MabiSkill skill)
        {
            var mana = skill.RankInfo.ManaTotal;
            var life = skill.RankInfo.LifeTotal;
            var stamina = skill.RankInfo.StaminaTotal;

            _creature.StrBaseSkill += skill.RankInfo.StrTotal;
            _creature.WillBaseSkill += skill.RankInfo.WillTotal;
            _creature.IntBaseSkill += skill.RankInfo.IntTotal;
            _creature.LuckBaseSkill += skill.RankInfo.LuckTotal;
            _creature.DexBaseSkill += skill.RankInfo.DexTotal;
            _creature.ManaMaxBaseSkill += mana;
            _creature.Mana += mana;
            _creature.LifeMaxBaseSkill += life;
            _creature.Life += life;
            _creature.StaminaMaxBaseSkill += stamina;
            _creature.Stamina += stamina;

            if (skill.Id == SkillConst.MeleeCombatMastery)
            {
                _creature.StatMods.Add(Stat.LifeMaxMod, skill.RankInfo.Var3, StatModSource.SkillRank, skill.Info.Id);
                _creature.Life += skill.RankInfo.Var3;
            }
            else if (skill.Id == SkillConst.MagicMastery)
            {
                _creature.StatMods.Add(Stat.ManaMaxMod, skill.RankInfo.Var1, StatModSource.SkillRank, skill.Info.Id);
                _creature.Mana += skill.RankInfo.Var1;
            }
            else if (skill.Id == SkillConst.Defense)
            {
                _creature.DefenseBaseSkill += (int)skill.RankInfo.Var1;
            }
        }
示例#4
0
        public override SkillResults Stop(MabiCreature creature, MabiSkill skill)
        {
            creature.Conditions.A &= ~CreatureConditionA.ManaShield;
            Send.StatusEffectUpdate(creature);

            return SkillResults.Okay;
        }
示例#5
0
        public override SkillResults Prepare(MabiCreature creature, MabiSkill skill, MabiPacket packet, uint castTime)
        {
            Send.Flash(creature);
            Send.SkillPrepare(creature.Client, creature, skill.Id, castTime);

            return SkillResults.Okay;
        }
示例#6
0
        public override SkillResults Use(MabiCreature creature, MabiSkill skill, MabiPacket packet)
        {
            var targetId = packet.GetLong();
            var target = WorldManager.Instance.GetCreatureById(targetId);
            if (target == null)
                return SkillResults.InvalidTarget;

            if (creature != target && !WorldManager.InRange(creature, target, 1000))
                return SkillResults.OutOfRange;

            // Reduce Stamina equal to healing amount if a player
            // is using the skill on himself.
            if (creature == target && creature is MabiPC)
            {
                var amount = Math.Min(skill.RankInfo.Var1, creature.LifeInjured - creature.Life);
                if (creature.Stamina < amount)
                    return SkillResults.InsufficientStamina;

                creature.Stamina -= amount;
            }

            target.Life += skill.RankInfo.Var1;
            WorldManager.Instance.CreatureStatsUpdate(target);

            SkillHelper.DecStack(creature, skill);

            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.UseMagic).PutString("healing").PutLong(target.Id), SendTargets.Range, creature);
            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.StackUpdate).PutString("healing_stack").PutBytes(creature.ActiveSkillStacks, 0), SendTargets.Range, creature);

            SkillHelper.GiveSkillExp(creature, skill, 20);

            Send.SkillUse(creature.Client, creature, skill.Id, targetId);

            return SkillResults.Okay;
        }
示例#7
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;
        }
示例#8
0
        public override SkillResults Complete(MabiCreature creature, MabiSkill skill, MabiPacket packet)
        {
            Send.SkillComplete(creature.Client, creature, skill.Id);
            if (creature.ActiveSkillStacks > 0)
                Send.SkillReady(creature.Client, creature, skill.Id);

            return SkillResults.Okay;
        }
示例#9
0
        public override SkillResults Stop(MabiCreature creature, MabiSkill skill)
        {
            creature.Deactivate(CreatureConditionB.Transparent);

            Send.StatusEffectUpdate(creature);

            return SkillResults.Okay;
        }
示例#10
0
        public override SkillResults Stop(MabiCreature creature, MabiSkill skill)
        {
            creature.Deactivate(CreatureConditionD.SpreadWings);

            Send.SpreadWings(creature, false);

            return SkillResults.Okay;
        }
示例#11
0
        public override SkillResults Start(MabiCreature creature, MabiSkill skill)
        {
            creature.Activate(CreatureConditionD.SpreadWings);

            Send.SpreadWings(creature, true);

            return SkillResults.Okay;
        }
示例#12
0
        public override SkillResults Complete(MabiCreature creature, MabiSkill skill, MabiPacket packet)
        {
            creature.Client.Send(new MabiPacket(Op.CombatSetAimR, creature.Id).PutByte(0));

            Send.SkillComplete(creature.Client, creature, skill.Id);

            return SkillResults.Okay;
        }
示例#13
0
        public override SkillResults Start(MabiCreature creature, MabiSkill skill)
        {
            creature.Conditions.A |= CreatureConditionA.ManaShield;
            Send.StatusEffectUpdate(creature);
            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.ManaShield), SendTargets.Range, creature);

            return SkillResults.Okay;
        }
示例#14
0
 /// <summary>
 /// Decreases stack and sends update.
 /// </summary>
 /// <param name="creature"></param>
 /// <param name="skill"></param>
 /// <param name="amount"></param>
 public static void DecStack(MabiCreature creature, MabiSkill skill, byte amount = 1)
 {
     if (creature.ActiveSkillStacks > amount)
         creature.ActiveSkillStacks -= amount;
     else
         creature.ActiveSkillStacks = 0;
     Send.SkillStackUpdate(creature.Client, creature, skill.Id, creature.ActiveSkillStacks);
 }
示例#15
0
        public override SkillResults Cancel(MabiCreature creature, MabiSkill skill)
        {
            SkillHelper.ClearStack(creature, skill);
            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.StackUpdate).PutString(this.Name).PutBytes(creature.ActiveSkillStacks, 0), SendTargets.Range, creature);

            WorldManager.Instance.Broadcast(new MabiPacket(Op.MotionCancel2, creature.Id).PutByte(1), SendTargets.Range, creature);

            return SkillResults.Okay;
        }
示例#16
0
        public override SkillResults Start(MabiCreature creature, MabiSkill skill)
        {
            if (creature.RightHand == null)
                return SkillResults.Failure;

            WorldManager.Instance.Broadcast(new MabiPacket(Op.OpenUmbrella, creature.Id).PutInt(creature.RightHand.Info.Class), SendTargets.Range, creature);

            return SkillResults.Okay;
        }
示例#17
0
        public override SkillResults Cancel(MabiCreature creature, MabiSkill skill)
        {
            if (creature.Target != null)
                creature.Client.Send(new MabiPacket(Op.CombatSetAimR, creature.Id).PutByte(0));

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

            return SkillResults.Okay;
        }
示例#18
0
        public virtual SkillResults Cancel(MabiCreature creature, MabiSkill skill)
        {
            //Logger.Unimplemented("Skill cancel handler for '{0}' ({1}).", skill.Id, skill.Info.Id);
            //return SkillResults.Unimplemented;

            // Canceling should be straight forward, let's just accept it.
            // Override for special stuff.
            return SkillResults.Okay;
        }
示例#19
0
        public override SkillResults Ready(MabiCreature creature, MabiSkill skill)
        {
            if (creature.ActiveSkillStacks < 1)
            {
                SkillHelper.IncStack(creature, skill);
            }
            Send.SkillReady(creature.Client, creature, skill.Id);

            return SkillResults.Okay;
        }
示例#20
0
        public override SkillResults Prepare(MabiCreature creature, MabiSkill skill, MabiPacket packet, uint castTime)
        {
            creature.StopMove();

            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.SkillInit).PutString("thunder").PutShort((ushort)skill.Id), SendTargets.Range, creature);

            Send.SkillPrepare(creature.Client, creature, skill.Id, castTime);

            return SkillResults.Okay;
        }
示例#21
0
        public override SkillResults Start(MabiCreature creature, MabiSkill skill, MabiPacket packet)
        {
            var parameter = (packet != null ? packet.GetStringOrEmpty() : "");

            var result = this.Start(creature, skill);

            Send.SkillStart(creature, skill.Id, parameter);

            return result;
        }
示例#22
0
        public override SkillResults Ready(MabiCreature creature, MabiSkill skill)
        {
            SkillHelper.FillStack(creature, skill);

            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.StackUpdate).PutString("healing_stack").PutBytes(creature.ActiveSkillStacks, 0), SendTargets.Range, creature);
            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.HoldMagic).PutString("healing"), SendTargets.Range, creature);

            Send.SkillReady(creature.Client, creature, skill.Id);

            return SkillResults.Okay;
        }
示例#23
0
        public override SkillResults Prepare(MabiCreature creature, MabiSkill skill, MabiPacket packet, uint castTime)
        {
            creature.StopMove();

            // Casting motion?
            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.Casting).PutShort(skill.Info.Id).PutBytes(0, 1).PutShort(0), SendTargets.Range, creature);

            Send.SkillPrepare(creature.Client, creature, skill.Id, castTime);

            return SkillResults.Okay;
        }
示例#24
0
        public void FireballProcessing(MabiCreature attacker, MabiSkill skill, MabiProp bomb, ulong targetId)
        {
            Thread.Sleep(4000);

            var victims = WorldManager.Instance.GetCreaturesInRange(bomb, 800).Where(c => !c.IsDead && c.IsAttackableBy(attacker)).ToList();

            ulong areaTarget = SkillHelper.GetAreaTargetID(bomb.Region, (uint)bomb.Info.X, (uint)bomb.Info.Y);

            var sAction = new AttackerAction(CombatActionType.SpecialHit, attacker, skill.Id, areaTarget);
            sAction.PropId = bomb.Id;
            sAction.Options = AttackerOptions.KnockBackHit1 | AttackerOptions.UseEffect;

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

            var rnd = RandomProvider.Get();

            foreach (var target in victims)
            {
                target.StopMove();

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

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

                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, bomb);
                if (target.IsDead)
                {
                    tAction.Options |= TargetOptions.FinishingKnockDown;
                }
                else
                {
                    tAction.Options |= TargetOptions.KnockDown;
                    CombatHelper.SetAggro(attacker, target);
                }

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

            WorldManager.Instance.HandleCombatActionPack(cap);

            WorldManager.Instance.RemoveProp(bomb);
        }
示例#25
0
        public override SkillResults Complete(MabiCreature creature, MabiSkill skill, MabiPacket packet)
        {
            if (creature.Temp.SkillItem1 == null)
                return SkillResults.Failure;

            Send.ItemUpdate(creature.Client, creature, creature.Temp.SkillItem1);
            Send.SkillComplete(creature.Client, creature, skill.Id, creature.Temp.SkillItem1.Id);

            creature.Temp.SkillItem1 = null;

            return SkillResults.Okay;
        }
        public override SkillResults Start(MabiCreature creature, MabiSkill skill, MabiPacket packet)
        {
            // Usually the second parameter is an empty string,
            // but if it's not empty it seems to be tags.
            var parameter = (packet != null && packet.GetElementType() == ElementType.String ? packet.GetString() : null);
            var tags = new MabiTags(parameter);

            var result = this.Start(creature, skill, tags);

            Send.SkillStart(creature, skill.Id, parameter);

            return result;
        }
示例#27
0
        public override SkillResults Use(MabiCreature creature, MabiSkill skill, MabiPacket packet)
        {
            var targetId = packet.GetLong();
            var target = WorldManager.Instance.GetCreatureById(targetId);
            if (target == null || !target.IsDead || (target.RevivalOptions & DeadMenuOptions.WaitForRescue) == 0 || !target.WaitingForRes)
                return SkillResults.InvalidTarget;

            WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.UseMagic).PutString("healing_phoenix").PutLong(target.Id), SendTargets.Range, creature);

            Send.SkillUse(creature.Client, creature, skill.Id, targetId);

            return SkillResults.Okay;
        }
示例#28
0
        public override SkillResults Stop(MabiCreature creature, MabiSkill skill, MabiPacket packet)
        {
            var parameter = (packet != null && packet.GetElementType() == ElementType.String ? packet.GetString() : null);

            var result = this.Stop(creature, skill);

            if (parameter != null)
                Send.SkillStop(creature, skill.Id, parameter);
            else
                Send.SkillStop(creature, skill.Id, 1);

            return result;
        }
示例#29
0
        public override SkillResults Start(MabiCreature creature, MabiSkill skill)
        {
            creature.Activate(CreatureConditionB.Demigod);

            creature.StopMove();

            // Spawn eruption
            {
                var pos = creature.GetPosition();
                var targets = WorldManager.Instance.GetAttackableCreaturesInRange(creature, EruptionRadius);

                var cap = new CombatActionPack(creature, skill.Id);
                var aAction = new AttackerAction(CombatActionType.SpecialHit, creature, skill.Id, SkillHelper.GetAreaTargetID(creature.Region, pos.X, pos.Y));
                aAction.Options |= AttackerOptions.KnockBackHit1 | AttackerOptions.UseEffect;

                cap.Add(aAction);

                foreach (var target in targets)
                {
                    target.StopMove();

                    // Officials use CM skill id.
                    var tAction = new TargetAction(CombatActionType.TakeHit, target, creature, skill.Id);
                    tAction.StunTime = EruptionStun;
                    tAction.Delay = 1000;

                    // Supposedly it's magic damage
                    tAction.Damage = creature.GetMagicDamage(null, EruptionDamage);

                    target.TakeDamage(tAction.Damage);
                    tAction.OldPosition = CombatHelper.KnockBack(target, creature, EruptionKnockBack);
                    if (target.IsDead)
                        tAction.Options |= TargetOptions.FinishingKnockDown;

                    cap.Add(tAction);
                }

                WorldManager.Instance.HandleCombatActionPack(cap);
            }

            Send.EffectDelayed(Effect.AwakeningOfLight1, 800, creature);
            Send.EffectDelayed(Effect.AwakeningOfLight2, 800, creature);
            Send.UseMotion(creature, 67, 3, false, false);

            creature.StatRegens.Add(creature.Temp.DemiHpRegen = new MabiStatRegen(Stat.Life, skill.RankInfo.Var3, creature.LifeMax));
            creature.StatRegens.Add(creature.Temp.DemiMpRegen = new MabiStatRegen(Stat.Mana, skill.RankInfo.Var4, creature.ManaMax));
            creature.StatRegens.Add(creature.Temp.DemiStmRegen = new MabiStatRegen(Stat.Stamina, skill.RankInfo.Var5, creature.StaminaMax));
            WorldManager.Instance.CreatureStatsUpdate(creature);

            return SkillResults.Okay;
        }
示例#30
0
        public override SkillResults Complete(MabiCreature creature, MabiSkill skill, MabiPacket packet)
        {
            if (creature.Temp.SkillItem1 == null || creature.Temp.SkillItem2 == null)
                return SkillResults.Failure;

            var part = packet.GetInt();

            if (packet.GetElementType() == ElementType.Short)
                return this.CompleteRegular(creature, packet, skill.Id, part);
            else if (packet.GetElementType() == ElementType.Byte)
                return this.CompleteFixed(creature, packet, skill.Id, part);

            return SkillResults.Failure;
        }