13 std::map<std::string, std::vector<std::string> >
addToRace;
14 std::map<std::string, std::vector<object *> >
races;
23 auto r =
races.find(race);
24 if (r ==
races.end()) {
25 LOG(
llevError,
"races_get_random_monster: requested non-existent aligned race %s!\n", race);
29 std::vector<object *> valid;
30 for (
auto it = (*r).second.begin(); it != (*r).second.end(); it++) {
31 if ((*it)->level <= level) {
38 return valid[
rndm(0, valid.size() - 1)];
57 if (sscanf(cp,
"RACE %s", variable)) {
58 strcpy(race, variable);
63 for (cp1 = cp; *cp1 ==
' '; cp1++)
66 for (cp1 = cp+strlen(cp)-1; *cp1 ==
' '; cp1--) {
82 for (
auto race =
races.cbegin(); race !=
races.cend(); race++) {
83 fprintf(stderr,
"\nRACE %s:\t", (*race).first.c_str());
84 for (
auto mon = (*race).second.cbegin(); mon != (*race).second.cend(); mon++) {
85 fprintf(stderr,
"%s (%d), ", (*mon)->arch->name, (*mon)->level);
100 for (
const auto& name : add.second) {
103 races[add.first].push_back(&mon->clone);
105 LOG(
llevError,
"races: %s %s\n", name.c_str(), mon ?
"is not a monster" :
"does not exist");
object * races_get_random_monster(const char *race, int level)
Get a random monster of specified race and level at most the specified one.
void dump_races(void)
Dumps all race information to stderr.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int rndm(int min, int max)
Returns a number between min and max.
std::map< std::string, std::vector< std::string > > addToRace
Global type definitions and header inclusions.
AssetsManager * getManager()
#define QUERY_FLAG(xyz, p)
Archetypes * archetypes()
Get archetypes.
void load_races(BufferReader *reader, const char *)
Reads the races file in the lib/ directory, then overwrites old 'race' entries.
#define MAX_BUF
Used for all kinds of things.
Compatibility implementations of useful nonstandard types and functions.
void free_races(void)
Frees all race-related information.
std::map< std::string, std::vector< object * > > races
Only for debugging purposes.
T * find(const Key &name)
Get a named asset if it exists.
#define FLAG_MONSTER
Will attack players.
C function wrappers to interact with assets.
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.