Mercurial > mm7
annotate Monsters.cpp @ 1554:e303d8a9bcdc
Merge
author | Grumpy7 |
---|---|
date | Sat, 07 Sep 2013 21:14:48 +0200 |
parents | c4ab816fcc5e |
children | 75fafd8ced59 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1113
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1113
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1113
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1113
diff
changeset
|
4 |
0 | 5 #include <stdlib.h> |
6 #include <stdio.h> | |
7 #include <string.h> | |
8 | |
9 #include "Monsters.h" | |
10 #include "FrameTableInc.h" | |
11 #include "Allocator.h" | |
12 #include "LOD.h" | |
189 | 13 #include "texts.h" |
0 | 14 #include "mm7_data.h" |
15 | |
16 | |
17 | |
18 | |
19 | |
20 struct MonsterStats *pMonsterStats; | |
21 struct MonsterList *pMonsterList; | |
22 | |
703 | 23 unsigned int ParseSpellType(struct FrameTableTxtLine* tbl, int* next_token); |
698 | 24 |
25 int ParseAttackType(const char *damage_type_str); | |
26 void ParseDamage( char *damage_str, unsigned __int8* dice_rolls, unsigned __int8* dice_sides, unsigned __int8* dmg_bonus ); | |
27 int ParseMissleAttackType(const char *missle_attack_str); | |
28 int ParseSpecialAttack(const char *spec_att_str); | |
29 | |
30 //----- (004548E2) -------------------------------------------------------- | |
703 | 31 unsigned int ParseSpellType( struct FrameTableTxtLine * tbl, int* next_token ) |
698 | 32 { |
33 | |
703 | 34 if (!tbl->pProperties[0] ) |
35 { | |
36 ++*next_token; | |
37 return 0; | |
38 } | |
1104 | 39 if ( !_stricmp(tbl->pProperties[0], "Dispel") ) //dispel magic |
703 | 40 { |
41 ++*next_token; | |
42 return 80; | |
43 } | |
1104 | 44 else if ( !_stricmp(tbl->pProperties[0], "Day") ) //day of protection |
703 | 45 { |
46 *next_token+=2;; | |
47 return 85; | |
48 } | |
1104 | 49 else if ( !_stricmp(tbl->pProperties[0], "Hour") ) //hour of power |
703 | 50 { |
51 *next_token+=2;; | |
52 return 86; | |
53 } | |
1104 | 54 else if ( !_stricmp(tbl->pProperties[0], "Shield") ) |
703 | 55 return 17; |
1104 | 56 else if ( !_stricmp(tbl->pProperties[0], "Spirit") ) |
703 | 57 { |
58 ++*next_token; | |
59 return 52; | |
60 } | |
1104 | 61 else if ( !_stricmp(tbl->pProperties[0], "Power") ) //power cure |
703 | 62 { |
63 ++*next_token; | |
64 return 77; | |
65 } | |
1104 | 66 else if ( !_stricmp(tbl->pProperties[0], "Meteor") ) //meteot shower |
703 | 67 { |
68 ++*next_token; | |
69 return 9; | |
70 } | |
1104 | 71 else if ( !_stricmp(tbl->pProperties[0], "Lightning") ) //Lightning bolt |
703 | 72 { |
73 ++*next_token; | |
74 return 18; | |
75 } | |
1104 | 76 else if ( !_stricmp(tbl->pProperties[0], "Implosion") ) |
703 | 77 return 20; |
1104 | 78 else if ( !_stricmp(tbl->pProperties[0], "Stone") ) |
703 | 79 { |
80 ++*next_token; | |
81 return 38; | |
82 } | |
1104 | 83 else if ( !_stricmp(tbl->pProperties[0], "Haste") ) |
703 | 84 return 5; |
1104 | 85 else if ( !_stricmp(tbl->pProperties[0], "Heroism") ) |
703 | 86 return 51; |
1104 | 87 else if ( !_stricmp(tbl->pProperties[0], "Pain") ) //pain reflection |
703 | 88 { |
89 ++*next_token; | |
90 return 95; | |
91 } | |
1104 | 92 else if ( !_stricmp(tbl->pProperties[0], "Sparks") ) |
703 | 93 return 15; |
1104 | 94 else if ( !_stricmp(tbl->pProperties[0], "Light") ) |
703 | 95 { |
96 ++*next_token; | |
97 return 78; | |
98 } | |
1104 | 99 else if ( !_stricmp(tbl->pProperties[0], "Toxic") ) //toxic cloud |
698 | 100 { |
703 | 101 ++*next_token; |
102 return 90; | |
103 } | |
1104 | 104 else if ( !_stricmp(tbl->pProperties[0], "ShrapMetal") ) |
703 | 105 return 93; |
1104 | 106 else if ( !_stricmp(tbl->pProperties[0], "Paralyze") ) |
703 | 107 return 81; |
1104 | 108 else if ( !_stricmp(tbl->pProperties[0], "Fireball") ) |
703 | 109 return 6; |
1104 | 110 else if ( !_stricmp(tbl->pProperties[0], "Incinerate") ) |
703 | 111 return 11; |
1104 | 112 else if ( !_stricmp(tbl->pProperties[0], "Fire") ) |
703 | 113 { |
114 ++*next_token; | |
115 return 2; | |
116 } | |
1104 | 117 else if ( !_stricmp(tbl->pProperties[0], "Rock") ) |
703 | 118 { |
119 ++*next_token; | |
120 return 41; | |
121 } | |
1104 | 122 else if ( !_stricmp(tbl->pProperties[0], "Mass") ) |
703 | 123 { |
124 ++*next_token; | |
125 return 44; | |
126 } | |
1104 | 127 else if ( !_stricmp(tbl->pProperties[0], "Ice") ) |
703 | 128 { |
129 ++*next_token; | |
130 return 26; | |
131 } | |
1104 | 132 else if ( !_stricmp(tbl->pProperties[0], "Acid") ) |
703 | 133 { |
134 ++*next_token; | |
135 return 29; | |
698 | 136 } |
1104 | 137 else if ( !_stricmp(tbl->pProperties[0], "Bless") ) |
703 | 138 return 46; |
1104 | 139 else if ( !_stricmp(tbl->pProperties[0], "Dragon") ) |
703 | 140 { |
141 ++*next_token; | |
142 return 97; | |
143 } | |
1104 | 144 else if ( !_stricmp(tbl->pProperties[0], "Reanimate") ) |
703 | 145 return 89; |
1104 | 146 else if ( !_stricmp(tbl->pProperties[0], "Summon") ) |
703 | 147 { |
148 ++*next_token; | |
149 return 82; | |
150 } | |
1104 | 151 else if ( !_stricmp(tbl->pProperties[0], "Fate") ) |
703 | 152 return 47; |
1104 | 153 else if ( !_stricmp(tbl->pProperties[0], "Harm") ) |
703 | 154 return 70; |
1104 | 155 else if ( !_stricmp(tbl->pProperties[0], "Mind") ) |
703 | 156 { |
157 ++*next_token; | |
158 return 57; | |
159 } | |
1104 | 160 else if ( !_stricmp(tbl->pProperties[0], "Blades") ) |
703 | 161 return 39; |
1104 | 162 else if ( !_stricmp(tbl->pProperties[0], "Psychic") ) |
703 | 163 { |
164 ++*next_token; | |
165 return 65; | |
166 } | |
1104 | 167 else if ( !_stricmp(tbl->pProperties[0], "Hammerhands") ) |
703 | 168 return 73; |
169 else | |
170 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
171 sprintf(pTmpBuf.data(), "Unknown monster spell %s", tbl->pProperties[0]); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
172 MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:1562", 0); |
703 | 173 ++*next_token; |
174 return 0; | |
175 } | |
698 | 176 } |
177 | |
178 //----- (00454CB4) -------------------------------------------------------- | |
179 int ParseAttackType( const char *damage_type_str ) | |
180 { | |
181 | |
182 switch (tolower(*damage_type_str)) | |
183 { | |
184 case 'f': return 0; //fire | |
185 case 'a': return 1; //air | |
186 case 'w': return 2; //water | |
187 case 'e': return 3; //earth | |
188 | |
189 case 's': return 6; //spirit | |
190 case 'm': return 7; //mind | |
191 //m ?? 8 | |
192 case 'l': return 9; //light | |
193 case 'd': return 10; //dark | |
194 // d?? 11 | |
195 } | |
196 return 4; //phis | |
197 | |
198 } | |
199 | |
200 //----- (00454D7D) -------------------------------------------------------- | |
201 void ParseDamage( char *damage_str, unsigned __int8* dice_rolls, unsigned __int8* dice_sides, unsigned __int8* dmg_bonus ) | |
202 { | |
203 int str_len=0; | |
204 int str_pos=0; | |
205 bool dice_flag=false; | |
206 | |
207 *dice_rolls = 0; | |
208 *dice_sides = 1; | |
209 *dmg_bonus = 0; | |
210 | |
211 str_len = strlen(damage_str); | |
212 if (str_len<=0) | |
213 return; | |
214 for (str_pos=0;str_pos<str_len;++str_pos ) | |
215 { | |
216 if (tolower(damage_str[str_pos])=='d') | |
217 { | |
218 damage_str[str_pos]='\0'; | |
219 *dice_rolls=atoi(damage_str); | |
220 *dice_sides=atoi(&damage_str[str_pos+1]); | |
221 dice_flag=true; | |
222 damage_str[str_pos]='d'; | |
223 } | |
224 else if (tolower(damage_str[str_pos])=='+') | |
225 *dmg_bonus=atoi(&damage_str[str_pos+1]); | |
226 } | |
227 if (!dice_flag) | |
228 { | |
229 if ((*damage_str>='0')&&(*damage_str<='9')) | |
230 { | |
231 *dice_rolls =atoi(damage_str); | |
232 *dice_sides = 1; | |
233 } | |
234 } | |
235 } | |
236 | |
237 //----- (00454E3A) -------------------------------------------------------- | |
238 int ParseMissleAttackType(const char *missle_attack_str) | |
239 { | |
1104 | 240 if ( !_stricmp(missle_attack_str, "ARROW") ) |
698 | 241 return 1; |
1104 | 242 else if ( !_stricmp(missle_attack_str, "ARROWF") ) |
698 | 243 return 2; |
1104 | 244 else if ( !_stricmp(missle_attack_str, "FIRE") ) |
698 | 245 return 3; |
1104 | 246 else if ( !_stricmp(missle_attack_str, "AIR") ) |
698 | 247 return 4; |
1104 | 248 else if ( !_stricmp(missle_attack_str, "WATER") ) |
698 | 249 return 5; |
1104 | 250 else if ( !_stricmp(missle_attack_str, "EARTH") ) |
698 | 251 return 6; |
1104 | 252 else if ( !_stricmp(missle_attack_str, "SPIRIT") ) |
698 | 253 return 7; |
1104 | 254 else if ( !_stricmp(missle_attack_str, "MIND") ) |
698 | 255 return 8; |
1104 | 256 else if ( !_stricmp(missle_attack_str, "BODY") ) |
698 | 257 return 9; |
1104 | 258 else if ( !_stricmp(missle_attack_str, "LIGHT") ) |
698 | 259 return 10; |
1104 | 260 else if ( !_stricmp(missle_attack_str, "DARK") ) |
698 | 261 return 11; |
1104 | 262 else if ( !_stricmp(missle_attack_str, "ENER") ) |
698 | 263 return 13; |
264 else return 0; | |
265 } | |
266 | |
267 | |
703 | 268 int ParseSpecialAttack(char *spec_att_str) |
698 | 269 { |
703 | 270 _strlwr(spec_att_str); |
698 | 271 if ( strstr(spec_att_str, "curse") ) |
272 return 1; | |
273 else if ( strstr(spec_att_str, "weak") ) | |
274 return 2; | |
275 else if ( strstr(spec_att_str, "asleep") ) | |
276 return 3; | |
277 else if ( strstr(spec_att_str, "afraid") ) | |
278 return 23; | |
279 else if ( strstr(spec_att_str, "drunk") ) | |
280 return 4; | |
281 else if ( strstr(spec_att_str, "insane") ) | |
282 return 5; | |
283 else if ( strstr(spec_att_str, "poison1") ) | |
284 return 6; | |
285 else if ( strstr(spec_att_str, "poison2") ) | |
286 return 7; | |
287 else if ( strstr(spec_att_str, "poison3") ) | |
288 return 8; | |
289 else if ( strstr(spec_att_str, "disease1") ) | |
290 return 9; | |
291 else if ( strstr(spec_att_str, "disease2") ) | |
292 return 10; | |
293 else if ( strstr(spec_att_str, "disease3") ) | |
294 return 11; | |
295 else if ( strstr(spec_att_str, "paralyze") ) | |
296 return 12; | |
297 else if ( strstr(spec_att_str, "uncon") ) | |
298 return 13; | |
299 else if ( strstr(spec_att_str, "dead") ) | |
300 return 14; | |
301 else if ( strstr(spec_att_str, "stone") ) | |
302 return 15; | |
303 else if ( strstr(spec_att_str, "errad") ) | |
304 return 16; | |
305 else if ( strstr(spec_att_str, "brkitem") ) | |
306 return 17; | |
307 else if ( strstr(spec_att_str, "brkarmor") ) | |
308 return 18; | |
309 else if ( strstr(spec_att_str, "brkweapon") ) | |
310 return 19; | |
311 else if ( strstr(spec_att_str, "steal") ) | |
312 return 20; | |
313 else if ( strstr(spec_att_str, "age") ) | |
314 return 21; | |
315 else if ( strstr(spec_att_str, "drainsp") ) | |
316 return 22; | |
317 else return 0; | |
318 } | |
0 | 319 |
320 //----- (004598FC) -------------------------------------------------------- | |
321 bool MonsterList::FromFileTxt(const char *Args) | |
322 { | |
323 MonsterList *v2; // ebx@1 | |
324 FILE *v3; // eax@1 | |
325 unsigned int v4; // esi@3 | |
326 void *v5; // eax@9 | |
327 FILE *v6; // ST14_4@11 | |
328 char *i; // eax@11 | |
329 signed int v8; // esi@12 | |
330 unsigned __int16 v9; // ax@16 | |
331 const char *v10; // ST18_4@16 | |
332 unsigned __int16 v11; // ax@16 | |
333 const char *v12; // ST14_4@16 | |
334 unsigned __int16 v13; // ax@16 | |
335 const char *v14; // ST10_4@16 | |
336 __int16 v15; // ax@16 | |
337 const char *v16; // ST0C_4@16 | |
338 int v17; // esi@16 | |
339 unsigned __int8 v18; // al@16 | |
340 signed int v19; // esi@16 | |
341 unsigned __int16 v20; // ax@17 | |
342 int v21; // ecx@17 | |
343 char Buf; // [sp+4h] [bp-304h]@3 | |
344 FrameTableTxtLine v24; // [sp+1F8h] [bp-110h]@4 | |
345 FrameTableTxtLine v25; // [sp+274h] [bp-94h]@4 | |
346 int v26; // [sp+2F0h] [bp-18h]@16 | |
347 char v27; // [sp+2F4h] [bp-14h]@14 | |
348 char v28; // [sp+2F5h] [bp-13h]@14 | |
349 char v29; // [sp+2F6h] [bp-12h]@14 | |
350 char v30; // [sp+2F7h] [bp-11h]@14 | |
351 char v31; // [sp+2F8h] [bp-10h]@14 | |
352 char v32; // [sp+2F9h] [bp-Fh]@14 | |
353 char v33; // [sp+2FAh] [bp-Eh]@14 | |
354 char v34; // [sp+2FBh] [bp-Dh]@14 | |
355 char v35; // [sp+2FCh] [bp-Ch]@14 | |
356 char v36; // [sp+2FDh] [bp-Bh]@14 | |
357 char v37; // [sp+2FEh] [bp-Ah]@14 | |
358 char v38; // [sp+2FFh] [bp-9h]@14 | |
359 char v39; // [sp+300h] [bp-8h]@14 | |
360 char v40; // [sp+301h] [bp-7h]@14 | |
361 char v41; // [sp+302h] [bp-6h]@14 | |
362 char v42; // [sp+303h] [bp-5h]@14 | |
363 FILE *File; // [sp+304h] [bp-4h]@1 | |
364 unsigned int Argsa; // [sp+310h] [bp+8h]@3 | |
365 int Argsb; // [sp+310h] [bp+8h]@16 | |
366 | |
367 v2 = this; | |
368 v3 = fopen(Args, "r"); | |
369 File = v3; | |
370 if ( !v3 ) | |
1545 | 371 Error("MonsterRaceListStruct::load - Unable to open file: %s."); |
372 | |
0 | 373 v4 = 0; |
374 Argsa = 0; | |
375 if ( fgets(&Buf, 490, v3) ) | |
376 { | |
377 do | |
378 { | |
379 *strchr(&Buf, 10) = 0; | |
380 memcpy(&v25, frame_table_txt_parser(&Buf, &v24), sizeof(v25)); | |
701 | 381 if ( v25.uPropCount && *v25.pProperties[0] != 47 ) |
0 | 382 ++Argsa; |
383 } | |
384 while ( fgets(&Buf, 490, File) ); | |
385 v4 = Argsa; | |
386 } | |
387 v2->uNumMonsters = v4; | |
388 v5 = pAllocator->AllocNamedChunk(v2->pMonsters, 152 * v4, "Mon Race"); | |
389 v2->pMonsters = (MonsterDesc *)v5; | |
390 if ( !v5 ) | |
1545 | 391 Error("MonsterRaceListStruct::load - Out of Memory!"); |
392 | |
0 | 393 v6 = File; |
394 v2->uNumMonsters = 0; | |
395 fseek(v6, 0, 0); | |
396 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | |
397 { | |
398 *strchr(&Buf, 10) = 0; | |
399 memcpy(&v25, frame_table_txt_parser(&Buf, &v24), sizeof(v25)); | |
400 v8 = 0; | |
701 | 401 if ( v25.uPropCount && *v25.pProperties[0] != 47 ) |
0 | 402 { |
403 strcpy(v2->pMonsters[v2->uNumMonsters].pMonsterName, v25.pProperties[0]); | |
404 v35 = 0; | |
405 v36 = 1; | |
406 v37 = 7; | |
407 v38 = 2; | |
408 v39 = 3; | |
409 v40 = 4; | |
410 v41 = 5; | |
411 v42 = 6; | |
412 v27 = 1; | |
413 v28 = 2; | |
414 v29 = 3; | |
415 v30 = 4; | |
416 v31 = 4; | |
417 v32 = 5; | |
418 v33 = 6; | |
419 v34 = 7; | |
420 do | |
421 { | |
422 strcpy( | |
423 v2->pMonsters[v2->uNumMonsters].pSpriteNames[(unsigned __int8)*(&v35 + v8)], | |
424 v25.pProperties[(unsigned __int8)*(&v27 + v8)]); | |
425 ++v8; | |
426 } | |
427 while ( v8 < 8 ); | |
428 v9 = atoi(v25.pProperties[8]); | |
429 v10 = v25.pProperties[9]; | |
430 v2->pMonsters[v2->uNumMonsters].uMonsterHeight = v9; | |
431 v11 = atoi(v10); | |
432 v12 = v25.pProperties[10]; | |
433 v2->pMonsters[v2->uNumMonsters].uMovementSpeed = v11; | |
434 v13 = atoi(v12); | |
435 v14 = v25.pProperties[11]; | |
436 v2->pMonsters[v2->uNumMonsters].uMonsterRadius = v13; | |
437 v15 = atoi(v14); | |
438 v16 = v25.pProperties[12]; | |
439 v2->pMonsters[v2->uNumMonsters].uToHitRadius = v15; | |
440 v17 = (unsigned __int8)atoi(v16); | |
701 | 441 Argsb = atoi(v25.pProperties[13]) & 0xFF; |
442 v26 = atoi(v25.pProperties[14]) & 0xFF; | |
443 v18 = atoi(v25.pProperties[15]); | |
0 | 444 v2->pMonsters[v2->uNumMonsters].uTintColor = v18 | ((v26 | ((Argsb | (v17 << 8)) << 8)) << 8); |
445 v19 = 0; | |
446 do | |
447 { | |
701 | 448 v20 = atoi(v25.pProperties[v19 + 16]); |
449 v21 = v19++ ; | |
450 v2->pMonsters[v2->uNumMonsters].pSoundSampleIDs[v21] = v20; | |
0 | 451 } |
452 while ( v19 < 4 ); | |
453 ++v2->uNumMonsters; | |
454 } | |
455 } | |
456 fclose(File); | |
457 return 1; | |
458 } | |
459 | |
460 //----- (004598AF) -------------------------------------------------------- | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
461 void MonsterList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) |
0 | 462 { |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
463 uint num_mm6_monsters = data_mm6 ? *(int *)data_mm6 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
464 num_mm7_monsters = data_mm7 ? *(int *)data_mm7 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
465 num_mm8_monsters = data_mm8 ? *(int *)data_mm8 : 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
466 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
467 uNumMonsters = num_mm6_monsters + num_mm7_monsters + num_mm8_monsters; |
1545 | 468 Assert(uNumMonsters); |
469 Assert(!num_mm8_monsters); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
470 |
698 | 471 pMonsters = (MonsterDesc *)pAllocator->AllocNamedChunk(pMonsters, sizeof(MonsterDesc) * uNumMonsters, "Mon Race"); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
472 memcpy(pMonsters, (char *)data_mm7 + 4, num_mm7_monsters * sizeof(MonsterDesc)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
473 for (uint i = 0; i < num_mm6_monsters; ++i) |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
474 { |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
475 auto src = (MonsterDesc_mm6 *)((char *)data_mm6 + 4) + i; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
476 auto dst = pMonsters + num_mm7_monsters + i; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
477 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
478 dst->uMonsterHeight = src->uMonsterHeight; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
479 dst->uMonsterRadius = src->uMonsterRadius; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
480 dst->uMovementSpeed = src->uMovementSpeed; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
481 dst->uToHitRadius = src->uToHitRadius; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
482 dst->uTintColor = 0xFFFFFFFF; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
483 memcpy(dst->pSoundSampleIDs, src->pSoundSampleIDs, sizeof(src->pSoundSampleIDs)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
484 memcpy(dst->pMonsterName, src->pMonsterName, sizeof(src->pMonsterName)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
485 memcpy(dst->pSpriteNames, src->pSpriteNames, sizeof(src->pSpriteNames)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
486 } |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1456
diff
changeset
|
487 memcpy(pMonsters + num_mm6_monsters + num_mm7_monsters, (char *)data_mm8 + 4, num_mm8_monsters * sizeof(MonsterDesc)); |
0 | 488 } |
489 | |
490 //----- (00459860) -------------------------------------------------------- | |
491 void MonsterList::ToFile() | |
492 { | |
493 MonsterList *v1; // esi@1 | |
494 FILE *v2; // eax@1 | |
495 FILE *v3; // edi@1 | |
496 | |
497 v1 = this; | |
498 v2 = fopen("data\\dmonlist.bin", "wb"); | |
499 v3 = v2; | |
500 if ( !v2 ) | |
1545 | 501 Error("Unable to save dmonlist.bin!"); |
0 | 502 fwrite(v1, 4u, 1u, v2); |
503 fwrite(v1->pMonsters, 0x98u, v1->uNumMonsters, v3); | |
504 fclose(v3); | |
505 } | |
506 | |
507 | |
508 //----- (004563FF) -------------------------------------------------------- | |
751 | 509 signed int MonsterStats::FindMonsterByTextureName(const char *monster_textr_name) |
0 | 510 { |
751 | 511 for (int i=1; i<uNumMonsters; ++i) |
694 | 512 { |
1104 | 513 if((pInfos[i].pName )&& (!_stricmp(pInfos[i].pPictureName, monster_textr_name))) |
694 | 514 return i; |
515 } | |
516 return -1; | |
0 | 517 } |
518 | |
519 | |
520 //----- (00454F4E) -------------------------------------------------------- | |
521 void MonsterStats::InitializePlacements() | |
522 { | |
237 | 523 int i; |
524 char* test_string; | |
525 unsigned char c; | |
526 bool break_loop; | |
527 unsigned int temp_str_len; | |
528 char* tmp_pos; | |
529 int decode_step; | |
530 int item_counter; | |
0 | 531 |
532 pMonsterPlacementTXT_Raw = (char *)pEvents_LOD->LoadRaw("placemon.txt", 0); | |
533 strtok(pMonsterPlacementTXT_Raw, "\r"); | |
237 | 534 for (i=1; i<31; ++i) |
535 { | |
536 test_string = strtok(NULL, "\r") + 1; | |
537 break_loop = false; | |
538 decode_step=0; | |
539 do | |
540 { | |
541 c = *(unsigned char*)test_string; | |
542 temp_str_len = 0; | |
543 while((c!='\t')&&(c>0)) | |
544 { | |
545 ++temp_str_len; | |
546 c=test_string[temp_str_len]; | |
547 } | |
548 tmp_pos=test_string+temp_str_len; | |
549 if (*tmp_pos == 0) | |
550 break_loop = true; | |
551 *tmp_pos = 0; | |
552 if (temp_str_len) | |
553 { | |
554 if (decode_step==1) | |
555 pPlaceStrings[i]=RemoveQuotes(test_string); | |
556 } | |
557 else | |
558 { | |
559 break_loop = true; | |
560 } | |
561 ++decode_step; | |
562 test_string=tmp_pos+1; | |
563 } while ((decode_step<3)&&!break_loop); | |
564 } | |
565 uNumPlacements = 31; | |
0 | 566 } |
567 | |
568 //----- (0045501E) -------------------------------------------------------- | |
569 void MonsterStats::Initialize() | |
694 | 570 { |
571 int i,j; | |
572 char* test_string; | |
573 unsigned char c; | |
574 bool break_loop; | |
575 unsigned int temp_str_len; | |
576 char* tmp_pos; | |
577 int decode_step; | |
578 int item_counter; | |
579 int curr_rec_num; | |
703 | 580 char parse_str[64]; |
751 | 581 char Src[120]; |
582 FrameTableTxtLine parsed_field; | |
694 | 583 |
584 if ( pMonstersTXT_Raw ) | |
585 pAllocator->FreeChunk(pMonstersTXT_Raw); | |
586 pMonstersTXT_Raw = NULL; | |
587 pMonstersTXT_Raw = (char *)pEvents_LOD->LoadRaw("monsters.txt", 0); | |
588 strtok(pMonstersTXT_Raw, "\r"); | |
589 strtok(NULL, "\r"); | |
590 strtok(NULL, "\r"); | |
591 strtok(NULL, "\r"); | |
592 uNumMonsters = 265; | |
593 curr_rec_num=0; | |
594 for (i=0;i<uNumMonsters-1;++i) | |
595 { | |
596 test_string = strtok(NULL, "\r") + 1; | |
597 break_loop = false; | |
598 decode_step=0; | |
599 do | |
600 { | |
601 c = *(unsigned char*)test_string; | |
602 temp_str_len = 0; | |
603 while((c!='\t')&&(c>0)) | |
604 { | |
605 ++temp_str_len; | |
606 c=test_string[temp_str_len]; | |
607 } | |
608 tmp_pos=test_string+temp_str_len; | |
609 if (*tmp_pos == 0) | |
610 break_loop = true; | |
611 *tmp_pos = 0; | |
612 if (temp_str_len) | |
613 { | |
614 switch (decode_step) | |
615 { | |
616 case 0: | |
617 curr_rec_num=atoi(test_string); | |
618 pInfos[curr_rec_num].uID=curr_rec_num; | |
619 break; | |
620 case 1: | |
621 pInfos[curr_rec_num].pName=RemoveQuotes(test_string); | |
622 break; | |
623 case 2: | |
624 pInfos[curr_rec_num].pPictureName=RemoveQuotes(test_string); | |
625 break; | |
626 case 3: | |
627 pInfos[curr_rec_num].uLevel=atoi(test_string); | |
628 break; | |
629 case 4: | |
630 { | |
631 int str_len=0; | |
632 int str_pos=0; | |
633 pInfos[curr_rec_num].uHP=0; | |
634 if (test_string[0]=='"') | |
635 test_string[0]=' '; | |
636 str_len=strlen(test_string); | |
637 if (str_len==0) | |
638 break; | |
639 while ((test_string[str_pos]!=',')&&(str_pos<str_len)) | |
640 ++str_pos; | |
641 if (str_len==str_pos) | |
642 pInfos[curr_rec_num].uHP=atoi(test_string); | |
643 else | |
644 { | |
645 test_string[str_pos]='\0'; | |
646 pInfos[curr_rec_num].uHP=1000*atoi(test_string); | |
647 pInfos[curr_rec_num].uHP+=atoi(&test_string[str_pos+1]); | |
648 test_string[str_pos]=','; | |
649 } | |
650 } | |
651 break; | |
652 case 5: | |
653 pInfos[curr_rec_num].uAC=atoi(test_string); | |
654 break; | |
655 case 6: | |
656 { | |
657 int str_len=0; | |
658 int str_pos=0; | |
659 pInfos[curr_rec_num].uExp=0; | |
660 if (test_string[0]=='"') | |
661 test_string[0]=' '; | |
662 str_len=strlen(test_string); | |
663 if (str_len==0) | |
664 break; | |
665 while ((test_string[str_pos]!=',')&&(str_pos<str_len)) | |
666 ++str_pos; | |
667 if (str_len==str_pos) | |
668 pInfos[curr_rec_num].uExp=atoi(test_string); | |
669 else | |
670 { | |
671 test_string[str_pos]='\0'; | |
672 pInfos[curr_rec_num].uExp=1000*atoi(test_string); | |
673 pInfos[curr_rec_num].uExp+=atoi(&test_string[str_pos+1]); | |
674 test_string[str_pos]=','; | |
675 } | |
676 } | |
677 break; | |
678 case 7: | |
679 { | |
680 int str_len=0; | |
681 int str_pos=0; | |
682 bool chance_flag=false; | |
683 bool dice_flag=false; | |
684 bool item_type_flag=false; | |
685 char* item_name; | |
686 pInfos[curr_rec_num].uTreasureDropChance=0; | |
687 pInfos[curr_rec_num].uTreasureDiceRolls=0; | |
688 pInfos[curr_rec_num].uTreasureDiceSides=0; | |
698 | 689 pInfos[curr_rec_num].uTreasureType=0; |
690 pInfos[curr_rec_num].uTreasureLevel=0; | |
694 | 691 if (test_string[0]=='"') |
692 test_string[0]=' '; | |
693 str_len=strlen(test_string); | |
694 do | |
695 { | |
696 switch(tolower(test_string[str_pos])) | |
697 { | |
698 case '%': chance_flag=true; break; | |
699 case 'd': dice_flag=true; break; | |
700 case 'l': item_type_flag=true; break; | |
701 } | |
702 ++str_pos; | |
703 } | |
704 while(str_pos<str_len); | |
705 if (chance_flag) | |
706 { | |
707 pInfos[curr_rec_num].uTreasureDropChance=atoi(test_string); | |
708 } | |
709 else | |
710 { | |
711 if ((!dice_flag)&&(!item_type_flag)) | |
712 break; | |
713 pInfos[curr_rec_num].uTreasureDropChance=100; | |
714 } | |
715 if (dice_flag) | |
716 { | |
717 str_pos=0; | |
718 dice_flag=false; | |
719 do | |
720 { | |
721 switch(tolower(test_string[str_pos])) | |
722 { | |
723 case '%': | |
724 pInfos[curr_rec_num].uTreasureDiceRolls=atoi(&test_string[str_pos+1]); | |
725 dice_flag=true; | |
726 break; | |
727 case 'd': | |
728 if(!dice_flag) | |
729 pInfos[curr_rec_num].uTreasureDiceRolls=atoi(test_string); | |
730 pInfos[curr_rec_num].uTreasureDiceSides=atoi(&test_string[str_pos+1]); | |
731 str_pos=str_len; | |
732 break; | |
0 | 733 |
694 | 734 } |
735 ++str_pos; | |
736 } | |
737 while(str_pos<str_len); | |
738 } | |
739 if (item_type_flag) | |
740 { | |
741 str_pos=0; | |
742 do | |
743 { | |
744 if (tolower(test_string[str_pos])=='l') | |
745 break; | |
746 ++str_pos; | |
747 } | |
748 while(str_pos<str_len); | |
698 | 749 |
694 | 750 pInfos[curr_rec_num].uTreasureLevel=test_string[str_pos+1]-'0'; |
751 item_name=&test_string[str_pos+2]; | |
752 if (*item_name) | |
753 { | |
1104 | 754 if ( !_stricmp(item_name, "WEAPON")) |
694 | 755 pInfos[curr_rec_num].uTreasureType= 20; |
1104 | 756 else if ( !_stricmp(item_name, "ARMOR")) |
694 | 757 pInfos[curr_rec_num].uTreasureType= 21; |
1104 | 758 else if ( !_stricmp(item_name, "MISC")) |
694 | 759 pInfos[curr_rec_num].uTreasureType= 22; |
1104 | 760 else if ( !_stricmp(item_name, "SWORD")) |
694 | 761 pInfos[curr_rec_num].uTreasureType= 23; |
1104 | 762 else if ( !_stricmp(item_name, "DAGGER")) |
694 | 763 pInfos[curr_rec_num].uTreasureType= 24; |
1104 | 764 else if ( !_stricmp(item_name, "AXE")) |
694 | 765 pInfos[curr_rec_num].uTreasureType= 25; |
1104 | 766 else if ( !_stricmp(item_name, "SPEAR")) |
694 | 767 pInfos[curr_rec_num].uTreasureType= 26; |
1104 | 768 else if ( !_stricmp(item_name, "BOW")) |
694 | 769 pInfos[curr_rec_num].uTreasureType= 27; |
1104 | 770 else if ( !_stricmp(item_name, "MACE")) |
694 | 771 pInfos[curr_rec_num].uTreasureType= 28; |
1104 | 772 else if ( !_stricmp(item_name, "CLUB")) |
694 | 773 pInfos[curr_rec_num].uTreasureType= 29; |
1104 | 774 else if ( !_stricmp(item_name, "STAFF")) |
694 | 775 pInfos[curr_rec_num].uTreasureType= 30; |
1104 | 776 else if ( !_stricmp(item_name, "LEATHER")) |
694 | 777 pInfos[curr_rec_num].uTreasureType= 31; |
1104 | 778 else if ( !_stricmp(item_name, "CHAIN")) |
694 | 779 pInfos[curr_rec_num].uTreasureType= 32; |
1104 | 780 else if ( !_stricmp(item_name, "PLATE")) |
694 | 781 pInfos[curr_rec_num].uTreasureType= 33; |
1104 | 782 else if ( !_stricmp(item_name, "SHIELD")) |
694 | 783 pInfos[curr_rec_num].uTreasureType= 34; |
1104 | 784 else if ( !_stricmp(item_name, "HELM")) |
694 | 785 pInfos[curr_rec_num].uTreasureType= 35; |
1104 | 786 else if ( !_stricmp(item_name, "BELT")) |
694 | 787 pInfos[curr_rec_num].uTreasureType= 36; |
1104 | 788 else if ( !_stricmp(item_name, "CAPE")) |
694 | 789 pInfos[curr_rec_num].uTreasureType= 37; |
1104 | 790 else if ( !_stricmp(item_name, "GAUNTLETS")) |
694 | 791 pInfos[curr_rec_num].uTreasureType= 38; |
1104 | 792 else if ( !_stricmp(item_name, "BOOTS")) |
694 | 793 pInfos[curr_rec_num].uTreasureType= 39; |
1104 | 794 else if ( !_stricmp(item_name, "RING")) |
694 | 795 pInfos[curr_rec_num].uTreasureType= 40; |
1104 | 796 else if ( !_stricmp(item_name, "AMULET")) |
694 | 797 pInfos[curr_rec_num].uTreasureType= 41; |
1104 | 798 else if ( !_stricmp(item_name, "WAND")) |
694 | 799 pInfos[curr_rec_num].uTreasureType= 42; |
1104 | 800 else if ( !_stricmp(item_name, "SCROLL")) |
694 | 801 pInfos[curr_rec_num].uTreasureType= 43; |
1104 | 802 else if ( !_stricmp(item_name, "GEM")) |
694 | 803 pInfos[curr_rec_num].uTreasureType= 46; |
804 } | |
805 } | |
806 | |
807 } | |
808 break; | |
809 case 8: | |
810 { | |
811 pInfos[curr_rec_num].bQuestMonster=0; | |
812 if (atoi(test_string)) | |
813 pInfos[curr_rec_num].bQuestMonster=1; | |
814 } | |
815 break; | |
816 case 9: | |
817 { | |
818 pInfos[curr_rec_num].uFlying=false; | |
819 if (_strnicmp(test_string, "n",1)) | |
820 pInfos[curr_rec_num].uFlying=true; | |
821 } | |
822 break; | |
823 case 10: | |
824 { | |
825 switch(tolower(test_string[0])) | |
826 { | |
1456 | 827 case 's': pInfos[curr_rec_num].uMovementType=MONSTER_MOVEMENT_TYPE_SHORT;// short |
694 | 828 if (tolower(test_string[1])!='h') |
1456 | 829 pInfos[curr_rec_num].uMovementType=MONSTER_MOVEMENT_TYPE_STAIONARY; //stationary |
694 | 830 break; //short |
831 case 'l': pInfos[curr_rec_num].uMovementType=2; break; //long | |
832 case 'm': pInfos[curr_rec_num].uMovementType=1; break; //med | |
1332 | 833 case 'g': pInfos[curr_rec_num].uMovementType=3; break; //global? |
694 | 834 default: |
835 pInfos[curr_rec_num].uMovementType=4; //free | |
836 } | |
837 } | |
838 break; | |
839 case 11: | |
840 { | |
841 switch(tolower(test_string[0])) | |
842 { | |
843 case 's': pInfos[curr_rec_num].uAIType=0; break; // suicide | |
844 case 'w': pInfos[curr_rec_num].uAIType=1; break; //wimp | |
845 case 'n': pInfos[curr_rec_num].uAIType=2; break; //normal | |
846 default: | |
847 pInfos[curr_rec_num].uAIType=3; //Agress | |
848 } | |
849 } | |
850 break; | |
851 case 12: | |
852 pInfos[curr_rec_num].uHostilityType=(MonsterInfo::HostilityRadius)atoi(test_string); | |
853 break; | |
854 case 13: | |
855 pInfos[curr_rec_num].uBaseSpeed=atoi(test_string); | |
856 break; | |
857 case 14: | |
858 pInfos[curr_rec_num].uRecoveryTime=atoi(test_string); | |
859 break; | |
860 case 15: | |
861 { | |
862 int str_len=0; | |
863 int str_pos=0; | |
864 pInfos[curr_rec_num].uAttackPreference=0; | |
865 pInfos[curr_rec_num].uNumCharactersAttackedPerSpecialAbility=0; | |
866 str_len=strlen(test_string); | |
867 for (str_pos=0;str_pos<str_len;++str_pos ) | |
868 { | |
869 switch(tolower(test_string[str_pos])) | |
870 { | |
871 case '0': pInfos[curr_rec_num].uAttackPreference|=0x0004; break; | |
872 case '2': pInfos[curr_rec_num].uNumCharactersAttackedPerSpecialAbility=2; break; | |
873 case '3': pInfos[curr_rec_num].uNumCharactersAttackedPerSpecialAbility=3; break; | |
874 case '4': pInfos[curr_rec_num].uNumCharactersAttackedPerSpecialAbility=4; break; | |
875 case 'c': pInfos[curr_rec_num].uAttackPreference|=0x0010; break; | |
876 case 'd': pInfos[curr_rec_num].uAttackPreference|=0x0008; break; | |
698 | 877 case 'e': pInfos[curr_rec_num].uAttackPreference|=0x1000; break; |
694 | 878 case 'f': pInfos[curr_rec_num].uAttackPreference|=0x0400; break; |
879 case 'h': pInfos[curr_rec_num].uAttackPreference|=0x0800; break; | |
880 case 'k': pInfos[curr_rec_num].uAttackPreference|=0x0001; break; | |
881 case 'm': pInfos[curr_rec_num].uAttackPreference|=0x0100; break; | |
882 case 'o': pInfos[curr_rec_num].uAttackPreference|=0x0400; break; | |
883 case 'p': pInfos[curr_rec_num].uAttackPreference|=0x0002; break; | |
884 case 'r': pInfos[curr_rec_num].uAttackPreference|=0x0040; break; | |
885 case 's': pInfos[curr_rec_num].uAttackPreference|=0x0020; break; | |
886 case 't': pInfos[curr_rec_num].uAttackPreference|=0x0080; break; | |
887 case 'w': pInfos[curr_rec_num].uAttackPreference|=0x2000; break; | |
888 case 'x': pInfos[curr_rec_num].uAttackPreference|=0x0200; break; | |
889 } | |
890 } | |
891 } | |
892 break; | |
698 | 893 case 16: |
694 | 894 { |
703 | 895 int str_len=0; |
896 int str_pos=0; | |
897 pInfos[curr_rec_num].uSpecialAttackType=1; | |
898 pInfos[curr_rec_num].uSpecialAttack=0; | |
899 str_len=strlen(test_string); | |
900 if (str_len>1) | |
901 { | |
902 for (str_pos=0;str_pos<str_len;++str_pos ) | |
903 { | |
904 if (tolower(test_string[str_pos])=='x') | |
905 { | |
906 test_string[str_pos]='\0'; | |
907 pInfos[curr_rec_num].uSpecialAttackType=atoi(&test_string[str_pos+1]); | |
908 test_string[str_pos]='x'; | |
909 break; | |
910 } | |
911 } | |
912 pInfos[curr_rec_num].uSpecialAttack=ParseSpecialAttack(test_string); | |
913 } | |
694 | 914 } |
915 break; | |
916 case 17: | |
698 | 917 pInfos[curr_rec_num].uAttack1Type=ParseAttackType(test_string); |
694 | 918 break; |
919 case 18: | |
920 { | |
698 | 921 ParseDamage(test_string, &pInfos[curr_rec_num].uAttack1DamageDiceRolls, |
922 &pInfos[curr_rec_num].uAttack1DamageDiceSides, | |
923 &pInfos[curr_rec_num].uAttack1DamageBonus); | |
694 | 924 } |
925 break; | |
698 | 926 case 19: |
927 pInfos[curr_rec_num].uMissleAttack1Type=ParseMissleAttackType(test_string); | |
694 | 928 break; |
929 case 20: | |
698 | 930 pInfos[curr_rec_num].uAttack2Chance=atoi(test_string); |
694 | 931 break; |
932 case 21: | |
698 | 933 pInfos[curr_rec_num].uAttack2Type=ParseAttackType(test_string); |
694 | 934 break; |
935 case 22: | |
936 { | |
698 | 937 ParseDamage(test_string, &pInfos[curr_rec_num].uAttack2DamageDiceRolls, |
938 &pInfos[curr_rec_num].uAttack2DamageDiceSides, | |
939 &pInfos[curr_rec_num].uAttack2DamageBonus); | |
694 | 940 } |
941 break; | |
942 case 23: | |
698 | 943 pInfos[curr_rec_num].uMissleAttack2Type=ParseMissleAttackType(test_string); |
694 | 944 break; |
945 case 24: | |
698 | 946 pInfos[curr_rec_num].uSpell1UseChance=atoi(test_string); |
694 | 947 break; |
948 case 25: | |
949 { | |
703 | 950 int param_num; |
951 char type_flag; | |
952 strcpy(parse_str,test_string); | |
953 parse_str[0]=' '; | |
954 parse_str[strlen(parse_str)-1]=' '; | |
751 | 955 frame_table_txt_parser(parse_str,&parsed_field); |
956 if (parsed_field.uPropCount>2) | |
703 | 957 { |
958 param_num=1; | |
751 | 959 pInfos[curr_rec_num].uSpell1ID=ParseSpellType(&parsed_field,¶m_num); |
960 type_flag=*parsed_field.pProperties[param_num]; | |
961 pInfos[curr_rec_num].uSpellSkillAndMastery1=atoi(parsed_field.pProperties[param_num+1])&0x003F; | |
703 | 962 switch(type_flag) |
963 { | |
964 case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0040; break; | |
965 case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0080; break; | |
966 case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0100; break; | |
967 } | |
968 } | |
969 else | |
970 { | |
971 pInfos[curr_rec_num].uSpell1ID=0; | |
972 pInfos[curr_rec_num].uSpellSkillAndMastery1=0; | |
973 } | |
694 | 974 |
975 } | |
976 break; | |
977 case 26: | |
698 | 978 pInfos[curr_rec_num].uSpell2UseChance=atoi(test_string); |
694 | 979 break; |
980 case 27: | |
981 { | |
703 | 982 int param_num; |
983 char type_flag; | |
984 strcpy(parse_str,test_string); | |
985 parse_str[0]=' '; | |
986 parse_str[strlen(parse_str)-1]=' '; | |
751 | 987 frame_table_txt_parser(parse_str,&parsed_field); |
988 if (parsed_field.uPropCount>2) | |
703 | 989 { |
990 param_num=1; | |
751 | 991 pInfos[curr_rec_num].uSpell2ID=ParseSpellType(&parsed_field,¶m_num); |
992 type_flag=*parsed_field.pProperties[param_num]; | |
993 pInfos[curr_rec_num].uSpellSkillAndMastery2=atoi(parsed_field.pProperties[param_num+1])&0x003F; | |
703 | 994 switch(type_flag) |
995 { | |
996 case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0040; break; | |
997 case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0080; break; | |
998 case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0100; break; | |
999 } | |
1000 } | |
1001 else | |
1002 { | |
1003 pInfos[curr_rec_num].uSpell2ID=0; | |
1004 pInfos[curr_rec_num].uSpellSkillAndMastery2=0; | |
1005 } | |
694 | 1006 } |
1007 break; | |
1008 case 28: | |
1009 { | |
698 | 1010 if (tolower(test_string[0])=='i') |
1011 pInfos[curr_rec_num].uResFire=200; | |
1012 else | |
1013 pInfos[curr_rec_num].uResFire=atoi(test_string); | |
694 | 1014 } |
1015 break; | |
1016 case 29: | |
1017 { | |
698 | 1018 if (tolower(test_string[0])=='i') |
1019 pInfos[curr_rec_num].uResAir=200; | |
1020 else | |
1021 pInfos[curr_rec_num].uResAir=atoi(test_string); | |
694 | 1022 } |
1023 break; | |
1024 case 30: | |
1025 { | |
698 | 1026 if (tolower(test_string[0])=='i') |
1027 pInfos[curr_rec_num].uResWater=200; | |
1028 else | |
1029 pInfos[curr_rec_num].uResWater=atoi(test_string); | |
694 | 1030 } |
1031 break; | |
1032 case 31: | |
1033 { | |
698 | 1034 if (tolower(test_string[0])=='i') |
1035 pInfos[curr_rec_num].uResEarth=200; | |
1036 else | |
1037 pInfos[curr_rec_num].uResEarth=atoi(test_string); | |
694 | 1038 } |
1039 break; | |
1040 case 32: | |
1041 { | |
698 | 1042 if (tolower(test_string[0])=='i') |
1043 pInfos[curr_rec_num].uResMind=200; | |
1044 else | |
1045 pInfos[curr_rec_num].uResMind=atoi(test_string); | |
694 | 1046 } |
1047 break; | |
1048 case 33: | |
1049 { | |
698 | 1050 if (tolower(test_string[0])=='i') |
1051 pInfos[curr_rec_num].uResSpirit=200; | |
1052 else | |
1053 pInfos[curr_rec_num].uResSpirit=atoi(test_string); | |
694 | 1054 } |
1055 break; | |
1056 case 34: | |
1057 { | |
698 | 1058 if (tolower(test_string[0])=='i') |
1059 pInfos[curr_rec_num].uResBody=200; | |
1060 else | |
1061 pInfos[curr_rec_num].uResBody=atoi(test_string); | |
694 | 1062 } |
1063 break; | |
1064 case 35: | |
1065 { | |
698 | 1066 if (tolower(test_string[0])=='i') |
1067 pInfos[curr_rec_num].uResLight=200; | |
1068 else | |
1069 pInfos[curr_rec_num].uResLight=atoi(test_string); | |
694 | 1070 } |
1071 break; | |
1072 case 36: | |
1073 { | |
698 | 1074 if (tolower(test_string[0])=='i') |
1075 pInfos[curr_rec_num].uResDark=200; | |
1076 else | |
1077 pInfos[curr_rec_num].uResDark=atoi(test_string); | |
694 | 1078 } |
1079 break; | |
1080 case 37: | |
1081 { | |
698 | 1082 if (tolower(test_string[0])=='i') |
1083 pInfos[curr_rec_num].uResPhysical=200; | |
1084 else | |
1085 pInfos[curr_rec_num].uResPhysical=atoi(test_string); | |
694 | 1086 } |
1087 break; | |
1088 case 38: | |
1089 { | |
751 | 1090 int param_num; |
1091 char type_flag; | |
1092 pInfos[curr_rec_num].uSpecialAbilityType=0; | |
1093 pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus=0; | |
1094 strcpy(parse_str,test_string); | |
1095 parse_str[0]=' '; | |
1096 parse_str[strlen(parse_str)-1]=' '; | |
1097 frame_table_txt_parser(parse_str,&parsed_field); | |
1098 if ( parsed_field.uPropCount ) | |
1099 { | |
1100 // v74 = v94.field_0; | |
1101 if ( parsed_field.uPropCount < 10 ) | |
1102 { | |
1104 | 1103 if (! _stricmp(parsed_field.pProperties[0], "shot") ) |
751 | 1104 { |
1105 pInfos[curr_rec_num].uSpecialAbilityType=1; | |
1106 pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus=atoi((char *)(parsed_field.pProperties[1] + 1)); | |
1107 } | |
1104 | 1108 else if (!_stricmp(parsed_field.pProperties[0], "summon") ) |
751 | 1109 { |
1110 pInfos[curr_rec_num].uSpecialAbilityType=2; | |
1111 if ( parsed_field.uPropCount > 1 ) | |
1112 { | |
1113 pTmpBuf[0] = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1114 strcpy(pTmpBuf.data(), parsed_field.pProperties[2]); |
751 | 1115 if ( parsed_field.uPropCount > 2 ) |
1116 { | |
1117 int prop_cnt = 3; | |
1118 if ( parsed_field.uPropCount > 3 ) | |
1119 { | |
1120 do | |
1121 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1122 strcat(pTmpBuf.data(), " "); |
751 | 1123 char test_char = parsed_field.pProperties[prop_cnt][0]; |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1124 strcat(pTmpBuf.data(), parsed_field.pProperties[prop_cnt]); |
751 | 1125 if ( prop_cnt == (parsed_field.uPropCount - 1) ) |
1126 { | |
1127 switch (tolower(test_char)) | |
1128 { | |
1129 case 'a': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 1; break; | |
1130 case 'b': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 2; break; | |
1131 case 'c': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 3; break; | |
1132 default: | |
1133 pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 0; | |
1134 } | |
1135 | |
1136 } | |
1137 ++prop_cnt; | |
1138 } | |
1139 while ( prop_cnt < parsed_field.uPropCount ); | |
1140 } | |
1141 } | |
1142 else | |
1143 { | |
1144 pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 0; | |
1145 } | |
1146 if ( pMonsterList->uNumMonsters ) | |
1147 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1148 pInfos[curr_rec_num].field_3C_some_special_attack = pMonsterList->GetMonsterIDByName(pTmpBuf.data()) + 1; |
751 | 1149 if ( pInfos[curr_rec_num].field_3C_some_special_attack == -1 ) |
1150 { | |
1217 | 1151 sprintf(Src, "Can't create random monster: '%s' See MapStats!", pTmpBuf.data()); |
751 | 1152 MessageBoxA(nullptr, Src, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:2239", 0); |
1153 } | |
1154 } | |
1155 pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 0; | |
1104 | 1156 if ( !_stricmp(parsed_field.pProperties[1], "ground") ) |
751 | 1157 pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 1; |
1158 if ( pInfos[curr_rec_num].field_3C_some_special_attack == -1 ) | |
1159 pInfos[curr_rec_num].uSpecialAbilityType = 0; | |
1160 } | |
1161 } | |
1104 | 1162 else if (!_stricmp(parsed_field.pProperties[0], "explode") ) |
751 | 1163 { |
1164 pInfos[curr_rec_num].uSpecialAbilityType = 3; | |
1165 ParseDamage((char*)parsed_field.pProperties[1], &pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls, | |
1166 &pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides, | |
1167 &pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus); | |
1168 pInfos[curr_rec_num].field_3C_some_special_attack = ParseAttackType(test_string); | |
1169 } | |
1170 } | |
1171 } | |
694 | 1172 } |
698 | 1173 break; |
694 | 1174 } |
1175 } | |
1176 else | |
1177 { | |
1178 break_loop = true; | |
1179 } | |
1180 ++decode_step; | |
1181 test_string=tmp_pos+1; | |
1182 } while ((decode_step<39)&&!break_loop); | |
1183 } | |
1184 uNumMonsters = i; | |
0 | 1185 } |
1186 | |
1187 | |
1188 //----- (0044FA08) -------------------------------------------------------- | |
751 | 1189 signed __int16 MonsterList::GetMonsterIDByName( const char *pMonsterName ) |
0 | 1190 { |
751 | 1191 if (!pMonsterName) |
1192 return -1; | |
1193 for (signed __int16 i=1; i<=uNumMonsters; ++i) | |
1194 { | |
1104 | 1195 if( (!_stricmp(pMonsters[i].pMonsterName, pMonsterName))) |
751 | 1196 return i; |
0 | 1197 } |
1545 | 1198 Error("Monster not found: %s", pMonsterName); |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1104
diff
changeset
|
1199 } |
1297 | 1200 //----- (00438BDF) -------------------------------------------------------- |
1201 bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype) | |
1202 { | |
1203 unsigned __int8 v2; // zf@15 | |
1204 char v3; // sf@15 | |
1205 unsigned __int8 v4; // of@15 | |
1206 bool result; // eax@33 | |
1207 | |
1208 switch ( eSupertype ) | |
1209 { | |
1210 case MONSTER_SUPERTYPE_UNDEAD: | |
1211 if ( (signed int)uMonsterInfoID >= MONSTER_GHOST_1 && (signed int)uMonsterInfoID <= MONSTER_GHOST_3 | |
1212 || (signed int)uMonsterInfoID >= MONSTER_LICH_1 && (signed int)uMonsterInfoID <= MONSTER_LICH_3 | |
1213 || (signed int)uMonsterInfoID >= MONSTER_SKELETON_1 && (signed int)uMonsterInfoID <= MONSTER_SKELETON_3 | |
1214 || (signed int)uMonsterInfoID >= MONSTER_VAMPIRE_1 && (signed int)uMonsterInfoID <= MONSTER_VAMPIRE_3 | |
1215 || (signed int)uMonsterInfoID >= MONSTER_WIGHT_1 && (signed int)uMonsterInfoID <= MONSTER_WIGHT_3 | |
1216 || (signed int)uMonsterInfoID >= MONSTER_ZOMBIE_1 && (signed int)uMonsterInfoID <= MONSTER_ZOMBIE_3 ) | |
1217 goto ret_true; | |
1218 if ( (signed int)uMonsterInfoID < MONSTER_GHOUL_1 ) | |
1219 goto ret_false; | |
1220 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_GHOUL_3); | |
1221 v2 = uMonsterInfoID == MONSTER_GHOUL_3; | |
1222 v3 = ((uMonsterInfoID - MONSTER_GHOUL_3) & 0x80000000u) != 0; | |
1223 goto false_if_outside; | |
1224 case MONSTER_SUPERTYPE_KREEGAN: | |
1225 if ( (signed int)uMonsterInfoID < MONSTER_DEVIL_1 ) | |
1226 goto ret_false; | |
1227 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DEVIL_3); | |
1228 v2 = uMonsterInfoID == MONSTER_DEVIL_3; | |
1229 v3 = ((uMonsterInfoID - MONSTER_DEVIL_3) & 0x80000000u) != 0; | |
1230 goto false_if_outside; | |
1231 case MONSTER_SUPERTYPE_ELF: | |
1232 if ( (signed int)uMonsterInfoID >= MONSTER_PEASANT_ELF_FEMALE_1_1 | |
1233 && (signed int)uMonsterInfoID <= MONSTER_PEASANT_ELF_MALE_3_3 | |
1234 || (signed int)uMonsterInfoID >= MONSTER_ELF_ARCHER_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_ARCHER_3 ) | |
1235 goto ret_true; | |
1236 if ( (signed int)uMonsterInfoID < MONSTER_ELF_SPEARMAN_1 ) | |
1237 goto ret_false; | |
1238 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELF_SPEARMAN_3); | |
1239 v2 = uMonsterInfoID == MONSTER_ELF_SPEARMAN_3; | |
1240 v3 = ((uMonsterInfoID - MONSTER_ELF_SPEARMAN_3) & 0x80000000u) != 0; | |
1241 goto false_if_outside; | |
1242 case MONSTER_SUPERTYPE_DRAGON: | |
1243 if ( (signed int)uMonsterInfoID < MONSTER_DRAGON_1 ) | |
1244 goto ret_false; | |
1245 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DRAGON_3); | |
1246 v2 = uMonsterInfoID == MONSTER_DRAGON_3; | |
1247 v3 = ((uMonsterInfoID - MONSTER_DRAGON_3) & 0x80000000u) != 0; | |
1248 goto false_if_outside; | |
1249 case MONSTER_SUPERTYPE_WATER_ELEMENTAL: | |
1250 if ( (signed int)uMonsterInfoID < MONSTER_ELEMENTAL_WATER_1 ) | |
1251 goto ret_false; | |
1252 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELEMENTAL_WATER_3); | |
1253 v2 = uMonsterInfoID == MONSTER_ELEMENTAL_WATER_3; | |
1254 v3 = ((uMonsterInfoID - MONSTER_ELEMENTAL_WATER_3) & 0x80000000u) != 0; | |
1255 goto false_if_outside; | |
1256 case MONSTER_SUPERTYPE_TREANT: | |
1257 if ( (signed int)uMonsterInfoID < MONSTER_TREANT_1 ) | |
1258 goto ret_false; | |
1259 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TREANT_3); | |
1260 v2 = uMonsterInfoID == MONSTER_TREANT_3; | |
1261 v3 = ((uMonsterInfoID - MONSTER_TREANT_3) & 0x80000000u) != 0; | |
1262 goto false_if_outside; | |
1263 case MONSTER_SUPERTYPE_TITAN: | |
1264 if ( (signed int)uMonsterInfoID < MONSTER_TITAN_1 ) | |
1265 goto ret_false; | |
1266 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TITAN_3); | |
1267 v2 = uMonsterInfoID == MONSTER_TITAN_3; | |
1268 v3 = ((uMonsterInfoID - MONSTER_TITAN_3) & 0x80000000u) != 0; | |
1269 false_if_outside: | |
1270 if ( !((unsigned __int8)(v3 ^ v4) | v2) ) | |
1271 goto ret_false; | |
1272 ret_true: | |
1273 result = 1; | |
1274 break; | |
1275 default: | |
1276 ret_false: | |
1277 result = 0; | |
1278 break; | |
1279 } | |
1280 return result; | |
1281 } |