Jump to content
L. Jessee

Spawning East Units Into Shoothouse

Recommended Posts

My goal here is to, from a laptop station execute a script to spawn enemy units into a shoot house. (the goal basically, is to have popup targets that shoot back, hence the disableAI "MOVE") So that after it is cleared the units can be spawned in again. I do have a repetitive cleanup script that should remove the dead units. I am using "old leaflets" for the markers for the spawn locations '_cqcspawns'. The script creates a group needed for the creatUnit. I am getting an error on line 12 for the getPosATL command. Error getposatl: Type Array, expected Object. I was hoping that someone more knowledgeable than me might give some insight as to making this script work. Below is the script. Thank you in advance.

 

/* Prevents dedicated server running script */
if (isDedicated) exitWith {};
/* Private variables */
private ["_cqcLiveTargets","_cqcSpawns","_azimuth"];
/* createGroup [side, deleteWhenEmpty] needed for createUnit function later */
private _cqcLiveTargets = createGroup east;
/* Define spawn locations using variable names of leaflets as markers */
private _cqcSpawns = [cqcspawn_001,cqcspawn_002,cqcspawn_003,cqcspawn_004,cqcspawn_005,cqcspawn_006,cqcspawn_007];
/* type createUnit [position, group, init, skill, rank] function for spawning a unit */
 {
  "O_G_Soldier_lite_F" createUnit [
    getPosATL _cqcSpawns,
    _cqcLiveTargets,
    "call{_this disableAI "MOVE"; _azimuth = getDir _cqcspawns; _this setDir _azimuth;}",
    0.1,
    "PRIVATE"
];} forEach _cqcSpawns;

 

Share this post


Link to post
Share on other sites
/* Prevents dedicated server running script */
if (isDedicated) exitWith {};	//Never going to be dedicated if calling from an action

/* Private variables */
private ["_cqcLiveTargets","_cqcSpawns","_azimuth"];

/* createGroup [side, deleteWhenEmpty] needed for createUnit function later */
private _cqcLiveTargets = createGroup east;

/* Define spawn locations using variable names of leaflets as markers */
private _cqcSpawns = [cqcspawn_001,cqcspawn_002,cqcspawn_003,cqcspawn_004,cqcspawn_005,cqcspawn_006,cqcspawn_007];

/* type createUnit [position, group, init, skill, rank] function for spawning a unit */
//Would recommend using the other syntax of create unit
 {
  "O_G_Soldier_lite_F" createUnit [
    getPosATL _cqcSpawns,	//Passing whole array, should be _x current forEach element
    _cqcLiveTargets,
    //STRING in STRING notice color of MOVE
    //Unit is this not _this
    //again dir of _cqcspawns array not _x
    "call{_this disableAI "MOVE"; _azimuth = getDir _cqcspawns; _this setDir _azimuth;}",
    0.1,
    "PRIVATE"
];} forEach _cqcSpawns; 

So...

Spoiler

// Private variables
private ["_cqcLiveTargets","_cqcSpawns"];

// createGroup [side, deleteWhenEmpty] needed for createUnit function later
// delete when empty so next time this runs its not adding infinite groups
private _cqcLiveTargets = createGroup[ east, true ];

// Define spawn locations using variable names of leaflets as markers
private _cqcSpawns = [cqcspawn_001,cqcspawn_002,cqcspawn_003,cqcspawn_004,cqcspawn_005,cqcspawn_006,cqcspawn_007];

// _unit = group createUnit [type, position, markers, placement, special]
{
	private _unit = _cqcLiveTargets createUnit[ "O_G_Soldier_lite_F", getPosATL _x, [], 0, "NONE" ];
	
	_unit disableAI "MOVE";
	_unit setDir getDir _x;
	_unit setUnitRank "PRIVATE";
	_unit setSkill 0.1;
} forEach _cqcSpawns; 

 

Share this post


Link to post
Share on other sites

Thank you for the reply... I'm going to look over this very carefully to analyze the logic. I want to make sure I understand it correctly.

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

×