Jump to content

Recommended Posts

AI Spawn Script Pack

v1.15

What?

Script pack that makes it fast and easy to add dynamic AI in your mission. AI group transported with chopper, paradrop group, militarized area, buildings filled with soldiers, and ambient combat! It has also caching functionality and lots of stuff to be customized.

 

Download:

AISSP 1.15.zip

 

Online documentation and setup tools for all the scripts:

v1.15 Documentation and setup tools

 

How to install?

Extract LV folder into your mission folder. Use setup tools in documentation or example missions to set it up on your mission.

 

NOTE:
All the classnames for AI comes from LV\config_aissp.hpp.
Therefore you must include this into your missions description.ext:

class aissp_configs
{
	#include "LV\config_aissp.hpp"
};

If you don't have description.ext in your mission, you can use the one I included in the zip.
 

v1.15 Changelog

Added

  • Added new main script: AmbientExplosions.
  • Added LV\LV_functions\LV_fnc_findPosition.sqf to handle position searching between distances from defined center(s) while avoiding defined areas and/or objects.

Fixed

  • Fixed a bug where ReinforcementChopper choppers dropped dead right after spawning (reason was UAV config entries in classname arrays where the script selected a chopper).
  • Improved heli spawning in ReinforcementChopper.

Changed

  • ReinforcementChopper: parsing off chopper classnames which includes 'UAV' or 'Light'.
  • ReinforcementChopper: using now bis_fnc_spawncrew instead of manually creating pilot (now chopper also has a crew instead of lonely pilot).

 

Main scripts

  • Ambient Combat
    Spawns random groups and vehicles around player/object and makes them patrol around it. You can define how many groups there is at the same time, how far they spawn, spawning delay, AI skill levels, do AI groups communicate, how far from "defined center" they dissapear, and other stuff.
    Every vehicle is counted as one group, so if 'groups' argument is set to 2, there might spawn only 2 vehicles, eventhough vehicles spawns with 30% probability. Once group is dead or distance between group and center object is more than defined max distance, group will be deleted and new one is created. Groups will spawn equally for all teams.
    You can also define markers where AmbientCombat wont spawn units and which it tries to avoid when patrolling.
    AmbientCombat can also be deleted with external script, which has it's own features to offer you different solutions.
  • Ambient Explosions
    Creates explosions all around, avoiding units and areas you want it to avoid. Can be brought to scene by planes or artillery.
  • Militarize
    Fills area with units. You can define the area size, units side, does soldiers or ground vehicles or both spawn, will they stay still or patrol inside area, how much there will spawn units, AI skill levels, and other stuff.
  • FillHouse
    Fills nearest building, OR all buildings in defined range, with soldiers. You can define side of soldiers, will they patrol or not, how will they patrol (only inside of building or also outside), spawning percentage, area radius, AI skill levels, and other stuff.
  • ReinforcementChopper
    Spawns chopper which transports infantry group where ever you like and leaves after that. You can define side, does the chopper land exactly on target or will it find more suitable drop zone, how far it comes from, from what direction it comes from, will it unload infantry group straight away or will it react against possible threats before that, etc.
    And for infantry group you can choose its target, which can either be a single marker, array of markers (if so, you can set it also to cycle these markers), or unit/object, group size, AI skill levels, and other stuff.
  • HeliParadrop
    Creates AI paratrooper group which will dropped from the sky by a chopper. Various options, for example distance, direction, flyheight, drop distance, parachute open altitude, target, and many more!

 

FAQ

 

Q: Where to put script files?

When you save your mission in editor, it will be saved to C:\Users\YOUR_NAME\Documents\Arma 3\missions\MISSION_NAME\ and into that folder you should put LV folder.

Q: How to add script in Trigger?

If script's calling line goes like: nul = [this,1,50..] execVM... then usually you can just put the same line into Triggers' ON ACT -field and replace first argument with target objects/markers/units name.

Add for example Game Logic there where you want this script to be located and name it gamelog01, and then call the script from trigger: nul = [gamelog01,1,50..] execVM.... In militarize, fillHouse and reinforcementChopper the first argument is target location/object/marker (fillHouse wont support markers yet).

Q: I'm getting error when I use markers, what to do?

Most likely you have forgotten to use quotes with marker name when you refer to it. If you name your marker as marker1, in scripts and calling lines you must use quotes: "marker1".

Q: How to execute a script only for group leader?

Custom init executes on every unit, but you can also use it to execute something only for leader, like this:


"if(this==(leader(group this)))then{nul = [this] execVM 'leaderScript.sqf'};"
 

Q: Getting errors when using simpleCache?

Use fillHouse & militarize in gamelogics, and name the gamelogics.

Q: Getting error when targeting inf group to hunt player group?

If this happens, check if you have set the target like: (group player). If so, name the group and replace (group player) with that name.

How to name it? Set in unit's init: groupName = group this;

Q: CustomInit wont work! What to do?

Make sure you have ended every sentence to semicolon, and you have NOT used normal quotes (") inside "custom init line". Instead of " use ' or "".

For example: "hint 'this is custom init';"

If problem occurs when you try to use EventHandler -> do NOT include any conditions inside EventHandler. Use it to execVM your own script file which has the conditions inside it.

  • Like 11
  • Thanks 1

Share this post


Link to post
Share on other sites

Hey SpunFin,

A question about militarize, does this spawn individual units that patrol or groups.. if individual units are they somehow 'connected' or share info when they knows about them?

Also that the Flash App is a neat little feature, thanks for making it :)

Share this post


Link to post
Share on other sites

Having used spunFIN's scripts for a while now, I can definitely say they're great for anyone looking for some great AI creation/control scripts.

Share this post


Link to post
Share on other sites
Hey SpunFin,

A question about militarize, does this spawn individual units that patrol or groups.. if individual units are they somehow 'connected' or share info when they knows about them?

Also that the Flash App is a neat little feature, thanks for making it :)

Hey mate o/

It creates single group, but units patrol individually (doMove), so they should share their knowledge.

Np, I just hope everything works with it :)

Meatball, thanks for kudos! :)

Share this post


Link to post
Share on other sites

Finally figured out how to make these scripts work, mission making is so much easier.Thanks for the continued support and improvements spunFIN !

:cool:

Share this post


Link to post
Share on other sites

hi spunFIN,

yesterday i stumbled over your AISSP script at armaholic, btw V0.9, it works like a charm for me with one exclusion.

I wrote a little spawnscript to populate Altis but the custom init line in militarize gave me headache.

I tried different versions of it with ' and "", all trow errors about missing '{'.

Here a look:

this one works:

_UsedInit = "removeBackpack this; removeVest this; this addVest 'V_TacVest_blk_POLICE';";

this one don't:

_UsedInit = "_this unlinkItem 'NVGoggles'; _this unlinkItem 'NVGoggles_OPFOR'; this unlinkItem 'NVGoggles_INDEP'; this unlinkItem 'ItemGPS'; removeBackpack this; removeVest this; this addVest 'V_TacVest_blk_POLICE'; if (random 1 < 0.5) then {this addMagazine ['30Rnd_9x21_Mag', 6]; this addWeapon 'SMG_02_F';}";

the whole spawnscript:

if(isNil("LV_ACskills"))then{LV_ACskills = compile preprocessFile "addons\LV\LV_functions\LV_fnc_ACskills.sqf";};
if(isNil("LV_vehicleInit"))then{LV_vehicleInit = compile preprocessFile "addons\LV\LV_functions\LV_fnc_vehicleInit.sqf";};
if(isNil("LV_fullLandVehicle"))then{LV_fullLandVehicle = compile preprocessFile "addons\LV\LV_functions\LV_fnc_fullLandVehicle.sqf";};
if(isNil("LV_fullAirVehicle"))then{LV_fullAirVehicle = compile preprocessFile "addons\LV\LV_functions\LV_fnc_fullAirVehicle.sqf";};
if(isNil("LV_fullWaterVehicle"))then{LV_fullWaterVehicle = compile preprocessFile "addons\LV\LV_functions\LV_fnc_fullWaterVehicle.sqf";};
if(isNil("LV_GetPlayers"))then{LV_GetPlayers = compile preprocessFile "addons\LV\LV_functions\LV_fnc_getPlayers.sqf";};

if(isNil("LV_militarize"))then{LV_militarize = compile preprocessFile "addons\LV\militarize.sqf";};
if(isNil("LV_fnc_simpleCache"))then{LV_fnc_simpleCache = compile preprocessFile "addons\LV\LV_functions\LV_fnc_simpleCache.sqf";};

_side_list = [1, 2, 3];
_mrkrText = "Patrol_Mrkr";
PatrolSpawnMarkers_list = [];
_sCmilID_list = [];
_usedLVgroupCnt = 0;
_UsedmilID = 0;

//get all Patrolmarkers and count them
{
if (_mrkrText == markerText _x) then {
	PatrolSpawnMarkers_list set [count PatrolSpawnMarkers_list, _x];
	_usedLVgroupCnt = _usedLVgroupCnt + 1;
	//diag_log format["%1", _x];
	sleep 0.001;
};
}forEach allMapMarkers;
//sleep 1;
//diag_log format["%1", _usedLVgroupCnt];

//get randomness for militarize script and spawn each
{
_UsedtargetMrkr = getMarkerPos _x;
_Usedside = _side_list select (floor(random(count _side_list)));
_Usedradius = 200 + floor(random 300);
_UsedspwnMen = [true, true];
_UsedspwnVeh = [false, false, false];
_Usedstill = false;
_UsedMenRatio = [6, floor(random 5)];
_UsedVehRatio = [0, 0];
_UsedSkill = 0.3 + random 0.025;
_UsedGroup = Nil;
//_UsedInit = "_this unlinkItem 'NVGoggles'; _this unlinkItem 'NVGoggles_OPFOR'; this unlinkItem 'NVGoggles_INDEP'; this unlinkItem 'ItemGPS'; removeBackpack this; removeVest this; this addVest 'V_TacVest_blk_POLICE'; if (random 1 < 0.5) then {this addMagazine ['30Rnd_9x21_Mag', 6]; this addWeapon 'SMG_02_F';}";
_UsedInit = "removeBackpack this; removeVest this; this addVest 'V_TacVest_blk_POLICE';";
_UsedmilID = _UsedmilID + 1;
_hndl = [_UsedtargetMrkr, _Usedside, _Usedradius, _UsedspwnMen, _UsedspwnVeh, _Usedstill, _UsedMenRatio, _UsedVehRatio, _UsedSkill, nil, _UsedInit, _UsedmilID] spawn LV_militarize;
waitUntil {scriptDone _hndl};
_sCmilID_list set [count _sCmilID_list, _UsedmilID];
diag_log format["LV Militarize ready: %1", _UsedmilID];
}forEach PatrolSpawnMarkers_list;

_sCplayer_list = [];
_sCdistance = 2000;
_sCkpCnt = false;
_sCMP = true;
nul = [_sCmilID_list, _sCplayer_list, _sCdistance, _sCkpCnt, _sCMP] spawn LV_fnc_simpleCache;
diag_log format["LV_simpleCache ready!"];

greetings Na_Palm

Share this post


Link to post
Share on other sites

Hey Na_Palm,

I'm afraid this happens becouse else-block includes semicolon, and unfortunately that makes my script think it's the end of script line -> it compiles the line.

In this case I would suggest you only to use custom init to execVM/call external gear script where you would do all that magic (eventho you probably wanted to keep all that in one sqf file). :)

Share this post


Link to post
Share on other sites

ok, thanks spunFIN. I will then go with a call argument for it or maybe introduce a new legacy class for my military police troopers :)

I'am now in the process of eliminating the stutters, at start time, in your system. If you don't mind i would like to post the results later or should i send them to you?

Share this post


Link to post
Share on other sites

Feel free to post, all results and possible solutions are always welcome :)

  • Like 1

Share this post


Link to post
Share on other sites

spunFIN, is there a way to give the a.i. that are spawned custom loadouts?

Share this post


Link to post
Share on other sites

If I'm running a mod with a custom faction, is there a way I can select units from that faction and not just the side of the AI? I'd like to be able to use them exclusively, and I'm hoping this could work.

Share this post


Link to post
Share on other sites

@DoRo,

Yes, you would need to use custom init -parameter. You can do simple things in it like this:

"removeAllWeapons this; this addMagazines ['100Rnd_65x39_caseless_mag',5]; this addWeapon 'arifle_MX_F';"

Or it might be easier & nicer if you used it to call your own gear script like this:

"nul = [this] execVM 'myGear.sqf';"

And just make myGear.sqf into your mission folder and write your gear stuff there:

_unit = this select 0;
removeAllWeapons _unit; 
_unit addMagazines ["100Rnd_65x39_caseless_mag",5]; 
_unit addWeapon "arifle_MX_F";

@BadHabitz,

It should be possible. I havent really used model/faction mods in A3, but I would imagine that you can just modify classname arrays in my scripts to make it work. Which scripts and mod are you using? I'll take a look. :)

Share this post


Link to post
Share on other sites
@BadHabitz,

It should be possible. I havent really used model/faction mods in A3, but I would imagine that you can just modify classname arrays in my scripts to make it work. Which scripts and mod are you using? I'll take a look. :)

This is the one that will probably get the most mileage in our modpack http://forums.bistudio.com/showthread.php?160602-Russian-GRU-and-OMON-Spetsnaz-A3

It would also make sense to have multiple factions to take into account for your 'side' paramater, in case you want to play as OPFOR and only want to have FIA or NATO covered under your script. As A3 matures you'll have more and more robust addon factions, so figuring that out now might be a good idea.

Share this post


Link to post
Share on other sites
@DoRo,

Yes, you would need to use custom init -parameter. You can do simple things in it like this:

"removeAllWeapons this; this addMagazines ['100Rnd_65x39_caseless_mag',5]; this addWeapon 'arifle_MX_F';"

Or it might be easier & nicer if you used it to call your own gear script like this:

"nul = [this] execVM 'myGear.sqf';"

And just make myGear.sqf into your mission folder and write your gear stuff there:

_unit = this select 0;
removeAllWeapons _unit; 
_unit addMagazines ["100Rnd_65x39_caseless_mag",5]; 
_unit addWeapon "arifle_MX_F";

@BadHabitz,

It should be possible. I havent really used model/faction mods in A3, but I would imagine that you can just modify classname arrays in my scripts to make it work. Which scripts and mod are you using? I'll take a look. :)

Thanks,

I see where to put my init commands in ".sqf" but how exactly would this be handled since multiple a.i. are spawned sometimes with a + number? Would all spawn in with the same gear? Is there a way to randomize this? I guess I could just use multiple fillhouse scripts mixing them up between riflemen, machine gunners, ect.

Share this post


Link to post
Share on other sites

Having a bit of a problem calling my own script.

I've tried 2 ways:

First Way:

_unit = this select 0;

removeallWeapons _unit;

removeallassigneditems _unit;

removeuniform _unit;

removevest _unit;

removebackpack this;

_unit addvest "V_Chestrig_khk";

_unit addMagazines ["30Rnd_mas_545x39_mag",5];

_unit addWeapon "LMG_mas_rpk_F";

_unit adduniform "U_IG_Guerilla3_1";

Second Way:

removeallweapons this;

removeallassigneditems this;

removeuniform this;

removevest this;

removebackpack this;

this addvest "V_Chestrig_khk";

this addMagazines ["30Rnd_mas_545x39_mag",5];

this addWeapon "LMG_mas_rpk_F";

this adduniform "U_IG_Guerilla3_1";

Share this post


Link to post
Share on other sites

hi DoRo,

i assume that you used for both ways an external script 'myGear.sqf' as spunFIN suggested.

So, for your 1st the only thing to change are the two "this", as it is an call with execVM you would have to use "_this":

_unit = _this select 0;
removeallWeapons _unit; 
removeallassigneditems _unit; 
removeuniform _unit; 
removevest _unit; 
removebackpack _unit;
_unit addvest "V_Chestrig_khk"; 
_unit addMagazines ["30Rnd_mas_545x39_mag",5]; 
_unit addWeapon "LMG_mas_rpk_F"; 
_unit adduniform "U_IG_Guerilla3_1";

and in the 2nd try the same, try "_this" there too. Both ways should then work.

have a look at https://community.bistudio.com/wiki/this for the use of the corresponding 'this' or '_this'.

oh dammit that reads like ******, I hope you get what i wanted to say :)

greetings Na_Palm

Share this post


Link to post
Share on other sites
hi DoRo,

i assume that you used for both ways an external script 'myGear.sqf' as spunFIN suggested.

So, for your 1st the only thing to change are the two "this", as it is an call with execVM you would have to use "_this":

_unit = _this select 0;
removeallWeapons _unit; 
removeallassigneditems _unit; 
removeuniform _unit; 
removevest _unit; 
removebackpack _unit;
_unit addvest "V_Chestrig_khk"; 
_unit addMagazines ["30Rnd_mas_545x39_mag",5]; 
_unit addWeapon "LMG_mas_rpk_F"; 
_unit adduniform "U_IG_Guerilla3_1";

and in the 2nd try the same, try "_this" there too. Both ways should then work.

have a look at https://community.bistudio.com/wiki/this for the use of the corresponding 'this' or '_this'.

oh dammit that reads like ******, I hope you get what i wanted to say :)

greetings Na_Palm

Thanks a bunch man! I'll give that try in a bit.

Share this post


Link to post
Share on other sites

@DoRo,

Ah yeah sorry I forgot that downscore! :P

About that randomized gear, you could do it this way:

_unit = _this select 0;

_rifles = ["arifle_MX_F","arifle_SDAR_F"];
_mags = ["30Rnd_65x39_caseless_mag","30Rnd_556x45_Stanag"];
_chosen = (floor(random(count _rifles)));

_unit addMagazines [(_mags select _chosen),5]; 
_unit addWeapon (_rifles select _chosen); 

Just remember to set corresponding ammo classname into exactly same spot in _mags where you got weapon classname in _rifles.

Share this post


Link to post
Share on other sites
hi DoRo,

i assume that you used for both ways an external script 'myGear.sqf' as spunFIN suggested.

So, for your 1st the only thing to change are the two "this", as it is an call with execVM you would have to use "_this":

_unit = _this select 0;
removeallWeapons _unit; 
removeallassigneditems _unit; 
removeuniform _unit; 
removevest _unit; 
removebackpack _unit;
_unit addvest "V_Chestrig_khk"; 
_unit addMagazines ["30Rnd_mas_545x39_mag",5]; 
_unit addWeapon "LMG_mas_rpk_F"; 
_unit adduniform "U_IG_Guerilla3_1";

and in the 2nd try the same, try "_this" there too. Both ways should then work.

have a look at https://community.bistudio.com/wiki/this for the use of the corresponding 'this' or '_this'.

oh dammit that reads like ******, I hope you get what i wanted to say :)

greetings Na_Palm

Hmm, it still doesn't seem to want to work. I'm beginning to think it has to do with the calling my own script.

Example of what I'm using: "nul = [this] execVM 'RPKsoldier.sqf';" in my Initialization box in the AISSP flash program.

Whats in my gear script:

_unit = _this select 0;

removeallWeapons _unit;

removeallassigneditems _unit;

removeuniform _unit;

removevest _unit;

removebackpack _unit;

_unit addvest "V_Chestrig_khk";

_unit addMagazines ["30Rnd_mas_545x39_mag",5];

_unit addWeapon "LMG_mas_rpk_F";

_unit adduniform "U_IG_Guerilla3_1";

Share this post


Link to post
Share on other sites

@DoRo,

Could you upload your mission folder or pbo somewhere so I can take a closer look where it goes wrong? :) That custom init & script looks right.

Share this post


Link to post
Share on other sites

I have had time to poke a bit around in your files. Only touched militarize.sqf and LV_fnc_simpleCache.sqf along the files called/spawned through them.

first round optimization: AISSP_opt1.Altis.zip

This is a simple SP mission i made with your AISSP under addons/ and spawned 43 militarize places on the map and then used simpleCache for all of them.

my Changes:

1. i cut in all files the createCenter command and placed it once for each side in my init.sqf. The side center only needs to be created once per side.

2. in every while, for and forEach loop i placed 'sleep 0.001;' if they are in a spawned or execVMed script. While this slows all loops marginally it opens them up,

so ArmA has a chance to interrupt at that point and looks for other concurrent running scripts and executes them. This one becomes more and more importantly

the more scripts you have running through spawn/execVM.

3. pre compiled every missing script before spawning it. Frees also up much of hassle a mission has to run.Let you stare at the loading screen a bit longer.

4. changed the spawn call so every militarize runs alone and not all concurrently.

from

nul = [arguments] spawn militarize;

to

_hndl = [arguments] spawn militarize;
waitUntil{scriptDone _hndl;};

That are my findings/changes for now. I have a bit of trouble to understand why you are doing some calls that way in LV_fnc_simpleCache.sqf in some places.

(ex. lines 37,39,40 or 82)

why this:

call compile format["nul = %1 execVM 'addons\LV\militarize.sqf';",_params];

if this does the same and is way simpler??

_hndl = _params spawn LV_militarize;

Please dont take all that as complaining!!! I really like your scripts at hand and only want to optimize them a bit.

Btw i like that your way of indent the code is mostly the same as my way :)

greetings Na_Palm

Share this post


Link to post
Share on other sites

this is realy a cool script i am using it almost constant, one question though is there an option to include the FIA faction (blufor) as choosable i would like to see ambient combat between FIA and CSAT / AAF troops.

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

×