However, when the database starts to get very large it tends to slow down your computer... [If anyone knows a way to remedy this, I'd appreciate the tip. :)] so, the database is flushed when it reaches a certain number of entries. (Be sure to specify that in the macro text.)
When you wish to end the macro, you will need to /end.
Enjoy,
Lestor
Code: Select all
| - Radial pet attack macro by Lestor
| - Syntax: /macro petattack [radius]
#turbo
| Change this number to specify the maximum number of mobs to que up.
#define QEUCOUNT 20
Sub Main
/declare count1 global
/declare count2 global
/call FlushDB
/declare targetID global
/declare range global
/varset range @Param0
/echo Radius set to @range
/if $defined(Param0)==FALSE {
/echo Usage /macro petattack [range]
/echo Default range is 200.
/varset range 200
}
/varset count2 0
/varset targetID $char(id)
:Loop
/doevents
/if n @count2>QEUCOUNT /call FlushDB
/call AttackTarget
/doevents
/delay 1
/varset targetID $char(id)
/goto :Loop
/return
sub AttackTarget
:Loop
/doevents
/if n $spawn($searchspawn(npc,id:@targetID,next),distance)>@range /return
/call CheckTargetID $searchspawn(npc,id:@targetID,next)
/varset targetID $searchspawn(npc,id:@targetID,next)
/if $return==EXSISTS /goto :Loop
/delay 1
/target id @targetID
/echo Attacking '$target(name)'...
/pet attack
/return
Sub FlushDB
/zapvars novars notimers
/varset count1 0
/varset count2 0
/echo Flushing database...
/declare targetDB array
/delay 10
/return
Sub CheckTargetID(id)
/varset count1 0
:Loop
/if n @targetDB(@count1)==$searchspawn(npc,id:@targetID,next) /return EXSISTS
/if @targetDB(@count1)==UNDEFINED-ARRAY-ELEMENT {
/call AddTargetID @id
/varadd count2 1
/return ADDED
}
/varadd count1 1
/goto :Loop
/return
Sub AddTargetID(id)
/varset targetDB(@count1) @id
/return

