Beispiel #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);
            }
        }
Beispiel #2
0
        public SkillSlot LoadSkillSlot(Terraria.ModLoader.IO.TagCompound tag, string SkillSlotText)
        {
            SkillSlot ss = new SkillSlot();

            if (tag.GetBool(SkillSlotText + "_Exists"))
            {
                int    ClassID    = tag.GetInt(SkillSlotText + "_ClassID");
                string ClassModID = tag.GetString(SkillSlotText + "_ClassModID");
                int    SkillID    = tag.GetInt(SkillSlotText + "_SkillID");
                string SkillModID = tag.GetString(SkillSlotText + "_SkillModID");
                for (int c = 0; c < Classes.Count; c++)
                {
                    if (Classes[c].ClassID == ClassID && Classes[c].ClassModID == ClassModID)
                    {
                        for (int s = 0; s < Classes[c].Skills.Count; s++)
                        {
                            if (Classes[c].Skills[s].ID == SkillID && Classes[c].Skills[s].ModID == SkillModID)
                            {
                                ss.ClassPosition = c;
                                ss.SkillPosition = s;
                                break;
                            }
                        }
                    }
                }
            }
            return(ss);
        }
 public static void Load(Terraria.ModLoader.IO.TagCompound tag, int ModVersion)
 {
     SpawnedTombstone = tag.GetBool("TombstoneExists");
     TombstoneTileX   = tag.GetInt("TombstonePosX");
     TombstoneTileY   = tag.GetInt("TombstonePosY");
     AlexNPCPosition  = NPC.FindFirstNPC(ModContent.NPCType <Npcs.AlexNPC>());
 }
Beispiel #4
0
        public static void LoadQuest(string QuestKey, Terraria.ModLoader.IO.TagCompound Reader, int ModVersion, PlayerMod pm)
        {
            int       QuestID    = Reader.GetInt(QuestKey + "_ID");
            string    QuestModID = Reader.GetString(QuestKey + "_ModID");
            QuestData qd         = null;

            foreach (QuestData qd2 in pm.QuestDatas)
            {
                if (qd2.QuestID == QuestID && qd2.QuestModID == QuestModID)
                {
                    qd = qd2;
                    break;
                }
            }
            Terraria.ModLoader.IO.TagCompound QuestData = Reader.Get <Terraria.ModLoader.IO.TagCompound>(QuestKey + "_QuestData");
            if (qd == null)
            {
                qd                   = QuestContainer.GetQuestBase(QuestID, QuestModID).GetQuestData;
                qd.QuestID           = QuestID;
                qd.QuestModID        = QuestModID;
                qd.IsUnexistingQuest = true;
                qd.SavedQuestData    = QuestData;
                pm.QuestDatas.Add(qd);
            }
            else
            {
                qd.CustomLoadQuest(QuestKey, QuestData, ModVersion);
            }
        }
Beispiel #5
0
        public void Load(Terraria.ModLoader.IO.TagCompound tag, int ClassIndex, int ModVersion)
        {
            string ClassText  = "Class_" + ClassIndex;
            int    ClassID    = tag.GetInt(ClassText + "_ID");
            string ClassModID = tag.GetString(ClassText + "_ModID");

            ChangeClass(ClassID, ClassModID);
            Level = tag.GetInt(ClassText + "_Level");
            Exp   = tag.GetInt(ClassText + "_Exp");
            int SkillCount = tag.GetInt(ClassText + "_SkillCount");

            for (int s = 0; s < SkillCount; s++)
            {
                string SkillText  = ClassText + "_Skill_" + s;
                int    ID         = tag.GetInt(SkillText + "_ID");
                string ModID      = tag.GetString(SkillText + "_ModID");
                int    SkillLevel = tag.GetInt(SkillText + "_Level");
                int    Cooldown   = tag.GetInt(SkillText + "_Cooldown");
                foreach (SkillData sd in Skills)
                {
                    if (sd.ID == ID && sd.ModID == ModID)
                    {
                        sd.Level    = SkillLevel;
                        sd.Cooldown = Cooldown;
                        break;
                    }
                }
            }
        }
Beispiel #6
0
        public void Load(Terraria.ModLoader.IO.TagCompound tag)
        {
            int ModVersion = tag.GetInt("ModVersion");
            int LoreCount  = tag.GetInt("ObjectivesProgressCount");

            for (int i = 0; i < LoreCount; i++)
            {
                float Progress             = tag.GetFloat("ObjectivesProgressStep" + i);
                ClassLoreStepProgress clsp = new ClassLoreStepProgress();
                clsp.StepValue = Progress;
                if (i < LoreInternalProgress.Count)
                {
                    LoreInternalProgress[i] = clsp;
                }
                else
                {
                    LoreInternalProgress.Add(clsp);
                }
            }
        }
Beispiel #7
0
 public void Load(Terraria.ModLoader.IO.TagCompound writer, string UniqueID, int ModVersion)
 {
     RequestID         = writer.GetInt(UniqueID + "_ID");
     RequestModID      = writer.GetString(UniqueID + "_ModID");
     state             = (RequestState)writer.GetByte(UniqueID + "_State");
     ObjectiveCount    = writer.GetInt(UniqueID + "_ObjectiveCount");
     MaxObjectiveCount = writer.GetInt(UniqueID + "_MaxObjectiveCount");
     RequestTimeLeft   = writer.GetInt(UniqueID + "_TimeLeft");
     for (byte i = 0; i < 3; i++)
     {
         string            RewardID = UniqueID + "_rwi" + i;
         ThisRequestReward reward   = Rewards[i];
         reward.item  = writer.Get <Item>(RewardID + "_item");
         reward.value = writer.GetInt(RewardID + "_value");
     }
     if (state != RequestState.Cooldown)
     {
         Base = RequestContainer.GetRequest(RequestID, RequestModID);
     }
 }
        public static void LoadShops(Terraria.ModLoader.IO.TagCompound tag, int ModVersion)
        {
            int ShopCount = tag.GetInt("Shop_Count");

            for (int s = 0; s < ShopCount; s++)
            {
                string       ShopTag    = "Shop_s" + s + ">";
                int          OwnerID    = tag.GetInt(ShopTag + "OwnerID");
                string       OwnerModID = tag.GetString(ShopTag + "OwnerModID");
                GuardianBase gb         = GuardianBase.GetGuardianBase(OwnerID, OwnerModID);
                GuardianShop shop       = GetShop(OwnerID, OwnerModID);
                if (shop == null)
                {
                    gb.SetupShop(OwnerID, OwnerModID);
                    shop = GetShop(OwnerID, OwnerModID);
                }
                if (shop != null)
                {
                    int ItemCount = tag.GetInt(ShopTag + "ItemCount");
                    for (int i = 0; i < ItemCount; i++)
                    {
                        string ItemTag = ShopTag + "i" + i + ">";
                        if (tag.GetBool(ItemTag + "hasitem"))
                        {
                            bool   IsModItem = tag.GetBool(ItemTag + "ismoditem");
                            string ItemInternalName = null, ItemModInternalName = null;
                            int    ItemID = 0;
                            if (IsModItem)
                            {
                                ItemInternalName    = tag.GetString(ItemTag + "itemname");
                                ItemModInternalName = tag.GetString(ItemTag + "itemmodname");
                            }
                            else
                            {
                                ItemID = tag.GetInt(ItemTag + "itemid");
                            }
                            foreach (GuardianShopItem item in shop.Items)
                            {
                                if (item.ItemID == 0)
                                {
                                    continue;
                                }
                                if (ItemInternalName != null)
                                {
                                    Item anotheritem = new Item();
                                    anotheritem.SetDefaults(item.ItemID, true);
                                    if (anotheritem.modItem == null || anotheritem.modItem.Name != ItemInternalName || anotheritem.modItem.mod.Name != ItemModInternalName)
                                    {
                                        continue;
                                    }
                                }
                                else if (ItemID != item.ItemID)
                                {
                                    continue;
                                }
                                item.SaleTime      = tag.GetInt(ItemTag + "saletime");
                                item.TimedSaleTime = tag.GetInt(ItemTag + "timedsaletime");
                                item.Stack         = tag.GetInt(ItemTag + "stack");
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #9
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;
                        }
                    }
                }
            }
        }