示例#1
0
        private void _handleRefreshReply(Packet pkt)
        {
            if (OnWarpAgree == null)
                return;

            byte numOtherChars = pkt.GetChar();
            if (pkt.GetByte() != 255)
                return;

            List<CharacterData> otherChars = new List<CharacterData>(numOtherChars);
            for (int i = 0; i < numOtherChars; ++i)
            {
                CharacterData data = new CharacterData(pkt);
                otherChars.Add(data);
                if (pkt.GetByte() != 255)
                    return;
            }

            List<NPCData> otherNPCs = new List<NPCData>();
            while (pkt.PeekByte() != 255)
            {
                NPCData newGuy = new NPCData(pkt);
                otherNPCs.Add(newGuy);
            }
            pkt.GetByte();

            List<MapItem> mapItems = new List<MapItem>();
            while (pkt.ReadPos < pkt.Length)
            {
                mapItems.Add(new MapItem
                {
                    uid = pkt.GetShort(),
                    id = pkt.GetShort(),
                    x = pkt.GetChar(),
                    y = pkt.GetChar(),
                    amount = pkt.GetThree(),
                    //turn off drop protection for items coming into view - server will validate
                    time = DateTime.Now.AddSeconds(-5),
                    npcDrop = false,
                    playerID = -1
                });
            }

            OnWarpAgree(-1, WarpAnimation.None, otherChars, otherNPCs, mapItems);
        }
示例#2
0
        //constructs a character from a packet sent from the server
        public Character(PacketAPI api, CharacterData data)
        {
            //initialize lists
            m_packetAPI = api;

            Inventory = new List<InventoryItem>();
            Spells = new List<CharacterSpell>();
            PaperDoll = new short[(int)EquipLocation.PAPERDOLL_MAX];

            Name = data.Name;

            ID = data.ID;
            CurrentMap = data.Map;
            X = data.X;
            Y = data.Y;

            PaddedGuildTag = data.GuildTag;

            RenderData = new CharRenderData
            {
                facing = data.Direction,
                level = data.Level,
                gender = data.Gender,
                hairstyle = data.HairStyle,
                haircolor = data.HairColor,
                race = data.Race
            };

            Stats = new CharStatData
            {
                maxhp = data.MaxHP,
                hp = data.HP,
                maxtp = data.MaxTP,
                tp = data.TP
            };

            EquipItem(ItemType.Boots, 0, data.Boots, true);
            EquipItem(ItemType.Armor, 0, data.Armor, true);
            EquipItem(ItemType.Hat, 0, data.Hat, true);
            EquipItem(ItemType.Shield, 0, data.Shield, true);
            EquipItem(ItemType.Weapon, 0, data.Weapon, true);

            RenderData.SetSitting(data.Sitting);
            RenderData.SetHidden(data.Hidden);
        }
示例#3
0
        private void _handleWarpAgree(Packet pkt)
        {
            if (pkt.GetChar() != 2 || OnWarpAgree == null) return;

            short mapID = pkt.GetShort();
            WarpAnimation anim = (WarpAnimation)pkt.GetChar();

            int numOtherCharacters = pkt.GetChar();
            if (pkt.GetByte() != 255) return;

            List<CharacterData> otherCharacters = new List<CharacterData>(numOtherCharacters - 1);
            for (int i = 0; i < numOtherCharacters; ++i)
            {
                CharacterData newChar = new CharacterData(pkt);
                otherCharacters.Add(newChar);
                if (pkt.GetByte() != 255) return;
            }

            List<NPCData> otherNPCs = new List<NPCData>();
            while (pkt.PeekByte() != 255)
            {
                otherNPCs.Add(new NPCData(pkt));
            }
            if (pkt.GetByte() != 255) return;

            List<MapItem> otherItems = new List<MapItem>();
            while (pkt.ReadPos < pkt.Length)
            {
                otherItems.Add(new MapItem
                {
                    uid = pkt.GetShort(),
                    id = pkt.GetShort(),
                    x = pkt.GetChar(),
                    y = pkt.GetChar(),
                    amount = pkt.GetThree(),
                    //turn off drop protection for items coming into view - server will validate
                    time = DateTime.Now.AddSeconds(-5),
                    npcDrop = false,
                    playerID = -1
                });
            }

            OnWarpAgree(mapID, anim, otherCharacters, otherNPCs, otherItems);
        }
 private void _playerEnterMap(CharacterData data, WarpAnimation anim)
 {
     World.Instance.ActiveMapRenderer.AddOtherPlayer(data, anim);
 }
示例#5
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();
			}
		}
示例#6
0
        /// <summary>
        /// Used to apply changes from Welcome packet to existing character.
        /// </summary>
        /// <param name="newGuy">Changes to MainPlayer.ActiveCharacter, contained in a CharacterData object</param>
        /// <param name="copyPaperdoll">Set to true if paperdoll data from newGuy should be applied to this character</param>
        public void ApplyData(CharacterData newGuy, bool copyPaperdoll = true)
        {
            ID = newGuy.ID;
            Name = newGuy.Name;
            PaddedGuildTag = newGuy.GuildTag;
            if (copyPaperdoll)
            {
                //only set the doll graphic info in render data - don't change the paperdoll info!
                RenderData.SetBoots(newGuy.Boots);
                RenderData.SetArmor(newGuy.Armor);
                RenderData.SetHat(newGuy.Hat);
                RenderData.SetShield(newGuy.Shield);
                RenderData.SetWeapon(newGuy.Weapon);
            }
            Stats.SetHP(newGuy.HP);
            Stats.SetMaxHP(newGuy.MaxHP);
            Stats.SetTP(newGuy.TP);
            Stats.SetMaxTP(newGuy.MaxTP);

            RenderData.SetDirection(newGuy.Direction);
            RenderData.SetHairStyle(newGuy.HairStyle);
            RenderData.SetHairColor(newGuy.HairColor);
            RenderData.SetGender(newGuy.Gender);
            RenderData.SetRace(newGuy.Race);
            RenderData.SetSitting(newGuy.Sitting);
            RenderData.level = newGuy.Level;
            RenderData.SetWalkFrame(0);
            State = RenderData.sitting == SitState.Standing ? CharacterActionState.Standing : CharacterActionState.Sitting;
            CurrentMap = newGuy.Map;
            X = newGuy.X;
            Y = newGuy.Y;
            //GuildRankNum = newGuy.GuildRankNum; //todo: ???
        }
示例#7
0
        internal WelcomeMessageData(Packet pkt)
        {
            m_news = new List <string>();
            for (int i = 0; i < 9; ++i)
            {
                m_news.Add(pkt.GetBreakString());
            }

            Weight    = pkt.GetChar();
            MaxWeight = pkt.GetChar();

            m_inventory = new List <InventoryItem>();
            while (pkt.PeekByte() != 255)
            {
                m_inventory.Add(new InventoryItem {
                    id = pkt.GetShort(), amount = pkt.GetInt()
                });
            }
            pkt.GetByte();

            m_spells = new List <CharacterSpell>();
            while (pkt.PeekByte() != 255)
            {
                m_spells.Add(new CharacterSpell {
                    id = pkt.GetShort(), level = pkt.GetShort()
                });
            }
            pkt.GetByte();

            //Get data for other characters
            int numOtherCharacters = pkt.GetChar();

            m_characters = new List <CharacterData>(numOtherCharacters);
            if (pkt.GetByte() != 255)
            {
                throw new Exception();
            }
            for (int i = 0; i < numOtherCharacters; ++i)
            {
                CharacterData newGuy = new CharacterData(pkt);
                if (pkt.GetByte() != 255)
                {
                    throw new Exception();
                }

                m_characters.Add(newGuy);
            }

            //get data for any npcs
            m_npcs = new List <NPCData>();
            while (pkt.PeekByte() != 255)
            {
                NPCData newGuy = new NPCData(pkt);
                m_npcs.Add(newGuy);
            }
            pkt.GetByte();

            //get data for items on map
            m_items = new List <MapItem>();
            while (pkt.ReadPos < pkt.Length)
            {
                m_items.Add(new MapItem
                {
                    uid    = pkt.GetShort(),
                    id     = pkt.GetShort(),
                    x      = pkt.GetChar(),
                    y      = pkt.GetChar(),
                    amount = pkt.GetThree(),
                    //turn off drop protection for items coming into view - server will validate
                    time     = DateTime.Now.AddSeconds(-5),
                    npcDrop  = false,
                    playerID = -1
                });
            }
        }
示例#8
0
		internal WelcomeMessageData(Packet pkt)
		{
			m_news = new List<string>();
			for (int i = 0; i < 9; ++i)
			{
				m_news.Add(pkt.GetBreakString());
			}

			Weight = pkt.GetChar();
			MaxWeight = pkt.GetChar();

			m_inventory = new List<InventoryItem>();
			while (pkt.PeekByte() != 255)
				m_inventory.Add(new InventoryItem { id = pkt.GetShort(), amount = pkt.GetInt() });
			pkt.GetByte();

			m_spells = new List<CharacterSpell>();
			while (pkt.PeekByte() != 255)
				m_spells.Add(new CharacterSpell { id = pkt.GetShort(), level = pkt.GetShort() });
			pkt.GetByte();

			//Get data for other characters
			int numOtherCharacters = pkt.GetChar();
			m_characters = new List<CharacterData>(numOtherCharacters);
			if (pkt.GetByte() != 255) throw new Exception();
			for (int i = 0; i < numOtherCharacters; ++i)
			{
				CharacterData newGuy = new CharacterData(pkt);
				if (pkt.GetByte() != 255)
					throw new Exception();

				m_characters.Add(newGuy);
			}

			//get data for any npcs
			m_npcs = new List<NPCData>();
			while (pkt.PeekByte() != 255)
			{
				NPCData newGuy = new NPCData(pkt);
				m_npcs.Add(newGuy);
			}
			pkt.GetByte();

			//get data for items on map
			m_items = new List<MapItem>();
			while (pkt.ReadPos < pkt.Length)
			{
				m_items.Add(new MapItem
				{
					uid = pkt.GetShort(),
					id = pkt.GetShort(),
					x = pkt.GetChar(),
					y = pkt.GetChar(),
					amount = pkt.GetThree(),
					//turn off drop protection for items coming into view - server will validate
					time = DateTime.Now.AddSeconds(-5),
					npcDrop = false,
					playerID = -1
				});
			}
		}
示例#9
0
		public void AddOtherPlayer(CharacterData c, WarpAnimation anim = WarpAnimation.None)
		{
			CharacterRenderer otherRend = null;
			lock (_characterListLock)
			{
				Character other = _characterRenderers.Select(x => x.Character).FirstOrDefault(x => x.Name == c.Name && x.ID == c.ID);
				if (other == null)
				{
					other = new Character(_api, c);
					lock (_characterListLock)
					{
						_characterRenderers.Add(otherRend = new CharacterRenderer(other));
						_characterRenderers[_characterRenderers.Count - 1].Visible = true;
						_characterRenderers[_characterRenderers.Count - 1].Initialize();
					}
					other.RenderData.SetUpdate(true);
				}
				else
				{
					other.ApplyData(c);
				}
			}

			if (anim == WarpAnimation.Admin && otherRend != null)
				otherRend.ShowWarpArrive();
		}