Got a cool macro idea? Wanna request a macro? Here is the place for you!
Moderator: MacroQuest Developers
-
Tuna
- a lesser mummy

- Posts: 68
- Joined: Mon Jul 21, 2003 4:10 pm
Post
by Tuna » Tue Dec 16, 2003 4:20 pm
I have a few very large macros I have written. I'd consider myself a novice at the scripting language. However, there is something I'd like to do.
Basically have a one-shot macro which executes code like this:
Code: Select all
for every mob M in a 100 unit radius
if M not debuffed yet /call Debuff M
next M
sub Debuff
/target id M
/cast 1, pause
/cast 2, pause
/cast 3, pause
add M to an array of debuffed mob IDs
/return
Reasoning:
I tend to XP with chaotic psycho pullers. We like to fight 3 to 7 blue cons at once. I am mana stingy on my bot. I want the bot to cast something on every mob within range.
Dunno any way to iterate a list, and as far as I can tell, /target only accepts one "notid" parameter.
Thanks,
Tuna
-
Raebis
- a ghoul

- Posts: 81
- Joined: Fri Dec 12, 2003 6:23 am
Post
by Raebis » Tue Dec 16, 2003 6:07 pm
i dont' know how to do for/next loops but the code in.. the code in red is pseudo-code (not correct syntax for MQ2)
Code: Select all
/varset SID1 $searchspawn(npc,loc,radius:600) |Targets the first nearest mob
| enter your cast here routines for the first mob here
[color=red]do until @MID=0[/color]
/varset MID1 $searchspawn(npc,loc,radius:100,"id:@SID1","next")
|enter cast routines here for subsequent mobs
[color=red]loop[/color]
every time the loop goes through the next closest mob within radis:100 is targeted.
I'm not sure if after all mobs in the radius are targeted the next /target request is zero.... but you get the idea
Always say what you want to say. Because those who mind, don't matter. And those who matter, don't mind.
-
Tuna
- a lesser mummy

- Posts: 68
- Joined: Mon Jul 21, 2003 4:10 pm
Post
by Tuna » Tue Dec 16, 2003 6:12 pm
Okay, apparently my reading comprehension skills are lacking. Never saw searchspawn() or the 'next' option to /target.
Should be a piece of cake now. I'll go test on a bunch of orc pawns.
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Tue Dec 16, 2003 7:14 pm
Make sure you download and compile the latest MQ2 zip. The $searchspawn radius stuff was fixed on the 10th of Dec I believe.
This should get you started.
Code: Select all
#turbo 20
Sub Main
/declare NpcCount global
/declare DebuffCount global
/declare Radius global
/declare MobList array
/declare Debuff array
/declare DebuffWaitTime array
/declare a local
/varset Radius 100
| Set this to the number of debuff spells you will be casting.
/varset DebuffCount 3
| Set these to the names of the debuff spells you will be casting.
/varset Debuff(1) "Debuff Spell Name1"
/varset Debuff(2) "Debuff Spell Name2"
/varset Debuff(3) "Debuff Spell Name3"
| Set these to a value larger than the cast time of the debuff spell.
/varset DebuffWaitTime(1) 3s
/varset DebuffWaitTime(2) 3s
/varset DebuffWaitTime(3) 3s
/call IterateNPC
/if n @NpcCount>0 {
/for a 1 to @NpcCount
/echo Debuffing: $spawn(@MobList(@a),name,clean)
/call Debuff @MobList(@a)
/next a
}
/return
Sub IterateNPC
/declare npcid local
/declare firstnpcid local
/declare lastnpcid local
/varset npcid 0
/varset firstnpcid 0
/varset lastnpcid 0
/varset NpcCount 0
/varset npcid $searchspawn(npc,radius:@Radius)
:Loop
/if n @npcid==@firstnpcid {
/return
} else {
/if n @NpcCount==0 /varset firstnpcid @npcid
/varset lastnpcid @npcid
/varset npcid $searchspawn(npc,id:@lastnpcid,radius:@Radius,next)
/if n @lastnpcid!=0 /varadd NpcCount 1
/if n @lastnpcid!=0 /varset MobList(@NpcCount) @lastnpcid
}
/goto :Loop
/return
Sub Debuff(mobid)
/declare b local
/target id @mobid
/for b 1 to @DebuffCount
/echo Casting @Debuff(@b) on $spawn(@mobid,name,clean)
/cast "@Debuff(@b)"
/delay @DebuffWaitTime(@b)
/next b
/return
Last edited by
ml2517 on Mon Dec 29, 2003 12:00 pm, edited 1 time in total.
-
Tuna
- a lesser mummy

- Posts: 68
- Joined: Mon Jul 21, 2003 4:10 pm
Post
by Tuna » Wed Dec 17, 2003 2:10 pm
Thank you, that was very helpful!
-
Raebis
- a ghoul

- Posts: 81
- Joined: Fri Dec 12, 2003 6:23 am
Post
by Raebis » Wed Dec 17, 2003 2:45 pm
oops i forgot one thing:
that way u actually target it heh
Always say what you want to say. Because those who mind, don't matter. And those who matter, don't mind.
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Fri Jan 09, 2004 10:35 pm
Just posting this here for Stm for lack of a better thread.
Code: Select all
#turbo 50
Sub Main
/declare MobID global
/varset MobID 0
/declare Radius global
| Placing a marker where we started the script at.
/declare StartLocX global
/declare StartLocY global
/varset StartLocX $char(x)
/varset StartLocY $char(y)
:MainLoop
/call DoMobSearch
/delay 1
/doevents
/goto :MainLoop
/return
Sub DoMobSearch
/for Radius 0 to 10000 step 100
/echo Trying Radius:@Radius
/call FindMobTarget npc 50 65 @StartLocX @StartLocY @Radius
/if n $return!=0 {
/varset MobID $return
/call GotMob
/return
}
/next Radius
/echo Didn't find a mob that met the criteria of your search.
/echo Trying search again.
/return
Sub FindMobTarget(SrchType,SrchLevelMin,SrchLevelMax,SrchLocX,SrchLocY,SrchRadius)
/declare npcid local
/declare firstnpcid local
/declare lastnpcid local
/declare lastmob local
/declare lastmobdist local
/declare NpcCount local
/varset npcid 0
/varset firstnpcid 0
/varset lastnpcid 0
/varset NpcCount 0
/varset npcid $searchspawn(@SrchType,range:@SrchLevelMin:@SrchLevelMax,loc:@SrchLocX:@SrchLocY,radius:@SrchRadius)
/if n @npcid>0 {
/if n $spawn(@npcid,hp,pct)>95 /return @npcid
}
:FindMobLoop
/if n @npcid==@firstnpcid {
/return 0
} else {
/if n @NpcCount==0 /varset firstnpcid @npcid
/varset lastnpcid @npcid
/varset npcid $searchspawn(@SrchType,id:@lastnpcid,range:@SrchLevelMin:@SrchLevelMax,loc:@SrchLocX:@SrchLocY,radius:@SrchRadius,next)
/if n @npcid>0 {
/if n $spawn(@npcid,hp,pct)>95 /return @npcid
}
/if n @lastnpcid!=0 /varadd NpcCount 1
}
/goto :FindMobLoop
/return 0
Sub GotMob
/echo The mob ID we found is: @MobID
/echo The mob name is: $spawn(@MobID,name,clean)
/echo The mob's level is: $spawn(@MobID,level)
/endmacro
/return
-
[40oz]
- a hill giant

- Posts: 156
- Joined: Tue Nov 12, 2002 12:14 pm
Post
by [40oz] » Sun Jan 11, 2004 4:39 am
quick note...
if mobs move, you might debuff same mob twice. the only way i can think to do this is to have something that looks like this very poorly written psuedo-code:
Code: Select all
.
.
.
currentMobs=0
currentMobArray[0]=NULL
for mobs
do debuffs
currentMobArray[currentMobs]=$target(id)
currentMobs++
next mob
.
.
.
sub event_mobdies
for mobtest 0 to currentMobs
if currentMobArray[mobtest] = dead
move everything in the array beyond that number back one spot
decrement currentMobs
next mobtest
/return
-
antithott
- orc pawn

- Posts: 15
- Joined: Mon May 19, 2003 6:15 am
Post
by antithott » Mon Feb 02, 2004 2:49 pm
Hi, i got a question about this code ml2517 wrote, I put it into my own shaman script, so that i can toggle it on / off, which is a nice addition for a ldon run. but a problem comes, Cause it keep debuffing the same mob over once it get to the end of the list, IE, if 1 mob is pulled it will continue to malo and slow this mob, Is there a way you can maybe add each mob it debuff into a .ini file and then exclude its Id until you zone next time, Then have it clear the Ini? or a much easier way perhaps
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Mon Feb 02, 2004 3:28 pm
You'd need to store it in an array for a given period of time and then expire it. If I get some free time tonight I'll mess around with it. The reason I hadn't added it in to begin with is that the script wasn't meant to loop forever. It was meant to be run when mobs were incoming and then once it went through the cycle it would terminate. Also, I was still in the learning phase and just playing around to see if I understood how to do it.
