1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-28 03:57:22 +02:00

mtn v3 - more fixes

This commit is contained in:
Gerkiz 2022-07-10 22:35:22 +02:00
parent e12bf74822
commit 71a3cee6a0
4 changed files with 60 additions and 33 deletions

View File

@ -120,6 +120,7 @@ death_message_7=__1__ tried to cheat their way north!
forcefield=Forcefield does not approve.
greeting=[color=blue]Comfylatron:[/color]\nGreetings, __1__!\nPlease read the map info.
death_mode_warning=[color=blue]Comfylatron:[/color]\nCAUTION! Walking outside of the locomotive aura will kill you!
aura_upgrade_warning=[color=blue]Comfylatron:[/color]\nThe locomotive aura range has been upgraded!
damage_mode_warning=[color=blue]Comfylatron:[/color]\nCAUTION! Walking outside of the locomotive aura will slowly kill you!
cleaner=[color=blue]Cleaner:[/color]\n__1__ has left his goodies! Be quick and fetch them!
reset_in=Game will __1__ in __2__ seconds!

View File

@ -1107,6 +1107,9 @@ function Public.boost_difficulty()
local force = game.forces.player
local active_surface_index = WPT.get('active_surface_index')
local surface = game.get_surface(active_surface_index)
if index == 1 then
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5
force.character_running_speed_modifier = 0.15
@ -1145,6 +1148,17 @@ function Public.boost_difficulty()
WPT.set('difficulty_set', true)
local damage_warning = ({'main.damage_mode_warning'})
Alert.alert_all_players_location(data, damage_warning)
Core.iter_players(
function(player)
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
if pos then
player.teleport(pos, surface)
else
pos = game.forces.player.get_spawn_position(surface)
player.teleport(pos, surface)
end
end
)
elseif index == 3 then
force.character_running_speed_modifier = 0
force.manual_crafting_speed_modifier = 0
@ -1162,17 +1176,27 @@ function Public.boost_difficulty()
WD.set_boss_health_increment_per_wave(10)
WD.set('death_mode', true)
WPT.set('difficulty_set', true)
Core.iter_players(
function(player)
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
if pos then
player.teleport(pos, surface)
else
pos = game.forces.player.get_spawn_position(surface)
player.teleport(pos, surface)
end
end
)
local upgrades = WPT.get('upgrades')
upgrades.locomotive_aura_radius = upgrades.locomotive_aura_radius + 20
if WPT.get('circle') then
rendering.destroy(WPT.get('circle'))
end
local active_surface_index = WPT.get('active_surface_index')
local locomotive = WPT.get('locomotive')
WPT.set(
'circle',
rendering.draw_circle {
surface = game.surfaces[active_surface_index],
surface = active_surface_index,
target = locomotive,
color = locomotive.color,
filled = false,
@ -1180,6 +1204,8 @@ function Public.boost_difficulty()
only_in_alt_mode = false
}
)
local aura_upgrade = ({'main.aura_upgrade_warning'})
Alert.alert_all_players_location(data, aura_upgrade)
local death_warning = ({'main.death_mode_warning'})
Alert.alert_all_players_location(data, death_warning)
difficulty_and_adjust_prices()

View File

@ -4,7 +4,6 @@ local LocomotiveMarket = require 'maps.mountain_fortress_v3.locomotive.market'
local ICW = require 'maps.mountain_fortress_v3.icw.main'
local WPT = require 'maps.mountain_fortress_v3.table'
local ICFunctions = require 'maps.mountain_fortress_v3.ic.functions'
local ICT = require 'maps.mountain_fortress_v3.ic.table'
local Session = require 'utils.datastore.session_data'
local Difficulty = require 'modules.difficulty_vote_by_amount'
local RPG = require 'modules.rpg.main'
@ -34,6 +33,11 @@ local valid_armors = {
['power-armor-mk2'] = true
}
local non_valid_vehicles = {
['car'] = true,
['spider-vehicle'] = true
}
local function add_random_loot_to_main_market(rarity)
local main_market_items = WPT.get('main_market_items')
local items = Market.get_random_item(rarity, true, false)
@ -132,6 +136,10 @@ local function hurt_players_outside_of_aura()
if not Diff then
return
end
local difficulty_set = WPT.get('difficulty_set')
if not difficulty_set then
return
end
local death_mode = false
if Diff.index == 1 then
return
@ -139,13 +147,6 @@ local function hurt_players_outside_of_aura()
death_mode = true
end
local health_pool_upgrade = false
local upgrades = WPT.get('upgrades')
if upgrades.has_upgraded_health_pool then
health_pool_upgrade = true
end
local loco_surface = WPT.get('loco_surface')
if not (loco_surface and loco_surface.valid) then
return
@ -153,6 +154,8 @@ local function hurt_players_outside_of_aura()
local locomotive = WPT.get('locomotive')
local loco = locomotive.position
local upgrades = WPT.get('upgrades')
local players = game.connected_players
for i = 1, #players do
local player = players[i]
@ -170,37 +173,24 @@ local function hurt_players_outside_of_aura()
end
local entity = player.character
if entity and entity.valid then
local max_health = entity.prototype.max_health
local max_health = floor(player.character.prototype.max_health + player.character_health_bonus + player.force.character_health_bonus)
local vehicle = player.vehicle
if vehicle and vehicle.valid and non_valid_vehicles[vehicle.type] then
player.driving = false
end
if death_mode then
if vehicle and vehicle.valid then
vehicle.die()
end
if entity.name == 'character' then
game.print(player.name .. messages[random(1, #messages)], {r = 200, g = 0, b = 0})
end
entity.die()
else
if vehicle and vehicle.valid then
local v_health = vehicle.prototype.max_health
if not health_pool_upgrade then
vehicle.health = vehicle.health - (v_health / 20)
else
local cars = ICT.get('cars')
local car = cars[vehicle.unit_number]
if not car then
return
end
ICFunctions.set_damage_health({entity = vehicle, final_damage_amount = (v_health / 20), car = car})
end
else
entity.health = entity.health - (max_health / 5)
if entity.health <= 0 then
if entity.name == 'character' then
game.print(player.name .. messages[random(1, #messages)], {r = 200, g = 0, b = 0})
end
entity.die()
entity.damage(1, 'enemy')
entity.health = entity.health - (max_health / 25)
if entity.health <= 0 then
if entity.name == 'character' then
game.print(player.name .. messages[random(1, #messages)], {r = 200, g = 0, b = 0})
end
entity.die()
end
end
end

View File

@ -113,6 +113,16 @@ function Public.iter_connected_players(callback)
end
end
--- Iterates over all players
---@param callback function
function Public.iter_players(callback)
local players = game.players
for i = 1, #players do
local player = players[i]
callback(player)
end
end
function Public.cast_bool(var)
if var then
return true