AIChat: chat with your ai
Posted: 13 Jun 2008 12:50
As promised yesterday night in another thread, here it is: AIChat. It adds one more event: AIEvent.AI_ET_RECEIVE_CHAT. Usage example:
AIChat offers the following functions:
static bool SendBroadcastMessage(const char *message);
static bool SendTeamMessage(AICompany::CompanyID company_id, const char *message);
static bool SendIndividualMessage(uint32 to, const char *message);
Note that you shouldn't make up values for the parameter 'to' from SendInidividualMessage yourself. You should only call it with values you got from AIEventReceiveChat.GetSender(). If you need more documentation, read the patch.
Code: Select all
while (AIEventController.IsEventWaiting()) {
local e = AIEventController.GetNextEvent();
switch (e.GetEventType()) {
case AIEvent.AI_ET_RECEIVE_CHAT:
local chat_event = AIEventReceiveChat.Convert(e);
AILog.Info("Received chat message (from " + chat_event.GetSender() + "): " + chat_event.GetMessage());
AIChat.SendIndividualMessage(chat_event.GetSender(),"Thanks for your message");
break;
}
}
static bool SendBroadcastMessage(const char *message);
static bool SendTeamMessage(AICompany::CompanyID company_id, const char *message);
static bool SendIndividualMessage(uint32 to, const char *message);
Note that you shouldn't make up values for the parameter 'to' from SendInidividualMessage yourself. You should only call it with values you got from AIEventReceiveChat.GetSender(). If you need more documentation, read the patch.