Jump to content
ShiftyFR

Firing range and scoring

Recommended Posts

Hi everyone,

 

I have a firing range, and I would like to make targets not going up after being shot, but only if asked by an addaction, with a scoring system.

Have you any idea/example for me ?

 

Thank you :)

Share this post


Link to post
Share on other sites

Hmm, it's not bad, but for example, an instructor can't take a look at the score of a trainee :/

Share this post


Link to post
Share on other sites

Hi guys,

 

I got a firing range from an "old" mission, and it's perfect. But I have only 1 problem.

 

There is 7 lanes, with 4 targets at 100, 200, 300 and 500 meters. There is a scoring system working perfectly. The only problem I have is in the nopop target. I want them to not pop up after being shot. In local it's working, but when on the server, some time a target pop up again. Maybe because the script had no time to be activate before another target get hit ?

 

Here is the all script

Spoiler

//preping target list
_targetList = nearestObjects [(getMarkerPos "fr_init") , ["TargetPopup_ACR"], 1000];

//score function

bwi_func_target_hit =
    {
        private["_shooter"];
        _shooter = _this select 1;
        _shooter addScore 1;
    };

bwi_func_no_pop =
    {    
        private["_target"];
        sleep 1;
        _target = _this select 0;
        waitUntil {(_target animationPhase "terc") < 1};
        
        _target animate ['terc', 1];
    };

targets100 = [];
targets200 = [];
targets300 = [];
targets500 = [];


TargetsLane1 = [];
TargetsLane2 = [];
TargetsLane3 = [];
TargetsLane4 = [];
TargetsLane5 = [];
TargetsLane6 = [];
TargetsLane7 = [];

//check targets, sort targets

{
    _x addEventHandler ["Hit", {_this call bwi_func_target_hit}];
    _x animate ['terc', 1];
    
    _test100 = [targets100trigger,getPosAtl _x] call BIS_fnc_inTrigger;
    _test200 = [targets200trigger,getPosAtl _x] call BIS_fnc_inTrigger;
    _test300 = [targets300trigger,getPosAtl _x] call BIS_fnc_inTrigger;
    _test500 = [targets500trigger,getPosAtl _x] call BIS_fnc_inTrigger;

    
    _testLane1 = [triggerlane1,getPosAtl _x] call BIS_fnc_inTrigger;
    _testLane2 = [triggerlane2,getPosAtl _x] call BIS_fnc_inTrigger;
    _testLane3 = [triggerlane3,getPosAtl _x] call BIS_fnc_inTrigger;
    _testLane4 = [triggerlane4,getPosAtl _x] call BIS_fnc_inTrigger;
    _testLane5 = [triggerlane5,getPosAtl _x] call BIS_fnc_inTrigger;
    _testLane6 = [triggerlane6,getPosAtl _x] call BIS_fnc_inTrigger;
    _testLane7 = [triggerlane7,getPosAtl _x] call BIS_fnc_inTrigger;
    
    if (_test100) then {targets100 set [count targets100, _x];};
    if (_test200) then {targets200 set [count targets200, _x];};
    if (_test300) then {targets300 set [count targets300, _x];};
    if (_test500) then {targets500 set [count targets500, _x];};

    
    if (_testLane1) then {TargetsLane1 set [count TargetsLane1, _x];_x addEventHandler ["Hit", {_this spawn bwi_Func_No_Pop;}];};
    if (_testLane2) then {TargetsLane2 set [count TargetsLane2, _x];_x addEventHandler ["Hit", {_this spawn bwi_Func_No_Pop;}];};
    if (_testLane3) then {TargetsLane3 set [count TargetsLane3, _x];_x addEventHandler ["Hit", {_this spawn bwi_Func_No_Pop;}];};
    if (_testLane4) then {TargetsLane4 set [count TargetsLane4, _x];_x addEventHandler ["Hit", {_this spawn bwi_Func_No_Pop;}];};
    if (_testLane5) then {TargetsLane5 set [count TargetsLane5, _x];_x addEventHandler ["Hit", {_this spawn bwi_Func_No_Pop;}];};
    if (_testLane6) then {TargetsLane6 set [count TargetsLane6, _x];_x addEventHandler ["Hit", {_this spawn bwi_Func_No_Pop;}];};
    if (_testLane7) then {TargetsLane7 set [count TargetsLane7, _x];_x addEventHandler ["Hit", {_this spawn bwi_Func_No_Pop;}];};

} forEach _targetList;

bwi_Func_clear_all_scores = {
    
    If (!isServer) exitWith {};    
    {
        _x addScore -(score _x);
        _x setVariable ["bwiRangeShotCount", 0,true];
    } forEach playableUnits;

};

bwi_Func_clear_my_score = {
    If (!isServer) exitWith {};
    _unit = _this select 0;    
    _unit addScore -(score _unit);
    _unit setVariable ["bwiRangeShotCount", 0,true];
};


bwi_Func_100_targets =
{
    // [[0],'bwi_Func_100_targets',false,false] spawn BIS_fnc_MP;
    _state = _this select 0;
    {_x animate ['terc', _state];} forEach targets100;

};


bwi_Func_200_targets =
{
    // [[0],'bwi_Func_100_targets',false,false] spawn BIS_fnc_MP;
    _state = _this select 0;
    {_x animate ['terc', _state];} forEach targets200;

};

bwi_Func_300_targets =
{
    _state = _this select 0;
    {_x animate ['terc', _state];} forEach targets300;

};

bwi_Func_500_targets =
{
    _state = _this select 0;
    {_x animate ['terc', _state];} forEach targets500;

};


fr_laptop addAction ["Activer les cibles à 100m","[[0],'bwi_Func_100_targets',false,false] spawn BIS_fnc_MP;",1];
fr_laptop addAction ["Désactiver les cibles à 100m","[[1],'bwi_Func_100_targets',false,false] spawn BIS_fnc_MP;",1];
fr_laptop addAction ["Activer les cibles à 200m","[[0],'bwi_Func_200_targets',false,false] spawn BIS_fnc_MP;",1];
fr_laptop addAction ["Désactiver les cibles à 200m","[[1],'bwi_Func_200_targets',false,false] spawn BIS_fnc_MP;",1];
fr_laptop addAction ["Activer les cibles à 300m","[[0],'bwi_Func_300_targets',false,false] spawn BIS_fnc_MP;",1];
fr_laptop addAction ["Désactiver les cibles à 300m","[[1],'bwi_Func_300_targets',false,false] spawn BIS_fnc_MP;",1];
fr_laptop addAction ["Activer les cibles à 500m","[[0],'bwi_Func_500_targets',false,false] spawn BIS_fnc_MP;",1];
fr_laptop addAction ["Désactiver les cibles à 500m","[[1],'bwi_Func_500_targets',false,false] spawn BIS_fnc_MP;",1];
fr_laptop addAction ["Réinitialiser le score","[[player],'bwi_Func_clear_my_score',false,false] spawn BIS_fnc_MP;"];
fr_laptop addAction ["Réinitialiser tous les scores","[[[]],'bwi_Func_clear_all_scores',false,false] spawn BIS_fnc_MP;",1];

 

There is another way to stop target from poping up ?

 

Thank you

Edited by Shifty.FR

Share this post


Link to post
Share on other sites

I suspect your issue has something to do with addEventHandler. Try replacing it with addMPEventHandler and using MPHit instead.

if (_testLane1) then {TargetsLane1 set [count TargetsLane1, _x];_x addMPEventHandler ["MPHit", {_this execVM "bwi_Func_No_Pop.sqf";}];};
if (_testLane2) then {TargetsLane2 set [count TargetsLane2, _x];_x addMPEventHandler ["MPHit", {_this execVM "bwi_Func_No_Pop.sqf";}];};
if (_testLane3) then {TargetsLane3 set [count TargetsLane3, _x];_x addMPEventHandler ["MPHit", {_this execVM "bwi_Func_No_Pop.sqf";}];};
if (_testLane4) then {TargetsLane4 set [count TargetsLane4, _x];_x addMPEventHandler ["MPHit", {_this execVM "bwi_Func_No_Pop.sqf";}];};
if (_testLane5) then {TargetsLane5 set [count TargetsLane5, _x];_x addMPEventHandler ["MPHit", {_this execVM "bwi_Func_No_Pop.sqf";}];};
if (_testLane6) then {TargetsLane6 set [count TargetsLane6, _x];_x addMPEventHandler ["MPHit", {_this execVM "bwi_Func_No_Pop.sqf";}];};
if (_testLane7) then {TargetsLane7 set [count TargetsLane7, _x];_x addMPEventHandler ["MPHit", {_this execVM "bwi_Func_No_Pop.sqf";}];};

bwi_Func_No_Pop.sqf

params["_target"];
_target animate ['terc', 1];

 

  • Like 1

Share this post


Link to post
Share on other sites

Hmm, that's unfortunate.

 

I can't find the TargetPopup_ACR object in the biki, is it included in a mod? If so, does the mod include a target that does not pop up?

 

We might be able to get around this problem by using a non-popup target. In the meantime, I'll take another look at your script to see if I can find the root cause of the problem.

Share this post


Link to post
Share on other sites

TargetPopup_ACR are from CUP. But wasn't working too with BI's one.

There is Non-popup target ? It will resolve all my problems !

Share this post


Link to post
Share on other sites

I looked up this issue and it has been mentioned here (targets kept staying up). I tested the command they used and it seems to make all targets stay down now:

nopop = true;

Now, I am not sure if it works with TargetPopup_ACR but give it a try.

Edited by dchan200
Clarify that nopop affects all targets
  • Like 1

Share this post


Link to post
Share on other sites

Yes it's working ! Now I have another problem, because I have other pop-up target outside of the firing range which need to comes back up after being shots xD

Share this post


Link to post
Share on other sites

We might run into the same issue as before (just in reverse) if we add an event handler to make each target go up. Using nopop should prevent the targets from automatically playing animations which might've solved the main problem.

 

But, let's see if we're on the right track by adding event handlers to each of the pop-up targets outside of the firing range.

 

Add the following code somewhere. Note, you'll need to include the targets you want to pop back up.

_popups = [];

{
    _x addMPEventHandler ["MPHit", {_this execVM "bwi_Func_Pop.sqf";}];

} forEach(_popups);

bwi_Func_Pop.sqf:

params["_target"];

// Do not want target to pop back up instantly
sleep 5;

_target animate ['terc', 0];

Note: have not tested code

Share this post


Link to post
Share on other sites

hmm, is it not easier if I modify the init.sqf with :

 

_nopopup = [(target of the firing range];

{
    nopop = true;

};

? (Listing targets of the Firing range will be easier for sure ^^)

Share this post


Link to post
Share on other sites

Well, you should try it on a smaller set of targets to make sure it works first. Try it on these targets:

if (_testLane1) then {TargetsLane1 set [count TargetsLane1, _x];_x addMPEventHandler ["MPHit", {_this execVM "bwi_Func_Pop.sqf";}];};

All the other targets should remain down when hit, but the ones listed above should go back up after a few seconds.

Share this post


Link to post
Share on other sites

Write it like this

22 minutes ago, Shifty.FR said:

_popups = [T1,T2];

T1 and T2 should be the target objects.

Share this post


Link to post
Share on other sites

If it worked for T1 and T2, it'll be simple to add all the other targets using set difference (no need to do it manually). I'll help you with that when necessary.

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

×