Exemple #1
0
		protected override void SendQuestWindow(GameNPC questNPC, GamePlayer player, RewardQuest quest,	bool offer)
		{
			GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.Dialog));
			ushort QuestID = QuestMgr.GetIDForQuestType(quest.GetType());
			pak.WriteShort((offer) ? (byte)0x22 : (byte)0x21); // Dialog
			pak.WriteShort(QuestID);
			pak.WriteShort((ushort)questNPC.ObjectID);
			pak.WriteByte(0x00); // unknown
			pak.WriteByte(0x00); // unknown
			pak.WriteByte(0x00); // unknown
			pak.WriteByte(0x00); // unknown
			pak.WriteByte((offer) ? (byte)0x02 : (byte)0x01); // Accept/Decline or Finish/Not Yet
			pak.WriteByte(0x01); // Wrap
			pak.WritePascalString(quest.Name);
			if (quest.Summary.Length > 255)
				pak.WritePascalString(quest.Summary.Substring(0,255));
			else
				pak.WritePascalString(quest.Summary);
			if (offer)
			{
				pak.WriteShort((ushort)quest.Story.Length);
				pak.WriteStringBytes(quest.Story);
			}
			else
			{
				pak.WriteShort((ushort)quest.Conclusion.Length);
				pak.WriteStringBytes(quest.Conclusion);
			}
			pak.WriteShort(QuestID);
			pak.WriteByte((byte)quest.Goals.Count); // #goals count
			foreach (RewardQuest.QuestGoal goal in quest.Goals)
			{
				pak.WritePascalString(String.Format("{0}\r", goal.Description));
			}
			pak.WriteByte((byte)quest.Level);
			pak.WriteByte((byte)quest.Rewards.MoneyPercent);
			pak.WriteByte((byte)quest.Rewards.ExperiencePercent(player));
			pak.WriteByte((byte)quest.Rewards.BasicItems.Count);
			foreach (ItemTemplate reward in quest.Rewards.BasicItems)
				WriteTemplateData(pak, reward, 1);
			pak.WriteByte((byte)quest.Rewards.ChoiceOf);
			pak.WriteByte((byte)quest.Rewards.OptionalItems.Count);
			foreach (ItemTemplate reward in quest.Rewards.OptionalItems)
				WriteTemplateData(pak, reward, 1);
			SendTCP(pak);
		}
Exemple #2
0
		protected override void SendQuestWindow(GameNPC questNPC, GamePlayer player, RewardQuest quest,	bool offer)
		{
			using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.Dialog)))
			{
				ushort QuestID = QuestMgr.GetIDForQuestType(quest.GetType());
				pak.WriteShort((offer) ? (byte)0x22 : (byte)0x21); // Dialog
				pak.WriteShort(QuestID);
				pak.WriteShort((ushort)questNPC.ObjectID);
				pak.WriteByte(0x00); // unknown
				pak.WriteByte(0x00); // unknown
				pak.WriteByte(0x00); // unknown
				pak.WriteByte(0x00); // unknown
				pak.WriteByte((offer) ? (byte)0x02 : (byte)0x01); // Accept/Decline or Finish/Not Yet
				pak.WriteByte(0x01); // Wrap
				pak.WritePascalString(quest.Name);
	
				String personalizedSummary = BehaviourUtils.GetPersonalizedMessage(quest.Summary, player);
				if (personalizedSummary.Length > 255)
					pak.WritePascalString(personalizedSummary.Substring(0, 255)); // Summary is max 255 bytes !
				else
					pak.WritePascalString(personalizedSummary);
	
				if (offer)
				{
					String personalizedStory = BehaviourUtils.GetPersonalizedMessage(quest.Story, player);
	
					if (personalizedStory.Length > ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH)
					{
						pak.WriteShort((ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH);
						pak.WriteStringBytes(personalizedStory.Substring(0, ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH));
					}
					else
					{
						pak.WriteShort((ushort)personalizedStory.Length);
						pak.WriteStringBytes(personalizedStory);
					}
				}
				else
				{
					if (quest.Conclusion.Length > (ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH)
					{
						pak.WriteShort((ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH);
						pak.WriteStringBytes(quest.Conclusion.Substring(0, (ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH));
					}
					else
					{
						pak.WriteShort((ushort)quest.Conclusion.Length);
						pak.WriteStringBytes(quest.Conclusion);
					}
				}
	
				pak.WriteShort(QuestID);
				pak.WriteByte((byte)quest.Goals.Count); // #goals count
				foreach (RewardQuest.QuestGoal goal in quest.Goals)
				{
					pak.WritePascalString(String.Format("{0}\r", goal.Description));
				}
				pak.WriteInt((uint)(quest.Rewards.Money)); // unknown, new in 1.94
				pak.WriteByte((byte)quest.Rewards.ExperiencePercent(player));
				pak.WriteByte((byte)quest.Rewards.BasicItems.Count);
				foreach (ItemTemplate reward in quest.Rewards.BasicItems)
				{
					WriteItemData(pak, GameInventoryItem.Create<ItemTemplate>(reward));
				}
				pak.WriteByte((byte)quest.Rewards.ChoiceOf);
				pak.WriteByte((byte)quest.Rewards.OptionalItems.Count);
				foreach (ItemTemplate reward in quest.Rewards.OptionalItems)
				{
					WriteItemData(pak, GameInventoryItem.Create<ItemTemplate>(reward));
				}
				SendTCP(pak);
			}
		}