Some time ago I had a idea how to make AI soldiers to hide (take cover behind friendly tanks) - you know this scens - soldiers shooting to enemy and after a second taking cover. I know.... everyone wants to see this kind of stuff in action (so am I
)
This is my Idea:
All tanks and APC are more/less same size (I mean here how much ground they "use"). With help of very simple trigonometry (part of math- you know.. sin , cos , tg, ctg), getDir (I think this function was called so), and getPos we can find corner of a tank and other places which are in the moment give cover from enemy fire (we need to know where enemy shoot to us from - the event "fired" or "moust known enemy script" or its variants can be useful) and its ready.
So how I think this script should work?
1. If something goes wrong (or not wrong) (unit is being fired, pre-scripted trigger etc.) script is activated.
2. Script ("take cover behind tank !!") selects random or (not random) soldiers from our group to go behind tank , and to prone, and to stay there for while..
a) we get dir of tank
b) we get position of tank
c) we use data form a) and b) to calculate position where corner and cover
should be (more less of course)
4) doMove ....
5) wait till done
6) make AI use this cover - by making it stay in position (I saw it in custom formation script) combination of playmove and switch move (for custom moves)...
What do you think