Page 1 of 1

Mod to turn peaceful_mode OFF after X minutes?

Posted: Sun Mar 20, 2016 9:28 pm
by Peter34
Say, 180 minutes. PeaceOff180M.zip

Upon gamestart, peaceful_mode is set to ON, regardless of game setup choice settings.

After 120 minutes, the mod sends a warning text to console output. "1 hour until Biter aggression!"
After 150 minutes, a sterner warning text: "WARNING: 30 minutes to combat"
165, sterner still. 175 a very insisting text...
At 180, peaceful_mode is set to OFF, and the console notifies all players.

Can someone make such a mod, please? Obviously it'd have to count time from true_gamestart, in order to work in multipayer. So there needs to be a world age variable of some kind. If there isn't, it probably can't be done.

I know players can already do this manually. Even in a coop MP game, the players can agree to, say, 2.5 or 4 hours of peaceful, then one player sets his phone on a timer, and when the phone beeps, he is supposed to tell the other player and then use the console command. But will he? Doing this kind of thing manually, there can be all sorts of temptations to give oneself (or the team) 5 or 10 more minutes. Maybe something happened earlier that felt unfair.

Having it all as an automated process that just works, proceeeding with machine-like mercilessness, would be preferable. Plus someone might forget to set his phone's timer. Honestly.

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Sun Mar 20, 2016 9:42 pm
by prg

Code: Select all

function print_all(text)
    for _, v in pairs(game.players) do v.print(text) end
end

script.on_init(function()
    game.peaceful_mode = true
    game.forces.enemy.kill_all_units()
end)

script.on_event(defines.events.on_tick, function(event)
    if event.tick == 60 * 60 * 120 then print_all("warning1")
    elseif event.tick == 60 * 60 * 150 then print_all("warning2")
    elseif event.tick == 60 * 60 * 180 then
        print_all("omg they're coming")
        game.peaceful_mode = false
        game.forces.enemy.kill_all_units()
    end
end)
Not tested.

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Wed Mar 23, 2016 12:12 pm
by Lerrrtaste
+++ - Supporting that!

Another Suggestion by myself is to add a command to activate/deactivate the peacful mode manually.

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Wed Mar 23, 2016 12:14 pm
by Lerrrtaste
prg wrote:

Code: Select all

function print_all(text)
    for _, v in pairs(game.players) do v.print(text) end
end

script.on_init(function()
    game.peaceful_mode = true
    game.forces.enemy.kill_all_units()
end)

script.on_event(defines.events.on_tick, function(event)
    if event.tick == 60 * 60 * 120 then print_all("warning1")
    elseif event.tick == 60 * 60 * 150 then print_all("warning2")
    elseif event.tick == 60 * 60 * 180 then
        print_all("omg they're coming")
        game.peaceful_mode = false
        game.forces.enemy.kill_all_units()
    end
end)
Not tested.

How to add this to the game :D?

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Thu Mar 24, 2016 12:54 pm
by Peter34
Lerrrtaste wrote: How to add this to the game :D?
I don't understand it at all, either. He skipped far too many steps in the procedure.

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Tue Jul 12, 2016 1:35 am
by Peter34
I still need to know which file to put that script into. I'm a very inexperienced modder. So far I've only made mods to change item recipes, or made changes to other people's mods (for my personal use) to change the stats of items (e.g. range, recipe costs).

Where do scripts go, in a mod?

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Tue Jul 12, 2016 1:51 am
by Ranakastrasz
Peter34 wrote:I still need to know which file to put that script into. I'm a very inexperienced modder. So far I've only made mods to change item recipes, or made changes to other people's mods (for my personal use) to change the stats of items (e.g. range, recipe costs).

Where do scripts go, in a mod?
control.lua

Suggest you look at other mods, and use that as a starting point. Thats how I learned Factorio Specific modding. Actually, Thats how I learned Warcraft 3 Modding, Fate Modding, and a few other games as well. find a mod, pull it apart, and figure out how it works....

Also Why I totally failed at modding Starcraft 2, (Aside from, the horrid editer) as well as a few others. Lack of examples.

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Tue Jul 12, 2016 9:04 pm
by credomane
So I was bored. Made this a mod.

Simple mod. Mostly took prg's code snippet, patched it to work with Factorio 0.13 added my own surprise and made the attached Factorio 0.13 mod.

Mod only works with the games default surface. Probably all you wanted any how.
Only enables and gives three hour warning on news games.
ALL games with mod will get the count down warnings and peaceful mode turned off after 3 hours of game ticks.

Warnings are 3 hours at start then 2 hours, 1 hour, 30 minutes, 15 minutes , 10 minutes, and a final warning at 5 minutes.
Then "They awaken..." when the mod turns off peaceful. Depending on pollution attacks could be quick or take awhile. :P

[edit]
The license on the mod is MIT except for my little surprise. The license on that is in the text file of the same name.

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Thu Jul 14, 2016 11:54 am
by Peter34
Thanks a lot! I wasn't able to decipher control.lua sufficiently to figure out what the "surprise" is (unless it's the kill_all thing which I suspect would be a necessary component of such a mod anyway, but wasn't sure about), but the rest of it looks very good!

I'll be testing the mod in a MP game, starting maybe 2 weeks and a few days from now.

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Thu Jul 14, 2016 3:00 pm
by credomane
When the game switches from peace to non-peaceful and visa-versa the biters don't switch modes. Didn't in 0.12 and older anyways. So a kill all on them is needed to "force" them to mode switch but the surprise is nothing bad or even hidden. You should have seen it when you dug about the mod. Probably didn't realize that is was the surprise is all. So even better. Consider it an extra warning to the console print out when peaceful mod turns off. :)

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Tue Nov 15, 2016 1:28 am
by Peter34
Sorry for not reporting back earlier. This mod works fine in MP 0.13, and updating it to 0.14 is as simple as editing the relevant data file and changing "0.13" to "0.14".

Thanks!

Re: Mod to turn peaceful_mode OFF after X minutes?

Posted: Tue Nov 15, 2016 4:41 pm
by aubergine18
This might also be of interest - it limits evolution of enemies based on your current research: https://mods.factorio.com/mods/Telemak/ ... nEvolution