Dj Rolnik 29 Posted August 15, 2018 Hey guys, I am coming to ask for help with what seems to me like a relatively simple thing, yet I cannot figure this out. I would like to have the AI unit run a script which will make it go prone and stay in place on command. The problem is I cannot seem to get the unit to do what the script says. I beleive it's something to do with the "this select" command and since I cannot figure it out I would be grateful if someone could tell me how to get it to work. What I have so far in the Civ unit init: this addAction ["Get on the ground!", {execVM "Civ_ground.sqf"}]; I can approach the unit and order it to get on the ground, but as I stated, it does not want to do it. In the Civ_ground.sqf I have this: _civ = _this select 0; _civ setunitPos "DOWN"; _civ setBehaviour "CARELESS"; _civ disableAI "MOVE"; Thanks a lot for your help! Adam Share this post Link to post Share on other sites
JohnKalo 657 Posted August 15, 2018 For starters I use this when I add an action: this addAction ["Get on the ground!", "Civ_ground.sqf"] Then since the unit is a specific one why not name it and then in the script add: name_of_unit setUnitPos "DOWN"; name_of_unit setBehaviour "CARELESS"; name_of_unit disableAI "MOVE"; it should work 2 Share this post Link to post Share on other sites
Dj Rolnik 29 Posted August 15, 2018 Thanks for a quick response @JohnKalo! Yep, that should do the trick. But what if I have a multitude of civilians and naming all of them is going to be super time consuming and would require separate scripts for all of them. Alternatively, would it be possible to have this kind of action work across all civilians that appear in the game, even the ones spawned during the game by Zeus? That would probably be much more difficult tho :( Thanks! Adam 1 Share this post Link to post Share on other sites
froggyluv 2136 Posted August 15, 2018 Also you could use a function for cursorTarget so it only works at what you aiming at. Just whipped this in editor but it works player addAction ["Get on the ground!", {cursortarget call CivDown}]; CivDown = { _civ =_this; _side = side _this; if ( _side == Civilian) then { _civ setunitPos "DOWN"; _civ setBehaviour "CARELESS"; _civ disableAI "MOVE"; } }; Share this post Link to post Share on other sites
JohnKalo 657 Posted August 15, 2018 Yep that one is indeed harder. Especially when it comes to adding the action to Zeus spawned civilians. I have never worked with Zeus so someone else should save the day. Would not like to state something that does not work. Share this post Link to post Share on other sites
froggyluv 2136 Posted August 15, 2018 Not sure what you mean - i just used it on a Zeus spawned civilian no problem. As long as its spawned in the 'Civilian class' it will work Share this post Link to post Share on other sites
Dj Rolnik 29 Posted August 15, 2018 Thank you guys for your help. Unfortunately I keep getting this error message no matter what I do.. 'cursortarget call |#|CivDown' Error Undefined variable in expression: civdown I put the "player addAction" either in mission init or in player init but neither works. Am I missing something @froggyluv? Share this post Link to post Share on other sites
froggyluv 2136 Posted August 15, 2018 The CivDown is a functioned that needs to be defined before called so put it in your init.sqf file or the like. 1 Share this post Link to post Share on other sites
Dj Rolnik 29 Posted August 15, 2018 Ah yes! Now it's working just as I needed it to! Thank you very much for your help guys. Below is the final code that I have if anyone's interested. player addAction ["Get on the ground!", {cursortarget call CivDown}]; acim_fnc_playActionNow = { _unit = _this select 0; _gesture = _this select 1; _unit playActionNow _gesture; }; CivDown = { _civ =_this; _side = side _this; if ( _side == Civilian) then { player say3D "getdown"; [player, "gestureGo"] call acim_fnc_playActionNow; sleep 1; _civ setunitPos "DOWN"; _civ setBehaviour "CARELESS"; _civ disableAI "MOVE";} }; Thanks again! Adam 1 Share this post Link to post Share on other sites
Dj Rolnik 29 Posted August 31, 2018 Hey guys, I need to reactivate this topic as I have come across a critical error that I cannot figure out without your help. The script in general works as intended, but only to a certain extent in SP. Whenever I enter the server with a friend it works flawlessly for me (my character does scream out using his voice + the civ reacts to the commands), but for my friend it only produces the gesture and sound. Seems like civs do not follow his orders at all. I believe it may be due to the _civ variable somehow being local for me as the host only, and not assigned to him, but I am not sure about that. I would really appreciate any help in getting the script to work for all players in the server. This is what I have in initPlayerLocal.sqf. Maybe I should create some separate function scripts for that, I don't know. I am really stumped.. if (side player == blufor) then { player addAction ["Get down!", {cursortarget call CivDown}]; player addAction ["Get out!", {cursortarget call CivGoAway}]; }; acim_fnc_playActionNow = { _unit = _this select 0; _gesture = _this select 1; _unit playActionNow _gesture; }; CivDown = { _civ =_this; _side = side _this; if (( _side == Civilian) && (_civ isKindOf "Man") && (alive _civ)) then { _random = 6; _randomResult = floor(random _random); switch (_randomResult) do { case 0: {[player, "get_down_on_the_ground"] call CBA_fnc_globalSay3d;}; case 1: {[player, "get_down"] call CBA_fnc_globalSay3d;}; case 2: {[player, "freeze"] call CBA_fnc_globalSay3d;}; case 3: {[player, "freeze_2"] call CBA_fnc_globalSay3d;}; case 4: {[player, "stop"] call CBA_fnc_globalSay3d;}; case 5: {[player, "stop_right_there"] call CBA_fnc_globalSay3d;}; }; [player, "gestureGo"] call acim_fnc_playActionNow; sleep 1; if (player distance _civ < 40) then { _civ disableAI "MOVE"; sleep 0.3; _civ setUnitPos "DOWN"; _civ setBehaviour "CARELESS";} }; }; CivGoAway = { _civ =_this; _side = side _this; if (( _side == Civilian) && (_civ isKindOf "Man") && (alive _civ)) then { _random = 6; _randomResult = floor(random _random); switch (_randomResult) do { case 0: {[player, "move_it"] call CBA_fnc_globalSay3d;}; case 1: {[player, "go"] call CBA_fnc_globalSay3d;}; case 2: {[player, "move"] call CBA_fnc_globalSay3d;}; case 3: {[player, "get_the_hell_outta_here"] call CBA_fnc_globalSay3d;}; case 4: {[player, "move_your_ass"] call CBA_fnc_globalSay3d;}; case 5: {[player, "off_you_go"] call CBA_fnc_globalSay3d;}; }; [player, "gestureGo"] call acim_fnc_playActionNow; sleep 1; if (player distance _civ < 40) then { _civ enableAI "MOVE"; sleep 0.3; _civ setUnitPos "UP"; _civ setBehaviour "COMBAT"; _civ move (waypoint_trigger call BIS_fnc_randomPosTrigger);} }; }; Thank you, Adam Share this post Link to post Share on other sites
Dj Rolnik 29 Posted September 1, 2018 Bumping this topic. Can anyone please advise how can I make the actions work for all players in the game? Thank you in advance. Share this post Link to post Share on other sites