Home   Help Search Login Register  

Author Topic: ai co-op behaviour  (Read 1340 times)

0 Members and 1 Guest are viewing this topic.

CopyKill

  • Guest
ai co-op behaviour
« on: 01 Jul 2003, 14:02:11 »
hey there...
i'm trying to do a rescue mission, in which your target is to rescue and protect an impotant politician from a hostage situation.. now the main problem is the ai-politician, who doesn't really act cooperatively ;-)
there are two main problems:
1. The hostage should follow your team no matter which player is triggering him to join the team. (at the moment he can only be triggered by the group-leader [tag])
2. if you enter e vehicle, he should automatically enter the same vehicle, whatever it's name tag is (don't want to set up a trigger for every vehicle available in the mission :-) also he should leave the vehicle if you do, and shouldn't have to be triggered in a special location...
thanx in advance
(and switch; thanks for your advice to the transport question!)

PheliCan

  • Guest
Re:ai co-op behaviour
« Reply #1 on: 01 Jul 2003, 16:23:34 »
Use neatestObject[politician, "Man"] to determine which units is closest to the hostage. If this unit is a member of your group, use the join command...


Something like this:

Code: [Select]
#loop
_nearUnit = neatestObject[politician, "Man"]
?(_nearUnit in (units player)) : [_nearUnit] join player
~0.01
goto "loop"

The hostage is named "politician".
The script could use some tweaking thu...  ;)
« Last Edit: 01 Jul 2003, 16:24:38 by PheliCan »

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:ai co-op behaviour
« Reply #2 on: 01 Jul 2003, 16:49:30 »
(folds up shirt sleeves) Ok, lets have a look at the two problems at hand, shall we? Note that there may be more than one way to solve these things, depending on how you have things set up in the mission. Anyway, I'll note the assumptions I make as we go along.
Quote
1. The hostage should follow your team no matter which player is triggering him to join the team. (at the moment he can only be triggered by the group-leader [tag])
If the hostage (politician) is stationary (not moving, e.g. in a house ), do as follows:
    [1] make a small trigger somewhere near the hostage, elliptic, with say axis a and b set to 1 m.
    [2]zoom in on the map and drag that tiny area trigger on top of where the hostage is.
    [3]choose "F5 - Synchronize" and "connect" the trigger with the player group's leader.
    [4]open up the properties dialog for the trigger (double-click it). Have a look at the "Activation" drop-down menu and select
"Any group member"
[/list]Now we have a trigger that is activated by anyone in the player group getting within 1 meter of the hostage. In the trigger's On activation field, put
Code: [Select]
[politician] join player...and zoink - you have rescued the poor fella. :-)

Quote
2. if you enter e vehicle, he should automatically enter the same vehicle, whatever it's name tag is (don't want to set up a trigger for every vehicle available in the mission :-) also he should leave the vehicle if you do, and shouldn't have to be triggered in a special location...

(Scratches head) Ok... let's see... off the top of my head, I can think of a few ways to do it:
  • Add a "getin" event handler to all vehicles the player might use and let that event handler run a cunning script to get the hostage to enter same vehicle
  • Have a sort of monitor script running, checking wether or not the player is in a vehicle from time to time and upon noting that the hostage is rescued and the player has entered a vehicle, get the hostage to enter same transport.
  • Require the lazy player to boss around the hostage, manually telling him to mount the player's ride. I like this one, since I won't have to tailor-make a scripting solution for you. ;-)
Take a moment to consider these tree possible solutions and tell me what you think would fit.

PS. PheliCans script can be tweaked/bug fixed like so:
Code: [Select]
#loop
_nearUnit = neatestObject[politician, "Man"]
?(_nearUnit in (units player)) : [politician] join player
~0.5
goto "loop"

Changed two things: 1 - it's the politician that should join the player group, not whomever is nearest to the politician.  2 - waiting only 0.01 secs between iterations is a waste of valuable CPU time. OFP, as we all know, chews CPU like its going out of fashion...  ;D

Quote
(and switch; thanks for your advice to the transport question!)
You're welcome! Please go back to that thread and mark it as "problem solved". Helps keep the forum neat and tidy.

CopyKill

  • Guest
Re:ai co-op behaviour
« Reply #3 on: 02 Jul 2003, 03:44:03 »
Hey again..
thanx for your tips guys!
i just got home (it's 3:18am) and need some sleep, so i will test your ideas later on.. ;-)
and about the hostage guy: i too think giving him orders manually would be the easyest way to handle it.. thanx anyways :-)

read ya l8er
copy