mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-18 03:21:36 +02:00
junkyard >> unburrowing_worm
This commit is contained in:
parent
b9300a4edc
commit
a9f5b4785e
@ -11,7 +11,7 @@ require "group"
|
||||
require "player_list"
|
||||
require "poll"
|
||||
require "score"
|
||||
--require "on_tick_schedule"
|
||||
require "on_tick_schedule"
|
||||
|
||||
---- enable modules here ----
|
||||
--require "maps.tools.cheat_mode"
|
||||
@ -37,13 +37,13 @@ require "score"
|
||||
--require "maps.biter_battles"
|
||||
--require "maps.cave_miner"
|
||||
--require "maps.labyrinth"
|
||||
--require "maps.junkyard"
|
||||
require "maps.junkyard"
|
||||
--require "maps.spooky_forest"
|
||||
--require "maps.nightfall"
|
||||
--require "maps.atoll"
|
||||
--require "maps.tank_battles"
|
||||
--require "maps.spiral_troopers"
|
||||
require "maps.fish_defender"
|
||||
--require "maps.fish_defender"
|
||||
--require "maps.mountain_fortress"
|
||||
--require "maps.stoneblock"
|
||||
--require "maps.deep_jungle"
|
||||
|
63
functions/unburrowing_worm.lua
Normal file
63
functions/unburrowing_worm.lua
Normal file
@ -0,0 +1,63 @@
|
||||
local math_random = math.random
|
||||
local table_insert = table.insert
|
||||
|
||||
local worm_raffle_table = {
|
||||
[1] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret"},
|
||||
[2] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret"},
|
||||
[3] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret"},
|
||||
[4] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret"},
|
||||
[5] = {"small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret"},
|
||||
[6] = {"small-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret"},
|
||||
[7] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret"},
|
||||
[8] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret"},
|
||||
[9] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"},
|
||||
[10] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"}
|
||||
}
|
||||
|
||||
local function create_particles(surface, position, amount)
|
||||
for i = 1, amount, 1 do
|
||||
local m = math_random(8, 24)
|
||||
local m2 = m * 0.005
|
||||
|
||||
surface.create_entity({
|
||||
name = "stone-particle",
|
||||
position = position,
|
||||
frame_speed = 0.1,
|
||||
vertical_speed = 0.1,
|
||||
height = 0.1,
|
||||
movement = {m2 - (math_random(0, m) * 0.01), m2 - (math_random(0, m) * 0.01)}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local function spawn_worm(surface, position)
|
||||
local evolution = math.ceil(game.forces.enemy.evolution_factor * 10)
|
||||
local raffle = worm_raffle_table[evolution]
|
||||
local worm_name = raffle[math.random(1,#raffle)]
|
||||
surface.create_entity({name = worm_name, position = position})
|
||||
end
|
||||
|
||||
local function unburrowing_worm(surface, position)
|
||||
if not surface then return end
|
||||
if not position then return end
|
||||
if not position.x then return end
|
||||
if not position.y then return end
|
||||
|
||||
for t = 1, 360, 1 do
|
||||
if not global.on_tick_schedule[game.tick + t] then global.on_tick_schedule[game.tick + t] = {} end
|
||||
|
||||
global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = {
|
||||
func = create_particles,
|
||||
args = {surface, position, math.ceil(t * 0.07)}
|
||||
}
|
||||
|
||||
if t == 360 then
|
||||
global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = {
|
||||
func = spawn_worm,
|
||||
args = {surface, position}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return unburrowing_worm
|
@ -5,6 +5,7 @@ require "maps.modules.satellite_score"
|
||||
require "maps.modules.mineable_wreckage_yields_scrap"
|
||||
require "maps.modules.spawners_contain_biters"
|
||||
require "maps.modules.biters_yield_coins"
|
||||
local unburrowing_worm = require "functions.unburrowing_worm"
|
||||
|
||||
local simplex_noise = require 'utils.simplex_noise'
|
||||
simplex_noise = simplex_noise.d2
|
||||
@ -336,7 +337,16 @@ local function on_player_joined_game(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
if entity.name ~= "mineable-wreckage" then return end
|
||||
if math_random(1,2) ~= 1 then return end
|
||||
unburrowing_worm(entity.surface, entity.position)
|
||||
end
|
||||
|
||||
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
event.add(defines.events.on_chunk_charted, on_chunk_charted)
|
Loading…
x
Reference in New Issue
Block a user