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

mtn fortress changes

This commit is contained in:
Gerkiz
2020-11-17 12:45:27 +01:00
parent edf007feb3
commit 88f46983af
14 changed files with 815 additions and 130 deletions

View File

@@ -39,7 +39,7 @@ function Public.reset_table()
this.vehicle_nanobots_unlocked = false
this.game_restart_timer = nil
this.wave_count = 0
this.wave_limit = 9999
this.wave_limit = 2000
this.attack_wave_threat = nil
this.market = nil
this.market_age = nil

View File

@@ -15,6 +15,16 @@ local floor = math.floor
local random = math.random
local sqrt = math.sqrt
local z = {
[3] = true,
[6] = true,
[12] = true,
[15] = true,
[16] = true,
[18] = true,
[22] = true
}
local collapse_message =
Token.register(
function(data)
@@ -34,11 +44,10 @@ local spidertron_unlocked =
Alert.alert_all_players(30, message, nil, 'achievement/tech-maniac', 0.1)
end
)
--[[
local calculate_hp = function(zone)
return 2 + 0.2 * zone - 1 * floor(zone / 20)
end
end ]]
local first_player_to_zone =
Token.register(
function(data)
@@ -61,9 +70,9 @@ local artillery_warning =
)
local function distance(player)
local rpg_t = RPG_Settings.get('rpg_t')
local index = player.index
local bonus = RPG_Settings.get_value_from_player(index, 'bonus')
local rpg_extra = RPG_Settings.get('rpg_extra')
local bonus = rpg_t[player.index].bonus
local breached_wall = WPT.get('breached_wall')
local bonus_xp_on_join = WPT.get('bonus_xp_on_join')
local enable_arties = WPT.get('enable_arties')
@@ -131,7 +140,24 @@ local function distance(player)
}
Task.set_timeout_in_ticks(550, collapse_message, data)
end
rpg_t[player.index].bonus = bonus + 1
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)
elseif not z[b] then
RPG_Settings.set_value_to_player(index, 'forest_zone', false)
end
Functions.gain_xp(player, bonus_xp_on_join * bonus)
local message = ({'breached_wall.wall_breached', bonus})
Alert.alert_player_warning(player, 10, message)

View File

@@ -0,0 +1,241 @@
local Event = require 'utils.event'
local Global = require 'utils.global'
local BiterRolls = require 'modules.wave_defense.biter_rolls'
local BiterHealthBooster = require 'modules.biter_health_booster'
local WD = require 'modules.wave_defense.table'
local WPT = require 'maps.mountain_fortress_v3.table'
local Diff = require 'modules.difficulty_vote_by_amount'
local traps = {}
Global.register(
traps,
function(t)
traps = t
end
)
local Public = {}
local floor = math.floor
local random = math.random
local abs = math.abs
local sqrt = math.sqrt
local spawn_amount_rolls = {}
for a = 48, 1, -1 do
spawn_amount_rolls[#spawn_amount_rolls + 1] = floor(a ^ 5)
end
local random_particles = {
'dirt-2-stone-particle-medium',
'dirt-4-dust-particle',
'coal-particle'
}
local s_random_particles = #random_particles
local function create_particles(data)
local surface = data.surface
local position = data.position
local amount = data.amount
if not surface or not surface.valid then
return
end
for i = 1, amount, 1 do
local m = random(6, 12)
local m2 = m * 0.005
surface.create_particle(
{
name = random_particles[random(1, s_random_particles)],
position = position,
frame_speed = 0.1,
vertical_speed = 0.1,
height = 0.1,
movement = {m2 - (random(0, m) * 0.01), m2 - (random(0, m) * 0.01)}
}
)
end
end
local function spawn_biters(data)
local surface = data.surface
local position = data.position
local h = floor(abs(position.y))
local wave_number = WD.get('wave_number')
local max_biters = WPT.get('biters')
local d = Diff.get()
if max_biters.amount >= max_biters.limit then
return
end
if not position then
position = surface.find_non_colliding_position('small-biter', position, 10, 1)
if not position then
return
end
end
local m = 0.0015
if d.difficulty_vote_index then
if not d.strength_modifier then
m = m * 1.05
else
m = m * d.strength_modifier
end
end
local boosted_health = 1 + (wave_number * (m * 2))
if wave_number >= 100 then
boosted_health = boosted_health * 2
end
BiterRolls.wave_defense_set_unit_raffle(h * 0.20)
local unit
if random(1, 3) == 1 then
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = position})
max_biters.amount = max_biters.amount + 1
else
unit = surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = position})
max_biters.amount = max_biters.amount + 1
end
if random(1, 64) == 1 then
max_biters.amount = max_biters.amount + 1
BiterHealthBooster.add_boss_unit(unit, boosted_health, 0.38)
end
end
local function spawn_worms(data)
local max_biters = WPT.get('biters')
if max_biters.amount >= max_biters.limit then
return
end
local surface = data.surface
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})
max_biters.amount = max_biters.amount + 1
end
function Public.buried_biter(surface, position, max)
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 amount = 8
local a = 0
max = max or random(4, 6)
local ticks = amount * 30
ticks = ticks + 90
for t = 1, ticks, 1 do
if not traps[game.tick + t] then
traps[game.tick + t] = {}
end
traps[game.tick + t][#traps[game.tick + t] + 1] = {
callback = 'create_particles',
data = {surface = surface, position = {x = position.x, y = position.y}, amount = 4}
}
if t > 90 then
if t % 30 == 29 then
a = a + 1
traps[game.tick + t][#traps[game.tick + t] + 1] = {
callback = 'spawn_biters',
data = {surface = surface, position = {x = position.x, y = position.y}}
}
if a >= max then
break
end
end
end
end
end
function Public.buried_worm(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 amount = 8
local ticks = amount * 30
ticks = ticks + 90
local a = false
for t = 1, ticks, 1 do
if not traps[game.tick + t] then
traps[game.tick + t] = {}
end
traps[game.tick + t][#traps[game.tick + t] + 1] = {
callback = 'create_particles',
data = {surface = surface, position = {x = position.x, y = position.y}, amount = 4}
}
if not a then
traps[game.tick + t][#traps[game.tick + t] + 1] = {
callback = 'spawn_worms',
data = {surface = surface, position = {x = position.x, y = position.y}}
}
a = true
end
end
end
local callbacks = {
['create_particles'] = create_particles,
['spawn_biters'] = spawn_biters,
['spawn_worms'] = spawn_worms
}
local function on_tick()
local t = game.tick
if not traps[t] then
return
end
for _, token in pairs(traps[t]) do
local callback = token.callback
local data = token.data
local cbl = callbacks[callback]
if callbacks[callback] then
cbl(data)
end
end
traps[t] = nil
end
Event.add(defines.events.on_tick, on_tick)
return Public

View File

@@ -2,13 +2,13 @@ require 'modules.rocks_broken_paint_tiles'
local Event = require 'utils.event'
local Server = require 'utils.server'
local Map_score = require 'comfy_panel.map_score'
local BiterRolls = require 'modules.wave_defense.biter_rolls'
local BuriedEnemies = require 'modules.wave_defense.buried_enemies'
local BuriedEnemies = require 'maps.mountain_fortress_v3.buried_enemies'
local Loot = require 'maps.mountain_fortress_v3.loot'
local Pets = require 'maps.mountain_fortress_v3.biter_pets'
local RPG_Settings = require 'modules.rpg.table'
local Functions = require 'modules.rpg.functions'
local Callbacks = require 'maps.mountain_fortress_v3.functions'
local Mining = require 'maps.mountain_fortress_v3.mining'
local Terrain = require 'maps.mountain_fortress_v3.terrain'
local Traps = require 'maps.mountain_fortress_v3.traps'
@@ -215,10 +215,11 @@ local function set_objective_health(final_damage_amount)
return
end
locomotive_health = floor(locomotive_health - final_damage_amount)
WPT.set('locomotive_health', floor(locomotive_health - final_damage_amount))
if locomotive_health > locomotive_max_health then
locomotive_health = locomotive_max_health
WPT.set('locomotive_health', locomotive_max_health)
end
locomotive_health = WPT.get('locomotive_health')
if locomotive_health <= 0 then
Public.loco_died()
@@ -233,6 +234,14 @@ end
local function protect_entities(event)
local entity = event.entity
local dmg = event.final_damage_amount
if not dmg then
return
end
if entity.type == 'simple-entity' and dmg >= 300 then
entity.health = entity.health + dmg
end
if entity.force.index ~= 1 then
return
@@ -264,18 +273,22 @@ local function protect_entities(event)
end
local units = exists()
if is_protected(entity) then
if event.cause and event.cause.valid then
if (event.cause and event.cause.valid) then
if event.cause.force.index == 2 and units[entity.unit_number] then
set_objective_health(event.final_damage_amount)
return set_objective_health(dmg)
elseif event.cause.force.index == 2 then
return
else
event.entity.health = event.entity.health + event.final_damage_amount
entity.health = entity.health + dmg
end
elseif not (event.cause and event.cause.valid) then
if event.force.index == 2 and units[entity.unit_number] then
return set_objective_health(dmg)
end
end
event.entity.health = event.entity.health + event.final_damage_amount
entity.health = entity.health + dmg
end
end
@@ -330,7 +343,7 @@ end
local projectiles = {'grenade', 'explosive-rocket', 'grenade', 'explosive-rocket', 'explosive-cannon-projectile'}
local function angry_tree(entity, cause)
local function angry_tree(entity, cause, player)
if entity.type ~= 'tree' then
return
end
@@ -338,10 +351,10 @@ local function angry_tree(entity, cause)
if abs(entity.position.y) < Terrain.level_depth then
return
end
if random(1, 4) == 1 then
if random(1, 16) == 1 then
BuriedEnemies.buried_biter(entity.surface, entity.position)
end
if random(1, 8) == 1 then
if random(1, 16) == 1 then
BuriedEnemies.buried_worm(entity.surface, entity.position)
end
if random(1, 32) ~= 1 then
@@ -356,6 +369,24 @@ local function angry_tree(entity, cause)
if not position then
position = {entity.position.x + (-20 + random(0, 40)), entity.position.y + (-20 + random(0, 40))}
end
if player then
local forest_zone = RPG_Settings.get_value_from_player(player.index, 'forest_zone')
if forest_zone and random(1, 32) == 1 then
local cbl = Callbacks.power_source_callback
local data = {callback_data = Callbacks.laser_turrent_power_source}
local e =
entity.surface.create_entity(
{
name = 'laser-turret',
position = entity.position,
force = 'enemy'
}
)
local callback = Token.get(cbl)
callback(e, data)
return
end
end
entity.surface.create_entity(
{
@@ -373,6 +404,13 @@ end
local function give_coin(player)
local coin_amount = WPT.get('coin_amount')
local coin_override = WPT.get('coin_override')
local forest_zone = RPG_Settings.get_value_from_player(player.index, 'forest_zone')
if forest_zone then
if random(1, 32) ~= 1 then
return
end
end
if coin_amount >= 1 then
if coin_override then
@@ -409,6 +447,8 @@ local mining_events = {
return
end
local max_biters = WPT.get('biters')
BuriedEnemies.buried_biter(entity.surface, entity.position, 1)
entity.destroy()
end,
@@ -464,7 +504,7 @@ local mining_events = {
local player = game.get_player(index)
if entity.type == 'tree' then
angry_tree(entity, player.character)
angry_tree(entity, player.character, player)
entity.destroy()
end
end,
@@ -777,11 +817,7 @@ end
local function on_entity_damaged(event)
local entity = event.entity
if not entity then
return
end
if not entity.valid then
if not (entity and entity.valid) then
return
end
@@ -836,6 +872,8 @@ local function on_entity_died(event)
return
end
local cause = event.cause
local map_name = 'mountain_fortress_v3'
if string.sub(entity.surface.name, 0, #map_name) ~= map_name then
@@ -848,9 +886,14 @@ local function on_entity_died(event)
on_entity_removed(d)
if event.cause then
if event.cause.valid then
if event.cause.force.index == 2 or event.cause.force.index == 3 then
local player
if cause then
if cause.valid then
if (cause and cause.name == 'character' and cause.player) then
player = cause.player
end
if cause.force.index == 2 or cause.force.index == 3 then
entity.destroy()
return
end
@@ -906,7 +949,7 @@ local function on_entity_died(event)
entity.destroy()
return
end
angry_tree(entity, event.cause)
angry_tree(entity, cause, player)
return
end
@@ -938,19 +981,6 @@ local function on_entity_died(event)
end
end
function Public.set_scores()
local locomotive = WPT.get('locomotive')
if not (locomotive and locomotive.valid) then
return
end
local score = floor(locomotive.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)
end
end
end
function Public.unstuck_player(index)
local player = game.get_player(index)
local surface = player.surface
@@ -969,7 +999,6 @@ function Public.loco_died()
if wave_defense_table.game_lost then
return
end
Public.set_scores()
if not locomotive.valid then
local this = WPT.get()
if this.announced_message then

View File

@@ -32,8 +32,6 @@ local artillery_target_entities = {
'tank',
'car',
'furnace',
'straight-rail',
'curved-rail',
'locomotive',
'cargo-wagon',
'fluid-wagon',
@@ -141,6 +139,10 @@ local function do_magic_crafters()
local fcount = floor(count)
if fcount > 1 then
fcount = 1
end
if fcount > 0 then
entity.get_output_inventory().insert {name = data.item, count = fcount}
data.last_tick = tick - (count - fcount) / rate
@@ -218,7 +220,7 @@ local artillery_target_callback =
local x, y = pos.x, pos.y
local dx, dy = tx - x, ty - y
local d = dx * dx + dy * dy
if d >= 1024 then -- 32 ^ 2
if d >= 1024 and d <= 441398 then -- 704 in depth~
entity.surface.create_entity {
name = 'artillery-projectile',
position = position,

View File

@@ -0,0 +1,370 @@
local Event = require 'utils.event'
local Global = require 'utils.global'
local Server = require 'utils.server'
local Token = require 'utils.token'
local Tabs = require 'comfy_panel.main'
local WPT = require 'maps.mountain_fortress_v3.table'
local score_dataset = 'highscores'
local set_data = Server.set_data
local try_get_data = Server.try_get_data
local Public = {}
local insert = table.insert
local random = math.random
local this = {
score_table = {},
sort_by = {}
}
Global.register(
this,
function(t)
this = t
end
)
local biters = {
'small-biter',
'medium-biter',
'big-biter',
'behemoth-biter',
'small-spitter',
'medium-spitter',
'big-spitter',
'behemoth-spitter'
}
local function get_total_biter_killcount(force)
local count = 0
for _, biter in pairs(biters) do
count = count + force.kill_count_statistics.get_input_count(biter)
end
return count
end
local function get_additional_stats(key)
if not this.score_table['player'] then
this.score_table['player'] = {}
end
local player = game.forces.player
local breached_zone = WPT.get('breached_wall')
local c = get_total_biter_killcount(player)
local t = this.score_table['player']
t.rockets_launched = player.rockets_launched
t.biters_killed = c
if breached_zone == 1 then
t.breached_zone = breached_zone
else
t.breached_zone = breached_zone - 1
end
set_data(score_dataset, key, t)
end
local get_scores =
Token.register(
function(data)
local value = data.value
if not this.score_table['player'] then
this.score_table['player'] = {}
end
this.score_table['player'] = value
end
)
function Public.get_scores()
local secs = Server.get_current_time()
local key = 'mountain_fortress_v3_scores'
if not secs then
return
else
try_get_data(score_dataset, key, get_scores)
end
end
function Public.set_scores(key)
local secs = Server.get_current_time()
key = tostring(key)
if not secs then
return
else
get_additional_stats(key)
end
end
local sorting_symbol = {ascending = '', descending = ''}
local function get_score_list()
local score_force = this.score_table['player']
local score_list = {}
if not score_force then
score_list[#score_list + 1] = {
name = 'Nothing here yet',
killscore = 0,
deaths = 0,
built_entities = 0,
mined_entities = 0
}
return score_list
end
for p, _ in pairs(score_force.players) do
if score_force.players[p] then
local score = score_force.players[p]
insert(
score_list,
{
name = p,
killscore = score.killscore or 0,
deaths = score.deaths or 0,
built_entities = score.built_entities or 0,
mined_entities = score.mined_entities or 0
}
)
end
end
return score_list
end
local function get_sorted_list(method, column_name, score_list)
local comparators = {
['ascending'] = function(a, b)
return a[column_name] < b[column_name]
end,
['descending'] = function(a, b)
return a[column_name] > b[column_name]
end
}
table.sort(score_list, comparators[method])
return score_list
end
local function add_global_stats(frame)
local score = this.score_table['player']
local t = frame.add {type = 'table', column_count = 6}
local l = t.add {type = 'label', caption = 'Rockets launched: '}
l.style.font = 'default-game'
l.style.font_color = {r = 175, g = 75, b = 255}
l.style.minimal_width = 140
local l = t.add {type = 'label', caption = score.rockets_launched}
l.style.font = 'default-listbox'
l.style.font_color = {r = 0.9, g = 0.9, b = 0.9}
l.style.minimal_width = 123
local l = t.add {type = 'label', caption = 'Dead bugs: '}
l.style.font = 'default-game'
l.style.font_color = {r = 0.90, g = 0.3, b = 0.3}
l.style.minimal_width = 100
local l = t.add {type = 'label', caption = score.biters_killed}
l.style.font = 'default-listbox'
l.style.font_color = {r = 0.9, g = 0.9, b = 0.9}
l.style.minimal_width = 145
local l = t.add {type = 'label', caption = 'Breached zones: '}
l.style.font = 'default-game'
l.style.font_color = {r = 0, g = 128, b = 0}
l.style.minimal_width = 100
local l = t.add {type = 'label', caption = score.breached_zone - 1}
l.style.font = 'default-listbox'
l.style.font_color = {r = 0.9, g = 0.9, b = 0.9}
l.style.minimal_width = 145
end
local show_score = (function(player, frame)
frame.clear()
local flow = frame.add {type = 'flow'}
local sFlow = flow.style
sFlow.horizontally_stretchable = true
sFlow.horizontal_align = 'center'
sFlow.vertical_align = 'center'
local stats = flow.add {type = 'label', caption = 'Previous game statistics!'}
local s_stats = stats.style
s_stats.font = 'heading-1'
s_stats.font_color = {r = 0.98, g = 0.66, b = 0.22}
s_stats.horizontal_align = 'center'
s_stats.vertical_align = 'center'
-- Global stats : rockets, biters kills
add_global_stats(frame)
-- Separator
local line = frame.add {type = 'line'}
line.style.top_margin = 8
line.style.bottom_margin = 8
-- Score per player
local t = frame.add {type = 'table', column_count = 5}
-- Score headers
local headers = {
{name = 'score_player', caption = 'Player'},
{column = 'killscore', name = 'score_killscore', caption = 'Killscore'},
{column = 'deaths', name = 'score_deaths', caption = 'Deaths'},
{column = 'built_entities', name = 'score_built_entities', caption = 'Built structures'},
{column = 'mined_entities', name = 'score_mined_entities', caption = 'Mined entities'}
}
local sorting_pref = this.sort_by[player.index]
for _, header in ipairs(headers) do
local cap = header.caption
-- Add sorting symbol if any
if header.column and sorting_pref.column == header.column then
local symbol = sorting_symbol[sorting_pref.method]
cap = symbol .. cap
end
-- Header
local label =
t.add {
type = 'label',
caption = cap,
name = header.name
}
label.style.font = 'default-listbox'
label.style.font_color = {r = 0.98, g = 0.66, b = 0.22} -- yellow
label.style.minimal_width = 150
label.style.horizontal_align = 'right'
end
-- Score list
local score_list = get_score_list()
if #game.connected_players > 1 then
score_list = get_sorted_list(sorting_pref.method, sorting_pref.column, score_list)
end
-- New pane for scores (while keeping headers at same position)
local scroll_pane =
frame.add(
{
type = 'scroll-pane',
name = 'score_scroll_pane',
direction = 'vertical',
horizontal_scroll_policy = 'never',
vertical_scroll_policy = 'auto'
}
)
scroll_pane.style.maximal_height = 400
local t = scroll_pane.add {type = 'table', column_count = 5}
-- Score entries
for _, entry in pairs(score_list) do
local p
if not (entry and entry.name) then
p = {color = {r = random(1, 255), g = random(1, 255), b = random(1, 255)}}
else
p = game.players[entry.name]
if not p then
p = {color = {r = random(1, 255), g = random(1, 255), b = random(1, 255)}}
end
end
local special_color = {
r = p.color.r * 0.6 + 0.4,
g = p.color.g * 0.6 + 0.4,
b = p.color.b * 0.6 + 0.4,
a = 1
}
local line = {
{caption = entry.name, color = special_color},
{caption = tostring(entry.killscore)},
{caption = tostring(entry.deaths)},
{caption = tostring(entry.built_entities)},
{caption = tostring(entry.mined_entities)}
}
local default_color = {r = 0.9, g = 0.9, b = 0.9}
for _, column in ipairs(line) do
local label =
t.add {
type = 'label',
caption = column.caption,
color = column.color or default_color
}
label.style.font = 'default'
label.style.minimal_width = 150
label.style.maximal_width = 150
label.style.horizontal_align = 'right'
end -- foreach column
end -- foreach entry
end) -- show_score
comfy_panel_tabs['HighScore'] = {gui = show_score, admin = false}
local function on_gui_click(event)
if not event then
return
end
if not event.element then
return
end
if not event.element.valid then
return
end
local player = game.players[event.element.player_index]
local frame = Tabs.comfy_panel_get_active_frame(player)
if not frame then
return
end
if frame.name ~= 'HighScore' then
return
end
local name = event.element.name
-- Handles click on the checkbox, for floating score
if name == 'show_floating_killscore_texts' then
global.show_floating_killscore[player.name] = event.element.state
return
end
-- Handles click on a score header
local element_to_column = {
['score_killscore'] = 'killscore',
['score_deaths'] = 'deaths',
['score_built_entities'] = 'built_entities',
['score_mined_entities'] = 'mined_entities'
}
local column = element_to_column[name]
if column then
local sorting_pref = this.sort_by[player.index]
if sorting_pref.column == column and sorting_pref.method == 'descending' then
sorting_pref.method = 'ascending'
else
sorting_pref.method = 'descending'
sorting_pref.column = column
end
show_score(player, frame)
return
end
end
local function on_player_joined_game(event)
local player = game.players[event.player_index]
if not this.sort_by[player.index] then
this.sort_by[player.index] = {method = 'descending', column = 'killscore'}
end
end
local function on_player_left_game(event)
local player = game.players[event.player_index]
if this.sort_by[player.index] then
this.sort_by[player.index] = nil
end
end
Event.add(defines.events.on_player_left_game, on_player_left_game)
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Event.add(defines.events.on_gui_click, on_gui_click)
Event.add(Server.events.on_server_started, Public.get_scores)
return Public

View File

@@ -304,7 +304,10 @@ end
local function property_boost(data)
local xp_floating_text_color = {r = 188, g = 201, b = 63}
local visuals_delay = 1800
local locomotive_surface = WPT.get('locomotive_surface')
local loco_surface = WPT.get('loco_surface')
if not (loco_surface and loco_surface.valid) then
return
end
local locomotive_xp_aura = WPT.get('locomotive_xp_aura')
local locomotive = WPT.get('locomotive')
local xp_points = WPT.get('xp_points')
@@ -321,7 +324,7 @@ local function property_boost(data)
return
end
if player.afk_time < 200 then
if Math2D.bounding_box.contains_point(area, player.position) or player.surface.index == locomotive_surface.index then
if Math2D.bounding_box.contains_point(area, player.position) or player.surface.index == loco_surface.index then
Public.add_player_to_permission_group(player, 'locomotive')
local pos = player.position
Functions.gain_xp(player, 0.5 * (rpg[player.index].bonus + xp_points))

View File

@@ -12,12 +12,12 @@ require 'modules.biters_yield_coins'
require 'modules.wave_defense.main'
require 'modules.charging_station'
-- local HS = require 'maps.mountain_fortress_v3.highscore'
local IC = require 'maps.mountain_fortress_v3.ic.table'
local Autostash = require 'modules.autostash'
local Group = require 'comfy_panel.group'
local PL = require 'comfy_panel.player_list'
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'
@@ -301,8 +301,6 @@ function Public.reset_map()
game.reset_time_played()
WPT.reset_table()
Map_score.reset_score()
RPG_Func.rpg_reset_all_players()
RPG_Settings.set_surface_name('mountain_fortress_v3')
RPG_Settings.enable_health_and_mana_bars(true)
@@ -331,9 +329,6 @@ function Public.reset_map()
Balance.init_enemy_weapon_damage()
global.custom_highscore.description = 'Wagon distance reached:'
Entities.set_scores()
AntiGrief.log_tree_harvest(true)
AntiGrief.whitelist_types('tree', true)
AntiGrief.enable_capsule_warning(false)
@@ -574,7 +569,7 @@ local has_the_game_ended = function()
return
end
local this = WPT.get('this')
local this = WPT.get()
this.game_reset_tick = this.game_reset_tick - 30
if this.game_reset_tick % 1800 == 0 then
@@ -812,14 +807,14 @@ local on_tick = function()
if tick % 1000 == 0 then
collapse_after_wave_100()
Entities.set_scores()
set_difficulty()
local spawn_near_collapse = WPT.get('spawn_near_collapse')
if spawn_near_collapse then
local collapse_pos = Collapse.get_position()
local position = surface.find_non_colliding_position('rocket-silo', collapse_pos, 128, 1)
if position then
WD.set_spawn_position({position.x, position.y - 50})
WD.set_spawn_position({x = position.x, y = position.y - 50})
end
end
end
@@ -840,8 +835,8 @@ local on_init = function()
this.rocks_yield_ore_maximum_amount = 500
this.type_modifier = 1
this.rocks_yield_ore_base_amount = 50
this.rocks_yield_ore_distance_modifier = 0.025
this.rocks_yield_ore_base_amount = 40
this.rocks_yield_ore_distance_modifier = 0.020
local T = Map.Pop_info()
T.localised_category = 'mountain_fortress_v3'

View File

@@ -1,4 +1,5 @@
local WPT = require 'maps.mountain_fortress_v3.table'
local RPG_Settings = require 'modules.rpg.table'
require 'modules.check_fullness'
local Public = {}
@@ -413,11 +414,14 @@ function Public.on_player_mined_entity(event)
player = player
}
-- if this.breached_wall == 6 then
-- randomness_scrap(data)
-- else
randomness(data)
-- end
local index = player.index
local scrap_zone = RPG_Settings.get_value_from_player(index, 'scrap_zone')
if scrap_zone then
randomness_scrap(data)
else
randomness(data)
end
end
end

View File

@@ -61,7 +61,7 @@ local oil_loot = {
stack = {
recipe = 'basic-oil-processing',
output = {
min_rate = 4.125 / 60,
min_rate = 1 / 60,
distance_factor = 1 / 10 / 60 / 512,
item = 'petroleum-gas',
fluidbox_index = 2
@@ -73,9 +73,9 @@ local oil_loot = {
stack = {
recipe = 'advanced-oil-processing',
output = {
{min_rate = 3.125 / 60, distance_factor = 3.125 / 60 / 512, item = 'heavy-oil', fluidbox_index = 3},
{min_rate = 5.625 / 60, distance_factor = 5.625 / 60 / 512, item = 'light-oil', fluidbox_index = 4},
{min_rate = 6.875 / 60, distance_factor = 6.875 / 60 / 512, item = 'petroleum-gas', fluidbox_index = 5}
{min_rate = 0.7 / 60, distance_factor = 3.125 / 60 / 512, item = 'heavy-oil', fluidbox_index = 3},
{min_rate = 0.82 / 60, distance_factor = 5.625 / 60 / 512, item = 'light-oil', fluidbox_index = 4},
{min_rate = 0.83 / 60, distance_factor = 6.875 / 60 / 512, item = 'petroleum-gas', fluidbox_index = 5}
}
},
weight = 0.1
@@ -88,7 +88,7 @@ local oil_prod_loot = {
recipe = 'lubricant',
output = {
item = 'lubricant',
min_rate = 2.825 / 60,
min_rate = 0.7 / 60,
distance_factor = 1 / 10 / 60 / 512,
fluidbox_index = 2
}
@@ -100,7 +100,7 @@ local oil_prod_loot = {
recipe = 'solid-fuel-from-light-oil',
output = {
item = 'solid-fuel',
min_rate = 2 / 60,
min_rate = 0.7 / 60,
distance_factor = 1 / 4 / 60 / 512
}
},
@@ -111,7 +111,7 @@ local oil_prod_loot = {
recipe = 'sulfuric-acid',
output = {
item = 'sulfuric-acid',
min_rate = 2.825 / 60,
min_rate = 0.8 / 60,
distance_factor = 1 / 8 / 60 / 512,
fluidbox_index = 2
}
@@ -123,7 +123,7 @@ local oil_prod_loot = {
recipe = 'battery',
output = {
item = 'battery',
min_rate = 2 / 60,
min_rate = 0.6 / 60,
distance_factor = 1 / 25 / 60 / 512
}
},
@@ -134,7 +134,7 @@ local oil_prod_loot = {
recipe = 'sulfur',
output = {
item = 'sulfur',
min_rate = 2.825 / 60,
min_rate = 0.8 / 60,
distance_factor = 1 / 25 / 60 / 512
}
},
@@ -145,7 +145,7 @@ local oil_prod_loot = {
recipe = 'plastic-bar',
output = {
item = 'plastic-bar',
min_rate = 2 / 60,
min_rate = 0.8 / 60,
distance_factor = 1 / 25 / 60 / 512
}
},
@@ -157,42 +157,42 @@ local resource_loot = {
{
stack = {
recipe = 'stone-wall',
output = {item = 'stone-wall', min_rate = 1.5 / 60, distance_factor = 1 / 6 / 60 / 512}
output = {item = 'stone-wall', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512}
},
weight = 10
},
{
stack = {
recipe = 'iron-gear-wheel',
output = {item = 'iron-gear-wheel', min_rate = 1.5 / 60, distance_factor = 1 / 6 / 60 / 512}
output = {item = 'iron-gear-wheel', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512}
},
weight = 12
},
{
stack = {
recipe = 'inserter',
output = {item = 'inserter', min_rate = 1.5 / 60, distance_factor = 1 / 6 / 60 / 512}
output = {item = 'inserter', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512}
},
weight = 12
},
{
stack = {
recipe = 'transport-belt',
output = {item = 'transport-belt', min_rate = 1.5 / 60, distance_factor = 1 / 6 / 60 / 512}
output = {item = 'transport-belt', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512}
},
weight = 8
},
{
stack = {
recipe = 'underground-belt',
output = {item = 'underground-belt', min_rate = 1.0 / 60, distance_factor = 1 / 6 / 60 / 512}
output = {item = 'underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
},
weight = 8
},
{
stack = {
recipe = 'small-electric-pole',
output = {item = 'small-electric-pole', min_rate = 1.0 / 60, distance_factor = 1 / 6 / 60 / 512}
output = {item = 'small-electric-pole', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
},
weight = 8
},

View File

@@ -192,8 +192,11 @@ function Public.get(key)
end
end
function Public.set(key)
if key then
function Public.set(key, value)
if key and value then
this[key] = value
return this[key]
elseif key then
return this[key]
else
return this

View File

@@ -401,7 +401,7 @@ local function process_level_14_position(x, y, data)
--Resource Spots
if smol_areas < -0.71 then
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
end
@@ -476,7 +476,7 @@ local function process_level_13_position(x, y, data)
--Resource Spots
if smol_areas < -0.72 then
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
end
@@ -552,7 +552,7 @@ local function process_level_12_position(x, y, data, void_or_lab)
--Resource Spots
if smol_areas < -0.72 then
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
end
@@ -646,7 +646,7 @@ local function process_level_11_position(x, y, data)
--Resource Spots
if smol_areas < -0.72 then
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
end
@@ -744,7 +744,7 @@ local function process_level_10_position(x, y, data)
end
--Resource Spots
if smol_areas < -0.72 then
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
end
@@ -869,7 +869,7 @@ local function process_level_9_position(x, y, data)
--Resource Spots
if smol_areas < -0.72 then
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
end
@@ -974,7 +974,7 @@ local function process_level_8_position(x, y, data, void_or_lab)
--Resource Spots
if smol_areas < -0.72 then
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
end
@@ -1102,7 +1102,7 @@ local function process_level_7_position(x, y, data, void_or_lab)
--Resource Spots
if smol_areas < -0.72 then
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
end
@@ -1155,7 +1155,7 @@ local function process_level_6_position(x, y, data, void_or_lab)
--Resource Spots
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
@@ -1282,7 +1282,7 @@ local function process_level_5_position(x, y, data, void_or_lab)
--Resource Spots
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
@@ -1410,7 +1410,7 @@ local function process_level_4_position(x, y, data, void_or_lab)
--Resource Spots
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
@@ -1466,7 +1466,7 @@ local function process_level_3_position(x, y, data, void_or_lab)
--Resource Spots
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
@@ -1621,7 +1621,7 @@ local function process_level_2_position(x, y, data, void_or_lab)
--Resource Spots
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
@@ -1761,7 +1761,7 @@ local function process_level_1_2_position(x, y, data, void_or_lab)
--Resource Spots
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then
@@ -1939,7 +1939,7 @@ local function process_level_1_position(x, y, data, void_or_lab)
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 32) == 1 then
@@ -2104,7 +2104,7 @@ local function process_level_0_position(x, y, data, void_or_lab)
if smol_areas < 0.055 and smol_areas > -0.025 then
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
if random(1, 8) == 1 then
if random(1, 32) == 1 then
Generate_resources(buildings, p, Public.level_depth)
end
if random(1, 128) == 1 then

View File

@@ -28,8 +28,7 @@ function Public.draw_gui_char_button(player)
if player.gui.top[draw_main_frame_name] then
return
end
local b =
player.gui.top.add({type = 'sprite-button', name = draw_main_frame_name, caption = '[RPG]', tooltip = 'RPG'})
local b = player.gui.top.add({type = 'sprite-button', name = draw_main_frame_name, caption = '[RPG]', tooltip = 'RPG'})
b.style.font_color = {165, 165, 165}
b.style.font = 'heading-3'
b.style.minimal_height = 34
@@ -53,9 +52,7 @@ end
local function get_class(player)
local rpg_t = RPG.get('rpg_t')
local average =
(rpg_t[player.index].strength + rpg_t[player.index].magicka + rpg_t[player.index].dexterity +
rpg_t[player.index].vitality) /
4
(rpg_t[player.index].strength + rpg_t[player.index].magicka + rpg_t[player.index].dexterity + rpg_t[player.index].vitality) / 4
local high_attribute = 0
local high_attribute_name = ''
for _, attribute in pairs({'strength', 'magicka', 'dexterity', 'vitality'}) do
@@ -219,15 +216,7 @@ local function draw_main_frame(player, location)
local rank = add_gui_stat(main_table, get_class(player), 200, ({'rpg_gui.class_info', get_class(player)}))
rank.style.font = 'default-large-bold'
add_elem_stat(
main_table,
({'rpg_gui.settings_name'}),
200,
35,
nil,
({'rpg_gui.settings_frame'}),
settings_button_name
)
add_elem_stat(main_table, ({'rpg_gui.settings_name'}), 200, 35, nil, ({'rpg_gui.settings_frame'}), settings_button_name)
add_separator(scroll_pane, 400)
@@ -289,14 +278,11 @@ local function draw_main_frame(player, location)
add_gui_description(left_bottom_table, ' ', 40)
add_gui_description(left_bottom_table, ({'rpg_gui.life_name'}), w1, ({'rpg_gui.life_tooltip'}))
local health_gui =
add_gui_stat(left_bottom_table, math.floor(player.character.health), w2, ({'rpg_gui.life_increase'}))
local health_gui = add_gui_stat(left_bottom_table, math.floor(player.character.health), w2, ({'rpg_gui.life_increase'}))
data.health = health_gui
add_gui_stat(
left_bottom_table,
math.floor(
player.character.prototype.max_health + player.character_health_bonus + player.force.character_health_bonus
),
math.floor(player.character.prototype.max_health + player.character_health_bonus + player.force.character_health_bonus),
w2,
({'rpg_gui.life_maximum'})
)
@@ -353,14 +339,12 @@ local function draw_main_frame(player, location)
add_gui_description(right_bottom_table, ' ', w0)
add_gui_description(right_bottom_table, ({'rpg_gui.mining_name'}), w1)
local mining_speed_value =
math.round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100) ..
'%'
math.round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100) .. '%'
add_gui_stat(right_bottom_table, mining_speed_value, w2)
add_gui_description(right_bottom_table, ' ', w0)
add_gui_description(right_bottom_table, ({'rpg_gui.slot_name'}), w1)
local slot_bonus_value =
'+ ' .. math.round(player.force.character_inventory_slots_bonus + player.character_inventory_slots_bonus)
local slot_bonus_value = '+ ' .. math.round(player.force.character_inventory_slots_bonus + player.character_inventory_slots_bonus)
add_gui_stat(right_bottom_table, slot_bonus_value, w2)
add_gui_description(right_bottom_table, ' ', w0)
@@ -382,8 +366,7 @@ local function draw_main_frame(player, location)
add_gui_description(right_bottom_table, '', w0, '', nil, 5)
add_gui_description(right_bottom_table, '', w0, '', nil, 5)
local reach_distance_value =
'+ ' .. (player.force.character_reach_distance_bonus + player.character_reach_distance_bonus)
local reach_distance_value = '+ ' .. (player.force.character_reach_distance_bonus + player.character_reach_distance_bonus)
local reach_bonus_tooltip = ({
'rpg_gui.bonus_tooltip',
player.character_reach_distance_bonus,
@@ -406,15 +389,13 @@ local function draw_main_frame(player, location)
add_gui_description(right_bottom_table, ' ', w0)
add_gui_description(right_bottom_table, ({'rpg_gui.crafting_speed'}), w1)
local crafting_speed_value =
math.round((player.force.manual_crafting_speed_modifier + player.character_crafting_speed_modifier + 1) * 100) ..
'%'
math.round((player.force.manual_crafting_speed_modifier + player.character_crafting_speed_modifier + 1) * 100) .. '%'
add_gui_stat(right_bottom_table, crafting_speed_value, w2)
add_gui_description(right_bottom_table, ' ', w0)
add_gui_description(right_bottom_table, ({'rpg_gui.running_speed'}), w1)
local running_speed_value =
math.round((player.force.character_running_speed_modifier + player.character_running_speed_modifier + 1) * 100) ..
'%'
math.round((player.force.character_running_speed_modifier + player.character_running_speed_modifier + 1) * 100) .. '%'
add_gui_stat(right_bottom_table, running_speed_value, w2)
add_gui_description(right_bottom_table, ' ', w0)
@@ -492,7 +473,7 @@ function Public.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.07, 1)
player_modifiers[player.index].character_maximum_following_robot_count_bonus['rpg'] = math.round(strength / 2 * 0.03, 3)
local magic = rpg_t[player.index].magicka - 10
local v = magic * 0.22
@@ -512,8 +493,7 @@ function Public.update_player_stats(player)
player_modifiers[player.index].character_running_speed_modifier['rpg'] = math.round(dexterity * 0.0015, 3)
player_modifiers[player.index].character_crafting_speed_modifier['rpg'] = math.round(dexterity * 0.015, 3)
player_modifiers[player.index].character_health_bonus['rpg'] =
math.round((rpg_t[player.index].vitality - 10) * 6, 3)
player_modifiers[player.index].character_health_bonus['rpg'] = math.round((rpg_t[player.index].vitality - 10) * 6, 3)
P.update_player_modifiers(player)
end

View File

@@ -130,6 +130,38 @@ function Public.get(key)
end
end
--- Gets value from player rpg_t table
---@param key <string>
---@param value <string>
function Public.get_value_from_player(key, value)
if key and value then
if (this.rpg_t[key] and this.rpg_t[key][value]) then
return this.rpg_t[key][value]
end
return false
end
if key then
if this.rpg_t[key] then
return this.rpg_t[key]
end
return false
end
return false
end
--- Sets value to player rpg_t table
---@param key <string>
---@param value <string>
---@param setter <string>
function Public.set_value_to_player(key, value, setter)
if key and value then
if (this.rpg_t[key] and this.rpg_t[key][value]) then
this.rpg_t[key][value] = setter or false
elseif (this.rpg_t[key] and not this.rpg_t[key][value]) then
this.rpg_t[key][value] = setter or false
end
end
end
--- Sets value to table
---@param key <string>
function Public.set(key)