Babysteps, learning to make simple macros, help wanted.

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

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

Babysteps, learning to make simple macros, help wanted.

Post by aChallenged1 » Thu Jul 08, 2004 7:24 pm

Code: Select all

| - myfirst_continued.mac - 
| 
| Just to prove I have a basic understanding of Event usage 
| Subroutine usage and return and paramaters for catching chat sequences. 
| Now adding in #include, declare, and call 

#include exptracking.inc 

#Event Assist "#1# tells the #*#Assist#*#" 
#Event UnderAttack "#1# has #2# you for#*#" 

Sub Main 
   /declare IniFileName string outer aChallenged1.ini 
   /call StartExpTrack 
      :Loop 
        /doevents 
        /delay 1 
        /goto :Loop 
     /return 

Sub Event_Assist 
  /echo Assisting #1#! 
  /assist #1# 
  /delay 1s 
  /pet attack 
/return 

Sub Event_UnderAttack 
  /popup "You are under attack!" 
  /face 
  /attack on 
/return
It should work. Whether or not it really does, at this point, is not an issue. I'm trying to understand things a little at a time.

What I want to know is did I add in the exptracer.inc properly and call it properly?

If not, what did I do wrong?

EDIT: moved /call out of loop
Last edited by aChallenged1 on Fri Jul 09, 2004 6:44 am, edited 1 time in total.

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

Post by aChallenged1 » Thu Jul 08, 2004 7:54 pm

Ok, I think I found an issue with this already. Actually I'm sure of it.

It is not from running the above macro, but from running another macro to try out the exptracking.inc.

In the macro, which I took from the same thread as the exptracker.inc, it /declares in the macro. When I ran the macro it kept giving me an error saying IniFileName has already been declared. I was just looking inside the inc file and I found near the top that it was trying to declare IniFilesName. Now, would it be ok to declare within the INC or should I declare in the macro? Some of what I have read makes me think in the macro.

Vexix
Genbot Janitor
Posts: 245
Joined: Sat Apr 17, 2004 10:10 am

Post by Vexix » Thu Jul 08, 2004 8:14 pm

Either place is fine, just make sure it's only declared once.

--Vexix

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

Post by aChallenged1 » Thu Jul 08, 2004 9:38 pm

Commented it out in the INC and it didn't give me an error. Good to know.

Thanks.

Still not sure that the exptracking.inc is doing what it was intended to do. It is supposed to /echo xp at each kill, even rez. I am not seeing that. Might be there is a toggle or such I need to set. I'll look into it some more. I do have an INI file that is tracking my total xp though.

s16z
a ghoul
a ghoul
Posts: 97
Joined: Thu Apr 01, 2004 12:03 pm

Post by s16z » Fri Jul 09, 2004 12:05 am

Every 1/10th of a second (or some time slightly higher than that) you are calling "StartExpTrack". Shouldn't you only call that once, when you want it started (in other words, move it out of the loop).

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

Post by aChallenged1 » Fri Jul 09, 2004 6:42 am

Thanks.

I found the problem with not spouting out my xp at each kill, have to edit the ini file and add

Code: Select all

[Settings]
Noise=1

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

Post by aChallenged1 » Fri Jul 09, 2004 10:14 am

I added that setting as indicated above, and still does not do /echo for experience gained, etc. Frustrating!

Code: Select all

|** 
  ExpReport.inc written by Preocts. Updated last: 05/01/2004 

  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
The above is code from Snippets by Preocts.
Going to try something, having looked some more.