##### Crawl Init file ############################################### # For descriptions of all options, as well as some more in-depth information # on setting them, consult the file # options_guide.txt # in your /docs directory. If you can't find it, the file is also available # online at: # https://github.com/crawl/crawl/blob/master/crawl-ref/docs/options_guide.txt # # Crawl uses the first file of the following list as its option file: # * init.txt in the -rcdir directory (if specified) # * .crawlrc in the -rcdir directory (if specified) # * init.txt (in the Crawl directory) # * ~/.crawl/init.txt (Unix only) # * ~/.crawlrc (Unix only) # * ~/init.txt (Unix only) # * settings/init.txt (in the Crawl directory) ##### Some basic explanation of option syntax ####################### # Lines beginning with '#' are comments. The basic syntax is: # # field = value or field.subfield = value # # Only one specification is allowed per line. # # The terms are typically case-insensitive except in the fairly obvious # cases (the character's name and specifying files or directories when # on a system that has case-sensitive filenames). # # White space is stripped from the beginning and end of the line, as # well as immediately before and after the '='. If the option allows # multiple comma/semicolon-separated terms (such as # autopickup_exceptions), all whitespace around the separator is also # trimmed. All other whitespace is left intact. # # There are three broad types of Crawl options: true/false values (booleans), # arbitrary values, and lists of values. The first two types use only the # simple =, with later options - which includes your options that are different # from the defaults - overriding earlier ones. List options allow using +=, ^=, # -=, and = to append, prepend, remove, and reset, respectively. Usually you will # want to use += to add to a list option. Lastly, there is := which you can use # to create an alias, like so: # ae := autopickup_exceptions # From there on, 'ae' will be treated as if it you typed autopickup_exceptions, # so you can save time typing it. # ##### Other files ################################################### # You can include other files from your options file using the 'include' # option. Crawl will treat it as if you copied the whole text of that file # into your options file in that spot. You can uncomment some of the following # lines by removing the beginning '#' to include some of the other files in # this folder. # Some useful, more advanced options, implemented in LUA. # include = advanced_optioneering.txt # Alternative vi bindings for Dvorak users. # include = dvorak_command_keys.txt # Alternative vi bindings for Colemak users. # include = colemak_command_keys.txt # Alternative vi bindings for Neo users. # include = neo_command_keys.txt # Override the vi movement keys with a non-command. # include = no_vi_command_keys.txt # Turn the shift-vi keys into safe move, instead of run. # include = safe_move_shift.txt { ----------------------------- ---- Begin char_defaults ---- ----------------------------- -- See README.md for documentation. weapon_skills = { "Maces & Flails", "Axes", "Polearms", "Staves", "Unarmed Combat", "Short Blades", "Long Blades" } ranged_skills = { "Throwing", "Ranged Weapons" } other_skills = { "Fighting", "Armour", "Dodging", "Shields", "Stealth", "Spellcasting", "Conjurations", "Hexes", "Summonings", "Necromancy", "Translocations", "Alchemy", "Fire Magic", "Ice Magic", "Air Magic", "Earth Magic", "Invocations", "Evocations", "Shapeshifting" } skill_glyphs = { [1] = "+", [2] = "*" } chdat = nil char_combo = you.race() .. you.class() loaded_attempted = false -- Wrapper of crawl.mpr() that prints text in white by default. if not mpr then mpr = function (msg, color) if not color then color = "white" end crawl.mpr("<" .. color .. ">" .. msg .. "") end end function skill_message(prefix, skill, skill_type, value, target) local msg = "" if prefix then msg = prefix .. ";" end if skill_type then msg = msg .. skill_type .. "(" .. skill .. "):" .. value .. "," .. target else msg = msg .. skill .. ":" .. value .. "," .. target end return msg end function save_char_defaults(quiet) if you.class() == "Wanderer" then return end if not c_persist.char_defaults then c_persist.char_defaults = { } end c_persist.char_defaults[char_combo] = { } chdat = c_persist.char_defaults[char_combo] local msg = nil local have_weapon = false for _,sk in ipairs(weapon_skills) do if you.train_skill(sk) > 0 then chdat["Weapon"] = { level = you.train_skill(sk), target = you.get_training_target(sk) } msg = skill_message(nil, sk, "Weapon", skill_glyphs[chdat["Weapon"].level], chdat["Weapon"].target) have_weapon = true break end end if not have_weapon then chdat["Weapon"] = nil end local have_ranged = false for _,sk in ipairs(ranged_skills) do if you.train_skill(sk) > 0 then chdat["Ranged"] = { level = you.train_skill(sk), target = you.get_training_target(sk) } msg = skill_message(msg, sk, "Ranged", skill_glyphs[chdat["Ranged"].level], chdat["Ranged"].target) have_ranged = true break end end if not have_ranged then chdat["Ranged"] = nil end for _,sk in ipairs(other_skills) do if you.train_skill(sk) > 0 then chdat[sk] = { level = you.train_skill(sk), target = you.get_training_target(sk) } msg = skill_message(msg, sk, nil, skill_glyphs[chdat[sk].level], chdat[sk].target) else chdat[sk] = nil end end if not quiet then mpr("Saved default for " .. char_combo .. ": " .. msg) end end function have_defaults() return you.class() ~= "Wanderer" and c_persist.char_defaults ~= nil and c_persist.char_defaults[char_combo] ~= nil end function load_char_defaults(quiet) if not have_defaults() then return end local msg = nil local found_weapon = false chdat = c_persist.char_defaults[char_combo] for _,sk in ipairs(weapon_skills) do if you.base_skill(sk) > 0 and chdat["Weapon"] and chdat["Weapon"].level and chdat["Weapon"].target then you.train_skill(sk, chdat["Weapon"].level) you.set_training_target(sk, chdat["Weapon"].target) msg = skill_message(msg, sk, "Weapon", skill_glyphs[chdat["Weapon"].level], chdat["Weapon"].target) found_weapon = true else you.train_skill(sk, 0) end end if chdat["Weapon"] and chdat["Weapon"].level and chdat["Weapon"].target and not found_weapon then you.train_skill("Unarmed Combat", chdat["Weapon"].level) you.set_training_target("Unarmed Combat", chdat["Weapon"].target) msg = skill_message(msg, "Unarmed Combat", "Weapon", skill_glyphs[chdat["Weapon"].level], chdat["Weapon"].target) end local found_ranged = false for _,sk in ipairs(ranged_skills) do if you.base_skill(sk) > 0 and chdat["Ranged"] and chdat["Ranged"].level and chdat["Ranged"].target then you.train_skill(sk, chdat["Ranged"].level) you.set_training_target(sk, chdat["Ranged"].target) msg = skill_message(msg, sk, "Ranged", skill_glyphs[chdat["Ranged"].level], chdat["Ranged"].target) found_ranged = true else you.train_skill(sk, 0) end end if chdat["Ranged"] and chdat["Ranged"].level and chdat["Ranged"].target and not found_ranged then you.train_skill("Throwing", chdat["Ranged"].level) msg = skill_message(msg, "Throwing", "Ranged", skill_glyphs[chdat["Ranged"].level], chdat["Ranged"].target) end for _,sk in ipairs(other_skills) do if chdat[sk] and chdat[sk].level and chdat[sk].target then you.train_skill(sk, chdat[sk].level) you.set_training_target(sk, chdat[sk].target) msg = skill_message(msg, sk, nil, skill_glyphs[chdat[sk].level], chdat[sk].target) else you.train_skill(sk, 0) end end if not quiet and msg ~= "" then mpr("Loaded default for " .. char_combo .. ": " .. msg) end end function char_defaults(quiet) if you.turns() ~= 0 then return end if not load_attempted then load_char_defaults(quiet) load_attempted = true -- Open the skill menu if we don't have settings to load. if not have_defaults() then crawl.sendkeys("m") end end end --------------------------- ---- End char_defaults ---- --------------------------- } { function ready() -- Enable character defaults char_defaults() end } # Save character defaults macros += M _ ===save_char_defaults