Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- THE SPACE TOY!!!
- Based on: Spacewars 1.0.0! Simlulate space in space.
- Script Version: beta v0.6
- ####################
- CHANGES:
- -- Added fighter lvl 2, with void ray (sadly same as laser) and stealth tech
- -- Added bomber lvl 2, with chemical weapon, also with stealth
- -- Added kamikaze ship, explodes when near enemy ships
- -- Added decrafter, a ship that tries to assimilate, but mostly destroys the obliterators
- -- Added deserted planet, also possible when changing planet's tmp to 1
- -- Added split fighter, tier 2 spacecraft, splits into 4 fighters when destroyed
- -- Added terraform ships, transform harsh terrain into their terrain
- -- No more opening settings menu! Just press the S button below the console button
- -- Technology! Press M to see research progress
- -- Messages about building obliterators and labs
- -- Statistics! Press T to see totals
- -- Fixed a misspell in the research (reserarch)
- PLANNED:
- -- Electromagnetic Pulse Area
- -- The Plague
- -- Split Bombers
- ]]--
- sim.gravityMode(1);
- sim.airMode(3);
- sim.edgeMode(2);
- local function settings(mousex, mousey, button, event)
- tpt.drawrect(613, 97, 14, 14, 204, 204, 204)
- tpt.fillrect(613, 97, 14, 14, 0, 0, 0, 255)
- tpt.drawtext(618, 101, "S", 255, 255, 255, 255)
- if tpt.mousex >= 613 and tpt.mousey >= 97 and tpt.mousex <= 627 and tpt.mousey <= 111 then
- tpt.drawtext(499, 101, "Space Simulation, yay!", 0, 0, 255, 255)
- tpt.drawrect(613, 97, 14, 14, 255, 255, 255)
- end
- if tpt.mousex >= 613 and tpt.mousey >= 97 and tpt.mousex <= 627 and tpt.mousey <= 111 then
- if event == 1 then
- sim.gravityMode(1);
- sim.airMode(3);
- sim.edgeMode(2);
- end
- end
- end
- tpt.register_mouseclick(settings)
- tpt.register_step(settings)
- --Totals
- totallabs = 0
- totaldest = 0
- totalstolen = 0
- totalexpl = 0
- totalshipdest = 0
- --Elements
- local continent;
- local ocean;
- local planet;
- local dplanet;
- local desert;
- local rock;
- local lasr;
- local city;
- local explosion;
- local missile;
- local ship;
- local bomber;
- local mothership;
- local builder;
- local decrafter;
- local nukeMissile;
- local kamikaze;
- local terraformer;
- local facility;
- --Settings
- local explosionSpread = 0.5;
- local fighterLife = 1;
- local mothershipLife = 10;
- local destroyerLife = 20;
- local rTech = 0;
- local gTech = 0;
- local bTech = 0;
- local gdTech = 0;
- local wTech = 0;
- local gyTech = 0;
- local obliterators = 0;
- local splits = 0;
- local splitcreator;
- local function keepInPercent()
- if rTech > 20 then
- rTech = rTech - 1
- elseif gTech > 20 then
- gTech = gTech - 1
- elseif bTech > 20 then
- bTech = bTech - 1
- elseif gdTech > 20 then
- gdTech = gdTech - 1
- elseif wTech > 20 then
- wTech = wTech - 1
- elseif gyTech > 20 then
- gyTech = gyTech - 1
- end;
- end
- tpt.register_step(keepInPercent)
- local function getFraction(tmp, big)
- -- Not for simulation, just for help
- if big == 1 then
- if tmp == 0 then
- return "Red"
- elseif tmp == 1 then
- return "Green"
- elseif tmp == 2 then
- return "Blue"
- elseif tmp == 3 then
- return "Golden"
- elseif tmp == 4 then
- return "White"
- elseif tmp == 5 then
- return "Gray"
- end
- elseif big == 0 then
- if tmp == 0 then
- return "red"
- elseif tmp == 1 then
- return "green"
- elseif tmp == 2 then
- return "blue"
- elseif tmp == 3 then
- return "golden"
- elseif tmp == 4 then
- return "white"
- elseif tmp == 5 then
- return "gray"
- end
- end
- end
- local R = 0
- local G = 0
- local B = 0
- local GD = 0
- local W = 0
- local GY = 0
- local function inform()
- if rTech == 20 and R == 0 then
- print("Red: Technology tier 2 acquired!");
- R = 1
- elseif gTech == 20 and G == 0 then
- print("Green: Technology tier 2 acquired!");
- G = 1
- elseif bTech == 20 and B == 0 then
- print("Blue: Technology tier 2 acquired!");
- B = 1
- elseif gdTech == 20 and GD == 0 then
- print("Golden: Technology tier 2 acquired!");
- GD = 1
- elseif wTech == 20 and W == 0 then
- print("White: Technology tier 2 acquired!");
- W = 1
- elseif gyTech == 20 and GY == 0 then
- print("Gray: Technology tier 2 acquired!");
- GY = 1
- end;
- if rTech >= 10 and gTech >= 10 and bTech >= 10 and gdTech >= 10 and wTech >= 10 and gyTech >= 10 and obliterators == 0 then
- print('WARNING: Obliterator cannon deployment has begun!');
- obliterators = 1
- end
- end
- tpt.register_step(inform)
- --Desert
- desert = elements.allocate("JosephMA", "DSRT");
- elements.element(desert, elements.element(elements.DEFAULT_PT_SAND));
- elements.property(desert, "HighTemperature", 673.15);
- elements.property(desert, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA);
- elements.property(desert, "Name", "DSRT");
- elements.property(desert, "Description", "Deserts, barren sandy lands.");
- elements.property(desert, "MenuSection", 15);
- --Rock
- rock = elements.allocate("JosephMA", "ROCK");
- elements.element(rock, elements.element(elements.DEFAULT_PT_BRCK));
- elements.property(rock, "HighTemperature", 873.15);
- elements.property(rock, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA);
- elements.property(rock, "Name", "ROCK");
- elements.property(rock, "Description", "Rocks, stony and rocky.");
- elements.property(rock, "MenuSection", 15);
- --City
- city = elements.allocate("JosephMA", "CITY");
- elements.element(city, elements.element(elements.DEFAULT_PT_BRCK));
- elements.property(city, "Color", 0xFF505070);
- elements.property(city, "HighTemperature", 873.15);
- elements.property(city, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(city, "Name", "CITY");
- elements.property(city, "Description", "A city. People live here.");
- elements.property(city, "MenuSection", 15);
- local function cityUpdate(i, x, y, s, n)
- if sim.partProperty(i, "tmp2") == 0 then
- sim.partProperty(i, "tmp", math.random(0, 5));
- sim.partProperty(i, "tmp2", 1);
- end
- if math.random(1, 500) == 1 then
- local part;
- if math.random(1, 1000) == 1 then
- if sim.partProperty(i, "tmp") == 0 and rTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), destroyer)
- print("Red: Released a destroyer spaceship!")
- totaldest = totaldest + 1
- elseif sim.partProperty(i, "tmp") == 1 and gTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), destroyer)
- print("Green: Released a destroyer spaceship!")
- totaldest = totaldest + 1
- elseif sim.partProperty(i, "tmp") == 2 and bTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), destroyer)
- print("Blue: Released a destroyer spaceship!")
- totaldest = totaldest + 1
- elseif sim.partProperty(i, "tmp") == 3 and gdTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), destroyer)
- print("Golden: Released a destroyer spaceship!")
- totaldest = totaldest + 1
- elseif sim.partProperty(i, "tmp") == 4 and wTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), destroyer)
- print("White: Released a destroyer spaceship!")
- totaldest = totaldest + 1
- elseif sim.partProperty(i, "tmp") == 5 and gyTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), destroyer)
- print("Gray: Released a destroyer spaceship!")
- totaldest = totaldest + 1
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), elem.DEFAULT_PT_NONE)
- end
- elseif math.random(1, 200) == 1 then
- if sim.partProperty(i, "tmp") == 0 and rTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), mothership)
- elseif sim.partProperty(i, "tmp") == 1 and gTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), mothership)
- elseif sim.partProperty(i, "tmp") == 2 and bTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), mothership)
- elseif sim.partProperty(i, "tmp") == 3 and gdTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), mothership)
- elseif sim.partProperty(i, "tmp") == 4 and wTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), mothership)
- elseif sim.partProperty(i, "tmp") == 5 and gyTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), mothership)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), elem.DEFAULT_PT_NONE)
- end
- elseif math.random(1, 200) == 1 then
- if sim.partProperty(i, "tmp") == 0 and rTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), terraformer)
- elseif sim.partProperty(i, "tmp") == 1 and gTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), terraformer)
- elseif sim.partProperty(i, "tmp") == 2 and bTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), terraformer)
- elseif sim.partProperty(i, "tmp") == 3 and gdTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), terraformer)
- elseif sim.partProperty(i, "tmp") == 4 and wTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), terraformer)
- elseif sim.partProperty(i, "tmp") == 5 and gyTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), terraformer)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), elem.DEFAULT_PT_NONE)
- end
- elseif math.random(1, 2) == 1 then
- local rand2 = math.random(1, 2)
- if sim.partProperty(i, "tmp") == 0 and rTech == 20 then
- if rand2 == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), ship2)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), splitship)
- end
- elseif sim.partProperty(i, "tmp") == 1 and gTech == 20 then
- if rand2 == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), ship2)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), splitship)
- end
- elseif sim.partProperty(i, "tmp") == 2 and bTech == 20 then
- if rand2 == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), ship2)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), splitship)
- end
- elseif sim.partProperty(i, "tmp") == 3 and gdTech == 20 then
- if rand2 == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), ship2)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), splitship)
- end
- elseif sim.partProperty(i, "tmp") == 4 and wTech == 20 then
- if rand2 == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), ship2)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), splitship)
- end
- elseif sim.partProperty(i, "tmp") == 5 and gyTech == 20 then
- if rand2 == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), ship2)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), splitship)
- end
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), ship)
- end
- elseif math.random(1, 2) == 1 then
- if sim.partProperty(i, "tmp") == 0 and rTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), bomber2)
- elseif sim.partProperty(i, "tmp") == 1 and gTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), bomber2)
- elseif sim.partProperty(i, "tmp") == 2 and bTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), bomber2)
- elseif sim.partProperty(i, "tmp") == 3 and gdTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), bomber2)
- elseif sim.partProperty(i, "tmp") == 4 and wTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), bomber2)
- elseif sim.partProperty(i, "tmp") == 5 and gyTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), bomber2)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), bomber)
- end
- elseif math.random(1, 2) == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), kamikaze);
- elseif math.random(1, 100) == 1 then
- if sim.partProperty(i, "tmp") == 0 and rTech == 20 and obliterators == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), decrafter)
- elseif sim.partProperty(i, "tmp") == 1 and gTech == 20 and obliterators == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), decrafter)
- elseif sim.partProperty(i, "tmp") == 2 and bTech == 20 and obliterators == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), decrafter)
- elseif sim.partProperty(i, "tmp") == 3 and gdTech == 20 and obliterators == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), decrafter)
- elseif sim.partProperty(i, "tmp") == 4 and wTech == 20 and obliterators == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), decrafter)
- elseif sim.partProperty(i, "tmp") == 5 and gyTech == 20 and obliterators == 1 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), decrafter)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), elem.DEFAULT_PT_NONE)
- end
- else
- if sim.partProperty(i, "tmp") == 0 and rTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), builder2)
- elseif sim.partProperty(i, "tmp") == 1 and gTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), builder2)
- elseif sim.partProperty(i, "tmp") == 2 and bTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), builder2)
- elseif sim.partProperty(i, "tmp") == 3 and gdTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), builder2)
- elseif sim.partProperty(i, "tmp") == 4 and wTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), builder2)
- elseif sim.partProperty(i, "tmp") == 5 and gyTech == 20 then
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), builder2)
- else
- part = sim.partCreate(-1, x + math.random(-25, 25), y + math.random(-25, 25), builder)
- end
- end;
- sim.partProperty(part, "tmp", sim.partProperty(i, "tmp"));
- end
- end
- elements.property(city, "Update", cityUpdate);
- --Continent
- continent = elements.allocate("JosephMA", "CONT");
- elements.element(continent, elements.element(elements.DEFAULT_PT_PLNT));
- elements.property(continent, "HighTemperature", 473.15);
- elements.property(continent, "HighTemperatureTransition", rock);
- elements.property(continent, "Name", "CONT");
- elements.property(continent, "Description", "Continent makes up planets.");
- elements.property(continent, "MenuSection", 15);
- local function continentUpdate(i, x, y, s, n)
- local life = sim.partProperty(i, "life");
- if life > 0 then
- for r in sim.neighbors(x,y,1,1) do
- if math.random(1, 8) == 1 and sim.partProperty(r, "type") == ocean then
- sim.partChangeType(r, continent);
- sim.partProperty(r, "life", life - 1);
- end
- end
- elseif math.random(1, 100000000) == 1 then
- for r in sim.neighbors(x,y,1,1) do
- if sim.partProperty(r, "type") == city then
- sim.partProperty(i, "tmp", sim.partProperty(r, "tmp"));
- sim.partProperty(i, "tmp2", sim.partProperty(r, "tmp2"));
- break;
- end
- end
- sim.partChangeType(i, city);
- end
- end
- elements.property(continent, "Update", continentUpdate);
- --Ocean
- ocean = elements.allocate("JosephMA", "OCEN");
- elements.element(ocean, elements.element(elements.DEFAULT_PT_WATR));
- elements.property(ocean, "HighTemperature", 473.15);
- elements.property(ocean, "HighTemperatureTransition", desert);
- elements.property(ocean, "Name", "OCEN");
- elements.property(ocean, "Description", "Oceans able to substain life on planets.");
- elements.property(ocean, "MenuSection", 15);
- --Planet
- planet = elements.allocate("JosephMA", "PLNE");
- elements.element(planet, elements.element(elements.DEFAULT_PT_DMND));
- elements.property(planet, "Name", "PLNE");
- elements.property(planet, "Description", "Creates a randomized planet.");
- --Deserted planet
- dplanet = elements.allocate("JosephMA", "DPLN");
- elements.element(dplanet, elements.element(elements.DEFAULT_PT_DMND));
- elements.property(dplanet, "Name", "DPLN");
- elements.property(dplanet, "Description", "A deserted globe.");
- --Laser
- laser = elements.allocate("JosephMA", "LASR");
- elements.element(laser, elements.element(elements.DEFAULT_PT_PHOT));
- elements.property(laser, "Name", "LASR");
- elements.property(laser, "Temperature", 295.15);
- elements.property(laser, "Description", "Lasers, shoot everything up!");
- elements.property(laser, "MenuSection", 15);
- --Void ray
- void = elements.allocate("JosephMA", "VRAY");
- elements.element(void, elements.element(elements.DEFAULT_PT_PHOT));
- elements.property(void, "Name", "VRAY");
- elements.property(void, "Temperature", 1275.15);
- elements.property(void, "Flammable", 9999)
- elements.property(void, "Explosive", 1)
- elements.property(void, "Description", "Void rays, blow everything... out!");
- elements.property(void, "MenuSection", 15);
- --Explosion
- explosion = elements.allocate("JosephMA", "EXPL");
- elements.element(explosion, elements.element(elements.DEFAULT_PT_DUST));
- elements.property(explosion, "Name", "EXPL");
- elements.property(explosion, "Temperature", 673.15);
- elements.property(explosion, "Description", "Explosions, boom!");
- elements.property(explosion, "MenuSection", elem.SC_EXPLOSIVE);
- local function explosionUpdate(i, x, y, s, n)
- --Spawn explosion
- local temp = tpt.get_property("temp", i);
- local life = tpt.get_property("life", i);
- local spread;
- if life == 0 then
- spread = explosionSpread;
- else
- spread = life;
- end
- sim.partKill(x - 1, y);
- sim.partKill(x + 1, y);
- sim.partKill(x - 2, y);
- sim.partKill(x + 2, y);
- sim.partKill(x, y - 1);
- sim.partKill(x, y + 1);
- sim.partKill(x, y - 2);
- sim.partKill(x, y + 2);
- sim.partKill(x - 1, y - 1);
- sim.partKill(x + 1, y - 1);
- sim.partKill(x - 1, y + 1);
- sim.partKill(x + 1, y + 1);
- for t=0, 50, 1
- do
- local part = sim.partCreate(-3, x, y, elements.DEFAULT_PT_EMBR);
- tpt.set_property("temp", temp, part);
- tpt.set_property("life", math.random() * 100, part);
- local angle = math.random() * 2.0 * math.pi/spread;
- local v = (math.random()) * 5.0/spread;
- tpt.set_property("vx", v * math.cos(angle), part);
- tpt.set_property("vy", v * math.sin(angle), part);
- end
- sim.partKill(i);
- return 1;
- end
- elements.property(explosion, "Update", explosionUpdate);
- --Missile
- missile = elements.allocate("JosephMA", "MISL");
- elements.element(missile, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(missile, "Name", "MISL");
- elements.property(missile, "Colour", 0x5D5D5C);
- elements.property(missile, "Description", "Explodes after a set life time!");
- elements.property(missile, "MenuSection", 15);
- local function missileUpdate(i, x, y, s, n)
- sim.partProperty(i, "life", sim.partProperty(i, "life") - 1);
- if sim.partProperty(i, "life") <= 0 then
- local part = sim.partCreate(-1, x, y, explosion);
- sim.partProperty(part, "life", 1);
- sim.partKill(i);
- totalexpl = totalexpl + 1
- return 1;
- end
- --Smoke Trail
- local part = sim.partCreate(-1, x, y, elements.DEFAULT_PT_SMKE);
- sim.partProperty(part, "life", 20);
- end
- elements.property(missile, "Update", missileUpdate);
- --Chemical weapon
- chema = elements.allocate("JosephMA", "CHEM");
- elements.element(chema, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(chema, "Name", "CHEM");
- elements.property(chema, "Colour", 0x5D5D5C);
- elements.property(chema, "Description", "Chemical weapon! Releases toxic and caustic gas, explodes after setting life time.");
- elements.property(chema, "MenuSection", 15);
- local function chemaUpdate(i, x, y, s, n)
- sim.partProperty(i, "life", sim.partProperty(i, "life") - 1);
- if sim.partProperty(i, "life") <= 0 then
- local part = sim.partCreate(-1, x, y, explosion);
- sim.partProperty(part, "life", 1);
- sim.partKill(i);
- totalexpl = totalexpl + 1
- return 1;
- end
- --Toxic Trail
- local part = sim.partCreate(-1, x, y, elements.DEFAULT_PT_CAUS);
- sim.partProperty(part, "life", 20);
- end
- elements.property(chema, "Update", chemaUpdate);
- --Ship
- ship = elements.allocate("JosephMA", "SHIP");
- elements.element(ship, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(ship, "HighTemperature", 1273.15);
- elements.property(ship, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(ship, "Name", "SHIP");
- elements.property(ship, "Description", "Spacecraft fighter shoots lasers.");
- elements.property(ship, "MenuSection", elem.SC_SPECIAL);
- local function shipUpdate(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", fighterLife, i);
- life = fighterLife;
- end
- local rand = math.random(1, 150);
- if rand <= 75 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-3, 3), i);
- else
- tpt.set_property("vy", math.random(-3, 3), i);
- end
- end
- --Shooting
- if rand == 1 then
- for r in sim.neighbors(x,y,5,5) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == lab) and sim.partProperty(r, "tmp") ~= tmp then
- local part = sim.partCreate(-3, x, y, laser);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 20, part);
- end
- end
- end
- end
- elements.property(ship, "Update", shipUpdate);
- local function shipGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- return 1,0x00000001,255,r,g,b,255,255,255,255;
- end
- elements.property(ship, "Graphics", shipGraphics);
- --Split ship
- splitship = elements.allocate("JosephMA", "SSHP");
- elements.element(splitship, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(splitship, "HighTemperature", 1273.15);
- elements.property(splitship, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(splitship, "Name", "SSHP");
- elements.property(splitship, "Description", "Split fighter, when destroyed turns into 4 normal fighters.");
- elements.property(splitship, "MenuSection", elem.SC_SPECIAL);
- local function splitshipUpdate(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", fighterLife, i);
- life = fighterLife;
- end
- local rand = math.random(1, 150);
- if rand <= 75 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- local part
- part = sim.partCreate(-1, x - 1, y - 1, ship)
- tpt.set_property("tmp", tpt.get_property("tmp", i), part);
- part = sim.partCreate(-1, x - 1, y + 1, ship)
- tpt.set_property("tmp", tpt.get_property("tmp", i), part);
- part = sim.partCreate(-1, x + 1, y - 1, ship)
- tpt.set_property("tmp", tpt.get_property("tmp", i), part);
- part = sim.partCreate(-1, x + 1, y + 1, ship)
- tpt.set_property("tmp", tpt.get_property("tmp", i), part);
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-3, 3), i);
- else
- tpt.set_property("vy", math.random(-3, 3), i);
- end
- end
- --Shooting
- local tmp = tpt.get_property("tmp", i);
- if rand == 1 then
- for r in sim.neighbors(x,y,5,5) do
- local partType = sim.partProperty(r, "type");
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == lab) and sim.partProperty(r, "tmp") ~= tmp then
- local part = sim.partCreate(-3, x, y, laser);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 20, part);
- end
- end
- end
- if splits == 0 then
- print(getFraction(tmp, 1) .. ": The first split ship in history has been built!")
- splitcreator = tmp
- splits = 1
- end
- end
- elements.property(splitship, "Update", splitshipUpdate);
- local function splitshipGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- return 1,0x00000001,255,r,g,b,255,255,255,255;
- end
- elements.property(splitship, "Graphics", splitshipGraphics);
- --Ship 2
- ship2 = elements.allocate("JosephMA", "SHIP2");
- elements.element(ship2, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(ship2, "HighTemperature", 1273.15);
- elements.property(ship2, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(ship2, "Name", "SHP2");
- elements.property(ship2, "Description", "Level 2 of spacecraft fighter, shoots with destructive void rays");
- elements.property(ship2, "MenuSection", elem.SC_SPECIAL);
- local function shipUpdate2(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", fighterLife, i);
- life = fighterLife;
- end
- local rand = math.random(1, 150);
- if rand <= 75 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-3, 3), i);
- else
- tpt.set_property("vy", math.random(-3, 3), i);
- end
- end
- --Shooting
- if rand == 1 then
- for r in sim.neighbors(x,y,5,5) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == ship2 or partType == bomber2 or partType == kamikaze or partType == decrafter) and sim.partProperty(r, "tmp") ~= tmp then
- local part = sim.partCreate(-3, x, y, void);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 20, part);
- end
- end
- end
- end
- elements.property(ship2, "Update", shipUpdate2);
- local function shipGraphics2(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- return 1,0x00000001,255,r,g,b,255,255,255,255;
- end
- elements.property(ship2, "Graphics", shipGraphics2);
- --Bomber
- bomber = elements.allocate("JosephMA", "BMBR");
- elements.element(bomber, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(bomber, "HighTemperature", 1273.15);
- elements.property(bomber, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(bomber, "Name", "BMBR");
- elements.property(bomber, "Description", "Spacecraft bomber shoots missiles.");
- elements.property(bomber, "MenuSection", elem.SC_SPECIAL);
- local function bomberUpdate(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", fighterLife, i);
- life = fighterLife;
- end
- local rand = math.random(1, 150);
- if rand <= 75 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-1, 1), i);
- else
- tpt.set_property("vy", math.random(-1, 1), i);
- end
- end
- --Shooting
- if rand == 1 then
- for r in sim.neighbors(x,y,5,5) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == kamikaze or partType == lab) and sim.partProperty(r, "tmp") ~= tmp then
- local part = sim.partCreate(-3, x, y, missile);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("life", 20, part);
- break;
- end
- end
- end
- end
- elements.property(bomber, "Update", bomberUpdate);
- local function bomberGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- return 1,0x00000001,255,r,g,b,255,255,255,255;
- end
- elements.property(bomber, "Graphics", bomberGraphics);
- --Bomber 2
- bomber2 = elements.allocate("JosephMA", "BMBR2");
- elements.element(bomber2, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(bomber2, "HighTemperature", 1273.15);
- elements.property(bomber2, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(bomber2, "Name", "BMB2");
- elements.property(bomber2, "Description", "Level 2 of space bomber, has got chemical weapon onboard.");
- elements.property(bomber2, "Hardness", 0);
- elements.property(bomber2, "MenuSection", elem.SC_SPECIAL);
- local function bomberUpdate2(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", fighterLife, i);
- life = fighterLife;
- end
- local rand = math.random(1, 150);
- if rand <= 75 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-1, 1), i);
- else
- tpt.set_property("vy", math.random(-1, 1), i);
- end
- end
- --Shooting
- if rand == 1 then
- for r in sim.neighbors(x,y,5,5) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == kamikaze or partType == lab or partType == decrafter) and sim.partProperty(r, "tmp") ~= tmp then
- local part = sim.partCreate(-3, x, y, chema);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("life", 20, part);
- break;
- end
- end
- end
- end
- elements.property(bomber2, "Update", bomberUpdate2);
- local function bomberGraphics2(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- return 1,0x00000001,255,r,g,b,255,255,255,255;
- end
- elements.property(bomber2, "Graphics", bomberGraphics2);
- --Mothership
- mothership = elements.allocate("JosephMA", "MOTH");
- elements.element(mothership, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(mothership, "HighTemperature", 1273.15);
- elements.property(mothership, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(mothership, "Name", "MOTH");
- elements.property(mothership, "Description", "Mothership produces ships and fires fast! Also has nukes onboard");
- elements.property(mothership, "MenuSection", elem.SC_SPECIAL);
- local function mothershipUpdate(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", mothershipLife, i);
- life = mothershipLife;
- end
- local rand = math.random(1, 60);
- if rand <= 30 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- tpt.set_property("life", life - 1, i);
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-1, 1), i);
- else
- tpt.set_property("vy", math.random(-1, 1), i);
- end
- end
- --Shooting
- if rand == 1 then
- for r in sim.neighbors(x,y,10,10) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == kamikaze or partType == lab or partType == decrafter) and sim.partProperty(r, "tmp") ~= tmp then
- if partType ~= city then
- local part = sim.partCreate(-3, x, y, laser);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 20, part);
- part = sim.partCreate(-3, x - 1, y, laser);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 20, part);
- part = sim.partCreate(-3, x + 1, y, laser);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 20, part);
- part = sim.partCreate(-3, x, y - 1, laser);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 20, part);
- part = sim.partCreate(-3, x, y + 1, laser);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 20, part);
- elseif (partType == obliteratorCannon) and sim.partProperty(r, "tmp") ~= tmp then
- local part;
- part = sim.partCreate(-3, x, y, decrafter);
- sim.partProperty(part, "tmp", sim.partProperty(i, "tmp"));
- else
- --Destroy or assimilate
- if math.random(1, 2) == 1 then
- --sim.partChangeType(r, elements.DEFAULT_PT_BOMB);
- sim.partChangeType(r, rock);
- else
- sim.partProperty(r, "tmp", tmp)
- end
- end
- end
- end
- end
- --Create more ships
- if math.random(1, 300) == 1 then
- local part;
- if math.random(1, 2) == 1 then
- part = sim.partCreate(-3, x, y, ship);
- else
- part = sim.partCreate(-3, x , y, bomber);
- end
- sim.partProperty(part, "tmp", sim.partProperty(i, "tmp"));
- end
- end
- elements.property(mothership, "Update", mothershipUpdate);
- local function mothershipGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- local x = tpt.get_property("x",i);
- local y = tpt.get_property("y",i);
- graphics.fillRect(x - 2, y - 2, 5, 5, r, g, b);
- end
- elements.property(mothership, "Graphics", mothershipGraphics);
- --Destroyer
- destroyer = elements.allocate("JosephMA", "DSTR");
- elements.element(destroyer, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(destroyer, "HighTemperature", 1273.15);
- elements.property(destroyer, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(destroyer, "Name", "DSTR");
- elements.property(destroyer, "Description", "Destroys all worlds.");
- elements.property(destroyer, "MenuSection", elem.SC_SPECIAL);
- local function destroyerUpdate(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", destroyerLife, i);
- life = destroyerLife;
- end
- local rand = math.random(1, 30);
- if rand <= 15 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- tpt.set_property("life", life - 1, i);
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-1, 1), i);
- else
- tpt.set_property("vy", math.random(-1, 1), i);
- end
- end
- --Shooting
- if rand == 1 then
- for r in sim.neighbors(x,y,10,10) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == kamikaze or partType == lab or partType == decrafter) and sim.partProperty(r, "tmp") ~= tmp then
- if partType ~= city then
- --Nuke missile
- local part = sim.partCreate(-3, x, y, nukeMissile);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- --tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 40, part);
- else
- --Destroy
- if math.random(1, 2) == 1 then
- --sim.partChangeType(r, elements.DEFAULT_PT_BOMB);
- sim.partChangeType(r, rock);
- end
- end
- --[[elseif partType == ocean or partType == continent then
- --Destroy
- if math.random(1, 10) == 1 then
- sim.partChangeType(r, elements.DEFAULT_PT_BOMB);
- else
- sim.partProperty(r, "temp", 2773.15);
- end
- elseif partType == desert then
- --Obliviate
- sim.partChangeType(r, elements.DEFAULT_PT_PLSM);]]--
- end
- end
- end
- --Create more ships
- if math.random(1, 300) == 1 then
- local part;
- if math.random(1, 2) == 1 then
- part = sim.partCreate(-3, x, y, ship);
- else
- part = sim.partCreate(-3, x , y, bomber);
- end
- sim.partProperty(part, "tmp", sim.partProperty(i, "tmp"));
- end
- end
- elements.property(destroyer, "Update", destroyerUpdate);
- local function destroyerGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- local x = tpt.get_property("x",i);
- local y = tpt.get_property("y",i);
- graphics.fillRect(x - 4, y - 4, 9, 9, r, g, b);
- end
- elements.property(destroyer, "Graphics", destroyerGraphics);
- --Builder
- builder = elements.allocate("JosephMA", "BLDR");
- elements.element(builder, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(builder, "HighTemperature", 1273.15);
- elements.property(builder, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(builder, "Name", "BLDR");
- elements.property(builder, "Description", "Spacecraft builder builds space cities.");
- elements.property(builder, "MenuSection", elem.SC_SPECIAL);
- local function builderUpdate(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", fighterLife, i);
- life = fighterLife;
- end
- --Damage
- if math.random(1, 2) == 1 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-3, 3), i);
- else
- tpt.set_property("vy", math.random(-3, 3), i);
- end
- end
- --Create construction
- if math.random(1, 1000) == 1 then
- local building = math.random(1, 100)
- --Lab
- if building <= 99 and building >= 85 then
- sim.partProperty(i, "tmp2", 1);
- sim.partChangeType(i, lab);
- if sim.partProperty(i, "tmp") == 0 then
- print("Red: Laboratory has been built!")
- elseif sim.partProperty(i, "tmp") == 1 then
- print("Green: Laboratory has been built!")
- elseif sim.partProperty(i, "tmp") == 2 then
- print("Blue: Laboratory has been built!")
- elseif sim.partProperty(i, "tmp") == 3 then
- print("Golden: Laboratory has been built!")
- elseif sim.partProperty(i, "tmp") == 4 then
- print("White: Laboratory has been built!")
- elseif sim.partProperty(i, "tmp") == 5 then
- print("Gray: Laboratory has been built!")
- end
- totallabs = totallabs + 1
- --City
- elseif building < 90 then
- sim.partProperty(i, "tmp2", 1);
- sim.partChangeType(i, city);
- --Obliterator cannon
- elseif building == 100 and rTech >= 10 and gTech >= 10 and bTech >= 10 and gdTech >= 10 and wTech >= 10 and gyTech >= 10 then
- sim.partChangeType(i, obliteratorCannon);
- if sim.partProperty(i, "tmp") == 0 then
- print("Red: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 1 then
- print("Green: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 2 then
- print("Blue: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 3 then
- print("Golden: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 4 then
- print("White: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 5 then
- print("Gray: Obliterator cannon has been built!")
- end
- end
- end
- end
- elements.property(builder, "Update", builderUpdate);
- local function builderGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- return 1,0x00000001,255,r,g,b,255,255,255,255;
- end
- elements.property(builder, "Graphics", builderGraphics);
- --Builder 2
- builder2 = elements.allocate("JosephMA", "BLDR2");
- elements.element(builder2, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(builder2, "HighTemperature", 1273.15);
- elements.property(builder2, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(builder2, "Name", "BLD2");
- elements.property(builder2, "Description", "Spacecraft builder builds obliterators more often.");
- elements.property(builder2, "MenuSection", elem.SC_SPECIAL);
- local function builder2Update(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", fighterLife, i);
- life = fighterLife;
- end
- --Damage
- if math.random(1, 2) == 1 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-3, 3), i);
- else
- tpt.set_property("vy", math.random(-3, 3), i);
- end
- end
- --Create construction
- if math.random(1, 1000) == 1 then
- local building = math.random(1, 100)
- --City
- if building < 97 then
- sim.partProperty(i, "tmp2", 1);
- sim.partChangeType(i, city);
- --Obliterator cannon
- elseif building <= 100 and building >= 98 and rTech >= 10 and gTech >= 10 and bTech >= 10 and gdTech >= 10 and wTech >= 10 and gyTech >= 10 then
- sim.partChangeType(i, obliteratorCannon);
- if sim.partProperty(i, "tmp") == 0 then
- print("Red: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 1 then
- print("Green: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 2 then
- print("Blue: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 3 then
- print("Golden: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 4 then
- print("White: Obliterator cannon has been built!")
- elseif sim.partProperty(i, "tmp") == 5 then
- print("Gray: Obliterator cannon has been built!")
- end
- end
- end
- end
- elements.property(builder2, "Update", builder2Update);
- local function builder2Graphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- return 1,0x00000001,255,r,g,b,255,255,255,255;
- end
- elements.property(builder2, "Graphics", builder2Graphics);
- --Kamikaze
- kamikaze = elements.allocate("JosephMA", "KMKZ");
- elements.element(kamikaze, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(kamikaze, "HighTemperature", 1273.15);
- elements.property(kamikaze, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(kamikaze, "Name", "KMKZ");
- elements.property(kamikaze, "Description", "Spacecraft kamikaze, explodes when near enemy ships.");
- elements.property(kamikaze, "MenuSection", elem.SC_SPECIAL);
- local function kamikazeUpdate(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", fighterLife, i);
- life = fighterLife;
- end
- local rand = math.random(1, 150);
- if rand <= 75 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-1, 1), i);
- else
- tpt.set_property("vy", math.random(-1, 1), i);
- end
- end
- if rand == 1 then
- for r in sim.neighbors(x,y,10,10) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == kamikaze or partType == lab) and sim.partProperty(r, "tmp") ~= tmp then
- tpt.set_property("vx", (sim.partProperty(r, "x") - x)^0, i);
- tpt.set_property("vy", (sim.partProperty(r, "y") - y)^0, i);
- break;
- end
- end
- --Explode
- for r in sim.neighbors(x,y,3,3) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == lab) and sim.partProperty(r, "tmp") ~= tmp then
- tpt.set_property("type","expl",i);
- tpt.set_property("life","0",i);
- break;
- end
- end
- end
- end
- elements.property(kamikaze, "Update", kamikazeUpdate);
- local function kamikazeGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- return 1,0x00000001,255,r,g,b,255,255,255,255;
- end
- elements.property(kamikaze, "Graphics", kamikazeGraphics);
- --Nuke Missile
- nukeMissile = elements.allocate("JosephMA", "MSLE");
- elements.element(nukeMissile, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(nukeMissile, "Name", "MSLE");
- elements.property(nukeMissile, "Colour", 0x5D5D5C);
- elements.property(nukeMissile, "Description", "Nuke missile, explodes after a set life time!");
- elements.property(nukeMissile, "MenuSection", 15);
- local function nukeMissileUpdate(i, x, y, s, n)
- sim.partProperty(i, "life", sim.partProperty(i, "life") - 1);
- if sim.partProperty(i, "life") <= 0 then
- local part = sim.partCreate(-1, x, y, explosion);
- sim.partProperty(part, "life", 1);
- --Explode
- for r in sim.neighbors(x,y,20,20) do
- local part = sim.partCreate(-3, sim.partProperty(r, "x"), sim.partProperty(r, "y"), elements.DEFAULT_PT_PLSM);
- sim.partProperty(part, "life", 300);
- sim.partKill(r);
- end
- sim.partKill(i);
- totalexpl = totalexpl + 1
- return 1;
- end
- --Smoke Trail
- local part = sim.partCreate(-1, x, y, elements.DEFAULT_PT_SMKE);
- sim.partProperty(part, "life", 20);
- end
- elements.property(nukeMissile, "Update", nukeMissileUpdate);
- --Decrafter
- decrafter = elements.allocate("JosephMA", "DCRF");
- elements.element(decrafter, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(decrafter, "HighTemperature", 1273.15);
- elements.property(decrafter, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(decrafter, "Name", "DCRF");
- elements.property(decrafter, "Description", "Spacecraft decrafter, steal or destroy enemy obliterators. Very resistant.");
- elements.property(decrafter, "MenuSection", elem.SC_SPECIAL);
- local function decrafterUpdate(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", fighterLife, i);
- life = fighterLife;
- end;
- local stuff = 0;
- if stuff == 0 then
- tpt.set_property("life", 10, i);
- stuff = 1
- end;
- local rand = math.random(1, 150);
- if rand <= 75 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR or partType == elements.DEFAULT_PT_CAUS then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- totalshipdest = totalshipdest + 1
- return 1;
- end
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-1, 1), i);
- else
- tpt.set_property("vy", math.random(-1, 1), i);
- end
- end
- --Destroy or steal
- for r in sim.neighbors(x,y,5,5) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- local enemytmp = tpt.get_property("tmp", r)
- if (partType == obliteratorCannon) and sim.partProperty(r, "tmp") ~= tmp then
- random = math.random(1, 5)
- if random > 1 then
- tpt.set_property("type","msle",i);
- tpt.set_property("life","100",i);
- tpt.set_property("vx","0",i);
- tpt.set_property("vy","0",i);
- print(getFraction(tmp, 1) .. ": A decrafter has set a nuke near a " .. getFraction(enemytmp, 0) .. " obliterator cannon!")
- else
- tpt.set_property("tmp", tmp, r);
- sim.partKill(i);
- print(getFraction(tmp, 1) .. ": A decrafter stole a " .. getFraction(enemytmp, 0) .. " obliterator cannon!")
- totalstolen = totalstolen + 1
- end;
- break;
- end
- end
- end
- elements.property(decrafter, "Update", decrafterUpdate);
- local function decrafterGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- local x = tpt.get_property("x",i);
- local y = tpt.get_property("y",i);
- graphics.fillRect(x - 1, y - 1, 3, 3, r, g, b);
- end
- elements.property(decrafter, "Graphics", decrafterGraphics);
- --Terraformer
- terraformer = elements.allocate("JosephMA", "TFRM");
- elements.element(terraformer, elements.element(elements.DEFAULT_PT_PROT));
- elements.property(terraformer, "HighTemperature", 1273.15);
- elements.property(terraformer, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(terraformer, "Name", "TFRM");
- elements.property(terraformer, "Description", "Spacecraft terraformer , makes planets more suitable for life.");
- elements.property(terraformer, "MenuSection", elem.SC_SPECIAL);
- local function terraformerUpdate(i, x, y, s, n)
- --tmp is current team
- local life = tpt.get_property("life", i);
- if life == 0 then
- tpt.set_property("life", mothershipLife, i);
- life = mothershipLife;
- end
- local rand = math.random(1, 30);
- if rand <= 15 then
- for r in sim.neighbors(x,y,1,1) do
- local partType = sim.partProperty(r, "type");
- if partType == laser and sim.partProperty(r, "tmp") ~= tpt.get_property("tmp", i) then
- sim.partKill(r);
- tpt.set_property("life", life - 1, i);
- life = life - 1;
- if life - 1 <= -1 then
- sim.partKill(i);
- return 1;
- end
- elseif partType == explosion or partType == elements.DEFAULT_PT_EMBR then
- tpt.set_property("life", life - 1, i);
- if life - 1 <= -1 then
- sim.partKill(i);
- return 1;
- end
- end
- end
- end
- --Movement
- if math.random(1, 100) == 1 then
- if math.random(1, 2) == 1 then
- tpt.set_property("vx", math.random(-1, 1), i);
- else
- tpt.set_property("vy", math.random(-1, 1), i);
- end
- end
- --Shooting
- if math.random(1, 50) == 1 then
- for r in sim.neighbors(x,y,10,10) do
- local partType = sim.partProperty(r, "type");
- local partcType = sim.partProperty(r, "ctype");
- local tmp = tpt.get_property("tmp", i);
- if partType == rock and sim.partProperty(r, "temp") < 400 then
- sim.partChangeType(r, continent);
- sim.partProperty(r, "tmp", tmp);
- sim.partProperty(r, "tmp2", 1);
- end
- if partType == desert and sim.partProperty(r, "temp") < 400 then
- sim.partChangeType(r, ocean);
- end
- if partType == rock or partType == desert or partcType == rock or partcType == desert and sim.partProperty(r, "temp") > 400 and sim.partProperty(r, "temp") < 3273 then
- sim.partProperty(r, "temp", sim.partProperty(r, "temp")-500);
- end
- end
- end
- end
- elements.property(terraformer, "Update", terraformerUpdate);
- local function terraformerGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- -- local x = tpt.get_property("x",i);
- -- local y = tpt.get_property("y",i);
- -- graphics.fillRect(x - 4, y - 4, 9, 9, r, g, b);
- end
- elements.property(terraformer, "Graphics", terraformerGraphics);
- --Obliterator cannon
- obliteratorCannon = elements.allocate("JosephMA", "OBLC");
- elements.element(obliteratorCannon, elements.element(elements.DEFAULT_PT_BRCK));
- elements.property(obliteratorCannon, "HighTemperature", 873.15);
- elements.property(obliteratorCannon, "HighTemperatureTransition", elements.DEFAULT_PT_BRMT);
- elements.property(obliteratorCannon, "Name", "OBLC");
- elements.property(obliteratorCannon, "Description", "Obliterator cannon destroys the universe.");
- elements.property(obliteratorCannon, "MenuSection", elem.SC_SPECIAL);
- local function obliteratorCannonUpdate(i, x, y, s, n)
- if math.random(1, 500) == 1 then
- for r in sim.neighbors(x,y,100,100) do
- local partType = sim.partProperty(r, "type");
- local tmp = tpt.get_property("tmp", i);
- if (partType == ship or partType == bomber or partType == city or partType == mothership or partType == destroyer or partType == builder or partType == ship2 or partType == bomber2 or partType == lab) and sim.partProperty(r, "tmp") ~= tmp then
- if partType ~= city then
- --Nuke missile
- local part = sim.partCreate(-3, x, y, nukeMissile);
- tpt.set_property("vx", sim.partProperty(r, "x") - x, part);
- tpt.set_property("vy", sim.partProperty(r, "y") - y, part);
- --tpt.set_property("tmp", tmp, part);
- tpt.set_property("life", 65, part);
- else
- --Destroy
- if math.random(1, 50) <= 49 then
- sim.partChangeType(r, rock);
- else
- sim.partChangeType(r, elements.DEFAULT_PT_BOMB);
- end
- end
- end
- end
- --Fire missiles
- for t=0, 50, 1
- do
- local part = sim.partCreate(-3, x, y, missile);
- tpt.set_property("life", math.random() * 150, part);
- local angle = math.random() * 2.0 * math.pi/0.5;
- local v = (math.random()) * 5.0/0.5;
- tpt.set_property("vx", v * math.cos(angle), part);
- tpt.set_property("vy", v * math.sin(angle), part);
- end
- end
- end
- elements.property(obliteratorCannon, "Update", obliteratorCannonUpdate);
- local function obliteratorCannonGraphics(i, colr, colg, colb)
- local r;
- local g;
- local b;
- local tmp = tpt.get_property("tmp", i);
- if tmp == 0 then
- r = 255;
- g = 0;
- b = 0;
- elseif tmp == 1 then
- r = 0;
- g = 255;
- b = 0;
- elseif tmp == 2 then
- r = 0;
- g = 0;
- b = 255;
- elseif tmp == 3 then
- r = 255;
- g = 204;
- b = 0;
- elseif tmp == 4 then
- r = 255;
- g = 255;
- b = 255;
- elseif tmp == 5 then
- r = 153;
- g = 153;
- b = 153;
- end
- tpt.drawline(sim.partProperty(i, "x"), sim.partProperty(i, "y"), sim.partProperty(i, "x") + 5, sim.partProperty(i, "y"), r, g, b)
- return 1,0x00000001,255,r,g,b,255,255,255,255;
- end
- elements.property(obliteratorCannon, "Graphics", obliteratorCannonGraphics);
- local function rockUpdate(i, x, y, s, n)
- local life = sim.partProperty(i, "life");
- if life > 0 then
- sim.partProperty(i, "life", life - 1);
- for r in sim.neighbors(x,y,1,1) do
- if math.random(1, 8) == 1 and sim.partProperty(r, "type") == desert then
- sim.partChangeType(r, rock);
- sim.partProperty(r, "life", life - 1);
- end
- end
- end
- end
- elements.property(rock, "Update", rockUpdate);
- local function planetUpdate(i, x, y, s, n)
- if sim.partProperty(i, "tmp") == 0 then
- if math.random(1, 20) == 1 then
- sim.partProperty(i, "life", math.random(0, 10));
- sim.partChangeType(i, continent);
- else
- sim.partChangeType(i, ocean);
- end
- end;
- if sim.partProperty(i, "tmp") == 1 then
- if math.random(1, 20) == 1 then
- sim.partProperty(i, "life", math.random(0, 10));
- sim.partChangeType(i, rock);
- else
- sim.partChangeType(i, desert);
- end
- end
- end;
- elements.property(planet, "Update", planetUpdate);
- local function dplanetUpdate(i, x, y, s, n)
- sim.partProperty(i, "tmp", 1);
- sim.partChangeType(i, planet)
- end;
- elements.property(dplanet, "Update", dplanetUpdate);
- lab = elements.allocate("JosephMA", "LAB");
- elements.element(lab, elements.element(elements.DEFAULT_PT_BRCK));
- elements.property(lab, "Name", "LAB");
- elements.property(lab, "Colour", 0x00FFDE);
- elements.property(lab, "Description", "Laboratory expands technologies");
- elements.property(lab, "MenuSection", 15);
- local function labUpdate(i, x, y, s, n)
- if sim.partProperty(i, "tmp2") == 1 then
- if sim.partProperty(i, "tmp") == 0 then
- rTech = rTech + 1
- elseif sim.partProperty(i, "tmp") == 1 then
- gTech = gTech + 1
- elseif sim.partProperty(i, "tmp") == 2 then
- bTech = bTech + 1
- elseif sim.partProperty(i, "tmp") == 3 then
- gdTech = gdTech + 1
- elseif sim.partProperty(i, "tmp") == 4 then
- wTech = wTech + 1
- elseif sim.partProperty(i, "tmp") == 5 then
- gyTech = gyTech + 1
- end;
- sim.partProperty(i, "tmp2", 2)
- end
- end
- elements.property(lab, "Update", labUpdate);
- local function showLabs(key, nkey, modifier, event)
- if key == "m" and event == 2 then
- print("Red lab research: " .. rTech*5 .. "%");
- print("Green lab research: " .. gTech*5 .. "%");
- print("Blue lab reserach: " .. bTech*5 .. "%");
- print("Golden lab research: " .. gdTech*5 .. "%");
- print("White lab research: " .. wTech*5 .. "%");
- print("Gray lab research: " .. gyTech*5 .. "%");
- if obliterators == 0 then
- print("Obliterator cannons: Not yet deployed")
- else
- print("Obliterator cannons: Deployed!")
- end;
- if splits == 0 then
- print("Split ships: Not yet invented.")
- else
- print("Split ships: Deployed! (first by the " .. getFraction(splitcreator, 0) .. " scientists)")
- end
- end
- end;
- tpt.register_keypress(showLabs)
- local function totals(key, nkey, modifier, event)
- if key == "t" and event == 2 then
- print("Statistics:")
- print("Total labs built: " .. totallabs)
- print("Total destroyers constructed: " .. totaldest)
- print("Total obliterators stolen: " .. totalstolen)
- print("Total missiles exploded: " .. totalexpl)
- print("Total ships destroyed (by their enemies): " .. totalshipdest)
- end
- end
- tpt.register_keypress(totals)
- local function reset(mousex, mousey, button, event)
- tpt.drawrect(613, 113, 14, 14, 204, 204, 204)
- tpt.fillrect(613, 113, 14, 14, 0, 0, 0, 255)
- tpt.drawtext(618, 117, "R", 255, 255, 255, 255)
- if tpt.mousex >= 613 and tpt.mousey >= 113 and tpt.mousex <= 627 and tpt.mousey <= 127 then
- tpt.drawtext(537, 115, "Reset progress", 255, 0, 0, 255)
- tpt.drawrect(613, 113, 14, 14, 255, 255, 255)
- end
- if tpt.mousex >= 613 and tpt.mousey >= 113 and tpt.mousex <= 627 and tpt.mousey <= 127 then
- if event == 1 then
- rTech = 0;
- gTech = 0
- bTech = 0;
- gdTech = 0;
- wTech = 0;
- gyTech = 0;
- obliterators = 0;
- splits = 0;
- splitcreator = nil;
- totallabs = 0;
- totaldest = 0;
- totalstolen = 0;
- totalexpl = 0;
- totalshipdest = 0;
- end
- end
- end
- tpt.register_mouseclick(reset)
- tpt.register_step(reset)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement