forked from Savage-Game-Design/Mike-Force
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from dijksterhuis/daccong-ctf-again
DacCong: Fully functioning Capture The Flag system.
- Loading branch information
Showing
11 changed files
with
408 additions
and
98 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
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
62 changes: 62 additions & 0 deletions
62
mission/functions/systems/dac_cong/fn_ctf_broadcast_notify_immediate.sqf
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,62 @@ | ||
/* | ||
File: fn_ctf_broadcast_notify_immediate.sqf | ||
Author: "DJ" Dijksterhuis | ||
Public: No | ||
Description: | ||
Display a notification for all players via a remoteExec callback. | ||
Used to perform a global notification broadcast out to all players | ||
from a specific player locality. | ||
player -> server -> all players | ||
Means the specific player client isn't sending out remoteExec instructions to | ||
all connected players, hopefully mitigating some desync/latency issues and enabling | ||
use to implement a CfgRemoteExec later on. | ||
TODO: Refactor this out to core/helpers? | ||
TODO: Rename? Should be like fn_broadcast_global_notification.sqf | ||
Parameter(s): | ||
- _notificationClass -- class name of the notification to show [STRING] | ||
- _args -- arguments for string replacement in notification description text [ARRAY] | ||
Returns: nothing | ||
Example(s): | ||
// from player locality | ||
// remote execs this script on the server | ||
// which then remoteExecs a notification for all clients (and server, see note below) | ||
["FireInTheHole"] remoteExec ["vn_mf_fnc_ctf_broadcast_notify_immediate", 2]; | ||
// from server locality | ||
["FireInTheHole"] call vn_mf_fnc_ctf_broadcast_notify_immediate; | ||
*/ | ||
|
||
params [ | ||
"_notificationClass", | ||
["_args", []] | ||
]; | ||
|
||
if (!isServer) exitWith { | ||
["ERROR", "Function should only run on server!"] call para_g_fnc_log; | ||
}; | ||
|
||
if (_notificationClass isEqualTo "") exitWith { | ||
["ERROR", format ["Function passed an empty string for _notificationClass! value=%1", _notificationClass]] call para_g_fnc_log; | ||
}; | ||
|
||
if !(_notificationClass isEqualType "testvalue") exitWith { | ||
["ERROR", format ["Function passed non-string for _notificationClass! value=%1", _notificationClass]] call para_g_fnc_log; | ||
}; | ||
|
||
if !(_args isEqualType []) exitWith { | ||
["ERROR", format ["Function passed non-array for _args! value=%1", _args]] call para_g_fnc_log; | ||
}; | ||
|
||
// This *should* be -2 --> but then notifications don't work on player hosted (local development) | ||
// cba to optimise this right now. it'll be fine for the moment. | ||
[_notificationClass, _args] remoteExec ["para_c_fnc_show_notification", 0]; | ||
|
||
nil; |
74 changes: 74 additions & 0 deletions
74
mission/functions/systems/dac_cong/fn_ctf_handle_flag_height_change.sqf
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,74 @@ | ||
/* | ||
File: fn_ctf_handle_flag_height_change.sqf | ||
Author: "DJ" Dijksterhuis | ||
Public: No | ||
Description: | ||
Handle lowering/raising the flag server side. | ||
Parameter(s): | ||
_target -- flag we'll be raising / lowering | ||
_progress -- how many steps | ||
_maxProgress -- total steps | ||
_direction -- -1/+1 for lower/raise | ||
Returns: nothing | ||
Example(s): | ||
// lower | ||
[_target, 4, 24, -1] call vn_mf_fnc_ctf_handle_flag_height_change; | ||
// raise | ||
[_target, 4, 24, 1] call vn_mf_fnc_ctf_handle_flag_height_change; | ||
*/ | ||
|
||
params ["_target", "_progress", "_maxProgress", "_direction"]; | ||
|
||
private _tickRate = 3; | ||
|
||
// only change things every 3 holdAction ticks to ensure we're not spamming clients | ||
// with a massive amount of changes (always a total of 24 ticks) | ||
if ((_progress mod _tickRate ) isEqualTo 0) then { | ||
|
||
private _startingFlagHeight = flagAnimationPhase _target; | ||
private _newHeight = _startingFlagHeight; | ||
|
||
// -1 ---> dac cong lowering the flag | ||
// +1 ---> bluefor raising the flag | ||
|
||
if (_direction isEqualTo -1) then { | ||
|
||
_newHeight = _startingFlagHeight - (_tickRate / _maxProgress); | ||
|
||
if (_newHeight <= 0) exitWith { | ||
|
||
// global command, no need to remoteExec | ||
deleteVehicle _target; | ||
|
||
// broadcast notification out to all players | ||
["DacCongCapturedFlag"] call vn_mf_fnc_ctf_broadcast_notify_immediate; | ||
|
||
// clear the JIP queue for flag height. | ||
remoteExec ["", "JIP_DACCONG_CTF_FLAG_HEIGHT"]; | ||
}; | ||
|
||
} else { | ||
|
||
_newHeight = _startingFlagHeight + (_tickRate / _maxProgress); | ||
|
||
if (_newHeight >= 1) exitWith { | ||
|
||
// broadcast the the new flag height globally with JIP ID (includes server) | ||
[_target, 1] remoteExec ["setFlagAnimationPhase", 0, "JIP_DACCONG_CTF_FLAG_HEIGHT"]; | ||
|
||
// broadcast notification out to all players | ||
["BlueforRaisedFlag"] call vn_mf_fnc_ctf_broadcast_notify_immediate; | ||
|
||
}; | ||
}; | ||
// set the new height globally via JIP queue so new players also see the flag at the right height | ||
// includes changing it on the server | ||
[_target, _newHeight] remoteExec ["setFlagAnimationPhase", 0, "JIP_DACCONG_CTF_FLAG_HEIGHT"]; | ||
}; | ||
|
||
nil; |
Oops, something went wrong.