/// <summary> /// Broadcasts Effect in range of creature, with the given packet id. /// </summary> /// <remarks> /// Parameters have to be casted to the proper type, use carefully! /// </remarks> /// <param name="id"></param> /// <param name="entity"></param> /// <param name="effectId"></param> /// <param name="parameters"></param> public static void Effect(long id, Entity entity, int effectId, params object[] parameters) { var packet = new Packet(Op.Effect, id); 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 ushort) packet.PutUShort((ushort)p); else if (p is int) packet.PutInt((int)p); else if (p is uint) packet.PutUInt((uint)p); else if (p is long) packet.PutLong((long)p); else if (p is ulong) packet.PutULong((ulong)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()); } entity.Region.Broadcast(packet, entity); }
/// <summary> /// Sends OpenBank to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="bank"></param> /// <param name="race"></param> public static void OpenBank(Creature creature, BankInventory bank, BankTabRace race) { var packet = new Packet(Op.OpenBank, creature.EntityId); packet.PutByte(1); packet.PutByte((byte)race); packet.PutLong(DateTime.Now); packet.PutByte(0); packet.PutString(creature.Client.Account.Id); packet.PutString("Global"); // Current bank id packet.PutString("Bank"); // Current bank title packet.PutInt(bank.Gold); var tabList = bank.GetTabList(race); packet.PutInt(tabList.Count); foreach (var tab in tabList) { packet.PutString(tab.Name); packet.PutByte((byte)tab.Race); // [190200, NA204 (2015-05-19)] ? // Haven't opened a bank in a while, could've been // added earlier. -- exec { packet.PutInt(0); } packet.PutInt(tab.Width); packet.PutInt(tab.Height); var itemList = tab.GetItemList(); packet.PutInt(itemList.Count); foreach (var item in itemList) { packet.PutString("Global"); // Bank id packet.PutULong(18446744017659355058); packet.PutULong(0); packet.AddItemInfo(item, ItemPacketType.Private); } } creature.Client.Send(packet); }