private void _useItem(ItemUseData data)
		{
			World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(data.ItemID, data.CharacterAmount, data.Weight, data.MaxWeight);
			switch (data.Type)
			{
				case ItemType.Teleport: /*Warp packet handles the rest!*/ break;
				case ItemType.Heal:
					{
						World.Instance.MainPlayer.ActiveCharacter.Stats.HP = data.HP;
						World.Instance.MainPlayer.ActiveCharacter.Stats.TP = data.TP;

						int percent = (int)Math.Round(100.0 * ((double)data.HP / World.Instance.MainPlayer.ActiveCharacter.Stats.MaxHP));

						if (data.HPGain > 0)
							World.Instance.ActiveCharacterRenderer.SetDamageCounterValue(data.HPGain, percent, true);
						m_game.Hud.RefreshStats();
					}
					break;
				case ItemType.HairDye:
					{
						World.Instance.MainPlayer.ActiveCharacter.RenderData.SetHairColor(data.HairColor);
					}
					break;
				case ItemType.Beer:
					World.Instance.ActiveCharacterRenderer.MakeDrunk();
					m_game.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_ITEM_USE_DRUNK);
					break;
				case ItemType.EffectPotion:
					{
						m_game.Hud.DisableEffectPotionUse();
						var effectRenderer = new EffectRenderer(m_game, World.Instance.ActiveCharacterRenderer, m_game.Hud.EnableEffectPotionUse);
						effectRenderer.SetEffectInfoTypeAndID(EffectType.Potion, data.EffectID);
						effectRenderer.ShowEffect();
					}
					break;
				case ItemType.CureCurse:
					{
						//actually remove the item(s) from the main character
						Character c = World.Instance.MainPlayer.ActiveCharacter;
						for (int i = 0; i < (int)EquipLocation.PAPERDOLL_MAX; ++i)
						{
							int nextID = c.PaperDoll[i];
							if (nextID > 0 && World.Instance.EIF.GetItemRecordByID(nextID).Special == ItemSpecial.Cursed)
							{
								c.PaperDoll[i] = 0;
								switch ((EquipLocation)i)
								{
									case EquipLocation.Boots: c.RenderData.SetBoots(0); break;
									case EquipLocation.Armor: c.RenderData.SetArmor(0); break;
									case EquipLocation.Hat: c.RenderData.SetHat(0); break;
									case EquipLocation.Shield: c.RenderData.SetShield(0); break;
									case EquipLocation.Weapon: c.RenderData.SetWeapon(0); break;
								}
							}
						}

						//update main character's stats
						CharStatData s = c.Stats;
						s.MaxHP = data.CureStats.MaxHP;
						s.MaxTP = data.CureStats.MaxTP;
						s.Str = data.CureStats.Str;
						s.Int = data.CureStats.Int;
						s.Wis = data.CureStats.Wis;
						s.Agi = data.CureStats.Agi;
						s.Con = data.CureStats.Con;
						s.Cha = data.CureStats.Cha;
						s.MinDam = data.CureStats.MinDam;
						s.MaxDam = data.CureStats.MaxDam;
						s.Accuracy = data.CureStats.Accuracy;
						s.Evade = data.CureStats.Evade;
						s.Armor = data.CureStats.Armor;
						m_game.Hud.RefreshStats();
					}
					break;
				case ItemType.EXPReward:
					{
						CharStatData s = World.Instance.MainPlayer.ActiveCharacter.Stats;
						if (s.Level < data.RewardStats.Level)
						{
							//level up!
							World.Instance.MainPlayer.ActiveCharacter.Emote(Emote.LevelUp);
							World.Instance.ActiveCharacterRenderer.PlayerEmote();
							s.Level = data.RewardStats.Level;
						}
						s.Experience = data.RewardStats.Exp;
						s.StatPoints = data.RewardStats.StatPoints;
						s.SkillPoints = data.RewardStats.SkillPoints;
						s.MaxHP = data.RewardStats.MaxHP;
						s.MaxTP = data.RewardStats.MaxTP;
						s.MaxSP = data.RewardStats.MaxSP;
					}
					break;
			}
		}
Exemplo n.º 2
0
		public void WarpAgreeAction(short mapID, WarpAnimation anim, List<CharacterData> chars, List<NPCData> npcs, List<MapItem> items)
		{
			if (!_tryLoadMap(mapID, false))
			{
				EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
				return;
			}

			if(mapID > 0)
				MainPlayer.ActiveCharacter.CurrentMap = mapID;

			if(ActiveMapRenderer.MapRef != MapCache[MainPlayer.ActiveCharacter.CurrentMap])
				ActiveMapRenderer.SetActiveMap(MapCache[MainPlayer.ActiveCharacter.CurrentMap]);

			ActiveMapRenderer.ClearOtherPlayers();
			ActiveMapRenderer.ClearOtherNPCs();
			ActiveMapRenderer.ClearMapItems();

			foreach (var data in chars)
			{
				if (data.ID == MainPlayer.ActiveCharacter.ID)
					MainPlayer.ActiveCharacter.ApplyData(data);
				else
					ActiveMapRenderer.AddOtherPlayer(data);
			}

			foreach (var data in npcs)
				ActiveMapRenderer.AddOtherNPC(data);

			foreach (MapItem mi in items)
				ActiveMapRenderer.AddMapItem(mi);

			if (anim == WarpAnimation.Admin)
			{
				var effectRenderer = new EffectRenderer(EOGame.Instance, ActiveCharacterRenderer, delegate { });
				effectRenderer.SetEffectInfoTypeAndID(EffectType.WarpDestination, 0);
				effectRenderer.ShowEffect();
			}
		}
Exemplo n.º 3
0
		public void AddOtherPlayer(CharacterData c, WarpAnimation anim = WarpAnimation.None)
		{
			CharacterRenderer otherRend = null;
			lock (_rendererListLock)
			{
				Character other = otherRenderers.Select(x => x.Character).FirstOrDefault(x => x.Name == c.Name && x.ID == c.ID);
				if (other == null)
				{
					other = new Character(m_api, c);
					lock (_rendererListLock)
					{
						otherRenderers.Add(otherRend = new CharacterRenderer(other));
						otherRenderers[otherRenderers.Count - 1].Visible = true;
						otherRenderers[otherRenderers.Count - 1].Initialize();
					}
					other.RenderData.SetUpdate(true);
				}
				else
				{
					other.ApplyData(c);
				}
			}

			if (anim == WarpAnimation.Admin && otherRend != null)
			{
				var effectRenderer = new EffectRenderer((EOGame) Game, otherRend, delegate { });
				effectRenderer.SetEffectInfoTypeAndID(EffectType.WarpDestination, 0);
				effectRenderer.ShowEffect();
			}
		}
Exemplo n.º 4
0
		public void RemoveOtherPlayer(short id, WarpAnimation anim = WarpAnimation.None)
		{
			lock (_rendererListLock)
			{
				int ndx;
				if ((ndx = otherRenderers.FindIndex(cc => cc.Character.ID == id)) >= 0)
				{
					var rend = otherRenderers[ndx];
					rend.HideChatBubble();
					rend.Visible = false;
					otherRenderers.Remove(rend);

					Action closeRenderer = () => { rend.Close(); };
					if (anim == WarpAnimation.Admin)
					{
						var effectRenderer = new EffectRenderer((EOGame)Game, rend, closeRenderer);
						effectRenderer.SetEffectInfoTypeAndID(EffectType.WarpOriginal, 0);
						effectRenderer.ShowEffect();
					}
					else
					{
						closeRenderer();
					}
				}
			}
		}
Exemplo n.º 5
0
		private void _renderSpellOnNPC(short spellID, NPC renderer)
		{
			if (spellID < 1) return;

			var spellInfo = World.Instance.ESF.GetSpellRecordByID(spellID);
			var effect = new EffectRenderer((EOGame)Game, renderer, delegate { });
			effect.SetEffectInfoTypeAndID(EffectType.Spell, spellInfo.Graphic);
			effect.ShowEffect();
		}
Exemplo n.º 6
0
		private void RenderEffect(EffectType effectType, int effectID)
		{
			var gfxManager = ((EOGame)Game).GFXManager;
			_effectRenderer = new EffectRenderer(gfxManager, this, () => _effectRenderer = null);
			_effectRenderer.SetEffectInfoTypeAndID(effectType, effectID);
			_effectRenderer.ShowEffect();
		}
Exemplo n.º 7
0
		private void RenderWaterSplashie()
		{
			if (_waterEffect != null)
			{
				_waterEffect.Restart();
				return;
			}

			_waterEffect = new EffectRenderer((EOGame)Game, this, () => _waterEffect = null);
			_waterEffect.SetEffectInfoTypeAndID(EffectType.WaterSplashies, 0);
			_waterEffect.ShowEffect();
		}
Exemplo n.º 8
0
		private void ResetEffectRenderer()
		{
			if (_effectRenderer != null)
			{
				_effectRenderer.Dispose();
				_effectRenderer = null;
			}
		}
Exemplo n.º 9
0
		private void RenderEffect(EffectType effectType, int effectID = 0, Action cleanupAction = null)
		{
			cleanupAction = cleanupAction ?? delegate { };
			Action fullCleanup = () =>
			{
				_effectRenderer = null;
				cleanupAction();
			};

			var gfxManager = ((EOGame)Game).GFXManager;
			_effectRenderer = new EffectRenderer(gfxManager, this, fullCleanup);
			_effectRenderer.SetEffectInfoTypeAndID(effectType, effectID);
			_effectRenderer.ShowEffect();
		}