Exemplo n.º 1
0
        private void ModifyFreighterSeed(ModifyOptions opt, dynamic json)
        {
            ulong?seed = null;

            if (opt.SetFreighterSeed != null)
            {
                try
                {
                    seed = ParseUlongOption(opt.SetFreighterSeed);
                }
                catch (Exception x)
                {
                    throw new ArgumentException(string.Format("Invalid value for option {0}: {1}", "--modify-freighter-seed", opt.SetFreighterSeed), x);
                }
            }
            else if (opt.RandomizeFreighterSeed)
            {
                byte[] randBytes = new byte[8];
                _random.NextBytes(randBytes);
                seed = BitConverter.ToUInt64(randBytes, 0);
            }

            if (seed != null)
            {
                string seedStr = string.Format("0x{0:X16}", seed);
                LogVerbose("Setting freightert seed to: {0}", seedStr);
                json.PlayerStateData.CurrentFreighter.Seed[1] = seedStr;
            }
        }
Exemplo n.º 2
0
        private void ModifyShipSeed(ModifyOptions opt, dynamic json)
        {
            ulong?seed = null;

            if (opt.SetShipSeed != null)
            {
                try
                {
                    seed = ParseUlongOption(opt.SetShipSeed);
                }
                catch (Exception x)
                {
                    throw new ArgumentException(string.Format("Invalid value for option {0}: {1}", "--set-ship-seed", opt.SetShipSeed), x);
                }
            }
            else if (opt.RandomizeShipSeed)
            {
                byte[] randBytes = new byte[8];
                _random.NextBytes(randBytes);
                seed = BitConverter.ToUInt64(randBytes, 0);
            }

            if (seed != null)
            {
                string seedStr = string.Format("0x{0:X16}", seed);
                LogVerbose("Setting ship seed to: {0}", seedStr);
                PrimaryShipNode(json).Resource.Seed[1] = seedStr;
            }
        }
Exemplo n.º 3
0
        private void ModifyShipSlots(ModifyOptions opt, dynamic json)
        {
            if (opt.TechGroups.Contains(TechGrp.ship))
            {
                LogVerbose("Updating Ship");
                if (opt.Energy || opt.Everything)
                {
                    json.PlayerStateData.ShipHealth = 8;
                    json.PlayerStateData.ShipShield = 200;
                }

                foreach (var slot in PrimaryShipInventoryNode(json).Slots)
                {
                    if (opt.Repair || opt.Everything)
                    {
                        slot.DamageFactor = 0.0f;
                    }

                    if ((opt.Energy || opt.Everything) && slot.Type.InventoryType == "Technology" && _refillableTech.Contains(slot.Id.Value))
                    {
                        slot.Amount = slot.MaxAmount;
                    }

                    if ((opt.Inventory || opt.Everything) && (slot.Type.InventoryType == "Product" || slot.Type.InventoryType == "Substance"))
                    {
                        slot.Amount = slot.MaxAmount;
                    }
                }
            }
        }
Exemplo n.º 4
0
        private bool RunModify(ModifyOptions opt)
        {
            try
            {
                DoCommon(opt);

                GameSaveDir gsd;
                try
                {
                    gsd = new GameSaveDir(opt.SaveDir);
                }
                catch (Exception x)
                {
                    LogError("Error locating game save file:\n{0}", x.Message);
                    return(false);
                }

                dynamic json;
                try
                {
                    json = ReadLatestSaveFile(gsd, opt.GameMode);
                }
                catch (Exception x)
                {
                    Console.WriteLine("Error loading or parsing save file: {0}", x.Message);
                    return(false);
                }

                // Now iterate through JSON, maxing out technology, Substance, and Product values in Inventory, ShipInventory, and FreighterInventory

                ModifyExosuitSlots(opt, json);
                ModifyMultitoolSlots(opt, json);
                ModifyShipSlots(opt, json);
                ModifyFreighterSlots(opt, json);
                ModifyShipSeed(opt, json);
                ModifyMultitoolSeed(opt, json);
                ModifyFreighterSeed(opt, json);

                BackupSave(gsd, opt);

                try
                {
                    WriteLatestSaveFile(gsd, opt.GameMode, json, opt.UseOldFormat);
                }
                catch (Exception x)
                {
                    throw new Exception(string.Format("Error storing save file: {0}", x.Message), x);
                }
            }
            catch (Exception x)
            {
                LogError(x.Message);
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
 private void ModifyFreighterSlots(ModifyOptions opt, dynamic json)
 {
     if (opt.TechGroups.Contains(TechGrp.freighter))
     {
         LogVerbose("Updating Freighter");
         foreach (var slot in FreighterInventoryNode(json).Slots)
         {
             if ((opt.Inventory || opt.Everything) &&
                 // Leave this next line in as protection against future version of NMS allowing other things in Freighter
                 (slot.Type.InventoryType == "Product" || slot.Type.InventoryType == "Substance")
                 )
             {
                 slot.Amount = slot.MaxAmount;
             }
         }
     }
 }
Exemplo n.º 6
0
        private void ModifyMultitoolSlots(ModifyOptions opt, dynamic json)
        {
            if (opt.TechGroups.Contains(TechGrp.multitool))
            {
                LogVerbose("Updating Multitool");
                foreach (var slot in WeaponInventoryNode(json).Slots)
                {
                    if (opt.Repair || opt.Everything)
                    {
                        slot.DamageFactor = 0.0f;
                    }

                    if ((opt.Energy || opt.Everything) && _refillableTech.Contains(slot.Id.Value))
                    {
                        slot.Amount = slot.MaxAmount;
                    }
                }
            }
        }