-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced vanilla ticket handling with bespoke stuff. (#152)
Specified isCall for all respawn modes. Added new timed-tickets mode. IDK why it was missing.
- Loading branch information
Showing
11 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "../macros.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "macros.hpp" | ||
|
||
/* | ||
CAFE Tickets on-killed script. | ||
Disable respawn if no tickets remain, then wait until any tickets are added to re-enable respawn. | ||
*/ | ||
|
||
params ["_oldUnit", "_killer", "_respawn", "_respawnDelay"]; | ||
|
||
// Wait until a ticket is gained or player is alive. Re-enable respawn if ticket is gained. | ||
// If player does not respawn and tickets run out again, re-disable respawn and await further tickets. | ||
f_fnc_respawn_tickets_waitForTickets = | ||
{ | ||
[ | ||
// Condition | ||
{ | ||
(alive player) or {([player, 0, true] call bis_fnc_respawnTickets) > 0} | ||
}, | ||
|
||
// Script | ||
{ | ||
if (alive player) exitWith {}; | ||
|
||
DEBUG_FORMAT1_LOG("[RESPAWN-2] %1 has tickets now - removing the wait.", player) | ||
setPlayerRespawnTime 1; | ||
[] call f_fnc_respawn_tickets_waitForNoTickets; | ||
} | ||
|
||
] call CBA_fnc_waitUntilAndExecute; | ||
}; | ||
|
||
// Wait until all tickets are lost or player is alive. Re-disable respawn if tickets are lost. | ||
// If player does not respawn and tickets are gained, re-enable respawn and await further ticket depletion. | ||
f_fnc_respawn_tickets_waitForNoTickets = | ||
{ | ||
[ | ||
// Condition | ||
{ | ||
(alive player) or {([player, 0, true] call bis_fnc_respawnTickets) <= 0} | ||
}, | ||
|
||
// Script | ||
{ | ||
if (alive player) exitWith {}; | ||
|
||
DEBUG_FORMAT1_LOG("[RESPAWN-2] %1 has no more tickets now - re-applying the wait.", player) | ||
setPlayerRespawnTime 1e10; | ||
[] call f_fnc_respawn_tickets_waitForTickets; | ||
} | ||
|
||
] call CBA_fnc_waitUntilAndExecute; | ||
}; | ||
|
||
|
||
// Check if tickets are available, and poll for ticket gain or ticket depletion accordingly. | ||
private _remainingTickets = [player, 0, true] call bis_fnc_respawnTickets; | ||
|
||
if (_remainingTickets > 0) then | ||
{ | ||
DEBUG_FORMAT2_LOG("[RESPAWN-2] %1 has %2 tickets remaining - not enforcing a wait.", player, _remainingTickets) | ||
[] call f_fnc_respawn_tickets_waitForNoTickets; | ||
} | ||
else | ||
{ | ||
DEBUG_FORMAT2_LOG("[RESPAWN-2] %1 has %2 tickets remaining - enforcing a wait.", player, _remainingTickets) | ||
setPlayerRespawnTime 1e10; | ||
[] call f_fnc_respawn_tickets_waitForTickets; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "macros.hpp" | ||
|
||
/* | ||
CAFE Tickets on-respawn script. | ||
Remove a ticket from the most-local non-zero ticket pool to the player. | ||
*/ | ||
|
||
params [["_newUnit", objNull, [objNull]], "_oldUnit", "_respawn", "_respawnDelay"]; | ||
|
||
if (!isPlayer _newUnit && !isNull _newUnit) exitWith | ||
{ | ||
["Attempting to use 'CAFE_Tickets' on AI unit '%1' - can be used only on players.", _newUnit] call BIS_fnc_error; | ||
}; | ||
|
||
if (isNil 'f_var_respawn_tickets_hadFirstSpawn') exitWith | ||
{ | ||
DEBUG_FORMAT1_LOG("[RESPAWN-2] %1 spawning for the first time - not removing a ticket.", _newUnit) | ||
f_var_respawn_tickets_hadFirstSpawn = true; | ||
}; | ||
|
||
DEBUG_FORMAT1_LOG("[RESPAWN-2] %1 spawning - removing a ticket.", _newUnit) | ||
[_newUnit, -1, true] call bis_fnc_respawnTickets; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class CAFE_Tickets | ||
{ | ||
onPlayerKilled = "components\respawn\tickets\onPlayerKilled.sqf"; | ||
onPlayerRespawn = "components\respawn\tickets\onPlayerRespawn.sqf"; | ||
isCall = 1; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters