-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add create teleporter module * Add docs to modules list * Apply suggestions from code review Co-Authored-By: Ralfs Garkaklis <ralfs@garkaklis.com> * Move event code to function * Use macro for location icon path
- Loading branch information
Showing
11 changed files
with
180 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
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
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
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,67 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: mharis001 | ||
* Adds a teleporter action to the given object. | ||
* | ||
* Arguments: | ||
* 0: Teleporter <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [cursorObject] call zen_modules_fnc_addTeleporterAction | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_object"]; | ||
|
||
private _actionID = _object addAction [ | ||
"", | ||
{ | ||
params ["_target"]; | ||
|
||
private _names = []; | ||
private _objects = []; | ||
|
||
{ | ||
_x params ["_object", "_name"]; | ||
|
||
if (_object != _target) then { | ||
_names pushBack _name; | ||
_objects pushBack _object; | ||
}; | ||
} forEach GVAR(teleporters); | ||
|
||
[ELSTRING(common,Teleport), [ | ||
["LIST", "str_dn_locations", [_objects, _names, 0], true] | ||
], { | ||
params ["_values"]; | ||
_values params ["_object"]; | ||
|
||
// Exit if the object was deleted after opening the menu | ||
// Otherwise the unit will be teleported to [0, 0, 0] | ||
if (isNull _object) exitWith {}; | ||
|
||
private _unit = call CBA_fnc_currentUnit; | ||
|
||
// Attempt to move unit into the object if it is a vehicle | ||
if (_unit moveInAny _object) exitWith {}; | ||
|
||
// Move unit near the object if the object is not a vehicle or is full | ||
_unit setVehiclePosition [_object, [], 0, "NONE"]; | ||
}] call EFUNC(dialog,create); | ||
}, | ||
nil, | ||
100, | ||
true, | ||
true, | ||
"", | ||
QUOTE(!(GVAR(teleporters) select {_x select 0 != _target} isEqualTo [])), | ||
10 | ||
]; | ||
|
||
private _text = format ["<t color='#FFFFFF'>%1</t>", localize ELSTRING(common,Teleport)]; | ||
private _picture = format ["<img image='%1' size='1.75' /><br />%2", ICON_LOCATION, _text]; | ||
_object setUserActionText [_actionID, _text, "", _picture]; |
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,33 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: mharis001 | ||
* Zeus module function to create a teleporter. | ||
* | ||
* Arguments: | ||
* 0: Logic <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [LOGIC] call zen_modules_fnc_moduleCreateTeleporter | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_logic"]; | ||
|
||
private _object = attachedTo _logic; | ||
private _position = getPosATL _logic; | ||
|
||
[LSTRING(ModuleCreateTeleporter), [ | ||
["EDIT", "STR_3DEN_Object_Attribute_UnitName_displayName", _position call BIS_fnc_locationDescription, true] | ||
], { | ||
params ["_values", "_args"]; | ||
_values params ["_name"]; | ||
_args params ["_object", "_position"]; | ||
|
||
[QGVAR(moduleCreateTeleporter), [_object, _position, _name]] call CBA_fnc_serverEvent; | ||
}, {}, [_object, _position]] call EFUNC(dialog,create); | ||
|
||
deleteVehicle _logic; |
48 changes: 48 additions & 0 deletions
48
addons/modules/functions/fnc_moduleCreateTeleporterServer.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,48 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: mharis001 | ||
* Zeus module function to create a new teleport location. | ||
* | ||
* Arguments: | ||
* 0: Teleporter <OBJECT> | ||
* 1: Position <ARRAY> | ||
* 2: Name <STRING> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [objNull, [0, 0, 0], "Location"] call zen_modules_fnc_moduleCreateTeleporterServer | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_object", "_position", "_name"]; | ||
|
||
// Create a flag pole object if an object wasn't given | ||
if (isNull _object) then { | ||
_object = createVehicle ["FlagPole_F", _position, [], 0, "NONE"]; | ||
[QEGVAR(common,addObjects), [[_object]]] call CBA_fnc_localEvent; | ||
}; | ||
|
||
// Add teleport action to new teleporter object | ||
private _jipID = [QGVAR(addTeleporterAction), _object] call CBA_fnc_globalEventJIP; | ||
[_jipID, _object] call CBA_fnc_removeGlobalEventJIP; | ||
|
||
// Add EH to remove object from the teleporters list if it is deleted | ||
_object addEventHandler ["Deleted", { | ||
params ["_object"]; | ||
|
||
private _index = GVAR(teleporters) findIf { | ||
_object isEqualTo (_x select 0); | ||
}; | ||
|
||
if (_index != -1) then { | ||
GVAR(teleporters) deleteAt _index; | ||
publicVariable QGVAR(teleporters); | ||
}; | ||
}]; | ||
|
||
// Add new teleport location and broadcast the updated list | ||
GVAR(teleporters) pushBack [_object, _name]; | ||
publicVariable QGVAR(teleporters); |
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
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