mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
Player data types updated
- Saves more kill data to Scoreboard - Displays total kills in score board - Saves player data to crash site scenario data set - Added scenario name to data set so that if we later want to add data for danger ores we can filter it out
This commit is contained in:
parent
b18dad52cb
commit
9b39e35d0d
@ -20,6 +20,7 @@ local coins_spent_name = 'coins-spent'
|
||||
local coins_earned_name = 'coins-earned'
|
||||
local player_deaths_name = 'player-deaths'
|
||||
local player_distance_walked_name = 'player-distance-walked'
|
||||
local player_total_kills_name = 'player-total-kills'
|
||||
local random = math.random
|
||||
local ipairs = ipairs
|
||||
local pairs = pairs
|
||||
@ -80,6 +81,7 @@ local time_heading_name = Gui.uid_name()
|
||||
local rank_heading_name = Gui.uid_name()
|
||||
local distance_heading_name = Gui.uid_name()
|
||||
local coin_heading_name = Gui.uid_name()
|
||||
local kills_heading_name = Gui.uid_name()
|
||||
local deaths_heading_name = Gui.uid_name()
|
||||
local poke_name_heading_name = Gui.uid_name()
|
||||
local report_heading_name = Gui.uid_name()
|
||||
@ -90,6 +92,7 @@ local time_cell_name = Gui.uid_name()
|
||||
local rank_cell_name = Gui.uid_name()
|
||||
local distance_cell_name = Gui.uid_name()
|
||||
local coin_cell_name = Gui.uid_name()
|
||||
local kills_cell_name = Gui.uid_name()
|
||||
local deaths_cell_name = Gui.uid_name()
|
||||
local poke_cell_name = Gui.uid_name()
|
||||
local report_cell_name = Gui.uid_name()
|
||||
@ -342,6 +345,36 @@ local column_builders = {
|
||||
return label
|
||||
end
|
||||
},
|
||||
[kills_heading_name] = {
|
||||
create_data = function(player)
|
||||
local player_index = player.index
|
||||
return {
|
||||
count = get_for_player(player_index, player_total_kills_name),
|
||||
}
|
||||
end,
|
||||
sort = function(a, b)
|
||||
return a.count < b.count
|
||||
end,
|
||||
draw_heading = function(parent, sort_symbol)
|
||||
local caption = {'player_list.kills_caption', sort_symbol}
|
||||
local label = parent.add {type = 'label', name = kills_heading_name, caption = caption}
|
||||
local label_style = label.style
|
||||
apply_heading_style(label_style)
|
||||
label_style.width = 60
|
||||
|
||||
return label
|
||||
end,
|
||||
draw_cell = function(parent, cell_data)
|
||||
local text = concat({cell_data.count})
|
||||
|
||||
local label = parent.add {type = 'label', name = kills_cell_name, caption = text}
|
||||
local label_style = label.style
|
||||
label_style.horizontal_align = 'center'
|
||||
label_style.width = 80
|
||||
|
||||
return label
|
||||
end
|
||||
},
|
||||
[deaths_heading_name] = {
|
||||
create_data = function(player)
|
||||
local player_index = player.index
|
||||
@ -505,12 +538,13 @@ local function get_default_player_settings()
|
||||
columns[6] = coin_heading_name
|
||||
offset = 7
|
||||
end
|
||||
columns[offset] = deaths_heading_name
|
||||
columns[offset + 1] = poke_name_heading_name
|
||||
columns[offset + 2] = report_heading_name
|
||||
columns[offset] = kills_heading_name
|
||||
columns[offset + 1] = deaths_heading_name
|
||||
columns[offset + 2] = poke_name_heading_name
|
||||
columns[offset + 3] = report_heading_name
|
||||
return {
|
||||
columns = columns,
|
||||
sort = -3
|
||||
sort = -4
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -21,6 +21,11 @@ local player_console_chats_name = 'player-console-chats'
|
||||
local player_items_crafted_name = 'player-items-crafted'
|
||||
local player_distance_walked_name = 'player-distance-walked'
|
||||
local satellites_launched_name = 'satellites-launched'
|
||||
local player_units_killed_name = 'player-units-killed' --biters and spitters
|
||||
local player_worms_killed_name = 'player-worms-killed'
|
||||
local player_spawners_killed_name = 'player-spawners-killed'
|
||||
local player_total_kills_name = 'player-total-kills'
|
||||
local player_turrets_killed_name = 'player-turrets-killed'
|
||||
|
||||
ScoreTracker.register(rocks_smashed_name, {'player_stats.rocks_smashed'}, '[img=entity.rock-huge]')
|
||||
ScoreTracker.register(trees_cut_down_name, {'player_stats.trees_cut_down'}, '[img=entity.tree-02]')
|
||||
@ -36,6 +41,11 @@ ScoreTracker.register(player_console_chats_name, {'player_stats.player_console_c
|
||||
ScoreTracker.register(player_items_crafted_name, {'player_stats.player_items_crafted'})
|
||||
ScoreTracker.register(player_distance_walked_name, {'player_stats.player_distance_walked'})
|
||||
ScoreTracker.register(satellites_launched_name, {'player_stats.satellites_launched'}, '[img=item.satellite]')
|
||||
ScoreTracker.register(player_units_killed_name, {'player_stats.player_units_killed'})
|
||||
ScoreTracker.register(player_worms_killed_name, {'player_stats.player_worms_killed'})
|
||||
ScoreTracker.register(player_spawners_killed_name, {'player_stats.player_spawners_killed'})
|
||||
ScoreTracker.register(player_turrets_killed_name, {'player_stats.player_turrets_killed'})
|
||||
ScoreTracker.register(player_total_kills_name, {'player_stats.player_total_kills'})
|
||||
|
||||
local train_kill_causes = {
|
||||
['locomotive'] = true,
|
||||
@ -44,6 +54,41 @@ local train_kill_causes = {
|
||||
['artillery-wagon'] = true
|
||||
}
|
||||
|
||||
local spawners = {
|
||||
['biter-spawner'] = true,
|
||||
['spitter-spawner'] = true
|
||||
}
|
||||
|
||||
local worms = {
|
||||
['small-worm-turret'] = true,
|
||||
['medium-worm-turret'] = true,
|
||||
['big-worm-turret'] = true,
|
||||
['behemoth-worm-turret'] = true
|
||||
}
|
||||
|
||||
local units = {
|
||||
['small-biter'] = true,
|
||||
['medium-biter'] = true,
|
||||
['big-biter'] = true,
|
||||
['behemoth-biter'] = true,
|
||||
['small-spitter'] = true,
|
||||
['medium-spitter'] = true,
|
||||
['big-spitter'] = true,
|
||||
['behemoth-spitter'] = true
|
||||
}
|
||||
|
||||
local turrets = {
|
||||
['gun-turret'] = true,
|
||||
['laser-turret'] = true,
|
||||
['artillery-turret'] = true,
|
||||
['flamethrower-turret'] = true
|
||||
}
|
||||
|
||||
local others = {
|
||||
['defender'] = true,
|
||||
['destroyer'] = true
|
||||
}
|
||||
|
||||
local player_last_position = {}
|
||||
local player_death_causes = {}
|
||||
|
||||
@ -140,6 +185,23 @@ end
|
||||
local function biter_kill_counter(event)
|
||||
if event.entity.force.name == 'enemy' then
|
||||
change_for_global(aliens_killed_name, 1)
|
||||
-- Only store for players if its an allowed entity (ie not for walls, chests etc)
|
||||
if (event.cause.name == 'character') and (worms[event.entity.name] or turrets[event.entity.name] or spawners[event.entity.name] or units[event.entity.name] or others[event.entity.name]) then
|
||||
local player_index = event.cause.player.index
|
||||
change_for_player(player_index, player_total_kills_name,1)
|
||||
if worms[event.entity.name] then
|
||||
change_for_player(player_index, player_worms_killed_name,1)
|
||||
end
|
||||
if turrets[event.entity.name ] then
|
||||
change_for_player(player_index, player_turrets_killed_name,1)
|
||||
end
|
||||
if spawners[event.entity.name ] then
|
||||
change_for_player(player_index, player_spawners_killed_name ,1)
|
||||
end
|
||||
if units[event.entity.name ] then
|
||||
change_for_player(player_index, player_units_killed_name,1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,6 +59,7 @@ time_caption=Time __1__
|
||||
rank_caption=Rank __1__
|
||||
distance_caption=Distance __1__
|
||||
coins_caption=Coins __1__
|
||||
kills_caption=Kills __1__
|
||||
deaths_caption=Deaths __1__
|
||||
poke_caption=Poke __1__
|
||||
report_caption=Report __1__
|
||||
|
@ -90,22 +90,42 @@ function Public.control(config)
|
||||
elseif state == 1 then
|
||||
local time_string = Core.format_time(game.ticks_played)
|
||||
Server.to_discord_named_raw(map_promotion_channel, crash_site_role_mention
|
||||
.. ' **Crash Site has just restarted! Previous map lasted: ' .. time_string .. '!**')
|
||||
.. ' **Crash Site has just restarted! Previous map lasted: ' .. time_string .. '!**')
|
||||
|
||||
local end_epoch = Server.get_current_time()
|
||||
if end_epoch == nil then
|
||||
end_epoch = -1 -- end_epoch is nil if the restart command is used locally rather than on the server
|
||||
end
|
||||
|
||||
local player_data = {}
|
||||
for _, p in pairs(game.players) do
|
||||
player_data[p.index] = {
|
||||
name = p.name,
|
||||
total_kills = ScoreTracker.get_for_player(p.index, 'player-total-kills'),
|
||||
spawners_killed = ScoreTracker.get_for_player(p.index, 'player-spawners-killed'),
|
||||
worms_killed = ScoreTracker.get_for_player(p.index, 'player-worms-killed'),
|
||||
units_killed = ScoreTracker.get_for_player(p.index, 'player-units-killed'),
|
||||
turrets_killed = ScoreTracker.get_for_player(p.index, 'player-turrets-killed'),
|
||||
distance_walked = ScoreTracker.get_for_player(p.index, 'player-distance-walked'),
|
||||
player_deaths = ScoreTracker.get_for_player(p.index, 'player-deaths'),
|
||||
coins_earned = ScoreTracker.get_for_player(p.index, 'coins-earned'),
|
||||
entities_built = ScoreTracker.get_for_player(p.index, 'built-by-players'),
|
||||
time_played = p.online_time
|
||||
}
|
||||
end
|
||||
|
||||
local statistics = {
|
||||
scenario = data.scenario_name,
|
||||
start_epoch = Server.get_start_time(),
|
||||
end_epoch = end_epoch, -- stored as key already, useful to have it as part of same structure
|
||||
game_ticks = game.ticks_played,
|
||||
enemy_entities = count_enemy_entities(),
|
||||
biters_killed = ScoreTracker.get_for_global('aliens-killed'),
|
||||
total_players = #game.players
|
||||
total_players = #game.players,
|
||||
player_data = player_data
|
||||
}
|
||||
Server.set_data('crash_site_data', tostring(end_epoch), statistics) -- Store the table, with end_epoch as the key
|
||||
|
||||
Server.set_data('crash_site_data_test', tostring(end_epoch), statistics) -- Store the table, with end_epoch as the key
|
||||
Popup.all('\nServer restarting!\nInitiated by ' .. data.name .. '\n')
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user