Fixes and Upgrades

Fixed Flag in ground upon building, added full on vector to the snapping
system, added mins and max to the movements key handler and cleaned up
code
This commit is contained in:
DESKTOP-UH65DCE\MusTanG 2017-02-24 00:03:59 -06:00
parent ef588190fd
commit df742612d4
5 changed files with 35 additions and 67 deletions

View File

@ -34,8 +34,7 @@ else
ExileClientConstructionRotation = 0;
ExileClientConstructionObjectDisplayName = getText(configFile >> "CfgVehicles" >> _previewObjectClassName >> "displayName");
ExileClientConstructionOffset = [0, 5,0];
BuildPosX = 0;BuildPosY = 5;BuildPosZ = 0;BuildVecYaw = 0;BuildVecPitch = 0;BuildVecRoll = 0;
[] call freeVectorBuilding;
BuildVecYaw = 0;BuildVecPitch = 0;BuildVecRoll = 0;
ExileClientConstructionMode = 1;
ExileClientConstructionIsInSelectSnapObjectMode = true;
ExileClientConstructionSupportSnapMode = count(ExileClientConstructionSnapToObjectClassNames) > 0;

View File

@ -26,7 +26,7 @@ ExileClientConstructionSnapToObjectClassNames = (ExileClientConstructionConfig >
ExileClientConstructionProcess = 1;
ExileClientConstructionOffset = [0, 5, 0];
ExileClientConstructionPosition = [0, 0, 0];
BuildPosX = 0;BuildPosY = 5;BuildPosZ = 0;BuildVecYaw = 0;BuildVecPitch = 0;BuildVecRoll = 0;
BuildVecYaw = 0;BuildVecPitch = 0;BuildVecRoll = 0;
ExileClientConstructionRotation = 0;
ExileClientConstructionKitClassName = _kitClassName;
ExileClientConstructionObjectDisplayName = getText(configFile >> "CfgVehicles" >> _previewObjectClassName >> "displayName");

View File

@ -70,7 +70,6 @@ switch (ExileClientConstructionResult) do
};
};
};
BuildPosX = 0;BuildPosY = 5;BuildPosZ = 0;
BuildVecYaw = 0;BuildVecPitch = 0;BuildVecRoll = 0;
(findDisplay 46) displayRemoveEventHandler ["KeyDown", keyDownEHId];
ExileClientConstructionObject = objNull;

View File

@ -73,17 +73,19 @@ while {ExileClientConstructionResult isEqualTo 0} do
{
case 1:
{
_newDirAndUp = [[sin BuildVecYaw * cos BuildVecPitch, cos BuildVecYaw * cos BuildVecPitch, sin BuildVecPitch],[[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
_vectorDirection = _newDirAndUp select 0;
_vectorUp = _newDirAndUp select 1;
ExileClientConstructionObject setVectorDirAndUp [_vectorDirection,_vectorUp];
_position = ASLtoATL (AGLtoASL (player modelToWorld ExileClientConstructionOffset));
ExileClientConstructionObject setPosATL _position;
ExileClientConstructionObject attachTo [player,ExileClientConstructionOffset];
//_position = ASLtoATL (AGLtoASL (player modelToWorld ExileClientConstructionOffset));
//_rotation = (ExileClientConstructionRotation + (getDir player) + 360) % 360;
//_vectorDirection = [sin(_rotation), cos(_rotation), 0];
if!(_isFlag)then{
_newDirAndUp = [[sin BuildVecYaw * cos BuildVecPitch, cos BuildVecYaw * cos BuildVecPitch, sin BuildVecPitch],[[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
_vectorDirection = _newDirAndUp select 0;
_vectorUp = _newDirAndUp select 1;
ExileClientConstructionObject setVectorDirAndUp [_vectorDirection,_vectorUp];
_position = ASLtoATL (AGLtoASL (player modelToWorld ExileClientConstructionOffset));
ExileClientConstructionObject setPosATL _position;
ExileClientConstructionObject attachTo [player,ExileClientConstructionOffset];
}else{
_position = ASLtoATL (AGLtoASL (player modelToWorld ExileClientConstructionOffset));
_rotation = (ExileClientConstructionRotation + (getDir player) + 360) % 360;
_vectorDirection = [sin(_rotation), cos(_rotation), 0];
};
};
case 2:
{
@ -113,8 +115,8 @@ while {ExileClientConstructionResult isEqualTo 0} do
ExileClientConstructionCurrentSnapToObject = objNull;
_position = getPosATL player;
_position set [2, -500];
_rotation = (ExileClientConstructionRotation + (getDir player) + 360) % 360;
_vectorDirection = [sin(_rotation), cos(_rotation), 0];
_newDirAndUp = [[sin BuildVecYaw * cos BuildVecPitch, cos BuildVecYaw * cos BuildVecPitch, sin BuildVecPitch],[[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
_vectorDirection = _newDirAndUp select 0;
_potentionalSnapObject = cursorTarget;
if !(isNull _potentionalSnapObject) then
{
@ -148,8 +150,8 @@ while {ExileClientConstructionResult isEqualTo 0} do
if (_x distance _position < 1) exitWith
{
_position = _x;
_rotation = (ExileClientConstructionRotation + (getDir ExileClientConstructionCurrentSnapToObject) + 360) % 360;
_vectorDirection = [sin(_rotation), cos(_rotation), 0];
_newDirAndUp = [[sin BuildVecYaw * cos BuildVecPitch, cos BuildVecYaw * cos BuildVecPitch, sin BuildVecPitch],[[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
_vectorDirection = _newDirAndUp select 0;
_vectorUp = vectorUp ExileClientConstructionCurrentSnapToObject;
ExileClientConstructionIsSnapped = true;
};

View File

@ -26,9 +26,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 3;};
if(_ctrl)then{_adjust = 0.5;};
if(_alt)then{ _adjust = 0.25;};
BuildVecYaw = BuildVecYaw - _adjust;
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecYaw = (((BuildVecYaw - _adjust)min 360) max -360);
_handled = true;
};
case 73: {
@ -36,9 +34,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 3;};
if(_ctrl)then{_adjust = 0.5;};
if(_alt)then{ _adjust = 0.25;};
BuildVecYaw = BuildVecYaw + _adjust;
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecYaw = (((BuildVecYaw + _adjust)min 360) max -360);
_handled = true;
};
case 16: {
@ -46,9 +42,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 3;};
if(_ctrl)then{_adjust = 0.5;};
if(_alt)then{ _adjust = 0.25;};
BuildVecYaw = BuildVecYaw - _adjust;
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecYaw = (((BuildVecYaw - _adjust)min 360) max -360);
_handled = true;
};
case 18: {
@ -56,9 +50,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 3;};
if(_ctrl)then{_adjust = 0.5;};
if(_alt)then{ _adjust = 0.25;};
BuildVecYaw = BuildVecYaw + _adjust;
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecYaw = (((BuildVecYaw + _adjust)min 360) max -360);
_handled = true;
};
case 72: {
@ -66,10 +58,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 1.5;};
if(_ctrl)then{_adjust = 0.1;};
if(_alt)then{ _adjust = 0.01;};
BuildPosY = BuildPosY + _adjust;
ExileClientConstructionOffset = [BuildPosX,BuildPosY,BuildPosZ];
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
ExileClientConstructionOffset set [1,((((ExileClientConstructionOffset select 1) + _adjust)min 10) max -10)];
_handled = true;
};
case 80: {
@ -77,10 +66,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 1.5;};
if(_ctrl)then{_adjust = 0.1;};
if(_alt)then{ _adjust = 0.01;};
BuildPosY = BuildPosY - _adjust;
ExileClientConstructionOffset = [BuildPosX,BuildPosY,BuildPosZ];
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
ExileClientConstructionOffset set [1,((((ExileClientConstructionOffset select 1) - _adjust)min 10) max -10)];
_handled = true;
};
case 75: {
@ -88,10 +74,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 1.5;};
if(_ctrl)then{_adjust = 0.1;};
if(_alt)then{ _adjust = 0.01;};
BuildPosX = BuildPosX - _adjust;
ExileClientConstructionOffset = [BuildPosX,BuildPosY,BuildPosZ];
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
ExileClientConstructionOffset set [0,((((ExileClientConstructionOffset select 0) - _adjust)min 10) max -10)];
_handled = true;
};
case 77: {
@ -99,24 +82,17 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 1.5;};
if(_ctrl)then{_adjust = 0.1;};
if(_alt)then{ _adjust = 0.01;};
BuildPosX = BuildPosX + _adjust;
ExileClientConstructionOffset = [BuildPosX,BuildPosY,BuildPosZ];
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
ExileClientConstructionOffset set [0,((((ExileClientConstructionOffset select 0) + _adjust)min 10) max -10)];
_handled = true;
};
case 76: {
BuildPosX = 0;BuildPosY = 5;BuildPosZ = 0;BuildVecYaw = 0;BuildVecPitch = 0;BuildVecRoll = 0;
ExileClientConstructionOffset = [BuildPosX,BuildPosY,BuildPosZ];
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecYaw = 0;BuildVecPitch = 0;BuildVecRoll = 0;
ExileClientConstructionOffset = [0,5,0];
_handled = true;
};
case 14: {
BuildPosX = 0;BuildPosY = 5;BuildPosZ = 0;BuildVecYaw = 0;BuildVecPitch = 0;BuildVecRoll = 0;
ExileClientConstructionOffset = [BuildPosX,BuildPosY,BuildPosZ];
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecYaw = 0;BuildVecPitch = 0;BuildVecRoll = 0;
ExileClientConstructionOffset = [0,5,0];
_handled = true;
};
case 208: {
@ -124,9 +100,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 1.5;};
if(_ctrl)then{_adjust = 0.1;};
if(_alt)then{ _adjust = 0.01;};
BuildVecPitch = BuildVecPitch + _adjust;BuildVecYaw = BuildVecYaw;BuildVecRoll = BuildVecRoll;
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecPitch = (((BuildVecPitch + _adjust)min 360) max -360);
_handled = true;
};
case 200: {
@ -134,9 +108,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 1.5;};
if(_ctrl)then{_adjust = 0.1;};
if(_alt)then{ _adjust = 0.01;};
BuildVecPitch = BuildVecPitch - _adjust;BuildVecYaw = BuildVecYaw;BuildVecRoll = BuildVecRoll;
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecPitch =(((BuildVecPitch - _adjust)min 360) max -360);
_handled = true;
};
case 203: {
@ -144,9 +116,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 1.5;};
if(_ctrl)then{_adjust = 0.1;};
if(_alt)then{ _adjust = 0.01;};
BuildVecRoll = BuildVecRoll - _adjust;
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecRoll = (((BuildVecRoll - _adjust)min 360) max -360);
_handled = true;
};
case 205: {
@ -154,9 +124,7 @@ keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", {
if(_shift)then{_adjust = 1.5;};
if(_ctrl)then{_adjust = 0.1;};
if(_alt)then{ _adjust = 0.01;};
BuildVecRoll = BuildVecRoll + _adjust;
_newDirAndUp = [[ sin BuildVecYaw * cos BuildVecPitch,cos BuildVecYaw * cos BuildVecPitch,sin BuildVecPitch], [[ sin BuildVecRoll,-sin BuildVecPitch,cos BuildVecRoll * cos BuildVecPitch],-BuildVecYaw] call BIS_fnc_rotateVector2D];
ExileClientConstructionObject setVectorDirAndUp _newDirAndUp;
BuildVecRoll = (((BuildVecRoll + _adjust)min 360) max -360);;
_handled = true;
};
};