Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V0.96.8] carry ressource crates #813

Merged
merged 13 commits into from
Oct 28, 2023
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## 0.96.8 (TBD)
* Added: Czech translation. Thanks to [MJVEVERUSKA](https://github.com/MJVEVERUSKA)
* Added: Ability to carry ressource crates.
* Added: Scripts/configs to setup and run development environment from VSCode tasks
* Updated: Italian localization. Thanks to [k4s0](https://github.com/k4s0)
* Tweaked: Splitted the config file in separate files, as it was getting quite big.
Expand Down
31 changes: 30 additions & 1 deletion Missionframework/functions/fn_addActionsPlayer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
File: fn_addActionsPlayer.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2020-04-13
Last Update: 2020-09-12
Last Update: 2023-10-28
License: MIT License - http://www.opensource.org/licenses/MIT

Description:
Expand Down Expand Up @@ -370,4 +370,33 @@ _player addAction [
"
];

// Drop crate
_player addAction [
["<t color='#FFFF00'>", localize "STR_ACTION_CRATE_DROP", "</t>"] joinString "",
{
params ["_player"];
private _crate = _player getVariable ["KPLIB_carriedObject", objNull];

// prevent players from putting crates inside vehicles
private _crateSize = sizeOf typeOf _crate * 1.5;
private _nearObjects = (_crate nearEntities [["Man", "Air", "Car", "Tank"], _crateSize]) - [_crate, _player];
if (_nearObjects isNotEqualTo []) exitWith {
hint format [localize "STR_PLACEMENT_IMPOSSIBLE", count _nearObjects, _crateSize toFixed 0];
};

_player setVariable ["KPLIB_carriedObject", nil];
detach _crate;
_crate awake true;
},
nil,
-504,
true,
false,
"",
toString {
alive _originalTarget &&
build_confirmed == 0 && _this in _this && {!isNull (_this getVariable ["KPLIB_carriedObject", objNull])}
}
];
Dubjunk marked this conversation as resolved.
Show resolved Hide resolved

true
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,24 @@ while {true} do {
_b_action_id2 = _next_box addAction ["<t color='#FFFF00'>" + localize "STR_ACTION_STORE_CRATE" + "</t>",{[(_this select 0), (nearestObjects [player,KPLIB_storageBuildings,20]) select 0,true] call KPLIB_fnc_crateToStorage;},"",-502,true,true,"","build_confirmed == 0 && (_this distance _target < 5) && (vehicle player == player)"];
_b_action_id3 = _next_box addAction ["<t color='#FFFF00'>" + localize "STR_ACTION_CRATE_VALUE" + "</t>",{[_this select 0] call KPLIB_fnc_checkCrateValue;uiSleep 3; hint "";},"",-503,true,true,"","build_confirmed == 0 && (_this distance _target < 5) && (vehicle player == player)"];
_b_action_id4 = _next_box addAction ["<t color='#FFFF00'>" + localize "STR_ACTION_CRATE_PUSH" + "</t>",{(_this select 0) setPos ((_this select 0) getPos [1, (player getDir (_this select 0))]);},"",-504,true,false,"","build_confirmed == 0 && (_this distance _target < 5) && (vehicle player == player)"];
_b_action_id_carry = _next_box addAction [
"<t color='#FFFF00'>" + localize "STR_ACTION_CRATE_CARRY" + "</t>",
{
params ["_crate", "_player"];
_crate attachTo [_player, [0, 2, 1]];
_player setVariable ["KPLIB_carriedObject", _crate];
},
"", -504, true, false, "",
toString {
build_confirmed == 0 && _this in _this && {isNull (_this getVariable ["KPLIB_carriedObject", objNull])}
},
5 // radius
];
_next_box setVariable ["KPLIB_ammo_box_action", _b_action_id1, false];
_next_box setVariable ["KP_crate_store_action", _b_action_id2, false];
_next_box setVariable ["KP_crate_value_action", _b_action_id3, false];
_next_box setVariable ["KP_crate_push_action", _b_action_id4, false];
_next_box setVariable ["KP_crate_carry_action", _b_action_id_carry, false];
_managed_boxes pushback _next_box;
};

Expand All @@ -75,6 +89,8 @@ while {true} do {
_next_box removeAction (_next_box getVariable ["KP_crate_store_action", -1]);
_next_box removeAction (_next_box getVariable ["KP_crate_value_action", -1]);
_next_box removeAction (_next_box getVariable ["KP_crate_push_action", -1]);
_next_box removeAction (_next_box getVariable ["KP_crate_carry_action", -1]);
_next_box removeAction (_next_box getVariable ["KP_crate_drop_action", -1]);
}
} foreach _managed_boxes;

Expand Down
6 changes: 6 additions & 0 deletions Missionframework/scripts/client/init_client.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ player addEventHandler ["GetInMan", {[_this select 2] spawn kp_fuel_consumption;
player addEventHandler ["GetInMan", {[_this select 2] call KPLIB_fnc_setVehiclesSeized;}];
player addEventHandler ["GetInMan", {[_this select 2] call KPLIB_fnc_setVehicleCaptured;}];
player addEventHandler ["GetInMan", {[_this select 2] call kp_vehicle_permissions;}];
player addEventHandler ["GetInMan", {
params ["_player"];
// prevent players from getting into vehicles while carrying
if (isNull (_player getVariable ["KPLIB_carriedObject", objNull])) exitWith {};
moveOut _player;
}];
player addEventHandler ["SeatSwitchedMan", {[_this select 2] call kp_vehicle_permissions;}];
player addEventHandler ["HandleRating", {if ((_this select 1) < 0) then {0};}];

Expand Down
8 changes: 8 additions & 0 deletions Missionframework/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5109,6 +5109,14 @@
<Korean>-- 군수물품 밀기</Korean>
<Czech>-- TLAČIT KRABICI</Czech>
</Key>
<Key ID="STR_ACTION_CRATE_CARRY">
<Original>-- CARRY CRATE</Original>
<German>-- KISTE TRAGEN</German>
</Key>
<Key ID="STR_ACTION_CRATE_DROP">
<Original>-- DROP CRATE</Original>
<German>-- KISTE ABLEGEN</German>
</Key>
<Key ID="STR_ACTION_SORT_STORAGE">
<Original>-- STACK AND SORT</Original>
<German>-- STAPELN UND SORTIEREN</German>
Expand Down