mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-16 02:47:48 +02:00
mtn fortress tweaks
This commit is contained in:
parent
77b331dc4d
commit
0eef7c588d
@ -12,15 +12,13 @@ function Public.init_enemy_weapon_damage()
|
||||
['bullet'] = 0,
|
||||
['cannon-shell'] = 0,
|
||||
['capsule'] = 0,
|
||||
['combat-robot-beam'] = 0,
|
||||
['combat-robot-laser'] = 0,
|
||||
['beam'] = 0,
|
||||
['laser'] = 0,
|
||||
['electric'] = 0,
|
||||
['flamethrower'] = 0,
|
||||
['grenade'] = 0,
|
||||
['landmine'] = 0,
|
||||
['laser-turret'] = 0,
|
||||
['melee'] = 0,
|
||||
['railgun'] = 0,
|
||||
['rocket'] = 0,
|
||||
['shotgun-shell'] = 0
|
||||
}
|
||||
@ -44,15 +42,13 @@ local function enemy_weapon_damage()
|
||||
['biological'] = 0.08,
|
||||
['bullet'] = 0.08,
|
||||
['capsule'] = 0.08,
|
||||
['combat-robot-beam'] = 0.08,
|
||||
['combat-robot-laser'] = 0.08,
|
||||
['beam'] = 0.08,
|
||||
['laser'] = 0.08,
|
||||
['electric'] = 0.08,
|
||||
['flamethrower'] = 0.08,
|
||||
--['grenade'] = 0.08,
|
||||
['landmine'] = 0.08,
|
||||
['laser-turret'] = 0.08,
|
||||
['melee'] = 0.08
|
||||
--['railgun'] = 0.08,
|
||||
--['rocket'] = 0.08,
|
||||
--['shotgun-shell'] = 0.08
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ local raise_event = script.raise_event
|
||||
local floor = math.floor
|
||||
local random = math.random
|
||||
local sqrt = math.sqrt
|
||||
local level_depth = WPT.level_depth
|
||||
|
||||
local z = {
|
||||
[3] = true,
|
||||
@ -78,6 +79,26 @@ local spidertron_too_far =
|
||||
end
|
||||
)
|
||||
|
||||
local compare_player_pos = function(player)
|
||||
local p = player.position
|
||||
local index = player.index
|
||||
if p.y <= -level_depth * 5 and p.y >= -level_depth * 6 then
|
||||
RPG_Settings.set_value_to_player(index, 'scrap_zone', true)
|
||||
elseif p.y <= -level_depth * 15 and p.y >= -level_depth * 16 then
|
||||
RPG_Settings.set_value_to_player(index, 'scrap_zone', true)
|
||||
elseif not (p.y <= -level_depth * 5 and p.y >= -level_depth * 6) then
|
||||
local has_scrap = RPG_Settings.get_value_from_player(index, 'scrap_zone')
|
||||
if has_scrap then
|
||||
RPG_Settings.set_value_to_player(index, 'scrap_zone', false)
|
||||
end
|
||||
elseif not (p.y <= -level_depth * 15 and p.y >= -level_depth * 16) then
|
||||
local has_scrap = RPG_Settings.get_value_from_player(index, 'scrap_zone')
|
||||
if has_scrap then
|
||||
RPG_Settings.set_value_to_player(index, 'scrap_zone', false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local compare_player_and_train = function(player, entity)
|
||||
local position = player.position
|
||||
local locomotive = WPT.get('locomotive')
|
||||
@ -116,6 +137,8 @@ local function distance(player)
|
||||
local bonus_xp_on_join = WPT.get('bonus_xp_on_join')
|
||||
local enable_arties = WPT.get('enable_arties')
|
||||
|
||||
local p = player.position
|
||||
|
||||
local s = WPT.get('validate_spider')
|
||||
if s[index] then
|
||||
local e = s[index]
|
||||
@ -125,7 +148,9 @@ local function distance(player)
|
||||
compare_player_and_train(player, s[index])
|
||||
end
|
||||
|
||||
local distance_to_center = floor(sqrt(player.position.x ^ 2 + player.position.y ^ 2))
|
||||
compare_player_pos(player)
|
||||
|
||||
local distance_to_center = floor(sqrt(p.x ^ 2 + p.y ^ 2))
|
||||
local location = distance_to_center
|
||||
if location < Terrain.level_depth * bonus - 10 then
|
||||
return
|
||||
@ -206,14 +231,6 @@ local function distance(player)
|
||||
RPG_Settings.set_value_to_player(index, 'bonus', bonus + 1)
|
||||
|
||||
local b = RPG_Settings.get_value_from_player(index, 'bonus')
|
||||
if b == 6 or b == 16 then
|
||||
RPG_Settings.set_value_to_player(index, 'scrap_zone', true)
|
||||
elseif not (b == 6 or b == 16) then
|
||||
local has_scrap = RPG_Settings.get_value_from_player(index, 'scrap_zone')
|
||||
if has_scrap then
|
||||
RPG_Settings.set_value_to_player(index, 'scrap_zone', false)
|
||||
end
|
||||
end
|
||||
|
||||
if z[b] then
|
||||
RPG_Settings.set_value_to_player(index, 'forest_zone', true)
|
||||
|
@ -61,6 +61,9 @@ end
|
||||
|
||||
local function spawn_biters(data)
|
||||
local surface = data.surface
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
local position = data.position
|
||||
local h = floor(abs(position.y))
|
||||
local wave_number = WD.get('wave_number')
|
||||
@ -133,6 +136,9 @@ local function spawn_worms(data)
|
||||
end
|
||||
|
||||
local surface = data.surface
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
local position = data.position
|
||||
BiterRolls.wave_defense_set_worm_raffle(sqrt(position.x ^ 2 + position.y ^ 2) * 0.20)
|
||||
surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = position})
|
||||
@ -140,10 +146,7 @@ local function spawn_worms(data)
|
||||
end
|
||||
|
||||
function Public.buried_biter(surface, position, max)
|
||||
if not surface then
|
||||
return
|
||||
end
|
||||
if not surface.valid then
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
if not position then
|
||||
@ -188,10 +191,7 @@ function Public.buried_biter(surface, position, max)
|
||||
end
|
||||
|
||||
function Public.buried_worm(surface, position)
|
||||
if not surface then
|
||||
return
|
||||
end
|
||||
if not surface.valid then
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
if not position then
|
||||
@ -251,6 +251,12 @@ local function on_tick()
|
||||
traps[t] = nil
|
||||
end
|
||||
|
||||
function Public.reset()
|
||||
for k, _ in pairs(traps) do
|
||||
traps[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
|
||||
return Public
|
||||
|
@ -462,7 +462,7 @@ Public.power_source_callback =
|
||||
power_source.destructible = false
|
||||
local power_pole =
|
||||
turret.surface.create_entity {
|
||||
name = 'crash-site-electric-pole',
|
||||
name = 'small-electric-pole',
|
||||
position = {x = turret.position.x, y = turret.position.y}
|
||||
}
|
||||
power_pole.destructible = false
|
||||
|
@ -470,7 +470,7 @@ local function validate_index()
|
||||
local loco_surface = icw_locomotive.surface
|
||||
local unit_surface = locomotive.unit_number
|
||||
local locomotive_surface = game.surfaces[icw_table.wagons[unit_surface].surface.index]
|
||||
if not loco_surface.valid then
|
||||
if loco_surface.valid then
|
||||
WPT.set().loco_surface = locomotive_surface
|
||||
end
|
||||
end
|
||||
@ -526,10 +526,10 @@ local function create_poison_cloud(position)
|
||||
end
|
||||
|
||||
local function close_market_gui(player)
|
||||
local this = WPT.get()
|
||||
local players = WPT.get('players')
|
||||
|
||||
local element = player.gui.screen
|
||||
local data = this.players[player.index].data
|
||||
local data = players[player.index].data
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
@ -537,7 +537,7 @@ local function close_market_gui(player)
|
||||
local frame = element[main_frame_name]
|
||||
Public.close_gui_player(frame)
|
||||
if data then
|
||||
this.players[player.index].data = nil
|
||||
players[player.index].data = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -12,6 +12,7 @@ require 'modules.spawners_contain_biters'
|
||||
require 'modules.wave_defense.main'
|
||||
require 'modules.charging_station'
|
||||
|
||||
local BuriedEnemies = require 'maps.mountain_fortress_v3.buried_enemies'
|
||||
local math2d = require 'math2d'
|
||||
-- local HS = require 'maps.mountain_fortress_v3.highscore'
|
||||
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
||||
@ -71,6 +72,14 @@ local collapse_kill = {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
local function debug_str(msg)
|
||||
local debug = WPT.get('debug')
|
||||
if not debug then
|
||||
return
|
||||
end
|
||||
print('Mtn: ' .. msg)
|
||||
end
|
||||
|
||||
local function get_player_data(player, remove_user_data)
|
||||
local players = WPT.get('players')
|
||||
if remove_user_data then
|
||||
@ -322,6 +331,7 @@ function Public.reset_map()
|
||||
|
||||
Autostash.insert_into_furnace(true)
|
||||
Autostash.insert_into_wagon(true)
|
||||
BuriedEnemies.reset()
|
||||
|
||||
Poll.reset()
|
||||
ICW.reset()
|
||||
@ -787,7 +797,21 @@ local set_spawn_position = function()
|
||||
end
|
||||
local l = locomotive.position
|
||||
|
||||
local retries = 0
|
||||
local function check_tile(surface, tile, tbl, inc)
|
||||
if not (surface and surface.valid) then
|
||||
return false
|
||||
end
|
||||
if not tile then
|
||||
return false
|
||||
end
|
||||
local get_tile = surface.get_tile(tile)
|
||||
if get_tile.valid and get_tile.name == 'out-of-map' then
|
||||
remove(tbl.tbl, inc - inc + 1)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
::retry::
|
||||
|
||||
@ -796,10 +820,14 @@ local set_spawn_position = function()
|
||||
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
local spawn_near_collapse = WPT.get('spawn_near_collapse')
|
||||
if spawn_near_collapse then
|
||||
local collapse_position = surface.find_non_colliding_position('small-biter', collapse_pos, 128, 1)
|
||||
|
||||
if spawn_near_collapse.active then
|
||||
local collapse_position = surface.find_non_colliding_position('small-biter', collapse_pos, 32, 2)
|
||||
local sizeof = locomotive_positions.tbl[total_pos - total_pos + 1]
|
||||
local get_tile = surface.get_tile(sizeof)
|
||||
if get_tile.valid and get_tile.name == 'out-of-map' then
|
||||
@ -817,24 +845,38 @@ local set_spawn_position = function()
|
||||
local l_y = l.y
|
||||
local t_y = locomotive_position.y
|
||||
local c_y = collapse_pos.y
|
||||
if total_pos > 35 then
|
||||
if l_y - t_y <= -150 then
|
||||
if total_pos > spawn_near_collapse.total_pos then
|
||||
if l_y - t_y <= spawn_near_collapse.compare then
|
||||
if locomotive_position then
|
||||
if oom then
|
||||
debug_str('total_pos was higher - found oom')
|
||||
return
|
||||
end
|
||||
debug_str('total_pos was higher - spawning at locomotive_position')
|
||||
WD.set_spawn_position(locomotive_position)
|
||||
end
|
||||
elseif c_y - t_y <= 100 then
|
||||
if distance_from >= 10 then
|
||||
WD.set_spawn_position(locomotive_position)
|
||||
elseif c_y - t_y <= spawn_near_collapse.compare_next then
|
||||
if distance_from >= spawn_near_collapse.distance_from then
|
||||
local success = check_tile(surface, locomotive_position, locomotive_positions.tbl, total_pos)
|
||||
if success then
|
||||
debug_str('distance_from was higher - found oom')
|
||||
return
|
||||
end
|
||||
debug_str('distance_from was higher - spawning at locomotive_position')
|
||||
WD.set_spawn_position({x = locomotive_position.x, y = collapse_pos.y - 20})
|
||||
else
|
||||
WD.set_spawn_position({x = locomotive_position.x, y = locomotive_position.y + 50})
|
||||
debug_str('distance_from was lower - spawning at locomotive_position')
|
||||
WD.set_spawn_position({x = locomotive_position.x, y = collapse_pos.y - 20})
|
||||
end
|
||||
else
|
||||
if collapse_position then
|
||||
debug_str('total_pos was higher - spawning at collapse_position')
|
||||
WD.set_spawn_position(collapse_position)
|
||||
end
|
||||
end
|
||||
else
|
||||
if collapse_position then
|
||||
debug_str('total_pos was lower - spawning at collapse_position')
|
||||
WD.set_spawn_position(collapse_position)
|
||||
end
|
||||
end
|
||||
|
@ -15,6 +15,8 @@ Global.register(
|
||||
end
|
||||
)
|
||||
|
||||
Public.level_depth = 704
|
||||
|
||||
Public.pickaxe_upgrades = {
|
||||
'Wood',
|
||||
'Plastic',
|
||||
@ -176,7 +178,13 @@ function Public.reset_table()
|
||||
this.explosive_bullets = false
|
||||
this.locomotive_biter = nil
|
||||
this.disconnect_wagon = false
|
||||
this.spawn_near_collapse = true
|
||||
this.spawn_near_collapse = {
|
||||
active = true,
|
||||
total_pos = 35,
|
||||
compare = -150,
|
||||
compare_next = 200,
|
||||
distance_from = 2
|
||||
}
|
||||
this.spidertron_unlocked_at_wave = 11
|
||||
-- this.void_or_tile = 'lab-dark-2'
|
||||
this.void_or_tile = 'out-of-map'
|
||||
|
@ -11,7 +11,7 @@ local abs = math.abs
|
||||
local floor = math.floor
|
||||
local ceil = math.ceil
|
||||
|
||||
Public.level_depth = 704
|
||||
Public.level_depth = WPT.level_depth
|
||||
Public.level_width = 512
|
||||
local worm_level_modifier = 0.19
|
||||
|
||||
@ -49,11 +49,6 @@ local tree_raffle = {
|
||||
local size_of_tree_raffle = #tree_raffle
|
||||
|
||||
local scrap_entities = {
|
||||
'crash-site-assembling-machine-1-broken',
|
||||
'crash-site-assembling-machine-2-broken',
|
||||
'crash-site-assembling-machine-1-broken',
|
||||
'crash-site-assembling-machine-2-broken',
|
||||
'crash-site-lab-broken',
|
||||
'medium-ship-wreck',
|
||||
'small-ship-wreck',
|
||||
'medium-ship-wreck',
|
||||
|
Loading…
Reference in New Issue
Block a user