exptracking.inc -- Exp tracker. Yay math =/

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

magictiger
a snow griffon
a snow griffon
Posts: 450
Joined: Sun Mar 21, 2004 2:24 pm

Post by magictiger » Tue Jul 13, 2004 5:20 am

Not updated every fight because it's using the old events system. It's real easy to convert over. There's a post in the macro depot that should explain all of it. (or at least there used to be)

hiipii
a ghoul
a ghoul
Posts: 93
Joined: Sat Jun 19, 2004 5:01 pm

Post by hiipii » Tue Jul 13, 2004 5:26 pm

to update the events all you need to do is change
#Event GainExp "You gain"
#Event GainExp "You regain some experience from resurrection"
#Event LoseExp "You have been slain"
to

Code: Select all

#Event GainExp "#*#You gain#*#" 
#Event GainExp "#*#You regain some experience from resurrection#*#" 
#Event LoseExp "#*#You have been slain#*#"
that *should* make it update correctly

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Tue Jul 13, 2004 11:04 pm

Thanks, I've made the change and will try it out asap!

A Troll
a lesser mummy
a lesser mummy
Posts: 30
Joined: Fri May 21, 2004 10:04 am

Post by A Troll » Sun Jul 18, 2004 6:29 am

ok thanks, works now perfectly

but got another question now :-)
is there a way to change the script to schow the exp changes like 1,31% instead of 1%

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Sun Jul 18, 2004 6:40 am

It should be easy. I don't know the coding for it but the Integers would have to be changed to a 2place decimal so that it could give you n.xy

Might find the code in one of the HUD or UI posts. I'll have to look that up as I like the decimals as well so I can see exactly what I am getting.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Sun Jul 18, 2004 6:41 am

I'm really tired but it's something like
/declare Current int local ${Me.PctExp}
changing it to float or something like that <yawn>

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Sun Jul 18, 2004 6:48 am

Thanks Drumstix, that looks close to what I found in my UI that showed percent with decimal to 2 places.

Edit: that is already in there. Must be something within the math that needs to be changed. I'm starting to see how things work a little at a time, but honestly the math sections always drive me out of my skull.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Sun Jul 18, 2004 6:59 am

Code: Select all

|** 
  ExpReport.inc written by Preocts. Updated last: 05/01/2004 
  Modified for post on 07/18/04 from info posted by hiipii to make it compatible
  with the recent changes in coding for Events.

  This file tracks exp information. It is dependant on ini information. That 
  information is stored in ${IniFileName} under keys [ExpTrack] and [Settings] 
  *Should handle Exp, AA, Leadership, and RaidLeadership equally as well. 
  [ExpTrack] is self creating. 
  [Settings] is not required. Optional ValueNames include: 
    Noise=0[default] no /echos to screen. 1 /echos to screen each kill 

  REQUIRED OUTER VAR: IniFileName 
  Should easy to understand what to set this to. 

**| 

#Event GainExp "#*#You gain#*#" 
#Event GainExp "#*#You regain some experience from resurrection#*#" 
#Event LoseExp "#*#You have been slain#*#" 

Sub StartExpTrack 
  |/declare IniFileName string outer whatever.ini 
  |Update the ini with current Exp and AAexp 
  /ini "${IniFileName}" "ExpTrack" "PastExp" "${Me.PctExp}" 
  /ini "${IniFileName}" "ExpTrack" "PastAA" "${Me.PctAAExp}" 
  /ini "${IniFileName}" "ExpTrack" "PastLeader" "${Me.PctGroupLeaderExp}" 
  /ini "${IniFileName}" "ExpTrack" "PastRaid" "${Me.PctRaidLeaderExp}" 
/return 

Sub Event_GainExp 
| If nothing has changed: miscall, leave. 
  /if (${Ini[${IniFileName},ExpTrack,PastExp,0]}==${CurrentExp} && ${Ini[${IniFileName},ExpTrack,PastAA,0]}==${CurrentAA}) /return 

| This sub is just all math logic for calc'ing EXP gains. Gains, not loses. 
| Thanks to Lax's new ${} phrasing this is done with ONE loop! Rock on your bad self Lax! 
  /declare Past int local 
  /declare Current int local ${Me.PctExp} 
  /declare Count int local 
  /declare Total int local 
  /declare Change int local 0 
  /declare ExpType string local Exp 

  :FourLoop 
    /varset Past ${Ini[${IniFileName},ExpTrack,Past${ExpType},0]} 
    /varset Count ${Ini[${IniFileName},ExpTrack,${ExpType}Count,0]} 
    /varset Total ${Ini[${IniFileName},ExpTrack,${ExpType}Total,0]} 
    /if (${Past}!=${Current}) { 
      /if (${Past}<${Current}) { 
        /varcalc Change ${Current}-${Past} 
      } else { 
        /if (${Current}) { 
          /varcalc Change (${Current}+100)-${Past} 
        } else { 
          /varcalc Change 100-${Past} 
        } 
      } 
      /varcalc Count ${Count}+1 
      /varcalc Total ${Total}+${Change} 
      /if (${Ini[${IniFileName},Settings,Echo,0]}) { 
        /echo You have gained ${Change}% ${ExpType} experience on that kill. 
        /echo Total ${ExpType} changes: ${Count}, Total ${ExpType} Gained: ${Total}, Average per change: ${Math.Calc[${Total}/${Count}]}% ${ExpType} Exp 
      } 
    } 
    /ini "${IniFileName}" "ExpTrack" "Past${ExpType}" ${Current} 
    /ini "${IniFileName}" "ExpTrack" "${ExpType}Count" ${Count} 
    /ini "${IniFileName}" "ExpTrack" "${ExpType}Total" ${Total} 
    /if (${ExpType.Equal[Exp]}) { 
      /varset ExpType AA 
      /varset Current ${Me.PctAAExp} 
      /varset Change 0 
      /goto :FourLoop 
    } 
    /if (${ExpType.Equal[AA]}) { 
      /varset ExpType Leader 
      /varset Current ${Me.PctGroupLeaderExp} 
      /varset Change 0 
      /goto :FourLoop 
    } 
    /if (${ExpType.Equal[Leader]}) { 
      /varset ExpType Raid 
      /varset Current ${Me.PctRaidLeaderExp} 
      /varset Change 0 
      /goto :FourLoop 
    } 
/return 

Sub Event_LoseExp 
| More math, this time with EXP lose due to death. 
  /declare PastExp int local ${Ini[${IniFileName},ExpTrack,PastExp,0]} 
  /declare CurrentExp int local ${Me.PctExp} 
  /declare ExpCount int local ${Ini[${IniFileName},ExpTrack,ExpCount,0]} 
  /declare ExpTotal int local ${Ini[${IniFileName},ExpTrack,ExpTotal,0]} 
  /declare ExpChange int local 0 
  
| If nothing has changed: miscall, leave. 
  /if (${PastExp}==${CurrentExp}) /return 
  /if (${PastExp}>${CurrentExp}) { 
    /varcalc ExpChange ${PastExp}-${CurrentExp} 
  } else { 
    /varcalc ExpChange (${PastExp}+100)-${CurrentExp} 
  } 
  /varcalc ExpTotal ${ExpTotal}-${ExpChange} 
  /varcalc ExpCount ${ExpCount} + 1 
  /if (${Ini[${IniFileName},Settings,Echo,0]}) { 
    /echo Ouch, You have lost ${ExpChange}% experience because of death. 
    /echo Total Exp Changes: ${ExpCount}, Total Exp Gained: ${ExpTotal}, Average per change: ${Math.Calc[${ExpTotal}/${ExpCount}]}% Exp 
  } 
  /ini "${IniFileName}" "ExpTrack" "PastExp" ${CurrentExp} 
  /ini "${IniFileName}" "ExpTrack" "ExpCount" ${ExpCount} 
  /ini "${IniFileName}" "ExpTrack" "ExpTotal" ${ExpTotal} 
/return
This incorperates the changes posted by hiipii to make it function properly again.
It does not show decimal, only whole numbers in calculations shown upon XP gained/lost.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Sun Jul 18, 2004 5:10 pm

aChallenged1 wrote:Thanks Drumstix, that looks close to what I found in my UI that showed percent with decimal to 2 places.

Edit: that is already in there. Must be something within the math that needs to be changed. I'm starting to see how things work a little at a time, but honestly the math sections always drive me out of my skull.
Where's it already in there?

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Sun Jul 18, 2004 7:15 pm

| This sub is just all math logic for calc'ing EXP gains. Gains, not loses.
| Thanks to Lax's new ${} phrasing this is done with ONE loop! Rock on your bad self Lax!
/declare Past int local

/declare Current int local ${Me.PctExp} // <==This line here!
/declare Count int local
/declare Total int local
/declare Change int local 0
/declare ExpType string local Exp
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Mon Jul 19, 2004 12:28 am

Did you even read my post from before. go read it again.

zanomo
a hill giant
a hill giant
Posts: 285
Joined: Thu Jun 24, 2004 11:21 pm

Post by zanomo » Mon Jul 19, 2004 1:45 am

From the manual:

Code: Select all

character (inherits spawn)  
  
Members  
 int ID Spawn ID 
 string Name First name 
 int Level  Level 
 int Exp  Experience (of 330) 
 float PctExp Experience as a % 
PctExp is already a float...

so:

Code: Select all

/declare Current float local ${Me.PctExp}
and changing all the other variables associated with this calculation would give you a float result.

(sorry for my bad English...)

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Mon Jul 19, 2004 9:03 am

Sorry Drumstix, I'm so used to having the example posted that I misunderstood what you were telling me.

Thinking about it now, I should have understood. Int is always a whole number so that original line could not have given anything but a whole number.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Mon Jul 19, 2004 5:43 pm

Bingo.

A Troll
a lesser mummy
a lesser mummy
Posts: 30
Joined: Fri May 21, 2004 10:04 am

Post by A Troll » Thu Jul 22, 2004 2:27 pm

Works now , thanks for the help :-)