Jump to content
Sign in to follow this  
KC Grimes

Pop-Up Targets (Firing Range)

Recommended Posts

I do apologize for making yet another thread related to Pop Up targets, but I am yet to find what I am looking for.

I am working on a training camp for the realism unit that I am in. It includes multiple things, including a firing range. Right now the range is just a bunch of spread out targets from 50 to 700 meters out that fall when you hit them, then they come back up a couple seconds later. If anyone here has played the America's Army 3 Marksmanship Qualification course, that is what I am looking for. For those of you who haven't, I want to be able to make the red targets not only fall when hit, but also fall if it isn't hit within a certain amount of time, then pop back up after a certain amount of time, then continue the cycle endlessly. If anyone can help me,  please reply in this thread. Thank you!

-SPC KC Grimes,

3/1-15/K/1/1/1

Share this post


Link to post
Share on other sites

There are several scripts around but this is one someone else started and I added some scoring which may not be 100% right.

I think it's popping up a target that doesn't exist, see if you can fix it.

//////////////////////////////////////////////////////////////////
//                 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";

Share this post


Link to post
Share on other sites

Thanks for the reply. I do not know much about triggers and modules yet (still working on that), so what is the trigger in that script? How do I start this?

Share this post


Link to post
Share on other sites

Past this in one of the popup targets

nul=[] execVM "popup.sqf" 

and name the targets

pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5, pt1_6, pt1_7

just like that.

Share this post


Link to post
Share on other sites

It works perfectly. Thank you very much! I haven't experienced it popping up any non-existent target's though.

Share this post


Link to post
Share on other sites

This is the same script I am using (although I modified mine a bit) but it works well. Thanks mate!

Share this post


Link to post
Share on other sites

So, this script is working great, I just had 4 questions :P

1. Is there a way to get the targets to start down instead of up at the start of the session? It's just kind of confusing when it says "Begin!" and then 3 targets pop up, but they don't count. So if they could fall down instead of pop up at the start, that would be awesome.

2. At each hint and each change of the set of targets there is a VERY loud bleeping/pinging sound. Any idea as to how to get rid of that or lower the volume?

3. When the targets sets are switching, all of the targets flip up and down rapidily a couple times, then are either up or down but still random. Any idea how to fix this? Or is it just lag?

4. This part is pretty much optional. The map I have is a full training camp with many things on it. Is there a way to set up a trigger that activates this qualification script below? It's fine how it is, but it is just really annoying to have to end the map, switch out the scripts, then start it again with everyone redownloading and reloading. In the Single Player shooting range in BCT it is started on a trigger it seems, or some script. Anyone have any idea as to how to do that?

Here's my popup.sqf script for Pistol Qualification:

_inc     = 0;
_count   = 0;
_targets = [pt5, pt5_1, pt5_2];
_many    =  count _targets;
nopop=true;
{_x  animate["terc",1]} forEach _targets;

sleep 10;
hint "Please wait until everyone loads the map";
sleep 20;
hint "Welcome to Camp Marne's Live Fire Pistol Qualification Range";
sleep 5;
hint "Setting up the Range";
sleep 3;
hint "The Qualification Course will begin in 10 Seconds";
sleep 2;
hint "The Qualification Course will begin in 8 Seconds";
sleep 2;
hint "The Qualification Course will begin in 6 Seconds";
sleep 2;
hint "The Qualification Course will begin in 4 Seconds";
sleep 2;
hint "The Qualification Course will begin in 2 Seconds";
sleep 2;
hint "Begin!";

while {_inc<10} do 
{
_rnumber = random _many-1;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];
sleep 5;
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 5;
hint "Qualification complete! See your CO for score and debriefing.";

Thanks for putting up with me. :)

Share this post


Link to post
Share on other sites

1. All I can think of is putting this code in the Init Box of each target, then they'll go down as they're created .

this animate["terc",1]

2. You can make the Hint silent ie HintSilent and then the text or use Sidechat I think.

3. If your trying to use it for multi player then I believe you need to add a couple of lines of script, I haven't any experience yet so you'll have to search around for that.

4. If your currently calling the code from an Init Box then just copy that line to a trigger and place it in the on Act box and set the trigger up to anyone present.

Share this post


Link to post
Share on other sites

Ah, now I see what you mean by it not counting properly. I want to have 5 targets for the pistol range. Is there a way I can choose how many targets pop up each set? And is there a way to have the counter count the number of targets hit/miss, not set?

Share this post


Link to post
Share on other sites

You could just copy and rename the script and change the target names but that would require two different ranges.

If you want to keep to one script you could lay down the max number of targets and then pass a variable to replace the

_many    =  count _targets;

with the number of targets you want to popup.

If you had 8 max targets changing many to 3 would result in the first 3 targets working, if it was 5 then the first 5 would popup ect.

I haven't tested it so it may or may not work.

As for the last part of the question I don't really understand it.

Share this post


Link to post
Share on other sites

if (_rtarget animationPhase "terc" > 0.1) then

This line is what starts the 'Count' part of the scoring. '_rtarget' is a random target. So if 3 targets popped up, only 1 of them would actually be scored if you hit it. You don't know which one because it is random. It's like a range with 3 targets but only 1 matters, so it only counts one for hits and misses. What I want to do is have a script that adds 3 to 'Count' if 3 targets pop up, not just 1. So the scoring system with your current script is only scoring one target, and I need it to score all of them, but on the same scoreboard.

Share this post


Link to post
Share on other sites

The only way I can think of would be to scrap the current scoring system and try eventhandlers they can detect a bullet hit.

I did get that far but I couldn't manage to get a result out of it.

I do think I found the bug in the current scoring system, I believe the numbers work better when converted to whole numbers.

You need to change some of the code.

_rnumber = random _many;
_int = _rnumber%1;
_rnumber = _rnumber-_int;
_rtarget = _targets select _rnumber;

Share this post


Link to post
Share on other sites

Didn't work :( Not sure about eventhandlers. How far did you get? Guide me to where you are and then I'll mess with it.

Edited by Grimes [3rd ID]

Share this post


Link to post
Share on other sites

I'm still using the original code with the random number fix which hasn't messed up yet for me.

The eventhandler will post a hint telling you it was hit but I haven't found a way if scoring it.

I did try

_rtarget addEventHandler ["hit", {hint "Hit Target";_count=_count+1;}];

It doesn't through an error but won't return the count.

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: TODO: Author Name
//////////////////////////////////////////////////////////////////
//                 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;
_int = _rnumber%1;
_rnumber = _rnumber-_int;
_rtarget = _targets select _rnumber; 
_rtarget animate["terc", 0];


_rtarget addEventHandler ["hit", {hint "Hit Target";}];
sleep 3;
//if (_rtarget animationPhase "terc" > 0.1) then
//{
//_count = _count+1;
//};
hint format ["Targets :%1 Hit :%2",_inc+1,_count];
_rtarget removeEventHandler ["hit", 0]; 
_rtarget animate["terc", 1];
_inc = _inc + 1;
};
sleep 8;
hint "Session Complete";

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Alright, thanks. For now I just removed the hint format part that displays the scoreboard. I'll just get the people to count hits and misses, no big deal. I'll still mess around with this though, if you'll continue to help as well. Anyone else is welcome to chip in ;)

Share this post


Link to post
Share on other sites

I'm a java programmer and know little about the syntax in this language but I will offer my help. I am not too sure how your event handler works and all but if it can tell if the target is hit, it should have some sort of return value attached to it so you can tell that it did indeed get hit with in your code.

If the event handler can tell you if it was hit, then can't you increment a number every time it says hit?

pseudo code: (riding on the fact that there is a return value for the event handler)

_numHits = 0;

_numMissed = 0;

_isHit = _rtarget removeEventHandler ["hit", 0];

if(_isHit == 1)

_numHits++;

else

_numMissed++;

Share this post


Link to post
Share on other sites

Cheers.

I tried something close to that and have just tried what you suggest but without any luck the return value seems isn't working. It may be a dimension although when I try and access it I get errors.

Share this post


Link to post
Share on other sites

//////////////////////////////////////////////////////////////////
//                 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";

That is the original script... And it is working for me perfectly... I don't know what the problem is with your as to why it's not counting. Perhaps you changed a variable or have a variable set as something else, elsewhere.... That would botch it pretty fast.

Share this post


Link to post
Share on other sites

It's not like it doesn't work, it works fine. Just not the way I want it to :P

Share this post


Link to post
Share on other sites

Ic ic... How does it differ from what your trying to do exactly?

Share this post


Link to post
Share on other sites

What I want is a qualification range with 5 targets. I want 1-3 random targets popping up at a time until 25 targets have been popped up. We nearly have this. Currently instead of just 25 targets popping up, it is actually 25 groups (1-3 per) of targets popping up, which obviously throws everything off.

Now, if this can not be achieved, just 1 target at a time is perfectly fine with me, I just need to change some sleep times.

Share this post


Link to post
Share on other sites

Yea I have not yet got that far with mine... I currently have 2 operational firing ranges... Of which either can be set for a random 20 targets or a random 10 targets (for rifles and pistols) i am going to be working on a machine gun range which will popup a group of targets at a time...

When I get that far I'll let you know... Lot's of demands on me right now to get this mission done for the unit heh.

Share this post


Link to post
Share on other sites

This is about it for me, 3 targets per set = 24 total targets with scoring.

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: TODO: Author Name
//////////////////////////////////////////////////////////////////
//                 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;
_rnumber1=0;
_rnumber2=0;
_rnumber3=0;

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


while {_inc<8} do 
{
_rnumber1 = random _many;
_int = _rnumber1%1;
_rnumber1 = _rnumber1-_int;

while {(_rnumber1 == _rnumber2) or (_rnumber1 == _rnumber3) or (_rnumber2 == _rnumber3)} do
{  
_rnumber2 = random _many;
_int = _rnumber2%1;
_rnumber2 = _rnumber2-_int;

_rnumber3 = random _many;
_int = _rnumber3%1;
_rnumber3 = _rnumber3-_int;
};

_rtarget1 = _targets select _rnumber1;
_rtarget2 = _targets select _rnumber2;
_rtarget3 = _targets select _rnumber3;

_rtarget1 animate["terc", 0];
_rtarget2 animate["terc", 0];
_rtarget3 animate["terc", 0];

sleep 3;

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

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

hint format ["Targets :%1 Hit :%2",(_inc+1)*3,_count];
_rtarget1 animate["terc", 1];
_rtarget2 animate["terc", 1];
_rtarget3 animate["terc", 1];
sleep 2;
_inc = _inc + 1;
};
sleep 8;
hint "Session Complete";

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Nice. So, I tried that script, and found 2 problems. But the good thing is we are almost finished :P

1. Too many targets were up at certain times, should only be 1-3. Again, if this can not be achieved, just 1 at a time is fine.

2. It scored the hits exactly how I wanted it (1 target hit = +1 to hit counter), but it still counted every group of targets as 1 target. Half way there! :D

And I had a question... is there anything you can put into the script so it does not activate at the beginning of the map, and only by trigger? I've got the trigger set up and it works fine, but I don't want the script to always activate at the beginning of the map.

Share this post


Link to post
Share on other sites

while {(_rnumber1 == _rnumber2) or (_rnumber1 == _rnumber3) or (_rnumber2 == _rnumber3)} do

{

_rnumber2 = random _many;

_int = _rnumber2%1;

_rnumber2 = _rnumber2-_int;

_rnumber3 = random _many;

_int = _rnumber3%1;

_rnumber3 = _rnumber3-_int;

};

I think I understand what this loop is doing but not the condition.

Instead of doing this in sets like _inc<8 could we not start it off like this instead?

_totalTargets = 25;

_numTargets = 0;

while {_numTargets < _totalTargets} do

{

have a random number [1-3] say _popNum

inside a loop that loops around _popNum times and checks (_numTargets < _totalTargets), have it pick a random target and pop it up. and at every instance of that loop increment _numTargets.

}

I am still learning the syntax for this language but I am sure that code will work if implemented.

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  

×