Skip to content

Instantly share code, notes, and snippets.

@GeorgeDettmer
Last active April 27, 2016 15:56
Show Gist options
  • Save GeorgeDettmer/5b853003f1b14d2b86fa to your computer and use it in GitHub Desktop.
Save GeorgeDettmer/5b853003f1b14d2b86fa to your computer and use it in GitHub Desktop.
Incapacitate at 95% damage and prevent damage until revived/bleedout
.25 spawn {
while {TRUE} do {
_ct = cursorTarget;
_actions = [];
_crew = [];
if (_ct isKindOf "LandVehicle") then {
_crew = crew _ct;
if (_crew isEqualTo []) exitWith {};
{
if (_x getVariable ["#MOSES#incapacitated",true]) then {
_action = _ct addAction [
format["Unload %1",name _x],
{
_vehicle = _this select 0;
_player = _this select 1;
_action = _this select 2;
_unit = _this select 3;
if (isNil '_unit') exitWith {
systemChat "Could not unload _unit==nil";
_vehicle removeAction _action;
};
if !(alive _unit) exitWith {
systemChat "_unit is not alive";
_vehicle removeAction _action;
};
if !(isNull attachedObject _unit) exitWith {
systemChat "_unit attached...";
};
systemChat format["Unloaded %1 from %2",name _unit,getText(configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName")];
_vehicle removeAction _action;
moveOut _unit;
unassignVehicle _unit;
_unit playMoveNow "";
_unit attachTo [player];
},
_x,
1,
false,
true,
"",
'
alive _target && {_target distance player < 5}
'
];
_actions pushBack _action;
};
false
} count _crew;
waitUntil {uiSleep _this; cursorTarget != _ct || !(crew _ct isEqualTo _crew)};
{
_ct removeAction _x;
} count _actions;
};
};
};
player addEventHandler ["AnimStateChanged",{
if (player getVariable ["#MOSES#incapacitated",false]) then {
if (_this select 1 == "incapacitated") exitWith {
player allowDamage false;
player setPosWorld getPosWorld player;
player allowDamage true;
[player,"acts_injuredlyingrifle02_180"] remoteExec ["switchMove",allPlayers];
};
if (_this select 1 != "acts_injuredlyingrifle02_180") then {
player switchMove "acts_injuredlyingrifle02_180"
};
};
}];
player addEventHandler ["HandleDamage",{
if (_this select 2 > 0.95) then {
if !(_this select 0 getVariable ["#MOSES#incapacitated",false]) then {
[true,600] spawn MOSES_fnc_incapacitate;
};
0.95
};
}];
MOSES_fnc_incapacitate = {
if (_this isEqualType true) then {
_this = [_this];
};
params[["_incapacitate",!(player getVariable ["#MOSES#incapacitated",false]),[false]],["_bleedout",300,[0]]];
if (player getVariable ["#MOSES#incapacitated",false] isEqualTo _incapacitate) exitWith {};
player setVariable ["#MOSES#incapacitated",_incapacitate,true];
player setCaptive _incapacitate;
if _incapacitate then [{
if (vehicle player == player) then [{
player allowDamage false;
player spawn {
_rag = "Land_Can_V3_F" createVehicleLocal [0,0,0];
_rag setMass 1e10;
_rag attachTo [_this,[0,0,0],"Spine3"];
_rag setVelocity [0,0,6];
_this allowDamage false;
detach _rag;
uiSleep .1;
deleteVehicle _rag;
_this allowDamage true;
};
{inGameUISetEventHandler [_x,"true"]} forEach ["Action","NextAction","PrevAction"];
MOSES_incapacitate_cameraView = cameraView;
player switchCamera "EXTERNAL";
{player disableCollisionWith _x} count allPlayers;
},{
private _assignedRole = assignedVehicleRole player select 0;
if (_assignedRole == "cargo") then {
player playActionNow "Die";
};
}];
showHUD [false,false,true,true,true,true,true,false];
if !(scriptDone (missionNamespace getVariable ["#MOSES#incapacitate_thread_bleedout",scriptNull])) then {
terminate (missionNamespace getVariable ["#MOSES#incapacitate_thread_bleedout",scriptNull]);
};
MOSES_incapacitate_keyHold = false;
missionNamespace setVariable ["#MOSES#incapacitate_thread_bleedout",_bleedout spawn {
if (isNil "MOSES_incapacitate_ppColor") then {
MOSES_incapacitate_ppColor = ppEffectCreate ["ColorCorrections",1632]
};
if (isNil "MOSES_incapacitate_ppVig") then {
MOSES_incapacitate_ppVig = ppEffectCreate ["ColorCorrections",1633]
};
if (isNil "MOSES_incapacitate_ppBlur") then {
MOSES_incapacitate_ppBlur = ppEffectCreate ["DynamicBlur",525]
};
MOSES_incapacitate_ppColor ppEffectAdjust [1,1,0.15,[0.3,0.3,0.3,0],[0.3,0.3,0.3,0.3],[1,1,1,1]];
MOSES_incapacitate_ppVig ppEffectAdjust [1,1,0,[0.15,0,0,1],[1.0,0.5,0.5,1],[0.587,0.199,0.114,0],[1,1,0,0,0,0.2,1]];
MOSES_incapacitate_ppBlur ppEffectAdjust [0];
{
_x ppEffectCommit 0;
_x ppEffectEnable true;
_x ppEffectForceInNVG true
} forEach [MOSES_incapacitate_ppColor,MOSES_incapacitate_ppVig,MOSES_incapacitate_ppBlur];
_timeToKill = diag_tickTime + _this;
RscRespawnCounter_Custom = _this;
RscRespawnCounter_description = "<t align='center'>AWAITING MEDICAL ATTENTION</t>";
_layer = "MOSES_incapacitate_layer_bleedout";
_layer cutRsc ["RscRespawnCounter","PLAIN"];
waitUntil {
uiSleep .25;
_timePercentageElapsed = 1/_this * (_timeToKill-diag_tickTime);
_brightness = 0.2 + (0.1 * _timePercentageElapsed);
MOSES_incapacitate_ppColor ppEffectAdjust [1,1, 0.15 * _timePercentageElapsed,[0.3,0.3,0.3,0],[_brightness,_brightness,_brightness,_brightness],[1,1,1,1]];
_intensity = 0.6 + (0.4 * _timePercentageElapsed);
MOSES_incapacitate_ppVig ppEffectAdjust [1,1,0,[0.15,0,0,1],[1.0,0.5,0.5,1],[0.587,0.199,0.114,0],[_intensity,_intensity,0,0,0,0.2,1]];
MOSES_incapacitate_ppBlur ppEffectAdjust [0.7 * (1 - _timePercentageElapsed)];
{_x ppEffectCommit 1} forEach [MOSES_incapacitate_ppColor,MOSES_incapacitate_ppVig,MOSES_incapacitate_ppBlur];
bis_keyhold_action = ["EXIT VEHICLE","RESPAWN"] select (player == vehicle player);
if (missionNamespace getVariable ["MOSES_incapacitate_keyHold",false] && {missionNamespace getVariable ["bis_keyhold_action",""] == "EXIT VEHICLE"}) then {
MOSES_incapacitate_keyHold = false;
moveOut player;
[player,"acts_injuredlyingrifle02_180"] remoteExec ["switchMove",allPlayers];
{inGameUISetEventHandler [_x,"true"]} forEach ["Action","NextAction","PrevAction"];
MOSES_incapacitate_cameraView = cameraView;
player switchCamera "EXTERNAL";
{player disableCollisionWith _x} count allPlayers;
0 spawn {
MOSES_incapacitate_keyHold = ["RESPAWN",2,{alive player && player getVariable ["#MOSES#incapacitated",false]},[]] call BIS_fnc_keyHold;
};
};
missionNamespace getVariable ["MOSES_incapacitate_keyHold",false] || diag_tickTime >= _timeToKill
};
_layer cutText ["","PLAIN"];
uiNamespace getVariable ["#MOSES#incapacitate_RscRespawnCounter",displayNull] closeDisplay 0;
player setDamage 1;
}];
0 spawn {
MOSES_incapacitate_keyHold = [["EXIT VEHICLE","RESPAWN"] select (player == vehicle player),2,{alive player && player getVariable ["#MOSES#incapacitated",false]},[]] call BIS_fnc_keyHold;
};
},{
terminate (missionNamespace getVariable ["#MOSES#incapacitate_thread_bleedout",scriptNull]);
"MOSES_incapacitate_layer_bleedout" cutText ["","PLAIN"];
showHUD [true,true,true,true,true,true,true,true];
{_x ppEffectEnable false} forEach [MOSES_incapacitate_ppColor,MOSES_incapacitate_ppVig,MOSES_incapacitate_ppBlur];
{inGameUISetEventHandler [_x,"false"]} forEach ["Action","NextAction","PrevAction"];
{player enableCollisionWith _x} count allPlayers;
if (vehicle player == player) then {
[player,"amovppnemstpsnonwnondnon"] remoteExec ["switchMove",allPlayers];
player switchCamera (missionNamespace getVariable ["MOSES_incapacitate_cameraView","INTERNAL"]);
};
}];
};
MOSES_incapacitate_action_transport = player addAction ["Transport incapacitated unit",{
_ct = cursorTarget;
if ({if (_x getVariable ["#MOSES#incapacitated",false]) exitWith {TRUE}; FALSE} forEach crew _ct) then {
if (_ct isKindOf "Man") exitWith {
systemChat "Man";
_isCarrying = {_x getVariable ["#MOSES#incapacitated",false]} count attachedObjects player > 0;
if _isCarrying then [{
systemChat "_isCarrying";
player playMoveNow "";
systemChat format["Dropped %1",{if (_x getVariable ["#MOSES#incapacitated",false]) then [{detach _x; _x playMoveNow ""; true},{false}]} count attachedObjects player];
},{
systemChat "!_isCarrying";
_ct playMoveNow "";
_ct attachTo [player];
}];
};
}
},nil,1,false,false,"",'
{if (isPlayer _x && {_x getVariable ["#MOSES#incapacitated",false]}) exitWith {TRUE}; FALSE} forEach crew cursorTarget
'];
player addAction ["Revive",{
_ct = cursorTarget;
if (_ct getVariable ["#MOSES#incapacitated",false]) then {
_ct setVariable ["#MOSES#incapacitated",false];
[false] remoteExec ["MOSES_fnc_incapacitate",_ct];
}
},nil,1,true,false,"",'
player isKindOf "b_medic_F" &&
"MediKit" in items player &&
isPlayer cursorTarget &&
cursorTarget isKindOf "Man" &&
{cursorTarget getVariable ["#MOSES#incapacitated",false]}
'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment