Skip to content

Commit

Permalink
sheep transport, interacts added procedurally (#140)
Browse files Browse the repository at this point in the history
**sheep transport**

* stop/start animal behavior on interact
* carry using ACE_dragging
* transport on flatbeds
    * gaz-66, zil-131, ural & vanilla "truck"
    * configurable positioning
    * locking & unlocking of single seats - humans can be loaded next to sheep, if they dont collide
    * configurable unloadActionPoint at back of vehicle
    * selectively or bulk unload (the latter with progress bar)
    * optionally select specific seat when loading animal
* extensible configuration (could be used for more livestock or even stuff like crates etc)
    * utility script in tools/
* no support for mixed configurations (yet)
* add PBO files to .gitignore

*this commit contains all the squashed history from gruppe-adler/grad-animalTransport and lots of refactoring on top*
  • Loading branch information
Fusselwurm authored Nov 23, 2019
1 parent a2c2146 commit 30e5ea7
Show file tree
Hide file tree
Showing 38 changed files with 971 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
release/
*.pbo
.idea/
.vscode/

Expand Down
1 change: 1 addition & 0 deletions addons/animalTransport/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x\grad\addons\animalTransport
27 changes: 27 additions & 0 deletions addons/animalTransport/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
clientInit = QUOTE(call COMPILE_FILE(XEH_postClientInit));
};
};


class Extended_InitPost_EventHandlers {
class Sheep_random_F {
class ADDON {
init = QUOTE(_this call ace_dragging_fnc_initObject);
};
};
};
188 changes: 188 additions & 0 deletions addons/animalTransport/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
class CfgVehicles {
class Animal_Base_F;
class Sheep_random_F: Animal_Base_F {
class GRAD_AnimalTransport {
stop = "Sheep_Stop";
default = "Sheep_Idle_Stop";
actionPoint[] = {0, 0.35, 0.65};
};
ACE_dragging_canCarry = 1;
ACE_dragging_carryPosition[] = {-0.5, 0.6, 0.5};
ACE_dragging_carryDirection = 90;
};

class Van_01_base_F;
class I_G_Van_01_transport_F: Van_01_base_F {
class GRAD_AnimalTransport {
unloadPoint[] = {0, -4.2, -0.6};
unloadActionPoint[] = {0, -3.4, -0.4};
class Sheep_random_F {
class Spaces {
class FrontOuterLeft {
offset[] = {-0.7, -1.4, -0.6};
cargoIndices[] = {2, 4};
};
class FrontInnerLeft {
offset[] = {-0.25, -1.6, -0.6};
cargoIndices[] = {2, 4};
};
class FrontInnerRight {
offset[] = {0.2, -1.4, -0.6};
cargoIndices[] = {3, 5};
};
class FrontOuterRight {
offset[] = { 0.65, -1.6, -0.6};
cargoIndices[] = {3, 5};
};
class BackOuterRight {
offset[] = { 0.7, -3.0, -0.6};
cargoIndices[] = {7, 9,11};
};
class BackInnerRight {
offset[] = { 0.25, -2.8, -0.6};
cargoIndices[] = {7, 9,11};
};
class BackInnerLeft {
offset[] = { -0.2, -3.0, -0.6};
cargoIndices[] = {6, 8, 10};
};
class BackOuterLeft {
offset[] = { -0.65, -2.8, -0.6};
cargoIndices[] = {6, 8, 10};
};
};
};
};
};

class RHS_Ural_Civ_Base;
class rhsgref_ins_ural_work_open: RHS_Ural_Civ_Base {
class GRAD_AnimalTransport {
unloadPoint[] = {0, -4.1, -0.2};
unloadActionPoint[] = {0, -3.3, -0.1};
class Sheep_random_F {
class Spaces {
class FrontLeft {
offset[] = {-0.50, -0.70, -0.20};
cargoIndices[] = {13, 3, 5};
};
class FrontMiddle {
offset[] = {-0.05, -0.70, -0.20};
cargoIndices[] = {};
};
class FrontRight {
offset[] = {0.50, -0.70, -0.20};
cargoIndices[] = {12, 2, 4};
};
class CenterLeft {
offset[] = {-0.50, -2.10, -0.20};
cargoIndices[] = {5, 7, 9};
};
class CenterMiddle {
offset[] = {0.00, -2.20, -0.20};
cargoIndices[] = {};
};
class CenterRight {
offset[] = {0.5, -2.10, -0.20};
cargoIndices[] = {4, 6, 8};
};
class RearRight {
offset[] = {-0.4, -2.60, -0.20};
dir = 90;
cargoIndices[] = {8, 9};
};
class RearLeft {
offset[] = {0.4, -3.0, -0.20};
dir = 270;
cargoIndices[] = {10, 11};
};
};
};
};
};
class rhs_gaz66_vmf;
class rhs_gaz66o_vmf: rhs_gaz66_vmf {
class GRAD_AnimalTransport {
unloadPoint[] = {0, -3.4, -0.6};
unloadActionPoint[] = {0, -2.6, -0.4};
class Sheep_random_F {
class Spaces {
class FrontOuterLeft {
offset[] = {-0.8, -0.6, -0.6};
};
class FrontInnerLeft {
offset[] = {-0.35, -0.75, -0.6};
};
class FrontInnerRight {
offset[] = {0.1, -0.6, -0.6};
};
class FrontOuterRight {
offset[] = { 0.55, -0.75, -0.6};
};
class BackOuterRight {
offset[] = { 0.55, -2.0, -0.6};
};
class BackInnerRight {
offset[] = { 0.25, -1.8, -0.6};
};
class BackInnerLeft {
offset[] = { -0.2, -2.0, -0.6};
};
class BackOuterLeft {
offset[] = { -0.65, -1.8, -0.6};
};
};
};
};
};
class rhs_zil131_open_base;
class rhs_zil131_flatbed_base: rhs_zil131_open_base {
class GRAD_AnimalTransport {
unloadPoint[] = {0, -3.4, -0.6};
unloadActionPoint[] = {0, -2.6, -0.4};
class Sheep_random_F {
class Spaces {
class FrontOuterLeft {
offset[] = {-0.9, -0.5, -0.6};
};
class FrontInnerLeft {
offset[] = {-0.45, -0.65, -0.6};
};
class FrontMiddle {
offset[] = {0.0, -0.5, -0.6};
};
class FrontInnerRight {
offset[] = { 0.45, -0.65, -0.6};
};
class FrontOuterRight {
offset[] = { 0.9, -0.5, -0.6};
};
class CenterRight {
offset[] = { -0.1, -1.1, -0.6};
dir = 90;
};
class BackOuterRight {
offset[] = { 0.9, -1.5, -0.6};
dir = 180;
};
class BackInnerRight {
offset[] = { 0.45, -1.4, -0.6};
dir = 180;
};
class BackInnerLeft {
offset[] = { -0.45, -1.0, -0.6};
dir = 180;
};
class BackOuterLeft {
offset[] = { -0.9, -1.1, -0.6};
dir = 180;
};
class BackLeft {
offset[] = { -0.0, -2.4, -0.6};
dir = 270;
};
};
};
};
};
};
38 changes: 38 additions & 0 deletions addons/animalTransport/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
### animalTransport

Carry animals and load them onto flatbed trucks.

#### Maintainer(s)

* Fusselwurm

#### Description

Adds ACE actions onto animals:
* carry
* load onto vehicle (with submenus for specific vehicles and positions)

*Animals will stop walking while their ACE interact menu is open*

Adds ACE action to the rear of a flatbed, if at least one animal is loaded:
* unload animals (with submenu for specific animal)

Adds CBA options for
* unloading speed for multiple animals
* maximum loading distance for animals

#### Supported trucks/animals

| vehicle type | sheep |
|-------------------|-------|
| Vanilla van (ind)| 8 |
| RHS GAZ66 | 8 |
| RHS Ural (benches)| 8 |
| ЗИЛ-131 | 11 |


To add more animals, patch up the vehicle classes as seen in `CfgVehicles.hpp`

##### For reference: animal dimensions

* a single sheep takes about is about 45cm wide and 130cm long
23 changes: 23 additions & 0 deletions addons/animalTransport/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PREP(controlAnimal);
PREP(findSuitableSpace);
PREP(findSuitableSpaces);
PREP(findSuitableVehicle);
PREP(findSuitableVehicles);
PREP(getSupportedAnimalConfigs);
PREP(getCustomConfig);
PREP(getSupportedCarConfigs);
PREP(interact_loadAction);
PREP(interact_loadChildren);
PREP(interact_loadChildrenSpaces);
PREP(interact_loadCondition);
PREP(interact_unloadAction);
PREP(interact_unloadChildren);
PREP(interact_unloadCondition);
PREP(player_interactMenuClosed);
PREP(player_interactMenuOpened);
PREP(player_unloadAnimals);
PREP(vehicle_loadAnimal);
PREP(vehicle_lockCargoIndex);
PREP(vehicle_unloadAnimal);
PREP(vehicle_unloadAnimalDetach);
PREP(vehicleName);
70 changes: 70 additions & 0 deletions addons/animalTransport/XEH_postClientInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "script_component.hpp"

LOG("postClientInit");

if (!hasInterface) exitWith {};

{
private _interactPoint = ([_x >> "GRAD_AnimalTransport", "actionPoint", [0, 0, 0]] call BIS_fnc_returnConfigEntry);

private _mainAction = [
"ACE_MainActions",
"Interactions",
"",
{},
{true},
{[]},
[],
_interactPoint
] call ace_interact_menu_fnc_createAction;

[
configName _x,
0,
[],
_mainAction,
true
] call ace_interact_menu_fnc_addActionToClass;

private _loadAction = [
QGVAR(loadAction),
"load on vehicle",
"a3\ui_f\data\IGUI\Cfg\Actions\loadVehicle_ca.paa",
FUNC(interact_loadAction),
FUNC(interact_loadCondition),
FUNC(interact_loadChildren),
[],
_interactPoint
] call ace_interact_menu_fnc_createAction;
[
configName _x,
0,
["ACE_MainActions"],
_loadAction,
true
] call ace_interact_menu_fnc_addActionToClass;

} forEach ([] call FUNC(getSupportedAnimalConfigs));

{
private _unloadActionPoint = ([_x >> "GRAD_AnimalTransport", "unloadActionPoint", [0, 0, 0]] call BIS_fnc_returnConfigEntry);
private _positionedUnloadAction = [
QGVAR(unloadAction),
"unload animals",
"",
FUNC(interact_unloadAction),
FUNC(interact_unloadCondition),
FUNC(interact_unloadChildren),
[],
_unloadActionPoint,
2.5
] call ace_interact_menu_fnc_createAction;

[
configName _x,
0,
[],
_positionedUnloadAction,
true
] call ace_interact_menu_fnc_addActionToClass;
} forEach ([] call FUNC(getSupportedCarConfigs));
21 changes: 21 additions & 0 deletions addons/animalTransport/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "script_component.hpp"

[QGVAR(vehicle_loadAnimal), {
scriptName QGVAR(vehicle_loadAnimal);
_this call FUNC(vehicle_loadAnimal);
}] call CBA_fnc_addEventHandler;

[QGVAR(vehicle_unloadAnimal), {
scriptName QGVAR(vehicle_unloadAnimal);
_this call FUNC(vehicle_unloadAnimal);
}] call CBA_fnc_addEventHandler;

["ace_interactMenuOpened", {
scriptName QGVAR(ace_interactMenuOpened);
_this call FUNC(player_interactMenuOpened)
}] call CBA_fnc_addEventHandler;

["ace_interactMenuClosed", {
scriptName QGVAR(ace_interactMenuClosed);
_this call FUNC(player_interactMenuClosed)
}] call CBA_fnc_addEventHandler;
Loading

0 comments on commit 30e5ea7

Please sign in to comment.