Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Data = {} -- Holds all userdata stuff.
- Data.Ships = {} -- your ships!
- Data.Sector = function () -- Generates a table map of sectors!
- local Sectors = {}
- for x = -10, 10 do
- for y = -10, 10 do
- local Node = {}
- Node.X = x;
- Node.Y = y;
- Node.SectorName = tostring( "Sector "..Node.X..","..Node.Y);
- Node.Colonies = {};
- Node.MaxColonies = math.random(1, 5);
- Node.Armies = {};
- Sectors[#Sectors + 1] = Node
- end
- end
- return Sectors
- end
- Data.Profit = {0, 0}; -- [1] , min per cycle (30s) [2] is max per cycle. RATIO IS 10:0.3 (1 colony with 10 population produces 1 , 3
- Data.Balance = 10000e4;
- Data.tColonies = 0;
- Data.tShips = 0;
- math.randomseed(tick())
- local ScreenGui = script.Parent:WaitForChild("ScreenGui")
- local StatsBackDrop = ScreenGui:WaitForChild("StatsBD")
- local function ConvertIdToName (ID)
- local IDDICTIONARY = {
- [1] = "Bulldog MkI";
- [2] = "Bulldog MkII";
- [3] = "Bulldog MkIII";
- [4] = "Bulldog MkIIII";
- [5] = "Node MkI";
- [6] = "Node MkII";
- [7] = "Node MkIII";
- [8] = "Node MkIIII";
- [9] = "Harvester MkI";
- [10] = "Harvester MkII";
- [11] = "Harvester MkIII";
- [12] = "Cyrogem";
- }
- return IDDICTIONARY[ID] or "undefined"
- end
- local Ships = {
- --Bulldog
- ['Bulldog MkI'] = {
- ['Class'] = "Miner";
- ['Price'] = 10000;
- ['MiningPercent'] = 898; -- no bonus on rarer ores.
- ['CargoHold'] = 15000; -- holds 50 ores,
- ['Health'] = 20;
- ['Shields'] = 0;
- ['Attack'] = 0; -- Doesn't have defenses
- };
- ['Bulldog MkII'] = {
- ['Class'] = "Miner";
- ['Price'] = 23500 * 2.20;
- ['MiningPercent'] = 5; -- 15% bonus
- ['CargoHold'] = 16;
- ['Health'] = 45;
- ['Shields'] = 0;
- ['Attack'] = 0;
- };
- ['Bulldog MkIII'] = {
- ['Class'] = "Miner";
- ['Price'] = 800000 * 1.20;
- ['MiningPercent'] = 70; -- 25% bonus
- ['CargoHold'] = 19;
- ['Health'] = 80;
- ['Shields'] = 15; -- Regenerates 1 shield point every 7.5 seconds, 100 shields = 1 shield every second etc.
- ['Attack'] = 1; -- Defends its self
- };
- ['Bulldog MkIIII'] = {
- ['Class'] = "Miner";
- ['Price'] = 1234000;
- ['MiningPercent'] = 160; -- 60% bonus;
- ['CargoHold'] = 30;
- ['Health'] = 300;
- ['Shields'] = 40;
- ['Attack'] = 8;
- };
- --Node Fleet Assulters
- ['Node MkI'] = {
- ['Class'] = "Spawner_Fleet";
- ['MaxFleetSize'] = 5;
- ['Price'] = 4400000;
- ['FleetDamageEach'] = 2;
- ['FleetHealthEach'] = 10;
- ['FleetShieldEach'] = 50;
- ['Health'] = 100;
- ['Shields'] = 200;
- ['Attack'] = 20;
- };
- ['Node MkII'] = {
- ['Class'] = "Spawner_Fleet";
- ['MaxFleetSize'] = 8;
- ['Price'] = 736000000;
- ['FleetDamageEach'] = 5;
- ['FleetHealthEach'] = 25;
- ['FleetShieldEach'] = 75;
- ['Health'] = 175;
- ['Shields'] = 350;
- ['Attack'] = 35;
- };
- ['Node MkIII'] = {
- ['Class'] = "Spawner_Fleet";
- ['MaxFleetSize'] = 9;
- ['Price'] = 64500080000;
- ['FleetDamageEach'] = 8;
- ['FleetHealthEach'] = 45;
- ['FleetShieldEach'] = 115;
- ['Health'] = 250;
- ['Shields'] = 400;
- ['Attack'] = 70;
- };
- ['Node MkIIII'] = {
- ['Class'] = "Spawner_Fleet";
- ['MaxFleetSize'] = 9;
- ['Price'] = 1.5e12;
- ['FleetDamageEach'] = 8;
- ['FleetHealthEach'] = 64;
- ['FleetShieldEach'] = 128;
- ['Health'] = 320;
- ['Shields'] = 400;
- ['Attack'] = 80;
- };
- --Harvesters
- ['Harvester MkI'] = {
- ['Class'] = {"Miner", "Harvester"};
- ['CargoHold'] = 40;
- ['MiningPercent'] = 250; --150% bonus;
- ['IncomeGenerator'] = {"Percent", "Balance", "Single", 0.033}; -- provides 0.033% of current balance per each owned
- ['Price'] = 1e9;
- ['Health'] = 200;
- ['Shields'] = 100;
- ['Attack'] = 20;
- };
- ['Harvester MkII'] = {
- ['Class'] = {"Miner", "Harvester"};
- ['CargoHold'] = 50;
- ['MiningPercent'] = 300; --200% bonus;
- ['IncomeGenerator'] = {"Percent", "Balance", "Single", 0.099}; -- provides 0.099% of current balance per each owned
- ['Price'] = 1e11;
- ['Health'] = 800;
- ['Shields'] = 0;
- ['Attack'] = 35;
- };
- ['Harvester MkIII'] = {
- ['Class'] = {"Miner", "Harvester"};
- ['CargoHold'] = 60;
- ['MiningPercent'] = 450; --350% bonus;
- ['IncomeGenerator'] = {"Percent", "Balance", "Single", 0.217}; -- provides 0.217% of current balance per each owned
- ['Price'] = 1.9e12;
- ['Health'] = 1300;
- ['Shields'] = 900;
- ['Attack'] = 20;
- };
- ['Cyrogem'] = {
- ['Class'] = "Lander";
- ['Price'] = 100e3;
- ['Health'] = 25;
- ['Shields'] = 0;
- ['Attack'] = 0;
- };
- }
- --Core Functions--
- function Deduct (n)
- Data.Balance = Data.Balance - n;
- end
- function Increment (n)
- Data.Balance = Data.Balance + n;
- end
- function UpdateStatLabels ()
- local Stats = StatsBackDrop:WaitForChild("Stats")
- local Profit = Stats.Profit
- local Spice = Stats.Spice
- local TotalShips = Stats.TotalShips
- local TotalColonies = Stats.TotalColonies;
- Spice.Text = "Spice: "..tostring(Data.Balance);
- Profit.Text = "+ "..tostring(Data.Profit[1].. " -> "..Data.Profit[2].." cycle (30s)")
- end
- -- Intialize Sector Generation --
- Data.Sector = Data.Sector();
- ---------------------------------
- local CoreGui = game:GetService("StarterGui");
- UpdateStatLabels()
- function ColonizeSector (SectorCoords, UniqueLanderId)
- local function CheckIfUniqueIdClassIsLander ()
- for i,v in pairs (Data.Ships) do
- if v.UniqueId == UniqueLanderId then
- if v.ShipInformation.Class == "Lander" then
- MakeChatMessage("An error has occured; (this is a bug test)!", "System", Color3.fromRGB(255,255,255))
- return true;
- else
- MakeChatMessage("An error has occured (not read as 'LANDER'; (this is a bug test)!", "System", Color3.fromRGB(255,255,255))
- return false;
- end
- end
- end
- end
- if CheckIfUniqueIdClassIsLander() then
- MakeChatMessage("It went through!!", "System", Color3.fromRGB(255,255,255))
- local ColonyFormat = {
- Owner = game.Players.LocalPlayer;
- Population = 0;
- ConstructionSlots = {
- {-2, 2, Structure = nil;},{-1, 2, Structure = nil;}, {0, 2, Structure = nil;}, {1, 2, Structure = nil;}, {2, 2, Structure = nil;},
- {-2, 1, Structure = nil;},{-1, 1, Structure = nil;}, {0, 1, Structure = nil;}, {1, 1, Structure = nil;}, {2,1, Structure = nil;},
- {-2, 0, Structure = nil;},{-1, 0, Structure = nil;}, {0, 0, Structure = nil;}, {1, 0, Structure = nil;}, {2,0, Structure = nil;},
- {-2, -1, Structure = nil;},{-1, -1, Structure = nil;}, {0, -1, Structure = nil;}, {1, -1, Structure = nil;}, {2,-1, Structure = nil;},
- {-2, -2, Structure = nil;},{-1, -2, Structure = nil;}, {0, -2, Structure = nil;}, {1, -2, Structure = nil;}, {2,-2, Structure = nil;},
- };
- }
- print(type(Data.Sector))
- for i,v in pairs (Data.Sector) do
- if v.X == SectorCoords[1] and v.Y == SectorCoords[2] then
- if #v.Colonies >= v.MaxColonies then
- MakeChatMessage("That sector is already maxed out of available colonies!", "Warning");
- break;
- else
- v.Colonies[math.random(1, math.random(1000, 1000e4))] = ColonyFormat
- MakeChatMessage("A new colony is brought into the hands of your galactic empire!", "System", Color3.fromRGB(0,255,255))
- break;
- end
- MakeChatMessage("Current x:"..v.X.." y:"..v.Y, "System", Color3.fromRGB(255,255,255))
- end
- end
- end
- end
- function MakeChatMessage (ChatText, ChatType, CustomColor)
- local CustomColorEnabled = {false};
- if CustomColor ~= nil and type(CustomColor) == "Color3" then
- CustomColorEnabled[1] = true;
- end
- local ChatTypes = {
- ['nil'] = {Prefix = "", Color = Color3.fromRGB(255,255,255)};
- ['System'] = {Prefix = "[System]: ", Color = Color3.fromRGB(188,188,178)};
- ['Unsuccessful'] = {Prefix = "[Purchasing]: ", Color = Color3.fromRGB(255,90,90)};
- ['Successful'] = {Prefix = "[Purchasing]: ", Color = Color3.fromRGB(90, 255, 90)};
- ['Warn'] = {Prefix = "[WARNING]: ", Color = Color3.fromRGB(188,188, 0)};
- };
- local _CHATTYPE = ChatTypes[ChatType] or nil
- if _CHATTYPE == nil then
- _CHATTYPE = ChatTypes['nil'];
- end
- CoreGui:SetCore("ChatMakeSystemMessage", {
- Text = _CHATTYPE.Prefix..ChatText;
- Color = CustomColor or _CHATTYPE.Color;
- TextSize = 14;
- --Font = "SourceSansBold";
- TextFont = "SourceSansBold";
- -- just seeing if this is how its done
- })
- end
- local function GetPriceOfShip (ShipName)
- for index, ship in pairs (Ships) do
- if index == ShipName then
- print(index)
- local Price = ship.Price;
- if Price ~= nil then
- return Price;
- end
- end
- end
- end
- local function GetClassOfShip (ShipName)
- for index, ship in pairs (Ships) do
- print(index)
- if index == ShipName then
- local Class = ship.Class;
- if Class ~= nil then
- return Class;
- end
- end
- end
- end
- local function GetInfoOfShip (ShipName)
- for index, ship in pairs (Ships) do
- if index == ShipName then
- return ship
- end
- end
- return {};
- end
- local function GetActualShipFromUniqueId (UniqueId)
- for i,v in pairs (Data.Ships) do
- if v.UniqueId == UniqueId then
- return i, v;
- end
- end
- return nil
- end
- local function PurchaseShip (ShipName, numBuy)
- numBuy = tonumber(numBuy) or 1
- for i = 0, numBuy-1 do
- local Price = GetPriceOfShip(ShipName);
- local Class = GetClassOfShip(ShipName);
- print(Price)
- print(Class)
- if Price and Class and Data.Balance >= Price then
- Deduct(Price)
- UpdateStatLabels()
- MakeChatMessage(
- "You've successfully purchased an \""..ShipName.."\"! -"..tostring(Price).." spice!",
- "Successful")
- local NumberOfShips = function ()
- local num = 0;
- for i,v in pairs (Data.Ships) do
- if i:find(ShipName) then
- num = num + 1
- end
- end
- return num
- end
- ShipInformation = GetInfoOfShip(ShipName);
- Owner = game.Players.LocalPlayer.Name;
- local SimpleCount = NumberOfShips()
- local UniqueId=tostring(math.random(1256)..math.random(1256)..math.random(1256)..math.random(1256))
- print(UniqueId)
- print(ShipInformation.Class)
- Data.Ships[ShipName..SimpleCount] = {ShipInformation = ShipInformation, UniqueId = UniqueId, SectorHousing = {0, 0}};
- return Data.Ships[ShipName..SimpleCount];
- else
- MakeChatMessage(
- "Failed to purchase an \""..ShipName.."\ x"..numBuy-1 .."\"! -"..tostring(Price * (numBuy - i)).." spice!",
- "Unsuccessful")
- break
- end
- end
- end
- local function ListShips ()
- local List = {};
- for index, ship in pairs (Data.Ships) do
- table.insert(List, ship)
- print(index.." UNIQUE ID:"..ship.UniqueId)
- end
- return List;
- end
- function MineAll ()
- local Ships = ListShips()
- local Ores = {"Stone", "Coal", "Iron", "Silver", "Copper", "Sulphur", "Iridium", "Diamond", "Oynx", "Ruby", "Sapphire", "Platinum", "Gold", "Ashley'sPussy'"};
- local Values = {math.random(1, 95)/2, math.random(1, 190)/2, math.random(1, 380)/2, math.random(1, 760)/2, math.random(1, 1520)/2, math.random(1, 3040)/2, math.random(6080)/2, math.random(12160)/2, math.random(24320)/2, math.random(48640)/2, math.random(97280)/2, math.random(194560)/2, math.random(194560 * 2)/2, math.random(194560*4/2)};
- local Chances = {12000, 300, 300, 300, 125, 75, 50, 50, 35, 35, 35, 25, 25, 15};
- local ValueGain = 0;
- local OresFound = {}
- local CargoHold = 0;
- MakeChatMessage("All Mining ships were launched to collect ores, waiting for their return!\nCommands temporarily disabled!", "System", Color3.fromRGB(255,255,0));
- for i,v in pairs (Ships) do
- wait()
- if type(v.ShipInformation.Class) == "string" or type(v.ShipInformation.Class) == "table" then
- local Classes = function ()
- if type(v.ShipInformation.Class) == "string" then
- return v.ShipInformation.Class else return v.ShipInformation.Class[1], v.ShipInformation.Class[2]
- end
- end
- local Class1, Class2 = Classes();
- if Class1:find("Miner") or Class2 ~= nil and Class2:find("Harvester") then
- -- Don't worry about class 2 for now
- CargoHold = CargoHold + v.ShipInformation['CargoHold'];
- for cargo = 0, v.ShipInformation.CargoHold/2 do
- local OREFOUND = nil;
- repeat
- local OreToFind = math.random(1, #Ores)
- local Chance = Chances[OreToFind]
- if math.random(0, 15000 - (v.ShipInformation.MiningPercent*10)) <= Chance then
- OREFOUND = OreToFind
- end
- until OREFOUND ~= nil
- print(OREFOUND)
- table.insert(OresFound, Ores[OREFOUND]);
- --ValueGain = ValueGain + Values[OREFOUND];
- Increment(Values[OREFOUND]);
- end
- end
- end
- UpdateStatLabels()
- end
- --Increment(math.ceil(ValueGain))
- MakeChatMessage("All Mining ships have returned and sold ores! Earned "..math.ceil(ValueGain).." spice!", "System", Color3.fromRGB(255,255,0));
- end
- local function MoveCommand (UniqueId, NewSector)
- for i,v in pairs (Data.Ships) do
- if v.UniqueId == UniqueId then
- if NewSector ~= nil then
- if type(NewSector) == 'table' then
- if #NewSector == 2 then
- MakeChatMessage("Ship with UniqueId: \""..UniqueId.."\" is moving to Sector "..NewSector[1]..", "..NewSector[2], "System")
- local x = NewSector[1];
- local y = NewSector[2];
- local function DesignatedTime (x, y, ox, oy)
- return ((x / y) ^ (ox / oy)) * 7
- end
- local Time = DesignatedTime(x, y, v.SectorHousing[1], v.SectorHousing[2])
- local ConsumedTime = 0
- print(Time)
- repeat wait(0.1) ConsumedTime = ConsumedTime + 0.1 until ConsumedTime >= Time
- print("Consumed Enough Time command done")
- v.SectorHousing[1] = x;
- v.SectorHousing[2] = y;
- end
- end
- end
- break;
- end
- end
- end
- function DestructShip (UniqueId)
- for i,v in pairs (Data.Ships) do
- if v.UniqueId == UniqueId then
- v = nil
- end
- end
- end
- function ShipBattle (Ship1, Ship2)
- local Name, MyShip = GetActualShipFromUniqueId(Ship1)
- local EnemyShip = Ship2;
- if MyShip ~= nil then
- MakeChatMessage("Your ship \""..Name.."\" is under attack!", "Warning");
- local DoneFighting = false;
- local function DetermineWhoAttacksFirst ()
- return math.random(2);
- end
- local Result = DetermineWhoAttacksFirst()
- local function CheckForWinner(Health1, Health2)
- print(Health1.." 1".." "..Health2.." 2")
- if Health1 <= 0 then
- return false;
- elseif Health2 <= 0 then
- return true;
- end
- return nil
- end
- local function afterBattle ()
- --spawn(function()
- repeat wait(3)
- local WhoAttacks = math.random(2)
- if WhoAttacks == 1 then
- EnemyShip.Health = EnemyShip.Health - MyShip.ShipInformation.Attack
- MakeChatMessage("Your ship strikes the enemy dealing "..MyShip.ShipInformation.Attack.." DMG!", "System")
- else
- MyShip.ShipInformation.Health = MyShip.ShipInformation.Health - EnemyShip.Attack
- MakeChatMessage("Your ship takes a hit from the enemy strike, taking "..EnemyShip.Attack.." DMG!", "System")
- end
- until CheckForWinner(MyShip.ShipInformation.Health, EnemyShip.Health) ~= nil
- if CheckForWinner(MyShip.ShipInformation.Health, EnemyShip.Health) == true then
- MakeChatMessage("You've won the battle and recieved cargo! (FUTURE NOT ACTUALLY REWARDED", "System");
- else
- MakeChatMessage("You've lost your ship in the battle, it explodes and a manly tear drops.", "Warning");
- DestructShip(MyShip.UniqueId);
- end
- --end)
- end
- if Result == 1 then
- MakeChatMessage("Your ship attacks first!", "System");
- EnemyShip.Health = EnemyShip.Health - MyShip.ShipInformation.Attack
- if CheckForWinner(MyShip.ShipInformation.Health, EnemyShip.Health) == nil then
- afterBattle ()
- end
- else
- MakeChatMessage("Your ship attacks second!", "System");
- MyShip.ShipInformation.Health = MyShip.ShipInformation.Health - EnemyShip.Attack
- if CheckForWinner(MyShip.ShipInformation.Health, EnemyShip.Health) == nil then
- afterBattle ()
- end
- end
- end
- end
- MineAll()
- --Cycle--
- local Action = false;
- game.Players.LocalPlayer.Chatted:Connect(function(Message)
- print(Message)
- if Action then
- MakeChatMessage("You or your ships are currently performing an action!", 'Warning');
- return
- end
- if Message:find("$") then
- if Message:lower() == "mine all" then
- Action = true;
- MineAll()
- end
- if Message:sub(2, 4) == "buy" then
- local ship = ConvertIdToName(tonumber(Message:sub(5, Message:find(";")-1 or Message:len())))
- local numBuy = tonumber(Message:sub(Message:find(";") + 1 or Message:len()));
- if ship == "undefined" then
- MakeChatMessage(Message:sub(4, Message:find(";") or Message:len()).." isn't an valid id!", "Warning");
- else
- if numBuy and type(numBuy) == 'number' and numBuy > 1 then
- PurchaseShip(ship, numBuy)
- else
- PurchaseShip(ship, 1)
- end
- end
- end
- end
- Action = false;
- end)
- local TestLander = PurchaseShip("Cyrogem", 1);
- local TestId = TestLander.UniqueId
- --print(TestId)
- ColonizeSector({0, 0}, TestId)
- TestLander = PurchaseShip("Cyrogem", 1);
- TestId = TestLander.UniqueId
- ColonizeSector({0, -2}, TestId)
- while wait(10) do
- Increment(math.random(Data.Profit[1], Data.Profit[2]))
- local function SetMinProfit ()
- local MinProfit = 0;
- for index,sector in pairs (Data.Sector) do
- for _index, colony in pairs (sector.Colonies) do
- if colony.Owner == game.Players.LocalPlayer then
- local Population = colony.Population
- MinProfit = MinProfit + math.ceil(Population / 10);
- end
- end
- end
- Data.Profit[1] = MinProfit;
- end
- local function SetMaxProfit ()
- local MaxProfit = 0;
- for index,sector in pairs (Data.Sector) do
- for _index, colony in pairs (sector.Colonies) do
- if colony.Owner == game.Players.LocalPlayer then
- local Population = colony.Population
- MaxProfit = MaxProfit + math.ceil(Population / 3);
- end
- end
- end
- Data.Profit[2] = MaxProfit;
- end
- for _, sector in pairs (Data.Sector) do
- for _i, colony in pairs (sector.Colonies) do
- if colony.Owner == game.Players.LocalPlayer then
- local Population = colony.Population
- local IncreasePopulationOfKidsFromGirlsPussies = math.random(1, 25) + math.floor(
- Population / 100
- ) * 5 + math.floor (
- Population / 1000
- ) * 20
- colony.Population = colony.Population + IncreasePopulationOfKidsFromGirlsPussies;
- end
- end
- end
- SetMinProfit()
- SetMaxProfit()
- --ShipBattle(ListShips()[1].UniqueId, {Health = 100; Attack = 50;})
- UpdateStatLabels()
- end
- --MoveCommand(ListShips()[1].UniqueId, {20, 20})
- --MoveCommand(ListShips()[2].UniqueId, {20, 20})
- --[[
- MakeChatMessage("Example of NIL", nil, nil);
- MakeChatMessage("Example of WARN", "Warn", nil);
- MakeChatMessage("Example of PURCHASE-Unsuccessful", "Unsuccessful", nil);
- MakeChatMessage("Example of PURCHASE-successful", "Successful", nil);
- MakeChatMessage("Example of System", "System", nil)
- ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement