Advertisement
IrishDruid

Trollget

Dec 24th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.21 KB | None | 0 0
  1.   function gadget:GetInfo()
  2.     return {
  3.       name      = "Trollifier: Suicidal Storm Module  v1.2",
  4.       desc      = "A little release as part of the trollifier gadget. Makes units fall from the sky!",
  5.       author    = "IrishDruid with help from xponen",
  6.       date      = "Last Thursday",
  7.       license   = "PINGAS",
  8.       layer     = 5,
  9.       enabled   = true,
  10.     }
  11.   end
  12.  
  13.     --declare variables--
  14.   local rany        = 0
  15.   local ranx        = 0
  16.   local mapy        = 0
  17.   local mapx        = 0
  18.   local gaiaid      = 0
  19.   local testunit    = 0
  20.   local hello       = 0
  21.   local impx        = 0
  22.   local impy        = 0
  23.   local impz        = 0
  24.   local ticknum     = 0
  25.   local intensity   = 30
  26.   local missiles    = false
  27.   local ran         = 0
  28.   local hpbonus     = 0.3
  29.   local barrage     = 4
  30.   local gaiaunits
  31.   local nuker       = {}
  32.   local coms        = {}
  33.   local randomtime  = 300
  34.   local unitnotbounds   = false
  35.   local unitarray   = {}
  36.   local shiparray   = {}
  37.   local techlevel   = 1
  38.   local nuketime    = 960
  39.   local missiletime = 100
  40.   local nukers      = 0
  41.   local Zenith
  42.   local DRP
  43.   local zenithtime  = 300
  44.   local drptime     = 300
  45.   local missilearray    = {}
  46.   local shiptime    = 300
  47.   local nukefrq     = 45
  48.   local years       = 68
  49.   local watchforme  = 0
  50.   local comarray    = {}
  51.   local arraypull   = 1
  52.   local randomsecs  = 1
  53.  
  54.   --Speedups--
  55.   local Echo        = Spring.Echo
  56.   local CreateUnit  = Spring.CreateUnit
  57.   local DestroyUnit = Spring.DestroyUnit
  58.   local PlaySound   = Spring.PlaySoundFile
  59.   local DamageUnit  = Spring.AddUnitDamage
  60.   local Impulse     = Spring.AddUnitImpulse
  61.   local Order       = Spring.GiveOrderToUnit
  62.   local GetZ        = Spring.GetGroundHeight
  63.   local Rotate      = Spring.SetUnitRotation
  64.   local AlwaysVisible   = Spring.SetUnitAlwaysVisible
  65.   local IsDead      = Spring.GetUnitIsDead
  66.  
  67.   --Sounds--
  68.   local sounds_nuke     = "Sounds\\Alert.ogg"       -- remove me later? possibly.
  69.   local sounds_drain    = "Sounds\\Bankrupt.ogg"
  70.   local sounds_interest = "Sounds\\interest.ogg"
  71.   local sounds_die  = "Sounds\\DIE.ogg"
  72.   local sounds_spanish  = "Sounds\\Expect.ogg"
  73.   local sounds_pingas   = "Sounds\\Pingas.ogg"
  74.   local sounds_spam = "Sounds\\spam.ogg"
  75.   local sounds_wham = "Sounds\\Whammy.ogg"
  76.   local sounds_intense  = "Sounds\\intense.ogg"
  77.   local sounds_diff = "Sounds\\completely_different.ogg"
  78.   local sounds_havoc    = "Sounds\\havoc.ogg"
  79.   local sounds_song = "Sounds\\PINGASSONG.ogg"
  80.   local sounds_9000 = "Sounds\\9000.ogg"
  81.   local sounds_EA   = "Sounds\\EA.ogg"
  82.   local array_sounds    = {"Sounds\\Bankrupt.ogg", "Sounds\\interest.ogg", "Sounds\\DIE.ogg", "Sounds\\Expect.ogg", "Sounds\\Pingas.ogg", "Sounds\\spam.ogg", "Sounds\\Whammy.ogg", "Sounds\\intense.ogg", "Sounds\\completely_different.ogg", "Sounds\\havoc.ogg", "Sounds\\9000.ogg", "Sounds\\EA.ogg"}
  83.  
  84.   --Unitdefs--
  85.   local roach       = "corroach"
  86.   local dirtbox     = "corclog"
  87.   local tick        = "armtick"
  88.   local scuttle     = "corsktl"
  89.   local crusader    = "armroy"
  90.   local enforcer    = "corroy"
  91.   local frigate     = "coresupp"
  92.   local skeeter     = "armpt"
  93.   local pyro        = "corpyro2"
  94.   local aaship      = "corarch"
  95.   local carrier     = "armcarry"
  96.   local destroyer   = "destroyer"
  97.   local hca     = "assaultcruiser"
  98.   local battleship  = "corbats"
  99.   local racketeer   = "shieldarty"
  100.   local pillager    = "cormart"
  101.   local crabe       = "armcrabe"
  102.   local punisher    = "hovershotgun"
  103.   local morning     = "hoversonic"
  104.   local duck        = "amphraider3"
  105.   local flea        = "armflea"
  106.   local merl        = "armmerl"
  107.   local pene        = "armmanni"
  108.   local sniper      = "armsnipe"
  109.   local dodo        = "chicken_dodo"
  110.   local soniccom    = "comm_sonic"
  111.   local nuke        = "corsilo"
  112.   local jug     = "gorg"
  113.   local scorp       = "scorpion"
  114.   local banisher    = "tawf114"
  115.   local tremor      = "trem"
  116.   local support     = "commsupport1"
  117.   local reaper      = "correap"
  118.   local sumo        = "corsumo"
  119.   local dante       = "dante"
  120.   local strikecom   = "cremcom1"
  121.   local bhj     = "jumpblackhole"
  122.   local funnel      = "funnelweb"
  123.   local goliath     = "corgol"
  124.   local battlecom   = "corcom1"
  125.   local buoy        = "amphfloater"
  126.   local dguner      = "armcomdgun"
  127.   local hammer      = "armham"
  128.   local detri       = "armorco"
  129.   local cata        = "armraven"
  130.   local razorback   = "armraz"
  131.   local rocko       = "armrock"
  132.   local recluse     = "armsptk"
  133.   local warrior     = "armwar"
  134.   local zeus        = "armzeus"
  135.   local toad        = "chicken_shield"
  136.   local white       = "chicken_dragon"
  137.   local welder      = "coracv"
  138.   local bandit      = "corak"
  139.   local jack        = "corcan"
  140.   local vandal      = "corcrash"
  141.   local dart        = "corfav"
  142.   local wolverine   = "corgarp"
  143.   local scorcher    = "corgator"
  144.   local leveler     = "corlevlr"
  145.   local outlaw      = "cormak"
  146.   local ravager     = "corraid"
  147.   local copperhead  = "corsent"
  148.   local scrubber    = "corsh"
  149.   local rogue       = "corstorm"
  150.   local thug        = "corthud"
  151.   local firewalker  = "firewalker"
  152.   local flail       = "hoveraa"
  153.   local haldbard    = "hoverassault"
  154.   local mace        = "hoverriot"
  155.   local billshot    = "hoverskirm"
  156.   local koda        = "logkoda"
  157.   local scapel      = "nsaclash"
  158.   local pather      = "panther"
  159.   local hermit      = "spiderassault"
  160.   local grizzley    = "amphassault"
  161.   local scallop     = "amphriot"
  162.   local bantha      = "armbanth"
  163.   local scythe      = "spherepole"
  164.   local moderator   = "slowmort"
  165.   local glaive      = "armpw"
  166.   local disco       = "raveparty"
  167.   local blastwing   = "blastwing"
  168.   local queen       = "chickenlandqueen"
  169.  
  170.   -- Constants --
  171.  
  172.   local array_tech1 = {flea,tick,dirtbox,welder,dart,scorcher,outlaw,scrubber,koda,moderator,glaive,duck,bandit,pyro}
  173.   local array_tech2 = {roach,buoy,hammer,dodo,racketeer,rocko,warrior,toad,vandal,leveler,ravager,rogue,thug,mace,haldbard,panther,scallop}
  174.   local array_tech3 = {reaper,merl,sniper,scuttle,banisher,armsptk,bhj,zeus,pillager,punisher,wolverine,copperhead,billshot,scapel,scythe,support}
  175.   local array_tech4 = {"subscout",tremor,morning,jack,firewalker,flail,battlecom,strikecom}
  176.   local array_tech5 = {goliath,sumo,pene,crabe,white,dguner,grizzley,soniccom}
  177.   local array_ship  = {skeeter, crusader, enforcer, aaship, frigate, carrier, destroyer, hca, battleship}
  178.   local array_strider   = {dguner,jug,scorp,dante,funnel,detri,cata,razorback,bantha,queen}
  179.   local array_missile   = {"napalmmissile", "seismic", "tacnuke", "empmissile"}
  180.   local array_strings   = {"Stupid Nub, Kills are for pros.", "Forgot to eat their wheaties.", "Forgot Poland.", "Stick to Commander Junior next time. It suits your skill level.",
  181.                "Silly Kamakazi, you Missed WWII by " .. years .. " years","Got Pingas'ed","Forgot their big stick","Didn't find love here","Won the death lottery","LOL! What a nub!",
  182.                "The reason why we can't have nice things", "Next time, read the newbie guide, noob","-_- WHY?!","No comment", "Wasn't Korean enough.", "Leave the micro to the Koreans pls.",
  183.                "Noob Alert!", "Fail", "Failed like Failer fails.", "Forgot to plop a brain.", "Boom! Headshot!", "TANGO DOWN!", "Commander Raeg Quit", "Fire is the best way to unwant something",
  184.                "Protip: You suck", "Protip: Read the newbie guide", "Protip: To kill enemy units, shoot at them until they die.", "Naaab!", "Nab", "L2Play nub", "Lol Fail", "U mad bro?",
  185.                "Trololololol", "Forgot their AA", "Fucks in sky.", "Y So mad?", "Too much porn, not enough game", "Was Under 9000!", "Became An Hero.", "Party V&","protip: Don't allow yourself to be provoked and don't be a douche.",
  186.                "Uses Attack instead of Fight", "NO YOU!!!", "BRB, FBI", "Forgot to water his cactus.", "fucks fucking fuck fucker","Less threatening than the love boat.","Earned their derploma",
  187.                "Ban Hammered", "Modabuse is srs business", "Raeg moar nub!", "Bananaed", "Spam moar fleas next time", "Honk!", "Lolwut?", "xponen was here", "Dont commorph next time!", "Didn't expect a kind of Spanish Inquisition"}
  188.   -- local nukeweapon   = WeaponDefNames["corsilo_crblmssl"].id -- dont need this any more.
  189.   -- BEGIN SCRIPT--
  190.  
  191.   if (gadgetHandler:IsSyncedCode()) then
  192.    
  193.     -- Toolbox Functions --
  194.    
  195.     local function NilCorrector(key,unittype)
  196.       if unittype == "ship" then
  197.     shiparray[key] = array_ship[math.random(1,#array_ship)]
  198.     return
  199.       end
  200.       if unittype == "unit" then
  201.     unitarray[key] = array_tech1[math.random(1,#array_tech1)]
  202.     return
  203.       end
  204.       if unittype == "missile" then
  205.     missilearray[key] = array_missile[math.random(1,#array_missile)]
  206.     return
  207.       end
  208.     end
  209.    
  210.    
  211.     local function BuildMissileArray(size)
  212.       for i = 1, size do
  213.         missilearray[i] = array_missile[math.random(1,#array_missile)]
  214.       end
  215.     end
  216.    
  217.     local function NukeCom(uid,x,y)
  218.       Spring.SetUnitStockpile(uid,1,0)
  219.       Order(uid,CMD.ATTACK,{x,GetZ(x,y),y},{})
  220.     end
  221.    
  222.     local function NukeMe(uid,x,y)
  223.       Spring.SetUnitStockpile(uid,1,0)
  224.       Order(uid,CMD.ATTACK,{x,GetZ(x,y),y},{})
  225.       SendToUnsynced("speccheat", "Real location is " .. x .. "," .. y .. ".")
  226.       random = math.random(1,3)
  227.       if random == 1 then
  228.     ranx = math.random(0,mapx)
  229.     rany = math.random(0,mapy)
  230.     SendToUnsynced("mapmarker", "Incoming nuke!" ,ranx,rany)
  231.     SendToUnsynced("mapmarker", "Incoming nuke!" ,x,y)
  232.     ranx = math.random(0,mapx)
  233.     rany = math.random(0,mapy)
  234.     SendToUnsynced("mapmarker", "Incoming nuke!" ,ranx,rany)
  235.       end
  236.       if random == 2 then
  237.     SendToUnsynced("mapmarker", "Incoming nuke!" ,x,y)
  238.     ranx = math.random(0,mapx)
  239.     rany = math.random(0,mapy)
  240.     SendToUnsynced("mapmarker", "Incoming nuke!" ,ranx,rany)
  241.     ranx = math.random(0,mapx)
  242.     rany = math.random(0,mapy)
  243.     SendToUnsynced("mapmarker", "Incoming nuke!" ,ranx,rany)
  244.       end
  245.       if random == 3 then
  246.     ranx = math.random(0,mapx)
  247.     rany = math.random(0,mapy)
  248.     SendToUnsynced("mapmarker", "Incoming nuke!" ,ranx,rany)
  249.     ranx = math.random(0,mapx)
  250.     rany = math.random(0,mapy)
  251.     SendToUnsynced("mapmarker", "Incoming nuke!" ,ranx,rany)
  252.     SendToUnsynced("mapmarker", "Incoming nuke!" ,x,y)
  253.       end
  254.     end
  255.    
  256.     local function BuildUnitArray(size)
  257.      for i=1, size do
  258.     rannum = math.random(1,techlevel)
  259.     if rannum == 1 then
  260.       unitarray[i] = array_tech1[math.random(1,#array_tech1)]
  261.     end
  262.     if rannum == 2 then
  263.       unitarray[i] = array_tech2[math.random(1,#array_tech2)]
  264.     end
  265.     if rannum == 3 then
  266.       unitarray[i] = array_tech3[math.random(1,#array_tech3)]
  267.     end
  268.     if rannum == 4 then
  269.       unitarray[i] = array_tech4[math.random(1,#array_tech4)]
  270.     end
  271.     if rannum == 5 then
  272.       unitarray[i] = array_tech5[math.random(1,#array_tech5)]
  273.     end
  274.     if rannum == 6 then
  275.       unitarray[i] = array_strider[math.random(1,#array_strider)]
  276.     end
  277.       end
  278.    end
  279.    
  280.     local function BuildShipArray(size)
  281.       for i=1, size do
  282.     shiparray[i] = array_ship[math.random(1,#array_ship)]
  283.       end
  284.     end  
  285.    
  286.     local function teleportunit(uid,x,y,z)
  287.       Spring.MoveCtrl.Enable(uid)
  288.       Spring.MoveCtrl.SetPosition(uid,x,y,z)
  289.       Spring.MoveCtrl.Disable(uid)
  290.     end
  291.    
  292.     local function teleport(uid,x,y,z)
  293.       Spring.MoveCtrl.Enable(uid)
  294.       Spring.MoveCtrl.SetPosition(uid,x,y,z)
  295.     end
  296.    
  297.     local function Impulser(uid,x,z,y)
  298.       Impulse(uid, 0, 40, 0)
  299.       Impulse(uid, x, z, y)
  300.     end
  301.    
  302.     local function CheckPos(uid)
  303.      --check x--
  304.      if Spring.ValidUnitID(uid) == true then
  305.        ux,uz,uy = Spring.GetUnitPosition(uid)
  306.        if ux <= -200 then
  307.          Impulse(uid, 1, 0.1, 0)
  308.          unitnotbounds = true
  309.        end
  310.        if ux >= mapx+200 then
  311.       Impulse(uid, -1, 0.1, 0)
  312.       unitnotbounds = true
  313.        end
  314.        --check y--
  315.        if uy <= -200 then
  316.       Impulse(uid, 0, 0.1, 1)
  317.       unitnotbounds = true
  318.        end
  319.        if uy >= mapy+200 then
  320.          Impulse(uid, 0, 0.1, -1)
  321.          unitnotbounds = true
  322.        end
  323.        if uz == GetZ(ux,uy) or uz <= 0 and unitnotbounds == false then
  324.          DestroyUnit(uid, true, false)
  325.        end
  326.        if uz <= 0 and unitnotbounds == false then       -- Fix to hovercraft on water issue.
  327.          DestroyUnit(uid,true,false)
  328.        end
  329.        unitnotbounds = false
  330.      end
  331.     end
  332.    
  333.     local function SpawnMacro(unittype,key)
  334.       ranx = math.random(0, mapx)
  335.       rany = math.random(0, mapy)
  336.       impx = math.random(-4, 4)
  337.       impy = math.random(-4, 4)
  338.       impz = math.random(0, 5)
  339.       impz = -impz-48
  340.       if unittype == nil then
  341.     NilCorrector(key, "unit")
  342.     unittype = unitarray[math.random(1,#unitarray)]
  343.       end
  344.       testunit = CreateUnit(unittype, ranx, 1001, rany, "s", 0)             --work around?
  345.       if Spring.ValidUnitID(testunit) == true then
  346.     Spring.TransferUnit(testunit,gaiaid,false)
  347.     Spring.SetUnitMaxHealth(testunit, (400*hpbonus))
  348.     Spring.SetUnitHealth(testunit,(400*hpbonus))
  349.     Impulser(testunit, impx, impz, impy)
  350.     ran = math.random(0,10)
  351.     if ran >= 4 then  
  352.       impx = math.random(-2,2)
  353.       impy = math.random(-2,2)
  354.       Rotate(testunit,impx,0,impy)
  355.     else
  356.       impx = math.random(-2,2)
  357.       Rotate(testunit,0,impx,0)
  358.     end
  359.       end
  360.     end
  361.    
  362.     local function UpdateArtilleryAttack(uid)
  363.       ranx = math.random(0,mapx)
  364.       rany = math.random(0,mapy)
  365.       Order(testunit,CMD.ATTACK,{ranx,GetZ(ranx,rany),rany},{})
  366.     end
  367.    
  368.     local function SpawnNuker()
  369.      nuker[nukers+1] = CreateUnit(nuke, mapx, 1001, mapy, "s", 0)
  370.      Spring.TransferUnit(nuker[nukers+1],gaiaid,false)
  371.      teleport(nuker[nukers+1],mapx/2+math.random(-500,500),1500,mapy/2+math.random(-500,500))
  372.      Spring.SetUnitCloak(nuker[nukers+1],true,4,1)
  373.      Spring.SetUnitArmored(nuker[nukers+1],true,100)
  374.      Spring.SetUnitStealth(nuker[nukers+1],true)
  375.      nukers = nukers+1
  376.     end
  377.    
  378.     local function SpawnMissile(unitdef,key)
  379.     if key == nil or key == "bypass" then       -- bypass the checks.
  380.       ranx = math.random(100, mapx)
  381.       rany = math.random(100, mapy)
  382.       testunit = CreateUnit(unitdef, ranx, 1001, rany, "s", 0)
  383.       if Spring.ValidUnitID(testunit) == true then
  384.     Spring.TransferUnit(testunit,gaiaid,false)
  385.     teleport(testunit,ranx,1200,rany)
  386.     ranx = ranx + math.random(-100, 100)
  387.     rany = rany + math.random(-100, 100)
  388.     Order(testunit,CMD.ATTACK,{ranx,GetZ(ranx,rany),rany},{})
  389.       end
  390.     else
  391.       if missilearray[key] == nil then
  392.     NilCorrector(key,"missile")
  393.     unitdef = missilearray[math.random(1,#missilearray)]
  394.       end
  395.      ranx = math.random(100, mapx)
  396.      rany = math.random(100, mapy)
  397.      testunit = CreateUnit(unitdef, ranx, 1001, rany, "s", 0)
  398.      if Spring.ValidUnitID(testunit) == true then
  399.     Spring.TransferUnit(testunit,gaiaid,false)
  400.     teleport(testunit,ranx,1200,rany)
  401.     ranx = ranx + math.random(-100, 100)
  402.        rany = rany + math.random(-100, 100)
  403.        Order(testunit,CMD.ATTACK,{ranx,GetZ(ranx,rany),rany},{})
  404.        end
  405.      end
  406.    end
  407.    
  408.    
  409.     local function SpawnShip(unittype)
  410.       ranx = math.random(100, mapx)
  411.       rany = math.random(100, mapy)
  412.       impx = math.random(0,4)
  413.       impy = math.random(0,4)
  414.       testunit = CreateUnit(unittype, ranx, 1001, rany, "s", 0)
  415.       if Spring.ValidUnitID(testunit) == true then
  416.     Spring.TransferUnit(testunit,gaiaid,false)
  417.     Impulser(testunit, impx, -42, impy)
  418.     Spring.SetUnitMaxHealth(testunit, (750*hpbonus))
  419.     Spring.SetUnitHealth(testunit,(750*hpbonus))
  420.     Rotate(testunit,impx,2,impy)
  421.       end
  422.     end
  423.    
  424.     local function tickstorm()
  425.       arraypull = math.random(1,#unitarray)
  426.       SpawnMacro(unitarray[arraypull],arraypull)
  427.       if barrage >= 0 and missiles then
  428.     arraypull = math.random(1,#missilearray)
  429.         SpawnMissile(missilearray[arraypull],arraypull)
  430.         barrage = barrage - 1
  431.       end
  432.       if math.random(0,10) >= 5 and Spring.GetGameFrame() >= shiptime then
  433.     SpawnShip(shiparray[arraypull])
  434.       end
  435.     end
  436.    
  437.     local function SkuttleStorm(unittype)
  438.       ranx = math.random(100, mapx)
  439.       rany = math.random(100, mapy)
  440.       impx = math.random(0,4)
  441.       impy = math.random(0,4)
  442.       unit = CreateUnit(unittype, ranx, 1001, rany, "s", 0)
  443.       Spring.TransferUnit(unit,gaiaid,false)
  444.       Spring.SetUnitCloak(unit,true,4,1)
  445.       Spring.SetUnitStealth(unit,true)
  446.       Impulser(unit, impx, -49, impy)
  447.       Rotate(unit,impx,2,impy)
  448.     end
  449.    
  450.     local function CheckMessage(frame)
  451.       if frame == 30 then
  452.     eta = randomsecs + math.random(-30,30)
  453.     Echo("Trollstorm ETA: " .. eta .. " seconds.")
  454.       end
  455.       if frame == missiletime then
  456.     BuildMissileArray(30)
  457.     missiles = true
  458.     Echo("Warning: The Trollgeon General suggests eating missiles. Heres some on the house!")
  459.     SendToUnsynced("sounder", sounds_wham)
  460.       end
  461.       if frame == nuketime then
  462.     missiles = false
  463.     SpawnNuker()
  464.     SpawnNuker()
  465.     SendToUnsynced("sounder", sounds_EA)
  466.     Echo("WARNING: You have failed to end the game by this point. Nukes will start launching. Yeah? Well fuck you too mate.")
  467.       end
  468.       if frame == drptime then
  469.        DRP = CreateUnit(disco, -750, 1001, -750, "s", 0)
  470.        teleport(DRP,-750,1001,-750)
  471.        Spring.TransferUnit(DRP,gaiaid,false)
  472.        Spring.SetUnitCloak(DRP,true,4,1)
  473.        Spring.SetUnitArmored(DRP,true,100)
  474.        Spring.SetUnitStealth(DRP,true)
  475.        Echo("WARNING: Epic lulz launch detected!")
  476.       end
  477.       if frame == zenithtime then
  478.        Echo("Warning: Lulz shower incoming.")
  479.        missiles = false
  480.        Zenith = CreateUnit("zenith", 1000, 1001, 1000, 0, "s")
  481.        Spring.TransferUnit(Zenith,gaiaid,false)
  482.        teleport(Zenith,mapx/2,1001,mapy/2)
  483.        Spring.SetUnitStealth(Zenith,true)
  484.        Spring.SetUnitCloak(Zenith,true,4,1)
  485.        Spring.SetUnitArmored(Zenith,true,100)
  486.        SendToUnsynced("sounder", sounds_spanish,2.0)
  487.       end
  488.     end
  489.    
  490.     local function DetriDrop(unittype)
  491.       ranx = math.random(100, mapx)
  492.       rany = math.random(100, mapy)
  493.       impx = math.random(0,4)
  494.       impy = math.random(0,4)
  495.       unit = CreateUnit(unittype, ranx, 1001, rany, "s", 0)
  496.       Spring.TransferUnit(unit,gaiaid,false)
  497.       Spring.SetUnitCloak(unit,true,4,1)
  498.       Spring.SetUnitStealth(unit,true)
  499.       Impulser(unit, impx, -40, impy)
  500.       Rotate(unit,impx,2,impy)
  501.     end
  502.    
  503.     local function DropUnit(unittype,x,y)
  504.       impx = math.random(0,4)
  505.       impy = math.random(0,4)
  506.       unit = CreateUnit(unittype,x,1001,y,"s",0)
  507.       Spring.TransferUnit(unit,gaiaid,false)
  508.       Spring.SetUnitCloak(unit,true,4,1)
  509.       Spring.SetUnitStealth(unit,true)
  510.       Impulser(unit,impx,-47,impy)
  511.       Rotate(unit,impx,2,impy)
  512.     end
  513.    
  514.    
  515.     local function EventSystem()
  516.       eventid = math.random(0,20)
  517.      if eventid == 0 then           -- Carrier Fleet!
  518.        for i=1, 10 do
  519.       SpawnShip(carrier)
  520.     end
  521.       Echo("Chickens unleashing plot: Carrier assault!")
  522.       end
  523.       if eventid == 1 then          -- Battleship Fleet
  524.        for i=1, 5 do
  525.       SpawnShip(battleship)
  526.     end
  527.     Echo("Chickens unleashing plot: Orbital Bombardment!")
  528.       end
  529.       if eventid == 2 then
  530.     if #nuker == 0 then
  531.       SpawnNuker()
  532.       SpawnNuker()
  533.     end
  534.         for i=1, #nuker do
  535.       NukeMe(nuker[i], math.random(0,mapx), math.random(0,mapy))
  536.         end
  537.         Echo("World War III has started!!!")
  538.       end
  539.       if eventid == 3 then           -- Skuttle Storm!
  540.         for i=1, 40 do
  541.       SkuttleStorm(scuttle)
  542.         end
  543.         Echo("Chickens unleashing plot: SkuttleStorm!")
  544.       end
  545.       if eventid == 4 then           -- Roach Storm!
  546.         for i=1, 40 do
  547.       SkuttleStorm(roach)
  548.         end
  549.         Echo("Chickens unleashing plot: RoachStorm!")
  550.       end
  551.       if eventid == 5 then           -- Detri drop!
  552.         Echo("Chickens unleashing plot: Detri Drop")
  553.         DetriDrop(detri)
  554.         DetriDrop(detri)
  555.       end
  556.       if eventid == 6 then           -- Flying ultis
  557.         Echo("Chickens unleashing plot: LOL WUT?")
  558.         for i=1, 10 do
  559.       DetriDrop(dguner)
  560.         end
  561.       end
  562.       if eventid == 7 then           -- Flying sonic coms
  563.         Echo("Chickens unleashing plot: Your mum")
  564.         for i=1, 40 do
  565.       DetriDrop(soniccom)
  566.         end
  567.       end
  568.       if eventid == 8 then           -- Let's shuffle all units' positions for teh lulz.
  569.         Echo("Chickens unleashing plot: Fuck in sky.")
  570.         allunits = Spring.GetAllUnits()
  571.         for i=1, #allunits do
  572.       x,y,z = Spring.GetUnitPosition()
  573.       if y == GetZ(x,z) then
  574.         isOnGround = true
  575.       end
  576.       if Spring.GetUnitTeam(allunits[i]) ~= gaiaid and isOnGround then
  577.         x = math.random(0,mapx)
  578.         y = math.random(0,mapy)
  579.         teleportunit(allunits[i],x,GetZ(x,y),y)
  580.       end
  581.         end
  582.       end
  583.       if eventid == 9 then           -- Profit!
  584.     allunits = Spring.GetAllUnits()
  585.     for i=1, #allunits do
  586.       uid = allunits[i]
  587.       unitDefID = Spring.GetUnitDefID(allunits[i])
  588.       if Spring.GetUnitTeam(allunits[i]) ~= gaiaid and UnitDefs[unitDefID].customParams.commtype or UnitDefs[unitDefID].customParams.iscommander then
  589.         comarray[#comarray+1] = allunits[i]
  590.       end
  591.     end
  592.     if #comarray == 0 then
  593.       return
  594.     else
  595.       watchforme = comarray[math.random(1,#comarray)]
  596.       x,_,y = Spring.GetUnitPosition(watchforme)
  597.       DropUnit(scuttle,x,y)
  598.       Echo("Chickens unleashing plot: Hammer Time")
  599.     end
  600.       end
  601.       if eventid == 10 then          -- Nuke com
  602.     allunits = Spring.GetAllUnits()
  603.     for i=1, #allunits do
  604.       uid = allunits[i]
  605.       unitDefID = Spring.GetUnitDefID(allunits[i])
  606.       if Spring.GetUnitTeam(allunits[i]) ~= gaiaid and UnitDefs[unitDefID].customParams.commtype or UnitDefs[unitDefID].customParams.iscommander then
  607.         comarray[#comarray+1] = allunits[i]
  608.       end
  609.     end
  610.     if #comarray == 0 then
  611.       return
  612.     end
  613.     watchforme = comarray[math.random(1,#comarray)]
  614.     x,_,y = Spring.GetUnitPosition(watchforme)
  615.     for i=1, #nuker do
  616.       NukeCom(nuker[i],x,y)
  617.     end
  618.       end
  619.       if eventid == 11 then         -- Carpetbombing
  620.     y = math.random(0,mapy)
  621.     for i=1, mapx/100 do
  622.       DropUnit(roach,i*100,y)
  623.     end
  624.     Echo("Chickens unleashing plot: U MAD BRO?")
  625.       end
  626.       if eventid == 12 then         --
  627.     num = math.random(1,5)*3
  628.     for i=1, num do
  629.       SendToUnsynced("mapmarker", "Incoming nuke!" ,math.random(0,mapx),math.random(0,mapy))
  630.     end
  631.     Echo("World War III has started!!!")
  632.       end
  633.       if eventid == 13 then         -- rain debris
  634.     for i=1, 40 do
  635.       unit = CreateUnit(blastwing,0,1001,0,"s",0)
  636.       Spring.TransferUnit(unit, gaiaid, false)
  637.       teleport(unit,math.random(0,mapx),400,math.random(0,mapy))
  638.       DestroyUnit(unit,true,false)
  639.     end
  640.       end
  641.       if eventid == 14 then         -- additional nukers
  642.     for i=1, 40 do
  643.       SpawnMissile("tacnuke", "bypass")
  644.     end
  645.     Echo("Chickens unleashing plot: Penetrator Drop!")
  646.       end
  647.       if eventid == 15 then         -- hammer time
  648.     for i=1, 40 do
  649.       SpawnMacro(hammer)
  650.     end
  651.     Echo("Its hammer time!")
  652.       end
  653.       if eventid == 16 then         -- Carpet Bomb
  654.     x = math.random(0,mapx)
  655.     for i=1, mapy/100 do
  656.       DropUnit(roach,x,i*100)
  657.     end
  658.     Echo("Chickens unleashing plot: U MAD BRO?")
  659.       end
  660.       if eventid == 17 then         -- QUEEN DROP!
  661.     for i=1, 3 do
  662.       DetriDrop(queen)
  663.     end
  664.     Echo("The Hive is angered!")
  665.       end
  666.       if eventid == 18 then         -- Tickstorm!
  667.     Echo("Chickens unleashing plot: FAIL MODE!")
  668.     for i=1, 40 do
  669.       DropUnit(tick, math.random(0,mapx),math.random(0,mapy))
  670.     end
  671.       end
  672.       if eventid == 19 then         -- Penes!!!
  673.     for i=1, 30 do
  674.       DetriDrop(pene)
  675.     end
  676.     Echo("Chickens unleashing plot: Siberian Husky assault.")
  677.       end
  678.       if eventid == 20 then         --SNIPERS OMFG
  679.     for i=1,40 do
  680.       DetriDrop(sniper)
  681.     end
  682.     Echo("Chickens unleashing plot: Orbital Sniper Base")
  683.       end
  684.     end
  685.    
  686.     -- Gadget Functions --
  687.    
  688.     function gadget:GameStart()
  689.      gaiaid = Spring.GetGaiaTeamID()
  690.      hello = math.random(1,3)
  691.      if hello == 1 then
  692.        SendToUnsynced("sounder", sounds_pingas,2.0)
  693.      end
  694.      if hello == 2 then
  695.        SendToUnsynced("sounder", sounds_die,1.5)
  696.      end
  697.      if hello == 3 then
  698.        SendToUnsynced("sounder", sounds_drain,1.0)
  699.      end
  700.      BuildShipArray(40)
  701.      SpawnNuker()
  702.      SpawnNuker()
  703.      SendToUnsynced("announcement", "Trolly Rain Gadget v1.2 by [ISP]IrishDruid. Please enjoy your doom. Thank you :-)")
  704.      SendToUnsynced("speccheat", "Startup time is: " .. randomtime/30 .. " seconds into the game.")
  705.      SendToUnsynced("speccheat", "Nukes will arrive in " .. nuketime/30 .. " seconds.")
  706.      SendToUnsynced("speccheat", "Zenith comes at: " .. zenithtime/30 .. ".")
  707.      SendToUnsynced("speccheat", "Tech progression rate is: " .. techrate/30 .. ".")
  708.      SendToUnsynced("playerchat", 0, "We recommend you turn off gui_news_ticker.lua widget or the battle will get very annoying.")
  709.      SendToUnsynced("setcolour", gaiaid,math.random(),math.random(),math.random())
  710.      allunits = Spring.GetAllUnits()        -- am i neccessary?
  711.      BuildMissileArray(30)
  712.     end
  713.    
  714.     function gadget:GameFrame(frame)
  715.       if frame >= randomtime and frame%techrate == 0 and techlevel <= 5 then
  716.     techlevel = techlevel + 1
  717.       end
  718.       if frame%900 == 0 then
  719.     BuildUnitArray(30)
  720.     hpbonus = hpbonus+0.05
  721.       end
  722.       if frame%1800 == 1799 then
  723.     BuildShipArray(30)
  724.     nukefrq = math.random(30,120)
  725.     nukefrq = nukefrq*30
  726.       end
  727.       if frame == randomtime then
  728.        hello = math.random(1,30)
  729.     if hello <= 10 then
  730.       SendToUnsynced("sounder", sounds_nuke)
  731.     end
  732.     if hello >= 11 and hello <= 20 then
  733.       SendToUnsynced("sounder", sounds_song)
  734.     end
  735.     if hello >= 21 then
  736.       SendToUnsynced("sounder", sounds_EA, 2.0)
  737.     end
  738.       end
  739.       if frame%30 == 0 and frame <= zenithtime+1 then
  740.     CheckMessage(frame)
  741.       end
  742.       ran = math.random(0,4)
  743.       if frame == 90 and ran == 2 then
  744.     NukeMe(nuker[1],math.random(0,mapx),math.random(0,mapy))
  745.       end
  746.       if frame == 90 and ran == 3 then
  747.     NukeMe(nuker[1],math.random(0,mapx),math.random(0,mapy))
  748.     NukeMe(nuker[2],math.random(0,mapx),math.random(0,mapy))
  749.       end
  750.       if frame%3600 == 30 and missiles then
  751.     BuildMissileArray(30)
  752.       end
  753.       if frame%10 == 0 then
  754.     gaiaunits = Spring.GetTeamUnits(gaiaid)
  755.     for i=1, #gaiaunits do
  756.       CheckPos(gaiaunits[i])
  757.     end
  758.       end
  759.       if frame >= randomtime and frame%6000 == 0 then
  760.     EventSystem()
  761.       end
  762.       if frame >= nuketime and frame%10800 == 0 then
  763.     SpawnNuker()
  764.       end
  765.       if frame >= nuketime and frame%nukefrq == 0 then
  766.     for i=1, #nuker do
  767.       NukeMe(nuker[i], math.random(0,mapx), math.random(0,mapy))
  768.     end
  769.      end
  770.      if frame >= zenithtime and frame%300 == 0 then
  771.        UpdateArtilleryAttack(Zenith)
  772.      end
  773.      if frame >= drptime and frame%300 == 5 then
  774.        UpdateArtilleryAttack(DRP)
  775.      end
  776.       if frame%3600 == 0 and frame >= missiletime and missiles then
  777.     barrage = barrage + math.random(1,10) + 600/intensity
  778.       end
  779.       if frame >= randomtime and frame%intensity == 0 then
  780.     tickstorm()
  781.       end
  782.       if frame >= randomtime and frame%1800 == 0 then
  783.     intensity = math.random(5,60)
  784.     stormlvl = 30/intensity
  785.     Echo("New intensity level: " .. stormlvl .. " drops per second.")
  786.       end
  787.     end
  788.    
  789.     function gadget:UnitDestroyed(unitID, unitDefID, UnitTeam, attackerID, attackerTeamID)
  790.       if UnitDefs[unitDefID].customParams.commtype or UnitDefs[unitDefID].customParams.iscommander then
  791.     if Spring.GetUnitRulesParam(unitID, "wasMorphedTo") == nil and UnitTeam ~= gaiaid then
  792.       if unitID ~= watchforme then
  793.         x,y,z = Spring.GetUnitPosition(unitID)
  794.         SendToUnsynced("sounder", array_sounds[math.random(1,#array_sounds)], 1.0)
  795.         SendToUnsynced("mapmarker", array_strings[math.random(1,#array_strings)], x, z)
  796.       else
  797.         x,y,z = Spring.GetUnitPosition(unitID)
  798.         SendToUnsynced("sounder", array_sounds[math.random(1,#array_sounds)], 1.0)
  799.         SendToUnsynced("mapmarker", "U Mad?", x, z)
  800.       end
  801.     end
  802.       end
  803.       for i=1, #nuker do                                            -- Check if nuker is alive
  804.     if unitID == nuker[i] then
  805.       nuker[i] = CreateUnit(nuke, mapx, 1001, mapy, "s", 0)
  806.       Spring.TransferUnit(nuker[i],gaiaid,false)
  807.       teleport(nuker[i],mapx/2+math.random(-500,500),1500,mapy/2+math.random(-500,500))
  808.       Spring.SetUnitCloak(nuker[i],true,4,1)
  809.       Spring.SetUnitArmored(nuker[i],true,100)
  810.       Spring.SetUnitStealth(nuker[i],true)
  811.     end
  812.       end
  813.     end
  814.    
  815.     function gadget:Initialize()
  816.      if Game.modShortName ~= "ZK" then
  817.        Echo("[WARNING]: Trollifier Gadget is not compatiable with this Mod. Please use Zero-K for the time being.")
  818.        gadgetHandler:RemoveGadget()
  819.        return
  820.      end
  821.      mapx = Game.mapSizeX
  822.      mapy = Game.mapSizeZ
  823.      randomtime = math.random(70,300)
  824.      randomsecs = randomtime
  825.      nuketime = math.random(randomtime+900,randomtime+1500)
  826.      missiletime = math.random(randomtime+300,randomtime+600)
  827.      zenithtime = math.random(randomtime+1000,randomtime+1600)
  828.      drptime = math.random(randomtime+1500,randomtime+2000)
  829.      shiptime = math.random(randomtime+240,randomtime+600)
  830.      techrate = math.random(30,450)
  831.      randomtime = randomtime*30
  832.      techrate = techrate*30
  833.      missiletime = missiletime*30
  834.      nuketime = nuketime*30
  835.      zenithtime = zenithtime*30
  836.      drptime = drptime*30
  837.      shiptime = shiptime*30
  838.     end
  839.    
  840.     function gadget:GameOver()
  841.       Echo("[Trollifier Rain Gadget]: Game over. Writing variables to infolog for review.")
  842.       Echo("Gaia ID: " .. gaiaid)
  843.       Echo("Start time: " .. randomtime/30)
  844.       Echo("Missiles start time: " .. missiletime/30)
  845.       Echo("Nuke start time: " .. nuketime/30)
  846.       Echo("Zenith time: " .. zenithtime/30)
  847.       Echo("Rave Party time: " .. drptime/30)
  848.       Echo("Ship time: " .. shiptime/30)
  849.       Echo("Tech Progression rate: " .. techrate/30)
  850.       Echo("--Nuke IDs--")
  851.       for i=1, #nuker do
  852.     Echo("nuker[" .. i .. "] = " .. nuker[i])
  853.       end
  854.     end
  855.    
  856.    
  857. else
  858.    
  859.     local function sounder(_,file,vol)
  860.       if vol == nil or vol == 0 then
  861.     vol = 1.0
  862.       end
  863.       PlaySound(file,vol)
  864.     end
  865.    
  866.     local function teamchat(_,id,text)
  867.       Spring.SendMessageToAllyTeam(id,text)
  868.     end
  869.    
  870.     local function setcolour(_,id,r,b,g)
  871.       Spring.SetTeamColor(id,r,b,g)
  872.     end
  873.    
  874.     local function mapmarker(_,text,x,y)
  875.       Spring.MarkerAddPoint(x,GetZ(x,y),y,text,true)
  876.     end
  877.    
  878.     local function announcement(_,text)
  879.       Spring.SendMessage(text)
  880.     end
  881.    
  882.     local function speccheat(_,text)
  883.       Spring.SendMessageToSpectators(text)
  884.     end
  885.    
  886.     local function playerchat(_,id,text)
  887.       Spring.SendMessageToPlayer(id,text)
  888.     end
  889.    
  890.     function gadget:Initialize()
  891.       gadgetHandler:AddSyncAction("sounder", sounder)
  892.       gadgetHandler:AddSyncAction("mapmarker", mapmarker)
  893.       gadgetHandler:AddSyncAction("announcement", announcement)
  894.       gadgetHandler:AddSyncAction("speccheat", speccheat)
  895.       gadgetHandler:AddSyncAction("playerchat", playerchat)
  896.       gadgetHandler:AddSyncAction("teamchat", teamchat)
  897.       gadgetHandler:AddSyncAction("setcolour", setcolour)
  898.     end
  899.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement