Jump to content
Sign in to follow this  
zephyrdark

I Hear You! - ACRE AI Detection Script

Recommended Posts

Hey everyone.

I'm still pretty novice when comes to scripting. Lately been working on some new scripts. This script allows for hostile AI within the defined radius to detect players speaking and seek out the source of the sound. Its pretty rough in its current state, however it has proved to work.

Requires CBA

Requires ACRE

/*
I Hear You! Script by Blackpython of TacticalGamer.com
##########################################
***Requires CBA***

Script Call Line:
[-1, {nul=[*radius*,*hostile side*]execVM "IHearYou.sqf";}] call CBA_fnc_globalExecute;

*radius* = Radius Enemies can hear players
*hostile side* = WEST , EAST, RESISTANCE , CIVILIAN. Depending on the side that can hear you and react.

*/

private ["_AIAry","_ret","_rad","_wpNew","_side","_pos","_posPlay"];
_rad = _this select 0;
_side = _this select 1;
_AIAry = [];
while {true} do
{
   if (isServer) exitWith {};
   {if (side _x == _side) then {_AIAry = _AIAry + [_x]}} forEach allUnits;
   {if (_x in _AIAry) then {_AIAry = _AIAry - [_x]}} forEach allDead;
   {
       if ((_x distance player) <= _rad) then 
       {
           {if (_x != player) then {_AIAry = _AIAry + [_x]}} forEach allUnits;
           {if (_x in _AIAry) then {_AIAry = _AIAry - [_x]}} forEach allDead;
           _ret = [player] call acre_api_fnc_isSpeaking;
           if (_ret) then
           {
               _x setBehaviour "AWARE";
               _pos = getpos player;
               _posPlay = [(_pos select 0) + round(random 15),(_pos select 1) - round(random 15)];
               _wpNew = (group _x) addWaypoint [_posPlay, 0];
               _wpNew setWaypointType "MOVE";
               (group _x) setCurrentWaypoint _wpNew;
           }
       }
   }  forEach _AIAry;
   sleep 0.1;
}

Mediafire Download: http://www.mediafire.com/?j8mt8ht5x18unte

Share this post


Link to post
Share on other sites

Shit dude, that may be something I was looking for for some time already!

One question: does the script define AI awareness by checking how loud player speaks? Whisper could be a huge solution here!

Share this post


Link to post
Share on other sites

I really wish it could. I use the API for ACRE that detects if a player is speaking. Doesn't handle volume sadly. If I knew how to write a plugin for that I wold, but... :/

Share this post


Link to post
Share on other sites

Oh, wow, this needs way more views!

Works just fine, thanks alot!

Share this post


Link to post
Share on other sites

Can anyone confirm if this really works. I have been testing this out in my ACE Insurgency missions and it does not seem to do anything.

Share this post


Link to post
Share on other sites

Doesn´t seem to work here, too.

Where should "[-1, {nul=[25,EAST]execVM "IHearYou.sqf";}] call CBA_fnc_globalExecute;" be placed? In init.sqf or the init of the AI-leader?

Share this post


Link to post
Share on other sites

Love the concept! Going to definitely check this out.

Share this post


Link to post
Share on other sites
;2174314']Doesn´t seem to work here' date=' too.

Where should "[-1, {nul=[25,EAST']execVM "IHearYou.sqf";}] call CBA_fnc_globalExecute;" be placed? In init.sqf or the init of the AI-leader?

Hey Mike,

better later than never:

You simply put it inside the init.sqf.

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
Sign in to follow this  

×