Jump to content
NewwyKungz

I would like some advice on how to write a KOTH Laser designator script.

Recommended Posts

I need some advice on how to write a KOTH laser script. I'm just starting to write this script as my first script and I don't know where to start, can you give me some advice?

Share this post


Link to post
Share on other sites

A description of what exactly you are trying to do would help. "A laser designator script" is a bit general. For example i made a script for UAVs that can lock the turret on a target and feeds extra info to the user whenever the laser is active.

 

There's also a few scripts based around using laser designators. Finding some and pulling them apart would also give you a better idea of what's needed and would also help you narrow down on just exactly you need to ask. Sometimes working out what you need to ask can be the hardest part. 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for your help. I'm having a bit of a problem right now. I can't get drawicon3d to use in my script.

 

Spoiler

_TargetPos = getPos laserTarget player;

if (isLaserOn player) then{
	hint "True"
	drawIcon3D ["", [1,0,0], _TargetPos, 1, 1, 1, name player, 0, 1, "EtelkaMonospacePro", "right"]
} else {
	hint "False"
};

 

 

Share this post


Link to post
Share on other sites

Normal. This command must be framed/drawn 3D. See examples in biki.

Of course, remove the hint (or use hintSilent) and, for the laser off, make _targetPos  [0,0,0] or erase name player by "", or... 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

Normal. This command must be framed/drawn 3D. See examples in biki.

Of course, remove the hint (or use hintSilent) and, for the laser off, make _targetPos  [0,0,0] or erase name player by "", or... 

Thank for your help.

 

Now I need a command to get position my laser. I've tried laserTarget and I think it came out pretty bad. Do you have any advice?

Share this post


Link to post
Share on other sites
3 hours ago, NewwyKungz said:

Thank for your help.

 

Now I need a command to get position my laser. I've tried laserTarget and I think it came out pretty bad. Do you have any advice?

 

laserTarget should work. It returns an object (the laser target) and so you just need to grab that unit's position. How were you using it?

  • Thanks 1

Share this post


Link to post
Share on other sites

I use the code below But the result turned out to be that the Text is much lower than the target. The lower it is, the lower it will be.

 

Code

Spoiler

 


drawIcon3D ["", [1,0,0,0.8], ASLToAGL getPos laserTarget player, 0, 0, 0, name player, 0, 0.02, "EtelkaMonospacePro", "right"];

 

Img

Spoiler

3f2f02e05b1a913b17d57da22b1a7a8f.pngf68893ea13f7428c3cfcf858d49f51a7.png

Share this post


Link to post
Share on other sites

I'm using it now, I tried removing ASLToAGL and it worked, now I'm wondering if I should put execVM in init.sqf or where to have it run when the mission starts. And how do I remove or hide drawicon3d ? It can't use in MP. 

5 hours ago, NewwyKungz said:

I use the code below But the result turned out to be that the Text is much lower than the target. The lower it is, the lower it will be.

 

Code

  Reveal hidden contents

 



drawIcon3D ["", [1,0,0,0.8], ASLToAGL getPos laserTarget player, 0, 0, 0, name player, 0, 0.02, "EtelkaMonospacePro", "right"];

 

Img

  Reveal hidden contents

3f2f02e05b1a913b17d57da22b1a7a8f.pngf68893ea13f7428c3cfcf858d49f51a7.png

 

Share this post


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

 

 

Now I think I'm using it perfectly. The only problem was that other players couldn't see my laser.

That My Code 

addMissionEventHandler ["Draw3D", {
		_ReTargetpos = [0,0,0];
		_cansee = [objNull, "VIEW"] checkVisibility [eyePos player, _Targetpos];
		private _Targetpos = getPosVisual laserTarget player;
		if (isLaserOn player && _cansee > 0) then{
			//hint "True"
			drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\TacticalDisplay\targetLaserTexture_gs.paa", [1,0,0,0.8], _Targetpos, 0.7, 0.7, 0, name player, 0, 0.025, "EtelkaMonospacePro"];
		} else {
			drawIcon3D ["", [1,0,0,0], getPosVisual laserTarget player, 0, -0.1, 0, name player, 0, 0.03, "EtelkaMonospacePro"];
		};
}];

 

And I use it in init.sqf 

[] execVM "laser.sqf";

 

Share this post


Link to post
Share on other sites

The problem is addMissionEventHandler is local (and that's normal). If you want to make it global, you must remoteExec, or more accurately publicVariable, something.

But, first of all, just little questions:

- if I'm right, when lasing on a target, all your friendly player can see the aiming point with NVG (not tested for a while). Isn't it enough, like in real life?

- are you re-inventing the vanilla tactical ping?

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites
13 minutes ago, pierremgi said:

The problem is addMissionEventHandler is local (and that's normal). If you want to make it global, you must remoteExec, or more accurately publicVariable, something.

But, first of all, just little questions:

- if I'm right, when lasing on a target, all your friendly player can see the aiming point with NVG (not tested for a while). Isn't it enough, like in real life?

- are you re-inventing the vanilla tactical ping?

 

 

- It's true that players can see it through NVG, but it's quite difficult to spot this tiny dot.

- In terms of tacticalping, I think it's necessary to reactivate when changing targets. But if it's a laser marker, it will be used as long as the laser is on.

 

I'm trying to make it as new player-friendly as possible as my server has quite a lot of 0 hour new players playing and I'd love to try writing my own scripts so that I can improve. yourself too

Share this post


Link to post
Share on other sites
On 9/21/2021 at 6:30 AM, pierremgi said:

The problem is addMissionEventHandler is local (and that's normal). If you want to make it global, you must remoteExec, or more accurately publicVariable, something.

But, first of all, just little questions:

- if I'm right, when lasing on a target, all your friendly player can see the aiming point with NVG (not tested for a while). Isn't it enough, like in real life?

- are you re-inventing the vanilla tactical ping?

 

 

Do you have an example of remoteExec, I'm trying to understand it but I still don't understand it, I've been looking for information about it in the wiki and still don't understand it. can you help

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/Multiplayer_Scripting

 

This explains a lot about scripting for multiplayer. I can tell you from experience that without an understand of localities or client-server interactions, it will seem pretty confusing. But once you understand it (and it's not as difficult as it might seem at first) it becomes pretty clear how to write for a multiplayer environment. If you don't want to go through the whole page though there is a part that deals with remoteExec, and the wiki's entry for remoteExec is pretty detailed.

 

Though one of the biggest things you can do to help yourself is to be aware of a command's locality for its arguments and effects, which are usually two icons of the top of a command's wiki entry ( e.g. https://community.bistudio.com/wiki/createUnit indicates that arguments are local and effects are global, by the icons at the top of the page).

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

In MP you must avoid any broadcast for nuts, and limit shared data at most.

If you are so much fond of learning MP scripting, you will find on this forum and BIKI, all topics about commands and functions, their syntax, arguments local or global or server only, effects local or global... due to locality,... but also initialization order, remote execution, public variables, specific event sqfs, code optimization, MP mission scripting...

 

So, with a little experience, I can say your project can be resource consuming, more or less. I suggest you this way:

- in initServer.sqf (create it, at mission root, if not already done).
 

LASERPOINTS = [];
publicVariable "LASERPOINTS";

 

- in initPlayerLocal.sqf (create it, at mission root, if not already done).

 

addMissionEventHandler ["Draw3D",
  {
     if (!isNull laserTarget player) then {
       if !([laserTarget player,name player] in LASERPOINTS) then {
         LASERPOINTS pushbackUnique [laserTarget player,name player];
         publicVariable "LASERPOINTS";
       }
    } else {
       LASERPOINTS = LASERPOINTS select {!isNull (_x#0)};
       publicVariable "LASERPOINTS";
    };
    {
       drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\TacticalDisplay\targetLaserTexture_gs.paa", [1,0,0,0.8], getposVisual (_x#0), 0.7, 0.7, 0, _x#1, 0, 0.025, "EtelkaMonospacePro"];
    } count LASERPOINTS;
  }
];

 

OK in SP. Not tested in MP, should work.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Now I have tried your test script and it works.
Thank you both so much for always helping me.

Now I'm trying to understand the script and trying to fix it but it doesn't work.
So I want to ask about this script.
- How does it work?
- I should put a command checkVisibility in which part of the script

 

in my script  i'm put it here.

		_cansee = [objNull, "VIEW"] checkVisibility [eyePos player, getPosASLVisual laserTarget player];
		_Targetpos = getPosVisual laserTarget player;
		
		if (isLaserOn player && _cansee > 0) then{

 

  • Like 1

Share this post


Link to post
Share on other sites

laserTarget player is an object ( laserTargetW class for BLUFOR so this target is EAST side),  created when the player is laser on on something (ground, vehicles, targets). This object is null on sky or laser off

 

So, there is no need for checking laser on in my script. The laser point(s) (one per player if lazing) can automatically deleted (so the object becomes null) after few seconds if the target/ground is lost. Nothing to do.

 

_cansee = 1 if target is objnull (sky or laser off). I don't know what you want to do with that but it's a waste of code, imho. _cansee reaches 0 just in heavy fog. In this case, the lasertargetWest has the same behavior than pointing to the sky. The laser point stays few seconds on the edge of ground then disappears.

 

  • Thanks 1

Share this post


Link to post
Share on other sites
25 minutes ago, pierremgi said:

laserTarget player is an object ( laserTargetW class for BLUFOR so this target is EAST side),  created when the player is laser on on something (ground, vehicles, targets). This object is null on sky or laser off

 

So, there is no need for checking laser on in my script. The laser point(s) (one per player if lazing) can automatically deleted (so the object becomes null) after few seconds if the target/ground is lost. Nothing to do.

 

_cansee = 1 if target is objnull (sky or laser off). I don't know what you want to do with that but it's a waste of code, imho. _cansee reaches 0 just in heavy fog. In this case, the lasertargetWest has the same behavior than pointing to the sky. The laser point stays few seconds on the edge of ground then disappears.

 

 

 

I try to make people who can't see the point. The laser will not be able to see the mark.
For example:
I turned on the laser and between you and me there is a building blocking you so you can't see the laser marker.

Share this post


Link to post
Share on other sites
7 hours ago, NewwyKungz said:

 

 

I try to make people who can't see the point. The laser will not be able to see the mark.
For example:
I turned on the laser and between you and me there is a building blocking you so you can't see the laser marker.

the LASERPOINTS can be filtered like this:
 

{
  drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\TacticalDisplay\targetLaserTexture_gs.paa",[1,0,0,0.8],getposVisual (_x#0),0.7,0.7,0,_x#1,0,0.025,"EtelkaMonospacePro"];
} count (LASERPOINTS select {private _cs= [objNull, "VIEW"] checkVisibility [eyePos player, getPosASLVisual(_x#0)]; _cs >0 && _cs != 1 })

not tested

  • Thanks 1

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

×