monster mob;
buffer loadPage() {
if(form_fields() contains "runcombat" && form_field("runcombat") == "heckyes")
return run_combat();
buffer page = visit_url();
mob = last_monster();
// Add doctype to escape quirks mode
return page.replace_string('<html>', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<html>');
}
void showForm(buffer page) {
boolean SpecialMonster() {
switch(mob) {
case $monster[batwinged gremlin]:
return my_location() != $location[Near an Abandoned Refrigerator];
case $monster[erudite gremlin]:
return my_location() != $location[Out By that Rusted-Out Car];
case $monster[spider gremlin]:
return my_location() != $location[Over Where the Old Tires Are];
case $monster[vegetable gremlin]:
return my_location() != $location[Next to that Barrel with Something Burning in it];
case $monster[wall of skin]:
case $monster[wall of bones]:
case $monster[Dad Sea Monkee]:
case $monster[unusual construct]:
return true;
}
return false;
}
skill monsterSkill() {
switch(mob) {
case $monster[fire truck]:
if(have_skill($skill[Volcanometeor Showeruption]) && item_amount($item[volcanic ash]) > 3)
return $skill[Volcanometeor Showeruption];
return $skill[Awesome Balls of Fire];
case $monster[ice cream truck]:
return $skill[Snowclone];
case $monster[monster hearse]:
return $skill[Raise Backup Dancer];
case $monster[sewer tanker]:
return $skill[Eggsplosion];
case $monster[sketchy van]:
return $skill[Grease Lightning];
}
return $skill[none];
}
string select;
matcher skillCheck = create_matcher(">(?:Wink at|Unleash Nanites|[^>:]+: Fire a badly romantic arrow|Release the Boots)", page);
if(skillCheck.find()) select = skillCheck.group(0);
else if(my_location() == $location[A Deserted Stretch of I-911])
select = ">"+monsterSkill();
else if($familiar[Happy Medium].image == "medium_3.gif" && page.contains_text("Siphon Spirits"))
select = ">Siphon Spirits";
if(limit_mode() != "" || SpecialMonster() || page.contains_text("Steal Accordion") || page.contains_text("% chance of being free)") || select != "") {
// Fix selected skill
if(select != "") {
page = page.replace_string('" selected>', '" >');
page = page.replace_string(select, "selected"+select);
}
// If CAB is present, un-hide the old combat form && only if form has option to unhide (not last round)
if(page.contains_text("<div id=topbar>") && page.contains_text("<a href='#'")) {
string result = replace_all(create_matcher("(<div id='fightform' class='hideform'>|<br><a href='#'[^<]*</a>)", page), "");
page.set_length(0);
page.append(result);
}
}
}
buffer nanorhino(buffer page) {
buffer charge_form() {
buffer form;
form.append('<form name=nano action=fight.php method=post><input type=hidden name=action value="skill"><tr><td align=center><select name=whichskill><option value=\'none\'>Nanorhino at full CHARGE!</option>');
if(have_skill($skill[Clobber]))
form.append('<option value="1022" picurl="clobber" >Clobber (Nano-banish) </option>');
if(have_skill($skill[Toss]))
form.append('<option value="2023" picurl="toss" >Toss (Nano-banish)</option>');
if(have_skill($skill[Spaghetti Spear]))
form.append('<option value="3020" picurl="line" >Spaghetti Spear (Gray Goo)</option>');
if(have_skill($skill[Salsaball]))
form.append('<option value="4020" picurl="salsaball" >Salsaball (Gray Goo)</option>');
if(have_skill($skill[Suckerpunch]))
form.append('<option value="5021" picurl="hernia" >Suckerpunch (Yellow Ray)</option>');
if(have_skill($skill[Sing]))
form.append('<option value="6025" picurl="breath" >Sing (Yellow Ray)</option>');
form.append('/select> <input class=button type=submit onclick="return killforms(this);" value="Use Skill"></td></tr></form>\n</td></tr></table></center></td></tr><tr>');
return form;
}
if(my_familiar() == $familiar[Nanorhino] && get_property("_nanorhinoCharge") == "100")
return page.replace_string("</td></tr></table></center></td></tr><tr>", charge_form());
return page;
}
// Weirdeaux monster part counter by Deadned (#1909053)
// http://kolmafia.us/showthread.php?17091-weirdeaux-monster-stat-box
buffer weirdeaux(buffer page) {
if(my_location() != $location[The Mansion of Dr. Weirdeaux])
return page;
record part {
string name;
string ef;
float factor;
};
static {
part [int] bod;
bod[1] = new part("Shark", "Multiplies Monster Attack by ", 1.2);
bod[2] = new part("Leopard", "Multiplies Monster Defense by ", 1.2);
bod[3] = new part("Bear", "Multiplies Monster HP by ", 1.2);
bod[4] = new part("Bee", "Sometimes dodges attacks", 0.0);
bod[5] = new part("Snail", "Reflects spells", 0.0);
bod[6] = new part("Cheetah", "Always gets the jump", 0.0);
bod[7] = new part("Hedgehog", "Deals damage when hit with melee attacks", 0.0);
bod[8] = new part("Wolf", "Passively deals spooky damage each round", 0.0);
bod[9] = new part("Elephant", "Adds elemental resistance", 0.0);
part [int] head;
head[1] = new part("Tiger", "Damage 30% of Max HP at start of combat", 0.0);
head[2] = new part("Cobra", "You acquire an effect: A Little Bit Poisoned", 0.0);
head[3] = new part("Gorilla", "You acquire an effect: Flattened (Muscle -50%)", 0.0);
head[4] = new part("Goat", "You acquire an effect: Konked on the Head (Mysticality -50%)", 0.0);
head[5] = new part("Pufferfish", " You acquire an effect: Partially Paralyzed (Moxie -50%)", 0.0);
head[6] = new part("Giraffe", " --- ", 0.0);
head[7] = new part("Frog", "Blocks combat items", 0.0);
head[8] = new part("Alligator", "Damage 50% of Max HP at start of combat", 0.0);
head[9] = new part("Naked Mole Rat", "Spooky damage 130% of Max HP at start of combat", 0.0);
head[10] = new part("Jellyfish", "Sometimes blocks your actions", 0.0);
part [int] butt;
butt[1] = new part("Rhinocerous", "Damage 10% of current HP each round", 0.0);
butt[2] = new part("Spider", "Each round, you acquire an effect: Webbed (All stats penalty by 10 * duration)", 0.0);
butt[3] = new part("Fire Ant", "Hot damage 30% of current HP each round", 0.0);
butt[4] = new part("Penguin", "Cold damage 30% of current HP each round", 0.0);
butt[5] = new part("Skunk", "Stench damage 30% of current HP each round", 0.0);
butt[6] = new part("Bat", "Spooky damage 30% of current HP each round", 0.0);
butt[7] = new part("Leech", "Sleaze damage 30% of current HP each round", 0.0);
butt[8] = new part("Rattlesnake", "Spooky damage 50% of current HP each round & prevents familiar actions", 0.0);
butt[9] = new part("Scorpion", "You acquire an effect: A Little Bit Poisoned", 0.0);
butt[10] = new part("Octopus", "Prevents the use of combat skills", 0.0);
}
//counts parts in image
int totalParts = 2;
int [int] s;
matcher m = create_matcher("an_seg(\\d)",page);
while(m.find()) {
s[ to_int(group(m,1)) ] += 1;
totalParts += 1;
}
if(totalParts > 0) {
buffer out;
out.append("<table><tr><th colspan=4 align=left>The monster\'s <b>");
out.append(totalParts);
out.append("</b> pieces are composed of:</th></tr>");
// Find head
m = create_matcher("an_head(\\d+)",page);
if(m.find()) {
out.append("<tr><td><image src=/images/adventureimages/an_head");
out.append(m.group(1));
out.append(".gif height=40></td><td>");
out.append(head[ m.group(1).to_int() ].name);
out.append("</td><td> Head </td><td>");
out.append(head[ m.group(1).to_int() ].ef);
out.append("</td> </tr>");
}
// Find butt
m = create_matcher("an_butt(\\d+)",page);
if(m.find()) {
out.append("<tr><td><image src=/images/adventureimages/an_butt");
out.append(m.group(1));
out.append(".gif height=40></td><td>");
out.append(butt[ m.group(1).to_int() ].name);
out.append("</td><td> Butt </td><td>");
out.append(butt[ m.group(1).to_int() ].ef);
out.append("</td> </tr>");
}
for x from 1 to 9 {
if(to_int(s[x])>0) {
out.append("<tr><td><image src=/images/adventureimages/an_seg");
out.append(x);
out.append(".gif height=40></td><td>");
out.append(bod[x].name);
out.append("</td><td> ");
if(s[x] > 1) {
out.append("<span style='font-size: 75%;vertical-align:top;'>x </span>");
out.append(s[x]);
}
out.append("</td><td>");
out.append(bod[x].ef);
if(bod[x].factor != 0)
out.append(to_string(bod[x].factor ** s[x], "%,.2f"));
out.append("</td> </tr>");
}
}
out.append("</table>");
matcher n=create_matcher("(<table><tr><td><center><table>.+?</table>)<br>",page);
if(n.find())
return page.insert(n.end(1), out);
}
return page;
}
// Using an item that's not in your inventory advances the round counter without any actions happening. You're told that you don't have the item and the round count increments.
// fight.php?action=useitem&whichitem=1
buffer bad_item(buffer page) {
string begin = '<option value=0>(select an item)</option>';
string nothing = '<option picurl=antianti value=1>use nothing</option>';
int i = index_of(page, begin);
if(i > 0)
page = insert(page, i + length(begin), nothing);
return page;
}
buffer volcanic_ash(buffer page) {
string vmse = '<option value="55" picurl="volcmeteor" >Volcanometeor Showeruption (0 Muscularity Points)</option>';
if(page.contains_text(vmse) && available_amount($item[volcanic ash]) < 1)
return page.replace_string(vmse, "");
return page;
}
buffer ocrs(buffer page) {
buffer mods;
void add(buffer b, string s){
if(b.length() > 0) b.append(", ");
b.append(s);
}
void check_mods(string title, boolean [string] list) {
buffer section;
foreach rand in list
if(mob.random_modifiers[rand])
section.add(rand);
if(section.length() > 0) {
section.insert(0, title);
if(mods.length() > 0)
mods.append("<br />");
mods.append(section);
}
}
check_mods("Scary: ", $strings[ticking, ghostly, shaky, hopping-mad, electrified, unstoppable, untouchable]);
check_mods("Evasion: ", $strings[annoying, phase-shifting, restless, dancin', cartwheeling]);
check_mods("Aura: ", $strings[filthy, foul-mouthed, haunted, hot, wet]);
check_mods("Helpful: ", $strings[lazy, narcissistic, twirling, cowardly, frozen]);
check_mods("Extra: ", $strings[clingy, optimal]);
int x = page.index_of("<center><table><tr><td><center><table>");
if(x > 0 && mods.length() > 0)
page.insert(x, "<b>"+mods+"</b>");
return page;
}
buffer source(buffer page) {
buffer note;
if(mob == $monster[Source Agent]) {
// Display amage done by Big Guns
if(!page.contains_text('picurl="ss_guns" >Big Guns'))
return page;
int big_guns = have_skill($skill[Big Guns])? (1 - min(.50, monster_level_adjustment() * .004)) * 300: 0; // Big Guns damage
note.append("<center><span style='font-weight:bold; color:");
if(big_guns < monster_hp())
note.append("red");
else
note.append("green");
note.append(";'>Big Gun Damage: ");
note.append(big_guns);
note.append("</span></center>");
} else {
// Note interval to next Source Agent
matcher interval = create_matcher("var\\s*matrix_speed\\s*=\\s*(\\d+);", page);
note.append("<center><b>Matrix Speed: ");
if(interval.find())
note.append(interval.group(1));
else
note.append("~~");
note.append("</b></center>");
}
int x = page.index_of("<center><!--faaaaaaart--><table");
if(x > 0)
page.insert(x, note);
return page;
}
buffer path(buffer page) {
switch(my_path()) {
case "One Crazy Random Summer": return ocrs(page);
case "The Source": return source(page);
}
return page;
}
// darkcodelagsniper: http://kolmafia.us/showthread.php?19907-MultiCAB-Show-an-extra-Combat-Action-Bar
buffer addMultiCAB( buffer result ) {
matcher m = create_matcher( "actionbar\\.\\d+\\.js.*?</script>" , result );
if(m.find())
result.insert( m.end() , "<script src='MultiCAB.js'></script>" );
return result;
}
void main() {
buffer page = loadPage();
page = addMultiCAB(page);
page = nanorhino(page);
page = weirdeaux(page);
page = bad_item(page);
page = volcanic_ash(page);
page = path(page);
showForm(page);
write(page);
}