OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: CopyKill on 01 Jul 2003, 14:02:11

Title: ai co-op behaviour
Post by: CopyKill 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!)
Title: Re:ai co-op behaviour
Post by: PheliCan 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...  ;)
Title: Re:ai co-op behaviour
Post by: Killswitch 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:
"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:
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.
Title: Re:ai co-op behaviour
Post by: CopyKill 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