Abyss Ambulator
Posts: 1217
Joined: Sunday, 14th April 2013, 04:01
Quick species coding guide
Note that I haven't actually contributed any code to this game, but I thought this might be useful as an organization tool:
MAKING A NEW SPECIES:
This guide was written primarily by doing the following things:
1. Looking at what files affect how Minotaurs work, as a fairly regular baseline
2. Looking at what files affect how Felids work, as a data point for an insane species
3. Looking at what files affect how Demonspawn work, as a data point for a fairly complex species
I may have missed a few tiny things, but this should be VERY thorough.
BASICS OF ORGANIZATION:
A very sloppy way to describe how C++ is organized:
There are two types of files: header files (.h) and C++ files (.cc)
Typically, header files are a road map to a .cc file: A good, though sometimes inaccurate description is that header files describe WHAT a file will do, and a .cc file describes HOW it will do it
For example, acquire.h describes two functions: their names, their parameters, and what they return. But, it says nothing about how they work
All of that data is in acquire.cc
Sometimes, header files don't have a matching .cc file. This is often the case when they just contain data to be referenced later.
For example, aptitudes.h doesn't have an aptitudes.cc. It simply contains the data with all the species aptitudes.
Another important concept is that of an enum. Enums define a collection of names that never change that are used to reference something (For example, SP_MINOTAUR is used to say "This player is a minotaur")
GETTING STARTED:
Create the SP_FOO entry in enum.h
Set the aptitudes in aptitudes.h
Now look at species.cc. You'll return here for a few things, but for now, set the following:
species order: static species_type species_order[], line 11
species abbreviation: static const char * Species_Abbrev_List[NUM_SPECIES], line 52
species name: string species_name(species_type speci, bool genus, bool adj), line 126
species size: size_type species_size(species_type species, size_part_type psize), line 372
exp modifier: int species_exp_modifier(species_type species), line 544
HP modifier: int species_hp_modifier(species_type species), line 599
MP modifier: int species_mp_modifier(species_type species), line 651
Set starting stats and mutations in ng-setup.cc:
stats: static void _species_stat_init(species_type which_species), line 40
mutations: void give_basic_mutations(species_type speci), line 214
Mutation.cc and output.cc handle how mutations are displayed:
mutation.cc: string describe_mutations(bool center_title), line 319
output.cc: static string _status_mut_abilities(int sw), line 2576 //Warning: more technical
Set the recommended items and jobs in ng-restr.cc
UNRESTRICTED means recommended, RESTRICTED means not recommended, and BANNED means not allowed
The final bunch of major initial settings are in player.cc
Wearable items: bool you_can_wear(int eq, bool special_armour), line 684
Stat gains per level: void level_change(bool skip_attribute_increase), line 2911
Stealth modifier: static int _species_stealth_mod(), line 3522
Is unholy/undead: bool player::undead_or_demonic() const, line 6552
More technical:
Here's a bunch of little random details. Search for SP_FELID and SP_DEMONSPAWN to get a grasp on functionality
acquire.cc: allowed acquirement items, aka, screw felids. Also in dungeon.cc (line 4389)
attack.cc: special attack messages such as felid pouncing
describe.cc:
Print list of actions (for instance, felid's don't get a quiver option): static bool _actions_prompt(item_def &item, bool allow_inscribe, bool do_prompt), line 2336
Weird ghost description stuff: string get_ghost_description(const monster_info &mi, bool concise), line 4178
godabil.cc, godpassive.cc, godprayer.cc: handles god special cases. Gozag shops, Ru sacrifice weighting, Ash's passive, prayer messages
hints.cc: things like "Note that as a minotaur you will be unable to wear helmets"
invent.cc: handles inventory wielding restrictions, but NOT armour wearing, which is in item_use.cc
itenname.cc: handles item colorization aka whether an item is useless or not
main.cc: some special messages such as felids trying to remove nonexistent armour
melee_attack.cc: Includes aux attacks, constriction, and special cases such as minotaur retaliation. Also handles stab class for things like felid claws
mutation.cc: handles checks such as mutation restrictions (scales on a DS who already has scales for instance)
ng-wanderer.cc: starting items and skills
player.cc: Handles felid extra lives, new mutations, draconian transformations, and other level dependent changes
Weird little things such as player_has_feet(bool temp) (line 823), can_throw_large_rocks() (line 7827), can_smell() (line 7832),
player-act.cc: Checks if a species can wield a weapon and displays special descriptions such as felid paw unarmed attack
quiver.cc: stupid felids
religion.cc: felid weapon gifts
spl-book.cc, spl-util.cc: useless spells, aka, felids can't brand, mummy's can't transform
transform.cc: some description tweaks for things like blade hands as felids and octopodes.
- For this message the author TeshiAlair has received thanks: 11
- and into, Brannock, chequers, dolphin, guyht, Hirsch I, Mandragora, Neon, rockygargoyle, Sprucery and one more user