World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
NPC.h
См. документацию.
1 #pragma once
2 
3 #include <array>
4 
5 enum NPCProf {
6  Smith = 1, // GM Weapon Repair;
7  Armorer = 2, // GM Armor Repair;
8  Alchemist = 3, // GM Potion Repair;
9  Scholar = 4, // GM Item ID; Learning: +5
10  Guide = 5, // Travel by foot: -1 day;
11  Tracker = 6, // Travel by foot: -2 days;
12  Pathfinder = 7, // Travel by foot: -3 days;
13  Sailor = 8, // Travel by sea: -2 days;
14  Navigator = 9, // Travel by sea: -3 days;
15  Healer = 10,
18  Teacher = 13, // Learning: +10;
19  Instructor = 14, // Learning: +15;
20  Armsmaster = 15, // Armsmaster: +2;
21  Weaponsmaster = 16, // Armsmaster: +3;
22  Apprentice = 17, // Fire: +2; Air: +2; Water: +2; Earth: +2;
23  Mystic = 18, // Fire: +3; Air: +3; Water: +3; Earth: +3;
24  Spellmaster = 19, // Fire: +4; Air: +4; Water: +4; Earth: +4;
25  Trader = 20, // Merchant: +4;
26  Merchant = 21, // Merchant: +6;
27  Scout = 22, // Perception: +6;
28  Herbalist = 23, // Alchemy: +4;
29  Apothecary = 24, // Alchemy: +8;
30  Tinker = 25, // Traps: +4;
31  Locksmith = 26, // Traps: +6;
32  Fool = 27, // Luck: +5;
33  ChimneySweep = 28, // Luck: +20;
34  Porter = 29, // Food for rest: -1;
35  QuarterMaster = 30, // Food for rest: -2;
36  Factor = 31, // Gold finds: +10%;
37  Banker = 32, // Gold finds: +20%;
38  Cook = 33,
39  Chef = 34,
40  Horseman = 35, // Travel by foot: -2 days;
41  Bard = 36,
42  Enchanter = 37, // Resist All: +20;
43  Cartographer = 38, // Wizard Eye level 2;
44  WindMaster = 39,
46  GateMaster = 41,
47  Acolyte = 42,
48  Piper = 43,
49  Explorer = 44, // Travel by foot -1 day; Travel by sea: -1 day;
50  Pirate = 45, // Travel by sea: -2 days; Gold finds: +10%; Reputation:
51  // +5;
52  Squire = 46,
53  Psychic = 47, // Perception: +5; Luck: +10;
54  Gypsy = 48, // Food for rest: -1; Merchant: +3; Reputation: +5;
55  Diplomat = 49,
56  Duper = 50, // Merchant: +8; Reputation: +5;
57  Burglar = 51, // Traps: +8; Stealing: +8; Reputation: +5;
58  FallenWizard = 52, // Reputation: +5;
60  53, // Spirit: +2; Mind: +2; Body: +2;
62  54, // Spirit: +3; Mind: +3; Body: +3;
64  55, // Spirit: +4; Mind: +4; Body: +4;
65  Monk = 56, // Unarmed: +2; Dodge: +2;
66  Sage = 57, // Monster ID: +6
67  Hunter = 58 // Monster ID: +6
68 };
69 
70 struct NPCTopic {
71  const char *pTopic;
72  const char *pText;
73 };
74 
75 extern std::array<NPCTopic, 789> pNPCTopics;
76 
77 /* 136 */
78 #pragma pack(push, 1)
79 struct NPCData { // 4Ch
80  inline bool Hired() { return (uFlags & 0x80) != 0; }
81 
82  char *pName; // 0
83  unsigned int uPortraitID; // 4
84  unsigned int uFlags; // 8 // & 0x80 no greeting on dialogue start;
85  // looks like hired
86  int fame; // c
87  int rep; // 10
88  unsigned int Location2D; // 14
89  unsigned int uProfession; // 18
90  int greet; // 1c
91  int joins; // 20
92  int field_24;
93  unsigned int evt_A; // 28
94  unsigned int evt_B; // 2c evtb
95  unsigned int evt_C; // 30 evtc
96  unsigned int evt_D; // 34
97  unsigned int evt_E; // 38
98  unsigned int evt_F; // 3c
99  unsigned int uSex; // 40
101  int news_topic; // 48
102 };
103 #pragma pack(pop)
104 
105 /* 138 */
106 #pragma pack(push, 1)
108  inline NPCProfession()
109  : uHirePrice(0),
110  pBenefits(nullptr),
111  pActionText(nullptr),
112  pJoinText(nullptr),
113  pDismissText(nullptr) {}
114 
115  unsigned int uHirePrice;
116  char *pBenefits;
117  char *pActionText;
118  char *pJoinText;
120 };
121 #pragma pack(pop)
122 
123 /* 139 */
124 #pragma pack(push, 1)
126  unsigned int uTotalprofChance; // summ
127  char professionChancePerArea[60]; // prof position
128 };
129 #pragma pack(pop)
130 
131 /* 140 */
132 #pragma pack(push, 1)
133 struct NPCGreeting {
134  union {
135  struct {
136  char *pGreeting1; // at first meet
137  char *pGreeting2; // at latest meets
138  };
139  char *pGreetings[2];
140  };
141 };
142 #pragma pack(pop)
143 
144 /* 137 */
145 #pragma pack(push, 1)
146 struct NPCStats {
147  inline NPCStats()
148  : pNPCTopicTXT_Raw(nullptr),
149  pNPCTextTXT_Raw(nullptr),
150  pNPCDistTXT_Raw(nullptr) {
151  uNumNPCNames[0] = uNumNPCNames[1] = 0;
152  }
153 
154  void InitializeNPCText();
155  void InitializeNPCData();
156  void Initialize();
157  void Release();
158  void InitializeAdditionalNPCs(NPCData *pNPCDataBuff, int npc_uid,
159  int uLocation2D, int uMapId);
160  void _476C60_on_load_game();
161  char *sub_495366_MispronounceName(uint8_t firstLetter,
162  uint8_t genderId);
163 
164  NPCData pNPCData[501]; // 0 - 94BCh count from 1
165  NPCData pNewNPCData[501]; // 94BCh- 12978h count from 1
166  char *pNPCNames[540][2];
167  NPCProfession pProfessions[59]; // count from 1
169  char *pCatchPhrases[52]; // 15CA4h
170  char *pNPCUnicNames[500]; // from first batch
172  pProfessionChance[77]; // 16544h profession chance in each area
178  unsigned int uNewlNPCBufPos;
179  unsigned int uNumNewNPCs;
181  unsigned int uNumNPCProfessions;
182  unsigned int uNumNPCNames[2]; // 0 male 1 female
192 
195 };
196 #pragma pack(pop)
197 
198 extern int pDialogueNPCCount;
199 extern std::array<class Image *, 6> pDialogueNPCPortraits;
200 extern int uNumDialogueNPCPortraits;
201 extern struct NPCStats *pNPCStats;
202 
203 bool PartyHasDragon();
204 bool CheckHiredNPCSpeciality(unsigned int uProfession);
205 
206 int UseNPCSkill(NPCProf profession);
207 const char *ContractSelectText(int pEventCode);
209 void _4B4224_UpdateNPCTopics(int _this);
210 const char *GetProfessionActionText(int a1);
211 struct NPCData *GetNPCData(signed int npcid);
212 struct NPCData *GetNewNPCData(signed int npcid, int *npc_indx);
213 int GetGreetType(signed int SpeakingNPC_ID);
214 int NPC_EventProcessor(int npc_event_id, int entry_line = 0);
uint16_t
unsigned __int16 uint16_t
Definition: SDL_config.h:37
NPCGreeting::pGreeting1
char * pGreeting1
Definition: NPC.h:136
NPCData::uProfession
unsigned int uProfession
Definition: NPC.h:89
NPCGreeting
Definition: NPC.h:133
NPCStats::uNumNPCProfessions
unsigned int uNumNPCProfessions
Definition: NPC.h:181
NPCProfession::uHirePrice
unsigned int uHirePrice
Definition: NPC.h:115
pNPCStats
struct NPCStats * pNPCStats
Definition: NPC.cpp:29
Teacher
@ Teacher
Definition: NPC.h:18
NPCGreeting::pGreetings
char * pGreetings[2]
Definition: NPC.h:139
Tinker
@ Tinker
Definition: NPC.h:30
Smith
@ Smith
Definition: NPC.h:6
UseNPCSkill
int UseNPCSkill(NPCProf profession)
Definition: NPC.cpp:1378
Pirate
@ Pirate
Definition: NPC.h:50
Monk
@ Monk
Definition: NPC.h:65
NPCData::uFlags
unsigned int uFlags
Definition: NPC.h:84
NPCData::Hired
bool Hired()
Definition: NPC.h:80
NPCStats::InitializeAdditionalNPCs
void InitializeAdditionalNPCs(NPCData *pNPCDataBuff, int npc_uid, int uLocation2D, int uMapId)
Definition: NPC.cpp:582
NPCStats::pNPCNames
char * pNPCNames[540][2]
Definition: NPC.h:166
Psychic
@ Psychic
Definition: NPC.h:53
NPCStats::pNPCDataTXT_Raw
char * pNPCDataTXT_Raw
Definition: NPC.h:183
NPCStats::pGroups_copy
uint16_t pGroups_copy[51]
Definition: NPC.h:177
Diplomat
@ Diplomat
Definition: NPC.h:55
NPCData::evt_B
unsigned int evt_B
Definition: NPC.h:94
NPCStats::pNPCUnicNames
char * pNPCUnicNames[500]
Definition: NPC.h:170
NPCStats::pNPCNewsTXT_Raw
char * pNPCNewsTXT_Raw
Definition: NPC.h:186
Alchemist
@ Alchemist
Definition: NPC.h:8
NPCProfession::pActionText
char * pActionText
Definition: NPC.h:117
NPCStats::uNumNPCNames
unsigned int uNumNPCNames[2]
Definition: NPC.h:182
Instructor
@ Instructor
Definition: NPC.h:19
NPCProfession::NPCProfession
NPCProfession()
Definition: NPC.h:108
Burglar
@ Burglar
Definition: NPC.h:57
NPCStats::sub_495366_MispronounceName
char * sub_495366_MispronounceName(uint8_t firstLetter, uint8_t genderId)
Definition: NPC.cpp:714
FallenWizard
@ FallenWizard
Definition: NPC.h:58
NPCStats::Release
void Release()
Definition: NPC.cpp:556
Apothecary
@ Apothecary
Definition: NPC.h:29
NPCData::evt_E
unsigned int evt_E
Definition: NPC.h:97
Armorer
@ Armorer
Definition: NPC.h:7
NPCData::evt_C
unsigned int evt_C
Definition: NPC.h:95
WaterMaster
@ WaterMaster
Definition: NPC.h:45
NPCStats::pNCPGroupTXT_Raw
char * pNCPGroupTXT_Raw
Definition: NPC.h:191
NPCHireableDialogPrepare
void NPCHireableDialogPrepare()
Definition: NPC.cpp:1080
NPCProfessionChance::uTotalprofChance
unsigned int uTotalprofChance
Definition: NPC.h:126
NPCStats::field_17FC8
int field_17FC8
Definition: NPC.h:180
NPCTopic::pText
const char * pText
Definition: NPC.h:72
Scholar
@ Scholar
Definition: NPC.h:9
NPCStats::pNPCNamesTXT_Raw
char * pNPCNamesTXT_Raw
Definition: NPC.h:184
NPCData::evt_A
unsigned int evt_A
Definition: NPC.h:93
NPCStats::pCatchPhrases
char * pCatchPhrases[52]
Definition: NPC.h:169
NPCGreeting::pGreeting2
char * pGreeting2
Definition: NPC.h:137
NPCData::evt_D
unsigned int evt_D
Definition: NPC.h:96
NPCStats::uNumNewNPCs
unsigned int uNumNewNPCs
Definition: NPC.h:179
GetNPCData
struct NPCData * GetNPCData(signed int npcid)
Definition: NPC.cpp:43
WindMaster
@ WindMaster
Definition: NPC.h:44
pNPCTopics
std::array< NPCTopic, 789 > pNPCTopics
Definition: mm7_data.cpp:740
Acolyte2
@ Acolyte2
Definition: NPC.h:59
NPCStats::field_17888
int field_17888
Definition: NPC.h:174
Merchant
@ Merchant
Definition: NPC.h:26
Herbalist
@ Herbalist
Definition: NPC.h:28
NPCStats::pNPCProfTXT_Raw
char * pNPCProfTXT_Raw
Definition: NPC.h:185
NPCData::pName
char * pName
Definition: NPC.h:82
NPCStats::pNewNPCData
NPCData pNewNPCData[501]
Definition: NPC.h:165
Mystic
@ Mystic
Definition: NPC.h:23
Banker
@ Banker
Definition: NPC.h:37
Gypsy
@ Gypsy
Definition: NPC.h:54
NPCStats::pProfessions
NPCProfession pProfessions[59]
Definition: NPC.h:167
NPCStats::pNPCGreetings
NPCGreeting pNPCGreetings[205]
Definition: NPC.h:175
NPCStats::pNPCData
NPCData pNPCData[501]
Definition: NPC.h:164
Trader
@ Trader
Definition: NPC.h:25
ExpertHealer
@ ExpertHealer
Definition: NPC.h:16
NPCTopic
Definition: NPC.h:70
Cook
@ Cook
Definition: NPC.h:38
NPCStats::InitializeNPCData
void InitializeNPCData()
Definition: NPC.cpp:284
NPCStats::uNewlNPCBufPos
unsigned int uNewlNPCBufPos
Definition: NPC.h:178
PartyHasDragon
bool PartyHasDragon()
Definition: NPC.cpp:750
Cartographer
@ Cartographer
Definition: NPC.h:43
Bard
@ Bard
Definition: NPC.h:41
ContractSelectText
const char * ContractSelectText(int pEventCode)
Definition: NPC.cpp:1052
NPCTopic::pTopic
const char * pTopic
Definition: NPC.h:71
Weaponsmaster
@ Weaponsmaster
Definition: NPC.h:21
NPCProf
NPCProf
Definition: NPC.h:5
NPCData::rep
int rep
Definition: NPC.h:87
NPCStats::pAdditionalNPC
NPCData pAdditionalNPC[100]
Definition: NPC.h:168
NPCData::fame
int fame
Definition: NPC.h:86
NPCData
Definition: NPC.h:79
Armsmaster
@ Armsmaster
Definition: NPC.h:20
Squire
@ Squire
Definition: NPC.h:52
NPCStats::pNPCGreetTXT_Raw
char * pNPCGreetTXT_Raw
Definition: NPC.h:190
NPCProfessionChance::professionChancePerArea
char professionChancePerArea[60]
Definition: NPC.h:127
Tracker
@ Tracker
Definition: NPC.h:11
Scout
@ Scout
Definition: NPC.h:27
Navigator
@ Navigator
Definition: NPC.h:14
NPCData::uPortraitID
unsigned int uPortraitID
Definition: NPC.h:83
Sage
@ Sage
Definition: NPC.h:66
NPCStats::_476C60_on_load_game
void _476C60_on_load_game()
Definition: NPC.cpp:273
Hunter
@ Hunter
Definition: NPC.h:67
pDialogueNPCCount
int pDialogueNPCCount
Definition: NPC.cpp:26
Explorer
@ Explorer
Definition: NPC.h:49
MasterHealer
@ MasterHealer
Definition: NPC.h:17
NPCData::Location2D
unsigned int Location2D
Definition: NPC.h:88
Horseman
@ Horseman
Definition: NPC.h:40
GateMaster
@ GateMaster
Definition: NPC.h:46
Initiate
@ Initiate
Definition: NPC.h:61
uint8_t
unsigned __int8 uint8_t
Definition: SDL_config.h:35
Factor
@ Factor
Definition: NPC.h:36
NPCProfession::pDismissText
char * pDismissText
Definition: NPC.h:119
Healer
@ Healer
Definition: NPC.h:15
NPCProfession::pJoinText
char * pJoinText
Definition: NPC.h:118
pDialogueNPCPortraits
std::array< class Image *, 6 > pDialogueNPCPortraits
Definition: NPC.cpp:27
NPCStats::dword_AE3370_LastMispronouncedNameResult
static int dword_AE3370_LastMispronouncedNameResult
Definition: NPC.h:194
Prelate
@ Prelate
Definition: NPC.h:63
NPCData::greet
int greet
Definition: NPC.h:90
NPCData::bHasUsedTheAbility
int bHasUsedTheAbility
Definition: NPC.h:100
NPCStats::NPCStats
NPCStats()
Definition: NPC.h:147
NPCStats::Initialize
void Initialize()
Definition: NPC.cpp:445
Acolyte
@ Acolyte
Definition: NPC.h:47
Fool
@ Fool
Definition: NPC.h:32
NPCStats::pNPCTopicTXT_Raw
char * pNPCTopicTXT_Raw
Definition: NPC.h:187
CheckHiredNPCSpeciality
bool CheckHiredNPCSpeciality(unsigned int uProfession)
Definition: NPC.cpp:754
NPCData::evt_F
unsigned int evt_F
Definition: NPC.h:98
NPCStats::InitializeNPCText
void InitializeNPCText()
Definition: NPC.cpp:158
NPCData::news_topic
int news_topic
Definition: NPC.h:101
NPCData::joins
int joins
Definition: NPC.h:91
Pathfinder
@ Pathfinder
Definition: NPC.h:12
NPCStats::pProfessionChance
NPCProfessionChance pProfessionChance[77]
Definition: NPC.h:172
GetProfessionActionText
const char * GetProfessionActionText(int a1)
Definition: NPC.cpp:1369
NPC_EventProcessor
int NPC_EventProcessor(int npc_event_id, int entry_line=0)
Definition: NPC.cpp:1227
Locksmith
@ Locksmith
Definition: NPC.h:31
Duper
@ Duper
Definition: NPC.h:56
NPCProfession
Definition: NPC.h:107
NPCProfession::pBenefits
char * pBenefits
Definition: NPC.h:116
NPCProfessionChance
Definition: NPC.h:125
Chef
@ Chef
Definition: NPC.h:39
ChimneySweep
@ ChimneySweep
Definition: NPC.h:33
Apprentice
@ Apprentice
Definition: NPC.h:22
Porter
@ Porter
Definition: NPC.h:34
NPCStats::dword_AE336C_LastMispronouncedNameFirstLetter
static int dword_AE336C_LastMispronouncedNameFirstLetter
Definition: NPC.h:193
Enchanter
@ Enchanter
Definition: NPC.h:42
QuarterMaster
@ QuarterMaster
Definition: NPC.h:35
NPCStats::pGroups
uint16_t pGroups[51]
Definition: NPC.h:176
NPCStats::pNPCDistTXT_Raw
char * pNPCDistTXT_Raw
Definition: NPC.h:189
NPCStats::field_17884
int field_17884
Definition: NPC.h:173
NPCStats::pNPCTextTXT_Raw
char * pNPCTextTXT_Raw
Definition: NPC.h:188
NPCData::uSex
unsigned int uSex
Definition: NPC.h:99
uNumDialogueNPCPortraits
int uNumDialogueNPCPortraits
Definition: NPC.cpp:28
Piper
@ Piper
Definition: NPC.h:48
NPCData::field_24
int field_24
Definition: NPC.h:92
GetGreetType
int GetGreetType(signed int SpeakingNPC_ID)
Definition: NPC.cpp:1322
_4B4224_UpdateNPCTopics
void _4B4224_UpdateNPCTopics(int _this)
Definition: NPC.cpp:1110
GetNewNPCData
struct NPCData * GetNewNPCData(signed int npcid, int *npc_indx)
Definition: NPC.cpp:99
Guide
@ Guide
Definition: NPC.h:10
Spellmaster
@ Spellmaster
Definition: NPC.h:24
Sailor
@ Sailor
Definition: NPC.h:13
NPCStats
Definition: NPC.h:146