[WIP] Radar Mod

Topics and discussion about specific mods
Post Reply
kalapixie
Manual Inserter
Manual Inserter
Posts: 1
Joined: Mon Feb 18, 2013 2:14 pm
Contact:

[WIP] Radar Mod

Post by kalapixie »

Hey, guys!

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
http://pastebin.com/kZW1Qv5W

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
Last edited by rymn on Thu Feb 21, 2013 4:09 pm, edited 1 time in total.
Reason: updated title to new mod making convention

kovarex
Factorio Staff
Factorio Staff
Posts: 8058
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Radar Mod

Post by kovarex »

Congratulations on making the first mod :)

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Radar Mod

Post by rk84 »

Nice mod.
kalapixie wrote:Hey, guys!
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...
I think same happen once to me too. Only one attacking wave and then no attacks. I think I have the save, but it is in different computer. Also it was in 0.2.6
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: Radar Mod

Post by slpwnd »

That was fast. The mods are already coming :)

I like the usage of the Radar. Pretty original. We thought of having it actually help you to discover the map somehow later on. But this is simple and already useful.

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Radar Mod

Post by rk84 »

I edited the report part little bit. I made error marginal 10% instead static 3.

Code: Select all

report = math.floor( glob.attackcount + glob.attackcount * (game.getrandomnumber() - game.getrandomnumber()) / 10 )
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

Shocker
Inserter
Inserter
Posts: 20
Joined: Sat Feb 16, 2013 11:20 pm
Contact:

Re: Radar Mod

Post by Shocker »

Good idea, simple yet useful, can't go wrong there. Thanks for the mod!

Post Reply

Return to “Mods”