-
Notifications
You must be signed in to change notification settings - Fork 6
AI variables explained by rafa
These are all found in Control.java.
skiplev - The lower this is, the higher the chance that the AI will cut through a corner. Trivia: If a car is in last place, this value keeps decreasing until the AI cuts ahead of the other players.
fpnt - The (up to 5) fix points in a stage.
gowait - If it's true, the AI will go to its camping spot
attack - An "attack timer"; if it's 0, the AI will race, if it's anything else, the AI will waste, and every frame it keeps counting down to 0. Basically, the "temper" of the AI.
CheckPoints.opx and CheckPoints.opz - The X and Z positions of every car in the stage.
CheckPoints.x and CheckPoints.z - You know when you add )p to the end of pieces? Their coordinates go here. )p basically adds "nodes" for where the AI goes. Therefore, CheckPoints.x and CheckPoints.z are the X and Z coordinates of track pieces with )p at the end of them.
acr - The car that the AI will attack. 0 means it's gonna attack you, 6 means it's gonna attack the boss car, so on and so forth.
bulistc - Its main function is to make cars go through the stage backwards. On its own, though, it's not really helpful so what you could do is make the AI attack other cars when it gets close to them (like in Stage 11).
turntyp - What type of turn the AI is making/will make. 0 means the AI will turn without braking 1 means the AI will turn and brake 2 means the AI will turn and handbrake
pan - the "destination" angle of the AI car, as in "pan to". Mathematically, it is the tangent of the distance between the car's Z and the destination Z divided by the car's X and the destination X. For example, if you set this to 180, the car will turn to the 180 angle. Don't confuse this with "turning 180 degrees".
zyinv - Inverts the ZY angle. It is true if the AI is going backwards.
clrnce - The "squeezing room" (in degrees) that the AI has to make turns. Lower means more accurate turns, higher means less accurate turns. Trivia: To quote Ten of Graves: Do NOT put this at 0, or they'll keep swerving from side to side (because they keep trying to be at exactly the center of the road piece).
agressed - True if the AI is aggro'd on another car. Agressed actually just affects turns - when it's false, the AI cars stop holding up while turning, whereas when it's true they hold up as normal.
saftey - It basically affects how soon the AI cars begin to prepare for landing from a stunt. Higher values of saftey mean that they prepare for landing closer to the ground (generally a saftey value of 5-10 works pretty well for me), so a saftey value of 0 means that they play it very safe (but barely do any stunts).
usebounce - Basically means whether to treat bouncing (like from a stunt) as racing on the ground or racing in the air. In practice it really doesn't affect much so don't worry too much about it, although it is generally good practice to leave it as true so that the AI doesn't get needless bad landings from trying to stunt from a heavy bounce or something (which happens rarely anyway).
perfection - Affects how well the AI cars land from a stunt - if it's true, they land a lot more accurately than when it's false. It's best to just keep it true at all times.
hold - Think of hold as a timer that decreases every frame (like attack) - while it's greater than 0, the AI cars will never turn. So if I set hold to be 100 then it will take 100 frames before the AI cars will be able to turn.
revstart - How long the AI reverses for after the start of a race.
f - This one will probably have a different name depending on what NFM files you have, since it's a local variable. Affects many things. One of its behaviors is the threshold for the AI to cut corners - the larger it is, the higher the chance of the AI cutting corners. Another one of its behaviors is a multiplier for upwait and actwait.
wtx - The X coordinate of a camp out location. This changes based on how far the player is into the race.
wtz - The Z coordinate of a camp out location. This changes based on how far the player is into the race.
trfix - When trfix is 2, the AI go to their set fixing point (determined by the fpnt variable as you said). As the AI get within range of the fixing hoop, trfix becomes 3 which prepares the AI for fixing (like what stunts they should do, setting clrnce and acuracy to be 0 so they're as accurate as possible, etc.)
runbul - A timer for how long bulistc is true. When it reaches 0, bulistc is toggled to false.
forget - Makes the AI prioritize fixing over racing.
acuracy - Multiplier for the delay between each turn. Trivia: In custom stages, acuracy is always 0. This is probably Omar's attempt at fixing the his retarded AI not being able to drive on the rollercoaster parts. #FuckOmar
randtcnt - The actual delay between each turn. Affected by acuracy.
aim - Makes the AI more precise when targeting another car. Trivia: This works by making the AI think the target is farther away than it is, thus making the AI take smoother turns. Nice one, Omar. When it's at 1.0F, it means that the AI will target their opponent at their exact location. Which sounds great, but in practice it doesn't work well as it does not account for dodging at all.
The beauty lies in if aim is slightly below 1.0F or slightly above 1.0F - when you do that it aims for its target slightly off to its location. This means that the AI will still get a solid hit even if you dodge it (you'll have to do quite a large dodge to avoid getting hit completely). Of course, there is the chance that you dodge the other way and dodge them completely, but especially if the AI are wasting in packs, it does make dodging a whole lot tougher.
In terms of using this piece of code, you could probably use something like this:
aim = (m.random() / 2) + 0.75F;
Which causes aim to be any value from 0.75F to 1.25F, meaning that the AI will be completely unpredictable in which way they'll target you.
mustland - The higher this is, the less risky stunts the AI will perform. Trivia: When the AI car's power is under 50%, it will perform risky stunts to get its power back (this value is set to 0)
frx - The X coordinate range from which the AI will start to move from the camping spot and go for you.
frz - The Z coordinate range from which the AI will start to move from the camping spot and go for you.
rampp - Not really an important variable, but it basically controls how willing the AI cars are to go up ramps and stunt.
Picture this: an AI car is going through a stage pretty smoothly on a road piece. One of the next few pieces is a ramp piece. When rampp is 1, the next piece the AI would go to would be the ramp piece to try and stunt. If it was -1 (which it is when the AI is at max power) it would instead target the piece immediately after it (so it'll basically ignore the ramp piece).
The only problem is that even if the AI do ignore a ramp piece, it doesn't mean they will actively try and avoid it. If rampp is -1 but a ramp is in their way to the next piece (which happens 95% of the time), they'll still go up it and even stunt as normal.
The only real situation where this variable actually does something is when the AI gets back onto course after being launched or something - as they approach the track again, they can decide which piece to go to next. But in practice, this variable makes very little difference so don't worry about it too much.
afta - Just used for a few things regarding aggressiveness of the AI (if afta is true the AI will be willing to attack you, except that there about 1000000 other things that affect this, this is just one of the checks). As you suggested, it really doesn't affect much.
trickfase - When trickfase is 0, the AI isn't stunting. When trickfase is 1, the AI does its main part of the stunt (forward loops, backloops, etc.). When trickfase is 2, the AI begins preparing its car for landing from the stunt. Best not to edit it seeing as it's a pretty logical system.
upwait and actwait - The time it takes (in frames) for the AI to "release" a key and for it to "press" another key.
--- Tutorials ---
madness.pcleared explained by Ten Graves
This is very common in Control. I very rarely use this variable (mainly when I want camping AI or changing how they stunt), but you're probably curious to know what it is if you don't know yet Razz.
When you clear a checkpoint, "madness.pcleared" changes. It basically records how many pieces there are between checkpoints, and it accumulates too. Note that only pieces with an index at the end of it (I'm talking about the stage's code here) will count, so basically only pieces ending with "p", "pt", "ph", are counted.
For example, let's say there are two checkpoints. In the code, there are a total of 5 lines between them. Three of them are road pieces (ending with "p") and the other 2 are ramps, but without "pr" (so the AI won't try to use them). When I clear the 2nd of those two checkpoints, madness.pcleared increases by 3 (not 5, because only 3 of the pieces have an index).
Don't worry if you don't completely understand that. To be honest, it's not really efficient to work out what "pcleared" is between every checkpoint. You're much better off writing a code to make it display for you. The code below (in void stat of xtGraphics) could work:
rd.setColor(new Color(0, 0, 0));
rd.drawString("" + madness.pcleared + "", 200, 200);
Using that code will display what "pcleared" is after every checkpoint. "madness.pcleared" in control is VERY versatile. You can use it to tell the AI to do certain things while they're racing. The possibilities are endless Razz.
trfix explained by Ten Graves
You may have seen "trfix" in Control before, but it's actually a very interesting variable; something you mightn't have realised. So what is it?
First off, there are 4 values of which trfix can be. I don't actually know what ALL of the variations do, but the ones that I find very interesting are when trfix is 2 or 3.
When trfix is 2, the car starts to fix. Simple. But the cool thing is we can edit on when the cars fix quite easily. Find this in Control:
if((100F * (float)madness.hitmag) / (float)madness.maxmagmadness.cn] > (float)k2) {
trfix = 2;
}
This code basically means that when the AI's damage is above "k2"%, it'll try to fix. The great thing is k2 can be changed quite easily. For example:
if(checkpoints.stage == 9) {
k2 = 70;
}
So, when the stage is 9, the AI will fix when their damage is 70% or higher. This can be easily changed by doing something like this:
if(checkpoints.stage == 1) {
k2 = 0;
}
That code above basically means the AI will fix as soon as they take damage (wouldn't recommend it Razz) on Stage 1. The default point on when the AI fix is 80%, because of this:
int k2 = 80;
That int declaration basically sets the starting point for k2, and if it's not changed then it will stay that way, which is why on most stages cars fix at 80+% damage.
That's not all, you can even make the cars not fix at all on a stage! See this?
flag2 = true;
Basically when flag2 is true, the cars won't fix at all. So you can do something like this:
if(checkpoints.stage == 14) {
flag2 = true;
}
So on stage 14, the AI will no longer try to fix (if you're wondering why the cars sometimes drive in circles on the original Stage 14, the answer is that they're looking for a fix which doesn't exist, and this code fixes it).
(You're better off adding onto the existing "if" statements though instead of making your own to do this).
Now, what if trfix is 3? When the car gets close to the fixing hoop, trfix becomes 3. It's as simple as that, and, in most cases, it usually activates when the car is going up the ramp leading up to the fix hoop.
So what use does it have? Well, there's actually some code that tells the AI how to stunt when trfix is 3! This is the reason why the cars ALWAYS do forward loops when approaching the fix on Ghosts and Magic.
We can hack this quite easily. Check out the next spoiler to see how we can edit the AI's stunting.
changing how the cars stunt, explained by Ten Graves
First off, find this:
if(trickfase == 0)
From that point on, all the code below it affects how the AI stunt, until the end of void drive.
Let's start with the "uddirect" and "lrdirect" variables. In a nutshell, these variables tell the AI whether to do rollspins, backloops or forward loops.
If uddirect is 1, the AI will do forward loops. If it's -1 they will do backloops.
If lrdirect is 1, the AI will do right rollspins. If it's -1 they will do left rollspins.
You might be here from the previous "trfix" spoiler, so I'll tell you how to control the AI's stunting as they approach the fix. First off, find this:
if(trfix == 3 || trfix == 4)
Let's start with an example that's already there (or should be at least). Here's Stage 10's code for this:
if(checkpoints.stage == 10) {
uddirect = 1;
lrdirect = 0;
}
So basically, the AI will only do forward loops when they approach the fix on Stage 10. This code can be very useful if you want your AI to be very good at fixing first-time. For example, if the fix the AI are trying to reach is high relative to the ramp they use to get it, you'd want them to do backloops. So you can insert a code like this:
if(checkpoints.stage == *whatever stage you're editing*) {
uddirect = -1;
lrdirect = 0;
}
You could even make them do stuff like backloops by rollspins, in case your fix hoop is high AND not directly in front of the ramp. You'd simply change "uddirect" to -1 and "lrdirect" to either 1 or -1, depending on whether you want them to do right rollspins or left rollspins.
You might've also seen "stuntf" a lot. It's basically a template on how the AI stunt generally in a stage. I have limited knowledge in this variable, but what I do know is that when stuntf is 6, the AI will generally do forward loops in the stage. See this
if(checkpoints.stage == 14) {
saftey = 10;
if(madness.pcleared >= 4 && madness.pcleared < 70)
{
stuntf = 4;
} else
if(madness.cn == 12 || madness.cn == 8)
{
stuntf = 2;
}
if(madness.cn == 14)
{
stuntf = 6;
}
}
At the bottom you can see that if the car is 14 (Radical One), then stuntf is 6, which basically means that on Stage 14, Radical One will generally do forward loops (now you know why you used to find it so challenging Razz).
I don't really recommend using "stuntf" unless you know exactly what you're doing with it. I wouldn't really do it unless I want pitch-perfect AI. Don't get me wrong though, if you want to use it, go ahead
--- Glossary ---
skiplev - Skip in level
wtx - Wait X
wtz - Wait Z
frx - Free X
frz - Free Z
trickfase - Trick Phase
upwait - Release Wait
actwait - Action Wait
fpnt - Fix Point
gowait - Go Wait
acr - Attack Car
bulistc - Ballistic
turntyp - Turn Type
pan - Pan Towards
zyinv - Invert ZY
clrnce - Clearance
saftey - Safety
usebounce - Use Bouncing
revstart - Reverse Start
trfix - Try to fix
runbul - Run Ballistic
acuracy - Accuracy
randtcnt - Random Turn Counter
mustland - Must Land