Karmafied

Creating Static AI (Sector B-style)

16 posts in this topic

I am currently using A3XAI, DMS, and VEMFr (which all of the sudden have become friendly to players, WTF?), and yet I just want to be able to code in some AI in -specific- positions (and heights); much like the old Sector B on Tavi.

I thought there was a way to add each AI into the mission.sqm somehow? I don't expect them to patrol, I just want to be able to script exactly where I want each AI to be placed, including on multiple floors of buildings and facing certain directions.

Has anyone had luck with this?

Share this post


Link to post
Share on other sites
/*
	"Sector B" static mission for Altis.
	Created by [CiC]red_ned using templates by eraser1 
	Credits to "Kroenen" for creating the base.
	17 years of CiC http://cic-gaming.co.uk
*/

// For logging purposes
_num = DMS_MissionCount;


// Set mission side (only "bandit" is supported for now)
_side = "bandit";

_pos = [22196.2,19851.5,0];

if ([_pos,DMS_StaticMinPlayerDistance] call DMS_fnc_IsPlayerNearby) exitWith {"delay"};


// Set general mission difficulty
_difficulty = "hardcore";


// Define spawn locations for AI Soldiers. These will be used for the initial spawning of AI as well as reinforcements.
// The center spawn location is added 3 times so at least 3 AI will spawn initially at the center location, and so that future reinforcements are more likely to spawn at the center.
_AISoldierSpawnLocations =
[
[22196.2,19851.5,0],
[22444.1,19255.4,0],
[22466.2,19472.2,0],
[22301.2,19850,0],
[22513.3,19817.4,0],
[22863.6,19172.2,0],
[23027.6,19754.4,0],
[22489.7,20065.2,0],
[22032.3,19646,0],
[19403.5,21045.1,0],
[22550.3,19631.1,0],
[22818.5,20012.6,0],
[22491.1,19015.1,0],
[22817.6,19737,0],
[22711.8,20109.9,0],
[23045.1,19540.8,0]
];

// Create AI
_AICount = 25 + (round (random 5));


_group =
[
	_AISoldierSpawnLocations+[_pos,_pos,_pos],			// Pass the regular spawn locations as well as the center pos 3x
	_AICount,
	_difficulty,
	"random",
	_side
] call DMS_fnc_SpawnAIGroup_MultiPos;


_staticGuns =
[
	[
		_pos vectorAdd [-20,0,0],		// 5 meters West of center pos
		_pos vectorAdd [0,-5,0],		// 5 meters South of center pos
		[22437.3,20101.7,8.1287],	
		[22879.4,19863.4,10.2653],		
		[22141.6,19851.4,1.37462],
		[22518.6,20010.3,8.22713],
		[22478.2,20006.9,8.23055],
		[19403.5,21045.1,0],
		[22191.4,19267.4,0],
		[22199.3,19259.6,0]
	],
	_group,
	"assault",
	_difficulty,
	"bandit",
	"random"
] call DMS_fnc_SpawnAIStaticMG;



// Define the classnames and locations where the crates can spawn (at least 2, since we're spawning 2 crates)
_crateClasses_and_Positions =
[
	[[22551.3,19631.1,0],"I_CargoNet_01_ammo_F"],
	[[19404.5,21045.1,0],"I_CargoNet_01_ammo_F"],
	[[23046.1,19540.8,0],"I_CargoNet_01_ammo_F"]
];

{
	deleteVehicle (nearestObject _x);		// Make sure to remove any previous crates.
} forEach _crateClasses_and_Positions;

// Shuffle the list
_crateClasses_and_Positions = _crateClasses_and_Positions call ExileClient_util_array_shuffle;


// Create Crates
_crate0 = [_crateClasses_and_Positions select 0 select 1, _crateClasses_and_Positions select 0 select 0] call DMS_fnc_SpawnCrate;
_crate1 = [_crateClasses_and_Positions select 1 select 1, _crateClasses_and_Positions select 1 select 0] call DMS_fnc_SpawnCrate;

// Disable smoke on the crates so that the players have to search for them >:D
{
	_x setVariable ["DMS_AllowSmoke", false];
} forEach [_crate0,_crate1];

/*
// Don't think an armed AI vehicle fit the idea behind the mission. You're welcome to uncomment this if you want.
_veh =
[
	[
		[_pos,100,random 360] call DMS_fnc_SelectOffsetPos,
		_pos
	],
	_group,
	"assault",
	_difficulty,
	_side
] call DMS_fnc_SpawnAIVehicle;
*/
[
	_group,
	[_pos,[22898.8,19191.6,0]] call DMS_fnc_CalcPos,
	"base"
] call DMS_fnc_SetGroupBehavior;

[
	_group,
	[_pos,[22446.9,20174,0]] call DMS_fnc_CalcPos,
	"base"
] call DMS_fnc_SetGroupBehavior;


// Define mission-spawned AI Units
_missionAIUnits =
[
	_group 		// We only spawned the single group for this mission
];

// Define the group reinforcements
_groupReinforcementsInfo =
[
	[
		_group,			// pass the group
		[
			[
				0,		// Let's limit number of units instead...
				0
			],
			[
				10,	// Maximum 100 units can be given as reinforcements.
				0
			]
		],
		[
			120,		// About a 4 minute delay between reinforcements.
			diag_tickTime
		],
		_AISoldierSpawnLocations,
		"random",
		_difficulty,
		_side,
		"reinforce",
		[
			20,			// Reinforcements will only trigger if there's fewer than 10 members left in the group
			6			// 7 reinforcement units per wave.
		]
	]
];

// Define mission-spawned objects and loot values
_missionObjs =
[
	_staticGuns,			// static gun(s). Note, we don't add the base itself because it already spawns on server start.
	[],
	[[_crate0,[50,150,15]],[_crate1,[50,150,15]]]
];

// Define Mission Start message
_msgStart = ['#FFFF00', "Sector B Is On"];

// Define Mission Win message
_msgWIN = ['#0080ff',"They Have All Your Bases Targeted"];

// Define Mission Lose message
_msgLOSE = ['#FF0000',"Do Not Tread Lightly"];

// Define mission name (for map marker and logging)
_missionName = "Sector B";

// Create Markers
_markers =
[
	_pos,
	_missionName,
	_difficulty
] call DMS_fnc_CreateMarker;

_circle = _markers select 1;
_circle setMarkerDir 20;
_circle setMarkerSize [300,300];


_time = diag_tickTime;

// Parse and add mission info to missions monitor
_added =
[
	_pos,
	[
		[
			"kill",
			_group
		],
		[
			"playerNear",
			[_pos,100]
		]
	],
	_groupReinforcementsInfo,
	[
		_time,
		DMS_StaticMissionTimeOut call DMS_fnc_SelectRandomVal
	],
	_missionAIUnits,
	_missionObjs,
	[_missionName,_msgWIN,_msgLOSE],
	_markers,
	_side,
	_difficulty,
	[[],[]]
] call DMS_fnc_AddMissionToMonitor_Static;

// Check to see if it was added correctly, otherwise delete the stuff
if !(_added) exitWith
{
	diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_fnc_AddMissionToMonitor_Static! Deleting mission objects and resetting DMS_MissionCount.",_missionName];

	_cleanup = [];
	{
		_cleanup pushBack _x;
	} forEach _missionAIUnits;

	_cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
	
	{
		_cleanup pushBack (_x select 0);
	} foreach (_missionObjs select 2);

	_cleanup call DMS_fnc_CleanUp;


	// Delete the markers directly
	{deleteMarker _x;} forEach _markers;


	// Reset the mission count
	DMS_MissionCount = DMS_MissionCount - 1;
};


// Notify players
[_missionName,_msgStart] call DMS_fnc_BroadcastMissionStatus;



if (DMS_DEBUG) then
{
	(format ["MISSION: (%1) :: Mission #%2 started at %3 with %4 AI units and %5 difficulty at time %6",_missionName,_num,_pos,_AICount,_difficulty,_time]) call DMS_fnc_DebugLog;

 

Share this post


Link to post
Share on other sites
Advertisement

Thanks, @Beani. But will these guys stay put in one place? Or will they patrol? And can I put them on 2nd and 3rd floors?

Share this post


Link to post
Share on other sites

Haven't seen anyone figure out the grid system yet for Australia; which is what I am working with. 

Share this post


Link to post
Share on other sites

@Beani - That indeed could come in handy as A3XAI isn't supported anymore 

Nice share! :rock:

Share this post


Link to post
Share on other sites

Did you guys have to do anything specific to get a3_dms working out of the box? When i said I'm using DMS, I meant I had planned on adding it in same day. Then, after reading @Beani's post, I added it in... only to find it won't load missions. Even going back to default settings, nothing.

Share this post


Link to post
Share on other sites

Double check your code I just pulled the coords out lol

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.