#include "enemies.h" #include "constants.h" #include "enemies/dragon.h" #include "enemies/dwarf.h" #include "enemies/elf.h" #include "enemies/halfling.h" #include "enemies/human.h" #include "enemies/merchant.h" #include "enemies/orc.h" void new_dragon(RNG *rng, std::unique_ptr &p, const position &pos, const position &fallback, const feature enabled_features, int which_room) { const position nil{0, 0}; if (pos != nil) p = std::make_unique(rng, enabled_features, pos, which_room); else p = std::make_unique(rng, enabled_features, fallback, which_room); } const int EXCNT = 6; const race EXCHOICES[EXCNT] = { rhuman, rdwarf, rhalfling, relf, rorc, rmerchant }; const int CNT = 18; const race CHOICES[CNT] = { rhuman, rhuman, rhuman, rhuman, rdwarf, rdwarf, rdwarf, rhalfling, rhalfling, rhalfling, rhalfling, rhalfling, relf, relf, rorc, rorc, rmerchant, rmerchant }; enum race get_extra_race(RNG *rng) { return EXCHOICES[rng->rand_under(EXCNT)]; } enum race get_normal_race(RNG *rng) { return CHOICES[rng->rand_under(CNT)]; } void new_enemy(RNG *rng, std::unique_ptr &p, const position &pos, const feature enabled_features, int which_room) { using std::make_unique; enum race r; if (enabled_features & FEATURE_EXTRA_STUFF) r = get_extra_race(rng); else r = get_normal_race(rng); p = nullptr; switch (r) { case rdwarf: p = make_unique(rng, enabled_features, pos, which_room); break; case rhuman: p = make_unique(rng, enabled_features, pos, which_room); break; case relf: p = make_unique(rng, enabled_features, pos, which_room); break; case rorc: p = make_unique(rng, enabled_features, pos, which_room); break; case rmerchant: p = make_unique(rng, enabled_features, pos, which_room); break; case rhalfling: p = make_unique(rng, enabled_features, pos, which_room); break; default: break; } }