Jump to content
Sign in to follow this  
fasad

AI vs animated gates

Recommended Posts

Hi,

I'm making an island that features fenced off areas such as military bases and industrial estates. I would like the AI to only be able to enter/exit these areas through open gates. The problem is they either can't go through at all or run straight through the closed gates. I would like this to be solved naturally, that is without any monitoring or forced AI movement scripts! Too much overhead for such a stupid problem...

I'm specifically working with Mapfact fences and gates found in baracken 1.5. This problem covers many different aspects of OFP. This are the solutions I've tried and their results:

Add a F3WX path object to the wrp

No effect other than visible white blobs. bad p3d??

Add a path lod to the gate p3d

AI run straight through both open and closed gate via path.

Rotate path with gate animation

Apparently does not work. The path remains the same.

Re-model objects so their initial geometry allows passage

I noticed that AI only seem to only use the objects initial geometry. I editing the gates p3d so that they are initially open, and moved the memory vertices (the ai decide object size based on whichever vertices cover the largest area irrespective of LOD). I then reversed the config.cpp animations. Result = AI runs through both open and closed gates.

SetDammage 1, then setDammage 0 (several times)

This seems to trick the AI into thinking the object has no geometry. Ai Run straight through open and closed gate. Cannot be reversed?

Any suggested solutions? Maybe the gate object could be replaced with an indenticle but ai move transparent version when it is opened via the config animations, and visa-versa? What a pain!!

Share this post


Link to post
Share on other sites

do you mean that you want to animate the gate that has been placed in WRPTool without using scripts directly set up from a mission? So that everytime a soldier would move near the gate, it would open?

Share this post


Link to post
Share on other sites

Gate problem isn't an easy one...even portals without gates are sometimes a problem and may need a path lod to make AI go under it...maybe geo lod must be "perfect" (no non closed, no non convexity) to make it work..

Anyway you may solve it by creating "opened" gates and camcreating an invisible wall at the gates when they are closed, and deleting it when they are open. Another way could be a "setdir" script that progressively rotates the whole gate model around its center (which should modified), but it won't work with Wrp placed objects...

Share this post


Link to post
Share on other sites

linker split - the problem is that AI unit will not walk through a gate that can be opened by the animate command. This becomes a problem if that gate is the only way into an area.

create a geo only gate object when gate is closed to stop ai passing

I created an new object and script to place it over the existing gates when they shut. Opening deletes them. Depending on the alignment of the stars, AI will either walk straight through closed gate, or refuse to go through the gate after it has been closed then re-opened.

Share this post


Link to post
Share on other sites

uhm... understood... I'll make a search for it...

uhm...

try with this

Do you know what's the animationPhase of the gate?

Well, write a script that would lock the AI to move straight through the closed gate (so in the script put a condition that if the animationPhase of the gate is >= 0.5) then the AI will stop moving.

When the gate is open (so the animationPhase < 0.5) the Ai start again to move wink_o.gif

The script would be something like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;Set the movements of a soldier

;SYNTAX

;[nameofsoldier,"class of gate"] exec "stopAI.sqs"

;START of script

_soldier = _this select 0

_gate = _this select 1

_nearestgate = nearestObject [_soldier,_gate]

;Check the distance between soldier and the gate

_n = 2  ;//this sets the distance that the gate will be opened or closed

#START

? (_soldier distance _nearestgate) <= _n : goto "CONTINUE"

~0.01

goto "start"

#CONTINUE

;//check if the gate is opened or closed

?(_nearestgate animationPhase "name_of_animation" < 0.5) : goto "Open"

#CLOSE

dostop _soldier

;//Wait until the gate will be open

?(_nearestgate animationPhase "name_of_animation" < 0.5) : goto "Open"

goto "CLOSE"

#OPEN

;// In this case the Ai will be forced (via Switchmove) to move

~0.8

_soldier switchMove "CombatRunF"

~2;//Don't remeber the time of this animation... check it out

_soldier switchMove "CombatRunF"

exit

Share this post


Link to post
Share on other sites

I realise that a script to control units could solve this, but as I said in my first post, I don't want to do that. It's not at all suitable for non-linear missions and a total waste of CPU time! If that's the only way to get it done, I will just use fixed open gates or no gates at all.

Thanks anyway, have you any other suggestions? smile_o.gif

edit : Ooohh, maybe I could create a path only object upon gate opening, then delete it upon closing? Hmmm....

Share this post


Link to post
Share on other sites

create a path object when gate opens, delete it when gate shuts

semi-success, using large path with many branches on either side of the gate. If the AI is already within or near the path they will use it, so the player + his group can go through if they are in formation. If they are 50m+ from the gate when order is given they will not "see" the paths and will not attempt to pass through the gate.

AI inside path object likes to stay within it, so once through the gate they act a bit weird. I'll work on it some more tomorrow. good night smile_o.gif

Share this post


Link to post
Share on other sites

Im a semi noob in O2 modeling, but your latest problems looks like you forgot the start and end points fot the path?

I had the reversed problem: I wanted to make a tunnel (large mountain with hole) but AI refuses to move under it, and paths didnt quite work for vehicles.

Share this post


Link to post
Share on other sites

I labeled the vertices in#, but it seems the AI will only consider using paths if they are close by. I don't think they are the best solution for the gate problem.

It also seems the AI get all their route finding geo info in 2 dimensions only, so they will not walk under anything, including trees! When on a path, the AI will be able to ignore any geo info about an object and walk straight through. Soft vehicles can drive under objects as long as they are driving along a road. Driving AI is another problem for another day, I'm sick of seeing the AI drive off my nice straight road into a tree.

It seems the AI get their knowledge of static objects during initialisation of the mission. If you move a (mission editor placed) static object, the AI still behave as if it lies in it's original location. They will walk around it's initial location footprint as if it was still there, and will walk straight through it at it's new location. If you create a new static object, as far as the AI movement is concerned, it does not exist! Units created during a mission behave the same as those who have been there since init (inherit stupidity from the dummy unit?). Static means static...

However, this behaviour does not apply to non-static objects, such as tanks. I'll try creating a invisable gate with a tank based class and see if that will stop the buggers!!

Share this post


Link to post
Share on other sites

SOLVED smile_o.gif

Thanks for the input! My solution is basically as ProfTournesol describes :

Quote[/b] ] you may solve it by creating "opened" gates and camcreating an invisible wall at the gates when they are closed, and deleting it when they are open.

I have modified some gate p3ds so that they are initially open rather than closed. The memory vertices for the actions need to be moved closer to the gates hinge to allow the ~5m needed to allow the AI to pass (see my initial post). In each gates config, launch one script/function when closed, and another when it's opened.

The closed script creates a small underground object on either side of the closed gate to scare off the AI. As they are underground they have no influence on players or vehicles. The open gate script deletes the objects. I made a custom object that is basically a 20cm cube, with simulation = "thing" - without this the AI will walk straight through. The scripts should also setPos the objects, to make sure they are in the correct place after being created. Trig is needed to account for all gate orientations. Use an event Handler type "killed" to execute the gate open script if the gates are destroyed (and remove the EV with the gates opened script). I assume EV overheads are low enough to cover the ~10 such gates on my island without any affect?

Now I'm waiting on permission to create some modified gates based on the mapfact barracken gates, or failing that I'll make my own from scratch. Once I get a nice clean version going I'll post the scripts etc.

Share this post


Link to post
Share on other sites
Have you looked :

Here

and

here ?

Thanx, but I cancelled that project a year ago. (I made some objects for an island that is never completed)

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  

×