So, I was playing Factorio, and noticed aliens weren't attacking much, at all. So I checked the freeplay script....and I couldn't find anything wrong with it. After some dabbling, I found out that on that specific save, the alien wave countdown timer was...counting up. Alas, I didn't keep the save and I can't reproduce the bug. But since I was in the script anyways, I decided to mod the game to make alien waves a lot harder, and to give user to the Radar in freeplay mode.
Changes/Features:
Makes creepers spawn in much higher frequencies faster, and adds a little more variability and randomness to how much they spawn, and how often.
Makes radars tell you when the next wave is incoming, and occasionally how many enemies are incoming. The more radars you have, the more you'll get the information you need.
Code: Select all
require "util"
require "story"
require "defines"
game.oninit = function()
glob.player = game.getplayer()
gt = game.gettext
end
game.onevent = function(event)
if event.name == "ontick" then
if glob.introduction == nil then
glob.introduction = true
game.getplayer().insert{name="iron-plate", count=8}
game.getplayer().insert{name="pistol", count=1}
game.getplayer().insert{name="basic-bullet-magazine", count=10}
end
if game.getplayer().getshiplandinginprogress() then
local timeleft = game.getplayer().gettimetoland()
if timeleft == 0 then
game.setgamestate{gamefinished=true, playerwon=true}
end
if glob.untilnextattack == nil then
glob.untilnextattack = 1
end
local secondsleft = math.floor(timeleft / 60)
local minutes = math.floor((secondsleft)/60)
local seconds = math.floor(secondsleft - 60*minutes)
game.getplayer().setgoaldescription("Time until the fleet lands: " .. string.format("%d:%02d", minutes, seconds), true)
glob.untilnextattack = glob.untilnextattack - 1
if glob.untilnextattack == 0 then
game.setmulticommand({type=defines.command.attack,
target=game.getplayer(),
distraction=defines.distraction.byenemy},
10)
glob.untilnextattack = 60 * 10
end
end
if glob.untilnextattacknormal == nil then
glob.untilnextattacknormal = 60 * 60 * 4 + (game.getrandomnumber() * 2)
glob.attackcount = 1
end
glob.untilnextattacknormal = glob.untilnextattacknormal - 1
if glob.untilnextattacknormal <= 0 then
glob.untilnextattacknormal = 60 * 60 * 3 + game.getrandomnumber() * 60 * 60 * 9
game.setmulticommand({type=defines.command.attack,
target=game.getplayer(),
distraction=defines.distraction.byenemy},
glob.attackcount)
glob.attackcount = glob.attackcount + 1 + (game.getrandomnumber() * 3)
end
end
if event.name == "onsectorscanned" then
local secondsleft = math.floor(glob.untilnextattacknormal/ 60)
local minutes = math.floor((secondsleft)/60)
local seconds = math.floor(secondsleft - 60*minutes)
glob.player.print("Estimated time until next attack: " .. string.format("%d:%02d", minutes, seconds))
randomizer = game.getrandomnumber()
if(randomizer >= .75) then
report = math.floor(glob.attackcount + (3 * game.getrandomnumber()) - (3 * game.getrandomnumber()))
glob.player.print("Reports are coming in that the enemy forces will number around: " .. report)
end
end
end
All you have to do is find your rawbots install directory, go into data/lualib, make a copy of your freeplay.lua, and then copy/paste inside the current one with that.
- Mel