-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,993 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Summary: Gets a parameter value in a paired list on format ["KEY", value]. | ||
* Arguments: | ||
* _params: List of paired value parameters. | ||
* _key: String with key to look for. | ||
* _default: Value that is returned if key was not found. | ||
* Returns: Value associated with key. ObjNull if no key was found. | ||
*/ | ||
ENGIMA_TRAFFIC_GetParamValue = { | ||
private ["_params", "_key"]; | ||
private ["_value"]; | ||
|
||
_params = _this select 0; | ||
_key = _this select 1; | ||
_value = if (count _this > 2) then { _this select 2 } else { objNull }; | ||
|
||
{ | ||
if (_x select 0 == _key) then { | ||
_value = _x select 1; | ||
}; | ||
} foreach (_params); | ||
|
||
_value | ||
}; | ||
|
||
/* | ||
* Summary: Checks if a marker exists. | ||
* Arguments: | ||
* _marker: Marker name of marker to test. | ||
* Returns: true if marker exists, else false. | ||
*/ | ||
ENGIMA_TRAFFIC_MarkerExists = { | ||
private ["_exists", "_marker"]; | ||
|
||
_marker = _this select 0; | ||
|
||
_exists = false; | ||
if (((getMarkerPos _marker) select 0) != 0 || ((getMarkerPos _marker) select 1 != 0)) then { | ||
_exists = true; | ||
}; | ||
_exists | ||
}; | ||
|
||
/* | ||
* Summary: Checks if a position is inside a marker. | ||
* Remarks: Marker can be of shape "RECTANGLE" or "ELLIPSE" and at any angle. | ||
* Arguments: | ||
* _markerName: Name of current marker. | ||
* _pos: Position to test. | ||
* Returns: true if position is inside marker. Else false. | ||
*/ | ||
ENGIMA_TRAFFIC_PositionIsInsideMarker = { | ||
private ["_markerName", "_pos"]; | ||
private ["_isInside", "_px", "_py", "_mpx", "_mpy", "_msx", "_msy", "_ma", "_xmin", "_xmax", "_ymin", "_ymax", "_rpx", "_rpy", "_res"]; | ||
|
||
_pos = _this select 0; | ||
_markerName = _this select 1; | ||
|
||
_px = _pos select 0; | ||
_py = _pos select 1; | ||
_mpx = (getMarkerPos _markerName) select 0; | ||
_mpy = (getMarkerPos _markerName) select 1; | ||
_msx = (getMarkerSize _markerName) select 0; | ||
_msy = (getMarkerSize _markerName) select 1; | ||
_ma = -(markerDir _markerName); | ||
|
||
_xmin = _mpx - _msx; | ||
_xmax = _mpx + _msx; | ||
_ymin = _mpy - _msy; | ||
_ymax = _mpy + _msy; | ||
|
||
//Now, rotate point to investigate around markers center in order to check against a nonrotated marker | ||
_rpx = ( (_px - _mpx) * cos(_ma) ) + ( (_py - _mpy) * sin(_ma) ) + _mpx; | ||
_rpy = (-(_px - _mpx) * sin(_ma) ) + ( (_py - _mpy) * cos(_ma) ) + _mpy; | ||
|
||
_isInside = false; | ||
|
||
if (markerShape _markerName == "RECTANGLE") then { | ||
if (((_rpx > _xmin) && (_rpx < _xmax)) && ((_rpy > _ymin) && (_rpy < _ymax))) then | ||
{ | ||
_isInside = true; | ||
}; | ||
}; | ||
|
||
if (markerShape _markerName == "ELLIPSE") then { | ||
_res = (((_rpx-_mpx)^2)/(_msx^2)) + (((_rpy-_mpy)^2)/(_msy^2)); | ||
if ( _res < 1 ) then | ||
{ | ||
_isInside = true; | ||
}; | ||
}; | ||
|
||
_isInside | ||
}; |
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,179 @@ | ||
ENGIMA_TRAFFIC_SilentDebugMode = false; | ||
|
||
ENGIMA_TRAFFIC_DebugTextEventArgs = []; // Empty | ||
ENGIMA_TRAFFIC_DebugMarkerEventArgs = []; // [name, position, size, direction, shape ("RECTANGLE" or "ELLIPSE"), markerColor, markerText (optional)] or alternatively [name, position, type, markerColor (optional), markerText (optional)] | ||
ENGIMA_TRAFFIC_DeleteDebugMarkerEventArgs = []; // [name] | ||
|
||
"ENGIMA_TRAFFIC_DebugTextEventArgs" addPublicVariableEventHandler { | ||
ENGIMA_TRAFFIC_DebugTextEventArgs call ENGIMA_TRAFFIC_ShowDebugTextLocal; | ||
}; | ||
|
||
"ENGIMA_TRAFFIC_DebugMarkerEventArgs" addPublicVariableEventHandler { | ||
ENGIMA_TRAFFIC_DebugMarkerEventArgs call ENGIMA_TRAFFIC_SetDebugMarkerLocal; | ||
}; | ||
|
||
"ENGIMA_TRAFFIC_DeleteDebugMarkerEventArgs" addPublicVariableEventHandler { | ||
ENGIMA_TRAFFIC_DeleteDebugMarkerEventArgs call ENGIMA_TRAFFIC_DeleteDebugMarkerLocal; | ||
}; | ||
|
||
/* | ||
* Summary: Shows debug text on all clients. | ||
* Remarks: | ||
* if global variable "dre_var_CL_SilentDebugMode" is set to true, debug text will only be written to RTF-file and not shown on screen. | ||
* Arguments: | ||
* _text: Debug text. | ||
*/ | ||
ENGIMA_TRAFFIC_ShowDebugTextAllClients = { | ||
ENGIMA_TRAFFIC_DebugTextEventArgs = _this; | ||
publicVariable "ENGIMA_TRAFFIC_DebugTextEventArgs"; | ||
ENGIMA_TRAFFIC_DebugTextEventArgs call ENGIMA_TRAFFIC_ShowDebugTextLocal; | ||
}; | ||
|
||
/* | ||
* Summary: Shows debug text on local client. | ||
* Remarks: | ||
* if global variable "dre_var_CL_SilentDebugMode" is set to true, debug text will only be written to RTF-file and not shown on screen. | ||
* Arguments: | ||
* _text: Debug text. | ||
*/ | ||
ENGIMA_TRAFFIC_ShowDebugTextLocal = { | ||
private ["_minutes", "_seconds"]; | ||
|
||
if (!isNull player) then { | ||
if (!ENGIMA_TRAFFIC_SilentDebugMode) then { | ||
player sideChat (_this select 0); | ||
}; | ||
}; | ||
|
||
_minutes = floor (time / 60); | ||
_seconds = floor (time - (_minutes * 60)); | ||
diag_log ((str _minutes + ":" + str _seconds) + " Debug: " + (_this select 0)); | ||
}; | ||
|
||
/* | ||
* Summary: Shows debug marker on local client. | ||
* Remarks: | ||
* if global variable "dre_var_CL_SilentDebugMode" is set to true, debug marker will not shown. | ||
* Arguments alternative #1 (Marker representing an area): | ||
* _markerName: Marker's name. (must be global unique). | ||
* _position: Marker's position. | ||
* _size: Marker's size on array format [x, y]. | ||
* _direction: Marker's direction. | ||
* _shape: "RECTANGLE" or "ELLIPSE". | ||
* _markerColor: Marker's color ("Default", "ColorRed", "ColorYellow" etc.). | ||
* [_markerText]: Optional. Marker's text. | ||
* Arguments alternative #2 (Marker representing an icon). | ||
* _markerName: Marker's name. (must be global unique). | ||
* _position: Marker's position. | ||
* _type: Markers icon type (applies to icons in cfgIcons, like "Warning", "Dot" etc.). | ||
* [_markerColor]: Optional. Marker's color ("Default", "ColorRed", "ColorYellow" etc.). | ||
* [_markerText]. Optional. Marker's text. | ||
*/ | ||
ENGIMA_TRAFFIC_SetDebugMarkerLocal = { | ||
private ["_markerName", "_position", "_size", "_direction", "_type", "_shape", "_markerColor", "_markerText"]; | ||
private ["_marker"]; | ||
|
||
if (!isNull player) then { | ||
if (!ENGIMA_TRAFFIC_SilentDebugMode) then { | ||
_markerName = _this select 0; | ||
_position = _this select 1; | ||
_markerColor = "Default"; | ||
_markerText = ""; | ||
|
||
if (count _this == 6) then { | ||
_size = _this select 2; | ||
_direction = _this select 3; | ||
_shape = _this select 4; | ||
_markerColor = _this select 5; | ||
}; | ||
if (count _this == 7) then { | ||
_size = _this select 2; | ||
_direction = _this select 3; | ||
_shape = _this select 4; | ||
_markerColor = _this select 5; | ||
_markerText = _this select 6; | ||
}; | ||
if (count _this == 3) then { | ||
_type = _this select 2; | ||
_shape = "ICON"; | ||
}; | ||
if (count _this == 4) then { | ||
_type = _this select 2; | ||
_shape = "ICON"; | ||
_markerColor = _this select 3; | ||
}; | ||
if (count _this == 5) then { | ||
_type = _this select 2; | ||
_shape = "ICON"; | ||
_markerColor = _this select 3; | ||
_markerText = _this select 4; | ||
}; | ||
|
||
// Delete old marker | ||
if ([_markerName] call ENGIMA_TRAFFIC_MarkerExists) then { | ||
deleteMarkerLocal _markerName; | ||
}; | ||
|
||
// Set new marker | ||
_marker = createMarkerLocal [_markerName, _position]; | ||
_marker setMarkerShapeLocal _shape; | ||
_marker setMarkerColorLocal _markerColor; | ||
_marker setMarkerTextLocal _markerText; | ||
|
||
if (count _this == 6 || count _this == 7) then { | ||
_marker setMarkerSizeLocal _size; | ||
_marker setMarkerDirLocal _direction; | ||
}; | ||
if (count _this == 3 || count _this == 4 || count _this == 5) then { | ||
_marker setMarkerTypeLocal _type; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
/* | ||
* Summary: Shows debug marker on all clients. | ||
* Remarks: | ||
* if global variable "dre_var_CL_SilentDebugMode" is set to true, debug marker will not shown. | ||
* Arguments alternative #1 (Marker representing an area): | ||
* _markerName: Marker's name. (must be global unique). | ||
* _position: Marker's position. | ||
* _size: Marker's size on array format [x, y]. | ||
* _direction: Marker's direction. | ||
* _shape: "RECTANGLE" or "ELLIPSE". | ||
* _markerColor: Marker's color ("Default", "ColorRed", "ColorYellow" etc.). | ||
* [_markerText]: Optional. Marker's text. | ||
* Arguments alternative #2 (Marker representing an icon). | ||
* _markerName: Marker's name. (must be global unique). | ||
* _position: Marker's position. | ||
* _type: Markers icon type (applies to icons in cfgIcons, like "Warning", "Dot" etc.). | ||
* [_markerColor]: Optional. Marker's color ("Default", "ColorRed", "ColorYellow" etc.). | ||
* [_markerText]. Optional. Marker's text. | ||
*/ | ||
ENGIMA_TRAFFIC_SetDebugMarkerAllClients = { | ||
ENGIMA_TRAFFIC_DebugMarkerEventArgs = _this; | ||
publicVariable "ENGIMA_TRAFFIC_DebugMarkerEventArgs"; | ||
ENGIMA_TRAFFIC_DebugMarkerEventArgs call ENGIMA_TRAFFIC_SetDebugMarkerLocal; | ||
}; | ||
|
||
/* | ||
* Summary: Deletes a debug marker on local client. | ||
* Arguments: | ||
* _markerName: Name of marker to delete. | ||
*/ | ||
ENGIMA_TRAFFIC_DeleteDebugMarkerLocal = { | ||
private ["_markerName"]; | ||
_markerName = _this select 0; | ||
deleteMarkerLocal _markerName; | ||
}; | ||
|
||
/* | ||
* Summary: Deletes a debug marker on all clients. | ||
* Arguments: | ||
* _markerName: Name of marker to delete. | ||
*/ | ||
ENGIMA_TRAFFIC_DeleteDebugMarkerAllClients = { | ||
ENGIMA_TRAFFIC_DeleteDebugMarkerEventArgs = _this; | ||
publicVariable "ENGIMA_TRAFFIC_DeleteDebugMarkerEventArgs"; | ||
ENGIMA_TRAFFIC_DeleteDebugMarkerEventArgs call ENGIMA_TRAFFIC_DeleteDebugMarkerLocal; | ||
}; |
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,76 @@ | ||
/* | ||
* This file contains parameters to config and function call to start an instance of | ||
* traffic in the mission. The file is edited by the mission developer. | ||
* | ||
* See file Engima\Traffic\Documentation.txt for documentation and a full reference of | ||
* how to customize and use Engima's Traffic. | ||
*/ | ||
|
||
private ["_parameters"]; | ||
|
||
// Set traffic parameters. | ||
_parameters = [ | ||
["SIDE", civilian], | ||
["VEHICLES", [ | ||
"C_Offroad_01_F", | ||
"C_Offroad_01_repair_F", | ||
"C_Hatchback_01_F", | ||
"C_Hatchback_01_sport_F", | ||
"C_SUV_01_F", | ||
"C_Van_01_transport_F", | ||
"C_Van_01_box_F", | ||
"C_Van_01_fuel_F", | ||
|
||
|
||
"RDS_Gaz24_Civ_01", | ||
"RDS_Gaz24_Civ_02", | ||
"RDS_Gaz24_Civ_03", | ||
"RDS_Gaz24_Civ_01", | ||
"RDS_Gaz24_Civ_02", | ||
"RDS_Gaz24_Civ_03", | ||
"RDS_Gaz24_Civ_01", | ||
"RDS_Gaz24_Civ_02", | ||
"RDS_Gaz24_Civ_03", | ||
|
||
"RDS_Ikarus_Civ_01", | ||
"RDS_Ikarus_Civ_02", | ||
"RDS_Ikarus_Civ_02", | ||
|
||
"RDS_S1203_Civ_01", | ||
"RDS_S1203_Civ_02", | ||
"RDS_S1203_Civ_03", | ||
|
||
"RDS_Octavia_Civ_01", | ||
|
||
"RDS_Lada_Civ_01", | ||
"RDS_Lada_Civ_02", | ||
"RDS_Lada_Civ_03", | ||
"RDS_Lada_Civ_04", | ||
"RDS_Lada_Civ_05", | ||
"RDS_Lada_Civ_01", | ||
"RDS_Lada_Civ_02", | ||
"RDS_Lada_Civ_03", | ||
"RDS_Lada_Civ_04", | ||
|
||
"RDS_Zetor6945_Base", | ||
|
||
|
||
"RHS_Ural_Civ_01", | ||
"RHS_Ural_Civ_02", | ||
"RHS_Ural_Civ_03", | ||
"RHS_Ural_Open_Civ_01", | ||
"RHS_Ural_Open_Civ_02", | ||
"RHS_Ural_Open_Civ_03", | ||
"RHS_UAZ_open_chdkz", | ||
"RHS_UAZ_chdkz" | ||
]], | ||
["VEHICLES_COUNT", 10], | ||
["MIN_SPAWN_DISTANCE", 1500], | ||
["MAX_SPAWN_DISTANCE", 2500], | ||
["MIN_SKILL", 0.1], | ||
["MAX_SKILL", 0.2], | ||
["DEBUG", false] | ||
]; | ||
|
||
// Start an instance of the traffic | ||
_parameters spawn ENGIMA_TRAFFIC_StartTraffic; |
Oops, something went wrong.