Jump to content
Sign in to follow this  
wyattwic

Arma 2 - Thermal optics and Anti-Tank M107

Recommended Posts

Hello everyone!

First question, Is there a built in system for thermal optics on Arma 2 Vanilla? If so, how do I script it for player use?

Second question, Can someone suggest a way to replace a fired bullet with another? My goal is to make the M107 fire a sabot round.

Help would be greatly appreciated!

Share this post


Link to post
Share on other sites

I dug around and I found a nice thermal optic mod. I will utilize snippets to achieve end goal.

I was brainstorming about how to replace a M107 bullet with a SABOT round.

I know that "_this select 6" is the address of the rounds leaving the gun, when _this is the player. Can I do "_this select 6 = Sh_120_SABOT" via a fire event handler?

Share this post


Link to post
Share on other sites

Well, I am still stumped.

I have used "this addeventhandler ["fired",{_this set [6, "Sh_120_SABOT"]}];" with no success, and no errors.

Considering that the bullet is spawned as a vehicle, I think this may be much harder. Here is the process I am currently thinking of. If someone knows an easier way, let me know.

1. Get bullets position, speed, direction, etc.

2. Delete bullet.

3. Create "Sh_120_SABOT"

4. Apply position, speed, direction, etc.

---------- Post added at 19:35 ---------- Previous post was at 18:12 ----------

Okay, I have made some progress, not much though.

My current issue with this, is that the player firing dies instantly.

It looks like the round is impacting the unit that fires, that or recoil is killing him.

Help?

this addeventhandler ["fired",{

_velo = velocity (_this select 6);
_vect = vectordir (_this select 6);
_pos = getpos (_this select 6);
deleteVehicle (_this select 6);

_bullet = "Sh_120_SABOT" createVehicle _pos;
_bullet setpos _pos;
_bullet setvelocity _velo;
_bullet setvectordir _vect;
}];

---------- Post added at 20:30 ---------- Previous post was at 19:35 ----------

I figured out that problem, but a new one arrises.

Is there any way to get the position of a player, plus one meter to his front? I know how to move it in accordance with the poles, but I need it in accordance with the players direction.

Share this post


Link to post
Share on other sites
Is there any way to get the position of a player, plus one meter to his front?

Example with universal function:

PosTowards = 
{
private ["_pos","_angle","_dst","_dX","_dY","_px","_py"];

_pos = _this select 0;
_angle = _this select 1;
_dst = _this select 2;

_dX = _dst * (sin _angle);
_dY = _dst * (cos _angle);

_px = (_pos select 0) + _dX;
_py = (_pos select 1) + _dY;

[_px,_py,0]
};

_posFront = [(getPosATL player),(getDir player),1] call PosTowards;

Share this post


Link to post
Share on other sites

Purepassion - The M107 anti tank is going to be used as a special ability for a sniper in one of my game modes. He will be limited to firing a sabot round from his gun once every so often.

Rydygier - Thanks! I will give it a quick test soon and let you know of the outcome!

---------- Post added at 06:13 ---------- Previous post was at 05:06 ----------

Given I made a few modifications, Its working!

The following code, when applied to a units init scrip, will replace the end result with the one specified.

In the example of the KSVK, bullet maintains its standard trajectory and ricochet properties. Upon impact it changes into the desired effect. In this case, a tank SABOT round.

this addeventhandler ["fired",{
_btype = _this select 1;
if (_btype == "ksvk" or _btype == "m107") then {
   _velo = velocity (_this select 6);
_dir = getdir (_this select 6);
_pos = getpos (_this select 6);
_vect = vectorDir (_this select 6);
deleteVehicle (_this select 6);

_dX = 1 * (sin _dir);
_dY = 1 * (cos _dir);

_px = (_pos select 0) + _dX;
_py = (_pos select 1) + _dY;

_bullet = "Sh_120_SABOT" createVehicle [0,0,50];
_bullet setpos [_px,_py,(_pos select 2)];
_bullet setvelocity _velo;
_bullet setvectordir _vect;  
};}];

By no means is this script made to be ran in a production environment as is. This snippet is simply a doorway into what you can expand upon.

---------- Post added at 06:27 ---------- Previous post was at 06:13 ----------

Okay, more questions!

Is there a way to detect if a players binoculars are being looked through? How can I get the position he is looking at?

Edited by Wyattwic

Share this post


Link to post
Share on other sites

For checking if player is looking through some optics:

_isOptics = (cameraView == "GUNNER");

For checking, if unit is using binoculars:

_isBinoc = ((currentWeapon _unit) == "Binocular");

or

_isBinoc = ((currentWeapon _unit) in ["Binocular",... if needed - listed any other binocular classes, rangefinders and so on]);

Position of player looking:

_lookPos = screenToWorld [0.5,0.5];

Checks, what coordinates has a point, that center of the screen (so player's eyes) is pointing at. It shows coordinates of some point ahead of player with proper azimuth also when player looks at the sky. I'm not sure, how in such case it determines exact point.

Additionally cursorTarget command returns object, that player is targeting currently, if any.

Share this post


Link to post
Share on other sites

Another question - Sorry, trying to learn as much as I can!

Is it possible to spawn a GBU or CH-29 and and have them lock on to a position?

Share this post


Link to post
Share on other sites

There are scripts, that make projectile act like homing towards given position. No ready code this time, the overall way - calculating direction, 3D velocity vector for given projectile position, target position and intended projectile speed, and applying such velocity vector. Repeated all th route of course.

Such thing was used here, but links are dead. Probably somewhere else too, I do not remember where though.

Spawning is easy. You have to know projectile class and position to spawn. The use createVehicle. Eg:

_bomb = "Bo_GBU12_LGB" createVehicle _spawnPos;

Share this post


Link to post
Share on other sites

Spawning the bomb is the easy part, I just want the bomb to lock on to a laser target.

I may have to resort to an AI A10 Spawning and set laser marker aware.

Ill look around some more for another lock on method.

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  

×