Beispiel #1
0
		/// <summary>
		/// New item based on existing item.
		/// </summary>
		/// <param name="baseItem"></param>
		public Item(Item baseItem)
		{
			this.Info = baseItem.Info;
			this.OptionInfo = baseItem.OptionInfo;
			this.Data = baseItem.Data;
			this.MetaData1 = new MabiDictionary(baseItem.MetaData1.ToString());
			this.MetaData2 = new MabiDictionary(baseItem.MetaData2.ToString());
			this.EgoInfo = baseItem.EgoInfo.Copy();
			this.AddUpgradeEffect(baseItem.GetUpgradeEffects());

			if (baseItem.Quest != null)
			{
				this.Quest = new Quest(baseItem.Quest.Id);
				this.Quest.QuestItem = this;
			}

			this.SetNewEntityId();
		}
Beispiel #2
0
		public static Packet AddItemInfo(this Packet packet, Item item, ItemPacketType type)
		{
			packet.PutLong(item.EntityId);
			packet.PutByte((byte)type);
			packet.PutBin(item.Info);

			if (type == ItemPacketType.Public)
			{
				packet.PutByte(1);
				packet.PutByte(0);

				//packet.PutByte(0); // Bitmask
				// if & 1
				//     float
				packet.PutByte(1);
				packet.PutFloat(1); // Size multiplicator *hint: Server side giant key mod*

				packet.PutByte(item.FirstTimeAppear); // 0: No bouncing, 1: Bouncing, 2: Delayed bouncing
			}
			else if (type == ItemPacketType.Private)
			{
				packet.PutBin(item.OptionInfo);

				// Ego data
				if (item.Data.HasTag("/ego_weapon/"))
				{
					packet.PutString(item.EgoInfo.Name);
					packet.PutByte((byte)item.EgoInfo.Race);
					packet.PutByte(0); // ? increased from 14 to 18 when I fed a bottle to a sword

					packet.PutByte(item.EgoInfo.SocialLevel);
					packet.PutInt(item.EgoInfo.SocialExp);
					packet.PutByte(item.EgoInfo.StrLevel);
					packet.PutInt(item.EgoInfo.StrExp);
					packet.PutByte(item.EgoInfo.IntLevel);
					packet.PutInt(item.EgoInfo.IntExp);
					packet.PutByte(item.EgoInfo.DexLevel);
					packet.PutInt(item.EgoInfo.DexExp);
					packet.PutByte(item.EgoInfo.WillLevel);
					packet.PutInt(item.EgoInfo.WillExp);
					packet.PutByte(item.EgoInfo.LuckLevel);
					packet.PutInt(item.EgoInfo.LuckExp);
					packet.PutByte(item.EgoInfo.AwakeningEnergy);
					packet.PutInt(item.EgoInfo.AwakeningExp);

					packet.PutLong(0);
					packet.PutLong(item.EgoInfo.LastFeeding); // Last feeding time?
					packet.PutInt(0);
				}

				packet.PutString(item.MetaData1.ToString());
				packet.PutString(item.MetaData2.ToString());

				// Upgrades
				var upgradeEffects = item.GetUpgradeEffects();
				packet.PutByte((byte)upgradeEffects.Length);
				foreach (var upgradeEffect in upgradeEffects)
					packet.PutBin(upgradeEffect);

				// Special upgrades? (example)
				//0608 [0000000000000000] Long   : 0
				//0609 [........00000002] Int    : 2
				//0610 [........00000024] Int    : 36
				//0611 [........00000008] Int    : 8
				//0612 [........00000026] Int    : 38
				//0613 [........00000004] Int    : 4

				packet.PutLong(item.QuestId);

				// [190100, NA200 (2015-01-15)] ?
				{
					packet.PutByte(item.IsNew);
					packet.PutByte(0);
				}
			}

			return packet;
		}
Beispiel #3
0
		/// <summary>
		/// Applies upgrade effects from item.
		/// </summary>
		/// <param name="item"></param>
		private void ApplyUpgradeEffects(Item item)
		{
			foreach (var effect in item.GetUpgradeEffects())
			{
				var stat = effect.Stat.ToStat();
				var value = effect.Value;

				// Check stat
				if (stat == Stat.None)
				{
					Log.Warning("ApplyUpgradeEffects: Unknown/unhandled stat '{0}'.", effect.Stat);
					continue;
				}

				// Check requirements
				var fulfilled = false;

				// None
				if (effect.CheckType == UpgradeCheckType.None)
				{
					fulfilled = true;
				}
				// Stat ==, >, >=, <, <=
				else if (effect.CheckType >= UpgradeCheckType.GreaterThan && effect.CheckType <= UpgradeCheckType.Equal)
				{
					// Check upgrade stat and get value
					var valueToCheck = 0;
					switch (effect.CheckStat)
					{
						case UpgradeStat.Level: valueToCheck = _creature.Level; break;
						case UpgradeStat.TotalLevel: valueToCheck = _creature.TotalLevel; break;
						case UpgradeStat.ExplorationLevel: valueToCheck = 0; break; // TODO: Set once we have exploration levels.
						case UpgradeStat.Age: valueToCheck = _creature.Age; break;

						default:
							Log.Warning("ApplyUpgradeEffects: Unknown/unhandled check stat '{0}'.", effect.CheckStat);
							continue;
					}

					// Check value
					switch (effect.CheckType)
					{
						case UpgradeCheckType.Equal: fulfilled = (valueToCheck == effect.CheckValue); break;
						case UpgradeCheckType.GreaterThan: fulfilled = (valueToCheck > effect.CheckValue); break;
						case UpgradeCheckType.GreaterEqualThan: fulfilled = (valueToCheck >= effect.CheckValue); break;
						case UpgradeCheckType.LowerThan: fulfilled = (valueToCheck < effect.CheckValue); break;
						case UpgradeCheckType.LowerEqualThan: fulfilled = (valueToCheck <= effect.CheckValue); break;
					}
				}
				// Skill rank >, <, ==
				else if (effect.CheckType >= UpgradeCheckType.SkillRankEqual && effect.CheckType <= UpgradeCheckType.SkillRankLowerThan)
				{
					var skillId = effect.CheckSkillId;
					var skillRank = effect.CheckSkillRank;

					var skill = _creature.Skills.Get(effect.CheckSkillId);
					if (skill != null)
					{
						switch (effect.CheckType)
						{
							case UpgradeCheckType.SkillRankEqual: fulfilled = (skill.Info.Rank == effect.CheckSkillRank); break;
							case UpgradeCheckType.SkillRankGreaterThan: fulfilled = (skill.Info.Rank >= effect.CheckSkillRank); break;
							case UpgradeCheckType.SkillRankLowerThan: fulfilled = (skill.Info.Rank < effect.CheckSkillRank); break;
						}
					}
				}
				// Broken
				else if (effect.CheckType == UpgradeCheckType.WhenBroken)
				{
					fulfilled = (effect.CheckBroken && item.Durability == 0) || (!effect.CheckBroken && item.Durability != 0);
				}
				// Title
				else if (effect.CheckType == UpgradeCheckType.HoldingTitle)
				{
					fulfilled = (_creature.Titles.SelectedTitle == effect.CheckTitleId);
				}
				// Condition
				else if (effect.CheckType == UpgradeCheckType.InAStateOf)
				{
					fulfilled = _creature.Conditions.Has(effect.CheckCondition);
				}
				// PTJ
				else if (effect.CheckType == UpgradeCheckType.IfPtjCompletedMoreThan)
				{
					var trackRecord = _creature.Quests.GetPtjTrackRecord(effect.CheckPtj);
					fulfilled = (trackRecord.Done >= effect.CheckValue);
				}
				// Month
				else if (effect.CheckType == UpgradeCheckType.WhileBeing)
				{
					fulfilled = (ErinnTime.Now.Month == (int)effect.CheckMonth);
				}
				// Summon
				else if (effect.CheckType == UpgradeCheckType.WhileSummoned)
				{
					switch (effect.CheckStat)
					{
						case UpgradeStat.Pet: fulfilled = (_creature.Pet != null); break;
						case UpgradeStat.Golem: fulfilled = false; break; // TODO: Set once we have golems.
						case UpgradeStat.BarrierSpikes: fulfilled = false; break; // TODO: Set once we have barrier spikes.

						default:
							Log.Warning("ApplyUpgradeEffects: Unknown/unhandled check summon '{0}'.", effect.CheckStat);
							continue;
					}
				}
				else
				{
					Log.Warning("ApplyUpgradeEffects: Unknown/unhandled check type '{0}'.", effect.CheckType);
					continue;
				}

				// Apply if requirements are fulfilled
				if (fulfilled)
					_creature.StatMods.Add(stat, value, StatModSource.Equipment, item.EntityId);
			}
		}
Beispiel #4
0
		public static Packet AddItemInfo(this Packet packet, Item item, ItemPacketType type)
		{
			var isEgoWeapon = item.HasTag("/ego_weapon/");
			var isGuildRobe = item.HasTag("/guild_robe/");

			packet.PutLong(item.EntityId);
			packet.PutByte((byte)type);
			packet.PutBin(item.Info);

			if (isGuildRobe)
				// EBCL1:4:-16351525;EBCL2:4:-875718;EBLM1:1:46;EBLM2:1:11;EBLM3:1:4; (GLDNAM:s:European;)
				packet.PutString(item.MetaData1.ToString());

			if (type == ItemPacketType.Public)
			{
				packet.PutByte(1);

				// Affects color of dropped item's name (blue or green),
				// indicating its value.
				packet.PutByte((byte)item.UpgradeEffectCount);

				//packet.PutByte(0); // Bitmask
				// if & 1
				//     float
				packet.PutByte(1);
				packet.PutFloat(1); // Size multiplicator *hint: Server side giant key mod*

				packet.PutByte(item.FirstTimeAppear); // 0: No bouncing, 1: Bouncing, 2: Delayed bouncing
			}
			else if (type == ItemPacketType.Private)
			{
				packet.PutBin(item.OptionInfo);

				// Ego data
				if (isEgoWeapon)
				{
					packet.PutString(item.EgoInfo.Name);
					packet.PutByte((byte)item.EgoInfo.Race);
					packet.PutByte(0); // ? increased from 14 to 18 when I fed a bottle to a sword

					packet.PutByte(item.EgoInfo.SocialLevel);
					packet.PutInt(item.EgoInfo.SocialExp);
					packet.PutByte(item.EgoInfo.StrLevel);
					packet.PutInt(item.EgoInfo.StrExp);
					packet.PutByte(item.EgoInfo.IntLevel);
					packet.PutInt(item.EgoInfo.IntExp);
					packet.PutByte(item.EgoInfo.DexLevel);
					packet.PutInt(item.EgoInfo.DexExp);
					packet.PutByte(item.EgoInfo.WillLevel);
					packet.PutInt(item.EgoInfo.WillExp);
					packet.PutByte(item.EgoInfo.LuckLevel);
					packet.PutInt(item.EgoInfo.LuckExp);
					packet.PutByte(item.EgoInfo.AwakeningEnergy);
					packet.PutInt(item.EgoInfo.AwakeningExp);

					packet.PutLong(0);
					packet.PutLong(item.EgoInfo.LastFeeding); // Last feeding time?
					packet.PutInt(0);
				}

				packet.PutString(item.MetaData1.ToString());
				packet.PutString(item.MetaData2.ToString());

				// Upgrades
				var upgradeEffects = item.GetUpgradeEffects();
				packet.PutByte((byte)upgradeEffects.Length);
				foreach (var upgradeEffect in upgradeEffects)
					packet.PutBin(upgradeEffect);

				// Special upgrades? (example)
				//0608 [0000000000000000] Long   : 0
				//0609 [........00000002] Int    : 2
				//0610 [........00000024] Int    : 36
				//0611 [........00000008] Int    : 8
				//0612 [........00000026] Int    : 38
				//0613 [........00000004] Int    : 4

				packet.PutLong(item.QuestId);

				if (isGuildRobe)
					packet.PutString(item.MetaData1.GetString("GLDNAM"));

				// In NA235 (Sep. 2016) we found an additional integer for
				// Scythe that Reaps Darkness here, with no known purpose.
				// In NA236 we had to remove said int again.
				// It will be missed.
				//if (item.Info.Id == 41237)
				//	packet.PutInt(0);

				// [190100, NA200 (2015-01-15)] ?
				{
					packet.PutByte(item.IsNew);
					packet.PutByte(0);
				}
			}

			return packet;
		}