Steps to reproduce:
1. launch base game, no mods.
2. start a new save, all default settings.
3. run the below command in chat console:
Code: Select all
/c script.on_nth_tick(10, function()
    local player = game.players[1]
    local surface = player.surface
    local enemy = surface.find_nearest_enemy{
        position = player.position,
        max_distance = 50,
        force = player.force,
    }
    if not enemy then return end
    local rocket = surface.create_entity{
        name = "rocket",
        position = player.position,
        direction = player.character.direction,
        force = player.force,
        target = enemy,
        source = player.character,
        speed = 1/25,
        max_range = 50,
        player = player,
        character = player.character,
    }
end)
script.on_event(defines.events.on_entity_died, function(event) 
    game.print(event.entity.name .. " killed by " .. ((event.cause and event.cause.name) or "unknown"))
end)
5. Since the source of the rocket projectile is set as the player character, I would expect the character to be the source of the damage when an enemy dies, but instead it is always "unknown" (event.cause is nil).

