OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: JasonO on 14 May 2007, 00:23:58
-
Hi
I'm trying to create a squad of units in a script, however I can't seem to do it.
I read that a group MUST exist for the unit to spawn, so I made a unit near me (incase the unit's spawn there, i kept this unit close) with a presense of 0. Then in this units init field I have put:
egroup1 = group this
Nothing happened with this code when I want to spawn the unit. There is around 5-10 seconds before this line is run:
_unit_leader = "soldierEG" createUnit [_pos, egroup1]
CreateVehicle works fine using the _pos variable and the same unit type, but for some reason CreateUnit doesnt.
I can't use createvehicle because these units are brain dead. They don't move or shoot, just blink now and again.
I want to make a whole squad in egroup1 so I can move them to a location (which I can do with already created units).
Thanks for your help :)
-
Try this, but make sure more west units are present on the map, else you would need to call createCenter too.
// createwgroup.sqf
// [getMarkerPos "mk_squad"]execVM "gratewgroup.sqf"
//
private["_posleader", "_grpwest", "_pos", "_unit", "_i", "_type"];
_posleader = _this select 0;
_grpwest = createGroup west;
for [{_i = 0},{_i < 8},{_i = _i + 1}] do
{
if (_i == 0) then
{
_type = "TeamLeaderW";
}
else
{
_type = "SoldierWB";
};
_pos = [(_posleader select 0)+2*_i,(_posleader select 1)+2*_i, 0];
_unit = _grpwest createUnit [_type,_pos, [], 0, "FORM"];
if (_i == 0) then
{
_grpwest selectLeader _unit;
_unit setSkill 0.5;
_unit setRank "CORPORAL";
}
else
{
_unit setSkill 0.3;
_unit setRank "PRIVATE";
};
};
-
'|#|};'
Error Missing {
Can't see which bracket is causing that myself. You'll probably find it straight away.
Thanks for the reply though.
-
heres how im making some units and UAZ spawn on an invisible H (named: specnatz)
_specops = createGroup east;
_uaz = createVehicle ["UAZMG", (position specnatz), [], 0, "NONE"];
_spec1 = _specops createUnit ["SoldierESaboteurBizon", (position specnatz), [] ,0 ,"seargent"];
_spec1 setDir random 360;
_specops selectLeader _spec1;
_spec1 disableAI "MOVE";
_spec1 allowfleeing 0;
_spec1 setBehaviour "AWARE";
_spec2 = _specops createUnit ["SoldierESaboteurBizon", (position specnatz), [] ,0 ,"private"];
_spec2 setDir random 360;
_spec2 disableAI "MOVE";
_spec2 allowfleeing 0;
_spec2 setBehaviour "AWARE";
_spec3 = _specops createUnit ["SoldierESaboteur", (position specnatz), [] ,0 ,"private"];
_spec3 setDir random 360;
_spec3 disableAI "MOVE";
_spec3 allowfleeing 0;
_spec3 setBehaviour "AWARE";
_spec4 = _specops createUnit ["SoldierESaboteur", (position specnatz), [] ,0 ,"corporal"];
_spec4 MoveInGunner _UAZ;
_spec4 setDir random 360;
_spec4 disableAI "MOVE";
_spec4 allowfleeing 0;
_spec4 setBehaviour "AWARE";
_spec5 = _specops createUnit ["SoldierESaboteur", (position specnatz), [] ,0 ,"private"];
_spec5 setDir random 360;
_spec5 disableAI "MOVE";
_spec5 allowfleeing 0;
_spec5 setBehaviour "AWARE";
_spec6 = _specops createUnit ["SoldierESaboteur", (position specnatz), [] ,0 ,"private"];
_spec6 setDir random 360;
_spec6 disableAI "MOVE";
_spec6 allowfleeing 0;
_spec6 setBehaviour "AWARE";
_specops setCombatMode "RED";
-
Can't see which bracket is causing that myself. You'll probably find it straight away.
No problem in my end. Just did the following:
- Added a marker named "mk_group"
- And in the init.sqs: [getMarkerPos "mk_group"]execVM"createwgroup.sqf"
It works fine.
-
Ahh that's it thanks Mandoble. I wasn't executing the SQF file properly (exec not execVM). My SQF knowlage lacks, which is why I didn't see this error lol.
OK this works and I get a west AI squad. I've tried getting east to appear but no luck.
Edit: East now appear ok. I wen't back to read what else you said and saw you put this:
..make sure more west units are present on the map, else you would need to call createCenter too.
I have no east units yet so I had to do this:
_cntreast = createCenter east;
That worked.
Edit 2 : Argghh. OK the squad spawn and then move to a position I give them. However they don't shoot any targets or respond to them at all, they just run past.
Fixed again.. Just needed 1 enemy AI placed in the editor with 0 possibilty of presence, and they now move to my position and engage when they see me or my squad.
Thanks Mandoble, your a star! :good: