The text parsing contains some simple tricks to decipher common buff-beggage but may require tweaking, buffnames and addverbations seem to differ slightly from server to server.
The ini-file contain info for common druid buffs, just rip it out and replace with whatever class you're playing.
While running this module i suggest you have at least the most commonly requested buff memorized at all times, or it'll have to memorize the buff, cast spell & restore old spell gem.
In your script:
Code: Select all
#include spell_routines.inc
#define NOT_FOUND 0
#define INI_FILE yourinifile.ini
#include gimp_buffrequests.inc
|changes:
| * made into include
| * changed INI format to allow one ini file for multiple characters
| * put name of guild to buff in ini instead
| * auto disabled for melee classes
| * restores old spell if it was changed
| * predefined default spell slot: DEFAULT_SPELL_SLOT
| * ignores requests containing the , letter since they mess up the ini functions
| * uses a free spell gem for the spell if available
| * handles buff requests from group members
|Note: If BuffGuild is undefined in INI_FILE under ${Me.Name} section, ${Me.Guild} will be used
Code: Select all
| gimp_buffrequests.inc
#Event HandleBuffRequest "#1# tells you, '#2#'"
#Event HandleBuffRequest "#1# tells the group, '#2#'"
|If no spell slots are free, it will default to using this slot for buffing (old spell will be restored when done)
#Define DEFAULT_SPELL_SLOT 5
|Handle incomming command
Sub Event_HandleBuffRequest(FullText, Player, Text)
/if (!${gimp_buffrequests_loaded}) {
/declare gimp_buffrequests_loaded int outer 1
/declare gimp_buffrequests_activated int outer 1
/declare gimp_buffrequests_AllowedGuild string outer
/if ( ${Me.Class.Name.Equal["Bard"]} || ${Me.Class.Name.Equal["Berserker"]} || ${Me.Class.Name.Equal["Monk"]} || ${Me.Class.Name.Equal["Rogue"]} || ${Me.Class.Name.Equal["Warrior"]} ) {
/echo gimp_buffrequests.inc disabled for melee classes
/varset gimp_buffrequests_activated 0
/return
}
/declare str string local
/varset str ${Ini[INI_FILE, ${Me.Name}, BuffGuild,]}
/if (${str.NotEqual[NULL]}) {
/varset gimp_buffrequests_AllowedGuild ${str}
} else {
/varset gimp_buffrequests_AllowedGuild ${Me.Guild}
}
/echo gimp_buffrequests.inc initialized
/echo * Accepting <${gimp_buffrequests_AllowedGuild}> members
}
/if (!${gimp_buffrequests_activated}) {
/return
}
/declare CheckStr string local
/declare AllowedBuff int local NOT_FOUND
/declare RequestedBuff string local
/declare i int local 0
/declare OldSpell string local
/declare SpellSlot int local
|Is player in zone?
/if (!${Spawn[${Player}].ID}) {
|/echo # Debug: ${Player} not in zone said: ${Text}
/return
}
/if (${Spawn[${Player}].GM}) {
/beep
/echo # GM ${Player} told me: ${Text}
}
/if (${Spawn[${Player}].Type.NotEqual["PC"]}) {
|/echo # Debug: Ignoring non-player ${Player} (${Spawn[${Player}].Type})
/return
}
|Checking if player is in specified guild, or in white-list
/if (${Spawn[${Player}].Guild.NotEqual[${gimp_buffrequests_AllowedGuild}]}) {
/varset AllowedBuff ${Ini[INI_FILE, ${Me.Name}_AllowedPlayers, ${Player}, NOT_FOUND]}
/echo allowedbuff: ${AllowedBuff}
/if (${AllowedBuff} == NOT_FOUND) {
/echo # Debug: Ignoring request '${Text}' from ${Player}
/return
}
/echo # Debug: ${Player} is whitelisted (${AllowedBuff})
}
|Is player in line of sight?
/if (!${Spawn[${Player}].LineOfSight}) {
|/echo # Debug: ${Player} asked for buff but is not in LoS
/return
}
/varset RequestedBuff ${Text}
/if (${RequestedBuff.Right[50].Equal["Sorry, I am A.F.K. (Away From Keyboard) right now."]}) /varset RequestedBuff ${RequestedBuff.Left[-50]}
/if (${RequestedBuff.Left[12].Equal["can i get a "]}) /varset RequestedBuff ${RequestedBuff.Right[-12]}
/if (${RequestedBuff.Left[10].Equal["can i get "]}) /varset RequestedBuff ${RequestedBuff.Right[-10]}
/if (${RequestedBuff.Left[ 8].Equal["can you "]}) /varset RequestedBuff ${RequestedBuff.Right[-8]}
/if (${RequestedBuff.Right[3].Equal[" =)"]}) /varset RequestedBuff ${RequestedBuff.Left[-3]}
/if (${RequestedBuff.Right[3].Equal[" :)"]}) /varset RequestedBuff ${RequestedBuff.Left[-3]}
/if (${RequestedBuff.Right[2].Equal[" )"]}) /varset RequestedBuff ${RequestedBuff.Left[-2]}
/if (${RequestedBuff.Right[1].Equal["?"]}) /varset RequestedBuff ${RequestedBuff.Left[-1]}
/if (${RequestedBuff.Right[1].Equal["!"]}) /varset RequestedBuff ${RequestedBuff.Left[-1]}
/if (${RequestedBuff.Right[4].Equal[" hun"]}) /varset RequestedBuff ${RequestedBuff.Left[-4]}
/if (${RequestedBuff.Right[4].Equal[" wmp"]}) /varset RequestedBuff ${RequestedBuff.Left[-4]}
/if (${RequestedBuff.Right[4].Equal[" thx"]}) /varset RequestedBuff ${RequestedBuff.Left[-4]}
/if (${RequestedBuff.Right[13].Equal[" when you can"]}) /varset RequestedBuff ${RequestedBuff.Left[-13]}
/if (${RequestedBuff.Right[3].Equal[" me"]}) /varset RequestedBuff ${RequestedBuff.Left[-3]}
/if (${RequestedBuff.Right[3].Equal[" ty"]}) /varset RequestedBuff ${RequestedBuff.Left[-3]}
/if (${RequestedBuff.Right[4].Equal[" plz"]}) /varset RequestedBuff ${RequestedBuff.Left[-4]}
/if (${RequestedBuff.Right[4].Equal[" pls"]}) /varset RequestedBuff ${RequestedBuff.Left[-4]}
/if (${RequestedBuff.Right[7].Equal[" please"]}) /varset RequestedBuff ${RequestedBuff.Left[-7]}
/if (${RequestedBuff.Right[7].Equal[" thanks"]}) /varset RequestedBuff ${RequestedBuff.Left[-7]}
/if (${RequestedBuff.Length} < 1) {
|/echo # Debug: too short text
/return
}
/if (${RequestedBuff.Length} > 25) {
/echo # Debug: too long text
/return
}
|Ignore strings containing , since they mess up ini read functions
/if (${RequestedBuff.Find[,]}) {
/echo # Debug: ignoring requests containing ,
/return
}
|Process request
/varset CheckStr ${Ini[INI_FILE, ${Me.Name}_RecognizedBuffs, ${RequestedBuff}, NOT_FOUND]}
/if (${String[${CheckStr}].Equal[NOT_FOUND]}) {
/echo # Debug: buffreq parsed to: ${RequestedBuff}
|/docommand /tell ${Player} unknown buff
/return
} else {
|Is player in range? ${Spell[name].Range} just works if spell already is memmed
/if (${Spawn[${Player}].Distance} > 100) {
/echo # Debug: ${Player} asked for buff but is oor (${Spawn[${Player}].Distance})
/return
}
/echo # Buffing ${Player} with '${CheckStr}' (${Text})
|/docommand /tell ${Player} inc ${CheckStr}
|If spell is not memorized in any spell gem slot, find first free slot, else put in DEFAULT_SPELL_SLOT
/if (!${Me.Gem["${CheckStr}"]}) {
|Fixme: do i have 9th slot AA?
/for i 1 to 9
/if (!${Me.Gem[${i}].ID}) {
/varset SpellSlot ${i}
}
/next i
|Find first free spell slot, if none is free, fall back to DEFAULT_SPELL_SLOT
/if (!${SpellSlot}) {
/echo falling back to default slot since they full
/varset SpellSlot DEFAULT_SPELL_SLOT
}
/varset OldSpell ${Me.Gem[${SpellSlot}]}
/echo debug: oldspell: ${OldSpell}
/memspell ${SpellSlot} "${CheckStr}"
}
/target pc ${Player}
:loop
/if (!${Me.SpellReady[${CheckStr}]}) {
/goto :loop
/delay 5
}
/call Cast "${CheckStr}"
/echo # Debug: Done buffing ${Player}
|Restore old spell gem
/if (${String[${OldSpell}].NotEqual[NULL]}) {
/delay 2s
/echo # Debug: Restoring old spell: ${OldSpell} in slot ${SpellSlot}
/memspell ${SpellSlot} "${OldSpell}"
}
}
/returnCode: Select all
[PlayerName]
BuffGuild=Guild name (optional entry, falling back to your own guild name if not specified)
[PlayerName_AllowedPlayers]
MyFirstFriend=1
MySecondFriend=1
[PlayerName_RecognizedBuffs]
po9=Steeloak Skin
pot9=Steeloak Skin
9=Steeloak Skin
nine=Steeloak Skin
pot10=Steeloak Skin
steeloak=Steeloak Skin
steelowk=Steeloak Skin
steeloak skin=Steeloak Skin
ss=Steeloak Skin
skin=Steeloak Skin
steel=Steeloak Skin
oak=Steeloak Skin
soe=Spirit of Eagle
eagle=Spirit of Eagle
spirit of eagle=Spirit of Eagle
spirit of eagles=Spirit of Eagle
foe=Flight of Eagles
flight of eagle=Flight of Eagles
flight of eagles=Flight of Eagles
pos=Protection of Seasons
season=Protection of Seasons
seasons=Protection of Seasons
str=Nature's Might
natures might=Nature's Might
eb=Everlasting Breath
ds=Nettle Shield
regen=Oaken Vigor
sow=Spirit of Wolf
spirit of wolf=Spirit of Wolf



