OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Serial Killer on 08 Mar 2005, 21:05:04
-
I have to create a Su25 in the middle of game, and it must fly. How?
-
first thing which springs to mind -
have it flying somewhere distant from where the player will be. create a move/cycle waypoint combo on one extreme edge of the map to keep it going back and forth, with a few other waypoints round about the area where it's going to appear.
when you want to have it appear, setpos it into position, and use a switch trigger to change to the next set of waypoints.
-
Your post encouraged me to make a script for this, so here it is.
Call this script like this:
[NameOfDriver, "MarkerName", Direction, Height, Speed] exec "MoveInDriver.sqs"
NameofDriver is the name of the man you want to be the pilot
"MarkerName" is the name of the marker you want the plane created over, Keep the Quotes!
Direction is the direction you want the plane to fly in
Height is the hight at which you want the plane to be created at
Speed is the speed you want the plane to be created at.
I hope this helps!
EDIT:
While the speed variable does affect the speed of the airplane, the number you put in will most likely not be the speed the plane is created at. By raising the number, you can raise the speed, and by lowering the number you can lower the speed. But don't expect the plane to be created at 200 knots even though you put 200 as the variable. Unfortunately, I am not sure how to fix this.
-
I'm just checking.. Do you think that this works perfectly?
_man = _this select 0
_position = _this select 1
_dir = _this select 2
_height = _this select 3
_speed = _this select 4
;Create the plane
_plane = "Su25" createVehicle getmarkerpos _suicide
;Set the plane's height
_plane setpos [(getpos _plane select 0), (getpos _plane select 1), _85]
;Set the plane's direction
_plane setDir _90
;Set the plane's speed
_plane setvelocity [(sin getdir _plane)*(_100*.5), (cos getdir _plane) * (_100*.5), 0]
;Move the man in as driver
_man moveindriver _plane
exit
Do you think that I made something wrong?
-
you tell us - have you not tested it? best way to find out if it works or not.
as an aside, you might want to add
_man assignasdriver _plane
before the exit. this means the pilot will know he's supposed to be flying the plane rather than simply keeping the seat warm.
one other puzzling thing - the direction, speed and height are all passed to the script when you call it - hence all the [pilot,whereto,direction,etc...] exec "script.sqs" - but then you don't use any of the variables.
and i'm still not convinced that simply camcreating a plane out of thin air will do anything other than crash a perfectly good plane, as the pilot probably won't have time to realise he should switch the engines on.
but looking at the "suicide" marker - which btw should read
_plane = "Su25" createVehicle getmarkerpos "suicide"
maybe a crashing plane is the effect you're after.
test it, then tell us how it went :)
-
Great, it works perfectly! :) Next question... How can I create a waypoint for him?
-
and there's your problem right there. you can't. it's been magicked out of thin air, and so has no waypoints. and unlike planes, waypoints can't be created outwith the editor.
if the pilot exists before the plane, give him waypoints. when he's moved into the driving seat he'll follow his waypoints in the plane, so long as he's assigned as the driver. be sure to make him 'hold' on his first waypoint, and then use a switch trigger to set him moving once inside the plane, otherwise he'll set off on foot.
still don't understand why you're doing it this way, but meh... whatever tickles yer pickle ;)
-
I'll try it, thanks!
EDIT: I hope that this is the last question.. I have a script and it name is Su25.sqs. I have to stop that script in the middle of game. How?
-
With a global variable. Create a check in the middle of a loop, if the variable becomes false, then have it end the script.
-
Uhm.. I don't understand :-\ I put that script here, if it helps you..
_camera = "camera" camCreate [0,0,0]
_camera cameraeffect ["internal", "back"]
#loop
_camera camSetTarget su25
_camera camSetFOV 0.7
_camera camSetRelPos [-0.41, 3.6, 0.18]
_camera camCommit 0
@camCommitted _camera
?(proceed):goto "proceed"
goto "loop"
#proceed
One of my friends helped me with that script..
-
create a global variable in your init.sqs file like this:
stop_my_script = false
then in your loop:
_camera = "camera" camCreate [0,0,0]
_camera cameraeffect ["internal", "back"]
#loop
?(stop_my_script):exit
_camera camSetTarget su25
_camera camSetFOV 0.7
_camera camSetRelPos [-0.41, 3.6, 0.18]
_camera camCommit 0
@camCommitted _camera
?(proceed):goto "proceed"
goto "loop"
#proceed
...
then, when you want the script to end, use a trigger or some other script to set stop_my_script to true. that'll do it.
-
Thank you! 8)