Author Topic: Looting Issue  (Read 9381 times)

0 Members and 1 Guest are viewing this topic.

Offline godfetish

  • Newbie
  • *
  • Posts: 4
  • Activity:
    0%
  • Reputation Power: 1
  • godfetish has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
Re: Looting Issue
« Reply #15 on: February 23, 2017, 07:17:42 PM »
+1
If #contid = %contid the while loop is an infinite loop. Maybe that is where you are getting stuck?

Offline BobOzarius

  • Full Member
  • ***
  • Posts: 103
  • Activity:
    0%
  • Reputation Power: 2
  • BobOzarius has no influence.
  • Respect: +26
  • Referrals: 0
    • View Profile
Re: Looting Issue
« Reply #16 on: February 23, 2017, 08:10:12 PM »
0
I set a timer for it to break out, but forgot to add the time to actually break out of the while loop if it triggers.  ;)  It's there. You'll see it. Just above the while. if %contWait < #sysTime break needs to be INSIDE the while loop.  Oops.  ;)
« Last Edit: February 23, 2017, 08:11:45 PM by BobOzarius »

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: Looting Issue
« Reply #17 on: February 24, 2017, 02:56:12 AM »
+1
Here one of my sub when I use to gather leather.

Code: easyuo
  1. ; ----------------------------------------------------
  2. ;                gatherLeather
  3. ;-------------------------------------------------------
  4. sub TG_gatherLeather
  5. set %itemtype YFM
  6.  
  7.  
  8. finditem %itemtype G_9
  9. repeat
  10. event pathfind #findx #findy #charposz
  11. wait 2s
  12. if #findkind = -1
  13. {
  14. return
  15. }
  16.  
  17. finditem KFR_HFR C_ , #backpackid   : harvest Blade , Butcher Knife
  18. if #findkind = 1
  19. set #lobjectid HFR
  20. set #lobjectid #findID
  21. event macro 17
  22. wait 10
  23. finditem %itemtype G_2
  24. set #ltargetid #findid
  25. set #ltargetkind 1
  26. event macro 22
  27. ignoreitem #findid
  28. wait 1s
  29. {
  30.  gosub unloadbase
  31. }
  32. return
  33.  
  34. ; -----------------------------------------------------
  35.  
  36.  

Offline BobOzarius

  • Full Member
  • ***
  • Posts: 103
  • Activity:
    0%
  • Reputation Power: 2
  • BobOzarius has no influence.
  • Respect: +26
  • Referrals: 0
    • View Profile
Re: Looting Issue
« Reply #18 on: February 24, 2017, 05:22:33 AM »
+1
     It's bad practice to have a repeat without an until. Also, your wait timers don't allow for any error at all. So your character would be walking all over the place. To every corpse. What if the corpse was 9 tiles away? Is 2 seconds enough time while walking? Maybe. What if you lag? Having that wait 10 after the event macro 17 isn't very efficient either. It's a better idea to set a wait timer, over what it would normally take for a corpse to open, and detect if the #contid has changed. Because no 2 corpse container ids will be alike. Then on error, you can break out of that loop while you wait. What if the corpse doesn't open for some reason? Then you wait that 10, and continue through the code like an error never occurred. Which it did... That's not a good idea. You should look at mine for a better idea of how to do it. I actually put in a return for a corpse cont error so it will not continue to execute code if the container doesn't open. That also will fix missing corpses, because it won't ignore that corpse if it errors and it will reloot that corpse again. It's just more logical.

     Plus #findkind is oldschool.  ;)  #findcnt is better.  That's a very basic wait to handle cutting corpses. Now that I wrote all that, I'll write corpse cutting into mine to show you. Another issue you have, is you are doing a finditem every loop for tools, when that isn't needed. It's fine, just slows things down needlessly, when you start writing larger scripts that will matter. And this code should now account for all timings from actions performed in the script itself, so outside of this code, no timing should be needed to use it. It's all taken care of in the looting code itself. You could probly just do a gosub loot and put that code into that, with the variables at the top of the script and it would work fine.

Code: easyuo
  1. set %cutCorpse #true
  2. set %knife ; Set this to any knives or corpse cutting tool
  3. if %cutCorpse = #true
  4. {
  5.   finditem %knife c_ , #backpacked
  6.   if #findcnt > 0
  7.     set %knifeTool #findid
  8.   else
  9.     display ok Tool not found! Get a tool!
  10. }
  11. set %targetTimer #sysTime
  12. set %corpseContSize 144_212; Set this to whatever size the container is for a corpse on your shard
  13. set %corpseLooted n/a
  14. set %itemTypes VLK
  15. set %corpses YFM
  16.  
  17. repeat
  18. finditem %corpses G_2
  19. if #findcnt > 0
  20. {
  21.   set %corpse #findid
  22.   set %contid #contid
  23.   if %cutCorpse = #true
  24.   {
  25.     set #lobjectid %knifeTool
  26.     if #targCurs = 1
  27.     {
  28.       set #targCurs 0
  29.       wait 5
  30.     }
  31.     event macro 17
  32.     set #ltargetkind 1
  33.     set %targetTimer #sysTime + 1000
  34.     while %targetTimer > #sysTime && #targCurs = 0
  35.     {
  36.     }
  37.     if #targCurs = 1
  38.     {
  39.       event macro 22
  40.       while %targetTimer > #sysTime
  41.       {
  42.       }
  43.     }
  44.   }
  45.   while %targetTimer > #sysTime
  46.   {
  47.   }
  48.   event macro 17
  49.   set %contWait #sysTime + 1100
  50.   while #contsize <> %corpseContSize || #contid = %contid
  51.   {
  52.     if #contid <> %contid
  53.     {
  54.       wait 5
  55.       break
  56.     }
  57.   }
  58.   if %contWait < #sysTime
  59.   {
  60.     set %corpseLooted #false
  61.     while %contWait > #sysTime
  62.     {
  63.     }
  64.     return  ; Return on container error
  65.   }
  66.   set %corpseContId #contid
  67.   finditem %itemTypes c_ , %corpseContId
  68.   {
  69.     if #findcnt > 0
  70.     {
  71.       ; Find and loot whatever you want here
  72.       set %corpseLooted #true
  73.     }
  74.   }
  75.   if %corpseLooted = #true
  76.     ignoreitem %contid
  77.   while %contWait > #systime
  78.   {
  79.   }
  80. }
  81. until #false

Offline decloTopic starter

  • Jr. Member
  • **
  • Posts: 90
  • Activity:
    0%
  • Reputation Power: 2
  • declo has no influence.
  • Respect: +16
  • Referrals: 1
    • View Profile
Re: Looting Issue
« Reply #19 on: February 28, 2017, 02:28:01 PM »
0
The purpose for using finditem each time is that on a certain shard "SP" daggers or knifes wear out after so many uses.  So be using in each loop, if the previous item is destroyed, it uses a new item to continue one.

Just an FYI

Tags: