Home   Help Search Login Register  

Author Topic: Random spawn locations for several vehicles (Edited)  (Read 1325 times)

0 Members and 1 Guest are viewing this topic.

Offline Inkompetent

  • Members
  • *
Hello, hello. I have a little problem with randomizing the locations for my three shilkas on my co-op map.

I've tried to improve the script, but I get errors that are too long for my screen, and I can't find a log file for anything but game-crashes.

The error, as far as I can read it, reads like follows:

'if (_shilkaLoc < 5 && ! _busyLoc|#|[4]) then {shilka_array[_x-1] setPos shilkaECutting; _busyLoc set [5, true]; goto "Facing"}': Error Unkown

Code: [Select]
;;Declaration of variables
_x = 0
_array_size = 0
_busyLoc = [false,false,false,false,false,false]


#Loop
if (_x < count shilka_array) then {_x = _x + 1}

;Pick location
_shilkaLoc = random 6

if (_shilkaLoc < 1 && ! _busyLoc[0]) then {shilka_array[_x-1] setPos shilkaJoudov; _busyLoc set [0, true]; goto "shilkaPos"}
if (_shilkaLoc < 2 && ! _busyLoc[1]) then {shilka_array[_x-1] setPos shilkaPaseky; _busyLoc set [1, true]; goto "shilkaPos"}
if (_shilkaLoc < 3 && ! _busyLoc[2]) then {shilka_array[_x-1] setPos shilkaSkalice; _busyLoc set [2, true]; goto "shilkaPos"}
if (_shilkaLoc < 4 && ! _busyLoc[3]) then {shilka_array[_x-1] setPos shilkaOpatov; _busyLoc set [3, true]; goto "shilkaPos"}
if (_shilkaLoc < 5 && ! _busyLoc[4]) then {shilka_array[_x-1] setPos shilkaWCutting; _busyLoc set [4, true]; goto "Facing"}
if (_shilkaLoc <= 6 && ! _busyLoc[5]) then {shilka_array[_x-1] setPos shilkaECutting; _busyLoc set [5, true]; goto "Facing"}

_x = _x - 1

goto "Loop"


exit


#shilkaPos
_radius = random 100
_angle = random 360

_xPos = _radius * sin(_angle)
_yPos = _radius * cos(_angle)

shilka_array[_x-1] setPos [(getPos this select 0) + _xPos, (getPos this select 1) + _yPos, getPos this select 2]

goto "Facing"


#Facing
_direction = random 360
shilka_array[_x-1] setFormDir _direction

player globalChat "Shilka" _x "is on the field"

goto "Loop"
« Last Edit: 19 May 2007, 21:32:26 by Inkompetent »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: Random spawn locations for several vehicles (Edited)
« Reply #1 on: 19 May 2007, 21:44:52 »
I don't know if it will help you, but if you "group" a unit to a number of markers it will appear randomly at one of the marker positions.   Make the markers type empty, obviously.
Plenty of reviewed ArmA missions for you to play

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Random spawn locations for several vehicles (Edited)
« Reply #2 on: 22 May 2007, 01:50:31 »
The marker trick works, though it is hard to group them with the unit because the markers will disappear when you click on "Group". So place markers very near to unit, group them with unit, then click on "Markers" and move the markers where you really want them.

As for your script. I do not see anything wrong with it offhand. What is shilkaJoudov etc.?
urp!