Jump to content
Sign in to follow this  
Dramboi

progress bar for defusing bombs

Recommended Posts

I wonder if anyone here knows how for make a progress bar that execute when a person tries to defuse bomb or wrench an electrical system

thanks

Dramboi

Share this post


Link to post
Share on other sites

There´s certainly a different way, but I would make 3 or 4 jpgs of the evolving progress bar and show them as a ressource via script and a timed delay between the pictures to generate the look of a building bar.

Share this post


Link to post
Share on other sites

The simplest way may be to have a bar in the hintbox that changes color. It doesnt look very fancy but its good enough for me.

Taking this from a script in my mission and editing it a bit:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (player distance (_this select 0) > 1) exitWith {player sidechat "I have to get closer..."};

if (defusing) exitWith {player sidechat "I´m already defusing..."};

defusing = true;

player playMove "ainvpknlmstpslaywrfldnon";

waitUntil {(animationState player == "ainvpknlmstpslaywrfldnon") or !alive player};

defuseInfoT = "<br/><br/><t color='#5599FF' align = 'center'>Defusing bomb...<br/>[====================]</t>";

_i = 0;

_j = 0;

while {(_i<20) and (alive player)} do {

sleep 0.5;

defuseInfoT = "<br/><br/><t align = 'center'><t color='#5599FF'>Defusing bomb...</t><br/>";

defuseInfoT = defuseInfoT+"<t color='#5599FF'>[</t>";

while {_j <= _i} do {

defuseInfoT = defuseInfoT+"<t color='#00FF00'>=</t>";

_j = _j + 1;

};

_j = 0;

while {_j + _i < 19} do {

defuseInfoT = defuseInfoT + "<t color='#5599FF'>=</t>";

_j = _j + 1;

};

defuseInfoT = defuseInfoT + "<t color='#5599FF'>]</t></t>";

_i = _i + 1;

_j = 0;

if (!alive player) exitWith {defusing=false};

if (animationState player != "ainvpknlmstpslaywrfldnon") exitWith {player sidechat "Defuse aborted";defusing = false};

};

defuseInfoT = "<br/><br/><t align = 'center'><t color='#5599FF'>Done!<br/>[</t><t color='#00FF00'>====================</t><t color='#5599FF'>]</t></t>";

sleep 2;

defuseInfoT = "";

Use this to show the hint:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint parseText defuseInfoT

If you dont have any other hint looped you can probaly just add that line to inside the previous code.

I havent tested this to make sure it actually works but the code is ripped from a working script. Hopefully I have not messed up the conversion  smile_o.gif

Share this post


Link to post
Share on other sites

Adding to what has already been said, if you want an actual progress bar resource (mini dialog) in the centre of your screen, you can use code similar to this:

(You will need your own RscStructuredText definition - not shown to keep it simple)

defuse.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// display progress bar which triggers 'onLoad' event, with automatic hide duration

titleRsc["ProgressBar", "plain"];

description.ext:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class RscTitles

{

class ProgressBar

{

idd=509;

movingEnable=1;

duration=4; // how long to display dialog

name="ProgressBar";

controls[]={TextBox};

onLoad="[_this select 0, 510] execVM 'ProgressBar.sqf'"; // passes _display and IDC to script

class TextBox: RscStructuredText

{

idc=510;

size = 0.020;

colorBackground[]={0.2,0.2,0.2,0.4};

x=0.50-0.10;

y=0.40;

w=0.10*2;

h=0.04;

default=true;

};

};

};

ProgressBar.sqf: (uses similar code provided in post above)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private['_display_ProgressBar', '_IDC_ProgressBar', '_control', '_progress', '_j', '_bar'];

_display_ProgressBar = _this select 0;

_IDC_ProgressBar = _this select 1;

_control = _display_ProgressBar displayCtrl _IDC_ProgressBar;

_progress = 0;

while {(_progress<20) and (alive player)} do

{

sleep 0.08;

_bar = "<t align = 'center'><t color='#5599FF'>Defusing bomb...</t><br/>";

_bar = _bar+"<t color='#5599FF'>[</t>";

_j = 0;

while {_j <= _progress} do

{

_bar = _bar+"<t color='#00FF00'>=</t>";

_j = _j + 1;

};

_j = 0;

while {_j + _progress < 19} do

{

_bar = _bar + "<t color='#5599FF'>=</t>";

_j = _j + 1;

};

_bar = _bar + "<t color='#5599FF'>]</t></t>";

_progress = _progress + 1;

_control ctrlSetStructuredText composeText([parseText(_bar)]);

//if (!alive player) exitWith {defusing=false};

//if (animationState player != "ainvpknlmstpslaywrfldnon") exitWith {player sidechat "Defuse aborted";defusing = false};

};

Share this post


Link to post
Share on other sites

Thanks u all for the help espacially DR_eyeball

Share this post


Link to post
Share on other sites

I wasn't aware you could use HTML code in displays? wow_o.gif

Share this post


Link to post
Share on other sites

Wow, I wasn't aware that you could now use dialog scripting with title resources! That opens up a heck of a lot of opportunities! Basically, the old question of "how to make a dialog where I can still move" seems to be solved...

Share this post


Link to post
Share on other sites

I wasn't aware of it either until I checked the new Bezerk mission. I remember maybe 10 posts over this year asking whether it was possible and getting a 'no' answer each time.

I knew you could display 'self managing controls' like a map control, since that has been done lots of times in other missions. But to have controls for which you can display both changing text and graphics is very useful.

You'll be able to add HUD's for: speed, damage, altitude, scoring, etc.

Here's an example image of how I'm using it atm: (it also shows how you can do a graphic progress bar)

th_HUD.jpg

Image

Tip: I've found 1 limitation - it seems you can only show 1 resource at a time, so in my case, I had the score flags at the top and stats on the right, so you have to use 'ctrlShow' to hide various parts of the HUD when not in use.

P.S. That 'html' code is refered to as StructuredText in ArmA, if you're looking. It's syntax is slightly different at times.

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  

×