-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dragging - Corpse carrying and dragging - continued (#9273)
Co-authored-by: Dystopian <sddex@ya.ru> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: Joko <hoffman.jonas95@gmail.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com> Co-authored-by: BaerMitUmlaut <baermitumlaut@users.noreply.github.com> Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
- Loading branch information
1 parent
e560036
commit e2335c9
Showing
21 changed files
with
348 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: BaerMitUmlaut, johnb43 | ||
* Creates a draggable / carryable clone of a dead unit. | ||
* | ||
* Arguments: | ||
* 0: Unit dragging/carrying <OBJECT> | ||
* 1: Dead unit <OBJECT> | ||
* | ||
* Return Value: | ||
* Cloned unit <OBJECT> | ||
* | ||
* Example: | ||
* [player, cursorObject] call ace_dragging_fnc_createClone; | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_unit", "_target"]; | ||
|
||
// Don't sync corpse when a player joins in progress until the corpse is in its proper position | ||
[QGVAR(disableSyncMovedCorpseOnJIP), _target] call CBA_fnc_serverEvent; | ||
|
||
private _posATL = getPosATL _target; | ||
|
||
// Create clone | ||
private _clone = createVehicle [[configOf _target >> QGVAR(cloneClass), "TEXT", QGVAR(clone)] call CBA_fnc_getConfigEntry, _posATL, [], 0, "CAN_COLLIDE"]; | ||
|
||
// Claim the clone | ||
[_unit, _clone] call EFUNC(common,claim); | ||
|
||
// Move unit -10 m below terrain in order to hide it and remove its inventory access | ||
_posATL set [2, -10]; | ||
|
||
// Corpse is desynced, but it doesn't matter here | ||
_target setPosATL _posATL; | ||
|
||
// Hide unit until it can be moved below terrain | ||
private _isObjectHidden = isObjectHidden _target; | ||
|
||
if (!_isObjectHidden) then { | ||
[QEGVAR(common,hideObjectGlobal), [_target, true]] call CBA_fnc_serverEvent; | ||
}; | ||
|
||
// Prevents unit from falling when below terrain | ||
private _simulationEnabled = simulationEnabled _target; | ||
|
||
if (_simulationEnabled) then { | ||
[QEGVAR(common,enableSimulationGlobal), [_target, false]] call CBA_fnc_serverEvent; | ||
}; | ||
|
||
private _isInRemainsCollector = isInRemainsCollector _target; | ||
|
||
// Make sure corpse isn't deleted by engine's garbage collector | ||
if (_isInRemainsCollector) then { | ||
removeFromRemainsCollector [_target]; | ||
}; | ||
|
||
// Make sure clone has the same wound textures as the corpse | ||
_clone setDamage ((damage _target) min 0.99); // Don't kill the clone | ||
|
||
{ | ||
_clone setHitPointDamage [_x, (_target getHitPointDamage _x) min 0.99]; | ||
} forEach ["HitHead", "HitBody", "HitHands", "HitLegs"]; // Relevant hitpoints | ||
|
||
// Disable all damage | ||
_clone allowDamage false; | ||
_clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden, _simulationEnabled], true]; | ||
|
||
[_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout; | ||
|
||
// Sets the facial expression | ||
[[QGVAR(setCloneFace), [_clone, _target]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; | ||
|
||
// API | ||
[QGVAR(cloneCreated), [_clone, _target]] call CBA_fnc_localEvent; | ||
|
||
[{ | ||
params ["_clone", "_target"]; | ||
|
||
// Remove clone from all zeuses | ||
if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { | ||
[QEGVAR(zeus,removeObjects), [[_clone]]] call CBA_fnc_serverEvent; | ||
}; | ||
|
||
// Release claim on corpse | ||
[objNull, _target] call EFUNC(common,claim); | ||
}, [_clone, _target], 0.25] call CBA_fnc_waitAndExecute; | ||
|
||
// Save which curators had this object as editable | ||
if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { | ||
private _objectCurators = objectCurators _target; | ||
|
||
_target setVariable [QGVAR(objectCurators), _objectCurators, true]; | ||
|
||
if (_objectCurators isEqualTo []) exitWith {}; | ||
|
||
[QEGVAR(zeus,removeObjects), [[_target], _objectCurators]] call CBA_fnc_serverEvent; | ||
}; | ||
|
||
_clone |
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,80 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: BaerMitUmlaut, johnb43 | ||
* Drops a draggable / carryable clone of a dead unit. | ||
* | ||
* Arguments: | ||
* 0: Unit dragging / carrying <OBJECT> | ||
* 1: Clone <OBJECT> | ||
* 2: If unit is in building <BOOL> | ||
* | ||
* Return Value: | ||
* Original unit <OBJECT> | ||
* | ||
* Example: | ||
* [player, cursorObject, false] call ace_dragging_fnc_deleteClone; | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_unit", "_clone", "_inBuilding"]; | ||
|
||
(_clone getVariable [QGVAR(original), []]) params [ | ||
["_target", objNull], | ||
["_isInRemainsCollector", true], | ||
["_isObjectHidden", false], | ||
["_simulationEnabled", true] | ||
]; | ||
|
||
// API | ||
[QGVAR(cloneDeleted), [_clone, _target]] call CBA_fnc_localEvent; | ||
|
||
// Check if unit was deleted | ||
if (!isNull _target) then { | ||
private _posATL = getPosATL _clone; | ||
|
||
if (_inBuilding) then { | ||
_posATL = _posATL vectorAdd [0, 0, 0.05]; | ||
}; | ||
|
||
// Make sure position isn't underground | ||
if (_posATL select 2 < 0.05) then { | ||
_posATL set [2, 0.05]; | ||
}; | ||
|
||
// Move the unit globally (important, as it desyncs the corpse position otherwise) | ||
[QGVAR(moveCorpse), [_target, getDir _unit + 180, _posATL]] call CBA_fnc_globalEvent; | ||
|
||
// Unhide unit | ||
if (!_isObjectHidden) then { | ||
[QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent; | ||
}; | ||
|
||
// Enable simulation again | ||
if (_simulationEnabled) then { | ||
[QEGVAR(common,enableSimulationGlobal), [_target, true]] call CBA_fnc_serverEvent; | ||
}; | ||
|
||
// Detach first to prevent objNull in attachedObjects | ||
detach _clone; | ||
deleteVehicle _clone; | ||
|
||
// Get which curators had this object as editable | ||
if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { | ||
private _objectCurators = _target getVariable [QGVAR(objectCurators), []]; | ||
|
||
if (_objectCurators isEqualTo []) exitWith {}; | ||
|
||
[QEGVAR(zeus,addObjects), [[_target], _objectCurators]] call CBA_fnc_serverEvent; | ||
}; | ||
|
||
if (_isInRemainsCollector) then { | ||
addToRemainsCollector [_target]; | ||
}; | ||
} else { | ||
// Detach first to prevent objNull in attachedObjects | ||
detach _clone; | ||
deleteVehicle _clone; | ||
}; | ||
|
||
_target |
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
Oops, something went wrong.