1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-06 00:23:49 +02:00

soft reset fix for not refreshing player modifiers

This commit is contained in:
MewMew 2019-10-28 11:15:39 +01:00
parent 3f066aa6a1
commit a569571a5a
4 changed files with 76 additions and 3 deletions

View File

@ -29,6 +29,7 @@ local function equip_players(player_starting_items)
for item, amount in pairs(player_starting_items) do
player.insert({name = item, count = amount})
end
update_player_modifiers(player)
end
end

View File

@ -41,13 +41,14 @@ end
local function process_level_6_position(p, seed, tiles, entities, markets, treasure)
local large_caves = get_noise("large_caves", p, seed)
if large_caves > -0.03 and large_caves < 0.03 then
local cave_rivers = get_noise("cave_rivers", p, seed)
if large_caves > -0.03 and large_caves < 0.03 and cave_rivers < 0.25 then
tiles[#tiles + 1] = {name = "water-green", position = p}
if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end
return
end
local cave_rivers = get_noise("cave_rivers", p, seed)
if cave_rivers > -0.05 and cave_rivers < 0.05 then
if math_random(1,48) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
if math_random(1,768) == 1 then

View File

@ -66,6 +66,11 @@ function treasure_chest(surface, position)
{{name = "lubricant-barrel", count = math_random(4,10)}, weight = 1, evo_min = 0.3, evo_max = 0.5},
{{name = "rocket-fuel", count = math_random(4,10)}, weight = 2, evo_min = 0.3, evo_max = 0.7},
--{{name = "computer", count = 1}, weight = 2, evo_min = 0, evo_max = 1},
{{name = "effectivity-module", count = math_random(1,4)}, weight = 2, evo_min = 0.1, evo_max = 1},
{{name = "productivity-module", count = math_random(1,4)}, weight = 2, evo_min = 0.1, evo_max = 1},
{{name = "speed-module", count = math_random(1,4)}, weight = 2, evo_min = 0.1, evo_max = 1},
{{name = "steel-plate", count = math_random(25,75)}, weight = 2, evo_min = 0.1, evo_max = 0.3},
{{name = "nuclear-fuel", count = 1}, weight = 2, evo_min = 0.7, evo_max = 1},

View File

@ -0,0 +1,66 @@
local function move_unit_groups()
print("move_unit_groups 1")
local surface = game.surfaces[1]
local entities = surface.find_entities_filtered({type = "character", limit = 1})
if not entities[1] then return end
local character = entities[1]
--local character = game.connected_players[1].character
--if not character then return end
--if not character.valid then return end
print("move_unit_groups 2")
for key, group in pairs(global.unit_groups) do
if group.valid then
print("move_unit_groups 3")
group.set_command({
type = defines.command.compound,
structure_type = defines.compound_command.return_last,
commands = {
{
type = defines.command.attack,
target = character,
distraction = defines.distraction.by_enemy,
},
},
})
else
print("move_unit_groups 4")
global.unit_groups[key] = nil
end
end
end
local function spawn_unit_group()
print("spawn_unit_group 1")
local surface = game.surfaces[1]
if not global.unit_groups then global.unit_groups = {} end
print("spawn_unit_group 2")
local unit = surface.create_entity({name = "small-biter", position = {0,48}, force = "enemy"})
local unit_group = surface.create_unit_group({position = {0,48}, force = "enemy"})
print("spawn_unit_group 3")
unit_group.add_member(unit)
if global.table_insert then
table.insert(global.unit_groups, unit_group)
else
global.unit_groups[#global.unit_groups + 1] = unit_group
end
print("spawn_unit_group 4")
end
local function on_tick()
spawn_unit_group()
if game.tick % 120 == 0 then move_unit_groups() end
end
local function on_player_created(event)
local player = game.players[event.player_index]
player.insert({name = "grenade", count = 1000})
player.insert({name = "power-armor", count = 1})
end
local event = require 'utils.event'
event.on_nth_tick(30, on_tick)
event.add(defines.events.on_player_created, on_player_created)