示例#1
0
        public OldCharacter()
        {
            //mock all members with non-null fields
            //PacketAPI cannot be mocked...
            Inventory = new List <InventoryItem>();
            Spells    = new List <InventorySpell>();
            PaperDoll = new short[(int)EquipLocation.PAPERDOLL_MAX];

            Stats      = new CharStatData();
            RenderData = new CharRenderData();

            Name = PaddedGuildTag = GuildName = GuildRankStr = "";
        }
示例#2
0
        //constructs a character from a packet sent from the server
        public OldCharacter(PacketAPI api, CharacterData data)
        {
            //initialize lists
            m_packetAPI = api;

            Inventory = new List <InventoryItem>();
            Spells    = new List <InventorySpell>();
            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);
        }
        private void _useItem(ItemUseData data)
        {
            OldWorld.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:
            {
                OldWorld.Instance.MainPlayer.ActiveCharacter.Stats.HP = data.HP;
                OldWorld.Instance.MainPlayer.ActiveCharacter.Stats.TP = data.TP;

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

                if (data.HPGain > 0)
                {
                    OldWorld.Instance.ActiveCharacterRenderer.SetDamageCounterValue(data.HPGain, percent, true);
                }
                m_game.Hud.RefreshStats();
            }
            break;

            case ItemType.HairDye:
            {
                OldWorld.Instance.MainPlayer.ActiveCharacter.RenderData.SetHairColor(data.HairColor);
            }
            break;

            case ItemType.Beer:
                OldWorld.Instance.ActiveCharacterRenderer.MakeDrunk();
                m_game.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_ITEM_USE_DRUNK);
                break;

            case ItemType.EffectPotion:     //todo: effect potions for other players
                OldWorld.Instance.ActiveCharacterRenderer.ShowPotionAnimation(data.EffectID);
                break;

            case ItemType.CureCurse:
            {
                //actually remove the item(s) from the main character
                OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter;
                for (int i = 0; i < (int)EquipLocation.PAPERDOLL_MAX; ++i)
                {
                    int nextID = c.PaperDoll[i];
                    if (nextID > 0 && OldWorld.Instance.EIF[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 = OldWorld.Instance.MainPlayer.ActiveCharacter.Stats;
                if (s.Level < data.RewardStats.Level)
                {
                    //level up!
                    OldWorld.Instance.MainPlayer.ActiveCharacter.Emote(Emote.LevelUp);
                    OldWorld.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;
            }
        }