Results 1 to 6 of 6

Thread: Random spawn script assign waypoint

  1. #1

    Random spawn script assign waypoint

    I'm trying to spawn random enemy units at random markers and have them drive to a location.

    The random spawn at random markers works fine but I can't figure out how to move them, ie start driving.

    Spoiler:


    Where am I going wrong, I guess it's an issue calling them _spawn ?!

    Thanks
    I have searched the forums, Google, MSN, garage, shed, car, pockets, kitchen draws, pants, socks, down the sofa, under the bed, behind the Monitor, ashtray, belly button, cupboards, under cups, down the toilet, under the carpet, behind curtains, in Duvet cover, Wardrobe, inside the DVD player, searched the dog basket, "don't have a dog basket but I would have if I'd had one, and cannot find the answer to my question.
    So here I am, on my hands and knees, begging for someone to have the answer to the question I may have posed above.



    KonI™

  2. #2
    Have you tried using a waypoint?

  3. #3
    Gunnery Sergeant Koni's Avatar
    Join Date
    Jul 7 2006
    Location
    England
    Posts
    457
    Author of the Thread
    I have added a waypoint which works fine when spawning single units but when I try using the same way of adding a waypoint spawning a random unit it dosen't seem to work.

    _pos1 = getMarkerPos "airbase";
    _grp = _spawn;
    _wp = _grp addWaypoint [_pos1, 0];
    [_grp, 0] setWaypointType "SAD";



    Normally I would spawn a unit like this

    //////////////////////////////////////////////////////////////////////////////////////////////////
    _pos = getmarkerPos "spawn1";
    _skill = [0.1, 0.5];
    _side = east;
    _units = ["T72_RU"];

    r1 = [_pos, _side, _units, [], [], _skill] call BIS_fnc_spawnGroup;
    {
    _x setskill ["aimingAccuracy",0.75];
    _x setskill ["spotDistance",0.95];
    _x setskill ["spotTime",0.85];
    _x setskill ["courage",0.85];
    _x setskill ["commanding",0.85];
    _x setskill ["aimingShake",0.65];
    _x setskill ["aimingSpeed",0.85];
    } foreach units a1;

    sleep 0.5;


    _pos1 = getMarkerPos "airbase";
    _grp = a1;
    _wp = _grp addWaypoint [_pos1, 0];
    [_grp, 0] setWaypointType "SAD";

    //////////////////////////////////////////////////////////////////////////////////////////////////

    and the waypoint works fine, but it seems that using bis_fnc_spawnvehicle you can't name the group like using bis_fnc_spawnGroup, and using spawngroup dosen't spawn a random unit

  4. #4
    An extract from BIS_fnc_spawnVehicle:
    Code:
    Parameter(s):
    	_this select 0: desired position (Array).
    	_this select 1: desired azimuth (Number).
    	_this select 2: type of the vehicle (String).
    	_this select 3: side or existing group (Side or Group).
    
    Returns:
    	Array:
    	0: new vehicle (Object).
    	1: all crew (Array of Objects).
    	2: vehicle's group (Group).
    So, the problem is that you are using an array to add the waypoint, and not a group or vehicle.
    Do something like this instead:

    Code:
    _list = [_pos, _dir, _class, _side] call BIS_fnc_spawnVehicle;//array
    _vehicle = _list select 0;//object
    _crew = _list select 1;//array
    _grp = _list select 2;//group
    
    _wp = _grp addWaypoint [_pos1, 0];
    [_grp, 0] setWaypointType "SAD";
    _neo_
    Proud community admin/member of The Tour of Teamrespawn

  5. #5
    Gunnery Sergeant Koni's Avatar
    Join Date
    Jul 7 2006
    Location
    England
    Posts
    457
    Author of the Thread
    Thanks for your reply but I don't understand how I join up my code for spawning a random unit and what you have replied with.

    Sorry for being a bit slow on this.


    markers = ["spawn1","spawn2","spawn3","spawn4","spawn5"];
    _pos = markers select (floor random 5);
    _pos = getmarkerPos _pos;
    _vehicles = ["BMP3", "2S6M_Tunguska", "BTR90","T72_RU", "GAZ_Vodnik_HMG", "GAZ_Vodnik"] call BIS_fnc_selectRandom;
    _spawn = [_Pos, 1, _vehicles , East] call bis_fnc_spawnvehicle;


    That bit obviously chooses a random marker to spawn at and a random Armoured unit too.

    What I don't understand is what I do with this

    _list = [_pos, _dir, _class, _side] call BIS_fnc_spawnVehicle;//array
    _vehicle = _list select 0;//object
    _crew = _list select 1;//array
    _grp = _list select 2;//group

    _wp = _grp addWaypoint [_pos1, 0];
    [_grp, 0] setWaypointType "SAD";


    Sorry.

    ---------- Post added at 15:08 ---------- Previous post was at 14:16 ----------

    Got it working now but by bodging it a lot.

    I ended up changing side as EAST to a exsisting group name of the same side hidden where I wanted the random spawned unit to move to.


    Spoiler:


    I used a Russian soldier with no ammo with this lot in it's init field
    a1= group this; this hideobject true; this setcaptive true; this allowdamage false;

    and in my test it works fine, though not a propper way to get it working

    Just need to transfer this into the mission im making to make sure it still fits ok.

    If anyone could explain exactly how to do this propperly I'd like to learn.

    Thanks
    Last edited by Koni; Mar 21 2012 at 15:55.

  6. #6
    I shall not insult moderators
    Join Date
    Nov 25 2010
    Posts
    1,576
    You need to understand arrays and how to select the elements:
    http://community.bistudio.com/wiki/Array

    Arma2 Functions
    http://community.bistudio.com/wiki/Category:ArmA_2:_Functions

    BIS_fnc_spawnVehicle
    http://community.bistudio.com/wiki/BIS_fnc_spawnVehicle

    You will see on the BIS_fnc_spawnVehicle that using the command returns an array that is stored in the variable you call it with (you use _spawn).
    Return Value:
    Array - 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group)

    so _spawn is actually an array containing the following elements: [vehicle, crew, group]

    Now you can use those three items you just have to select them which is what Neo was explaining.

Similar Threads

  1. Random Spawn Generator script
    By OzeRick in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 2
    Last Post: Sep 24 2012, 18:03
  2. AI Random Spawn Script
    By Rifle22 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 5
    Last Post: Aug 28 2011, 14:28
  3. how to assign a unit to be a gunner using waypoint
    By gibson23 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 1
    Last Post: Jun 3 2011, 17:07
  4. gear assign script issues
    By galzohar in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 6
    Last Post: Nov 1 2009, 01:06
  5. Random Waypoint
    By jwalstab in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 4
    Last Post: Sep 11 2009, 02:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •