Jump to content
Sign in to follow this  
SouthSaturnDelta

spawned infantry wont move

Recommended Posts

Hi all,

  I have a script that spawns a group of infantry.

I got them to appear but they will not move to the point marked with   onmapsingleclick {}   ....

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">onMapSingleClick {}

_pos = _this select 0

[_pos, "Squad moving to grid location ", ". Over.", ["SideChat", player]] exec "UNS_GRD\gridcoordinates_pipe.sqs"

~5

"target" setMarkerPos _pos

"target" setMarkerType "destroy"

"target" setMarkerColor "Colorred"

trooper1 = "SoldierWB" createunit [getMarkerPos "spawninf1" ,groupAlpha ,"", 0.5, "PRIVATE"]

trooper1 setPos [(getPos trooper1 select 0),(getPos trooper1 select 1),(getPos trooper1 select 2)+1]

trooper1 setDir 180

~0.3

trooper2 = "SoldierWB" createunit [getMarkerPos "spawninf1" ,groupAlpha ,"", 0.5, "CORPORAL"]

trooper2 setPos [(getPos trooper2 select 0),(getPos trooper2 select 1),(getPos trooper2 select 2)+2]

trooper2 setDir 180

~0.3

trooper3 = "SoldierWB" createunit [getMarkerPos "spawninf1" ,groupAlpha ,"", 0.5, "CORPORAL"]

trooper3 setPos [(getPos trooper3 select 0),(getPos trooper3 select 1),(getPos trooper3 select 2)-1]

trooper3 setDir 180

~0.3

trooper4 = "SoldierWB" createunit [getMarkerPos "spawninf1" ,groupAlpha ,"", 0.5, "PRIVATE"]

trooper4 setPos [(getPos trooper4 select 0),(getPos trooper4 select 1),(getPos trooper4 select 2)-1]

trooper4 setDir 180

trooper2 Move _pos

@ unitReady trooper1

trooper1 Move _pos

trooper1 setBehaviour "combat"

trooper1 setCombatMode "red"

trooper1 setSpeedMode "normal"

@ unitReady trooper1

groupAlpha doMove (getMarkerPos "spawninf1")

@ unitReady trooper1

deletevehicle trooper1

trooper1 sideChat "New Support Unit available -over"

exit

So as you see they should get groovin' over to the user placed marker "_Pos" , like spawned vehicles or aircraft do.

How can I make these infantry move to the map placed marker ?

I'd like them to move to that position, clear any enemy presence, and then return back to the spawn marker and dissapear till needed again.

Share this post


Link to post
Share on other sites

Maybe you should move or doMove trooper1 to _pos instead of trooper2, because trooper1 is spawned first, so he should be the group's leader. I see that the 2nd and 3rd have higher rank, but maybe this is the prob.

And you could try to do a

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[ groupAlpha, 0 ] setwppos _pos

[ groupAlpha, 1 ] setwppos _pos

That may help also.

Share this post


Link to post
Share on other sites

Mmmm, you should correct your script in this way :

"domove" is an order given to a single unit,

"move" is a new waypoint for a group.

Unitready works : when a unit reaches a position ordered by "domove" ; with the leader of a group when he reaches a certain waypoint (sometimes alone, sometimes when the whole group is "near him", depends on the speedmode).

So use "domove" instead of "move" there :

Quote[/b] ]trooper2 DoMove _pos

@ unitReady trooper1

trooper1 DoMove _pos

And "move" instead of "domove" there :

Quote[/b] ]@ unitReady trooper1

groupAlpha Move (getMarkerPos "spawninf1")

@ unitReady trooper1

If you're not sure that "trooper1" is the leader of groupalpha, write :

Quote[/b] ]@ unitReady trooper1

groupAlpha Move (getMarkerPos "spawninf1")

@ unitReady leader groupalpha

Share this post


Link to post
Share on other sites

Thanks to both of you fopr your help kutya and proftournesol.

Now those inf do as they should I'm happy to say.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">onMapSingleClick {}

_pos = _this select 0

[_pos, "Squad moving to grid location ", ". Over.", ["SideChat", player]] exec "UNS_GRD\gridcoordinates_pipe.sqs"

~5

"target" setMarkerPos _pos

"target" setMarkerType "destroy"

"target" setMarkerColor "Colorred"

trooper1 = SoldierWB createunit [getMarkerPos "spawninf1" ,groupAlpha ,"", 0.5, "CORPORAL"]

trooper1 setPos [(getPos trooper1 select 0),(getPos trooper1 select 1),(getPos trooper1 select 2)+1]

trooper1 setDir 180

~0.3

trooper2 = SoldierWB createunit [getMarkerPos "spawninf1" ,groupAlpha ,"", 0.5, "PRIVATE"]

trooper2 setPos [(getPos trooper2 select 0),(getPos trooper2 select 1),(getPos trooper2 select 2)+2]

trooper2 setDir 180

~0.3

trooper3 = SoldierWB createunit [getMarkerPos "spawninf1" ,groupAlpha ,"", 0.5, "PRIVATE"]

trooper3 setPos [(getPos trooper3 select 0),(getPos trooper3 select 1),(getPos trooper3 select 2)-1]

trooper3 setDir 180

~0.3

trooper4 = SoldierWB createunit [getMarkerPos "spawninf1" ,groupAlpha ,"", 0.5, "PRIVATE"]

trooper4 setPos [(getPos trooper4 select 0),(getPos trooper4 select 1),(getPos trooper4 select 2)-1]

trooper4 setDir 180

trooper1 DoMove _pos

trooper1 setBehaviour "combat"

trooper1 setCombatMode "red"

trooper1 setSpeedMode "normal"

trooper2 DoMove _pos

trooper2 setBehaviour "combat"

trooper2 setCombatMode "red"

trooper2 setSpeedMode "normal"

trooper3 DoMove _pos

trooper3 setBehaviour "combat"

trooper3 setCombatMode "red"

trooper3 setSpeedMode "normal"

trooper4 DoMove _pos

trooper4 setBehaviour "combat"

trooper4 setCombatMode "red"

trooper4 setSpeedMode "normal"

groupAlpha Move _pos

@ unitReady leader groupalpha

groupAlpha Move (getMarkerPos "spawninf1")

@ unitReady leader groupalpha

deleteVehicle groupalpha

deleteVehicle trooper1

deleteVehicletrooper2

deleteVehicle trooper3

deleteVehicle trooper4

trooper1 sideChat "New Support Unit available -over"

exit

They move to the map placed postion, then return to their spawn.( They dont delete themselves yet but I'll try to sort this out or not bother removing them at all)

Posted it here in case others have a similar problem.

Many thanks,

SSD smile_o.gif

Share this post


Link to post
Share on other sites

Createunit does not return any value, so you have to assign each guy to your variables using it's init field like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"SoldierWB" createunit [getMarkerPos "spawninf1" ,groupAlpha ,"trooper1=This",0.5, "PRIVATE"]

~0.3

"SoldierWB" createunit [getMarkerPos "spawninf1" ,groupAlpha ,"trooper2=This", 0.5, "PRIVATE"]

~0.3

The reason your script probably looks like it's working is because the move commands work with groups. Not individual soldiers, so you only need one Move order to command the entire group. BTW This will fix your heli problem to.

Share this post


Link to post
Share on other sites

Fantastic intel there UNN.

Sorted out some more probs I had , but the helo's still seem to fall. yay.gif

I'll spend some time getting my head around a few of these new ( new to me !wink_o.gif code lines.

Many thanks again to you all,I'm slowly starting to get my head around the basics.

SSD wink_o.gif

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  

×