Home   Help Search Login Register  

Author Topic: How to set way points for a respawning man.  (Read 1995 times)

0 Members and 1 Guest are viewing this topic.

Offline D007

  • Members
  • *
How to set way points for a respawning man.
« on: 11 Aug 2008, 01:34:46 »
Thing is I need to spawn in 2 men and get them into a brdm.
We don't want them to be grouped to anyone but themselves but I guess that doesn't matter.

We have this brdm patrolling a small area and if it dies, it respawns and creates men that respawn to the vehicle.
They always run after the person we group them to though and we can't figure out for the life of us, how to make them go to a waypoint and cycle between maybe 2-4 waypoints.

they just want to chase their group leader, unless i disableai "move" or group them to a gamelogic.
I am not familiar with setting waypoints in a script at all, but i have been trying for like 2 days now..lol..
I'm just hoping someone could spare me another long night of errors and maybe explain to me how i can get these two men i spawn in, named
brdmm1 and brdmm2, to go to waypoints and cycle between them.

I assume an execvm would be necessary with a looped file, setting waits at every waypoint, for about 60 seconds.
the vehicle and the people all spawn in with names..
the vehicle is named: brdm1
the driver is: brdmm1
the gunner is: brdmm2

as it is i have it set up with like this. "brdm.sqs"
Code: [Select]

?! (local server): exit

_vehicle = _this select 0
_delay = _this select 1
_pos = _this select 2
_dir = _this select 3

; defining possible vehicle positions
_driver = _vehicle emptypositions "driver"
_gunner = _vehicle emptypositions "gunner"
_commander = _vehicle emptypositions "Commander"
_crew = _vehicle emptypositions "Cargo"

? (_pos == 0): _startpos = getpos _vehicle
? (_dir == 361): _startdir = getdir _vehicle

#waiting
; waiting for Vehicle is disabled
@ !(canmove _vehicle) &! (canfire _vehicle)

; checking if vehicle still is manned
~_delay
? (canmove _vehicle) && (canfire _vehicle): goto "waiting"
_new = typeof _vehicle
deletevehicle _vehicle
brdm1 = _new createvehicle _startpos
brdm1 setpos _startpos
brdm1 setdir _startdir
[brdm1, _delay, _pos, _dir] exec "brdm1.sqs"
[] exec "rebrdm.sqf";
exit


then "rebrdm.sqf"
brdm11 is the name of the invisible heli marker we use, to spawn in the soliders at.
M2officer is the name of the man im grouping them to at the moment.
because I don't know how else to do it XD.

Code: [Select]
_unit=brdmm1;"SoldierWB" createUnit [brdm11, m2officer],brdmm1, 1, colonel;this setPos [getPos brdm11 select 0, getPos brdm11 select 1, (getPos this select 2) +0];this setBehaviour "aware";removeallweapons this;this addweapon nvgoggles;this moveindriver brdm1; this addEventHandler ["killed",  {      _Killer = _this select 1;      _id=([man0] find _Killer)+1;  if(_id>0)then{["punishmentevent", _id] call SPON_publishGlobalEvent;}}];
_unit=brdmm2;"SoldierWB" createUnit [brdm11, m2officer],brdmm2, 1, colonel;this setPos [getPos brdm11 select 0, getPos brdm11 select 1, (getPos this select 2) +0];this setBehaviour "aware";removeallweapons this;this addweapon nvgoggles;this moveingunner brdm1; this addEventHandler ["killed",  {      _Killer = _this select 1;      _id=([man0] find _Killer)+1;  if(_id>0)then{["punishmentevent", _id] call SPON_publishGlobalEvent;}}];

exit;

how could I execute another script to tell them where to cycle to please?
or merge it into these.. or ..anything that will get the job done?
We'd really appreciate the help..lol..
thanks..
« Last Edit: 19 Aug 2008, 03:39:24 by D007 »

Offline ModestNovice

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #1 on: 11 Aug 2008, 01:57:49 »
well first of all, you state two commands that are wrong I believe.

1) you say @!(canmove _vehicle) &! (canfire _vehicle)
which I think you meant   @!(canmove _vehicle) && (!canfire _vehicle)

2) execVM is needed for sqf,  [] exec "rebrdm.sqf" =  is not valid.


ALSO:
in your "rebrdm.sqf", you use the word "this", which typically is used in the init line of a unit. So using it in a script, will not catch your brdm, but instead, will be the player, so your vehicle will be moving to the player, and you will be setting the player to new behaviour.


NOW: I believe there is a setWaypoint command, ya can always check the Biki.
But, you can do, _brdmm1 doMove (getMarkerPos "Move1")
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline D007

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #2 on: 11 Aug 2008, 04:52:52 »
wow..lol.. and I thought I was only a little wrong XD..

great news though.. ty..
any info on if im creating a group correctly or how to do so? lol
I checked the wiki, I guess I did that wrong as well..
 ug..

I was trying to
creategroup merc
merc join merc
brdmm1 join merc
brdmm2 join merc

so i can get them off the m2officer because they keep trying to go back to him ><..
I'll look into that more too i guess, but if anyone wants to offer a simple explanation on how to do this correctly I'd sure not mind.. :)..
Believe me, I've been trying.. ???

funny thing about the [] exec "brdm.sqf" not being valid is.. it works..lol.. 100% of the time..XD..
I'm changing it regardless though, since it's invalid..
I assume simply changing it to an sqs would suffice.

thanks a bunch for the help Dachews.. much appreciated..
« Last Edit: 11 Aug 2008, 04:57:22 by D007 »

Offline ModestNovice

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #3 on: 11 Aug 2008, 05:32:00 »
np.

Well for a group.

Make the 2 guys leave the officers group:
Code: [Select]
brdmm1 joinGroup Null
brdmm2 joinGroup Null

or if you choose to put it in an array, which make it easier if ya want to add more units in:
Code: [Select]
_units = [brdmm1, brdmm2];
{_x joinGroup Null} foreach _units;
« Last Edit: 11 Aug 2008, 05:34:10 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline D007

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #4 on: 12 Aug 2008, 04:30:12 »
cool thanks again Chews XD..

I went through my old files, after you told me I was incorrectly formatting things and remade them to be correct.
Couple of them weren't working like I thought they were. :blink:.. oops..
thanks again for the new info.
I will put it to use right now.
Hopefully i can answer more questions than I ask here eventually 

Edit:
ok.. i got this far with the waypoints and I can see their noticing them..
an error comes up at the end of the script though..
error is always at wp4's line and always says "error missing )"
do i need to loop it or something?
I'll try to create an array.. never done that before..lol..
I know I read somewhere about a max of 10000 loops..
and yada yada..
1st time for everything .

but here's the code..
I gotta be close. :good:
Code: [Select]

 #waypoints
 brdmm1 moveindriver brdm1
 brdmm2 moveingunner brdm1
 ~10
 brdmm1 doMove (getMarkerPos "wp1")
  @(brdmm1already wp1)
 ~10
 brdmm1 doMove (getMarkerPos "wp2")
  @(brdmm1already wp2)
 ~10
 brdmm1 doMove (getMarkerPos "wp3")
  @(brdmm1already wp3)
 ~10
 brdmm1 doMove (getMarkerPos "wp4")
  @(brdmm1already wp4)
  goto "waypoints"


or not? lol... :dunno:
« Last Edit: 12 Aug 2008, 06:08:36 by D007 »

Offline ModestNovice

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #5 on: 12 Aug 2008, 06:01:20 »
so what are you try to do here?

Have them continuously go through the waypoints?


« Last Edit: 12 Aug 2008, 06:07:31 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline D007

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #6 on: 12 Aug 2008, 06:06:34 »
yep..   :D

I tried to make it an execvm in an sqf, but it crashed my arma..lol..
I could of done it wrong of course..

Offline ModestNovice

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #7 on: 12 Aug 2008, 06:08:37 »
waypoint.sqf
Code: [Select]
for [{_i=0}, {_i<1}, {_i=_i}] do
 {
 brdmm1 moveInDriver brdm1;
 brdmm2 moveInGunner brdm1;
 Sleep 10;
 brdmm1 doMove (getMarkerPos "wp1");
 Sleep .4;
 atwp1 = true;
 waitUntil {atwp1};
 Sleep 10;
 brdmm1 doMove (getMarkerPos "wp2");
 Sleep .4;
 atwp2 = true;
 waitUntil {atwp2};
 Sleep 10;
 brdmm1 doMove (getMarkerPos "wp3");
 Sleep .4;
 atwp3 = true;
 waitUntil {atwp3};
 Sleep 10;
 brdmm1 doMove (getMarkerPos "wp4");
 Sleep 5;
 };


---------------------------------------------------------

in Init.sqf
Code: [Select]
atwp1 = false;
atwp2 = false;
atwp3 = false;
[] execVM "waypoint.sqf";


ALSO: the reason for crash arma = GoTo command is not supported in sqf
 
« Last Edit: 12 Aug 2008, 06:11:22 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline D007

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #8 on: 12 Aug 2008, 06:13:08 »
jebuss..
and no I was not close is the final answer...
right when I think I know something.. bam.
nope...lol..

but it was supposed to be a execvm.. dangit..lol.
I figured since it ran constantly it would need to be..
but that first crash made me bug out XD..

well thanks again Chews.. sorry to bug ya so much..
I read the comref and the biki religiously.
I try everything that makes sense to me.
I use old scripts and do whatever I can to understand this stuff
and learn it..lol..

To bad theres no arma editing tutors..lol.
well, you kinda are..  :clap:

lol thanks again :)
« Last Edit: 12 Aug 2008, 06:16:14 by D007 »

Offline ModestNovice

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #9 on: 12 Aug 2008, 06:18:12 »
hehe np  ;)
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Trexian

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #10 on: 12 Aug 2008, 16:29:05 »
Great pointers!

A question or 2 about the waypoint.sqf, though. :)

Why put it in a for loop that, I think, only happens 1 time? :)

Also, the sleep .4, then immediately set the atwp variable to true, then the waituntil line seems like it would all happen almost immediately.

Perhaps something more like:
Code: [Select]
brdmm1 moveInDriver brdm1;
 brdmm2 moveInGunner brdm1;
 Sleep 10;
 brdmm1 doMove (getMarkerPos "wp1");
 Sleep .4;
 waitUntil {(brdm1 distance wp1) < 20};
...

Not sure if the distance will see the marker wp1 as an object - may have to use the marker position - for the distance command.  But this way, it will wait until the brdm is less than 20m from the waypoint before moving on, right?
Sic semper tyrannosauro.

Offline ModestNovice

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #11 on: 13 Aug 2008, 02:30:47 »
uhhh, actually, the for loop, loops infinitely. Where as while true, only will do 10,000, I know what I did with the loop.

As if you read the line, the first code {_i=0};
then condition {_i<1};
then {_i=_i};

so _i is always less than 0;
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Trexian

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #12 on: 13 Aug 2008, 04:22:24 »
AH right!  Excellent!  I see now - I didn't read it closely enough and assumed the i=i+1 iteration!   :good:

And now... having tried something like this, I see that the waituntil won't do, because it pauses the whole script until that condition is satisfied.  So, if you want to run something like this for multiple units, it will literally do them one at a time. :)
Sic semper tyrannosauro.

Offline D007

  • Members
  • *
Re: How can I set way points for a man in a script?
« Reply #13 on: 16 Aug 2008, 03:14:49 »
After further investigation we found..
All you need to do is name a man and have him in his own group.
Then set waypoints for that man in the editor. Not in a script..
doing it in a script is more complicated.

Just make the man by trigger activation.
the condition in the trigger is:       !alive merc1

The code below is:     [] exec merc1.sqs
Code: [Select]
? !isServer: exit
@ ! (alive merc1)
merc1 = group merc1 createUnit ["Mercenary_soldier_sd_wdl", gl_loc1, [], 0, "form"]

Merc1 is the mans name.
merc1 is also the name of the group he's attached to.. which is himself.
Gl_loc is a invisible heli pad object. It needs to be where you want the unit to respawn.

(Idk if we need the If is server stuff..lol.. Still getting use to this a bit. XD
group the man to himself..
set waypoins and attitudes for those waypoints in the editor..
then whenever they respawn, they will keep those waypoints.
No looping scripts. nothing in the init.. Much easier..
I just didn't ask the right question..  :confused:

also you can have a trigger that's init line will read.   !alive merc1 removeallweapons this.  to take their gear away so it can't be taken or what not.
if you want them to get into a vehicle I recommend putting a line in the vehicle respawn script that says
Merc1 moveindriver poopmobile ..or whatever you name the vehicle.

Edit: DaChevs script works more reliably for all circumstances.
« Last Edit: 24 Aug 2008, 17:27:19 by D007 »