Quick fix for player physical position

This commit is contained in:
Cooldude2606
2024-10-19 18:30:58 +01:00
parent 90d0a122cd
commit 34a7879761
31 changed files with 82 additions and 41 deletions

View File

@@ -12,13 +12,13 @@ Event.add(defines.events.on_player_created, function(event)
player.force.friendly_fire = config.friendly_fire
game.map_settings.enemy_expansion.enabled = config.enemy_expansion
local r = config.chart_radius
local p = player.position
player.force.chart(player.surface, { { p.x - r, p.y - r }, { p.x + r, p.y + r } })
local p = player.physical_position
player.force.chart(player.physical_surface, { { p.x - r, p.y - r }, { p.x + r, p.y + r } })
end
-- spawn items
for item, callback in pairs(items) do
if type(callback) == "function" then
local stats = player.force.get_item_production_statistics(player.surface)
local stats = player.force.get_item_production_statistics(player.physical_surface)
local made = stats.get_input_count(item)
local success, count = pcall(callback, made, stats.get_input_count, player)
count = math.floor(count)

View File

@@ -27,7 +27,7 @@ local function create_map_tag(death)
local time = map_tag_time_format(death.time_of_death)
message = message .. " at " .. time
end
death.tag = player.force.add_chart_tag(player.surface, {
death.tag = player.force.add_chart_tag(player.physical_surface, {
position = death.position,
icon = config.map_icon,
text = message,
@@ -65,7 +65,7 @@ end
--- @param event EventData.on_player_died
Event.add(defines.events.on_player_died, function(event)
local player = game.players[event.player_index]
local corpse = player.surface.find_entity("character-corpse", player.position)
local corpse = player.surface.find_entity("character-corpse", player.physical_position)
if not corpse or not corpse.valid then return end
if config.use_chests_as_bodies then
local inventory = assert(corpse.get_inventory(defines.inventory.character_corpse))
@@ -83,7 +83,7 @@ Event.add(defines.events.on_player_died, function(event)
local death = {
player_name = player.name,
time_of_death = event.tick,
position = player.position,
position = player.physical_position,
corpse = corpse,
}
if config.show_map_markers then

View File

@@ -98,7 +98,7 @@ if config.fired_rocket then
return
end
if item.name == "rocket" then
add_log(get_secs() .. "," .. player.name .. ",shot-rocket," .. pos_to_string(player.position) .. "," .. pos_to_string(player.shooting_state.position))
add_log(get_secs() .. "," .. player.name .. ",shot-rocket," .. pos_to_string(player.physical_position) .. "," .. pos_to_string(player.shooting_state.position))
end
end)
end
@@ -117,7 +117,7 @@ if config.fired_explosive_rocket then
return
end
if item.name == "explosive-rocket" then
add_log(get_secs() .. "," .. player.name .. ",shot-explosive-rocket," .. pos_to_string(player.position) .. "," .. pos_to_string(player.shooting_state.position))
add_log(get_secs() .. "," .. player.name .. ",shot-explosive-rocket," .. pos_to_string(player.physical_position) .. "," .. pos_to_string(player.shooting_state.position))
end
end)
end
@@ -138,7 +138,7 @@ if config.fired_nuke then
end
if item.name == "atomic-bomb" then
add_log(get_secs() .. "," .. player.name .. ",shot-nuke," .. pos_to_string(player.position) .. "," .. pos_to_string(player.shooting_state.position))
add_log(get_secs() .. "," .. player.name .. ",shot-nuke," .. pos_to_string(player.physical_position) .. "," .. pos_to_string(player.shooting_state.position))
end
end)
end

View File

@@ -13,6 +13,7 @@ Commands.new_command("lawnmower", "Clean up biter corpse, decoratives and nuclea
:register(function(player, range)
local tile_to_do = {}
-- Intentionally left as player.position to allow use in remote view
player.surface.destroy_decoratives{ position = player.position, radius = range }
local entities = player.surface.find_entities_filtered{ position = player.position, radius = range, type = "corpse" }

View File

@@ -27,7 +27,7 @@ local function check_items(player, type)
ExpUtil.move_items_to_surface{
items = items,
surface = player.surface,
surface = game.planets.nauvis.surface,
allow_creation = true,
name = "iron-chest",
}

View File

@@ -75,8 +75,9 @@ end
-- When the player changes position the tile will have a chance to downgrade, debug check is here
Event.add(defines.events.on_player_changed_position, function(event)
local player = game.players[event.player_index]
local surface = player.surface
local position = player.position
if player.controller_type ~= defines.controllers.character then return end
local surface = player.physical_surface
local position = player.physical_position
local strength = get_tile_strength(surface, position)
if not strength then return end
if get_probability(strength) > math.random() then

View File

@@ -222,7 +222,7 @@ Event.add(defines.events.on_player_created, function(event)
if event.player_index ~= 1 then return end
local player = game.players[event.player_index]
local p = { x = 0, y = 0 }
local s = player.surface
local s = player.physical_surface
get_spawn_force()
spawn_area(s, p)
if config.pattern.enabled then spawn_pattern(s, p) end