예제 #1
0
        public override void Load(Terraria.ModLoader.IO.TagCompound tag)
        {
            if (!tag.ContainsKey("ModVersion"))
            {
                return;
            }
            int ModVersion = tag.GetInt("ModVersion");

            if (ModVersion < 1)
            {
                return;
            }
            int ClassCount = tag.GetInt("ClassCount");

            Classes.Clear();
            for (int c = 0; c < ClassCount; c++)
            {
                Classes.Add(new ClassData());
                Classes[c].Load(tag, c, ModVersion);
            }
            CombatSkill = LoadSkillSlot(tag, "CombatSkillSlot");
            for (int s = 0; s < 4; s++)
            {
                ActiveSkill[s] = LoadSkillSlot(tag, "ActiveSkillSlot_" + s);
            }
        }
예제 #2
0
        public void Load(Terraria.ModLoader.IO.TagCompound tag, int ModVersion, int UniqueID)
        {
            ID = tag.GetInt("GuardianID_" + UniqueID);
            if (ModVersion >= 35)
            {
                ModID = tag.GetString("GuardianModID_" + UniqueID);
            }
            else
            {
                ModID = MainMod.mod.Name;
            }
            if (ModVersion >= 19 && tag.ContainsKey("Name_" + UniqueID))
            {
                _Name = tag.GetString("Name_" + UniqueID);
                if (_Name == "")
                {
                    _Name = null;
                }
            }
            if (ModVersion >= 72)
            {
                PickedName = tag.GetByte("NameID_" + UniqueID);
                GuardianBase gb = Base;
                if (gb.PossibleNames.Length > 0 && PickedName > gb.PossibleNames.Length)
                {
                    PickedName = (byte)Main.rand.Next(gb.PossibleNames.Length);
                }
            }
            if (ModVersion >= 52)
            {
                IsStarter = tag.GetBool("StarterFlag_" + UniqueID);
            }
            if (ModVersion >= 7)
            {
                FriendshipLevel       = tag.GetByte("FriendshipLevel_" + UniqueID);
                FriendshipProgression = tag.GetByte("FriendshipProgress_" + UniqueID);
                TravellingStacker     = tag.GetFloat("TravellingStacker_" + UniqueID);
            }
            if (ModVersion >= 18)
            {
                DamageStacker = tag.GetFloat("DamageStacker_" + UniqueID);
            }
            if (ModVersion >= 25)
            {
                FoodStacker  = tag.GetByte("FoodStacker_" + UniqueID);
                DrinkStacker = tag.GetByte("DrinkStacker_" + UniqueID);
            }
            if (ModVersion >= 64)
            {
                ComfortStack  = tag.GetFloat("ComfortStack_" + UniqueID);
                ComfortPoints = tag.GetByte("ComfortPoints_" + UniqueID);
            }
            float HealthPercentage = -1;

            if (ModVersion >= 1)
            {
                HealthPercentage = tag.GetFloat("HealthPercentage_" + UniqueID);
                if (HealthPercentage >= 0)
                {
                    if (HealthPercentage <= 0)
                    {
                        HP = 1;
                    }
                    else
                    {
                        HP = (int)(MHP * HealthPercentage);
                    }
                }
            }
            if (ModVersion >= 58)
            {
                KnockedOut     = tag.GetBool("IsKnockedOut_" + UniqueID);
                KnockedOutCold = tag.GetBool("IsKnockedOutCold_" + UniqueID);
            }
            LifeCrystalHealth = (ModVersion < 42 ? (byte)tag.GetInt("LifeCrystals_" + UniqueID) : tag.GetByte("LifeCrystals_" + UniqueID));
            LifeFruitHealth   = (ModVersion < 42 ? (byte)tag.GetInt("LifeFruits_" + UniqueID) : tag.GetByte("LifeFruits_" + UniqueID));
            if (ModVersion >= 33)
            {
                Male = tag.GetBool("IsMale_" + UniqueID);
            }
            if (ModVersion >= 32 && ModVersion < 42)
            {
                tag.GetBool("ExtraAccessorySlot_" + UniqueID);
            }
            if (ModVersion >= 27)
            {
                ManaCrystals = (ModVersion < 42 ? (byte)tag.GetInt("ManaCrystals_" + UniqueID) : tag.GetByte("ManaCrystals_" + UniqueID));
            }
            if (ModVersion >= 5)
            {
                tactic = (CombatTactic)tag.GetByte("CombatTactic_" + UniqueID);
            }
            if (ModVersion >= 6)
            {
                Tanker = tag.GetBool("TankingFlag_" + UniqueID);
            }
            if (ModVersion >= 11)
            {
                OverrideQuickMountToMountGuardianInstead = tag.GetBool("QuickMountOverride_" + UniqueID);
            }
            if (ModVersion >= 12)
            {
                UseHeavyMeleeAttackWhenMounted = tag.GetBool("MountMeleeUsageToggle_" + UniqueID);
            }
            if (ModVersion >= 13)
            {
                AvoidCombat = tag.GetBool("AvoidCombat_" + UniqueID);
                ChargeAhead = tag.GetBool("ChargeAhead_" + UniqueID);
            }
            if (ModVersion >= 17)
            {
                Passive        = tag.GetBool("Passive_" + UniqueID);
                AttackMyTarget = tag.GetBool("AttackMyTarget_" + UniqueID);
            }
            if (ModVersion >= 21)
            {
                SitOnTheMount = tag.GetBool("SitOnMount_" + UniqueID);
            }
            if (ModVersion >= 26)
            {
                MayLootItems = tag.GetBool("MayLootItems_" + UniqueID);
            }
            if (ModVersion >= 28)
            {
                SetToPlayerSize = tag.GetBool("SetToPlayerSize_" + UniqueID);
            }
            if (ModVersion >= 31)
            {
                GetItemsISendtoTrash = tag.GetBool("GetItemsISendtoTrash_" + UniqueID);
            }
            if (ModVersion >= 41)
            {
                UseWeaponsByInventoryOrder = tag.GetBool("UseWeaponsByInventoryOrder" + UniqueID);
            }
            if (ModVersion >= 46)
            {
                ProtectMode = tag.GetBool("ProtectMode" + UniqueID);
            }
            if (ModVersion >= 49)
            {
                AutoSellWhenInvIsFull = tag.GetBool("AutoSell" + UniqueID);
            }
            if (ModVersion >= 65)
            {
                HideWereForm = tag.GetBool("HideWereForm" + UniqueID);
            }
            if (ModVersion >= 30)
            {
                GiftGiven = tag.GetBool("GiftGiven_" + UniqueID);
            }
            if (ModVersion >= 53)
            {
                for (int i = 0; i < 8; i++)
                {
                    MessageTriggerFlags[i] = tag.GetBool("MessageFlags" + i + "_" + UniqueID);
                    if (ModVersion < 78)
                    {
                        tag.GetBool("FriendLevelFlags" + i + "_" + UniqueID);
                    }
                }
            }
            int ContainerSize = tag.GetInt("InventorySize_" + UniqueID);

            for (int i = 0; i < ContainerSize; i++)
            {
                Item j = new Item();
                if (ModVersion < 2)
                {
                    j.SetDefaults(tag.GetInt("Inventory_" + i + "_Type_" + UniqueID), true);
                    j.stack  = tag.GetInt("Inventory_" + i + "_Stack_" + UniqueID);
                    j.prefix = tag.GetByte("Inventory_" + i + "_Prefix_" + UniqueID);
                }
                else
                {
                    bool ItemExists = true;
                    if (ModVersion >= 3)
                    {
                        ItemExists = tag.GetBool("Inventory_" + i + "_exists_" + UniqueID);
                    }
                    if (ItemExists)
                    {
                        j = tag.Get <Item>("Inventory_" + i + "_" + UniqueID);
                    }
                }
                if (i < Inventory.Length)
                {
                    Inventory[i] = j;
                }
            }
            ContainerSize = tag.GetInt("EquipmentsSize_" + UniqueID);
            for (int e = 0; e < ContainerSize; e++)
            {
                Item j = new Item();
                if (ModVersion < 4)
                {
                    j.SetDefaults(tag.GetInt("Equipment_" + e + "_Type_" + UniqueID), true);
                    j.stack  = tag.GetInt("Equipment_" + e + "_Stack_" + UniqueID);
                    j.prefix = tag.GetByte("Equipment_" + e + "_Prefix_" + UniqueID);
                }
                else
                {
                    if (tag.GetBool("Equipment_" + e + "_exists_" + UniqueID))
                    {
                        j = tag.Get <Item>("Equipment_" + e + "_" + UniqueID);
                    }
                }
                if (e < Equipments.Length)
                {
                    Equipments[e] = j;
                }
            }
            if (ModVersion >= 22)
            {
                int BuffCount = tag.GetInt("BuffCount_" + UniqueID);
                for (int b = 0; b < BuffCount; b++)
                {
                    int ID   = tag.GetInt("Buff_" + b + "_type_" + UniqueID),
                        Time = tag.GetInt("Buff_" + b + "_time_" + UniqueID);
                    if (Time > 0)
                    {
                        Buffs.Add(new BuffData(ID, Time));
                    }
                }
            }
            if (ModVersion >= 23)
            {
                int      SkillCount = tag.GetInt("SkillCount_" + UniqueID);
                string[] SkillNames = Enum.GetNames(typeof(GuardianSkills.SkillTypes));
                for (int s = 0; s < SkillCount; s++)
                {
                    string SkillType     = tag.GetString("SkillType_" + s + "_" + UniqueID);
                    int    SkillLevel    = tag.GetInt("SkillLevel_" + s + "_" + UniqueID);
                    float  SkillProgress = tag.GetFloat("SkillProgress_" + s + "_" + UniqueID);
                    for (int s2 = 0; s2 < SkillNames.Length; s2++)
                    {
                        if (SkillNames[s2] == SkillType)
                        {
                            SkillList[s2].Level    = SkillLevel;
                            SkillList[s2].Progress = SkillProgress;
                            break;
                        }
                    }
                }
            }
            if (ModVersion >= 29)
            {
                BodyDye.SetDefaults(tag.GetInt("BodyDye_" + UniqueID), true);
            }
            if (ModVersion >= 56)
            {
                Fatigue = (sbyte)tag.GetByte("FatigueCount_" + UniqueID);
                Injury  = (sbyte)tag.GetByte("InjuryCount_" + UniqueID);
            }

            /*if (ModVersion >= 61)
             * {
             *  request.Load(tag, ModVersion, UniqueID, this);
             * }*/
            if (ModVersion >= 101)
            {
                request.Load(tag, "Request_" + UniqueID, ModVersion);
            }
            //if (ModVersion >= 8)
            //    request.Load(tag, ModVersion, UniqueID);

            /*if (ModVersion < 95)
             * {
             *  if (ModVersion <= 80)
             *  {
             *      if (ModVersion >= 15)
             *          LifeTime = TimeSpan.FromSeconds(tag.GetDouble("ExistenceTime_" + UniqueID));
             *  }
             *  else
             *  {
             *      if (tag.GetBool("HasExistenceTime_" + UniqueID))
             *      {
             *          LifeTime = TimeSpan.FromSeconds(tag.GetDouble("ExistenceTime_" + UniqueID));
             *      }
             *  }
             * }*/
            if (ModVersion >= 66)
            {
                SkinID   = tag.GetByte("SkinID_" + UniqueID);
                OutfitID = tag.GetByte("OutfitID_" + UniqueID);
            }
            if (ModVersion >= 67)
            {
                _Coins = (uint)(tag.GetInt("Coins_" + UniqueID) + int.MaxValue);
            }
            if (ModVersion < 80)
            {
                ResetSkillsProgress();
            }
            if (ModVersion >= 83)
            {
                LoadCustom(tag, ModVersion, UniqueID);
            }
            if (ModVersion < 90)
            {
                GuardianCommonStatus status = GetCommonStatus;
                if (status.LifeCrystalsUsed < LifeCrystalHealth)
                {
                    status.LifeCrystalsUsed = LifeCrystalHealth;
                }
                if (status.LifeFruitsUsed < LifeFruitHealth)
                {
                    status.LifeFruitsUsed = LifeFruitHealth;
                }
                if (status.ManaCrystalsUsed < ManaCrystals)
                {
                    status.ManaCrystalsUsed = ManaCrystals;
                }
                foreach (GuardianSkills skill in status.SkillList)
                {
                    foreach (GuardianSkills other in SkillList)
                    {
                        if (skill.skillType == other.skillType && skill.Level < other.Level)
                        {
                            skill.Level    = other.Level;
                            skill.Progress = other.Progress;
                        }
                    }
                }
            }
        }