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); }
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); }
public static MabiPacket AcquireStat(MabiCreature creature, string statName, double amount) { var p = new MabiPacket(Op.AcquireInfo, creature.Id); p.PutString("<xml type='{0}' value='{1}' simple='true' onlyLog='false' />", statName, (uint)amount); p.PutInt(3000); return p; }
/// <summary> /// Plays sound in range of source. /// </summary> /// <param name="file">e.g. "data/sound/Glasgavelen_blowaway_endure.wav"</param> public static void PlaySound(string file, MabiEntity source) { var packet = new MabiPacket(Op.PlaySound, source.Id); packet.PutString(file); WorldManager.Instance.Broadcast(packet, SendTargets.Range, source); }
public static MabiPacket AcquireAp(MabiCreature creature, uint amount) { var p = new MabiPacket(Op.AcquireInfo, creature.Id); p.PutString("<xml type='ap' value='{0}' simple='true' onlyLog='false' />", amount); p.PutInt(3000); return p; }
public static MabiPacket AcquireExp(MabiCreature creature, uint amount) { var p = new MabiPacket(Op.AcquireInfo, creature.Id); p.PutString("<xml type='exp' value='{0}'/>", amount); p.PutInt(3000); return p; }
public static MabiPacket AcquireItem(MabiCreature creature, uint cls, uint amount) { var p = new MabiPacket(Op.AcquireInfo, creature.Id); p.PutString("<xml type='item' classid='{0}' value='{1}'/>", cls, amount); p.PutInt(3000); return p; }
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); }
/// <summary> /// Sends item box packet for fixed dyed item to client. /// </summary> /// <param name="client"></param> /// <param name="creature"></param> /// <param name="itemId"></param> public static void AcquireDyedItem(Client client, MabiCreature creature, ulong itemId) { var packet = new MabiPacket(Op.AcquireInfo2, creature.Id); packet.PutString("<xml type='fixed_color_dyeing' objectid='{0}'/>", itemId); packet.PutInt(3000); client.Send(packet); }
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); }
public static MabiPacket AcquireItem(MabiCreature creature, ulong itemId) { var p = new MabiPacket(Op.AcquireInfo, creature.Id); p.PutString("<xml type='item' objectid='{0}'/>", itemId); p.PutInt(3000); // 001 [................] String : <xml type='stamina' value='17' simple='true' onlyLog='false' /> // 002 [........00000BB8] Int : 3000 return p; }
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(); }
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); }
public void AddMemberPacket(MabiPacket packet, MabiCreature member) { if (!Members.Contains(member)) return; packet.PutInt(this.GetMemberNumber(member)); packet.PutLong(member.Id); packet.PutString(member.Name); packet.PutByte(1); // ? packet.PutInt(member.Region); MabiVertex loc = member.GetPosition(); packet.PutInt(loc.X); packet.PutInt(loc.Y); packet.PutByte(0); // ? packet.PutInt((uint)((member.Life * 100) / member.LifeMax)); packet.PutInt((uint)member.LifeMax); packet.PutLong(0); // ? }
private void SendUnsetBGM(MabiCreature creature, string file) { var p = new MabiPacket(Op.UnsetBgm, creature.Id); p.PutString(file); creature.Client.Send(p); }
private void SendSetBGM(MabiCreature creature, string file, PlayType type) { var p = new MabiPacket(Op.SetBgm, creature.Id); p.PutString(file); p.PutInt((uint)type); creature.Client.Send(p); }
public MabiPacket GetWeatherPacket(uint region, float from, float to, uint transitionTime = Transition) { var p = new MabiPacket(Op.Weather, Id.Broadcast); p.PutByte(0); p.PutInt(region); p.PutByte(2); p.PutByte(0); p.PutByte(1); p.PutString("constant_smooth"); p.PutFloat(to); p.PutLong(DateTime.Now); p.PutLong(DateTime.MinValue); p.PutFloat(from); p.PutFloat(from); p.PutLong(transitionTime); p.PutByte(false); p.PutLong(DateTime.MinValue); p.PutInt(2); p.PutByte(0); return p; }
public static void MsgBox(Client client, MabiCreature creature, string title, MsgBoxButtons buttons, MsgBoxAlign align, string format, params object[] args) { var packet = new MabiPacket(Op.MsgBox, creature.Id); packet.PutString(format, args); // Can be sent with the title enum as byte as well. packet.PutString(title); packet.PutByte((byte)buttons); packet.PutByte((byte)align); client.Send(packet); }
/// <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; }
public static void SystemMessage(Client client, MabiCreature target, string from, string format, params object[] args) { var packet = new MabiPacket(Op.Chat, target.Id); packet.PutByte(0); packet.PutString(from); packet.PutString(format, args); packet.PutByte(1); packet.PutSInt(-32640); packet.PutInt(0); packet.PutByte(0); client.Send(packet); }
/// <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); }
protected void SendScript(WorldClient client, string xml) { var p = new MabiPacket(Op.NPCTalk, client.Character.Id); p.PutString(xml); p.PutBin(new byte[] { 0 }); client.Send(p); }
public static void CutsceneStart(WorldClient client, MabiCutscene cutscene) { var p = new MabiPacket(Op.CutsceneStart, Id.World); p.PutLongs(client.Character.Id, cutscene.Leader.Id); p.PutString(cutscene.Name); p.PutSInt(cutscene.Actors.Count); foreach (var a in cutscene.Actors) { p.PutString(a.Item1); p.PutShort((ushort)a.Item2.Length); p.PutBin(a.Item2); } p.PutInt(1); p.PutLong(client.Character.Id); client.Send(p); }
public override SkillResults Prepare(MabiCreature creature, MabiSkill skill, MabiPacket packet, uint castTime) { var rnd = RandomProvider.Get(); // Check for instrument if (creature.RightHand == null || creature.RightHand.Type != ItemType.Instrument) return SkillResults.Failure; // Spawn chair for Cello if (creature.RightHand.DataInfo.Instrument == InstrumentType.Cello) { var pos = creature.GetPosition(); // Chair prop var prop = new MabiProp((!creature.IsGiant ? CelloChair : GiantCelloChair), creature.Region, pos.X, pos.Y, MabiMath.DirToRad(creature.Direction)); prop.State = "stand"; WorldManager.Instance.AddProp(prop); // Move char Send.AssignChair(creature, prop.Id, 1); // Update chair prop.ExtraData = string.Format("<xml OWNER='{0}' SITCHAR='{0}'/>", creature.Id); Send.PropUpdate(prop); creature.Temp.SittingProp = prop; } // Score scrolls go into the magazine pocket and need a SCORE tag. // XXX: Is it possbile to play random with a low durability scroll? bool hasScroll = (creature.Magazine != null && creature.Magazine.Tags.Has("SCORE") && creature.Magazine.OptionInfo.Durability >= DurabilityUse); // Random score if no usable scroll was found. uint rndScore = (!hasScroll ? (uint)rnd.Next(RandomScoreMin, RandomScoreMax + 1) : 0); // Quality seems to go from 0 (worst) to 3 (best). // Should be generated based on skills + random. var quality = (PlayingQuality)rnd.Next((int)PlayingQuality.VeryBad, (int)PlayingQuality.VeryGood + 1); // Up quality by chance, based on Musical Knowledge var knowledge = creature.Skills.Get(SkillConst.MusicalKnowledge); if (knowledge != null && rnd.Next(0, 100) < knowledge.RankInfo.Var2) quality++; if (quality > PlayingQuality.VeryGood) quality = PlayingQuality.VeryGood; // Save quality before checking perfect play option, // we want proper skill training. creature.Temp.PlayingInstrumentQuality = quality; if (WorldConf.PerfectPlay) { quality = PlayingQuality.VeryGood; Send.ServerMessage(creature.Client, creature, Localization.Get("skills.perfect_play")); // Regardless of the result, perfect play will let your performance sound perfect. } // Reduce scroll's durability. if (hasScroll) { creature.Magazine.ReduceDurability(DurabilityUse); creature.Client.Send( new MabiPacket(Op.ItemDurabilityUpdate, creature.Id) .PutLong(creature.Magazine.Id) .PutInt(creature.Magazine.OptionInfo.Durability) ); } // Music effect { var effect = hasScroll ? PacketCreator.PlayEffect(creature, creature.RightHand.DataInfo.Instrument, quality, creature.Magazine.Tags["SCORE"]) : PacketCreator.PlayEffect(creature, creature.RightHand.DataInfo.Instrument, quality, rndScore); WorldManager.Instance.Broadcast(effect, SendTargets.Range, creature); } // Use skill { var use = new MabiPacket(Op.SkillUse, creature.Id); use.PutShort(skill.Info.Id); use.PutLong(0); use.PutByte(hasScroll); if (!hasScroll) use.PutInt(rndScore); else use.PutString(creature.Magazine.Tags["SCORE"]); use.PutByte((byte)creature.RightHand.DataInfo.Instrument); use.PutByte(1); use.PutByte(0); creature.Client.Send(use); creature.ActiveSkillId = skill.Id; } // Change motion for Battle Mandolin (no idea if this official, but I like it =P) [exec] //if (creature.RightHand.Info.Class == 40367) // WorldManager.Instance.CreatureUseMotion(creature, 88, 2, true); return SkillResults.Okay; }
public void AddPartyPacket(MabiPacket packet) { packet.PutLong(_id); // Party ID packet.PutString(Name); packet.PutLong(Leader.Id); packet.PutByte(IsOpen); packet.PutInt((uint)Finish); packet.PutInt((uint)ExpShare); packet.PutLong(0); // Quest ID? packet.PutInt(MaxSize); packet.PutInt(Type); packet.PutString(Level); packet.PutString(Info); packet.PutInt((uint)Members.Count); foreach (var member in Members) AddMemberPacket(packet, member); packet.PutByte(0); }
/// <summary> /// Sends GuildMessage to creature's client. /// </summary> public static void GuildMessage(MabiCreature creature, MabiGuild guild, string format, params object[] args) { var character = creature as MabiPC; var packet = new MabiPacket(Op.GuildMessage, creature.Id); packet.PutLong(guild.Id); packet.PutString(character == null ? "Aura" : character.Server); packet.PutLong(creature.Id); packet.PutString(guild.Name); packet.PutString(string.Format(format, args)); packet.PutByte(1); packet.PutByte(1); creature.Client.Send(packet); }
/// <summary> /// Sends SkillStop to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="skillId"></param> /// <param name="parameter"></param> public static void SkillStop(MabiCreature creature, SkillConst skillId, string parameter) { var packet = new MabiPacket(Op.SkillStop, creature.Id); packet.PutShort((ushort)skillId); packet.PutString(parameter); creature.Client.Send(packet); }
/// <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; }
private static MabiPacket GetNotice(NoticeType type, uint duration, string format, params object[] args) { var packet = new MabiPacket(Op.Notice, Id.Broadcast); packet.PutByte((byte)type); packet.PutString(string.Format(format, args)); if (duration > 0) packet.PutInt(duration); return packet; }
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; }
/// <summary> /// Sends whisper chat to client. /// </summary> public static void Whisper(Client client, MabiCreature creature, string sender, string format, params object[] args) { var packet = new MabiPacket(Op.WhisperChat, creature.Id); packet.PutStrings(sender); packet.PutString(format, args); client.Send(packet); }