On the api I saw this: So after testing this on a corpse, it returned a variation, meaning the entity uses graphics variations.
Now I made character corpses that have the same graphics of a dead biter, again, using the same graphics variations. After the biter died, I create a character corpse, place it on the same position and give it the same variation as shown in the code below:
Code: Select all
script.on_event(defines.events.on_tick, function()
local ECE_tick_data = global.ECE_data[game.tick]
if ECE_tick_data then
for _, unitData in pairs(ECE_tick_data) do
local corpse = unitData.surface.find_entities_filtered{
name = unitData.name,
area = unitData.area,
limit = 1,
}[1]
if corpse then
local corpseExtended = unitData.surface.create_entity{
name = corpse.name .. "-extended",
position = corpse.position,
}
corpseExtended.graphics_variation = corpse.graphics_variation
end
end
end
end)
script.on_event(defines.events.on_entity_died, function(event)
local tick = game.tick + 50 -- 1/.02
local entity = event.entity
local entityPos = entity.position
if not global.ECE_data[tick] then global.ECE_data[tick] = {} end
table.insert(global.ECE_data[tick], {
name = entity.name .. "-corpse",
surface = entity.surface,
area = {
{x = entityPos.x-.5, y = entityPos.y-.5},
{x = entityPos.x+.5, y = entityPos.y+.5},
},
})
end)
I tried with another map generation, another seed and got the following result: As you can see, the character corpses (bottom row) are the same in both pictures, but the regular corpse ones are different. In fact, the regular corpses again used only 4 random variations, but again, randomly spread across all variations.
So what I think the bug is, is that vanilla is not using all variations, and the graphics_variation property is returning the wrong ones.
I also thought the variations where random becose they are shuffeled on a specific frame (i saw something in the prototypes about this), so to make sure I double tested this with setting the variation again, after the animation was done, which had the same effect as before:
Code: Select all
script.on_nth_tick(120, function()
for variant = 1, 16 do
game.surfaces[1].find_entities_filtered{
name = "small-biter-corpse",
position = {x = 5*variant, y = 0},
}[1].graphics_variation = variant
end
end)
EDIT: the forums didn't allow me to upload the mod, I've uploaded it externaly (available 7 days, I can upload it again if needed)
https://we.tl/t-DKcyjmAXzn
kind regards,
lovely_santa