mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-16 02:47:48 +02:00
mtn v3 - features and changes
This commit is contained in:
parent
af26bae0d0
commit
b550f3f1ee
@ -469,8 +469,8 @@ function Public.get(key)
|
||||
end
|
||||
|
||||
function Public.set(key, value)
|
||||
if key and (value or value == false) then
|
||||
this[key] = value
|
||||
if key then
|
||||
this[key] = value or false
|
||||
return this[key]
|
||||
elseif key then
|
||||
return this[key]
|
||||
|
@ -64,6 +64,7 @@ xp_bought_info=__1__ __2__ has bought the XP points modifier for __3__ coins.
|
||||
reroll_bought_info=__1__ __2__ has rerolled the market items for __3__ coins.
|
||||
pickaxe_bought_info=__1__ __2__ has upgraded the teams pickaxe to tier __3__ for __4__ coins.
|
||||
explosive_bullet_bought_info=__1__ __2__ has bought the explosive bullet modifier for __3__ coins.
|
||||
car_health_upgrade_pool_bought_info=__1__ __2__ has bought the global car health modifier for __3__ coins.
|
||||
one_flamethrower_bought_info=__1__ __2__ has bought a flamethrower-turret slot for __3__ coins.
|
||||
multiple_flamethrower_bought_info=__1__ __2__ has bought __3__ flamethrower-turret slot for __4__ coins.
|
||||
landmine_bought_info=__1__ __2__ has bought a landmine slot for __3__ coins.
|
||||
@ -81,6 +82,7 @@ artillery_unlocked=Artillery has now been unlocked at the market!
|
||||
chest=Upgrades the amount of chests that can be placed outside.\nCan be purchased multiple times. [__1__/7]
|
||||
locomotive_max_health=Upgrades the train health.\nCan be purchased multiple times. [__1__/99]
|
||||
locomotive_xp_aura=Upgrades the XP aura that is around the train. [__1__]
|
||||
global_car_health_modifier=Grants all cars/tanks/spidertrons a global health modifier.
|
||||
xp_points_boost=Upgrades the amount of XP points you get inside the XP aura [__1__]
|
||||
explosive_bullets=Upgrades ordinary SMG ammo to explosive bullets.
|
||||
reroll_market_items=Will reroll the items in the market and shuffle prices.
|
||||
|
@ -933,7 +933,7 @@ local function on_player_repaired_entity(event)
|
||||
local player = game.players[event.player_index]
|
||||
local repair_speed = RPG.get_magicka(player)
|
||||
if repair_speed <= 0 then
|
||||
set_train_final_health(-1, true)
|
||||
set_train_final_health(2, true)
|
||||
return
|
||||
else
|
||||
set_train_final_health(-repair_speed, true)
|
||||
|
@ -863,14 +863,26 @@ function Public.set_difficulty()
|
||||
Diff.difficulty_vote_value = 0.1
|
||||
end
|
||||
|
||||
if Diff.name == "I'm too young to die" then
|
||||
wave_defense_table.max_active_biters = 768 + player_count * (90 * Diff.difficulty_vote_value)
|
||||
elseif Diff.name == 'Hurt me plenty' then
|
||||
wave_defense_table.max_active_biters = 845 + player_count * (90 * Diff.difficulty_vote_value)
|
||||
elseif Diff.name == 'Ultra-violence' then
|
||||
wave_defense_table.max_active_biters = 1000 + player_count * (90 * Diff.difficulty_vote_value)
|
||||
end
|
||||
|
||||
if wave_defense_table.max_active_biters >= 4000 then
|
||||
wave_defense_table.max_active_biters = 4000
|
||||
end
|
||||
|
||||
-- threat gain / wave
|
||||
if Diff.name == "I'm too young to die" then
|
||||
wave_defense_table.threat_gain_multiplier = 1.2 + player_count * Diff.difficulty_vote_value * 0.1
|
||||
elseif Diff.name == 'Hurt me plenty' then
|
||||
wave_defense_table.threat_gain_multiplier = 2 + player_count * Diff.difficulty_vote_value * 0.1
|
||||
elseif Diff.name == 'Ultra-violence' then
|
||||
wave_defense_table.threat_gain_multiplier = 4 + player_count * Diff.difficulty_vote_value * 0.1
|
||||
end
|
||||
|
||||
-- local amount = player_count * 0.40 + 2 -- too high?
|
||||
local amount = player_count * difficulty.multiply + 2
|
||||
@ -881,11 +893,22 @@ function Public.set_difficulty()
|
||||
amount = difficulty.highest -- lowered from 20 to 10
|
||||
end
|
||||
|
||||
if Diff.name == "I'm too young to die" then
|
||||
wave_defense_table.wave_interval = 3600 - player_count * 60
|
||||
|
||||
if wave_defense_table.wave_interval < 1800 or wave_defense_table.threat <= 0 then
|
||||
wave_defense_table.wave_interval = 1800
|
||||
end
|
||||
elseif Diff.name == 'Hurt me plenty' then
|
||||
wave_defense_table.wave_interval = 2600 - player_count * 60
|
||||
if wave_defense_table.wave_interval < 1500 or wave_defense_table.threat <= 0 then
|
||||
wave_defense_table.wave_interval = 1500
|
||||
end
|
||||
elseif Diff.name == 'Ultra-violence' then
|
||||
wave_defense_table.wave_interval = 1600 - player_count * 60
|
||||
if wave_defense_table.wave_interval < 1100 or wave_defense_table.threat <= 0 then
|
||||
wave_defense_table.wave_interval = 1100
|
||||
end
|
||||
end
|
||||
|
||||
if collapse_amount then
|
||||
Collapse.set_amount(collapse_amount)
|
||||
@ -916,6 +939,8 @@ function Public.set_difficulty()
|
||||
mining_bonus = 3 -- set a static 300% bonus if there are <= 5 players.
|
||||
elseif player_count >= 6 and player_count <= 10 then
|
||||
mining_bonus = 1 -- set a static 100% bonus if there are <= 10 players.
|
||||
elseif player_count >= 11 then
|
||||
mining_bonus = 0 -- back to 0% with more than 11 players
|
||||
end
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + mining_bonus
|
||||
WPT.set('mining_bonus', mining_bonus) -- Setting mining_bonus globally so it remembers how much to reduce
|
||||
|
@ -4,10 +4,13 @@ local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
|
||||
local Public = {}
|
||||
local main_tile_name = 'black-refined-concrete'
|
||||
local raise_event = script.raise_event
|
||||
local round = math.round
|
||||
local floor = math.floor
|
||||
|
||||
local function validate_entity(entity)
|
||||
if not (entity and entity.valid) then
|
||||
@ -207,7 +210,9 @@ local function get_saved_entity(entity, index)
|
||||
end
|
||||
|
||||
local function replace_entity(cars, entity, index)
|
||||
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
|
||||
local unit_number = entity.unit_number
|
||||
local health = floor(2000 * entity.health * 0.002)
|
||||
for k, car in pairs(cars) do
|
||||
if car.saved_entity == index.saved_entity then
|
||||
local c = car
|
||||
@ -215,6 +220,11 @@ local function replace_entity(cars, entity, index)
|
||||
cars[unit_number].entity = entity
|
||||
cars[unit_number].saved_entity = nil
|
||||
cars[unit_number].transfer_entities = car.transfer_entities
|
||||
cars[unit_number].health_pool = {
|
||||
enabled = has_upgraded_health_pool or false,
|
||||
health = health,
|
||||
max = health
|
||||
}
|
||||
cars[k] = nil
|
||||
end
|
||||
end
|
||||
@ -714,6 +724,9 @@ function Public.kill_car(entity)
|
||||
return
|
||||
end
|
||||
|
||||
kick_players_out_of_vehicles(car)
|
||||
kick_players_from_surface(car)
|
||||
|
||||
local trust_system = IC.get('trust_system')
|
||||
local owner = car.owner
|
||||
|
||||
@ -728,9 +741,7 @@ function Public.kill_car(entity)
|
||||
|
||||
local surface_index = car.surface
|
||||
local surface = game.surfaces[surface_index]
|
||||
kick_players_out_of_vehicles(car)
|
||||
kill_doors(car)
|
||||
kick_players_from_surface(car)
|
||||
for _, tile in pairs(surface.find_tiles_filtered({area = car.area})) do
|
||||
surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true)
|
||||
end
|
||||
@ -902,6 +913,7 @@ function Public.create_car(event)
|
||||
end
|
||||
|
||||
local renders = IC.get('renders')
|
||||
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
|
||||
|
||||
local name, mined = get_player_entity(player)
|
||||
|
||||
@ -939,6 +951,8 @@ function Public.create_car(event)
|
||||
car_area = car_areas[ce.type]
|
||||
end
|
||||
|
||||
local health = floor(2000 * ce.health * 0.002)
|
||||
|
||||
cars[un] = {
|
||||
entity = ce,
|
||||
area = {
|
||||
@ -946,6 +960,11 @@ function Public.create_car(event)
|
||||
right_bottom = {x = car_area.right_bottom.x, y = car_area.right_bottom.y}
|
||||
},
|
||||
doors = {},
|
||||
health_pool = {
|
||||
enabled = has_upgraded_health_pool or false,
|
||||
health = health,
|
||||
max = health
|
||||
},
|
||||
owner = player.index,
|
||||
name = ce.name,
|
||||
type = ce.type
|
||||
@ -1131,6 +1150,85 @@ function Public.on_player_respawned(player)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.check_entity_healths()
|
||||
local cars = IC.get('cars')
|
||||
if not next(cars) then
|
||||
return
|
||||
end
|
||||
|
||||
local health_types = {
|
||||
['car'] = 450,
|
||||
['tank'] = 2000,
|
||||
['spidertron'] = 3000
|
||||
}
|
||||
|
||||
for k, car in pairs(cars) do
|
||||
local m = car.health_pool.health / car.health_pool.max
|
||||
|
||||
if car.health_pool.health > car.health_pool.max then
|
||||
car.health_pool.health = car.health_pool.max
|
||||
end
|
||||
|
||||
if (car.entity and car.entity.valid) then
|
||||
car.entity.health = health_types[car.entity.name] * m
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.set_damage_health(data)
|
||||
local entity = data.entity
|
||||
local final_damage_amount = data.final_damage_amount
|
||||
local car = data.car
|
||||
|
||||
if final_damage_amount == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local health_types = {
|
||||
['car'] = 450,
|
||||
['tank'] = 2000,
|
||||
['spidertron'] = 3000
|
||||
}
|
||||
|
||||
car.health_pool.health = round(car.health_pool.health - final_damage_amount)
|
||||
|
||||
if car.health_pool.health <= 0 then
|
||||
entity.die()
|
||||
return
|
||||
end
|
||||
|
||||
local m = car.health_pool.health / car.health_pool.max
|
||||
|
||||
entity.health = health_types[entity.name] * m
|
||||
end
|
||||
|
||||
function Public.set_repair_health(data)
|
||||
local entity = data.entity
|
||||
local car = data.car
|
||||
local player = data.player
|
||||
|
||||
local repair_speed = RPG.get_magicka(player)
|
||||
if repair_speed <= 0 then
|
||||
repair_speed = 5
|
||||
end
|
||||
|
||||
local health_types = {
|
||||
['car'] = 450,
|
||||
['tank'] = 2000,
|
||||
['spidertron'] = 3000
|
||||
}
|
||||
|
||||
car.health_pool.health = round(car.health_pool.health + repair_speed)
|
||||
|
||||
local m = car.health_pool.health / car.health_pool.max
|
||||
|
||||
if car.health_pool.health > car.health_pool.max then
|
||||
car.health_pool.health = car.health_pool.max
|
||||
end
|
||||
|
||||
entity.health = health_types[entity.name] * m
|
||||
end
|
||||
|
||||
Public.kick_player_from_surface = kick_player_from_surface
|
||||
Public.get_player_surface = get_player_surface
|
||||
Public.get_entity_from_player_surface = get_entity_from_player_surface
|
||||
|
@ -4,6 +4,7 @@ local Event = require 'utils.event'
|
||||
local Functions = require 'maps.mountain_fortress_v3.ic.functions'
|
||||
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
||||
local Minimap = require 'maps.mountain_fortress_v3.ic.minimap'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Public = {}
|
||||
|
||||
Public.reset = IC.reset
|
||||
@ -101,6 +102,10 @@ local function on_tick()
|
||||
|
||||
if tick % 20 == 1 then
|
||||
Functions.item_transfer()
|
||||
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
|
||||
if not has_upgraded_health_pool then
|
||||
Functions.check_entity_healths()
|
||||
end
|
||||
end
|
||||
|
||||
if tick % 240 == 0 then
|
||||
@ -208,6 +213,77 @@ local function on_gui_switch_state_changed(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
|
||||
if not has_upgraded_health_pool then
|
||||
return
|
||||
end
|
||||
|
||||
local entity = event.entity
|
||||
|
||||
if not (entity and entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
if not entity.unit_number then
|
||||
return
|
||||
end
|
||||
|
||||
local cars = IC.get('cars')
|
||||
local car = cars[entity.unit_number]
|
||||
if not car then
|
||||
return
|
||||
end
|
||||
|
||||
local final_damage_amount = event.final_damage_amount
|
||||
local force = event.force
|
||||
|
||||
if force.index == 1 then
|
||||
return
|
||||
end
|
||||
|
||||
local data = {
|
||||
entity = entity,
|
||||
final_damage_amount = final_damage_amount,
|
||||
car = car
|
||||
}
|
||||
|
||||
Functions.set_damage_health(data)
|
||||
end
|
||||
|
||||
local function on_player_repaired_entity(event)
|
||||
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
|
||||
if not has_upgraded_health_pool then
|
||||
return
|
||||
end
|
||||
|
||||
local entity = event.entity
|
||||
|
||||
if not (entity and entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
if not entity.unit_number then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
local cars = IC.get('cars')
|
||||
local car = cars[entity.unit_number]
|
||||
if not car then
|
||||
return
|
||||
end
|
||||
|
||||
local data = {
|
||||
entity = entity,
|
||||
car = car,
|
||||
player = player
|
||||
}
|
||||
|
||||
Functions.set_repair_health(data)
|
||||
end
|
||||
|
||||
local changed_surface = Minimap.changed_surface
|
||||
|
||||
Event.on_init(on_init)
|
||||
@ -225,5 +301,7 @@ Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(defines.events.on_player_changed_surface, changed_surface)
|
||||
Event.add(IC.events.on_player_kicked_from_surface, trigger_on_player_kicked_from_surface)
|
||||
Event.add(defines.events.on_gui_switch_state_changed, on_gui_switch_state_changed)
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
Event.add(defines.events.on_player_repaired_entity, on_player_repaired_entity)
|
||||
|
||||
return Public
|
||||
|
@ -19,11 +19,13 @@ local Token = require 'utils.token'
|
||||
local MapFunctions = require 'tools.map_functions'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local AI = require 'utils.ai'
|
||||
local MysticalChest = require 'maps.mountain_fortress_v3.mystical_chest'
|
||||
|
||||
local format_number = require 'util'.format_number
|
||||
|
||||
local Public = {}
|
||||
local concat = table.concat
|
||||
local insert = table.insert
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local rpg_main_frame = RPG.main_frame_name
|
||||
local random = math.random
|
||||
@ -32,6 +34,7 @@ local round = math.round
|
||||
local rad = math.rad
|
||||
local sin = math.sin
|
||||
local cos = math.cos
|
||||
local abs = math.abs
|
||||
local ceil = math.ceil
|
||||
|
||||
local clear_items_upon_surface_entry = {
|
||||
@ -1263,6 +1266,30 @@ local function gui_click(event)
|
||||
return
|
||||
end
|
||||
|
||||
if name == 'car_health_upgrade_pool' then
|
||||
player.remove_item({name = item.value, count = item.price})
|
||||
local message = ({
|
||||
'locomotive.car_health_upgrade_pool_bought_info',
|
||||
shopkeeper,
|
||||
player.name,
|
||||
format_number(item.price, true)
|
||||
})
|
||||
|
||||
Alert.alert_all_players(5, message)
|
||||
Server.to_discord_bold(
|
||||
table.concat {
|
||||
player.name .. ' has bought the global car health modifier for ' .. format_number(item.price) .. ' coins.'
|
||||
}
|
||||
)
|
||||
this.has_upgraded_health_pool = true
|
||||
this.explosive_bullets = true
|
||||
|
||||
redraw_market_items(data.item_frame, player, data.search_text)
|
||||
redraw_coins_left(data.coins_left, player)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if name == 'flamethrower_turrets' then
|
||||
player.remove_item({name = item.value, count = item.price})
|
||||
if item.stack >= 1 then
|
||||
@ -1529,6 +1556,27 @@ local function create_market(data, rebuild)
|
||||
|
||||
this.market = surface.create_entity {name = 'market', position = center_position, force = 'player'}
|
||||
|
||||
if this.mystical_chest_enabled then
|
||||
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
|
||||
}
|
||||
this.mystical_chest.entity.minable = false
|
||||
this.mystical_chest.entity.destructible = false
|
||||
if not this.mystical_chest.price then
|
||||
Public.add_mystical_chest()
|
||||
end
|
||||
rendering.draw_text {
|
||||
text = 'Mystical chest',
|
||||
surface = surface,
|
||||
target = this.mystical_chest.entity,
|
||||
scale = 1.2,
|
||||
target_offset = {0, 0},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
alignment = 'center'
|
||||
}
|
||||
end
|
||||
|
||||
Generate.wintery(this.market, 5.5)
|
||||
|
||||
rendering.draw_text {
|
||||
@ -1760,6 +1808,34 @@ local function divide_contents()
|
||||
::final::
|
||||
end
|
||||
|
||||
local function mystical_chest_reward()
|
||||
-- something fancy to reward players
|
||||
end
|
||||
|
||||
local function init_price_check(locomotive, mystical_chest)
|
||||
local roll = 48 + abs(locomotive.position.y) * 1.75
|
||||
roll = roll * random(25, 2455) * 0.01
|
||||
|
||||
local item_stacks = {}
|
||||
local roll_count = 2
|
||||
for _ = 1, roll_count, 1 do
|
||||
for _, stack in pairs(MysticalChest.roll(floor(roll / roll_count), 2)) do
|
||||
if not item_stacks[stack.name] then
|
||||
item_stacks[stack.name] = stack.count
|
||||
else
|
||||
item_stacks[stack.name] = item_stacks[stack.name] + stack.count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local price = {}
|
||||
for k, v in pairs(item_stacks) do
|
||||
insert(price, {name = k, count = v})
|
||||
end
|
||||
|
||||
mystical_chest.price = price
|
||||
end
|
||||
|
||||
local function place_market()
|
||||
local locomotive = WPT.get('locomotive')
|
||||
if not locomotive then
|
||||
@ -1952,6 +2028,47 @@ local function on_player_driving_changed_state(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function container_opened(event)
|
||||
local entity = event.entity
|
||||
if not entity then
|
||||
return
|
||||
end
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if not entity.unit_number then
|
||||
return
|
||||
end
|
||||
|
||||
local mystical_chest = WPT.get('mystical_chest')
|
||||
if not mystical_chest then
|
||||
return
|
||||
end
|
||||
if not (mystical_chest.entity and mystical_chest.entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
if entity.unit_number ~= mystical_chest.entity.unit_number then
|
||||
return
|
||||
end
|
||||
|
||||
local has_succeeded = Public.add_mystical_chest()
|
||||
if has_succeeded then
|
||||
local player = game.players[event.player_index]
|
||||
local colored_player_name =
|
||||
table.concat({'[color=', player.color.r * 0.6 + 0.35, ',', player.color.g * 0.6 + 0.35, ',', player.color.b * 0.6 + 0.35, ']', player.name, '[/color]'})
|
||||
game.print(colored_player_name .. ' unlocked the last missing piece for the mystical chest!')
|
||||
end
|
||||
end
|
||||
|
||||
local function on_gui_opened(event)
|
||||
container_opened(event)
|
||||
end
|
||||
|
||||
local function on_gui_closed(event)
|
||||
container_opened(event)
|
||||
end
|
||||
|
||||
function Public.close_gui_player(frame)
|
||||
if not frame then
|
||||
return
|
||||
@ -2179,6 +2296,7 @@ function Public.get_items()
|
||||
local landmine = WPT.get('upgrades').landmine.bought
|
||||
local fixed_prices = WPT.get('marked_fixed_prices')
|
||||
local health_upgrades_limit = WPT.get('health_upgrades_limit')
|
||||
local has_upgraded_health_pool = WPT.get('has_upgraded_health_pool')
|
||||
|
||||
local chest_limit_cost = round(fixed_prices.chest_limit_cost * (1 + chest_limit_outside_upgrades))
|
||||
local health_cost = round(fixed_prices.health_cost * (1 + health_upgrades))
|
||||
@ -2188,6 +2306,7 @@ function Public.get_items()
|
||||
local explosive_bullets_cost = round(fixed_prices.explosive_bullets_cost)
|
||||
local flamethrower_turrets_cost = round(fixed_prices.flamethrower_turrets_cost * (1 + flame_turret))
|
||||
local land_mine_cost = round(fixed_prices.land_mine_cost * (1 + landmine))
|
||||
local car_health_upgrade_pool = fixed_prices.car_health_upgrade_pool_cost
|
||||
|
||||
local pickaxe_tiers = WPT.pickaxe_upgrades
|
||||
local tier = WPT.get('pickaxe_tier')
|
||||
@ -2275,6 +2394,30 @@ function Public.get_items()
|
||||
upgrade = true,
|
||||
static = true
|
||||
}
|
||||
|
||||
if has_upgraded_health_pool then
|
||||
main_market_items['car_health_upgrade_pool'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = car_health_upgrade_pool,
|
||||
tooltip = ({'main_market.sold_out'}),
|
||||
sprite = 'achievement/iron-throne-1',
|
||||
enabled = false,
|
||||
upgrade = true,
|
||||
static = true
|
||||
}
|
||||
else
|
||||
main_market_items['car_health_upgrade_pool'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = car_health_upgrade_pool,
|
||||
tooltip = ({'main_market.global_car_health_modifier'}),
|
||||
sprite = 'achievement/iron-throne-1',
|
||||
enabled = true,
|
||||
upgrade = true,
|
||||
static = true
|
||||
}
|
||||
end
|
||||
main_market_items['xp_points_boost'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
@ -2609,6 +2752,51 @@ function Public.enable_robotic_defense(pos)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.add_mystical_chest()
|
||||
local locomotive = WPT.get('locomotive')
|
||||
if not locomotive then
|
||||
return
|
||||
end
|
||||
if not locomotive.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local mystical_chest = WPT.get('mystical_chest')
|
||||
if not (mystical_chest.entity and mystical_chest.entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
if not mystical_chest.price then
|
||||
init_price_check(locomotive, mystical_chest)
|
||||
end
|
||||
|
||||
local entity = mystical_chest.entity
|
||||
|
||||
local inventory = mystical_chest.entity.get_inventory(defines.inventory.chest)
|
||||
|
||||
for key, item_stack in pairs(mystical_chest.price) do
|
||||
local count_removed = inventory.remove(item_stack)
|
||||
mystical_chest.price[key].count = mystical_chest.price[key].count - count_removed
|
||||
if mystical_chest.price[key].count <= 0 then
|
||||
table.remove(mystical_chest.price, key)
|
||||
end
|
||||
end
|
||||
|
||||
if #mystical_chest.price == 0 then
|
||||
init_price_check(locomotive, mystical_chest)
|
||||
mystical_chest_reward()
|
||||
return true
|
||||
end
|
||||
|
||||
for slot = 1, 30, 1 do
|
||||
entity.clear_request_slot(slot)
|
||||
end
|
||||
|
||||
for slot, item_stack in pairs(mystical_chest.price) do
|
||||
mystical_chest.entity.set_request_slot(item_stack, slot)
|
||||
end
|
||||
end
|
||||
|
||||
local boost_players = Public.boost_players_around_train
|
||||
local pollute_area = Public.transfer_pollution
|
||||
|
||||
@ -2639,6 +2827,7 @@ local function tick()
|
||||
end
|
||||
|
||||
Public.place_market = place_market
|
||||
Public.init_price_check = init_price_check
|
||||
|
||||
Event.on_nth_tick(5, tick)
|
||||
Event.add(defines.events.on_gui_click, gui_click)
|
||||
@ -2657,5 +2846,7 @@ Event.add(defines.events.on_console_chat, on_console_chat)
|
||||
Event.add(defines.events.on_player_changed_surface, on_player_changed_surface)
|
||||
Event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
||||
Event.add(defines.events.on_train_created, set_carriages)
|
||||
Event.add(defines.events.on_gui_opened, on_gui_opened)
|
||||
Event.add(defines.events.on_gui_closed, on_gui_closed)
|
||||
|
||||
return Public
|
||||
|
@ -123,6 +123,8 @@ function Public.reset_map()
|
||||
local Diff = Difficulty.get()
|
||||
local this = WPT.get()
|
||||
local wave_defense_table = WD.get_table()
|
||||
Misc.set('creative_are_you_sure', false)
|
||||
Misc.set('creative_enabled', false)
|
||||
|
||||
Reset.enable_mapkeeper(true)
|
||||
|
||||
|
294
maps/mountain_fortress_v3/mystical_chest.lua
Normal file
294
maps/mountain_fortress_v3/mystical_chest.lua
Normal file
@ -0,0 +1,294 @@
|
||||
local Public = {}
|
||||
|
||||
local shuffle = table.shuffle_table
|
||||
local insert = table.insert
|
||||
local random = math.random
|
||||
local floor = math.floor
|
||||
|
||||
local item_worths = {
|
||||
['wooden-chest'] = 4,
|
||||
['iron-chest'] = 8,
|
||||
['steel-chest'] = 64,
|
||||
['storage-tank'] = 64,
|
||||
['transport-belt'] = 4,
|
||||
['fast-transport-belt'] = 16,
|
||||
['express-transport-belt'] = 64,
|
||||
['underground-belt'] = 16,
|
||||
['fast-underground-belt'] = 64,
|
||||
['express-underground-belt'] = 256,
|
||||
['splitter'] = 16,
|
||||
['fast-splitter'] = 64,
|
||||
['express-splitter'] = 256,
|
||||
['burner-inserter'] = 2,
|
||||
['inserter'] = 8,
|
||||
['long-handed-inserter'] = 16,
|
||||
['fast-inserter'] = 32,
|
||||
['filter-inserter'] = 40,
|
||||
['stack-inserter'] = 128,
|
||||
['stack-filter-inserter'] = 160,
|
||||
['small-electric-pole'] = 4,
|
||||
['medium-electric-pole'] = 32,
|
||||
['big-electric-pole'] = 64,
|
||||
['substation'] = 256,
|
||||
['pipe'] = 1,
|
||||
['pipe-to-ground'] = 15,
|
||||
['pump'] = 32,
|
||||
['rail'] = 8,
|
||||
['train-stop'] = 64,
|
||||
['rail-signal'] = 16,
|
||||
['rail-chain-signal'] = 16,
|
||||
['locomotive'] = 512,
|
||||
['cargo-wagon'] = 256,
|
||||
['fluid-wagon'] = 256,
|
||||
['artillery-wagon'] = 16384,
|
||||
['car'] = 128,
|
||||
['tank'] = 4096,
|
||||
['logistic-robot'] = 256,
|
||||
['construction-robot'] = 256,
|
||||
['logistic-chest-active-provider'] = 256,
|
||||
['logistic-chest-passive-provider'] = 256,
|
||||
['logistic-chest-storage'] = 256,
|
||||
['logistic-chest-buffer'] = 512,
|
||||
['logistic-chest-requester'] = 512,
|
||||
['roboport'] = 2048,
|
||||
['small-lamp'] = 16,
|
||||
['red-wire'] = 4,
|
||||
['green-wire'] = 4,
|
||||
['arithmetic-combinator'] = 16,
|
||||
['decider-combinator'] = 16,
|
||||
['constant-combinator'] = 16,
|
||||
['power-switch'] = 16,
|
||||
['programmable-speaker'] = 32,
|
||||
['stone-brick'] = 2,
|
||||
['concrete'] = 4,
|
||||
['hazard-concrete'] = 4,
|
||||
['refined-concrete'] = 16,
|
||||
['refined-hazard-concrete'] = 16,
|
||||
['cliff-explosives'] = 256,
|
||||
['repair-pack'] = 8,
|
||||
['boiler'] = 8,
|
||||
['steam-engine'] = 32,
|
||||
['solar-panel'] = 64,
|
||||
['accumulator'] = 64,
|
||||
['nuclear-reactor'] = 8192,
|
||||
['heat-pipe'] = 128,
|
||||
['heat-exchanger'] = 256,
|
||||
['steam-turbine'] = 256,
|
||||
['burner-mining-drill'] = 8,
|
||||
['electric-mining-drill'] = 32,
|
||||
['offshore-pump'] = 16,
|
||||
['pumpjack'] = 64,
|
||||
['stone-furnace'] = 4,
|
||||
['steel-furnace'] = 64,
|
||||
['electric-furnace'] = 256,
|
||||
['assembling-machine-1'] = 32,
|
||||
['assembling-machine-2'] = 128,
|
||||
['assembling-machine-3'] = 512,
|
||||
['oil-refinery'] = 256,
|
||||
['chemical-plant'] = 128,
|
||||
['centrifuge'] = 2048,
|
||||
['lab'] = 64,
|
||||
['beacon'] = 512,
|
||||
['speed-module'] = 128,
|
||||
['speed-module-2'] = 512,
|
||||
['speed-module-3'] = 2048,
|
||||
['effectivity-module'] = 128,
|
||||
['effectivity-module-2'] = 512,
|
||||
['effectivity-module-3'] = 2048,
|
||||
['productivity-module'] = 128,
|
||||
['productivity-module-2'] = 512,
|
||||
['productivity-module-3'] = 2048,
|
||||
['iron-plate'] = 1,
|
||||
['copper-plate'] = 1,
|
||||
['solid-fuel'] = 16,
|
||||
['steel-plate'] = 8,
|
||||
['plastic-bar'] = 8,
|
||||
['sulfur'] = 4,
|
||||
['battery'] = 16,
|
||||
['explosives'] = 4,
|
||||
['crude-oil-barrel'] = 8,
|
||||
['heavy-oil-barrel'] = 16,
|
||||
['light-oil-barrel'] = 16,
|
||||
['lubricant-barrel'] = 16,
|
||||
['petroleum-gas-barrel'] = 16,
|
||||
['sulfuric-acid-barrel'] = 16,
|
||||
['water-barrel'] = 4,
|
||||
['copper-cable'] = 1,
|
||||
['iron-stick'] = 1,
|
||||
['iron-gear-wheel'] = 2,
|
||||
['empty-barrel'] = 4,
|
||||
['electronic-circuit'] = 4,
|
||||
['advanced-circuit'] = 16,
|
||||
['processing-unit'] = 128,
|
||||
['engine-unit'] = 8,
|
||||
['electric-engine-unit'] = 64,
|
||||
['flying-robot-frame'] = 128,
|
||||
['satellite'] = 32768,
|
||||
['rocket-control-unit'] = 256,
|
||||
['low-density-structure'] = 64,
|
||||
['rocket-fuel'] = 256,
|
||||
['nuclear-fuel'] = 1024,
|
||||
['uranium-235'] = 1024,
|
||||
['uranium-238'] = 32,
|
||||
['uranium-fuel-cell'] = 128,
|
||||
['automation-science-pack'] = 4,
|
||||
['logistic-science-pack'] = 16,
|
||||
['military-science-pack'] = 64,
|
||||
['chemical-science-pack'] = 128,
|
||||
['production-science-pack'] = 256,
|
||||
['utility-science-pack'] = 256,
|
||||
['space-science-pack'] = 512,
|
||||
['pistol'] = 4,
|
||||
['submachine-gun'] = 32,
|
||||
['shotgun'] = 16,
|
||||
['combat-shotgun'] = 256,
|
||||
['rocket-launcher'] = 128,
|
||||
['flamethrower'] = 512,
|
||||
['land-mine'] = 8,
|
||||
['firearm-magazine'] = 4,
|
||||
['piercing-rounds-magazine'] = 8,
|
||||
['uranium-rounds-magazine'] = 64,
|
||||
['shotgun-shell'] = 4,
|
||||
['piercing-shotgun-shell'] = 16,
|
||||
['cannon-shell'] = 8,
|
||||
['explosive-cannon-shell'] = 16,
|
||||
['uranium-cannon-shell'] = 64,
|
||||
['explosive-uranium-cannon-shell'] = 64,
|
||||
['artillery-shell'] = 128,
|
||||
['rocket'] = 8,
|
||||
['explosive-rocket'] = 8,
|
||||
['atomic-bomb'] = 16384,
|
||||
['flamethrower-ammo'] = 32,
|
||||
['grenade'] = 16,
|
||||
['cluster-grenade'] = 64,
|
||||
['poison-capsule'] = 64,
|
||||
['slowdown-capsule'] = 16,
|
||||
['defender-capsule'] = 16,
|
||||
['distractor-capsule'] = 128,
|
||||
['destroyer-capsule'] = 256,
|
||||
['light-armor'] = 32,
|
||||
['heavy-armor'] = 256,
|
||||
['modular-armor'] = 1024,
|
||||
['power-armor'] = 4096,
|
||||
['power-armor-mk2'] = 32768,
|
||||
['solar-panel-equipment'] = 256,
|
||||
['fusion-reactor-equipment'] = 8192,
|
||||
['energy-shield-equipment'] = 512,
|
||||
['energy-shield-mk2-equipment'] = 4096,
|
||||
['battery-equipment'] = 128,
|
||||
['battery-mk2-equipment'] = 2048,
|
||||
['personal-laser-defense-equipment'] = 2048,
|
||||
['discharge-defense-equipment'] = 2048,
|
||||
['discharge-defense-remote'] = 32,
|
||||
['belt-immunity-equipment'] = 256,
|
||||
['exoskeleton-equipment'] = 1024,
|
||||
['personal-roboport-equipment'] = 512,
|
||||
['personal-roboport-mk2-equipment'] = 4096,
|
||||
['night-vision-equipment'] = 256,
|
||||
['stone-wall'] = 8,
|
||||
['gate'] = 16,
|
||||
['gun-turret'] = 64,
|
||||
['laser-turret'] = 1024,
|
||||
['flamethrower-turret'] = 2048,
|
||||
['artillery-turret'] = 8192,
|
||||
['radar'] = 32,
|
||||
['rocket-silo'] = 65536
|
||||
}
|
||||
|
||||
local item_names = {}
|
||||
for k, _ in pairs(item_worths) do
|
||||
insert(item_names, k)
|
||||
end
|
||||
local size_of_item_names = #item_names
|
||||
|
||||
local function get_raffle_keys()
|
||||
local raffle_keys = {}
|
||||
for i = 1, size_of_item_names, 1 do
|
||||
raffle_keys[i] = i
|
||||
end
|
||||
shuffle(raffle_keys)
|
||||
return raffle_keys
|
||||
end
|
||||
|
||||
function Public.roll_item_stack(remaining_budget, blacklist)
|
||||
if remaining_budget <= 0 then
|
||||
return
|
||||
end
|
||||
local raffle_keys = get_raffle_keys()
|
||||
local item_name = false
|
||||
local item_worth = 0
|
||||
for _, index in pairs(raffle_keys) do
|
||||
item_name = item_names[index]
|
||||
item_worth = item_worths[item_name]
|
||||
if not blacklist[item_name] and item_worth <= remaining_budget then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local stack_size = game.item_prototypes[item_name].stack_size * 32
|
||||
|
||||
local item_count = 1
|
||||
|
||||
for c = 1, random(1, stack_size), 1 do
|
||||
local price = c * item_worth
|
||||
if price <= remaining_budget then
|
||||
item_count = c
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return {name = item_name, count = item_count}
|
||||
end
|
||||
|
||||
local function roll_item_stacks(remaining_budget, max_slots, blacklist)
|
||||
local item_stack_set = {}
|
||||
local item_stack_set_worth = 0
|
||||
|
||||
for i = 1, max_slots, 1 do
|
||||
if remaining_budget <= 0 then
|
||||
break
|
||||
end
|
||||
local item_stack = Public.roll_item_stack(remaining_budget, blacklist)
|
||||
item_stack_set[i] = item_stack
|
||||
remaining_budget = remaining_budget - item_stack.count * item_worths[item_stack.name]
|
||||
item_stack_set_worth = item_stack_set_worth + item_stack.count * item_worths[item_stack.name]
|
||||
end
|
||||
|
||||
return item_stack_set, item_stack_set_worth
|
||||
end
|
||||
|
||||
function Public.roll(budget, max_slots, blacklist)
|
||||
if not budget then
|
||||
return
|
||||
end
|
||||
if not max_slots then
|
||||
return
|
||||
end
|
||||
|
||||
local b
|
||||
if not blacklist then
|
||||
b = {}
|
||||
else
|
||||
b = blacklist
|
||||
end
|
||||
|
||||
budget = floor(budget)
|
||||
if budget == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local final_stack_set
|
||||
local final_stack_set_worth = 0
|
||||
|
||||
for _ = 1, 5, 1 do
|
||||
local item_stack_set, item_stack_set_worth = roll_item_stacks(budget, max_slots, b)
|
||||
if item_stack_set_worth > final_stack_set_worth or item_stack_set_worth == budget then
|
||||
final_stack_set = item_stack_set
|
||||
final_stack_set_worth = item_stack_set_worth
|
||||
end
|
||||
end
|
||||
return final_stack_set
|
||||
end
|
||||
|
||||
return Public
|
@ -174,7 +174,8 @@ function Public.reset_table()
|
||||
xp_point_boost_cost = 5000,
|
||||
explosive_bullets_cost = 10000,
|
||||
flamethrower_turrets_cost = 3000,
|
||||
land_mine_cost = 2
|
||||
land_mine_cost = 2,
|
||||
car_health_upgrade_pool_cost = 100000
|
||||
}
|
||||
this.collapse_grace = true
|
||||
this.explosive_bullets = false
|
||||
@ -209,6 +210,10 @@ function Public.reset_table()
|
||||
this.market_announce = game.tick + 1200
|
||||
this.check_heavy_damage = true
|
||||
this.prestige_system_enabled = false
|
||||
this.has_upgraded_health_pool = false
|
||||
this.mystical_chest_enabled = false -- needs rewards before enabling
|
||||
this.alert_zone_1 = false -- alert the players
|
||||
|
||||
for k, _ in pairs(this.players) do
|
||||
this.players[k] = {}
|
||||
end
|
||||
|
@ -238,6 +238,7 @@ local function wall(p, data)
|
||||
local treasure = data.treasure
|
||||
local stone_wall = {callback = Functions.disable_minable_callback}
|
||||
local enable_arties = WPT.get('enable_arties')
|
||||
local alert_zone_1 = WPT.get('alert_zone_1')
|
||||
|
||||
local seed = data.seed
|
||||
local y = data.yv
|
||||
@ -303,6 +304,23 @@ local function wall(p, data)
|
||||
force = 'player',
|
||||
callback = stone_wall
|
||||
}
|
||||
if not alert_zone_1 then
|
||||
local x_min = -WPT.level_width / 2
|
||||
local x_max = WPT.level_width / 2
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}})
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}})
|
||||
WPT.set('alert_zone_1', true)
|
||||
rendering.draw_text {
|
||||
text = 'Breaching this wall will start collapse.',
|
||||
surface = surface,
|
||||
target = {0, p.y - 10},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 8,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
end
|
||||
else
|
||||
if random(1, 32 - y) == 1 then
|
||||
|
@ -24,6 +24,13 @@ local function remove_unit(entity)
|
||||
local active_biter_count = WD.get('active_biter_count')
|
||||
WD.set('active_biter_count', active_biter_count - 1)
|
||||
active_biters[unit_number] = nil
|
||||
|
||||
if active_biter_count <= 0 then
|
||||
WD.set('active_biter_count', 0)
|
||||
end
|
||||
if active_biter_threat <= 0 then
|
||||
WD.set('active_biter_threat', 0)
|
||||
end
|
||||
end
|
||||
|
||||
local function place_nest_near_unit_group()
|
||||
@ -243,7 +250,8 @@ local function on_entity_died(event)
|
||||
local threat = WD.get('threat')
|
||||
if threat <= 0 then
|
||||
WD.set('threat', 0)
|
||||
threat = WD.get('threat')
|
||||
remove_unit(entity)
|
||||
return
|
||||
end
|
||||
WD.set('threat', math.round(threat - threat_values[entity.name] * biter_health_boost, 2))
|
||||
remove_unit(entity)
|
||||
|
Loading…
Reference in New Issue
Block a user