Smart Enrage script

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Sadistic
orc pawn
orc pawn
Posts: 11
Joined: Mon Jan 19, 2004 1:33 am

Smart Enrage script

Post by Sadistic » Tue Jan 20, 2004 12:34 pm

Ive noticed while looking through alot of the code in the code depot that almost every script I found was using the same method to handle rage which is

Code: Select all


#Event Enraged "has become ENRAGED" 
#Event Offrage "is no longer enraged" 

Sub Event_Offrage 
   /if $target()=="TRUE" { 
         /varset EnrageVar 0 
         /attack 
      } 
   } 
/return

Sub Event_Enraged 
   /if $target()=="TRUE" { 
      /varset EnrageVar 1 
      /attack off 
   } 
/return 
I suppose no one has run into the probem (or just doesnt care) where player pets or a mob your not fighting goes enraged. I was hoping to get something a little more advanced working so that future scripts will employ a smart enrage detection. I dont claim to be a code genius since I started doing this a few days ago but this is what ive come up with.

Code: Select all

#event Enrage "@Param0" has become ENRAGED."

Sub Event_Enraged
	/if ($target(name,clean)==$arg(2,"@Param0")) {
                /varset EnrageVar 1
                /attack off
}
I read in the help file $target(name,clean) removes the _ and # from a mobs name. The $arg(2,"@Param0" is for the second word in the rage message? I realize that another case could come up where you could be on a raid fighting mobs that share the same name and all rage. I cant think of anything around that case.

Would this be a viable solution to the basic enrage checks we've been using?

blamstick
orc pawn
orc pawn
Posts: 27
Joined: Sat Sep 06, 2003 6:50 pm

Post by blamstick » Fri Jan 30, 2004 7:10 pm

I have the same problem. My pet enrages and it turns off my attack. Playing around with what you put here and this is what I'm trying.

In the ini file I setup an alias for the script to pass on the name of the target. And the hotkey is just /assist tankname on line 1 to get the mob targeted and line 2 is /melee.

/melee=/mac melee "$target(name)" or
/melee=/mac melee $target(name)

Come to think of it, I guess /mac melee $target(name,clean) would be the way to go. The @param0 would already be the exact name in the event and wouldn't need to strip it later.

Not sure if this works yet since I need to find some enraging mobs to test on but it would be nice to see if anyone else has a working method for this caus I'd like to see it workin!

I noticed one mistake in your code though - remove the ( before $target(name,clean). It should just be $target(name,clean). And remove the extra ) at the end of the statement.

You can test this by doing a quick check like this :

Code: Select all

Sub Main
/echo $target(name,clean)
/endmacro
/return

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Mon Feb 02, 2004 1:59 pm

Actually this never occurred to me when adding an enrage check to autofight.inc. Good idea, I'll see what I can come up with.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Mon Feb 02, 2004 3:01 pm

I actually already created a smart enrage/casting sort of routine. It is probably about as good as you are going to get.

It basically scrapes the event and then does a search spawn in your specified radius and compares the name from the mob that generated the event text and the mobs in your radius.

If the mob isn't in your defined radius it assumes the Enrage is from some other mob someone else is killing. You could in addition to this verify the health percentage of the mob etc to make it even more foolproof.

I might have to wait til I get home, not sure I have it here at work.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Mon Feb 02, 2004 3:23 pm

Here is the script I was talking about. It hasn't really been tested since I'd created it. I'd given it out to a few people and really didn't glance back over the code. When I just looked over it again I realized how little I knew of variable comparisons when I made it and made some corrections. Hopefully this works.

Read through the events and I think you should get the idea of what it is doing. Let me know if I need to fix it, like I said its been awhile since I made it. I should also not that this is a tank script I'd found in the depot initially, no clue who'd written it.

Code: Select all

|tank.mac
|
| Start the mac like this:  /macro tank.mac min max fastrange
|
| Example: /macro tank.mac 8 12 25
|

#Turbo 50
#Event Enraged "has become ENRAGED"
#Event Offrage "is no longer enraged"
#Event Bash "begins to cast a spell"


Sub Main
/declare RangeMin global
/declare RangeMax global
/declare FastRange global
/declare Combatstatus global
/declare EnrageVar global
/declare KickorSlam global

/declare DSChecktimer timer

| These are my damage shield clickies.  Comment them out if you don't have them and set them properly if you have some items. 
/call DS1
/call DS2
/call DS3

| This checks for your damage shield buff icons every 10 secs and refreshes as necessary.
/varset DSChecktimer 10s


/varset RangeMin @Param0
/varset RangeMax @Param1
/varset FastRange @Param2
/varset Combatstatus 0
/varset EnrageVar 0
/varset KickorSlam 1

:Mainloop
/call Combatcheck
/if $combat==TRUE {
    /if n $char(ability,"Taunt")>0 /doability "Taunt"
    /if n @KickorSlam==1 {
        /if n $char(ability,"Kick")>0 /doability "Kick"
    } else {
        /if n $char(ability,"Slam")==-2 /doability "Slam"
    }
}
/if n @DSChecktimer<=0 {
    /call DS1
    /call DS2
    /call DS3
    /varset DSChecktimer 10s
}
/if n @Combatstatus==1 /call RangeSub
/doevents
/goto :Mainloop
/return


Sub Combatcheck
/if n @EnrageVar==1 {
    /if $target()==TRUE {
        /return
    } else {
        /varset EnrageVar 0
        /varset Combatstatus 0
        /varset KickorSlam 1
    }
}
/if $target()==FALSE {
    /varset Combatstatus 0
    /varset KickorSlam 1
    /if $combat==TRUE {
        /attack off
    }
    /return
}
/if $target()==TRUE {
    /if $combat==TRUE {
        /varset Combatstatus 1
        /return
    }
}
/varset Combatstatus 0
/return


Sub Rangesub
/if "$target(type)"=="NPC" {
    /stand
    /face nolook fast
    /if n $target(distance)>=@FastRange /call Fastmove
    /if n $target(distance)>@RangeMax {
        /press up
    }
    /if n $target(distance)<@RangeMin {
        /press down
    }
}
/return


Sub Fastmove
:fastmoveloop
/if $target()==FALSE {
    /varset Combatstatus 0
    /varset KickorSlam 1
    /sendkey up up
    /if $combat==TRUE {
        /attack off
        /return
    }
}
/if "$target(type)"=="NPC" {
    /stand
    /face nolook fast
    /if n $target(distance)>@FastRange {
        /sendkey down up
        /attack off
    }
    /if n $target(distance)<=@FastRange {
        /if n @Combatstatus==1 {
            /if n @EnrageVar==0 {
                /attack on
            }
        }
        /sendkey up up
        /return
    }
}
/goto :fastmoveloop
/return

Sub DS1
/if n $char(buff,"Spikecoat")<=0 {
    /cast item "Girdle of Living Thorns"
    /delay 1s
}
/return

Sub DS2
/if n $char(buff,"Thorny Shield")<=0 {
    /cast item "Cloak of Thorns"
    /delay 1s
}
/return

Sub DS3
/if n $char(buff,"Shield of the Eighth")<=0 {
    /echo !!Recast *Shield of the Eighth*!!
}
/return


Sub Event_Enraged(OnRageText)
/if $target()==TRUE {
    /call FindEvtNPC "@OnRageText" 200 "has become ENRAGED"
    /if $return==FOUND {
        /varset EnrageVar 1
        /attack off
    }
}
/return


Sub Event_Offrage(OffRageText)
/if $target()==TRUE {
    /call FindEvtNPC "@OffRageText" 200 "is no longer enraged"
    /if $return==FOUND {
        /varset EnrageVar 0
        /attack on
    }
}
/return

Sub Event_Bash(BashText)
/if $target()==TRUE {
    /call FindEvtNPC "@BashText" 200 "begins to cast a spell"
    /if $return==FOUND {
         /varset KickorSlam 2
    }
}
/return

Sub FindEvtNPC(MsgText,SrchRadius,EvtText)
/declare MobName local
/declare MobID local
/declare LastID local
/declare PositionText local
/varset PositionText $instr("@EvtText","@MsgText")
/varset MobName "$mid(0,@PositionText,"@MsgText")"
/if "$right(1,"@MobName")"==" " /varset MobName "$left($calc($strlen("@MobName")-1),"@MobName")"
/varset MobID 0
/varset LastID 0
/if $target()==TRUE {
    /varset MobID $searchspawn("@MobName",npc,radius:@SrchRadius)
    :GetID
    /if n @MobID!=0 {
        /varset LastID @MobID
        /if n $target(id)==@MobID {
            /return FOUND
        } else {
            /varset MobID $searchspawn("@MobName",npc,id:@LastID,radius:@SrchRadius,next)
            /if n @LastID==@MobID /return NOTFOUND
            /goto :GetID                     
        }
    }
}
/return NOTFOUND