mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
smol changes to scrapyard
This commit is contained in:
parent
f8e8f27ef3
commit
853fa01a00
@ -5,7 +5,7 @@ function Public.init_enemy_weapon_damage()
|
||||
local data = {
|
||||
['artillery-shell'] = 0,
|
||||
['biological'] = 0.1,
|
||||
['bullet'] = 4,
|
||||
['bullet'] = 2.5,
|
||||
['cannon-shell'] = 0,
|
||||
['capsule'] = 0,
|
||||
['combat-robot-beam'] = 0,
|
||||
@ -56,10 +56,7 @@ local function enemy_weapon_damage()
|
||||
|
||||
for k, v in pairs(data) do
|
||||
local new = global.difficulty_vote_value * v
|
||||
if new > global.difficulty_vote_value then
|
||||
new = global.difficulty_vote_value / 2
|
||||
print('Ammo modifier is now: ' .. new)
|
||||
end
|
||||
|
||||
e.set_ammo_damage_modifier(k, new)
|
||||
s.set_ammo_damage_modifier(k, new)
|
||||
sd.set_ammo_damage_modifier(k, new)
|
||||
@ -68,6 +65,6 @@ local function enemy_weapon_damage()
|
||||
::rtn::
|
||||
end
|
||||
|
||||
Event.on_nth_tick(30, enemy_weapon_damage)
|
||||
Event.on_nth_tick(18000, enemy_weapon_damage)
|
||||
|
||||
return Public
|
||||
|
@ -1,4 +1,4 @@
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
local Event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
@ -101,7 +101,7 @@ local texts = {
|
||||
}
|
||||
|
||||
local function set_comfy_speech_bubble(text)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if this.comfybubble then
|
||||
this.comfybubble.destroy()
|
||||
end
|
||||
@ -117,7 +117,7 @@ local function set_comfy_speech_bubble(text)
|
||||
end
|
||||
|
||||
local function is_target_inside_habitat(pos, surface)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if pos.x < this.grandmaster_habitat.left_top.x then
|
||||
return false
|
||||
end
|
||||
@ -134,7 +134,7 @@ local function is_target_inside_habitat(pos, surface)
|
||||
end
|
||||
|
||||
local function get_nearby_players()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local players =
|
||||
this.grandmaster.surface.find_entities_filtered(
|
||||
{
|
||||
@ -152,7 +152,7 @@ local function get_nearby_players()
|
||||
end
|
||||
|
||||
local function visit_player()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if this.grandmaster_last_player_visit > game.tick then
|
||||
return false
|
||||
@ -200,7 +200,7 @@ local function visit_player()
|
||||
end
|
||||
|
||||
local function greet_player(nearby_characters)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not nearby_characters then
|
||||
return false
|
||||
end
|
||||
@ -222,7 +222,7 @@ local function greet_player(nearby_characters)
|
||||
end
|
||||
|
||||
local function talks(nearby_characters)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not nearby_characters then
|
||||
return false
|
||||
end
|
||||
@ -251,7 +251,7 @@ local function talks(nearby_characters)
|
||||
end
|
||||
|
||||
local function desync(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if this.comfybubble then
|
||||
this.comfybubble.destroy()
|
||||
end
|
||||
@ -314,7 +314,7 @@ local analyze_blacklist = {
|
||||
}
|
||||
|
||||
local function analyze_random_nearby_entity()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if math_random(1, 3) ~= 1 then
|
||||
return false
|
||||
end
|
||||
@ -377,7 +377,7 @@ local function analyze_random_nearby_entity()
|
||||
end
|
||||
|
||||
local function go_to_some_location()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if math_random(1, 4) ~= 1 then
|
||||
return false
|
||||
end
|
||||
@ -448,7 +448,7 @@ local function go_to_some_location()
|
||||
end
|
||||
|
||||
local function spawn_grandmaster(surface)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if surface == nil then
|
||||
return
|
||||
end
|
||||
@ -510,7 +510,7 @@ local function spawn_grandmaster(surface)
|
||||
end
|
||||
|
||||
local function heartbeat()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not this.locomotive.valid then
|
||||
return
|
||||
end
|
||||
@ -550,7 +550,7 @@ local function heartbeat()
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not this.grandmaster then
|
||||
return
|
||||
end
|
||||
@ -564,7 +564,7 @@ local function on_entity_damaged(event)
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not this.grandmaster then
|
||||
return
|
||||
end
|
||||
|
@ -1,12 +1,12 @@
|
||||
local Color = require 'utils.color_presets'
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
|
||||
commands.add_command(
|
||||
'rainbow_mode',
|
||||
'This will prevent new tiles from spawning when walking',
|
||||
function()
|
||||
local player = game.player
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if player and player.valid then
|
||||
if this.players[player.index].tiles_enabled == false then
|
||||
this.players[player.index].tiles_enabled = true
|
||||
|
@ -11,7 +11,7 @@ local RPG = require 'maps.scrapyard.rpg'
|
||||
local Scrap = require 'maps.scrapyard.mining_scrap'
|
||||
|
||||
-- tables
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
|
||||
-- module
|
||||
@ -46,7 +46,7 @@ local function shuffle(tbl)
|
||||
end
|
||||
|
||||
local function set_objective_health(entity, final_damage_amount)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if final_damage_amount == 0 then
|
||||
return
|
||||
end
|
||||
@ -73,7 +73,7 @@ local function set_objective_health(entity, final_damage_amount)
|
||||
end
|
||||
|
||||
local function is_protected(entity)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if string.sub(entity.surface.name, 0, 9) ~= 'scrapyard' then
|
||||
return true
|
||||
end
|
||||
@ -87,7 +87,7 @@ local function is_protected(entity)
|
||||
end
|
||||
|
||||
local function protect_train(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if event.entity.force.index ~= 1 then
|
||||
return
|
||||
end --Player Force
|
||||
@ -188,7 +188,7 @@ local function give_coin(player)
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
|
||||
Scrap.on_player_mined_entity(event)
|
||||
|
||||
@ -270,7 +270,7 @@ local function on_entity_damaged(event)
|
||||
end
|
||||
|
||||
local function on_player_repaired_entity(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not event.entity then
|
||||
return
|
||||
end
|
||||
@ -287,7 +287,7 @@ local function on_player_repaired_entity(event)
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
@ -400,7 +400,7 @@ local function on_built_entity(event)
|
||||
end
|
||||
|
||||
function Public.set_scores()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local wagon = this.locomotive_cargo
|
||||
if not wagon then
|
||||
return
|
||||
@ -417,7 +417,7 @@ function Public.set_scores()
|
||||
end
|
||||
|
||||
function Public.loco_died()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
local wave_defense_table = WD.get_table()
|
||||
Public.set_scores()
|
||||
|
@ -1,5 +1,5 @@
|
||||
local RPG = require 'maps.scrapyard.rpg'
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
local floor = math.floor
|
||||
local format_number = require 'util'.format_number
|
||||
|
||||
@ -55,7 +55,7 @@ end
|
||||
|
||||
local function update_gui(player)
|
||||
local rpg = RPG.get_table()
|
||||
local st = Scrap_table.get_table()
|
||||
local st = WPT.get_table()
|
||||
|
||||
if not player.gui.top.scrapyard then
|
||||
create_gui(player)
|
||||
|
@ -1,11 +1,13 @@
|
||||
local Event = require 'utils.event'
|
||||
local Power = require 'maps.scrapyard.power'
|
||||
local ICW = require 'maps.scrapyard.icw.main'
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
local RPG = require 'maps.scrapyard.rpg'
|
||||
local Terrain = require 'maps.scrapyard.terrain'
|
||||
require 'maps.scrapyard.locomotive_market'
|
||||
|
||||
local random = math.random
|
||||
|
||||
local Public = {}
|
||||
|
||||
local energy_upgrade = 50000000
|
||||
@ -59,7 +61,10 @@ local function rebuild_energy_overworld(data)
|
||||
}
|
||||
|
||||
this.ow_energy.destructible = false
|
||||
this.ow_energy.power_production = 5
|
||||
this.ow_energy.minable = false
|
||||
this.ow_energy.operable = false
|
||||
|
||||
this.ow_energy.power_production = 0
|
||||
if this.energy_purchased then
|
||||
this.ow_energy.electric_buffer_size = energy_upgrade
|
||||
else
|
||||
@ -90,7 +95,7 @@ local function rebuild_energy_loco(data, rebuild)
|
||||
name = 'electric-energy-interface',
|
||||
position = pos,
|
||||
create_build_effect_smoke = false,
|
||||
force = game.forces.neutral
|
||||
force = game.forces.enemy
|
||||
}
|
||||
|
||||
rendering.draw_text {
|
||||
@ -151,7 +156,7 @@ local function property_boost(data)
|
||||
end
|
||||
|
||||
local function train_rainbow()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not this.locomotive then
|
||||
return
|
||||
end
|
||||
@ -181,7 +186,7 @@ local function train_rainbow()
|
||||
end
|
||||
|
||||
local function reveal_train_area()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not this.locomotive then
|
||||
return
|
||||
end
|
||||
@ -220,7 +225,7 @@ local function reveal_train_area()
|
||||
end
|
||||
|
||||
local function fish_tag()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not this.locomotive_cargo then
|
||||
return
|
||||
end
|
||||
@ -256,7 +261,7 @@ local function fish_tag()
|
||||
end
|
||||
|
||||
local function set_player_spawn_and_refill_fish()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not this.locomotive_cargo then
|
||||
return
|
||||
end
|
||||
@ -280,7 +285,7 @@ local function set_player_spawn_and_refill_fish()
|
||||
end
|
||||
|
||||
local function tick()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if this.energy_shared then
|
||||
Public.power_source_overworld()
|
||||
Public.power_source_locomotive()
|
||||
@ -307,7 +312,7 @@ end
|
||||
|
||||
function Public.boost_players_around_train()
|
||||
local rpg = RPG.get_table()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if not this.locomotive then
|
||||
return
|
||||
@ -325,7 +330,7 @@ function Public.boost_players_around_train()
|
||||
end
|
||||
|
||||
function Public.render_train_hp()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
|
||||
this.health_text =
|
||||
@ -366,7 +371,7 @@ function Public.render_train_hp()
|
||||
end
|
||||
|
||||
function Public.locomotive_spawn(surface, position)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
for y = -6, 6, 2 do
|
||||
surface.create_entity(
|
||||
{name = 'straight-rail', position = {position.x, position.y + y}, force = 'player', direction = 0}
|
||||
@ -437,7 +442,7 @@ function Public.contains_positions(pos, area)
|
||||
end
|
||||
|
||||
function Public.power_source_overworld()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if not this.locomotive then
|
||||
return
|
||||
@ -455,7 +460,7 @@ function Public.power_source_overworld()
|
||||
end
|
||||
|
||||
function Public.power_source_locomotive()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local icw_table = ICW.get_table()
|
||||
if not this.locomotive then
|
||||
return
|
||||
|
@ -1,15 +1,16 @@
|
||||
local Event = require 'utils.event'
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local ICW = require 'maps.scrapyard.icw.main'
|
||||
local format_number = require 'util'.format_number
|
||||
|
||||
local grandmaster = '[color=blue]Grandmaster:[/color]'
|
||||
local duration_per_charge = 2700
|
||||
|
||||
local energy_upgrade = 50000000
|
||||
local random = math.random
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function shuffle(tbl)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
@ -19,54 +20,65 @@ local function shuffle(tbl)
|
||||
return tbl
|
||||
end
|
||||
|
||||
local items = {
|
||||
['clear_threat_level'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 50000,
|
||||
tooltip = '[Wave Defense]:\nClears the current threat to 0\nUsable if threat level is too high.\nCan be purchased multiple times.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['energy_upgrade'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 50000,
|
||||
tooltip = '[Linked Power]:\nUpgrades the buffer size of the energy interface\nUsable if the power dies easily.\nCan be purchased multiple times.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['locomotive_max_health'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 50000,
|
||||
tooltip = '[Locomotive Health]:\nUpgrades the train health.\nCan be purchased multiple times.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['locomotive_xp_aura'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 50000,
|
||||
tooltip = '[XP Aura]:\nUpgrades the aura that is around the train.\nNote! Reaching breach walls gives more XP.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['player_terrain_reveal'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 5000,
|
||||
tooltip = '[Terrain Reveal]:\nAllows the player to reveal terrain for a short amount of time.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['small-lamp'] = {stack = 1, value = 'coin', price = 5, tooltip = 'Small Lamp'},
|
||||
['land-mine'] = {stack = 1, value = 'coin', price = 25, tooltip = 'Land Mine'},
|
||||
['raw-fish'] = {stack = 2, value = 'coin', price = 25, tooltip = 'Raw Fish'},
|
||||
['firearm-magazine'] = {stack = 1, value = 'coin', price = 5, tooltip = 'Firearm Magazine'},
|
||||
['loader'] = {stack = 1, value = 'coin', price = 150, tooltip = 'Loader'},
|
||||
['fast-loader'] = {stack = 1, value = 'coin', price = 300, tooltip = 'Fast Loader'}
|
||||
}
|
||||
function Public.get_items()
|
||||
local this = WPT.get_table()
|
||||
|
||||
local threat_cost = 50000 * (1 + this.train_upgrades)
|
||||
local energy_cost = 50000 * (1 + this.train_upgrades)
|
||||
local health_cost = 50000 * (1 + this.train_upgrades)
|
||||
local aura_cost = 50000 * (1 + this.train_upgrades)
|
||||
|
||||
local items = {
|
||||
['clear_threat_level'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = threat_cost,
|
||||
tooltip = '[Wave Defense]:\nClears the current threat to 0\nUsable if threat level is too high.\nCan be purchased multiple times.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['energy_upgrade'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = energy_cost,
|
||||
tooltip = '[Linked Power]:\nUpgrades the buffer size of the energy interface\nUsable if the power dies easily.\nCan be purchased multiple times.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['locomotive_max_health'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = health_cost,
|
||||
tooltip = '[Locomotive Health]:\nUpgrades the train health.\nCan be purchased multiple times.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['locomotive_xp_aura'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = aura_cost,
|
||||
tooltip = '[XP Aura]:\nUpgrades the aura that is around the train.\nNote! Reaching breach walls gives more XP.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['player_terrain_reveal'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 250,
|
||||
tooltip = '[Terrain Reveal]:\nAllows the player to reveal terrain for a short amount of time.',
|
||||
sprite = 'item/computer',
|
||||
enabled = true
|
||||
},
|
||||
['small-lamp'] = {stack = 1, value = 'coin', price = 5, tooltip = 'Small Lamp'},
|
||||
['land-mine'] = {stack = 1, value = 'coin', price = 25, tooltip = 'Land Mine'},
|
||||
['raw-fish'] = {stack = 2, value = 'coin', price = 25, tooltip = 'Raw Fish'},
|
||||
['firearm-magazine'] = {stack = 1, value = 'coin', price = 5, tooltip = 'Firearm Magazine'},
|
||||
['loader'] = {stack = 1, value = 'coin', price = 150, tooltip = 'Loader'},
|
||||
['fast-loader'] = {stack = 1, value = 'coin', price = 300, tooltip = 'Fast Loader'}
|
||||
}
|
||||
|
||||
return items
|
||||
end
|
||||
|
||||
local space = {
|
||||
minimal_height = 10,
|
||||
@ -104,7 +116,7 @@ local function validate_player(player)
|
||||
end
|
||||
|
||||
local function close_market_gui(player)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
|
||||
local element = player.gui.center
|
||||
local data = this.players[player.index].data
|
||||
@ -127,10 +139,10 @@ local function redraw_market_items(gui, player, search_text)
|
||||
if not validate_player(player) then
|
||||
return
|
||||
end
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
|
||||
gui.clear()
|
||||
shuffle(items)
|
||||
shuffle(Public.get_items())
|
||||
|
||||
local inventory = player.get_main_inventory()
|
||||
local player_item_count = inventory.get_item_count('coin')
|
||||
@ -138,7 +150,7 @@ local function redraw_market_items(gui, player, search_text)
|
||||
local items_table = gui.add({type = 'table', column_count = 6})
|
||||
|
||||
local slider_value = math.ceil(this.players[player.index].data.slider.slider_value)
|
||||
for name, opts in pairs(items) do
|
||||
for name, opts in pairs(Public.get_items()) do
|
||||
if not search_text then
|
||||
goto continue
|
||||
end
|
||||
@ -150,6 +162,7 @@ local function redraw_market_items(gui, player, search_text)
|
||||
end
|
||||
local item_count = opts.stack * slider_value
|
||||
local item_cost = opts.price * slider_value
|
||||
|
||||
local flow = items_table.add({type = 'flow'})
|
||||
flow.style.vertical_align = 'bottom'
|
||||
|
||||
@ -168,7 +181,7 @@ local function redraw_market_items(gui, player, search_text)
|
||||
flow.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = format_number(item_cost, true) .. ' coin'
|
||||
caption = format_number(item_cost, true) .. ' coins'
|
||||
}
|
||||
)
|
||||
|
||||
@ -201,7 +214,7 @@ end
|
||||
|
||||
local function slider_changed(event)
|
||||
local player = game.players[event.player_index]
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local slider_value
|
||||
|
||||
slider_value = this.players
|
||||
@ -226,7 +239,7 @@ local function slider_changed(event)
|
||||
end
|
||||
|
||||
local function text_changed(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
local data = this.players[player.index].data
|
||||
@ -244,7 +257,7 @@ local function text_changed(event)
|
||||
end
|
||||
|
||||
local function gui_opened(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
|
||||
if not event.gui_type == defines.gui_type.entity then
|
||||
return
|
||||
@ -366,7 +379,7 @@ local function gui_opened(event)
|
||||
end
|
||||
|
||||
local function gui_click(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local wdt = WD.get_table()
|
||||
|
||||
local element = event.element
|
||||
@ -412,7 +425,7 @@ local function gui_click(event)
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
local item = items[name]
|
||||
local item = Public.get_items()[name]
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
@ -502,16 +515,23 @@ local function gui_click(event)
|
||||
return
|
||||
end
|
||||
if name == 'player_terrain_reveal' then
|
||||
if this.players[player.index].start_tick == nil then
|
||||
this.players[player.index].start_tick = game.tick
|
||||
player.print(
|
||||
grandmaster ..
|
||||
' ' ..
|
||||
player.name .. ' a fine choice! You can now reveal terrain when going through the black mist!',
|
||||
{r = 0.98, g = 0.66, b = 0.22}
|
||||
)
|
||||
else
|
||||
return player.print(
|
||||
grandmaster .. ' ' .. player.name .. ', you already have this feature!',
|
||||
{r = 0.98, g = 0.66, b = 0.22}
|
||||
)
|
||||
end
|
||||
|
||||
player.remove_item({name = item.value, count = cost})
|
||||
|
||||
this.players[player.index].reveal = this.players[player.index].reveal + duration_per_charge
|
||||
|
||||
player.print(
|
||||
grandmaster ..
|
||||
' ' .. player.name .. ' a fine choice! You can now reveal terrain when going through the black mist!',
|
||||
{r = 0.98, g = 0.66, b = 0.22}
|
||||
)
|
||||
|
||||
redraw_market_items(data.item_frame, player, data.search_text)
|
||||
redraw_coins_left(data.coins_left, player)
|
||||
|
||||
@ -536,7 +556,7 @@ end
|
||||
|
||||
local function gui_closed(event)
|
||||
local player = game.players[event.player_index]
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
|
||||
local type = event.gui_type
|
||||
|
||||
@ -564,7 +584,7 @@ local function contains_positions(pos, area)
|
||||
end
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local player = game.players[event.player_index]
|
||||
local data = this.players[player.index].data
|
||||
|
||||
@ -613,7 +633,7 @@ local function create_market(data, rebuild)
|
||||
end
|
||||
|
||||
local function place_market()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local icw_table = ICW.get_table()
|
||||
if not this.locomotive then
|
||||
return
|
||||
@ -635,7 +655,26 @@ local function place_market()
|
||||
end
|
||||
end
|
||||
|
||||
local function reset_player(player, this)
|
||||
this.players[player.index].start_tick = nil
|
||||
player.print(grandmaster .. ' ' .. player.name .. ', time is up!', {r = 0.98, g = 0.66, b = 0.22})
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
local this = WPT.get_table()
|
||||
if game.tick % 900 == 0 then
|
||||
if this.players then
|
||||
for k, v in pairs(this.players) do
|
||||
if not v.start_tick then
|
||||
return
|
||||
end
|
||||
if game.tick - v.start_tick > 6000 then
|
||||
reset_player(game.players[k], this)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
place_market()
|
||||
end
|
||||
|
||||
@ -646,3 +685,5 @@ Event.add(defines.events.on_gui_value_changed, slider_changed)
|
||||
Event.add(defines.events.on_gui_text_changed, text_changed)
|
||||
Event.add(defines.events.on_gui_closed, gui_closed)
|
||||
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
|
||||
return Public
|
||||
|
@ -31,7 +31,7 @@ local RPG = require 'maps.scrapyard.rpg'
|
||||
local Reset = require 'functions.soft_reset'
|
||||
local Terrain = require 'maps.scrapyard.terrain'
|
||||
local Event = require 'utils.event'
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
local Locomotive = require 'maps.scrapyard.locomotive'.locomotive_spawn
|
||||
local render_train_hp = require 'maps.scrapyard.locomotive'.render_train_hp
|
||||
local Score = require 'comfy_panel.score'
|
||||
@ -43,7 +43,7 @@ local Public = {}
|
||||
local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
|
||||
Scrap_table.init({train_reveal = true, energy_shared = true})
|
||||
WPT.init({train_reveal = true, energy_shared = true})
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['wood'] = 4, ['rail'] = 16, ['raw-fish'] = 2}
|
||||
local colors = {
|
||||
@ -67,6 +67,7 @@ local function create_forces_and_disable_tech()
|
||||
game.create_force('scrap_defense')
|
||||
game.forces.player.set_friend('scrap', true)
|
||||
game.forces.enemy.set_friend('scrap', true)
|
||||
game.forces.enemy.set_friend('scrap_defense', true)
|
||||
game.forces.scrap.set_friend('player', true)
|
||||
game.forces.scrap.set_friend('enemy', true)
|
||||
game.forces.scrap.share_chart = false
|
||||
@ -83,11 +84,14 @@ end
|
||||
local function set_difficulty()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local player_count = #game.connected_players
|
||||
if not global.difficulty_vote_value then
|
||||
global.difficulty_vote_value = 0.1
|
||||
end
|
||||
|
||||
wave_defense_table.max_active_biters = 1024
|
||||
wave_defense_table.max_active_biters = 768 + player_count * (90 * global.difficulty_vote_value)
|
||||
|
||||
-- threat gain / wave
|
||||
wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1
|
||||
wave_defense_table.threat_gain_multiplier = 1.2 + player_count * global.difficulty_vote_value * 0.1
|
||||
|
||||
local amount = player_count * 0.25 + 2
|
||||
amount = math.floor(amount)
|
||||
@ -104,13 +108,14 @@ local function set_difficulty()
|
||||
end
|
||||
|
||||
function Public.reset_map()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local get_score = Score.get_table()
|
||||
Poll.reset()
|
||||
ICW.reset()
|
||||
game.reset_time_played()
|
||||
Scrap_table.reset_table()
|
||||
create_forces_and_disable_tech()
|
||||
WPT.reset_table()
|
||||
wave_defense_table.math = 8
|
||||
if not this.train_reveal then
|
||||
this.revealed_spawn = game.tick + 100
|
||||
@ -167,9 +172,9 @@ function Public.reset_map()
|
||||
Collapse.start_now(false)
|
||||
|
||||
surface.ticks_per_day = surface.ticks_per_day * 2
|
||||
surface.daytime = 1
|
||||
surface.daytime = 0.71
|
||||
surface.brightness_visual_weights = {1, 0, 0, 0}
|
||||
surface.freeze_daytime = true
|
||||
surface.freeze_daytime = false
|
||||
surface.solar_power_multiplier = 1
|
||||
this.locomotive_health = 10000
|
||||
this.locomotive_max_health = 10000
|
||||
@ -307,7 +312,7 @@ local function change_tile(surface, pos, steps)
|
||||
end
|
||||
|
||||
local function on_player_changed_position(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local player = game.players[event.player_index]
|
||||
if string.sub(player.surface.name, 0, 9) ~= 'scrapyard' then
|
||||
return
|
||||
@ -338,9 +343,12 @@ local function on_player_changed_position(event)
|
||||
this.players[player.index].steps = this.players[player.index].steps + 1
|
||||
end
|
||||
::continue::
|
||||
if not this.train_reveal or this.players[player.index].reveal - game.tick > 0 then
|
||||
if
|
||||
not this.train_reveal or
|
||||
this.players[player.index].start_tick and game.tick - this.players[player.index].start_tick < 6400
|
||||
then
|
||||
if position.y < 5 then
|
||||
Terrain.reveal(player)
|
||||
Terrain.reveal_player(player)
|
||||
end
|
||||
end
|
||||
if position.y >= 190 then
|
||||
@ -357,7 +365,7 @@ local function on_player_changed_position(event)
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
@ -372,7 +380,6 @@ local function on_player_joined_game(event)
|
||||
tiles_enabled = true,
|
||||
steps = 0,
|
||||
first_join = false,
|
||||
reveal = 0,
|
||||
data = {}
|
||||
}
|
||||
end
|
||||
@ -401,7 +408,7 @@ local function on_player_left_game()
|
||||
end
|
||||
|
||||
local function on_pre_player_left_game(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local player = game.players[event.player_index]
|
||||
if player.controller_type == defines.controllers.editor then
|
||||
player.toggle_map_editor()
|
||||
@ -412,7 +419,7 @@ local function on_pre_player_left_game(event)
|
||||
end
|
||||
|
||||
local function offline_players()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local players = this.offline_players
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if #players > 0 then
|
||||
@ -560,7 +567,7 @@ local tick_minute_functions = {
|
||||
}
|
||||
|
||||
local on_tick = function()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
local wave_defense_table = WD.get_table()
|
||||
local tick = game.tick
|
||||
@ -613,16 +620,17 @@ local on_tick = function()
|
||||
end
|
||||
|
||||
local on_init = function()
|
||||
global.custom_highscore.description = 'Depth reached: '
|
||||
create_forces_and_disable_tech()
|
||||
Public.reset_map()
|
||||
|
||||
global.custom_highscore.description = 'Wagon distance reached:'
|
||||
|
||||
game.forces.scrap.share_chart = false
|
||||
global.rocks_yield_ore_maximum_amount = 500
|
||||
global.rocks_yield_ore_base_amount = 50
|
||||
global.rocks_yield_ore_distance_modifier = 0.025
|
||||
Public.reset_map()
|
||||
|
||||
local T = Map.Pop_info()
|
||||
T.main_caption = 'R a i n b o w S c r a p y a r d'
|
||||
T.main_caption = 'S c r a p y a r d '
|
||||
T.sub_caption = ' ---defend the choo---'
|
||||
T.text =
|
||||
table.concat(
|
||||
|
@ -1,4 +1,4 @@
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
|
||||
local Public = {}
|
||||
|
||||
@ -281,7 +281,7 @@ function Public.on_player_mined_entity(event)
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
local Event = require 'utils.event'
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
|
||||
local function balance(t)
|
||||
local g = 0
|
||||
@ -19,7 +19,7 @@ local function balance(t)
|
||||
end
|
||||
|
||||
local function tick()
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if not this.energy['scrapyard'] then
|
||||
this.energy['scrapyard'] = this.ow_energy
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ local create_entity_chain = require 'functions.create_entity_chain'
|
||||
local create_tile_chain = require 'functions.create_tile_chain'
|
||||
local noise_v1 = require 'utils.simplex_noise'.d2
|
||||
local map_functions = require 'tools.map_functions'
|
||||
local Scrap_table = require 'maps.scrapyard.table'
|
||||
local WPT = require 'maps.scrapyard.table'
|
||||
local shapes = require 'tools.shapes'
|
||||
local Loot = require 'maps.scrapyard.loot'
|
||||
local get_noise = require 'utils.get_noise'
|
||||
@ -100,6 +100,29 @@ local more_colors = {
|
||||
'blue-refined-concrete'
|
||||
}
|
||||
|
||||
local trees_terrain = {
|
||||
['dead-dry-hairy-tree'] = true,
|
||||
['dead-grey-trunk'] = true,
|
||||
['dead-tree-desert'] = true,
|
||||
['dry-hairy-tree'] = true,
|
||||
['dry-tree'] = true,
|
||||
['tree-01'] = true,
|
||||
['tree-02'] = true,
|
||||
['tree-02-red'] = true,
|
||||
['tree-03'] = true,
|
||||
['tree-04'] = true,
|
||||
['tree-05'] = true,
|
||||
['tree-06'] = true,
|
||||
['tree-06-brown'] = true,
|
||||
['tree-07'] = true,
|
||||
['tree-08'] = true,
|
||||
['tree-08-brown'] = true,
|
||||
['tree-08-red'] = true,
|
||||
['tree-09'] = true,
|
||||
['tree-09-brown'] = true,
|
||||
['tree-09-red'] = true
|
||||
}
|
||||
|
||||
local function place_wagon(data)
|
||||
local surface = data.surface
|
||||
local left_top = data.left_top
|
||||
@ -1242,8 +1265,54 @@ function Public.reveal_train(data)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.reveal(player)
|
||||
local this = Scrap_table.get_table()
|
||||
function Public.reveal_normally(data)
|
||||
local left_top = data.left_top
|
||||
local surface = data.surface
|
||||
data.tiles = {}
|
||||
data.entities = {}
|
||||
data.markets = {}
|
||||
data.treasure = {}
|
||||
local level_index = math_floor((math_abs(left_top.y / Public.level_depth)) % 9) + 1
|
||||
local process_level = Public.levels[level_index]
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
data.p = pos
|
||||
process_level(data)
|
||||
end
|
||||
end
|
||||
if #data.tiles > 0 then
|
||||
surface.set_tiles(data.tiles, true)
|
||||
end
|
||||
for _, entity in pairs(data.entities) do
|
||||
if surface.can_place_entity(entity) and entity == 'biter-spawner' or entity == 'spitter-spawner' then
|
||||
surface.create_entity(entity)
|
||||
else
|
||||
surface.create_entity(entity)
|
||||
end
|
||||
end
|
||||
if #data.markets > 0 then
|
||||
local pos = data.markets[math_random(1, #data.markets)]
|
||||
if
|
||||
surface.count_entities_filtered {
|
||||
area = {{pos.x - 96, pos.y - 96}, {pos.x + 96, pos.y + 96}},
|
||||
name = 'market',
|
||||
limit = 1
|
||||
} == 0
|
||||
then
|
||||
local market = Market.mountain_market(surface, pos, math_abs(pos.y) * 0.004)
|
||||
market.destructible = false
|
||||
end
|
||||
end
|
||||
for _, p in pairs(data.treasure) do
|
||||
local name = 'steel-chest'
|
||||
Loot.add(surface, p, name)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.reveal_player(player)
|
||||
local this = WPT.get_table()
|
||||
local seed = game.surfaces[this.active_surface_index].map_gen_settings.seed
|
||||
local position = player.position
|
||||
local surface = player.surface
|
||||
@ -1300,48 +1369,6 @@ function Public.reveal(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_spawn_area(data)
|
||||
local surface = data.surface
|
||||
local left_top = data.left_top
|
||||
|
||||
if left_top.y < -0 then
|
||||
return
|
||||
end
|
||||
if left_top.y > 10 then
|
||||
return
|
||||
end
|
||||
local tiles = {}
|
||||
local circles = shapes.circles
|
||||
|
||||
for r = 1, 12 do
|
||||
for k, v in pairs(circles[r]) do
|
||||
local pos = {x = left_top.x + v.x, y = left_top.y + 20 + v.y}
|
||||
if pos.x > -15 and pos.x < 15 and pos.y < 40 then
|
||||
insert(tiles, {name = more_colors[math_random(1, #more_colors)], position = pos})
|
||||
end
|
||||
if pos.x > -30 and pos.x < 30 and pos.y < 40 then
|
||||
insert(tiles, {name = more_colors[math_random(1, #more_colors)], position = pos})
|
||||
end
|
||||
if pos.x > -60 and pos.x < 60 and pos.y < 40 then
|
||||
insert(tiles, {name = more_colors[math_random(1, #more_colors)], position = pos})
|
||||
end
|
||||
if pos.x > -90 and pos.x < 90 and pos.y < 40 then
|
||||
insert(tiles, {name = more_colors[math_random(1, #more_colors)], position = pos})
|
||||
end
|
||||
if pos.x > -120 and pos.x < 120 and pos.y < 40 then
|
||||
insert(tiles, {name = more_colors[math_random(1, #more_colors)], position = pos})
|
||||
end
|
||||
if pos.x > -150 and pos.x < 150 and pos.y < 40 then
|
||||
insert(tiles, {name = more_colors[math_random(1, #more_colors)], position = pos})
|
||||
end
|
||||
if pos.x > -180 and pos.x < 180 and pos.y < 40 then
|
||||
insert(tiles, {name = more_colors[math_random(1, #more_colors)], position = pos})
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, true)
|
||||
end
|
||||
|
||||
local function is_out_of_map(p)
|
||||
if p.x < 196 and p.x >= -196 then
|
||||
return
|
||||
@ -1519,7 +1546,7 @@ local function out_of_map(data)
|
||||
end
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
local this = Scrap_table.get_table()
|
||||
local this = WPT.get_table()
|
||||
if string.sub(event.surface.name, 0, 9) ~= 'scrapyard' then
|
||||
return
|
||||
end
|
||||
@ -1575,14 +1602,18 @@ local function on_chunk_generated(event)
|
||||
if left_top.y >= 10 then
|
||||
border_chunk(data)
|
||||
end
|
||||
if left_top.y < 0 then
|
||||
if left_top.y < 0 and left_top.y > -50 then
|
||||
Public.reveal_normally(data)
|
||||
end
|
||||
|
||||
if left_top.y < -50 then
|
||||
process(data)
|
||||
if math_random(1, chance_for_wagon_spawn) == 1 then
|
||||
place_wagon(data)
|
||||
end
|
||||
end
|
||||
|
||||
out_of_map_area(data)
|
||||
generate_spawn_area(data)
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
|
Loading…
x
Reference in New Issue
Block a user