Instantly share code, notes, and snippets.
Created
September 15, 2019 05:40
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save AgentRev/0952d6447efab6c02d614b5aea8542f3 to your computer and use it in GitHub Desktop.
R3F v3.0 A3W early conversion attempt
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
/** | |
* Evalue régulièrement les conditions à vérifier pour autoriser les actions logistiques | |
* Permet de diminuer la fréquence des vérifications des conditions normalement faites | |
* dans les addAction (~60Hz) et donc de limiter la consommation CPU. | |
* | |
* Copyright (C) 2014 Team ~R3F~ | |
* | |
* This program is free software under the terms of the GNU General Public License version 3. | |
* You should have received a copy of the GNU General Public License | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
*/ | |
// Modified by AgentRev for A3Wasteland | |
#define MAX_VELOCITY_CAR 3 | |
#define MAX_VELOCITY_HELI 6 | |
_resetConditions = | |
{ | |
R3F_LOG_action_deplacer_objet_valide = false; | |
R3F_LOG_action_detacher_valide = false; | |
R3F_LOG_action_charger_deplace_valide = false; | |
R3F_LOG_action_charger_selection_valide = false; | |
R3F_LOG_action_contenu_vehicule_valide = false; | |
R3F_LOG_action_remorquer_deplace_valide = false; | |
R3F_LOG_action_remorquer_selection_valide = false; | |
R3F_LOG_action_selectionner_objet_remorque_valide = false; | |
R3F_LOG_action_selectionner_objet_charge_valide = false; | |
R3F_LOG_action_heliporter_valide = false; | |
R3F_LOG_action_heliport_larguer_valide = false; | |
R3F_LOG_action_ouvrir_usine_valide = false; | |
}; | |
_isMissionObject = { !local _object || {[":-", netId _object] call fn_findString == -1} }; | |
_isUavAI = { !isNull _this && !isPlayer _this && {getText (configFile >> "CfgVehicles" >> typeOf _this >> "simulation") == "UAVPilot"} }; | |
sleep 2; | |
_allowLogistics = compile R3F_LOG_CFG_string_condition_allow_logistics_on_this_client; | |
_allowFactory = compile R3F_LOG_CFG_string_condition_allow_creation_factory_on_this_client; | |
while {true} do | |
{ | |
_vehicle = vehicle player; | |
_cursorTarget_distance = call R3F_LOG_FNCT_3D_cursorTarget_distance_bbox; | |
_object = _cursorTarget_distance select 0; | |
if (_vehicle == player && !isNull _object && {!R3F_LOG_mutex_local_verrou && call _allowLogistics && call _isMissionObject && | |
_cursorTarget_distance select 1 < 14}) then | |
{ | |
R3F_LOG_objet_addAction = _object; | |
Object_canLock = !(_object getVariable ["objectLocked", false]); | |
_notDestroyed = alive _object; | |
_notDisabled = !(_object getVariable ["R3F_LOG_disabled", false]); | |
_movedBy = _object getVariable ["R3F_LOG_est_deplace_par", objNull]; | |
_carrier = _object getVariable ["R3F_LOG_est_transporte_par", objNull]; | |
_towedObject = _object getVariable ["R3F_LOG_remorque", objNull]; | |
_notBeingMoved = (!alive _movedBy || !isPlayer _movedBy); | |
_notBeingCarried = isNull _carrier; | |
_notTowing = isNull _towedObject; | |
_seatsEmpty = ({!(_x call _isUavAI)} count crew _object == 0); | |
_noDriver = (isNull driver _object || _object call _isUavAI); | |
_velocity = vectorMagnitude velocity _object; | |
_movedObject = R3F_LOGplayer_deplace_objet; | |
_handsFree = isNull _movedObject; | |
_selectedObject = R3F_LOG_objet_selectionne; | |
_noSelection = isNull _selectedObject; | |
_otherObject = [_movedObject, 3.75] call R3F_LOG_FNCT_3D_cursorTarget_virtuel; | |
// Si l'objet est un objet déplaçable | |
if ({_object isKindOf _x} count R3F_LOG_CFG_can_be_moved_by_player > 0) then | |
{ | |
// Condition action deplacer_objet | |
R3F_LOG_action_deplacer_objet_valide = (_notDisabled && {_handsFree && _noDriver && _notBeingMoved && _notBeingCarried}); | |
}; | |
// Si l'objet est un objet remorquable | |
if ({_object isKindOf _x} count R3F_LOG_CFG_can_be_towed > 0) then | |
{ | |
// Et qu'il est déplaçable | |
if ({_object isKindOf _x} count R3F_LOG_CFG_can_be_moved_by_player > 0) then | |
{ | |
// Condition action remorquer_deplace | |
R3F_LOG_action_remorquer_deplace_valide = (_notDisabled && {_noDriver && _movedObject == _object && alive _otherObject && | |
{ | |
!(_otherObject getVariable "R3F_LOG_disabled") && | |
{{_otherObject isKindOf _x} count R3F_LOG_CFG_can_tow > 0} && | |
isNull (_otherObject getVariable "R3F_LOG_est_transporte_par") && | |
isNull (_otherObject getVariable "R3F_LOG_remorque") && | |
vectorMagnitude velocity _otherObject < MAX_VELOCITY_CAR | |
}}); | |
}; | |
// Condition action selectionner_objet_remorque | |
R3F_LOG_action_selectionner_objet_remorque_valide = (_notDisabled && {_handsFree && _noDriver && _notBeingMoved && _notBeingCarried && _notTowing && _noSelection}); | |
// Condition action detacher | |
R3F_LOG_action_detacher_valide = (_notDisabled && {_handsFree && !isNull _carrier}); | |
}; | |
// Si l'objet est un objet transportable | |
if ({_object isKindOf _x} count R3F_LOG_classes_objets_transportables > 0) then | |
{ | |
// Et qu'il est déplaçable | |
if ({_object isKindOf _x} count R3F_LOG_CFG_can_be_moved_by_player > 0) then | |
{ | |
// Condition action charger_deplace | |
R3F_LOG_action_charger_deplace_valide = (_notDisabled && {_seatsEmpty && _movedObject == _object && alive _otherObject && | |
{ | |
!(_otherObject getVariable ["R3F_LOG_disabled", false]) && | |
{{_otherObject isKindOf _x} count R3F_LOG_classes_transporteurs > 0} && | |
vectorMagnitude velocity _otherObject < MAX_VELOCITY_CAR | |
}}); | |
}; | |
// Condition action selectionner_objet_charge | |
R3F_LOG_action_selectionner_objet_charge_valide = (_notDisabled && {_handsFree && _seatsEmpty && _notBeingCarried && _notTowing && _noSelection}); | |
}; | |
// Si l'objet est un véhicule remorqueur | |
if ({_object isKindOf _x} count R3F_LOG_CFG_can_tow > 0) then | |
{ | |
// Condition action remorquer_deplace | |
R3F_LOG_action_remorquer_deplace_valide = (_notDisabled && {_notDestroyed && _notBeingCarried && _notTowing && _movedObject != _object && alive _movedObject && | |
{ | |
!(_movedObject getVariable ["R3F_LOG_disabled", false]) && | |
{{_movedObject isKindOf _x} count R3F_LOG_CFG_can_be_towed > 0} && | |
_velocity < MAX_VELOCITY_CAR; | |
}}); | |
// Condition action remorquer_selection | |
R3F_LOG_action_remorquer_selection_valide = (_notDisabled && {_handsFree && _notDestroyed && _notBeingCarried && _notTowing && _selectedObject != _object && alive _selectedObject && | |
{ | |
!(_selectedObject getVariable ["R3F_LOG_disabled", false]) && | |
{{_selectedObject isKindOf _x} count R3F_LOG_CFG_can_be_towed > 0} && | |
_velocity < MAX_VELOCITY_CAR; | |
}}); | |
}; | |
// Si l'objet est un véhicule transporteur | |
if ({_object isKindOf _x} count R3F_LOG_classes_transporteurs > 0) then | |
{ | |
// Condition action charger_deplace | |
R3F_LOG_action_charger_deplace_valide = (_notDisabled && {_notDestroyed && _movedObject != _object && !isNull _movedObject && | |
{ | |
!(_movedObject getVariable ["R3F_LOG_disabled", false]) && | |
{{_movedObject isKindOf _x} count R3F_LOG_classes_objets_transportables > 0} && | |
_velocity < MAX_VELOCITY_CAR; | |
}}); | |
// Condition action charger_selection | |
R3F_LOG_action_charger_selection_valide = (_notDisabled && {_handsFree && _notDestroyed && _selectedObject != _object && !isNull _selectedObject && | |
{ | |
!(_selectedObject getVariable ["R3F_LOG_disabled", false]) && | |
{{_selectedObject isKindOf _x} count R3F_LOG_classes_objets_transportables > 0} && | |
_velocity < MAX_VELOCITY_CAR; | |
}}); | |
// Condition action contenu_vehicule | |
R3F_LOG_action_contenu_vehicule_valide = (_notDisabled && {_handsFree && _notDestroyed && _velocity < MAX_VELOCITY_CAR}); | |
}; | |
// Condition action ouvrir_usine | |
R3F_LOG_action_ouvrir_usine_valide = (_notDisabled && {_handsFree && _notDestroyed && | |
{ | |
!(_object getVariable ["R3F_LOG_CF_disabled", false]) && | |
_object getVariable ["R3F_LOG_CF_side_addAction", playerSide] == playerSide && | |
{call _allowFactory} | |
}}); | |
} | |
else | |
{ | |
call _resetConditions; | |
}; | |
// Si le joueur est pilote dans un héliporteur | |
if ({_vehicle isKindOf _x} count R3F_LOG_CFG_can_lift > 0) | |
{ | |
// On est dans le véhicule, on affiche pas les options de transporteur et remorqueur | |
call _resetConditions; | |
if (_vehicle != player && driver _vehicle == player && {!R3F_LOG_mutex_local_verrou && call _allowLogistics}) then | |
{ | |
R3F_LOG_objet_addAction = _vehicle; | |
_notDisabled = !(_vehicle getVariable ["R3F_LOG_disabled", false]); | |
_airliftedObject = _vehicle getVariable ["R3F_LOG_heliporte", objNull]; | |
_notAirlifting = isNull _airliftedObject; | |
_velocity = vectorMagnitude velocity _vehicle; | |
// Condition action heliporter | |
R3F_LOG_action_heliporter_valide = (_notDisabled && {_notAirlifting && _velocity < MAX_VELOCITY_HELI && | |
{ | |
{_x != _vehicle && !(_x getVariable ["R3F_LOG_disabled", false])} count nearestObjects [_vehicle, R3F_LOG_CFG_can_be_lifted, 15] > 0 | |
}}); | |
// Condition action heliport_larguer | |
R3F_LOG_action_heliport_larguer_valide = (_notDisabled && !isNull _airliftedObject); | |
}; | |
}; | |
sleep 0.4; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment