Added IED handling (for the player and support for AI). Can dial an IED and it will ring before exploding.

This commit is contained in:
Garth L-H de Wet 2015-02-04 02:16:47 +02:00
parent f2ef53168b
commit 749d068d2d
15 changed files with 529 additions and 6 deletions

View File

@ -24,6 +24,12 @@ class CfgACE_Triggers {
picture = PATHTOF(Data\UI\DeadmanSwitch.paa);
requires[] = {"ACE_DeadManSwitch"};
};
class Cellphone:Command {
displayName = $STR_ACE_Explosives_cellphone_displayName;
picture = PATHTOF(Data\UI\Cellphone_UI.paa);
onPlace = QUOTE(_this call FUNC(addCellphoneIED);false);
requires[] = {"ACE_Cellphone"};
};
class PressurePlate {
displayName = $STR_ACE_Explosives_PressurePlate;
picture = PATHTOF(Data\UI\PressurePlate.paa);

View File

@ -95,4 +95,33 @@ class CfgMagazines {
};
};
};
class IEDUrbanBig_Remote_Mag: DemoCharge_Remote_Mag {
ACE_SetupObject = "ACE_Explosives_Place_IEDUrbanBig";
class ACE_Triggers {
SupportedTriggers[] = {"Command","DeadmanSwitch", "Cellphone"};
class Command {
FuseTime = 0.5;
};
class DeadmanSwitch:Command{};
class Cellphone:Command{};
};
};
class IEDLandBig_Remote_Mag: IEDUrbanBig_Remote_Mag{
ACE_SetupObject = "ACE_Explosives_Place_IEDLandBig";
};
class IEDUrbanSmall_Remote_Mag: DemoCharge_Remote_Mag {
ACE_SetupObject = "ACE_Explosives_Place_IEDUrbanSmall";
class ACE_Triggers {
SupportedTriggers[] = {"Command","DeadmanSwitch", "Cellphone"};
class Command {
FuseTime = 0.5;
};
class DeadmanSwitch:Command{};
class Cellphone:Command{};
};
};
class IEDLandSmall_Remote_Mag: IEDUrbanSmall_Remote_Mag {
ACE_SetupObject = "ACE_Explosives_Place_IEDLandSmall";
};
};

View File

@ -49,6 +49,15 @@ class CfgVehicles {
priority = 0.8;
hotkey = "F";
};
class ACE_Cellphone {
displayName = $STR_ACE_Explosives_cellphone_displayName;
condition = "('ACE_Cellphone' in (items ace_player))";
statement = "closeDialog 0;createDialog 'Rsc_ACE_PhoneInterface';";
exceptions[] = {"ACE_Interaction_isNotSwimming"};
showDisabled = 0;
icon = PATHTOF(Data\UI\Cellphone_UI.paa);
priority = 0.8;
};
};
};
};
@ -105,6 +114,27 @@ class CfgVehicles {
model = "\A3\Weapons_F\Explosives\mine_SLAM_directional";
};
// IEDs
class ACE_Explosives_Place_IEDUrbanBig:ACE_Explosives_Place {
displayName = "IED Urban Big";
model = "\A3\Weapons_F\Explosives\IED_urban_big";
};
class ACE_Explosives_Place_IEDLandBig:ACE_Explosives_Place {
displayName = "IED Land Big";
model = "\A3\Weapons_F\Explosives\IED_land_big";
};
class ACE_Explosives_Place_IEDUrbanSmall:ACE_Explosives_Place {
displayName = "IED Urban Small";
model = "\A3\Weapons_F\Explosives\IED_urban_small";
};
class ACE_Explosives_Place_IEDLandSmall:ACE_Explosives_Place {
displayName = "IED Land Small";
model = "\A3\Weapons_F\Explosives\IED_land_small";
};
class NATO_Box_Base;
class EAST_Box_Base;
class IND_Box_Base;
@ -133,6 +163,7 @@ class CfgVehicles {
MACRO_ADDITEM(ACE_M26_Clacker,6)
MACRO_ADDITEM(ACE_DefusalKit,12)
MACRO_ADDITEM(ACE_Deadmanswitch,2)
MACRO_ADDITEM(ACE_Cellphone,3)
};
};
@ -142,6 +173,7 @@ class CfgVehicles {
MACRO_ADDITEM(ACE_M26_Clacker,2)
MACRO_ADDITEM(ACE_DefusalKit,2)
MACRO_ADDITEM(ACE_Deadmanswitch,1)
MACRO_ADDITEM(ACE_Cellphone,2)
};
};
@ -151,6 +183,7 @@ class CfgVehicles {
MACRO_ADDITEM(ACE_M26_Clacker,6)
MACRO_ADDITEM(ACE_DefusalKit,12)
MACRO_ADDITEM(ACE_Deadmanswitch,6)
MACRO_ADDITEM(ACE_Cellphone,10)
};
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -4,16 +4,49 @@
#define GUI_GRID_H (0.04)
#define ST_CENTER 0x02
#define X_OFFSET 0.25
class RscText;
class RscButton;
#define X_OFFSET 0.25
class RscXSliderH;
class IGUIBack;
class RscPicture;
class RscEdit;
class Rsc_ACE_Timer_Slider:RscXSliderH{
class Rsc_ACE_CallScreen_Edit:RscEdit {
canModify = 1;
colorBackground[] = {0,0,0,1};
colorText[] = {0,0,0,1};
colorDisabled[] = {1,1,1,0.25};
colorSelection[] = {
"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.69])",
"(profilenamespace getvariable ['GUI_BCG_RGB_G',0.75])",
"(profilenamespace getvariable ['GUI_BCG_RGB_B',0.5])",
1
};
text = "";
style = "0x00 + 0x40 + 0x200";
shadow = 1;
SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 20) * 1)";
x = 0.288594 * safezoneW + safezoneX;
w = 0.0825 * safezoneW;
h = 0.044 * safezoneH;
};
class Rsc_ACE_HiddenButton:RscButton {
colorText[] = {0, 0, 0, 0};
colorDisabled[] = {0, 0, 0, 0};
colorBackground[] = {0, 0, 0, 0};
colorBackgroundDisabled[] = {0, 0, 0, 0};
colorBackgroundActive[] = {0, 0, 0, 0};
colorFocused[] = {0, 0, 0, 0};
colorShadow[] = {0, 0, 0, 0};
colorBorder[] = {0, 0, 0, 0};
w = 0.095589;
h = 0.039216;
shadow = 0;
};
class Rsc_ACE_Timer_Slider:RscXSliderH {
x = 0.4;
y = 0.2;
w = 0.3;
@ -21,8 +54,7 @@ class Rsc_ACE_Timer_Slider:RscXSliderH{
colorBackground[] = {0,0,0,0.5};
};
class RscACE_SelectTimeUI
{
class RscACE_SelectTimeUI {
idd = 8854;
movingEnable = 0;
class controls {
@ -72,3 +104,185 @@ class RscACE_SelectTimeUI
};
};
};
class Rsc_ACE_NumKeyButton: Rsc_ACE_HiddenButton{};
class Rsc_ACE_PhoneInterface {
idd = 8855;
movingEnable = 1;
onLoad = QUOTE(GVAR(IED_CurrentSpeedDial) = -1);
class controls {
class RscPicture_1200: RscPicture {
idc = 1200;
text = PATHTOF(Data\UI\Cellphone_Background.paa);
x = 0.231875 * safezoneW + safezoneX;
y = 0.104 * safezoneH + safezoneY;
w = 0.195937 * safezoneW;
h = 0.704 * safezoneH;
};
class numkey_1: Rsc_ACE_NumKeyButton {
idc = 1600;
x = 0.278281 * safezoneW + safezoneX;
y = 0.533 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "1";
action = "ctrlSetText [1400,((ctrlText 1400) + '1')];";
};
class numkey_2: Rsc_ACE_NumKeyButton {
idc = 1601;
x = 0.314375 * safezoneW + safezoneX;
y = 0.533 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "2";
action = "ctrlSetText [1400,((ctrlText 1400) + '2')];";
};
class numkey_3: Rsc_ACE_NumKeyButton {
idc = 1602;
x = 0.350469 * safezoneW + safezoneX;
y = 0.533 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "3";
action = "ctrlSetText [1400,((ctrlText 1400) + '3')];";
};
class numkey_4: Rsc_ACE_NumKeyButton {
idc = 1603;
x = 0.278281 * safezoneW + safezoneX;
y = 0.577 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "4";
action = "ctrlSetText [1400,((ctrlText 1400) + '4')];";
};
class numkey_5: Rsc_ACE_NumKeyButton {
idc = 1604;
x = 0.314375 * safezoneW + safezoneX;
y = 0.577 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "5";
action = "ctrlSetText [1400,((ctrlText 1400) + '5')];";
};
class numkey_6: Rsc_ACE_NumKeyButton {
idc = 1605;
x = 0.350469 * safezoneW + safezoneX;
y = 0.577 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "6";
action = "ctrlSetText [1400,((ctrlText 1400) + '6')];";
};
class numkey_7: Rsc_ACE_NumKeyButton {
idc = 1606;
x = 0.278281 * safezoneW + safezoneX;
y = 0.621 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "7";
action = "ctrlSetText [1400,((ctrlText 1400) + '7')];";
};
class numkey_8: Rsc_ACE_NumKeyButton {
idc = 1607;
x = 0.314375 * safezoneW + safezoneX;
y = 0.621 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "8";
action = "ctrlSetText [1400,((ctrlText 1400) + '8')];";
};
class numkey_9: Rsc_ACE_NumKeyButton {
idc = 1608;
x = 0.350469 * safezoneW + safezoneX;
y = 0.621 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "9";
action = "ctrlSetText [1400,((ctrlText 1400) + '9')];";
};
class numkey_0: Rsc_ACE_NumKeyButton {
idc = 1609;
x = 0.314375 * safezoneW + safezoneX;
y = 0.676 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "0";
action = "ctrlSetText [1400,((ctrlText 1400) + '0')];";
};
class speedDialAdd: Rsc_ACE_NumKeyButton {
idc = 1610;
x = 0.278281 * safezoneW + safezoneX;
y = 0.676 * safezoneH + safezoneY;
w = 0.0309375 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "$STR_ACE_Explosives_Phone_AddToSpeedDial";
action = QUOTE([ARR_2(ctrlText 1401,ctrlText 1400)] call FUNC(addToSpeedDial););
};
class clear: Rsc_ACE_HiddenButton {
idc = 1610;
x = 0.278281 * safezoneW + safezoneX;
y = 0.445 * safezoneH + safezoneY;
w = 0.020625 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "$STR_ACE_Explosives_Clear";
action = QUOTE(ctrlSetText [ARR_2(1400,'')];[ctrlText 1401] call FUNC(removeFromSpeedDial);ctrlSetText [ARR_2(1401,'')];);
};
class dial: Rsc_ACE_HiddenButton {
idc = 1611;
x = 0.309219 * safezoneW + safezoneX;
y = 0.445 * safezoneH + safezoneY;
w = 0.04125 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "$STR_ACE_Explosives_Phone_Dial";
action = QUOTE([ARR_2(ace_player,ctrlText 1400)] call FUNC(dialPhone););
};
class up: Rsc_ACE_HiddenButton {
idc = 1612;
x = 0.360781 * safezoneW + safezoneX;
y = 0.445 * safezoneH + safezoneY;
w = 0.020625 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "$STR_ACE_Explosives_Phone_Up";
action = QUOTE([true] call FUNC(setSpeedDial));
};
class down: Rsc_ACE_HiddenButton {
idc = 1613;
x = 0.345312 * safezoneW + safezoneX;
y = 0.485 * safezoneH + safezoneY;
w = 0.020625 * safezoneW;
h = 0.033 * safezoneH;
tooltip = "$STR_ACE_Explosives_Phone_Down";
action = QUOTE([false] call FUNC(setSpeedDial));
};
class speedDial_Text: RscText {
idc = 1405;
y = 0.302 * safezoneH + safezoneY;
SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 22) * 1)";
x = 0.288594 * safezoneW + safezoneX;
w = 0.0825 * safezoneW;
h = 0.044 * safezoneH;
text = "Name";
};
class speedDial_edit: Rsc_ACE_CallScreen_Edit {
idc = 1401;
y = 0.302 * safezoneH + safezoneY;
x = 0.318 * safezoneW + safezoneX;
w = 0.1;
};
class numberEdit_Text: RscText {
idc = 1406;
y = 0.348 * safezoneH + safezoneY;
SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 22) * 1)";
x = 0.288594 * safezoneW + safezoneX;
w = 0.0825 * safezoneW;
h = 0.044 * safezoneH;
text = "#";
};
class number_edit: Rsc_ACE_CallScreen_Edit {
canModify = 0;
idc = 1400;
y = 0.348 * safezoneH + safezoneY;
x = 0.3 * safezoneW + safezoneX;
};
};
};

View File

@ -18,6 +18,7 @@ if !(hasInterface) exitWith {};
GVAR(PlacedCount) = 0;
GVAR(Setup) = objNull;
GVAR(pfeh_running) = false;
GVAR(CurrentSpeedDial) = 0;
[{(_this select 0) call FUNC(handleScrollWheel);}] call EFUNC(Common,addScrollWheelEventHandler);
player addEventHandler ["Killed", {

View File

@ -17,11 +17,14 @@
ADDON = false;
PREP(addCellphoneIED);
PREP(addClacker);
PREP(addToSpeedDial);
PREP(canDefuse);
PREP(canDetonate);
PREP(defuseExplosive);
PREP(detonateExplosive);
PREP(dialPhone);
PREP(handleScrollWheel);
@ -30,6 +33,7 @@ PREP(hasPlacedExplosives);
PREP(getDetonators);
PREP(getPlacedExplosives);
PREP(getSpeedDialExplosive);
PREP(openDetonateUI);
PREP(openPlaceUI);
@ -41,10 +45,12 @@ PREP(place_Approve);
PREP(place_Cancel);
PREP(placeExplosive);
PREP(removeFromSpeedDial);
PREP(selectTrigger);
PREP(setupExplosive);
PREP(setPosition);
PREP(setSpeedDial);
PREP(startDefuse);
PREP(startTimer);
PREP(triggerType);

View File

@ -0,0 +1,47 @@
/*
* Author: Garth 'L-H' de Wet
* Adds an IED to the cellphone list
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Explosive <OBJECT>
* 2: Magazine classname <STRING>
* 3: Extra variables <ARRAY>
*
* Return Value:
* None
*
* Example:
* Handled by PlaceExplosive.
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_4_PVT(_this,_unit,_explosive,_magazineClass,_extra);
// Config is the last item in the list of passed in items.
_config = (_this select 3) select (count (_this select 3) - 1);
_requiredItems = getArray(_config >> "requires");
_hasRequired = true;
_detonators = [_unit] call FUNC(getDetonators);
{
if !(_x in _detonators) exitWith{
_hasRequired = false;
};
} count _requiredItems;
private ["_code", "_count"];
_code = str(round (random 9999));
_count = 4 - count (toArray _code);
while {_count > 0} do {
_code = "0" + _code;
_count = _count - 1;
};
if (isNil QGVAR(CellphoneIEDs)) then {
GVAR(CellphoneIEDs) = [];
};
_count = GVAR(CellphoneIEDs) pushBack [_explosive,_code];
_count = _count + 1;
publicVariable QGVAR(CellphoneIEDs);
_unit sideChat format ["IED %1 code: %2", _count,_code];
if !(_hasRequired) exitWith {};
[format ["IED %1", _count],_code] call FUNC(addToSpeedDial);

View File

@ -0,0 +1,37 @@
/*
* Author: Garth 'L-H' de Wet
* Sets the speed dial for the UI.
*
* Arguments:
* 0: Name of speed dial <STRING>
* 1: Code to add to speed dial <STRING>
*
* Return Value:
* None
*
* Example:
* ["My Speed Dial","2131"] call ACE_explosives_fnc_addToSpeedDial;
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_speedDial", "_found"];
_speedDial = ace_player getVariable [QGVAR(SpeedDial), []];
_found = false;
EXPLODE_2_PVT(_this,_name,_code);
if ((_code) == "") ExitWith {
[_name] call FUNC(removeFromSpeedDial);
};
{
if ((_x select 0) == _name) exitWith {
_speedDial set [_foreachindex, _this];
_found = true;
};
} foreach _speedDial;
if (!_found) then {
_speedDial pushBack _this;
};
ace_player setVariable [QGVAR(SpeedDial), _speedDial];

View File

@ -0,0 +1,68 @@
/*
* Author: Garth 'L-H' de Wet
* Dials the number passed and detonates the explosive.
*
* Arguments:
* 0: Unit to do dialing <OBJECT>
* 1: Code to dial <STRING>
*
* Return Value:
* None
*
* Example:
* [ace_player,"2131"] call ACE_explosives_fnc_dialPhone;
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_arr", "_ran", "_i","_speedDial"];
EXPLODE_2_PVT(_this,_unit,_code);
if (_unit getVariable [QGVAR(Dialing),false]) exitWith {};
if !(alive _unit) exitWith {};
_unit setVariable [QGVAR(Dialing), true, true];
_ran = (ceil(random 8)) + 1;
_arr = [];
for [{_i=0}, {_i<_ran}, {_i=_i+1}] do {
_arr = _arr + ['.','..','...',''];
};
if (_unit == ace_player) then {
ctrlSetText [1400,"Calling"];
[{
EXPLODE_4_PVT(_this select 0,_unit,_i,_arr,_code);
if ((_i mod 4) == 0) then {
playSound3D [QUOTE(PATHTOF_R(Data\Audio\DialTone.wss)), objNull, false, (_unit ModelToWorld [0,0.2,2]), 15,1,2.5];
};
ctrlSetText [1400,format["Calling%1",_arr select (_i - 4)]];
if (_i >= (count _arr + 2)) then {
[_this select 1] call CALLSTACK(cba_fnc_removePerFrameHandler);
private "_explosive";
_explosive = [_unit, _code] call FUNC(getSpeedDialExplosive);
if (!isNull (_explosive)) then {
[_unit, -1, [_explosive, 1]] call FUNC(detonateExplosive);
};
_unit setVariable [QGVAR(Dialing), false, true];
if (_unit == ace_player) then {
ctrlSetText [1400,"Call Ended!"];
};
};
if (_i == (count _arr)) then {
private "_explosive";
_explosive = [_unit, _code] call FUNC(getSpeedDialExplosive);
if (!isNull (_explosive)) then {
playSound3D [QUOTE(PATHTOF_R(Data\Audio\Cellphone_Ring.wss)),objNull, false, getPosATL _explosive,3.16228,1,75];
};
};
(_this select 0) set [1, _i + 1];
}, 0.25, [_unit,4,_arr,_code]] call CALLSTACK(CBA_fnc_addPerFrameHandler);
} else {
private ["_explosive"];
_explosive = [_unit, _code] call FUNC(getSpeedDialExplosive);
if (!isNull (_explosive)) then {
[{
playSound3D [QUOTE(PATHTOF_R(Data\Audio\Cellphone_Ring.wss)),objNull, false, getPosATL (_this select 1),3.16228,1,75];
(_this select 0) setVariable [QGVAR(Dialing), false, true];
}, [_unit,_explosive], 0.25 * (count _arr - 4), 0] call EFUNC(common,waitAndExecute);
[_explosive,0.25 * (count _arr - 1)] call FUNC(startTimer);
};
};

View File

@ -0,0 +1,28 @@
/*
* Author: Garth 'L-H' de Wet
* Gets the explosive object or objNull from the speed dial entry.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Speed dial entry <STRING>
*
* Return Value:
* Associated explosive (or ObjNull) <OBJECT>
*
* Example:
* [ace_player, "2113"] call ace_explosives_fnc_getSpeedDialExplosive;
*
* Public: Yes
*/
#include "script_component.hpp"
EXPLODE_2_PVT(_this,_unit,_code);
private ["_explosive"];
if (isNil QGVAR(CellphoneIEDs)) exitWith {objNull};
_explosive = objNull;
{
if ((_x select 1) == _code) exitWith {
_explosive = _x select 0;
};
false
} count GVAR(CellphoneIEDs);
_explosive

View File

@ -0,0 +1,26 @@
/*
* Author: Garth 'L-H' de Wet
* Removes the specified speed dial from unit's speed dial.
*
* Arguments:
* 0: Speed dial name <STRING>
*
* Return Value:
* None
*
* Example:
* ["IED 1"] call ACE_explosives_fnc_removeFromSpeedDial;
*
* Public: Yes
*/
#include "script_component.hpp"
private "_speedDial";
_speedDial = ace_player getVariable [QGVAR(SpeedDial), []];
if (count _speedDial == 0) exitWith {};
{
if ((_x select 0) == (_this select 0)) exitWith {
_speedDial set [_foreachIndex, "x"];
_speedDial = _speedDial - ["x"];
ace_player setVariable [QGVAR(SpeedDial),_speedDial];
};
} foreach _speedDial;

View File

@ -0,0 +1,28 @@
/*
* Author: Garth 'L-H' de Wet
* Sets the speed dial for the UI.
*
* Arguments:
* 0: Whether to increase or decrease speed dial index <BOOL>
*
* Return Value:
* None
*
* Example:
* [true] call ACE_explosives_fnc_setSpeedDial; // increase
* [false] call ACE_explosives_fnc_setSpeedDial; // decrease
*
* Public: No
*/
#include "script_component.hpp"
private ["_speedDial", "_amount"];
_speedDial = ace_player getVariable [QGVAR(SpeedDial), []];
if (count _speedDial == 0) exitWith {};
_amount = if((_this select 0))then{1}else{-1};
GVAR(CurrentSpeedDial) = GVAR(CurrentSpeedDial) + _amount;
GVAR(CurrentSpeedDial) = if(GVAR(CurrentSpeedDial) < 0)then{(count _speedDial)-1}else{GVAR(CurrentSpeedDial)};
GVAR(CurrentSpeedDial) = if(GVAR(CurrentSpeedDial) >= (count _speedDial))then{0}else{GVAR(CurrentSpeedDial)};
ctrlSetText [1400,(_speedDial select GVAR(CurrentSpeedDial)) select 1];
ctrlSetText [1401,(_speedDial select GVAR(CurrentSpeedDial)) select 0];