Home   Help Search Login Register  

Author Topic: How can I make AI start and stay inside houses?  (Read 1461 times)

0 Members and 1 Guest are viewing this topic.

Offline DOA

  • Members
  • *
  • ArmA 2 Rules - Nothing else comes close!
    • The Graveyard Shift
How can I make AI start and stay inside houses?
« on: 15 Sep 2005, 16:39:47 »
I'm trying to make a mission where we go door to door looking for good guys and bad guys. Can someone tell me how to get AI to start or enter houses and then stay there till we come looking for them? Thanks...DOA
ArmA 2 - Nothing else comes close!
--
DOA

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:How can I make AI start and stay inside houses?
« Reply #1 on: 15 Sep 2005, 17:50:21 »
You can do that with the help of indexed positions, which are special positions in some buildings (enterable). Not all enterable buildings have them.

First you need to know the number of indexed positions in the building. You can use a function I wrote the other day:

buildingPosCount

BuildingPosCount gives you the absolute number of indexed positions in a building.

The next step might be to order (setPos or make them walk there like in this example) some AI soldiers to the positions. You can do it with the buildingPos function:

Code: [Select]
_unit move (_building buildingPos _rpos)
This code is from a script which is not complete, so I can't show all to you. But it gives you an example how you can use the buildingPos function. In the code above, _unit is of course the soldier you want to order to the building, _building is the building :) and _rpos is the index number of the position in the building.

You can pick the index number randomly so AI goes to some other position the next time you play your mission. Take a random integer between 0...(n-1) where n is the total number of indexed positions which buildingPosCount gives to you. And then order your AI to go to that position.

Important: If a building has for example 8 indexed positions, you can use them as 0...7 with the buildingPos function (because arrays in OFP start from 0, not from 1).

Note: AI has a lot of trouble when they are inside buildings. They might go through walls or go to the basement so that you can't see them anymore and they get stuck there. So it's not perfect but it's what we have.

After you have entered a house and the AI sees you, you can make the AI move to another position outside the house so he runs away from you, if possible. Commands you might need in this situation might be knowsAbout and move.
« Last Edit: 15 Sep 2005, 18:21:42 by Baddo »

Offline DOA

  • Members
  • *
  • ArmA 2 Rules - Nothing else comes close!
    • The Graveyard Shift
Re:How can I make AI start and stay inside houses?
« Reply #2 on: 15 Sep 2005, 21:05:32 »
Outstanding baddo! Thank you very much. I will try this right away.
Thanks again.
ArmA 2 - Nothing else comes close!
--
DOA