Jump to content
Sign in to follow this  
madmedic

Gradually slowing down a helicopter with a setvelocity loop...Please help.

Recommended Posts

Hi...Searched, but couldn't quite find anything that exactly fit my need.

As everyone knows, when a helicopter is flying at normal speed, and it comes to a waypoint that sets the speed to "limited", the chopper flares way up in the air when it slams on the brakes.

I want to avoid the flaring, by slowing it down gradually, with triggers BEFORE the waypoint, using a setvelocity loop of some sort.

Problem is...I am a remedial scripter.

I seem to remember a similar script in the old OFP days, but I can not find it.

Basically...I want to gradually slow the chopper down with setvelocity loop, between the first two waypoints...The second waypoint will be set to "limited" speed, but I want the chopper to already be going slow enough that it will not flare when it gets to this waypoint.

It will then continue at "limited" speed, to a third waypoint, where it will fastrope some troops and then fly off.

It needs to return to normal AI controlled speed, after it drops the troops.

(I am good with the fastrope part...I just need help with the slowing script)

Thanks in advance.

Share this post


Link to post
Share on other sites

I've used they myself in A2, it reduces the flare to about 10 meters if you want even less flare reduce the sleep 0.2 to 0.02

//
// place in waypoint on act 600 meters before land/target waypoint
// In landing/target waypoint on act put  Anti_flare = false; to end the script.
// null=[heli,height] execvm "Anti_flare.sqf";
//
_veh = _this select 0;// vehicle
_setheight = _this select 1;//approx height at which it aims to keep it at
_force = 1.8;
Anti_flare = true;
while {alive _veh and Anti_flare} do
{
_xv = velocity _veh select 0;
_yv = velocity _veh select 1;
_zv = velocity _veh select 2;

if ((getposATL _veh select 2) > _setheight) then
{ 
hintsilent format ["Anti flare Enabled %1",(getposatl _veh select 2)];
_veh setvelocity [_xv,_yv,_zv/_force];

};
sleep 0.2;// 0.02 for less flare

};
hintsilent "Anti flare Disabled";

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Actually...That doesn't do what I want it to do.

I don't want it to depend on height...Just speed.

What would I have to change in the "turbo" script below to make it SLOW the chopper, instead of speeding it up?... And to make it loop until the chopper slowed to a certain speed?

_vel = velocity _vehicle;
_dir = direction _vehicle;
_speed = 10; comment "Added speed";
_vehicle setVelocity [
(_vel select 0) + (sin _dir * _speed), 
(_vel select 1) + (cos _dir * _speed), 
(_vel select 2)
];

Edited by madmedic
problem not fixed

Share this post


Link to post
Share on other sites

I think it's divide by speed but I haven't checked for a while.

it was

_vehicle setVelocity [

(_vel select 0) - (sin _dir * _speed),

(_vel select 1) - (cos _dir * _speed),

(_vel select 2)

];

this seems to be working on speed

_vehicle = _this select 0;
duration = true;// set false in wp to terminate script
_set_speed = 10;// slow to this speed
_vehicle limitspeed _set_speed;

while {alive _vehicle and duration} do {
_vel = velocity _vehicle;
_dir = direction _vehicle;
_speed = 2;// rate of deceleration 

if  (speed _vehicle > _set_speed+2) then {// force vehicle to slow quickly 
_vehicle setVelocity [
   (_vel select 0) - (sin _dir * _speed), 
   (_vel select 1) - (cos _dir * _speed), 
   (_vel select 2)
];
};
sleep 0.2;  
hint format ["speed %1",speed _vehicle];// remove
};

hint "done";// remove
_vehicle limitspeed 1000;// return to max speed 

Edited by F2k Sel

Share this post


Link to post
Share on other sites
I think it's divide by speed but I haven't checked for a while.

it was

_vehicle setVelocity [

(_vel select 0) - (sin _dir * _speed),

(_vel select 1) - (cos _dir * _speed),

(_vel select 2)

];

this seems to be working on speed

_vehicle = _this select 0;
duration = true;// set false in wp to terminate script
_set_speed = 10;// slow to this speed
_vehicle limitspeed _set_speed;

while {alive _vehicle and duration} do {
_vel = velocity _vehicle;
_dir = direction _vehicle;
_speed = 2;// rate of deceleration 

if  (speed _vehicle > _set_speed+2) then {// force vehicle to slow quickly 
_vehicle setVelocity [
   (_vel select 0) - (sin _dir * _speed), 
   (_vel select 1) - (cos _dir * _speed), 
   (_vel select 2)
];
};
sleep 0.2;  
hint format ["speed %1",speed _vehicle];// remove
};

hint "done";// remove
_vehicle limitspeed 1000;// return to max speed 

Thanks...I will try this

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  

×