Jump to content
Sign in to follow this  
SaOk

Line Of Sight (Example Thread)

Recommended Posts

TerrainIntersect was changed to ATL in 94103. I updated the first post example to use new terrainIntersectASL command which works with the eyePos.

Share this post


Link to post
Share on other sites

Thanks, Sa0K - quick work indeed :)

Getting the message "The file you are looking for seems to be unavailable at the moment. Please come back later" on Game Front. Not unusual for them, seems it takes their server hours to update (or whatever). Will edit this post when I find the download is working.

Share this post


Link to post
Share on other sites

It was available after I uploaded it, will check that time to time and reupload if needed. The old example also works, you just need to add ASL after the terrainintersect in LOS.sqf.

Share this post


Link to post
Share on other sites

Thanks, Sa0k. Still getting the same message on Game Front, but no worries, their server isn't the sharpest blade in the rack. It will probably be OK tomorrow.

Briefly tried the combination of the 16 June PBO with the 93965 beta, the latest asr_ai v1.15.1 & TPWC suppression yesterday - this combination really does change the game, vastly better combat. I also tried it with no_auto_engage, ai_dodge & findcover from COSLX - all seemed to work fine together. All I need to do now is get some more time to play!

Edit: download working OK this morning :)

Edited by Orcinus

Share this post


Link to post
Share on other sites

Hi All

ive added LOS to the next version of battlezone and - WOW it changes the game play in a big way.

with a bit of creative scripting MLRS's and GRAD's are in the game with AI firing at targets and over hills ,

so far have not seen a missile hit a hill or structure.

my question is , does anyone know or care to guess will these commands be in any ARMA2 updates or just OA?

Share this post


Link to post
Share on other sites

I've uploaded a slightly reworked version of my AI LOS addon, incorporating the new terrainintersectasl command. As usch, it will only work on beta 94103 or greater.

http://filesonly.com/download.php?file=384TPW_AI_LOS_100.zip

Zonekiller, I've been flat out with working on the AI suppression mod, will be in touch soon about a more comprehensive AI LOS mod.

Edited by tpw

Share this post


Link to post
Share on other sites

ive been fooling around with different ways of gathering info on enemys instead of using nearestobjects and only running parts of the code that is relivant at the time

and now can run LOS on 400 AI without FPS drop

not only can they react to a seen target they will switch to the nearest target if one comes closer and can switch again if someone shoots at them and fall back to cover in

buildings ect

im still learning how to make it as a addon without using CBA so it will run on createunit as well as units put in the mission editor - any ideas ?-

Share this post


Link to post
Share on other sites

Hey guys been trying to keep up to date with whats going on in here, most of it way beyond my level of scripting knowledge. But the results speak for themselves, bloody fantastic...

I have a quick question for a mission concept i'm working on.

Would it be possible to use the new commands to detect if a player can see a certain object. Similar to doing a Detected By trigger. So when a unit has LOS on an object or AI unit whatever, it can set a trigger off which can be tied to an objective?

Share this post


Link to post
Share on other sites

glad to hear it :p you've probably guessed the next question...

If you get *insert time required*, could you post an example of how this would be achieved?

I would love you long time... well maybe just a few days, but we can discuss an extension period. ;)

Share this post


Link to post
Share on other sites

Thankyou zonekiller, gives me somewhere to start from, much appreciated.

Not sure i did the example mission right tho :p The girl got a bit of a suprise, when i threw her into the back of the hummer and made for the border.

Once again mate, cheers.

:beeeers:

P.S. You reckon this method would perform ok in a Dedicated MP enviroment?

Edited by Shadow.D. ^BOB^

Share this post


Link to post
Share on other sites

setvariable ["seen",[girl,plane],true]; change the setvariable's to true

hints are local but other then that YES

Share this post


Link to post
Share on other sites

Ok Zonekiller, i've managed to have a look and play with putting the example into a simplyfied test version of the mission idea while i get it working as intended. Just got a few questions, to try and get my head around exactly what is going on.

Sorry bear with me for this next bit...

Ok so my understanding of the variables that are in the example mission is that the variables are set so that only the objects that are "available" to be spotted are those that are sent in the variable as per each case.

So the init has

player setvariable ["seen",[boss,girl],true];

This means that the player LOS is only going to set off the hint when boss or girl are spotted. When then the girl is spotted, there is no change in the variable, meaning she can keep being spotted. Upon activating one of the other cases i see the variable is changed to allow only the "objectives" past that point to be spotted, aswell as the girl.

Correct?

I'm hoping that was as difficult to read, as it was to write :)

Ok so to my questions...

I have a simple layout of 4 Static MG positions, these are positioned N,E,S,W of the player on a runway.

NorthMG

EastMG

SouthMG

WestMG

The init.sqf is currently like this:

player setvariable ["seen",[NorthMG,EastMG,SouthMG,WestMG],true];

player execVM "ZKs_LOS_OBJECTS.sqf";

The seen.sqf like this:

while {true} do
{

waituntil {!isnil {_this getvariable "seen"}};

switch _this do
{
case NorthMG : {[nil,nil,rHINT,"HMG Position Spotted"] call RE;};
case EastMG : {[nil,nil,rHINT,"HMG Position Spotted"] call RE;};
case SouthMG : {[nil,nil,rHINT,"HMG Position Spotted"] call RE;};
case WestMG : {[nil,nil,rHINT,"HMG Position Spotted"] call RE;};
};



sleep 10;

_this setvariable ["seen",nil];

};

So at the moment any of the positions can be spotted multiple times. How would i eliminate one of the cases from the "seen.sqf", if it had already been spotted, or mark that certain object as spotted so the script would not consider it a valid LOS target to spot? Bearing in mind that any of the MG's can be spotted in no particular order.

Second question, could the angle of the LOS be reduced, so that the player would really have to be looking directly at the object/unit to fire the hint off? The idea is to use this for a recce mission.

I apologise for the massively long response...

Edited by Shadow.D. ^BOB^

Share this post


Link to post
Share on other sites
This means that the player LOS is only going to set off the hint when boss or girl are spotted. When then the girl is spotted, there is no change in the variable, meaning she can keep being spotted. Upon activating one of the other cases i see the variable is changed to allow only the "objectives" past that point to be spotted, aswell as the girl.

Correct?

YES

as far as the other stuff it depends on how you want it to work and how you setup the object arrays IE -

the ZKs_LOS_OBJECTS runs local to the player / unit

if all players share the object array then that will need to run on the server.

so if you add a wreck to the mission editor and call it S_Arrays then it would be done like this

in the init.sqf

if (isserver) then {

S_Arrays setvariable ["seen",[NorthMG,EastMG,SouthMG,WestMG],true];

};

ZKs_LOS_OBJECTS.sqf

_a = _this;
_delay = .1;


_veh = vehicle _a;
_eyeL_lock = 0;

while {true} do
{
[color="#FF0000"]// _nearunits can be any array you want , how ever you want to get it. [/color]
_nearunits = S_Arrays getvariable "seen";

_mytarget = objnull;
_pos2 = getpos _a;



		{
		_near = _x;
		_cansee = 0;

		if (alive _x) then 
			{
			_tInt = true;
			_lInt = true;
			_b = _near;
			_pos1 = getpos _b;


			_eyeD = 0;
			_eyeL = 0;

			[color="#FF0000"]// change the _left and _right number closer to 180 to narrow the view while on foot[/color]

			_left = 145; 
			_right = 215;

			_eyeDV = eyeDirection _a; 
			_eyeL_lock = if (_veh != vehicle _a) then {((_eyeDV select 0) atan2 (_eyeDV select 1))}else{_eyeL_lock};
			_veh = vehicle _a;


				if (vehicle _a != _a) then {


				_eyeL = direction _veh - 360;					

					if (_a == assignedGunner _veh) then
					{
					_gun = vehicle _a weaponsTurret ((assignedVehicleRole _a) select 1); 
					_guntype = (_gun select 0);
					_eyeGUN = vehicle _a weaponDirection _guntype; 
					_eyeL = ((_eyeGUN select 0) atan2 (_eyeGUN select 1));
					};

				[color="#FF0000"][/color][color="#FF0000"]// change the _left and _right number closer to 180 to narrow the view while in a vehicle[/color]
				_left = 130;
				_right = 230;
				};

				if (vehicle _a == _a) then {_eyeL_lock = 0;_eyeL = 0};

				_eyeD = ((_eyeDV select 0) atan2 (_eyeDV select 1)) - _eyeL_lock;
				_eyeD = _eyeD  + _eyeL;

			_dirTo = ((_pos2 select 0) - (_pos1 select 0)) atan2 ((_pos2 select 1) - (_pos1 select 1));
			_dirTo = _dirTo % 360;
			_ang =  abs (_dirTo - _eyeD);

				if ((_ang > _left) && (_ang < _right)) then 
				{
				_posASLa = (getPosASL _a);
				_posASLb = (getPosASL _b);

				_lInt = if (vehicle _a != _a) then {lineIntersects [_posASLa, _posASLb,vehicle _a,_b]}else{lineIntersects [(eyePos _a), (eyePos _b),vehicle _a,_b]};

					if !(_lInt) then 
					{
						_tInt = if (vehicle _a != _a) then {terrainIntersect [_posASLa, _posASLb]}else{terrainIntersectASL [(eyePos _a),(eyePos _b)]};
					};

				};

			if !(_tInt) then {_cansee = 1;};

			};

			if !(_cansee == 0) exitwith 
				{
				[color="#FF0000"]// this section runs when an object is spotted - you can run any code you want here - [/color]
				_mytarget = _near;
				_mytarget execVM "seen.sqf";
				}; 
		} foreach _nearunits;

sleep _delay;
};

since you only need things to be spotted once

the seen.sqf would look like this and be local to the player or unit

[nil,nil,rHINT,"HMG Position Spotted"] call RE;
_seenarray = S_Arrays getvariable "seen";
_seenarray = _seenarray - [_this];
S_Arrays setvariable ["seen",_seenarray,true];

Edited by Zonekiller

Share this post


Link to post
Share on other sites

Tell you what Zonekiller, i only wish i could get to grips with this sort of stuff like you and others can... Give me a Pegasus 107 engine and i'll service and refit that bitch, but this code stuff, my brain just isnt wired for it.

Got a couple more little question, not like you havent done enough already but hey it might come in handy for others. I have implemented the method above, which works just fine. Just a couple of problems have arisen, more in the method in which it is being used rather than the purpose of the code. As stated previously, the mission idea i'm looking at using this with, will be a recce of an area.

1. It is possible to do a check if the unit has LOS on the target, for more than a couple of seconds? As it is now, even with the view angles reduced to just 1 degree either side of 180, a quick sweep across the area sets the script off. To actually have the player have to look at the object for more than a second or two, should solve this problem.

2. Like the reduction of the view angle (horizontal), is there a way to do a similar thing with the vertical, so again the player could not set off the LOS by viewing a position below or above the target.

Not a major issue with number 2. As this will most probably become mute, if there is a solution for the first.

I know i say it alot, but again i appreciate the time you are putting into helping me out with this.

Edited by Shadow.D. ^BOB^

Share this post


Link to post
Share on other sites

Now that 3.01 of the suppression script is out, we need more support on this LOS script :) No pressure guys :)

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  

×