Event_Chat help

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

dravidiankayne
Chicken Little
Posts: 61
Joined: Mon Mar 29, 2004 3:14 pm

Event_Chat help

Post by dravidiankayne » Sun Apr 18, 2004 2:41 am

Okay, I've read through a lot of posts and have a little idea of how to use Sub Event_Chat(cType,cSender,cMessage), but I still have a few questions:

1: what are all the possible chat types? For instance, I want to have my character do something if he gets attacked. I've found I can use the following, which is not very efficient, but it works:

Code: Select all

#event 001a "YOU"
#event 001b "points of damage"
#event 001c "points of non-melee damage"

Sub Main
/declare Flag_x global
/varset Flag_x 0
:Mainloop
/doevents
/goto :Mainloop
/return

Sub Event_001a
/varset Flag_x 1
/return

Sub Event_001b
/if n @Flag_x==1 {
    DO WHATEVER
    /varset Flag_x 0
}
/return

Sub Event_001c
/if n @Flag_x==1 {
    DO WHATEVER
    /varset Flag_x 0
}
/return
Now this code works, but it's WAAAAY too many lines for my needs. If I could find out if there's a chat type that is sent for you being hit, that'd be awesome!

2: When looking for specific words in the message, what is the benefits of using '==' or '~~'?

With the answer of this post, I should be able to make some uber scripts with few lines.

Thanks

Goofmester1
a hill giant
a hill giant
Posts: 241
Joined: Thu Nov 06, 2003 4:26 am

Post by Goofmester1 » Sun Apr 18, 2004 2:58 am

Can awnser #2 for you.. The benifts of using "==" or "~~" are that

"==" is a exact match and "~~" is a something close that includes.

For example I set up a assist on tell. If the sub if is set as /if cMessage==Assist me then it will ignore all tells other than exact matches. Good for limiting responce to very controlled pre-planned tells (hotkeys and other macros.) If the sub is set to /if cMessage~~Assist me then it will assist on things like Assist me in killing this %T or assist me now. etc

dravidiankayne
Chicken Little
Posts: 61
Joined: Mon Mar 29, 2004 3:14 pm

Post by dravidiankayne » Sun Apr 18, 2004 3:10 am

Okay one more question:

What does adding #chat tell, or #chat guild, etc.....do at the beginning of the file? If you have only #chat tell, then does the Event_Chat only trigger on tells? Or if you have #chat tell, and #chat guild, will it only trigger when somebody says something in tell or guild?

daerck
a ghoul
a ghoul
Posts: 134
Joined: Mon Jan 12, 2004 8:44 pm

Post by daerck » Sun Apr 18, 2004 7:42 am

Yes, #chat is for specific chat events

I.e. when you do #chat tell, the Sub Event_Chat will be executed on each tell you recieve, with the parameters of ChatType, Sender and Chatmessage being passed to it.

I.e.

Code: Select all

Sub Event_Chat(ChatType, Sender, Text) {
  /echo You recieved a @ChatType message from @Sender saying @Text
}

This can be used to limit bots to accept commands from only one person, for example.

dravidiankayne
Chicken Little
Posts: 61
Joined: Mon Mar 29, 2004 3:14 pm

Post by dravidiankayne » Sun Apr 18, 2004 1:06 pm

Thanks both of you. Daerck, I can use that little snippet you posted to find out what all the chat types are as well. If nothing comes up when I get hit, then I guess being hit isn't included as a chat type. =) Maybe I'll post all the different types I find after a bit (or if I get real desperate I could just look in the code of the release lol)

dravidiankayne
Chicken Little
Posts: 61
Joined: Mon Mar 29, 2004 3:14 pm

Post by dravidiankayne » Sun Apr 18, 2004 10:09 pm

okay I guess it didn't work how I wanted, so I looked in the code itself. The chat types available are:

guild
group
tell
ooc
shout
auc
say
say

I don't know why there was 2 "say"s listed, but I listed the 2nd one anyways. I couldn't even see a difference in the code with the exception of one value, of which I couldn't see why there was the difference. For those of you who wish to look at this, the Event_Chat commands can be found in

MQ2UserVars.cpp in function VOID CheckChatForEvent(PCHAR szMsg) at line 95

daerck
a ghoul
a ghoul
Posts: 134
Joined: Mon Jan 12, 2004 8:44 pm

Post by daerck » Tue Apr 20, 2004 7:30 am

I think you are looking for something like this... Not sure if the plugin still gets updated or not, but it's a point to start.