Merge pull request #1820 from acemod/mk6-fixBISleveling

Mk6 fix leveling
This commit is contained in:
PabstMirror 2015-07-25 12:36:28 -05:00
commit 2a19521f68
7 changed files with 86 additions and 55 deletions

View File

@ -31,6 +31,8 @@ class CfgVehicles {
class Turrets: Turrets { class Turrets: Turrets {
class MainTurret: MainTurret { class MainTurret: MainTurret {
turretInfoType = "ACE_Mk6_RscWeaponRangeArtillery"; turretInfoType = "ACE_Mk6_RscWeaponRangeArtillery";
discreteDistance[] = {};
discreteDistanceInitIndex = 0;
}; };
}; };
class ACE_SelfActions { class ACE_SelfActions {

View File

@ -3,8 +3,17 @@ class RscInGameUI {
class CA_IGUI_elements_group: RscControlsGroup {}; class CA_IGUI_elements_group: RscControlsGroup {};
}; };
class ACE_Mk6_RscWeaponRangeArtillery: RscWeaponRangeArtillery { class ACE_Mk6_RscWeaponRangeArtillery: RscWeaponRangeArtillery {
onLoad = QUOTE(uiNamespace setVariable [ARR_2('ACE_Mk6_RscWeaponRangeArtillery',(_this select 0))]; _this call FUNC(turretDisplayLoaded);); onLoad = QUOTE(uiNamespace setVariable [ARR_2('ACE_Mk6_RscWeaponRangeArtillery', _this select 0)]; [ARR_2('infoDisplayChanged', [ARR_2(_this select 0, 'Mk6Mortar')])] call EFUNC(common,localEvent););
controls[] = {"ACE_MILS_GROUP", "CA_IGUI_elements_group","CA_RangeElements_group"}; controls[] = {"ACE_ChargeDisplay", "ACE_MILS_GROUP", "CA_IGUI_elements_group","CA_RangeElements_group"};
class ACE_ChargeDisplay: RscStructuredText {
idc = 80085;
colorText[] = {1, 1, 1, 1};
colorBackground[] = {0, 0, 0, 0.1};
x = "(profilenamespace getvariable ['IGUI_GRID_WEAPON_X', ((safezoneX + safezoneW) - (12.4 * (((safezoneW / safezoneH) min 1.2) / 40)) - 0.5 * (((safezoneW / safezoneH) min 1.2) / 40))])";
y = "2.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (profilenamespace getvariable ['IGUI_GRID_WEAPON_Y', (safezoneY + 0.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25))])";
w = "10 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class ACE_MILS_GROUP: CA_IGUI_elements_group { class ACE_MILS_GROUP: CA_IGUI_elements_group {
idc = 80170; idc = 80170;
class controls { class controls {

View File

@ -3,3 +3,4 @@
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
["playerVehicleChanged", {_this call FUNC(handlePlayerVehicleChanged);}] call EFUNC(common,addEventHandler); ["playerVehicleChanged", {_this call FUNC(handlePlayerVehicleChanged);}] call EFUNC(common,addEventHandler);
["infoDisplayChanged", {_this call FUNC(turretDisplayLoaded);}] call EFUNC(common,addEventHandler);

View File

@ -12,10 +12,13 @@ class CfgPatches {
}; };
}; };
#include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp" #include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp" #include "CfgVehicles.hpp"
#include "CfgWeapons.hpp" #include "CfgWeapons.hpp"
//UI Stuff:
class RscText; class RscText;
class RscListbox; class RscListbox;
class RscListNBox; class RscListNBox;
@ -23,7 +26,7 @@ class RscPicture;
class RscControlsGroup; class RscControlsGroup;
class ScrollBar; class ScrollBar;
class RscActiveText; class RscActiveText;
class RscStructuredText;
#include "RscInGameUI.hpp" #include "RscInGameUI.hpp"
#include "RscRangeTable.hpp" #include "RscRangeTable.hpp"
#include "ACE_Settings.hpp"

View File

@ -21,7 +21,7 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_shooterMan", "_bisAirFriction", "_temperature", "_newMuzzleVelocityCoefficent", "_bulletVelocity", "_bulletSpeed"]; private ["_shooterMan", "_temperature", "_newMuzzleVelocityCoefficent", "_bulletVelocity", "_bulletSpeed"];
disableSerialization; disableSerialization;
@ -35,11 +35,6 @@ if (_vehicle distance ACE_player > 8000) exitWith {false};
_shooterMan = gunner _vehicle; _shooterMan = gunner _vehicle;
if (!([_shooterMan] call EFUNC(common,isPlayer))) exitWith {false}; if (!([_shooterMan] call EFUNC(common,isPlayer))) exitWith {false};
//Should be zero, just make sure:
_bisAirFriction = getNumber (configFile >> "CfgAmmo" >> _ammo >> "airFriction");
if (_bisAirFriction != 0) exitWith {ERROR("Non zero base airFriction");};
//Calculate air density: //Calculate air density:
_altitude = (getPosASL _vehicle) select 2; _altitude = (getPosASL _vehicle) select 2;
_temperature = _altitude call EFUNC(weather,calculateTemperatureAtHeight); _temperature = _altitude call EFUNC(weather,calculateTemperatureAtHeight);

View File

@ -16,33 +16,29 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_chargeText", "_xPos", "_yPos", "_wPos", "_hPos", "_tubeWeaponName", "_fireModes"];
PARAMS_2(_player,_newVehicle); PARAMS_2(_player,_newVehicle);
private["_tubeWeaponName" ,"_fireModes"];
if (isNull _newVehicle) exitWith {}; if (isNull _newVehicle) exitWith {};
if (!(_newVehicle isKindOf "Mortar_01_base_F")) exitWith {}; if (!(_newVehicle isKindOf "Mortar_01_base_F")) exitWith {};
_chargeText = (findDisplay 46) ctrlCreate ["RscStructuredText", 80085];
_xPos = (profilenamespace getvariable ["IGUI_GRID_WEAPON_X", ((safezoneX + safezoneW) - (12.4 * (((safezoneW / safezoneH) min 1.2) / 40)) - 0.5 * (((safezoneW / safezoneH) min 1.2) / 40))]);
_yPos = 2.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (profilenamespace getvariable ["IGUI_GRID_WEAPON_Y", (safezoneY + 0.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25))]);
_wPos = 10 * (((safezoneW / safezoneH) min 1.2) / 40);
_hPos = 1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25);
_chargeText ctrlSetPosition [_xPos, _yPos, _wPos, _hPos];
_chargeText ctrlCommit 0;
_tubeWeaponName = (weapons _newVehicle) select 0; _tubeWeaponName = (weapons _newVehicle) select 0;
_fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes"); _fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes");
//Restore last firemode:
_lastFireMode = _newVehicle getVariable [QGVAR(lastFireMode), -1];
if (_lastFireMode != -1) then {
_player action ["SwitchWeapon", _newVehicle, _player, _lastFireMode];
};
[{ [{
private["_chargeText", "_currentChargeMode", "_currentFireMode", "_display", "_elevDeg", "_elevationDiff", "_lookVector", "_notGunnerView", "_realAzimuth", "_realElevation", "_upVectorDir", "_useMils", "_weaponDir"];
PARAMS_2(_args,_pfID); PARAMS_2(_args,_pfID);
EXPLODE_3_PVT(_args,_mortarVeh,_chargeText,_fireModes); EXPLODE_2_PVT(_args,_mortarVeh,_fireModes);
if ((vehicle ACE_player) != _mortarVeh) then { if ((vehicle ACE_player) != _mortarVeh) then {
[_pfID] call CBA_fnc_removePerFrameHandler; [_pfID] call CBA_fnc_removePerFrameHandler;
ctrlDelete _chargeText;
} else { } else {
_useMils = _mortarVeh getVariable [QGVAR(useMils), true]; _useMils = _mortarVeh getVariable [QGVAR(useMils), true];
@ -51,8 +47,9 @@ _fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes")
_currentFireMode = (weaponState [_mortarVeh, [0]]) select 2; _currentFireMode = (weaponState [_mortarVeh, [0]]) select 2;
_currentChargeMode = _fireModes find _currentFireMode; _currentChargeMode = _fireModes find _currentFireMode;
_text = format ["<t size='0.8'>%1: %2 <img image='%3'/></t>", (localize LSTRING(rangetable_charge)), _currentChargeMode, QUOTE(PATHTOF(UI\ui_charges.paa))]; //Save firemode on vehicle:
_chargeText ctrlSetStructuredText parseText _text; _mortarVeh setVariable [QGVAR(lastFireMode), _currentChargeMode];
if (shownArtilleryComputer && {!GVAR(allowComputerRangefinder)}) then { if (shownArtilleryComputer && {!GVAR(allowComputerRangefinder)}) then {
//Don't like this solution, but it works //Don't like this solution, but it works
closeDialog 0; closeDialog 0;
@ -62,18 +59,51 @@ _fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes")
_display = uiNamespace getVariable ["ACE_Mk6_RscWeaponRangeArtillery", displayNull]; _display = uiNamespace getVariable ["ACE_Mk6_RscWeaponRangeArtillery", displayNull];
if (isNull _display) exitWith {}; //It may be null for the first frame if (isNull _display) exitWith {}; //It may be null for the first frame
_chargeText = format ["<t size='0.8'>%1: %2 <img image='%3'/></t>", (localize LSTRING(rangetable_charge)), _currentChargeMode, QUOTE(PATHTOF(UI\ui_charges.paa))];
//Hud should hidden in 3rd person //Hud should hidden in 3rd person
_notGunnerView = cameraView != "GUNNER"; _notGunnerView = cameraView != "GUNNER";
//Update CurrentElevation Display: //Calc real azimuth/elevation
//(looking at the sky VS looking at ground will radicaly change fire direction because BIS)
_realAzimuth = -1;
_realElevation = -1;
if ((ctrlText (_display displayCtrl 173)) == "--") then {
//No range (looking at sky), it will follow weaponDir:
_weaponDir = _mortarVeh weaponDirection (currentWeapon _mortarVeh);
_realAzimuth = (_weaponDir select 0) atan2 (_weaponDir select 1);
_realElevation = asin (_weaponDir select 2);
} else {
//Valid range, will fire at camera dir
_lookVector = (ATLToASL (positionCameraToWorld [0,0,0])) vectorFromTo (ATLToASL (positionCameraToWorld [0,0,10]));
_realAzimuth = ((_lookVector select 0) atan2 (_lookVector select 1));
_upVectorDir = (((vectorUp _mortarVeh) select 0) atan2 ((vectorUp _mortarVeh) select 1));
_elevationDiff = (cos (_realAzimuth - _upVectorDir)) * acos ((vectorUp _mortarVeh) select 2);
_realElevation = ((180 / PI) * (_mortarVeh animationPhase "mainGun")) + 75 - _elevationDiff;
};
//Update Heading Display:
if (_notGunnerView || (!GVAR(allowCompass))) then {
(_display displayCtrl 80156) ctrlSetText "";
} else {
if (_useMils) then {
(_display displayCtrl 80156) ctrlSetText str (((round (_realAzimuth * 6400 / 360)) + 6400) % 6400);
} else {
(_display displayCtrl 80156) ctrlSetText str ((round (_realAzimuth + 360)) % 360);
};
};
//Update CurrentElevation Display and "charge" text
if (_notGunnerView) then { if (_notGunnerView) then {
(_display displayCtrl 80085) ctrlSetStructuredText parseText "";
(_display displayCtrl 80175) ctrlSetText ""; (_display displayCtrl 80175) ctrlSetText "";
} else { } else {
_elevDeg = parseNumber ctrlText (_display displayCtrl 175); (_display displayCtrl 80085) ctrlSetStructuredText parseText _chargeText;
if (_useMils) then { if (_useMils) then {
(_display displayCtrl 80175) ctrlSetText str round (_elevDeg * 6400 / 360); (_display displayCtrl 80175) ctrlSetText str ((round (_realElevation * 6400 / 360)) % 6400);
} else { } else {
(_display displayCtrl 80175) ctrlSetText str _elevDeg; (_display displayCtrl 80175) ctrlSetText str (((round (_realElevation * 100)) / 100) % 360);
}; };
}; };
@ -85,24 +115,13 @@ _fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes")
if (_elevDeg <= 0) then { //Bad data means "----" out of range if (_elevDeg <= 0) then { //Bad data means "----" out of range
(_display displayCtrl 80176) ctrlSetText (ctrlText (_display displayCtrl 176)); (_display displayCtrl 80176) ctrlSetText (ctrlText (_display displayCtrl 176));
} else { } else {
_elevDeg = _elevDeg + (_realElevation - (parseNumber ctrlText (_display displayCtrl 175)));
if (_useMils) then { if (_useMils) then {
(_display displayCtrl 80176) ctrlSetText str round (_elevDeg * 6400 / 360); (_display displayCtrl 80176) ctrlSetText str round ((round (_elevDeg * 6400 / 360)) % 6400);
} else { } else {
(_display displayCtrl 80176) ctrlSetText str _elevDeg; (_display displayCtrl 80176) ctrlSetText str (((round (_elevDeg * 100)) / 100) % 360);
}; };
}; };
}; };
//Update Heading Display:
if (_notGunnerView || (!GVAR(allowCompass))) then {
(_display displayCtrl 80156) ctrlSetText "";
} else {
_rotationDegrees = ((getDir _mortarVeh) + (((-180 / PI) * (_mortarVeh animationPhase "mainTurret")) + 360)) % 360;
if (_useMils) then {
(_display displayCtrl 80156) ctrlSetText str round (_rotationDegrees * 6400 / 360);
} else {
(_display displayCtrl 80156) ctrlSetText (ctrlText (_display displayCtrl 156));
};
};
}; };
}, 0, [_newVehicle, _chargeText,_fireModes]] call CBA_fnc_addPerFrameHandler; }, 0, [_newVehicle, _fireModes]] call CBA_fnc_addPerFrameHandler;

View File

@ -3,18 +3,28 @@
* Called when the mk6's in game UI is loaded. Hides rangefinder data if it is disabled. * Called when the mk6's in game UI is loaded. Hides rangefinder data if it is disabled.
* *
* Arguments: * Arguments:
* None * 0: Display <DISPLAY>
* 1: Type <STRING>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [] call ace_mk6mortar_fnc_turretDisplayLoaded * [rsc,"Mk6Mortar"] call ace_mk6mortar_fnc_turretDisplayLoaded
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
disableSerialization;
PARAMS_2(_display,_rscType);
if (_rscType != "Mk6Mortar") exitWith {};
if (isNull _display) exitWith {};
private ["_fnc_hideControl", "_xPos", "_yPos", "_wPos", "_hPos"];
#define CTRL_CA_OPTICSPITCH (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_OPTICSPITCH") #define CTRL_CA_OPTICSPITCH (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_OPTICSPITCH")
#define CTRL_CA_OPTICSZOOM (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_OPTICSZOOM") #define CTRL_CA_OPTICSZOOM (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_OPTICSZOOM")
#define CTRL_CA_SOLUTION_TEXT (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_SOLUTION_TEXT") #define CTRL_CA_SOLUTION_TEXT (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_SOLUTION_TEXT")
@ -29,15 +39,8 @@
#define CTRL_CA_ELEV (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_ELEV") #define CTRL_CA_ELEV (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_ELEV")
#define CTRL_CA_ELEV_NEED (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_ELEV_NEED") #define CTRL_CA_ELEV_NEED (configFile >> "RscInGameUI" >> "ACE_Mk6_RscWeaponRangeArtillery" >> "CA_IGUI_elements_group" >> "controls" >> "CA_ELEV_NEED")
private ["_display", "_fnc_hideControl"];
disableSerialization;
_display = uiNamespace getVariable ["ACE_Mk6_RscWeaponRangeArtillery", displayNull];
if (isNull _display) exitWith {};
_fnc_hideControl = { _fnc_hideControl = {
private "_idc"; private ["_idc", "_pos"];
PARAMS_2(_path,_hideCtrl); PARAMS_2(_path,_hideCtrl);
_idc = getNumber (_path >> "IDC"); _idc = getNumber (_path >> "IDC");
_pos = []; _pos = [];
@ -64,4 +67,3 @@ _fnc_hideControl = {
[CTRL_CA_HEADING, true] call _fnc_hideControl; [CTRL_CA_HEADING, true] call _fnc_hideControl;
[CTRL_CA_ELEV, true] call _fnc_hideControl; [CTRL_CA_ELEV, true] call _fnc_hideControl;
[CTRL_CA_ELEV_NEED, true] call _fnc_hideControl; [CTRL_CA_ELEV_NEED, true] call _fnc_hideControl;