Moderator: MacroQuest Developers

Why 5 seconds?Vexix wrote: Could one of you let me know the rationale behind SelfBuffInt array? It seems to basically create a countdown for the buffs to be checked? I'm thinking replacing it with the 5 second timer, and then checking all buffs each time, since I don't think the processor time to check all buffs will be that high.
--Vexix
Sorry this came after me. I think this may have been something Lord Giddeon added.Vexix wrote:I'm busily cranking away at the next version of genbot, with spells broken down into discrete steps and put into a spell queue. I'm working on putting items and alt abilities into the same stack now as well. Will hopefully have it up this week.
I think you'll like some of the new capabilities. ;)
Grimjack, Fez, or Lord Giddeon,
Could one of you let me know the rationale behind SelfBuffInt array? It seems to basically create a countdown for the buffs to be checked? I'm thinking replacing it with the 5 second timer, and then checking all buffs each time, since I don't think the processor time to check all buffs will be that high.
--Vexix
My attempts at using FIFO queues usualy ended up with catistrophic results. When I quit working on genbot commands somewhat queued on a FILO basis in that when you called for another command it would jump to the requested sub(once it hit a /doevents), complete that, and /return to the old one which seemed to work best with a group of bots. When you have an "oh shit" situation while making 6 bots do something, you don't want your super important life saving command to have to wait in line. Even with a command to clear pending commands, the extra step can be deadly. I would definatly heavily test anything you do reguarding this in many situations before switching. I can definatly see where spellcasting can cause some wierdness when you call for a spell while casting a spell (I somewhat remember dealing with it). I definatly wouldn't mind taking a look at what you have in the works.fez_ajer wrote:I've been thinking about spell queueing and I keep coming back to the fact that it puts casting out of sync with everything else going on. I think maybe the direction to head is queueing up whole commands. That way commands would still be parsed via the existing ExecCommand/Do-xxx mechanism, except they'd be pulled out of FIFO in the order they were received. All events would happen in the main loops then with events just adding more events to the queue.
We would need to add a special 'stop' command that would basically stop whatever is going on and empty out the command queue.

Code: Select all
|botspell.inc
|Bot spell module.
|Version 12.37
|Date:06/02/2004
|
||**
[botspell]
version=12.37
**||
|
#Define Debug-Spell TRUE
#event CastFizzle "Your spell fizzles!"
#event CastInterrupt "Your spell is interrupted."
#event CastInterrupt "Your casting has been interrupted."
#event CastNoMana "Insufficient Mana to cast this spell!"
#event CastResist "Your target resisted #*#"
#event CastTooFar "Your target is out of range, get closer!"
#event Collapse "Your gate is too unstable, and collapses."
#event Distracted "You are too distracted to cast a spell now!"
#event ImmuneSlow "Your target is immune to changes in its attack speed."
#event ImmuneRoot "Your target is immune to changes in its run speed."
#event MissedNote "You miss a note, bringing your song to a close!"
#event NoLOS "You cannot see your target."
#event NoMem "You do not seem to have that spell memorized."
#event NoOverWrite "Your spell would not have taken hold on your target."
#event NoTarget "You must first select a target for this spell!"
#event Recovered "You haven't recovered yet..."
#event Recovered "Spell recovery time not yet met."
#event RootOff "Your Immobilize spell has worn off."
#event Sitting "You must be standing to cast a spell."
#event Stunned "You can't cast spells while stunned!"
#event Stunned "You *CANNOT* cast spells, you have been silenced!"
Sub Init-Spell
/declare cmds-SPELL string outer Spell:
|For each command
|/call AddCommand "Command Section" "Command Phrase" "Called Sub"
|Command Section - where the command will be listed in response to the cmd phrase
|Command Phrase to trigger bot - End User can change to suit prefferences
|Called Sub - Routine to execute in response to Command Phrase
/call AddCommand SPELL Buff Do-buff
/call AddCommand SPELL chainnuke Do-chainnuke
/call AddCommand SPELL chainstun Do-chainstun
/call AddCommand SPELL evac Do-evac
/call AddCommand SPELL itemcast Do-itemcast
/call AddCommand SPELL loadlist Do-loadlist
/call AddCommand SPELL mana Do-mana
/call AddCommand SPELL SelfBuff AddSelfBuff
/call AddCommand SPELL setlomPCt Do-setlomPCt
/call AddCommand SPELL sn Do-sn
/call AddCommand SPELL snt Do-snt
/call AddCommand SPELL spellgem Do-spellgem
|/declare Vars
/declare BuffList[50,2] string outer
/declare BuffListAdvance timer outer
/declare BuffListTimes[50,2] int outer 0
/declare BuffListCount int outer 0
/declare CannAATimer timer outer
/declare CanniSpell string outer
/declare CannTimer timer outer
/declare CastLastResult string outer
/declare CastName string outer
/declare CastOldTargetID int outer
/declare CastQueue string outer
/declare CastStep int outer
/declare CastTarget string outer
/declare CastTime int outer
/declare CastTimer timer outer
/declare CastType string outer
/declare ChainNuke string outer
/declare ChainStun string outer
/declare ChainStunNum int outer
/declare ChainStunTime timer outer
/declare CTimer timer outer
/declare DefaultSpellSet string outer
/declare DelayBeforeSit string outer 3s
/declare DoAgain bool outer FALSE
/declare DoCanni bool outer FALSE
/declare DoYaulp bool outer FALSE
/declare EvacSpell string outer
/declare LastSn string outer NA
/declare LomMsg string outer
/declare LomTimer timer outer
/declare Remem bool outer FALSE
/declare ReportLom bool outer FALSE
/declare SelfBuffList string outer
/declare SelfBuff[15] string outer
/declare SelfBuffInt[15,2] int outer 0
/declare SelfBuffCount int outer 0
/declare SelfBuffPass int outer 0
/declare SitAfterCast bool outer FALSE
/declare SitTimer timer outer
/declare SpellFail bool outer FALSE
/declare SpellGem int outer
/declare SpellSlot int outer
/declare StartCast bool outer FALSE
/declare YaulpSpell string outer
/declare YaulpTimer timer outer
/declare ST-SpellMain timer outer 1
/call LoadSetting CanniSpell Spell CanniSpell Canniblize
/call LoadSetting ChainNuke Spell ChainNuke "Your Chain Nuke Spells sperated with |."
/call LoadSetting ChainStun Spell ChainStun "Your Chain Stun Spells sperated with |."
/call LoadSetting DefaultSpellSet Spell DefaultSpellSet Default
/call LoadSetting DelayBeforeSit Spell DelayBeforeSit 3s
/call LoadSetting DoCanni Spell DoCanni 0
/call LoadSetting DoYaulp Spell DoYaulp 0
/call LoadSetting EvacSpell Spell EvacSpell NONE
/call LoadSetting LomMsg Spell LomMsg "Warning I'm running low on Mana."
/call LoadSetting Remem Spell Remem 0
/call LoadSetting ReportLom Spell ReportLom 0
/call LoadSetting SelfBuffList Spell SelfBuffList "Buffs you wish to maintain of yourself separated with |"
/call LoadSetting SitAfterCast Spell SitAfterCast 0
/call LoadSetting SpellGem Spell SpellGem 8
/call LoadSetting YaulpSpell Spell YaulpSpell yaulp
/declare ArgNum int local 1
/for ArgNum 1 to ${Math.Calc[${SelfBuffList.Count[|]}+1]}
/varset CommandParam ${SelfBuffList.Arg[${ArgNum},|]}
/call AddSelfBuff "${CommandParam}"
/next ArgNum
/return
Sub SpellMain
/varset ST-SpellMain 1
/call CastFromQueue
|/if (${CastStep}) /call Cast-${CastType}
/if (${DoCanni}) /call CheckCann
/if (${DoYaulp}) /call CheckYaulp
/if (${SelfBuffPass}>40) {
/call CheckSelfBuffs
} else {
/varcalc SelfBuffPass ${SelfBuffPass}+1
}
/return
||||| Do Subs
Sub Do-buff
/declare BuffName string local
/declare BuffType string local
/if (!${Defined[Param0]}) /return
/if (${Param0.Equal[on]}) /return
/if (${Param0.Equal[off]}) {
/varset BuffListCount 0
/return
}
/declare SpellNameParam string local ${Param0}
/declare TargetName string local
/declare ParamCount int local 1
/if (${Param0.Equal[on]}) {
/varset SpellNameParam ${LastSn}
/goto :Do-BuffTargetStart
}
:Do-BuffSpellLoop
/if (${Defined[Param${ParamCount}]}) {
/if (${Param${ParamCount}.Equal[on]}) /goto :Do-BuffTargetStart
/varset SpellNameParam ${SpellNameParam} ${Param${ParamCount}}
/varcalc ParamCount ${ParamCount}+1
/goto :Do-BuffSpellLoop
}
:Do-BuffTargetStart
/varcalc ParamCount ${ParamCount}+1
/if (!${Defined[Param${ParamCount}]}) {
/varset TargetName me
} else {
/varset TargetName ${Param${ParamCount}}
/varcalc ParamCount ${ParamCount}+1
:Do-BuffTargetLoop
/if (${Defined[Param${ParamCount}]}) {
/varset TargetName ${TargetName} ${Param${ParamCount}}
/varcalc ParamCount ${ParamCount}+1
/goto :Do-BuffTargetLoop
}
/if (${TargetName.Equal[yourself]} || ${TargetName.Equal[${Me.CleanName}]}) {
/varset CommandParam ${SpellNameParam}
/call AddSelfBuff ${CommandParam}
/return
}
}
/call AssignCastTarget "${TargetName}"
/varset TargetName ${Macro.Return}
/if (${TargetName.Equal[0]}) {
/call ChatOut 5 ${MasterName} "I don't understand who to cast that buff on."
/return
}
/call RefineCast "${SpellNameParam}"
/if (${Macro.Return.Equal[0]}) /return
/varset SpellNameParam ${Macro.Return}
/if (Debug-Spell) /echo Do-buff "${SpellNameParam}" "${TargetName}"
/call AddCast "${SpellNameParam}" "${TargetName}" buff
|/if (${Macro.Return}==0) {
/if (TRUE) {
/declare NewBuff local
/varset NewBuff ${BuffListCount}
/varcalc NewBuff ${NewBuff}+1
/varset BuffList[${NewBuff},1] ${TargetName}
/varset BuffList[${NewBuff},2] ${SpellNameParam}
/varset BuffType ${SpellNameParam.Arg[1]}
/varset BuffName ${SpellNameParam.Right[-${SpellNameParam.Arg[1].Length}]}
/if (${SpellNameParam.Arg[1].Arg[1,-].Equal[spell]}) {
/varset BuffListTimes[${NewBuff},1] ${Spell[${BuffName}].Duration.TotalSeconds}
} else /if (${SpellNameParam.Arg[1].Arg[1,-].Equal[item]}) {
/varset BuffListTimes[${NewBuff},1] ${FindItem[${BuffName}].Spell.Duration.TotalSeconds}
} else /if (${SpellNameParam.Arg[1].Arg[1,-].Equal[alt]}) {
/varset BuffListTimes[${NewBuff},1] ${AltAbility[${BuffName}].ReuseTime}
}
/varset BuffListCount ${NewBuff}
/varset BuffListAdvance 50
}
/if (${SitAfterCast}) /varset SitTimer ${DelayBeforeSit}
/return
Sub Do-chainnuke
/declare NukeNum int local 1
/call StandardTarget "${CommandParam}"
:ChainNukeLoop
/if (${BreakOut}) /return
/if (!${Target.ID}) /return
/if (${Me.Gem[${ChainNuke.Arg[${NukeNum},|]}]}) /cast "${ChainNuke.Arg[${NukeNum},|]}"
/varcalc NukeNum ${NukeNum}+1
/if (!${ChainNuke.Arg[${NukeNum},|].Length}) /varset NukeNum 1
/goto :ChainNukeLoop
/return
Sub Do-chainstun
/call StandardTarget "${CommandParam}"
/if (!${Target.ID}) /return
/varset ChainStunNum 1
/call NextStun
/return
Sub Do-evac
/if (${EvacSpell.NotEqual[None]}) /call ChatOut 5 ${MasterName} "Moving to you and casting ${EvacSpell}!"
/call Do-moveto ${MasterName}
/call Delay 2s
/if (${EvacSpell.NotEqual[None]}) {
/if (Debug-Spell) /echo Do-evac "${EvacSpell}" ${Me.Name} heal
/call AddCast "${EvacSpell}" ${Me.Name} heal
}
/return
Sub Do-loadlist(string Spellset)
/if (!${Defined[Spellset]}) /return
/memspellset ${Spellset}
/return
Sub Do-itemcast
/if (!${Defined[Param0]}) /return
/if (${Me.Sitting}) {
/stand
/delay 3
}
/cast item "${CommandParam}"
/call ChatOut 3 ${MasterName} "Using ${CommandParam} on ${Target.CleanName}"
/return
Sub Do-mana
/if (!${Me.Class.CanCast}) /return
/declare RoundMana int local ${Math.Calc[${Math.Calc[${Me.PctMana}/5].Int}*5].Int}
/if (${RoundMana}==100) {
/call ChatOut 2 ${MasterName} "fm"
} else {
/call ChatOut 2 ${MasterName} "${RoundMana}m"
}
/return
Sub Do-sn(string newSpell)
/declare snTarget string local
/if ( !${Defined[newSpell]} && ${LastSn.Equal[NA]}) /return
/if (!${Defined[newSpell]}) /varset CommandParam "${LastSn}"
/if (!${Target.ID}) {
/varset snTarget 0
} else /if (${Target.Type.Equal[PC]}) {
/varset snTarget PC ${Target.CleanName}
} else /if (${Target.Type.Equal[Corpse]}) {
/varset snTarget Corpse id ${Target.ID}
} else {
/varset snTarget NPC id ${Target.ID}
}
|/call ChatOut 1 "${MasterName}" "Casting ${CommandParam} on ${Target.CleanName}"
/varset LastSn ${CommandParam}
/if (Debug-Spell) /echo Do-sn "${CommandParam}" "${snTarget}"
/call AddCast "${CommandParam}" "${snTarget}"
/return
Sub Do-snt
/if (!${Defined[Param0]}) /return
/if (${Param0.Equal[on]} && ${LastSn.NotEqual[NA]}) /return
/declare sntCastText string local ${Param0}
/declare ParamCount int local 1
/declare sntTarget string local 0
/if (${Param0.Equal[on]}) {
/varset sntCastText ${LastSn}
/goto :Do-sntTargetStart
}
:Do-sntSpellLoop
/if (${Defined[Param${ParamCount}]}) {
/if (${Param${ParamCount}.Equal[on]}) /goto :Do-sntTargetStart
/varset sntCastText ${sntCastText} ${Param${ParamCount}}
/varcalc ParamCount ${ParamCount}+1
/goto :Do-sntSpellLoop
}
:Do-sntTargetStart
/varcalc ParamCount ${ParamCount}+1
/if (${Defined[Param${ParamCount}]}) {
/varset sntTarget ${Param${ParamCount}}
/varcalc ParamCount ${ParamCount}+1
:Do-sntTargetLoop
/if (${Defined[Param${ParamCount}]}) {
/varset sntTarget ${sntTarget} ${Param${ParamCount}}
/varcalc ParamCount ${ParamCount}+1
/goto :Do-sntTargetLoop
}
}
/echo Target SHOULD be ${sntTarget}
/call AssignCastTarget "${sntTarget}"
/if (${Macro.Return.Equal[0]}) {
/call ChatOut 5 ${MasterName} "I don't have a target to cast on."
/return
}
/if (Debug-Spell) /echo Do-snt "${sntCastText}" "${Macro.Return}"
/call AddCast "${sntCastText}" "${Macro.Return}"
/varset LastSn ${sntCastText}
/return
Sub Do-spellgem
/if (!${Defined[Param0]}) {
/call ChatOut 3 ${MasterName} "I Gem ${SpellGem} when I need to mem new spells."
/return
}
/varset SpellGem ${Param0}
/call ChatOut 3 ${MasterName} "I will now use Gem ${SpellGem} when I need to mem new spells."
/return
|||| Called Subs
Sub AddCast(string AddCastText,string AddCastTarget,string AddCastCategory)
/declare AddCastType string local
/if (!${Defined[AddCastTarget]}) /varset AddCastTarget ${Target.Name}
/if (!${String[ corpse pc npc pet assist- 0 ].Find[ ${AddCastTarget.Arg[1].Lower} ]}) {
/call RefineTarget "${AddCastTarget}"
/varset AddCastTarget ${Macro.Return}
}
/if (!${String[ item spell alt ].Find[ ${AddCastText.Lower.Arg[1].Arg[1,-]} ]}) {
/call RefineCast "${AddCastText}"
/if (${Macro.Return.Equal[0]}) /return
/varset AddCastText ${Macro.Return}
}
/if (Debug-Spell) /echo AddCastText;AddCastTarget ${AddCastText};${AddCastTarget}
/if (!${CastQueue.Find[${AddCastText};${AddCastTarget}]}) {
/if (!${Defined[AddCastCategory]} || ${AddCastCategory.NotEqual[heal]}) {
/call ListAppendElement CastQueue "${AddCastText};${AddCastTarget}" |
} else {
/call ListPrependElement CastQueue "${AddCastText};${AddCastTarget}" |
}
}
/if (Debug-Spell) /echo CastQueue ${CastQueue}
/return
Sub CastFromQueue
/if (!${CastStep}) {
/if (!${CastQueue.Length}) /return
:gReplaceAssist
/if (${CastQueue.Find[assist-]}) {
/squelch /target clear
/if (Debug-Core) /echo /assist ${MasterName}
/assist ${MasterName}
/delay 3s ${Target.ID}
/if (${Target.ID}) {
/call RefineTarget "${Target.Name}"
/call ListReplacebyName CastQueue assist- "${Macro.Return}"
/goto :gReplaceAssist
} else {
/call ChatOut 4 ${MasterName} "Unable to assist you to find a target to cast on."
}
}
/varset CastType ${CastQueue.Arg[1]}
/varset CastName ${CastQueue.Arg[1,;].Right[-${Math.Calc[${CastQueue.Arg[1].Length}+1]}]}
/varset CastTarget ${CastQueue.Arg[1,|].Arg[2,;]}
/if (Debug-Spell) /echo CastType ${CastType} CastName ${CastName} CastTarget ${CastTarget}
/varset CastTimer 0
/varset CastStep 1
/varset CastOldTargetID 0
}
/if (Debug-Spell) /echo CastType CastName CastStep ${CastType} ${CastName} ${CastStep}
/if (${CastQueue.Length}) /call Cast-${CastType.Arg[1,-]}
/return
Sub Cast-spell
/if (${String[ 1 2 3 4 5 6 7 ].Find[ ${CastStep} ]}) {
|/echo going to sub
/goto :gCast-spell-${CastStep}
} else {
/echo CastStep = ${CastStep} -- No corresponding goto found. Returning.
/varstep CastStep 5
/return
}
| Wait for spell to pop up, stand up, and target correctly.
:gCast-spell-1
|/if (Debug-Spell) /echo Cast 1 ${CastName}
/if (${CastTimer}) /return
/varset CastLastResult CHECKING_Casting
/if (${Me.Casting.ID}) /return
/varset CastLastResult CHECKING_Moving
/if (${Me.Moving} && ${Spell[${CastName}].MyCastTime}>0.1 && ${Me.Class.Name.NotEqual[Bard]}) {
/varset CastStep 2
/return
}
/varset CastLastResult CHECKING_SpellMemmed
/if (!${Me.Gem[${CastName}]}) {
/varset CastStep 3
/return
}
/varset CastLastResult CHECKING_SpellUp
/if (!${Me.SpellReady[${CastName}]}) /return
/varset CastLastResult CHECKING_Standing
/if (!${Me.Standing}) {
/stand
/return
}
/if (${SitAfterCast}) /varset SitTimer 1140m
/varset CastLastResult CHECKING_Target
/if (!${String[|pb ae|self|ae pc v2|group v1|].Find[|${Spell[${CastName}].TargetType.Lower}|]} && ${CastTarget.NotEqual[0]}) {
/if (!${Spawn[${CastTarget}].ID}) {
/call ChatOut 3 ${MasterName} "I couldn't find the target: ${CastTarget}"
/varset CastStep 5
/varset CastLastResult TARGET_NOTEXIST
/return
}
/if (!${NearestSpawn[${CastTarget} radius ${MaxTargetRange}].ID}) {
/call ChatOut 3 ${MasterName} "Target: ${CastTarget} is out of range."
/varset CastStep 5
/varset CastLastResult TARGET_OUTOFRANGE
/return
}
/if (${Target.ID}!=${NearestSpawn[${CastTarget}].ID}) {
/varset CastOldTargetID ${Target.ID}
/target ${CastTarget}
/delay 2s ${Target.ID}==${NearestSpawn[${CastTarget}].ID}
/varset CastTimer 5
/if (${Target.ID}!=${NearestSpawn[${CastTarget}].ID}) {
/call ChatOut 3 ${MasterName} "Wasn't able to target: ${CastTarget}"
/varset CastStep 5
/varset CastLastResult TARGET_CANNOTTARGET
/return
}
}
/call ChatOut 3 ${MasterName} "Casting spell ${CastName} on ${Target.CleanName}."
} else {
/call ChatOut 3 ${MasterName} "Casting spell ${CastName}."
}
/cast "${CastName}"
/varset CastLastResult CAST_StillCasting
/varset CastStep 4
/varset CastTimer 0
/return
|Stop moving
:gCast-spell-2
/if (${Me.Moving}) {
/if (!${CastTimer}) {
/call ChatOut 3 ${MasterName} "Cast cast since I'm moving."
/keypress forward
/keypress back
/varset CastTimer 8
}
/return
}
/varcalc CastStep 1
/varset CastTimer 0
/return
| Memorize the spell
:gCast-spell-3
/if (!${Me.Gem["${CastName}"]}) {
/if (!${CastTimer}) {
/if (${CastType.Arg[2,_].Length}) {
/memspell ${CastType.Arg[2,_]} "${CastName}"
/call ChatOut 3 ${MasterName} "Memorizing spell: ${CastName} in slot ${CastType.Arg[2,_]}."
} else {
/memspell ${SpellGem} "${CastName}"
/call ChatOut 3 ${MasterName} "Memorizing spell: ${CastName} in default slot ${SpellGem}."
}
/varset CastTimer 5s
}
/return
}
/varset CastStep 1
/varset CastTimer 0
/return
| Wait for spell to finish
:gCast-spell-4
/if (${Me.Casting.ID}) {
/if (!${Me.Mount.ID} && ${Target.ID}!=${NearestSpawn[${CastTarget} radius ${MaxTargetRange}].ID}) {
/keypress FORWARD
/keypress BACK
/if (!${Me.Ducking}) /keypress DUCK
/delay 1
/if (${Me.Ducking}) /keypress DUCK
/varset CastStep 5
/call ChatOut 6 ${MasterName} "Interrupted spell: ${CastName}. Target ${NearestSpawn[${CastTarget}].CleanName} died, poofed, or came back to life!"
/varset CastLastResult SPELL_IntentionalInterruption
}
/return
}
/varcalc CastStep ${CastStep}+1
/return
| Put spells back if necessary and reset
:gCast-spell-5
/if (${CastTimer.OriginalValue}<>2) {
/varset CastTimer 2
/return
}
/if (${CastTimer}==0) {
/varset CastTime 0
/varcalc CastStep ${CastStep}+1
}
/return
| Delete old spell as cast and update status to successful unless otherwise
:gCast-spell-6
/if (${CastLastResult.Equal[CAST_StillCasting]}) /varset CastLastResult CAST_Successful
/call ListDelbyName CastQueue "${CastType} ${CastName};${CastTarget}" |
/if (${CastOldTargetID}) /target id ${CastOldTargetID} radius ${MaxTargetRange}
/if (Debug-Spell) /echo CastLastResult ${CastLastResult}
/if (${Remem}) {
/memspellset ${DefaultSpellSet}
/call ChatOut 6 ${MasterName} "Re-memorizing original spells."
/varset CastStep ${CastStep}+1
/return
}
/varset CastStep 0
/if (${SitAfterCast}) /varset SitTimer ${DelayBeforeSit}
/return
| Wait until spells are rememmed to continue
:gCast-spell-7
/if (${Window[SpellBookWnd].Open}) /return
/call ChatOut 6 ${MasterName} "Done memorizing original spells."
/if (${SitAfterCast}) /varset SitTimer ${DelayBeforeSit}
/varset CastStep 0
/return
Sub Cast-item
/if (${String[ 1 2 3 4 5 6 7 ].Find[ ${CastStep} ]}) {
|/echo going to sub
/goto :gCast-item-${CastStep}
} else {
/echo CastStep = ${CastStep} -- No corresponding goto found. Returning.
/varstep CastStep 5
/return
}
| Wait for spell to pop up, stand up, and target correctly.
:gCast-item-1
|/if (Debug-Spell) /echo Cast 1 ${CastName}
/if (${CastTimer}) /return
/varset CastLastResult CHECKING_Casting
/if (${Me.Casting.ID}) /return
/varset CastLastResult CHECKING_Moving
/if (${Me.Moving} && ${Spell[${CastName}].MyCastTime}>0.1 && ${Me.Class.Name.NotEqual[Bard]}) {
/varset CastStep 2
/return
}
/varset CastLastResult CHECKING_ItemEquipped
|/if (!${Me.Gem[${CastName}]}) {
| /varset CastStep 3
| /return
|}
/varset CastLastResult CHECKING_Standing
/if (!${Me.Standing}) {
/stand
/return
}
/if (${SitAfterCast}) /varset SitTimer 1140m
/varset CastLastResult CHECKING_Target
/if (!${String[|pb ae|self|ae pc v2|group v1|].Find[|${FindItem[${CastName}].Spell.TargetType.Lower}|]} && ${CastTarget.NotEqual[0]}) {
/if (!${Spawn[${CastTarget}].ID}) {
/call ChatOut 3 ${MasterName} "I couldn't find the target: ${CastTarget}"
/varset CastStep 5
/varset CastLastResult TARGET_NOTEXIST
/return
}
/if (!${NearestSpawn[${CastTarget} radius ${MaxTargetRange}].ID}) {
/call ChatOut 3 ${MasterName} "Target: ${CastTarget} is out of range."
/varset CastStep 5
/varset CastLastResult TARGET_OUTOFRANGE
/return
}
/if (${Target.ID}!=${NearestSpawn[${CastTarget}].ID}) {
/varset CastOldTargetID ${Target.ID}
/target ${CastTarget}
/delay 2s ${Target.ID}==${NearestSpawn[${CastTarget}].ID}
/varset CastTimer 5
/if (${Target.ID}!=${NearestSpawn[${CastTarget}].ID}) {
/call ChatOut 3 ${MasterName} "Wasn't able to target: ${CastTarget}"
/varset CastStep 5
/varset CastLastResult TARGET_CANNOTTARGET
/return
}
}
/call ChatOut 3 ${MasterName} "Casting item ${CastName} on ${Target.CleanName}."
} else {
/call ChatOut 3 ${MasterName} "Casting item ${CastName}."
}
/cast item "${CastName}"
/varset CastLastResult CAST_StillCasting
/varset CastStep 4
/varset CastTimer 0
/return
|Stop moving
:gCast-item-2
/if (${Me.Moving}) {
/if (!${CastTimer}) {
/call ChatOut 3 ${MasterName} "Cast cast since I'm moving."
/keypress forward
/keypress back
/varset CastTimer 8
}
/return
}
/varcalc CastStep 1
/varset CastTimer 0
/return
| Memorize the spell
:gCast-item-3
|/if (!${Me.Gem["${CastName}"]}) {
| /if (!${CastTimer}) {
| /if (${CastType.Arg[2,_].Length}) {
| /memspell ${CastType.Arg[2,_]} "${CastName}"
| /call ChatOut 3 ${MasterName} "Memorizing spell: ${CastName} in slot ${CastType.Arg[2,_]}."
| } else {
| /memspell ${SpellGem} "${CastName}"
| /call ChatOut 3 ${MasterName} "Memorizing spell: ${CastName} in default slot ${SpellGem}."
| }
| /varset CastTimer 5s
| }
| /return
|}
|/varset CastStep 1
|/varset CastTimer 0
|/return
| Wait for spell to finish
:gCast-item-4
/if (${Me.Casting.ID}) {
/if (!${Me.Mount.ID} && ${Target.ID}!=${NearestSpawn[${CastTarget} radius ${MaxTargetRange}].ID}) {
/keypress FORWARD
/keypress BACK
/if (!${Me.Ducking}) /keypress DUCK
/delay 1
/if (${Me.Ducking}) /keypress DUCK
/varset CastStep 5
/call ChatOut 6 ${MasterName} "Interrupted item: ${CastName}. Target ${NearestSpawn[${CastTarget}].CleanName} died, poofed, or came back to life!"
/varset CastLastResult SPELL_IntentionalInterruption
}
/return
}
/varcalc CastStep ${CastStep}+1
/return
| Put spells back if necessary and reset
:gCast-item-5
/if (${CastTimer.OriginalValue}<>2) {
/varset CastTimer 2
/return
}
/if (${CastTimer}==0) {
/varset CastTime 0
/varcalc CastStep ${CastStep}+1
}
/return
| Delete old spell as cast and update status to successful unless otherwise
:gCast-item-6
/if (${CastLastResult.Equal[CAST_StillCasting]}) /varset CastLastResult CAST_Successful
/call ListDelbyName CastQueue "${CastName};${CastTarget}" |
/if (${CastOldTargetID}) /target id ${CastOldTargetID} radius ${MaxTargetRange}
/if (Debug-Spell) /echo CastLastResult ${CastLastResult}
|/if (${Remem}) {
| /memspellset ${DefaultSpellSet}
| /call ChatOut 6 ${MasterName} "Re-memorizing original spells."
| /varset CastStep ${CastStep}+1
| /return
|}
/varset CastStep 0
/if (${SitAfterCast}) /varset SitTimer ${DelayBeforeSit}
/return
| Wait until spells are rememmed to continue
:gCast-item-7
|/if (${Window[SpellBookWnd].Open}) /return
|/call ChatOut 6 ${MasterName} "Done memorizing original spells."
|/if (${SitAfterCast}) /varset SitTimer ${DelayBeforeSit}
|/varset CastStep 0
/return
Sub AddSelfBuff
/if (!${Defined[Param0]}) /return
/if (${Param0.Equal[off]}) {
/varset SelfBuffCount 0
/return
}
/varcalc SelfBuffCount ${SelfBuffCount}+1
/call RefineCast "${CommandParam}"
/if (${Macro.Return.Equal[0]}) /return
/varset CommandParam ${Macro.Return}
/varset SelfBuff[${SelfBuffCount}] ${CommandParam}
/return
Sub AssignCastTarget(string ACTarget)
/if (!${Defined[ACTarget]} || !${ACTarget.Length} || ${ACTarget.Equal[0]}) {
/return assist-
} else /if (${ACTarget.Equal[yourself]} || ${ACTarget.Equal[${Me.CleanName}]}) {
/return ${Me.Name}
} else /if (${ACTarget.Equal[me]}) {
/return ${MasterName}
}
/return ${ACTarget}
Sub CheckCann
/if (!${Me.Moving}) {
/if (${Me.PctMana}<80 && ${Me.PctHPs}>=60 && ${Me.CurrentHPs}>1900 && ${CannAATimer}<=0) {
/alt activate 47
/varset CannAATimer 3m
}
/if (${Me.PctMana}<95 && ${Me.PctHPs}>=40 && ${CannTimer}<=0 && !${CastStep}) {
/if (Debug-Spell) /echo CheckCann "${CanniSpell}" "${Me.Name}"
/call AddCast "${CanniSpell}" ${Me.Name} buff
/varset CannTimer 4s
}
}
/return
Sub CheckMana
/if (${LomTimer}<=0) {
/if (${Me.PctMana}<${LomPct}) {
/call ChatOut 5 ${MasterName} "${LomMsg}"
/varset LomTimer 2m
}
}
/return
sub CheckSelfBuffs
/declare counter int local
/declare BuffName string local
/varset SelfBuffPass 0
/if (${SelfBuffList.Equal[Buffs you wish to maintain of yourself separated with |]} || !${SelfBuffList.Length}) /return
/for counter 1 to ${SelfBuffCount}
/varset BuffName ${SelfBuff[${counter}].Right[-${SelfBuff[${counter}].Arg[1].Length}]}
/if (!${Me.Buff[${BuffName}].ID} && ${SelfBuffInt[${counter},1]}<1) {
/if (Debug-Spell) /echo CheckSelfBuffs "${SelfBuff[${counter}]}" "${Me.Name}"
/call AddCast "${SelfBuff[${counter}]}" ${Me.Name} buff
/if (${Macro.Return}==1 && ${SelfBuffInt[${counter},2]}<6) {
/varset SelfBuffInt[${counter},1] 5
/varset SelfBuffInt[${counter},2] ${SelfBuffInt[${counter},2]}+1
}
/if (${Macro.Return}==1 && ${SelfBuffInt[${counter},2]}>=6) {
/varset SelfBuffInt[${counter},1] 900
/varset SelfBuffInt[${counter},2] 0
}
}
/next counter
/return
Sub CheckYaulp
/if (!${Me.Moving} && ${Me.PctMana}<95 && ${YaulpTimer}<=1) {
/if (Debug-Spell) /echo CheckYaulp "${YaulpSpell}" "${Me.Name}"
/call AddCast "${YaulpSpell}" ${Me.Name} buff
/varset YaulpTimer 25s
}
/return
Sub NextStun
/if (${BreakOut}) /return
/if (!${Target.ID}) /return
:JumpStunSpell
/if (${Me.Gem[${ChainStun.Arg[${ChainStunNum},|]}]}) {
/cast "${ChainStun.Arg[${ChainStunNum},|]}"
/varset ChainStunTime 50
} else {
/varcalc ChainStunNum ${ChainStunNum}+1
/goto :JumpStunSpell
}
/varcalc ChainStunNum ${ChainStunNum}+1
/if (!${ChainStun.Arg[${ChainStunNum},|].Length}) /varset ChainStunNum 1
/return
Sub RefineCast(string RCText)
/declare RCType string local ${RCText.Arg[1]}
/declare RCName string local ${RCText.Right[-${RCType.Length}]}
/declare RCCounter int local
/if (${String[ gem1 gem2 gem3 gem4 gem5 gem6 gem7 gem8 gem9 ].Find[ ${RCType.Lower} ]}) {
/varset RCType spell-${RCType.Right[1]}
/varset RCName ${RCName.Right[-${RCName.Arg[1].Length}]}
}
/if (${RCType.Arg[1.-].Equal[spell]}) {
/if (!${Int[${Me.Book[${RCName}]}]}) {
/call ChatOut 3 ${MasterName} "Spell: ${RCName} not found in your book."
/return 0
}
/return ${RCType} ${RCName}
}
/if (${RCType.Equal[slot]}) {
/varset RCType item-${RCName.Arg[1]}
/varset RCName ${RCName.Right[-${RCName.Arg[1].Length}]}
}
/if (${RCType.Arg[1.-].Equal[item]}) {
/if (!${FindItem[${RCName}].InvSlot}) {
/call ChatOut 3 ${MasterName} "Cannot find item: ${RCText} "
/return 0
}
/return ${RCType} ${RCName}
}
/if (${RCType.Equal[alt]}) {
/if (!${AltAbility[${RCName}].ID}) {
/call ChatOut 3 ${MasterName} "Do not understand Alt Ability: ${RCText} "
/return 0
}
/return ${RCType} ${RCName}
}
/return spell ${RCType} ${RCName}
Sub RefineTarget(string RFTarget)
/if (${RFTarget.Equal[assist]}) /return assist
/if (${NearestSpawn[${RFTarget}].Type.Equal[PC]}) {
/varset RFTarget pc ${NearestSpawn[${RFTarget}].Name}
} else {
/varset RFTarget ${NearestSpawn[${RFTarget}].Type} id ${NearestSpawn[${RFTarget}].ID}
}
/return ${RFTarget}
|||| Events
Sub Event_CastFizzle
/if (${CastStep}) {
/varset CastStep 0
/varset CastLastResult CAST_Fizzled
}
/return
Sub Event_CastInterrupt
/if (${CastStep}) {
/varset CastStep 0
/varset CastLastResult CAST_Interrupted
}
/return
Sub Event_CastNoMana
/if (${CastStep}) {
/varset CastLastResult CAST_CastNoMana
/if (${IsPally}) {
/varset CastStep 5
/varset CastLastResult CAST_CastNoMana
/if (${CastTimer}==0) {
/call ChatOut 5 "${MasterName} I am OOM!"
/varset CastTimer 100
/return
}
}
/call ChatOut 5 ${MasterName} "OOM. Medding 13 seconds and trying again. "
/varset CastStep 0
/if (!${Me.Standing} && !${Combatstatus}) /sit
/varset CastTimer 130
}
/return
Sub Event_CastResist
/if (${CastStep}) {
/varset CastStep 5
/if (${CastLastResult.Equal[CAST_StillCasting]}) {
/varset CastLastResult CAST_Resisted
/call ChatOut 3 ${MasterName} "${Target.CleanName} Resisted."
}
}
/return
Sub Event_CastTooFar
/if (${CastStep}) {
/call ChatOut 3 ${MasterName} "Too far away. "
/varset CastStep 5
/varset CastLastResult CAST_CastTooFar
}
/return
Sub Event_Collapse
/if (${CastStep}) {
/varset CastStep 0
}
/return
Sub Event_Distracted
/if (${CastStep}) {
/call ChatOut 5 ${MasterName} "I can't cast. I'm too distracted. "
/varset CastStep 5
/varset CastLastResult CAST_Distracted
}
/return
Sub Event_ImmuneRoot
/if (${CastStep}) {
/call ChatOut 3 ${MasterName} "Cannot Root or Snare this Target!"
/varset CastStep 5
/varset CastLastResult CAST_ImmuneRoot
}
/return
Sub Event_ImmuneSlow
/if (${CastStep}) {
/call ChatOut 3 ${MasterName} "Cannot Slow this Target (Immune)!"
/varset CastStep 5
/varset CastLastResult CAST_ImmuneSlow
}
/return
Sub Event_MissedNote
/if (${CastStep}) {
/varset CastStep 0
}
/return
Sub Event_NoLOS
/if (${CastStep}) {
/call ChatOut 10 ${MasterName} "I can't see my target. "
/varset CastStep 5
/varset CastLastResult CAST_NoLOS
}
/return
Sub Event_NoMem
/if (${CastStep}) {
/call ChatOut 5 ${MasterName} "That spell is not memed. "
/varset CastStep 0
/varset CastLastResult CAST_NoMem
}
/return
Sub Event_NoOverWrite
/if (${CastStep}) {
/call ChatOut 3 ${MasterName} "The spell won't take hold on the target."
/varset CastStep 5
/varset CastLastResult CAST_NoOverWrite
}
/return
Sub Event_NoTarget
/if (${CastStep}) {
/call ChatOut 3 ${MasterName} "I don't know what target to cast on. "
/varset CastStep 5
/varset CastLastResult CAST_NoTarget
}
/return
Sub Event_Recovered
/varset CastStep 0
/if (${CastStep}) {
/varset CastLastResult CAST_Recovered
}
/return
Sub Event_RootOff
/call ChatOut 5 ${MasterName} "Root has worn off. "
/return
Sub Event_Sitting
/if (${CastStep}) {
/varset CastStep 0
/varset CastLastResult CAST_NotStanding
}
/return
Sub Event_Stunned
/if (${CastStep}) {
/call ChatOut 5 ${MasterName} "I'm STUNNED. Waiting a second to try again."
/varset CastStep 0
/varset CastTimer 1s
/varset CastLastResult CAST_Stunned
}
/returnCode: Select all
} else /if (${ChatIn.Equal[IRC]}) {
/irc ${ChatText}
}
Code: Select all
} else /if (${ChatIn.Equal[IRC]}) {
/i say ${ChatText}
}
Have you checked your settings on the fps limiter(if the plugin/code is still in mq)? Check your BG setting and make sure it's not nicing down background eq's. I remember having to turn this off when running 2 on one machine for a friend of mine to keep Genbot from becoming too slugish.Vexix wrote:Well, new spells are largely working. Going to start bringing items into the fold next.
Speaking of framerate drops from macros, I've noticed that when I'm two boxing, the background bot response rate always drops way down. Does anyone have an idea on why this is?? I'm using XP. I've asked about it in the help forum here: http://macroquest2.com/phpBB2/viewtopic ... 4373#54373
Just bought an extra gig of ram to bring me up to 1.5GB, in the hopes that that would fix it. I do notice overall performance is faster, but background bot is just as pokey as ever. :P
--Vexix