Skip to content

Commit

Permalink
Automation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
houeland committed Feb 7, 2015
1 parent e01900c commit eb220cc
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 809 deletions.
105 changes: 6 additions & 99 deletions scripts/automation/ascension.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ function print_ascensiondebug(...)
end
end

result_status = {
finished = function()
finished = true
end
}

local function automate_day(whichday)
reset_error_trace_steps()
finished = false
Expand Down Expand Up @@ -2058,91 +2064,6 @@ endif
}
}

-- TODO: make into separate tasks
if quest("The Final Ultimate Epic Final Conflict") and quest_text("You've come to an odd junction in the cave leading to the Sorceress' Lair") then
if not have_item("stone tablet (Really Evil Rhythm)") and have_item("skeleton key") and quest_text("solve a really convoluted and contrived puzzle involving a cloud of gas") then
inform "do skeleton key"
script.maybe_ensure_buffs { "A Few Extra Pounds" }
while true do
if hp() <= 60 and hp() < maxhp() then
script.heal_up()
end
local before_hp = hp()
async_post_page("/lair2.php", { prepreaction = "skel" })
if have_item("stone tablet (Really Evil Rhythm)") or hp() >= before_hp then
break
end
end
if have_item("stone tablet (Really Evil Rhythm)") then
did_action = true
end
elseif countif("Boris's key") + countif("Jarlsberg's key") + countif("Sneaky Pete's key") < 3 and not have_item("makeshift SCUBA gear") then
-- TODO: if not enough fat loot tokens, and no wand, hmm(?)
inform "trading for legend keys"
for _, x in ipairs { "Boris's key", "Jarlsberg's key", "Sneaky Pete's key" } do
if not have_item(x) then
shop_buy_item(x, "damachine")
end
end
if countif("Boris's key") + countif("Jarlsberg's key") + countif("Sneaky Pete's key") >= 3 then
did_action = true
end
else
inform "pass lair statues"
if challenge == "fist" then
script.ensure_buffs { "Earthen Fist" }
end
while not have_item("stolen accordion") do
result, resulturl, advagain = script.buy_use_chewing_gum()
if not advagain then
critical "Failed to use chewing gum"
end
end

if ascensionstatus("Softcore") then
local maximum_lair_items_missing = 6
if requires_wand_of_nagamar() and not have_wand_or_parts() then
maximum_lair_items_missing = maximum_lair_items_missing + 1
end
if not have_item("star hat") then
maximum_lair_items_missing = maximum_lair_items_missing + 1
end
if can_wear_weapons() and not have_item("star crossbow") and not have_item("star staff") and not have_item("star sword") then
maximum_lair_items_missing = maximum_lair_items_missing + 1
end
for i = 1, 6 do
local item = get_lair_tower_monster_items()[i]
if item and have_item(item) then
maximum_lair_items_missing = maximum_lair_items_missing - 1
end
end
print("DEBUG pulls missing", pullsleft(), maximum_lair_items_missing)
if (pullsleft() or 0) >= maximum_lair_items_missing and (pullsleft() or 0) >= 3 then
pull_in_softcore("star hat")
if can_wear_weapons() and not have_item("star crossbow") and not have_item("star staff") and not have_item("star sword") then
pull_in_softcore("star crossbow")
end
end
end
result, resulturl = get_page("/lair2.php", { action = "statues" })
local missing_stuff = automate_lair_statues(result)
if missing_stuff and table.concat(missing_stuff, ", "):contains("smith a stone banjo") then
automate_smithing_stone_banjo()
result, resulturl = get_page("/lair2.php", { action = "statues" })
missing_stuff = automate_lair_statues(result)
end
if missing_stuff then
result, resulturl = get_page("/lair2.php")
result = add_message_to_page(get_result(), "TODO: finish lair<br><br>" .. table.concat(missing_stuff, ", "), nil, "darkorange")
did_action = false
finished = true
else
did_action = true
end
end
return result, resulturl, did_action
end

add_task {
when = challenge == "boris" and
daysthisrun() == 1 and
Expand Down Expand Up @@ -5700,20 +5621,6 @@ use gauze garter
did_action = not locked()
end

if locked() == "choice" and playerclass("Turtle Tamer") then
-- TODO: only trigger when there's only one choice
local ctr = 0
result, resulturl = get_page("/choice.php")
result, resulturl, advagain = handle_adventure_result(result, resulturl, "?", nil, nil, function(advtitle, choicenum, pt)
if ctr < 10 then
ctr = ctr + 1
print("AUTOMATION: guessing this is a turtle taming choice adventure, picking option 1")
return "", 1
end
end)
did_action = not locked()
end

if have_buff("Beaten Up") then
if get_result():contains("That's all the horror you can take. You flee the scene.") then
if have_buff("Beaten Up") then
Expand Down
30 changes: 7 additions & 23 deletions scripts/automation/nemesis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,28 +207,9 @@ setup_turnplaying_script {
end,
adventuring = function()
if quest_text("found a map to the secret tropical island") then
result = "do tropical island"
-- wear stuff
equip_item("pirate fledges", 2)
equip_item("ring of conflict", 3)
-- adventure repeatedly
for i = 1, 100 do
-- buff up
if not have_buff("The Sonata of Sneakiness") then
cast_skillid(6015, 2) -- sonata of sneakiness
end
if not have_buff("Smooth Movements") then
cast_skillid(5017, 2) -- smooth moves
end
result, resulturl, advagain = autoadventure { zoneid = 159, macro = automation_macro }
if not advagain then
break
end
-- choice O Cap'm, My Cap'm 189
-- opt 1 Front the meat and take the wheel
-- opt 2 Step away from the helm
-- opt 3 Show the tropical island volcano lair map to the navigator
end
set_result(use_item("secret tropical island volcano lair map"))
refresh_quest()
advagain = not quest_text("found a map to the secret tropical island")
elseif quest_text("put a stop to this Nemesis nonsense") or (quest("Me and My Nemesis") and have_item("secret tropical island volcano lair map")) then
if classid() == 1 then -- seal clubber
stop "TODO: Automate seal clubber island"
Expand All @@ -252,7 +233,7 @@ setup_turnplaying_script {
-- equip weapon Greek Pasta of Peril
-- "proxy:/volcanoisland.php?pwd=a412cd1e0a0d040806269162e564fcb1&action=tniat" Nothing
-- "proxy:/volcanomaze.php?" Nothing
elseif classid() == 4 then -- sauceror
elseif playerclass("Sauceror") then -- sauceror
automate_S_nemesis_island()
elseif classid() == 5 then -- disco bandit
automate_DB_nemesis_island()
Expand Down Expand Up @@ -381,6 +362,9 @@ function automate_S_nemesis_island()
if have_buff("Slimeform") then
stop "TODO: kill nemesis"
end
if not have_item("bottle of G&uuml;-Gone") then
get_page("/volcanoisland.php", { pwd = session.pwd, action = "npc" })
end
get_page("/account.php", { action = "autoattack", whichattack = 0, ajax = 1, pwd = session.pwd }) -- unset autoattack, bleh
script.bonus_target { "easy combat" }
script.ensure_buffs {}
Expand Down
17 changes: 10 additions & 7 deletions scripts/automation/scripts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1590,8 +1590,6 @@ function get_automation_scripts(cached_stuff)
local wear = f.wear

function f.pick_up_sr()
print " checking for SR"

local ls = ascension["last semirare"] or {}
local lastsemi = ls.encounter
local lastturn = ls.turn
Expand Down Expand Up @@ -1631,13 +1629,9 @@ endif
script.wear {}
stop "Pick up semirare in Boris"
end
if lastturn and lastturn + 250 < turnsthisrun() then
-- critical "Last semirare was a long time ago"
return
end
print("pick up SR, last semi", lastsemi, lastturn)
wear {}
if (not lastsemi and not lastturn and turnsthisrun() < 85) or (lastsemi ~= "In the Still of the Alley") then
if lastsemi ~= "In the Still of the Alley" then
inform "Pick up SR, make it wines"
result, resulturl, advagain = autoadventure { zoneid = 112, ignorewarnings = true }
if get_result():contains("In the Still of the Alley") then
Expand Down Expand Up @@ -4930,6 +4924,15 @@ function handle_adventure_result(pt, url, zoneid, macro, noncombatchoices, speci
if optname and not pickchoice then
print("ERROR: option " .. tostring(optname) .. " not found for " .. tostring(adventure_title) .. ".")
end
if not pickchoice then
local possiblities = {}
for nr in pt:gmatch([[<input type=hidden name=option value=([0-9])>]]) do
table.insert(possibilities, tonumber(nr))
end
if possibilities[1] and not possibilities[2] then
pickchoice = possibilities[1]
end
end
if pickchoice then
local pt, url = post_page("/choice.php", { pwd = session.pwd, whichchoice = choice_adventure_number, option = pickchoice })
-- print("choice ->", url)
Expand Down
44 changes: 20 additions & 24 deletions scripts/automation/seahorse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,25 @@ function automate_sea_find_castle()
}
end

function automate_sea_find_big_brother()
script.bonus_target { "noncombat" }
script.wear {
hat = first_wearable { not expertly_trained() and "sea cowboy hat" or nil, "Mer-kin sneakmask" },
local function get_exploration_outfit()
local towear = {
hat = first_wearable { "Mer-kin sneakmask" },
back = first_wearable { "old SCUBA tank" },
shirt = first_wearable { "sea salt scrubs" },
pants = first_wearable { not expertly_trained() and "sea chaps" or nil },
acc1 = "makeshift SCUBA gear",
}
if not expertly_trained() then
towear.hat = "sea cowboy hat"
towear.pants = "sea chaps"
end
if not have_item("old SCUBA tank") then
towear.hat = first_wearable { "Mer-kin scholar mask", "Mer-kin gladiator mask", "aerated diving helmet" }
end
return towear
end

function automate_sea_find_big_brother()
script.bonus_target { "noncombat" }
script.wear(get_exploration_outfit())
set_result(get_page("/monkeycastle.php"))
if get_result():contains("who=2") or not get_result():contains("littlebrother") then
set_result(async_get_page("/monkeycastle.php", { who = 1 }))
Expand All @@ -159,12 +170,7 @@ end

function automate_sea_find_grandpa()
script.bonus_target { "noncombat" }
script.wear {
hat = first_wearable { not expertly_trained() and "sea cowboy hat" or nil, "Mer-kin sneakmask" },
shirt = first_wearable { "sea salt scrubs" },
pants = first_wearable { not expertly_trained() and "sea chaps" or nil },
acc1 = "makeshift SCUBA gear",
}
script.wear(get_exploration_outfit())
set_result(get_page("/monkeycastle.php"))
if get_result():contains("who=3") or not get_result():contains("brothers") then
set_result(async_get_page("/monkeycastle.php", { who = 1 }))
Expand Down Expand Up @@ -224,12 +230,7 @@ function automate_sea_find_currents()

if have_item("Mer-kin lockkey") then
script.bonus_target { "noncombat" }
script.wear {
hat = first_wearable { not expertly_trained() and "sea cowboy hat" or nil, "Mer-kin sneakmask" },
shirt = first_wearable { "sea salt scrubs" },
pants = first_wearable { not expertly_trained() and "sea chaps" or nil },
acc1 = "makeshift SCUBA gear",
}
script.wear(get_exploration_outfit())
script.ensure_buffs { "Spirit of Garlic", "Fat Leon's Phat Loot Lyric", "Ghostly Shell", "Astral Shell", "Leash of Linguini", "Empathy", "Smooth Movements", "The Sonata of Sneakiness" }
script.heal_up()
script.ensure_mp(100)
Expand Down Expand Up @@ -287,12 +288,7 @@ function automate_sea_tame_seahorse()

if not expertly_trained() then
script.bonus_target { "item" }
script.wear {
hat = "sea cowboy hat",
shirt = first_wearable { "sea salt scrubs" },
pants = "sea chaps",
acc1 = "makeshift SCUBA gear",
}
script.wear(get_exploration_outfit())
script.ensure_buffs { "Spirit of Garlic", "Fat Leon's Phat Loot Lyric", "Ghostly Shell", "Astral Shell", "Leash of Linguini", "Empathy", "Donho's Bubbly Ballad" }
script.heal_up()
script.ensure_mp(100)
Expand Down
Loading

0 comments on commit eb220cc

Please sign in to comment.