forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
npc_class.h
134 lines (99 loc) · 3.5 KB
/
npc_class.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#pragma once
#ifndef CATA_SRC_NPC_CLASS_H
#define CATA_SRC_NPC_CLASS_H
#include <functional>
#include <map>
#include <vector>
#include <string>
#include "string_id.h"
#include "translations.h"
#include "type_id.h"
class JsonObject;
using Mutation_category_tag = std::string;
class Trait_group;
namespace trait_group
{
using Trait_group_tag = string_id<Trait_group>;
} // namespace trait_group
// TODO: Move to better suited file (rng.h/.cpp?)
class distribution
{
private:
std::function<float()> generator_function;
distribution( std::function<float()> gen );
public:
distribution();
distribution( const distribution & );
float roll() const;
distribution operator+( const distribution &other ) const;
distribution operator*( const distribution &other ) const;
distribution &operator=( const distribution &other );
static distribution constant( float val );
static distribution rng_roll( int from, int to );
static distribution dice_roll( int sides, int size );
static distribution one_in( float in );
};
class npc_class
{
private:
translation name;
translation job_description;
bool common = true;
distribution bonus_str;
distribution bonus_dex;
distribution bonus_int;
distribution bonus_per;
std::map<skill_id, distribution> skills;
// Just for finalization
std::map<skill_id, distribution> bonus_skills;
item_group_id shopkeeper_item_group = item_group_id( "EMPTY_GROUP" );
public:
npc_class_id id;
bool was_loaded = false;
item_group_id worn_override;
item_group_id carry_override;
item_group_id weapon_override;
std::map<Mutation_category_tag, distribution> mutation_rounds;
trait_group::Trait_group_tag traits = trait_group::Trait_group_tag( "EMPTY_GROUP" );
// the int is what level the spell starts at
std::map<spell_id, int> _starting_spells;
std::map<bionic_id, int> bionic_list;
npc_class();
std::string get_name() const;
std::string get_job_description() const;
int roll_strength() const;
int roll_dexterity() const;
int roll_intelligence() const;
int roll_perception() const;
int roll_skill( const skill_id & ) const;
const item_group_id &get_shopkeeper_items() const;
void load( const JsonObject &jo, const std::string &src );
static const npc_class_id &from_legacy_int( int i );
static const npc_class_id &random_common();
static void load_npc_class( const JsonObject &jo, const std::string &src );
static const std::vector<npc_class> &get_all();
static void reset_npc_classes();
static void finalize_all();
static void check_consistency();
};
// TODO: Get rid of that
extern npc_class_id NC_NONE;
extern npc_class_id NC_EVAC_SHOPKEEP;
extern npc_class_id NC_SHOPKEEP;
extern npc_class_id NC_HACKER;
extern npc_class_id NC_CYBORG;
extern npc_class_id NC_DOCTOR;
extern npc_class_id NC_TRADER;
extern npc_class_id NC_NINJA;
extern npc_class_id NC_COWBOY;
extern npc_class_id NC_SCIENTIST;
extern npc_class_id NC_BOUNTY_HUNTER;
extern npc_class_id NC_THUG;
extern npc_class_id NC_SCAVENGER;
extern npc_class_id NC_ARSONIST;
extern npc_class_id NC_HUNTER;
extern npc_class_id NC_SOLDIER;
extern npc_class_id NC_BARTENDER;
extern npc_class_id NC_JUNK_SHOPKEEP;
extern npc_class_id NC_HALLU;
#endif // CATA_SRC_NPC_CLASS_H