Jump to content
Sign in to follow this  
bspendlove

Check if Aircraft is Stalling

Recommended Posts

Hello!

 

I have been having a look over at: https://community.bistudio.com/wiki/HUD#Available_Conditions: and had noticed "stall". Would I be able to use this to tell everyone in the server that someone is stalling? (Mainly for 2-3 players in Aviation Training)

 

something on the lines of:

_player = player;
_veh = vehicle;

while (_player _veh is stalling)
{
   //Hint to all players someone is stalling their aircraft...
};

or would I have to use something like:

condition = "stall".....

OR

 

I am guessing I would have to do a bit more work and calculate it by values like speed/angle etc..

 

 

 

What kind of lines would I be looking at ? :D

Share this post


Link to post
Share on other sites

The condition you found is probably useless for a sqf based script, but you could try to find out the values (speed and angles) required to make an aircraft stall. The rest would be basic sqf scripting with some global hints.

while {true} do
{
    _speed = [speed vehicle player,2] call BIS_fnc_cutDecimals;
    _angle = (((vectorDir vehicle player) select 2) * 360);
    _angleShort = [_angle,2] call BIS_fnc_cutDecimals;
    hintSilent format ["Speed: %1km\n Angle: %2°",_speed,_angleShort];
    sleep 2;
};

Put this in the init.sqf of your test mission, it will display the speed and the angle of your vehicle.

 

Edit:  I did some more research and it seems that the A10 does begin to slow down at an angle of 150°, therefor the first condition would be _angle > 150. However, this value will probably change for the AAF and CSAT jet, since both have more engine power (so far I know).

  • Like 1

Share this post


Link to post
Share on other sites

Here's something I've worked out, works fine in single player and should also work in multiplayer. Would be glad so hear some feedback from you, however, keep in mind that this script is not fully optimised since I do not have any use for it actually.

/*
    Author: Revo

    Description:
    Checks every 2 seconds if player's aircraft is stalling and displays a global hint.
    Script should be executed in the initPlayerLocal.

    Parameter(s):
    -
        
    Returns:
    -
*/


_aircraft = vehicle player;
_aircraftType = typeOf vehicle player;
_name = name player;

//wait until player enters a proper aircraft
waitUntil {sleep 1; (_aircraftType isEqualTo "B_Plane_CAS_01_F" || _aircraftType isEqualTo "I_Plane_Fighter_03_CAS_F" || _aircraftType isEqualTo "I_Plane_Fighter_03_AA_F" || _aircraftType isEqualTo "O_Plane_CAS_02_F")};

while {true} do
{
    //check speed and angle of the aircraft frequently
    _speed = speed _aircraft;
    _angle = ((vectorDir _aircraft) select 2) * 360;
    //Check the type of the aircraft and display message if the conditions are met
    switch (_aircraftType) do {
        case "B_Plane_CAS_01_F":
        {
            if (_speed < 90 && _angle > 120) then //values need to be tweaked to fit the aircraft type
            {
                [[[_name],{hintSilent parseText format ["<t size ='1.5' color='#d6000b'>%1's aircraft is stalling!</t>",_this select 0]}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
            }
            else
            {
                [[[_name],{hintSilent ""}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
            };
        };
        case "O_Plane_CAS_02_F":
        {
            if (_speed < 90 && _angle > 180) then //values need to be tweaked to fit the aircraft type
            {
                [[[_name],{hintSilent parseText format ["<t size ='1.5' color='#d6000b'>%1's aircraft is stalling!</t>",_this select 0]}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
            }
            else
            {
                [[[_name],{hintSilent ""}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
            };
        };
        case "I_Plane_Fighter_03_CAS_F":
        {
            if (_speed < 90 && _angle > 130) then //values need to be tweaked to fit the aircraft type
            {
                [[[_name],{hintSilent parseText format ["<t size ='1.5' color='#d6000b'>%1's aircraft is stalling!</t>",_this select 0]}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
            }
            else
            {
                [[[_name],{hintSilent ""}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
            };
        };
        case "I_Plane_Fighter_03_AA_F":
        {
            if (_speed < 90 && _angle > 130) then //values need to be tweaked to fit the aircraft type
            {
                [[[_name],{hintSilent parseText format ["<t size ='1.5' color='#d6000b'>%1's aircraft is stalling!</t>",_this select 0]}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
            }
            else
            {
                [[[_name],{hintSilent ""}],"BIS_fnc_spawn",true] spawn BIS_fnc_MP;
            };
        };
    };
    sleep 2;
};

Share this post


Link to post
Share on other sites

I think this is slightly more accurate in determining when you are or are not stalling and will work on all planes.
Know this accuracy is all hinged on lifting off the ground the moment you have enough speed to do so. If you speed past what is required to lift off then accuracy will be skewed.
Thought I'd share.
Execute from initPlayerLocal or equivalent.

//Stall_Notice.sqf
private ["_isflying","_vehp","_liftVecMag","_currVecMag"];
_isflying = FALSE;

waitUntil {sleep 1; (vehicle player isKindOf "Plane_Base_F" && {(getPos vehicle player select 2) > 1})};
_vehp = vehicle player;
_liftVecMag = vectorMagnitudeSqr velocity _vehp;

_isflying = TRUE;

while {_isflying} do {
	_currVecMag = (vectorMagnitudeSqr velocity _vehp);
	if (_currVecMag < _liftVecMag) then {
		hint "you are stalling";
	}else{
		hint "";
	};
	_isflying = if (vehicle player isKindOf "Plane_Base_F") then {TRUE}else{FALSE};
	sleep 0.2;
};

if !(_isflying) exitWith {execVM "Stall_Notice.sqf";};
  • Like 1

Share this post


Link to post
Share on other sites
-snip-

 

Damn, very nice work! This is really interesting to work with, I can't thank you enough. I see what you mean about going past the required speed to lift off (including landing). I guess I can let my pilots off until they start stalling below 150 xD

 

It may take me a long while to edit it to what I have in my head, but I have nothing else to do for awhile :D

 

Thank you 

Share this post


Link to post
Share on other sites

How about some "bling bling"?

[
	[
		[_name],
		{
			scriptHandle_stall = _name spawn {
				_name = _this;
				_colors = ["#ffffff", "#d6000b"];
				_isRed = true;
				
				while {true} do {
					hintSilent parseText format ["<t size='1.5' color='%1'>%2's aircraft is stalling!</t>", _colors select _isRed, _name];
					_isRed = !_isRed;
					sleep 0.5;
				};
			};
		}
	],
	"BIS_fnc_call", true, false, true
] call BIS_fnc_MP;

//To end the "bling bling"
[{terminate scriptHandle_stall; hintSilent ""}, "BIS_fnc_call", true, false, true] call BIS_fnc_MP;

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  

×