Home   Help Search Login Register  

Author Topic: AI Infantry Refusing To Go Up Slope  (Read 3046 times)

0 Members and 1 Guest are viewing this topic.

Offline Meester

  • Members
  • *
AI Infantry Refusing To Go Up Slope
« on: 28 Sep 2010, 22:06:01 »
This is on Utes and after they have disembarked from a boat. The problem is the ai infantry refuse to go up a steep slope even though I, the player can walk and/or run up it. No waypoint shall convince them, nor getting them to move to a marker at the top of the hill (even though they move to the marker further along the beach in testing). I as the group leader cannot get them to move to the top of the hill where I am using the move command. I can spawn them up there but not get them to move on their own up. They just stand near the foot of the hill or run to the right a bit and then stand there instead doing nothing (if I move the waypoint to the right slightly for example). There seems to be a limit to where they can move to. Ive tried various waypoint behaviours but that does no good.

Is there any way to force them to move as well as I, the player up the hill. Can setting a topographical position of a waypoint and/or marker help? Bear in mind Im not too familiar with scripting, so maybe some explaination on how things work if you have a solution, wouldn't go amiss.

Offline ZapBrannigan

  • Members
  • *
Re: AI Infantry Refusing To Go Up Slope
« Reply #1 on: 29 Sep 2010, 05:46:21 »
This kind of thing usually involves some fiddling or a script.
attach the mission, i'll see if i can fix it for you.

zapp

Offline Meester

  • Members
  • *
Re: AI Infantry Refusing To Go Up Slope
« Reply #2 on: 07 Oct 2010, 01:02:08 »
Thank you very much. Im trying to get them to move to around the id 12076. Im not sure what to attach and as this forum doesn't allow sqm's to attach I hope this will do  :dunno:

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: AI Infantry Refusing To Go Up Slope
« Reply #3 on: 07 Oct 2010, 12:39:08 »
You could put the mission (or the relevant parts of it) in a ZIP file. ;)
try { return true; } finally { return false; }

Offline ZapBrannigan

  • Members
  • *
Re: AI Infantry Refusing To Go Up Slope
« Reply #4 on: 07 Oct 2010, 12:45:39 »
ha dude, this stuff is useless.  I need your mission file.  put the mission folder  in a zip and attach that.

Offline Meester

  • Members
  • *
Re: AI Infantry Refusing To Go Up Slope
« Reply #5 on: 11 Oct 2010, 01:27:27 »
Got ya. Here it is -

Offline ZapBrannigan

  • Members
  • *
Re: AI Infantry Refusing To Go Up Slope
« Reply #6 on: 11 Oct 2010, 16:54:04 »
Oh, you didn't tell me its on the tiny island.  AI path finding when on tiny islands is horrible. I tried a while but i cannot get them to go up using waypoints.   It looks like they aren't going to be anywhere near the player. why not just setpos them to the top when the player isn't looking.  Im not sure why you want them on that tiny island anyways. are they providing sniper cover?  It is easiest just to setpos them where you want them. But if for some reason the player is going to watch them go up the hill (which as far as i can tell he isn't) Then you will need to use an animation loop to manually "walk" them up the hill.  Its tedious though. Tell me if you want and i'll have a search on my drive and see if i still have my old one that can be modified for your situation. 

Offline Meester

  • Members
  • *
Re: AI Infantry Refusing To Go Up Slope
« Reply #7 on: 11 Oct 2010, 18:30:57 »
Im hoping for them to set-up a mortar on there and begin bombardment. Id like to get them to walk up the hill because teleporting is for me cheating & I prefer a dynamic environment where it looks as if the units are doing things by themselves [so no-one can go "aha!" thats how he does it, if they delve in further].

Id like to see how an animation loop works, if you don't mind too much. Id like to see how animation loops work too, so I would be able to do it in the future. Do you know why pathfinding on tiny islands is horrible? Many thanks.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: AI Infantry Refusing To Go Up Slope
« Reply #8 on: 12 Oct 2010, 09:32:04 »
Heya Meester,

The best I can suggest for AI-walking is something like "playaction walkf". You don't need an external script, just spawn one, for instance in the Init field of each unit:

Code: [Select]
_nul = this spawn {while {this distance endpoint > 2} do {this playaction "walkf"; sleep 0.5}; this playactionnow "walkf"}
Now all you need to do is place down something called "endpoint" (an invisible H or a Game Logic maybe), and mess around with the distance to make sure all the AIs move close enough to that point to stop :) Anyway, this should assure a smooth walk up just about anything, I think. If not, I'm out of ideas!

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

Offline ZapBrannigan

  • Members
  • *
Re: AI Infantry Refusing To Go Up Slope
« Reply #9 on: 12 Oct 2010, 10:06:36 »
Ah, if wolfrugs works then do that its much simpler.  but in case you were curious, the way i do animation loops is like this...


Basically an animation loop looks like this (in sqs because i think sqs is easier to learn because it is cleaner looking)

Code: [Select]
_unit = _this select 0
_tgt = _this select 1

? (((GetPos _Tgt select 1) - (GetPos _Unit select 1)) > 0): _Ang = ATan (((GetPos _Tgt select 0) - (GetPos _Unit select 0)) / ((GetPos _Tgt select 1) - (GetPos _Unit select 1)))
? (((GetPos _Tgt select 1) - (GetPos _Unit select 1)) < 0): _Ang = ATan (((GetPos _Tgt select 0) - (GetPos _Unit select 0)) / ((GetPos _Tgt select 1) - (GetPos _Unit select 1))) + 180
? _Ang < 0: _Ang = _Ang + 360

#loop
? (_unit distance _tgt)<5:exit
_unit setdir _ang
_unit switchmove"animationname"
~2
goto "loop"


The first line is the unit that will be moving
the second line is the place you want the unit to move to
the next few lines is a mathematical calculation to find the direction the unit should go to get to the target
the 6th line where it says  #loop  means start of a loop which in sqs scripting is well... like a loop :P  
the next line checks if the unit has arrived at the place, and if so it exits the script, if it is not then it ignores the part after the : and moves on to the next line.
in the next line we set the units direction as _ang which is a number value that was computed earlier to make the unit face the target. After that is the command that makes the unit play the animation, and finally a 2 second wait and then the loop starts over again by going back to #loop

the number after the ~ is the number of seconds it will wait, it is different for each animation, you will need to get it to be right at the point the animation is finished and the cycle should begin again, *this often is before the actual end of the animation*

some times you will need to further control the unit with a setpos inside the loop

tell me if you understand then we'll see if we can modify it for your situation.