Aleph-One-Marathon / alephone

Aleph One is the open source continuation of Bungie’s Marathon 2 game engine.
https://alephone.lhowon.org/
GNU General Public License v3.0
655 stars 99 forks source link

Targeted player:print messages in Lua only display for host in film replays #465

Closed aaronfreed closed 10 months ago

aaronfreed commented 10 months ago

Easily confirmed by opening a film of a network game, switching to any perspective besides the host’s, then typing the following code into the console:

for p in Players() do p:print(p) end

This will direct a message to each player in the game containing only ‘player x’, where x is their player id. No matter whose perspective you’re viewing, the game will print ‘player 0’. IMO, this is an engine bug; while there’s probably no way to make perspective switching not behave weirdly in live gameplay, ISTM that films should show messages to the player whose perspective you’re viewing, rather than messages to the host. It might also make sense to make a note of the discrepancy somewhere in the Lua documentation.

Edit: I should note that you can probably use a very ugly hack to get around this along the lines of:

function print_player_message(p, m)
    if Game.replay and Players.local_player.viewed_player == p
        then Players.print(m)
    else
        p:print(m)
    end
end

Then, instead of Players[x]:print(m), you’d use print_player_message(Players[x], m). I think this would work, but it’s ugly and hacky and I hate it.

aaronfreed commented 10 months ago

…ah, of course this is what Game.nonlocal_overlays is for. never mind then :v