Jump to content
Sign in to follow this  
[evo] dan

Spawned AI not engaging me

Recommended Posts

Hi, I am using the below script to spawn some enemies, but unfortunatly they do not attack me (sometimes they will). I am an independant PMC and they are A2 Insugrgents (which are opfor apparently). I have set it so independants are freindly to nobody, but it still fails to work. Here is the script I am using:

//by [EVO] Dan

sleep 5;
_nm = 1; //while loops variable being set
//this area is where things are put that the player will see, such as markers and tasks at the beginning of the mission. These are synced automatically on JIP
serverlogic setVehicleInit " tskObj1 = player createSimpleTask['Primary: Secure area']; tskObj1 setSimpleTaskDescription['Go to the marked area, clear it of enemies and make sure its secure.', 'Secure area', 'Secure area'];"; //adds the new task to all the players
serverlogic setVehicleInit " hint 'New mission available - check the map';"; //tells all the players that a new mission has been given
serverlogic setVehicleInit " Marker3 = createMarker ['m1m1', markerPos 'mission1']; 'm1m1' setMarkerShape 'ELLIPSE'; 'm1m1' setMarkerSize [50,50]; 'm1m1' setMarkerColor 'ColorRed'"; //adds the marker on the location that you want to mark out for the mission (sets the marker to be red)
processInitCommands; //makes the unit execute the commands that have just been put into the units init

//put any spawning/waypoint markers in this gap here if you are using them for controlling units (they only need to be created serverside since spawning is only done serverside, since it is automatically synced)
// _Marker3 = createMarker ["Marker3", [3500,3500]]; 
// "Marker3" setMarkerShape "RECTANGLE"; <-- example code
// "Marker3" setMarkerSize [50,50];

//this is the spawning section where units are spawned, and are given their waypoints (you might want to create some markers before this, either via this script, or in the editor, to use as spawn points or as places for waypoints, alternatively you could just insert coords
// http://community.bistudio.com/wiki/createUnit for the syntax
// http://community.bistudio.com/wiki/ArmA_2_OA:_Infantry for infantry classnames
_group = createGroup east; //creating a group for the units to go into (this is a must), you can use multiple groups if you want to have multiple patrols around your objective
"INS_Soldier_1" createUnit [markerPos "mission1", _group];//unit to be added
"INS_Villager3" createUnit [markerPos "mission1", _group];//second unit to be added to the first units group

_group1 = createGroup east; //creating a group for the units to go into (this is a must), you can use multiple groups if you want to have multiple patrols around your objective
"INS_Soldier_1" createUnit [markerPos "mission1", _group1];//unit to be added
"INS_Woodlander3" createUnit [markerPos "mission1", _group1];//second unit to be added to the first units group

//adding waypoints to the units (check the Biki for more info on types of waypoints)
_wp = _group addWaypoint [markerPos "mission1", 1]; //adding the waypoint to the correct group (http://community.bistudio.com/wiki/addWaypoint)
_wp2 = _group addWaypoint [markerPos "mission1", 1];
_wp3 = _group addWaypoint [markerPos "mission1", 1];
_wp setWaypointCombatMode "RED";
_wp setWaypointType "MOVE"; //setting the type of the waypoint (http://community.bistudio.com/wiki/setWaypointType for more types)
_wp2 setWaypointType "SAD";
_wp3 setWaypointType "CYCLE"; //allows it to keep going around
_wp2 setWaypointCompletionRadius 40; //sets waypoint radius
_wp2 setWaypointTimeout [20, 20, 20]; //sets how long they will do something for
_wp3 setWaypointCompletionRadius 40;
_wp setWaypointBehaviour "SAFE"; //sets whether they are alert or just being casual
_wp setWaypointSpeed "LIMITED"; //sets them to walking pace
_group setCurrentWaypoint [_wp2, 1]; //issuing the waypoint to the group
_group setCurrentWaypoint [_wp, 2]; //issuing the second waypoint to the group
_group setCurrentWaypoint [_wp3, 3]; //issue the third waypoint

//second patrol
_wp4 = _group1 addWaypoint [markerPos "mission1", 1]; //adding the waypoint to the correct group (http://community.bistudio.com/wiki/addWaypoint)
_wp5 = _group1 addWaypoint [markerPos "mission1", 1];
_wp6 = _group1 addWaypoint [markerPos "mission1", 1];
_wp4 setWaypointCombatMode "RED";
_wp4 setWaypointType "MOVE"; //setting the type of the waypoint (http://community.bistudio.com/wiki/setWaypointType for more types)
_wp5 setWaypointType "SAD";
_wp6 setWaypointType "CYCLE"; //allows it to keep going around
_wp5 setWaypointCompletionRadius 40; //sets waypoint radius
_wp5 setWaypointTimeout [20, 20, 20]; //sets how long they will do something for
_wp6 setWaypointCompletionRadius 40;
_wp4 setWaypointBehaviour "CARELESS"; //sets whether they are alert or just being casual
_wp4 setWaypointSpeed "LIMITED"; //sets them to walking pace
_group setCurrentWaypoint [_wp5, 1]; //issuing the waypoint to the group
_group setCurrentWaypoint [_wp4, 2]; //issuing the second waypoint to the group
_group setCurrentWaypoint [_wp6, 3]; //issue the third waypoint

//this is where the tirggers will go: (http://community.bistudio.com/wiki/createTrigger for trigger info)
_triggeram1 = createTrigger["EmptyDetector", markerPos "m1m1"];
_triggeram1 setTriggerArea [200,200,0,false];
_triggeram1 setTriggerActivation ["EAST","NOT PRESENT",true];
_triggeram1 setTriggerTimeout [1,1,1,true];
_triggeram1 setTriggerStatements ["this", "m1 = 1; publicVariable 'mission_status'; serverlogic setVariable ['mission_status', m1, TRUE];", "hint 'trigger off'"];

//while loop goes here, and stays running until the mission is completed, in order to prevent all the missions running straight after each other.
while{_nm == 1} do {
_ar1 = serverlogic getVariable ["mission_status", 0]; //every 10 seconds checks to see if the mission is complete, and then breaks out of the while statement, leaving it to finish up the mission before selecting a new one
sleep 10; //sleeps for a bit so it doesn't keep spamming the server with requests, which causes lag
if(_ar1 == 1) then {
	sleep 10; 
	_nm = 0; //break out of the while statement with this
};
};

//mission complete stuff goes here (like saying objective is complete/ deleting any uneeded markers)
_ar1 = 0; //set the global mission complete variable to zero
handle setVariable ["mission_status", _ar1, TRUE]; //global variable being reset to 0 for use in the next mission
serverlogic setVehicleInit " tskObj1 setTaskState 'Succeeded'; hint 'Mission completed';"; //this shows the mission up as completed (other states can be found at http://community.bistudio.com/wiki/setTaskState)
serverlogic setVehicleInit " deleteMarker 'm1m1';"; //this gets rid of the marker on the map that marked the mission as it is not needed any more. (alternatively you could change this so it just changes to a different colour to suggest the objective is completed)
processInitCommands; //makes the unit execute the commands that have just been put into the units init

//this is so that once this mission is complete, it will select a new one and start it
if(isServer) then {
_myMissions = ["mission1.sqf", "mission2.sqf"]; //array of missions (typically you would not have the mission you just completed in here, otherwise you might end up doing the same mission again straight after completing it)
_curMission = _myMissions select floor random count _myMissions; //picks a mission randomly from the array above
[] execVM _curMission; //executes the nwely selected mission
};	

Can anybody tell me why they are not always engaing me on sight? They have a clear view of me and won't engage me most of the time even when I am within 5m of them.

Share this post


Link to post
Share on other sites

As you say they do attack sometimes which has me puzzled, the usual solution is to just place one unit from each side on the map or spawned units won't attack.

Share this post


Link to post
Share on other sites

well I have 1 unit (non-playable and with prob of presence set to 0) from each faction in the top corner of the map, I had to add these to get them to spawn in the first place. BTW I am using ACE ACRE. I will pst my RPT tommorow if you need that to help.

Share this post


Link to post
Share on other sites

Also do the units that I place on the map in the top corner (the non-present, non-playable ones) have to not be just of the right side, but also of the same faction?

Or do I have to set skill for them when I spawn them, or do they by default come with all skills set to 0.5?

They will throw the occasional grenade at me, but the rest of the time they will just stand and look at me and not shoot at me.

Heres my RPT (adding a non-present guy of the same faction and side did not work):

Error loading control bin\config.bin/RscDisplayArcadeUnit/controls/CA_ValueFaction/
Error loading control bin\config.bin/RscDisplayArcadeUnit/controls/CA_ValueClass/
Error loading control bin\config.bin/RscDisplayArcadeUnit/controls/CA_ValueVehicle/
HUD: bone TargetDistanceMGun not found
HUD: bone TargetDistanceMGun not found
[6343,161.82,0,"XEH: PreInit Started. v1.0.0.184. MISSINIT: missionName=mmprototype_0_1_ace, worldName=utes, isMultiplayer=false, isServer=true, isDedicated=false"]
[6343,180.969,0,"XEH: PreInit Finished. CACHE DISABLED? (Disable caching with cba_disable_cache.pbo): SLX_XEH_RECOMPILE=false, CBA_COMPILE_RECOMPILE=false, CBA_FUNC_RECOMPILE=false"]
[6343,176.867,0,"x\ace\addons\sys_explosives\XEH_preInit.sqf:6","Initializing: ace_sys_explosives version: 1.13.0.559"]
[6343,178.901,0,"x\ace\addons\sys_wounds\XEH_preInit.sqf:8","WARNING: Enhanced Armor difficulty options enabled - this is not recommended in conjunction with ACE Wounds!"]
[7183,190.196,0,"XEH: PostInit Started"]
[7183,190.361,0,"CBA_VERSIONING: cba=1.0.0.184, cba_a2=1.0.0.8, cba_oa=1.0.0.6, ace=1.13.0.559, acex=1.13.0.363, acex_ru=1.13.0.69, acex_usnavy=1.13.0.71, "]
[7183,191.962,0,"XEH: PostInit Finished. State: _isClient=true, _isJip=false, _isDedClient=false, _isServer=true, _isDedServer=false, _playerCheckDone=true, _sp=true, _startInitDone=true, _postInitDone=true, _mpRespawn=false, _machineType=1, _sessionId=1, _level=0, _timeOut=false, _game=1, BIS_functions=L 1-1-F:1, group=L 1-1-F, player=R 1-1-A:1 ([EVO] Dan), _playerType="Soldier_M4A3_PMC", _playerGroup=R 1-1-A"]
[10003,313.383,121.195,"x\ace\addons\sys_explosives\XEH_preInit.sqf:452","FUNC_killed: _this=[O 1-1-A:2,R 1-1-A:1 ([EVO] Dan)]"]
[10003,313.383,121.195,"x\ace\addons\sys_explosives\XEH_preInit.sqf:453","EXPLODE_1 _this: _unit=O 1-1-A:2"]
[10003,313.383,121.195,"x\ace\addons\sys_explosives\XEH_preInit.sqf:421","FUNC_createClackerObject: _this=O 1-1-A:2"]
[10003,313.383,121.195,"x\ace\addons\sys_explosives\XEH_preInit.sqf:425","Exit: count _list=0"]
[10015,313.816,121.621,"x\ace\addons\sys_explosives\XEH_preInit.sqf:452","FUNC_killed: _this=[O 1-1-A:1,R 1-1-A:1 ([EVO] Dan)]"]
[10015,313.816,121.621,"x\ace\addons\sys_explosives\XEH_preInit.sqf:453","EXPLODE_1 _this: _unit=O 1-1-A:1"]
[10015,313.816,121.621,"x\ace\addons\sys_explosives\XEH_preInit.sqf:421","FUNC_createClackerObject: _this=O 1-1-A:1"]
[10015,313.817,121.621,"x\ace\addons\sys_explosives\XEH_preInit.sqf:425","Exit: count _list=0"]
[10454,333.689,141.192,"x\ace\addons\sys_explosives\XEH_preInit.sqf:452","FUNC_killed: _this=[O 1-1-B:1,R 1-1-A:1 ([EVO] Dan)]"]
[10454,333.689,141.192,"x\ace\addons\sys_explosives\XEH_preInit.sqf:453","EXPLODE_1 _this: _unit=O 1-1-B:1"]
[10454,333.689,141.192,"x\ace\addons\sys_explosives\XEH_preInit.sqf:421","FUNC_createClackerObject: _this=O 1-1-B:1"]
[10454,333.689,141.192,"x\ace\addons\sys_explosives\XEH_preInit.sqf:425","Exit: count _list=0"]
[10473,334.656,142.132,"x\ace\addons\sys_explosives\XEH_preInit.sqf:452","FUNC_killed: _this=[O 1-1-B:2,R 1-1-A:1 ([EVO] Dan)]"]
[10473,334.656,142.132,"x\ace\addons\sys_explosives\XEH_preInit.sqf:453","EXPLODE_1 _this: _unit=O 1-1-B:2"]
[10473,334.656,142.132,"x\ace\addons\sys_explosives\XEH_preInit.sqf:421","FUNC_createClackerObject: _this=O 1-1-B:2"]
[10473,334.656,142.132,"x\ace\addons\sys_explosives\XEH_preInit.sqf:425","Exit: count _list=0"]

Edited by [EVO] Dan

Share this post


Link to post
Share on other sites

Hi,

Make sure you create each Center and setFriend on them, like:

createCenter WEST;
createCenter EAST;
WEST setFriend [EAST, 0];
EAST setFriend [WEST, 0];

Share this post


Link to post
Share on other sites

[EVO] Dan,

Just a recommendation at first glance, try to keep your groups and waypoints together for ease of troubleshooting.

You have waypoints split up everywhere...

Do your groups even move where you want them to? Your waypoints are all on top of each other.

Here's my list of quick observations:

These are for your first group. All three are @ markerPos "mission1".

_wp = _group addWaypoint [markerPos "mission1", 1];

_wp2 = _group addWaypoint [markerPos "mission1", 1];

_wp3 = _group addWaypoint [markerPos "mission1", 1];

When you add waypoints this way, you are setting all three to the same marker, with a radius of 1 meter.

See here:

addWaypoint

At the first waypoint, _wp, you setWaypointCombatMode "RED"; but then setWaypointBehaviour "SAFE"; probably confusing to the AI.

These statements make no sense:

_group setCurrentWaypoint [_wp2, 1]; //issuing the waypoint to the group

_group setCurrentWaypoint [_wp, 2]; //issuing the second waypoint to the group

_group setCurrentWaypoint [_wp3, 3]; //issue the third waypoint

As the proper use of setCurrentWaypoint can be found here:

setCurrentWaypoint

Not only are you issuing these one right after the other, which is confusing, but not using the command syntax correctly.

The second group, same problems:

_wp4 = _group1 addWaypoint [markerPos "mission1", 1];

_wp5 = _group1 addWaypoint [markerPos "mission1", 1];

_wp6 = _group1 addWaypoint [markerPos "mission1", 1];

All at the same marker position, with radius of 1.

Again, first waypoint for this group, you have _wp4 setWaypointCombatMode "RED"; but then _wp4 setWaypointBehaviour "CARELESS";

They probably couldn't care less if you went up and scratched them on the ass...

With the second group, you end up setting the current waypoint for the first group, instead of the second group:

_group setCurrentWaypoint [_wp5, 1];

_group setCurrentWaypoint [_wp4, 2];

_group setCurrentWaypoint [_wp6, 3];

Again, not the proper syntax, and not using _group1.

Just my thoughts. I'm not at home to test your actual code, but hopefully these help.

Edited by panther42

Share this post


Link to post
Share on other sites

@Panther42

Yeah you were right, I changed a few things and it worked, they do patrol around though (they did before aswell). I also have now increased the radii.

@Neo

Your advice did not work.

Anyway thank you both for helping me out here.

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  

×