Jump to content
Play3r

check if player see a unit in his Binoculars

Recommended Posts

Hey to all you great scripters in the A3 forum.

 

I want to make a kind of a small intro to a game i want to make, that involves the player being a spotter for a Ai Sniper,

when the player have spotted the target with his binoculars the Ai will  shot the target.

 

To make it simple:

the target is named Targetoff

Ai sniper is named AiShooter

 

I have set up a trigger with this in ACT.

Aishooter DoTarget targetoff; Aishooter DoFire Targetoff; Targetoff setdamage 0.95;

 

All i need is a COND for my trigger.

I have tried to put a radio Alfa and that works great so the Ai DoFire at the targetoff.

 

if there is a tread in the forum plz guide me to it, i have tried to do a search but did came up empty handed.   

 

Share this post


Link to post
Share on other sites

A simple knowsabout check should do it.

If the player knows about a unit, the information immediately jumps above 0 and is shared with all other members of the group.

You can check for player or group player, makes no difference:

group player knowsabout targetoff > 0

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Grumpy Old Man said:

A simple knowsabout check should do it.

If the player knows about a unit, the information immediately jumps above 0 and is shared with all other members of the group.

You can check for player or group player, makes no difference:


group player knowsabout targetoff > 0

Cheers

Thanks @Grumpy Old Man

But will that not fire the trigger if the AiSniper see him first before the player does ?

it looks like the AiSniper fires before i find the TargetOff even if i look the other way.

Share this post


Link to post
Share on other sites
2 hours ago, Play3r said:

But will that not fire the trigger if the AiSniper see him first before the player does ?

 

Yeah, but what about combining that with cursorTarget or cursorObject, as well as a check for the binos being looked through?

  • Thanks 1

Share this post


Link to post
Share on other sites

 

currentWeapon player in ["Laserdesignator", "Laserdesignator_01_khk_F", "Laserdesignator_02", "Laserdesignator_02_ghex_F", "Laserdesignator_03", "Laserdesignator_mounted", "Laserdesignator_pilotCamera", "Rangefinder"]

Is how I check if the player is using the binos or rangefinder etc

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

Can will return "GUNNER" if the player is actually looking through the optics.

The you can use cursorobject as @beno_83au suggested

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

maybe like this:

put this in the AiShooter's init:

AiShooter disableAI "MOVE";
AiShooter disableAI "TARGET";
AiShooter disableAI "AUTOTARGET";

and maybe this in a trigger:

[] spawn { 

while {alive TargetOff} do { 
      	
	if (currentWeapon player == "Binocular" && cameraView == "Gunner" && cursorObject == TargetOff) then {  
	if (!lineIntersects [getPosASL Aishooter, getPosASL Targetoff] && [getposatl AiShooter,getdir AiShooter,45, getposatl TargetOff] call BIS_fnc_inAngleSector) then {  
  	AiShooter doTarget TargetOff;  
  	AiShooter forceWeaponFire [weaponState AiShooter select 1, weaponState AiShooter select 2];};  
  		};
	};  
};

 

  • Like 1

Share this post


Link to post
Share on other sites
On 3/2/2020 at 4:41 PM, Alert23 said:

maybe like this:

put this in the AiShooter's init:


AiShooter disableAI "MOVE";
AiShooter disableAI "TARGET";
AiShooter disableAI "AUTOTARGET";

and maybe this in a trigger:


[] spawn { 

while {alive TargetOff} do { 
      	
	if (currentWeapon player == "Binocular" && cameraView == "Gunner" && cursorObject == TargetOff) then {  
	if (!lineIntersects [getPosASL Aishooter, getPosASL Targetoff] && [getposatl AiShooter,getdir AiShooter,45, getposatl TargetOff] call BIS_fnc_inAngleSector) then {  
  	AiShooter doTarget TargetOff;  
  	AiShooter forceWeaponFire [weaponState AiShooter select 1, weaponState AiShooter select 2];};  
  		};
	};  
};

 

@Alert23 i keep getting a error either i put this in the COND or ACT filed of my trigger.

 

If i put inside the COND it says :

Type script, expected Bool

and i get a something about the script with a # in the first line of code.

 

If i put it inside ACT ist says :

On activation Type Script expected Nothing..

 

What can i be doing wrong, do i need to use CBA to get the script to work??

 

thanks

 

Share this post


Link to post
Share on other sites
2 hours ago, Play3r said:

@Alert23 i keep getting a error either i put this in the COND or ACT filed of my trigger.

 

If i put inside the COND it says :

Type script, expected Bool

and i get a something about the script with a # in the first line of code.

 

If i put it inside ACT ist says :

On activation Type Script expected Nothing..

 

What can i be doing wrong, do i need to use CBA to get the script to work??

 

thanks

 

sry, i test that in debug console.

 

Trigger Cond:

currentWeapon player in ["Laserdesignator", "Laserdesignator_01_khk_F", "Laserdesignator_02", "Laserdesignator_02_ghex_F", "Laserdesignator_03", "Laserdesignator_mounted", "Laserdesignator_pilotCamera", "Rangefinder","Binocular"] && cameraView == "Gunner" && cursorObject == TargetOff && !lineIntersects [getPosATL Aishooter, getPosATL Targetoff] && [getPosATL AiShooter,getdir AiShooter,45, getPosATL TargetOff] call BIS_fnc_inAngleSector && alive TargetOff

On activation:
 

[] spawn {
AiShooter doTarget TargetOff;
sleep 1;  
AiShooter forceWeaponFire [weaponState AiShooter select 1, weaponState AiShooter select 2];};

 

  • 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

×