Skip to content

Instantly share code, notes, and snippets.

@veteran29
Last active December 17, 2018 16:37
Show Gist options
  • Save veteran29/217d1c9de8c85fed1d89a669b780b378 to your computer and use it in GitHub Desktop.
Save veteran29/217d1c9de8c85fed1d89a669b780b378 to your computer and use it in GitHub Desktop.
KP Liberation Stuff
// Show activation ranges of all sectors
KPLIB_sectors_all apply {
private _rangeMarker = format ["%1_range", _x];
createMarkerLocal [_rangeMarker, getMarkerPos _x];
_rangeMarker setMarkerShapeLocal "ELLIPSE";
_rangeMarker setMarkerSizeLocal [KPLIB_param_sectorActRange, KPLIB_param_sectorActRange];
_rangeMarker setMarkerBrushLocal "BORDER";
_rangeMarker
};
// Fired when current player fob changes
// _fob has new FOB marker name or is an empty string when out of FOB
// Executed GLOBALLY
["KPLIB_player_fob", {
params ["_player", "_fob"];
if (_fob isEqualTo "") then {
systemChat format["PLayer: %1 out of FOB.", _player];
} else {
systemChat format["Player: %1, entered FOB: %2", _player, _fob];
};
}] call CBA_fnc_addEventHandler;
// Fired when sector is activated
// Executed GLOBALLY
["KPLIB_sector_activated", {
params ["_sector"];
systemChat format["Sector: %1 was activated", _sector];
}] call CBA_fnc_addEventHandler;
// Fired when sector is captured
// Executed GLOBALLY
["KPLIB_sector_captured", {
params ["_sector", "_side"];
systemChat format["Sector: %1 was captured", _sector];
}] call CBA_fnc_addEventHandler;
// Fired when sector is deactivated
// Executed GLOBALLY
["KPLIB_sector_deactivated", {
params ["_sector"];
systemChat format["Sector: %1 was deactivated", _sector];
}] call CBA_fnc_addEventHandler;
// Fired when FOB is built.
// Exectued GLOBALLY
["KPLIB_fob_built", {
params ["_fob"];
systemChat format["Fob %1 was built", _fob];
}] call CBA_fnc_addEventHandler;
// Fired when vehicle is created via "KPLIB_fnc_common_spawnVehicle"
// Executed LOCALLY where vehicle was spawned
["KPLIB_vehicle_spawned", {
params ["_vehicle"];
systemChat format["Vehicle was spawned: %1", _vehicle];
}] call CBA_fnc_addEventHandler;
// Fired when player redeploys
// Executed GLOBALLY
["KPLIB_player_redeploy", {
params ["_player", "_respawnPos", "_loadout"];
systemChat format["Player %1 spawned at position %2, with loadout %3", _player, _respawnPos, _loadout];
}] call CBA_fnc_addEventHandler;
/*
Execute in eden.
Will create basic "boilerplate" markers for mission. Might need manual tweaking.
*/
collect3DENHistory
{
{
private _locations = (nearestLocations [[0,0,0], _x, worldSize]);
private _markerName = "";
private _markerClass = "";
private _markerRotation = 0;
private _markerText = '_x';
switch true do {
case ("NameVillage" in _x): {
_markerName = "KPLIB_eden_city_%1";
_markerClass = "n_art";
};
case ("NameCityCapital" in _x): {
_markerName = "KPLIB_eden_metropolis_%1";
_markerClass = "n_service";
_markerRotation = 90;
};
case ("Hill" in _x): {
_markerName = "KPLIB_eden_tower_%1";
_markerClass = "loc_Transmitter";
_markerText = '"Radio Tower " + (mapGridPosition getPos _x)';
};
};
{
private _marker = create3DENEntity ["Marker", _markerClass, getPos _x];
set3DENAttributes [
[[_marker], "rotation", _markerRotation],
[[_marker], "itemClass", _markerClass],
[[_marker], "text", call compile _markerText],
// [[_marker], "baseColor", "ColorEAST"],
[[_marker], "markerName", format[_markerName, _forEachIndex]]
];
} forEach _locations;
} forEach [
["NameVillage", "NameCity"],
["NameCityCapital"],
["Hill"]
];
private _exclude = ["StorageBladder_01_fuel_forest_F","B_Truck_01_fuel_F","etc"];
private _fuelStations = ([0,0,0] nearObjects worldSize) select {getFuelCargo _x > 0 AND !(typeof _x in _exclude)};
{
private _obj = _x;
private _allMarkers = all3DENEntities select 5;
if (count (_allMarkers select {
private _pos = _x get3DENAttribute "position" select 0;
(_pos distance2D (getPos _obj)) < 300
}) == 0) then {
private _markerName = "KPLIB_eden_factory_%1";
private _markerClass = "loc_Fuelstation";
private _markerRotation = 0;
private _nearestLocationName = mapGridPosition _x;
private _nearestLocation = (nearestLocations [getPos _x, ["NameVillage", "NameCity", "NameCityCapital"], 1000, getPos _x]) select 0;
if !(_nearestLocation isEqualTo locationNull) then {_nearestLocationName = text _nearestLocation};
private _markerText = format["%1 Factory", _nearestLocationName];
private _marker = create3DENEntity ["Marker", _markerClass, getPos _x];
set3DENAttributes [
[[_marker], "rotation", _markerRotation],
[[_marker], "itemClass", _markerClass],
[[_marker], "text", _markerText],
[[_marker], "baseColor", "ColorEAST"],
[[_marker], "markerName", format[_markerName, _forEachIndex]]
];
};
} forEach _fuelStations;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment