Example #1
0
        public static void ChangesStance(MabiCreature creature, byte unk = 1)
        {
            var packet = new MabiPacket(Op.ChangesStance, creature.Id);
            packet.PutByte(creature.BattleState);
            packet.PutByte(unk);

            WorldManager.Instance.Broadcast(packet, SendTargets.Range, creature);
        }
Example #2
0
        public static void ChangeTitleResponse(Client client, MabiCreature creature, bool titleSuccess, bool optionTitleSuccess)
        {
            var packet = new MabiPacket(Op.ChangeTitleR, creature.Id);
            packet.PutByte(titleSuccess);
            packet.PutByte(optionTitleSuccess);

            client.Send(packet);
        }
Example #3
0
        public static void RecallMailResponse(WorldClient client, bool success, ulong mailId)
        {
            var packet = new MabiPacket(Op.RecallMailR, client.Character.Id);
            packet.PutByte(success);
            if (success)
            {
                packet.PutByte(success);
                packet.PutLong(mailId);
            }

            client.Send(packet);
        }
Example #4
0
        /// <summary>
        /// Sends character info (5209). Response is negative if character is null.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="character"></param>
        public static void CharacterInfo(Client client, MabiPC character)
        {
            var packet = new MabiPacket(Op.WorldCharInfoRequestR, Id.World);
            if (character != null)
            {
                packet.PutByte(true);
                packet.AddCreatureInfo(character, CreaturePacketType.Private);
            }
            else
            {
                packet.PutByte(false);
            }

            client.Send(packet);
        }
Example #5
0
        /// <summary>
        /// Sends ConvertGpConfirmR to creature's client.
        /// </summary>
        public static void ConvertGpConfirmR(MabiCreature creature, bool success)
        {
            var packet = new MabiPacket(Op.ConvertGpConfirmR, creature.Id);
            packet.PutByte(success);

            creature.Client.Send(packet);
        }
Example #6
0
        /// <summary>
        /// Sends GuildDonateR to creature's client.
        /// </summary>
        public static void GuildDonateR(MabiCreature creature, bool success)
        {
            var packet = new MabiPacket(Op.GuildDonateR, creature.Id);
            packet.PutByte(success);

            creature.Client.Send(packet);
        }
Example #7
0
        /// <summary>
        /// Sends disconnect info response.
        /// </summary>
        /// <param name="client"></param>
        public static void DisconnectResponse(Client client)
        {
            var packet = new MabiPacket(Op.WorldDisconnectR, Id.World);
            packet.PutByte(0);

            client.Send(packet);
        }
Example #8
0
 public virtual void Close(WorldClient client, string message = "<end/>")
 {
     var p = new MabiPacket(Op.NPCTalkEndR, client.Character.Id);
     p.PutByte(1);
     p.PutLong(client.NPCSession.Target.Id);
     p.PutString(message);
     client.Send(p);
 }
Example #9
0
        /// <summary>
        /// Sends ConvertGpR to creature's client.
        /// </summary>
        public static void ConvertGpR(MabiCreature creature, bool success, uint amount)
        {
            var packet = new MabiPacket(Op.ConvertGpR, creature.Id);
            packet.PutByte(success);
            packet.PutInt(amount);

            creature.Client.Send(packet);
        }
Example #10
0
        public static void NPCTalkStartResponse(WorldClient client, bool success, ulong npcId)
        {
            var packet = new MabiPacket(Op.NPCTalkStartR, client.Character.Id);
            packet.PutByte(success);
            if (success)
                packet.PutLong(npcId);

            client.Send(packet);
        }
Example #11
0
        public static void NPCTalkKeywordResponse(WorldClient client, bool success, string keyword)
        {
            var packet = new MabiPacket(Op.NPCTalkKeywordR, client.Character.Id);
            packet.PutByte(success);
            if (success)
                packet.PutString(keyword);

            client.Send(packet);
        }
Example #12
0
        public static void Chat(MabiCreature creature, byte type, string format, params object[] args)
        {
            var packet = new MabiPacket(Op.Chat, creature.Id);
            packet.PutByte(type);
            packet.PutString(creature.Name);
            packet.PutString(format, args);

            WorldManager.Instance.Broadcast(packet, SendTargets.Range, creature);
        }
Example #13
0
        /// <summary>
        /// Sends ItemAmount to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="item"></param>
        public static void ItemAmount(MabiCreature creature, MabiItem item)
        {
            var packet = new MabiPacket(Op.ItemAmount, creature.Id);
            packet.PutLong(item.Id);
            packet.PutShort(item.Info.Amount);
            packet.PutByte(2); // ? (related to the 2 in move item?)

            creature.Client.Send(packet);
        }
Example #14
0
        /// <summary>
        /// Sends DyePickColorR to creature's client.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="success"></param>
        public static void DyePickColorR(MabiCreature creature, bool success)
        {
            var packet = new MabiPacket(Op.DyePickColorR, creature.Id);
            packet.PutByte(success);
            if (success)
                packet.PutBin(creature.Temp.DyeCursors);

            creature.Client.Send(packet);
        }
Example #15
0
        public static void ConfirmMailRecipentResponse(WorldClient client, bool success, ulong recipientId)
        {
            var packet = new MabiPacket(Op.ConfirmMailRecipentR, client.Character.Id);
            packet.PutByte(success);
            if (success)
                packet.PutLong(recipientId);

            client.Send(packet);
        }
Example #16
0
        public static void GuildstoneLocation(Client client, MabiCreature creature)
        {
            var packet = new MabiPacket(Op.GuildstoneLocation, creature.Id);
            packet.PutByte(1);
            packet.PutInts(creature.Guild.Region);
            packet.PutInts(creature.Guild.X);
            packet.PutInts(creature.Guild.Y);

            client.Send(packet);
        }
Example #17
0
        /// <summary>
        /// Sends response to accept gift. Response will be negative if gift is null.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="gift"></param>
        public static void AcceptGiftResponse(LoginClient client, Gift gift)
        {
            var packet = new MabiPacket(Op.AcceptGiftR, Id.Login);
            if (gift != null)
            {
                packet.PutByte(true);
                packet.PutByte(gift.IsCharacter);
                packet.PutInt(0); // ?
                packet.PutInt(0); // ?
                packet.PutInt(gift.Type);
                // ?
            }
            else
            {
                packet.PutByte(false);
            }

            client.Send(packet);
        }
Example #18
0
        /// <summary>
        /// Sends positive login response.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="creature"></param>
        public static void LoginResponse(Client client, MabiCreature creature)
        {
            var packet = new MabiPacket(Op.WorldLoginR, Id.World);
            packet.PutByte(true);
            packet.PutLong(creature.Id);
            packet.PutLong(MabiTime.Now.DateTime);
            packet.PutInt(1);
            packet.PutString("");

            client.Send(packet);
        }
Example #19
0
        public static void OpenNPCShop(WorldClient client, MabiShop shop)
        {
            var packet = new MabiPacket(Op.OpenNPCShop, client.Character.Id);
            packet.PutString("shopname");
            packet.PutByte(0);
            packet.PutByte(0);
            packet.PutInt(0);
            packet.PutByte((byte)shop.Tabs.Count);
            for (var i = 0; i < shop.Tabs.Count; ++i)
            {
                packet.PutString("[{0}]{1}", i, shop.Tabs[i].Name);

                // [160200] ?
                {
                    packet.PutByte(0);
                }

                packet.PutShort((ushort)shop.Tabs[i].Items.Count);
                foreach (var item in shop.Tabs[i].Items)
                    packet.AddItemInfo(item, ItemPacketType.Private);
            }
            client.Send(packet);
        }
Example #20
0
        /// <summary>
        /// Broadcasts Effect packet in range. Parameters can be added,
        /// but you have to watch the types.
        /// </summary>
        public static void Effect(uint effect, MabiEntity source, params object[] args)
        {
            var packet = new MabiPacket(Op.Effect, source.Id);
            packet.PutInt(effect);
            foreach (var arg in args)
            {
                if (!(arg is bool))
                    packet.Put(arg);
                else
                    packet.PutByte((bool)arg);
            }

            WorldManager.Instance.Broadcast(packet, SendTargets.Range, source);
        }
Example #21
0
        public static void NPCTalkPartnerStartResponse(WorldClient client, bool success, ulong id, string partnerName)
        {
            var packet = new MabiPacket(Op.NPCTalkPartnerR, client.Character.Id);
            packet.PutByte(success);
            if (success)
            {
                packet.PutLong(id);
                packet.PutString(client.Character.Name + "'s " + partnerName);
                packet.PutString(client.Character.Name + "'s " + partnerName);
                client.Send(packet);
            }

            client.Send(packet);
        }
Example #22
0
    public override void Start()
    {
        stop = false;

        Thread t = null;

        t = new Thread(() =>
        {
            for (int i = 15; i < 2000; ++i)             // 2521
            {
                if (stop)
                {
                    i = 2175;
                }
                if (i > 2175)
                {
                    break;
                }

                var url       = string.Format("http://localhost/aura/visualchat/img/chat_20131005_00{0}_Zerono.png", i.ToString().PadLeft(4, '0'));
                ushort width  = 170;
                ushort height = 96;

                var p = new MabiPacket(Op.VisualChat, NPC.Id);
                p.PutString(NPC.Name);
                p.PutString(url);
                p.PutShorts(width, height);
                p.PutByte(0);
                WorldManager.Instance.Broadcast(p, SendTargets.Range, NPC);

                Thread.Sleep(100);

                // skip 1, 5fps
                Thread.Sleep(100);
                i++;
            }

            GC.KeepAlive(t);
        });
        t.Start();
    }
Example #23
0
        /// <summary>
        /// Broadcasts Phoenix Feather above dead creature effect in creature's range.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="creature"></param>
        public static void DeadFeather(MabiCreature creature, DeadMenuOptions options)
        {
            var bits = (uint)options;
            var flags = new List<uint>();

            // Break down options bit by bit, and add them to flags if set.
            for (uint i = 1; bits != 0; ++i, bits >>= 1)
            {
                if ((bits & 1) != 0)
                    flags.Add(i);
            }

            var packet = new MabiPacket(Op.DeadFeather, creature.Id);

            packet.PutShort((ushort)flags.Count);
            foreach (var f in flags)
                packet.PutInt(f);

            packet.PutByte(0);

            WorldManager.Instance.Broadcast(packet, SendTargets.Range, creature);
        }
Example #24
0
        private CommandResult Command_effect(WorldClient client, MabiCreature creature, string[] args, string msg)
        {
            if (args.Length < 2)
                return CommandResult.WrongParameter;

            var p = new MabiPacket(Op.Effect, creature.Id);

            uint id;
            if (!uint.TryParse(args[1], out id))
                return CommandResult.WrongParameter;

            p.PutInt(id);

            for (int i = 2; i < args.Length; ++i)
            {
                var splitted = args[i].Split(':');

                if (splitted[0] == "me")
                {
                    p.PutLong(creature.Id);
                    continue;
                }

                if (splitted.Length < 2)
                    continue;

                splitted[0] = splitted[0].Trim();
                splitted[1] = splitted[1].Trim();

                switch (splitted[0])
                {
                    case "b":
                        {
                            byte val;
                            if (!byte.TryParse(splitted[1], out val))
                                return CommandResult.WrongParameter;
                            p.PutByte(val);
                            break;
                        }
                    case "i":
                        {
                            uint val;
                            if (!uint.TryParse(splitted[1], out val))
                                return CommandResult.WrongParameter;
                            p.PutInt(val);
                            break;
                        }
                    case "s":
                        {
                            p.PutString(splitted[1]);
                            break;
                        }
                }
            }

            WorldManager.Instance.Broadcast(p, SendTargets.Range, creature);

            return CommandResult.Okay;
        }
Example #25
0
 /// <summary>
 /// Sends info on guild membership status changed. Pass null for guild to remove.
 /// </summary>
 /// <param name="guild"></param>
 /// <param name="creature"></param>
 /// <returns></returns>
 public static MabiPacket GuildMembershipChanged(MabiGuild guild, MabiCreature creature, GuildMemberRank rank = GuildMemberRank.Member)
 {
     var p = new MabiPacket(Op.GuildMembershipChanged, creature.Id);
     if (guild == null)
     {
         p.PutInt(0);
     }
     else
     {
         p.PutInt(1);
         p.PutString(guild.Name);
         p.PutLong(guild.Id);
         p.PutInt((uint)rank); // (5) Member Rank?
         p.PutByte(0);
     }
     return p;
 }
Example #26
0
        public static MabiPacket StatUpdate(MabiCreature creature, StatUpdateType type, params Stat[] stats)
        {
            var packet = new MabiPacket((type & StatUpdateType.Public) != 0 ? Op.StatUpdatePublic : Op.StatUpdatePrivate, creature.Id);

            packet.PutByte((byte)type);

            // Stats
            packet.PutSInt(stats.Length);
            foreach (var stat in stats)
            {
                packet.PutInt((uint)stat);
                switch (stat)
                {
                    case Stat.Height: packet.PutFloat(creature.Height); break;
                    case Stat.Weight: packet.PutFloat(creature.Weight); break;
                    case Stat.Upper: packet.PutFloat(creature.Upper); break;
                    case Stat.Lower: packet.PutFloat(creature.Lower); break;

                    case Stat.CombatPower: packet.PutFloat(creature.CombatPower); break;
                    case Stat.Level: packet.PutShort(creature.Level); break;
                    case Stat.AbilityPoints: packet.PutShort(creature.AbilityPoints); break;
                    case Stat.Experience: packet.PutLong(MabiData.ExpDb.CalculateRemaining(creature.Level, creature.Experience) * 1000); break;

                    case Stat.Life: packet.PutFloat(creature.Life); break;
                    case Stat.LifeMax: packet.PutFloat(creature.LifeMaxBaseTotal); break;
                    case Stat.LifeMaxMod: packet.PutFloat(creature.StatMods.GetMod(Stat.LifeMaxMod)); break;
                    case Stat.LifeInjured: packet.PutFloat(creature.LifeInjured); break;
                    case Stat.Mana: packet.PutFloat(creature.Mana); break;
                    case Stat.ManaMax: packet.PutFloat(creature.ManaMaxBaseTotal); break;
                    case Stat.ManaMaxMod: packet.PutFloat(creature.StatMods.GetMod(Stat.ManaMaxMod)); break;
                    case Stat.Stamina: packet.PutFloat(creature.Stamina); break;
                    case Stat.Food: packet.PutFloat(creature.StaminaHunger); break;
                    case Stat.StaminaMax: packet.PutFloat(creature.StaminaMaxBaseTotal); break;
                    case Stat.StaminaMaxMod: packet.PutFloat(creature.StatMods.GetMod(Stat.StaminaMaxMod)); break;

                    case Stat.StrMod: packet.PutFloat(creature.StatMods.GetMod(Stat.StrMod)); break;
                    case Stat.DexMod: packet.PutFloat(creature.StatMods.GetMod(Stat.DexMod)); break;
                    case Stat.IntMod: packet.PutFloat(creature.StatMods.GetMod(Stat.IntMod)); break;
                    case Stat.LuckMod: packet.PutFloat(creature.StatMods.GetMod(Stat.LuckMod)); break;
                    case Stat.WillMod: packet.PutFloat(creature.StatMods.GetMod(Stat.WillMod)); break;
                    case Stat.Str: packet.PutFloat(creature.StrBaseTotal); break;
                    case Stat.Int: packet.PutFloat(creature.IntBaseTotal); break;
                    case Stat.Dex: packet.PutFloat(creature.DexBaseTotal); break;
                    case Stat.Will: packet.PutFloat(creature.WillBaseTotal); break;
                    case Stat.Luck: packet.PutFloat(creature.LuckBaseTotal); break;

                    case Stat.DefenseBaseMod: packet.PutShort((ushort)creature.DefensePassive); break;
                    case Stat.ProtectBaseMod: packet.PutFloat(creature.ProtectionPassive * 100); break;

                    case Stat.DefenseMod: packet.PutShort((ushort)creature.StatMods.GetMod(Stat.DefenseMod)); break;
                    case Stat.ProtectMod: packet.PutFloat(creature.StatMods.GetMod(Stat.ProtectMod)); break;

                    // Client might crash with a mismatching value,
                    // take a chance and put an int by default.
                    default: packet.PutInt(1); break;
                }
            }

            // (New?) Stat regens
            packet.PutSInt(creature.StatRegens.Count);
            foreach (var mod in creature.StatRegens)
                mod.AddToPacket(packet);

            // Stat mod ids to remove?
            packet.PutInt(0);

            packet.PutInt(0);					 // ?

            if (type == StatUpdateType.Public)
            {
                packet.PutInt(0);  				 // ?

                // Stat mod ids to remove?
                packet.PutInt(0);

                packet.PutInt(0);				 // ?
            }

            return packet;
        }
Example #27
0
        // tmp
        public static MabiPacket StatRegenStop(MabiCreature creature, StatUpdateType type, params MabiStatRegen[] stats)
        {
            var packet = new MabiPacket((type & StatUpdateType.Public) != 0 ? Op.StatUpdatePublic : Op.StatUpdatePrivate, creature.Id);

            packet.PutByte((byte)type);
            packet.PutSInt(0); // Stats
            packet.PutInt(0); // Regens

            // Stat mod ids to remove
            packet.PutSInt(stats.Count());
            foreach (var mod in stats)
                packet.PutInt(mod.ModId);

            packet.PutInt(0);

            if (type == StatUpdateType.Public)
            {
                packet.PutInt(0);

                // Stat mod ids to remove
                packet.PutSInt(stats.Count());
                foreach (var mod in stats)
                    packet.PutInt(mod.ModId);

                packet.PutInt(0);
            }

            return packet;
        }
Example #28
0
 /// <summary>
 /// Playing instrument effect (sound and motion) for creature,
 /// based on the given score id (client:score.xml).
 /// </summary>
 /// <param name="creature"></param>
 /// <param name="instrument"></param>
 /// <param name="quality"></param>
 /// <param name="score"></param>
 /// <returns></returns>
 public static MabiPacket PlayEffect(MabiCreature creature, InstrumentType instrument, PlayingQuality quality, uint score)
 {
     var p = new MabiPacket(Op.Effect, creature.Id);
     p.PutInt(Effect.PlayMusic);
     p.PutByte(false);
     p.PutInt(score);
     p.PutInt(0);
     p.PutShort(0);
     p.PutInt(14113);
     p.PutByte((byte)quality);
     p.PutByte((byte)instrument);
     p.PutByte(0);
     p.PutByte(0);
     p.PutByte(1);
     return p;
 }
Example #29
0
 /// <summary>
 /// Playing instrument effect (sound and motion) for creature,
 /// based on the given MML code.
 /// </summary>
 /// <param name="creature"></param>
 /// <param name="instrument"></param>
 /// <param name="quality"></param>
 /// <param name="compressedMML"></param>
 /// <returns></returns>
 public static MabiPacket PlayEffect(MabiCreature creature, InstrumentType instrument, PlayingQuality quality, string compressedMML)
 {
     var p = new MabiPacket(Op.Effect, creature.Id);
     p.PutInt(Effect.PlayMusic);
     p.PutByte(true); // has scroll
     p.PutString(compressedMML);
     p.PutInt(0);
     p.PutShort(0);
     p.PutInt(14113); // ?
     p.PutByte((byte)quality);
     p.PutByte((byte)instrument);
     p.PutByte(0);
     p.PutByte(0);
     p.PutByte(1); // loops
     return p;
 }
 private MabiPacket GetPacket(MabiCreature creature, MabiSkill skill, bool transforming)
 {
     // TODO: Add actual transform level from rank info.
     // intVal1 = look, intVal2 = titleId
     var p = new MabiPacket(0xA41C, creature.Id);
     p.PutByte((byte)(transforming ? this.TransformId : (byte)0));
     p.PutShort((ushort)(transforming ? 15 : 0));
     p.PutShort((ushort)(transforming ? ((skill.Info.Rank + 1) / 4) : 0));
     p.PutByte(1);
     return p;
 }
Example #31
0
        /// <summary>
        /// Sends view equipment to client. Response is negative if items is null.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="targetId"></param>
        /// <param name="items"></param>
        public static void ViewEquipmentResponse(WorldClient client, ulong targetId, IEnumerable<MabiItem> items)
        {
            var packet = new MabiPacket(Op.ViewEquipmentR, client.Character.Id);
            if (items != null)
            {
                packet.PutByte(true);
                packet.PutLong(targetId);
                packet.PutInt((ushort)items.Count());
                foreach (var item in items)
                    packet.AddItemInfo(item, ItemPacketType.Private);
            }
            else
            {
                packet.PutByte(false);
            }

            client.Send(packet);
        }