Loot List Code

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

JJ
a hill giant
a hill giant
Posts: 227
Joined: Thu Nov 11, 2004 5:50 am

Loot List Code

Post by JJ » Mon Mar 21, 2005 4:15 pm

Just some code I have in an #include file that will keep track of whatever items you loot from each mob. It creates a new .ini file for the zone if you haven't looted in that zone. You can use this in conjunction with something like the forage macro to decide whether or not to keep the item. Create a folder called LootList in the macros folder.

UPDATE: Modified the mob's name parsing. It no longer needs to parse, so I got rid of the /declare, /varcalc, and used ${Target.DisplayName} instead.

Code: Select all

|LootMob.inc
| 
|Looting include that also keeps track of loot from mobs
| 

|||||||||||||||||||| 
| LootMob
|||||||||||||||||||| 
Sub LootMob 
{
  /declare slot int local 1
  /declare NumberItems int local 0

  /echo Looting corpse
  /target corpse
  /loot
  /delay 2s
  /varset NumberItems ${Corpse.Items}
  /if (${NumberItems}>0) {
    /for slot 1 to ${NumberItems}
      /nomodkey /itemnotify loot${slot} leftmouseup
      /delay 1s
      :LagFix
        /call DoINI "${Target.DisplayName}"
        /autoinventory
        /delay 1s
        /if (${Cursor.ID}) /goto :LagFix
    /next slot
  }
  /nomodkey /notify LootWnd DoneButton leftmouseup
  /delay 5
  /if (${Target.ID}) /target clear
  /delay 1s

/return
}

|||||||||||||||||||| 
| DoINI 
|||||||||||||||||||| 
Sub DoINI(string MobName)
{
   /declare ItemSetting int local 
   /declare NotFound int local -1

| Look up this item in (Zone).ini 
   /varset ItemSetting ${Ini["LootList/${Zone.ShortName}.ini",${MobName},${Cursor.Name},${NotFound}]} 
   /delay 5 

| If the item isn't in the .ini file then add it. 
   /if (${ItemSetting}==${NotFound}) { 
      /ini "LootList/${Zone.ShortName}.ini" "${MobName}" "${Cursor.Name}" "1"
      /varset ItemSetting 1 
   }
/return
}
I use this with a different macro, so that's why the .inc file. If you want, you can just create a macro that includes this file and calls Sub LootMob.
Last edited by JJ on Tue Mar 22, 2005 1:21 pm, edited 1 time in total.

Bardlover
a lesser mummy
a lesser mummy
Posts: 52
Joined: Sun Oct 10, 2004 5:32 pm

Convert

Post by Bardlover » Tue Mar 22, 2005 12:24 pm

this is a great idea, in fact I was looking for this for my bard. When Kiting in PoNightmare, they added a whole bunch of Lore-nodrop trash to almost every Nightstalker. Would be great if this were a plugin so it didn't interfere with the macros I am already running. Aside from that, I tried putting this in, but when I call it, it says that it flowed into a new subroutine.
| --------------
| -- Main Sub --
| --------------
Sub Main
#include LootMob.inc

Sub LootMob

was how I called it. Again idealy a plugin would be great so it loads all the time, keeps a list like the fishforage macro for the Keep / Destroy.

Arune
a hill giant
a hill giant
Posts: 216
Joined: Sat Jul 03, 2004 1:51 pm

Post by Arune » Tue Mar 22, 2005 12:27 pm

Bard - You have to call the sub, not put Sub BLAH here.

/call LootMob

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

Post by fearless » Tue Mar 22, 2005 12:50 pm

Should look more like

Code: Select all

#include LootMob.inc

Sub Main
 /call LootMob
/endmacro
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]

Bardlover
a lesser mummy
a lesser mummy
Posts: 52
Joined: Sun Oct 10, 2004 5:32 pm

Post by Bardlover » Tue Mar 22, 2005 7:50 pm

Cool, works great, Fyi for those who are gonna use this, you need to create the Lootlist directory for it to create and store the ini files in. Hope this gets worked into a plugin someday.

JJ
a hill giant
a hill giant
Posts: 227
Joined: Thu Nov 11, 2004 5:50 am

Post by JJ » Wed Mar 23, 2005 2:11 am

As I get time and learn how to actually make plugins work I might make something. I plan on migrating the same thing that forage.mac did with the keep/destroy option when and if I do create it.

Bardlover
a lesser mummy
a lesser mummy
Posts: 52
Joined: Sun Oct 10, 2004 5:32 pm

Post by Bardlover » Wed Mar 23, 2005 1:28 pm

Edited this one out to save scrolling space :) was just me pleading ignorance for those who feel like they are missing out :)
Last edited by Bardlover on Thu Mar 24, 2005 12:33 am, edited 2 times in total.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Wed Mar 23, 2005 1:50 pm

sub's don't have {...}

Bardlover
a lesser mummy
a lesser mummy
Posts: 52
Joined: Sun Oct 10, 2004 5:32 pm

Post by Bardlover » Wed Mar 23, 2005 6:27 pm

Edited this one out to save scrolling space :) was just me pleading ignorance for those who feel like they are missing out :)
Last edited by Bardlover on Thu Mar 24, 2005 12:32 am, edited 2 times in total.

JJ
a hill giant
a hill giant
Posts: 227
Joined: Thu Nov 11, 2004 5:50 am

Post by JJ » Wed Mar 23, 2005 10:28 pm

Post the error. I can't see what the problem is from just the code so far.

Bardlover
a lesser mummy
a lesser mummy
Posts: 52
Joined: Sun Oct 10, 2004 5:32 pm

Post by Bardlover » Thu Mar 24, 2005 12:05 am

This one works

Code: Select all

|LootMob.inc 
| 
|Looting include that also keeps track of loot from mobs 
| 

|||||||||||||||||||| 
| LootMob 
|||||||||||||||||||| 
Sub LootMob 
{ 
  /declare slot int local 1 
  /declare NumberItems int local 0 
  /declare CorpseCut int local 0 

  /echo Looting corpse 
  /target corpse 
  /loot 
  /delay 1s 
  /varset NumberItems ${Corpse.Items} 
  /if (${NumberItems}>0) { 
    /varcalc CorpseCut ${Target.CleanName.Find['s corpse]}-1 
    /for slot 1 to ${NumberItems} 
      /nomodkey /itemnotify loot${slot} leftmouseup 
      /delay 3
      :LagFix 
        /call DoINI "${Target.CleanName.Left[${CorpseCut}]}" 
        /autoinventory 
        /delay 1
        /if (${Cursor.ID}) /goto :LagFix 
    /next slot 
  } 
  /nomodkey /notify LootWnd DoneButton leftmouseup 
  /delay 5 
  /if (${Target.ID}) /target clear 
  /delay 1 

/return 
} 
|||||||||||||||||||| 
| DoINI 
|||||||||||||||||||| 
Sub DoINI(string MobName) 
{ 
   /declare ItemSetting int local 
   /declare NotFound int local 

   /varset NotFound -1 

   | Look up this item in .ini 
   /varset ItemSetting ${Ini["LootList/${Zone.ShortName}.ini",${MobName},${Cursor.Name},${NotFound}]} 

   /delay 5 

   | If the item isn't in the .ini file then add it. 
   /if (${ItemSetting}==${NotFound}) { 

      /ini "LootList/${Zone.ShortName}.ini" "${MobName}" "${Cursor.Name}" "1" 

      /varset ItemSetting 1 

   } 

   | If we're keeping this item then stash it in our bags. 
   | Otherwise, just destroy it. 
   /if (${ItemSetting}==1) { 

      :LootIt 
      /autoinventory 
      /delay 5 
      /if (${Cursor.ID}) /goto :LootIt 

   } else { 

      /destroy 
   } 
/return 
}
And Use this as the .mac file

Code: Select all

#include LootMob.inc 

Sub Main 
 /call LootMob 
/endmacro 
Don't forget to create the lootlist directory

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

Post by fearless » Thu Mar 24, 2005 9:33 am

The error you are getting is a result of writing your sub's wrong.

There is no wrapping {} around sub's. IE you do not use the bracket's marked in red. Is there some other macro or snippet somewhere that gave you the impression that those were required?

Code: Select all

Sub LootMob
[color=red]{[/color]
  /declare slot int local 1
  /declare NumberItems int local 0
  /declare CorpseCut int local 0

  /echo Looting corpse
  /target corpse
  /loot
  /delay 1s
  /varset NumberItems ${Corpse.Items}
  /if (${NumberItems}>0) {
    /varcalc CorpseCut ${Target.CleanName.Find['s corpse]}-1
    /for slot 1 to ${NumberItems}
      /nomodkey /itemnotify loot${slot} leftmouseup
      /delay 3
      :LagFix
        /call DoINI "${Target.CleanName.Left[${CorpseCut}]}"
        /autoinventory
        /delay 1
        /if (${Cursor.ID}) /goto :LagFix
    /next slot
  }
  /nomodkey /notify LootWnd DoneButton leftmouseup
  /delay 5
  /if (${Target.ID}) /target clear
  /delay 1

/return
[color=red]}[/color] 
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]

Bardlover
a lesser mummy
a lesser mummy
Posts: 52
Joined: Sun Oct 10, 2004 5:32 pm

Post by Bardlover » Thu Mar 24, 2005 12:27 pm

Honestly, I know next to nothing about this programming. I spent a little time programing webpages so learned some HTML, ASP, Webgroove, Webware, Coldfusion, but never got far in PHP which is this same C+ style of programming. I can read what it says and what it is trying to do, but would never be the creator of these :oops: That being said, I can kinda manipulate an existing product to do what I need if it is close. In this case, the original that worked had the {} if you look at the original, and I didn't know any better :shock: I just really appreciate and admire those of you who can create these projects.

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

Post by fearless » Thu Mar 24, 2005 12:31 pm

/smack JJ
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]

Bardlover
a lesser mummy
a lesser mummy
Posts: 52
Joined: Sun Oct 10, 2004 5:32 pm

Post by Bardlover » Tue Apr 12, 2005 2:17 pm

Well, nutz, not sure how to approch this problem. It works about 80% of the time doing what it is supposed to, which is delete all my trash drops. I even added an extra /destroy in there just to be safe

Code: Select all

|LootMob.inc 
| 
|Looting include that also keeps track of loot from mobs 
| 

|||||||||||||||||||| 
| LootMob 
|||||||||||||||||||| 
Sub LootMob 
{ 
  /declare slot int local 1 
  /declare NumberItems int local 0 
  /declare CorpseCut int local 0 

  /echo Looting corpse 
  /target corpse 
  /loot 
  /delay 1s 
  /varset NumberItems ${Corpse.Items} 
  /if (${NumberItems}>0) { 
    /varcalc CorpseCut ${Target.CleanName.Find['s corpse]}-1 
    /for slot 1 to ${NumberItems} 
      /nomodkey /itemnotify loot${slot} leftmouseup 
      /delay 3
      :LagFix 
        /call DoINI "${Target.CleanName.Left[${CorpseCut}]}" 
        /autoinventory 
        /delay 2
        /if (${Cursor.ID}) /goto :LagFix 
    /next slot 
  } 
  /nomodkey /notify LootWnd DoneButton leftmouseup 
  /delay 5 
  /if (${Target.ID}) /target clear 
  /delay 1 

/return 
} 
|||||||||||||||||||| 
| DoINI 
|||||||||||||||||||| 
Sub DoINI(string MobName) 
{ 
   /declare ItemSetting int local 
   /declare NotFound int local 

   /varset NotFound -1 

   | Look up this item in .ini 
   /varset ItemSetting ${Ini["LootList/${Zone.ShortName}.ini",${MobName},${Cursor.Name},${NotFound}]} 

   /delay 5 

   | If the item isn't in the .ini file then add it. 
   /if (${ItemSetting}==${NotFound}) { 

      /ini "LootList/${Zone.ShortName}.ini" "${MobName}" "${Cursor.Name}" "1" 

      /varset ItemSetting 1 

   } 

   | If we're keeping this item then stash it in our bags. 
   | Otherwise, just destroy it. 
   /if (${ItemSetting}==1) { 

      :LootIt 
      /autoinventory 
      /delay 3 
      /if (${Cursor.ID}) /goto :LootIt 

   } else { 

      /destroy 
      /delay 2
      /destroy
   } 
/return 
}
 
But for some reason, about 20% of the time it doesn't delete the item, just bags it then I have to find it in my bags, destroy, then can loot the next nodrop / lore / stupid disturbed beast essense in PoN.

If it didn't work at all, I could work on that, but with it working some of the time, thought I would throw it out there and see if anyone knows why.