Page 1 of 2

Loot List Code

Posted: Mon Mar 21, 2005 4:15 pm
by JJ
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.

Convert

Posted: Tue Mar 22, 2005 12:24 pm
by Bardlover
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.

Posted: Tue Mar 22, 2005 12:27 pm
by Arune
Bard - You have to call the sub, not put Sub BLAH here.

/call LootMob

Posted: Tue Mar 22, 2005 12:50 pm
by fearless
Should look more like

Code: Select all

#include LootMob.inc

Sub Main
 /call LootMob
/endmacro

Posted: Tue Mar 22, 2005 7:50 pm
by Bardlover
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.

Posted: Wed Mar 23, 2005 2:11 am
by JJ
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.

Posted: Wed Mar 23, 2005 1:28 pm
by Bardlover
Edited this one out to save scrolling space :) was just me pleading ignorance for those who feel like they are missing out :)

Posted: Wed Mar 23, 2005 1:50 pm
by dont_know_at_all
sub's don't have {...}

Posted: Wed Mar 23, 2005 6:27 pm
by Bardlover
Edited this one out to save scrolling space :) was just me pleading ignorance for those who feel like they are missing out :)

Posted: Wed Mar 23, 2005 10:28 pm
by JJ
Post the error. I can't see what the problem is from just the code so far.

Posted: Thu Mar 24, 2005 12:05 am
by Bardlover
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

Posted: Thu Mar 24, 2005 9:33 am
by fearless
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] 

Posted: Thu Mar 24, 2005 12:27 pm
by Bardlover
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.

Posted: Thu Mar 24, 2005 12:31 pm
by fearless
/smack JJ

Posted: Tue Apr 12, 2005 2:17 pm
by Bardlover
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.