## References
# http://crawl.akrasiac.org/docs/options_guide.txt
# http://doc.dcss.io/modules/you.html
# https://crawl.develz.org/wiki/doku.php?id=dcss:help:maps:lua:modules:you:start
########### CWZ Settings ###########
#$ lab_magic_window_translate = false
#$ lab_skill_window_translate = false
#$ lab_interface_translate = false
#$ lab_ability_window_translate = false
#$ lab_apply_font = false
#$ lab_transfer_chat_ingame = true
#$ lab_hide_chat_control = true
#$ lab_disable_mouse_move = true
#$ lab_sound_on = true
#$ lab_disable_chat_clear = true
#$ lab_gold_status = true
sound_on = true
sound_pack += https://osp.nemelex.cards/build/latest.zip:["init.txt"]
one_SDL_sound_channel = true
sound_fade_time = 0.5
sound_volume = 1.0
##### Dependency #####
include += Options1.rc
include += FormChange.rc
include += SpeedrunRest1.rc
include += HDATravel1.rc
include += HDAColor1.rc
: user_name = "ervpinj"
:if is_included_SpeedrunRest1 then
macros += M 5 5
:else
macros += M 5 5
:end
:if is_included_HDATravel1 then
macros += M o ===HDAtravel
macros += M + ===HDAtravel
macros += M \{-1016} ===HDAtravel
:else
macros += M o o
macros += M + o
macros += M \{-1016} o
:end
######################
{
function ready()
if is_included_FormChange then
FormChange()
end
if is_included_SpeedrunRest1 then
speedrun_rest()
end
OpenSkills()
TrainSkills()
PetrifyingCheck()
hp_percent()
mp_percent()
AnnounceDamage()
Vehumetoffer()
Ruoffer()
DDoorWarning()
DDoorCounter()
hpWarning_Early()
hpWarning_Mid()
hpWarning_Late()
XLCheckOptions_Early()
XLCheckOptions_Mid()
XLCheckOptions_Late()
end
}
{
local early = true
function XLCheckOptions_Early()
if you.xl() >= 8 and early then
early = false
end
end
}
{
local mid = true
function XLCheckOptions_Mid()
if you.xl() >= 14 and mid then
crawl.setopt("force_more_message -= opens the")
crawl.setopt("force_more_message -= comes? into view")
crawl.setopt("flash_screen_message -= carrying a wand of (acid|scatter|cloud|disintegration|iceblast)")
crawl.setopt("flash_screen_message -= wielding.* (distortion|chaos|electrocution).* comes? into view")
crawl.setopt("autopickup_exceptions ^= >boomerang")
crawl.setopt("autopickup_exceptions ^= >javelin")
crawl.setopt("autopickup_exceptions ^= >poisoned dart")
crawl.setopt("autopickup_exceptions ^= >curare")
crawl.setopt("autopickup_exceptions ^= >ring of (protection from (mag|fire|cold)|fli|mag|stealth|ice|fire|pois|wiz|int|str|dex|slay|eva|pos|prot|resi|see)")
crawl.setopt("autopickup_exceptions ^= >staff of (air|cold|conj|dea|ear|ene|fire|pois|pow|sum|wiz)")
crawl.setopt("autopickup_exceptions ^= >amulet of (reflect|faith|harm|magic|guard|rage|regene)")
crawl.setopt("autopickup_exceptions ^= >amulet of the (acrobat|gourmand)")
crawl.setopt("autopickup_exceptions ^= >potions? of (ligni|berserk rage)")
crawl.setopt("autopickup_exceptions ^= >wand.*(random|flame|polymorph|disintegration|iceblast)")
crawl.setopt("autopickup_exceptions ^= >(lightning rod|lamp of fire|phial of flood|crystal ball|fan of gales)")
crawl.setopt("autopickup_exceptions ^= >shield")
if you.race() == "Vampire" then
if you.class() == "Arcane Marksman" then
crawl.setopt("autopickup_exceptions ^= >bolts")
end
end
mid = false
end
end
}
{
local late = true
function XLCheckOptions_Late()
if you.xl() == 27 and late then
if (not (you.god() == "Gozag" or you.god() == "Zin")) then
crawl.setopt("autopickup_exceptions ^= >gold pieces")
end
crawl.setopt("autopickup_exceptions ^= >scrolls? of summoning")
crawl.setopt("autopickup_exceptions ^= >scrolls? of silence")
crawl.setopt("autopickup_exceptions ^= >wand of clouds")
late = false
end
end
}
{
local trainSkill = true
function TrainSkills()
if you.turns() == 0 and trainSkill then
you.set_training_target ("Spellcasting", 3)
you.set_training_target ("Conjurations", 3)
you.set_training_target ("Hexes", 3)
you.set_training_target ("Summonings", 3)
you.set_training_target ("Necromancy", 3)
you.set_training_target ("Translocations", 3)
you.set_training_target ("Transmutations", 3)
you.set_training_target ("Fire Magic", 3)
you.set_training_target ("Ice Magic", 3)
you.set_training_target ("Air Magic", 3)
you.set_training_target ("Earth Magic", 3)
you.set_training_target ("Armour", 3)
you.set_training_target ("Shields", 4)
you.set_training_target ("Throwing", 6)
you.set_training_target ("Evocations", 5)
if you.race() == "Minotaur" then
if you.class() == "Fighter" then
you.train_skill("Fighting", 1)
you.train_skill("Axes", 2)
you.train_skill("Armour", 1)
you.train_skill("Shields", 1)
you.set_training_target ("Fighting", 15)
you.set_training_target ("Axes", 18)
you.set_training_target ("Armour", 15)
you.set_training_target ("Shields", 15)
you.set_training_target ("Throwing", 16)
end
end
if you.race() == "Vampire" then
if you.class() == "Hexslinger" then
you.train_skill("Fighting", 2)
you.train_skill("Ranged Weapons", 0)
you.train_skill("Dodging", 0)
you.train_skill("Stealth", 1)
you.train_skill("Spellcasting", 1)
you.train_skill("Hexes", 1)
you.train_skill("Fire Magic", 0)
you.set_training_target ("Fighting", 2)
you.set_training_target ("Stealth", 3)
you.set_training_target ("Spellcasting", 3.5)
you.set_training_target ("Hexes", 7)
end
end
trainSkill = false
end
end
}
{
function PetrifyingCheck()
if you.petrifying() then
crawl.yesno("You are now petrifying so your action will be checked. (Y or N to confirm.)", false, false, true, true)
end
end
}
{
function hp_percent()
a,b=you.hp() return 100*a/b
end
}
{
function mp_percent()
a,b=you.mp() return 100*a/b
end
}
{
local need_skills_opened = true
function OpenSkills()
if you.turns() == 0 and need_skills_opened then
need_skills_opened = false
crawl.sendkeys("m!")
end
end
}
{
local early = true
function hpWarning_Early()
if you.hp() < 15 and hp_percent() < 20 and you.xl() < 9 and early then
if you.name() == user_name then
crawl.yesno("You die...", false, false, true, true)
else
crawl.yesno("The dice are ABSOLUTELY not on your side......", false, false, true, true)
end
early = false
end
if you.hp() >= 15 and hp_percent() >= 20 and you.xl() < 9 then
early = true
end
end
}
{
local mid = true
function hpWarning_Mid()
if you.hp() < 30 and you.xl() < 27 and you.xl() >= 9 and mid then
if you.name() == user_name then
crawl.yesno("You die...", false, false, true, true)
else
crawl.yesno("Consider to using tele/blink, potion or other emergency measures......", false, false, true, true)
end
mid = false
end
if you.hp() >= 30 and you.xl() < 27 and you.xl() >= 9 then
mid = true
end
end
}
{
local late = true
function hpWarning_Late()
if you.hp() < 50 and you.xl() == 27 and not you.status("death's door") and not you.status("death's door (expiring)") and late then
if you.name() == user_name then
crawl.yesno("You die...", false, false, true, true)
else
crawl.yesno("Keep playing prudently even on late-game......", false, false, true, true)
end
late = false
end
if you.hp() >= 50 and you.xl() == 27 then
late = true
end
end
}
{
local veh = true
function Vehumetoffer()
if string.find(crawl.messages(4), "Vehumet offers") and veh then
veh = false
crawl.yesno("Vehumet offers a spell for you! (Y or N to confirm.)", false, false, true, true)
end
if string.find(crawl.messages(4), "Vehumet accepts") then
veh = true
end
end
}
{
local ru = true
function Ruoffer()
if string.find(crawl.messages(4), "Ru believes") and ru then
ru = false
crawl.yesno("Ru offers sacrifice for you! (Y or N to confirm.)", false, false, true, true)
end
if string.find(crawl.messages(6), "Ru asks you to") or string.find(crawl.messages(6), "Ru will take longer") then
ru = true
end
end
}
{
local door = true
function DDoorWarning()
if you.status("death's door (expiring)") and door then
crawl.yesno("DDoor is almost expired! (Y or N to confirm.)", false, false, true, false)
crawl.mpr("It will be ended within 5-10 turns......")
door = false
end
if not you.status("death's door (expiring)") then
door = true
end
end
}
{
local counter = you.turns()
function DDoorCounter()
if you.status("death's door (expiring)") then
crawl.mpr("Count "..you.turns() - counter.."......")
end
if not you.status("death's door (expiring)") then
counter = you.turns()+1
end
end
}
{
local previous_hp = 0
local previous_mp = 0
local previous_form = ""
local was_berserk_last_turn = false
function AnnounceDamage()
local current_hp, max_hp = you.hp()
local current_mp, max_mp = you.mp()
--Things that increase hp/mp temporarily really mess with this
local current_form = you.transform()
local you_are_berserk = you.berserk()
local max_hp_increased = false
local max_hp_decreased = false
if (current_form ~= previous_form) then
if (previous_form:find("dragon") or
previous_form:find("statue") or
previous_form:find("tree") or
previous_form:find("ice")) then
max_hp_decreased = true
elseif (current_form:find("dragon") or
current_form:find("statue") or
current_form:find("tree") or
current_form:find("ice")) then
max_hp_increased = true
end
end
if (was_berserk_last_turn and not you_are_berserk) then
max_hp_decreased = true
elseif (you_are_berserk and not was_berserk_last_turn) then
max_hp_increased = true
end
--Skips message on initializing game
if previous_hp > 0 then
local hp_difference = previous_hp - current_hp
local mp_difference = previous_mp - current_mp
if max_hp_increased or max_hp_decreased then
if max_hp_increased then
crawl.mpr("You now have " .. current_hp .. "/" .. max_hp .. " hp.")
else
crawl.mpr("You now have " .. current_hp .. "/" .. max_hp .. " hp.")
end
else
--On losing health
if (current_hp < previous_hp) then
if current_hp <= (max_hp * 0.30) then
crawl.mpr("You take " .. hp_difference .. " damage, and have " .. current_hp .. "/" .. max_hp .. " hp.")
elseif current_hp <= (max_hp * 0.50) then
crawl.mpr("You take " .. hp_difference .. " damage, and have " .. current_hp .. "/" .. max_hp .. " hp.")
elseif current_hp <= (max_hp * 0.70) then
crawl.mpr("You take " .. hp_difference .. " damage, and have " .. current_hp .. "/" .. max_hp .. " hp.")
elseif current_hp <= (max_hp * 0.90) then
crawl.mpr("You take " .. hp_difference .. " damage, and have " .. current_hp .. "/" .. max_hp .. " hp.")
else
crawl.mpr("You take " .. hp_difference .. " damage, and have " .. current_hp .. "/" .. max_hp .. " hp.")
end
end
end
end
--Set previous hp/mp and form at end of turn
previous_hp = current_hp
previous_mp = current_mp
previous_form = current_form
was_berserk_last_turn = you_are_berserk
end
}
{
add_autopickup_func(function(it, name)
local class = it.class(true)
local armour_slots = {cloak="Cloak", helmet="Helmet", gloves="Gloves", boots="Boots", body="Armour"}
if (class == "armour") then
if it.is_useless then
return false
end
sub_type = it.subtype()
equipped_item = items.equipped_at(armour_slots[sub_type])
if (sub_type == "cloak") or (sub_type == "helmet") or (sub_type == "gloves") or (sub_type == "boots") then
if not equipped_item then
return true
elseif equipped_item.artefact then
return it.artefact
else
return it.artefact or it.branded or it.ego
end
end
if (sub_type == "body armour") then
if equipped_item then
local armourname = equipped_item.name()
if equipped_item.artefact or equipped_item.branded or equipped_item.ego or (equipped_item.plus > 2) or armourname:find("dragon") or armourname:find("troll") then
return it.artefact
else
return it.artefact or it.branded or it.ego
end
end
return true
end
if travel.find_deepest_explored("D") <= 4 and you.xl() <= 9 then
return it.artefact or it.branded or it.ego
end
end
end)
}
{
function spell_init()
local spell_list = {}
for _, spell_name in ipairs(you.spells()) do
spell_list[spell_name] = true
end
return spell_list
end
spells_known = spell_init()
}
{
function c_answer_prompt(prompt)
if prompt:find("Really passwall into a travel-excluded area?") then
return true
end
if prompt:find("Really.*into that net trap?") then
if is_included_HDATravel1 and (next(getMonsterList()) == nil) then
if spells_known["Blink"] and (spells.fail("Blink") <= 30) and (you.mp()>=2) then
crawl.sendkeys("zX")
return true
else
return true
end
end
end
if (prompt:find("Really fire in your") and prompt:find("'s direction?")) or (prompt:find("Your line of fire") and (prompt:find("blocked by"))) then
spells_known = spell_init()
if spells_known["Portal Projectile"] and (spells.fail("Portal Projectile") < 15) and (you.mp()>=8) then
crawl.sendkeys("zr")
return false
end
end
if (prompt:find("Really attack near your spectral"))then
spells_known = spell_init()
if spells_known["Death Channel"] then
return false
end
end
if prompt:find("vortices") or prompt:find("vortex") or prompt:find("friend") then
return true
end
if prompt:find("That beam") and you.res_fire() == 0 and not you.status("death's door") then
if crawl.yesno("REALLY cast on yourself without fire resistance?",false,'n') then
return
end
end
if prompt == "Annotate level on other end of current stairs?" then
return false
end
if prompt == "Really go through this one-way escape hatch?" then
return true
end
if prompt == "Die?" then
return false
end
end
}