PDA

View Full Version : find_demons.ash



the_great_cow_guru
09-03-2009, 02:04 AM
This is a simple script to find the names of all the demons, as requested here (http://kolmafia.us/showthread.php?p=16642#post16642). It requires zarqon's canadv.ash and zlib.ash to work. This script should be completely working now. :D

Make sure you have the latest versions of canadv and zlib, both have changed recently and it won't work unless you have the latest versions!

***Updates***
09.07.09 - correctly states that the pie demon has been found after finding it (thanks Jason)
09.04.09 - changed the pie demon function a bit, lets see if it gives the correct feedback now. also, zaqon made a change to canadv for me, so update your copy and it should work now.
09.03.09 - now tries multiple times to find the pie demon name instead of just once. added some comments for readability. made the feedback a bit more useful.

tgetgel
09-03-2009, 03:07 AM
Will have to try this out after rollover - adventured out and falling down drunk as well!

Thanks for the scripting - that was fast!

zarqon
09-03-2009, 03:29 AM
I already have my demon names, so I can't really help test this. Does the "summon fail" thing really work for getting the first demon name?

the_great_cow_guru
09-03-2009, 12:59 PM
Does the "summon fail" thing really work for getting the first demon name?

I already have my pie demon's name, so I can't test that one. But according to the wiki you sometimes get the pie demon's name when you summon an incorrect demon name. So unless anyone has a demon named fail, I think that should work.

tgetgel
09-03-2009, 02:09 PM
Got an error the first time I ran this - Line 213 - Nemesis Cave yada yada yada.

This line is in canadv.ash. Once I commented out that line, the script ran. It did not get the pie demon. It properly equipped the ear trumpet.

When I found the pie demon with other characters, I had to try summoning many times in a row. It appears that this tries once. Is that the case? When you get the wires crossed response, you have to use the name in wires crossed again to summon to get the pie demon and have it recognized as the demon name. At least that was my experience.

After getting Hoom Hah, got the message of
Found demon 2
Unknown location: Post-War Sonofa Beach
Please report this missing location here: http://kolmafia.us/showthread.php?t=2027
Can't find demon 3 right now.

So we moved on to Friars Gate and I saw this:
[34413] Friar's Gate
Encounter: Hellion
Strategy: G:\KoL Mafia\ccs\default.ccs [default]
Round 0: e85 wins initiative!
Round 1: e85 attacks!
You gain 5 Strengthliness
You gain 6 Wizardliness
You gain 2 Chutzpah

(spade does not use any parameters)
No spading data has been collected yet. Please try again later.


Don't know what the spading was about.

Would it help to maximize the non-combat adventures while finding demons? Rock salt, sonata of sneakiness, etc?

zarqon
09-03-2009, 03:44 PM
I guess my question is, does mafia detect/parse that "Wires Crossed" demon name when summoning? It just seems like kind of a special case compared to the others.


Would it help to maximize the non-combat adventures while finding demons? Rock salt, sonata of sneakiness, etc?

From the Wiki:


Demon name adventures will occur on average once every 150 turns in the four zones in which they can occur.

Doesn't say anything about whether this is affected by +/- combats. I'd assume not, actually. Probably more of a counter type situation.

Also, I don't know if you have the latest CanAdv or not -- there's no version checking in that one yet so I'd recommend making sure. I made a huge update to that recently.

the_great_cow_guru
09-03-2009, 04:40 PM
Got an error the first time I ran this - Line 213 - Nemesis Cave yada yada yada.

This line is in canadv.ash. Once I commented out that line, the script ran. It did not get the pie demon. It properly equipped the ear trumpet.

When I found the pie demon with other characters, I had to try summoning many times in a row. It appears that this tries once. Is that the case? When you get the wires crossed response, you have to use the name in wires crossed again to summon to get the pie demon and have it recognized as the demon name. At least that was my experience.

After getting Hoom Hah, got the message of
Found demon 2
Unknown location: Post-War Sonofa Beach
Please report this missing location here: http://kolmafia.us/showthread.php?t=2027
Can't find demon 3 right now.

So we moved on to Friars Gate and I saw this:
[34413] Friar's Gate
Encounter: Hellion
Strategy: G:\KoL Mafia\ccs\default.ccs [default]
Round 0: e85 wins initiative!
Round 1: e85 attacks!
You gain 5 Strengthliness
You gain 6 Wizardliness
You gain 2 Chutzpah

(spade does not use any parameters)
No spading data has been collected yet. Please try again later.


Don't know what the spading was about.

Would it help to maximize the non-combat adventures while finding demons? Rock salt, sonata of sneakiness, etc?

Sounds like a lot of these problems are coming from canadv, like zarqon said I would make sure you have the latest version. (The unknown location is from canadv, and the spading problem sounds like it might be too)

As for the pie demon, if what you say is true then I guess maybe I could use visit_url and parse the result each time looking for the wires crossed response and then use that name again so mafia recognizes it (Or even better just manually set the demon name and I could avoid using an extra summon). And it only does it once because i assumed you could only do one summon per day even if it failed. Is that not the case? And if you can do multiple summons per day it could be dangerous to just loop until you get the wires crossed response because there is the possibility of eating through lots of scrolls and candles in the process. I accidentally got drunk again before I could test it >_< so I'll try to remember tomorrow. I really need to make a multi for testing these things... but I'm too lazy.

Like zarqon said, I'm not sure if it's affected by the noncombat % I think it probably has it's own counter.

jasonharper
09-03-2009, 05:18 PM
Mafia should learn the pie demon name from the crossed wires response - no need to actually summon it. You can keep trying for that one for as long as you have scrolls & candles, the limit is one successful summon per day.

the_great_cow_guru
09-03-2009, 05:39 PM
Mafia should learn the pie demon name from the crossed wires response - no need to actually summon it. You can keep trying for that one for as long as you have scrolls & candles, the limit is one successful summon per day.

Oh ok, thanks for the clarification on that. So I guess that means my code will work if I just throw it in a while loop. Although I think I should put some kind of limit or something, to stop it from wasting all of your meat on scrolls and candles if the RNG decides to screw you.

zarqon
09-04-2009, 06:24 AM
I tested this on a multi that didn't have the pie demon name:


while (get_property("demonName1") == "")
cli_execute("summon christopher guest");

and it worked:


Summoning christopher guest...
Summoning christopher guest...
Demon name: Elwaitler
Summoning Chamber
Returned: void

Heffed
09-04-2009, 06:39 AM
It found the pie demon name for me on the third try, but it didn't think it did.


Creating scroll of ancient forbidden unspeakable evil (1)...
You acquire an item: scroll of ancient forbidden unspeakable evil
Successfully created scroll of ancient forbidden unspeakable evil (1)
Summoning fail...
Demon name: Ripbargam
Summoning Chamber
Can't find demon 1 right now
Putting on Lord Spookyraven's ear trumpet...
Equipment changed.

Resuming the script says it has located demon 1.

After finding Hoom Hah, I got the same message already mentioned.


Found demon 2
Unknown location: Post-War Sonofa Beach
Please report this missing location here: http://kolmafia.us/showthread.php?t=2027
You can't adventure at the Post-War Sonofa Beach right now.
Can't find demon 3 right now.

I downloaded the latest canadv.ash before running find_demons. (Assuming the download link on the first page of the Canadv thread is the latest) The character I'm testing with is level 31 and can definitely adventure at Sonofa Beach.

In all my time playing, I've never bothered with summoning demons. Now after running this script and finding a couple, I have a question. Is there someplace that lists the names of the demons you've found? I assumed they'd be under "Other Accomplishments" in the quest log, but that doesn't appear to be the case.

Spiny
09-04-2009, 06:53 AM
In all my time playing, I've never bothered with summoning demons. Now after running this script and finding a couple, I have a question. Is there someplace that lists the names of the demons you've found? I assumed they'd be under "Other Accomplishments" in the quest log, but that doesn't appear to be the case.

In the CLI you can type "demons" and this will list all known demons for the character in question. They are recorded into your preferences file, but it's always a good idea to make a note of them yourself ;) Also if you have any characters that learned demon names when not using mafia, you can set the respective demon name with "set demonName#=nameofdemon" Obviously you'd replace the # with the appropriate number of the respective demon according to the "demons" output.

-Spiny

Heffed
09-04-2009, 07:18 AM
In the CLI you can type "demons" and this will list all known demons for the character in question. They are recorded into your preferences file, but it's always a good idea to make a note of them yourself ;) Also if you have any characters that learned demon names when not using mafia, you can set the respective demon name with "set demonName#=nameofdemon" Obviously you'd replace the # with the appropriate number of the respective demon according to the "demons" output.

Good to know, thanks! :)

And yes, I had added the ones the script found to my "Notes", but was thinking there was probably something I was overlooking.

zarqon
09-04-2009, 08:22 AM
Hmmm, odd that an old snarfblat location would be missing from CanAdv, but missing it was. I just added it in and posted the update.

Heffed
09-04-2009, 09:35 AM
OK, thanks! I've updated canadv.ash again and I'll give this script another go tomorrow night when I have some more adventures. :)

the_great_cow_guru
09-04-2009, 03:30 PM
It found the pie demon name for me on the third try, but it didn't think it did.

Huh, that's interesting. I'll see if I can figure out why it did that


Hmmm, odd that an old snarfblat location would be missing from CanAdv, but missing it was. I just added it in and posted the update.

Thanks for the CanAdv fix, zarqon. Guess that should fix that problem.

tgetgel
09-04-2009, 04:14 PM
Quote:
Originally Posted by Heffed
It found the pie demon name for me on the third try, but it didn't think it did.


The Pie Demon shows up with the crossed wires adventure. The name is in the text, but does not get registered as being found until you actually use that name in a summoning. You might need to "show in browser" when that response shows up, then have the user copy the name and manually summon the Pie Demon.

At least that is how I had to do it.

the_great_cow_guru
09-04-2009, 04:18 PM
I was only missing the Post-war Sonofa Beach and the Friar's Gate ones, I ran it with zarqon's latest CanAdv and it found both. I looked at the code for the pie demon and, and I have no idea why it was saying it wasn't found. It looks like it should work... I wonder if it's some problem with mafia not updating the property when i think it does?

Here's the code for that part:



boolean find_pie_demon() {
if (get_property("demonName1") == "") {
if (get_property("demonSummoned") == "false") {
for i from 1 to max_summon_attempts {
cli_execute("summon fail");
if (get_property("demonName1") != "") return true;
}
print("I think we've wasted enough time summoning now...", "red");
} else {
print("You have already summoned a demon today.", "red");
}
}
return get_property("demonName1") != "";
}


Can anyone think of why that would be returning false after finding the pie demon? (It only happens if you don't have the pie demon when you run the function, and it finds it for you. Because I have already found it and it returns true when I run it.)

zarqon
09-04-2009, 07:07 PM
I'd do it with a while loop:


boolean find_pie_demon() {
if (get_property("demonSummoned") == "true") return error("You already summoned today.");
int i = 1;
while (get_property("demonName1") == "" && i < max_summon_attempts && retrieve_item(1,$item[scroll of ancient forbidden]) && retrieve_item(3,$item[thin black candle]))
cli_execute("summon Christopher Guest");
return get_property("demonName1") != "";
}

the_great_cow_guru
09-04-2009, 08:46 PM
I'd do it with a while loop:


boolean find_pie_demon() {
if (get_property("demonSummoned") == "true") return error("You already summoned today.");
int i = 1;
while (get_property("demonName1") == "" && i < max_summon_attempts && retrieve_item(1,$item[scroll of ancient forbidden]) && retrieve_item(3,$item[thin black candle]))
cli_execute("summon Christopher Guest");
return get_property("demonName1") != "";
}

Well it does look more concise, but i don't see why the result would be any different. Oh well, can't hurt to try it. Also, I guess it's a good idea to make sure you have the scroll and candles first.

tgetgel
09-04-2009, 09:20 PM
I guess it's a good idea to make sure you have the scroll and candles first.

Earlier today there was a 50 meat price difference between buying the ingredients for the scroll (assuming that you have none of the ingredients) and buying the completed scroll. If you try to summon and do not have the needed items, Mafia purchases the ingredients and creates the scroll.


Is getting the demon name adventure considered a non-combat adventure? Does maximizing the rate of non-combats make it faster to get the name adventure?

the_great_cow_guru
09-04-2009, 09:38 PM
Earlier today there was a 50 meat price difference between buying the ingredients for the scroll (assuming that you have none of the ingredients) and buying the completed scroll. If you try to summon and do not have the needed items, Mafia purchases the ingredients and creates the scroll.


Is getting the demon name adventure considered a non-combat adventure? Does maximizing the rate of non-combats make it faster to get the name adventure?

Yeah, summon automatically tries to buy them, but just in case you don't have access to the mall or something it's probably still a good idea to check. I'm not sure exactly what summon does if it can't get the necessary items, so better safe than sorry

As zarqon said a few posts back, the demon names occur ~once every 150 adventures in a zone where they can occur (according to the wiki) I'm not sure if this is affected by noncombat % or not. I agree with zarqon that it's probably based off some hidden counter and isn't affected by noncombat %. It would be easy enough to add, I just don't want to waste meat if it doesn't really help anything. If anyone knows more about how noncombat % affects the demon name adventures please let me know.

Spiny
09-04-2009, 09:55 PM
When one has mafia's buy from mall/npc option turned off, any call to retrieve_item() merely says "You need item x to continue" assuming you don't have the item, if you do, it just uses it.

-Spiny

the_great_cow_guru
09-04-2009, 10:23 PM
And what does it return? I'm assuming it returns false if it couldn't get the item. Is that not the case?

the_great_cow_guru
09-04-2009, 10:28 PM
Just updated the pie demon part using zarqon's code, those of you that don't have your pie demon yet, let me know if it works for you now.

Spiny
09-04-2009, 11:55 PM
And what does it return? I'm assuming it returns false if it couldn't get the item. Is that not the case?

Yes, it returns false:



> ash retrieve_item(1, $item[magical mystery juice])

You need 1 more magical mystery juice to continue.
Returned: false



Editted out my edit cos I'm an idiot, was testing with no meat on hand lol.

-Spiny

the_great_cow_guru
09-05-2009, 02:20 AM
Okay awesome, so then it should work for this purpose. As long as mafia updates the demonName1 property as soon as it encounters the signals crossed response

Heffed
09-05-2009, 05:24 AM
Okay awesome, so then it should work for this purpose. As long as mafia updates the demonName1 property as soon as it encounters the signals crossed response

It's still a bit fiddly in that respect. Tried it on a multi and got the same response as before.


Summoning Christopher Guest...
Demon name: Vek'Bazaba
Summoning Chamber
Can't find demon 1 right now
Putting on Lord Spookyraven's ear trumpet...
Equipment changed.


And again, if I abort the script and restart it says it has found demon 1.

the_great_cow_guru
09-05-2009, 10:53 PM
I think it must be an issue with mafia not setting the demonName1 property. Because the code looks like it should work and it's returning the same thing if you run it again later... just I think by then the property has been updated so it gives the correct result. Well I guess the important part is that it does find the demon name... even if the feedback isn't perfect. Does anyone know how i could force the property to get updated right away?

dj_d
09-07-2009, 06:44 AM
I'm puzzled - the code specifies "spooky raven" instead of spookyraven, which I believe is correct - why does it work?

I quoted all $item[foo] (to $item["foo"]) to fix emacs highlighting; perhaps quoting it made for stricter matching?

Regardless I removed the space and it now seems to be working. Pie demon is still broken per above, though.

zarqon
09-07-2009, 06:49 AM
Hahaha, did anyone notice my code never incremented i? I just happened to notice that.

I'd recommend a) fixing that, and b) adding some debug print commands, such as "i: demonName1 value" in the while loop, and also printing the property after the while loop is finished.

the_great_cow_guru
09-07-2009, 12:33 PM
Hahaha, did anyone notice my code never incremented i? I just happened to notice that.

Yeah, luckily I noticed that when I was copying it, so I just added a line to increment it ;)

I'll see what I can do to fix the pie demon problem. If worst comes to worst maybe I'll just take out the print statements. Then at least it wouldn't be giving incorrect feedback.

Hmm yeah, that's kind of surprising about the Spookyraven thing. I usually just guess with names and then look them up when mafia doesn't like them... but that one got by I guess.

jasonharper
09-07-2009, 05:09 PM
I've figured out what's going on with the pie demon, and it's a bit obscure, I'm afraid...

Discovering a demon name, with no goals active, will stop auto-adventuring. This, and other things that stop adventuring, are handled internally as a "pending state", which is basically the same as an error state except that it doesn't turn the display red. You normally never see a pending state in ASH, since they generally occur in the context of auto-adventuring, which will clear the pending state before returning. The pending states that occur when demons 2-5 are discovered therefore cause no problem.

However, when a demon name is discovered in the Summoning Chamber, there is no adventure request in progress - the pending state is still active on return from the cli_execute("summon..."). Like any error state, this is capable of aborting your script, and since you didn't capture the return value of cli_execute(), it does - the function immediately exits, without executing the final return get_property("demonName1") != "";

However, the return value of find_pie_demon() is used in your script, so THAT captures the error state, and allows the script to continue. Note that the 'return' statement didn't actually execute, so the apparent value of find_pie_demon() is unspecified - it happens to always be 'false' in this case (thus causing the script to believe that the name wasn't found), but in general the result of capturing the return value of an aborted user-defined function (rather than the built-in function that actually caused the abort) is meaningless.

What you need to do is capture the error at the source - the cli_execute(). Any of the following will do the job:
boolean _ = cli_execute(...);
if (cli_execute(...)) {}
(!cli_execute(...));

Bale
09-07-2009, 08:42 PM
(!cli_execute(...));

Whoa! That will work? All I need to do is to wrap it in parenthesis to capture the error state? No "if" needed? Or is the "!" necessary to capture the state by converting it to a boolean? Anyway, that's a lot prettier than the if(){} that I've been using.

Are the parenthesis really necessary if the "!" is doing the job?

jasonharper
09-07-2009, 09:47 PM
Something has to actually use the value in order to capture any errors - negation seems to be the simplest such operation for a boolean return value, unary '-' would likewise be simplest for an int value.

The outer parentheses are necessary to make this syntactically valid, since ASH does not allow arbitrary expressions to be used as statements - only a limited subset (such as function calls) that generally make sense when the resulting value is ignored. That subset does include parenthesized sub-expressions, in which case the sub-expression is not limited in any way.

Bale
09-07-2009, 10:03 PM
Thank you. I hate the dangling {} as well as the oddness of an if that does not control program flow. This is much prettier. I'll be very happy to use

(!adventure(1, locale));

instead of

if(adventure(1, locale)) {}

the_great_cow_guru
09-07-2009, 11:36 PM
Wow, that's tricky, I don't think I ever would have caught that. thanks for the help jason.

dj_d
09-07-2009, 11:43 PM
Got my demons! Thanks, cow.

the_great_cow_guru
09-07-2009, 11:51 PM
Got my demons! Thanks, cow.

Haha, you're welcome :)

tgetgel
09-08-2009, 02:32 AM
Got my demons too - twice!

I like the addition of the multiple attempts for the pie demon. Good work guru.

dj_d
09-08-2009, 03:34 AM
Yes, it's a solid and useful piece of scripting.

(appreciation sent via PM)

the_great_cow_guru
09-08-2009, 02:46 PM
Got my demons too - twice!

I like the addition of the multiple attempts for the pie demon. Good work guru.

Awesome, I'm glad that it seems to be working for everyone now.


Yes, it's a solid and useful piece of scripting.

(appreciation sent via PM)

Thanks dj :D

Randomlord
08-10-2011, 05:06 PM
Any chance of an update on this for the Friar's Gate?

Thanks,

Randomlord

err, nvm. It was just a simple "name" change.

Thanks!