Skip to content

Commit

Permalink
Merge pull request #182 from Freddo3000/v0.7.0
Browse files Browse the repository at this point in the history
v0.7.0
  • Loading branch information
ultranoobian authored Jun 12, 2019
2 parents 7b551a2 + 83a590e commit 7d982f9
Show file tree
Hide file tree
Showing 370 changed files with 9,566 additions and 4,804 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto
*.png binary
*.jpg binary
*.paa binary
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

DUWS-R.iml
localDevDeploy.properties
DUWS-R_dev.Altis.pbo
DUWS-R_dev.Altis.pbo
38 changes: 38 additions & 0 deletions source/AIS/AIS_SETUP.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// by Psychobastard
// AIS REVIVE Setup-File

//__________________________________________________________________________________________________________________________________________________________________
// v v v v v v v v v v v v --- Main Settings --- v v v v v v v v v v v v

AIS_REVIVE_INIT_UNITS = "allPlayers"; // Auto-Init a group of units: "allPlayers" , "allPlayables" , "allUnits", "allUnitsBLUFOR", "allUnitsOPFOR", "allUnitsINDFOR", "allUnitsCIVILIAN"
// Warning: I didn't recomment to use "allUnits" if you play with a lot of AI units! AIS is mainly created for players and/or their AI group.
AIS_MEDICAL_EDUCATION = 1; // Who can revive an unconscious unit? 0 == Everybody, 1 == Everybody with a First Aid Kit or Medkit, 2 == Only Medics (this affects both, AI and players!).
AIS_REVIVE_GUARANTY = false; // If true you will fall everytime in uncoscious mode, regardless how strong the impact of damage was.
AIS_MEDEVAC_STATIONS = [];// Add one or more objects and a radius to activate the medevac feature. If enabled revive is only at this place(s) possible. Empty array means feature is disabled.
// Syntax: f.e.: [ [myMedevacVehicle, 15], [myMedicTent, 10] ] --> make sure the variable name is avalible at gamestart. Otherwise call it later in a function.


//__________________________________________________________________________________________________________________________________________________________________
// v v v v v v v v v v v v --- Optional Settings --- v v v v v v v v v v v v

AIS_DAMAGE_TOLLERANCE_FACTOR = 1; // A higher value means more damage tolerance. 1 is Vanilla. 0.8 mean all damage will reduce to 80% of Vanilla.
AIS_BLEEDOUT_TIME = 300; // Basic life time in seconds until the unit bleed out and die.. The real life time depends on the real damage of the unit. (can be less or more time from the basic value)
AIS_REVIVETIME = 30; // Basic revive time in seconds. The real revive time depends on the real damage of the unit. (can be less or more time from the basic value)
AIS_STABILIZETIME = 20; // Basic stabilize time in seconds to stop the bleeding of a unconscious unit. The real revive time depends on the real damage of the unit. (can be less or more time from the basic value)
AIS_REVIVE_HEAL = false; // If set to true the injured unit get completely healed after the revive. (casual gameplay without a medic)
AIS_TOGGLE_RADIO = true; // If set to true, unconscious players cannot use his TFAR or ACRE radios.
AIS_NO_CHAT = true; // If set to true, a injured player cannot use text chat during he is uncoscious.
AIS_AI_HELP_RADIUS = 50; // Number, Radius in metres. Units in this radius will help to revive if no group member is able to revive. Max value is 200 metres.
AIS_DISABLE_RESPAWN_BUTTON = 30; // Time in seconds while the respawn button is disabled (Esc Menu). Set to 0 to enable the respawn button everytime.
AIS_DISABLE_FURTHER_DAMAGE = false; // If set to true, an unconcious unit wont become further damage til death. If set to false, an unconcious unit can also die before bleedout timer is over. (f.e. trough near explosions)


//__________________________________________________________________________________________________________________________________________________________________
// v v v v v v v v v v v v --- Visual Settings --- v v v v v v v v v v v v

AIS_SHOW_UNC_MARKERS = true; // If set to true, a marker will show injured units on the map.
AIS_SHOW_UNC_MESSAGE_TO = "Group"; // "None", "Side", "Group" --> who read the message about wounded units.
AIS_SHOW_UNC_3D_MARKERS = true; // If set to true, an in-game visible 3D-icon shows you the position of injured units (within a range of 20 metres and 35 metres for medics).
AIS_IMPACT_EFFECTS = true; // Set to true to enable impact effects. (simple simluation of supressing effects)
AIS_SHOW_COUNTDOWN = true; // If set to true, an unconscious unit will be able to see the bleed out timer.
AIS_SHOW_DIARYINFO = true; // If set to true, a diary entry with some informations about the AIS (Credits, features, How to) is added.
30 changes: 30 additions & 0 deletions source/AIS/Core/cfgFunctions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class AIS_Core
{
class AIS_Core
{
file = "AIS\Core";
class preInit { preInit = 1; };
class postInit { postInit = 1; };
class addAction;
class aisInitHost;
class aisInitPlayer;
class bindEventHandler;
class createLocalMarker;
class dynamicText;
class initEvents;
class inRange;
class interaction_Loop;
class isPlayable;
class onEachFrame;
class onNextFrame;
class progress_ShowBar;
class progress_ShowBarText;
class removeonEachFrame;
class setPosAGLS;
class setVariables;
class triggerEvent;
class waitUntilAndExecute;
class handleDisconnect;
class resetOnTeamSwitch;
};
};
46 changes: 46 additions & 0 deletions source/AIS/Core/fn_Interaction_Loop.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Author: NetFusion
Description:
Continuously checks whether an action should be added to the cursorTarget.
Parameter(s):
-
Remarks:
* Should only be called once per mission.
Returns:
-
Example:
-
*/

AIS_Core_lastCursorTarget = objNull;

[{
_cursorTarget = cursorTarget;
if (_cursorTarget isEqualTo AIS_Core_lastCursorTarget || {player distance _cursorTarget > 15}) exitWith {}; // psycho: prevent cycling trough cursorTargets more than 15m away (engine limitation is 15m for every action)
AIS_Core_lastCursorTarget = _cursorTarget;

private _objActions = _cursorTarget getVariable ["AIS_Core_actionStorage", []];
{
_x params ["_onObject", "_text", "_distance", "_condition", "_callback", "_args", "_formated"];

if (!(_x in _objActions)) then {
if ((_onObject isEqualType "" && {_cursorTarget isKindOf _onObject}) || (_onObject isEqualType objNull && {_cursorTarget isEqualTo _onObject})) then {
private _action = _cursorTarget addAction [_text, _callback, _args, 1.5, true, true, "", _condition, _distance];
_objActions pushBack _x;

if (_formated != "") then {
_cursorTarget setUserActionText [
_action,
_text,
format [_formated, _text],
""
];
};
};
};
nil
} count (missionNamespace getVariable ["AIS_Core_actionStorage", []]);

_cursorTarget setVariable ["AIS_Core_actionStorage", _objActions]; //@todo maybe init array and remove this line - this requires module dependencies
}] call AIS_Core_fnc_onEachFrame;
81 changes: 81 additions & 0 deletions source/AIS/Core/fn_addAction.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Author: [C-L-F] NetFusion
Edited: Psychobastard
Description:
Add an action to an object or type(s) of object(s).
Parameter(s):
0: STRING - the title of the action.
1: OBJECT, ARRAY, STRING - the object (type) which the action should be added to.
2: NUMBER - the distance in which the action is visible.
3: STRING - the condition which is evaluated on every frame (if play is in range) to determine whether the action is visible.
4: CODE - the callback which gets called when the action is activated.
5: ARRAY - (optional) the arguments which get passed to the callback.
Remarks:
* '_target' is the object inside the condition string.
* [object, caller, ID, arguments] is _this in the callback
Returns:
-
Example:
["Hint Hello!", player, 0, "true", { hint format ["Hello %1", name player]; }] call AIS_Core_fnc_addAction;
["Hint Hello!", "Man", 3, "true", { hint format ["Hello %1", name (_this select 0)]; }] call AIS_Core_fnc_addAction;
*/

params ["_text", "_onObject", "_distance", "_condition", "_callback", ["_args", []], ["_formated", "", [""]]];


if (_distance > 0) then {
_condition = format ["([cursorTarget, %1] call AIS_Core_fnc_inRange) && {%2}", _distance, _condition];
};


if (_onObject isEqualType objNull && {_onObject isEqualTo AIS_Core_realPlayer}) exitWith {
private _action = _onObject addAction [_text, _callback, _args, 1.5, false, true, "", _condition, _distance];

if (_formated != "") then {
_onObject setUserActionText [
_action,
_text,
format [_formated, _text],
""
];
};

[
"AIS_playerChanged", {
params ["_data", "_params"];
_data params ["_currentPlayer", "_oldPlayer"];
_params params ["_text", "_callback", "_distance", ["_args", []], "_condition", ["_formated", "", [""]]];

private _action = _currentPlayer addAction [_text, _callback, _args, 1.5, false, true, "", _condition, _distance];

if (_formated != "") then {
_currentPlayer setUserActionText [
_action,
_text,
format [_formated, _text],
""
];
};
},
[_text, _callback, _distance, _args, _condition, _formated]
] call AIS_Core_fnc_bindEventHandler;

};

if (!(_onObject isEqualType [])) then {
_onObject = [_onObject];
};

private _actionStorage = missionNamespace getVariable ["AIS_Core_actionStorage", []];
{
_actionStorage pushBack [_x, _text, _distance, _condition, _callback, _args, _formated];
nil
} count _onObject;
missionNamespace setVariable ["AIS_Core_actionStorage", _actionStorage]; //@todo maybe init array and remove this line

_action
33 changes: 33 additions & 0 deletions source/AIS/Core/fn_aisInitHost.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// this script run on the server/host for every unit which should be added to the revive system. It run's once by starting the mission.
params ["_unit"];
if (_unit getVariable ["AIS_noReviveInit", false]) exitWith {};

if (!isNil {_unit getVariable "ais_aisInit"}) then {
_unit removeAllEventHandlers "Killed";
_unit removeAllEventHandlers "Respawn";
_unit removeAllEventHandlers "HandleHeal";
[_unit] call AIS_Core_fnc_setVariables;
};
_unit setVariable ["ais_aisInit", true];


// set damage EH only for local and non-player units!
// last check if unit is local
if (local _unit && !(isPlayer _unit)) then {
[_unit] spawn {
_unit = _this select 0;

waitUntil {!isNil {_unit getVariable "BIS_fnc_feedback_hitArrayHandler"} || {time > 0}};
_unit removeAllEventHandlers "handleDamage";
["%1 --- add damageEH to AI %2", diag_ticktime, _unit] call BIS_fnc_logFormat;
ais_hdEH = _unit addEventHandler ["HandleDamage", {_this call AIS_Damage_fnc_handleDamage}];

ais_hkEH = _unit addEventHandler ["Killed", {_this call AIS_System_fnc_killed}];

if ([_unit] call AIS_Core_fnc_isPlayable) then {
ais_hrEH = _unit addEventHandler ["Respawn", {_this call AIS_System_fnc_respawn}];
};
_unit removeAllEventHandlers "HandleHeal";
ais_hhEH = _unit addEventHandler ["HandleHeal", {_this call AIS_System_fnc_handleHeal}];
};
};
105 changes: 105 additions & 0 deletions source/AIS/Core/fn_aisInitPlayer.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// this script run only by the player!
private _player = _this;
if (_player != player) exitWith {["%1 --- exit aisInitPlayer cause it's not the local player itself %2", diag_ticktime, _player] call BIS_fnc_logFormat};
if (isClass (configFile >> "CfgPatches" >> "ace_medical")) exitWith {["AIS: AIS shutdown itself cause ACE medical system is also running. ACE medical and AIS cant work at the same time."] call BIS_fnc_logFormat};

if (_player getVariable ["AIS_noReviveInit", false]) exitWith {};

// set damage EH local to the player
if (local _player) then {
[_player] call AIS_Core_fnc_setVariables;

[_player] spawn {
_player = _this select 0;
waitUntil {!isNil {_player getVariable "BIS_fnc_feedback_hitArrayHandler"} || {time > 0}};
_player removeAllEventHandlers "handleDamage"; // make sure nothing else working byside
//["%1 --- add damageEH to player %2", diag_ticktime, _player] call BIS_fnc_logFormat;
_player addEventHandler ["HandleDamage", {_this call AIS_Damage_fnc_handleDamage}];

_player addEventHandler ["Killed", {_this call AIS_System_fnc_killed}];

_player addEventHandler ["Respawn", {_this call AIS_System_fnc_respawn}];

_player addEventHandler ["HandleHeal", {_this call AIS_System_fnc_handleHeal}];

waitUntil {!isNull (findDisplay 46)};
(findDisplay 46) displayAddEventHandler ["KeyDown", {_this call AIS_System_fnc_keyHandler}];
};
};

// AI is local to the group leader on dedicated environment
if (!isServer && (count (units group player) > 1)) then {
if (leader group _player isEqualTo _player) then {

[_player] spawn {
_player = _this select 0;
_groupWithoutPlayers = ((units group _player) - (allUnits select {isPlayer _x}));
{[_x] call AIS_Core_fnc_setVariables; true} count _groupWithoutPlayers;

waitUntil {!isNil {_player getVariable "BIS_fnc_feedback_hitArrayHandler"} || {time > 0}};
{
_x removeAllEventHandlers "handleDamage";
//["%1 --- add damageEH to groupmember of %3's group: %2", diag_ticktime, _x, _player] call BIS_fnc_logFormat;
_x addEventHandler ["HandleDamage", {_this call AIS_Damage_fnc_handleDamage}];

_x removeAllEventHandlers "Killed";
_x addEventHandler ["Killed", {_this call AIS_System_fnc_killed}];

_x removeAllEventHandlers "Respawn";
if ([_x] call AIS_Core_fnc_isPlayable) then {
_x addEventHandler ["Respawn", {_this call AIS_System_fnc_respawn}];
};

_x addEventHandler ["HandleHeal", {_this call AIS_System_fnc_handleHeal}];

true
} count _groupWithoutPlayers;
};

};
};


// add handleHeal local to the player for every unit and set the correct anim-state (local)
private _allPlayers = allUnits select {isPlayer _x}; // doesn't use allPlayers at this point, cause it can be delayed in self-hosted env.
private _ais_revive_units = toLower AIS_REVIVE_INIT_UNITS;
private _init_units = call {
if (_ais_revive_units isEqualTo "allunits") exitWith {allUnits};
if (_ais_revive_units isEqualTo "allplayers") exitWith {_allPlayers}; // at this point only as a dummy. Cause everytime every player will auto-init, regardless what the setup will say.
if (_ais_revive_units isEqualTo "allplayables") exitWith {if (isMultiplayer) then {playableUnits} else {switchableUnits}};
if (_ais_revive_units isEqualTo "allunitsblufor") exitWith {allUnits select {(side _x) isEqualTo blufor}};
if (_ais_revive_units isEqualTo "allunitsopfor") exitWith {allUnits select {(side _x) isEqualTo opfor}};
if (_ais_revive_units isEqualTo "allunitsindfor") exitWith {allUnits select {(side _x) isEqualTo resistance}};
if (_ais_revive_units isEqualTo "allunitscivilian") exitWith {allUnits select {(side _x) isEqualTo civilian}};
diag_log "AIS ERROR: Issue in Setup-File found! Parameter AIS_REVIVE_UNITS wrong defined."; []
};
{
_x removeAllEventHandlers "HandleHeal";
_x addEventHandler ["HandleHeal", {_this call AIS_System_fnc_handleHeal}];

if (_x getVariable ["ais_unconscious", false]) then {
if (!isNull(_x getVariable ["ais_DragDrop_Player", objNull])) then {
_x switchMove "AinjPpneMrunSnonWnonDb";
} else {
_x playActionNow "agonyStart";
};
};

true
} count _init_units;


ais_medequip_array = [];
if (AIS_TOGGLE_RADIO) then {
[true] call AIS_Effects_fnc_toggleRadio;
};

// JIP in a unconscious AI... and avoid cheating by left in lobby...
if (_player getVariable ["ais_unconscious", false]) then {
[{[(_this select 0)] call AIS_System_fnc_setUnconscious}, [_player]] call AIS_Core_fnc_onNextFrame;
};

inGameUISetEventHandler ["Action", "_this call AIS_System_fnc_overrideHealAction"];


_respawnDelay = getMissionConfigValue ["respawnDelay", 0];
Loading

0 comments on commit 7d982f9

Please sign in to comment.