Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added ATM system
  • Loading branch information
AgentRev committed Jan 13, 2015
1 parent 41f1ef9 commit 0cf34c0
Show file tree
Hide file tree
Showing 46 changed files with 1,529 additions and 134 deletions.
190 changes: 116 additions & 74 deletions client/functions/drawPlayerMarkers.sqf
Expand Up @@ -10,100 +10,150 @@ if (!hasInterface) exitWith {};
#define DEFAULT_ICON_POS(UNIT) (UNIT modelToWorld (UNIT selectionPosition "spine3"))
#define MISSION_AI_FAR_DISTANCE 75

disableSerialization;

if (isNil "showPlayerNames") then { showPlayerNames = false };

drawPlayerMarkers_array = [];
drawPlayerMarkers_arrayLines = [];
A3W_mapDraw_arrIcons = [];
A3W_mapDraw_arrLines = [];
A3W_mapDraw_eventCode =
{
_mapCtrl = _this select 0;

if (!isNil "drawPlayerMarkers_thread") then { terminate drawPlayerMarkers_thread };
drawPlayerMarkers_thread = [] spawn
{
_item = _x;

// Dynamic size
{
if (count _item > _x) then
{
_val = _item select _x;
if (typeName _val == "CODE") then { _item set [_x, _this call _val] };
};
} forEach [3,4,8];

_mapCtrl drawIcon _item;
} forEach A3W_mapDraw_arrIcons;

{ _mapCtrl drawLine _x } forEach A3W_mapDraw_arrLines;
} call mf_compile;

if (!isNil "A3W_mapDraw_thread") then { terminate A3W_mapDraw_thread };
A3W_mapDraw_thread = [] spawn
{
scriptName "drawPlayerMarkers";

_showPlayers = ["A3W_teamPlayersMap"] call isConfigOn;
_missionAiDrawLines = ["A3W_missionFarAiDrawLines"] call isConfigOn;
_atmIcon = (call currMissionDir) + "client\icons\suatmm_icon.paa";
_atmIconSize = {(0.4 / ctrlMapScale (_this select 0)) max 8 min 25};

waitUntil
{
_newArray = [];

_isIndie = !(playerSide in [BLUFOR,OPFOR]);
_mapIconsEnabled = difficultyEnabled "map";

_allUAVs = allUnitsUAV;
_allDeadMen = allDeadMen;
_playableUnits = playableUnits;

reverse _allUAVs;
reverse _allDeadMen;
reverse _playableUnits;
_newArrayIcons = [];

if (!isNil "A3W_atmArray") then
{
_uav = _x;
_uavOwner = (uavControl _uav) select 0;
_deadATMs = [];

if (IS_FRIENDLY_PLAYER(_uavOwner) || (isNull _uavOwner && side _uav == playerSide)) then
{
_icon = getText (configFile >> "CfgVehicles" >> typeOf _uav >> "icon");
if (_icon == "") then { _icon = "iconMan" };

_color = if (group _uavOwner == group player) then { [0,1,0,1] } else { [1,1,1,1] };
_pos = if (_mapIconsEnabled) then { DEFAULT_ICON_POS(_uav) } else { getPosASLVisual _uav };

_newArray pushBack [_icon, _color, _pos, 24, 24, getDir _uav, "", 1]; // draw icon

if (showPlayerNames) then
if (alive _x) then
{
_newArrayIcons pushBack [_atmIcon, [1,1,1,1], getPosATL _x, _atmIconSize, _atmIconSize, 0];
}
else
{
_newArray pushBack ["#(argb,1,1,1)color(0,0,0,0)", _color, _pos, 25, 25, 0, "[AI]", 2, 0.05, "PuristaMedium"]; // draw text
_deadATMs pushback _x;
};
} forEach A3W_atmArray;

if (count _deadATMs > 0) then
{
_deadATMs spawn { A3W_atmArray = A3W_atmArray - _this };
};
} forEach _allUAVs;
};

if (_showPlayers) then
{
_newUnit = _x getVariable ["newRespawnedUnit", objNull];
_isIndie = !(playerSide in [BLUFOR,OPFOR]);
_mapIconsEnabled = difficultyEnabled "map";

if (IS_FRIENDLY_PLAYER(_x) || (_newUnit getVariable ["playerSpawning", false] && IS_FRIENDLY_PLAYER(_newUnit))) then
{
_veh = vehicle _x;
_pos = if (_mapIconsEnabled) then { DEFAULT_ICON_POS(_veh) } else { getPosASLVisual _x };
_allUAVs = allUnitsUAV;
_allDeadMen = allDeadMen;
_playableUnits = playableUnits;

_newArray pushBack ["\A3\ui_f_curator\Data\CfgMarkers\kia_ca.paa", [0,0,0,0.6], _pos, 22, 22, 0]; // draw skull
};
} forEach _allDeadMen;
reverse _allUAVs;
reverse _allDeadMen;
reverse _playableUnits;

{
if (IS_FRIENDLY_PLAYER(_x) && !(_x getVariable ["playerSpawning", false])) then
{
_veh = vehicle _x;
_uav = _x;
_uavOwner = (uavControl _uav) select 0;

if ((crew _veh) select 0 == _x) then
if (IS_FRIENDLY_PLAYER(_uavOwner) || (isNull _uavOwner && side _uav == playerSide)) then
{
_icon = getText (configFile >> "CfgVehicles" >> typeOf _veh >> "icon");
_icon = getText (configFile >> "CfgVehicles" >> typeOf _uav >> "icon");
if (_icon == "") then { _icon = "iconMan" };

_color = if (group _x == group player) then { [0,1,0,1] } else { [1,1,1,1] };
_vehColor = if ({group _x == group player} count crew _veh > 0) then { [0,1,0,1] } else { _color }; // make vehicle green if group player in it
_pos = if (_mapIconsEnabled) then { DEFAULT_ICON_POS(_veh) } else { getPosASLVisual _veh };
_dir = if (_icon == "iconParachute") then { 0 } else { getDir _veh };
_color = if (group _uavOwner == group player) then { [0,1,0,1] } else { [1,1,1,1] };
_pos = if (_mapIconsEnabled) then { DEFAULT_ICON_POS(_uav) } else { getPosASLVisual _uav };

if (_veh == _x && _x getVariable ["FAR_isUnconscious", 0] == 1) then { _vehColor = [1,0.25,0,1] }; // make icon orange if awaiting revive
_newArrayIcons pushBack [_icon, _color, _pos, 24, 24, getDir _uav, "", 1]; // draw icon

_newArray pushBack [_icon, _vehColor, _pos, 24, 24, _dir, "", 1]; // draw icon
if (showPlayerNames) then
{
_newArrayIcons pushBack ["#(argb,1,1,1)color(0,0,0,0)", _color, _pos, 25, 25, 0, "[AI]", 2, 0.05, "PuristaMedium"]; // draw text
};
};
} forEach _allUAVs;

{
_newUnit = _x getVariable ["newRespawnedUnit", objNull];

if (_x != player && showPlayerNames) then
if (IS_FRIENDLY_PLAYER(_x) || (_newUnit getVariable ["playerSpawning", false] && IS_FRIENDLY_PLAYER(_newUnit))) then
{
_veh = vehicle _x;
_pos = if (_mapIconsEnabled) then { DEFAULT_ICON_POS(_veh) } else { getPosASLVisual _x };

_newArrayIcons pushBack ["\A3\ui_f_curator\Data\CfgMarkers\kia_ca.paa", [0,0,0,0.6], _pos, 22, 22, 0]; // draw skull
};
} forEach _allDeadMen;

{
if (IS_FRIENDLY_PLAYER(_x) && !(_x getVariable ["playerSpawning", false])) then
{
_veh = vehicle _x;

if ((crew _veh) select 0 == _x) then
{
_newArray pushBack ["#(argb,1,1,1)color(0,0,0,0)", _color, _pos, 25, 25, 0, name _x, 2, 0.05, "PuristaMedium"]; // draw text
_icon = getText (configFile >> "CfgVehicles" >> typeOf _veh >> "icon");
if (_icon == "") then { _icon = "iconMan" };

_color = if (group _x == group player) then { [0,1,0,1] } else { [1,1,1,1] };
_vehColor = if ({group _x == group player} count crew _veh > 0) then { [0,1,0,1] } else { _color }; // make vehicle green if group player in it
_pos = if (_mapIconsEnabled) then { DEFAULT_ICON_POS(_veh) } else { getPosASLVisual _veh };
_dir = if (_icon == "iconParachute") then { 0 } else { getDir _veh };

if (_veh == _x && _x getVariable ["FAR_isUnconscious", 0] == 1) then { _vehColor = [1,0.25,0,1] }; // make icon orange if awaiting revive

_newArrayIcons pushBack [_icon, _vehColor, _pos, 24, 24, _dir, "", 1]; // draw icon

if (_x != player && showPlayerNames) then
{
_newArrayIcons pushBack ["#(argb,1,1,1)color(0,0,0,0)", _color, _pos, 25, 25, 0, name _x, 2, 0.05, "PuristaMedium"]; // draw text
};
};
};
};
} forEach _playableUnits;
} forEach _playableUnits;

if (!_mapIconsEnabled) then
{
_veh = vehicle player;
_newArray pushBack ["\A3\ui_f\Data\IGUI\Cfg\IslandMap\iconplayer_ca.paa", [1,0,0,1], getPosASLVisual _veh, 26, 26, getDir _veh]; // draw player circle
if (!_mapIconsEnabled) then
{
_veh = vehicle player;
_newArrayIcons pushBack ["\A3\ui_f\Data\IGUI\Cfg\IslandMap\iconplayer_ca.paa", [1,0,0,1], getPosASLVisual _veh, 26, 26, getDir _veh]; // draw player circle
};
};

drawPlayerMarkers_array = _newArray;
A3W_mapDraw_arrIcons = _newArrayIcons;

_newArrayLines = [];

Expand All @@ -123,7 +173,7 @@ drawPlayerMarkers_thread = [] spawn

if !(_veh in _vehs) then
{
if (_veh distance _markerPos > MISSION_AI_FAR_DISTANCE) then
if (alive _veh && _veh distance _markerPos > MISSION_AI_FAR_DISTANCE) then
{
_newArrayLines pushBack [_markerPos, getPosASLVisual _veh, [1,0,0,1]];
};
Expand All @@ -136,37 +186,29 @@ drawPlayerMarkers_thread = [] spawn
} forEach allGroups;
};

drawPlayerMarkers_arrayLines = _newArrayLines;
A3W_mapDraw_arrLines = _newArrayLines;
false
};
};

A3W_scriptThreads pushBack drawPlayerMarkers_thread;
A3W_scriptThreads pushBack A3W_mapDraw_thread;

// Main map = findDisplay 12 displayCtrl 51
// GPS = (uiNamespace getVariable ["RscMiniMap", displayNull]) displayCtrl 101
// UAV Terminal = findDisplay 160 displayCtrl 51

disableSerialization;
private ["_drawCode", "_display", "_mapCtrl"];

_drawCode =
{
_mapCtrl = _this select 0;
{ _mapCtrl drawIcon _x } forEach drawPlayerMarkers_array;
{ _mapCtrl drawLine _x } forEach drawPlayerMarkers_arrayLines;
};
private ["_display", "_mapCtrl"];

// Main map
waitUntil {_display = findDisplay 12; !isNull _display};
_mapCtrl = _display displayCtrl 51;

if (!isNil "drawPlayerMarkers_mapDraw") then { _mapCtrl ctrlRemoveEventHandler ["Draw", drawPlayerMarkers_mapDraw] };
drawPlayerMarkers_mapDraw = _mapCtrl ctrlAddEventHandler ["Draw", _drawCode];
if (!isNil "A3W_mapDraw_mainMapEH") then { _mapCtrl ctrlRemoveEventHandler ["Draw", A3W_mapDraw_mainMapEH] };
A3W_mapDraw_mainMapEH = _mapCtrl ctrlAddEventHandler ["Draw", A3W_mapDraw_eventCode];

// GPS
waitUntil {_display = uiNamespace getVariable ["RscMiniMap", displayNull]; !isNull _display};
_mapCtrl = _display displayCtrl 101;

if (!isNil "drawPlayerMarkers_gpsDraw") then { _mapCtrl ctrlRemoveEventHandler ["Draw", drawPlayerMarkers_gpsDraw] };
drawPlayerMarkers_gpsDraw = _mapCtrl ctrlAddEventHandler ["Draw", _drawCode];
if (!isNil "A3W_mapDraw_gpsMapEH") then { _mapCtrl ctrlRemoveEventHandler ["Draw", A3W_mapDraw_gpsMapEH] };
A3W_mapDraw_gpsMapEH = _mapCtrl ctrlAddEventHandler ["Draw", A3W_mapDraw_eventCode];
58 changes: 58 additions & 0 deletions client/functions/generateAtmArray.sqf
@@ -0,0 +1,58 @@
// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2015 A3Wasteland.com *
// ******************************************************************************************
// @file Name: generateAtmArray.sqf
// @file Author: AgentRev

private "_editorOnly";
_editorOnly = ["A3W_atmEditorPlacedOnly"] call isConfigOn;

if (isNil "A3W_atmArray") then
{
A3W_atmArray = allMissionObjects "Land_Atm_01_F" + allMissionObjects "Land_Atm_02_F";
};

{
{
if ((str _x) find ": atm_" != -1) then
{
if (_editorOnly && !(_x getVariable ["A3W_atmEditorPlaced", false])) then
{
if (alive _x) then { _x setDamage 1 };
}
else
{
if !(_x in A3W_atmArray) then { A3W_atmArray pushBack _x };
};
};
} forEach nearestObjects [_x, [], 5];
} forEach call compile preprocessFileLineNumbers "mapConfig\atmPositions.sqf";

if (["A3W_atmEnabled"] call isConfigOn) then
{
// Get rid of map ATMs that are within 3m of mission ones
{
if (_x getVariable ["A3W_atmEditorPlaced", false]) then
{
{
if ((str _x) find ": atm_" != -1 && {alive _x && !(_x getVariable ["A3W_atmEditorPlaced", false])}) then
{
_x setDamage 1;
};
} forEach nearestObjects [_x, [], 3];
};
} forEach A3W_atmArray;
}
else
{
// Delete all ATMs
{
if (local _x) then
{
deleteVehicle _x; // mission ATMs
_x setDamage 1; // map ATMs
};
} forEach A3W_atmArray;

A3W_atmArray = [];
};
48 changes: 44 additions & 4 deletions client/functions/playerEventServer.sqf
Expand Up @@ -20,10 +20,6 @@ switch (toLower _type) do
{
[] spawn fn_savePlayerData;
};
}
else
{
["The money was counterfeit!", 5] call mf_notify_client;
};
};

Expand All @@ -41,11 +37,55 @@ switch (toLower _type) do
};

playSound "defaultNotification";
call mf_items_warchest_refresh;
call mf_items_cratemoney_refresh;
true call mf_items_atm_refresh;
}
else
{
playSound "FD_CP_Not_Clear_F";
["Invalid transaction, please try again.", 5] call mf_notify_client;
};
};

case "atmtransfersent":
{
_amount = [_this, 1, 0, [0]] call BIS_fnc_param;
_name = [_this, 2, "", [""]] call BIS_fnc_param;

if (_amount != 0) then
{
_message = if (isStreamFriendlyUIEnabled) then {
"You have successfully transferred $%1"
} else {
"You have successfully transferred $%1 to %2"
};

playSound "defaultNotification";
[format [_message, [_amount] call fn_numbersText, _name], 5] call mf_notify_client;
true call mf_items_atm_refresh;
}
else
{
playSound "FD_CP_Not_Clear_F";
["Invalid transaction, please try again.", 5] call mf_notify_client;
true call mf_items_atm_refresh;
};
};

case "atmtransferreceived":
{
_amount = [_this, 1, 0, [0]] call BIS_fnc_param;
_name = [_this, 2, "", [""]] call BIS_fnc_param;

_message = if (isStreamFriendlyUIEnabled) then {
"You have received $%1 from a bank transfer"
} else {
"%2 has transferred $%1 to your bank account"
};

playSound "FD_Finish_F";
[format [_message, [_amount] call fn_numbersText, _name], 5] call mf_notify_client;
true call mf_items_atm_refresh;
};
};

0 comments on commit 0cf34c0

Please sign in to comment.