--[[ -- Precipitation v1.0 -- Author: W'rkncacnter, Irons --]] -- Feel free to modify this stuff. PRECIPITATION_PROJECTILE = "armageddon sphere" -- unused1 in physics file PRECIPITATION_WIND_DIR = 0 PRECIPITATION_WIND_ANGLE = -75 -- (-90 is straight down) CollectionsUsed = { 4 } -- Set to the collection you used in your physics for unused1. -- Don't modify this stuff Triggers = {} INTERVAL = 5 spawn = INTERVAL SPAWN_RATE = 4 -- Terrible name for this, I hope you don't try to understand how this works. RATE_SHITCATHODE = 0 TOT_SPAWN = 15 * 100 SPAWN_NUM = 100 projectile_num = 0 function Triggers.idle() if(spawn < 0) then spawn = INTERVAL end if(spawn % INTERVAL == 0) then for p in Polygons() do if(p.ceiling.transfer_mode == "landscape") then create_monsters(p) end end spawn = spawn - 1 else spawn = spawn - 1 end end function Triggers.projectile_detonated(type, owner, polygon, x, y, z) if type == PRECIPITATION_PROJECTILE then projectile_num = projectile_num - 1 end end function create_monsters(poly) area = math.floor(poly.area) for i = 0, area, 1 do if(Game.random(math.floor(TOT_SPAWN / SPAWN_NUM)) == 0) then x, y = ballsackXY(poly) proj = create_projectile(x, y, poly.ceiling.z, poly, PRECIPITATION_PROJECTILE) update_rate(proj) end end end function create_projectile(x, y, z, poly, proj) if projectile_num < (#Projectiles-128) then projectile_num = projectile_num + 1 return Projectiles.new(x, y, z, poly, proj) else return nil end end function ballsackXY(polygon) local lowestX, lowestY, highestX, highestY = 33,33,-33,-33 for e in polygon:endpoints() do if e.x < lowestX then lowestX = e.x end if e.y < lowestY then lowestY = e.y end if e.x > highestX then highestX = e.x end if e.y > highestY then highestY = e.y end end local tries = 0 while (tries < 5) do tries = tries + 1 local x = lowestX + Game.random(highestX * 1024 - lowestX * 1024) / 1024 local y = lowestY + Game.random(highestY * 1024 - lowestY * 1024) / 1024 if polygon:contains(x, y) then return x, y end end return polygon.x, polygon.y end function update_rate(proj) if(proj) then proj.facing = PRECIPITATION_WIND_DIR proj.pitch = PRECIPITATION_WIND_ANGLE RATE_SHITCATHODE = RATE_SHITCATHODE - 1 else RATE_SHITCATHODE = RATE_SHITCATHODE + 100 end if RATE_SHITCATHODE > 30 then SPAWN_RATE = SPAWN_RATE + 1 RATE_SHITCATHODE = 0 elseif RATE_SHITCATHODE < 30 then SPAWN_RATE = SPAWN_RATE - 1 RATE_SHITCATHODE = 0 end if SPAWN_RATE < 2 then SPAWN_RATE = 2 end TOT_SPAWN = TOT_SPAWN + SPAWN_RATE SPAWN_NUM = SPAWN_NUM + 1 if TOT_SPAWN > 60000 then TOT_SPAWN = (TOT_SPAWN / SPAWN_NUM) * 20 SPAWN_NUM = 20 end end