Page 1 of 1

How to make the AI Cheat

Posted: 09 May 2006, 22:13
by Veylon
I hope that this hasn't been posted somewhere else, but here's how to make the AI Cheat without anyone having to type ".cheat".

You have to call the GetCheatInterface() from the GlobalAICallback you get in the GlobalAI::Init(). This returns a pointer to a AICheats class or NULL if in a multiplayer game (incidentally, making a check of whether or not the AI is in a multiplayer game).

If it returns the valid pointer, it also turns on cheating in the game.

So, add something like this to the GlobalAI class in the header:

Code: Select all

AICheats *Cheater;
bool Cheating;
bool NetworkGame;
And something like this to the Init function in the source:

Code: Select all

Cheater = GlobalAICallback->GetCheatInterface();
if(Cheater != NULL)
{
  // Can Cheat
  Cheating = NetworkGame = true;
}
else
{
  // Can't Cheat
  Cheating = NetworkGame = false;
}
I ran into this on accident whilst browsing the various AI *.cpps in the source.

Posted: 09 May 2006, 22:20
by jcnossen
Im not sure if that piece of code is how it works right now.
I want to explain it a bit further for clarity:

Global AIs can always request the cheat interface now, and it will always provide one (even if .cheats isn't done by the user)
Another new behavior of the cheating support is the difference between passive cheats and active cheats. The AI can use passive cheats in a multiplayer game, and active+passive cheats in a singleplayer game. You can check this by calling:

bool CAICheats::OnlyPassiveCheats ()

I guess I forgot to put this in the changelog :roll:

Posted: 11 May 2006, 20:52
by Veylon
Well, it worked with 0.70b3, so I'll have to double-check it with 0.71b1. I'll bring a demo file or screenshots next time or else everyone can wait for the source code in OTAI's next version.

I've also found that it's possible for the AI to very easily get other players' data. Should that be something that's used, as in how the Starcraft AI and OTA AI always knew where your units were without having to explore? I've used to make the enemies units blow themselves up. I'll put up a replay of this next time.

Posted: 12 May 2006, 17:38
by LOrDo
Don't make your AI cheat, we want a smart AI, not a cheap AI.

Posted: 12 May 2006, 17:45
by AF
Well XE8 is both, with cheating as an option and I'm sure OTAI will be too

Posted: 12 May 2006, 18:00
by krogothe
KAI has been for months, the sheep shall follow :wink:
Its not a bad thing, currently AIs are way too easy for anyone who can even slightly play the game, so its just logical to up the difficulty until smarter behaviour is obtained...
Most of the AI cheat changes were because of me poking zaphod, gotta love him!

Posted: 13 May 2006, 06:57
by Neddie
LOrDo wrote:Don't make your AI cheat, we want a smart AI, not a cheap AI.
I agree.

Posted: 13 May 2006, 17:19
by AF
Type .aicheat to make NTai XE8 start cheating

Posted: 19 May 2006, 20:18
by Veylon
I wasn't thinking so much in terms as making hundreds of units coming out of thin air (as is interesting to see), as much as using information cheats, like finding out where the enemies are headed or seeing everything on the map. You know, the "traditional" AI advantages.

Also, I found a hack to get around the "Enemy entered LOS, but you can't see 'em" bug. That would surely be a fair use of hacking, right?

Anyway, I'll make up a config so that the player can tune OTAI's hacking however they want.

Posted: 19 May 2006, 21:05
by AF
Looking at the source it seems the cheat interface isnt synced at all for active cheats, which is soemthing I'd like ammended.....