Jump to content
Sign in to follow this  
Muzzwezz

SQS loops and ifstatements not working

Recommended Posts

Hello

My problem is basic i wanted to make my own "airlift" sequence, but outraged by the inaccuracy of "doMove" [Jeeps would teleport to choppers who where not stopping at the right location] i decided to make my own script.

First a bug or what? if i use FlyinHeight, it seems to work fine for numbers < 10, i can put 9.9 and its fine, but if i put 10 in then the helicopter goes to about 25 meters not 10! wtf.

Anyway carrying on my script atm is a SQS i would like to make it SQF but if i put execVM "..." into a "On Act.:" it comes up with an error "Type script expected nothing". Am i doing this wrong or cant i launch SQF from waypoint onAct?

so anyway carrying on here is the script that should work:

private ["_target", "_angle", "_distance", "_speed", "_defineSpeed", "_check"];

_defineSpeed = 10;
_check=0;

heli flyInHeight 9.99;
_target = [(position lan select 0)-(position heli select 0),(position lan select 1)-(position heli select 1)] ;

_angle = (_target select 0) atan2 (_target select 1);  //Get theta-angle
_distance = sqrt(((_target select 0)^2) + ((_target select 1)^2));
_speed = ((_target select 1) / (_target select 0))*_defineSpeed;  //Get the gradient

Heli setDir _angle;  //Face target the correct direction
Heli setVelocity [defineSpeed, _speed, 0];  //Set correct speed

;//@( (Heli distance lan) < 5);  //wait till they are within ~5m

player sidechat str(Heli distance lan);

while {_check == 0} do {
if((Heli distance lan) < 5) then {
	Heli setVelocity [0, 0, 0];  //Stop helicopter
	lan attachto [heli, [0,0,-7.5]];
	check=1;
};
};

Let me explain this a little, "Heli" is the helicopter to pickup the jeep "lan".

[if someone can tell me how to pass parameters to a script that would be great [i.e. make it a function e.g. airlift(Heli,lan); - would airlift lan with Heli]]

Now its the waiting till the helicopter reaches the target is the problem:

waitUntill {(heli distance lan )< 5} doesent work

@( (Heli distance lan) < 5); doesent work

Ive even tried putting in that horrible inefficient loop [ive tried several variations and code for SQS and SQF] but it never seems to work, it ignores both the while and if statement.

Any ideas guys? cheers.

edit:

[yes i know i dont check the quadrants on the angle-theta but ill add it in later]

Share this post


Link to post
Share on other sites



<object width="425" height="344"><param name="movie" value="http://www.youtube.com/watch?v=GE7oeZneiZI&hl=en_US&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/watch?v=GE7oeZneiZI&hl=en_US&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

Got it working in the end.

since the video i have tweaked the heli incoming speed and the distance the objects attach to the heli making it abit smoother.

Edited by Muzzwezz

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×