Sign up Calendar Latest Topics

  Author   Comment  

Posts: 2
Reply with quote  #1 

I have been struggling with AI commands in an upcoming mission I am scripting. I am trying to create a small race, but I keep having problems with the AI. 
My idea until now has been to "Point throttle" them towards a a point, once that point reached I would clear AI and add another "Point throttle" towards the victory line. 
Halfway through the first stretch the AI ships start turning in circles. I am clueless to what it might be - but my knowledge on XML is limited.

Here is an image of the code:
Race xml.png   Part of the code is a countdown script, showing a countdown on the main screen. 
If anyone has any insight into the I would truly appreciate it.



Posts: 94
Reply with quote  #2 
The only thing that jumps out at me is that those are CRAZY high topSpeed values. Maybe if you go out of a certain range the game engine has strange movement behavior? The normal topSpeed values are 3.0 is ~= Warp 1, 6.0 ~= Warp 2, etc.

If that's not it, you could try DIR_THROTTLE just as a test to see if you get the same results.

Also, I don't see a </event> for "AI GO"... I assume that just got cut off in your snippet?

Posts: 159
Reply with quote  #3 
Ok, so... some thoughts.

As DizzyKungFu pointed out, your topSpeed looks a little high, although in this case I'm not sure if that's really hurting anything if you're setting the throttle to 1. 

To set a ship's angle, you need to use radians instead of degrees. For the purposes of setting the angle of an object, the angle starts at 0.00 for "South", and progresses clockwise: 1.57 is "West", 3.14 is "North", and 4.71 is "East". 

Now... the tricky part. Somewhere around version 2.4-ish, Thom rewrote how the AI stack works for enemy ships, and since then the three THROTTLE commands don't work all that well. DIR_THROTTLE and POINT_THROTTLE are flaky. TARGET_THROTTLE I've had a little more success with, but it's still not all that reliable. If those THROTTLE commands aren't working, try setting the exitPointX/exitPointY/exitPointZ, clear the AI stack, and tell the ship to PROCEED_TO_EXIT. 

If you get the ship going in the right direction, and then all of a sudden the ship starts frantically wiggling back and forth, then it may be because your throttle speed is too fast for your ship's steering/turn rate. The pathfinding code may be overshooting where the ship wants to go, it attempts to turn in the correct direction, can't quite make the turn before the next tick takes it forward again, it tries to turn, rinse & repeat. So try adjusting the ship's steering/turn rate and see if that helps any. Keep in mind that the turn rate is defined in radians, so you want to use small float values. An Arvonian fighter, for example, has a turn rate of 0.01. Most enemy ships have a default turn rate between 0.002 and 0.004. Setting a very high turn rate, such as 3.0 to 6.0 (3.14 radians = 180 degrees, 6.28 radians = 360 degrees), may cause the ship to "overturn", which means it's pointed in the wrong direction when the tick wants to move it forward, and you'll see it wiggle back and forth. 

If all else fails... you can set the X/Z positions directly, or add values to the X/Z positions on every tick. 


Posts: 2
Reply with quote  #4 

Thank you for both your responses

Yes it seems like I have misunderstood the speed numbers. I have now tested it with all _THROTTLE commands, and my current guess is that it boils down to the combination of speed and steering/turn rate as described by Darrin. This shows especially if there are asteroids on the way, which makes the ai ships go into circular movement. I have unfortunately not arrived at any satisfactory balance. I am unable to bring the AI ships to the players level in maneuverability, so I might investigate how to decrease the capability of the player ship (limiting warp or increasing energy consumption). 

Thank you as well for explaining the angle radians, I was wondering what I did wrong there 😉


Posts: 159
Reply with quote  #5 
Something else to watch out for... when using something like PROCEED_TO_EXIT or if you want the ship to arrive at a particular waypoint before proceeding to the next waypoint. Once the enemy ships are traveling at a particular speed, it is difficult for them to stop at an exact coordinate, so they will frequently overshoot the waypoint, try to turn around (default turn radius is TINY), overshoot again, rinse & repeat. So use a condition that checks a certain area, such as a sphere or square, and change the ship's next waypoint as soon as it gets "close enough" rather than on the exact coordinates. 

If the route you want them to fly uses actual named objects as waypoints, then you might have better luck setting the "relative position of object" with regards to the waypoint. This lets you control the exact degree and distance of the ship with regards to that waypoint. Every tick, you can shorten the distance, although you'll probably need a good chunk of "trial and error" to get the speed right. 

Previous Topic | Next Topic

Quick Navigation:

Easily create a Forum Website with Website Toolbox.