Switch branches/tags
abyssal-overworld abyssrun adamant adrenaline_rush all_bits altarstats aphorism146 ashtier aspirants avg_hp_extended avg_hp_numeric balefularc basajaun bearkin bonerider boriscaling bosch boulder catlobe chaoscrawl charms-reform cia-name-fullemail city-connection cloud-overlays cloud_gen console-polearm container contrib-updates-in-progress contribguide councilgod crawl-map-inheritance crypt-tiles cup-of-charity cyc datafiles dazzling_ghosts ddredheal debian-trunk demigods des_load destruction devtest diffusion distortionbolt door_items_solidity door_items dpegs_dynamic_monsters ds_trade_offs earthspells eatingprompt effect-timer elf-vaults enslaved-monster-parsing evoker-playstyle evokers faith_and_reason faithful fancyhell farmer fedhas_decay firewalk flags flatweap floodkiller food-time food-unification forest_wyrm forest forge_dwarves frenzy frogs fsim_acgdrev gammafunk-patch-1 gauntlet gcc_cxx_assert gdr ghost_fixes gitorious-merge-requests/2 gitorious-merge-requests/3 gitorious-merge-requests/4 gitorious-merge-requests/5 gitorious-merge-requests/6 gitorious-merge-requests/7 gitorious-merge-requests/8 gitorious-merge-requests/9 gitorious-merge-requests/10 gitorious-merge-requests/11 gitorious-merge-requests/12 gitorious-merge-requests/13 gitorious-merge-requests/14 gitorious-merge-requests/16 gitorious-merge-requests/17 gitorious-merge-requests/18 gitorious-merge-requests/20 gitorious-merge-requests/21 gitorious-merge-requests/22 gitorious-merge-requests/23 gitorious-merge-requests/24 gitorious-merge-requests/25 gitorious-merge-requests/26 gitorious-merge-requests/27 gitorious-merge-requests/28 gitorious-merge-requests/29 gitorious-merge-requests/30 gitorious-merge-requests/31 gitorious-merge-requests/32 gnoll goldify-books graceful_shutdown halftone harpoon header_simplification hell-effect-end hexcrawl hohoho hotspot imp instapickupdrop insulation koboldcultist labrework laplace layout lighting_form lobster-trap marksperson master melee_linear_damage meleemoves merc-shops mons-gods monsterspelldesc more-xv-resists move-to-trap movement-behaviours movespeed msvc2012 mulch_ado_about_nothing multisprint mutation_cleanup myrmec myrmecia new-layouts new-tree-tiles new_nemelex new_squarelos newdolls newgame-menus nfm-bondage-compat nfm-cast-light nimble-hulk no-crawl-ref no_backtracking_god no_item_transit nomes nospawn nostalgia notzombiehands numpad-fix oubliette panlord-info parareform plutonians polypotion pr-599 pr554 pretty_shiny_sparkles props pubby_swamp race_reordering randbook-rare-spells randeffects_malmutate randfood random-choose-weighted-double randon-choose-weighted-lambda ranged_reform rc-control reaver remove_chance_breaks require_rename resize ruin_everything safer-bitfield salamander sanitize_inscripts savefile sdl-2.0.7 seen-test segfault-debug sewer-water-tiles shard shrapnel simple_yesno simpleclouds simplesif sixtytwo slowokhle small_dwarves smithgod_rebased smithgod snake-enemies spell-sources spellres spiderstuff sponcor spooky_cleanup squarelos statlockgnolls steamblast stone_soup-0.1.3 stone_soup-0.1.4 stone_soup-0.1.5 stone_soup-0.1.6 stone_soup-0.1.7 stone_soup-0.2 stone_soup-0.3 stone_soup-0.4 stone_soup-0.5 stone_soup-0.6 stone_soup-0.7 stone_soup-0.8 stone_soup-0.9 stone_soup-0.10 stone_soup-0.11 stone_soup-0.12 stone_soup-0.13 stone_soup-0.14 stone_soup-0.15 stone_soup-0.16 stone_soup-0.17 stone_soup-0.18 stone_soup-0.19 stone_soup-0.20 stone_soup-0.21 stone_soup-0.22 stone_soup stream-drakes taunt thaw thinskin thorn_god tileschat-mute tombhatch tornado4 transporter travis-cc travis-test travis tutorial_kiss ugliness ungendered uniq.seen vehumet_spells wand_merging wand_stacking wandcharges water-beetle webtiles-changes-bsr webtiles-changes-score webtiles-changes webtiles-mouse-control webtiles-options webtiles-unicode willitblend win32-backtrace wip-coloured-FAQ wip-corpse_name wip-ring-jiyva wip-simulacra-tiles wip-splash-logo wizlab_changes zin-mutation zombieform
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
124 lines (100 sloc) 5.43 KB
Written by Cerol, 2017/02/07
Backgrounds are one of the simplest gameplay elements to modify in the DCSS
codebase, as they only really determine things at character creation. Within the
code itself, they're usually referred to as jobs, not backgrounds, so I'll be
using these terms interchangeably. There's no code that checks for your starting
job later on, they just boost your stats a little and supply you with your
starting gear. I'll write up how to add a new background to the game here.
Note that this is meant to be a technical explanation of how to do this, and not
a game design discussion. Everything being implemented isn't meant to be a
serious addition to the game, just an example of how to add your own ideas.
We're going to add in a Shepherd job today. I feel there's a lack of peaceful,
relaxing jobs in the game, so we'll fill that space with our new job.
First we need to edit enum.h to tell the game our new job exists. Search for
"enum job_type", and we'll add in an entry right before the NUM_JOBS line.
This should look like:
NUM_JOBS, // always after the last job
Two side-notes here. First, you'll see that TAG_MAJOR_VERSION thing all over the
code base. Don't bother adding it in yourself. It's mostly used as shorthand to
mark code that isn't being used or could be removed. Second, the NUM_JOBS entry
in the enum list is a special value used pretty often in the codebase. Make sure
your new entry is right above NUM_JOBS for save compatibility reasons. Changing
the list in any other way might cause saved characters to change jobs mid-game
or throw errors later.
Second, we need to add the actual data for the background. For this, we go into
job-data.h. This struct in this file is reasonably well-explained:
struct job_def
const char* abbrev; ///< Two-letter abbreviation
const char* name; ///< Long name
int s, i, d; ///< Starting Str, int, and Dex
vector<species_type> recommended_species; ///< Which species are good at it
/// Guaranteed starting equipment. Uses vault spec syntax, with the plus:,
/// charges:, q:, and ego: tags supported.
vector<string> equipment;
weapon_choice wchoice; ///< how the weapon is chosen, if any
vector<pair<skill_type, int>> skills; ///< starting skills
The best thing to do is to copy an existing class and edit it's entries, just
to make sure you get the structure right. Also note that this file sorts the
entries alphabetically, so we'll follow suit here. Let's fill in our typical
// First, the basics:
"Sh", "Shepherd",
// Fieldwork keeps shepherds in good shape, and gives them lots of
// time to think.
12, 11, 12,
// Most shepherds are common folk.
// They should have a light breezy garment, something to read to
// pass the time, and a staff to protect their flock
{ "gold dragon scales plus:9", "book of the Dragon",
"greatsword plus:9 ego:flaming" },
// and just a couple skill points in stuff you might do around a field.
{ SK_DODGING, 3 }, {SK_ARMOR, 4} { SK_STEALTH, 1 }, },
} },
That looks like what I expect a shepherd to look like: lightly armed, lightly
armored, and just a speck of potential. Other bits of code will ensure any
weapons and armor are automatically equipped at creation (but not staves or
other equippables!).
If you skip one of the above steps, you'll hit an ASSERT error after running
the game. This is the typical way DCSS handles errors: Check for things that
shouldn't be and crash early with a clear message instead of crashing later
with a cryptic code dump.
The last step is to add it to the start-up menu. This is handled in,
and we need to edit the jobs_order[] array to add ours in. I think Shepherds
count as a Adventurer, so I'll update the entry for them:
coord_def(0, 7), 15,
And we're done. Compile and enjoy your new background!
... Unless your background has some other, more complicated starting situation
the way that Abyssal Knights and Chaos Knights do. Those can be set
in If you have some limitations or restrictions on your job (like
locking out a species for some reason, or if a piece of gear would be limited by
some racial element), you can add those checks into Finally,
the only other job-related special case is the Monk, which gets its piety
bonus handled in
Wanderers are special, and get their own file. There are 7 total files that
backgrounds touch on for their stuff right now. In most cases you should
only have to edit 3.
Summary and checklist:
- enum.h to add the background to the list
- job-data.h to fill in info about the job.
- to add it to the selection menu.
- for any factors you can't set in the job struct.
(and/or if you're messing with piety after character
creation like the monk.)
- for limitations to your background.
- for wanderer nonsense.