Home   Help Search Login Register  

Author Topic: WP limit?  (Read 2305 times)

0 Members and 1 Guest are viewing this topic.

sirglider

  • Guest
WP limit?
« on: 21 Dec 2005, 01:30:45 »
Hi all!

I'm working hard on my UAV consol to control many uav's at the same time and also in mp. My main script, from the dialog, is quite big about 20Ko. I'm testing it for the moment only on one computer, so in SP, so in local.
I'm assigning new WP from the main script to my uav's. They are then published with the publicvariable command. Each uav has got it's own loop running to see if their wp has changed for example.

The state is so: it's working fine at the beginning, every uav moves to its first wp. But then when I assigned them a new WP, they move but in a complete different direction and they never stop. They just flight straight in a direction. I've checked at many states if my wp are recognized. They are even recognized in the uav script. But the UAV doesn't obey to the moving order anymore.

Last test: if I assign a new WP from a radio trigger for example. No prob then.

Any idea? Limit of number of commands in a loop for example?

Thx mates for your help!  8)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:WP limit?
« Reply #1 on: 21 Dec 2005, 11:20:13 »
What you do you mean "assign them a new waypoint"?

Plenty of reviewed ArmA missions for you to play

sirglider

  • Guest
Re:WP limit?
« Reply #2 on: 21 Dec 2005, 11:50:19 »
In fact my WP assignement system works in two parts:
1st in the consol script, the new WP for the UAV is recorded as a variable format [x,y,z] then published with the publicvariable command to let the server know that I've assigned a new wp for my uav.
2nd script runs on the server for every uav. They check if their actual position is different (more than 50 meters away) from their WP, from the variable. If yes, then the uav script orders with the domove command the uav to go to the new WP.

Is it better explained so? ::)

Thx

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:WP limit?
« Reply #3 on: 21 Dec 2005, 12:03:06 »
Well, yes and no.   I still don't understand what you mean by "assigning" a waypoint.   Waypoints can only be  created in the Mission Editor:   what are you doing in the script?   Are you talking about real Waypoints or just positions designated by the script?

I know you're talking about MP but I'll leave this here for the moment since its not the MP bit that isn't working.
Plenty of reviewed ArmA missions for you to play

sirglider

  • Guest
Re:WP limit?
« Reply #4 on: 21 Dec 2005, 13:22:07 »
Quote
Well, yes and no.  I still don't understand what you mean by "assigning" a waypoint.  Waypoints can only be  created in the Mission Editor:  what are you doing in the script?  Are you talking about real Waypoints or just positions designated by the script?

You're right, as long as I know we cannot create WP via a script. So I designate position via a variable and then just order the unit to move to this variable with the command domove. Working fine for any unit normally...

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:WP limit?
« Reply #5 on: 21 Dec 2005, 13:49:43 »
Ah right, so its not a Waypoint, it's just a place you want him to go.

There is no limit on the number of commands in a loop.   However, stacked doMove commands can cause problems.   For a start, I'd consider using move rather that doMove because you want the whole group to go there.  (I assume.)    

Inanimate objects aren't very bright.   If they are going somewhere its probably because you told them to go there, even if you didn't mean to.     It sounds to me as if it all works on the first pass, but not the second pass ... which means there is something wrong in the script.

Post the relevant section and hopefully somebody will have a look at it.   Unfortunately scripting is not my strong point.



Plenty of reviewed ArmA missions for you to play

sirglider

  • Guest
Re:WP limit?
« Reply #6 on: 21 Dec 2005, 13:57:21 »
Do stacked move instead of stacked doMove run better? And in fact I'm trying to move a single unit, so no need of using a move function instead...
Anyway, I'll try your propostion tonight and then I'll post the part of my loop which is about WP and how they are assigned. At least I'll try so, cause I'm even getting lost myself in it!

Thx for your help MacGuba, will post the results tonight!

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:WP limit?
« Reply #7 on: 21 Dec 2005, 18:03:01 »
It is true that you don't need to use move, but it is more elegant.    doMove is really for when you want a unit to go point X while the rest of his group are going to point Y.    There is an underlying difference, in that move creates a virtual waypoint at the place in question.  

Plenty of reviewed ArmA missions for you to play

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:WP limit?
« Reply #8 on: 21 Dec 2005, 23:34:57 »

Just a point on this

You state that you PV the position
Am sure you know that you cannot pv an array as an array

You have to split it up into individual entities and transmit them as that then recompile on the receiving end


eg
transmitting script
tx_X = _position select 0
tx_Y = _position select 1
tx_Z = _position select 2
condition = true
{publicvariable _x}foreach [ tx_X,tx_Y,tx_Z,condition]
condition = false

Receiving script
@ condition
condition = false
_pos = [tx_x,tx_y,tx_z]
« Last Edit: 21 Dec 2005, 23:35:50 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

sirglider

  • Guest
Re:WP limit?
« Reply #9 on: 21 Dec 2005, 23:43:11 »
The control script checks if the WP from the actual Ranger is different from the Temppos defined with an OnMapSingleClick command and published. If there's a difference then it publishes the new position for the Ranger.
Code: [Select]
...
#loop
~0.005
...
_RangerWP = Call format [ "Ranger%1WP",_IDofRanger ]
...
If (abs ((Temppos select 0) - (_RangerWP select 0)) > 50) then {Call format ["Ranger%1WP = Temppos; publicvariable {Ranger%1WP}",_IDofRanger]; _objRanger sidechat format ["Roger, UAV %1 moving to %2",_IDofRanger,Temppos]}
If (abs ((Temppos select 1) - (_RangerWP select 1)) > 50) then {Call format ["Ranger%1WP = Temppos; publicvariable {Ranger%1WP}",_IDofRanger]; _objRanger sidechat format ["Roger, UAV %1 moving to %2",_IDofRanger,Temppos]}
...
goto "loop"

Then the UAV script checks if there's a difference between its actual position and the position saved in the consol script. If yes, then it orders the uav to move to this new WP.
Code: [Select]
...
#loop
_RangerWP = Call format [ "Ranger%1WP",_IDofRanger ]
...
If (abs ((_RangerWP select 0) - (getpos _objRanger select 0)) > 50) then {_objRanger move _RangerWP; player sidechat format ["_RangerWP = %1 pour _objRanger %2", _RangerWP, _IDofRanger]}
If (abs ((_RangerWP select 1) - (getpos _objRanger select 1)) > 50) then {_objRanger move _RangerWP; player sidechat format ["_RangerWP = %1 pour _objRanger %2", _RangerWP, _IDofRanger]}
...
goto "loop"
I've changed, on MacGuba's advice to a move command instead of a domove one. Results, working the first time I run the test, but not on the next ones... strange behaviour! But it works from time to time. But most of the time not...
An other result: the _RangerWP is well read in the UAV script. It means the information of changing it's designed point and publish it is good! Only the UAV doesn't answer on the command...

Thx for your help mates!

EDIT: @Terox
Quote
Am sure you know that you cannot pv an array as an array
I have no problem pulishing an array as a variable. Is it a MP feature that won't work on servers or so? Because localy there's no problem in saving and loading it... You just have to initiate it before.
« Last Edit: 21 Dec 2005, 23:55:22 by Sirglider »

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:WP limit?
« Reply #10 on: 22 Dec 2005, 17:41:48 »
Hello again Sirglider,

I can see a couple of problems, and would make a few suggestions as well.

Your first problem is that the waypoint X/Y is uncoupled:

Code: [Select]
If (abs ((Temppos select 0) - (_RangerWP select 0)) > 50) then {Call format ["Ranger%1WP = Temppos; publicvariable {Ranger%1WP}",_IDofRanger]; _objRanger sidechat format ["Roger, UAV %1 moving to %2",_IDofRanger,Temppos]}
If (abs ((Temppos select 1) - (_RangerWP select 1)) > 50) then {Call format ["Ranger%1WP = Temppos; publicvariable {Ranger%1WP}",_IDofRanger]; _objRanger sidechat format ["Roger, UAV %1 moving to %2",_IDofRanger,Temppos]}

That is, it reads:
IF THE X HAS CHANGED BY MORE THAN 50 M, CHANGE THE X
IF THE Y HAS CHANGED BY MORE THAN 50 M, CHANGE THE Y

It would be more effective (and have less weirdness), if you set it to:
IF THE (X OR Y) HAS CHANGED BY MORE THAN 50 M, CHANGE THE (X AND Y)


--
Another problem is the game engine. If you give a MOVE order or set a waypoint for a long distance, the pathfinding routine will time out, and the object will not move.

--
But the big problem is exactly as the others stated: you cannot use PublicVariable on an array. It doesn't work.


SUGGESTIONS:
There are two ways around the "Cannot transmit 3D coordinates" problem.
First, you can break _RANGER%WP into _RANGER%WPX and _RANGER%WPY, and give them integer values.
Second, you can CreateVehicle a Gamelogic and SetPos it.
So when the UAV inits, you would do something local to server only like:
(where _objRanger 1  indicates the UAV's name)
Code: [Select]
call format ["Ranger%1WP={Logic}CreateVehicle [0,0,0]; Ranger%1WP SetPos getpos _objRanger; publicvariable {Ranger%1WP}", _IDofRanger]
Then, your OnMapSingleClick code looks like:
Code: [Select]
OnMapSingleClick {call format ["Ranger%1WP Setpos _pos", IDSelectedRanger]; [] call MyMapClickHandlerFunction}

That will update the waypoint position. A side benefit to this is that you can use the DISTANCE command to find if it's moved.

This brings me to my second suggestion:
You don't need a Loop to check (poll) if the Map has been clicked: it's much more effective to start a function at that event that does what you need to do (this is what MyMapClickHandlerFunction does).

And if you use a network layer like CoC Network Services you can automate the whole process by sending a remotecall to handle the change in waypoint on the other side. (but that may be too much).

In any case, the loop for the UAV's control system, checking if the waypoint has changed, should not be too frequent. I would put in a delay of say ~.5 or so: no need for instant controls. In any case, there is little sense in checking for changes in MP status shorter than ~.1, since the MP updates at its fastest at 5 Hz.

And you will probably need some sort of fix for really long waypoints: either an error message, or an intermediate waypoint or set of waypoints.


Cheers!
Dinger/Cfit

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:WP limit?
« Reply #11 on: 23 Dec 2005, 22:35:54 »
From what i can decipher, it doesnt appear that you understand what a publicvariable is
(If i am wrong, i apologise)

getting back to basics

Local variables
eg
_Localvariable
starting with and underscore.....  is of use to only the script that created it
(any variable type can be used as a local variable)
 

Global variables
eg
tx_Myvar
is local only to a specific machine, if its value changes, only that local machine will know its new value
(other machines can also have a variable with the same name, but changing a value on 1 wont change a value on another
Any script/function can access and manipulate the variable
(any variable type can be used as a global variable)


Publicvariables
eg
tx_myvar = 2;Publicvariable "tx_myvar"
is transmitted to all machines over the network, ensuring that all these machines have the same value for tx_myvar

(any variable type can be PV'd with the exception of
STRINGS
or
ARRAYS



Hope that clarifies things for ya





On a client/server, eg single player type mp setup, when you PV an array, you arent actually PV'ing it, its value is only known because it is actually a global variable, but if you ran it from a dedicated server, it wouldnt be transmitted
« Last Edit: 23 Dec 2005, 22:36:54 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

sirglider

  • Guest
Re:WP limit?
« Reply #12 on: 03 Jan 2006, 09:50:53 »
My problem is not solved...

Thx Terox and Dinger. I tried both of your methods. Results: the same. My UAV's move to their next waypoint but only from time to time.

In fact, I don't really see the advantage of using a GL to designate a WP, except to get its position instead of transmitting an array of its position... There's no command to move to an object, so I have anyway to do domove getpos Ranger%1WP. Result I order a move to an array... My UAV's go to their waypoint but not always. It seems to work more or less fine in a close area (~2000m). But further it doesn't seem to work anymore...

Might there be a problem if my wp is insight of my UAV or not? Could the map affect in any way on my wp? Cause I use Desert Island for all my tests and further wp's are always in the sea...

Thx for your help mates!

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:WP limit?
« Reply #13 on: 03 Jan 2006, 20:07:03 »
when you issue a move command, the unit calculates the path it will take to the object

The further away the domove position, the longer it will take to calculate, thats why domoves to distant positions should be done in stages

I also seem to vaguely remember reading somewhere that there is a distance limit for the domove. (I may however be mistaken, am sure someone will respond)

what you could do is take a vector and issue the domove pos at a distance on that vector, and then keep re issuing until the end location has been reached, that may help you
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:WP limit?
« Reply #14 on: 04 Jan 2006, 01:16:19 »
I believe there is some kind of distance limit for some things ... I remember having trouble with choppers.   Can't remember exactly what though.   It was certainly solved by using shorter distances.      From memory I would say that to go from the northern end of Everon to the south you would need at least two intermediate waypoints or commands, and possibly three.

But as I say it was a long time ago so don't quote me.
Plenty of reviewed ArmA missions for you to play

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:WP limit?
« Reply #15 on: 04 Jan 2006, 13:13:50 »
Well, like I said:

a) YOU CAN'T PV ARRAYS. That's why you make an object and PV that.
b) The pathfinding routine _does_ time out and give up at a certain distance. Either calculate intermediate waypoints, or give an error and force the user to select a closer waypoint..
« Last Edit: 04 Jan 2006, 13:19:31 by Dinger »
Dinger/Cfit

Offline Roni

  • Members
  • *
  • Play the Game !
Re:WP limit?
« Reply #16 on: 15 Jan 2006, 04:03:55 »
Hi SG

I don't know if this helps but I just finished (after LOTS of effort !) a hunt and seek script that continuously sends a hunting group towards the last known position of a target group.  It sounds like it is similar to what you are looking to do.

The script itself is kind of complex (since I have the hunting group stop for lunch, set up camp at night, play sounds audible clues as it closes in on its target etc), but the hunting routine is pretty straightforward.

All I've done is give the hunting group one single waypoint, then in the script defined the hunting unit and its group and the target unit and its group and then set _commander lockWP true.  I then keep moving that waypoint whenever the hunting group reaches it or any of the other defined situations occur.  The main loop therefore looks something like this -

;      If commander team has been wiped out then exit
? _headCount < 1 : titleText[format["Team %1 has been wiped out !", _commanderName], "Plain"], exit


;      If head count < rout number then go to rout routine
? _headCount < _routNumber : goto "routRoutine"


;      If head count back to rout number then reset waypoint position
? (_headCount == _routNumber)  && _routing   : hint format ["Team %1 is back in action!", _commanderName]


;      If waypoint < 50m away then reset waypoint position
_distanceToWaypoint = sqrt((((_wayPointPos select 0) - (_commanderPos select 0))^2) + (((_wayPointPos select 1) - (_commanderPos select 1))^2))
? _distanceToWaypoint < 50 : goto "huntRoutine"


;      If confidence is high then reset waypoint position
? _commander knowsAbout _targetUnit > 3 : goto "huntRoutine"


;      If group is not elite and time is after 12PM then stop for lunch
? (daytime > 12) and (daytime < 13) and !(_elite)   : goto "lunchRoutine"


;      If group is not elite and time is after 7PM then set up camp
? (daytime > 19) and !(_elite) : goto "campRoutine"


;      If hunter is not elite then give players a clue as to the range to their pursuers, continue loop
? _elite : goto "loop"

Etc



I use the script with a separate respawn script that keeps restocking the hunting group as it takes casualties.  Different groups have different respawn rates and types so that some spawn quickly but produce crap (eg conscript groups), some spawn slowly but take almost 100% casualties to get off your back (elite groups), some are cowardly but come back quickly (eg recon groups).  That way you can drive the hunters away for a while, but unless you kill off every last unit it will eventually come back and track you down !

It sounds like all you need is the above lockWP true command and some way of updating the waypoint on player input (eg onMapSingleClick).

Hope that this helps.

Cheers



Roni