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

Fixes and tweaks

This commit is contained in:
Gerkiz 2023-05-05 00:41:22 +02:00
parent 381402e912
commit 899dd5dd25
10 changed files with 290 additions and 106 deletions

View File

@ -41,6 +41,7 @@ require 'utils.gui.server_select'
require 'utils.freeplay'
---------------- !ENABLE MODULES HERE ----------------
--require 'modules.rpg.main'
--require 'modules.admins_operate_biters'
--require 'modules.the_floor_is_lava'
--require 'modules.biters_landfill_on_death'
@ -240,7 +241,6 @@ require 'utils.freeplay'
---------------- MORE MODULES HERE ----------------
--require 'modules.hidden_dimension.main'
--require 'modules.towny.main'
--require 'modules.rpg.main'
--require 'modules.rpg'
--require 'modules.trees_grow'
--require 'modules.trees_randomly_die'

View File

@ -138,6 +138,9 @@ local check_distance_between_player_and_locomotive = function(player)
if c_y - t_y <= gap_between_locomotive.neg_gap then
player.teleport({position.x, locomotive.position.y + gap_between_locomotive.neg_gap + 2}, surface)
player.print(({'breached_wall.hinder'}), Color.warning)
if player.driving then
player.driving = false
end
if player.character then
player.character.health = player.character.health - 5
player.character.surface.create_entity({name = 'water-splash', position = position})

View File

@ -635,12 +635,16 @@ Public.magic_item_crafting_callback_weighted =
return
end
entity.minable = false
entity.destructible = false
entity.operable = false
local weights = callback_data.weights
local loot = callback_data.loot
local destructible = callback_data.destructible
if not destructible then
entity.destructible = false
end
entity.minable = false
entity.operable = false
local p = entity.position

View File

@ -42,6 +42,9 @@ local biters = {
local function get_lowest(tbl, column_name)
local t = {}
if not tbl then
return 100
end
for _, value in pairs(tbl) do
insert(t, value[column_name])
end
@ -60,6 +63,9 @@ end
local function get_highest(tbl, column_name)
local t = {}
if not tbl then
return 100
end
for _, value in pairs(tbl) do
insert(t, value[column_name])
end
@ -77,6 +83,10 @@ local function get_highest(tbl, column_name)
end
local function contains(tbl, key, string, rtn)
if not tbl then
return false
end
for index, value in pairs(tbl) do
if value[key] and value[key] == string then
if rtn then
@ -117,7 +127,7 @@ local function get_sorted_list(column_name, score_list)
return sl
end
local function get_mvps()
local function get_mvps(clear_state)
local new_score_table = Score.get_table().score_table
if not new_score_table['player'] then
return false
@ -125,7 +135,10 @@ local function get_mvps()
local old_score = this.score_table['player']
local score = new_score_table['player']
local score_list = {}
local mvp = old_score.players
local mvp = old_score.players or {}
if clear_state then
mvp = {}
end
for _, p in pairs(game.players) do
if score.players[p.name] then
@ -168,33 +181,38 @@ local function get_mvps()
if kill_list then
if not contains(mvp, 'name', kill_list.name) then
if kill_list.killscore >= lowest_k then
if death_list and death_list.deaths < highest_d then
insert(
mvp,
{
name = kill_list.name,
killscore = kill_list.killscore,
deaths = death_list.deaths
}
)
else
insert(
mvp,
{
name = kill_list.name,
killscore = kill_list.killscore
}
)
end
insert(
mvp,
{
name = kill_list.name,
killscore = kill_list.killscore,
mined_entities = kill_list.mined_entities,
built_entities = kill_list.built_entities,
deaths = kill_list.deaths
}
)
end
else
local index = contains(mvp, 'name', kill_list.name, true)
if index then
if mvp[index].killscore and kill_list.killscore > mvp[index].killscore then
mvp[index].killscore = kill_list.killscore
end
if death_list and mvp[index].deaths and death_list.deaths < mvp[index].deaths then
mvp[index].deaths = death_list.deaths
if mvp[index].mined_entities and kill_list.mined_entities > mvp[index].mined_entities then
mvp[index].mined_entities = kill_list.mined_entities
else
mvp[index].mined_entities = kill_list.mined_entities
end
if mvp[index].built_entities and kill_list.built_entities > mvp[index].built_entities then
mvp[index].built_entities = kill_list.built_entities
else
mvp[index].built_entities = kill_list.built_entities
end
if mvp[index].deaths and kill_list.deaths < mvp[index].deaths then
mvp[index].deaths = kill_list.deaths
else
mvp[index].deaths = kill_list.deaths
end
end
end
end
@ -202,33 +220,38 @@ local function get_mvps()
if mined_list then
if not contains(mvp, 'name', mined_list.name) then
if mined_list.mined_entities >= lowest_m then
if death_list and death_list.deaths < highest_d then
insert(
mvp,
{
name = mined_list.name,
mined_entities = mined_list.mined_entities,
deaths = death_list.deaths
}
)
else
insert(
mvp,
{
name = mined_list.name,
mined_entities = mined_list.mined_entities
}
)
end
insert(
mvp,
{
name = mined_list.name,
killscore = mined_list.killscore,
mined_entities = mined_list.mined_entities,
built_entities = mined_list.built_entities,
deaths = mined_list.deaths
}
)
end
else
local index = contains(mvp, 'name', mined_list.name, true)
if index then
if mvp[index].mined_entities and mined_list.mined_entities > mvp[index].mined_entities then
mvp[index].mined_entities = mined_list.mined_entities
end
if death_list and mvp[index].deaths and death_list.deaths < mvp[index].deaths then
mvp[index].deaths = death_list.deaths
if mvp[index].killscore and mined_list.killscore > mvp[index].killscore then
mvp[index].killscore = mined_list.killscore
else
mvp[index].killscore = mined_list.killscore
end
if mvp[index].built_entities and mined_list.built_entities > mvp[index].built_entities then
mvp[index].built_entities = mined_list.built_entities
else
mvp[index].built_entities = mined_list.built_entities
end
if mvp[index].deaths and mined_list.deaths < mvp[index].deaths then
mvp[index].deaths = mined_list.deaths
else
mvp[index].deaths = mined_list.deaths
end
end
end
end
@ -236,38 +259,82 @@ local function get_mvps()
if build_list then
if not contains(mvp, 'name', build_list.name) then
if build_list.built_entities >= lowest_b then
if death_list and death_list.deaths < highest_d then
insert(
mvp,
{
name = build_list.name,
built_entities = build_list.built_entities,
deaths = death_list.deaths
}
)
else
insert(
mvp,
{
name = build_list.name,
built_entities = build_list.built_entities
}
)
end
insert(
mvp,
{
name = build_list.name,
killscore = build_list.killscore,
mined_entities = build_list.mined_entities,
built_entities = build_list.built_entities,
deaths = build_list.deaths
}
)
end
else
local index = contains(mvp, 'name', build_list.name, true)
if index then
if mvp[index].built_entities and build_list.built_entities > mvp[index].built_entities then
mvp[index].built_entities = build_list.built_entities
end
if death_list and mvp[index].deaths and death_list.deaths < mvp[index].deaths then
mvp[index].deaths = death_list.deaths
if mvp[index].killscore and build_list.killscore > mvp[index].killscore then
mvp[index].killscore = build_list.killscore
else
mvp[index].killscore = build_list.killscore
end
if mvp[index].mined_entities and build_list.mined_entities > mvp[index].mined_entities then
mvp[index].mined_entities = build_list.mined_entities
else
mvp[index].mined_entities = build_list.mined_entities
end
if mvp[index].deaths and build_list.deaths < mvp[index].deaths then
mvp[index].deaths = build_list.deaths
else
mvp[index].deaths = build_list.deaths
end
end
end
end
end
if death_list then
if not contains(mvp, 'name', death_list.name) then
if death_list.deaths < highest_d then
insert(
mvp,
{
name = death_list.name,
killscore = death_list.killscore,
mined_entities = death_list.mined_entities,
built_entities = death_list.built_entities,
deaths = death_list.deaths
}
)
end
else
local index = contains(mvp, 'name', death_list.name, true)
if index then
if mvp[index].deaths and death_list.deaths < mvp[index].deaths then
mvp[index].deaths = death_list.deaths
if mvp[index].killscore and death_list.killscore > mvp[index].killscore then
mvp[index].killscore = death_list.killscore
else
mvp[index].killscore = death_list.killscore
end
if mvp[index].mined_entities and death_list.mined_entities > mvp[index].mined_entities then
mvp[index].mined_entities = death_list.mined_entities
else
mvp[index].mined_entities = death_list.mined_entities
end
if mvp[index].built_entities and death_list.built_entities > mvp[index].built_entities then
mvp[index].built_entities = death_list.built_entities
else
mvp[index].built_entities = death_list.built_entities
end
end
end
end
end
if mvp['GodGamer'] then
mvp['GodGamer'] = nil
end
@ -296,6 +363,7 @@ local function write_additional_stats(key, difficulty)
local new_rockets_launched = player.rockets_launched
local new_total_time = game.ticks_played
local t = this.score_table['player']
local clear_state = false
if this.score_table['player'] then
local old_wave = this.score_table['player'].wave_number
@ -304,48 +372,64 @@ local function write_additional_stats(key, difficulty)
local old_rockets_launched = this.score_table['player'].rockets_launched
local old_total_time = this.score_table['player'].total_time
local old_players = this.score_table['player'].players
if new_wave_number > old_wave then
t.wave_number = new_wave_number
else
t.wave_number = old_wave
if old_wave then
if new_wave_number > old_wave then
clear_state = true
t.wave_number = new_wave_number
else
t.wave_number = old_wave
end
end
if new_biters_killed > old_biters_killed then
t.biters_killed = new_biters_killed
else
t.biters_killed = old_biters_killed
if old_biters_killed then
if new_biters_killed > old_biters_killed then
t.biters_killed = new_biters_killed
else
t.biters_killed = old_biters_killed
end
end
if new_breached_zone > old_breached_zone then
t.breached_zone = new_breached_zone
else
t.breached_zone = old_breached_zone
if old_breached_zone then
if new_breached_zone > old_breached_zone then
t.breached_zone = new_breached_zone
else
t.breached_zone = old_breached_zone
end
end
if new_rockets_launched > old_rockets_launched then
t.rockets_launched = new_rockets_launched
else
t.rockets_launched = old_rockets_launched
if old_rockets_launched then
if new_rockets_launched > old_rockets_launched then
t.rockets_launched = new_rockets_launched
else
t.rockets_launched = old_rockets_launched
end
end
if new_total_time > old_total_time then
t.total_time = new_total_time
else
t.total_time = old_total_time
if old_total_time then
if new_total_time > old_total_time then
t.total_time = new_total_time
else
t.total_time = old_total_time
end
end
if difficulty then
t.difficulty = difficulty
end
local new_stats = get_mvps()
local new_stats = get_mvps(clear_state)
if new_stats then
t.players = new_stats
else
t.players = old_players
if old_players then
t.players = old_players
end
end
end
this.score_table['player'] = t
this.score_table['player'] = t
if key then
set_data(score_dataset, key, t)
if key then
set_data(score_dataset, key, t)
end
end
end
@ -370,6 +454,7 @@ function Public.get_scores()
end
end
-- local Core = require 'maps.mountain_fortress_v3.core' Core.set_scores()
function Public.set_scores(difficulty)
local secs = Server.get_current_time()
if not secs then
@ -614,6 +699,9 @@ local function on_gui_click(event)
end
local player = game.get_player(event.element.player_index)
if not player then
return
end
local frame = Gui.get_player_active_frame(player)
if not frame then

View File

@ -494,8 +494,8 @@ local function on_player_changed_surface(event)
return
end
local itemGhost = player.cursor_ghost
if itemGhost then
local item_ghost = player.cursor_ghost
if item_ghost then
player.cursor_ghost = nil
end

View File

@ -37,6 +37,10 @@ function Public.add_player_to_permission_group(player, group, forced)
end
limited_group.set_allows_action(defines.input_action.cancel_craft, false)
limited_group.set_allows_action(defines.input_action.drop_item, false)
limited_group.set_allows_action(defines.input_action.upgrade, false) -- fixes factorio base issue
limited_group.set_allows_action(defines.input_action.upgrade_opened_blueprint_by_item, false)
limited_group.set_allows_action(defines.input_action.upgrade_opened_blueprint_by_record, false)
limited_group.set_allows_action(defines.input_action.cancel_upgrade, false)
if allow_decon then
limited_group.set_allows_action(defines.input_action.deconstruct, true)
else

View File

@ -52,6 +52,7 @@ local role_to_mention = Discord.role_mentions.mtn_fortress
local floor = math.floor
local remove = table.remove
local random = math.random
RPG.disable_cooldowns_on_spells()
local collapse_kill = {
@ -263,6 +264,7 @@ function Public.reset_map()
WD.increase_average_unit_group_size(true)
WD.increase_max_active_unit_groups(true)
WD.enable_random_spawn_positions(true)
WD.set_pause_wave_in_ticks(random(18000, 54000))
Public.set_difficulty()
Public.disable_creative()

View File

@ -409,7 +409,8 @@ local testing_callback = {
data = {
loot = testing_loot,
weights = testing_weights,
testing = true
testing = true,
destructible = true
}
}
@ -417,7 +418,8 @@ local science_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = science_loot,
weights = science_weights
weights = science_weights,
destructible = true
}
}
@ -425,7 +427,8 @@ local building_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = ammo_loot,
weights = building_weights
weights = building_weights,
destructible = true
}
}
@ -433,7 +436,8 @@ local oil_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = oil_loot,
weights = oil_weights
weights = oil_weights,
destructible = true
}
}
@ -441,7 +445,8 @@ local oil_prod_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = oil_prod_loot,
weights = oil_prod_weights
weights = oil_prod_weights,
destructible = true
}
}
@ -449,7 +454,8 @@ local resource_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = resource_loot,
weights = resource_weights
weights = resource_weights,
destructible = true
}
}
@ -457,7 +463,8 @@ local furnace_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = furnace_loot,
weights = furnace_weights
weights = furnace_weights,
destructible = true
}
}

View File

@ -20,6 +20,12 @@ local floor = math.floor
local random = math.random
local abs = math.abs
local sub = string.sub
local angle_multipler = 2 * math.pi
local start_angle = -angle_multipler / 4
local update_rate = 4
local time_to_live = update_rate + 1
local draw_arc = rendering.draw_arc
--RPG Frames
local main_frame_name = Public.main_frame_name
@ -982,6 +988,51 @@ function Public.get_magicka(player)
return (rpg_t.magicka - 10) * 0.10
end
local show_cooldown
show_cooldown =
Token.register(
function(event)
local player_index = event.player_index
local player = game.get_player(player_index)
if not player or not player.valid then
return
end
local tick = event.tick
local now = game.tick
if now >= tick then
return
end
local fade = ((now - tick) / event.delay) + 1
if not player.character then
return
end
draw_arc(
{
color = {1 - fade, fade, 0},
max_radius = 0.5,
min_radius = 0.4,
start_angle = start_angle,
angle = fade * angle_multipler,
target = player.character,
target_offset = {x = 0, y = -2},
surface = player.surface,
time_to_live = time_to_live
}
)
Task.set_timeout_in_ticks(update_rate, show_cooldown, event)
end
)
Public.show_cooldown = show_cooldown
function Public.register_cooldown_for_player(player, spell)
Task.set_timeout_in_ticks(update_rate, show_cooldown, {player_index = player.index, tick = game.tick + spell.cooldown, delay = spell.cooldown})
end
--- Gives connected player some bonus xp if the map was preemptively shut down.
-- amount (integer) -- 10 levels
-- local Public = require 'modules.rpg.table' Public.give_xp(512)

View File

@ -980,6 +980,10 @@ local function on_player_used_capsule(event)
return
end
if spell.enforce_cooldown then
Public.register_cooldown_for_player(player, spell)
end
rpg_t.last_spawned = game.tick + spell.cooldown
Public.update_mana(player)
@ -1053,4 +1057,25 @@ Event.add(
end
)
if _DEBUG then
Public.disable_cooldowns_on_spells()
Event.on_init(
function()
Public.rpg_reset_all_players()
Public.enable_health_and_mana_bars(true)
Public.enable_wave_defense(true)
Public.enable_mana(true)
Public.personal_tax_rate(0.4)
Public.enable_stone_path(true)
Public.enable_aoe_punch(true)
Public.enable_aoe_punch_globally(false)
Public.enable_range_buffs(true)
Public.enable_auto_allocate(true)
Public.enable_explosive_bullets_globally(true)
Public.enable_explosive_bullets(false)
end
)
end
return Public