[0.17] corpse graphics_variation inconsistent

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
lovely_santa
Filter Inserter
Filter Inserter
Posts: 495
Joined: Sat Feb 18, 2017 9:41 pm
Contact:

[0.17] corpse graphics_variation inconsistent

Post by lovely_santa »

Hi

On the api I saw this:
api call
api call
unknown.png (8.91 KiB) Viewed 1387 times
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 didn't delete the old (regular) corpse yet, to make sure I did this right. I quickly noticed the corpse and character corpse did not mach graphics at all. To do some testing, I created 16 corpses and character corpses, set there variation and started comparing them as some are shown in the picture below:
all variations 1
all variations 1
unknown.png (5.1 MiB) Viewed 1387 times
I quickly noticed that they aren't the same, in fact, I tried maching the character-corpse variations onto the vanilla variations, and I quicly realised the vanilla variations are only 4 different variations, in a random order. (instead of all 16).

I tried with another map generation, another seed and got the following result:
all variations 2
all variations 2
unknown.png (2.74 MiB) Viewed 1387 times
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)
I've attached the mod in question that generates all the character corpses in the prototype stage, and then generates the two rows of corpses on_init as shown in the code above.

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
You can find all my mods on the mod portal. Also helping on Arch666Angel's mods.
Image

Rseding91
Factorio Staff
Factorio Staff
Posts: 12224
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17] corpse graphics_variation inconsistent

Post by Rseding91 »

The character corpse has special variation logic for selecting the variation to match the armor the player died with which is going to mess with any logic you're trying to do.

Additionally corpses have multiple variations depending on the entity they're meant to be showing (worms, spawners, biters, and so on).
If you want to get ahold of me I'm almost always on Discord.

User avatar
lovely_santa
Filter Inserter
Filter Inserter
Posts: 495
Joined: Sat Feb 18, 2017 9:41 pm
Contact:

Re: [0.17] corpse graphics_variation inconsistent

Post by lovely_santa »

Rseding91 wrote:
Sun Mar 24, 2019 10:11 pm
The character corpse has special variation logic for selecting the variation to match the armor the player died with which is going to mess with any logic you're trying to do.
As I saw, the different items in the player defines the looks, selecting different picture sets. Inside a picture you have seperate frames that are the variations for the character corpse, the base game has 2 variations for each 'look' of the player, for example shown in the picture below:
level1_dead.png
level1_dead.png (5.57 KiB) Viewed 1364 times
That said, I only have 1 'look' defined, and the 16 variations I am creating are always the same 16 variations, on all maps, and in order of the frames I define them. If I take this as reference, the regular corpses don't use 16 variations. In fact, they have 16 variations defined, but when I set all the 16 variations, I only count 5 different sprites used.

Example: I have a 'new' player without anything in the inventory, when that character dies, it takes the first set of picture variations as defined in the prototype:

Code: Select all

    armor_picture_mapping =
    {
      --nil = 1,
      ["light-armor"] = 2,
      ["heavy-armor"] = not data.is_demo and 2 or nil,
      ["modular-armor"] = not data.is_demo and 3 or nil,
      ["power-armor"] = not data.is_demo and 3 or nil,
      ["power-armor-mk2"] = not data.is_demo and 3 or nil
    }
As the picture above already shows, there are two variations. With using command /c game.player.selected.graphics_variation = 1/2 I can swap between both variations.

When I insert power armor into my player and do the same, it selects the 3rd set of corpse pictures, and again, with setting variation to 1 or 2 I can swap between both.
Rseding91 wrote:
Sun Mar 24, 2019 10:11 pm
Additionally corpses have multiple variations depending on the entity they're meant to be showing (worms, spawners, biters, and so on).
Each entity has there own corpse, small-biter -> small-biter-corpse etc. Each corpse has 16 variations (aka directions) set, It is these 16 variations I added to the character corpse.

The issue is that the regular corpse type entity does not use 16 variations, but for example in the first picture, the corpses only used variation 1, 2, 3, 4 and 16. The other variations (5-15) where duplicates of these 5. On a new map gen there are 5 other variations, and the other 11 where duplicates of these ones.
  • For regular biter corpses (type "corpse"), when I generate all 16 different variations, am I supposed to see all 16 different animation/sprites?
  • When making a map with a small-biter-corpse with variation 1, it is not the same as on another map with the same variation. Am I missing some behaviour here? It has still the same prototype...
  • Or am I missing something in the behaviour of the character corpse, because this is every time the same in comparison to the regular corpses?
Kind regards
lovely_santa
You can find all my mods on the mod portal. Also helping on Arch666Angel's mods.
Image

posila
Factorio Staff
Factorio Staff
Posts: 5147
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.17] corpse graphics_variation inconsistent

Post by posila »

Hello, the issue is graphics_variation is read only on the corpse entity. I'll make it writeable for next release.

Other than that, there is no issue. Biter corpses have 16 directions and 4 variations of dying animation, where the variations are made up by playing 7 frames from direction the biter had at moment of its death and then switching to random direction that is compatible with the original one. That is what the direction_shuffle and shuffle_directions_at_frame prototype definitions do. In 0.16 biter corpses had just single variation (and 16 directions).

Note: corpses have 4 different variation variables for 4 different layers on them, so they are not very compatible with graphics_variation property that was added mainly for controlling variations on simple-entity

Post Reply

Return to “Resolved Problems and Bugs”