Jump to content
Harvath.S

Targets Reanimate Despite Script

Recommended Posts

Hello all,

 

Thank you in advance for the help.

 

I have run into an issue with a script I am using for a KD Range. The scripts work exactly how I want them too. But I have run into an issue once I uploaded the mission with these scripts to the Dedicated Server.

 

The targets are designed to popup on command, which they do, and then go down and stay down once shot or a certain period of time has passed. This is where I find my issue.

 

If there is no outside influence (The target does not get shot) the script works perfectly. However, if the target is shot it goes down and pops back up until the script calls that target again, at which point the target remains up until the script tells it to lower itself.

 

I am calling the script using addAction on an object.


Here is the script:

Spoiler

initPlayerLocal.sqf


Range_1 addAction ["Activate Range","popup1.sqf"];

popup1.sqf


#define SOUND_ACTIVE "a3\missions_f_beta\data\sounds\firing_drills\course_active.wss"
#define SOUND_CLEAR "a3\missions_f_beta\data\sounds\firing_drills\checkpoint_clear.wss"

if (isDedicated) then{};

_inc     = 0;
_count   = 0;
_targets = [pt1_50,pt1_100, pt1_150, pt1_200, pt1_250, pt1_300];
_group   = 0;

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

nopop=true;


sleep 5;
[-2, {hint _this}, "Please ensure that one 20 round magazine is loaded."] call CBA_fnc_globalExecute;
sleep 5;
[-2, {hint _this}, "Assume a prone, supported position and scan your lane."] call CBA_fnc_globalExecute;
sleep 5;
[-2, {hint _this}, "Range Starting in 10 seconds!"] call CBA_fnc_globalExecute;
sleep 5;
[-2, {hint _this}, "Range Starting in 5 seconds!"] call CBA_fnc_globalExecute;
sleep 5;
[-2, {hint _this}, "Range is hot!"] call CBA_fnc_globalExecute;
playSound3D [SOUND_ACTIVE, range_1, false, getPosASL range_1, +5, 1, 10];


pt1_50 animate["terc", 0];

sleep 4;


if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;




pt1_100 animate["terc", 0];

sleep 4;

if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_150 animate["terc", 0];

sleep 4;

if (pt1_150 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_150 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_250 animate["terc", 0];

sleep 4;

if (pt1_250 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_250 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_200 animate["terc", 0];

sleep 4;

if (pt1_200 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_200 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_300 animate["terc", 0];

sleep 4;

if (pt1_300 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_300 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_150 animate["terc", 0];
pt1_200 animate["terc", 0];

sleep 6;

if (pt1_150 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_150 animate["terc", 1];
};
if (pt1_200 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_200 animate["terc", 1];
};
_inc = _inc +2;

sleep 3;



pt1_100 animate["terc", 0];
pt1_250 animate["terc", 0];

sleep 6;

if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
if (pt1_250 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_250 animate["terc", 1];
};
_inc = _inc +2;

sleep 3;



pt1_300 animate["terc", 0];

sleep 4;

if (pt1_300 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_300 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_50 animate["terc", 0];

sleep 4;

if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_200 animate["terc", 0];

sleep 4;

if (pt1_200 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_200 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_150 animate["terc", 0];


sleep 4;

if (pt1_150 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_150 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_100 animate["terc", 0];
pt1_200 animate["terc", 0];

sleep 6;

if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
if (pt1_200 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_200 animate["terc", 1];
};
_inc = _inc +2;

sleep 3;



pt1_150 animate["terc", 0];
pt1_100 animate["terc", 0];

sleep 6;

if (pt1_150 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_150 animate["terc", 1];
};
if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
_inc = _inc +2;

sleep 3;



pt1_100 animate["terc", 0];

sleep 4;

if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_50 animate["terc", 0];

sleep 4;

if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;

playSound3D [SOUND_CLEAR, range_1, false, getPosASL range_1, +5, 1, 10];

sleep 3;
[-2, {hint _this}, "Reload one 10 round magazine."] call CBA_fnc_globalExecute;
sleep 10;
[-2, {hint _this}, "Assume a prone, unsupported position."] call CBA_fnc_globalExecute;
sleep 10;
[-2, {hint _this}, "Scan your Lane, Range is hot!"] call CBA_fnc_globalExecute;
playSound3D [SOUND_ACTIVE, range_1, false, getPosASL range_1, +5, 1, 10];

pt1_50 animate["terc", 0];

sleep 4;

if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;


pt1_150 animate["terc", 0];

sleep 4;

if (pt1_150 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_150 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_100 animate["terc", 0];
pt1_200 animate["terc", 0];

sleep 6;

if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
if (pt1_200 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_200 animate["terc", 1];
};
_inc = _inc +2;


sleep 3;



pt1_300 animate["terc", 0];

sleep 4;

if (pt1_300 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_300 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_150 animate["terc", 0];
pt1_50 animate["terc", 0];

sleep 6;

if (pt1_150 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_150 animate["terc", 1];
};
if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
_inc = _inc +2;

sleep 3;



pt1_100 animate["terc", 0];
pt1_250 animate["terc", 0];

sleep 6;

if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
if (pt1_250 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_250 animate["terc", 1];
};
_inc = _inc +2;

sleep 3;



pt1_50 animate["terc", 0];

sleep 4;

if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;

playSound3D [SOUND_CLEAR, range_1, false, getPosASL range_1, +5, 1, 10];

sleep 3;
[-2, {hint _this}, "Reload one 10 round magazine."] call CBA_fnc_globalExecute;
sleep 6;
[-2, {hint _this}, "Assume a kneeling position."] call CBA_fnc_globalExecute;
sleep 10;
[-2, {hint _this}, "Scan your Lane, Range is hot!"] call CBA_fnc_globalExecute;
playSound3D [SOUND_ACTIVE, range_1, false, getPosASL range_1, +5, 1, 10];

pt1_50 animate["terc", 0];

sleep 4;

if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;


pt1_100 animate["terc", 0];

sleep 4;

if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_50 animate["terc", 0];
pt1_150 animate["terc", 0];

sleep 6;

if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
if (pt1_150 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_150 animate["terc", 1];
};
_inc = _inc +2;

sleep 3;



pt1_150 animate["terc", 0];

sleep 4;

if (pt1_150 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_150 animate["terc", 1];
};
_inc = _inc +1;


sleep 3;


pt1_50 animate["terc", 0];
pt1_100 animate["terc", 0];

sleep 6;

if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
_inc = _inc +2;

sleep 4;



pt1_100 animate["terc", 0];

sleep 4;

if (pt1_100 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_100 animate["terc", 1];
};
_inc = _inc +1;

sleep 3;



pt1_150 animate["terc", 0];
pt1_200 animate["terc", 0];

sleep 6;

if (pt1_150 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_150 animate["terc", 1];
};
if (pt1_200 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_200 animate["terc", 1];
};
_inc = _inc +2;

sleep 3;

playSound3D [SOUND_CLEAR, range_1, false, getPosASL range_1, +5, 1, 10];
[-2, {hint _this}, "Cease Fire! Cease Fire! Cease Fire!"] call CBA_fnc_globalExecute;
{_x  animate["terc",1]} forEach _targets;

sleep 5;
 if (_count >= 36)  then {hint "You Scored EXPERT"};

 if (_count <= 35)  then {hint "You Scored RIFLEMAN"};

 if (_count <= 29)  then {hint "You Scored Marksman"};

 if (_count <= 22)  then {hint "FAILED"};

 

 

Again, thank you for the help.

Share this post


Link to post
Share on other sites

Default behaviour of the popup target is to go back up when shot. They will only stay down when animated to do so by script. Since you only animate them down again if the player missed they will stay up if hit. 

 

Change (for all targets of course):

if (pt1_50 animationPhase "terc" != 0) then {
        _count = _count + 1;
} else {
        pt1_50 animate["terc", 1];
};
_inc = _inc +1;

To:

if (pt1_150 animationPhase "terc" != 0) then { 
	_count = _count + 1;
};
pt1_150 animate["terc", 1];
_inc = _inc +1

You may also have an issue with timing. You are sleeping for 4 and 6 seconds after the targets have gone up. Since you are doing the targets in the same sequence every time it's likely that your player will learn the sequence and take down the targets so quickly that they popup back up before your sleeps are done. Since those hits wouldn't count the unintended consequence is that the player is punished for being too good.  I recommend using eventhandlers instead. Bit trickier but done right will be more reliable.  Check out this post I've made, specifically the addEventHandler parts.

 

Share this post


Link to post
Share on other sites

mrcurry,

 

Thank you! I was out of town this weekend so I was unable to make any changes yet. I will update the script tonight and inform you how it goes! 

Share this post


Link to post
Share on other sites

There was no change to behavior of the targets. Upon the target raising and being hit it still behaves exactly like a popup target would normally.

 

To clarify the first post, my issue is this:

First target pops

First target is hit

First target lowers

First target pops ///// this is where the issue is.

Second target pops

 

Timing is not a big issue. Our members do a familiarization course on a range with no scripting and simple targets. The KD Range is only used by the member one time. But do I understand you correctly in that there is a certain window of time to hit the target *between* the sleep commands?

 

My understanding, basic that it is, is that the first sleep command below is the time until the target would lower itself. Meaning that as long as the target is hit during the 4 seconds before it is lowered should be all that matters? I could be and probably am way off base with that; but it is how I understand it to be.

pt1_50 animate["terc", 0];

sleep 4;


if (pt1_50 animationPhase "terc" != 0) then { 
	_count = _count + 1;
};
pt1_50 animate["terc", 1];
_inc = _inc +1

sleep 3;

 

Share this post


Link to post
Share on other sites

Back in the days you could use "nopop = true;" to make targets stay down once hit.

Some time ago this changed, and only certain targets stay down, while others still pop up again for some weird reason.

 

Cheers

Share this post


Link to post
Share on other sites

I have "nopop=true;" in the script to be safe. But the fact that that command is FUBAR *should* be solved by the manual animation of each target. But for some reason they just don't want to play with me.

Share this post


Link to post
Share on other sites

As it works fine in SP using nopop =true  and not on the Dedicated Server you might need to run it on each machine or locally.

I don't do any MP coding so not sure the best way to do that.

 

The other option is use Human Target Simple  as that has no auto animation.

To knock it down you would need to add an eventhadler to each target that will tell it to go down when hit.

The rest of your code would still work as before.

this addEventHandler ["Hit", {(_this select 0) animate["terc", 1]}]

in each targets init.

 

 

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

×