Jump to content

Photo
- - - - -

How to spawn unit at specific time ?


  • Please log in to reply
13 replies to this topic
Thread Starter
Wiggum
Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 19 February 2010 - 22:45 #1

Hi,

i searched this forum and the Editing Guide but found no answer.
How can i make a unit spawn or start another script at a specific time like 07:00 or something ?

My mission starts at 05:00 and the unit should spawn at 06:00, is there some other way then "sleep 3600" ?

Manzilla
Manzilla

    First Lieutenant

  • Members
  • 5142 posts

Posted 20 February 2010 - 00:53 #2

Hi,

i searched this forum and the Editing Guide but found no answer.
How can i make a unit spawn or start another script at a specific time like 07:00 or something ?

My mission starts at 05:00 and the unit should spawn at 06:00, is there some other way then "sleep 3600" ?


Oh damn this is a great question, I could use this in my current WIP. I was just doing a search for it but no real luck. I eagerly wait to see a solution.
:coop: :yay::yay::yay: (God damn bananas..... again)

Join the most rootin', tootin'est crew on these here forums! That's right folks we're darn tootin'.

Mike Tyson's ode to Manzilla's SP playing style:

My style is impetuous. My defense is impregnable and I'm just ferocious.... I want your heart, I want to eat his children! Praise be to Allah!


soccerboy
soccerboy

    Corporal

  • Members
  • 91 posts

Posted 20 February 2010 - 01:40 #3

Hi,

i searched this forum and the Editing Guide but found no answer.
How can i make a unit spawn or start another script at a specific time like 07:00 or something ?

My mission starts at 05:00 and the unit should spawn at 06:00, is there some other way then "sleep 3600" ?


the way i would do it is to write a script to run on mission start and just let it wait until the time spent has reached your limit so to say:

waituntil {((time) >= 3600)}

More Info

another way to do it is maybe use a trigger from within the editor to just wait for 3600 seconds (countdown/timeout) or use the condition field of that trigger with:
((time) >= 3600)

sorry if i can't come up with anything better :)

Thread Starter
Wiggum
Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 20 February 2010 - 14:06 #4

thanks soccerboy !

i have another problem with my spawn, i want to spawn a unit and give it a name, nut how can i give a spawned unit a name ?

my script:

if (isServer) then {
_pos = getMarkerPos "ziel";
_skill = [0.8, 0.8];
_side = RESISTANCE;
_units = ["Functionary2"];

_newGroup = [_pos, _side, _units, [], [], _skill] call BIS_fnc_spawnGroup;

_waypoint0 = _newGroup addwaypoint[getmarkerpos"WP1",0];
_waypoint0 setwaypointtype"Move";
_waypoint0 setWaypointBehaviour "Safe";
_waypoint0 setWaypointSpeed "LIMITED";

_waypoint1 = _newGroup addwaypoint[getmarkerpos"WP2",0];
_waypoint1 setwaypointtype "GETIN NEAREST";
_waypoint1 setWaypointBehaviour "Safe";
_waypoint1 setWaypointSpeed "LIMITED";

_waypoint2 = _newGroup addwaypoint[getmarkerpos"WP3",0];
_waypoint2 setwaypointtype"Move";
_waypoint2 setWaypointBehaviour "Safe";
_waypoint2 setWaypointSpeed "NORMAL";

_waypoint3 = _newGroup addwaypoint[getmarkerpos"WP4",0];
_waypoint3 setwaypointtype"Move";
_waypoint3 setWaypointBehaviour "Safe";
_waypoint3 setWaypointSpeed "NORMAL";
};



soccerboy
soccerboy

    Corporal

  • Members
  • 91 posts

Posted 20 February 2010 - 15:50 #5

thanks soccerboy !

i have another problem with my spawn, i want to spawn a unit and give it a name, nut how can i give a spawned unit a name ?

my script:


what exactly are you trying to do with the unit names?
you could just save the names in a global array like for instance "group_array = (units _newgroup)" then you could easily access the names with "select (index number)" without () :)

lets imagine your script creates two units then it'll be "group_array = [unit1, unit2]" then if you want to check if they're still alive or set damage or what ever you just select the index of the unit you want to access and do what ever you want to him like "_unit = group_array select 0".

you also can put that command anywhere after the group has been created before the script exits.

if you need more info about arrays here is a nice page to read up on them

Edited by soccerboy, 20 February 2010 - 15:52.


Imutep
Imutep

    Master Gunnery Sergeant

  • Members
  • 1365 posts

Posted 20 February 2010 - 16:15 #6

Hi,

i searched this forum and the Editing Guide but found no answer.
How can i make a unit spawn or start another script at a specific time like 07:00 or something ?

My mission starts at 05:00 and the unit should spawn at 06:00, is there some other way then "sleep 3600" ?

Use the dayTime command.
if (daytime == 6.00) then 
{
...................
};
For spawning units with name, take a look at Tajins script here.

Edited by Imutep, 20 February 2010 - 16:18.

Posted Image
Assault Mission Studio - German Mission Editing && Scripting Website

Thread Starter
Wiggum
Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 20 February 2010 - 16:42 #7

Thanks soccerboy and Imutep !

I simple want to give every spawned unit a name so i can ckeck if they are alive. At the moment i dont understand how to setup it correctly, what comes in the triggers ?

I want the spawned unit name = target1 and in a trigger as condition (!alive target1).

Manzilla
Manzilla

    First Lieutenant

  • Members
  • 5142 posts

Posted 20 February 2010 - 17:01 #8

what exactly are you trying to do with the unit names?
you could just save the names in a global array like for instance "group_array = (units _newgroup)" then you could easily access the names with "select (index number)" without () :)

lets imagine your script creates two units then it'll be "group_array = [unit1, unit2]" then if you want to check if they're still alive or set damage or what ever you just select the index of the unit you want to access and do what ever you want to him like "_unit = group_array select 0".

you also can put that command anywhere after the group has been created before the script exits.

if you need more info about arrays here is a nice page to read up on them


soccerboy,

Good f*&$in' post. I've never been able to figure what this is all about. That really helped. Question though, could you show how we could use this to set damage and check if they are still alive. Sometimes the BIKI makes my head explode, but it sure is a helpful thing nonetheless.

Thanks in advance.
:coop: :yay::yay::yay: (God damn bananas..... again)

Join the most rootin', tootin'est crew on these here forums! That's right folks we're darn tootin'.

Mike Tyson's ode to Manzilla's SP playing style:

My style is impetuous. My defense is impregnable and I'm just ferocious.... I want your heart, I want to eat his children! Praise be to Allah!


soccerboy
soccerboy

    Corporal

  • Members
  • 91 posts

Posted 20 February 2010 - 18:31 #9

Use the dayTime command.

if (daytime == 6.00) then 
{
...................
};
For spawning units with name, take a look at Tajins script here.


ah i totally forgot about that command :)


soccerboy,

Good f*&$in' post. I've never been able to figure what this is all about. That really helped. Question though, could you show how we could use this to set damage and check if they are still alive. Sometimes the BIKI makes my head explode, but it sure is a helpful thing nonetheless.

Thanks in advance.


glad i could help somewhere. over the past few weeks/months i've become very proficient with arrays and i love using them to pass information around :)

when it comes to that kind of things i like to use a "For loop" because i just find it to be easier readable as to what you're really doing and its better if you want to include ascending or descending number variables to your commands.

like if you're passing an array of units to check if those units are still alive you would go:
here and here is some info on for loops.

for both examples we'll call the unit array "array = [unit1, unit2]". now we can check those units.

for [{_u = 0},{_u < (count (array))},{_u = _u + 1}] do
{
      _unit = array select _u;
      if (alive _unit) then
      {
             _unit setdamage 1;
      };
};

you could also probably do it with a foreach command that i don't have much experience with but i'm guessing it would look like this (foreach is good if you're not trying to add other information like ascending or descending numbers. i can be wrong however since i don't use much of foreach commands):
here is some info on the foreach command.


{
     if (alive _x) then
     {
             _x setdamage 1;
     };
} foreach array;

the way i understand how foreach works is "{code} foreach array" so i can only assume that my foreach demo is correct however i can't try that out at this moment but i will at a later time.

if you need more help or have more questions feel free to PM me or post in this topic. i'll be keeping my eye on this one for a while to help out where i can :)

Edited by soccerboy, 20 February 2010 - 18:48.
updated link for the for loop


Thread Starter
Wiggum
Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 20 February 2010 - 18:48 #10

Thanks again soccerboy !
But i dont know where i should put "array = [unit1, unit2]"...

soccerboy
soccerboy

    Corporal

  • Members
  • 91 posts

Posted 20 February 2010 - 18:55 #11

Thanks again soccerboy !
But i dont know where i should put "array = [unit1, unit2]"...


oh that's just an example as to what the array would look like to the computer, if you're trying to get the units from a group you would use
array_name = units groupname

or if you only know one units name then

array_name = units group unitname

the breakdown of it is
"units" means get the units of a known group name into an array
"group" means get the known unit's group name

i'm going to take your script for example the way you have it setup is you're unit's group name will be "_newgroup" so to get the units name in a global array it would be
array_name = units _newgroup

Group
Units

i hope that clarifies things a bit better :)

Edited by soccerboy, 20 February 2010 - 18:58.


Thread Starter
Wiggum
Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 02 March 2010 - 20:58 #12

Sorry, me again...

But i dont get it...i read some stuff about "arrays" but i dont know how this works.
Can someone please make a little example mission that has just a empty car that i can spawn with a trigger RADIO ALPHA.
Now if the spawned car is destroyed a hint message should tell me something, i mean in "Conditions" field of another trigger !(alive .... <- name of car)

Please, i think this is so important for any mission maker !

JW Custom
JW Custom

    Chief Warrant Officer

  • Members
  • 3261 posts

Posted 02 March 2010 - 21:45 #13

Sorry, me again...

But i dont get it...i read some stuff about "arrays" but i dont know how this works.
Can someone please make a little example mission that has just a empty car that i can spawn with a trigger RADIO ALPHA.
Now if the spawned car is destroyed a hint message should tell me something, i mean in "Conditions" field of another trigger !(alive .... <- name of car)

Please, i think this is so important for any mission maker !


Here you go, as simple as it gets :)

http://www.filefacto...rSpawn.utes.zip
Casual ArmA Players it's all about teamwork and fun, join now!

ArmA2 Missions: http://arma2missions.webege.com/

Thread Starter
Wiggum
Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 02 March 2010 - 22:29 #14

Thanks JW Custom for your help.

If you want to know how to give a spawned Unit a name look here:
if (true) then
{
  _this = createVehicle ["ACE_UH60M", markerPos "AMS_heloStart", [], 0, "FORM"];
  [COLOR="Red"]_this setVehicleVarName "unitname";
  unitname = _this;[/COLOR]
};
http://community.bis...tVehicleVarName

In your spawn script it could look like this:
_helo2 = createVehicle ["ACE_UH60M", markerPos "AMS_heloStart2", [], 0, "FLY"];
_helo2 setDir -118.24;
[COLOR="Red"]_helo2 setVehicleVarName "heli1";
 heli1 = _helo2;[/COLOR]

Thanks to Imutep and JW Custom !