Home   Help Search Login Register  

Author Topic: Script Request - AI Spotting  (Read 2550 times)

0 Members and 1 Guest are viewing this topic.

Offline trooper543

  • Members
  • *
Script Request - AI Spotting
« on: 01 Feb 2008, 16:46:04 »
Hi there all

I was wondering if anybody in the community has a script that will allow an AI soldier be a spotter?

What i would like to do is have AI soldiers that acts as a spotter's within different groups, that when they spot heavy armour / large groups that they will relay the information back to the player (who is in a different group) by marking the map as well as when the make contact with the enemy.

The main aim is to ensure info is passed back to the player so that the player can co ordinate his attack with the info

Any help and assistance will be very much appreciated

thanks

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Script Request - AI Spotting
« Reply #1 on: 01 Feb 2008, 17:19:22 »
First, with a presence trigger placed where the spotter is, and with a range equivalent to normal visual range would be enough to get the list of units that the spotter might "see" (you may create this trigger dinamically and keep moving it to spotter position every a pair of seconds in a loop, for example). Now you only need to use knowsAbout command to check how much the spotter knows about every unit into the trigger list. you might set a minimum knowsabout level to mark the position of a vehicne in the map. For example, with 1 you might mark position, above 1 you mark direction and type of unit too.

Offline trooper543

  • Members
  • *
Re: Script Request - AI Spotting
« Reply #2 on: 01 Feb 2008, 17:32:01 »
@ Mandoble

Thanks you so much for the response

Sorry to sound like idiot but where would i start ? Sorry just that i am not a scripter

I will check out the knowabout command

thanks


Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Script Request - AI Spotting
« Reply #3 on: 01 Feb 2008, 17:48:56 »
Hope this is easy to follow

Code: [Select]
// spotter.sqf
// res = [spotterunit]execVM"spotter.sqf"

// Looking for EAST units
_spotter = _this select 0;
_maxrange = 1200;
_trigger = createTrigger ["EmptyDetector", getPos vehicle _spotter];
_trigger setTriggerActivation ["EAST", "PRESENT", false];
_trigger setTriggerArea [_maxrange, _maxrange, 0, false];
_trigger setTriggerType "NONE";
_trigger setTriggerStatements ["this", "", ""];
_trigger setTriggerTimeout [0, 0, 0, false ];
// The trigger is created, its list will contain any EAST unit or vehicle present and closer than 1200m to its center

while {alive _spotter} do
{
   // Trigger is placed at spotter (or spotter vehicle) postion
   _trigger setPos getPos vehicle _spotter;

   // We wait a second to make sure the list of the trigger is correctly updated after the change of position
   Sleep 1;

   // Now the list is examined, looking for units known by the spotter
   {
      if (_spotter knowsAbout _x > 0) then
      {
         hint format["Our spotter knows something about %1 which is at %2 heading to %3", _x, getPos _x, getDir _x];
      };
   } forEach list _trigger;
   Sleep 3;
};

deleteVehicle _trigger;
« Last Edit: 02 Feb 2008, 11:05:13 by Mandoble »

Offline trooper543

  • Members
  • *
Re: Script Request - AI Spotting
« Reply #4 on: 01 Feb 2008, 19:08:20 »
@ mandabole

Once again thanks you ever so much !! It is really appreciated

So i just call the script in the spotter units int?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Script Request - AI Spotting
« Reply #5 on: 01 Feb 2008, 20:11:28 »
You may create a init.sqf file, which is automatically executed at mission startup and inside:

Code: [Select]
//init.sqf
[spotterunitname]execVM"spotter.sqf";

Offline trooper543

  • Members
  • *
Re: Script Request - AI Spotting
« Reply #6 on: 02 Feb 2008, 10:43:49 »
@Mandoble

Thanks once again for the script and the help it is very much appreciated.

i setup a unit called spotter 1 put the script and init script in the mission folder and i get an error message saying error line 12

have i done something wrong?

thanks

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Script Request - AI Spotting
« Reply #7 on: 02 Feb 2008, 11:05:41 »
lol, sorry _spotter = _this select 1; should be _spotter = _this select 0;
Already corrected above.

Offline trooper543

  • Members
  • *
Re: Script Request - AI Spotting
« Reply #8 on: 03 Feb 2008, 01:06:36 »
@ Mandoble

Sir, you are a gentlemen and a scholar!! and i again thank you

Offline LeeHunt

  • Former Staff
  • ****
  • John 21:25
Re: Script Request - AI Spotting
« Reply #9 on: 03 Feb 2008, 14:52:35 »
this is a great idea! i was looking for something similar.  i'll test it out when i can but i think this should also be a Resource for ofpec...

Offline Tajin

  • Members
  • *
Re: Script Request - AI Spotting
« Reply #10 on: 03 Feb 2008, 16:16:23 »
Haven't messed around with that command yet, but I believe it could be used for very much the same thing, just without triggers.:

http://community.bistudio.com/wiki/nearTargets

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Script Request - AI Spotting
« Reply #11 on: 03 Feb 2008, 19:25:10 »
Yes, nearTargets is also an option. Problem (or advantage) is that all data comming from it is "perceived".