mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-22 03:38:48 +02:00
Make grief prevention more aggressive: kill player's character and hold all crafting queue in corpse (via pre-death inventory resize by bonus multiplier, same used in RPG system and returned by this system back to normal sizes), instead relying on Factorio's item placement, so no items are lost from team.
Corrected shown message on player abuse attempt. P.S. Not a Lua developer at all, so styleguide may be broken.
This commit is contained in:
parent
2442340ed6
commit
621c1486bf
@ -614,12 +614,23 @@ end
|
||||
local function on_player_cancelled_crafting(event)
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
local count = #event.items
|
||||
local count = event.items.get_item_count() -- Error in calculations were just misinterpretation of API, #event.items returned item slots, not actual count.
|
||||
|
||||
local playerInventoryStacks = #player.get_main_inventory() -- Get this to calculate overhead + player inventory
|
||||
local canceledCraftingQueueStacks = #event.items -- Get item stacks num from crafting queue
|
||||
|
||||
if canceledCraftingQueueStacks > playerInventoryStacks then
|
||||
player.character.character_inventory_slots_bonus = canceledCraftingQueueStacks + playerInventoryStacks -- Resize player's inventory for this entity at maximum level to hold crafting queue + inventory, so don't cause item drop.
|
||||
for i = 1, canceledCraftingQueueStacks do -- Manually insert crafting queue to inventory
|
||||
player.character.get_main_inventory().insert(event.items[i])
|
||||
end
|
||||
player.character.die('player') -- Kill griefer!11 Thanks to RPG system - inventory size will automagically returned to it's previous state, so there is no abuse of playable RPG.
|
||||
end
|
||||
|
||||
if count > 40 then
|
||||
Utils.action_warning(
|
||||
'{Crafting}',
|
||||
player.name .. ' canceled their craft of item ' .. event.recipe.name .. ' of total count ' .. count .. '.'
|
||||
player.name .. ' canceled their craft of item ' .. event.recipe.name .. ' of total count ' .. count .. ' in raw items (' .. canceledCraftingQueueStacks .. ' slots)' -- Corrected message
|
||||
)
|
||||
if not this.cancel_crafting_history[player.index] then
|
||||
this.cancel_crafting_history[player.index] = {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user