The DLL:
download here (place in your DoW directory)
How to use it: Make sure it is in your DoW directory and then open the AI mod .module file, and change the DllName line to:
DllName = dowai_mod
What it does: Allows AI players running on the same computer to communicate with each other
Detailed documentation:
Global variable aimod_extensions_versionThis variable will be set if the DLL is loaded correctly, and for this version of the DLL it is the string "1.0". If the DLL is not loaded then this varialbe will be nil.
Global table ai_communicationThis is a global table which contains all of the communication methods (the three methods below)
ai_communication.can_talk_toIn: float PlayerID [, float PlayerID2 [, float PlayerID3 [, ...]]]
Out: float Number
Returns the number of players which can be contacted of the list of PlayerIDs passed
Useful to find out which AI players are running on this computer
ai_communication.send_broadcastIn: string FunctionName [, any Arg1 [, any Arg2 [, ...]]]
Out: none
Calls FunctionName(Arg1, Arg2, ...) on every other AI player
FunctionName must be a global function
Arg1 through ArgN can be: nil, boolean, number, string, or table (but table keys and values can only be nil, boolean, number, string and tables)
Returns nothing
ai_communication.send_messageIn: number TargetPlayerId, string FunctionName [, any Arg1 [, any Arg2 [, ...]]]
Out: [any Return1 [, any Return2 [, ...]]]
Calls FunctionName(Arg1, Arg2, ...) on the AI with player ID TargetPlayerId
Cannot call itself (will return nil)
FunctionName must be a global function
Arg1 through ArgN can be: nil, boolean, number, string, or table (but table keys and values can only be nil, boolean, number, string and tables)
Returns the return value(s) of FunctionName(Arg1, Arg2, ...)
Return1 through ReturnN can be: nil, boolean, number, string, or table (but table keys and values can only be nil, boolean, number, string and tables)
If the AI with player ID TargetPlayerId cannot be found, then nothing is returned
Example codefunction recv_message(from, arg1, arg2, arg3)
aitimelog("C:\\ailog.txt", "Got message from " .. tostring(from) .. ": " .. arg1 .. " " .. tostring(arg2) .. " " .. tostring(arg3))
end
function recv_chat_message(from, arg1, arg2, arg3)
aitimelog("C:\\ailog.txt", "Got chat from " .. tostring(from) .. ": " .. arg1 .. " " .. tostring(arg2) .. " " .. tostring(arg3))
return "cheese pie", "ret2", arg2 + 2
end
-- ...
msg_to_print = "Can talk to: "
for i = 1000 , 1010 do
if(ai_communication.can_talk_to(i) == 1) then
msg_to_print = msg_to_print .. tostring(i) .. " "
if i ~= self.player_id then
ret1, ret2, ret3 = ai_communication.send_message(i, "recv_chat_message", self.player_id, "cheese", 15, true)
aitimelog("C:\\ailog.txt", "Got reply from " .. tostring(i) .. ": " .. tostring(ret1) .. " " .. tostring(ret2) .. " " .. tostring(ret3))
end
end
end
aitimelog("C:\\ailog.txt", msg_to_print)
ai_communication.send_broadcast("recv_message", self.player_id, "some_string1", 42, true)
Comments / questions ?