Jump to content
Necropaulo

[Solved] Stop AI Move in a HoldAction

Recommended Posts

Hey everyone, first, thanks to all ! This forum is a treasure of knowledge ! 😀

 

I'm on a mission (SP/MP) and i wanna use COS to spawn civilians around Altis. This part is easy. But i wanna give them a little interaction, so I tried to put a HoldAction on every units spawning with COS. I cannot figure how to make the civilian stop moving during my script, then get back on his path, does anybody have a solution ?

 

At the moment, i do it like this :

 

AddScript_Unit.sqf (from COS)

Spoiler

_unit =(_this select 0);

 

[_unit,"Interroger","\a3\missions_f_oldman\data\img\holdactions\holdAction_talk_ca.paa","\a3\missions_f_oldman\data\img\holdactions\holdAction_talk_ca.paa","_this distance _target < 3","_caller distance _target < 3",{},{},{execVm "Sound\intero.sqf";},{},[],2,0,false,false] remoteExec ["BIS_fnc_holdActionAdd", 0, _unit];

 

This one works, but civilians continue their path during my script.

 

For your information, I call this one :

 

intero.sqf

Spoiler

_unit disableAI "Move";


line1 = ["HQ", "my text"];
line2 = ["HQ", "my text"];
[[line1,line2],"SIDE",0.05,true] execVM "fn_simpleConv.sqf";
playSound ["fin1", true];
sleep 7;
playSound ["fin2", true];


_unit enableAI "Move";

 

Two parts with disableAI/enableAI don't work, I thought i needed to put them in the AddScript_Unit.sqf but I don't know how.

I hope i was explicit enough ! Have a good mission making to all !

Share this post


Link to post
Share on other sites

Hello,

You could try, in initPlayerLocal.sqf or any sqf for clients, once player exists, something like:


 

player spawn {
  params ["_plyr","_unit"];
  while {true} do {
    sleep 1;
    if (_plyr nearEntities ["Civilian",10] isnotEqualTo []) then {
      _unit = (_plyr nearEntities ["Civilian",10])#0;
      [_unit, "path"] remoteExec ["disableAi",0,TRUE];
      waitUntil {sleep 1; _unit distance2D _plyr > 10};
      [_unit, "path"] remoteExec ["enableAI",0,TRUE];
    }
  }
};

 

You can add an extra condition for stopping civilian, only IF Interroger holdAction on it:

if ("Interroger" in (_unit actionParams 0)#0) Then {...};  // Case SenSiTiVe!

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Big big big tank you ! Your lines do exactly what i'm looking for ! I haven't think about playerInitLocal, but it's a really simple way to do that ! Thanks again !

Share this post


Link to post
Share on other sites

Just to complete the answer, of course you can add the code inside the hold action, but you need to call the action, then the AI stops... Not easy and you need to release it at a moment...

 

You can test:

[_unit,
    "Interroger",
    "\a3\missions_f_oldman\data\img\holdactions\holdAction_talk_ca.paa",
    "\a3\missions_f_oldman\data\img\holdactions\holdAction_talk_ca.paa",
    "_this distance _target < 5",
    "_caller distance _target < 5",
    {params ["_target"]; [_target, "path"] remoteExec ["disableAi",0,TRUE]},
    {},
    {params ["_target"]; [_target, "path"] remoteExec ["enableAi",0,TRUE]; execVm "Sound\intero.sqf"},
    {params ["_target"]; [_target, "path"] remoteExec ["enableAi",0,TRUE]},
    [],2,0,false,false
  ] remoteExec ["BIS_fnc_holdActionAdd", 0, _unit];

 

  • Like 1

Share this post


Link to post
Share on other sites

I'm looking to make civilian more immersive, so first solution seem better to me, but thank, now i can I see how i can do it with my HoldAction script !  Have a good day ! 😊

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×