Mercurial > mm7
annotate Monsters.cpp @ 1381:729635c2bb40
small commentary
author | Ritor1 |
---|---|
date | Tue, 16 Jul 2013 14:26:13 +0600 |
parents | 1e35cfed7928 |
children | 5c95f2246c2a |
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 ) | |
371 Abortf("MonsterRaceListStruct::load - Unable to open file: %s."); | |
372 v4 = 0; | |
373 Argsa = 0; | |
374 if ( fgets(&Buf, 490, v3) ) | |
375 { | |
376 do | |
377 { | |
378 *strchr(&Buf, 10) = 0; | |
379 memcpy(&v25, frame_table_txt_parser(&Buf, &v24), sizeof(v25)); | |
701 | 380 if ( v25.uPropCount && *v25.pProperties[0] != 47 ) |
0 | 381 ++Argsa; |
382 } | |
383 while ( fgets(&Buf, 490, File) ); | |
384 v4 = Argsa; | |
385 } | |
386 v2->uNumMonsters = v4; | |
387 v5 = pAllocator->AllocNamedChunk(v2->pMonsters, 152 * v4, "Mon Race"); | |
388 v2->pMonsters = (MonsterDesc *)v5; | |
389 if ( !v5 ) | |
390 Abortf("MonsterRaceListStruct::load - Out of Memory!"); | |
391 v6 = File; | |
392 v2->uNumMonsters = 0; | |
393 fseek(v6, 0, 0); | |
394 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | |
395 { | |
396 *strchr(&Buf, 10) = 0; | |
397 memcpy(&v25, frame_table_txt_parser(&Buf, &v24), sizeof(v25)); | |
398 v8 = 0; | |
701 | 399 if ( v25.uPropCount && *v25.pProperties[0] != 47 ) |
0 | 400 { |
401 strcpy(v2->pMonsters[v2->uNumMonsters].pMonsterName, v25.pProperties[0]); | |
402 v35 = 0; | |
403 v36 = 1; | |
404 v37 = 7; | |
405 v38 = 2; | |
406 v39 = 3; | |
407 v40 = 4; | |
408 v41 = 5; | |
409 v42 = 6; | |
410 v27 = 1; | |
411 v28 = 2; | |
412 v29 = 3; | |
413 v30 = 4; | |
414 v31 = 4; | |
415 v32 = 5; | |
416 v33 = 6; | |
417 v34 = 7; | |
418 do | |
419 { | |
420 strcpy( | |
421 v2->pMonsters[v2->uNumMonsters].pSpriteNames[(unsigned __int8)*(&v35 + v8)], | |
422 v25.pProperties[(unsigned __int8)*(&v27 + v8)]); | |
423 ++v8; | |
424 } | |
425 while ( v8 < 8 ); | |
426 v9 = atoi(v25.pProperties[8]); | |
427 v10 = v25.pProperties[9]; | |
428 v2->pMonsters[v2->uNumMonsters].uMonsterHeight = v9; | |
429 v11 = atoi(v10); | |
430 v12 = v25.pProperties[10]; | |
431 v2->pMonsters[v2->uNumMonsters].uMovementSpeed = v11; | |
432 v13 = atoi(v12); | |
433 v14 = v25.pProperties[11]; | |
434 v2->pMonsters[v2->uNumMonsters].uMonsterRadius = v13; | |
435 v15 = atoi(v14); | |
436 v16 = v25.pProperties[12]; | |
437 v2->pMonsters[v2->uNumMonsters].uToHitRadius = v15; | |
438 v17 = (unsigned __int8)atoi(v16); | |
701 | 439 Argsb = atoi(v25.pProperties[13]) & 0xFF; |
440 v26 = atoi(v25.pProperties[14]) & 0xFF; | |
441 v18 = atoi(v25.pProperties[15]); | |
0 | 442 v2->pMonsters[v2->uNumMonsters].uTintColor = v18 | ((v26 | ((Argsb | (v17 << 8)) << 8)) << 8); |
443 v19 = 0; | |
444 do | |
445 { | |
701 | 446 v20 = atoi(v25.pProperties[v19 + 16]); |
447 v21 = v19++ ; | |
448 v2->pMonsters[v2->uNumMonsters].pSoundSampleIDs[v21] = v20; | |
0 | 449 } |
450 while ( v19 < 4 ); | |
451 ++v2->uNumMonsters; | |
452 } | |
453 } | |
454 fclose(File); | |
455 return 1; | |
456 } | |
457 | |
458 //----- (004598AF) -------------------------------------------------------- | |
459 void MonsterList::FromFile(void *pSerialized) | |
460 { | |
461 uNumMonsters = *(int *)pSerialized; | |
698 | 462 pMonsters = (MonsterDesc *)pAllocator->AllocNamedChunk(pMonsters, sizeof(MonsterDesc) * uNumMonsters, "Mon Race"); |
463 memcpy(pMonsters, (char *)pSerialized + 4, sizeof(MonsterDesc) * uNumMonsters); | |
0 | 464 } |
465 | |
466 //----- (00459860) -------------------------------------------------------- | |
467 void MonsterList::ToFile() | |
468 { | |
469 MonsterList *v1; // esi@1 | |
470 FILE *v2; // eax@1 | |
471 FILE *v3; // edi@1 | |
472 | |
473 v1 = this; | |
474 v2 = fopen("data\\dmonlist.bin", "wb"); | |
475 v3 = v2; | |
476 if ( !v2 ) | |
477 Abortf("Unable to save dmonlist.bin!"); | |
478 fwrite(v1, 4u, 1u, v2); | |
479 fwrite(v1->pMonsters, 0x98u, v1->uNumMonsters, v3); | |
480 fclose(v3); | |
481 } | |
482 | |
483 | |
484 //----- (004563FF) -------------------------------------------------------- | |
751 | 485 signed int MonsterStats::FindMonsterByTextureName(const char *monster_textr_name) |
0 | 486 { |
751 | 487 for (int i=1; i<uNumMonsters; ++i) |
694 | 488 { |
1104 | 489 if((pInfos[i].pName )&& (!_stricmp(pInfos[i].pPictureName, monster_textr_name))) |
694 | 490 return i; |
491 } | |
492 return -1; | |
0 | 493 } |
494 | |
495 | |
496 //----- (00454F4E) -------------------------------------------------------- | |
497 void MonsterStats::InitializePlacements() | |
498 { | |
237 | 499 int i; |
500 char* test_string; | |
501 unsigned char c; | |
502 bool break_loop; | |
503 unsigned int temp_str_len; | |
504 char* tmp_pos; | |
505 int decode_step; | |
506 int item_counter; | |
0 | 507 |
508 pMonsterPlacementTXT_Raw = (char *)pEvents_LOD->LoadRaw("placemon.txt", 0); | |
509 strtok(pMonsterPlacementTXT_Raw, "\r"); | |
237 | 510 for (i=1; i<31; ++i) |
511 { | |
512 test_string = strtok(NULL, "\r") + 1; | |
513 break_loop = false; | |
514 decode_step=0; | |
515 do | |
516 { | |
517 c = *(unsigned char*)test_string; | |
518 temp_str_len = 0; | |
519 while((c!='\t')&&(c>0)) | |
520 { | |
521 ++temp_str_len; | |
522 c=test_string[temp_str_len]; | |
523 } | |
524 tmp_pos=test_string+temp_str_len; | |
525 if (*tmp_pos == 0) | |
526 break_loop = true; | |
527 *tmp_pos = 0; | |
528 if (temp_str_len) | |
529 { | |
530 if (decode_step==1) | |
531 pPlaceStrings[i]=RemoveQuotes(test_string); | |
532 } | |
533 else | |
534 { | |
535 break_loop = true; | |
536 } | |
537 ++decode_step; | |
538 test_string=tmp_pos+1; | |
539 } while ((decode_step<3)&&!break_loop); | |
540 } | |
541 uNumPlacements = 31; | |
0 | 542 } |
543 | |
544 //----- (0045501E) -------------------------------------------------------- | |
545 void MonsterStats::Initialize() | |
694 | 546 { |
547 int i,j; | |
548 char* test_string; | |
549 unsigned char c; | |
550 bool break_loop; | |
551 unsigned int temp_str_len; | |
552 char* tmp_pos; | |
553 int decode_step; | |
554 int item_counter; | |
555 int curr_rec_num; | |
703 | 556 char parse_str[64]; |
751 | 557 char Src[120]; |
558 FrameTableTxtLine parsed_field; | |
694 | 559 |
560 if ( pMonstersTXT_Raw ) | |
561 pAllocator->FreeChunk(pMonstersTXT_Raw); | |
562 pMonstersTXT_Raw = NULL; | |
563 pMonstersTXT_Raw = (char *)pEvents_LOD->LoadRaw("monsters.txt", 0); | |
564 strtok(pMonstersTXT_Raw, "\r"); | |
565 strtok(NULL, "\r"); | |
566 strtok(NULL, "\r"); | |
567 strtok(NULL, "\r"); | |
568 uNumMonsters = 265; | |
569 curr_rec_num=0; | |
570 for (i=0;i<uNumMonsters-1;++i) | |
571 { | |
572 test_string = strtok(NULL, "\r") + 1; | |
573 break_loop = false; | |
574 decode_step=0; | |
575 do | |
576 { | |
577 c = *(unsigned char*)test_string; | |
578 temp_str_len = 0; | |
579 while((c!='\t')&&(c>0)) | |
580 { | |
581 ++temp_str_len; | |
582 c=test_string[temp_str_len]; | |
583 } | |
584 tmp_pos=test_string+temp_str_len; | |
585 if (*tmp_pos == 0) | |
586 break_loop = true; | |
587 *tmp_pos = 0; | |
588 if (temp_str_len) | |
589 { | |
590 switch (decode_step) | |
591 { | |
592 case 0: | |
593 curr_rec_num=atoi(test_string); | |
594 pInfos[curr_rec_num].uID=curr_rec_num; | |
595 break; | |
596 case 1: | |
597 pInfos[curr_rec_num].pName=RemoveQuotes(test_string); | |
598 break; | |
599 case 2: | |
600 pInfos[curr_rec_num].pPictureName=RemoveQuotes(test_string); | |
601 break; | |
602 case 3: | |
603 pInfos[curr_rec_num].uLevel=atoi(test_string); | |
604 break; | |
605 case 4: | |
606 { | |
607 int str_len=0; | |
608 int str_pos=0; | |
609 pInfos[curr_rec_num].uHP=0; | |
610 if (test_string[0]=='"') | |
611 test_string[0]=' '; | |
612 str_len=strlen(test_string); | |
613 if (str_len==0) | |
614 break; | |
615 while ((test_string[str_pos]!=',')&&(str_pos<str_len)) | |
616 ++str_pos; | |
617 if (str_len==str_pos) | |
618 pInfos[curr_rec_num].uHP=atoi(test_string); | |
619 else | |
620 { | |
621 test_string[str_pos]='\0'; | |
622 pInfos[curr_rec_num].uHP=1000*atoi(test_string); | |
623 pInfos[curr_rec_num].uHP+=atoi(&test_string[str_pos+1]); | |
624 test_string[str_pos]=','; | |
625 } | |
626 } | |
627 break; | |
628 case 5: | |
629 pInfos[curr_rec_num].uAC=atoi(test_string); | |
630 break; | |
631 case 6: | |
632 { | |
633 int str_len=0; | |
634 int str_pos=0; | |
635 pInfos[curr_rec_num].uExp=0; | |
636 if (test_string[0]=='"') | |
637 test_string[0]=' '; | |
638 str_len=strlen(test_string); | |
639 if (str_len==0) | |
640 break; | |
641 while ((test_string[str_pos]!=',')&&(str_pos<str_len)) | |
642 ++str_pos; | |
643 if (str_len==str_pos) | |
644 pInfos[curr_rec_num].uExp=atoi(test_string); | |
645 else | |
646 { | |
647 test_string[str_pos]='\0'; | |
648 pInfos[curr_rec_num].uExp=1000*atoi(test_string); | |
649 pInfos[curr_rec_num].uExp+=atoi(&test_string[str_pos+1]); | |
650 test_string[str_pos]=','; | |
651 } | |
652 } | |
653 break; | |
654 case 7: | |
655 { | |
656 int str_len=0; | |
657 int str_pos=0; | |
658 bool chance_flag=false; | |
659 bool dice_flag=false; | |
660 bool item_type_flag=false; | |
661 char* item_name; | |
662 pInfos[curr_rec_num].uTreasureDropChance=0; | |
663 pInfos[curr_rec_num].uTreasureDiceRolls=0; | |
664 pInfos[curr_rec_num].uTreasureDiceSides=0; | |
698 | 665 pInfos[curr_rec_num].uTreasureType=0; |
666 pInfos[curr_rec_num].uTreasureLevel=0; | |
694 | 667 if (test_string[0]=='"') |
668 test_string[0]=' '; | |
669 str_len=strlen(test_string); | |
670 do | |
671 { | |
672 switch(tolower(test_string[str_pos])) | |
673 { | |
674 case '%': chance_flag=true; break; | |
675 case 'd': dice_flag=true; break; | |
676 case 'l': item_type_flag=true; break; | |
677 } | |
678 ++str_pos; | |
679 } | |
680 while(str_pos<str_len); | |
681 if (chance_flag) | |
682 { | |
683 pInfos[curr_rec_num].uTreasureDropChance=atoi(test_string); | |
684 } | |
685 else | |
686 { | |
687 if ((!dice_flag)&&(!item_type_flag)) | |
688 break; | |
689 pInfos[curr_rec_num].uTreasureDropChance=100; | |
690 } | |
691 if (dice_flag) | |
692 { | |
693 str_pos=0; | |
694 dice_flag=false; | |
695 do | |
696 { | |
697 switch(tolower(test_string[str_pos])) | |
698 { | |
699 case '%': | |
700 pInfos[curr_rec_num].uTreasureDiceRolls=atoi(&test_string[str_pos+1]); | |
701 dice_flag=true; | |
702 break; | |
703 case 'd': | |
704 if(!dice_flag) | |
705 pInfos[curr_rec_num].uTreasureDiceRolls=atoi(test_string); | |
706 pInfos[curr_rec_num].uTreasureDiceSides=atoi(&test_string[str_pos+1]); | |
707 str_pos=str_len; | |
708 break; | |
0 | 709 |
694 | 710 } |
711 ++str_pos; | |
712 } | |
713 while(str_pos<str_len); | |
714 } | |
715 if (item_type_flag) | |
716 { | |
717 str_pos=0; | |
718 do | |
719 { | |
720 if (tolower(test_string[str_pos])=='l') | |
721 break; | |
722 ++str_pos; | |
723 } | |
724 while(str_pos<str_len); | |
698 | 725 |
694 | 726 pInfos[curr_rec_num].uTreasureLevel=test_string[str_pos+1]-'0'; |
727 item_name=&test_string[str_pos+2]; | |
728 if (*item_name) | |
729 { | |
1104 | 730 if ( !_stricmp(item_name, "WEAPON")) |
694 | 731 pInfos[curr_rec_num].uTreasureType= 20; |
1104 | 732 else if ( !_stricmp(item_name, "ARMOR")) |
694 | 733 pInfos[curr_rec_num].uTreasureType= 21; |
1104 | 734 else if ( !_stricmp(item_name, "MISC")) |
694 | 735 pInfos[curr_rec_num].uTreasureType= 22; |
1104 | 736 else if ( !_stricmp(item_name, "SWORD")) |
694 | 737 pInfos[curr_rec_num].uTreasureType= 23; |
1104 | 738 else if ( !_stricmp(item_name, "DAGGER")) |
694 | 739 pInfos[curr_rec_num].uTreasureType= 24; |
1104 | 740 else if ( !_stricmp(item_name, "AXE")) |
694 | 741 pInfos[curr_rec_num].uTreasureType= 25; |
1104 | 742 else if ( !_stricmp(item_name, "SPEAR")) |
694 | 743 pInfos[curr_rec_num].uTreasureType= 26; |
1104 | 744 else if ( !_stricmp(item_name, "BOW")) |
694 | 745 pInfos[curr_rec_num].uTreasureType= 27; |
1104 | 746 else if ( !_stricmp(item_name, "MACE")) |
694 | 747 pInfos[curr_rec_num].uTreasureType= 28; |
1104 | 748 else if ( !_stricmp(item_name, "CLUB")) |
694 | 749 pInfos[curr_rec_num].uTreasureType= 29; |
1104 | 750 else if ( !_stricmp(item_name, "STAFF")) |
694 | 751 pInfos[curr_rec_num].uTreasureType= 30; |
1104 | 752 else if ( !_stricmp(item_name, "LEATHER")) |
694 | 753 pInfos[curr_rec_num].uTreasureType= 31; |
1104 | 754 else if ( !_stricmp(item_name, "CHAIN")) |
694 | 755 pInfos[curr_rec_num].uTreasureType= 32; |
1104 | 756 else if ( !_stricmp(item_name, "PLATE")) |
694 | 757 pInfos[curr_rec_num].uTreasureType= 33; |
1104 | 758 else if ( !_stricmp(item_name, "SHIELD")) |
694 | 759 pInfos[curr_rec_num].uTreasureType= 34; |
1104 | 760 else if ( !_stricmp(item_name, "HELM")) |
694 | 761 pInfos[curr_rec_num].uTreasureType= 35; |
1104 | 762 else if ( !_stricmp(item_name, "BELT")) |
694 | 763 pInfos[curr_rec_num].uTreasureType= 36; |
1104 | 764 else if ( !_stricmp(item_name, "CAPE")) |
694 | 765 pInfos[curr_rec_num].uTreasureType= 37; |
1104 | 766 else if ( !_stricmp(item_name, "GAUNTLETS")) |
694 | 767 pInfos[curr_rec_num].uTreasureType= 38; |
1104 | 768 else if ( !_stricmp(item_name, "BOOTS")) |
694 | 769 pInfos[curr_rec_num].uTreasureType= 39; |
1104 | 770 else if ( !_stricmp(item_name, "RING")) |
694 | 771 pInfos[curr_rec_num].uTreasureType= 40; |
1104 | 772 else if ( !_stricmp(item_name, "AMULET")) |
694 | 773 pInfos[curr_rec_num].uTreasureType= 41; |
1104 | 774 else if ( !_stricmp(item_name, "WAND")) |
694 | 775 pInfos[curr_rec_num].uTreasureType= 42; |
1104 | 776 else if ( !_stricmp(item_name, "SCROLL")) |
694 | 777 pInfos[curr_rec_num].uTreasureType= 43; |
1104 | 778 else if ( !_stricmp(item_name, "GEM")) |
694 | 779 pInfos[curr_rec_num].uTreasureType= 46; |
780 } | |
781 } | |
782 | |
783 } | |
784 break; | |
785 case 8: | |
786 { | |
787 pInfos[curr_rec_num].bQuestMonster=0; | |
788 if (atoi(test_string)) | |
789 pInfos[curr_rec_num].bQuestMonster=1; | |
790 } | |
791 break; | |
792 case 9: | |
793 { | |
794 pInfos[curr_rec_num].uFlying=false; | |
795 if (_strnicmp(test_string, "n",1)) | |
796 pInfos[curr_rec_num].uFlying=true; | |
797 } | |
798 break; | |
799 case 10: | |
800 { | |
801 switch(tolower(test_string[0])) | |
802 { | |
803 case 's': pInfos[curr_rec_num].uMovementType=0;// short | |
804 if (tolower(test_string[1])!='h') | |
1332 | 805 pInfos[curr_rec_num].uMovementType=5; //stationary? |
694 | 806 break; //short |
807 case 'l': pInfos[curr_rec_num].uMovementType=2; break; //long | |
808 case 'm': pInfos[curr_rec_num].uMovementType=1; break; //med | |
1332 | 809 case 'g': pInfos[curr_rec_num].uMovementType=3; break; //global? |
694 | 810 default: |
811 pInfos[curr_rec_num].uMovementType=4; //free | |
812 } | |
813 } | |
814 break; | |
815 case 11: | |
816 { | |
817 switch(tolower(test_string[0])) | |
818 { | |
819 case 's': pInfos[curr_rec_num].uAIType=0; break; // suicide | |
820 case 'w': pInfos[curr_rec_num].uAIType=1; break; //wimp | |
821 case 'n': pInfos[curr_rec_num].uAIType=2; break; //normal | |
822 default: | |
823 pInfos[curr_rec_num].uAIType=3; //Agress | |
824 } | |
825 } | |
826 break; | |
827 case 12: | |
828 pInfos[curr_rec_num].uHostilityType=(MonsterInfo::HostilityRadius)atoi(test_string); | |
829 break; | |
830 case 13: | |
831 pInfos[curr_rec_num].uBaseSpeed=atoi(test_string); | |
832 break; | |
833 case 14: | |
834 pInfos[curr_rec_num].uRecoveryTime=atoi(test_string); | |
835 break; | |
836 case 15: | |
837 { | |
838 int str_len=0; | |
839 int str_pos=0; | |
840 pInfos[curr_rec_num].uAttackPreference=0; | |
841 pInfos[curr_rec_num].uNumCharactersAttackedPerSpecialAbility=0; | |
842 str_len=strlen(test_string); | |
843 for (str_pos=0;str_pos<str_len;++str_pos ) | |
844 { | |
845 switch(tolower(test_string[str_pos])) | |
846 { | |
847 case '0': pInfos[curr_rec_num].uAttackPreference|=0x0004; break; | |
848 case '2': pInfos[curr_rec_num].uNumCharactersAttackedPerSpecialAbility=2; break; | |
849 case '3': pInfos[curr_rec_num].uNumCharactersAttackedPerSpecialAbility=3; break; | |
850 case '4': pInfos[curr_rec_num].uNumCharactersAttackedPerSpecialAbility=4; break; | |
851 case 'c': pInfos[curr_rec_num].uAttackPreference|=0x0010; break; | |
852 case 'd': pInfos[curr_rec_num].uAttackPreference|=0x0008; break; | |
698 | 853 case 'e': pInfos[curr_rec_num].uAttackPreference|=0x1000; break; |
694 | 854 case 'f': pInfos[curr_rec_num].uAttackPreference|=0x0400; break; |
855 case 'h': pInfos[curr_rec_num].uAttackPreference|=0x0800; break; | |
856 case 'k': pInfos[curr_rec_num].uAttackPreference|=0x0001; break; | |
857 case 'm': pInfos[curr_rec_num].uAttackPreference|=0x0100; break; | |
858 case 'o': pInfos[curr_rec_num].uAttackPreference|=0x0400; break; | |
859 case 'p': pInfos[curr_rec_num].uAttackPreference|=0x0002; break; | |
860 case 'r': pInfos[curr_rec_num].uAttackPreference|=0x0040; break; | |
861 case 's': pInfos[curr_rec_num].uAttackPreference|=0x0020; break; | |
862 case 't': pInfos[curr_rec_num].uAttackPreference|=0x0080; break; | |
863 case 'w': pInfos[curr_rec_num].uAttackPreference|=0x2000; break; | |
864 case 'x': pInfos[curr_rec_num].uAttackPreference|=0x0200; break; | |
865 } | |
866 } | |
867 } | |
868 break; | |
698 | 869 case 16: |
694 | 870 { |
703 | 871 int str_len=0; |
872 int str_pos=0; | |
873 pInfos[curr_rec_num].uSpecialAttackType=1; | |
874 pInfos[curr_rec_num].uSpecialAttack=0; | |
875 str_len=strlen(test_string); | |
876 if (str_len>1) | |
877 { | |
878 for (str_pos=0;str_pos<str_len;++str_pos ) | |
879 { | |
880 if (tolower(test_string[str_pos])=='x') | |
881 { | |
882 test_string[str_pos]='\0'; | |
883 pInfos[curr_rec_num].uSpecialAttackType=atoi(&test_string[str_pos+1]); | |
884 test_string[str_pos]='x'; | |
885 break; | |
886 } | |
887 } | |
888 pInfos[curr_rec_num].uSpecialAttack=ParseSpecialAttack(test_string); | |
889 } | |
694 | 890 } |
891 break; | |
892 case 17: | |
698 | 893 pInfos[curr_rec_num].uAttack1Type=ParseAttackType(test_string); |
694 | 894 break; |
895 case 18: | |
896 { | |
698 | 897 ParseDamage(test_string, &pInfos[curr_rec_num].uAttack1DamageDiceRolls, |
898 &pInfos[curr_rec_num].uAttack1DamageDiceSides, | |
899 &pInfos[curr_rec_num].uAttack1DamageBonus); | |
694 | 900 } |
901 break; | |
698 | 902 case 19: |
903 pInfos[curr_rec_num].uMissleAttack1Type=ParseMissleAttackType(test_string); | |
694 | 904 break; |
905 case 20: | |
698 | 906 pInfos[curr_rec_num].uAttack2Chance=atoi(test_string); |
694 | 907 break; |
908 case 21: | |
698 | 909 pInfos[curr_rec_num].uAttack2Type=ParseAttackType(test_string); |
694 | 910 break; |
911 case 22: | |
912 { | |
698 | 913 ParseDamage(test_string, &pInfos[curr_rec_num].uAttack2DamageDiceRolls, |
914 &pInfos[curr_rec_num].uAttack2DamageDiceSides, | |
915 &pInfos[curr_rec_num].uAttack2DamageBonus); | |
694 | 916 } |
917 break; | |
918 case 23: | |
698 | 919 pInfos[curr_rec_num].uMissleAttack2Type=ParseMissleAttackType(test_string); |
694 | 920 break; |
921 case 24: | |
698 | 922 pInfos[curr_rec_num].uSpell1UseChance=atoi(test_string); |
694 | 923 break; |
924 case 25: | |
925 { | |
703 | 926 int param_num; |
927 char type_flag; | |
928 strcpy(parse_str,test_string); | |
929 parse_str[0]=' '; | |
930 parse_str[strlen(parse_str)-1]=' '; | |
751 | 931 frame_table_txt_parser(parse_str,&parsed_field); |
932 if (parsed_field.uPropCount>2) | |
703 | 933 { |
934 param_num=1; | |
751 | 935 pInfos[curr_rec_num].uSpell1ID=ParseSpellType(&parsed_field,¶m_num); |
936 type_flag=*parsed_field.pProperties[param_num]; | |
937 pInfos[curr_rec_num].uSpellSkillAndMastery1=atoi(parsed_field.pProperties[param_num+1])&0x003F; | |
703 | 938 switch(type_flag) |
939 { | |
940 case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0040; break; | |
941 case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0080; break; | |
942 case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0100; break; | |
943 } | |
944 } | |
945 else | |
946 { | |
947 pInfos[curr_rec_num].uSpell1ID=0; | |
948 pInfos[curr_rec_num].uSpellSkillAndMastery1=0; | |
949 } | |
694 | 950 |
951 } | |
952 break; | |
953 case 26: | |
698 | 954 pInfos[curr_rec_num].uSpell2UseChance=atoi(test_string); |
694 | 955 break; |
956 case 27: | |
957 { | |
703 | 958 int param_num; |
959 char type_flag; | |
960 strcpy(parse_str,test_string); | |
961 parse_str[0]=' '; | |
962 parse_str[strlen(parse_str)-1]=' '; | |
751 | 963 frame_table_txt_parser(parse_str,&parsed_field); |
964 if (parsed_field.uPropCount>2) | |
703 | 965 { |
966 param_num=1; | |
751 | 967 pInfos[curr_rec_num].uSpell2ID=ParseSpellType(&parsed_field,¶m_num); |
968 type_flag=*parsed_field.pProperties[param_num]; | |
969 pInfos[curr_rec_num].uSpellSkillAndMastery2=atoi(parsed_field.pProperties[param_num+1])&0x003F; | |
703 | 970 switch(type_flag) |
971 { | |
972 case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0040; break; | |
973 case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0080; break; | |
974 case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0100; break; | |
975 } | |
976 } | |
977 else | |
978 { | |
979 pInfos[curr_rec_num].uSpell2ID=0; | |
980 pInfos[curr_rec_num].uSpellSkillAndMastery2=0; | |
981 } | |
694 | 982 } |
983 break; | |
984 case 28: | |
985 { | |
698 | 986 if (tolower(test_string[0])=='i') |
987 pInfos[curr_rec_num].uResFire=200; | |
988 else | |
989 pInfos[curr_rec_num].uResFire=atoi(test_string); | |
694 | 990 } |
991 break; | |
992 case 29: | |
993 { | |
698 | 994 if (tolower(test_string[0])=='i') |
995 pInfos[curr_rec_num].uResAir=200; | |
996 else | |
997 pInfos[curr_rec_num].uResAir=atoi(test_string); | |
694 | 998 } |
999 break; | |
1000 case 30: | |
1001 { | |
698 | 1002 if (tolower(test_string[0])=='i') |
1003 pInfos[curr_rec_num].uResWater=200; | |
1004 else | |
1005 pInfos[curr_rec_num].uResWater=atoi(test_string); | |
694 | 1006 } |
1007 break; | |
1008 case 31: | |
1009 { | |
698 | 1010 if (tolower(test_string[0])=='i') |
1011 pInfos[curr_rec_num].uResEarth=200; | |
1012 else | |
1013 pInfos[curr_rec_num].uResEarth=atoi(test_string); | |
694 | 1014 } |
1015 break; | |
1016 case 32: | |
1017 { | |
698 | 1018 if (tolower(test_string[0])=='i') |
1019 pInfos[curr_rec_num].uResMind=200; | |
1020 else | |
1021 pInfos[curr_rec_num].uResMind=atoi(test_string); | |
694 | 1022 } |
1023 break; | |
1024 case 33: | |
1025 { | |
698 | 1026 if (tolower(test_string[0])=='i') |
1027 pInfos[curr_rec_num].uResSpirit=200; | |
1028 else | |
1029 pInfos[curr_rec_num].uResSpirit=atoi(test_string); | |
694 | 1030 } |
1031 break; | |
1032 case 34: | |
1033 { | |
698 | 1034 if (tolower(test_string[0])=='i') |
1035 pInfos[curr_rec_num].uResBody=200; | |
1036 else | |
1037 pInfos[curr_rec_num].uResBody=atoi(test_string); | |
694 | 1038 } |
1039 break; | |
1040 case 35: | |
1041 { | |
698 | 1042 if (tolower(test_string[0])=='i') |
1043 pInfos[curr_rec_num].uResLight=200; | |
1044 else | |
1045 pInfos[curr_rec_num].uResLight=atoi(test_string); | |
694 | 1046 } |
1047 break; | |
1048 case 36: | |
1049 { | |
698 | 1050 if (tolower(test_string[0])=='i') |
1051 pInfos[curr_rec_num].uResDark=200; | |
1052 else | |
1053 pInfos[curr_rec_num].uResDark=atoi(test_string); | |
694 | 1054 } |
1055 break; | |
1056 case 37: | |
1057 { | |
698 | 1058 if (tolower(test_string[0])=='i') |
1059 pInfos[curr_rec_num].uResPhysical=200; | |
1060 else | |
1061 pInfos[curr_rec_num].uResPhysical=atoi(test_string); | |
694 | 1062 } |
1063 break; | |
1064 case 38: | |
1065 { | |
751 | 1066 int param_num; |
1067 char type_flag; | |
1068 pInfos[curr_rec_num].uSpecialAbilityType=0; | |
1069 pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus=0; | |
1070 strcpy(parse_str,test_string); | |
1071 parse_str[0]=' '; | |
1072 parse_str[strlen(parse_str)-1]=' '; | |
1073 frame_table_txt_parser(parse_str,&parsed_field); | |
1074 if ( parsed_field.uPropCount ) | |
1075 { | |
1076 // v74 = v94.field_0; | |
1077 if ( parsed_field.uPropCount < 10 ) | |
1078 { | |
1104 | 1079 if (! _stricmp(parsed_field.pProperties[0], "shot") ) |
751 | 1080 { |
1081 pInfos[curr_rec_num].uSpecialAbilityType=1; | |
1082 pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus=atoi((char *)(parsed_field.pProperties[1] + 1)); | |
1083 } | |
1104 | 1084 else if (!_stricmp(parsed_field.pProperties[0], "summon") ) |
751 | 1085 { |
1086 pInfos[curr_rec_num].uSpecialAbilityType=2; | |
1087 if ( parsed_field.uPropCount > 1 ) | |
1088 { | |
1089 pTmpBuf[0] = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1090 strcpy(pTmpBuf.data(), parsed_field.pProperties[2]); |
751 | 1091 if ( parsed_field.uPropCount > 2 ) |
1092 { | |
1093 int prop_cnt = 3; | |
1094 if ( parsed_field.uPropCount > 3 ) | |
1095 { | |
1096 do | |
1097 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1098 strcat(pTmpBuf.data(), " "); |
751 | 1099 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
|
1100 strcat(pTmpBuf.data(), parsed_field.pProperties[prop_cnt]); |
751 | 1101 if ( prop_cnt == (parsed_field.uPropCount - 1) ) |
1102 { | |
1103 switch (tolower(test_char)) | |
1104 { | |
1105 case 'a': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 1; break; | |
1106 case 'b': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 2; break; | |
1107 case 'c': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 3; break; | |
1108 default: | |
1109 pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 0; | |
1110 } | |
1111 | |
1112 } | |
1113 ++prop_cnt; | |
1114 } | |
1115 while ( prop_cnt < parsed_field.uPropCount ); | |
1116 } | |
1117 } | |
1118 else | |
1119 { | |
1120 pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 0; | |
1121 } | |
1122 if ( pMonsterList->uNumMonsters ) | |
1123 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
1124 pInfos[curr_rec_num].field_3C_some_special_attack = pMonsterList->GetMonsterIDByName(pTmpBuf.data()) + 1; |
751 | 1125 if ( pInfos[curr_rec_num].field_3C_some_special_attack == -1 ) |
1126 { | |
1217 | 1127 sprintf(Src, "Can't create random monster: '%s' See MapStats!", pTmpBuf.data()); |
751 | 1128 MessageBoxA(nullptr, Src, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:2239", 0); |
1129 } | |
1130 } | |
1131 pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 0; | |
1104 | 1132 if ( !_stricmp(parsed_field.pProperties[1], "ground") ) |
751 | 1133 pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 1; |
1134 if ( pInfos[curr_rec_num].field_3C_some_special_attack == -1 ) | |
1135 pInfos[curr_rec_num].uSpecialAbilityType = 0; | |
1136 } | |
1137 } | |
1104 | 1138 else if (!_stricmp(parsed_field.pProperties[0], "explode") ) |
751 | 1139 { |
1140 pInfos[curr_rec_num].uSpecialAbilityType = 3; | |
1141 ParseDamage((char*)parsed_field.pProperties[1], &pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls, | |
1142 &pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides, | |
1143 &pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus); | |
1144 pInfos[curr_rec_num].field_3C_some_special_attack = ParseAttackType(test_string); | |
1145 } | |
1146 } | |
1147 } | |
694 | 1148 } |
698 | 1149 break; |
694 | 1150 } |
1151 } | |
1152 else | |
1153 { | |
1154 break_loop = true; | |
1155 } | |
1156 ++decode_step; | |
1157 test_string=tmp_pos+1; | |
1158 } while ((decode_step<39)&&!break_loop); | |
1159 } | |
1160 uNumMonsters = i; | |
0 | 1161 } |
1162 | |
1163 | |
1164 //----- (0044FA08) -------------------------------------------------------- | |
751 | 1165 signed __int16 MonsterList::GetMonsterIDByName( const char *pMonsterName ) |
0 | 1166 { |
751 | 1167 if (!pMonsterName) |
1168 return -1; | |
1169 for (signed __int16 i=1; i<=uNumMonsters; ++i) | |
1170 { | |
1104 | 1171 if( (!_stricmp(pMonsters[i].pMonsterName, pMonsterName))) |
751 | 1172 return i; |
0 | 1173 } |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1104
diff
changeset
|
1174 assert(false && "Monster not found!"); |
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1104
diff
changeset
|
1175 } |
1297 | 1176 //----- (00438BDF) -------------------------------------------------------- |
1177 bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype) | |
1178 { | |
1179 unsigned __int8 v2; // zf@15 | |
1180 char v3; // sf@15 | |
1181 unsigned __int8 v4; // of@15 | |
1182 bool result; // eax@33 | |
1183 | |
1184 switch ( eSupertype ) | |
1185 { | |
1186 case MONSTER_SUPERTYPE_UNDEAD: | |
1187 if ( (signed int)uMonsterInfoID >= MONSTER_GHOST_1 && (signed int)uMonsterInfoID <= MONSTER_GHOST_3 | |
1188 || (signed int)uMonsterInfoID >= MONSTER_LICH_1 && (signed int)uMonsterInfoID <= MONSTER_LICH_3 | |
1189 || (signed int)uMonsterInfoID >= MONSTER_SKELETON_1 && (signed int)uMonsterInfoID <= MONSTER_SKELETON_3 | |
1190 || (signed int)uMonsterInfoID >= MONSTER_VAMPIRE_1 && (signed int)uMonsterInfoID <= MONSTER_VAMPIRE_3 | |
1191 || (signed int)uMonsterInfoID >= MONSTER_WIGHT_1 && (signed int)uMonsterInfoID <= MONSTER_WIGHT_3 | |
1192 || (signed int)uMonsterInfoID >= MONSTER_ZOMBIE_1 && (signed int)uMonsterInfoID <= MONSTER_ZOMBIE_3 ) | |
1193 goto ret_true; | |
1194 if ( (signed int)uMonsterInfoID < MONSTER_GHOUL_1 ) | |
1195 goto ret_false; | |
1196 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_GHOUL_3); | |
1197 v2 = uMonsterInfoID == MONSTER_GHOUL_3; | |
1198 v3 = ((uMonsterInfoID - MONSTER_GHOUL_3) & 0x80000000u) != 0; | |
1199 goto false_if_outside; | |
1200 case MONSTER_SUPERTYPE_KREEGAN: | |
1201 if ( (signed int)uMonsterInfoID < MONSTER_DEVIL_1 ) | |
1202 goto ret_false; | |
1203 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DEVIL_3); | |
1204 v2 = uMonsterInfoID == MONSTER_DEVIL_3; | |
1205 v3 = ((uMonsterInfoID - MONSTER_DEVIL_3) & 0x80000000u) != 0; | |
1206 goto false_if_outside; | |
1207 case MONSTER_SUPERTYPE_ELF: | |
1208 if ( (signed int)uMonsterInfoID >= MONSTER_PEASANT_ELF_FEMALE_1_1 | |
1209 && (signed int)uMonsterInfoID <= MONSTER_PEASANT_ELF_MALE_3_3 | |
1210 || (signed int)uMonsterInfoID >= MONSTER_ELF_ARCHER_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_ARCHER_3 ) | |
1211 goto ret_true; | |
1212 if ( (signed int)uMonsterInfoID < MONSTER_ELF_SPEARMAN_1 ) | |
1213 goto ret_false; | |
1214 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELF_SPEARMAN_3); | |
1215 v2 = uMonsterInfoID == MONSTER_ELF_SPEARMAN_3; | |
1216 v3 = ((uMonsterInfoID - MONSTER_ELF_SPEARMAN_3) & 0x80000000u) != 0; | |
1217 goto false_if_outside; | |
1218 case MONSTER_SUPERTYPE_DRAGON: | |
1219 if ( (signed int)uMonsterInfoID < MONSTER_DRAGON_1 ) | |
1220 goto ret_false; | |
1221 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DRAGON_3); | |
1222 v2 = uMonsterInfoID == MONSTER_DRAGON_3; | |
1223 v3 = ((uMonsterInfoID - MONSTER_DRAGON_3) & 0x80000000u) != 0; | |
1224 goto false_if_outside; | |
1225 case MONSTER_SUPERTYPE_WATER_ELEMENTAL: | |
1226 if ( (signed int)uMonsterInfoID < MONSTER_ELEMENTAL_WATER_1 ) | |
1227 goto ret_false; | |
1228 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELEMENTAL_WATER_3); | |
1229 v2 = uMonsterInfoID == MONSTER_ELEMENTAL_WATER_3; | |
1230 v3 = ((uMonsterInfoID - MONSTER_ELEMENTAL_WATER_3) & 0x80000000u) != 0; | |
1231 goto false_if_outside; | |
1232 case MONSTER_SUPERTYPE_TREANT: | |
1233 if ( (signed int)uMonsterInfoID < MONSTER_TREANT_1 ) | |
1234 goto ret_false; | |
1235 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TREANT_3); | |
1236 v2 = uMonsterInfoID == MONSTER_TREANT_3; | |
1237 v3 = ((uMonsterInfoID - MONSTER_TREANT_3) & 0x80000000u) != 0; | |
1238 goto false_if_outside; | |
1239 case MONSTER_SUPERTYPE_TITAN: | |
1240 if ( (signed int)uMonsterInfoID < MONSTER_TITAN_1 ) | |
1241 goto ret_false; | |
1242 v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TITAN_3); | |
1243 v2 = uMonsterInfoID == MONSTER_TITAN_3; | |
1244 v3 = ((uMonsterInfoID - MONSTER_TITAN_3) & 0x80000000u) != 0; | |
1245 false_if_outside: | |
1246 if ( !((unsigned __int8)(v3 ^ v4) | v2) ) | |
1247 goto ret_false; | |
1248 ret_true: | |
1249 result = 1; | |
1250 break; | |
1251 default: | |
1252 ret_false: | |
1253 result = 0; | |
1254 break; | |
1255 } | |
1256 return result; | |
1257 } |