-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: create extra state for passengers (#79)
* resolve circular dependency, hopefully more robust and more clear mountup/dismount logic * Remove condition for mountUp: I cannot remember why all civs of a group needed to rally for the group leader to call everyone to mount up. Remove condition. * fix mountUp->voyage|transit logic. take care to look for the correct vehicle.
- Loading branch information
1 parent
9b6e3cd
commit 2fe1853
Showing
12 changed files
with
98 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
addons/cars/functions/fnc_sm_business_state_rideInBack_enter.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "..\script_component.hpp" | ||
|
||
private _grpVeh = _this call FUNC(getGroupVehicle); | ||
|
||
if (vehicle _this != _grpVeh) then { | ||
_this assignAsCargo _grpVeh; | ||
[_this] orderGetIn true; | ||
}; |
3 changes: 3 additions & 0 deletions
3
addons/cars/functions/fnc_sm_business_state_rideInBack_exit.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "..\script_component.hpp" | ||
|
||
unassignVehicle _this; |
8 changes: 3 additions & 5 deletions
8
addons/cars/functions/fnc_sm_business_trans_rally_mountUp_condition.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
#include "..\script_component.hpp" | ||
|
||
if (leader _this != _this) exitWith {}; | ||
|
||
private _haveVehicle = (canMove (_this call FUNC(getGroupVehicle))); | ||
|
||
if (!_haveVehicle && (_this getVariable ["grad_civs_primaryTask", ""] in ["voyage", "transit"])) exitWith { | ||
_this setVariable ["grad_civs_primaryTask", "patrol", true]; | ||
INFO_1("%1 was tasked with voyage but vehicle %2 is immovable or absent - will go on patrol hencewith", _this, _this call FUNC(getGroupVehicle)); | ||
}; | ||
|
||
private _grpUnits = units _this; | ||
private _allRallying = -1 == (_grpUnits findIf { ([_x, "business"] call EFUNC(common,civGetState)) != "bus_rally" }); | ||
|
||
_allRallying && _haveVehicle && (leader _this == _this) | ||
_haveVehicle |
13 changes: 13 additions & 0 deletions
13
addons/cars/functions/fnc_sm_business_trans_rally_rideInBack_condition.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "..\script_component.hpp" | ||
|
||
private _leader = leader _this; | ||
|
||
if (_leader == _this) exitWith {false}; | ||
|
||
private _leaderStatus = [_leader, "business"] call EFUNC(common,civGetState); | ||
private _grpVeh = _this call FUNC(getGroupVehicle); | ||
|
||
private _leaderIsCallingForMountUp = (_leaderStatus == "bus_mountUp"); | ||
private _leaderIsRallyingAndMounted = {_leaderStatus == "bus_rally" && vehicle _leader == _grpVeh}; | ||
|
||
_leaderIsCallingForMountUp || _leaderIsRallyingAndMounted |
9 changes: 9 additions & 0 deletions
9
addons/cars/functions/fnc_sm_business_trans_rideInBack_rally_condition.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "..\script_component.hpp" | ||
|
||
private _leader = leader _this; | ||
private _leaderStatus = [_leader, "business"] call EFUNC(common,civGetState); | ||
|
||
private _leaderDismounts = _leaderStatus == "bus_dismount"; | ||
private _leaderRallyingAndDismounted = {_leaderStatus == "bus_rally" && vehicle _leader == _leader}; | ||
|
||
_leaderDismounts || _leaderRallyingAndDismounted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
addons/legacy/functions/fnc_sm_business_state_rally_loop.sqf
This file was deleted.
Oops, something went wrong.
20 changes: 13 additions & 7 deletions
20
addons/transit/functions/fnc_sm_business_trans_mountUp_transit_condition.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
#include "..\script_component.hpp" | ||
|
||
private _civ = _this; | ||
|
||
private _isLeader = (leader _civ) == _civ; | ||
if (leader _civ != _this) exitWith {false}; | ||
|
||
private _groupVehicle = _civ call EFUNC(cars,getGroupVehicle); | ||
private _units = units _civ; | ||
|
||
private _allAssigned = { | ||
(_units arrayIntersect (crew _groupVehicle)) isEqualTo _units | ||
}; | ||
|
||
private _allMounted = { | ||
private _units = units _civ; | ||
private _mountedUnits = crew vehicle _civ; | ||
private _mountedUnits = _units select {vehicle _x == _groupVehicle}; | ||
(_units arrayIntersect _mountedUnits) isEqualTo _units | ||
}; | ||
|
||
private _isTaskTransit = { | ||
_civ getVariable ["grad_civs_primaryTask", ""] == "transit" | ||
}; | ||
private _isTaskTransit = _civ getVariable ["grad_civs_primaryTask", ""] == "transit"; | ||
|
||
_isLeader && _allMounted && _isTaskTransit | ||
_isTaskTransit && _allAssigned && _allMounted |
23 changes: 20 additions & 3 deletions
23
addons/voyage/functions/fnc_sm_business_trans_mountUp_voyage_condition.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
private _grpMembers = units _this; | ||
private _mountedCount = { vehicle _x != _x } count _grpMembers; | ||
#include "..\script_component.hpp" | ||
|
||
(_mountedCount == count _grpMembers) && (leader _this == _this) && (_this getVariable ["grad_civs_primaryTask", ""] == "voyage") | ||
private _civ = _this; | ||
|
||
if (leader _civ != _this) exitWith {false}; | ||
|
||
private _groupVehicle = _civ call EFUNC(cars,getGroupVehicle); | ||
private _units = units _civ; | ||
|
||
private _allAssigned = { | ||
(_units arrayIntersect (crew _groupVehicle)) isEqualTo _units | ||
}; | ||
|
||
private _allMounted = { | ||
private _mountedUnits = _units select {vehicle _x == _groupVehicle}; | ||
(_units arrayIntersect _mountedUnits) isEqualTo _units | ||
}; | ||
|
||
private _isTaskTransit = _civ getVariable ["grad_civs_primaryTask", ""] == "voyage"; | ||
|
||
_isTaskTransit && _allAssigned && _allMounted |