Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // hugmeir's combat script. WIP forever.
- import <zlib.ash>
- boolean [string] mm;
- boolean monster_modifiers_may_stop_actions() {
- if ( mm["annoying"] || mm["phase-shifting"] || mm["restless"] )
- return true;
- return false;
- }
- int get_property_int(string prop) {
- return get_property(prop).to_int();
- }
- boolean can_use_skill(skill this_skill) {
- if ( !have_skill(this_skill) )
- return false;
- if ( !this_skill.is_unrestricted() )
- return false;
- boolean can_use_skill = true;
- switch ( this_skill ) {
- case $skill[KGB tranquilizer dart]:
- if ( get_property_int("_kgbTranquilizerDartUses") >= 3 )
- return false;
- break;
- case $skill[Snokebomb]:
- if ( get_property_int("_snokebombUsed") >= 3 )
- return false;
- break;
- case $skill[Shattering Punch]:
- if ( get_property_int("_shatteringPunchUsed") >= 3 )
- return false;
- break;
- case $skill[Macrometeorite]:
- if ( get_property_int("_macrometeoriteUses") >= 10 )
- return false;
- break;
- }
- if ( mp_cost(this_skill) > my_mp() )
- return false;
- return true;
- }
- string [int] macro_list;
- void push_turnless_macro(string elem) {
- int idx = macro_list.count();
- macro_list[idx] = elem;
- return;
- }
- int rounds_so_far = 0;
- void push_action(string elem) {
- push_turnless_macro(elem);
- rounds_so_far += 1;
- return;
- }
- void push_blockable_action(string action) {
- push_action(action);
- if ( monster_modifiers_may_stop_actions() ) {
- string [int] bullshit;
- if ( mm["phase-shifting"] )
- bullshit[bullshit.count()] = "blinks out of existence";
- if ( mm["annoying"] )
- bullshit[bullshit.count()] = "stopping you in your tracks";
- if ( mm["restless"] )
- bullshit[bullshit.count()] = "moves out of the way before you can";
- bullshit[bullshit.count()] = "moved by the time you can finish";
- if ( mm["cartwheeling"] )
- bullshit[bullshit.count()] = "cartwheels out of the way";
- buffer repeat_macro;
- repeat_macro.append("repeat ");
- foreach idx, match_string in bullshit {
- if ( idx != 0 )
- repeat_macro.append(" || ");
- repeat_macro.append("match \"" + match_string +"\"");
- }
- push_turnless_macro(repeat_macro.to_string());
- }
- }
- string compose_combat_macro() {
- buffer result;
- foreach idx, macro in macro_list {
- if ( idx == 0 ) {
- result.append(macro);
- }
- else {
- result.append(";");
- result.append(macro);
- }
- }
- return result.to_string();
- }
- void push_item_multiuse_if_possible(item this_item) {
- int item_amount = this_item.available_amount();
- if ( item_amount > 0) {
- if ( item_amount == 1 ) {
- push_blockable_action("use " + this_item.to_string());
- }
- else {
- push_blockable_action("use " + this_item.to_string() + ", " + this_item.to_string());
- }
- }
- }
- void push_skill (skill this_skill) {
- push_blockable_action("skill " + this_skill.to_string());
- }
- void push_skill (string skill_as_string) {
- push_blockable_action("skill " + skill_as_string);
- }
- void instakill_macro() {
- foreach this_item in $items[exploding cigar] {
- push_item_multiuse_if_possible(this_item);
- }
- foreach this_skill in $skills[shattering punch, macrometeorite, cleesh] {
- if ( can_use_skill( this_skill ) )
- push_skill(this_skill);
- }
- push_turnless_macro("abort \"I bring bad news\"");
- }
- void get_stun_macro() {
- if ( can_use_skill($skill[noodles of fire]) ) {
- push_skill($skill[noodles of fire]);
- return;
- }
- switch ( my_class() ) {
- case $class[pastamancer]:
- push_skill($skill[entangling noodles]);
- return;
- case $class[seal clubber]:
- // todo if club is equipped
- if (
- $slot[weapon].equipped_item().item_type() == "club"
- &&
- my_fury() > 1
- &&
- can_use_skill($skill[club foot])
- ) {
- push_skill($skill[club foot]);
- return;
- }
- break;
- case $class[sauceror]:
- if ( my_soulsauce() > 5 && can_use_skill($skill[soul bubble]) ) {
- push_skill($skill[soul bubble]);
- return;
- }
- break;
- case $class[accordion thief]:
- if (
- $slot[weapon].equipped_item().item_type() == "accordion"
- &&
- can_use_skill($skill[accordion bash])
- ) {
- push_skill($skill[accordion bash]);
- return;
- }
- break;
- // TODO TT love.
- // case $class[turtle tamer]:
- // if hasskill shell up && (haseffect 1422 || haseffect 1423 || haseffect 1424)
- // if ( can_use_skill($skill[shell up]) && )
- // break;
- default:
- break;
- }
- if ( can_use_skill($skill[shadow noodles]) ) {
- push_skill($skill[shadow noodles]);
- return;
- }
- return;
- }
- void nosy_nose_olfact_macro() {
- if ( my_familiar() == $familiar[Nosy Nose] ) {
- push_blockable_action("skill 7166");
- }
- }
- void micrometeorite_macro () {
- push_skill("micrometeorite");
- }
- int _expected_damage(monster foe, stat this_stat) {
- int player_stat = my_buffedstat(this_stat);
- float attack_type_multiplier = 1.0; // no lunging permed yet
- float weapon_type_multiplier = 0.75;
- int initial_damage = floor(
- player_stat * attack_type_multiplier * weapon_type_multiplier
- );
- if ( initial_damage < 0 )
- initial_damage = 0;
- int damage_minus_def = initial_damage - foe.base_defense;
- // TODO fists?
- item weapon = $slot[weapon].equipped_item();
- int weapon_damage = weapon.get_power();
- int crit_multiplier = 1; // eh
- int weapon_damage_total = weapon_damage * crit_multiplier * attack_type_multiplier;
- int bonus_weapon_damage = numeric_modifier("Weapon Damage").to_int();
- int bonus_prism = numeric_modifier("Prismatic Damage");
- int total = damage_minus_def + weapon_damage_total + bonus_weapon_damage + bonus_prism;
- // wiki formula stops at total, but that gives results almost twice
- // as high as the actual damage dealt. I probably have one of
- // the inputs wrong. In any case, let's just go very conservative
- // and just return half of the damage the formula gave us.
- return floor(total / 2);
- }
- int expected_ranged_damage(monster foe) {
- int ranged_damage = _expected_damage(foe, $stat[moxie]);
- int bonus_ranged_damage = numeric_modifier("Ranged Damage").to_int();
- return ranged_damage + bonus_ranged_damage;
- }
- int expected_weapon_damage(monster foe) {
- return _expected_damage(foe, $stat[muscle]);
- }
- void default_fight_macro(monster foe) {
- boolean immune_to_physical = false;
- switch (foe) {
- case $monster[mouthless murmur]:
- immune_to_physical = true;
- break;
- default:
- immune_to_physical = foe.physical_resistance >= 90;
- }
- push_turnless_macro("while !pastround 26"); // 28 aborts all
- if ( mm["untouchable"] || immune_to_physical ) {
- // rainbow damage. Or well, this because it's all I got
- push_action("skill saucestorm");
- }
- else {
- item equipped_weapon = $slot[weapon].equipped_item();
- string equipped_weapon_type = weapon_type(equipped_weapon);
- int expected_attack_damage = 0;
- if ( equipped_weapon_type == $stat[moxie] ) {
- expected_attack_damage = expected_ranged_damage(foe);
- }
- else if ( equipped_weapon_type == $stat[muscle] ) {
- expected_attack_damage = expected_weapon_damage(foe);
- }
- if ( expected_attack_damage > 80 ) {
- push_action("attack");
- }
- else {
- push_action("skill saucestorm");
- }
- if ( $item[gauze garter].available_amount() > 1 ) {
- // TODO moar
- push_turnless_macro("if hppercentbelow 50 && pastround 10");
- push_item_multiuse_if_possible($item[gauze garter]);
- push_turnless_macro("endif");
- }
- }
- push_turnless_macro("endwhile");
- if ( mm["untouchable"] ) {
- // Instakill anything that got this far.
- instakill_macro();
- }
- }
- boolean ticking_and_needs_instakill(monster foe) {
- if ( !mm["ticking"] )
- return false;
- if ( mm["frozen"] )
- return false;
- if ( mm["fragile"] && !mm["unlucky"] )
- return false;
- if ( mm["untouchable"] ) {
- if ( mm["unlucky"] )
- return false; // we'll see.
- return true;
- }
- if ( monster_modifiers_may_stop_actions() && foe.raw_hp > 90 )
- return true;
- return false;
- }
- boolean foe_should_be_nosy_nose_olfacted (monster foe) {
- switch (foe) {
- case $monster[drunk pygmy]: return true;
- case $monster[pygmy witch surgeon]: return true;
- case $monster[pygmy shaman]: return true;
- case $monster[gaudy pirate]: return true;
- case $monster[dirty old lihc]: return true;
- case $monster[tomb rat]: return true;
- case $monster[pygmy witch accountant]:
- if (my_location() == $location[The Hidden Office Building])
- return true;
- return false;
- }
- return false;
- }
- boolean will_survive_n_rounds(monster foe, int rounds) {
- int damage_in_one_turn = 0;
- if ( mm["cowardly"] )
- return true;
- foreach monster_modifier, has_modifier in mm {
- if ( has_modifier == true ) {
- switch ( monster_modifier ) {
- case "electrified":
- damage_in_one_turn += my_maxhp() * 0.2;
- break;
- case "filthy":
- case "foul-mouthed":
- case "haunted":
- case "hot":
- case "wet":
- damage_in_one_turn += 30; // eh
- break;
- }
- }
- }
- int plain_attack_damage = expected_damage(foe);
- if ( plain_attack_damage < 0 ) // unspaded monster
- plain_attack_damage = 10;
- if ( mm["shaky"] ) {
- plain_attack_damage = plain_attack_damage * 3;
- }
- else if ( mm["cloned"] ) {
- plain_attack_damage = plain_attack_damage * 2;
- }
- print_html("plain dmg: " + plain_attack_damage + " | from mods: " + damage_in_one_turn);
- damage_in_one_turn += plain_attack_damage;
- int total_damage = damage_in_one_turn * rounds;
- return total_damage < my_hp();
- }
- boolean will_survive_round(monster foe) { // shortcut
- return will_survive_n_rounds(foe, 1);
- }
- string gremlin_stasis_macro(monster foe) {
- // TODO
- return "abort \"Do gremlins on your own, you lazy fuck!\"";
- }
- void rave_macro_generic(string which_combo) {
- string rave_combo = get_property("raveCombo1");
- if ( rave_combo == "" )
- return;
- string [int] skill_order = rave_combo.split_string(",");
- foreach rave_skill in skill_order {
- push_skill(skill_order[rave_skill]);
- }
- }
- void rave_plus_item_macro() {
- rave_macro_generic("raveCombo1");
- }
- void rave_plus_meat_macro() {
- rave_macro_generic("raveCombo2");
- }
- void rave_stun_macro() {
- rave_macro_generic("raveCombo3");
- }
- boolean rave_steal_macro() {
- string rave_steal = get_property("raveCombo5");
- if ( rave_steal == "" )
- return false;
- int steals_count = get_property("_raveStealCount").to_int();
- int steals_left = 30 - steals_count;
- if ( steals_left <= 0 )
- return false;
- string [int] skill_order = rave_steal.split_string(",");
- foreach rave_skill in skill_order {
- push_skill(skill_order[rave_skill]);
- }
- return true;
- }
- void pickpocket_macro(int num_items_dropped) {
- if ( num_items_dropped < 1 )
- return;
- // no PP
- if ( !($classes[disco bandit,accordion thief] contains my_class()) )
- return;
- // pp if we got the jump
- push_turnless_macro("if gotjump");
- push_action("pickpocket");
- push_turnless_macro("endif");
- boolean have_second_pp = have_equipped($item[Bling of the New Wave]);
- if ( !have_second_pp )
- return;
- // Second PP; only do it if the first attempt failed, OR
- // if the monster drops more than one item
- if ( num_items_dropped > 1 ) {
- push_action("pickpocket");
- }
- else {
- // Only drops one item. So only do the second PP
- // if the first one failed. This will also trigger if
- // we did not get the jump.
- push_turnless_macro("if !match \"You deftly slip your fingers\"");
- push_action("pickpocket");
- push_turnless_macro("endif");
- }
- // match at this point will show whether we final pickpocket
- // succeeded
- return;
- }
- void disco_dance_macro() {
- push_skill("disco dance of doom");
- push_skill("disco dance ii");
- push_skill("disco dance 3");
- }
- void add_goto_runaway_function(monster foe) {
- push_turnless_macro("sub try_goto_runaway");
- if ( mm["ticking"] ) {
- push_turnless_macro("if pastround 2");
- instakill_macro();
- push_turnless_macro("endif");
- }
- push_turnless_macro("while hascombatitem 4948");
- push_action("use 4948"); // hurmph.
- push_turnless_macro("endwhile");
- // Stole the goto, tried to do a free runaway, but failed.
- // So just kill it.
- default_fight_macro(foe);
- push_turnless_macro("endsub");
- }
- void banish_pool_one_macro() {
- foreach this_skill in $skills[snokebomb, KGB tranquilizer dart] {
- if ( can_use_skill(this_skill) )
- push_skill(this_skill);
- }
- if ( have_equipped($item[mafia thumb ring]) ) {
- int current_mp = my_mp();
- if ( current_mp >= 15 ) {
- push_turnless_macro("if hasskill Show them your ring");
- push_skill("Show them your ring");
- push_turnless_macro("endif");
- }
- }
- foreach this_item in $items[louder than bomb, tennis ball, crystal skull] {
- push_item_multiuse_if_possible(this_item);
- }
- push_turnless_macro("abort \"Cannot banish?!\"");
- }
- boolean delevel_is_useful(monster foe) {
- int monster_attack = foe.base_attack + 20; // to be on the safe side
- if ( my_buffedstat($stat[moxie]) > monster_attack )
- return false;
- return true;
- }
- boolean in_aftercore() {
- return !in_hardcore() && can_interact();
- }
- void main(int initround, monster foe, string pg) {
- mm = foe.random_modifiers;
- // Step up the base macro:
- push_turnless_macro("scrollwhendone");
- push_turnless_macro("abort hppercentbelow 25 || hpbelow 20 || pastround 28");
- boolean disco_bandit = my_class() == $class[disco bandit];
- int pickpocketable_items = 0;
- boolean consider_pickpocket = false;
- boolean ran_combat = false;
- boolean stagger_immune = false;
- foreach item_id, record_value in foe.item_drops_array() {
- if ( record_value.type == "c" ) { // conditional
- if ( item_type( record_value.drop ) != "shirt" )
- continue;
- }
- if ( record_value.rate == 0 ) // < 1% conditional
- continue;
- pickpocketable_items += 1;
- }
- if ( ticking_and_needs_instakill(foe) ) {
- instakill_macro();
- }
- else {
- if ( mm["unstoppable"] ) {
- stagger_immune = true;
- if ( mm["electrified"] && monster_modifiers_may_stop_actions() ) {
- // TODO check if we can survive long enough, otherwise
- // instakill
- if ( foe.raw_hp > 100 ) {
- // eh, no chance. Just instakill it.
- instakill_macro();
- }
- }
- }
- if ( pickpocketable_items > 0 ) {
- consider_pickpocket = true;
- }
- }
- if ( foe == $monster[Eldritch Tentacle] ) {
- stagger_immune = true;
- }
- location where = my_location();
- if ( in_aftercore() ) {
- boolean do_weaksauce = false;
- switch ( where ) {
- case $location[Hobopolis Town Square]:
- do_weaksauce = true;
- pickpocket_macro(pickpocketable_items);
- break;
- case $location[Cobb's Knob Menagerie\, Level 1]:
- // aftercore UR farming
- if ( mm["solid gold"] ) { // just kill solid gold monsters
- pickpocket_macro(pickpocketable_items);
- }
- else {
- switch (foe) {
- case $monster[Fruit Golem]:
- pickpocket_macro(pickpocketable_items);
- banish_pool_one_macro();
- break;
- case $monster[BASIC Elemental]:
- add_goto_runaway_function(foe);
- pickpocket_macro(pickpocketable_items);
- push_turnless_macro("if match \"You deftly slip your fingers\"; call try_goto_runaway; endif;");
- // Rave real
- if ( !mm["ticking"] && rave_steal_macro() ) {
- push_turnless_macro("if match \"Your savage beatdown seems to have knocked loose some treasure\"");
- push_turnless_macro("call try_goto_runaway");
- push_turnless_macro("endif");
- }
- break;
- default:
- push_turnless_macro("abort \"what\"");
- break;
- }
- }
- break;
- case $location[the red zeppelin]:
- if ( $item[glark cable].available_amount() > 0 && get_property("_glarkCableUses").to_int() < 5 )
- push_item_multiuse_if_possible($item[glark cable]);
- break;
- case $location[the hidden bowling alley]:
- if ( foe != $monster[drunk pygmy] && $item[short writ of habeas corpus].available_amount() > 0) {
- pickpocket_macro(pickpocketable_items);
- push_item_multiuse_if_possible($item[short writ of habeas corpus]);
- }
- default:
- if ( consider_pickpocket )
- pickpocket_macro(pickpocketable_items);
- break;
- }
- boolean should_delevel = delevel_is_useful(foe);
- if ( !stagger_immune ) {
- if ( should_delevel )
- micrometeorite_macro();
- get_stun_macro();
- }
- if ( do_weaksauce && should_delevel && !mm["ticking"] )
- push_skill("curse of weaksauce");
- if ( disco_bandit && !mm["ticking"] ) { // can deal with ticking if we keep up a stun.
- int rounds_spent = 0;
- if ( mm["solid gold"] ) {
- // +50% meat from rave
- if ( will_survive_n_rounds(foe, 2 + rounds_spent) ) {
- rounds_spent += 2;
- rave_plus_meat_macro();
- }
- }
- if ( pickpocketable_items > 0 ) {
- // +30% item from discosity
- if ( will_survive_n_rounds(foe, 1 + rounds_spent) ) {
- disco_dance_macro();
- rounds_spent += 1;
- }
- // +30% item from rave
- if ( will_survive_n_rounds(foe, 2 + rounds_spent) ) {
- rave_plus_item_macro();
- rounds_spent += 2;
- }
- }
- if ( !mm["solid gold"] && foe.min_meat > 80 ) {
- // eh, sure.
- if ( will_survive_n_rounds(foe, 2 + rounds_spent) ) {
- rave_plus_meat_macro();
- rounds_spent += 2;
- }
- }
- }
- }
- else { // in-run
- // TODO actually write this out. Have not been in-run since I
- // started writing this...
- if ( foe_should_be_nosy_nose_olfacted(foe) )
- nosy_nose_olfact_macro();
- // in-run
- if (
- where == $location[Barrrney's Barrr]
- &&
- foe.phylum == $phylum[pirate]
- ) {
- push_blockable_action("use big book of pirate insults");
- }
- if (
- $item[rock band flyers].available_amount() > 0
- &&
- get_property("flyeredML").to_int() < 10000
- &&
- will_survive_round(foe)
- ) {
- // TODO heal in case we pickpocketed
- push_blockable_action("use rock band flyers");
- }
- if ( contains_text(foe.manuel_name, "gremlin") ) {
- //string gremlin_stasis_macro = gremlin_stasis_macro(foe);
- //combat_macro = combat_macro + gremlin_stasis_macro;
- }
- }
- default_fight_macro(foe);
- // Show the macro, just in case...
- string full_combat_macro = compose_combat_macro();
- print_html(full_combat_macro);
- run_combat(full_combat_macro);
- if ( in_aftercore() ) {
- if (
- where == $location[Hobopolis Town Square]
- &&
- my_familiar() == $familiar[slimeling]
- ) {
- int max_mp = my_maxmp();
- int threshold = max_mp * 0.4;
- if ( my_mp() < threshold ) {
- float slimeling_fullness = get_property("slimelingFullness").to_float();
- if ( slimeling_fullness < 5.0 ) {
- cli_execute("slimeling 1 ring of aggravate");
- }
- }
- }
- if ( my_hp() < ( my_maxhp() * 0.6 ) ) {
- cli_execute("cast cannelloni cocoon");
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement