Jump to content
Sign in to follow this  
therev709

Shoot House Script :D

Recommended Posts

I'm trying to put together a shoot house, and need some hardcore scripting advice . . . as my scripting skills are quite noob.

Heres a script I'm using for a rifle range, works perfect:

//////////////////////////////////////////////////////////////////
//                 How to use. 
// 1. Place a popup target and name it to pt1 
// 2. copy it 8 times and it will auto name the targets
// 3. place this line in a trigger or init  nul=[] execVM "popup.sqf" 

_inc     = 0;
_count   = 0;
_targets = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7];
_many    =  count _targets;
nopop=true;
{_x  animate["terc",1]} forEach _targets;

hint "Setting up the Range";
sleep 2;
hint "Ready";
sleep 2;


while {_inc<20} do 
{
_rnumber = random _many-1;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];
sleep 3;
if (_rtarget animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };
  hint format ["Targets :%1 Hit :%2",_inc+1,_count];
_rtarget animate["terc", 1];
_inc = _inc + 1;
};
sleep 8;
hint "Session Complete";

Now, heres what I'm trying to do:

Have a shoot house with ~14 targets and ~6 hostage targets. I don't need targets to pop up at random, but would like a have a hint activated by a trigger at the end of the shoot house tell the player the time it took from beginning to end, how many targets they hit, and how many hostages they hit.

Maybe later on down the road I'll set up a point system, but for now I would just like a this to work :)

Thanks in advance!!!

Share this post


Link to post
Share on other sites

Do I see an early version of a little test project I did a while back.

How far have you got?

Popping units into the house at random isn't to hard if a little tiresome.

You could use a HIT Event Handler to check for damage and a Killed EVH for fatal shot, I don't know how this would work in MP as EVH's are local I think.

Scoring wouldn't be that hard, a simple timer with kills and misses.

Share this post


Link to post
Share on other sites

This is for a singe player mission for now, I haven't ventured into MP or COOP yet . . . :) I do love the popup target script, works like a charm :)

Otherwise, my current shoot house script isnt working at all . . . so im nowhere yet lol.

Share this post


Link to post
Share on other sites

I think I can get a script to return the number of hits and misses, but I'm not sure how to get a rundown of the time. I'm thinking of somehow getting a snapshot of the time the run through of the shoot house begins and then the time the player finishes, and then just subtract the start time from the finish time . . . I just have no clue how to do that.

Any ideas?

---------- Post added at 06:27 AM ---------- Previous post was at 05:14 AM ----------

Here is my shoot house script that activates the run through:

FINLINE = FALSE;
nopop = TRUE;
_count = 0;
_targets = [t1,t1_1, t1_2, t1_3, t1_4, t1_5, t1_6, t1_7, t1_8, t1_9, t1_10, t1_11, t1_12, t1_13, t1_14];
_hit = 

titleCut ["", "BLACK OUT", 1];
sleep 2;
player setPos (getPos shstart);
player setDir 215;
door1 setPos (getPos doorpos1);
titleCut ["", "BLACK IN", 2];

{_x  animate["terc",1]} forEach _targets;

hint "Setting up the Range, standby";
sleep 2;
hint "Shooters, ready your weapons!";
sleep 2;
hint "Shooters, targets pop up, knock em down!";
sleep 1;

{_x  animate["terc",0]} forEach _targets;

if (t1 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_1 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_2 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_3 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_4 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_5 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_6 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_7 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_8 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_9 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_10 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_11 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };
if (t1_12 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_13 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

if (t1_14 animationPhase "terc" > 0.1) then
{
	_count = _count+1;
	    };

waitUntil { FINLINE };

hint format ["Targets :15 Hit :%1",_count];

door1 setPos (getPos doorpos2);
{_x  animate["terc",0]} forEach _targets;
nopop=FALSE;

There is a trigger at the finish line that activates FINLINE. All of that works, gonna work on it some more tomorrow to include a hostage hit count.

Still lost on how to get a stop watch like time though,

Any suggestions?

Edited by TheRev709

Share this post


Link to post
Share on other sites

A timer could be something as simple as this

///////////////////////////////////////////////////////////////
// place in start triggers on act     nul=[] execvm "timer.sqf";
// place in end triggers   on act     endtime = 1; 
///////////////////////////////////////////////////////////////
// that gives you 2 mins or time taken
///////////////////////////////////////////////////////////////

endtime = 0;

while {(time < 120) and (endtime == 0)} do {
hintsilent format ["Time Taken %1",time];
sleep 0.1;
};

It may be better practice to use a variable instead of time and increment that but in this case I think it would be ok.

I can't test anything right now but it should work.

.

---------- Post added at 11:25 AM ---------- Previous post was at 10:42 AM ----------

just looking without testing your script I see _hit = should be _hit = 0; or remove as I don't see it being used.

FINLINE needs to be FINLINE = TRUE in the finish trigger

I think you will need a good size delay before the if statements or they may count before your ready.

Having said that I'm not sure how they will count anyway, won't the script just pass them by and goto the waituntil.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

you're a savior mate. I was shooting all of the targets and didn't realize they were already being counted lol!! I'm testing your timing script and working a hostage targe count in there too :)

BTW is there anyway to just say "if (any of the _targets) are (knocked down) then cout+1" rather than have an if then statement for every one?

Also, the timer works great, but it displays the time since the mission started. In this case the shoot house isn't until later in the mission :/ I know I can use a daytime variable, but I'm not sure how to get a snapshot of it from the start of the shoot house and the end, so I can just subtract one from the other.

EDIT: I'm at a loss, you were right about the script skipping the if/then and going to the waitUntil . . .

Edited by TheRev709

Share this post


Link to post
Share on other sites

I thought that might be the case with time, this now just takes whatever the time was when it started away from the result.

I think you can just do time=0 to restart the timer anyway.

//timer

endtime = 0;
_time= 0;
_starttime = time;
while {(_time < 120) and (endtime == 0)} do {
	  hintsilent format ["Time %1",_time];
 _time = (time-_starttime);
sleep 0.1;
};

I'm not sure about the knockdown state, I would think it has an animation state that could be checked.

It may be as it is now and just check the state of each target after you've finished. It should be possible to use the foreach command for that as used when setting the state of the target.

ie { if (_x animationPhase "terc" > 0.1) then

{

_count=_count+1;

};

} forEach _targets;

I haven't tested it so don't count on it working.

cya Sel.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

The timer script works perfectly! Although, I'm still having trouble getting the target hit count script to work. I'm thinking about going back to using even handlers . . . only with my lack of experience I doubt I can figure that one out :/

Share this post


Link to post
Share on other sites
The timer script works perfectly! Although, I'm still having trouble getting the target hit count script to work. I'm thinking about going back to using even handlers . . . only with my lack of experience I doubt I can figure that one out :/

see what you can do with this, it seems to be working.

I've turned off your titles to speed up testing.

Also I had a problem with _time as it seems to be a reserved variable although it worked I changed it to _times just in case.

FINLINE=true was also giving me a problem so I changed it to use 0 and 1.

_times = 0;
FINLINE = 0; 
nopop = TRUE;
_count = 0;
_targets = [t1,t1_1, t1_2, t1_3, t1_4, t1_5, t1_6, t1_7, t1_8, t1_9, t1_10, t1_11, t1_12, t1_13, t1_14];
_hit = 0;

//titleCut ["", "BLACK OUT", 1];
//sleep 2;
//player setPos (getPos shstart);
//player setDir 215;
//door1 setPos (getPos doorpos1);
//titleCut ["", "BLACK IN", 2];


// setting up range
{_x  animate["terc",1]} forEach _targets;

hint "Setting up the Range, standby";
sleep 2;
hint "Shooters, ready your weapons!";
sleep 2;
hint "Shooters, targets pop up, knock em down!";
sleep 1;

{_x  animate["terc",0]} forEach _targets; 
// exit setup range


// shooting in progress
nopop=true;
sleep 1;
_starttime = time;
while {(_times < 20) and ( FINLINE == 0) } do {
	  hintsilent format ["Time %1",_times];
 _times = (time-_starttime);
sleep 0.1;
};
// exit shoot


// count targets down
{ 
if (_x animationPhase "terc" > 0.1) then
{
_count=_count+1;
};
} forEach _targets;
// exit count

hint format ["Targets :15 Hit :%1",_count];

//door1 setPos (getPos doorpos2);
{_x  animate["terc",0]} forEach _targets;
//nopop=FALSE;

Share this post


Link to post
Share on other sites

everything works all except for one thing . . . it only shows the scores after the time limit runs down. If I cross the trigger with

FINLINE = TRUE;

the clock just stops and doesn't show the scores.

I tried to put this in front of the scores hint:

hint"";
sleep 1;

but it did nothing. Then I tried an if/then statement for FINLINE == 1, FINLINE > 0, FINLINE that would activate the scores hint, but alas none of it worked :/

I did change the scores like just now to:

hint format ["Targets :15 Hit :%1 Time: %2",_count,_times];

to add the final run time to the end, which works, but again only when the clock runs down, it will display the final time.

Also, thanks a ton for helping me out with this, I barely have enough time as it is, much less to learn all there is to know about scripting ;)

Edited by TheRev709

Share this post


Link to post
Share on other sites

Works just fine here, leave the code as is and just goto the finish trigger and change FINLINE = true to FINLINE = 1;

I did miss telling you that sorry.

I

Edited by F2k Sel

Share this post


Link to post
Share on other sites

I must have accidentally deleted a symbol or something, cause i recopied and pasted it and it works! I did already change the trigger to FINLINE = 1;.

I hate it when I forget a bracket or semi-colon . . . lol.

But its working perfectly now! Thanks so much! I'm gonna take a break from this and work on other aspects of my sp campaign, but I want to come back to this and edit the script so that when the player hits a hostage target, it deducts from the targets hit, but I think I can figure that out . . . we'll see lol.

Thank again!

Share this post


Link to post
Share on other sites
I must have accidentally deleted a symbol or something, cause i recopied and pasted it and it works! I did already change the trigger to FINLINE = 1;.

I hate it when I forget a bracket or semi-colon . . . lol.

But its working perfectly now! Thanks so much! I'm gonna take a break from this and work on other aspects of my sp campaign, but I want to come back to this and edit the script so that when the player hits a hostage target, it deducts from the targets hit, but I think I can figure that out . . . we'll see lol.

Thank again![/quote

No problem if you get stuck just PM.

Cya.

Share this post


Link to post
Share on other sites

Dear TheRev709,

Could you send me an example mission using your shoothouse script? I want to try to use it in one of my missions but like you I am not so good at scripting, so having an example mission would really help me a lot. I would of course give you credit in the mission briefing notes.

Thank you!

Garthra

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  

×