RyanTurner 23 Posted August 30, 2019 Trying to do a simple Animation plays on death. If the unit it's in Combat and gets killed plays a wounded animation, when is out of combat gets up again (something like Brothers In Arms Hell's Highway AI "knock-out"); I've made a script that check player's behaviour, simply need to know how to check if the unit it's killed to play an animation and get out of it afterwards while {True} do{ hintSilent(behaviour Player); switch (behaviour Player) do{ case "COMBAT": { // behaviour Player == "COMBAT" Player sideChat "Combat"; }; default{ // behaviour Player == "CARELESS" | behaviour Player == "SAFE" | behaviour Player == "AWARE" | behaviour Player == "STEALTH" Player sideChat "Out of combat"; {_x setDamage 0} foreach units group Player; }; }; }; Share this post Link to post Share on other sites
wogz187 1085 Posted August 30, 2019 I'm not sure I understand just what you mean. If you can animate/resurrect a dead character? I do know you can make an event handler on HIT which will make invincible units record hits. Record three hits, play dead animation. After dead animation, do whatever because the character never really died. You're a better script writer than I am so you can probably figure out how to use the actual damage received instead of how many hits. Have fun! Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted August 30, 2019 4 hours ago, RyanTurner said: If the unit it's in Combat and gets killed plays a wounded animation, when is out of combat gets up again (something like Brothers In Arms Hell's Highway AI "knock-out"); Do you mean that you want to have your ai incapacitated when they are in combat ? 1 Share this post Link to post Share on other sites
RyanTurner 23 Posted August 31, 2019 @wogz187 and @GEORGE FLOROS GR While In combat if AI health goes 0 or below instead of being killed, gets incapacitated and when combat ends they get up again. Link this: -Down 3 Share this post Link to post Share on other sites
wogz187 1085 Posted August 31, 2019 @RyanTurner, Quote While In combat if AI health goes 0 or below instead of being killed We have to sort this part. I don't think you can have both 0 HP and be NOT dead. So, like I said above, the units will need a way to "fake" death. Something like this, _unit addEventHandler ["HitPart", {((_this select 0) select 0); if (_unit getdammage)>0.8 then { _unit setcaptive true; _unit setunconscious true; _unit setdammage 0; }; {((_this select 0) select 0) RemoveEventHandler ["HitPart",0]}}]; untested. And then use your combat state to wake it back up. I use a variation of the code above to do the exact same thing you are asking for except when the unit gets hit they just take a knee for a few seconds, drop a smoke grenade, and complain about "I'm taking fire!". (probably want to (_unit allowDamage false;) while the unit is unconscious) Have fun! 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted August 31, 2019 From what you are saying , all i'm thinking is a code , that the enemy ai will be incapacitated when the player is in a certain distance and the behaviour of the unit is "combat" and when the player will be off that certain distance the ai will be up again. I'm going to check it. 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted August 31, 2019 (edited) try this : in the initserver.sqf Spoiler //________________ Author : GEORGE FLOROS [GR] ___________ 01.09.19 _____________ /* ________________ GF_Unconscious_Distance Script - Mod ________________ Please keep the Credits or add them to your Diary https://community.bistudio.com/wiki/SQF_syntax Don't try to open this with the simple notepad. For everything that is with comment // in front or between /* means that it is disabled , so there is no need to delete the extra lines. You can open this ex: with notepad++ https://notepad-plus-plus.org/ and also use the extra pluggins (this way will be better , it will give also some certain colors to be able to detect ex. problems ) http://www.armaholic.com/page.php?id=8680 or use any other program for editing . For the Compilation List of my GF Scripts , you can search in: https://forums.bohemia.net/forums/topic/215850-compilation-list-of-my-gf-scripts/ */ //________________ Settings ________________ GF_Unconscious_Distance = 10; // meters GF_Unconscious_Distance_Check = { private _false = false; while{!_false}do{ GF_Unconscious_allPlayers = allUnits select {isPlayer _x && {!(_x isKindOf "HeadlessClient_F")}}; if(isMultiplayer)then{ if(_this getVariable ["Var_GF_Unconscious_Distance",false])then{ if({_x distance _this > GF_Unconscious_Distance}count GF_Unconscious_allPlayers > 0)then{ [_this] call GF_Unconscious_Wake_up; _false = true; }; }; }else{ if(_this getVariable ["Var_GF_Unconscious_Distance",false])then{ if((_this distance player) > GF_Unconscious_Distance)then{ [_this] call GF_Unconscious_Wake_up; _false = true; }; }; }; uisleep 1; systemchat "GF_Unconscious_Distance_Check"; }; }; GF_Unconscious = { params ["_unit"]; if(vehicle _unit != _unit)then{_unit action ["eject", vehicle _unit]}; [_unit,true]remoteExec["setUnconscious",_unit]; [_unit,true]remoteExec["setCaptive",0]; _unit setVariable ["Var_GF_setUnconscious",true]; _unit setVariable["Var_GF_Unconscious_Distance",true]; _unit spawn GF_Unconscious_Distance_Check; _unit removeEventHandler ["HandleDamage",0]; systemchat "GF_Unconscious"; }; //___________________ GF_Unconscious_HD ___________________ GF_Unconscious_HD = { params ["_unit"]; _unit addEventHandler ["HandleDamage",{ params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; _selection = _this select 2; systemchat format ["%1",damage _unit]; if(damage _unit + _selection >= 1)then{ _damage = 0.99; //hint format ["handle %1",typeOf _unit]; [_unit,false]remoteExec["allowDamage",_unit]; if!(_unit getVariable ["Var_GF_Unconscious_EH",false])then{ _unit spawn GF_Unconscious; _unit setVariable ["Var_GF_Unconscious_EH",true]; }; _damage; }; }]; }; //___________________ GF_Revive_Loop ___________________ GF_Unconscious_Wake_up = { params ["_unit"]; [_unit,false]remoteExec["setUnconscious",_unit]; ["#rev",1,_unit]remoteExecCall["BIS_fnc_reviveOnState",_unit]; uisleep 3; [_unit,true]remoteExec["allowDamage",_unit]; _unit setVariable["Var_GF_Unconscious_Distance",false]; _unit setVariable ["Var_GF_Unconscious_EH",false]; _unit spawn GF_Unconscious_HD; systemchat "GF_Unconscious_Wake_up"; _unit addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; _selection = _this select 2; // systemchat format ["%1",damage _unit]; if(damage _unit + _selection >= 1)then{ _damage = 0.99; //hint format ["handle %1",typeOf _unit]; [_unit,false]remoteExec["allowDamage",_unit]; if!(_unit getVariable ["Var_GF_Unconscious_EH",false])then{ _unit spawn GF_Unconscious; _unit setVariable ["Var_GF_Unconscious_EH",true]; }; _damage; }; }]; }; //___________________ spawn GF_Unconscious ___________________ []spawn{ while{true}do{ { if( (alive _x) && (!(isPlayer _x)) && (!(_x getVariable ["Var_GF_Unconscious",false])) )then{ _x spawn GF_Unconscious_HD; }; _x setVariable ["Var_GF_Unconscious",true]; }forEach allUnits; uisleep 1; }; }; Edited January 4, 2020 by GEORGE FLOROS GR 3 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted September 1, 2019 I forgot about the behaviour ! Hold on ! 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted September 1, 2019 I can't add the behaviour because the script must work when they get hit , so they are already in Combat behaviour. 1 Share this post Link to post Share on other sites
RyanTurner 23 Posted September 1, 2019 Sorry for the late response, been busy with work ^^" I've just tested this it's something like this i wanted to do, now let's see reading your code and adapting with my own knowledge and changing it to the way I want (Instead of "waking up" when i Get away from them, they would only "Wake up" after being Out of Combat. And @GEORGE FLOROS GR Thanks a lot man, and If get this script working the way i want, don't worry I will be crediting you for help and everyone else 😃 @wogz187; George at Line:148 gives an error if you want to take a look at: Imagur Image 2 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted September 2, 2019 21 hours ago, RyanTurner said: George at Line:148 gives an error if you want to take a look at: Imagur Image Thank you very much RyanTurner ! This might be the invisible character bug from the forum so just delete the line and write this on your own again . If there is still a problem, i will upload the example here. 2 Share this post Link to post Share on other sites