Jump to content
Sign in to follow this  
igneous01

Simple Bomb defusal with keypad

Recommended Posts

2011081300001.th.jpg

here is an example mission of a very basic bomb defusal script using a keypad.

The defusal code is a randomly generated array of numbers (6 digits, but you can extend this if you want to make it harder), has a custom gui for the keypad to make it look pretty. # is to enter the code, and * is to abort (escape the menu)

In the example mission, the suitcase will give you the action to defuse the bomb, you have 60 seconds until it detonates. Once the action is selected, you will have a brief moment to see the code, and afterwards the keypad will show up and allow you to input the numbers exactly as they were ordered on the screen. If you provide the wrong code, a message will show up saying the bomb is armed in 5 seconds (which you will inevitably die from).

Its fairly straightforward scripting, with the only thing being a hassle was the dialog (my first dialog ever yay!) - hasnt been tested in MP, just a little something for mission makers to experiment with and customize it themselves for their mission purposes.

feel free to tweak the scripts to your needs, or make a better version (im too lazy)

link: http://www.4shared.com/file/vcrrBMgC/Keypad_Defuse_Example.html?

Share this post


Link to post
Share on other sites

nice, grats on figuring out the dialogs haha. hopefully someday i'll grasp it (my first attempt a while back wasn't so successful). will def try this out, looks cool, thanks!

Share this post


Link to post
Share on other sites

I havnt gotten that far into displaying the numbers you put in on a pad, maybe someone else knows how to get it working properly?

I will spend some more time on it to see if i can get a simple number display working

---------- Post added at 04:54 PM ---------- Previous post was at 03:46 PM ----------

edit*

ok so after a bit more reading I managed to get numbers to display on the keypad (though they have brackets surrounding them separated by commas)

it now looks like this when you put in numbers:

2011081300002.th.jpg

here is the description.ext, just copy and replace as new description.ext and it should work:

// Control types

#define CT_STATIC 0

#define CT_BUTTON 1

#define CT_EDIT 2

#define CT_SLIDER 3

#define CT_COMBO 4

#define CT_LISTBOX 5

#define CT_TOOLBOX 6

#define CT_CHECKBOXES 7

#define CT_PROGRESS 8

#define CT_HTML 9

#define CT_STATIC_SKEW 10

#define CT_ACTIVETEXT 11

#define CT_TREE 12

#define CT_STRUCTURED_TEXT 13

#define CT_CONTEXT_MENU 14

#define CT_CONTROLS_GROUP 15

#define CT_SHORTCUT_BUTTON 16 // Arma 2 - textured button

#define CT_XKEYDESC 40

#define CT_XBUTTON 41

#define CT_XLISTBOX 42

#define CT_XSLIDER 43

#define CT_XCOMBO 44

#define CT_ANIMATED_TEXTURE 45

#define CT_OBJECT 80

#define CT_OBJECT_ZOOM 81

#define CT_OBJECT_CONTAINER 82

#define CT_OBJECT_CONT_ANIM 83

#define CT_LINEBREAK 98

#define CT_USER 99

#define CT_MAP 100

#define CT_MAP_MAIN 101

#define CT_List_N_Box 102 // Arma 2 - N columns list box

// Static styles

#define ST_POS 0x0F

#define ST_HPOS 0x03

#define ST_VPOS 0x0C

#define ST_LEFT 0x00

#define ST_RIGHT 0x01

#define ST_CENTER 0x02

#define ST_DOWN 0x04

#define ST_UP 0x08

#define ST_VCENTER 0x0c

#define ST_TYPE 0xF0

#define ST_SINGLE 0

#define ST_MULTI 16

#define ST_TITLE_BAR 32

#define ST_PICTURE 48

#define ST_FRAME 64

#define ST_BACKGROUND 80

#define ST_GROUP_BOX 96

#define ST_GROUP_BOX2 112

#define ST_HUD_BACKGROUND 128

#define ST_TILE_PICTURE 144

#define ST_WITH_RECT 160

#define ST_LINE 176

#define ST_SHADOW 0x100

#define ST_NO_RECT 0x200 // this style works for CT_STATIC in conjunction with ST_MULTI

#define ST_KEEP_ASPECT_RATIO 0x800

#define ST_TITLE ST_TITLE_BAR + ST_CENTER

// Slider styles

#define SL_DIR 0x400

#define SL_VERT 0

#define SL_HORZ 0x400

#define SL_TEXTURES 0x10

// Listbox styles

#define LB_TEXTURES 0x10

#define LB_MULTI 0x20

#define FontM "Zeppelin32"

class KeypadDefuse {

idd = -1;

movingEnable = false;

controlsBackground[] = {};

controls[] = {

"B1",

"B2",

"B3",

"B4",

"B5",

"B6",

"B7",

"B8",

"B9",

"B0",

"BEnter",

"BAbort",

"KeypadImage",

"NumberDisplay"

};

objects[] = {};

class B1 {

idc = -1;

type = 1;

style = 2;

moving = false;

x = 0.39;

y = 0.39;

h = 0.08;

w = 0.06;

font = "Zeppelin32";

sizeEx = 0.05;

// action uses script commands to close dialog and display a hint

action = "CODEINPUT set [count CODEINPUT, 1]; ctrlSetText [1099, str CODEINPUT];";

text = "";

default = false;

colorText[] = {0,0,0,1}; // white

colorFocused[] = {0.1,0.1,0.1,0.1}; // green

colorShadow[] = {0,0,0,0}; // darkgrey

colorBorder[] = {0.5,0.5,0.5,0}; // grey

colorBackground[] = {0.7,0.7,0.7,1};

colorBackgroundActive[] = {0.1,0.1,0.1,0.3}; // green

colorDisabled[] = {1,0,0,1}; // red

colorBackgroundDisabled[] = {0.5,0.5,0.5,0}; // grey

borderSize = 0.015;

offsetX = 0.005;

offsetY = 0.005;

offsetPressedX = 0.002;

offsetPressedY = 0.002;

soundEnter[] = {"",0,1}; // NoSound

soundPush[] = {"",0,1}; // NoSound

soundClick[] = {"",0,1}; // NoSound

soundEscape[] = {"",0,1}; // NoSound

};

class B2 : B1 {

x = 0.47;

text = "";

action = "CODEINPUT set [count CODEINPUT, 2]; ctrlSetText [1099, str CODEINPUT];"

};

class B3 : B1 {

x = 0.55;

text = "";

action = "CODEINPUT set [count CODEINPUT, 3]; ctrlSetText [1099, str CODEINPUT];";

};

class B4 : B1 {

y = 0.50;

text = "";

action = "CODEINPUT set [count CODEINPUT, 4]; ctrlSetText [1099, str CODEINPUT];";

};

class B5 : B4 {

x = 0.47;

text = "";

action = "CODEINPUT set [count CODEINPUT, 5]; ctrlSetText [1099, str CODEINPUT];";

};

class B6 : B4 {

x = 0.55;

text = "";

action = "CODEINPUT set [count CODEINPUT, 6]; ctrlSetText [1099, str CODEINPUT];";

};

class B7 : B1 {

y = 0.61;

text = "";

action = "CODEINPUT set [count CODEINPUT, 7]; ctrlSetText [1099, str CODEINPUT];";

};

class B8 : B7 {

x = 0.47;

text = "";

action = "CODEINPUT set [count CODEINPUT, 8]; ctrlSetText [1099, str CODEINPUT];";

};

class B9 : B7 {

x = 0.55;

text = "";

action = "CODEINPUT set [count CODEINPUT, 9]; ctrlSetText [1099, str CODEINPUT];";

};

class B0 : B8 {

y = 0.72;

text = "";

action = "CODEINPUT set [count CODEINPUT, 0]; ctrlSetText [1099, str CODEINPUT];";

};

class BEnter : B9 {

y = 0.72;

text = "";

action = "closeDialog 0; nul = [code, CODEINPUT] execVM 'CodeCompare.sqf';";

};

class BAbort : B7 {

y = 0.72;

text = "";

action = "closeDialog 0; CODE = []; CODEINPUT = [];";

};

class KeypadImage {

idc = -1;

type = CT_STATIC;

style = ST_PICTURE;

colorText[] = { };

colorBackground[] = { };

font = "Zeppelin32";

sizeEx = 0.023;

x = 0.35; y = 0.2;

w = 0.3; h = 0.8;

text = "pics\keypad.paa";

};

class NumberDisplay {

idc = 1099;

type = CT_STATIC ; // defined constant

style = ST_LEFT; // defined constant

colorText[] = { 1, 0, 0, 1 };

colorBackground[] = { 1, 1, 1, 0 };

font = FontM; // defined constant

sizeEx = 0.072;

x = 0.38; y = 0.24;

w = 0.23; h = 0.1;

text = "";

};

};

Share this post


Link to post
Share on other sites

If you don't want brackets and commas then this might do it (where X is the number):

action = "CODEINPUT set [count CODEINPUT, 7]; ctrlSetText [1099, (ctrlText 1099) + str X];";

Share this post


Link to post
Share on other sites

Nice work, downloading.

I am working on a multiple missions MP mission, and have been looking at having some form of code be input by players to skip to a previous gained point upon a restart etc.

This will help alot in getting that working.

Cheers

Share this post


Link to post
Share on other sites

How can I make this work with the GLT MOAB.

I changed in the Timer.sqf and the Compare to the Classname from the default to:

"1Rnd_GBU43_GLT"

nothing happens at Time= -1

Share this post


Link to post
Share on other sites
How can I make this work with the GLT MOAB.

I changed in the Timer.sqf and the Compare to the Classname from the default to:

"1Rnd_GBU43_GLT"

nothing happens at Time= -1

is that the magazine classname or the ammo classname?

createVehicle only works for cfgAmmo types, it doesnt work for magazines.

Share this post


Link to post
Share on other sites

It would be nice if there was a delete button, since when you quit it the code still stays there, also it seems the that numbers disappear on the screen then reappear randomly.

Very nice script, but it has many bugs which hinders its true capability! :D

-Bigshot

Share this post


Link to post
Share on other sites
It would be nice if there was a delete button, since when you quit it the code still stays there, also it seems the that numbers disappear on the screen then reappear randomly.

Very nice script, but it has many bugs which hinders its true capability! :D

-Bigshot

interesting, ive never had the numbers reappear when i exit the keypad, it always turns blank again and i can re input the numbers.

perhaps its not working in MP as intended. But as far as im aware, closing a dialog completely resets the text of that dialog (???) as it is being initialized again with its original settings (i dont know if this is true, my guess as to how dialogs operate)

I will have a look at those issues you experienced.

@foxhound

thanks for posting, appreciated ^^

Share this post


Link to post
Share on other sites

Yeah, I was in a test server that I was hosting so that could definitely be causing it!

Hope you find a fix! :D

-Bigshot

Share this post


Link to post
Share on other sites

I could use a version where you get the code one place, (you need to find intel on it somewhere) and not nessesarely a random one, could be custom made with the mission if it had to and then find the bomb and defuse it with the code you where given someplace else. :sly:

Share this post


Link to post
Share on other sites

I would love to use that in a different way.

Let's say i have a mission where there's an A-10. When someone tries to get in as pilot your keypad comes for the player to put the code. If code is correct, player can get in as pilot if not, vehicle will be locked.

Can your script be modified for that?

Share this post


Link to post
Share on other sites
I would love to use that in a different way.

Let's say i have a mission where there's an A-10. When someone tries to get in as pilot your keypad comes for the player to put the code. If code is correct, player can get in as pilot if not, vehicle will be locked.

Can your script be modified for that?

sure, it certainly is possible, however I have no way of making this MP compatible because I have no server to test with other people with atm.

But for example, changing the DefuseAction.sqf to not generate a random array (CODE) and instead declaring this inside the init.sqf or description.ext (using constants) you could use the codecompare script to check if your code is right, and then unlock the vehicle as needed.

Share this post


Link to post
Share on other sites

Think you could tweak it so that it changes the hint format to display Hours, Minutes and Seconds?

I'm making a misson with a 2hr timelimit to find a bomb across Takistan and it would be quite useful.

Was looking at MaxTimer script to see about incorporating this into yours, but it seems a little over my head...

http://www.armaholic.com/page.php?id=14974

Also, what would the exact scripting be if I wanted to be an exact code...

for instance I want the code to be 123456

Would I just change in Defuse Action

CODE = [(round(random 9)), (round(random 9)), (round(random 9)), (round(random 9)), (round(random 9)), (round(random 9))];

to

CODE = [1, 2,...etc]

?

Share this post


Link to post
Share on other sites

@Blackfox34

It looks like that change you made would work properly.

Have you even tried it yet?

Share this post


Link to post
Share on other sites

yes that works. I just got to test it.

---------- Post added at 10:38 AM ---------- Previous post was at 09:23 AM ----------

next question, think anyone could script me a MP parameter that would allow you to change the time.

Share this post


Link to post
Share on other sites

You know you could just use the CodePad script for ArmA that I made (based on Blanco's for OFP) some time ago, right? Supports multiple codepads, with their own codes (that can be added as 'known' and displayed on a piece of paper), and can allow any kind of script to be run either when adding the right code or the wrong. Also includes sounds.

Not to hijack anyone's thread. So sorry for that.

Regards,

Wolfrug

Share this post


Link to post
Share on other sites

Any help with getting this to work on a dedi would be most helpful, it all works great when I host and I go upto the device, but if anyone else goes up to the device they get the Defuse action but and it seems to work but they never get the timer , nor any explosion etc..

Is it because it is run from the addaction so it is local to who activates it ?

Add action onto Laptop

MyCivAction=this addAction ["Phone HQ","intel.sqf"]

Intel.sqf

//////////////IED misssion from FOB///////////

deletevehicle Cheget; // delete just in case it is still on map 
["remove_action", []] call CBA_fnc_globalEvent; // remove the add action from the Laptop


[nil,nil,rHINT,"We have some Intel on another bomb location, you are to try and defuse the Bomb and stop collateral damage"] call RE;
waituntil { !isNil "BIS_fnc_init" }; 
//[nil,nil,rPlaysound,"dropbox"] call RE;


////get a random Marker
_random = floor(random 5);
_spawnspot = ["boom1", "boom2", "boom3","boom4","boom5","boom6","boom7","boom8","boom9","convoywp10_a"] select _random; 
Cheget = "Suitcase" createVehicle getmarkerpos _spawnspot;
//add the defuse addation on the case
Cheget setVehicleInit "defuseaction = this addaction [""Defuse"", ""DefuseAction.sqf""]";
processInitCommands;


//Create marker location
_marker = createMarker[format["marker%1",Cheget],getmarkerpos _spawnspot ];
_marker setMarkerShape "ICON";
_marker setMarkerType "FLAG";
_marker setMarkerText "Bomb Location";
_marker setMarkerSize [.50, .50];

///create trigger to activate timer
_triggeram1 = createTrigger["EmptyDetector",[getmarkerpos _spawnspot select 0,getmarkerpos _spawnspot select 1,0]];
_triggeram1 setTriggerArea [30,30,0,false];
_triggeram1 setTriggerActivation ["WEST","PRESENT",true];
_triggeram1 setTriggerTimeout [5,5,5,true];
_triggeram1 setTriggerStatements ["this", "BombTimerScript = [this, 25] execVM 'BombTimer.sqf';",""];


waitUntil{!(isNil "BIS_fnc_init")};
waitUntil{!(isNil "BIS_MPF_InitDone")};
////Create Enemy//////////////////
_dis = 80;
_ang = random 360;
_dx = sin(_ang)*_dis;
_dy = cos(_ang)*_dis;
_positionToSpawnIn = [((getpos Cheget) select 0) + _dx, ((getpos Cheget) select 1) + _dy, 0];
_armourgrp1 = [_positionToSpawnIn, east,["Offroad_DSHKM_INS", "BTR90","BTR90","BTR90"],[[-3,-3], [3,3], [0,0], [3,-3]]]  call BIS_fnc_spawnGroup;
Sleep .5;
[_armourgrp1, getPos cheget, 150] call bis_fnc_taskPatrol;

// How many enemies in each group.
_enemyCount = 10 ;
// Spawn the first group and have them patrol
_grprIED = [getPos Cheget, east, _enemyCount] call BIS_fnc_spawnGroup;
[_grprIED, getPos cheget, 150] call bis_fnc_taskPatrol;


waituntil{!alive Cheget};

["add_action", []] call CBA_fnc_globalEvent; /// add action back to laptop

[nil,nil,rHINT,"Well done come back for more intel when you have time "] call RE;

///Clean Up/////////////////////
Deletemarker _marker;
deletevehicle _triggeram1;
deletevehicle Cheget;
_grprIED spawn {
_units = units _this;
waitUntil {sleep 300; ({alive _x} count _units) == 0};
{deleteVehicle _x} foreach _units;
deleteGroup _this;

{deletevehicle _x;} foreach crew _armourgrp1;
deletevehicle _armourgrp1;

Share this post


Link to post
Share on other sites

I was able to get it to work on our dedicated server, however, all my texts are local to the player, but the explosions and such were not.

To test whether or not the bomb script would crash the server, I tested it with about 6 or so players and it work perfectly. My script is basically the same but I changed it to incorporate the MOAB and 12 of them go off across the map during the fail scenario.

I set my misson up that you must gather intel from objects and it gives you text in the form of Global chat, instead of hints because I found that the hints were difficult to see with the hintSilent timer, which every player could see on the server.

Only the player who activated the action could see the globalChat and the BombKeypad, however the explosion was seen by me (who did not activate it) and the destruction was for everyone. I have another IED script in the misson too and that worked as well, similar to yours but without a defusal script.

My editied bombTimer.sqf

private ["_bomb", "_timer"];
_bomb = _this select 0;
_timer = _this select 1;

waitUntil {_timer = _timer - 1; sleep 1; hintsilent format ["Time: %1", _timer]; _timer < 0 || DEFUSED};

if (_timer < 0) then {
_blast = "GLT_GBU43" createVehicle (position bomb1);"GLT_GBU43" createVehicle (position bomb2);"GLT_GBU43" createVehicle (position bomb3);"GLT_GBU43" createVehicle (position bomb4);"GLT_GBU43" createVehicle (position bomb5);"GLT_GBU43" createVehicle (position bomb6);"GLT_GBU43" createVehicle (position bomb7);"GLT_GBU43" createVehicle (position bomb8);"GLT_GBU43" createVehicle (position bomb9);"GLT_GBU43" createVehicle (position bomb10);"GLT_GBU43" createVehicle (position bomb11);"GLT_GBU43" createVehicle (position bomb12);
Cheget removeaction defuseaction;
};

Here is my IED script which is verysimilar to some aspects of the others

ied removeAction action4;
titletext ["BOMB ACTIVATED. Destruction in 10...9", "PLAIN DOWN"];
sleep 10;
_explosion = "M_Hellfire_AT" createVehicle (position ied);

where Action4= ied addAction ["Boot Laptop","ied.sqf"];

You could incorprate this the same way though, by just using the DefuseAction.sqf or whatever and have it work through similar.

---------- Post added at 08:07 PM ---------- Previous post was at 08:00 PM ----------

Wait I think I see, I'm not very good at scripting, but at second glance it seems that you are having issues with the bomb and the hint timer showing up. It also seems like you are trying to make the bomb spawn in a random spot, attached to the marker, and the timer also. I cannot tell you if your script is flawed persay, but I can give you how I did the same thing, randomizing the bomb location.

Placed Cheget or the "bomb" on the map. In init.sqf execVM "randomspawn.sqf";

if (!isServer) exitWith {};

private ["_pos1","_pos2","_pos3","_posarray","_random_object_pos"];

_pos1 = [5021.61,6895.65,0.240967];
_pos2 = [25.5294,7060.59,0.00158691];
_pos3 = [10745.3,8692.2,0.00143433];


_posarray = [_pos1,_pos2,_pos3];

_random_object_pos = (_posarray select (floor(random(count _posarray))));

cheget setpos _random_object_pos;




/// You now have a random object postion just use the variable: _random_object_pos

where the numbers are the X,Y,Z coordinate. This makes it so you can accurately place bombs in buildings, pretty much anywhere. You can also control probability by using the same location or grids to make it have a higher chance of one location over the other. You can add more than 3 or have less than 3 positions. While it's not totally random to the maker, its pretty much random to the player unless you play it over and over.

I used intel through the map to create markers to these locations or search areas here is an example of an intel script through addaction

deletevehicle map;
Chat globalChat "Seems as if the Al-Qaeda are hiding something in the Feruz Abad mines. Head to the map marker.";

_markerstr = createMarker["Mine",[5043.39,6885,0.00143433]];
_markerstr setMarkerShape "ICON";
"Mine" setMarkerType "mil_warning";
"Mine" setMarkerColor "ColorRed";
"Mine" setMarkerText "Mine"; 

map removeAction action2;

I used a gamelogic as Chat to say the texts, however, this is local. Now you can just activate the bomb and timer from the beginning of the misson like the example and it should all work in MP except for intel hints etc..where are local to the player. They can be made to MP, but I don't know how/haven't looked to hard into it.

hope some of this helped you.

Share this post


Link to post
Share on other sites

Thanks,

Sorry I might not have been to clear.

Whoever uses the addaction to generate the Intel mission , it looks like they are the only one who can see the timer once in range no one elses, also it seems that they are the only one who can defuse or trigger the IED, once it blows eveyone can see the explosion fione , but if someone goes upto the device and tries to defuse it dose not blow.

So it looks like only the person who uses the addaction seems to see the Timer and activate the IED.

?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×