OK, so you found def StuckHandler. That's the first part. Now, in order to make it so your changes don't affect every single other AI, you need to copy and paste it into a new .py. Having def StuckHandler in the AI .py overrides anything in __init__.py, so you can safely edit it without affecting other bots.
However, there's a problem. def StuckHandler doesn't use Throttle commands, so you can't tell the AI to drive any slower. Therefore, you need to write a new StuckHandler that does use Throttle commands. Before you start panicking, don't worry--I've already done this! Just replace the def StuckHandler in your .py with this:
def StuckHandler(self):
"Do nothing."
while 1:
for i in range(0, 16):
yield 0
def GoodStuckHandler(self, bTarget):
if self.bImmobile:
self.srimechtimer += 1
# keep driving in one direction as long as we can
if self.GetSpeed() > 0.5:
self.Throttle(100)
if self.GetSpeed() < -0.5:
self.Throttle(-100)
# if we're not moving very fast try wiggling back and forth
if abs(self.GetSpeed()) <= 0.5:
self.wiggletimer += 1
if self.wiggletimer < 0:
self.Throttle(100)
if self.wiggletimer >= 0:
self.Throttle(-100)
if self.wiggletimer >= 8:
self.wiggletimer = -8
# fire everything we have as a last-ditch effort if we're still not free after 5 seconds
if self.srimechtimer >= 20:
self.srispintimer += 1
for trigger in self.triggers:
self.Input(trigger, 0, 1)
for trigger in self.trigger2:
self.Input(trigger, 0, 1)
if self.srispintimer < 7:
self.Input("Spin", 0, -100)
if self.srispintimer >= 7:
self.Input("Spin", 0, 100)
if self.srispintimer == 15:
self.srispintimer = 0
else:
self.srimechtimer = 0
self.srispintimer = 0
self.wiggletimer = -8
This is from my EcoOmni.py. I made def StuckHandler do nothing; it's just there to override the one in __init__.py, and then I added a new StuckHandler. This StuckHandler is better suited for slow bots, and it also happens to use Throttle commands. If you want your bot to drive slower in reverse, just find wherever it says "self.Throttle(-100)" and change it to a lower number, like -50.
Now you're almost done. All that's left to do is integrate the new StuckHandler into the .py. First, you need to set all the custom variables to some value in def __init__. If you don't, the game won't know what those variables are when they are called and it will crash. You can just copy and paste this into def __init__.
self.goodFunction = self.GoodStuckHandler
self.wiggletimer = -8
self.srimechtimer = 0
self.srispintimer = 0
Then you need to add this right below "self.RegisterSmartZone(self.zone, 1)" in def Activate.
else:
# get rid of reference to self
self.goodFunction = None
The else should be on the same indentation with the "if active:".
Finally, you need to tell the driving commands in def GoodStuckHandler to override the AI's normal driving. You do this by putting the following at the end of def Tick:
bReturn = AI.SuperAI.Tick(self)
# call this now so it takes place after other driving commands
if self.goodFunction: self.goodFunction(len(targets) > 0)
return bReturn
Normally it says "return AI.SuperAI.Tick(self)" at the end of the .py. Get rid of that and replace it with that new code.
NOW the .py should be done. If it doesn't work, you probably have messed up indentation somewhere. Open it up in Python (available here:
http://www.python.org/download/releases/2.6.6/); it includes a handy text editor with an error-checking utility that tells you if you have any syntax errors or messed up indentation.