stone spheres, and the item database

izchak

Member
I'm writing a script to clear out the hidden city, and I've run into a problem.
I want to be able to figure out which spheres I have not yet identified, and to be able to count how many spheres I have identified.
For those who are unaware, mafia has a very useful feature where it automatically identifies a stone sphere for you when you use it, and marks it as such in its item database. For instance, if your cracked stone sphere is the water one, mafia will mark it as a 'cracked stone sphere of water' in your inventory and item dropdowns.

Here's the snippet I was hoping to use.
Code:
int identified_spheres() {
	int ids = 0;
	if(item_amount($item[sphere of water]) > 0) ids = ids + 1;
	if(item_amount($item[sphere of fire]) > 0) ids = ids + 1;
	if(item_amount($item[sphere of lightning]) > 0) ids = ids + 1;
	if(item_amount($item[sphere of plants]) > 0) ids = ids + 1;
	print("identified spheres : " + ids);
	return ids;
}
(is there a ++ feature?)

Now, at the time of testing, I have identified two of my spheres, the water and lightning ones.
So, when I verify this script, mafia tells me:
Item sphere of fire not found in database
and if I comment out the 'sphere of fire' bit, it tells me:
Item sphere of plants not found in database

Now, it seems to me this is where one would use try and catch blocks normally. Is there a way to 'try' a block of code, as such?
Alternatively, can anyone think of a way to figure out how many identified spheres I have, and which ones are still unidentified, in ASH?
 

izchak

Member
Well, for the interested, heres a preliminary 'hidden city' script.

Quite simply, this clears out the hidden city, stopping when you have all 4 spheres, 4 altars, and the smallish temple.

I say preliminary, because it still requires some fiddling.
For instance, I kill all monsters with shieldbutt, and I kill the protector spirits with feathers.
If either of these are invalid combat options for you, you'll need to hack in your own combat style.
I might do it myself, if I get bored.
Also, until I figure out how to handle the identifying of the spheres, it aborts once you have 3 spheres, leaving you to ID the three spheres. Then you can comment out the 'abort' line, and re-run this script to finish clearing out the hidden city.

I'm posting it here because it relates to the problem I've posted about, and I dont deem it complete enough to post in the 'completed scripts' subforums.
 

iniquitous

New member
Well, the first thing I'd note in case you haven't figured it out purely from your scripting work is that things such as the sphere of fire isn't an actual item. So the only things you can reference are things like rough sphere, as informative as that is. My best idea for what you can do to identify them is to use boolean values (true/false) for each sphere and just have your script set to use any sphere you haven't used yet in combat. When you do set the boolean to true and just have it run until you have 4 sphere and at least 3 trues. That'll give you all the information you need to use them for the altars. That should give you at least a decent conceptual standpoint to work from.
 

izchak

Member
Ah-ha!
But thats where the cunning mafia part comes into play. Once you've identified the 'fire' sphere, mafia will mark it as such in its item database, and calling $item[sphere of fire] will tell you which sphere is the fire one. The problem is that if you ask for the sphere of fire before its been identified, mafia rightly throws an error, as it doesnt know what item you're talking about...

EDIT: as for the boolean idea, that may well be what I end up doing. I don't like using booleans for that because it relies upon knowledge of what has already happened. If I cancel the script halfway through the city and call it again, it will try to identify the spheres again, even though they've already been identified.

I'll probably make an update in a few days, when I return to the hidden city (chaining 4-day casual runs, because they're cheap and easy).
 

holatuwol

Developer
Once you've identified at least one sphere...

PHP:
if ( get_property( "lastStoneSphere2174" ) == "" )
   // mossy sphere not identified
if ( get_property( "lastStoneSphere2175" ) == "" )
   // smooth sphere not identified
if ( get_property( "lastStoneSphere2176" ) == "" )
   // cracked sphere not identified
if ( get_property( "lastStoneSphere2177" ) == "" )
   // rough sphere not identified

ASH doesn't currently have access to your ascension count, or else you could check "lastStoneSphereReset" to make sure there are valid values in there for the possibility where you don't have any spheres properly identified.
 

izchak

Member
Ooh, thanks hola!
Thats exactly the kind of thing I was looking for. I've figured out a way to check if a stone has been identified now, I'll post the updated script up in a few days when I've tested it.

Out of idle interest, does a similar mechanic apply to the bang potions?
 

macman104

Member
[quote author=izchak link=topic=1205.msg5681#msg5681 date=1188848965]
Ooh, thanks hola!
Thats exactly the kind of thing I was looking for. I've figured out a way to check if a stone has been identified now, I'll post the updated script up in a few days when I've tested it.

Out of idle interest, does a similar mechanic apply to the bang potions?
[/quote]Indeed
Code:
lastBangPotion819=
lastBangPotion820=
lastBangPotion821=
lastBangPotion822=
lastBangPotion823=
lastBangPotion824=
lastBangPotion825=
lastBangPotion826=
lastBangPotion827=
 

izchak

Member
A final question or two:

Does a similar thing happen for the dusty wine identification when you put on the spectacles?

And, is it possible to 'force' an identify by inserting the correct string into that property?
I can see that being useful when identifying the bang potions. If you identify what 8 of the 9 potions are, you can infer what the 9th one is. Its pretty easy to script figuring out what that 9th one is, but keeping track of all nine in your head is a little bit tricky...
 

macman104

Member
[quote author=izchak link=topic=1205.msg5691#msg5691 date=1188996219]Does a similar thing happen for the dusty wine identification when you put on the spectacles?[/quote]Certainly!
Code:
lastDustyBottle2271=
lastDustyBottle2272=
lastDustyBottle2273=
lastDustyBottle2274=
lastDustyBottle2275=
lastDustyBottle2276=
You can also pull up the bottles by typing "dusty" into the gCLI.
And, is it possible to 'force' an identify by inserting the correct string into that property?
I would imagine so. Using the set_property command. Can't see why that wouldn't work...
 

dangerpin

Member
I was having a heck of a time putting together a script to adventure in the ruins to get shrinking powder for my Fernswarthy's Basement dive, this script helped me get it together. Thanks for the hard work and detailed info on what each section does, I really appreciate it.
 

izchak

Member
If all you want to do is adventure in a given square in the hidden city, its fairly simple. A lot simpler than my complex 'explore the city' script, for sure!

Code:
int citysquare = 99;
string url = visit_url("hiddencity.php?which=" + citysquare);
if(contains_text(url, "Combat")) run_combat();
else print("some kind of noncombat was encountered");
Simply adjust the citysquare to the square number you wish to adventure in, and repeat as appropriate!

( I recently discovered the run_combat() function, and it rocks! )
 

dangerpin

Member
Well that is significantly simpler than what I plugged together. I'll try that out after rollover!

Your brain is full of win.
 
Top