diff --git a/config.lua b/config.lua index bae9818f..9b987182 100644 --- a/config.lua +++ b/config.lua @@ -10,6 +10,7 @@ global.scenario.variables.mods = require "locale.resources.mods" global.scenario.variables.regulars = require "locale.resources.regulars" global.scenario.variables.player_positions = {} global.scenario.variables.player_walk_distances = {} +global.scenario.variables.player_deaths = {} global.scenario.config = {} global.scenario.custom_functions = {} global.scenario.config.nuke_min_time_hours = 3 --how long a player must be on the server to be allowed to use the nuke diff --git a/fish_market.lua b/fish_market.lua index d14f98a3..ff200052 100644 --- a/fish_market.lua +++ b/fish_market.lua @@ -57,7 +57,7 @@ function spawn_market(cmd) local market = surface.create_entity{name="market", position=market_location, force=force} market.destructible = false - market.add_market_item{price={{"raw-fish", 10}}, offer={type="give-item", item="exoskeleton-equipment"}} + market.add_market_item{price={{"raw-fish", 10}}, offer={type="give-item", item="discharge-defense-remote"}} market.add_market_item{price={{"raw-fish", 30}}, offer={type="give-item", item="small-plane"}} market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="rail", count=2}} market.add_market_item{price={{"raw-fish", 2}}, offer={type="give-item", item="rail-signal"}} @@ -75,14 +75,28 @@ function spawn_market(cmd) market.add_market_item{price={{"raw-fish", 2}}, offer={type="give-item", item="grenade"}} market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="land-mine"}} market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="solid-fuel"}} + market.add_market_item{price={{"raw-fish", 15}}, offer={type="give-item", item="steel-axe"}} market.add_market_item{price={{"raw-fish", 125}}, offer={type="give-item", item="rocket-launcher"}} market.add_market_item{price={{"raw-fish", 15}}, offer={type="give-item", item="rocket"}} market.add_market_item{price={{"raw-fish", 20}}, offer={type="give-item", item="explosive-rocket"}} market.add_market_item{price={{"raw-fish", 2500}}, offer={type="give-item", item="atomic-bomb"}} + market.add_market_item{price={{"raw-fish", 25}}, offer={type="give-item", item="railgun"}} + market.add_market_item{price={{"raw-fish", 10}}, offer={type="give-item", item="railgun-dart", count=10}} market.add_market_item{price={{"raw-fish", 100}}, offer={type="give-item", item="loader"}} market.add_market_item{price={{"raw-fish", 175}}, offer={type="give-item", item="fast-loader"}} market.add_market_item{price={{"raw-fish", 250}}, offer={type="give-item", item="express-loader"}} market.add_market_item{price={{"raw-fish", 1000}}, offer={type="give-item", item="belt-immunity-equipment"}} + market.add_market_item{price={{"raw-fish", 200}}, offer={type="give-item", item="modular-armor"}} + market.add_market_item{price={{"raw-fish", 500}}, offer={type="give-item", item="power-armor"}} + market.add_market_item{price={{"raw-fish", 2000}}, offer={type="give-item", item="power-armor-mk2"}} + market.add_market_item{price={{"raw-fish", 150}}, offer={type="give-item", item="personal-roboport-equipment"}} + market.add_market_item{price={{"raw-fish", 1500}}, offer={type="give-item", item="personal-roboport-mk2-equipment"}} + market.add_market_item{price={{"raw-fish", 50}}, offer={type="give-item", item="construction-robot", count=10}} + market.add_market_item{price={{"raw-fish", 50}}, offer={type="give-item", item="solar-panel-equipment", count=1}} + market.add_market_item{price={{"raw-fish", 50}}, offer={type="give-item", item="battery-equipment", count=1}} + market.add_market_item{price={{"raw-fish", 750}}, offer={type="give-item", item="battery-mk2-equipment", count=1}} + market.add_market_item{price={{"raw-fish", 2000}}, offer={type="give-item", item="fusion-reactor-equipment", count=1}} + market.add_market_item{price={{"raw-fish", 100}}, offer={type="give-item", item="exoskeleton-equipment"}} end @@ -94,6 +108,7 @@ local total_fish_market_messages = #fish_market_message local total_fish_market_bonus_messages = #fish_market_bonus_message if not global.fish_market_fish_caught then global.fish_market_fish_caught = {} end +if not global.fish_market_fish_spent then global.fish_market_fish_spent = {} end local function fish_earned(event, amount) @@ -101,9 +116,9 @@ local function fish_earned(event, amount) player.insert { name = "raw-fish", count = amount } if global.fish_market_fish_caught[event.player_index] then - global.fish_market_fish_caught[event.player_index] = global.fish_market_fish_caught[event.player_index] + 1 + global.fish_market_fish_caught[event.player_index] = global.fish_market_fish_caught[event.player_index] + amount else - global.fish_market_fish_caught[event.player_index] = 1 + global.fish_market_fish_caught[event.player_index] = amount end if global.fish_market_fish_caught[event.player_index] <= total_fish_market_messages then @@ -225,6 +240,12 @@ local function market_item_purchased(event) local player = game.players[event.player_index] + -- cost + market_items = event.market.get_market_items() + market_item = market_items[event.offer_index] + fish_cost = market_item.price[1].amount * event.count + global.fish_market_fish_spent[event.player_index] = global.fish_market_fish_spent[event.player_index] + fish_cost + if event.offer_index == 1 then -- exoskeleton-equipment player.get_inventory(defines.inventory.player_main).remove({name="exoskeleton-equipment", count=event.count}) boost_player_runningspeed(player) @@ -321,7 +342,35 @@ function fish_market_on_180_ticks() end end +function fish_built_entity (event) + entity = event.created_entity + if entity.type == "entity-ghost" then + -- No reward for ghosts / bps + return + end + + -- player_index = event.player_index + + if entity.type == "furnace" then + local x = math.random(1,5) + if x == 1 then + fish_earned(event, 5) + end + elseif entity.type == "assembling-machine" then + local x = math.random(1,5) + if x == 1 then + fish_earned(event, 5) + end + elseif entity.type == "mining-drill" then + local x = math.random(1,5) + if x == 1 then + fish_earned(event, 5) + end + end + +end Event.register(defines.events.on_preplayer_mined_item, preplayer_mined_item) Event.register(defines.events.on_entity_died, fish_drop_entity_died) Event.register(defines.events.on_market_item_purchased, market_item_purchased) +Event.register(defines.events.on_built_entity, fish_built_entity) diff --git a/player_list.lua b/player_list.lua index f218d8bc..1936dab1 100644 --- a/player_list.lua +++ b/player_list.lua @@ -27,6 +27,10 @@ local function on_player_joined_game(event) global.poke_spam_protection[event.player_index] = game.tick if not global.player_list_pokes_counter then global.player_list_pokes_counter = {} end + if not global.scenario.variables.player_deaths[player.name] then global.scenario.variables.player_deaths[player.name] = 0 end + if not global.fish_market_fish_caught[event.player_index] then global.fish_market_fish_caught[event.player_index] = 0 end + if not global.fish_market_fish_spent[event.player_index] then global.fish_market_fish_spent[event.player_index] = 0 end + if player.gui.top.player_list_button == nil then local button = player.gui.top.add({ type = "sprite-button", name = "player_list_button", sprite = "item/heavy-armor" }) button.style.minimal_height = 38 @@ -184,14 +188,14 @@ local function player_list_show(player, sort_by) player.gui.left.direction = "horizontal" local frame = player.gui.left.add { type = "frame", name = "player-list-panel", direction = "vertical" } - frame.style.minimal_width = 540 + frame.style.minimal_width = 650 frame.style.top_padding = 8 frame.style.left_padding = 8 frame.style.right_padding = 8 frame.style.bottom_padding = 8 - local player_list_panel_header_table = frame.add { type = "table", name = "player_list_panel_header_table", colspan = 5 } + local player_list_panel_header_table = frame.add { type = "table", name = "player_list_panel_header_table", colspan = 7 } local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_1", caption = " " .. #game.connected_players } label.style.font = "default-game" @@ -210,7 +214,7 @@ local function player_list_show(player, sort_by) str = "" if sort_by == "time_played_asc" then str = symbol_asc .. " " end if sort_by == "time_played_desc" then str = symbol_desc .. " " end - local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_3", caption = str .. "Time played" } + local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_3", caption = str .. "Time" } label.style.font = "default-listbox" label.style.font_color = { r=0.98, g=0.66, b=0.22} label.style.minimal_width = 130 @@ -220,11 +224,29 @@ local function player_list_show(player, sort_by) str = "" if sort_by == "distance_asc" then str = symbol_asc .. " " end if sort_by == "distance_desc" then str = symbol_desc .. " " end - local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_4", caption = str .. "Distance walked" } + local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_4", caption = str .. "Walked" } label.style.font = "default-listbox" label.style.font_color = { r=0.98, g=0.66, b=0.22} - label.style.minimal_width = 160 - label.style.maximal_width = 160 + label.style.minimal_width = 100 + label.style.maximal_width = 100 + + str = "" + if sort_by == "fish_asc" then str = symbol_asc .. " " end + if sort_by == "fish_desc" then str = symbol_desc .. " " end + local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_fish", caption = str .. "Fish" } + label.style.font = "default-listbox" + label.style.font_color = { r=0.98, g=0.66, b=0.22} + label.style.minimal_width = 80 + label.style.maximal_width = 80 + + str = "" + if sort_by == "deaths_asc" then str = symbol_asc .. " " end + if sort_by == "deaths_desc" then str = symbol_desc .. " " end + local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_deaths", caption = str .. "Deaths" } + label.style.font = "default-listbox" + label.style.font_color = { r=0.98, g=0.66, b=0.22} + label.style.minimal_width = 80 + label.style.maximal_width = 80 str = "" if sort_by == "pokes_asc" then str = symbol_asc .. " " end @@ -235,10 +257,10 @@ local function player_list_show(player, sort_by) label.style.minimal_width = 35 local player_list_panel_table = frame.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"} - player_list_panel_table.style.maximal_height = 530 + player_list_panel_table.style.maximal_height = 650 - player_list_panel_table = player_list_panel_table.add { type = "table", name = "player_list_panel_table", colspan = 5 } + player_list_panel_table = player_list_panel_table.add { type = "table", name = "player_list_panel_table", colspan = 7 } local player_list = get_sorted_list(sort_by) @@ -262,8 +284,16 @@ local function player_list_show(player, sort_by) label.style.maximal_width = 130 local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_distance_" .. i, caption = round(global.scenario.variables.player_walk_distances[player_list[i].name]/1000, 1) .. " km" } - label.style.minimal_width = 160 - label.style.maximal_width = 160 + label.style.minimal_width = 100 + label.style.maximal_width = 100 + + local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_fish" .. i, caption = global.fish_market_fish_caught[player_list[i].player_index] .. " / " .. global.fish_market_fish_spent[player_list[i].player_index] } + label.style.minimal_width = 80 + label.style.maximal_width = 80 + + local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_deaths" .. i, caption = global.scenario.variables.player_deaths[player_list[i].name] } + label.style.minimal_width = 80 + label.style.maximal_width = 80 local flow = player_list_panel_table.add { type = "flow", name = "button_flow_" .. i, direction = "horizontal" } @@ -368,5 +398,16 @@ function player_list_on_12_seconds() end end end + +local function player_list_on_player_died( event_player, cause ) + player = game.players[event_player.player_index] + if not global.scenario.variables.player_deaths[player.name] then + global.scenario.variables.player_deaths[player.name] = 0 + end + global.scenario.variables.player_deaths[player.name] = global.scenario.variables.player_deaths[player.name] + 1 +end + + Event.register(defines.events.on_player_joined_game, on_player_joined_game) Event.register(defines.events.on_gui_click, on_gui_click) +Event.register(defines.events.on_player_died, player_list_on_player_died)