Skip to content

Commit

Permalink
Merge pull request #448 from 1kuemmel1/ADD-overhaul_place_options
Browse files Browse the repository at this point in the history
Add: Expand place options
  • Loading branch information
Vdauphin authored Jan 6, 2018
2 parents 8a39af4 + ca07143 commit 532ab64
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 51 deletions.
4 changes: 2 additions & 2 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

private ["_p_civ_veh","_p_db","_p_en","_hideout_n","_cache_info_def","_cache_info_ratio","_info_chance","_p_rep","_p_skill","_c_array","_tower","_array","_chopper","_p_civ","_btc_rearming_vehicles","_vehicles","_magazines","_p_city_radius","_magazines_static","_static","_btc_rearming_static","_magazines_clean","_weapons_usefull","_magazines_static_clean","_p_en_AA"];

btc_version = 1.17; diag_log format ["=BTC= HEARTS AND MINDS VERSION %1",(str(btc_version) + ".7")];
btc_version = 1.171; diag_log format ["=BTC= HEARTS AND MINDS VERSION %1",(str(btc_version) + ".7")];

//Param

Expand Down Expand Up @@ -547,4 +547,4 @@ if (isNil "btc_side_assigned") then {btc_side_assigned = false;};
btc_AI_skill = _p_skill;

//Headless
btc_units_owners = [];
btc_units_owners = [];
35 changes: 24 additions & 11 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/loadObjectStatus.sqf
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@

params ["_object_data"];
_object_data params ["_type","_posWorld","_dir","_magClass","_cargo","_inventory","_vectorPos"];

private _obj = (_object_data select 0) createVehicle (_object_data select 1);
//create object
private _obj = _type createVehicle _posWorld;
btc_log_obj_created pushBack _obj;

//give the curator controll of the object
btc_curator addCuratorEditableObjects [[_obj], false];
_obj setDir (_object_data select 2);
_obj setPosASL (_object_data select 1);
if ((_object_data select 3) != "") then {_obj setVariable ["ace_rearm_magazineClass",(_object_data select 3),true]};

//set direction
_obj setDir _dir;

//set the position of the object
_obj setPosWorld _posWorld;

//set the vector postion
_obj setVectorDirAndUp _vectorPos;

//set ace magazine classes
if !(_magClass isEqualTo "") then {_obj setVariable ["ace_rearm_magazineClass",_magClass,true]};

//handle cargo
{
/*private "_l";
_l = _x createVehicle [0,0,0];
Expand Down Expand Up @@ -41,26 +55,25 @@ if ((_object_data select 3) != "") then {_obj setVariable ["ace_rearm_magazineCl
};
};
[_l,_obj] call btc_fnc_log_server_load;
} foreach (_object_data select 4);
private _cont = (_object_data select 5);
} foreach _cargo;

//set inventory content for weapons, magazines and items
_inventory params ["_weap","_mags","_items"];
clearWeaponCargoGlobal _obj;clearItemCargoGlobal _obj;clearMagazineCargoGlobal _obj;
private _weap = _cont select 0;
if (count _weap > 0) then {
for "_i" from 0 to ((count (_weap select 0)) - 1) do {
_obj addWeaponCargoGlobal[((_weap select 0) select _i),((_weap select 1) select _i)];
};
};
private _mags = _cont select 1;
if (count _mags > 0) then {
for "_i" from 0 to ((count (_mags select 0)) - 1) do {
_obj addMagazineCargoGlobal[((_mags select 0) select _i),((_mags select 1) select _i)];
};
};
private _items = _cont select 2;
if (count _items > 0) then {
for "_i" from 0 to ((count (_items select 0)) - 1) do {
_obj addItemCargoGlobal[((_items select 0) select _i),((_items select 1) select _i)];
};
};

_obj
_obj
12 changes: 10 additions & 2 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/saveObjectStatus.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ params ["_object"];
private _data = [];

if !(!isNil {_object getVariable "loaded"} || !Alive _object || isNull _object) then {
//select 0: Type
_data pushBack (typeOf _object);
_data pushBack (getPosASL _object);
//select 1: World Pos
_data pushBack (getPosWorld _object);
//select 2: Dir
_data pushBack (getDir _object);
//select 3: ACE rearm
_data pushBack (_object getVariable ["ace_rearm_magazineClass",""]);
//select 4: Cargo
private _cargo = [];
{_cargo pushBack [(typeOf _x),(_x getVariable ["ace_rearm_magazineClass",""]),[getWeaponCargo _x,getMagazineCargo _x,getItemCargo _x]]} foreach (_object getVariable ["cargo",[]]);
_data pushBack _cargo;
//select 5: Inventory
private _cont = [getWeaponCargo _object,getMagazineCargo _object,getItemCargo _object];
_data pushBack _cont;
//select 6: Vector Pos (Dir and Up)
_data pushBack [vectorDir _object, vectorUp _object];
};

_data
_data
59 changes: 42 additions & 17 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/log/place.sqf
Original file line number Diff line number Diff line change
@@ -1,44 +1,69 @@

private ["_bbr","_c"];

btc_log_placing_obj = _this;

[btc_log_placing_obj,player] remoteExec ["btc_fnc_set_owner", 2];

hint composeText [
(localize "STR_BTC_HAM_LOG_PLACE_HINT1"), //Q/Z to raise/lower the object
localize "STR_BTC_HAM_LOG_PLACE_HINT1", //Q/Z to raise/lower the object
lineBreak,
localize "STR_BTC_HAM_LOG_PLACE_HINT2", //X/C to rotate the object
lineBreak,
(localize "STR_BTC_HAM_LOG_PLACE_HINT2"), //X/C to rotate the object
localize "STR_BTC_HAM_LOG_PLACE_HINT3", //F/R to tilt the object
lineBreak,
(localize "STR_BTC_HAM_LOG_PLACE_HINT3") //X/C to rotate the object
localize "STR_BTC_HAM_LOG_PLACE_HINT4" //SHIFT to increase the movement
];

btc_log_placing = true;
btc_log_placing_dir = 180;
btc_log_release = player addAction [("<t color=""#ED2744"">" + (localize "STR_BTC_HAM_LOG_PLACE_RELEASE") + "</t>"),{btc_log_placing = false;}, [], 9, true, false, "", "true"]; //Release
btc_log_rotating_dir = 0;
btc_log_ptich_dir = 0;

//add action ACE
[player, "DefaultAction", {true}, {btc_log_placing = false;}] call ace_common_fnc_addActionEventHandler;

//show mouse hint for release
[localize "STR_BTC_HAM_LOG_PLACE_RELEASE",""] call ace_interaction_fnc_showMouseHint; //Release

//add actions to keys
btc_log_place_EH_keydown = (findDisplay 46) displayAddEventHandler ["KeyDown", btc_fnc_log_place_key_down];

[player] call ace_weaponselect_fnc_putWeaponAway;
player forceWalk true;

btc_log_placing_obj enableSimulation false;

_bbr = boundingBoxReal btc_log_placing_obj;
_c = boundingCenter btc_log_placing_obj;
private _bbr = boundingBoxReal btc_log_placing_obj;
private _c = boundingCenter btc_log_placing_obj;

btc_log_placing_h = (abs ((_bbr select 0) select 2)) - (_c select 2);
btc_log_placing_d = 1.5 + (abs (((_bbr select 1) select 1) - ((_bbr select 0) select 1)));

btc_log_placing_obj attachTo [player,[0,(btc_log_placing_d),btc_log_placing_h]];
btc_log_placing_obj setDir btc_log_placing_dir;
btc_log_placing_obj setDir btc_log_rotating_dir;

[{
params ["_arguments", "_idPFH"];
if (!alive player || player getVariable ["ACE_isUnconscious",false] || !btc_log_placing) then {

btc_log_placing_obj enableSimulation true;
detach btc_log_placing_obj;

//save to DB
[btc_log_placing_obj] call btc_fnc_db_saveObjectStatus;
//btc_log_obj_created pushBack btc_log_placing_obj;

player forceWalk false;

btc_log_placing_obj = objNull;
(findDisplay 46) displayRemoveEventHandler ["KeyDown",btc_log_place_EH_keydown];

hintSilent "";

waitUntil {!alive player || player getVariable ["ACE_isUnconscious",false] || !btc_log_placing};
//remove mouse hint
call ace_interaction_fnc_hideMouseHint;

btc_log_placing_obj enableSimulation true;
detach btc_log_placing_obj;
player forceWalk false;
//remove PFH
[_idPFH] call CBA_fnc_removePerFrameHandler;

btc_log_placing_obj = objNull;
(findDisplay 46) displayRemoveEventHandler ["KeyDown",btc_log_place_EH_keydown];
player removeAction btc_log_release;
hintSilent "";
};
}, 0.5, [_this]] call CBA_fnc_addPerFrameHandler;
93 changes: 74 additions & 19 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/log/place_key_down.sqf
Original file line number Diff line number Diff line change
@@ -1,25 +1,80 @@
/*
16 Q
44 Z
30 A
32 D
45 X
46 C
DIK_KeyCodes: https://community.bistudio.com/wiki/DIK_KeyCodes
*/
params ["_display","_key","_shift","_ctrl","_alt",["_keyPressed",false]];

private ["_key","_shift","_ctrl","_alt","_turbo"];
private _turbo = if (_shift) then {1} else {0};

_key = _this select 1;
_shift = _this select 2;
_ctrl = _this select 3;
_alt = _this select 4;
//height [+] (Key 16: Q)
if (_key isEqualTo 16) then {
//check for max height
if !(btc_log_placing_h > btc_log_placing_max_h) then {
//increase height
btc_log_placing_h = btc_log_placing_h + 0.1 + (_turbo/2);
//placing
btc_log_placing_obj attachTo [player,[0,btc_log_placing_d,btc_log_placing_h]];
};
//set var
_keyPressed = true;
};
//height [-] (Key 44: Z*) (*German keyboard: Y)
if (_key isEqualTo 44) then {
//check for min height
if !(btc_log_placing_h < - 2) then {
//decrease heigth
btc_log_placing_h = btc_log_placing_h - 0.1 - (_turbo/2);
//placing
btc_log_placing_obj attachTo [player,[0,btc_log_placing_d,btc_log_placing_h]];
};
//set var
_keyPressed = true;
};
//yaw [+] (Key 45: X)
if (_key isEqualTo 45) then {
//rotating clockwise
btc_log_placing_dir = btc_log_placing_dir + 0.5 + _turbo;
//set var
_keyPressed = true;
};
//yaw [-] (Key 46: C)
if (_key isEqualTo 46) then {
//rotating counterclockwise
btc_log_placing_dir = btc_log_placing_dir - 0.5 - _turbo;
//set var
_keyPressed = true;
};
//roll [+] (Key 33: F)
if (_key isEqualTo 33) then {
//tilting clockwise
btc_log_rotating_dir = btc_log_rotating_dir + 0.5 + _turbo;
//set var
_keyPressed = true;
};
//roll [-] (Key 19: R)
if (_key isEqualTo 19) then {
//tilting counterclockwise
btc_log_rotating_dir = btc_log_rotating_dir - 0.5 - _turbo;
//set var
_keyPressed = true;
};

_turbo = if (_shift) then {1} else {0};
//set object position (rotation and tilting)
if (_keyPressed) then {
btc_log_placing_obj setVectorDirAndUp [
[
(sin btc_log_placing_dir) * (cos btc_log_ptich_dir),
(cos btc_log_placing_dir) * (cos btc_log_ptich_dir),
(sin btc_log_ptich_dir)
],
[
[
(sin btc_log_rotating_dir),
(-sin btc_log_ptich_dir),
(cos btc_log_rotating_dir * cos btc_log_ptich_dir)
],
-btc_log_placing_dir
] call BIS_fnc_rotateVector2D
];
};

switch (true) do {
case (_key == 16) : {if (btc_log_placing_h > btc_log_placing_max_h) exitWith {true};btc_log_placing_h = btc_log_placing_h + 0.1 + (_turbo/2);btc_log_placing_obj attachTo [player,[0,btc_log_placing_d,btc_log_placing_h]];true};
case (_key == 44) : {if (btc_log_placing_h < - 2) exitWith {true};btc_log_placing_h = btc_log_placing_h - 0.1 - (_turbo/2);btc_log_placing_obj attachTo [player,[0,btc_log_placing_d,btc_log_placing_h]];true};
case (_key == 45) : {btc_log_placing_dir = btc_log_placing_dir + 0.5 + _turbo;btc_log_placing_obj setDir btc_log_placing_dir;true};
case (_key == 46) : {btc_log_placing_dir = btc_log_placing_dir - 0.5 - _turbo;btc_log_placing_obj setDir btc_log_placing_dir;true};
default {false};
};
_keyPressed
5 changes: 5 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,11 @@
<German>X/C um das Objekt zu drehen</German>
</Key>
<Key ID="STR_BTC_HAM_LOG_PLACE_HINT3">
<Original>F/R to tilt the object</Original>
<English>F/R to tilt the object</English>
<German>F/R um das Object zu neigen</German>
</Key>
<Key ID="STR_BTC_HAM_LOG_PLACE_HINT4">
<Original>SHIFT to increase the movement</Original>
<English>SHIFT to increase the movement</English>
<German>SHIFT um die Bewegung des Objektes zu beschleunigen</German>
Expand Down

0 comments on commit 532ab64

Please sign in to comment.