Jump to content
Sign in to follow this  
imutep

Spawning Camp Script

Recommended Posts

Last days i spend a lot of time to spawn a russian camp with vehicles, camp guards, patrols .... But without Fort_RazorWires. With 2 example missions i hope this helps beginners to learn spawning objects and units with [X Y] coordinates an (or) with markers as positions. I don't know if this is the best script-way, but it works. :rolleyes:

base1s.jpg base2s.jpg

Download

Script:

/*
Script file for ArmA2
Spawning russian camp with patrols
Created by: Imutep
http://www.assaultmissionstudio.de

Example:
nul = [this] execVM "woodCamp.sqf";

Needed moduls:
Funktions manager

Needed empty markers:
Red = Points of spawning patrols
Green = spawned soldier positions
Yellow = spawned vehicles positions
Black = spawned objects positions
*/ 

_this = createCenter east;
_center_0 = _this;

_group_0 = createGroup _center_0;

_vehicle_0 = objNull;
if (true) then
{
 _this = createVehicle ["RU_WarfareBBarracks", getMarkerPos "basem", [], 0, "CAN_COLLIDE"];
 _vehicle_0 = _this;
 _this setDir 121.874;
 _this setPos getMarkerPos "basem";
};

_vehicle_1 = objNull;
if (true) then
{
 _this = createVehicle ["FlagCarrierRU", getMarkerPos "flagpos", [], 0, "CAN_COLLIDE"];
 _vehicle_2 = _this;
 _this setDir 30.978;
 _this setPos getMarkerPos "flagpos";
};

_vehicle_2 = objNull;
if (true) then
{
 _this = createVehicle ["BTR90_HQ", getMarkerPos "btrpos", [], 0, "CAN_COLLIDE"];
 _vehicle_2 = _this;
 _this setDir 215.01576;
 _this setPos getMarkerPos "btrpos";
};

_vehicle_3 = objNull;
if (true) then
{
 _this = createVehicle ["HeliH", getMarkerPos "hpos", [], 0, "CAN_COLLIDE"];
 _vehicle_3 = _this;
 _this setDir 208.256;
 _this setPos getMarkerPos "hpos";
};

_vehicle_4 = objNull;
if (true) then
{
 _this = createVehicle ["Ka52Black", getMarkerPos "hpos", [], 0, "CAN_COLLIDE"];
 _vehicle_4 = _this;
 _this setDir 208.256;
 _this setPos getMarkerPos "hpos";
};

_vehicle_5 = objNull;
if (true) then
{
 _this = createVehicle ["RU_WarfareBMGNest_PK", getMarkerPos "mgpos", [], 0, "CAN_COLLIDE"];
 _vehicle_6 = _this;
 _this setDir 26.83569;
 _this setPos getMarkerPos "mgpos";
};

_vehicle_6 = objNull;
if (true) then
{
 _this = createVehicle ["RU_WarfareBFieldhHospital", getMarkerPos "sanpos", [], 0, "CAN_COLLIDE"];
 _vehicle_6 = _this;
 _this setDir -59.300674;
 _this setPos getMarkerPos "sanpos";
};

_vehicle_7 = objNull;
if (true) then
{
 _this = createVehicle ["GAZ_Vodnik_MedEvac", getMarkerPos "vodpos", [], 0, "CAN_COLLIDE"];
 _vehicle_7 = _this;
 _this setDir -143.89613;
 _this setPos getMarkerPos "vodpos";
};

_vehicle_8 = objNull;
if (true) then
{
 _this = createVehicle ["Land_CamoNetVar_EAST", getMarkerPos "guardpos", [], 0, "CAN_COLLIDE"];
 _vehicle_8 = _this;
 _this setDir 93.607002;
 _this setPos getMarkerPos "guardpos";
};

_vehicle_9 = objNull;
if (true) then
{
 _this = createVehicle ["Land_Campfire_burning", getMarkerPos "feuerpos", [], 0, "CAN_COLLIDE"];
 _vehicle_9 = _this;
 _this setDir 93.607002;
 _this setPos getMarkerPos "feuerpos";
};

_vehicle_10 = objNull;
if (true) then
{
 _this = createVehicle ["Paleta2", getMarkerPos "palpos", [], 0, "CAN_COLLIDE"];
 _vehicle_10 = _this;
 _this setDir (random 360);
 _this setPos getMarkerPos "palpos";
};

_vehicle_11 = objNull;
if (true) then
{
 _this = createVehicle ["Land_Antenna", getMarkerPos "antpos", [], 0, "CAN_COLLIDE"];
 _vehicle_11 = _this;
 _this setDir 93.607002;
 _this setPos getMarkerPos "antpos";
};

_vehicle_12 = objNull;
if (true) then
{
 _this = createVehicle ["Notice_board", getMarkerPos "tafelpos", [], 0, "CAN_COLLIDE"];
 _vehicle_12 = _this;
 _this setDir 51.876671;
 _this setPos getMarkerPos "tafelpos";
};

_vehicle_13 = objNull;
if (true) then
{
 _this = createVehicle ["RUBasicAmmunitionBox", getMarkerPos "munpos", [], 0, "CAN_COLLIDE"];
 _vehicle_13 = _this;
 _this setDir -57.251743;
 _this setPos getMarkerPos "munpos";
};

_vehicle_14 = objNull;
if (true) then
{
 _this = createVehicle ["RUBasicWeaponsBox", getMarkerPos "munpos_1", [], 0, "CAN_COLLIDE"];
 _vehicle_14 = _this;
 _this setDir 91.353088;
 _this setPos getMarkerPos "munpos_1";
};

_vehicle_15 = objNull;
if (true) then
{
 _this = createVehicle ["UAZ_RU", getMarkerPos "uazpos", [], 0, "CAN_COLLIDE"];
 _vehicle_15 = _this;
 _this setDir (random 360);
 _this setPos getMarkerPos "uazpos";
};

_vehicle_16 = objNull;
if (true) then
{
 _this = createVehicle ["KamazReammo", getMarkerPos "ammokampos", [], 0, "CAN_COLLIDE"];
 _vehicle_16 = _this;
 _this setDir 120;
 _this setPos getMarkerPos "ammokampos";
};

_vehicle_17 = objNull;
if (true) then
{
 _this = createVehicle ["KamazOpen", getMarkerPos "kampos", [], 0, "CAN_COLLIDE"];
 _vehicle_17 = _this;
 _this setDir 120;
 _this setPos getMarkerPos "kampos";
};


//Spawn units in the camp - Each unit who is not in a group, must create a group for it
_group_1 = createGroup _center_0;

_unit_0 = objNull;
if (true) then
{
 _this = _group_1 createUnit ["RU_Soldier_MG", getMarkerpOS "soldat", [], 0, "CAN_COLLIDE"];
 _unit_0 = _this;
 _this setDir 208.256;
};
_group_2 = createGroup _center_0;
_unit_0 = objNull;
if (true) then
{
 _this = _group_2 createUnit ["RU_Soldier_GL", getMarkerpOS "soldat_1", [], 0, "CAN_COLLIDE"];
 _unit_0 = _this;
 _this setDir 118.424;
};

_group_3 = createGroup _center_0;
_unit_0 = objNull;
if (true) then
{
 _this = _group_3 createUnit ["RU_Soldier_LAT", getMarkerpOS "soldat_2", [], 0, "CAN_COLLIDE"];
 _unit_0 = _this;
};

_group_4 = createGroup _center_0;
_unit_0 = objNull;
if (true) then
{
 _this = _group_4 createUnit ["RU_Soldier_Medic", getMarkerpOS "soldat_3", [], 0, "CAN_COLLIDE"];
 _unit_0 = _this;
 _this setDir 208.256;
};

_group_5 = createGroup _center_0;
_unit_0 = objNull;
if (true) then
{
 _this = _group_5 createUnit ["RU_Soldier_AT", getMarkerpOS "soldat_4", [], 0, "CAN_COLLIDE"];
 _unit_0 = _this;
 _this setDir (random 360);
};

_group_6 = createGroup _center_0;
_unit_0 = objNull;
if (true) then
{
 _this = _group_6 createUnit ["RU_Soldier_AA", getMarkerpOS "soldat_5", [], 0, "CAN_COLLIDE"];
 _unit_0 = _this;
 _this setDir (random 360);
};


//Vodnik in the camp
[(getMarkerPos "vodpos_1"), Random 360, "GAZ_Vodnik", east] call BIS_fnc_spawnVehicle;

//Group will man nearby static defenses and guard the position in the camp.
_guardunits = 4 + Random 2;
_guardgrp = [(getMarkerpos "guardpos"),east,_guardunits] call bis_fnc_spawngroup;
[_guardgrp, (getMarkerpos "guardpos")] call BIS_fnc_taskDefend;

//Create a random patrol of several waypoints around a given position in the camp (200 meter waypoint distance)
_patrolunits = 5 + Random 3;
_patrolgrp = [(getMarkerpos "patrolpos"),east,_patrolunits] call bis_fnc_spawngroup;
[_patrolgrp, (getMarkerPos "guardpos"), 200] call BIS_fnc_taskPatrol;

Spawned objects in the Camp:

* Basis Baracke

* Helipad

* KA-52

* BTR-90

* UAZ

* Vodnik

* Vodnik_mediEvac

* Kamo Truck

* Kamo Reammo Truck

* Field hospital

* MG position

* Camo net

* Mapboard

* Ammo boxes

* camp fire

* Paletas

* Antenna

* Guards

* Wood patrol

* Camp guards

One thing is, that the spawned soldiers all look to the north. I set any azimuts (setDir positions), but they always look gen north. I don't know why. Any ideas to fix this would be nice.

Enjoy!

Share this post


Link to post
Share on other sites

One thing is, that the spawned soldiers all look to the north. I set any azimuts (setDir positions), but they always look gen north. I don't know why. Any ideas to fix this would be nice.

Try setVectorDir.

Share this post


Link to post
Share on other sites

Thx Big Dawg KS, but it doesn't work. I think the VectorDir command is only for objects. I tryed the lookAt command now. Strange, that setDir doesn't work.

Share this post


Link to post
Share on other sites

SetVectorDir should work on men. Perhaps try setVectorDirAndUp. Also make sure your vector is correct.

Share this post


Link to post
Share on other sites

I would try delaying the "setDir" command.

Both setDir and the setVector commands work on soldiers, that much is certain so the problem will be somewhere else.

Oh and I would use the "_this" variable only for parameters passed to the script, nothing else. Not sure if it can cause problems, I just wouldn't do it.

Share this post


Link to post
Share on other sites

Ok, i changed the "_this" variable to another one. But its the same. They look to the north. I give up.....till tomorrow. Thx for the tips!

_group_4 = createGroup _center_0;
_unit_0 = objNull;
if (true) then
{
 _this = _group_4 createUnit ["RU_Soldier_Medic", getMarkerpOS "soldat_3", [], 0, "CAN_COLLIDE"];
 _unit_0 setDir 208.256;
};

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  

×