# Writen by Bale
# import "choice.rainman.ash";
# import "place.town_right.ash";
// Step 0 is started. Unstarted and finished are trivial to check.
boolean below_step(string pref, int step) {
pref = get_property(pref);
if(pref == "unstarted") return true;
if(pref == "started") return step > 0;
if(pref == "finished") return false;
return pref.substring(4).to_int() < step;
}
// Am I guitarless?
boolean need_guitarrr() {
foreach it in $items[acoustic guitarrr, stone banjo, massive sitar, dueling banjo, dueling turtle, 4-dimensional guitar, heavy metal thunderrr guitarrr]
if(available_amount(it) > 0) return false;
return true;
}
// Check for Dungeons of Doom
boolean need_bangs() {
int gate_potions, missing_potions;
boolean inebriety, teleportitis, need_extra;
for i from 819 to 827 {
switch(get_property("lastBangPotion"+i)) {
# case "healing": case "sleepiness": case "confusion": break;
case "inebriety": inebriety = true; break;
case "teleportitis": teleportitis = true;
case "blessing": case "detection": case "mental acuity": case "ettin strength":
if(available_amount(to_item(i)) == 0)
missing_potions = missing_potions + 1;
else gate_potions = gate_potions + 1;
break;
case "":
if(available_amount(to_item(i)) == 0)
missing_potions = missing_potions + 1;
if(available_amount(to_item(i)) < 2)
need_extra = true;
break;
}
if(gate_potions == 5) return false;
}
if(teleportitis && inebriety && missing_potions == 0) return false;
if(need_extra) return true;
return false;
}
boolean [monster] best_monsters() {
boolean [monster] mon;
if(have_skill($skill[Summon Smithsness]) && available_amount($item[dirty hobo gloves]) + available_amount($item[Hand in Glove]) == 0)
mon[ my_ascensions() % 2 == 0? $monster[drunken half-orc hobo]: $monster[hung-over half-orc hobo] ] = true;
if(available_amount($item[Lady Spookyraven's necklace]) == 0 && get_property("questM20Necklace") != "finished")
mon[ $monster[writing desk] ] = true;
if(available_amount($item[killing jar]) == 0 && get_property("questL11Desert") != "finished" && (get_property("gnasirProgress").to_int() & 4) == 0)
mon[ $monster[banshee librarian] ] = true;
if(available_amount($item[disposable instant camera]) == 0 && available_amount($item[Lord Spookyraven's spectacles]) == 0)
mon[ $monster[animated ornate nightstand] ] = true;
if("questL04Bat".below_step(3))
mon[ $monster[screambat] ] = true;
if("questL08Trapper".below_step(3)) {
if(available_amount($item[ninja rope]) + available_amount($item[ninja crampons]) + available_amount($item[ninja carabiner]) < 3)
mon[ $monster[ninja snowman assassin] ] = true;
if(!have_outfit("Mining Gear") && "questL08Trapper".below_step(2)) {
mon[ $monster[7-Foot Dwarf Foreman] ] = true;
mon[ $monster[mountain man] ] = true;
}
}
if(get_property("questL07Cyrptic") != "finished") {
if(get_property("cyrptAlcoveEvilness").to_int() > 25)
mon[ $monster[modern zmobie] ] = true;
if(get_property("cyrptCrannyEvilness").to_int() > 25)
mon[ $monster[swarm of ghuol whelps] ] = true;
}
if("questL11Desert".below_step(4) && available_amount($item[drum machine]) == 0)
mon[ $monster[Blur] ] = true;
if(available_amount($item[stone wool]) < (get_property("lastTempleUnlock").to_int() == my_ascensions()? 1: 3))
mon[ $monster[Baa'baa'bu'ran] ] = true;
if(available_amount($item[Talisman o' Namsilat]) == 0)
mon[ $monster[gaudy pirate] ] = true;
if("questL11Palindome".below_step(4) && available_amount($item[wet stunt nut stew]) == 0) {
if(available_amount($item[wet stew]) == 0) {
if(available_amount($item[lion oil]) == 0)
mon[ $monster[whitesnake] ] = true;
if(available_amount($item[bird rib]) == 0)
mon[ $monster[white lion] ] = true;
}
if(available_amount($item[stunt nuts]) == 0)
mon[ $monster[Bob Racecar] ] = true;
}
if(get_property("questL11Worship") != "finished" && available_amount($item[stone triangle]) == 0
&& available_amount($item[antique machete]) + available_amount($item[muculent machete]) == 0)
mon[ $monster[forest spirit] ] = true;
if(get_property("hiddenTavernUnlock").to_int() < my_ascensions())
mon[ $monster[pygmy janitor] ] = true;
if("questL12War".below_step(1)) {
if(!have_outfit("War Hippy Fatigues")) {
mon[ $monster[Bailey's Beetle] ] = true;
mon[ $monster[War Hippy Spy] ] = true;
}
if(!have_outfit("Frat Warrior Fatigues"))
mon[ $monster[Orcish Frat Boy Spy] ] = true;
}
if(available_amount($item[barrel of gunpowder]) < 5 && get_property("sidequestLighthouseCompleted") == "none")
mon[ $monster[lobsterfrogman] ] = true;
if(get_property("sidequestNunsCompleted") == "none")
mon[ $monster[dirty thieving brigand] ] = true;
if(available_amount($item[digital key]) == 0) {
mon[ $monster[Blooper] ] = true;
mon[ $monster[ghost] ] = true;
mon[ $monster[morbid skull] ] = true;
}
if(available_amount($item[star hat]) == 0 && available_amount($item[Richard's star key]) == 0 && available_amount($item[star sword]) + available_amount($item[star crossbow]) + available_amount($item[star staff]) == 0) {
mon[ $monster[Astronomer] ] = true;
mon[ my_ascensions() % 2 == 0? $monster[Skinflute]: $monster[Camel's Toe] ] = true;
}
if(need_guitarrr())
mon[ $monster[grungy pirate] ] = true;
if(available_amount($item[Bram's choker]) == 0)
mon[ $monster[Bram the Stoker] ] = true;
if((my_primestat() == $stat[moxie] || have_familiar($familiar[Mad Hatrack]))&& available_amount($item[spangly sombrero]) == 0
|| (have_familiar($familiar[Fancypants Scarecrow]) && available_amount($item[spangly mariachi pants]) == 0))
mon[ $monster[sleepy mariachi] ] = true;
if(my_primestat() == $stat[mysticality] && available_amount($item[antique hand mirror]) == 0)
mon[ $monster[remains of a jilted mistress] ] = true;
if(get_property("lastDispensaryOpen").to_int() < my_ascensions() && !have_outfit("Knob Goblin Elite Guard Uniform"))
mon[ $monster[Knob Goblin Elite Guard Captain] ] = true;
if(need_bangs()) {
mon[ $monster[Quantum Mechanic] ] = true;
mon[ $monster[mind flayer] ] = true;
}
if(my_path() == "Heavy Rains") { // I might re-use this code for unknown future content
mon[ $monster[alley catfish] ] = true;
mon[ $monster[piranhadon] ] = true;
}
return mon;
}
buffer rainy_fax(buffer page) {
string [string] mon;
boolean [monster] best_monsters = best_monsters();
matcher select = create_matcher('<option value=(\\d+)>([^<]+)</option>', page);
while(select.find())
if(best_monsters contains select.group(2).to_monster())
mon[ select.group(2) ] = select.group(0);
// Gremlins are trickier because they can appear on the list TWICE so I need to ID them by number
// <option value=547>erudite gremlin</option> <option value=549>batwinged gremlin</option> <option value=551>vegetable gremlin</option> <option value=553>spider gremlin</option>
if(available_amount($item[molybdenum magnet]) > 0)
foreach gremlin in $strings[547, 549, 551, 553] {
select = create_matcher('<option value='+gremlin+'>([^<]+)</option>', page);
if(select.find())
mon[ select.group(1) ] = select.group(0);
}
if(count(mon) > 0) {
page.replace_string(">Make: <", ">Make (full list):<");
buffer filter;
filter.append("<form action=choice.php method=post><input type=hidden name=pwd value=");
filter.append(my_hash());
filter.append("><input type=hidden name=whichchoice value=970>Make (useful monsters): <select name=whichmonster>");
foreach m,o in mon
filter.append(o);
filter.append("</select><input type=hidden name=option value=1><input type=submit class=button name=choice2 value='and Fight!'></form>");
return page.insert(index_of(page, '</form><form ')+ 7, filter);
}
return page;
}
buffer annotate(buffer page) {
buffer c;
matcher choices = create_matcher("<input type=hidden name=pwd value='[^']+'><input type=hidden name=whichchoice value=(\\d+)><input type=hidden name=option value=(\\d+)>", page);
while(choices.find())
choices.append_replacement(c, choices.group(2)+": "+choices.group(0));
choices.append_tail(c);
// Add choiceAdventure number to title
matcher title = create_matcher('<input type=hidden name=whichchoice value=(\\d+)>.+(</form><p></center></td></tr>)</table></center>', c);
if(title.find())
return c.replace_string(title.group(2), title.group(2)+"<tr><td><span style='float:right;color:blue;font-weight:bold'>choiceAdventure"+title.group(1)+"</span></td></tr>");
return c;
}
buffer crimbot_factory(buffer page) {
// View entire image
int i = index_of(page, "z-index: 1;");
if(i > 0)
page = page.insert(index_of(page, "z-index: 1;"), "opacity: 0.5; ");
// Stabilize the image
# page = page.replace_string("drifty.animate({top: top, left: left}, 2000, 'swing', moveDrifty);", "");
return page;
}
buffer pick_card(buffer page) {
void addText( string initialText, string addedText ) {
int index = index_of( page, initialText );
if ( index == -1 ) return;
index += length( initialText );
insert( page, index, " - " + addedText );
}
if( !page.contains_text( 'bgcolor=blue><b>Pick a Card</b>' ) )
return page;
addText( "X of Clubs", "PvP Fights" );
addText( "X of Diamonds", "cubic zirconia" );
addText( "X of Hearts", "bubblegum hearts" );
addText( "X of Spades", "shovels, spading string" );
addText( "X of Papayas", "papayas" );
addText( "X of Kumquats", "kumquats" );
addText( "X of Salads", "delicious salad" );
addText( "X of Cups", "random booze" );
addText( "X of Coins", "valuable coins" );
addText( "X of Swords", "random swords" );
addText( "X of Wands", "random buffs" );
addText( "0 - The Fool", "20 turns of +200% moxie" );
addText( "I - The Magician", "20 turns of +200% myst" );
addText( "II - The High Priestess", "fight a hippy" );
addText( "III - The Empress", "500 myst substats" );
addText( "IV - The Emperor", "fight The Emperor" );
addText( "V - The Hierophant", "fight a dude" );
addText( "VI - The Lovers", "500 moxie substats" );
addText( "VII - The Chariot", "fight a construct" );
addText( "IX - The Hermit", "fight The Hermit" );
addText( "X - The Wheel of Fortune", "20 turns of +100% item" );
addText( "XI - Strength", "20 turns of +200% muscle" );
addText( "XII - The Hanged Man", "fight an orc" );
addText( "XIII - Death", "fight an undead" );
addText( "XIV - Temperance", "fight a hobo" );
addText( "XV - The Devil", "fight a demon" );
addText( "XVI - The Tower", "tower key" );
addText( "XVII - The Star", "fight a constellation" );
addText( "XVIII - The Moon", "fight a horror" );
addText( "XXI - The World", "500 muscle substats" );
addText( "Plains", "white mana" );
addText( "Swamp", "black mana" );
addText( "Mountain", "red mana" );
addText( "Forest", "green mana" );
addText( "Island", "blue mana" );
addText( "Healing Salve", "get skill" );
addText( "Dark Ritual", "get skill" );
addText( "Lightning Bolt", "get skill" );
addText( "Giant Growth", "get skill" );
addText( "Ancestral Recall", "get skill" );
addText( "The Hive", "fight a bug" );
addText( "Goblin Sapper", "fight a goblin" );
addText( "Fire Elemental", "fight an elemental" );
addText( "Unstable Portal", "fight a weird" );
addText( "Lead Pipe", "1h club, +50 HP, +100% mus" );
addText( "Rope", "1h whip, +2 mus stats, 10 fam wt" );
addText( "Wrench", "1h utensil, +50 MP, 100% spell damage" );
addText( "Candlestick", "1h wand, 2 myst stats, +100% myst" );
addText( "Knife", "1h knife, +50% meat, +100% moxie" );
addText( "Revolver", "1h pistol, +2 moxie stats, +50% init" );
addText( "Professor Plum", "plums" );
addText( "Spare Tire", "tires" );
addText( "Extra Tank", "full meat tank" );
addText( "Sheep", "3 stone wool" );
addText( "Year of Plenty", "5 random food" );
addText( "Mine", "1 of each ore" );
addText( "Laboratory", "5 random potions" );
addText( "Werewolf", "fight a beast" );
addText( "Go Fish", "fight a fish" );
addText( "Plantable Greeting Card", "fight a plant" );
addText( "Pirate Birthday Card", "fight a pirate" );
addText( "Christmas Card", "fight an elf" );
addText( "Gift Card", "get a gift card" );
addText( "Suit Warehouse Discount Card", "fight a penguin" );
addText( "1952 Mickey Mantle", "10k autosell" );
addText( "Slimer Trading Card", "fight a slime" );
addText( "Aquarius Horoscope", "fight a mer-kin" );
addText( "Hunky Fireman Card", "fight a humanoid" );
addText( "Green Card", "fight a legal alien" );
addText( "The Race Card", "20 turns of +200% init" );
return page;
}
buffer witchess(buffer page) {
record reward {
string match_text;
item it;
string type;
string additional_text;
};
static {
reward [8] witch_pieces;
witch_pieces[0] = new reward("<b>Pawn</b></a>", $item[armored prawn], "Spleen", "Init +50%");
witch_pieces[1] = new reward("<b>Knight</b></a>", $item[jumping horseradish], "Food", "Meat +100%");
witch_pieces[2] = new reward("<b>Bishop</b></a>", $item[Sacramento wine], "Booze", "Item +50%");
witch_pieces[3] = new reward("<b>Rook</b></a>", $item[Greek fire], "Potion", "ML +25<br>Exp +10");
witch_pieces[4] = new reward("<b>Ox</b></a>", $item[ox-head shield], "Shield", "Max HP +100<br>DR +26<br>Prismatic Res +2<br>Rollover Fites +8<br>Never Fumble");
witch_pieces[5] = new reward("<b>King</b></a>", $item[dented scepter], "Club", "Mus Exp +5<br>HP Regen 5-10<br>Mus +50%<br>Wpn Dmg +50%<br>Critical Hit +10%");
witch_pieces[6] = new reward("<b>Witch</b></a>", $item[battle broom], "Accessory", "Myst Exp +5<br>MP Regen 5-10<br>Myst +50%<br>Spell Dmg +100%<br>Spell Critical +10%");
witch_pieces[7] = new reward("<b>Queen</b></a>", $item[very pointy crown], "Hat", "Mox Exp +5<br>Rollover Adv +5<br>Mox +50%<br>Combat Rate -5<br>Critical Hit Delevel");
}
foreach i, s in witch_pieces {
buffer rep;
rep.append(s.match_text);
rep.append("<br><center><table><tr title='");
rep.append(s.it);
rep.append(" (have ");
rep.append(available_amount(s.it));
rep.append(")");
if($items[ox-head shield, dented scepter, battle broom, very pointy crown] contains s.it)
rep.append("\nWill disappear at the end of day");
rep.append("'><td><img src='/images/itemimages/");
rep.append(s.it.image);
rep.append("' class='hand' onClick='javascript:descitem(");
rep.append(s.it.descid);
rep.append(")'></td><td><a onClick='javascript:descitem(");
rep.append(s.it.descid);
rep.append(")'><b>");
rep.append(s.type);
rep.append("</a></b></td></tr></table></center><div style=\"color:blue; font-size:75%\">");
rep.append(s.additional_text);
rep.append("</div>");
page.replace_string(s.match_text, rep);
}
// Line up the pieces neatly.
page.replace_string('<div style="display:inline-block; text-align: center; width: 120px">', '<div style="vertical-align:top; display:inline-block; text-align: center; width: 120px">');
return page;
}
buffer special_pages(buffer page) {
if(page.contains_text('bgcolor=blue><b>Rainy Fax Dreams on your Wedding Day</b>'))
return rainy_fax(page);
if(page.contains_text('bgcolor=blue><b>Pick a Card</b>'))
return pick_card(page);
if(page.contains_text("Your Witchess set came with a "))
return witchess(page);
return page;
}
void main() {
# if(true) return;
# foreach key in form_fields() print(key+" -- "+ form_field(key));
switch(form_field("whichchoice")) {
case "793": // The Shore, Inc. > Gift Shop
case "189": // O Cap'm, My Cap'm > Set an Open Course for the Virgin Booty
return;
case "970": // Rainy Fax Dreams on your Wedding Day
if(form_fields() contains "whichmonster")
return; // Don't override combat with faxed monster
break;
case "991": // Build a Crimbot!
case "992": // Inside the Fully Automated Crimbo Factory
visit_url().crimbot_factory().write();
return;
case "1171": // LT&T Office
# visit_url().ltt().write();
return;
}
visit_url().special_pages().write();
}