SC2Mapster.com Wiki

SC2 API / Functions / TriggerAddEventChatMessage

TriggerAddEventChatMessage

void TriggerAddEventChatMessage (trigger t,      int player,
                                 string capture, bool strict);

Register a trigger that will be executed on Chat Messages

Parameters

trigger t

The trigger that will be executed. Must have the following prototype:

bool name(bool checkConds, bool doActions);
  • checkConds : always true?
  • doActions : always true?
  • The return value is used to increment either FailedConditions (when false) or Run in the debug trigger window
int player

The number of the player

string capture

The string you want to capture. This is case insensitive.

bool strict
  • true: The chat message has to be exactly the capture string
  • false : The string to capture is a substring of the chat message

Examples

Example: Repeat Trigger
// Define the trigger function
bool TriggerRepeat (bool checkConds, bool doActions) {
    // Repeat what you said
    UIDisplayMessage(PlayerGroupAll(),
                 c_messageAreaSubtitle,
                 StringToText(EventChatMessage(false)));
    return true;
}

// Create a new trigger based off the function
trigger t = TriggerCreate("TriggerRepeat");

// Bind it to the Chat Message event
TriggerAddEventChatMessage(t, 1, "repeat", false);

// Whenever the player 1 will say something that contains the word "repeat"
// It is going to call the trigger and repeat what he just said.

You must login to post a comment. Don't have an account? Register to get one!

  • 1 comment
  • Avatar of vjeux vjeux Thu, 04 Mar 2010 17:04:11

    This is used that way in the Blizzard AI code (MeleeAI.galaxy)

    bool DebugMeleeTrigger (bool c, bool a) {
        if (a) {
            DebugMelee(StringToInt(StringWord(EventChatMessage(false), 2)));
        }
        return true;
    }
    
    bool g_debugMeleeInit = false;
    void DebugMeleeInit () {
        trigger t;
    
        if (!g_debugMeleeInit) {
            t = TriggerCreate("DebugMeleeTrigger");
            TriggerAddEventChatMessage(t, 1, "waves", false);
            g_debugMeleeInit = true;
        }
    }
    

    When the player 1 says "waves 1" it will call DebugMelee(1)

    Last edited on 08 Mar 2010 by vjeux
  • 1 comment

Facts

Date created
04 Mar 2010
Last updated
10 Mar 2010

Author