Code:
Sub Main
/while (1) {
/do this
/if (blah) {
/do this
}
if (blah2) {
/do that
}
}
/return
a while loop allows you to continually go top to bottom doing the things you want to do.
any time someone (including me) has said "just need a super simple thing" there are other things that end up being needed.
like /delay while moving to a mob, checking that your target is on, addressing that you're not trying to attack something that is invalid, maybe handle being stuck, stopping to med, etc.
and that's not to say that you dont, in fact, really want something that simple - it just "never is just i need a while loop"
it might be easier to strip off what you don't need/want rather than building from scratch
but you can slap your snippet inside a while loop, and when you are no longer in combat, grab a new mob and go fight it.
word of advice - it is a bad idea to target something you can't see - I would suggest using mq2nav to
/nav spawn blah and then target and it and attack it when you get there
here's something i put together in like 2019 (i was super new and didn't know shit so it's probably trash, and i'm not going to clean it up because it is near useless, but it might give you something to work with)
rat.mac
Code:
| You can change "rat" to "whatevermob"
Sub Main
/declare Mob string outer "rat"
/while (1) {
/if (${SpawnCount[npc ${Mob} radius 60]} >=1) /call NavToSpawnName ${Mob}
/if (${Target.ID} && ${Target.Distance3D} < 5) /call BustEmUp
/delay 1s
}
/return
Sub NavToSpawnName(Mob)
/|echo In NavToSpawn
/nav spawn ${Mob}
/delay 2s ${Navigation.Active}
/while (${Navigation.Active}) {
/if (${Spawn[npc ${Mob}].Distance3D} > 15) {
/delay 1s
} else {
/break
}
}
/if (${Spawn[npc ${Mob}].Distance3D} < 5) {
/target npc ${Mob}
/face fast
}
/return
Sub BustEmUp
|/echo Bust Em Up
/if (!${Me.Combat}) {
/attack on
/while (${Target.PctHPs} > 1) {
/delay 1s
/if (${Target.Distance3D} > 30) {
/break
}
}
}
/return