First you need to get the trigger word ID (much like a packet ID). These can be pulled from the speech.mul with a hex editor.
Below you can see the ones we currently handle in the code
Code: Select all
enum TriggerWords
{
TW_BALANCE = 0x0001, // Balance
TW_BANK = 0x0002, // Bank
TW_GUARDS = 0x0007, // Guard
TW_QUESTDEST = 0x001D, // Destination
TW_QUESTTAKE = 0x001E, // I will take thee
TW_HOUSELOCKDOWN = 0x0023, // I wish to lock this down
TW_HOUSERELEASE = 0x0024, // I wish to release this
TW_RESIGN = 0x002A, // I resign from my guild
TW_KILLS = 0x0032, // I must consider my sins
TW_HOUSEEJECT = 0x0033, // Remove Thyself
TW_HOUSEBAN = 0x0034, // I Ban Thee
TW_STOP2 = 0x0036,
TW_VENDORBUY = 0x003C, // Vendor Buy
TW_VENDORVIEW = 0x003D, // Vendor View
TW_VENDORGOLD = 0x003E, // Vendor Gold
TW_VENDORSTATUS = 0x003F, // Vendor Status
TW_VENDORDISMISS = 0x0040, // Vendor Dismiss
TW_SETNAME = 0x0042, // Set Name
TW_BOATFORWARD = 0x0045, // Forward
TW_BOATBACKWARD = 0x0046, // Backward
TW_BOATLEFT = 0x0047, // Left
TW_BOATRIGHT = 0x0048, // Right
TW_BOATSTARBOARD = 0x0049, // Starboard
TW_BOATPORT = 0x004A, // Port
TW_BOATSTOP = 0x004F, // Stop
TW_BOATTURNRIGHT = 0x0065, // Turn Right
TW_BOATTURNLEFT = 0x0066, // Turn Left
TW_BOATTURNAROUND = 0x0067, // Turn Around
TW_BOATUNFURL = 0x0068, // Unfurl Sail
TW_BOATFURL = 0x0069, // Furl Sail
TW_TRAIN = 0x006C, // Train, Teach
TW_FOLLOW2 = 0x00E8, // Follow
TW_GOLD = 0x0134, // Gold
TW_VENDORSELL = 0x014D, // Vendor Sell
TW_COME = 0x0155, // Come
TW_FETCH = 0x0157, // Fetch
TW_GET = 0x0158, // Get
TW_BRING = 0x0159, // Bring
TW_FOLLOW = 0x015A, // Follow
TW_FRIEND = 0x015B, // Friend
TW_GUARD = 0x015C, // Guard (Pet)
TW_KILL = 0x015D, // Kill
TW_ATTACK = 0x015E, // Attack
TW_STOP = 0x0161, // Stop
TW_FOLLOWME = 0x0163, // Follow Me
TW_ALLCOME = 0x0164, // All Come
TW_ALLFOLLOW = 0x0165, // All Follow
TW_ALLGUARD = 0x0166, // All Guard
TW_ALLSTOP = 0x0167, // All Stop
TW_ALLKILL = 0x0168, // All Kill
TW_ALLATTACK = 0x0169, // All Attack
TW_ALLGUARDME = 0x016B, // All Guard Me
TW_ALLFOLLOWME = 0x016C, // All Follow Me
TW_RELEASE = 0x016D, // Release
TW_TRANSFER = 0x016E, // Transfer
TW_STAY = 0x016F, // Stay
TW_ALLSTAY = 0x0170, // All Stay
TW_BUY = 0x0171, // Buy
TW_VIEW = 0x0172, // View
TW_COLLECT = 0x0173, // Collect
TW_STATUS = 0x0174, // Status
TW_DISMISS = 0x0175, // Dismiss
TW_SELL = 0x0177, // Sell
TW_COUNT = 0xFFFF
};
Once you have the ID, you would add this support to the onSpeech() event in place of handling the string directly.
So:
Code: Select all
function onSpeech( myString, myPlayer, myNPC )
{
var mySock = myPlayer.socket;
if( mySock != null )
{
for( var trigWord = mySock.FirstTriggerWord(); !mySock.FinishedTriggerWords(); trigWord = mySock.NextTriggerWord(); )
{
switch( trigWord )
{
case 0x0002: // Bank
DoStuff();
return 2;
}
}
}
}
Basically it is faster than string handling (as the client is doing all that parsing for you anyway).