lexx 1393 Posted June 29, 2016 I feel a little dumb right now, so I'll have to ask the forum...What I have: Singleplayer mission.What I need: Revive dead units via script. A part of me hoped this would be as easy as "_x setDamage 0", but apparently it is not. So now the question: Anyone can tell me the most easiest way to revive a dead unit (ai, not the player)? Is it possible without a HandleDamage event handler? If not, how would I use the event handler in this case? I pretty much want the dead ai to "become alive" again on the spot, then stand up and act as normal. Happy to hear ideas. Thanks in advance. 2 Share this post Link to post Share on other sites
Joe98 92 Posted June 29, 2016 You could delete the dead AI and replace him with a living one. Share this post Link to post Share on other sites
POLPOX 779 Posted June 30, 2016 There is no actually revive system, so I just create this. Feel free to use and modify. PLP_fnc_revive = { _pos = getPosATL _this ; _dir = getDir _this ; _type = typeOf _this ; _name = name _this ; _nameSound = nameSound _this ; _face = face _this ; _speaker = speaker _this ; _loadout = getUnitLoadout _this ; _wpnCargo = getWeaponCargo (_pos nearestObject "weaponHolderSimulated") ; deleteVehicle _this ; _group = createGroup side _this ; _unit = _group createUnit [_type,_pos,[],0,"CAN_COLLIDE"] ; _unit setDir _dir ; _unit switchMove "AmovPpneMstpSnonWnonDnon" ; _unit setUnitLoadout _loadout ; _unit addWeapon (_wpnCargo select 0 select 0) ; _unit setName _name ; _unit setNameSound _nameSound ; _unit setFace _face ; _unit setSpeaker _speaker ; } ; player addAction [ "Revive him", { cursorTarget call PLP_fnc_revive ; }, nil,1.5,true,true,"", " !alive cursorTarget and cursorTarget distance player < 5 " ] ; Only problem is the name won't inheritance 2 Share this post Link to post Share on other sites
lexx 1393 Posted June 30, 2016 But this basically removes the unit and spawns a new one on the position, no? That's not really pretty when the player is looking at the bodies. How about "faking the dead"? Like, check the damage the unit has taken, and if it's enough to kill it, start some ragdoll / fall down animation and let it remain still on the ground until we revert this via script and the unit gets up again. Would something like this be possible? /Edit: Actually I just tried your script above. I think it works pretty well already. The transition from dead to revived looks a little bit harsh, like I wrote above, but I think it's still in the "ok"-zone, especially if the player is not exactly right next to the unit. Still, if anyone might have a different idea, I am all ears. Share this post Link to post Share on other sites
POLPOX 779 Posted June 30, 2016 I know how to (almost) force ragdoll but don't know how to stay ragdoll so just tested some and I think found the answer: it is impossible. a addEventHandler ["HitPart",{ hint str _this ; _unit = param [0] param [0] ; _vel = param [0] param [4]; if (animationState _unit find "unconscious" != -1) exitWith {} ; _unit allowDamage false ; _unit disableAI "ANIM" ; systemchat str _this ; [_unit,_vel] spawn { params ["_unit","_vel"] ; _createBalloon = { _dummy = "Steel_Plate_L_F" createVehicle [0,0,0] ; _dummy setMass 10e30 ; _dummy setObjectTextureGlobal [0,""] ; { _x disableCollisionWith _dummy ; } forEach allUnits - [_unit] ; hintsilent str _dummy ; } ; private "_dummy" ; while {alive _unit} do { if (isNil "_dummy") then { call _createBalloon ; } ; _dummy setPosATL (_unit modelToWorld (_unit selectionPosition "pelvis") vectorAdd (vectorNormalized _vel vectorMultiply -0.05)) ; _dummy setVelocity (vectorNormalized _vel vectorMultiply 10) ; } ; } ; }]; I tested with this but this is pretttttyyyyy glitchy and they want to change their animations by themselves. Maybe there is a solution but this is my limit. 1 Share this post Link to post Share on other sites
Grumpy Old Man 3548 Posted July 1, 2016 Still hoping there will be a ragdoll command in A3. I guess in A2 you could do something like this because there were death animations, without a dedicated ragdoll command this seems impossible as of right now. Cheers Share this post Link to post Share on other sites
kylania 568 Posted July 1, 2016 Still hoping there will be a ragdoll command in A3. I guess in A2 you could do something like this because there were death animations, without a dedicated ragdoll command this seems impossible as of right now. Cheers Maybe try this? Share this post Link to post Share on other sites
Play3r 147 Posted June 8, 2017 On 30/6/2016 at 6:20 AM, polpox said: There is no actually revive system, so I just create this. Feel free to use and modify. PLP_fnc_revive = { _pos = getPosATL _this ; _dir = getDir _this ; _type = typeOf _this ; _name = name _this ; _nameSound = nameSound _this ; _face = face _this ; _speaker = speaker _this ; _loadout = getUnitLoadout _this ; _wpnCargo = getWeaponCargo (_pos nearestObject "weaponHolderSimulated") ; deleteVehicle _this ; _group = createGroup side _this ; _unit = _group createUnit [_type,_pos,[],0,"CAN_COLLIDE"] ; _unit setDir _dir ; _unit switchMove "AmovPpneMstpSnonWnonDnon" ; _unit setUnitLoadout _loadout ; _unit addWeapon (_wpnCargo select 0 select 0) ; _unit setName _name ; _unit setNameSound _nameSound ; _unit setFace _face ; _unit setSpeaker _speaker ; } ; player addAction [ "Revive him", { cursorTarget call PLP_fnc_revive ; }, nil,1.5,true,true,"", " !alive cursorTarget and cursorTarget distance player < 5 " ] ; Only problem is the name won't inheritance I want to make the revive work "automatic" for the AI in a mission i am making. I want the AI to wake up in random time so it is not the player or anyone else that does it. Can that be done with this script? Can i just remove the AddAction option and put a random sleep command in the beginning and that way make the unit spawn in random times? And another ? do i have to write it in a SQF or put it inside the INIT of a unit. Share this post Link to post Share on other sites
theend3r 83 Posted June 8, 2017 51 minutes ago, Play3r said: I want to make the revive work "automatic" for the AI in a mission i am making. I want the AI to wake up in random time so it is not the player or anyone else that does it. Can that be done with this script? Can i just remove the AddAction option and put a random sleep command in the beginning and that way make the unit spawn in random times? And another ? do i have to write it in a SQF or put it inside the INIT of a unit. I've made a zombie script where if your team mates get killed, they resurrect after a while (the script is normally more complicated with random chances of revival and such but I deleted that in this case): { _x addEventHandler ['HandleDamage', { params['_unit', '_selName', '_damage', '_source']; if (_damage > 0.99) then { _damage = 0.99; _unit setUnconscious true; }; _damage }]; _trg = createTrigger ["EmptyDetector", getPos _x]; _trg setTriggerArea [0, 0, 0, false]; _trg setTriggerActivation ["NONE", "PRESENT", false]; call compile format [" _trg setTriggerStatements [""lifeState %1 == 'INCAPACITATED'"","" [] spawn { sleep 3; %1 removeAllEventHandlers 'HandleDamage'; sleep (15 + (random 10)); if (alive %1) then { %1 setDamage 0.4; [%1] execVM 'skull.sqf'; //my zombie script sleep (10 + (random 10)); %1 setUnconscious false; } }; deleteVehicle thisTrigger; "",""""]; ", _x call bis_fnc_objectVar]; } forEach ((units group player) - [player]); This will only work one time since you don't un-zombie someone but it's easy to make it repeatable by: removing the trigger deletion, removing the EH deletion and making the trigger repeatable. I'd say that this trigger solution is rather elegant as HandleDamage usually fires multiple times which complicates things but not in this case. Share this post Link to post Share on other sites
Play3r 147 Posted June 8, 2017 1 minute ago, theend3r said: I've made a zombie script where if your team mates get killed, they resurrect after a while (the script is normally more complicated with random chances of revival and such but I deleted that in this case): { _x addEventHandler ['HandleDamage', { params['_unit', '_selName', '_damage', '_source']; if (_damage > 0.99) then { _damage = 0.99; _unit setUnconscious true; }; _damage }]; _trg = createTrigger ["EmptyDetector", getPos _x]; _trg setTriggerArea [0, 0, 0, false]; _trg setTriggerActivation ["NONE", "PRESENT", false]; call compile format [" _trg setTriggerStatements [""lifeState %1 == 'INCAPACITATED'"","" [] spawn { sleep 3; %1 removeAllEventHandlers 'HandleDamage'; sleep (15 + (random 10)); if (alive %1) then { %1 setDamage 0.4; [%1] execVM 'skull.sqf'; //my zombie script sleep (10 + (random 10)); %1 setUnconscious false; } }; deleteVehicle thisTrigger; "",""""]; ", _x call bis_fnc_objectVar]; } forEach ((units group player) - [player]); This will only work one time since you don't un-zombie someone but it's easy to make it repeatable by: removing the trigger deletion, removing the EH deletion and making the trigger repeatable. I'd say that this trigger solution is rather elegant as HandleDamage usually fires multiple times which complicates things but not in this case. do i just have to put it in the init of unit or a sqf file ?? Share this post Link to post Share on other sites
theend3r 83 Posted June 8, 2017 8 minutes ago, Play3r said: do i just have to put it in the init of unit or a sqf file ?? I have it in my init.sqf file but honestly, if you don't even know how this works, you're better off not using it. Share this post Link to post Share on other sites
Play3r 147 Posted June 8, 2017 1 minute ago, theend3r said: I have it in my init.sqf file but honestly, if you don't even know how this works, you're better off not using it. i ask because i do not want all of my enemies to have the option so if it can be put in INIT on the unit that need it. Share this post Link to post Share on other sites
pierremgi 4906 Posted June 8, 2017 I'm using a script respawning AI units, on start or death or marker position. Share this post Link to post Share on other sites