Author Topic: FindItem, IgnoreItem and #findType = X  (Read 4823 times)

0 Members and 1 Guest are viewing this topic.

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
FindItem, IgnoreItem and #findType = X
« on: February 22, 2010, 05:45:04 AM »
0
Just a short quip about something I discovered. You real scripters probably already know about it, so this is for the nubs.

When you are cycling through items you normally use a standard flow:

finditem
do whatever to item
ignore item

I was using that flow for Detecting Hidden on boxes. If I had 20 boxes on the ground, the script would find one, detect on it, ignore it, the find the next one. Once all were detected I did a ignoreitem reset to clear the ignore list and start over again.

The problem is how I had my ignoreitem. It was before the Detect portion, so if I had a count of 0 items (and reset the ignoreitem list) it would still try to detect the "unfound" item, which results in a #findType and #findID of X.

findItem %boxes G_6 ; find all boxes within 6 that are on the ground
if #findCnt = 0
  ignoreitem reset ; if it doesn't find one, because I've ignored them all, then reset the ignore list
detect hidden ; detect on the found ones
ignoreitem #findID ; ignore the one I just detected

See how when I ignore the last box, the script will #findCnt 0 and reset the ignore list THEN it will try to detect hidden, but the item is that X because the count was 0.

This is how I got around it.

findItem %boxes G_6
set %findCnt #findCnt ; so I'm setting a variable to keep track of how many are found
detect hidden ; detect on the found one
ignoreitem #findID ; ignore the one I just detected
if %findCnt = 1 ; so the last one I detected on was the LAST ONE FOUND
  ignoreitem reset ; since I just checked the last one found, reset the ignore list

This works well. Scripts that cycle through stuff and ignores items should have some type of safety like this to ensure you don't waste one cycle trying to do something to an item thats not found.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #1 on: February 22, 2010, 06:59:05 AM »
0
-Ive found it best never to use the ignore item command at all.
- Its also good practive to use as little finditems as possible as they are very cpu intensive and are one of the causes of crashes when multiscripts are running.

So my solution is issue finditem command once... load all the results into my own array.. then itterate through that array doing what ever i needed to do.   To reset just set the counter back to 1

Ie for your detect example
Code: [Select]
Finditem <boxes>  G_5
set %MYArrayCount #findcnt
IF #findcnt > 0
  {
   For #findindex 1 #findcnt
     {
      set %MyarrayFindid . #findindex #findid
       ; save other findstuff you want
     }
  }

If %MYArrayCount > 0
  {
  Repeat
     For %Count 1 %MyArrayCount
         {
          gosub PerformDetectHiddenActionon  %MyArrayFindid . %Count
          }
  Until %ExitScript
  }
Halt

The above also presumes that you are doing other finds thus invalidating the finditem array... if your not doing other finds you can make it even simpler

Code: [Select]
Finditem <boxes>  G_5
IF #findcnt > 0
  {
   Repeat
      For #findindex 1 #findcnt
         {
          gosub PerformDetectHiddenActionon  #Findid
          }
   Until %ExitScript
  }

(If someone comes along and picks up your boxes you might get an error.. but can compensate for that in the action sub)
« Last Edit: February 22, 2010, 07:02:41 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #2 on: February 22, 2010, 07:29:21 AM »
0
I suppose a #findCnt then "for/next" would work as well. The problem is, as you stated, sometimes they move.

If you #findCnt and find 6 crates, then begin detecting on them, the full cycle will take ~60 seconds. In that time one, or more of the crates may have been removed. So a #findCnt has to be done each cycle.

By using the variable %findCnt I can ensure that when there's only 1 (or 0) left the ignored list will be reset and the cycle started over.

I wish I could reduce the amount of #findItem, but in the case of the Detect script I can not.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #3 on: February 22, 2010, 07:29:46 AM »
0
Something I've also Noticed........


Finditem %Whatever
Ignoreitem #findid
Ignoreitem #findid
finditem %whatever

when you do the same ignoreitem Twice, they seem to cancel each other out..... This gets very frustrating when you try to add certain circumstances for ignoring things, and then just a universal ignore. So, if you are having issues with ignoreitem Not actually ignore something, pay attention to how many times you ignore that object.
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #4 on: February 22, 2010, 07:41:49 AM »
0
So it's like a double negative? LOL

findItem MySenses
ignoreItem MySenses ; ok, your senses won't be detected and are ignored
ignoreItem MySenses ; ok, ignore the fact that your suppose to ignore my senses...
move to MySenses ; please, bring me to my senses
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #5 on: February 22, 2010, 07:46:17 AM »
0
Exactly!!!!
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #6 on: February 22, 2010, 09:08:05 AM »
0
I suppose a #findCnt then "for/next" would work as well. The problem is, as you stated, sometimes they move.

If you #findCnt and find 6 crates, then begin detecting on them, the full cycle will take ~60 seconds. In that time one, or more of the crates may have been removed. So a #findCnt has to be done each cycle.

By using the variable %findCnt I can ensure that when there's only 1 (or 0) left the ignored list will be reset and the cycle started over.

I wish I could reduce the amount of #findItem, but in the case of the Detect script I can not.
In the case of Detect Hidden you really don't want/need to ignoreitem anyhow. Once a trunk spawns you want to detect on it until it's gone then find another.

Not to deter from this excellent discussion on the use of these functions though, just wanted to mention that.

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Scrripty

  • Guest
Re: FindItem, IgnoreItem and #findType = X
« Reply #7 on: February 22, 2010, 09:22:40 AM »
0
Depending on if you're in a location that spawns with the right type of chest for your skill level... :)  If chests are spawning probly a good idea to scan them all and detect each one so you gain off of the ones that are the higher level and lower level...  variety speeds up gains imho.

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #8 on: February 22, 2010, 09:22:51 AM »
0
I disagree 12X... ;)

I think cycling through the chests improves your chances for gains. There must be varying levels of chests, so using the same one might not be optimal for gains. If it's at a level that your not going to gain on, would you want to just detect on it?

I say NAY! Lets check them all so that if 50% of them are "gainable" at least we have the opportunity to gain!
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #9 on: February 22, 2010, 09:45:19 AM »
0
I disagree 12X... ;)

I think cycling through the chests improves your chances for gains. There must be varying levels of chests, so using the same one might not be optimal for gains. If it's at a level that your not going to gain on, would you want to just detect on it?

I say NAY! Lets check them all so that if 50% of them are "gainable" at least we have the opportunity to gain!
We should have a "Detect-off" to test each of our logics. Start new char with 50 Detect, I fire up mine and you fire up yours in the same room at Vesper bank. Hit play and see who's right ;) I'm confident you will gain faster by not ignoring targets after a single attempt. I agree that there is a risk of getting "stuck" on a trunk at a level too low to gain from any longer thus wasting a bit of time but the trunk refresh rate is slow enough that I know for a fact you'll waste a lot more time waiting for new trunks to spawn after only one attempt each.

Let's do this!! :D

Now what would be cool is if there was a correlation between container type and the difficulty but unfortunately three different small wooden boxes could be three totally different skill levels.

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #10 on: February 22, 2010, 09:52:15 AM »
0
I know I would win this event. No doubt. More targets = More chances to gain.

It doesn't take any longer to change targets, yet even as you stated "there is a risk of getting "stuck" on a trunk".

Quote from: Some Detect Competition Loser
I know for a fact you'll waste a lot more time waiting for new trunks to spawn after only one attempt each.

Wrong! I don't wait for new boxes!!

Remember, my method doesn't wait for new ones to appear. It cycles through whats there, ignoring each one it detects, until it detects the last one it finds, then it clears the ignore list and begins the cycle again.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #11 on: February 22, 2010, 10:07:57 AM »
0
Aka, For #findindex 1 #findcnt
But with a refresh Rate :)
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: FindItem, IgnoreItem and #findType = X
« Reply #12 on: February 22, 2010, 10:29:52 AM »
0
I know I would win this event. No doubt. More targets = More chances to gain.

It doesn't take any longer to change targets, yet even as you stated "there is a risk of getting "stuck" on a trunk".

Quote from: Some Detect Competition Loser
I know for a fact you'll waste a lot more time waiting for new trunks to spawn after only one attempt each.

Wrong! I don't wait for new boxes!!

Remember, my method doesn't wait for new ones to appear. It cycles through whats there, ignoring each one it detects, until it detects the last one it finds, then it clears the ignore list and begins the cycle again.
Ahhh I misunderstood. Ok, now I can agree with you that this would be faster :P Strike all that and let's return to the regularly scheduled program, already in progress...

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Tags: