Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
guidelines:adding_message_to_gamebots [2012/02/08 16:47] martin.cerny |
guidelines:adding_message_to_gamebots [2012/02/08 16:59] martin.cerny |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Introduction====== | + | ======Adding new GameBots message and commands (UnrealScript)====== |
GameBots messages are text strings exported from Unreal Tournament through socket connection. GameBots commands are text strings sent from Pogamut to Unreal Tournament. Here we will provide you with some basic information on how to create a new GameBots message or command. Afterwards you may also want to check the topic: [[Adding GameBots message to Pogamut JAVA|Adding new GameBots message to Pogamut JAVA]]. | GameBots messages are text strings exported from Unreal Tournament through socket connection. GameBots commands are text strings sent from Pogamut to Unreal Tournament. Here we will provide you with some basic information on how to create a new GameBots message or command. Afterwards you may also want to check the topic: [[Adding GameBots message to Pogamut JAVA|Adding new GameBots message to Pogamut JAVA]]. | ||
Line 96: | Line 96: | ||
Except for special messages (handshake with server, password), the message handling is done in '' | Except for special messages (handshake with server, password), the message handling is done in '' | ||
- | < | + | < |
function ProcessRegularAction(string cmdType) | function ProcessRegularAction(string cmdType) | ||
{ | { | ||
Line 113: | Line 113: | ||
In your handler method, you are free to use method GetArgVal(argName) to parse command arguments (it is automagically filled with arguments from most recent command. | In your handler method, you are free to use method GetArgVal(argName) to parse command arguments (it is automagically filled with arguments from most recent command. | ||
+ | ====== Triggering Kismet event with a command ====== | ||
+ | |||
+ | One nice thing to do with a message is to fire a custom Kismet event when a command is received. Here is an example of such a handler function (from SpyVsSpy project). | ||
+ | |||
+ | <code php> | ||
+ | function ReceivedChangeDoorState(){ | ||
+ | local Sequence GameSeq; | ||
+ | local array< | ||
+ | local array< | ||
+ | local int i; | ||
+ | local string doorFrom; | ||
+ | local string doorTo; | ||
+ | local bool open; | ||
+ | local SeqEvent_ExternalDoorStateChange doorChangeEvent; | ||
+ | |||
+ | doorFrom = GetArgVal(" | ||
+ | doorTo = GetArgVal(" | ||
+ | open = bool(GetArgVal(" | ||
+ | |||
+ | |||
+ | |||
+ | GameSeq = WorldInfo.GetGameSequence(); | ||
+ | if (GameSeq != None) | ||
+ | { | ||
+ | |||
+ | // find all instance of our event | ||
+ | GameSeq.FindSeqObjectsByClass(class' | ||
+ | |||
+ | //choose the right activation link number | ||
+ | if(open){ | ||
+ | ActivateIndices[0] = 0; | ||
+ | } else { | ||
+ | ActivateIndices[0] = 1; | ||
+ | } | ||
+ | for (i = 0; i < AllDoorEvents.Length; | ||
+ | { | ||
+ | doorChangeEvent = SeqEvent_ExternalDoorStateChange(AllDoorEvents[i]); | ||
+ | //Check custom activation condition | ||
+ | if( (doorChangeEvent.DoorFrom == doorFrom && doorChangeEvent.DoorTo == doorTo) | ||
+ | || (doorChangeEvent.DoorFrom == doorTo && doorChangeEvent.DoorTo == doorFrom) | ||
+ | ){ | ||
+ | // | ||
+ | doorChangeEvent.CheckActivate(WorldInfo, | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Here we have a custom kismet event with two output links. | ||
+ | This method gets all event object of appropriate class, performs custom checking, whether the message should trigger the event and then triggers the appropriate activation link on them. | ||
====== Adding project-specific messages and commands ====== | ====== Adding project-specific messages and commands ====== |