-
Notifications
You must be signed in to change notification settings - Fork 109
Added DMS_fnc_TargetsKilledPercent function, to check % of alive bots #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ravenger2709
wants to merge
15
commits into
Defent:master
Choose a base branch
from
Ravenger2709:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a224f8d
Added DMS_fnc_TargetsKilledPercent function, to check alive bots and …
Ravenger2709 4cd86d0
FIX - Added TargetsKilledPercent class to config.cpp
Ravenger2709 fc0c835
delete debug logging for new function
Ravenger2709 f39bf0d
changed logic on count living units and save it count on mission start
Ravenger2709 c500a91
have not idea now ho to fix it
Ravenger2709 621e4bd
forgotten commit
Ravenger2709 9acced3
another try
Ravenger2709 0b27f36
and another try...
Ravenger2709 d6880f1
lost variable
Ravenger2709 8781e12
Changed global vars to local, changed DMS_fnc_MissionSuccessState to …
Ravenger2709 8c41155
turn off debug messages
Ravenger2709 fab3d7e
small fix for Total killed units
Ravenger2709 f834f39
comment debug messages
Ravenger2709 8831402
now bots in turrets and vehicle counted too
Ravenger2709 3885c24
turn off debug messages
Ravenger2709 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
127 changes: 53 additions & 74 deletions
127
@ExileServer/addons/a3_dms/scripts/fn_MissionSuccessState.sqf
This file contains hidden or 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 |
---|---|---|
@@ -1,95 +1,74 @@ | ||
/* | ||
DMS_fnc_MissionSuccessState | ||
Created by eraser1 | ||
DMS_fnc_MissionSuccessState | ||
Created by eraser1 | ||
Modified by Ravenger2709 | ||
|
||
Usage: | ||
[ | ||
[_completionType1,_completionArgs1,_isAbsoluteCondition], | ||
[_completionType2,_completionArgs2,_isAbsoluteCondition], | ||
... | ||
[_completionTypeN,_completionArgsN,_isAbsoluteCondition] | ||
] call DMS_fnc_MissionSuccessState; | ||
Usage: | ||
[ | ||
[_completionType1,_completionArgs1,_isAbsoluteCondition], | ||
[_completionType2,_completionArgs2,_isAbsoluteCondition], | ||
... | ||
[_completionTypeN,_completionArgsN,_isAbsoluteCondition] | ||
] call DMS_fnc_MissionSuccessState; | ||
*/ | ||
|
||
if !(_this isEqualType []) exitWith | ||
{ | ||
diag_log format ["DMS ERROR :: DMS_fnc_MissionSuccessState called with invalid parameter: %1",_this]; | ||
if !(_this isEqualType []) exitWith { | ||
diag_log format ["DMS ERROR :: DMS_fnc_MissionSuccessState called with invalid parameter: %1",_this]; | ||
}; | ||
|
||
private _success = true; | ||
private _exit = false; | ||
|
||
{ | ||
if (_exit) exitWith {}; | ||
|
||
try | ||
{ | ||
if !(_x params | ||
[ | ||
"_completionType", | ||
"_completionArgs" | ||
]) | ||
then | ||
{ | ||
diag_log format ["DMS ERROR :: DMS_fnc_MissionSuccessState has invalid parameters in: %1",_x]; | ||
throw "ERROR"; | ||
}; | ||
if (_exit) exitWith {}; | ||
|
||
try { | ||
if !(_x params ["_completionType", "_completionArgs"]) then { | ||
diag_log format ["DMS ERROR :: DMS_fnc_MissionSuccessState has invalid parameters in: %1",_x]; | ||
throw "ERROR"; | ||
}; | ||
|
||
private _absoluteWinCondition = _x param [2, false, [true]]; | ||
private _absoluteWinCondition = _x param [2, false, [true]]; | ||
|
||
if (!_success && {!_absoluteWinCondition}) then | ||
{ | ||
throw format ["Skipping completion check for condition |%1|; Condition is not absolute and a previous condition has already been failed.",_x]; | ||
}; | ||
if (!_success && {!_absoluteWinCondition}) then { | ||
throw format ["Skipping completion check for condition |%1|; Condition is not absolute and a previous condition has already been failed.",_x]; | ||
}; | ||
|
||
if (DMS_DEBUG) then { | ||
(format ["MissionSuccessState :: Checking completion type ""%1"" with argument |%2|. Absolute: %3",_completionType,_completionArgs,_absoluteWinCondition]) call DMS_fnc_DebugLog; | ||
}; | ||
|
||
if (DMS_DEBUG) then | ||
{ | ||
(format ["MissionSuccessState :: Checking completion type ""%1"" with argument |%2|. Absolute: %3",_completionType,_completionArgs,_absoluteWinCondition]) call DMS_fnc_DebugLog; | ||
}; | ||
|
||
switch (toLower _completionType) do | ||
{ | ||
case "kill": | ||
{ | ||
_success = _completionArgs call DMS_fnc_TargetsKilled; | ||
}; | ||
/* | ||
case "killpercent": | ||
{ | ||
_success = _completionArgs call DMS_fnc_TargetsKilledPercent;//<---TODO | ||
}; | ||
*/ | ||
case "playernear": | ||
{ | ||
_success = _completionArgs call DMS_fnc_IsPlayerNearby; | ||
}; | ||
case "external": // This is a special completion type. It is intended to be a flag for people who want to control mission completion using _onMonitorStart and _onMonitorEnd through array manipulation. You probably don't want to use this unless you know what you're doing. | ||
{ | ||
_success = _completionArgs; | ||
}; | ||
default | ||
{ | ||
diag_log format ["DMS ERROR :: Invalid completion type (%1) with args: %2",_completionType,_completionArgs]; | ||
throw "ERROR"; | ||
switch (toLower _completionType) do { | ||
case "kill": { | ||
_success = _completionArgs call DMS_fnc_TargetsKilled; | ||
}; | ||
case "killpercent": { | ||
private _initialUnitCount = _completionArgs select 0; | ||
private _args = _completionArgs select [1, count _completionArgs - 1]; //Look for bandit.sqf mission for "killpercent" condnition example. | ||
_success = [_initialUnitCount, _args] call DMS_fnc_TargetsKilledPercent; | ||
}; | ||
case "playernear": { | ||
_success = _completionArgs call DMS_fnc_IsPlayerNearby; | ||
}; | ||
case "external": { | ||
_success = _completionArgs; | ||
}; | ||
default { | ||
diag_log format ["DMS ERROR :: Invalid completion type (%1) with args: %2",_completionType,_completionArgs]; | ||
throw "ERROR"; | ||
}; | ||
}; | ||
}; | ||
|
||
|
||
if (_success && {_absoluteWinCondition}) then | ||
{ | ||
_exit = true; | ||
throw format ["Mission completed because of absolute win condition: %1",_x]; | ||
}; | ||
} | ||
catch | ||
{ | ||
if (DMS_DEBUG) then | ||
{ | ||
(format ["MissionSuccessState :: %1",_exception]) call DMS_fnc_DebugLog; | ||
}; | ||
}; | ||
if (_success && {_absoluteWinCondition}) then { | ||
_exit = true; | ||
throw format ["Mission completed because of absolute win condition: %1",_x]; | ||
}; | ||
} catch { | ||
if (DMS_DEBUG) then { | ||
(format ["MissionSuccessState :: %1",_exception]) call DMS_fnc_DebugLog; | ||
}; | ||
}; | ||
} forEach _this; | ||
|
||
_success; |
50 changes: 50 additions & 0 deletions
50
@ExileServer/addons/a3_dms/scripts/fn_TargetsKilledPercent.sqf
This file contains hidden or 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,50 @@ | ||
/* | ||
DMS_fnc_TargetsKilledPercent | ||
Created by Ravenger2709 | ||
|
||
Usage: | ||
[ | ||
_initialUnitCount, | ||
_unit, | ||
_group, | ||
_object | ||
] call DMS_fnc_TargetsKilledPercent; | ||
|
||
Will accept non-array argument of group, unit, or object. | ||
*/ | ||
|
||
if (_this isEqualTo []) exitWith { | ||
diag_log "DMS ERROR :: Calling DMS_TargetsKilled with empty array!"; | ||
}; | ||
|
||
private _initialUnitCount = _this select 0; | ||
private _args = _this select [1, count _this - 1]; | ||
private _killedpercent = false; | ||
|
||
// Get the kill percent value from config | ||
private _killPercent = DMS_AI_KillPercent; | ||
//diag_log format ["DMS DEBUG :: Kill percent value: %1", _killPercent]; | ||
//diag_log format ["DMS DEBUG :: Initial unit count: %1", _initialUnitCount]; | ||
|
||
// Calculate the acceptable number of killed units based on initial unit count | ||
private _unitsThreshold = ceil(_killPercent * _initialUnitCount / 100); | ||
//diag_log format ["DMS DEBUG :: Units threshold (killed units): %1", _unitsThreshold]; | ||
|
||
// Get all living AI units | ||
private _allUnits = _args call DMS_fnc_GetAllUnits; | ||
private _totalUnits = count _allUnits; | ||
//diag_log format ["DMS DEBUG :: Total living units: %1", _totalUnits]; | ||
|
||
// Calculate the number of killed units | ||
private _killedUnits = if (_initialUnitCount - _totalUnits > 0) then {_initialUnitCount - _totalUnits} else {0}; | ||
//diag_log format ["DMS DEBUG :: Total killed units: %1", _killedUnits]; | ||
|
||
// Check if the number of killed units is greater than or equal to the threshold | ||
if (_killedUnits >= _unitsThreshold) then { | ||
_killedpercent = true; | ||
//diag_log "DMS DEBUG :: Kill percent condition met"; | ||
} else { | ||
//diag_log "DMS DEBUG :: Kill percent condition not met"; | ||
}; | ||
|
||
_killedpercent; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.