OK, I'm fixing/revamping has_goal() right now, and I thought others may find this interesting. Here's my testing for circular items, foreaching over every monster's drops:
Code:
wad of dough is circular! Dropped by: Bread Golem
wad of dough is circular! Dropped by: Doughbat
Orcish meat locker is circular! Dropped by: Gelatinous Cube
wad of dough is circular! Dropped by: Gnollish Piebaker
wad of dough is circular! Dropped by: Knob Goblin Chef
wad of dough is circular! Dropped by: Yeast Beast
Hmmmm, thought I,
looks like I could just make exceptions for a couple items.
Then I ran the same test on
all items and got the following not-so-tiny list:
Code:
MSG
Orcish meat locker
ancient cursed foot locker
ballast turtle
bottlecap turtle
box turtle
boxcar turtle
briefcase
cursed black pearl onion
cursed bottle of black-label rum
cursed bottle of rum
cursed cannonball
cursed dirty joke scroll
cursed piece of thirteen
cursed sea biscuit
cursed voodoo skull
decorative fountain
disassembled clover
dueling turtle
fat stacks of cash
flat dough
furry green turtle
gilded ancient cursed chest
gilded ancient cursed key
grinning turtle
hedgeturtle
hobo nickel
ice-cold Sir Schlitz
ice-cold six-pack
knobby helmet turtle
ornate ancient cursed chest
ornate ancient cursed key
padded tortoise
painted turtle
rusty metal key
samurai turtle
sewer turtle
simple ancient cursed key
skeletortoise
sleeping wereturtle
snorkel
soup turtle
spices
stuffed Baron von Ratsworth
stuffed Meat
stuffed crazy bastard sword
stuffed key
stuffed martini
stuffed mink
stuffed monocle
stuffed teddy butler
stuffed tin of caviar
stuffed treasure chest
syncopated turtle
taco shell
ten-leaf clover
torquoise
tortoboggan
turtle wax greaves
turtle wax helmet
turtle wax shield
wad of dough
wooden figurine
So, rather than code exceptions, I just added a recursion limiter like I used in my test script -- there, I disallowed recursion more than 30 levels deep. Just to be absolutely sure, upping the recursion limit to 1000 did not decrease the number of items that were limited. In fact, I could actually lower the limit as far as 3 without increasing the number of limit-cutoff items. I'll go with 5 to be fast yet safe -- I'm pretty sure we won't ever see that limit reached unless TPTB implement a babushka doll.
Perhaps the most interesting result of my testing is this:
> conditions clear
Conditions list cleared.
> call test
pack of chewing gum is/has a goal.
pack of KWE trading card is/has a goal.
boxcar turtle is/has a goal.
medium slimy cyst is/has a goal.
What? Despite having no goals, has_goal() returns true for these items?? It's not a mafia issue -- I checked and is_goal() returns false for these items.
After a little investigation, it turns out that for some reason all of these items have a chance of getting $item[none] listed in use_for_items.txt. Evidently there's a chance of using the item and getting nothing? Anyway, this meant that one of the possible result items ($item[none]) matched my current bounty hunt (none), so it returned 1.0 for those items. I made a special case to skip $item[none], so regardless of what that means in use_for_items, it's now a more robust function.
Heads-Up:
For
float has_goal(monster), it will return the sum chance of getting a goal from a monster à la the use_for_items data file. In other words, if a monster drops 1 goal at 100% and another at 50%, it will return 1.5, not 1.0.
I opted for the sum over the highest since a) it's easy to
min(1.0, result) whatever you get if you need a strict percentage, and 2) you can compare the goal-getting efficacy of monsters that drop multiple goals, as in this test:
> call test
white pixel is 1.0 of a goal.
Blooper: 2.9358573
Buzzy Beetle: 0.7798809
Goomba: 0.7798809
Koopa Troopa: 0.7798809
Tektite: 0.7798809
finished!
The same will apply to the upcoming
has_goal(location), although these percentages will invariably be smaller.
Update should be up tonight or tomorrow.
And while I'm here, I would like to give a huge thanks to Jason for implementing
item_drops_array() -- without which, much of this would be guesswork at best.