This example is triggered from an event OR a heal and it will remove the Necromancer "Lich" spell:
[AdvHeal]
[AH3]
Gem=Script
Spell=DropLich
SpellFoci=
DurMod=0
SpellAlias=droplich
SpellMinMana=0
Announce=/bc
TarCnt=1
Class=pc hp40 nec
[AdvEvent]
[AE3]
Gem=Script
Spell=DropLich
SpellFoci=
DurMod=0
Delay=0
EventMinMana=100
EventMinHP=40
MinMana=20
MaxMana=100
MinHP=0
MaxHP=90
TarType=tnt
SpellAlias=
Announce=/bc
[Script-DropLich]
Commands=1
C1=/if ({Me.Buff[Lich].ID}) /removebuff Lich
This example is launched via the ACBefore command from the [Melee] section. Assume Sneak Attack is bound to hotkey 6. What the bot will do is to trigger Sneak Attack, attempt proper position, backstab the mob, then revert to "normal"
[Script-SneakAttack]
Commands=10
C1=/if ({Melee.Enable}) /melee plugin=0
C2=/if ({Me.CombatAbilityReady[Sneak Attack]}) /keypress 6
C3=/if (!{Me.Moving} && !{Stick.MoveBehind} && {Stick.Distance}!={Math.Calc[{Spawn[{ACMATarget}].MaxRangeTo}+5]}) /stick {Math.Calc[{Spawn[{ACMATarget}].MaxRangeTo}+5]} behind id {ACMATarget}
C4=/if ({Target.ID}!={ACMATarget}) /multiline ; /target id {ACMATarget};/delay 5
C5=/if ({Melee.BackAngle}>60 || {Melee.BackAngle}<-60) /goto :Top
C6=/if ({Target.Distance3D}>={Spawn[{ACMATarget}].MaxRangeTo}) /stick {Math.Calc[{Spawn[{ACMATarget}].MaxRangeTo}-5]} hold behind id {ACMATarget}
C7=/if ({Target.Distance3D}>={Spawn[{ACMATarget}].MaxRangeTo}-3) /goto :Top
C8=/delay 5
C9=/if ({Me.AbilityReady[Backstab]}) /doability backstab
C10=/melee plugin=1
This example will confirm you are hidden and sneaking when at "camp" and not sneaking when I'm in follow mode. It will also re-engage if MQ2Melee lost "stick" because of too much mob movement
[Script-HideSneak]
Commands=4
C1=/if ({FollowFlag} && {Me.Sneaking}) /multiline ; /doability sneak;/return
C2=/if (!{FollowFlag} && !{ACState} && {Select[{MakeCamp},on]} && {Me.AbilityReady[Hide]} && !{Me.Moving} && !{Melee.Combat}) /multiline ; /doability Hide;/delay 5
C3=/if (!{FollowFlag} && !{ACState} && {Select[{MakeCamp},on]} && {Me.AbilityReady[Sneak]} && !{Me.AbilityReady[Hide]} && !{Me.Moving} && !{Melee.Combat}) /multiline ; /doability Sneak;/delay 5
C4=/if ({ACState} && {ACMATarget} && {Target.ID} && {Me.AbilityReady[Backstab]}) /keypress q
Example of createing a new global var and an example of using it
[Script-EventsOff]
Commands=2
C1=/if (!{Defined[CheckSlow]}) /declare CheckSlow int outer 1
C2=/if ({DoEvents}) /multiline ; /varset DoEvents FALSE;/varset CheckSlow 1
[Script-EventsOn]
Commands=2
C1=/if (!{Defined[CheckSlow]}) /declare CheckSlow int outer 3
C1=/if (!{DoEvents}) /multiline ; /varset DoEvents TRUE;/varcalc CheckSlow {CheckSlow}+1
[Script-IsSlowed]
Commands=3
C1=/if (!{Defined[CheckSlow]}) /multiline ; /varset DoEvents FALSE;/return
C2=/if ({CheckSlow}<=4) /varset DoEvents FALSE
C3=/if ({CheckSlow}>4) /varset DoEvents TRUE;/varset CheckSlow 1
Example of using a ModBot global string. This will create a new pet, say when your existing pet is about to die
Please note in the INI snippets below that the INI generated global string PetCast has a space. To pass this properly in the script, you must encapsulate it in apostrophes. Script code uses apostrophes in place of quotes.
[Script-NewPet]
Commands=4
C1=/multiline ; /casting ''{PetCast}'' -maxtries|5;/delay 2s
C2=/if ({Cast.Timing}>600) /goto :Top
C3=/multiline ; /if ({Me.Pet.ID}) /pet go away;/delay 2s !{Me.Casting.ID}
C4=/if (!{Me.Pet.ID}) /goto :Top
Example of using PetCast for a cleric hammer, to be called from a ACBefore command
[Settings]
DoPet=FALSE
PetCast=Unswerving hammer of awesomeness|gem1
[Melee]
ACBefore=/if (!{Me.Pet.ID} && {ACMATarget} && {Spawn[{ACMATarget}].Type.Equal[NPC]} && {Spawn[{ACMATarget}].Distance3D}<={ACLeash}) /call MBScript SumHam
[Script-SumHam]
Commands=2
C1=/if ({Target.ID}!={ACMATarget}) /multiline ; /target id {ACMATarget};/delay 5
C2=/if (!{Me.Pet.ID}) /multiline ; /casting ''{PetCast}'' -maxtries|2;/delay 3s