Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment