1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00

Merge pull request #35 from M3wM3w/master

update from main
This commit is contained in:
hanakocz 2020-10-21 20:23:52 +02:00 committed by GitHub
commit fa4a5da937
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 623 additions and 67 deletions

View File

@ -13,6 +13,7 @@ to your scenario control.lua.
Minor changes by ~~~Gerkiz~~~
--]]
local Event = require 'utils.event'
local Where = require 'commands.where'
local Session = require 'utils.datastore.session_data'
local Jailed = require 'utils.datastore.jail_data'
local Tabs = require 'comfy_panel.main'
@ -497,16 +498,16 @@ local function player_list_show(player, frame, sort_by)
if game.players[player_list[i].name].admin then
trusted = '[color=red][A][/color]'
tooltip = 'This player is an admin of this server.'
tooltip = 'This player is an admin of this server.\nLeft-click to show this person on map!'
elseif jailed[player_list[i].name] then
trusted = '[color=orange][J][/color]'
tooltip = 'This player is currently jailed.'
tooltip = 'This player is currently jailed.\nLeft-click to show this person on map!'
elseif play_table[player_list[i].name] then
trusted = '[color=green][T][/color]'
tooltip = 'This player is trusted.'
tooltip = 'This player is trusted.\nLeft-click to show this person on map!'
else
trusted = '[color=yellow][U][/color]'
tooltip = 'This player is not trusted.'
tooltip = 'This player is not trusted.\nLeft-click to show this person on map!'
end
local caption
@ -517,10 +518,15 @@ local function player_list_show(player, frame, sort_by)
end
-- Name
local p = game.players[player_list[i].name]
if not p or not p.valid then
return
end
local name_label =
player_list_panel_table.add {
type = 'label',
name = 'player_list_panel_player_names_' .. i,
name = p.index,
caption = caption,
tooltip = tooltip
}
@ -637,6 +643,15 @@ local function on_gui_click(event)
if not event.element.valid then
return
end
--Locate other players
local index = tonumber(event.element.name)
if index and game.players[index] and index == game.players[index].index then
local target = game.players[index]
if not target or not target.valid then
return
end
Where.create_mini_camera_gui(player, target.name, target.position, target.surface.index)
end
--Poke other players
if string.sub(event.element.name, 1, 11) == 'poke_player' then
local poked_player = string.sub(event.element.name, 13, string.len(event.element.name))

View File

@ -3,6 +3,8 @@
local Color = require 'utils.color_presets'
local Event = require 'utils.event'
local Public = {}
local function validate_player(player)
if not player then
return false
@ -80,4 +82,8 @@ local function on_gui_click(event)
end
end
Public.create_mini_camera_gui = create_mini_camera_gui
Event.add(defines.events.on_gui_click, on_gui_click)
return Public

View File

@ -8,6 +8,7 @@ require 'utils.server_commands'
require 'utils.utils'
require 'utils.table'
require 'utils.freeplay'
require 'utils.datastore.server_ups'
require 'utils.datastore.color_data'
require 'utils.datastore.session_data'
require 'utils.datastore.jail_data'
@ -135,6 +136,7 @@ require 'modules.autostash'
--![[You fell in a dark cave, will you survive?]]--
--require 'maps.cave_miner'
--require 'maps.cave_choppy.cave_miner'
--require 'maps.cave_miner_v2.main'
--![[Hungry boxes eat your items, but reward you with new territory to build.]]--
--require 'maps.expanse.main'
@ -201,7 +203,6 @@ require 'modules.autostash'
--require 'maps.pitch_black.main'
--require 'maps.cube'
--require 'maps.mountain_race.main'
--require 'maps.cave_miner_v2.main'
--require 'maps.native_war.main'
---------------------------------------------------------------

View File

@ -3,6 +3,11 @@ description=A chonky scenario featuring a whole compilation of different maps,\n
[biter_battles]
map_info= - - B I T E R B A T T L E S - -\n\n The biters have noticed that you are secretly hoarding fish in the rocket silo.\n Your objective is to defend your silo, while defeating the other team.\n\n Feed your opponent's biters with science packs to increase their strength.\n High tier science juice will yield stronger mutagenic results.\n Only feeding and time increases their power and will lead to your teams victory.\n\n There is no major direct pvp combat.\n The horizontal border river is landfill proof.\n Construction robots can not build on the other teams's side.\n The random map layout is mirrored to provide a fair competition.\n\n West and East directions contain no biter nests,\n leaving room for factory expansion and outpost building.\n North and South directions are biter territory.\n\n The gui yields two different main stats for each team's biters.\n\n - EVO -\n Evolution of the biters. Increases when they get fed.\n Can rise above 100% which unlocks endgame modifiers,\n granting them increased damage and health.\n\n - THREAT -\n Causes biters to attack. Reduces when biters are slain.\n Feeding gives permanent "threat-income", as well as creating instant threat.\n A high threat value causes big attacks. Values of zero or below will cause no attacks.
[cave_miner]
map_info_main_caption= - - C A V E M I N E R - -
map_info_sub_caption=MINING DIAMONDS
map_info_text=Delve deep for greater treasures, but also face increased dangers.\n\nYour pickaxe can be upgraded at the market.\nThe price of the upgrade may be rerolled by spending fish.\n\nBreaking rocks is exhausting and might make you hungry.\nSo don´t forget to eat some fish once in a while to stay well fed.\nBe careful, eating too much might have it´s consequences too.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nSome explosives may cause parts of the ceiling to crumble, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nDarkness is a hazard in the mines, stay near your lamps..
[desert_oasis]
map_info_main_caption=--Desert Oasis--
map_info_sub_caption=Survival in the dry sands.

View File

@ -3,6 +3,7 @@ local Public = {}
local Constants = require 'maps.cave_miner_v2.constants'
local BiterRaffle = require "functions.biter_raffle"
local LootRaffle = require "functions.loot_raffle"
local Esq = require "modules.entity_spawn_queue"
local math_sqrt = math.sqrt
local math_random = math.random
@ -41,7 +42,7 @@ function Public.spawn_player(player)
end
function Public.set_mining_speed(cave_miner, force)
force.manual_mining_speed_modifier = -0.50 + cave_miner.pickaxe_tier * 0.35
force.manual_mining_speed_modifier = -0.50 + cave_miner.pickaxe_tier * 0.40
return force.manual_mining_speed_modifier
end
@ -66,6 +67,17 @@ function Public.spawn_random_biter(surface, position, multiplier)
return unit
end
function Public.rock_spawns_biters(cave_miner, position)
local amount = Public.roll_biter_amount()
local surface = game.surfaces.nauvis
local d = math_sqrt(position.x ^ 2 + position.y ^ 2) * 0.0001
local tick = game.tick
for _ = 1, amount, 1 do
tick = tick + math_random(30, 120)
Esq.add_to_queue(tick, surface, {name = BiterRaffle.roll("mixed", d), position = position, force = "enemy"}, 8)
end
end
function Public.loot_crate(surface, position, multiplier, slots, container_name)
local d = math_sqrt(position.x ^ 2 + position.y ^ 2)
local item_stacks = LootRaffle.roll(d * multiplier, slots, loot_blacklist)
@ -113,4 +125,41 @@ function Public.update_top_gui(cave_miner)
end
end
local function is_entity_in_darkness(entity)
if not entity then return end
if not entity.valid then return end
local position = entity.position
local d = position.x ^ 2 + position.y ^ 2
if d < 512 then return false end
for _, lamp in pairs(entity.surface.find_entities_filtered({area={{position.x - 16, position.y - 16},{position.x + 16, position.y + 16}}, name = "small-lamp"})) do
local circuit = lamp.get_or_create_control_behavior()
if circuit then
if lamp.energy > 25 and circuit.disabled == false then
return
end
else
if lamp.energy > 25 then
return
end
end
end
return true
end
function Public.darkness(cave_miner)
for _, player in pairs(game.connected_players) do
local character = player.character
if character and character.valid then
character.disable_flashlight()
if is_entity_in_darkness(character) then
local d = math_sqrt(character.position.x ^ 2 + character.position.y ^ 2) * 0.0001
Esq.add_to_queue(game.tick + 60, player.surface, {name = BiterRaffle.roll("mixed", d), position = character.position, force = "enemy"}, 8)
end
end
end
end
return Public

View File

@ -7,6 +7,7 @@ local Market = require 'maps.cave_miner_v2.market'
local Server = require 'utils.server'
local Terrain = require 'maps.cave_miner_v2.terrain'
local Pets = require "modules.biter_pets"
local Map_info = require "modules.map_info"
require "modules.satellite_score"
require "modules.hunger"
@ -76,11 +77,8 @@ local function on_player_mined_entity(event)
local position = entity.position
if entity.type == "simple-entity" then
cave_miner.rocks_broken = cave_miner.rocks_broken + 1
if math.random(1, 12) == 1 then
local amount = Functions.roll_biter_amount()
for _ = 1, amount, 1 do
Functions.spawn_random_biter(surface, position, 1)
end
if math.random(1, 16) == 1 then
Functions.rock_spawns_biters(cave_miner, position)
return
end
if math.random(1, 1024) == 1 then
@ -96,11 +94,19 @@ local function on_entity_died(event)
if not entity then return end
if not entity.valid then return end
local surface = entity.surface
local position = entity.position
local position = entity.position
if entity.type == "unit" then
if math.random(1, 8) == 1 then
surface.spill_item_stack(position, {name = "raw-fish", count = 1}, true)
end
return
end
if entity.type == "simple-entity" then
cave_miner.rocks_broken = cave_miner.rocks_broken + 1
if math.random(1, 2) == 1 then
Functions.spawn_random_biter(surface, position, 1)
if math.random(1, 4) == 1 then
Functions.rock_spawns_biters(cave_miner, position)
end
return
end
@ -146,6 +152,8 @@ local function init(cave_miner)
force.technologies["landfill"].enabled = false
force.technologies["spidertron"].enabled = false
force.technologies["artillery"].enabled = false
force.technologies["artillery-shell-range-1"].enabled = false
force.technologies["artillery-shell-speed-1"].enabled = false
cave_miner.gamestate = "spawn_players"
end
@ -161,23 +169,29 @@ local function spawn_players(cave_miner)
cave_miner.gamestate = "game_in_progress"
end
local game_tasks = {
[15] = Functions.update_top_gui,
[30] = function()
local reveal = cave_miner.reveal_queue[1]
if not reveal then return end
local brush_size = 3
if Constants.reveal_chain_brush_sizes[reveal[1]] then brush_size = Constants.reveal_chain_brush_sizes[reveal[1]] end
Terrain.reveal(
cave_miner,
game.surfaces.nauvis,
game.surfaces.cave_miner_source,
{x = reveal[2], y = reveal[3]},
brush_size
)
table.remove(cave_miner.reveal_queue, 1)
end,
[45] = Functions.darkness,
}
local function game_in_progress(cave_miner)
local tick = game.ticks_played
if tick % 60 ~= 0 then return end
Functions.update_top_gui(cave_miner)
local reveal = cave_miner.reveal_queue[1]
if not reveal then return end
local brush_size = 3
if Constants.reveal_chain_brush_sizes[reveal[1]] then brush_size = Constants.reveal_chain_brush_sizes[reveal[1]] end
Terrain.reveal(
cave_miner,
game.surfaces.nauvis,
game.surfaces.cave_miner_source,
{x = reveal[2], y = reveal[3]},
brush_size
)
table.remove(cave_miner.reveal_queue, 1)
local tick = game.ticks_played % 60
if not game_tasks[tick] then return end
game_tasks[tick](cave_miner)
end
local gamestates = {
@ -199,7 +213,7 @@ local function on_init()
cave_miner.reveal_queue = {}
global.rocks_yield_ore_maximum_amount = 256
global.rocks_yield_ore_base_amount = 32
global.rocks_yield_ore_base_amount = 28
global.rocks_yield_ore_distance_modifier = 0.01
Explosives.set_destructible_tile("out-of-map", 1500)
@ -216,6 +230,11 @@ local function on_init()
global.rocks_yield_ore_veins.amount_modifier = 0.25
global.rocks_yield_ore_veins.chance = 756
local T = Map_info.Pop_info()
T.localised_category = "cave_miner"
T.main_caption_color = {r = 200, g = 100, b = 0}
T.sub_caption_color = {r = 0, g = 175, b = 175}
end
Event.on_init(on_init)

View File

@ -41,8 +41,13 @@ end
function Public.spawn(cave_miner)
local surface = game.surfaces.nauvis
local market = surface.create_entity({name = "market", position = {0,0}})
rendering.draw_light({
sprite = "utility/light_medium", scale = 7, intensity = 0.8, minimum_darkness = 0,
oriented = true, color = {255,255,255}, target = market,
surface = surface, visible = true, only_in_alt_mode = false,
})
market.destructible = false
Public.refresh_offers(market, cave_miner)
Public.refresh_offers(market, cave_miner)
end
function Public.offer_bought(event, cave_miner)

View File

@ -112,6 +112,13 @@ end
function biomes.spawn(surface, seed, position, square_distance)
if square_distance < 32 then return end
local noise = GetNoise("decoratives", position, seed)
if math_abs(noise) > 0.5 then
surface.set_tiles({{name = "water", position = position}}, true, false, false, false)
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = position}) end
return
end
if math_abs(noise) > 0.15 and math_random(1, 2) > 1 then
local a = (-49 + math_random(0, 98)) * 0.01
local b = (-49 + math_random(0, 98)) * 0.01

View File

@ -0,0 +1,95 @@
local Server = require 'utils.server'
local FDT = require 'maps.fish_defender.table'
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
commands.add_command(
'scenario',
'Usable only for admins - controls the scenario!',
function(cmd)
local p
local player = game.player
if not player or not player.valid then
p = log
else
p = player.print
if not player.admin then
return
end
end
local param = cmd.parameter
if param == 'restart' or param == 'shutdown' or param == 'reset' or param == 'restartnow' then
goto continue
else
p('[ERROR] Arguments are:\nrestart\nshutdown\nreset\nrestartnow')
return
end
::continue::
local this = FDT.get()
local reset_map = require 'maps.fish_defender.main'
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
p(
'[WARNING] This command will disable the soft-reset feature, run this command again if you really want to do this!'
)
return
end
if param == 'restart' then
if this.restart then
this.reset_are_you_sure = nil
this.restart = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is enabled.')
return
else
this.reset_are_you_sure = nil
this.restart = true
this.soft_reset = false
if this.shutdown then
this.shutdown = false
end
p('[WARNING] Soft-reset is disabled! Server will restart from scenario.')
return
end
elseif param == 'restartnow' then
this.reset_are_you_sure = nil
p(player.name .. ' has restarted the game.')
Server.start_scenario('Fish_Defender')
return
elseif param == 'shutdown' then
if this.shutdown then
this.reset_are_you_sure = nil
this.shutdown = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is enabled.')
return
else
this.reset_are_you_sure = nil
this.shutdown = true
this.soft_reset = false
if this.restart then
this.restart = false
end
p('[WARNING] Soft-reset is disabled! Server will shutdown.')
return
end
elseif param == 'reset' then
this.reset_are_you_sure = nil
if player and player.valid then
game.print(mapkeeper .. ' ' .. player.name .. ', has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
else
game.print(mapkeeper .. ' server, has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
end
reset_map(true)
p('[WARNING] Game has been reset!')
return
end
end
)

View File

@ -3,13 +3,15 @@
--require "modules.rpg"
require 'maps.fish_defender.market'
require 'maps.fish_defender.commands'
require 'maps.fish_defender.on_entity_damaged'
require 'modules.rocket_launch_always_yields_science'
require 'modules.launch_fish_to_win'
require 'modules.biters_yield_coins'
require 'modules.dangerous_goods'
require 'modules.custom_death_messages'
require 'modules.launch_fish_to_win'
local AntiGrief = require 'antigrief'
local Terrain = require 'maps.fish_defender.terrain'
local Unit_health_booster = require 'modules.biter_health_booster'
local Difficulty = require 'modules.difficulty_vote'
@ -1134,8 +1136,10 @@ local function on_init(reset)
local this = FDT.get()
AntiGrief.reset_tables()
FDT.reset_table()
Poll.reset()
global.fish_in_space = 0
local difficulties = {
[1] = {
@ -1168,9 +1172,12 @@ local function on_init(reset)
Diff.difficulty_poll_closing_timeout = this.wave_grace_period
get_score.score_table = {}
game.remove_offline_players()
local map_gen_settings = {}
map_gen_settings.height = 2048
map_gen_settings.water = 0.10
map_gen_settings.seed = math_random(10000, 99999)
map_gen_settings.terrain_segmentation = 3
map_gen_settings.cliff_settings = {cliff_elevation_interval = 32, cliff_elevation_0 = 32}
map_gen_settings.autoplace_controls = {

View File

@ -8,6 +8,7 @@ local blacklist = {
['cargo-wagon'] = true,
['locomotive'] = true,
['artillery-wagon'] = true,
['artillery-turret'] = true,
['fluid-wagon'] = true,
['land-mine'] = true,
['car'] = true,

View File

@ -6,7 +6,7 @@ local WPT = require 'maps.mountain_fortress_v3.table'
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
commands.add_command(
'mf_commands',
'scenario',
'Usable only for admins - controls the scenario!',
function(cmd)
local p

View File

@ -33,7 +33,11 @@ local artillery_target_entities = {
'car',
'furnace',
'straight-rail',
'curved-rail'
'curved-rail',
'locomotive',
'cargo-wagon',
'fluid-wagon',
'artillery-wagon'
}
local function fast_remove(tbl, index)

View File

@ -316,6 +316,10 @@ function Public.update_gui(player)
local rpg_extra = RPG_Settings.get('rpg_extra')
local this = WPT.get()
if not validate_player(player) then
return
end
if not player.gui.top[main_frame_name] then
return
end
@ -342,7 +346,7 @@ function Public.update_gui(player)
local speed =
math.round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100)
gui.pickaxe_tier.caption = ' [img=item.dummy-steel-axe]: ' .. pick_tier
gui.pickaxe_tier.caption = ' [img=item.dummy-steel-axe]: ' .. pick_tier .. ' (' .. tier .. ')'
gui.pickaxe_tier.tooltip = ({'gui.current_pickaxe_tier', pick_tier, speed})
gui.biters_killed.caption = ' [img=entity.small-biter]: ' .. format_number(this.biters_killed, true)

View File

@ -618,7 +618,7 @@ function Public.kill_car(ic, entity)
local entity_type = ic.entity_type
if not entity_type[entity.name] then
if not entity_type[entity.type] then
return
end
local car = ic.cars[entity.unit_number]
@ -778,7 +778,7 @@ function Public.create_car(ic, event)
return
end
if not entity_type[ce.name] then
if not entity_type[ce.type] then
return
end

View File

@ -229,6 +229,7 @@ function Public.changed_surface(event)
if Functions.get_player_surface(ic, player) then
Public.toggle_button(player)
Public.minimap(player, surface)
if wd and wd.visible then
wd.visible = false
end

View File

@ -39,12 +39,14 @@ function Public.reset()
this.entity_type = {
['car'] = true,
['tank'] = true,
['spidertron'] = true
['spidertron'] = true,
['spider-vehicle'] = true
}
this.car_areas = {
['car'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 20}},
['tank'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 40}},
['spidertron'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 60}}
['spidertron'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 60}},
['spider-vehicle'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 60}}
}
end

View File

@ -257,21 +257,29 @@ function Public.add_player_to_permission_group(player, group, forced)
if enable_permission_group_disconnect then
local locomotive_group = game.permissions.get_group('locomotive')
local plebs_group = game.permissions.get_group('plebs')
local default_group = game.permissions.get_group('Default')
if locomotive_group then
locomotive_group.set_allows_action(defines.input_action.disconnect_rolling_stock, true)
end
if plebs_group then
plebs_group.set_allows_action(defines.input_action.disconnect_rolling_stock, true)
end
if default_group then
default_group.set_allows_action(defines.input_action.disconnect_rolling_stock, true)
end
else
local locomotive_group = game.permissions.get_group('locomotive')
local plebs_group = game.permissions.get_group('plebs')
local default_group = game.permissions.get_group('Default')
if locomotive_group then
locomotive_group.set_allows_action(defines.input_action.disconnect_rolling_stock, false)
end
if plebs_group then
plebs_group.set_allows_action(defines.input_action.disconnect_rolling_stock, false)
end
if default_group then
default_group.set_allows_action(defines.input_action.disconnect_rolling_stock, false)
end
end
if playtime < 5184000 then -- 24 hours
@ -962,10 +970,12 @@ local function gui_click(event)
}
)
game.forces.player.manual_mining_speed_modifier = game.forces.player.manual_mining_speed_modifier + 0.25
local force = game.forces.player
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.05
local force_mining_speed = WPT.get('force_mining_speed')
force_mining_speed.speed = game.forces.player.manual_mining_speed_modifier
force_mining_speed.speed = force.manual_mining_speed_modifier
redraw_market_items(data.item_frame, player, data.search_text)
redraw_coins_left(data.coins_left, player)
@ -1898,14 +1908,14 @@ function Public.get_items()
local flame_turret = WPT.get('upgrades').flame_turret.bought
local landmine = WPT.get('upgrades').landmine.bought
local chest_limit_cost = 2500 * (1 + chest_limit_outside_upgrades)
local chest_limit_cost = 3000 * (1 + chest_limit_outside_upgrades)
local health_cost = 10000 * (1 + health_upgrades)
local pickaxe_cost = 2500 * (1 + pickaxe_tier)
local pickaxe_cost = 3000 * (1 + pickaxe_tier)
local reroll_cost = 1000 * (1 + reroll_amounts)
local aura_cost = 4000 * (1 + aura_upgrades)
local xp_point_boost_cost = 5000 * (1 + xp_points_upgrade)
local explosive_bullets_cost = 20000
local flamethrower_turrets_cost = 2500 * (1 + flame_turret)
local flamethrower_turrets_cost = 3000 * (1 + flame_turret)
local land_mine_cost = 2 * (1 + landmine)
local skill_reset_cost = 100000
main_market_items['reroll_market_items'] = {

View File

@ -13,6 +13,7 @@ local blacklist = {
['spidertron'] = true,
['locomotive'] = true,
['artillery-wagon'] = true,
['artillery-turret'] = true,
['fluid-wagon'] = true
}

View File

@ -0,0 +1,64 @@
-- Queue entities to spawn at certain ticks -- mewmew
-- Add entities via .add_to_queue(tick, surface, entity_data, non_colliding_position_search_radius)
-- Example Esq.add_to_queue(3486, game.surfaces.nauvis, {name = "small-biter", position = {16, 17}, force = "player"}, false)
local Event = require 'utils.event'
local Global = require 'utils.global'
local table_insert = table.insert
local Public = {}
local ESQ = {}
Global.register(
ESQ,
function(tbl)
ESQ = tbl
end
)
local function spawn_entity(surface_index, entity_data, non_colliding_position_search_radius)
local surface = game.surfaces[surface_index]
if not surface then return end
if not surface.valid then return end
if non_colliding_position_search_radius then
local p = surface.find_non_colliding_position(entity_data.name, entity_data.position, non_colliding_position_search_radius, 0.5)
if p then entity_data.position = p end
end
surface.create_entity(entity_data)
end
function Public.add_to_queue(tick, surface, entity_data, non_colliding_position_search_radius)
if not surface then return end
if not surface.valid then return end
if not entity_data then return end
if not entity_data.position then return end
if not entity_data.name then return end
if not tick then return end
local queue = ESQ.queue
local entity = {}
for k, v in pairs(entity_data) do entity[k] = v end
tick = tostring(tick)
if not queue[tick] then queue[tick] = {} end
table_insert(queue[tick], {surface.index, entity, non_colliding_position_search_radius})
end
local function on_tick()
local tick = tostring(game.tick)
if not ESQ.queue[tick] then return end
for _, v in pairs(ESQ.queue[tick]) do spawn_entity(v[1], v[2], v[3]) end
ESQ.queue[tick] = nil
end
local function on_init()
ESQ.queue = {}
end
Event.on_init(on_init)
Event.add(defines.events.on_tick, on_tick)
return Public

123
modules/rpg/commands.lua Normal file
View File

@ -0,0 +1,123 @@
local RPG = require 'modules.rpg.table'
local Utils = require 'utils.core'
local Color = require 'utils.color_presets'
local round = math.round
local validate_args = function(data)
local player = data.player
local target = data.target
local rpg_t = data.rpg_t
if not target then
return false
end
if not target.valid then
return false
end
if not target.character then
return false
end
if not target.connected then
return false
end
if not game.players[target.index] then
return false
end
if not player then
return false
end
if not player.valid then
return false
end
if not player.character then
return false
end
if not player.connected then
return false
end
if not game.players[player.index] then
return false
end
if not target or not game.players[target.index] then
Utils.print_to(player, 'Invalid name.')
return false
end
if not rpg_t[target.index] then
Utils.print_to(player, 'Invalid target.')
return false
end
return true
end
local print_stats = function(target, tbl)
if not target then
return
end
if not tbl then
return
end
local t = tbl[target.index]
local level = t.level
local xp = round(t.xp)
local strength = t.strength
local magicka = t.magicka
local dexterity = t.dexterity
local vitality = t.vitality
local output = '[color=blue]' .. target.name .. '[/color] has the following stats: \n'
output = output .. '[color=green]Level:[/color] ' .. level .. '\n'
output = output .. '[color=green]XP:[/color] ' .. xp .. '\n'
output = output .. '[color=green]Strength:[/color] ' .. strength .. '\n'
output = output .. '[color=green]Magic:[/color] ' .. magicka .. '\n'
output = output .. '[color=green]Dexterity:[/color] ' .. dexterity .. '\n'
output = output .. '[color=green]Vitality:[/color] ' .. vitality
return output
end
commands.add_command(
'stats',
'Check what stats a user has!',
function(cmd)
local player = game.player
if not player or not player.valid then
return
end
local param = cmd.parameter
local target = game.players[param]
if not target or not target.valid then
return
end
local rpg_t = RPG.get('rpg_t')
local data = {
player = player,
target = target,
rpg_t = rpg_t
}
if validate_args(data) then
local msg = print_stats(target, rpg_t)
player.play_sound {path = 'utility/scenario_message', volume_modifier = 1}
player.print(msg)
else
player.print('Please type a name of a player who is connected.', Color.warning)
end
end
)

View File

@ -686,7 +686,7 @@ function Public.global_pool(players, count)
RPG.debug_log('RPG - player capped: ' .. p.name .. '. Amount to pool:' .. share)
end
else
local message = ({'rpg_functions.pool_reward'})
local message = ({'rpg_functions.pool_reward', p.name})
Alert.alert_player_warning(p, 10, message)
share = share / 10
rpg_extra.leftover_pool = rpg_extra.leftover_pool + share

View File

@ -7,6 +7,7 @@ local WD = require 'modules.wave_defense.table'
local Math2D = require 'math2d'
--RPG Modules
require 'modules.rpg.commands'
local RPG = require 'modules.rpg.table'
local Functions = require 'modules.rpg.functions'
local RPG_GUI = require 'modules.rpg.gui'

View File

@ -8,7 +8,7 @@ function Public.conjure_items()
obj_to_create = 'stone-wall',
level = 10,
type = 'item',
mana_cost = 35,
mana_cost = 60,
tick = 100,
enabled = true
}
@ -18,7 +18,7 @@ function Public.conjure_items()
obj_to_create = 'wooden-chest',
level = 2,
type = 'item',
mana_cost = 30,
mana_cost = 50,
tick = 100,
enabled = true
}
@ -27,7 +27,7 @@ function Public.conjure_items()
obj_to_create = 'iron-chest',
level = 10,
type = 'item',
mana_cost = 40,
mana_cost = 110,
tick = 200,
enabled = true
}
@ -36,7 +36,7 @@ function Public.conjure_items()
obj_to_create = 'steel-chest',
level = 15,
type = 'item',
mana_cost = 50,
mana_cost = 150,
tick = 300,
enabled = true
}
@ -45,7 +45,7 @@ function Public.conjure_items()
obj_to_create = 'transport-belt',
level = 3,
type = 'item',
mana_cost = 40,
mana_cost = 80,
tick = 100,
enabled = true
}
@ -54,7 +54,7 @@ function Public.conjure_items()
obj_to_create = 'fast-transport-belt',
level = 20,
type = 'item',
mana_cost = 50,
mana_cost = 110,
tick = 200,
enabled = true
}
@ -63,7 +63,7 @@ function Public.conjure_items()
obj_to_create = 'express-transport-belt',
level = 60,
type = 'item',
mana_cost = 60,
mana_cost = 150,
tick = 300,
enabled = true
}
@ -72,7 +72,7 @@ function Public.conjure_items()
obj_to_create = 'underground-belt',
level = 3,
type = 'item',
mana_cost = 40,
mana_cost = 80,
tick = 100,
enabled = true
}
@ -81,7 +81,7 @@ function Public.conjure_items()
obj_to_create = 'fast-underground-belt',
level = 20,
type = 'item',
mana_cost = 50,
mana_cost = 110,
tick = 200,
enabled = true
}
@ -90,7 +90,7 @@ function Public.conjure_items()
obj_to_create = 'express-underground-belt',
level = 60,
type = 'item',
mana_cost = 60,
mana_cost = 150,
tick = 300,
enabled = true
}
@ -110,7 +110,7 @@ function Public.conjure_items()
biter = true,
type = 'entity',
mana_cost = 55,
tick = 100,
tick = 200,
enabled = true
}
spells[#spells + 1] = {
@ -120,7 +120,7 @@ function Public.conjure_items()
biter = true,
type = 'entity',
mana_cost = 55,
tick = 100,
tick = 200,
enabled = true
}
spells[#spells + 1] = {
@ -130,7 +130,7 @@ function Public.conjure_items()
biter = true,
type = 'entity',
mana_cost = 100,
tick = 200,
tick = 300,
enabled = true
}
spells[#spells + 1] = {
@ -139,7 +139,7 @@ function Public.conjure_items()
level = 70,
type = 'entity',
mana_cost = 100,
tick = 200,
tick = 300,
enabled = true
}
spells[#spells + 1] = {
@ -148,7 +148,7 @@ function Public.conjure_items()
level = 100,
biter = true,
type = 'entity',
mana_cost = 600,
mana_cost = 800,
tick = 1420,
enabled = true
}
@ -268,7 +268,7 @@ function Public.conjure_items()
force = 'player',
level = 50,
type = 'special',
mana_cost = 200,
mana_cost = 300,
tick = 320,
enabled = true
}

View File

@ -326,7 +326,7 @@ local vote_to_jail = function(player, griefer, msg)
end
local vote_to_free = function(player, griefer)
if votefree[griefer] and not votefree[griefer] then
if not votefree[griefer] then
votefree[griefer] = {index = 0, actor = player.name}
local message = player.name .. ' has started a vote to free player ' .. griefer
Utils.print_to(nil, message)

View File

@ -0,0 +1,94 @@
local Server = require 'utils.server'
local GUI = require 'utils.gui'
local Event = require 'utils.event'
local Color = require 'utils.color_presets'
local ups_label = GUI.uid_name()
local function validate_player(player)
if not player or not player.valid then
return false
end
return true
end
local function set_location(event)
local player = game.get_player(event.player_index)
local gui = player.gui
local label = gui.screen[ups_label]
local res = player.display_resolution
local uis = player.display_scale
label.location = {x = res.width - 423 * uis, y = 30 * uis}
end
Event.add(
defines.events.on_player_joined_game,
function(event)
local player = game.get_player(event.player_index)
local ups = Server.get_ups()
local sUPS = 'SUPS = ' .. ups
local label = player.gui.screen[ups_label]
if not label or not label.valid then
label =
player.gui.screen.add(
{
type = 'label',
name = ups_label,
caption = sUPS
}
)
local style = label.style
style.font = 'default-game'
end
set_location(event)
label.visible = false
end
)
-- Update the value each second
Event.on_nth_tick(
60,
function()
local ups = Server.get_ups()
local caption = 'SUPS = ' .. ups
local players = game.connected_players
for _, player in pairs(players) do
local label = player.gui.screen[ups_label]
if label and label.valid then
label.caption = caption
end
end
end
)
commands.add_command(
'server-ups',
'Toggle the server UPS display!',
function()
local player = game.player
local secs = Server.get_current_time()
if validate_player(player) then
if not secs then
return player.print('Not running on Comfy backend.', Color.warning)
end
local label = player.gui.screen[ups_label]
if not label or not label.valid then
return
end
if label.visible then
label.visible = false
else
label.visible = true
end
end
end
)
Event.add(defines.events.on_player_display_resolution_changed, set_location)
Event.add(defines.events.on_player_display_scale_changed, set_location)

View File

@ -72,6 +72,11 @@ local noises = {
{modifier = 0.01, weight = 0.35},
{modifier = 0.05, weight = 0.23},
{modifier = 0.1, weight = 0.11}
},
['big_cave'] = {
{modifier = 0.003, weight = 1},
{modifier = 0.02, weight = 0.05},
{modifier = 0.15, weight = 0.02}
},
['small_caves'] = {
{modifier = 0.008, weight = 1},
@ -93,7 +98,7 @@ local noises = {
{modifier = 0.01, weight = 1},
{modifier = 0.05, weight = 0.5},
{modifier = 0.1, weight = 0.025}
}
},
}
--returns a float number between -1 and 1

View File

@ -16,15 +16,18 @@ local serialize_options = {sparse = true, compact = true}
local Public = {}
local server_time = {secs = nil, tick = 0}
local server_ups = {ups = 60}
local requests = {}
Global.register(
{
server_time = server_time,
server_ups = server_ups,
requests = requests
},
function(tbl)
server_time = tbl.server_time
server_ups = tbl.server_ups
requests = tbl.requests
end
)
@ -663,6 +666,19 @@ function Public.get_time_data_raw()
return server_time
end
--- Called by the web server to set the ups value.
-- @param tick<number> tick
function Public.set_ups(tick)
server_ups.ups = tick
end
--- Gets a the estimated UPS from the web panel that is sent to the server.
-- This is calculated and measured in the wrapper.
-- @return number
function Public.get_ups()
return server_ups.ups
end
--- Gets an estimate of the current server time as a unix epoch timestamp.
-- If the server time has not been set returns nil.
-- The estimate may be slightly off if within the last minute the game has been paused, saving or overwise,

View File

@ -1,4 +1,7 @@
local Poll = {send_poll_result_to_discord = function () end}
local Poll = {
send_poll_result_to_discord = function()
end
}
local Token = require 'utils.token'
local Server = require 'utils.server'
@ -9,7 +12,6 @@ ServerCommands = {}
ServerCommands.get_poll_result = Poll.send_poll_result_to_discord
function ServerCommands.raise_callback(func_token, data)
local func = Token.get(func_token)
func(data)
@ -23,6 +25,25 @@ function ServerCommands.server_started()
end
ServerCommands.set_time = Server.set_time
ServerCommands.set_ups = Server.set_ups
ServerCommands.get_ups = Server.get_ups
ServerCommands.query_online_players = Server.query_online_players
local SC_Interface = {
get_ups = function()
return ServerCommands.get_ups()
end,
set_ups = function(tick)
if tick then
ServerCommands.set_ups(tick)
else
error("Remote call parameter to ServerCommands set_ups can't be nil.")
end
end
}
if not remote.interfaces['ServerCommands'] then
remote.add_interface('ServerCommands', SC_Interface)
end
return ServerCommands