track.mac - Zone Dependant | Rare Spawn List | Tracker

Post your completed (working) macros here. Only for macros using MQ2Data syntax!

Moderator: MacroQuest Developers

Shin Noir
a ghoul
a ghoul
Posts: 90
Joined: Tue Aug 05, 2003 8:18 pm

track.mac - Zone Dependant | Rare Spawn List | Tracker

Post by Shin Noir » Thu May 31, 2007 12:34 am

Description: A NPC spawn tracker.

Features include:
  • When a tracked mob spawns - How many of a tracked mob is in the zone
    When a tracked mob dies - How many of a tracked spawn is left in the zone
    Individual zone lists (Alert.ini)
I joined EQ recently again and figured no better way to rejoice than to revitalize some of my old code with the new variables and random improvements MQ has.(See here for old tracker macro) Good job devs on the MQ macro tweaks!


Be gentle about my coding skills I've been learning the new verbage and such maybe 3 hours exclusively writing this... Oh and let me know if you find it useful! Thanks

Code: Select all

|#Track.mac
|Ideally you want to run this by doing /Mac track run
|But if you don't it'll nag you with who created this and additional parameters.
|#Created by Shin Noir.#

Sub Main

/declare MaxTrack int outer 99
/declare i int local
/declare MobsToTrack int outer
/declare SpawnTracker[${MaxTrack}] int outer 0
   /if (${Param0.Equal["add"]}) {
      /if (${Ini[Alerts.ini,${Zone.ShortName},index]}==NULL) {
       /varset i 0
      } else {
       /varset i ${Ini[Alerts.ini,${Zone.ShortName},index,${Param1}]}
      }
      /varcalc i ${i}+1
      /ini "Alerts.ini" "${Zone.ShortName}" "${i}" ${Param1}
      /ini "Alerts.ini" "${Zone.ShortName}" "index" "${i}"
      /echo Added NPC to ${Zone.ShortName}(${i}):${Param1}
      /goto :Run
   }
   /if (${Param0.Equal["run"]}) /goto :Run
   /if (${Param0.Equal["list"]}) /call ListMobs
   /if (!${Defined[Param0]}) /call Syntax 

   :Run
  /declare Current_Zone outer
  /varset Current_Zone ${Zone.ShortName}

  /if (${Ini[Alerts.ini,${Zone.ShortName},index]}==NULL) {
    /echo Zone is currently ${Zone.ShortName} with no spawns being tracked.
    /ini "Alerts.ini" "${Zone.ShortName}" "index" "0"    
  } else {
    /echo Zone is currently ${Zone.ShortName} with ${Ini[Alerts.ini,${Zone.ShortName},index]} spawns being tracked.
  }
  
   :Loop
   /if (${Zone.ShortName.NotEqual[${Current_Zone}]}) {
    /if (${Ini[Alerts.ini,${Zone.ShortName},index]}==NULL) {
        /echo Zone is currently ${Zone.ShortName} with no spawns being tracked.
        /ini "Alerts.ini" "${Zone.ShortName}" "index" "0"    
    } else {
        /echo Zone is currently ${Zone.ShortName} with ${Ini[Alerts.ini,${Zone.ShortName},index]} spawns being tracked.
    }
    
    /for i 1 to 99
      /varset SpawnTracker[${i}] 0
    /next i  
     /ini "Alerts.ini" "Current_Zone" "visited" "${Time.Date} at ${Time.Time24}" 
     /varset Current_Zone ${Zone.ShortName}
   }
      /call DoTracking
   /doevents
   /goto :Loop
/return

Sub DoTracking
/if (${Ini[Alerts.ini,${Zone.ShortName},index]}==NULL) {
/varset MobsToTrack 0
} else {
/varset MobsToTrack 1
}
/if (${MobsToTrack}>0) {
   /declare i int local
     /for i 1 to ${Ini[Alerts.ini,${Zone.ShortName},index]}
              /if (${SpawnTracker[${i}]}<${SpawnCount[npc ${Ini[Alerts.ini,${Zone.ShortName},${i}]}]}) {        
                /echo ${Ini[Alerts.ini,${Zone.ShortName},${i}]} is up (${SpawnCount[npc ${Ini[Alerts.ini,${Zone.ShortName},${i}]}]} total).
                /varset SpawnTracker[${i}] ${SpawnCount[npc ${Ini[Alerts.ini,${Zone.ShortName},${i}]}]}
              } else /if (${SpawnTracker[${i}]}>${SpawnCount[npc ${Ini[Alerts.ini,${Zone.ShortName},${i}]}]}) {
	      /if (${SpawnTracker[${i}]}>0) {        
                /echo ${Ini[Alerts.ini,${Zone.ShortName},${i}]} has died (${SpawnCount[npc ${Ini[Alerts.ini,${Zone.ShortName},${i}]}]} remain).
                /varset SpawnTracker[${i}] ${SpawnCount[npc ${Ini[Alerts.ini,${Zone.ShortName},${i}]}]}
              }  
         }
     /next i
}
/return

Sub ListMobs 
   /declare i int local
   /echo Track List:
   /if (${Ini[Alerts.ini,${Zone.ShortName},index]}==NULL) {
      /echo None.
   } else {
      /for i 1 to ${Ini[Alerts.ini,${Zone.ShortName},index]}
        /echo ${Ini[Alerts.ini,${Zone.ShortName},${i}]}
      /next i
   }
/return

Sub Syntax
      /echo Created by Shin Noir.
      /echo Note you can use "add <name>" or "list" when calling this macro.
/return

zoobish
a lesser mummy
a lesser mummy
Posts: 40
Joined: Tue Apr 18, 2006 6:59 am

Nice

Post by zoobish » Thu May 31, 2007 5:53 am

Cool =)

Instead of /doevents, i put in a /delay 1. So it checks 10 times a second, more than enough =)

Whats Current_Zone for?? lol...

I added an outer variable to main:

Code: Select all

/declare alertFile string outer d:\mq2\Macros\Alert.ini
Then put ${alertFile} in place of all your references to "Alert.ini". Works good, only one place yah gotta change yah file name at... Maybe adding the toons name infront, so my necro dont get the same alerts as my beast... lol... Tho I could hack that into it. Very easy, prolly no extra lines of code... hmm like:

Code: Select all

/declare alertFile string outer d:\mq2\Macros\${Me.Name}_Alert.ini
or even:

Code: Select all

/declare alertFile string outer d:\mq2\Macros\${Macroquest.Server}_${Me.Name}_Alert.ini
or to be more correct:

Code: Select all

/declare aFilePath string local d:\mq2\Macros\
/declare aFileName string outer ${aFilePath}${Macroquest.Server}_${Me.Name}_Alert.ini
blah...

I like this, yeah :twisted: Will probably use it :D

Shin Noir
a ghoul
a ghoul
Posts: 90
Joined: Tue Aug 05, 2003 8:18 pm

Post by Shin Noir » Thu May 31, 2007 11:06 am

Current_Zone is how I detect a zone change.
When it boots up it stores the current zone in this variable, when you change zones it will do the comparison in the loop to find out the current zone does not match Current_Zone and echo the zone change, along with the number of new mobs being tracked

Thanks @ the dodelay, i'll edit it in a bit.

zoobish
a lesser mummy
a lesser mummy
Posts: 40
Joined: Tue Apr 18, 2006 6:59 am

Post by zoobish » Fri Jun 01, 2007 3:35 am

Shin Noir wrote:Current_Zone is how I detect a zone change.
When it boots up it stores the current zone in this variable, ...
But all I have in my alert file is:

Code: Select all

[Current_Zone]
visited=05/31/2007 at 19:08:16
[Bazaar]
1=Banker
index=3
2=Orc
3=Goat
[PoKnowledge]
index=0
[Draniksscar]
index=0
[Causeway]
index=2
1=deathhowler
2=drunt
[GuildLobby]
index=0
[GuildHall]
index=0
I can't see how it stores the current zone name... Seems irrelevant.

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Fri Jun 01, 2007 11:21 am

It stores it in memory while the macro is running. It does not use the ini.
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

jacensolo
a snow griffon
a snow griffon
Posts: 427
Joined: Wed Feb 14, 2007 8:51 am
Location: Right behind you

Dealing with INI lists

Post by jacensolo » Fri Jun 01, 2007 3:20 pm

I see that you are using "index" as a key in your INI file both to determine if a zone has any mobs set to watch and to know how many mobs to check. Another method which I recently discovered and which I find very useful is to use (${Ini[YourFile.ini,YourSection].Count[|]}-1) in If statements like that. Checking the INI with only a file and section given returns each item in that section, divided with | marks, with an extra | at the end. So it might return |Item1|Thing2|Key3||. I've never tried to do that with one in which the section did not exist, but I would assume that it would either return 1 or NULL. This could easily be implemented first to run a check on each mob listed, and second as a check in your script, rather than storing a separate key for each zone. With that method, instead of storing the current zone name and running a check on that, you could have something like "/if (!${Ini[YourFile.ini,${Zone.Name}].Count[|]}) { give_your_warning_here } else { your_mob_watch_script_here }". Note that that only works if the section being undefined returns NULL. If it returns 1, you would have to add a "-1" to that if statement.

Shin Noir
a ghoul
a ghoul
Posts: 90
Joined: Tue Aug 05, 2003 8:18 pm

Post by Shin Noir » Sat Jun 02, 2007 5:14 am

zoobish wrote:
Shin Noir wrote:Current_Zone is how I detect a zone change.
When it boots up it stores the current zone in this variable, ...
But all I have in my alert file is:

Code: Select all

[Current_Zone]
visited=05/31/2007 at 19:08:16
I can't see how it stores the current zone name... Seems irrelevant.
When I first was scrounging this up I was going to do a little report on the last time you visited the zone. It seems I forgot to remove that line 8P

In regards to your question, note this code:

Code: Select all

  /if (${Zone.ShortName.NotEqual[${Current_Zone}]}) { 
    /if (${Ini[Alerts.ini,${Zone.ShortName},index]}==NULL) { 
        /echo Zone is currently ${Zone.ShortName} with no spawns being tracked. 
        /ini "Alerts.ini" "${Zone.ShortName}" "index" "0"    
    } else { 
        /echo Zone is currently ${Zone.ShortName} with ${Ini[Alerts.ini,${Zone.ShortName},index]} spawns being tracked. 
    } 
    
    /for i 1 to 99 
      /varset SpawnTracker[${i}] 0 
    /next i  
     /ini "Alerts.ini" "Current_Zone" "visited" "${Time.Date} at ${Time.Time24}" 
     /varset Current_Zone ${Zone.ShortName} 
   }
Especially note the first line. See that condition is only met when you change zones, and it will just do an introductory echo "Your current zone is ${Zone.ShortName} and X amount of mobs are on the INI file to be tracked." Once it does the announcement, Current_Zone variable to set to ${Zone.ShortName}, and that condition won't be met again until you zone once again invoking the echo again..

Also I will look into the new INI key with pipe delimited alerts that jacensolo mentioned.

Thanks for the feedback! Stay in touch for a fix. :)

nagual2007
orc pawn
orc pawn
Posts: 12
Joined: Thu Jan 03, 2008 5:18 am

Post by nagual2007 » Thu Jun 19, 2008 6:22 am

Hi

Im new to all this MQ stuff but have managed to compile and figure out how to use these codes, by fluke off course

What i want to know with this code is how do you actually get a up a list of mobs that are being tracked.All i get is The zone is Currently ________ with no spawns being tracked

Are there other commands besides /mac tracker.mac ? that i need to know

Any help would be much appreciated

nagual2007
orc pawn
orc pawn
Posts: 12
Joined: Thu Jan 03, 2008 5:18 am

Post by nagual2007 » Fri Jun 20, 2008 2:17 am

NM i figured it out

/mac tracker.mac add <name of mob> works good :)

User avatar
KungFuHamster
a snow griffon
a snow griffon
Posts: 337
Joined: Wed Oct 02, 2002 7:47 am

Post by KungFuHamster » Fri Jun 20, 2008 3:08 am

MQ2Targets does this sort of thing as a plugin. Of course, if they limit the tracking radius again, it's all moot..