Transferring rest of function files

This commit is contained in:
SilentSpike 2015-05-10 17:17:17 +01:00
parent e0c658560b
commit eaa0f16e30
3 changed files with 308 additions and 0 deletions

View File

@ -0,0 +1,18 @@
_logic = _this select 0;
_units = _this select 1;
_activated = _this select 2;
if (_activated) then {
_explosive = gettext (configfile >> "cfgvehicles" >> typeof _logic >> "explosive");
if (_explosive != "") then {
_explosive = createvehicle [_explosive,position _logic,[],0,"none"];
_explosive attachto [_logic];
//--- Show hint to curator who placed the object
[[["Curator","PlaceMines"],nil,nil,nil,nil,nil,nil,true],"bis_fnc_advHint",_logic] call bis_fnc_mp;
waituntil {sleep 0.1; isnull _explosive || isnull _logic || !alive _logic};
if (isnull _logic) then {deletevehicle _explosive;} else {_explosive setdamage 1;};
deletevehicle _logic;
};
};

View File

@ -0,0 +1,141 @@
_logic = _this select 0;
_units = _this select 1;
_activated = _this select 2;
if ({local _x} count (objectcurators _logic) > 0) then {
//--- Reveal the circle to curators
_logic hideobject false;
_logic setpos position _logic;
};
if !(isserver) exitwith {};
if (_activated) then {
_ammo = _logic getvariable ["type",gettext (configfile >> "cfgvehicles" >> typeof _logic >> "ammo")];
if (_ammo != "") then {
_cfgAmmo = configfile >> "cfgammo" >> _ammo;
//if !(isclass _cfgAmmo) exitwith {["CfgAmmo class '%1' not found.",_ammo] call bis_fnc_error;};
_dirVar = _fnc_scriptname + typeof _logic;
_logic setdir (missionnamespace getvariable [_dirVar,direction _logic]); //--- Restore custom direction
_pos = getposatl _logic;
_posAmmo = +_pos;
_posAmmo set [2,0];
_dir = direction _logic;
_simulation = tolower gettext (configfile >> "cfgammo" >> _ammo >> "simulation");
_altitude = 0;
_velocity = [];
_attach = false;
_radio = "";
_delay = 60;
_sound = "";
_soundSourceClass = "";
_hint = [];
_shakeStrength = 0;
_shakeRadius = 0;
switch (_simulation) do {
case "shotshell": {
_altitude = 1000;
_velocity = [0,0,-100];
_radio = "SentGenIncoming";
_sounds = if (getnumber (_cfgAmmo >> "hit") < 200) then {["mortar1","mortar2"]} else {["shell1","shell2","shell3","shell4"]};
_sound = _sounds call bis_fnc_selectrandom;
_hint = ["Curator","PlaceOrdnance"];
_shakeStrength = 0.01;
_shakeRadius = 300;
};
case "shotsubmunitions": {
_posAmmo = [_posAmmo,500,_dir + 180] call bis_fnc_relpos;
_altitude = 1000 - ((getterrainheightasl _posAmmo) - (getterrainheightasl _pos));
_posAmmo set [2,_altitude];
_velocity = [sin _dir * 68,cos _dir * 68,-100];
_radio = "SentGenIncoming";
_hint = ["Curator","PlaceOrdnance"];
_shakeStrength = 0.02;
_shakeRadius = 500;
};
case "shotilluminating": {
_altitude = 66;
_velocity = [wind select 0,wind select 1,30];
_sound = "SN_Flare_Fired_4";
_soundSourceClass = "SoundFlareLoop_F";
};
case "shotnvgmarker";
case "shotsmokex": {
_altitude = 0;
_velocity = [0,0,0];
_attach = true;
};
default {["Ammo simulation '%1' is not supported",_simulation] call bis_fnc_error;};
};
if (count _hint > 0) then {
[[_hint,nil,nil,nil,nil,nil,nil,true],"bis_fnc_advHint",objectcurators _logic] call bis_fnc_mp;
};
if (count _velocity == 3) then {
_altitude = (_logic getvariable ["altitude",_altitude]) call bis_fnc_parsenumber;
_radio = _logic getvariable ["radio",_radio];
//--- Create projectile
_posAmmo set [2,_altitude];
_projectile = createvehicle [_ammo,_posAmmo,[],0,"none"];
_projectile setpos _posAmmo;
_projectile setvelocity _velocity;
if (_attach) then {_projectile attachto [_logic,[0,0,_altitude]];};
//--- Play sound
if (_sound != "") then {[[_logic,_sound,"say3D"],"bis_fnc_sayMessage"] call bis_fnc_mp;};
//--- Create sound source
_soundSource = if (_soundSourceClass != "") then {createSoundSource [_soundSourceClass,_pos,[],0]} else {objnull};
//--- Update
if (_attach) then {
waituntil {
_soundSource setposatl getposatl _projectile;
sleep 1;
isnull _projectile || isnull _logic
};
} else {
waituntil {
_soundSource setposatl getposatl _projectile;
if (getposatl _logic distance _pos > 0 || direction _logic != _dir) then {
_posNew = getposasl _logic;
_dirDiff = direction _logic - _dir;
_posNew = [_posNew,[getposasl _projectile,_pos] call bis_fnc_distance2d,direction _logic + 180] call bis_fnc_relpos;
_posNew set [2,getposasl _projectile select 2];
_projectile setvelocity ([velocity _projectile,-_dirDiff] call bis_fnc_rotatevector2d);
_projectile setposasl _posNew;
_pos = getposatl _logic;
_dir = direction _logic;
missionnamespace setvariable [_dirVar,_dir];
};
sleep 0.1;
isnull _projectile || isnull _logic
};
};
deletevehicle _projectile;
deletevehicle _soundSource;
if (count objectcurators _logic > 0) then {
//--- Delete curator spawned logic
if (_shakeStrength > 0) then {
if (_simulation == "shotsubmunitions") then {sleep 0.5;};
[[_shakeStrength,0.7,[position _logic,_shakeRadius]],"bis_fnc_shakeCuratorCamera"] call bis_fnc_mp;
};
deletevehicle _logic;
} else {
//--- Repeat to achieve permanent effect
_repeat = _logic getvariable ["repeat",0] > 0;
if (_repeat) then {
[_logic,_units,_activated] call bis_fnc_moduleprojectile;
} else {
deletevehicle _logic;
};
};
} else {
deletevehicle _logic;
};
} else {
["Cannot create projectile, 'ammo' config attribute is missing in %1",typeof _logic] call bis_fnc_error;
};
};

View File

@ -0,0 +1,149 @@
_logic = _this select 0;
_units = _this select 1;
_activated = _this select 2;
if (_activated && local _logic && !isnull curatorcamera) then {
//--- Terminate when remote control is already in progress
if !(isnull (missionnamespace getvariable ["bis_fnc_moduleRemoteControl_unit",objnull])) exitwith {};
//--- Get unit under cursor
_unit = objnull;
_mouseOver = missionnamespace getvariable ["bis_fnc_curatorObjectPlaced_mouseOver",[""]];
if ((_mouseOver select 0) == typename objnull) then {_unit = _mouseOver select 1;};
_unit = effectivecommander _unit;
//--- Check if the unit is suitable
_error = "";
if !(side group _unit in [east,west,resistance,civilian]) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorEmpty";};
if (isplayer _unit) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer";};
if !(alive _unit) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorDestroyed";};
if (isnull _unit) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorNull";};
if !(isnull (_unit getvariable ["bis_fnc_moduleRemoteControl_owner",objnull])) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorControl";};
if (_error == "") then {
_unit spawn {
scriptname "bis_fnc_moduleRemoteControl: Loop";
_unit = _this;
_vehicle = vehicle _unit;
_vehicleRole = str assignedvehiclerole _unit;
bis_fnc_moduleRemoteControl_unit = _unit;
_unit setvariable ["bis_fnc_moduleRemoteControl_owner",player,true];
_blur = ppeffectcreate ["RadialBlur",144];
_blur ppeffectenable true;
_blur ppeffectadjust [0,0,0.3,0.3];
_blur ppeffectcommit 0;
_blur ppeffectadjust [0.03,0.03,0.1,0.1];
_blur ppeffectcommit 1;
_cam = "camera" camcreate getposatl curatorcamera;
_cam cameraeffect ["internal","back"];
_cam campreparetarget (screentoworld [0.5,0.5]);
_cam camcommitprepared 0;
_cam campreparetarget _unit;
_cam campreparefov 0.1;
_cam camcommitprepared 1;
sleep 0.75;
("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black out",0.25];
sleep 0.25;
//--- Wait for interface to close
(finddisplay 312) closedisplay 2;
waituntil {isnull curatorcamera};
//--- Switch
player remotecontrol _unit;
if (cameraon != _vehicle) then {
_vehicle switchcamera cameraview;
};
ppeffectdestroy _blur;
_cam cameraeffect ["terminate","back"];
camdestroy _cam;
_color = ppeffectcreate ["colorCorrections",1896];
_color ppeffectenable true;
_color ppeffectadjust [1,1,0,[0,0,0,1],[1,1,1,1],[0,0,0,0],[0.9,0.0,0,0,0,0.5,1]];
_color ppeffectcommit 0;
_curator = getassignedcuratorlogic player;
[_curator,"curatorObjectRemoteControlled",[_curator,player,_unit,true]] call bis_fnc_callScriptedEventHandler;
[["Curator","RemoteControl"],nil,nil,nil,nil,nil,nil,true] call bis_fnc_advHint;
sleep 0.3;
_color ppeffectadjust [1,1,0,[0,0,0,1],[1,1,1,1],[0,0,0,0],[0.9,0.85,0,0,0,0.5,1]];
_color ppeffectcommit 0.3;
("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black in",0.5];
//--- Back to player
_vehicle = vehicle _unit;
_vehicleRole = str assignedvehiclerole _unit;
_rating = rating player;
waituntil {
//--- Refresh when vehicle or vehicle role changes
if ((vehicle _unit != _vehicle || str assignedvehiclerole _unit != _vehicleRole) && {alive _unit}) then {
player remotecontrol _unit;
_vehicle = vehicle _unit;
_vehicleRole = str assignedvehiclerole _unit;
};
if (rating player < _rating) then {
player addrating (-rating player + _rating);
};
sleep 0.01;
!isnull curatorcamera
||
{cameraon == vehicle player}
||
{!alive _unit} //--- Also isnull check, objNull is not alive
||
{isnull getassignedcuratorlogic player}
//||
//{_unit getvariable ["bis_fnc_moduleRemoteControl_owner",objnull] != player} //--- Another curator stole the unit
};
player addrating (-rating player + _rating);
objnull remotecontrol _unit;
_unit setvariable ["bis_fnc_moduleRemoteControl_owner",nil,true];
//--- Death screen
if (
isnull curatorcamera
&&
{cameraon != vehicle player}
&&
{!isnull _unit}
&&
{!isnull getassignedcuratorlogic player}
//&&
//{(_unit getvariable ["bis_fnc_moduleRemoteControl_owner",objnull] == player)}
) then {
sleep 2;
("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black out",1];
sleep 1;
};
_unitPos = getposatl _unit;
_camPos = [_unitPos,10,direction _unit + 180] call bis_fnc_relpos;
_camPos set [2,(_unitPos select 2) + (getterrainheightasl _unitPos) - (getterrainheightasl _camPos) + 10];
//[_camPos,_unit] call bis_fnc_setcuratorcamera;
(getassignedcuratorlogic player) setvariable ["bis_fnc_modulecuratorsetcamera_params",[_camPos,_unit]];
sleep 0.1; //--- Engine needs a delay in case controlled unit was deleted
("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black in",1e10];
opencuratorinterface;
ppeffectdestroy _color;
waituntil {!isnull curatorcamera};
player switchcamera cameraview;
bis_fnc_moduleRemoteControl_unit = nil;
("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black in",1];
[_curator,"curatorObjectRemoteControlled",[_curator,player,_unit,false]] call bis_fnc_callScriptedEventHandler;
sleep 0.01;
};
} else {
[objnull,_error] call bis_fnc_showCuratorFeedbackMessage;
};
deletevehicle _logic;
};