mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-14 02:34:09 +02:00
mountain fortress fixes
This commit is contained in:
parent
a7724f9f49
commit
5787381c68
@ -1,8 +1,12 @@
|
||||
local Event = require 'utils.event'
|
||||
local Timestamp = require 'utils.timestamp'
|
||||
local Server = require 'utils.server'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Task = require 'utils.task'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
local format = string.format
|
||||
|
||||
commands.add_command(
|
||||
'reset_game',
|
||||
@ -200,3 +204,43 @@ commands.add_command(
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local function on_console_command(event)
|
||||
local cmd = event.command
|
||||
if not event.player_index then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
local param = event.parameters
|
||||
|
||||
if not player.admin then
|
||||
return
|
||||
end
|
||||
|
||||
local server_time = Server.get_current_time()
|
||||
if server_time then
|
||||
server_time = format('(Server time: %s)', Timestamp.to_string(server_time))
|
||||
else
|
||||
server_time = game.tick
|
||||
end
|
||||
|
||||
if player then
|
||||
if param then
|
||||
print(player.name .. ' used command: ' .. cmd .. ' with param: ' .. param .. ' at tick: ' .. server_time)
|
||||
return
|
||||
else
|
||||
print(player.name .. ' used command: ' .. cmd .. ' at tick: ' .. server_time)
|
||||
return
|
||||
end
|
||||
else
|
||||
if param then
|
||||
print('used command: ' .. cmd .. ' with param: ' .. param .. ' at tick: ' .. server_time)
|
||||
return
|
||||
else
|
||||
print('used command: ' .. cmd .. ' at tick: ' .. server_time)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_console_command, on_console_command)
|
||||
|
@ -9,6 +9,7 @@ local RPG = require 'maps.mountain_fortress_v3.rpg'
|
||||
local Mining = require 'maps.mountain_fortress_v3.mining'
|
||||
local Terrain = require 'maps.mountain_fortress_v3.terrain'
|
||||
local BiterHealthBooster = require 'modules.biter_health_booster'
|
||||
local Traps = require 'maps.mountain_fortress_v3.traps'
|
||||
--local HD = require 'modules.hidden_dimension.main'
|
||||
|
||||
-- tables
|
||||
@ -81,7 +82,6 @@ local function set_objective_health(final_damage_amount)
|
||||
|
||||
if this.locomotive_health <= 0 then
|
||||
Public.loco_died()
|
||||
this.locomotive_health = 0
|
||||
end
|
||||
|
||||
local m = this.locomotive_health / this.locomotive_max_health
|
||||
@ -318,6 +318,10 @@ local function on_player_mined_entity(event)
|
||||
entity.destroy()
|
||||
return
|
||||
end
|
||||
if math_random(1, 512) == 1 then
|
||||
Traps(entity.surface, entity.position)
|
||||
return
|
||||
end
|
||||
hidden_biter_pet(event)
|
||||
hidden_treasure(event)
|
||||
angry_tree(event.entity, game.players[event.player_index].character)
|
||||
@ -361,8 +365,88 @@ local function on_robot_mined_entity(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_damage(event)
|
||||
local entity = event.entity
|
||||
local damage = event.original_damage_amount + event.original_damage_amount * math_random(1, 100)
|
||||
if entity.prototype.resistances then
|
||||
if entity.prototype.resistances.physical then
|
||||
damage = damage - entity.prototype.resistances.physical.decrease
|
||||
damage = damage - damage * entity.prototype.resistances.physical.percent
|
||||
end
|
||||
end
|
||||
damage = math.round(damage, 3)
|
||||
if damage < 1 then
|
||||
damage = 1
|
||||
end
|
||||
return damage
|
||||
end
|
||||
|
||||
local function kaboom(entity, target, damage)
|
||||
local base_vector = {target.position.x - entity.position.x, target.position.y - entity.position.y}
|
||||
|
||||
local vector = {base_vector[1], base_vector[2]}
|
||||
vector[1] = vector[1] * 512
|
||||
vector[2] = vector[2] * 256
|
||||
|
||||
local msg = {'TASTY', 'MUNCH', 'SNACK_TIME', 'OVER 9000!'}
|
||||
|
||||
entity.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {entity.position.x + base_vector[1] * 0.5, entity.position.y + base_vector[2] * 0.5},
|
||||
text = msg[math_random(1, #msg)],
|
||||
color = {255, 0, 0}
|
||||
}
|
||||
)
|
||||
|
||||
if math.abs(vector[1]) > math.abs(vector[2]) then
|
||||
local d = math.abs(vector[1])
|
||||
if math.abs(vector[1]) > 0 then
|
||||
vector[1] = vector[1] / d
|
||||
end
|
||||
if math.abs(vector[2]) > 0 then
|
||||
vector[2] = vector[2] / d
|
||||
end
|
||||
else
|
||||
local d = math.abs(vector[2])
|
||||
if math.abs(vector[2]) > 0 then
|
||||
vector[2] = vector[2] / d
|
||||
end
|
||||
if math.abs(vector[1]) > 0 and d > 0 then
|
||||
vector[1] = vector[1] / d
|
||||
end
|
||||
end
|
||||
|
||||
vector[1] = vector[1] * 1.5
|
||||
vector[2] = vector[2] * 1.5
|
||||
|
||||
local a = 0.25
|
||||
|
||||
for i = 1, 16, 1 do
|
||||
for x = i * -1 * a, i * a, 1 do
|
||||
for y = i * -1 * a, i * a, 1 do
|
||||
local p = {entity.position.x + x + vector[1] * i, entity.position.y + y + vector[2] * i}
|
||||
entity.surface.create_trivial_smoke({name = 'fire-smoke', position = p})
|
||||
for _, e in pairs(entity.surface.find_entities({{p[1] - a, p[2] - a}, {p[1] + a, p[2] + a}})) do
|
||||
if e.valid then
|
||||
if e.health then
|
||||
if e.destructible and e.minable then
|
||||
if e.force.index ~= entity.force.index then
|
||||
e.health = e.health - damage * 0.05
|
||||
if e.health <= 0 then
|
||||
e.die(e.force.name, entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function boss_puncher(event)
|
||||
local wd = WD.get_table()
|
||||
local cause = event.cause
|
||||
if not cause then
|
||||
return
|
||||
@ -371,6 +455,10 @@ local function boss_puncher(event)
|
||||
return
|
||||
end
|
||||
|
||||
if cause.force.index ~= 2 then
|
||||
return
|
||||
end
|
||||
|
||||
local entity = event.entity
|
||||
|
||||
if entity.force.index ~= 1 then
|
||||
@ -383,99 +471,10 @@ local function boss_puncher(event)
|
||||
return
|
||||
end
|
||||
|
||||
local function kaboom(e_cause, target, damage)
|
||||
local base_vector = {target.position.x - e_cause.position.x, target.position.y - e_cause.position.y}
|
||||
|
||||
local vector = {base_vector[1], base_vector[2]}
|
||||
vector[1] = vector[1] * 512
|
||||
vector[2] = vector[2] * 256
|
||||
|
||||
local msg = {'TASTY', 'MUNCH', 'SNACK_TIME', 'OVER 9000!'}
|
||||
|
||||
e_cause.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {e_cause.position.x + base_vector[1] * 0.5, e_cause.position.y + base_vector[2] * 0.5},
|
||||
text = msg[math_random(1, #msg)],
|
||||
color = {255, 0, 0}
|
||||
}
|
||||
)
|
||||
e_cause.surface.create_entity({name = 'blood-explosion-huge', position = target.position})
|
||||
e_cause.surface.create_entity(
|
||||
{
|
||||
name = 'big-artillery-explosion',
|
||||
position = {target.position.x + vector[1] * 0.5, target.position.y + vector[2] * 0.5}
|
||||
}
|
||||
)
|
||||
|
||||
if math.abs(vector[1]) > math.abs(vector[2]) then
|
||||
local d = math.abs(vector[1])
|
||||
if math.abs(vector[1]) > 0 then
|
||||
vector[1] = vector[1] / d
|
||||
end
|
||||
if math.abs(vector[2]) > 0 then
|
||||
vector[2] = vector[2] / d
|
||||
end
|
||||
else
|
||||
local d = math.abs(vector[2])
|
||||
if math.abs(vector[2]) > 0 then
|
||||
vector[2] = vector[2] / d
|
||||
end
|
||||
if math.abs(vector[1]) > 0 and d > 0 then
|
||||
vector[1] = vector[1] / d
|
||||
end
|
||||
end
|
||||
|
||||
vector[1] = vector[1] * 1.5
|
||||
vector[2] = vector[2] * 1.5
|
||||
|
||||
local a = 0.25
|
||||
|
||||
for i = 1, 16, 1 do
|
||||
for x = i * -1 * a, i * a, 1 do
|
||||
for y = i * -1 * a, i * a, 1 do
|
||||
if not e_cause.valid then
|
||||
return
|
||||
end
|
||||
local p = {e_cause.position.x + x + vector[1] * i, e_cause.position.y + y + vector[2] * i}
|
||||
e_cause.surface.create_trivial_smoke({name = 'fire-smoke', position = p})
|
||||
for _, e in pairs(entity.surface.find_entities({{p[1] - a, p[2] - a}, {p[1] + a, p[2] + a}})) do
|
||||
if e.valid then
|
||||
if e.health then
|
||||
if e.destructible and e.minable then
|
||||
if e.force.index ~= e_cause.force.index then
|
||||
e.health = e.health - damage * 0.05
|
||||
if e.health <= 0 then
|
||||
e.die(e.force.name, e_cause)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local function get_damage()
|
||||
local damage = event.original_damage_amount + event.original_damage_amount * math_random(1, 100)
|
||||
if entity.prototype.resistances then
|
||||
if entity.prototype.resistances.physical then
|
||||
damage = damage - entity.prototype.resistances.physical.decrease
|
||||
damage = damage - damage * entity.prototype.resistances.physical.percent
|
||||
end
|
||||
end
|
||||
damage = math.round(damage, 3)
|
||||
if damage < 1 then
|
||||
damage = 1
|
||||
end
|
||||
return damage
|
||||
end
|
||||
if wd.boss_wave then
|
||||
if math_random(0, 512) == 1 then
|
||||
kaboom(cause, entity, get_damage())
|
||||
return
|
||||
end
|
||||
local wd = WD.get_table()
|
||||
if wd.boss_wave_warning then
|
||||
kaboom(cause, entity, get_damage(event))
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@ -492,7 +491,9 @@ local function on_entity_damaged(event)
|
||||
|
||||
protect_entities(event)
|
||||
biters_chew_rocks_faster(event)
|
||||
boss_puncher(event)
|
||||
if math_random(0, 512) == 1 then
|
||||
boss_puncher(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_repaired_entity(event)
|
||||
@ -573,6 +574,10 @@ local function on_entity_died(event)
|
||||
hidden_biter(event.entity)
|
||||
return
|
||||
end
|
||||
if math_random(1, 512) == 1 then
|
||||
Traps(entity.surface, entity.position)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if entity.type == 'tree' then
|
||||
@ -589,14 +594,14 @@ end
|
||||
|
||||
function Public.set_scores()
|
||||
local this = WPT.get()
|
||||
local wagon = this.locomotive_cargo
|
||||
if not wagon then
|
||||
local loco = this.locomotive
|
||||
if not loco then
|
||||
return
|
||||
end
|
||||
if not wagon.valid then
|
||||
if not loco.valid then
|
||||
return
|
||||
end
|
||||
local score = math_floor(wagon.position.y * -1)
|
||||
local score = math_floor(loco.position.y * -1)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if score > Map_score.get_score(player) then
|
||||
Map_score.set_score(player, score)
|
||||
@ -625,8 +630,6 @@ function Public.loco_died()
|
||||
-- }
|
||||
-- )
|
||||
this.locomotive_health = 0
|
||||
this.locomotive.health = 1
|
||||
this.locomotive.destructible = false
|
||||
this.locomotive.color = {0.49, 0, 255, 1}
|
||||
rendering.set_text(this.health_text, 'HP: ' .. this.locomotive_health .. ' / ' .. this.locomotive_max_health)
|
||||
wave_defense_table.game_lost = true
|
||||
|
@ -290,7 +290,8 @@ Public.light_oil_ammo = {name = 'light-oil', amount = 100}
|
||||
Public.artillery_shell_ammo = {name = 'artillery-shell', count = 15}
|
||||
Public.laser_turrent_power_source = {buffer_size = 2400000, power_production = 40000}
|
||||
|
||||
Event.on_nth_tick(15, tick)
|
||||
Event.on_nth_tick(20, tick)
|
||||
--Event.add(defines.events.on_tick, tick)
|
||||
Event.add(defines.events.on_entity_died, turret_died)
|
||||
|
||||
return Public
|
||||
|
@ -7,8 +7,8 @@ local Terrain = require 'maps.mountain_fortress_v3.terrain'.heavy_functions
|
||||
|
||||
local insert = table.insert
|
||||
|
||||
local tiles_per_call
|
||||
local total_calls
|
||||
local tiles_per_call = 32
|
||||
local total_calls = math.ceil(1024 / tiles_per_call)
|
||||
local regen_decoratives = false
|
||||
local force_chunk = false
|
||||
|
||||
@ -479,29 +479,16 @@ end
|
||||
local do_chunk = Public.do_chunk
|
||||
local schedule_chunk = Public.schedule_chunk
|
||||
|
||||
function Public.init(args)
|
||||
if args then
|
||||
tiles_per_call = args.tiles_per_call or 32
|
||||
regen_decoratives = args.regen_decoratives or false
|
||||
else
|
||||
tiles_per_call = 32
|
||||
regen_decoratives = false
|
||||
end
|
||||
|
||||
total_calls = math.ceil(1024 / tiles_per_call)
|
||||
end
|
||||
|
||||
local function on_chunk(event)
|
||||
if force_chunk then
|
||||
do_chunk(event)
|
||||
elseif event.tick == 0 then
|
||||
do_chunk(event)
|
||||
--do_chunk(event)
|
||||
else
|
||||
schedule_chunk(event)
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk)
|
||||
Public.init()
|
||||
|
||||
return Public
|
||||
|
@ -193,6 +193,11 @@ local function on_player_changed_surface(event)
|
||||
local icw_locomotive = WPT.get('icw_locomotive')
|
||||
local loco_surface = icw_locomotive.surface
|
||||
|
||||
if player.gui.top[main_button_name] then
|
||||
player.gui.top[main_button_name].tooltip = 'Shows statistics!'
|
||||
player.gui.top[main_button_name].sprite = 'item/dummy-steel-axe'
|
||||
end
|
||||
|
||||
if not locomotive then
|
||||
return
|
||||
end
|
||||
@ -208,6 +213,10 @@ local function on_player_changed_surface(event)
|
||||
end
|
||||
|
||||
if player.surface == locomotive.surface then
|
||||
local s = player.gui.left.icw_map
|
||||
if s and s.visible then
|
||||
player.gui.left.icw_map.visible = false
|
||||
end
|
||||
player.gui.top[main_button_name].tooltip = 'Shows statistics!'
|
||||
player.gui.top[main_button_name].sprite = 'item/dummy-steel-axe'
|
||||
elseif player.surface == loco_surface then
|
||||
|
@ -396,13 +396,13 @@ function Public.create_wagon_room(icw, wagon)
|
||||
end
|
||||
|
||||
if wagon.entity.type == 'cargo-wagon' then
|
||||
local get_icw = ICW.get()
|
||||
local multiple_chests = ICW.get('multiple_chests')
|
||||
local position1 = {-12, 1}
|
||||
local position2 = {12, 1}
|
||||
local position3 = {-12, 58}
|
||||
local position4 = {12, 58}
|
||||
|
||||
if get_icw.multiple_chests then
|
||||
if multiple_chests then
|
||||
local e1 =
|
||||
surface.create_entity(
|
||||
{
|
||||
@ -534,6 +534,14 @@ function Public.create_wagon_room(icw, wagon)
|
||||
end
|
||||
|
||||
function Public.create_wagon(icw, created_entity, delay_surface)
|
||||
if not created_entity then
|
||||
return
|
||||
end
|
||||
|
||||
if not created_entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if not created_entity.unit_number then
|
||||
return
|
||||
end
|
||||
|
@ -490,9 +490,15 @@ local function gui_click(event)
|
||||
if not player.opened then
|
||||
return
|
||||
end
|
||||
if not player.opened.name == 'market' then
|
||||
|
||||
if not player.opened.name then
|
||||
return
|
||||
end
|
||||
|
||||
if not player.opened.name == 'market_gui' then
|
||||
return
|
||||
end
|
||||
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
|
@ -1,18 +1,5 @@
|
||||
require 'maps.mountain_fortress_v3.generate'
|
||||
require 'maps.mountain_fortress_v3.commands'
|
||||
require 'maps.mountain_fortress_v3.breached_wall'
|
||||
|
||||
require 'modules.dynamic_landfill'
|
||||
require 'modules.shotgun_buff'
|
||||
require 'modules.rocks_heal_over_time'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
require 'modules.rocks_yield_ore_veins'
|
||||
require 'modules.spawners_contain_biters'
|
||||
require 'modules.biters_yield_coins'
|
||||
require 'modules.wave_defense.main'
|
||||
require 'modules.mineable_wreckage_yields_scrap'
|
||||
|
||||
local CS = require 'maps.mountain_fortress_v3.surface'
|
||||
local Map_score = require 'comfy_panel.map_score'
|
||||
local Server = require 'utils.server'
|
||||
local Explosives = require 'modules.explosives'
|
||||
local Balance = require 'maps.mountain_fortress_v3.balance'
|
||||
@ -34,6 +21,20 @@ local Difficulty = require 'modules.difficulty_vote'
|
||||
local Task = require 'utils.task'
|
||||
--local HD = require 'modules.hidden_dimension.main'
|
||||
|
||||
require 'maps.mountain_fortress_v3.generate'
|
||||
require 'maps.mountain_fortress_v3.commands'
|
||||
require 'maps.mountain_fortress_v3.breached_wall'
|
||||
|
||||
require 'modules.dynamic_landfill'
|
||||
require 'modules.shotgun_buff'
|
||||
require 'modules.rocks_heal_over_time'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
require 'modules.rocks_yield_ore_veins'
|
||||
require 'modules.spawners_contain_biters'
|
||||
require 'modules.biters_yield_coins'
|
||||
require 'modules.wave_defense.main'
|
||||
require 'modules.mineable_wreckage_yields_scrap'
|
||||
|
||||
local Public = {}
|
||||
-- local raise_event = script.raise_event
|
||||
|
||||
@ -213,6 +214,7 @@ function Public.reset_map()
|
||||
ICW.reset()
|
||||
game.reset_time_played()
|
||||
WPT.reset_table()
|
||||
Map_score.reset_score()
|
||||
|
||||
disable_tech()
|
||||
|
||||
@ -225,6 +227,8 @@ function Public.reset_map()
|
||||
Balance.init_enemy_weapon_damage()
|
||||
|
||||
global.bad_fire_history = {}
|
||||
global.custom_highscore.description = 'Wagon distance reached:'
|
||||
Entities.set_scores()
|
||||
global.friendly_fire_history = {}
|
||||
global.landfill_history = {}
|
||||
global.mining_history = {}
|
||||
@ -311,15 +315,14 @@ local function on_player_changed_position(event)
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local players = WPT.get('players')
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local this = WPT.get()
|
||||
local player = game.players[event.player_index]
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
|
||||
set_difficulty()
|
||||
|
||||
if not players[player.index] then
|
||||
players[player.index] = {
|
||||
if not this.players[player.index] then
|
||||
this.players[player.index] = {
|
||||
data = {}
|
||||
}
|
||||
player.print('Greetings, ' .. player.name .. '!', {r = 0.98, g = 0.66, b = 0.22})
|
||||
@ -330,7 +333,7 @@ local function on_player_joined_game(event)
|
||||
--RPG.gain_xp(player, 515)
|
||||
end
|
||||
|
||||
if player.surface.index ~= active_surface_index then
|
||||
if player.surface.index ~= this.active_surface_index then
|
||||
player.teleport(
|
||||
surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5),
|
||||
surface
|
||||
@ -566,8 +569,6 @@ local on_init = function()
|
||||
local this = WPT.get()
|
||||
Public.reset_map()
|
||||
|
||||
global.custom_highscore.description = 'Wagon distance reached:'
|
||||
|
||||
local difficulties = {
|
||||
[1] = {
|
||||
name = 'Easy',
|
||||
|
@ -66,12 +66,33 @@ local rpg_frame_icons = {
|
||||
'entity/behemoth-spitter'
|
||||
}
|
||||
|
||||
local rpg_xp_yield = {
|
||||
['behemoth-biter'] = 16,
|
||||
['behemoth-spitter'] = 16,
|
||||
['behemoth-worm-turret'] = 64,
|
||||
['big-biter'] = 8,
|
||||
['big-spitter'] = 8,
|
||||
['big-worm-turret'] = 48,
|
||||
['biter-spawner'] = 64,
|
||||
['character'] = 16,
|
||||
['gun-turret'] = 8,
|
||||
['laser-turret'] = 16,
|
||||
['medium-biter'] = 4,
|
||||
['medium-spitter'] = 4,
|
||||
['medium-worm-turret'] = 32,
|
||||
['small-biter'] = 1,
|
||||
['small-spitter'] = 1,
|
||||
['small-worm-turret'] = 16,
|
||||
['spitter-spawner'] = 64
|
||||
}
|
||||
|
||||
Global.register(
|
||||
{rpg_t = rpg_t, rpg_frame_icons = rpg_frame_icons, rpg_extra = rpg_extra},
|
||||
{rpg_t = rpg_t, rpg_frame_icons = rpg_frame_icons, rpg_extra = rpg_extra, rpg_xp_yield = rpg_xp_yield},
|
||||
function(tbl)
|
||||
rpg_t = tbl.rpg_t
|
||||
rpg_frame_icons = tbl.rpg_frame_icons
|
||||
rpg_extra = tbl.rpg_extra
|
||||
rpg_xp_yield = tbl.rpg_xp_yield
|
||||
end
|
||||
)
|
||||
|
||||
@ -108,26 +129,6 @@ local classes = {
|
||||
['vitality'] = 'TANK'
|
||||
}
|
||||
|
||||
local xp_yield = {
|
||||
['behemoth-biter'] = 16,
|
||||
['behemoth-spitter'] = 16,
|
||||
['behemoth-worm-turret'] = 64,
|
||||
['big-biter'] = 8,
|
||||
['big-spitter'] = 8,
|
||||
['big-worm-turret'] = 48,
|
||||
['biter-spawner'] = 64,
|
||||
['character'] = 16,
|
||||
['gun-turret'] = 8,
|
||||
['laser-turret'] = 16,
|
||||
['medium-biter'] = 4,
|
||||
['medium-spitter'] = 4,
|
||||
['medium-worm-turret'] = 32,
|
||||
['small-biter'] = 1,
|
||||
['small-spitter'] = 1,
|
||||
['small-worm-turret'] = 16,
|
||||
['spitter-spawner'] = 64
|
||||
}
|
||||
|
||||
local enemy_types = {
|
||||
['unit'] = true,
|
||||
['unit-spawner'] = true,
|
||||
@ -159,16 +160,16 @@ local function level_limit_exceeded(player, value)
|
||||
end
|
||||
|
||||
local limits = {
|
||||
[1] = 20,
|
||||
[2] = 40,
|
||||
[3] = 60,
|
||||
[4] = 80,
|
||||
[5] = 100,
|
||||
[6] = 120,
|
||||
[7] = 140,
|
||||
[8] = 160,
|
||||
[9] = 180,
|
||||
[10] = 200
|
||||
[1] = 30,
|
||||
[2] = 50,
|
||||
[3] = 70,
|
||||
[4] = 90,
|
||||
[5] = 110,
|
||||
[6] = 130,
|
||||
[7] = 150,
|
||||
[8] = 170,
|
||||
[9] = 190,
|
||||
[10] = 210
|
||||
}
|
||||
|
||||
local level = rpg_t[player.index].level
|
||||
@ -269,7 +270,7 @@ local function update_player_stats(player)
|
||||
local strength = rpg_t[player.index].strength - 10
|
||||
player_modifiers[player.index].character_inventory_slots_bonus['rpg'] = math.round(strength * 0.2, 3)
|
||||
player_modifiers[player.index].character_mining_speed_modifier['rpg'] = math.round(strength * 0.007, 3)
|
||||
player_modifiers[player.index].character_maximum_following_robot_count_bonus['rpg'] = math.round(strength * 0.2, 3)
|
||||
player_modifiers[player.index].character_maximum_following_robot_count_bonus['rpg'] = math.round(strength * 0.07, 1)
|
||||
|
||||
local magic = rpg_t[player.index].magicka - 10
|
||||
local v = magic * 0.22
|
||||
@ -336,7 +337,7 @@ local function add_gui_stat(element, value, width)
|
||||
return e
|
||||
end
|
||||
|
||||
local function add_gui_increase_stat(element, name, player, width)
|
||||
local function add_gui_increase_stat(element, name, player)
|
||||
local sprite = 'virtual-signal/signal-red'
|
||||
local symbol = '✚'
|
||||
if rpg_t[player.index].points_to_distribute <= 0 then
|
||||
@ -383,6 +384,9 @@ local function draw_gui(player, forced)
|
||||
return
|
||||
end
|
||||
|
||||
local value
|
||||
local e
|
||||
|
||||
local frame = player.gui.left.add({type = 'frame', name = 'rpg', direction = 'vertical'})
|
||||
frame.style.maximal_width = 425
|
||||
frame.style.minimal_width = 425
|
||||
@ -391,15 +395,15 @@ local function draw_gui(player, forced)
|
||||
add_separator(frame, 400)
|
||||
|
||||
local t = frame.add({type = 'table', column_count = 2})
|
||||
local e = add_gui_stat(t, player.name, 200)
|
||||
e = add_gui_stat(t, player.name, 200)
|
||||
e.style.font_color = player.chat_color
|
||||
e.style.font = 'default-large-bold'
|
||||
local e = add_gui_stat(t, get_class(player), 200)
|
||||
e = add_gui_stat(t, get_class(player), 200)
|
||||
e.style.font = 'default-large-bold'
|
||||
|
||||
add_separator(frame, 400)
|
||||
|
||||
local t = frame.add({type = 'table', column_count = 4})
|
||||
t = frame.add({type = 'table', column_count = 4})
|
||||
t.style.cell_padding = 1
|
||||
|
||||
local level_tooltip =
|
||||
@ -407,16 +411,20 @@ local function draw_gui(player, forced)
|
||||
level_limit_exceeded(player, true) .. '\nIncreases by breaching walls/zones.'
|
||||
|
||||
add_gui_description(t, 'LEVEL', 80)
|
||||
local e = add_gui_stat(t, rpg_t[player.index].level, 80)
|
||||
e.tooltip = level_tooltip
|
||||
e = add_gui_stat(t, rpg_t[player.index].level, 80)
|
||||
if rpg_extra.level_limit_enabled then
|
||||
e.tooltip = level_tooltip
|
||||
else
|
||||
e.tooltip = gain_info_tooltip
|
||||
end
|
||||
|
||||
add_gui_description(t, 'EXPERIENCE', 100)
|
||||
local e = add_gui_stat(t, math.floor(rpg_t[player.index].xp), 125)
|
||||
e = add_gui_stat(t, math.floor(rpg_t[player.index].xp), 125)
|
||||
e.tooltip = gain_info_tooltip
|
||||
|
||||
if not rpg_t[player.index].reset then
|
||||
add_gui_description(t, 'RESET', 80)
|
||||
local e = add_gui_stat(t, rpg_t[player.index].reset, 80)
|
||||
e = add_gui_stat(t, rpg_t[player.index].reset, 80)
|
||||
if rpg_t[player.index].level <= 19 then
|
||||
e.tooltip = reset_not_available
|
||||
else
|
||||
@ -428,7 +436,7 @@ local function draw_gui(player, forced)
|
||||
end
|
||||
|
||||
add_gui_description(t, 'NEXT LEVEL', 100)
|
||||
local e = add_gui_stat(t, experience_levels[rpg_t[player.index].level + 1], 125)
|
||||
e = add_gui_stat(t, experience_levels[rpg_t[player.index].level + 1], 125)
|
||||
e.tooltip = gain_info_tooltip
|
||||
|
||||
add_separator(frame, 400)
|
||||
@ -440,35 +448,35 @@ local function draw_gui(player, forced)
|
||||
local w2 = 63
|
||||
|
||||
local tip = 'Increases inventory slots, mining speed.\nIncreases melee damage and amount of robot followers.'
|
||||
local e = add_gui_description(tt, 'STRENGTH', w1)
|
||||
e = add_gui_description(tt, 'STRENGTH', w1)
|
||||
e.tooltip = tip
|
||||
local e = add_gui_stat(tt, rpg_t[player.index].strength, w2)
|
||||
e = add_gui_stat(tt, rpg_t[player.index].strength, w2)
|
||||
e.tooltip = tip
|
||||
add_gui_increase_stat(tt, 'strength', player)
|
||||
|
||||
local tip = 'Increases reach distance.'
|
||||
local e = add_gui_description(tt, 'MAGIC', w1)
|
||||
e = add_gui_description(tt, 'MAGIC', w1)
|
||||
e.tooltip = tip
|
||||
local e = add_gui_stat(tt, rpg_t[player.index].magicka, w2)
|
||||
e = add_gui_stat(tt, rpg_t[player.index].magicka, w2)
|
||||
e.tooltip = tip
|
||||
add_gui_increase_stat(tt, 'magicka', player)
|
||||
|
||||
local tip = 'Increases running and crafting speed.'
|
||||
local e = add_gui_description(tt, 'DEXTERITY', w1)
|
||||
e = add_gui_description(tt, 'DEXTERITY', w1)
|
||||
e.tooltip = tip
|
||||
local e = add_gui_stat(tt, rpg_t[player.index].dexterity, w2)
|
||||
e = add_gui_stat(tt, rpg_t[player.index].dexterity, w2)
|
||||
e.tooltip = tip
|
||||
add_gui_increase_stat(tt, 'dexterity', player)
|
||||
|
||||
local tip = 'Increases health.\nIncreases melee life on-hit.'
|
||||
local e = add_gui_description(tt, 'VITALITY', w1)
|
||||
e = add_gui_description(tt, 'VITALITY', w1)
|
||||
e.tooltip = tip
|
||||
local e = add_gui_stat(tt, rpg_t[player.index].vitality, w2)
|
||||
e = add_gui_stat(tt, rpg_t[player.index].vitality, w2)
|
||||
e.tooltip = tip
|
||||
add_gui_increase_stat(tt, 'vitality', player)
|
||||
|
||||
add_gui_description(tt, 'POINTS TO\nDISTRIBUTE', w1)
|
||||
local e = add_gui_stat(tt, rpg_t[player.index].points_to_distribute, w2)
|
||||
e = add_gui_stat(tt, rpg_t[player.index].points_to_distribute, w2)
|
||||
e.style.font_color = {200, 0, 0}
|
||||
add_gui_description(tt, ' ', w2)
|
||||
|
||||
@ -507,32 +515,31 @@ local function draw_gui(player, forced)
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'MINING\nSPEED', w1)
|
||||
local value =
|
||||
value =
|
||||
math_round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100) ..
|
||||
'%'
|
||||
add_gui_stat(tt, value, w2)
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'SLOT\nBONUS', w1)
|
||||
local value =
|
||||
'+ ' .. math_round(player.force.character_inventory_slots_bonus + player.character_inventory_slots_bonus)
|
||||
value = '+ ' .. math_round(player.force.character_inventory_slots_bonus + player.character_inventory_slots_bonus)
|
||||
add_gui_stat(tt, value, w2)
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'MELEE\nDAMAGE', w1)
|
||||
local value = math_round(100 * (1 + get_melee_modifier(player))) .. '%'
|
||||
local e = add_gui_stat(tt, value, w2)
|
||||
value = math_round(100 * (1 + get_melee_modifier(player))) .. '%'
|
||||
e = add_gui_stat(tt, value, w2)
|
||||
e.tooltip =
|
||||
'Life on-hit: ' .. get_life_on_hit(player) .. '\nOne punch chance: ' .. get_one_punch_chance(player) .. '%'
|
||||
|
||||
local e = add_gui_description(tt, '', w0)
|
||||
e = add_gui_description(tt, '', w0)
|
||||
e.style.maximal_height = 10
|
||||
local e = add_gui_description(tt, '', w0)
|
||||
e = add_gui_description(tt, '', w0)
|
||||
e.style.maximal_height = 10
|
||||
local e = add_gui_description(tt, '', w0)
|
||||
e = add_gui_description(tt, '', w0)
|
||||
e.style.maximal_height = 10
|
||||
|
||||
local value = '+ ' .. (player.force.character_reach_distance_bonus + player.character_reach_distance_bonus)
|
||||
value = '+ ' .. (player.force.character_reach_distance_bonus + player.character_reach_distance_bonus)
|
||||
local tooltip = ''
|
||||
tooltip = tooltip .. 'Reach distance bonus: ' .. player.character_reach_distance_bonus
|
||||
tooltip = tooltip .. '\nBuild distance bonus: ' .. player.character_build_distance_bonus
|
||||
@ -541,48 +548,48 @@ local function draw_gui(player, forced)
|
||||
tooltip = tooltip .. '\nItem pickup distance bonus: ' .. player.character_item_pickup_distance_bonus
|
||||
tooltip = tooltip .. '\nResource reach distance bonus: ' .. player.character_resource_reach_distance_bonus
|
||||
add_gui_description(tt, ' ', w0)
|
||||
local e = add_gui_description(tt, 'REACH\nDISTANCE', w1)
|
||||
e = add_gui_description(tt, 'REACH\nDISTANCE', w1)
|
||||
e.tooltip = tooltip
|
||||
local e = add_gui_stat(tt, value, w2)
|
||||
e = add_gui_stat(tt, value, w2)
|
||||
e.tooltip = tooltip
|
||||
|
||||
local e = add_gui_description(tt, '', w0)
|
||||
e = add_gui_description(tt, '', w0)
|
||||
e.style.maximal_height = 10
|
||||
local e = add_gui_description(tt, '', w0)
|
||||
e = add_gui_description(tt, '', w0)
|
||||
e.style.maximal_height = 10
|
||||
local e = add_gui_description(tt, '', w0)
|
||||
e = add_gui_description(tt, '', w0)
|
||||
e.style.maximal_height = 10
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'CRAFTING\nSPEED', w1)
|
||||
local value =
|
||||
value =
|
||||
math_round((player.force.manual_crafting_speed_modifier + player.character_crafting_speed_modifier + 1) * 100) ..
|
||||
'%'
|
||||
add_gui_stat(tt, value, w2)
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'RUNNING\nSPEED', w1)
|
||||
local value =
|
||||
value =
|
||||
math_round((player.force.character_running_speed_modifier + player.character_running_speed_modifier + 1) * 100) ..
|
||||
'%'
|
||||
add_gui_stat(tt, value, w2)
|
||||
|
||||
local e = add_gui_description(tt, '', w0)
|
||||
e = add_gui_description(tt, '', w0)
|
||||
e.style.maximal_height = 10
|
||||
local e = add_gui_description(tt, '', w0)
|
||||
e = add_gui_description(tt, '', w0)
|
||||
e.style.maximal_height = 10
|
||||
local e = add_gui_description(tt, '', w0)
|
||||
e = add_gui_description(tt, '', w0)
|
||||
e.style.maximal_height = 10
|
||||
|
||||
add_gui_description(tt, ' ', w0)
|
||||
add_gui_description(tt, 'HEALTH\nBONUS', w1)
|
||||
local value = '+ ' .. math_round((player.force.character_health_bonus + player.character_health_bonus))
|
||||
value = '+ ' .. math_round((player.force.character_health_bonus + player.character_health_bonus))
|
||||
add_gui_stat(tt, value, w2)
|
||||
|
||||
add_separator(frame, 400)
|
||||
local t = frame.add({type = 'table', column_count = 14})
|
||||
for i = 1, 14, 1 do
|
||||
local e = t.add({type = 'sprite', sprite = rpg_frame_icons[i]})
|
||||
e = t.add({type = 'sprite', sprite = rpg_frame_icons[i]})
|
||||
e.style.maximal_width = 24
|
||||
e.style.maximal_height = 24
|
||||
e.style.padding = 0
|
||||
@ -693,7 +700,11 @@ function Public.gain_xp(player, amount)
|
||||
end
|
||||
|
||||
local function global_pool()
|
||||
local pool = math.floor(rpg_t.global_pool)
|
||||
if not rpg_t.global_pool then
|
||||
return
|
||||
end
|
||||
|
||||
local pool = math_floor(rpg_t.global_pool)
|
||||
local random_amount = math_random(5000, 10000)
|
||||
if pool <= random_amount then
|
||||
return
|
||||
@ -713,7 +724,6 @@ local function global_pool()
|
||||
rpg_t[p.index].xp_since_last_floaty_text = 0
|
||||
Public.gain_xp(p, share)
|
||||
xp_effects(p)
|
||||
nth_tick = 1
|
||||
else
|
||||
p.print(teller .. ' ' .. p.name .. ' received nothing. Reason: AFK')
|
||||
end
|
||||
@ -951,12 +961,12 @@ local function on_entity_died(event)
|
||||
end
|
||||
end
|
||||
|
||||
if xp_yield['big-biter'] <= 16 then
|
||||
if rpg_xp_yield['big-biter'] <= 16 then
|
||||
local wd = WD.get_table()
|
||||
local wave_number = wd.wave_number
|
||||
if wave_number >= 500 then
|
||||
xp_yield['big-biter'] = 16
|
||||
xp_yield['behemoth-biter'] = 64
|
||||
rpg_xp_yield['big-biter'] = 16
|
||||
rpg_xp_yield['behemoth-biter'] = 64
|
||||
end
|
||||
end
|
||||
|
||||
@ -985,8 +995,8 @@ local function on_entity_died(event)
|
||||
if global.biter_health_boost then
|
||||
if enemy_types[event.entity.type] then
|
||||
for _, player in pairs(players) do
|
||||
if xp_yield[event.entity.name] then
|
||||
Public.gain_xp(player, xp_yield[event.entity.name] * global.biter_health_boost)
|
||||
if rpg_xp_yield[event.entity.name] then
|
||||
Public.gain_xp(player, rpg_xp_yield[event.entity.name] * global.biter_health_boost)
|
||||
else
|
||||
Public.gain_xp(player, 0.5 * global.biter_health_boost)
|
||||
end
|
||||
@ -997,8 +1007,8 @@ local function on_entity_died(event)
|
||||
|
||||
--Grant normal XP
|
||||
for _, player in pairs(players) do
|
||||
if xp_yield[event.entity.name] then
|
||||
Public.gain_xp(player, xp_yield[event.entity.name])
|
||||
if rpg_xp_yield[event.entity.name] then
|
||||
Public.gain_xp(player, rpg_xp_yield[event.entity.name])
|
||||
else
|
||||
Public.gain_xp(player, 0.5)
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
require 'util'
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local surface_name = 'mountain_fortress_v3'
|
||||
@ -32,7 +33,7 @@ end
|
||||
|
||||
function Public.create_surface()
|
||||
local map_gen_settings = {
|
||||
['seed'] = math.random(1000, 99999),
|
||||
['seed'] = math.random(10000, 99999),
|
||||
['width'] = level_width,
|
||||
['water'] = 0.001,
|
||||
['starting_area'] = 1,
|
||||
@ -40,7 +41,17 @@ function Public.create_surface()
|
||||
['default_enable_all_autoplace_controls'] = true,
|
||||
['autoplace_settings'] = {
|
||||
['entity'] = {treat_missing_as_default = false},
|
||||
['tile'] = {treat_missing_as_default = true},
|
||||
['tile'] = {
|
||||
settings = {
|
||||
['deepwater'] = {frequency = 1, size = 0, richness = 1},
|
||||
['deepwater-green'] = {frequency = 1, size = 0, richness = 1},
|
||||
['water'] = {frequency = 1, size = 0, richness = 1},
|
||||
['water-green'] = {frequency = 1, size = 0, richness = 1},
|
||||
['water-mud'] = {frequency = 1, size = 0, richness = 1},
|
||||
['water-shallow'] = {frequency = 1, size = 0, richness = 1}
|
||||
},
|
||||
treat_missing_as_default = true
|
||||
},
|
||||
['decorative'] = {treat_missing_as_default = true}
|
||||
},
|
||||
property_expression_names = {
|
||||
|
@ -15,7 +15,8 @@ local this = {
|
||||
magic_crafters = {index = 1},
|
||||
magic_fluid_crafters = {index = 1},
|
||||
breached_wall = 1,
|
||||
entity_limits = {}
|
||||
entity_limits = {},
|
||||
traps = {}
|
||||
}
|
||||
local Public = {}
|
||||
|
||||
@ -80,6 +81,7 @@ function Public.reset_table()
|
||||
x = 0,
|
||||
y = 0
|
||||
}
|
||||
this.traps = {}
|
||||
end
|
||||
|
||||
function Public.get(key)
|
||||
|
@ -1602,42 +1602,10 @@ Event.add(
|
||||
return
|
||||
end
|
||||
|
||||
local function get_replacement_tile(position)
|
||||
for i = 1, 128, 1 do
|
||||
local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}}
|
||||
table.shuffle_table(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if tile.valid and not tile.collides_with('resource-layer') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
end
|
||||
return 'grass-1'
|
||||
end
|
||||
|
||||
local function clear_water()
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
local oom = surface.get_tile(p).name == 'out-of-map'
|
||||
if oom then
|
||||
return
|
||||
end
|
||||
if surface.get_tile(p).collides_with('resource-layer') then
|
||||
surface.set_tiles({{name = get_replacement_tile(p), position = p}}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if left_top.y > 32 then
|
||||
game.forces.player.chart(surface, {{left_top.x, left_top.y}, {left_top.x + 31, left_top.y + 31}})
|
||||
end
|
||||
|
||||
if left_top.y >= 0 then
|
||||
clear_water()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
|
137
maps/mountain_fortress_v3/traps.lua
Normal file
137
maps/mountain_fortress_v3/traps.lua
Normal file
@ -0,0 +1,137 @@
|
||||
local Event = require 'utils.event'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
|
||||
local tick_tacks = {'*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*'}
|
||||
|
||||
local kaboom_weights = {
|
||||
{name = 'grenade', chance = 7},
|
||||
{name = 'cluster-grenade', chance = 1},
|
||||
{name = 'destroyer-capsule', chance = 1},
|
||||
{name = 'defender-capsule', chance = 4},
|
||||
{name = 'distractor-capsule', chance = 2},
|
||||
{name = 'poison-capsule', chance = 2},
|
||||
{name = 'explosive-uranium-cannon-projectile', chance = 3},
|
||||
{name = 'explosive-cannon-projectile', chance = 5}
|
||||
}
|
||||
|
||||
local kabooms = {}
|
||||
for _, t in pairs(kaboom_weights) do
|
||||
for x = 1, t.chance, 1 do
|
||||
table.insert(kabooms, t.name)
|
||||
end
|
||||
end
|
||||
|
||||
local function create_flying_text(surface, position, text)
|
||||
if not surface.valid then
|
||||
return
|
||||
end
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = text,
|
||||
color = {r = 0.75, g = 0.75, b = 0.75}
|
||||
}
|
||||
)
|
||||
|
||||
surface.play_sound({path = 'utility/armor_insert', position = position, volume_modifier = 0.75})
|
||||
end
|
||||
|
||||
local function create_kaboom(surface, position, name)
|
||||
if not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local target = position
|
||||
local speed = 0.5
|
||||
if name == 'defender-capsule' or name == 'destroyer-capsule' or name == 'distractor-capsule' then
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = '(((Sentries Engaging Target)))',
|
||||
color = {r = 0.8, g = 0.0, b = 0.0}
|
||||
}
|
||||
)
|
||||
local nearest_player_unit =
|
||||
surface.find_nearest_enemy({position = position, max_distance = 128, force = 'enemy'})
|
||||
if nearest_player_unit then
|
||||
target = nearest_player_unit.position
|
||||
end
|
||||
speed = 0.001
|
||||
end
|
||||
surface.create_entity(
|
||||
{
|
||||
name = name,
|
||||
position = position,
|
||||
force = 'enemy',
|
||||
target = target,
|
||||
speed = speed
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local function tick_tack_trap(surface, position)
|
||||
if not surface then
|
||||
return
|
||||
end
|
||||
if not surface.valid then
|
||||
return
|
||||
end
|
||||
if not position then
|
||||
return
|
||||
end
|
||||
if not position.x then
|
||||
return
|
||||
end
|
||||
if not position.y then
|
||||
return
|
||||
end
|
||||
local traps = WPT.get('traps')
|
||||
local tick_tack_count = math.random(5, 9)
|
||||
for t = 60, tick_tack_count * 60, 60 do
|
||||
if not traps[game.tick + t] then
|
||||
traps[game.tick + t] = {}
|
||||
end
|
||||
|
||||
if t < tick_tack_count * 60 then
|
||||
traps[game.tick + t][#traps[game.tick + t] + 1] = {
|
||||
callback = 'create_flying_text',
|
||||
params = {surface, {x = position.x, y = position.y}, tick_tacks[math.random(1, #tick_tacks)]}
|
||||
}
|
||||
else
|
||||
if math.random(1, 10) == 1 then
|
||||
traps[game.tick + t][#traps[game.tick + t] + 1] = {
|
||||
callback = 'create_flying_text',
|
||||
params = {surface, {x = position.x, y = position.y}, '( ͡° ͜ʖ ͡°)'}
|
||||
}
|
||||
else
|
||||
traps[game.tick + t][#traps[game.tick + t] + 1] = {
|
||||
callback = 'create_kaboom',
|
||||
params = {surface, {x = position.x, y = position.y}, kabooms[math.random(1, #kabooms)]}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
local traps = WPT.get('traps')
|
||||
if not traps[game.tick] then
|
||||
return
|
||||
end
|
||||
for _, token in pairs(traps[game.tick]) do
|
||||
local callback = token.callback
|
||||
local params = token.params
|
||||
if callback == 'create_kaboom' then
|
||||
create_kaboom(params[1], params[2], params[3])
|
||||
elseif callback == 'create_flying_text' then
|
||||
create_flying_text(params[1], params[2], params[3])
|
||||
end
|
||||
end
|
||||
traps[game.tick] = nil
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
|
||||
return tick_tack_trap
|
Loading…
Reference in New Issue
Block a user