need some help with killing off a mob

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

dman
a hill giant
a hill giant
Posts: 181
Joined: Fri Dec 05, 2003 12:54 pm

need some help with killing off a mob

Post by dman » Fri Dec 05, 2003 1:23 pm

Ok, I'm trying to create a macro that keeps track of my damage output for my characters. I have the damage parsing out fine, but I'm trying to come up with an easy way to determine the correct ending of a mob. The experience event can only go so far and I have a few ideas to cut off premature ending of the tracking from exp messages not related to your current target. But when you don't get an exp message for one of various reasons I can't figure out how to determine if I should end the current mob and start another. For now I set an event to force a mob reset when I send myself a tell.

Code: Select all

| damage.mac
| Usage /macro damage.mac
|
| Credits:  The CountArgs sub is ripped from the sits macro by kargonis
|
| MobArray(@CurrentMob,1)   = Mob Name
| MobArray(@CurrentMob,2)   = Total Hit Count
| MobArray(@CurrentMob,3)   = Total Miss Count
| MobArray(@CurrentMob,4)   = Total Damage Count
| MobArray(@CurrentMob,5)   = Slash Count
| MobArray(@CurrentMob,6)   = Slash Miss Count
| MobArray(@CurrentMob,7)   = Slashing Damage
| MobArray(@CurrentMob,8)   = Pierce Count
| MobArray(@CurrentMob,9)   = Pierce Miss Count
| MobArray(@CurrentMob,10) = Piercing Damage
| MobArray(@CurrentMob,11) = Blunt Count
| MobArray(@CurrentMob,12) = Blunt Miss Count
| MobArray(@CurrentMob,13) = Blunt Damage
| MobArray(@CurrentMob,14) = Unarmed count
| MobArray(@CurrentMob,15) = Unarmed Miss count
| MobArray(@CurrentMob,16) = Unarmed damage
| MobArray(@CurrentMob,17) = Special Attack count
| MobArray(@CurrentMob,18) = Special Attack miss count
| MobArray(@CurrentMob,19) = Special Attack damage
| MobArray(@CurrentMob,20) = Non-melee hit count
| MobArray(@CurrentMob,21) = Non-melee miss count
| MobArray(@CurrentMob,22) = Non-melee damage
| MobArray(@CurrentMob,23) = Mob Start Time ($running as mob is first attacked by us)
| MobArray(@CurrentMob,24) = Mob End Time ($running as mob is flushed)

#event Damage "points of damage."
#event Miss "You try to"
#event Resist "Your target resisted"
#event Exp "You gain"
#event Force "Talking to yourself again?"
#event NMDamage "points of non-melee damage."

#turbo

Sub Main
  :Loop
    /doevents
  /goto :Loop

Sub Event_Damage
  /declare DamageAmount local
| Check to see if variables are there
  /if $defined(VariablesSetup)!="TRUE" /call SetupVariables
| Check to see if this is a new mob
  /if n @MobStart==0 /call StartMob
| Find Melee Damage
  /if $arg(1,"@Param0")=="You" {
    /varset DamageAmount $arg(@MDamageArg,"@Param0")
    /varadd MobArray(@CurrentMob,2) 1
    /varadd MobArray(@CurrentMob,4) @DamageAmount
    /if $arg(2,"@Param0")=="slash" {
      /varadd MobArray(@CurrentMob,5) 1
      /varadd MobArray(@CurrentMob,7) @DamageAmount
|  /echo Slash
      /return
    } else  /if $arg(2,"@Param0")=="pierce" {
      /varadd MobArray(@CurrentMob,8) 1
      /varadd MobArray(@CurrentMob,10) @DamageAmount
|  /echo Pierce
      /return
    } else  /if $arg(2,"@Param0")=="crush" {
      /varadd MobArray(@CurrentMob,11) 1
      /varadd MobArray(@CurrentMob,13) @DamageAmount
|  /echo Crush
      /return
    } else  /if $arg(2,"@Param0")=="hit" {
      /varadd MobArray(@CurrentMob,14) 1
      /varadd MobArray(@CurrentMob,16) @DamageAmount
|  /echo Hit
      /return
    } else {
      /varadd MobArray(@CurrentMob,17) 1
      /varadd MobArray(@CurrentMob,19) @DamageAmount
|  /echo Other
      /return
    }
  }
  /return

Sub Event_NMDamage
  /declare DamageAmount local
| Check to see if variables are there
  /if $defined(VariablesSetup)!="TRUE" /call SetupVariables
| Check to see if this is a new mob
  /if n @MobStart==0 /call StartMob
| Find Non-melee damage
  /if $arg(1,"@Param0")=="$char(name)" {
    /varset DamageAmount $arg(@NMDamageArg,"@Param0)
    /varadd MobArray(@CurrentMob,2) 1
    /varadd MobArray(@CurrentMob,4) @DamageAmount
    /varadd MobArray(@CurrentMob,20) 1
    /varadd MobArray(@CurrentMob,22) @DamageAmount
|  /echo Nuke
    /return
  }
  /return

Sub Event_Miss
| Check to see if variables are there
  /if $defined(VariablesSetup)!="TRUE" /call SetupVariables
| Check to see if this is a new mob
  /if n @MobStart==0 /call StartMob
  /varadd MobArray(@CurrentMob,3) 1
  /if $arg(4,"@Param0")=="slash" {
    /varadd MobArray(@CurrentMob,6) 1
    /return
    } else  /if $arg(4,"@Param0")=="pierce" {
      /varadd MobArray(@CurrentMob,9) 1
      /return
    } else  /if $arg(4,"@Param0")=="crush" {
      /varadd MobArray(@CurrentMob,12) 1
      /return
    } else  /if $arg(4,"@Param0")=="hit" {
      /varadd MobArray(@CurrentMob,15) 1
      /return
    } else {
      /varadd MobArray(@CurrentMob,18) 1
      /return
    }
  /return

Sub Event_Resist
  | Check to see if variables are there
  /if $defined(VariablesSetup)!="TRUE" /call SetupVariables
| Check to see if this is a new mob
  /if n @MobStart==0 /call StartMob
  /varadd MobArray(@CurrentMob,3) 1
  /varadd MobArray(@CurrentMob,21) 1
  /return

Sub Event_Exp
  /call MobEnd
  /return

Sub Event_Force
  /call MobEnd
  /return

Sub SetupVariables
  /declare VariablesSetup global
  /declare MobArray array2
  /declare CurrentMob global
  /declare MobStart global
  /declare MDamageArg global
  /declare NMDamageArg global
  /varset VariablesSetup 0
  /varset CurrentMob 0
  /varset MobStart 0
  /return

Sub StartMob
  /declare loopcounter local
  /varadd CurrentMob 1
  /varset MobArray(@CurrentMob,1) "$target(name,clean)"
  /for loopcounter 2 to 22
    /varset MobArray(@CurrentMob,@loopcounter) 0
  /next loopcounter
  /varset MobArray(@CurrentMob,23) $running
  /varset MobArray(@CurrentMob,24) 0
  /varset MobStart 1
  /call CountArgs "$target(name,clean)"
|    /echo $int($return)
    /varset MDamageArg $int($calc($return+4))
    /varset NMDamageArg $int($calc($return+4))
  /return

Sub MobEnd
  /declare moblength local
  /varset MobArray(@CurrentMob,24) $running
  /varset MobStart 0
  /varset moblength $int($calc(@MobArray(@CurrentMob,24)-@MobArray(@CurrentMob,23)))
  /echo @MobArray(@CurrentMob,1) dead in $int(@moblength) seconds.
  /echo You did $int(@MobArray(@CurrentMob,4)) damage for $calc(@MobArray(@CurrentMob,4)/@moblength) dps.
  /return

Sub CountArgs 
/declare ArgCount local 
/declare ArgTemp local 
   /if $defined(Param0)==false { 
      /echo Syntax: /call CountArgs "space seperated string of arguments" 
      /endmacro 
   } 
   /varset ArgCount 1 
   /varset ArgTemp 1 
   :Loop 
      /if "$mid($int(@ArgTemp),1,"@Param0")"==" " /varadd ArgCount 1 
      /varadd ArgTemp 1 
   /if n @ArgTemp<$strLen("@Param0") /goto :Loop 
/return $int(@ArgCount)