Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- AutoLockPicker
- by second_coming
- http://www.exilemod.com/profile/60-second_coming/
- Allow players to have a chance to lock pick any locked door or safe (also a chance to eloctrocute on failed unlocking!)
- Initial Script Code: Stealthstick's "Explosive-To-Vehicle" Script
- Electrocution effect: http://www.altisliferpg.com/topic/224-effects-on-marijuana-use/
- */
- // ======================================================================================================================================================================================
- // User configurable Variables
- // ======================================================================================================================================================================================
- // Which locks can be opened
- LockpickLandVehicles = false; // All land vehicles (cars, vans, trucks etc) ::: acceptable values true or false
- LockpickAir = false; // Helis and jets ::: acceptable values true or false
- LockpickShip = false; // Boats, jetskis and submarines ::: acceptable values true or false
- LockpickDoors = true; // Exile build-able doors ::: acceptable values true or false
- LockpickSafes = true; // Exile build-able doors ::: acceptable values true or false
- LockpickDistance = 2; // Maximum distance away from the object to unlock
- // Chance to succeed or be electrocuted
- SuccessChance = 15; // (Between 1-100) % Chance to successfully pick the lock
- ElectrocuteChance = 20; // (Between 1-100) % Chance of electrocution on if the lock pick fails
- // Damage Settings
- InflictDamage = true; // If true damage is added, if false just stun
- MinimumDamage = 50; // (Between 1-100) min% of full health Damage to inflict must be less than MaximumDamage
- MaximumDamage = 90; // (Between 1-100) max% of full health Damage to inflict must be more than MinimumDamage
- StunTime = 10; // Time in seconds to stun the player on electrocution (if it doesn't kill them)
- // Materials Required to Create AutoLockPicker
- MaterialRequired1 = 'Exile_Item_Laptop'; // First material required to create AutoLockPicker (default is 'CircuitParts' or Electronic Component)
- MaterialRequired1Count = 1;
- MaterialRequired2 = 'Exile_Item_ExtensionCord'; // Second material required to create AutoLockPicker (default is 'ItemCorrugated' or small metal parts)
- MaterialRequired2Count = 2;
- // Usage Restrictions
- AllowInSafeZone = false; // (Leave true if you don't use inSafezone) Allow use of AutoLockPicker in safezones
- _MinimumPlayers = 0; // Number of players required online before the option to lock pick becomes available (set to 0 to always allow)
- AllowLockPicksNear = true; // (Leave true for no restriction) selecting false will make the script check if one has been placed within LockpickDistance m of the player
- UnlockableItems = ["Exile_Construction_WoodDoor_Reinforced_Static","Exile_Construction_WoodDoor_Static","Exile_Construction_WoodGate_Reinforced_Static","Exile_Construction_WoodGate_Static","Land_City_Gate_F","Land_Stone_Gate_F"];
- // ======================================================================================================================================================================================
- // End of User configurable Variables
- // ======================================================================================================================================================================================
- MISSION_ROOT = call
- {
- private "_arr";
- _arr = toArray __FILE__;
- _arr resize (count _arr - 18);
- toString _arr
- };
- LockPickingInProgress = false;
- if(AllowInSafeZone && count playableUnits >= _MinimumPlayers) then
- {
- SafeToALP = true;
- }
- else
- {
- if(!ExilePlayerInSafezone && count playableUnits >= _MinimumPlayers) then
- {
- SafeToALP = true;
- }
- else
- {
- SafeToALP = false;
- };
- };
- LockPickableItems = [];
- if(LockpickLandVehicles) then
- {
- LockPickableItems = LockPickableItems + ["LandVehicle"];
- };
- if(LockpickAir) then
- {
- LockPickableItems = LockPickableItems + ["Air"];
- };
- if(LockpickShip) then
- {
- LockPickableItems = LockPickableItems + ["Ship"];
- };
- if(LockpickDoors) then
- {
- LockPickableItems = LockPickableItems + UnlockableItems;
- };
- if(LockpickSafes) then
- {
- LockPickableItems = LockPickableItems + ["Exile_Container_Safe"];
- };
- AutoLockPicker_MatsCheck =
- {
- _charge1 = _this select 0;
- _charge2 = _this select 1;
- _unit = _this select 2;
- _hasIt1 = _charge1 in (magazines _unit);
- _hasIt1Count = {_x == _charge1} count magazines player;
- _hasIt2 = _charge2 in (magazines _unit);
- _hasIt2Count = {_x == _charge2} count magazines player;
- _hasEnough = false;
- if(_hasIt1Count >= MaterialRequired1Count && _hasIt2Count >= MaterialRequired2Count) then
- {
- _hasEnough = true;
- };
- _CanPlace = false;
- _nearALP = nearestObjects [_unit,["Land_PortableLongRangeRadio_F"],LockpickDistance];
- if(AllowLockPicksNear || (count _nearALP == 0 && !AllowLockPicksNear)) then
- {
- _CanPlace = true;
- };
- _target = cursorTarget;
- _LockPickable = false;
- if ((typeOf cursorTarget) in LockPickableItems) then
- {
- _LockPickable = true;
- }
- else
- {
- if (_target isKindOf "LandVehicle" && LockpickLandVehicles) then
- {
- _LockPickable = true;
- };
- if (_target isKindOf "Air" && LockpickAir) then
- {
- _LockPickable = true;
- };
- if (_target isKindOf "Ship" && LockpickShip) then
- {
- _LockPickable = true;
- };
- };
- _locked = 0;
- _locked = _target getVariable "ExileIsLocked";
- //hint format ["Target: %1 Lockpickable: %2 Locked: %3 Distance: %4",(typeOf cursorTarget),_LockPickable,locked cursorTarget,_unit distance cursorTarget];
- _nearVehs = false;
- if (_LockPickable && _unit distance _target < LockpickDistance) then
- {
- _nearVehs = true;
- };
- _return = (_hasEnough && _nearVehs && alive _unit && SafeToALP && _CanPlace && _locked == -1 && !LockPickingInProgress);
- _return
- };
- AutoLockPicker_Countdown = { [ format["<t size='0.70' color='#00FFFF'>%1</t>",_this], 0,1,5,0,0,301] spawn bis_fnc_dynamicText; };
- AutoLockPicker_Activate =
- {
- _unit = _this select 0;
- LockPickingInProgress = true;
- _lockpicks = _unit getVariable ["lockpicks",[]];
- {
- //systemchat format["Lockpick: %1",_x];
- if(alive _x && SafeToALP) then
- {
- _time = 30;
- _attemptFinished = false;
- _nearVehicle = (nearestObjects [_x,LockPickableItems,LockpickDistance]) select 0;
- player playActionNow "medicStart";
- removeAllActions player;
- while {alive player and (player distance _nearVehicle) < LockpickDistance and (_time > 0) and !_attemptFinished} do
- {
- if!(["medic",animationState player] call BIS_fnc_inString) then
- {
- player playActionNow "medicStart";
- };
- (format["time remaining %1 sec", _time] ) call AutoLockPicker_Countdown;
- if (_time <= 0.1) then { ("") call AutoLockPicker_Countdown; _attemptFinished = true; player playActionNow "medicstop"; };
- _time = _time - 1;
- if(_time > 1) then { sleep 1; };
- };
- ("") call AutoLockPicker_Countdown;
- [player] call AutoLockPicker_Actions;
- // Chance to unlock
- _chance = Ceil random 100;
- if(_chance <= SuccessChance) then{
- // Unlock the door or vehicle
- //player switchMove "";
- _nearVehicle = (nearestObjects [_x,LockPickableItems,LockpickDistance]) select 0;
- deleteVehicle _x;
- ALPUNLOCK = [_nearVehicle];
- uiSleep 0.2;
- publicVariableServer "ALPUNLOCK";
- uiSleep 0.2;
- if ((typeOf _nearVehicle) in UnlockableItems) then
- {
- ["Success", "The AutoLockPicker worked! Opening door"] call ExileClient_gui_notification_event_addNotification;
- _nearVehicle setVariable ["ExileIsLocked", 0, true];
- _nearVehicle lock 0;
- }
- else
- {
- ["Success", "The AutoLockPicker worked! Unlocking Safe"] call ExileClient_gui_notification_event_addNotification;
- _nearVehicle setVariable ["ExileIsLocked", 0, true];
- _nearVehicle lock 0;
- }
- }
- else
- {
- //_unit switchMove "";
- _chance2 = Ceil random 100;
- if(_chance2 <= ElectrocuteChance) then
- {
- // Chance of electrocution
- _DamagetoInflict = (Ceil random (MaximumDamage - MinimumDamage))/100;
- _damage = Damage player;
- _damage = _damage + (MinimumDamage/100) + _DamagetoInflict;
- playSound3D [MISSION_ROOT + "electrocute.ogg", player, false, getPosASL player, 1, 1, 0];
- if(_damage > 1 && InflictDamage) then
- {
- ["RestartWarning", "The AutoLockPicker malfunctioned and electrocuted you"] call ExileClient_gui_notification_event_addNotification;
- systemChat "The AutoLockPicker malfunctioned and electrocuted you";
- player setDamage 1;
- ExileClientPlayerAttributes set [0, 0];
- // Activate ppEffects
- "chromAberration" ppEffectEnable true;
- "radialBlur" ppEffectEnable true;
- enableCamShake true;
- // 5secs of effects
- for "_i" from 0 to 4 do
- {
- "chromAberration" ppEffectAdjust [random 0.25,random 0.25,true];
- "chromAberration" ppEffectCommit 1;
- "radialBlur" ppEffectAdjust [random 0.02,random 0.02,0.15,0.15];
- "radialBlur" ppEffectCommit 1;
- addcamShake[random 3, 1, random 3];
- uiSleep 1;
- };
- //Stop effects
- "chromAberration" ppEffectAdjust [0,0,true];
- "chromAberration" ppEffectCommit 5;
- "radialBlur" ppEffectAdjust [0,0,0,0];
- "radialBlur" ppEffectCommit 5;
- uiSleep 6;
- //Deactivate ppEffects
- "chromAberration" ppEffectEnable false;
- "radialBlur" ppEffectEnable false;
- resetCamShake;
- }
- else
- {
- ["RestartWarning", "The AutoLockPicker malfunctioned and gave you an electric shock"] call ExileClient_gui_notification_event_addNotification;
- systemChat "The AutoLockPicker malfunctioned and gave you an electric shock";
- if(InflictDamage) then
- {
- player setDamage _damage;
- ExileClientPlayerAttributes set [0, (1 - _damage) * 100];
- };
- player playActionNow "GestureSpasm0";
- // Activate ppEffects
- "chromAberration" ppEffectEnable true;
- "radialBlur" ppEffectEnable true;
- enableCamShake true;
- uiSleep 1;
- // Stop the player from moving while shocked
- player enablesimulation false;
- // StunTime seconds of effects
- for "_i" from 0 to StunTime do
- {
- "chromAberration" ppEffectAdjust [random 0.25,random 0.25,true];
- "chromAberration" ppEffectCommit 1;
- "radialBlur" ppEffectAdjust [random 0.02,random 0.02,0.15,0.15];
- "radialBlur" ppEffectCommit 1;
- addcamShake[random 5, 1, random 5];
- uiSleep 1;
- };
- player enablesimulation true;
- //Stop effects
- "chromAberration" ppEffectAdjust [0,0,true];
- "chromAberration" ppEffectCommit 5;
- "radialBlur" ppEffectAdjust [0,0,0,0];
- "radialBlur" ppEffectCommit 5;
- uiSleep 3;
- player playActionNow "PlayerStand";
- //Deactivate ppEffects
- "chromAberration" ppEffectEnable false;
- "radialBlur" ppEffectEnable false;
- resetCamShake;
- };
- deleteVehicle _x;
- LockPickingInProgress = false;
- }
- else
- {
- ["RestartWarning", "The AutoLockPicker failed to unlock the door, try again"] call ExileClient_gui_notification_event_addNotification;
- deleteVehicle _x;
- }
- };
- };
- } forEach _lockpicks;
- _unit setVariable ["lockpicks",[]];
- };
- AutoLockPicker_AttachALP =
- {
- _array = _this select 3;
- _charge = _array select 0;
- _unit = _array select 1;
- private "_class";
- for "_i" from 1 to MaterialRequired2Count step 1 do
- {
- _unit removemagazine MaterialRequired2;
- uiSleep 0.1;
- };
- _unit setUnitPos "MIDDLE";
- switch _charge do
- {
- case "Land_PortableLongRangeRadio_F":
- {
- _class = "Land_PortableLongRangeRadio_F";
- };
- };
- _nearVehicle = (nearestObjects [_unit,LockPickableItems,LockpickDistance]) select 0;
- _autolockpick = _class createVehicle [0,0,0];
- _autolockpick attachTo [_unit,[0,0,0],"leftHand"];
- _random0 = random 180;
- _random1 = random 180;
- [_autolockpick,_random0,_random1] call BIS_fnc_SetPitchBank;
- [_autolockpick,_nearVehicle,_unit,_random0,_random1] spawn
- {
- _autolockpick = _this select 0;
- _nearVehicle = _this select 1;
- _unit = _this select 2;
- _random0 = _this select 3;
- _random1 = _this select 4;
- _autolockpick attachTo [_nearVehicle, [0,0,0.2]];
- [_autolockpick,_random0,_random1] call BIS_fnc_SetPitchBank;
- _unit setVariable ["lockpicks",(_unit getVariable ["lockpicks",[]]) + [_autolockpick]];
- uiSleep 8;
- };
- uiSleep 1;
- [_unit] call AutoLockPicker_Activate;
- };
- AutoLockPicker_Actions =
- {
- private ["_unit"];
- _unit = _this select 0;
- _unit addAction ["<t color=""#0099FF"">" +"Use AutoLockPicker", AutoLockPicker_AttachALP, ["Land_PortableLongRangeRadio_F",_unit], 1, true, true, "","[MaterialRequired1,MaterialRequired2,_target] call AutoLockPicker_MatsCheck"];
- //_unit addAction ["<t color=""#3D993D"">" +"Activate AutoLockPicker", AutoLockPicker_Activate, [_unit], 1, true, true, "","[_target] call AutoLockPicker_UnitCheck"];
- };
- //removeAllActions player;
- //=======================
- [player] call AutoLockPicker_Actions;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement