CountExp.inc

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

Dregs
orc pawn
orc pawn
Posts: 20
Joined: Tue Dec 29, 2009 9:57 am

CountExp.inc

Post by Dregs » Thu Dec 31, 2009 11:51 pm

Here is an include file I made since I found I was running some kind of exp per mob calculation in most of the macros I was using. I previously had some errors with the calculations showing negative numbers, or other strangeness if you gained a level or dinged an AA, but I (think) I now have a special condition for each one, that should display the exp correctly even when dinging an AA or leveling up. As there are 8 different conditions for group and solo exp, please let me know if any of them don't work correctly. I have never had a toon level up, get an AA, and gain a leadership point all at the same time, but I thought I'd make it handle everything, just in case, although, some parts like these are yet untested as that's extremely difficult to plan.

Anyway, here's the code.

Code: Select all

|Countexp.inc Version 1.0
|Written by Dregs
|Based on exp-calculating code from the rogue helper macro
|------------------------------------------------------------------------------
|Usage: Make sure to include a line for /doevents
|       Post these variables into the macro you want to call this snippet from:
|
|   /declare MobsKilled int outer 0
|   /declare LDExp float outer ${Me.PctGroupLeaderExp} 
|   /declare AAExp float outer ${Me.PctAAExp} 
|   /declare Exp float outer ${Me.PctExp}
|   /declare CurrentAA int outer ${Me.AAPointsTotal}
|   /declare CurrentLevel int outer ${Me.Level}
|   /declare CurrentLeaderPoints int outer ${Me.GroupLeaderPoints}
|------------------------------------------------------------------------------
#event GroupExp "#*#You gain party experience#*#"
#event SoloExp "#*#You gain experience#*#"

Sub Event_GroupExp
   /varcalc MobsKilled (1+${MobsKilled})
   /if (${Me.Level}>${CurrentLevel} && ${Me.AAPointsTotal}>${CurrentAA} && ${Me.GroupLeaderPoints}>${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Group XP: REG (${Math.Calc[100+${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[100+${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[100+${Me.PctGroupLeaderExp}-${LDExp}]}%)
   }
   /if (${Me.Level}>${CurrentLevel} && ${Me.AAPointsTotal}>${CurrentAA} && ${Me.GroupLeaderPoints}==${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Group XP: REG (${Math.Calc[100+${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[100+${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%) 
   }
   /if (${Me.Level}>${CurrentLevel} && ${Me.AAPointsTotal}==${CurrentAA} && ${Me.GroupLeaderPoints}==${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Group XP: Reg (${Math.Calc[100+${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /if (${Me.Level}>${CurrentLevel} && ${Me.AAPointsTotal}==${CurrentAA} && ${Me.GroupLeaderPoints}>${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Group XP: Reg (${Math.Calc[100+${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[100+${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /if (${Me.Level}==${CurrentLevel} && ${Me.AAPointsTotal}>${CurrentAA} && ${Me.GroupLeaderPoints}>${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Group XP: Reg (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[100+${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[100+${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /if (${Me.Level}==${CurrentLevel} && ${Me.AAPointsTotal}==${CurrentAA} && ${Me.GroupLeaderPoints}==${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Group XP: REG (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%) 
   }
   /if (${Me.Level}==${CurrentLevel} && ${Me.AAPointsTotal}==${CurrentAA} && ${Me.GroupLeaderPoints}>${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Group XP: Reg (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[100+${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /if (${Me.Level}==${CurrentLevel} && ${Me.AAPointsTotal}>${CurrentAA} && ${Me.GroupLeaderPoints}==${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Group XP: Reg (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[100+${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /varset CurrentAA ${Me.AAPointsTotal}
   /varset CurrentLevel ${Me.Level}
   /varset CurrentLeaderPoints ${Me.GroupLeaderPoints}
   /varset LDExp ${Me.PctGroupLeaderExp} 
   /varset AAExp ${Me.PctAAExp} 
   /varset Exp ${Me.PctExp}
/return

Sub Event_SoloExp
   /varcalc MobsKilled (1+${MobsKilled})
   /if (${Me.Level}>${CurrentLevel} && ${Me.AAPointsTotal}>${CurrentAA} && ${Me.GroupLeaderPoints}>${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Solo XP: REG (${Math.Calc[100+${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[100+${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[100+${Me.PctGroupLeaderExp}-${LDExp}]}%)
   }
   /if (${Me.Level}>${CurrentLevel} && ${Me.AAPointsTotal}>${CurrentAA} && ${Me.GroupLeaderPoints}==${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Solo XP: REG (${Math.Calc[100+${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[100+${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%) 
   }
   /if (${Me.Level}>${CurrentLevel} && ${Me.AAPointsTotal}==${CurrentAA} && ${Me.GroupLeaderPoints}==${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Solo XP: Reg (${Math.Calc[100+${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /if (${Me.Level}>${CurrentLevel} && ${Me.AAPointsTotal}==${CurrentAA} && ${Me.GroupLeaderPoints}>${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Solo XP: Reg (${Math.Calc[100+${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[100+${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /if (${Me.Level}==${CurrentLevel} && ${Me.AAPointsTotal}>${CurrentAA} && ${Me.GroupLeaderPoints}>${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Solo XP: Reg (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[100+${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[100+${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /if (${Me.Level}==${CurrentLevel} && ${Me.AAPointsTotal}==${CurrentAA} && ${Me.GroupLeaderPoints}==${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Solo XP: REG (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%) 
   }
   /if (${Me.Level}==${CurrentLevel} && ${Me.AAPointsTotal}==${CurrentAA} && ${Me.GroupLeaderPoints}>${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Solo XP: Reg (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[100+${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /if (${Me.Level}==${CurrentLevel} && ${Me.AAPointsTotal}>${CurrentAA} && ${Me.GroupLeaderPoints}==${CurrentLeaderPoints}) {
      /echo Kill number ${MobsKilled} yielded Solo XP: Reg (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[100+${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%
   }
   /varset CurrentAA ${Me.AAPointsTotal}
   /varset CurrentLevel ${Me.Level}
   /varset CurrentLeaderPoints ${Me.GroupLeaderPoints}
   /varset LDExp ${Me.PctGroupLeaderExp} 
   /varset AAExp ${Me.PctAAExp} 
   /varset Exp ${Me.PctExp}
/return

LamahHerder
a hill giant
a hill giant
Posts: 299
Joined: Sat Jun 29, 2002 2:37 am

Post by LamahHerder » Tue Jan 12, 2010 1:20 am

Thanks

Dregs
orc pawn
orc pawn
Posts: 20
Joined: Tue Dec 29, 2009 9:57 am

Post by Dregs » Mon Jan 25, 2010 11:42 am

*Edited when I realized I could make it drastically shorter and maintain the same functionality*
Here is my version 2.0 of this include file. I shortened it a bit, and added a bit of functionality.

Now if you type
/echo report exp
it will report how much experience you have gained since starting the macro, and also tell how much exp you are getting per mob, on average.

Please keep in mind that this will not work for calculating how much exp you are gaining while shrouded as it will say you are getting 0.00% per kill.

Code: Select all

|Countexp.inc Version 2.0
|Written by Dregs
|Based on exp-calculating code from the rogue helper macro
|------------------------------------------------------------------------------
|Usage: Include the following lines in your macro:
|       #include CountExp.inc
|       /call CreateCountExpVariables
|       /doevents
|------------------------------------------------------------------------------
#event GainedExp "#*#You gain #0#!!"
#event ReportExp "#*#[MQ2] Report exp#*#"

Sub CreateCountExpVariables
   /declare MobsKilled int outer 0
   /declare ReportLDExp float outer 0
   /declare ReportAAExp float outer 0
   /declare ReportExp float outer 0
   /declare ReportLDExpTotal float outer 0
   /declare ReportAAExpTotal float outer 0
   /declare ReportExpTotal float outer 0
   /declare LDExp float outer ${Me.PctGroupLeaderExp} 
   /declare AAExp float outer ${Me.PctAAExp} 
   /declare Exp float outer ${Me.PctExp}
   /declare CurrentAA int outer ${Me.AAPointsTotal}
   /declare CurrentLevel int outer ${Me.Level}
   /declare CurrentLeaderPoints int outer ${Me.GroupLeaderPoints}
   /declare StartingLDExp float outer ${Me.PctGroupLeaderExp}
   /declare StartingAAExp float outer ${Me.PctAAExp}
   /declare StartingExp float outer ${Me.PctExp}
/return

Sub Event_GainedExp(string WhatType)
   /varcalc MobsKilled (1+${MobsKilled})
   /if (${Me.Level}>${CurrentLevel}) /varcalc ReportExp (100+${Me.PctExp}-${Exp})
   /if (${Me.Level}==${CurrentLevel}) /varcalc ReportExp (${Me.PctExp}-${Exp})
   /if (${Me.AAPointsTotal}>${CurrentAA}) /varcalc ReportAAExp (100+${Me.PctAAExp}-${AAExp})
   /if (${Me.AAPointsTotal}==${CurrentAA}) /varcalc ReportAAExp (${Me.PctAAExp}-${AAExp})
   /if (${Me.GroupLeaderPoints}>${CurrentLeaderPoints}) /varcalc ReportLDExp (100+${Me.PctGroupLeaderExp}-${LDExp})
   /if (${Me.GroupLeaderPoints}==${CurrentLeaderPoints}) /varcalc ReportLDExp (${Me.PctGroupLeaderExp}-${LDExp})
   /if (${WhatType.Equal[experience]}) {
      /echo Kill number ${MobsKilled} yielded Solo XP: REG (${ReportExp}%), AA (${ReportAAExp}%), LDR (${ReportLDExp}%)
   }
   /if (${WhatType.Equal[party experience]}) {
      /echo Kill number ${MobsKilled} yielded Group XP: REG (${ReportExp}%), AA (${ReportAAExp}%), LDR (${ReportLDExp}%)
   }
   /varcalc ReportExpTotal (${ReportExp}+${ReportExpTotal})
   /varcalc ReportLDExpTotal (${ReportLDExp}+${ReportLDExpTotal})
   /varcalc ReportAAExpTotal (${ReportAAExp}+${ReportAAExpTotal})
   /varset CurrentAA ${Me.AAPointsTotal}
   /varset CurrentLevel ${Me.Level}
   /varset CurrentLeaderPoints ${Me.GroupLeaderPoints}
   /varset LDExp ${Me.PctGroupLeaderExp} 
   /varset AAExp ${Me.PctAAExp} 
   /varset Exp ${Me.PctExp}
/return

Sub Event_ReportExp
   /echo You have gained ${ReportExpTotal}% level exp, ${ReportAAExpTotal}% AA exp, and ${ReportLDExpTotal}% leadership exp from ${MobsKilled} mobs.
   /if (${MobsKilled}>0) {
      /echo You are averaging ${Math.Calc[${ReportExpTotal}/${MobsKilled}]}% Level exp, ${Math.Calc[${ReportAAExpTotal}/${MobsKilled}]}% AA exp, and ${Math.Calc[${ReportLDExpTotal}/${MobsKilled}]}% Leadership exp per mob. 
   }
/return