I'm writing a new universal "Game Over" Zscript Plugin.
The idea behind this is that I found out that I prefer having more keys set to let me "continue" my game, instead of just the use key.
The script would load the last saved game if I die, or restart the level.
This is what I have so far:
Code: Select all
class GameOver : EventHandler {
static const name commands[] =
{
"+use",
"+attack",
"+altattack",
"+jump"
};
override bool InputProcess(InputEvent e) {
if (e.Type == InputEvent.Type_KeyDown) {
SendNetworkEvent("keypress", e.KeyScan);
}
return false;
}
override void NetworkProcess(ConsoleEvent e) {
if (e.Name == "keypress") {
PlayerInfo player = players[consoleplayer];
PlayerPawn playerPawn = player.mo;
int key1, key2;
for (int i = 0; i < commands.size(); i++)
{
[key1, key2] = Bindings.GetKeysForCommand(commands[i]);
if ((key1 && key1 == e.Args[0]) || (key2 && key2 == e.Args[0]))
{
if (player.playerstate == PST_DEAD) {
player.playerstate = PST_REBORN;
}
}
}
}
}
}
Thanks in advance!