Home   Help Search Login Register  

Author Topic: Prevent AI crawling through sandbag walls  (Read 1351 times)

0 Members and 1 Guest are viewing this topic.

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Prevent AI crawling through sandbag walls
« on: 27 Jan 2008, 01:34:35 »
I have another question (i can see myself getting reprimanded for asking too many silly questions soon), but i have another question i would like some help with....

Is it possible to prevent grouped AI moving through sandbag walls? I have a mission where there is 4 loons grouped each to a number of static Machine Guns in seperate forts. Im running a script that replaces the Machine Gunner when he is killed with a member of his group & this all works fine..but

I don't want the replacement gunners to be seen or vulerable to enemy fire...at least until they have moved into the gunners position. So to get around this i built a small pen using sandbag walls around the rear of each fort for the men of each group to hide behind (& looks quite good). I setUnitPos "DOWN" each of the replacement gunners which keeps them out of sight fine, however they do crawl around through the sandbag wall as though it was invisible & out into the open  ???

To get around this i tried disableAI "MOVE", this works to keep them behind cover okay...but then when it comes their turn to replace the dead gunner - they can't move! ...well obviously der...i've disabled thier ability to move! Well i thought about enableAI "MOVE" each time the gunner dies, but i can't because the "ReplaceGunner.sqs" i'm using is generic & is one script called by each MG.

Though if i could just prevent the loons from each group crawling through their designated fort's sandbag walled pen, all would be fine & my problem solved...So is it possible to prevent them behaving this way. I also don't understand why a group that has no waypoints & each members formation is set to "NONE" when created in the editor ALWAYS then decide to move into formation when mission starts  :blink:  formation is set to none isn't it?

I'm really sorry for rambling on but i just figured it be best if i explain the situation as best i could so that you know exactly what i'm trying to do & where my knowledge of this game engine is at this moment...i never learnt through OPF, though if i had of known what could be done with this engine i would of started long ago.

Want to know is this;
1.) Is it possible to prevent a group that has no waypoints moving into formation at mission start without using disableAI "MOVE". I don't really feel like running a dozen looping scripts that are identical just so i can enableAI "MOVE" again when the gunner needs replacing...when the generic script i'm using works fine for all groups.

Code: [Select]
;MGReplace.sqs
_mg = _this select 0
_gunners = _this - [_this select 0]

#Loop
@ count (crew _mg) < 1
? not alive _mg : exit

#Choose
_newGunner = _gunners select random(count _gunners)
_gunners = _gunners - [_newGunner]
? (count _gunners < 1) and (not alive _newGunner) : exit
~1
? not alive _newGunner : goto "Choose"
_newGunner assignAsGunner _mg
[_newGunner] orderGetIn TRUE
? count _gunners < 1 : exit
goto "Loop"

2.) Is it possible to prevent the AI from crawling through editor placed objects, ie sandbag walls.

I hope this makes sense to someone
« Last Edit: 27 Jan 2008, 01:57:53 by Carroll »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Prevent AI crawling through sandbag walls
« Reply #1 on: 27 Jan 2008, 10:50:35 »
Simple solution here: just add one line to the below code, and it'll happily run on all instances of the replacement. I'd say the best place is right here:

Code: [Select]
....
? not alive _newGunner : goto "Choose"
_newGunner assignAsGunner _mg
[_newGunner] orderGetIn TRUE
[b]_newGunner enableAI "MOVE"[/b]
? count _gunners < 1 : exit
goto "Loop"

That should enable the _newgunner's AI just as it's given the order to get into the gunner position as a replacement.  ;)

As to preventing the AI from crawling through objects etc: I think this is an issue half to do with animations (once an animation is started, for an AI, it will continue regardless of obstacles - which in some cases leads to clipping), and half to do with streaming - once the AI is outside a certain range, their "collission detection" is relaxed quite a bit, causing them to do silly stuff like run through walls and bushes and stuff. :) So no - I don't think there's much you can do!

G'luck!

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: Prevent AI crawling through sandbag walls
« Reply #2 on: 27 Jan 2008, 16:32:11 »
works great, thanks Wolfrug....however when the replace gunners is called, the rest of the groups movement animations start also (like you explained), & yeap they again begin crawling out through the sandbags as though they were invisible. Perhaps i should try re-disabling "move" somewhere in the script.....but frankly i'm happy with just disablingAI until the original gunner is killed & needs replacing like in your example - which only happens once the Landing boats are almost at the shore anyways. Keeping them in the enclosures was my main concern at mission start as i have quite a few artillery shells falling about the place until the boats reach land.

I'm not too worried if the replacement gunners then begin crawling around i guess, it adds an element of confusion to the mix once the action starts  :o

Anyway i've still got some more editing to do before the mission is even close to finished, thanks for your & everyone elses help :good:

Note: i've made quite a few missions already which are quite good i think & was wondering how i'd go about posting 1 or 2 here at OFPEC for others to enjoy some time in the near future?
« Last Edit: 27 Jan 2008, 16:36:08 by Carroll »

Offline Barbolani

  • Members
  • *
Re: Prevent AI crawling through sandbag walls
« Reply #3 on: 28 Jan 2008, 11:21:07 »
Hi ppl,

If i understood your request, youve got:

- Different forts, different MG positions.
- All the gunners of all the MG grouped, so they knowabout the same enemies...
- You want a replace gunner script, so if a gunner is killed and the MG is alive, another comes and mans the MG
- You want to keep that "backstage" of gunners as safe as possible, at least while they are waiting to be called to get into the MG.

Well, heres my suggestion. The solution is a bit a la CoD, but could improve your mission (Making ArmA more "gamey" Wolfrug  ;)

- In each fort, place a little building (maybe a Tent) so the new units will appear from there.
- Make a script that checks if the gunner is alive as you did.
- You can place at safe distance the units you want and after making a check if the gunner is alive, Setpos the new unit (kinda teleporting) in the building position, so the player cannot see him teleporting (make sure about it)
- Or, if you wish, I suggest to use createUnit instead, so you can directly provide infinite gunners till the MG is dead (kinda CoD)
- I suggest not to place the gun very close to that respawn point so the player has an oportunity to kill the gunner before he enters the MG (more CoD)
- In the script, make the unit join the group of gunners as soon as the gunner is into the MG
- Another suggestion, when the player reaches some distance to the respawn / teleporting points, interrupt the script.

If you really need the details about scripting that, im working on one, but is unfinished...


Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: Prevent AI crawling through sandbag walls
« Reply #4 on: 28 Jan 2008, 11:35:05 »
Thanks for sharing your ideas with me Barbolani, they are all very interesting to me & worthly of looking into further which i will do when time permits me. I think even if i don't use any of your suggestions for this mission, i will no doubt keep them in mind next time i want to acheive these results  :good:

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Prevent AI crawling through sandbag walls
« Reply #5 on: 28 Jan 2008, 11:58:24 »
Just a silly suggestion. I understand you have a protected area with sandbags and units there are lying on the ground. Well, you might do the following, put a second set of sandbags over the current ones so you create a "tall" sandbags wall, and let your units there standing up (while protected).

Check the lower-right screenshot here, at both sides of the main door, this is what I mean with the double sandbag "wall".
« Last Edit: 28 Jan 2008, 12:00:42 by Mandoble »

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: Prevent AI crawling through sandbag walls
« Reply #6 on: 29 Jan 2008, 04:31:10 »
Thanks Mandoble, i have no probs setting the pos of an extra set of bags like you suggest. My problem is that on mission start those in the enclosure can walk through the wall regardless of height as though the wall was invisible. I need prevent them from doing this.

Is there a way i can manipulate the LOD of the wall objects so that prevents this from happening?

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Prevent AI crawling through sandbag walls
« Reply #7 on: 29 Jan 2008, 06:36:28 »
Here's a couple suggestions:

1.  To keep unit from moving, try "dostop unit".

2.  When you want unit to exit the sandbag area, use a predefined sequence of animations.  By this I mean, point the  unit in the direction you want him to move (using setdir), and then use playmove or switchmove to execute the crawl animations to get him to exit area.  I have gotten units to perform very precise movements this way. 
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...