1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-25 21:29:06 +02:00

Merge pull request #173 from ComfyFactory/fixes_and_tweaks

Various bug fixes and minor tweak to mining drills bonus
This commit is contained in:
Gerkiz 2021-11-20 00:45:15 +01:00 committed by GitHub
commit 70c168dff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 113 additions and 71 deletions

View File

@ -21,7 +21,7 @@ pool_reward=[color=blue]Global Pool Reward:[/color]\n __1__ received nothing. Re
[rpg_gui]
gain_info_tooltip=XP gain from mining, moving, crafting, repairing and combat.
allocate_info=Right-click to allocate __1__ points.\nShift + click to allocate all points.
allocate_info=Right-click to allocate __1__ points.\nShift + left-click to allocate all points\nShift + right-click to allocate half your points.
player_name=Hello __1__!
class_info=You're a __1__.
settings_frame=Configure your RPG player-settings here!

View File

@ -50,6 +50,9 @@ local function get_coin_count(entity)
if not biter_health_boost_units[unit_number][3] then
return coin_count
end
if not biter_health_boost_units[unit_number][3].healthbar_id then -- only bosses
return coin_count
end
local m = 1 / biter_health_boost_units[unit_number][2]
coin_count = floor(coin_count * m)
if coin_count < 1 then

View File

@ -1123,7 +1123,6 @@ function Public.boost_difficulty()
WPT.set('bonus_xp_on_join', 500)
WD.set('next_wave', game.tick + 3600 * 15)
WPT.set('spidertron_unlocked_at_zone', 10)
WD.set_biter_health_boost(1.50)
unit_modifiers.limit_value = 30
unit_modifiers.health_increase_per_boss_wave = 0.04
WPT.set('difficulty_set', true)
@ -1141,7 +1140,6 @@ function Public.boost_difficulty()
WPT.set('spidertron_unlocked_at_zone', 8)
unit_modifiers.limit_value = 40
unit_modifiers.health_increase_per_boss_wave = 0.06
WD.set_biter_health_boost(2)
WPT.set('difficulty_set', true)
elseif name == 'Ultra-violence' then
force.character_running_speed_modifier = 0
@ -1156,7 +1154,6 @@ function Public.boost_difficulty()
WPT.set('spidertron_unlocked_at_zone', 6)
unit_modifiers.limit_value = 50
unit_modifiers.health_increase_per_boss_wave = 0.08
WD.set_biter_health_boost(4)
WPT.set('difficulty_set', true)
end
end
@ -1469,7 +1466,7 @@ function Public.on_research_finished(event)
local player = game.forces.player
research.force.character_inventory_slots_bonus = player.mining_drill_productivity_bonus * 50 -- +5 Slots /
bonus_drill.mining_drill_productivity_bonus = bonus_drill.mining_drill_productivity_bonus + 0.1
bonus_drill.mining_drill_productivity_bonus = bonus_drill.mining_drill_productivity_bonus + 0.03
if bonus_drill.mining_drill_productivity_bonus >= 3 then
bonus_drill.mining_drill_productivity_bonus = 3
end

View File

@ -346,7 +346,7 @@ local function do_place_entities(data)
if entity then
if e.note then
local modified_unit_health = WD.get('modified_unit_health')
BiterHealthBooster.add_unit(entity, modified_unit_health.current_value)
BiterHealthBooster.add_unit(entity, modified_unit_health.current_value + 1)
end
wintery(entity)
if e.direction then
@ -379,7 +379,7 @@ local function do_place_entities(data)
if entity then
if e.note then
local modified_unit_health = WD.get('modified_unit_health')
BiterHealthBooster.add_unit(entity, modified_unit_health.current_value)
BiterHealthBooster.add_unit(entity, modified_unit_health.current_value + 1)
end
wintery(entity)
if e.direction then

View File

@ -1342,9 +1342,13 @@ local function create_market(data, rebuild)
this.market = surface.create_entity {name = 'market', position = center_position, force = 'player'}
if this.mystical_chest_enabled then
if this.mystical_chest and this.mystical_chest.entity then
this.mystical_chest.entity.destroy()
this.mystical_chest.entity = nil
end
this.mystical_chest = {
entity = surface.create_entity {name = 'logistic-chest-requester', position = {x = center_position.x, y = center_position.y + 2}, force = 'neutral'},
price = false
entity = surface.create_entity {name = 'logistic-chest-requester', position = {x = center_position.x, y = center_position.y + 2}, force = 'neutral'}
}
this.mystical_chest.entity.minable = false
this.mystical_chest.entity.destructible = false

View File

@ -112,7 +112,7 @@ local init_bonus_drill_force = function()
end
bonus_drill.set_friend('player', true)
player.set_friend('bonus_drill', true)
bonus_drill.mining_drill_productivity_bonus = 1
bonus_drill.mining_drill_productivity_bonus = 0.5
end
local is_position_near_tbl = function(position, tbl)
@ -274,7 +274,7 @@ function Public.reset_map()
WD.alert_boss_wave(true)
WD.clear_corpses(false)
WD.remove_entities(true)
WD.enable_threat_log(true)
WD.enable_threat_log(false) -- creates waaaay to many entries in the global table
WD.check_collapse_position(true)
WD.set_disable_threat_below_zero(true)
WD.increase_boss_health_per_wave(true)

View File

@ -2,6 +2,7 @@
-- modified by gerkiz
local Global = require 'utils.global'
local SpamProtection = require 'utils.spam_protection'
local Event = require 'utils.event'
local BottomFrame = require 'comfy_panel.bottom_frame'
local floor = math.floor
@ -289,7 +290,6 @@ local function insert_to_furnace(player_inventory, chests, name, count, floaty_t
end
local function insert_into_wagon(stack, chests, name, floaty_text_list)
-- Attempt to load filtered cargo wagon
for chestnr, chest in pairs(chests.chest) do
if chest.type == 'cargo-wagon' then
@ -307,7 +307,6 @@ local function insert_into_wagon(stack, chests, name, floaty_text_list)
end
local function insert_into_wagon_filtered(stack, chests, name, floaty_text_list)
-- Attempt to load filtered cargo wagon
for chestnr, chest in pairs(chests.chest) do
if chest.type == 'cargo-wagon' then
@ -552,7 +551,8 @@ local function create_gui_button(player)
tooltip =
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
else
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
tooltip =
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
end
if this.bottom_button then
local data = BottomFrame.get('bottom_quickbar_button')
@ -634,6 +634,10 @@ local function on_gui_click(event)
end
if event.element.name == name then
local is_spamming = SpamProtection.is_spamming(player, nil, 'Autostash Click')
if is_spamming then
return
end
auto_stash(player, event)
end
end

View File

@ -86,17 +86,36 @@ local function on_gui_click(event)
end
if shift then
local count = rpg_t.points_left
if not count then
return
if event.button == defines.mouse_button_type.left then
local count = rpg_t.points_left
if not count then
return
end
rpg_t.points_left = 0
rpg_t[index] = rpg_t[index] + count
if not rpg_t.reset then
rpg_t.total = rpg_t.total + count
end
Public.toggle(player, true)
Public.update_player_stats(player)
elseif event.button == defines.mouse_button_type.right then
local left = rpg_t.points_left / 2
if left > 2 then
for _ = 1, left, 1 do
if rpg_t.points_left <= 0 then
Public.toggle(player, true)
return
end
rpg_t.points_left = rpg_t.points_left - 1
rpg_t[index] = rpg_t[index] + 1
if not rpg_t.reset then
rpg_t.total = rpg_t.total + 1
end
Public.update_player_stats(player)
end
end
Public.toggle(player, true)
end
rpg_t.points_left = 0
rpg_t[index] = rpg_t[index] + count
if not rpg_t.reset then
rpg_t.total = rpg_t.total + count
end
Public.toggle(player, true)
Public.update_player_stats(player)
elseif event.button == defines.mouse_button_type.right then
for _ = 1, points_per_level, 1 do
if rpg_t.points_left <= 0 then
@ -590,8 +609,8 @@ local function one_punch(character, target, damage, get_health_pool)
if max_unit_health <= 0 then
max_unit_health = 4
end
if max_unit_health >= 15 then
max_unit_health = 15
if max_unit_health >= 10 then
max_unit_health = 10
end
local final = floor(damage * max_unit_health)
character.surface.create_entity(

View File

@ -86,7 +86,12 @@ local function find_initial_spot(surface, position)
end
if math_random(1, 2) == 1 then
local random_pos = {{x = pos.x - 10, y = pos.y - 5}, {x = pos.x + 10, y = pos.y + 5}, {x = pos.x - 10, y = pos.y + 5}, {x = pos.x + 10, y = pos.y - 5}}
local random_pos = {
{x = pos.x - 10, y = pos.y - 5},
{x = pos.x + 10, y = pos.y + 5},
{x = pos.x - 10, y = pos.y + 5},
{x = pos.x + 10, y = pos.y - 5}
}
local actual_pos = shuffle(random_pos)
pos = {x = actual_pos[1].x, y = actual_pos[1].y}
end
@ -261,6 +266,7 @@ local function is_unit_valid(biter)
end
local function refresh_active_unit_threat()
local unit_group_pos = Public.get('unit_group_pos')
local active_biter_threat = Public.get('active_biter_threat')
local active_biters = Public.get('active_biters')
debug_print('refresh_active_unit_threat - current value ' .. active_biter_threat)
@ -275,6 +281,10 @@ local function refresh_active_unit_threat()
local biter_health_boost = BiterHealthBooster.get('biter_health_boost')
Public.set('active_biter_threat', math_round(biter_threat * biter_health_boost, 2))
debug_print('refresh_active_unit_threat - new value ' .. active_biter_threat)
if unit_group_pos.index > 500 then
unit_group_pos.positions = {}
unit_group_pos.index = 0
end
end
local function time_out_biters()
@ -327,7 +337,11 @@ local function get_random_close_spawner()
end
goto retry
end
if not spawner or (center.x - spawner_2.position.x) ^ 2 + (center.y - spawner_2.position.y) ^ 2 < (center.x - spawner.position.x) ^ 2 + (center.y - spawner.position.y) ^ 2 then
if
not spawner or
(center.x - spawner_2.position.x) ^ 2 + (center.y - spawner_2.position.y) ^ 2 <
(center.x - spawner.position.x) ^ 2 + (center.y - spawner.position.y) ^ 2
then
spawner = spawner_2
if spawner and spawner.position then
debug_print('get_random_close_spawner - Found at x' .. spawner.position.x .. ' y' .. spawner.position.y)
@ -379,7 +393,9 @@ local function set_main_target()
end
Public.set('target', sec_target)
debug_print('set_main_target -- New main target ' .. sec_target.name .. ' at position x' .. sec_target.position.x .. ' y' .. sec_target.position.y .. ' selected.')
debug_print(
'set_main_target -- New main target ' .. sec_target.name .. ' at position x' .. sec_target.position.x .. ' y' .. sec_target.position.y .. ' selected.'
)
end
local function set_group_spawn_position(surface)
@ -398,27 +414,25 @@ end
local function set_enemy_evolution()
local wave_number = Public.get('wave_number')
local biter_health_boost = Public.get('biter_health_boost')
local active_biters = Public.get('active_biters')
local threat = Public.get('threat')
local evolution_factor = wave_number * 0.001
local biter_h_boost = 1
local enemy = game.forces.enemy
local biter_health_boost = 1
if evolution_factor > 1 then
evolution_factor = 1
end
if biter_health_boost then
biter_h_boost = math_round(biter_health_boost + (threat - 5000) * 0.000044, 3)
else
biter_h_boost = math_round(biter_h_boost + (threat - 5000) * 0.000044, 3)
end
if biter_h_boost <= 1 then
biter_h_boost = 1
if not next(active_biters) then
Public.set('active_biter_count', 0)
end
BiterHealthBooster.set('biter_health_boost', biter_h_boost)
Public.set('biter_health_boost', biter_h_boost)
if threat > 50000 then
biter_health_boost = math_round(biter_health_boost + (threat - 50000) * 0.000033, 3)
end
BiterHealthBooster.set('biter_health_boost', biter_health_boost)
if enemy.evolution_factor == 1 and evolution_factor == 1 then
return
@ -455,6 +469,7 @@ end
local function get_active_unit_groups_count()
local unit_groups = Public.get('unit_groups')
local unit_group_pos = Public.get('unit_group_pos')
local count = 0
for k, g in pairs(unit_groups) do
@ -469,17 +484,13 @@ local function get_active_unit_groups_count()
end
else
unit_groups[k] = nil
unit_group_pos.positions[k] = nil
local unit_groups_size = Public.get('unit_groups_size')
Public.set('unit_groups_size', unit_groups_size - 1)
local unit_group_last_command = Public.get('unit_group_last_command')
if unit_group_last_command[k] then
unit_group_last_command[k] = nil
end
local unit_group_pos = Public.get('unit_group_pos')
local positions = unit_group_pos.positions
if positions[k] then
positions[k] = nil
end
end
end
debug_print('Active unit group count: ' .. count)
@ -527,7 +538,7 @@ local function spawn_biter(surface, position, forceSpawn, is_boss_biter)
local increase_boss_health_per_wave = Public.get('increase_boss_health_per_wave')
if increase_boss_health_per_wave then
local modified_boss_unit_health = Public.get('modified_boss_unit_health')
BiterHealthBooster.add_boss_unit(biter, modified_boss_unit_health, 0.55)
BiterHealthBooster.add_boss_unit(biter, modified_boss_unit_health.current_value, 0.55)
else
local sum = boosted_health * 5
debug_print('Boss Health Boosted: ' .. sum)
@ -569,8 +580,8 @@ local function increase_biters_health()
return
end
local boosted_health = BiterHealthBooster.get('biter_health_boost')
local wave_number = Public.get('wave_number')
-- local boosted_health = BiterHealthBooster.get('biter_health_boost')
-- local wave_number = Public.get('wave_number')
-- this sets normal units health
local modified_unit_health = Public.get('modified_unit_health')
@ -581,17 +592,24 @@ local function increase_biters_health()
Public.set('modified_unit_health').current_value = modified_unit_health.current_value + modified_unit_health.health_increase_per_boss_wave
-- this sets boss units health
if boosted_health == 1 then
boosted_health = 1.25
end
-- if boosted_health == 1 then
-- boosted_health = 1.25
-- end
boosted_health = math_round(boosted_health * (wave_number * 0.04), 3)
debug_print_health('boosted_health: ' .. boosted_health)
if boosted_health >= 300 then
boosted_health = 300
end
-- boosted_health = math_round(boosted_health * (wave_number * 0.04), 3)
-- debug_print_health('boosted_health: ' .. boosted_health)
-- if boosted_health >= 300 then
-- boosted_health = 300
-- end
-- Public.set('modified_boss_unit_health', boosted_health)
Public.set('modified_boss_unit_health', boosted_health)
-- this sets boss units health
local modified_boss_unit_health = Public.get('modified_boss_unit_health')
if modified_boss_unit_health.current_value > modified_boss_unit_health.limit_value then
modified_boss_unit_health.current_value = modified_boss_unit_health.limit_value
end
debug_print_health('modified_boss_unit_health.current_value: ' .. modified_boss_unit_health.current_value)
Public.set('modified_boss_unit_health').current_value = modified_boss_unit_health.current_value + modified_boss_unit_health.health_increase_per_boss_wave
end
local function set_next_wave()
@ -994,6 +1012,7 @@ local function spawn_unit_group(fs, only_bosses)
local unit_group_pos = Public.get('unit_group_pos')
local unit_group = surface.create_unit_group({position = spawn_position, force = 'enemy'})
unit_group_pos.index = unit_group_pos.index + 1
unit_group_pos.positions[unit_group.group_number] = {position = unit_group.position, index = 0}
local average_unit_group_size = Public.get('average_unit_group_size')
local group_size = math_floor(average_unit_group_size * group_size_modifier_raffle[math_random(1, group_size_modifier_raffle_size)])

View File

@ -46,6 +46,7 @@ function Public.reset_wave_defense()
this.unit_groups = {}
this.unit_groups_size = 0
this.unit_group_pos = {
index = 0,
positions = {}
}
this.index = 0
@ -60,7 +61,6 @@ function Public.reset_wave_defense()
this.worm_building_density = 16
this.worm_raffle = {}
this.clear_corpses = false
this.biter_health_boost = 1
this.alert_boss_wave = false
this.remove_entities = false
this.enable_side_target = false
@ -74,8 +74,13 @@ function Public.reset_wave_defense()
this.fill_tiles_so_biter_can_path = true
this.modified_unit_health = {
current_value = 1.02,
limit_value = 30,
health_increase_per_boss_wave = 0.04
limit_value = 60,
health_increase_per_boss_wave = 0.08
}
this.modified_boss_unit_health = {
current_value = 2.00,
limit_value = 500,
health_increase_per_boss_wave = 0.15
}
end
@ -209,15 +214,6 @@ function Public.increase_damage_per_wave(boolean)
return this.increase_damage_per_wave
end
function Public.set_biter_health_boost(number)
if number and type(number) == 'number' then
this.biter_health_boost = number
else
this.biter_health_boost = 1
end
return this.biter_health_boost
end
function Public.pause(boolean)
this.paused = boolean or false
end

View File

@ -91,7 +91,7 @@ local function place_nest_near_unit_group()
local spawner = unit.surface.create_entity({name = name, position = position, force = unit.force})
if boss then
BiterHealthBooster.add_boss_unit(spawner, modified_boss_unit_health)
BiterHealthBooster.add_boss_unit(spawner, modified_boss_unit_health.current_value)
else
BiterHealthBooster.add_unit(spawner, modified_unit_health.current_value)
end
@ -188,7 +188,7 @@ function Public.build_worm()
local modified_boss_unit_health = Public.get('modified_boss_unit_health')
if boss then
BiterHealthBooster.add_boss_unit(u, modified_boss_unit_health)
BiterHealthBooster.add_boss_unit(u, modified_boss_unit_health.current_value)
else
BiterHealthBooster.add_unit(u, modified_unit_health.current_value)
end