/// <summary> /// Sends EnterDynamicRegion to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="warpFromRegionId"></param> /// <param name="warpToRegion"></param> public static void EnterDynamicRegion(Creature creature, int warpFromRegionId, Region warpToRegion, int x, int y) { var warpTo = warpToRegion as DynamicRegion; if (warpTo == null) throw new ArgumentException("EnterDynamicRegion requires a dynamic region."); var pos = creature.GetPosition(); var packet = new Packet(Op.EnterDynamicRegion, MabiId.Broadcast); packet.PutLong(creature.EntityId); packet.PutInt(warpFromRegionId); // creature's current region or 0? packet.PutInt(warpToRegion.Id); packet.PutString(warpToRegion.Name); // dynamic region name packet.PutUInt(0x80000000); // bitmask? (|1 = time difference?) packet.PutInt(warpTo.BaseId); packet.PutString(warpTo.BaseName); packet.PutInt(200); // 100|200 (100 changes the lighting?) packet.PutByte(0); // 1 = next is empty? packet.PutString("data/world/{0}/{1}", warpTo.BaseName, warpTo.Variation); packet.PutByte(0); //if (^ true) //{ // pp.PutByte(1); // pp.PutInt(3100); // some region id? //} packet.PutInt(x); // target x pos packet.PutInt(y); // target y pos creature.Client.Send(packet); }
/// <summary> /// Sends Weather. /// </summary> private static void Weather(Action<Packet> sender, IWeatherProvider provider) { var packet = new Packet(Op.Weather, MabiId.Broadcast); packet.PutByte(0); packet.PutInt(provider.RegionId); if (provider is IWeatherProviderTable) { var table = (IWeatherProviderTable)provider; packet.PutByte(0); packet.PutInt(table.GroupId); packet.PutByte(2); packet.PutByte(1); packet.PutString("table"); packet.PutString(table.Name); packet.PutLong(0); packet.PutByte(0); } else if (provider is IWeatherProviderConstant) { var constant = (IWeatherProviderConstant)provider; // Packet structure is guessed, even though it works, // based on constant_smooth. packet.PutByte(2); packet.PutByte(0); packet.PutByte(1); packet.PutString("constant"); packet.PutFloat(constant.Weather); packet.PutLong(0); packet.PutByte(0); } else if (provider is IWeatherProviderConstantSmooth) { var constantSmooth = (IWeatherProviderConstantSmooth)provider; packet.PutByte(2); packet.PutByte(0); packet.PutByte(1); packet.PutString("constant_smooth"); packet.PutFloat(constantSmooth.Weather); packet.PutLong(DateTime.Now); // Start packet.PutLong(DateTime.MinValue); // End packet.PutFloat(constantSmooth.WeatherBefore); packet.PutFloat(constantSmooth.WeatherBefore); packet.PutLong(constantSmooth.TransitionTime); packet.PutByte(false); // bool? Is table appended? byte? Appended type? packet.PutLong(DateTime.MinValue); // End packet.PutInt(2); // Append a table packet here to go back to that after end packet.PutByte(0); } sender(packet); }
/// <summary> /// Sends GuildInfoNoGuild to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="guild"></param> public static void GuildInfoNoGuild(Creature creature, Guild guild) { var packet = new Packet(Op.GuildInfoNoGuild, creature.EntityId); packet.PutLong(guild.Id); packet.PutString(guild.Name); packet.PutString(guild.LeaderName); packet.PutInt(guild.MemberCount); packet.PutString(guild.IntroMessage); creature.Client.Send(packet); }
/// <summary> /// Broadcasts new prop extension. /// </summary> /// <param name="prop"></param> /// <param name="ext"></param> public static void AddPropExtension(Prop prop, PropExtension ext) { var packet = new Packet(Op.AddPropExtension, prop.EntityId); packet.PutInt((int)ext.SignalType); packet.PutInt((int)ext.EventType); packet.PutString(ext.Name); packet.PutByte(ext.Mode); packet.PutString(ext.Value.ToString()); prop.Region.Broadcast(packet); }
/// <summary> /// Sends BankAddItem to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="item"></param> /// <param name="bankId"></param> /// <param name="tabName"></param> public static void BankAddItem(Creature creature, Item item, string bankId, string tabName) { var packet = new Packet(Op.BankAddItem, creature.EntityId); packet.PutString(tabName); packet.PutString(bankId); packet.PutLong(0); packet.PutLong(0); packet.AddItemInfo(item, ItemPacketType.Private); creature.Client.Send(packet); }
/// <summary> /// Sends GuildInfoApplied to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="guild"></param> public static void GuildInfoApplied(Creature creature, Guild guild) { // The fields of this packet were guessed, something might be missing. var packet = new Packet(Op.GuildInfoApplied, creature.EntityId); packet.PutLong(guild.Id); packet.PutString(guild.Server); packet.PutLong(creature.EntityId); packet.PutString(guild.Name); creature.Client.Send(packet); }
public static void System_Broadcast(string from, string format, params object[] args) { var packet = new Packet(Op.Chat, MabiId.Broadcast); packet.PutByte(0); packet.PutString("<{0}>", from); packet.PutString(format, args); packet.PutByte(true); packet.PutUInt(0xFFFF8080); packet.PutInt(0); packet.PutByte(0); ChannelServer.Instance.World.Broadcast(packet); }
/// <summary> /// Sends system message (special Chat) to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="from"></param> /// <param name="format"></param> /// <param name="args"></param> private static void SystemMessage(Creature creature, string from, string format, params object[] args) { var packet = new Packet(Op.Chat, creature.EntityId); packet.PutByte(0); packet.PutString(from); packet.PutString(format, args); packet.PutByte(true); packet.PutUInt(0xFFFF8080); packet.PutInt(0); packet.PutByte(0); creature.Client.Send(packet); }
/// <summary> /// Sends GmcpNpcListR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="success"></param> public static void GmcpNpcListR(Creature creature, ICollection<Creature> npcs) { var packet = new Packet(Op.GmcpNpcListR, creature.EntityId); packet.PutInt(npcs.Count); foreach (var npc in npcs) { packet.PutInt(npc.Race); // RaceId packet.PutString(npc.Name); // Name packet.PutString(npc.Name); // Local Name packet.PutString(npc.RegionId.ToString()); // Location } creature.Client.Send(packet); }
/// <summary> /// Sends Internal.Broadcast to login server. /// </summary> public static void Internal_Broadcast(string message) { var packet = new Packet(Op.Internal.BroadcastNotice, 0); packet.PutString(message); ChannelServer.Instance.LoginServer.Send(packet); }
/// <summary> /// Sends GmcpNpcListR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="npcs"></param> public static void GmcpNpcListR(Creature creature, ICollection<Creature> npcs) { var packet = new Packet(Op.GmcpNpcListR, creature.EntityId); packet.PutInt(npcs.Count); foreach (var npc in npcs) { var pos = npc.GetPosition(); packet.PutInt(npc.RegionId); packet.PutString(npc.Name); // Name packet.PutString(npc.Name); // Local Name packet.PutString("{0} @ {1}/{2}", npc.RegionId, pos.X, pos.Y); // Location } creature.Client.Send(packet); }
/// <summary> /// Sends Internal.ServerIdentify to login server. /// </summary> public static void Internal_ServerIdentify() { var packet = new Packet(Op.Internal.ServerIdentify, 0); packet.PutString(Password.Hash(ChannelServer.Instance.Conf.Internal.Password)); ChannelServer.Instance.LoginServer.Send(packet); }
/// <summary> /// Sends Internal.ChannelStatus to login server. /// </summary> public static void Internal_ChannelStatus() { var cur = 0;// ChannelServer.Instance.World.GetCharactersCount(); var max = ChannelServer.Instance.Conf.Channel.MaxUsers; var packet = new Packet(Op.Internal.ChannelStatus, 0); packet.PutString(ChannelServer.Instance.Conf.Channel.ChannelServer); packet.PutString(ChannelServer.Instance.Conf.Channel.ChannelName); packet.PutString(ChannelServer.Instance.Conf.Channel.ChannelHost); packet.PutInt(ChannelServer.Instance.Conf.Channel.ChannelPort); packet.PutInt(cur); packet.PutInt(max); packet.PutInt((int)ChannelState.Normal); ChannelServer.Instance.LoginServer.Send(packet); }
/// <summary> /// Sends AcquireInfo to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="itemId"></param> /// <param name="amount"></param> public static void AcquireItemInfo(Creature creature, int itemId, int amount) { var packet = new Packet(Op.AcquireInfo, creature.EntityId); packet.PutString("<xml type='item' classid='{0}' value='{1}'/>", itemId, amount); packet.PutInt(3000); creature.Client.Send(packet); }
/// <summary> /// Sends Chat in range of creature. /// </summary> /// <param name="creature">Source, in terms of name and position</param> /// <param name="format"></param> /// <param name="args"></param> public static void Chat(Creature creature, string format, params object[] args) { var packet = new Packet(Op.Chat, creature.EntityId); packet.PutByte(0); // speech (0) vs thought (1) bubble packet.PutString(creature.Name); packet.PutString(format, args); // The following part is not required for normal chat packet.PutByte(0); // 1 hides chat bubble and enables --v packet.PutUInt(0); // custom color (supports alpha transparency, FF is 100% opaque) packet.PutInt(0); packet.PutByte(0); creature.Region.Broadcast(packet, creature); }
/// <summary> /// Sends AcquireInfo2 to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="itemEntityId"></param> public static void AcquireFixedDyedItemInfo(Creature creature, long itemEntityId) { var packet = new Packet(Op.AcquireInfo2, creature.EntityId); packet.PutString("<xml type='fixed_color_dyeing' objectid='{0}'/>", itemEntityId); packet.PutInt(3000); creature.Client.Send(packet); }
/// <summary> /// Sends GetPetAiR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="ai">Negative answer if null</param> public static void GetPetAiR(Creature creature, string ai) { var packet = new Packet(Op.GetPetAiR, creature.EntityId); packet.PutByte(ai != null); packet.PutString(ai); creature.Client.Send(packet); }
/// <summary> /// Sends NpcTalk to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="xml"></param> public static void NpcTalk(Creature creature, string xml) { var packet = new Packet(Op.NpcTalk, creature.EntityId); packet.PutString(xml); packet.PutBin(); creature.Client.Send(packet); }
/// <summary> /// Sends AcquireInfo2 to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="itemEntityId"></param> /// <param name="selected"></param> public static void AcquireDyedItemInfo(Creature creature, long itemEntityId, byte selected) { var packet = new Packet(Op.AcquireInfo2, creature.EntityId); packet.PutString("<xml type='dyeing' objectid='{0}' selected='{1}'/>", itemEntityId, selected); packet.PutInt(3000); creature.Client.Send(packet); }
/// <summary> /// Sends EntrustmentR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="success"></param> /// <param name="partner"></param> public static void EntrustmentR(Creature creature, bool success, Creature partner) { var packet = new Packet(Op.EntrustmentR, creature.EntityId); packet.PutByte(success); packet.PutLong(partner.EntityId); packet.PutString(partner.Name); creature.Client.Send(packet); }
/// <summary> /// Sends BankRemoveItem to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="tabName"></param> /// <param name="itemEntityId"></param> public static void BankRemoveItem(Creature creature, string tabName, long itemEntityId) { var packet = new Packet(Op.BankRemoveItem, creature.EntityId); packet.PutString(tabName); packet.PutLong(itemEntityId); creature.Client.Send(packet); }
/// <summary> /// Sends NpcTalkEndR to creature's client. /// </summary> /// <remarks> /// If no message is specified "<end/>" is sent, /// to close the dialog box immediately. /// </remarks> /// <param name="creature"></param> /// <param name="npcId"></param> /// <param name="message">Last message before closing.</param> public static void NpcTalkEndR(Creature creature, long npcId, string message = null) { var p = new Packet(Op.NpcTalkEndR, creature.EntityId); p.PutByte(true); p.PutLong(npcId); p.PutString(message ?? "<end/>"); creature.Client.Send(p); }
/// <summary> /// Sends message as response to login (LoginR). /// </summary> /// <param name="client"></param> /// <param name="format"></param> /// <param name="args"></param> public static void LoginR_Msg(LoginClient client, string format, params object[] args) { var packet = new Packet(Op.LoginR, MabiId.Login); packet.PutByte((byte)LoginResult.Message); packet.PutInt((int)LoginResultMessage.Custom); packet.PutInt(1); packet.PutString(format, args); client.Send(packet); }
public static void System_Broadcast(string from, string format, params object[] args) { var packet = new Packet(Op.Chat, MabiId.Broadcast); foreach (var msg in string.Format(format, args).Chunkify(100)) // Mabi displays up to 100 chars { packet.PutByte(0); packet.PutString("<{0}>", from); packet.PutString(msg); packet.PutByte(true); packet.PutUInt(0xFFFF8080); packet.PutInt(0); packet.PutByte(0); ChannelServer.Instance.World.Broadcast(packet); packet.Clear(packet.Op, packet.Id); } }
/// <summary> /// Sends ChannelInfoRequestR to client. /// </summary> /// <param name="client"></param> /// <param name="info">Negative response if null.</param> /// <param name="characterId"></param> public static void ChannelInfoRequestR(LoginClient client, ChannelInfo info, long characterId) { var packet = new Packet(Op.ChannelInfoRequestR, MabiId.Channel); packet.PutByte(info != null); if (info != null) { packet.PutString(info.ServerName); packet.PutString(info.Name); packet.PutShort(6); // Channel "Id"? (seems to be equal to channel nr) packet.PutString(info.Host); packet.PutString(info.Host); packet.PutShort((short)info.Port); packet.PutShort((short)(info.Port + 2)); packet.PutInt(1); packet.PutLong(characterId); } client.Send(packet); }
/// <summary> /// Sends ChannelLoginR to client. /// </summary> /// <remarks> /// Sending a negative response doesn't do anything. /// </remarks> public static void ChannelLoginR(ChannelClient client, long creatureId) { var packet = new Packet(Op.ChannelLoginR, MabiId.Channel); packet.PutByte(true); packet.PutLong(creatureId); packet.PutLong(DateTime.Now); packet.PutInt((int)DateTime.Now.DayOfWeek); packet.PutString(""); // http://211.218.233.238/korea/ client.Send(packet); }
/// <summary> /// Sends positive response to login. /// </summary> /// <param name="client"></param> /// <param name="account"></param> /// <param name="sessionKey"></param> /// <param name="serverList"></param> public static void LoginR(LoginClient client, Account account, long sessionKey, ICollection<ServerInfo> serverList) { var packet = new Packet(Op.LoginR, MabiId.Login); packet.PutByte((byte)LoginResult.Success); packet.PutString(account.Name); // [160XXX] Double account name { packet.PutString(account.Name); } packet.PutLong(sessionKey); packet.PutByte(0); // Servers // -------------------------------------------------------------- packet.AddServerList(serverList, ServerInfoType.Client); // Account Info // -------------------------------------------------------------- packet.Add(account); client.Send(packet); }
/// <summary> /// Sends system message (special Chat) to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="from"></param> /// <param name="format"></param> /// <param name="args"></param> private static void SystemMessage(Creature creature, string from, string format, params object[] args) { var packet = new Packet(Op.Chat, creature.EntityId); foreach (var msg in string.Format(format, args).Chunkify(100)) // Mabi displays up to 100 chars { packet.PutByte(0); packet.PutString(from); packet.PutString(msg); packet.PutByte(true); packet.PutUInt(0xFFFF8080); packet.PutInt(0); packet.PutByte(0); creature.Client.Send(packet); packet.Clear(packet.Op, packet.Id); } }
/// <summary> /// Broadcasts Effect in range of creature. /// </summary> /// <remarks> /// Parameters have to be casted to the proper type, use carefully! /// </remarks> /// <param name="creature"></param> /// <param name="parameters"></param> public static void Effect(Creature creature, int effectId, params object[] parameters) { var packet = new Packet(Op.Effect, creature.EntityId); packet.PutInt(effectId); foreach (var p in parameters) { if (p is byte) packet.PutByte((byte)p); else if (p is bool) packet.PutByte((bool)p); else if (p is short) packet.PutShort((short)p); else if (p is int) packet.PutInt((int)p); else if (p is long) packet.PutLong((long)p); else if (p is float) packet.PutFloat((float)p); else if (p is string) packet.PutString((string)p); else throw new Exception("Unsupported effect parameter: " + p.GetType()); } creature.Region.Broadcast(packet, creature); }
/// <summary> /// Broadcasts Effect in range of creature. /// </summary> /// <param name="creature"></param> /// <param name="instrument"></param> /// <param name="quality"></param> /// <param name="compressedMML"></param> /// <param name="rndScore"></param> public static void PlayEffect(Creature creature, InstrumentType instrument, PlayingQuality quality, string compressedMML, int rndScore) { var packet = new Packet(Op.Effect, creature.EntityId); packet.PutInt(E.PlayMusic); packet.PutByte(compressedMML != null); // has scroll if (compressedMML != null) packet.PutString(compressedMML); else packet.PutInt(rndScore); packet.PutInt(0); packet.PutShort(0); packet.PutInt(14113); // ? packet.PutByte((byte)quality); packet.PutByte((byte)instrument); packet.PutByte(0); packet.PutByte(0); packet.PutByte(1); // loops // Singing? //packet.PutByte(0); //packet.PutByte(1); creature.Region.Broadcast(packet, creature); }