OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Gruntage on 27 Feb 2010, 17:41:58
-
Hi all
In my mission i need a random vehicle (from a list) to spawn at a given location and then move to another location. Ive searched the forums but couldnt find anything. Can any1 help?
Thx in advance
Gruntage
-
Very funny you should ask. I've been working on a similar script for the last few days, inspired loosely by savedbygrace's patrol replacement script for Kolgujev Contract. This is how SBG did it:
#patrol1start
_alpha = {alive _x} count units patrol1
? _alpha == 3 : goto "patrol2start"
#create1
_NUMBERS = 20
_NUMB = Random _NUMBERS
?(_numb < 1) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 1) and (_numb <= 2) ) : "soldierElaw" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 2) and (_numb <= 3) ) : "soldierEMG" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 3) and (_numb <= 4) ) : "soldierEG" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 4) and (_numb <= 5) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 5) and (_numb <= 6) ) : "soldierEMedic" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 6) and (_numb <= 7) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 7) and (_numb <= 8) ) : "soldierESniper" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 8) and (_numb <= 9) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 9) and (_numb <= 10) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 10) and (_numb <= 11) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 11) and (_numb <= 12) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 12) and (_numb <= 13) ) : "soldierESniper" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 13) and (_numb <= 14) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 14) and (_numb <= 15) ) : "soldierElaw" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 15) and (_numb <= 16) ) : "soldierEMG" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 16) and (_numb <= 17) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 17) and (_numb <= 18) ) : "soldierEG" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
?( (_numb > 18) and (_numb <= 19) ) : "soldierEMedic" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "corporal"]
?( (_numb > 19) and (_numb <= 20) ) : "soldierE" createUnit [getMarkerPos "PatrolMarker", patrol1,"this AddEventHandler [{Killed},{_this exec {scripts\deletehandler.sqs}}]", 1, "private"]
~.01
goto "patrol1start"
A random number is defined at the beginning, and the created unit type depends on the number.
Of course, you say you need a vehicle, so use createvehicle commands instead of createunit. To name your vehicle, just use code like this
newapc = "M113" createvehicle getpos spawnpoint
Then move some people into this empty vehicle:
loon1 moveInDriver newapc
and tell him to move somewhere
loon1 move getpos player
Does that work?
-
Thx for ur help kurtz. i have a random vehicle spawning at a game logic. Ive managed to get them to move somewhere else but im havin trouble deleting the vehicle when it reaches its waypoint ??? Ive tried the deletevehicle command but i cant get it to work properly. Any ideas???
-
??? You should just be able to delete the vehicle with
deletevehicle newapc
where newapc was the name you gave it when it was created. It works for me. Here, try playing the attached desert island test.
-
got it working now. but i had to delete the dead bodies of the tank's crew separately. Thx for ur help :D