Jump to content
joejoe87577

Popup Target hitmarker

Recommended Posts

Hello everyone,

I've been looking around for a script that tells me where a popup target has been hit.

Just like in this mission from ArmA 1:

Link to armaholic

I couldn't extract the pbo file with elitness or cpbo (I couldn't get it running on my system). It would help a lot if anyone could extract the file and post it right here.

I've already made contact with the mission author, but he has not written any scripts for a long time, so he could not help me with that.

Kind regards,

Joejoe

Share this post


Link to post
Share on other sites

[NOTE: I don't have ArmA1 so can't check how the mission above represents the hit markers, but I'll jump in anyway!]

I knew I had a script that I used to do something similar during alpha/beta, but had to find it and then check that it still worked. I've checked this on the current dev build only, so YMMV.

To test simply create two targets in the editor. Name one anything you like and add the init: This addEventHandler ["HitPart", "_this execVM 'Scripts\Range\Accuracy.sqf'"];

(Check the path on that init and change as needed.)

The second target is named 'pt1_0'. No init needed. You can 'this allowDamage false;' if you have to ;-)

create the marker: Empty > Objects (Helpers) > Sphere (10cm)

and name it 'Hit_Ind'. It can be placed anywhere on the map as it's position is what is updated.

You'll already have placed down someone to shoot at the target, right?!

Copy and save the code below to a file: Accuracy.sqf

Save and preview in the editor.

// Accuracy Marker using "HitPart" Event Handler
//NOTE: Known to be have been buggy in dedicated MP (late 2012). Current status unknown.
//
//Add this init to target shot at 
//Init: This addEventHandler ["HitPart", "_this execVM 'Scripts\Range\Accuracy.sqf'"];
//
// Returned from "HitPart" EH: TYPE ARRAY [[target, shooter, bullet, position, velocity, selection, ammo, direction, radius, surface, direct]]
//target: Object - Object that got injured/damaged.
//shooter: Object - Unit that inflicted the damage. If injured by a vehicle impact or a fall the target itself is returned, or, in case of explosions, the null object. In case of explosives that were planted by someone (e.g. satchel charges), that unit is returned.
//bullet: Object - Object that was fired.
//position: Position3D - Position the bullet impacted (ASL).
//velocity: Vector3D - 3D speed at which bullet impacted.
//selection: Array - Array of Strings with named selection of the object that were hit.
//ammo: Array - Ammo info: [hit value, indirect hit value, indirect hit range, explosive damage, ammo class name] OR, if there is no shot object: [impulse value on object collided with,0,0,0]
//direction: Vector3D - vector that is orthogonal (perpendicular) to the surface struck. For example, if a wall was hit, vector would be pointing out of the wall at a 90 degree angle.
//radius: Number - Radius (size) of component hit.
//surface: String - Surface type struck.
//direct: Boolean - true if object was directly hit, false if it was hit by indirect/splash damage.

private ["_array", "_unit", "_shooter", "_bullet", "_position", "_velocity", "_selection",
"_ammo", "_direction", "_radius", "_surface", "_direct", "_PositionASL", "_PosASL_1", "_PosASL_2", "_PosASL_3", "_Position_1", "_Position_2", "_Position_3", "_A", "_B", "_C",
"_PosASL_PT1_0", "_PosASL_PT1_0_X", "_PosASL_PT1_0_Y", "_PosASL_PT1_0_Z", "_D", "_E", "_F", "_G", "_H", "_I", "_PosASL_PT1_99", "_PosASL_PT1_99_X", "_PosASL_PT1_99_Y", "_PosASL_PT1_99_Z", "_J", "_K", "_L"];

_array = _this Select 0;

_unit = _array Select 0;
_shooter = _array Select 1;
_bullet = _array Select 2;
_position = _array Select 3;
_velocity = _array Select 4;
_selection = _array Select 5;
_ammo = _array Select 6;
_direction = _array Select 7;
_radius = _array Select 8;
_surface = _array Select 9;
_direct = _array Select 10;

_PositionASL = getPosASL _unit;
_PosASL_1 = _PositionASL Select 0;
_PosASL_2 = _PositionASL Select 1;
_PosASL_3 = _PositionASL Select 2;

//hintc format ["X: %1 Y: %2 Z: %3",_PosASL_1,_PosASL_2,_PosASL_3];

_Position_1 = _Position Select 0;
_Position_2 = _Position Select 1;
_Position_3 = _Position Select 2;
//hintc format ["X: %1 Y: %2 Z: %3",_Position_1,_Position_2,_Position_3];

//Reference Target 1

_A = _Position_1-_PosASL_1;
_B = _Position_2-_PosASL_2;
_C = _Position_3-_PosASL_3;
//hintc format ["X: %1 Y: %2 Z: %3",_A,_B,_C];

_PosASL_PT1_0 = getPosASL PT1_0;
_PosASL_PT1_0_X = _PosASL_PT1_0 Select 0;
_PosASL_PT1_0_Y = _PosASL_PT1_0 Select 1;
_PosASL_PT1_0_Z = _PosASL_PT1_0 Select 2;

_D = _PosASL_PT1_0_X+_A;
_E = _PosASL_PT1_0_Y+_B;
_F = _PosASL_PT1_0_Z+_C;

// Hit_Ind is object type: Empty > Objects (Helpers) > Sphere (10cm)
Hit_Ind setposASL [_D,_E,_F];

playSound3D ["A3\Sounds_F\sfx\blip1.wav", player, false, getPos player, 1, 1, 0]

Hopefully this will get you where you want to go...

Cheers.

Edited by DJPorterNZ
Spelling, grammar

Share this post


Link to post
Share on other sites

I came up with something similar:

place a "Simple Target" (class "Target_F") on your range and put this in the init:

this addEventHandler ["HitPart", {_spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3);}];

this worked on vehicles and other signs too.

Edited by Falsche9
  • Like 1

Share this post


Link to post
Share on other sites

Very simple & elegant solution there, Falsche.

I've filed that little nugget away for a rainy day.

Share this post


Link to post
Share on other sites

I'll give it a try and make a quick sample mission.

---------- Post added at 20:38 ---------- Previous post was at 20:31 ----------

Almost the right Thing. But what I wanted was this:

3-sniper_range.jpg

(bottom right corner)

I've no idea how this works. I've done some dialogs, but i don't now how to make that sort of hint/Dialog.

---------- Post added at 20:51 ---------- Previous post was at 20:38 ----------

I've made a sample Mission and uploaded it to my skydrive: http://sdrv.ms/1gQcEMo

Share this post


Link to post
Share on other sites

I don't know much about dialogues but why not just have a live PIP view of the target?

This will create a target at the distance in the direction the player is facing:

nul = [50] execVM "target.sqf";

_dist = _this select 0;

_tgtPos = player modelToWorld [0,_dist,0];
_tgt = createVehicle ["Target_F", _tgtPos, [], 0, "CAN_COLLIDE"];
_dir = [player,_tgt] call BIS_fnc_dirTo;
_tgt setDir _dir;
_tgt addEventHandler ["HitPart", {_mkr = "Land_PencilRed_F" createVehicle [0,0,0]; _mkr enableSimulation false; _mkr setPosASL (_this select 0 select 3);}];

_obj = createVehicle ["Sign_Sphere10cm_F", [0,0,0], [], 0, "CAN_COLLIDE"];
_obj setObjectTexture [0,"#(argb,8,8,3)color(0,0,0,0)"];
_obj setPos (_tgt modelToWorld [0,-0.5,1]);
_camPos = ([0,0,0]);

[] call BIS_fnc_PIP;
sleep 1;
_targ_pip = ["rendertarget0",[[_obj,_camPos],_tgt],_obj] call BIS_fnc_PIP;
_targ_pip camCommit 0;

//assistance to find the target - can be hard to spot in the terrain
_wp = (group player) addWaypoint [_tgtPos, 0];
_wp setWaypointType "MOVE";

_arrow = createVehicle ["Sign_Arrow_Large_F", [0,0,0], [], 0, "CAN_COLLIDE"];
_arrow setPosATL [_tgtPos select 0,_tgtPos select 1, 2];

Picture of result:

http://31.media.tumblr.com/9844365958a0765262034bb331da4235/tumblr_my973kkiY51sneir7o1_1280.jpg

Edited by Mattar_Tharkari
  • Like 1

Share this post


Link to post
Share on other sites

Thanks, this works for me. But there are two Problems remaining.

The 1fst one is rather easy, how do I destroy/remove/disable the PiP? I've tried "camDestroy", "deleteVehicle" on the "_obj" and on the "rendertarget0". But it doesn't work. How do i remove the PiP?

And the 2nd one is that the PiP Picture doesn't Show the same as the live view does.

b02z.jpg

On the Picture the Little sphere on the popup target Shows where the bullet hit. But on the PiP there is no sphere, i've also tried it with a IR Laser at night. same result, I aim for the "head" but the laser in the PiP Shows a completly different Position.

---------- Post added at 12:40 ---------- Previous post was at 12:29 ----------

I've uploaded the example Mission to my skydrive: Link

Grab a weapon from the VirtualAmmoBox and go to one of the Shooting positions, the PiP will appear, as soon as you leave the Shooting Position (the hint "false" appears), the pip should disappear.

Share this post


Link to post
Share on other sites

[] call BIS_fnc_PIP;

Will remove the PIP - notice I put it in my script to remove any existing PIPs?

Camera is blind to helper objects which is why I use red pencils in the script. If you need something larger use red gull cans ("Land_Can_V3_F")?

  • Like 1

Share this post


Link to post
Share on other sites
I came up with something similar:

place a "Simple Target" (class "Target_F") on your range and put this in the init:

this addEventHandler ["HitPart", {_spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3);}];

this worked on vehicles and other signs too.

Thanks for this....it works well in creating the markers on targets.....

I've been trying to figure out how to use deleteVehicle to get rid of the _spr = "Sign_Sphere10cm_F" vehicles created by this..... but with no success.

Assuming I put this in a Simple Target..... how would you recommend setting up an addAction or trigger to delete the vehicles created after finishing firing on the target so I could then re-engage a clean target ?

I appreciate the Code you provided and wonder what you would recommend.... I have been googling an searching numerous resources for about a week + to try to figure it out myself via markers, triggers, ini box inputs etc etc.

s/f & Thanks for anything you can provide

AldoUSMC

Share this post


Link to post
Share on other sites

you could create an array , you will only need ary=[]; in one target or game logic or it will mess up, it just needs it to create the variable.

ary=[];this addEventHandler ["HitPart", {_spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3); ary=ary+[_spr]}];

players init

this addAction ["remove markers",{{deletevehicle  _x} foreach ary;ary=[]}]

  • Like 1

Share this post


Link to post
Share on other sites

I'll look up my solution, but you'll have to wait until tomorrow as I'm not at my computer.

Gesendet von meinem Nexus 7 mit Tapatalk

Share this post


Link to post
Share on other sites
On 12/23/2013 at 2:46 AM, Falsche9 said:

I came up with something similar:

place a "Simple Target" (class "Target_F") on your range and put this in the init:

 


this addEventHandler ["HitPart", {_spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3);}];
 

 

this worked on vehicles and other signs too.

Is there any way I can get a smaller sphere to appear so that I can get a more precise location of where my shot landed?

Share this post


Link to post
Share on other sites
1 hour ago, Sunith Sunil Mani said:

Is there any way I can get a smaller sphere to appear so that I can get a more precise location of where my shot landed?

Or an HUD?

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

I must dig into my scripts...

 

I didn't find anymore this entire code, but I can give you a way to do:

 

First, have a display. I customized a target but you can use vanilla one. In description.ext:
 

Spoiler

 

#define CT_STATIC               0
#define CT_PROGRESS             8
#define ST_VERTICAL             1
#define ST_CENTER               2
#define ST_PICTURE             48
#define ST_KEEP_ASPECT_RATIO 2048

class RscPicture
{
  access = 0;
  type = 0;
  style = "48 + 2048";
  idc = -1;
  colorBackground[] = {0, 0, 0, 0 };
  colorText[] = {1, 1, 1, 1 };
  font = "TahomaB";
  sizeEx = 0;
  lineSpacing = 0;
  text = "";
  fixedWidth = 0;
  shadow = 0;
  x = 0;
  y = 0;
  w = 0.2;
  h = 0.15;
  tooltipColorText[] = {1, 1, 1, 1 };
  tooltipColorBox[] = {1, 1, 1, 1 };
  tooltipColorShade[] = {0, 0, 0, 0.65 };
};

class RscTitles
{
  titles[] = {"targetResult","Default"};

  class cardboardTarget
  {
    idd = -1;
    duration = 100000;
    fadein = 0;
    fadeout = 0;
    name="MGI target precision";
    onLoad = "uiNamespace setVariable ['popupboard', _this #0]";

    controls[]=
    {
      target_frame,
      spot1,
      spot2,
      spot3,
      spot4,
      spot5
    };
    class target_frame: RscPicture
    {
      idc = 300;
      x = 0.424 * safezoneW + safezoneX;
      y = 0.73 * safezoneH + safezoneY;
      w = 0.15 * safezoneW;
      h = 0.15 * safezoneH;
    };
    class spot1: RscPicture
    {
      idc = 301;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
    class spot2: RscPicture
    {
      idc = 302;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
    class spot3: RscPicture
    {
      idc = 303;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
    class spot4: RscPicture
    {
      idc = 304;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
    class spot5: RscPicture
    {
      idc = 305;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
  };
  class Default
  {
  idd = -1;
  fadein = 0;
  fadeout = 0;
  duration = 0;
  };
};

 

 

Place a trigger on shooter stand in order to activate the target and the code. Here I named the trigger popTrg1 (for other script) and the target tgtPopup1

BLUFOR PRESENT repeatable. In on act field:

 

Spoiler

0 = [thisTrigger,thislist,tgtPopup1] spawn {
  params ["_trg","_shooters","_tgt"];
  _shooter = _shooters select 0;
  _EHid = str(_this select 2);
  hint "open fire when ready";
  12345 cutRsc ["cardboardTarget","PLAIN",0.2,false];
  [_EHid, "onEachFrame", {
    _shooter = _this select 0;
    _tgt = _this select 1;
    _tgt_drawing = (uiNameSpace getVariable "popupboard") displayCtrl 300;
    _tgt_drawing  ctrlSetText "a3\structures_f\training\data\target_longrange_co.paa";
    _tgt_drawing  ctrlSetPosition [0.424  * safezoneW + safezoneX, 0.73* safezoneH + safezoneY, 0.15 * safezoneW, 0.15 * safezoneH * 1.77778];
    _tgt_drawing  ctrlSetTextColor [1,1,1,1];
    _tgt_drawing  ctrlCommit 0;
   _impact1 = (uiNameSpace getVariable "popupboard") displayCtrl 301;
   _impact2 = (uiNameSpace getVariable "popupboard") displayCtrl 302;
   _impact3 = (uiNameSpace getVariable "popupboard") displayCtrl 303;
   _impact4 = (uiNameSpace getVariable "popupboard") displayCtrl 304;
   _impact5 = (uiNameSpace getVariable "popupboard") displayCtrl 305;
   _impacts = [_impact1,_impact2,_impact3,_impact4,_impact5];
 
   {_x ctrlSetText "A3\ui_f\data\map\VehicleIcons\iconexplosiveat_ca.paa"; _x ctrlSetTextColor [0,0,0,0]} forEach _impacts;
   if (_shooter getVariable ["shots",0] >0) then {
     _impact_nbr = (_shooter getVariable "shots") - 1;
     for "_i" from 0 to ((_impact_nbr) mod 5)  do {
       _impacts select (_i mod 5) ctrlSetPosition [(0.494 - (_tgt getVariable "results" select (_impact_nbr -_i) select 0))  * safezoneW + safezoneX, (0.844 - (_tgt getVariable "results" select (_impact_nbr -_i) select 1)) * safezoneH + safezoneY, 0.01 * safezoneW, 0.01 * safezoneH * 1.77778];
       _impacts select (_i mod 5) ctrlSetTextColor [1,1,1,1];
       _impacts select (_i mod 5) ctrlCommit 0;
     };
    }
  },[_shooter,_tgt]] call BIS_fnc_addStackedEventHandler;
  waitUntil {sleep 0.5; !triggerActivated _trg};
  12345 cutRsc ["default","PLAIN",0.2];
  hint parsetext "<t>End of serial<br/>Check safety<t/>";
  _shooter setVariable ["shots",0];
  [_EHid, "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
};

 

and now another script for the target:

 

Spoiler

if (isServer) then {
  this setVectorUp [0,0,1];
  this setVariable ["results",[]];
  this setVariable ["nopop",true,true];
  this animate ["terc",1];
  this addEventHandler ["hitpart", {
    _this spawn {
      _dX_impact = 0;
      _dZ_impact = 0;
      _tgt = _this select 0 select 0;
      _shooter = _this select 0 select 1;
      _coord_impact = _this select 0 select 3;
      _shooter setVariable ["shots",(_shooter getvariable ["shots",0]) + 1];
      _center_tgt = (getposasl _tgt) vectorAdd [0.138,-0.04,1.03];
      _center_X = [_center_tgt select 0, _center_tgt select 1, 0];
      _impact_X = [_coord_impact select 0, _coord_impact select 1, 0];
      _vector_impact_hor = _impact_X vectorDiff _center_X;
      _vector_dir_hor = [- ((vectorDir _tgt) select 1), (vectorDir _tgt) select 0, 0];
      _sign = (_vector_impact_hor vectorDotProduct _vector_dir_hor)/abs (_vector_impact_hor vectorDotProduct _vector_dir_hor);
      _dX_impact = 0.22 * (_coord_impact distance2D _center_tgt) * _sign;
      _dZ_impact = 0.39 * ((_coord_impact select 2) -  ((_center_tgt select 2)));
      (_tgt getVariable "results") pushback [_dX_impact,_dZ_impact];
      hint parsetext format ["<t size='1.30' font='PuristaMedium' color='#ffffff'>shots<br/><t size='1' align='left'>%1<br/>%2<br/><br/>Hits: %3<br/>Distance to tgt: %4 m<br/>last impact acc: %5 cm<br/>",toLower (rank _shooter), name _shooter,player getVariable "shots",round (player distance _tgt),round (100 * (_coord_impact distance _center_tgt))];
    }
  }];

 

I don't have time to tune the display and the _dX _dY with the impact on the display.  It's just a way to do, not a complete, working code.

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites
On 12/23/2013 at 5:40 PM, Mattar_Tharkari said:

I don't know much about dialogues but why not just have a live PIP view of the target?

This will create a target at the distance in the direction the player is facing:

nul = [50] execVM "target.sqf";

 


_dist = _this select 0;

_tgtPos = player modelToWorld [0,_dist,0];
_tgt = createVehicle ["Target_F", _tgtPos, [], 0, "CAN_COLLIDE"];
_dir = [player,_tgt] call BIS_fnc_dirTo;
_tgt setDir _dir;
_tgt addEventHandler ["HitPart", {_mkr = "Land_PencilRed_F" createVehicle [0,0,0]; _mkr enableSimulation false; _mkr setPosASL (_this select 0 select 3);}];

_obj = createVehicle ["Sign_Sphere10cm_F", [0,0,0], [], 0, "CAN_COLLIDE"];
_obj setObjectTexture [0,"#(argb,8,8,3)color(0,0,0,0)"];
_obj setPos (_tgt modelToWorld [0,-0.5,1]);
_camPos = ([0,0,0]);

[] call BIS_fnc_PIP;
sleep 1;
_targ_pip = ["rendertarget0",[[_obj,_camPos],_tgt],_obj] call BIS_fnc_PIP;
_targ_pip camCommit 0;

//assistance to find the target - can be hard to spot in the terrain
_wp = (group player) addWaypoint [_tgtPos, 0];
_wp setWaypointType "MOVE";

_arrow = createVehicle ["Sign_Arrow_Large_F", [0,0,0], [], 0, "CAN_COLLIDE"];
_arrow setPosATL [_tgtPos select 0,_tgtPos select 1, 2];
 

 

Picture of result:

http://31.media.tumblr.com/9844365958a0765262034bb331da4235/tumblr_my973kkiY51sneir7o1_1280.jpg

I tried this but everytime I put it into the init of a Simple Target it keeps telling me Local Variable in Global Space. Any advice? Getting this code to work would be really amazing as I am planning on using it for a school project.

Share this post


Link to post
Share on other sites
22 hours ago, pierremgi said:

I must dig into my scripts...

 

I didn't find anymore this entire code, but I can give you a way to do:

 

First, have a display. I customized a target but you can use vanilla one. In description.ext:
 

  Hide contents

 

#define CT_STATIC               0
#define CT_PROGRESS             8
#define ST_VERTICAL             1
#define ST_CENTER               2
#define ST_PICTURE             48
#define ST_KEEP_ASPECT_RATIO 2048

class RscPicture
{
  access = 0;
  type = 0;
  style = "48 + 2048";
  idc = -1;
  colorBackground[] = {0, 0, 0, 0 };
  colorText[] = {1, 1, 1, 1 };
  font = "TahomaB";
  sizeEx = 0;
  lineSpacing = 0;
  text = "";
  fixedWidth = 0;
  shadow = 0;
  x = 0;
  y = 0;
  w = 0.2;
  h = 0.15;
  tooltipColorText[] = {1, 1, 1, 1 };
  tooltipColorBox[] = {1, 1, 1, 1 };
  tooltipColorShade[] = {0, 0, 0, 0.65 };
};

class RscTitles
{
  titles[] = {"targetResult","Default"};

  class cardboardTarget
  {
    idd = -1;
    duration = 100000;
    fadein = 0;
    fadeout = 0;
    name="MGI target precision";
    onLoad = "uiNamespace setVariable ['popupboard', _this #0]";

    controls[]=
    {
      target_frame,
      spot1,
      spot2,
      spot3,
      spot4,
      spot5
    };
    class target_frame: RscPicture
    {
      idc = 300;
      x = 0.424 * safezoneW + safezoneX;
      y = 0.73 * safezoneH + safezoneY;
      w = 0.15 * safezoneW;
      h = 0.15 * safezoneH;
    };
    class spot1: RscPicture
    {
      idc = 301;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
    class spot2: RscPicture
    {
      idc = 302;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
    class spot3: RscPicture
    {
      idc = 303;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
    class spot4: RscPicture
    {
      idc = 304;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
    class spot5: RscPicture
    {
      idc = 305;
      x = 0.494 * safezoneW + safezoneX;
      y = 0.854 * safezoneH + safezoneY;
      w = 0.01 * safezoneW;
      h = 0.01 * safezoneH;
    };
  };
  class Default
  {
  idd = -1;
  fadein = 0;
  fadeout = 0;
  duration = 0;
  };
};

 

 

Place a trigger on shooter stand in order to activate the target and the code. Here I named the trigger popTrg1 (for other script) and the target tgtPopup1

BLUFOR PRESENT repeatable. In on act field:

 

  Hide contents

0 = [thisTrigger,thislist,tgtPopup1] spawn {
  params ["_trg","_shooters","_tgt"];
  _shooter = _shooters select 0;
  _EHid = str(_this select 2);
  hint "open fire when ready";
  12345 cutRsc ["cardboardTarget","PLAIN",0.2,false];
  [_EHid, "onEachFrame", {
    _shooter = _this select 0;
    _tgt = _this select 1;
    _tgt_drawing = (uiNameSpace getVariable "popupboard") displayCtrl 300;
    _tgt_drawing  ctrlSetText "a3\structures_f\training\data\target_longrange_co.paa";
    _tgt_drawing  ctrlSetPosition [0.424  * safezoneW + safezoneX, 0.73* safezoneH + safezoneY, 0.15 * safezoneW, 0.15 * safezoneH * 1.77778];
    _tgt_drawing  ctrlSetTextColor [1,1,1,1];
    _tgt_drawing  ctrlCommit 0;
   _impact1 = (uiNameSpace getVariable "popupboard") displayCtrl 301;
   _impact2 = (uiNameSpace getVariable "popupboard") displayCtrl 302;
   _impact3 = (uiNameSpace getVariable "popupboard") displayCtrl 303;
   _impact4 = (uiNameSpace getVariable "popupboard") displayCtrl 304;
   _impact5 = (uiNameSpace getVariable "popupboard") displayCtrl 305;
   _impacts = [_impact1,_impact2,_impact3,_impact4,_impact5];
 
   {_x ctrlSetText "A3\ui_f\data\map\VehicleIcons\iconexplosiveat_ca.paa"; _x ctrlSetTextColor [0,0,0,0]} forEach _impacts;
   if (_shooter getVariable ["shots",0] >0) then {
     _impact_nbr = (_shooter getVariable "shots") - 1;
     for "_i" from 0 to ((_impact_nbr) mod 5)  do {
       _impacts select (_i mod 5) ctrlSetPosition [(0.494 - (_tgt getVariable "results" select (_impact_nbr -_i) select 0))  * safezoneW + safezoneX, (0.844 - (_tgt getVariable "results" select (_impact_nbr -_i) select 1)) * safezoneH + safezoneY, 0.01 * safezoneW, 0.01 * safezoneH * 1.77778];
       _impacts select (_i mod 5) ctrlSetTextColor [1,1,1,1];
       _impacts select (_i mod 5) ctrlCommit 0;
     };
    }
  },[_shooter,_tgt]] call BIS_fnc_addStackedEventHandler;
  waitUntil {sleep 0.5; !triggerActivated _trg};
  12345 cutRsc ["default","PLAIN",0.2];
  hint parsetext "<t>End of serial<br/>Check safety<t/>";
  _shooter setVariable ["shots",0];
  [_EHid, "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
};

 

and now another script for the target:

 

  Hide contents

if (isServer) then {
  this setVectorUp [0,0,1];
  this setVariable ["results",[]];
  this setVariable ["nopop",true,true];
  this animate ["terc",1];
  this addEventHandler ["hitpart", {
    _this spawn {
      _dX_impact = 0;
      _dZ_impact = 0;
      _tgt = _this select 0 select 0;
      _shooter = _this select 0 select 1;
      _coord_impact = _this select 0 select 3;
      _shooter setVariable ["shots",(_shooter getvariable ["shots",0]) + 1];
      _center_tgt = (getposasl _tgt) vectorAdd [0.138,-0.04,1.03];
      _center_X = [_center_tgt select 0, _center_tgt select 1, 0];
      _impact_X = [_coord_impact select 0, _coord_impact select 1, 0];
      _vector_impact_hor = _impact_X vectorDiff _center_X;
      _vector_dir_hor = [- ((vectorDir _tgt) select 1), (vectorDir _tgt) select 0, 0];
      _sign = (_vector_impact_hor vectorDotProduct _vector_dir_hor)/abs (_vector_impact_hor vectorDotProduct _vector_dir_hor);
      _dX_impact = 0.22 * (_coord_impact distance2D _center_tgt) * _sign;
      _dZ_impact = 0.39 * ((_coord_impact select 2) -  ((_center_tgt select 2)));
      (_tgt getVariable "results") pushback [_dX_impact,_dZ_impact];
      hint parsetext format ["<t size='1.30' font='PuristaMedium' color='#ffffff'>shots<br/><t size='1' align='left'>%1<br/>%2<br/><br/>Hits: %3<br/>Distance to tgt: %4 m<br/>last impact acc: %5 cm<br/>",toLower (rank _shooter), name _shooter,player getVariable "shots",round (player distance _tgt),round (100 * (_coord_impact distance _center_tgt))];
    }
  }];

 

I don't have time to tune the display and the _dX _dY with the impact on the display.  It's just a way to do, not a complete, working code.

 

 

This one looks really cool. Is there any way to get this to work on a simple target instead of a popup one. I believe that can remove the trigger on the shooter stand and shorten the code. Also, could you please explain how to set up a display target? I don't understand how to get the HUD target to appear. P.s. Sorry I'm really new to this scripting and all, so I apologise for sounding stupid 

Share this post


Link to post
Share on other sites

There are many possibilities for displays (and dialogs, the difference is dialogs give you the possibility to move a cursor or click on buttons).

Here, the layer is called by cutRsc (so a resource) . This command is displaying texts and pictures defined in description.ext (or config.cpp for an addon) via rscTitles

 

You can choose what target you want but the center of the target is not necessary the center of the object (never in fact). So, for each target, you need to find the correcting vector to be applied on impact coordinates I grabbed by "hitPart" eventHandler i.e. this returned value is referenced on absolute ASL coordinates. You need to find the x,y coordinates from the center of the target, itself from the center of the object.  Then, when you can say the impact is x,y (centi)meters from the center of the target, you have to translate that in x,y safeZone for screen. The reason why I have no time to dig deeper in such (old) code.

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

×