freghar / arma-additions

Other
4 stars 0 forks source link

Transform Kill player on JIP module into something more useful #14

Open freghar opened 3 years ago

freghar commented 3 years ago

Make a new, better, simpler "One life" module, without all the teleport-auto-rejoin-gear-restoration logic and death/unconsciousness detection.

Essentially,

  1. Mission has respawn enabled (somewhere) so lobby slots don't disappear
  2. The module sets setPlayerRespawnTime to something insanely high, actually preventing respawn
  3. The module adds (somehow, Killed EH?) a spectator on player death Actually just add the spectator respawn template, it is weird if the player actually respawns (can control unit while having spectator UI), but with high setPlayerRespawnTime it works just like the no-respawn spectator
  4. The module also kills any new JIPed players, spawning spectator (I remember this being fucky, we'll see) the respawn template will take care of this, though do test it rigorously

In addition, the module kills only players who have 0 "JIP lives". All players start with 0 JIP lives (added to some hashmap or list), meaning non-JIPers have only the current life, JIPers are automatically killed (without a life). Whenever a player JIPs, the counter is checked and if >0, it's decremented (check+decrement as unscheduled, to prevent conflict with scripts accessing it) and the player is allowed to JIP through and spawn. Respawn is never allowed (setPlayerRespawnTime is always high), if a player with >0 lives wants to respawn, they need to go to lobby and JIP. This is to prevent breakage of the spectator logic on death (also they might want to spectate for a bit).

Further, a Zeus Enhanced custom module can be added that uses Dynamic Dialogs to list players (COMBO) with their lives directly in the string, like Freghar (2), with a second control, SLIDER with 0 decimal places being used to specify the new amount of lives. This way, a player getting "Arma'd" can be pardoned (by assigning 1 more life).

Perhaps also have functions that

Maybe also have the starting amount of lives configurable in Eden (ie. 3 JIP lives for any player, whether they start the mission as non-JIP or JIP later on).

PS: Alternatively, index players by steamid and log only their last used name, to prevent people rejoining with different names / profiles.

PPS: Have a "give new player an extra life" checkbox that allows a never-seen-before JIPed player to spawn, but only once. This makes it possible for late-joiners to enter a one-life game and makes the system more fair.

PPPS: Check if the ACE spectator respawn template actually works. If not, create a custom one under CfgRespawnTemplates, ... or just see if the Killed EH is fine to use without a respawn template. After all, the Spectator template just calls BIS_fnc_respawnSpectator as onPlayerKilled / onPlayerRespawn.

milivojm commented 3 years ago

Interesting concept, might actually finally enable one life or X life missions. Right now think we all gave up on it because Arma connection issues.

This could also be useful for PvP since AFAIK we run those missions without respawn.

I presume JIP lives data would be on the server only?

One extra interesting feature would be to allow MM to dynamically reward player(s) for completing an objective (PvP, PvEvP game modes) with extra life.

freghar commented 3 years ago

I presume JIP lives data would be on the server only?

Yes. Any modifications would be done via remoteExec running unscheduled code to read+modify+write.

One extra interesting feature would be to allow MM to dynamically reward player(s) for completing an objective (PvP, PvEvP game modes) with extra life.

Hence the functions I mentioned, meant to be used by MMs:

Perhaps also have functions that

  • increment lives by some number, in an atomic/safe manner
  • set the amount of lives to some value

Maybe also an optional checkbox feature to give disconnected people an extra life (disconnect while alive and not dead/unconscious), when playing with people who we trust wouldn't try to cheat the system.

freghar commented 3 years ago

FTR; If I need to wait for the loading screen to disappear before spawning spectator and if PreloadFinished doesn't work reliably in MP (as past experience suggests), maybe give https://github.com/CBATeam/CBA_A3/wiki/Loading-Screen-Event-Handler a shot.

freghar commented 3 years ago

A less convoluted system would be simply adjusting respawn timeout + spawning/destroying spectator manually ... parameters for spectators (1st/3rd person only, etc.) are passed via function args and could be customized as module parameters.

Basically, everywhere on join:

waitUntil { !isNull player };
setPlayerRespawnTime 10000000;  // small enough to not trigger error
player addEventHandler ["Respawn", {
    setPlayerRespawnTime 10000000;   // respawn happens by setting this to 0, re-set it after respawn finishes
}];
player addEventHandler ["Killed", {
    ["Initialize", [player]] call BIS_fnc_EGSpectator;  // add custom args
}];

additionally, if JIPing,

waitUntil { !isNil "a3aa_preload_finished" };  // because spectator *hates* being opened on loading screen
moveOut player;
player setDamage [1, false];  // do this before setPosASL for spectator camera to remain where player was
[player, {
    _this enableSimulationGlobal false;
    _this setPosASL [0,0,-10000];
}] remoteExec ["call", 2];

A "pardon" zeus action can then do remoteExec on the target client:

["Terminate", [player]] call BIS_fnc_EGSpectator;
setPlayerRespawnTime 0;

This basically closes down the spectator and instantly respawns the player.

No custom database of lives, nothing complicated, no "VISCOM" station needed, all dead people are on the same ACRE2 net that Zeus can switch to temporarily to relay a message.

The critical part here is to hide scoreboard and respawn counter (in MP respawn settings in 3DEN), otherwise it will show in the spectator (as -:--:-- since the time is >24h) in the center of the screen, annoyingly.

... Also maybe set some variable on the JIP-killed corpse to delete it on respawn, to not pollute the [0,0] point with corpses.

Also have some easy-to-use function for pardoning from a debug console, as the admin loses zeus when dead.

// <something> can be dead player object, string with player name, or clientOwner
// - in case of player name/owner, just iterate `allPlayers` for `!alive` and use `name` / `owner`
<something> call a3aa_ee_onelife_pardon;
milivojm commented 3 years ago

Personally, think the 1st concept was more robust and "cleaner" because it can be incorporated into some X life scenario.

freghar commented 3 years ago

Personally, think the 1st concept was more robust and "cleaner" because it can be incorporated into some X life scenario.

Not really cleaner, it would have used the same underlying principle, but further require correct spectator checkbox in MP respawn settings (which might not have worked, needing the same spectator hack), and anybody waiting for pardon would have to go back to lobby and JIP.

Also, the second version has a realistic chance of being implemented this year. :)

Regarding N-life missions, extra pardon logic can be pretty easily layered by the mission on top of the 2nd concept, whether that's N shared lives per side (tickets), or N lives per each player, or whatever else.