Tsuey / L4D2-Community-Update

Help us shape the potential future of L4D2 vanilla.
70 stars 23 forks source link

EndScriptedMode calls round_end game event #428

Open eyal282 opened 1 year ago

eyal282 commented 1 year ago

Description

I hope it's the same in Sourcemod as it is in VScript, because it was only tested in Sourcemod, but EndScriptedMode end of round prevent function calls round_end. This is very annoying and I would appreciate a fix.

Reproduction steps

I imagine it happens on the OnGameEvent_round_end because it should be identical to Sourcemod.

Additional files

No response

alexiscoutinho commented 1 year ago

I really don't understand what's the problem here.

eyal282 commented 1 year ago

I really don't understand what's the problem here.

There's a function called EndScriptedMode, which is a function, as stupid as its name is, prevents the ending of a round. Used to be used in Tank Run and Dash, but after Tank Run stopped being bad, it's only used in Dash. When a round is prevented from being over, round_end event should not be called.

alexiscoutinho commented 1 year ago

Oh, I see, lol.

Treescrub commented 12 months ago

Can confirm it happens with VScript, returning -1 from EndScriptedMode will still cause the round_end event to fire.

Treescrub commented 12 months ago

I'm not so sure this is really a bug. Preventing the round from ending doesn't seem to be the purpose of EndScriptedMode, rather it seems that it's meant to modify how the round ends.

Shadowysn commented 12 months ago

round_end contains parameters that include a reason string, if any of these parameters are modified by EndScriptedMode other mods can check for the reason and decide to fire their code or not. Though this is obscure and wouldn't fix the problem for already-coded scripts that use round_end generally.

eyal282 commented 12 months ago

I'm not so sure this is really a bug. Preventing the round from ending doesn't seem to be the purpose of EndScriptedMode, rather it seems that it's meant to modify how the round ends.

There was a change in Tank Run very very recently that used this to prevent round from ending. If EndScriptedMode is used to prevent round from ending, it should not fire round_end event until the round ends.

Treescrub commented 12 months ago

The bug seems to be that returning an invalid scenario end reason from EndScriptedMode prevents the round from ending properly, not that round_end is fired even when EndScriptedMode prevents the round from ending. IMO it would be good to allow mutations to control when rounds end, but using EndScriptedMode this way seems to be unintended and round_end being fired is just a side effect.

Best options to allow mutations to prevent the round from ending would probably either be to do nothing but pretend to have handled round ending if int returned from EndScriptedMode is negative (or a reason that isn't handled normally). Or add a new callback specifically to prevent round ending.

eyal282 commented 11 months ago

The bug seems to be that returning an invalid scenario end reason from EndScriptedMode prevents the round from ending properly, not that round_end is fired even when EndScriptedMode prevents the round from ending. IMO it would be good to allow mutations to control when rounds end, but using EndScriptedMode this way seems to be unintended and round_end being fired is just a side effect.

Best options to allow mutations to prevent the round from ending would probably either be to do nothing but pretend to have handled round ending if int returned from EndScriptedMode is negative (or a reason that isn't handled normally). Or add a new callback specifically to prevent round ending.

EndScriptedMode is literally being used by official mutations to block scenario from ending.

Treescrub commented 11 months ago

EndScriptedMode is literally being used by official mutations to block scenario from ending.

Which mutations are using it?

eyal282 commented 11 months ago

EndScriptedMode is literally being used by official mutations to block scenario from ending.

Which mutations are using it?

Old Tank Run ( "old" = very new, happened under 3 months ago )