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