public override void ShowTo(User invoker, VisibleObject invokee) { Logger.DebugFormat("active for input dialog: {0}, {1}, {2}", TopCaption, InputLength, BottomCaption); var dialogPacket = base.GenerateBasePacket(invoker, invokee); dialogPacket.WriteString8(TopCaption); dialogPacket.WriteByte((byte)InputLength); dialogPacket.WriteString8(BottomCaption); invoker.Enqueue(dialogPacket); RunCallback(invoker, invokee); }
public override void ShowTo(User invoker, VisibleObject invokee) { var dialogPacket = base.GenerateBasePacket(invoker, invokee); if (Options.Count > 0) { dialogPacket.WriteByte((byte)Options.Count); foreach (var option in Options) { dialogPacket.WriteString8(option.OptionText); } invoker.Enqueue(dialogPacket); RunCallback(invoker, invokee); } }
public override void OnClick(User invoker) { // Return a profile packet (0x34) to the user who clicked. // This packet format is: // uint32 id, 18 equipment slots (uint16 sprite, byte color), byte namelength, string name, // byte nation, byte titlelength, string title, byte grouping, byte guildranklength, string guildrank, // byte classnamelength, string classname, byte guildnamelength, byte guildname, byte numLegendMarks (lame!), // numLegendMarks[byte icon, byte color, byte marklength, string mark] // This packet can also contain a portrait and profile text but we haven't even remotely implemented it yet. var profilePacket = new ServerPacket(0x34); profilePacket.WriteUInt32(Id); // Equipment block is 3 bytes per slot and contains 54 bytes (18 slots), which I believe is sprite+color // EXCEPT WHEN IT'S MUNGED IN SOME OBSCURE WAY BECAUSE REASONS foreach (var tuple in Equipment.GetEquipmentDisplayList()) { profilePacket.WriteUInt16(tuple.Item1); profilePacket.WriteByte(tuple.Item2); } profilePacket.WriteByte((byte)GroupStatus); profilePacket.WriteString8(Name); profilePacket.WriteByte((byte)Citizenship.flag); // This should pull from town / nation profilePacket.WriteString8(Title); profilePacket.WriteByte((byte)(Grouping ? 1 : 0)); profilePacket.WriteString8(GuildRank); profilePacket.WriteString8(Hybrasyl.Constants.REVERSE_CLASSES[(int)Class]); profilePacket.WriteString8(Guild); profilePacket.WriteByte((byte)LegendMarks.Count); foreach (var mark in LegendMarks) { profilePacket.WriteByte((byte)mark.icon); profilePacket.WriteByte((byte)mark.color); profilePacket.WriteString8(mark.prefix); profilePacket.WriteString8(mark.text); } profilePacket.WriteUInt16((ushort)(PortraitData.Length + ProfileText.Length + 4)); profilePacket.WriteUInt16((ushort)PortraitData.Length); profilePacket.Write(PortraitData); profilePacket.WriteString16(ProfileText); invoker.Enqueue(profilePacket); }
public override void ShowTo(User invoker, VisibleObject invokee) { var dialogPacket = base.GenerateBasePacket(invoker, invokee); invoker.Enqueue(dialogPacket); RunCallback(invoker, invokee); }
public void DisplayPursuits(User invoker) { var menupacket = new ServerPacket(0x2F); // menuType (0), objectType (1 for "creature"), objectID, random, sprite, spritecolor, // random1 (same as random), sprite, spriteColor, ??, promptName (Green "nameplate" text on dialog), // byte pursuitsCount, array <string pursuitName, uint16 pursuitID> menupacket.WriteByte(0); if (this is Merchant || this is Creature) { menupacket.WriteByte(1); } else if (this is Item) { menupacket.WriteByte(2); } else if (this is Reactor) { menupacket.WriteByte(4); } else { menupacket.WriteByte(3); // this is probably bad } menupacket.WriteUInt32(Id); menupacket.WriteByte(1); menupacket.WriteUInt16((ushort)(0x4000 + Sprite)); menupacket.WriteByte(0); menupacket.WriteByte(1); menupacket.WriteUInt16((ushort)(0x4000 + Sprite)); menupacket.WriteByte(0); menupacket.WriteByte(0); menupacket.WriteString8(Name); menupacket.WriteString16(DisplayText ?? String.Empty); // Generate our list of dialog options int countPosition = menupacket.Position; menupacket.WriteByte(0); int pursuitCount = Pursuits.Count; if (this is Merchant) { var merchant = (Merchant)this; if (merchant.Jobs.HasFlag(MerchantJob.Vendor)) { menupacket.WriteString8("Buy"); menupacket.WriteUInt16((ushort)MerchantMenuItem.BuyItemMenu); menupacket.WriteString8("Sell"); menupacket.WriteUInt16((ushort)MerchantMenuItem.SellItemMenu); pursuitCount += 2; } if (merchant.Jobs.HasFlag(MerchantJob.Banker)) { menupacket.WriteString8("Withdraw Item"); menupacket.WriteUInt16((ushort)MerchantMenuItem.WithdrawItemMenu); menupacket.WriteString8("Withdraw Gold"); menupacket.WriteUInt16((ushort)MerchantMenuItem.WithdrawGoldMenu); menupacket.WriteString8("Deposit Item"); menupacket.WriteUInt16((ushort)MerchantMenuItem.DepositItemMenu); menupacket.WriteString8("Deposit Gold"); menupacket.WriteUInt16((ushort)MerchantMenuItem.DepositGoldMenu); pursuitCount += 4; } if (merchant.Jobs.HasFlag(MerchantJob.Repairer)) { menupacket.WriteString8("Repair Item"); menupacket.WriteUInt16((ushort)MerchantMenuItem.RepairItemMenu); menupacket.WriteString8("Repair All Items"); menupacket.WriteUInt16((ushort)MerchantMenuItem.RepairAllItems); pursuitCount += 2; } if (merchant.Jobs.HasFlag(MerchantJob.Trainer)) { /* if merchant has skills available to user: * menupacket.WriteString8("Learn Skill"); * menupacket.WriteUInt16((ushort)MerchantMenuItem.LearnSkillMenu); * pursuitCount++; * if merchant has spells available to user: * menupacket.WriteString8("Learn Spell"); * menupacket.WriteUInt16((ushort)MerchantMenuItem.LearnSpellMenu); * pursuitCount++; */ menupacket.WriteString8("Forget Skill"); menupacket.WriteUInt16((ushort)MerchantMenuItem.ForgetSkillMenu); menupacket.WriteString8("Forget Spell"); menupacket.WriteUInt16((ushort)MerchantMenuItem.ForgetSpellMenu); pursuitCount += 2; } if (merchant.Jobs.HasFlag(MerchantJob.Postman)) { menupacket.WriteString8("Send Parcel"); menupacket.WriteUInt16((ushort)MerchantMenuItem.SendParcelMenu); pursuitCount++; /* if user has item named "Letter" * menupacket.WriteString8("Send Letter"); * menupacket.WriteUInt16((ushort)MerchantMenuItem.SendLetterMenu); * pursuitCount++; * if user has incoming parcel * menupacket.WriteString8("Receive Parcel"); * menupacket.WriteUInt16((ushort)MerchantMenuItem.ReceiveParcel); * pursuitCount++; */ } } foreach (var pursuit in Pursuits) { Logger.DebugFormat("Pursuit {0}, id {1}", pursuit.Name, pursuit.Id); menupacket.WriteString8(pursuit.Name); menupacket.WriteUInt16((ushort)pursuit.Id); } menupacket.Seek(countPosition, PacketSeekOrigin.Begin); menupacket.WriteByte((byte)pursuitCount); menupacket.DumpPacket(); invoker.Enqueue(menupacket); }