OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Inkompetent on 19 May 2007, 19:14:09
-
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
;;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"
-
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.
-
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.?