6 #include "../Tables/FrameTableInc.h"
14 void ParseDamage(
char *damage_str,
unsigned __int8 *dice_rolls,
15 unsigned __int8 *dice_sides,
unsigned __int8 *dmg_bonus);
31 }
else if (!_stricmp(tbl->
pProperties[0],
"Hour")) {
34 }
else if (!_stricmp(tbl->
pProperties[0],
"Shield")) {
36 }
else if (!_stricmp(tbl->
pProperties[0],
"Spirit")) {
39 }
else if (!_stricmp(tbl->
pProperties[0],
"Power")) {
42 }
else if (!_stricmp(tbl->
pProperties[0],
"Meteor")) {
45 }
else if (!_stricmp(tbl->
pProperties[0],
"Lightning")) {
48 }
else if (!_stricmp(tbl->
pProperties[0],
"Implosion")) {
50 }
else if (!_stricmp(tbl->
pProperties[0],
"Stone")) {
53 }
else if (!_stricmp(tbl->
pProperties[0],
"Haste")) {
55 }
else if (!_stricmp(tbl->
pProperties[0],
"Heroism")) {
57 }
else if (!_stricmp(tbl->
pProperties[0],
"Pain")) {
60 }
else if (!_stricmp(tbl->
pProperties[0],
"Sparks")) {
62 }
else if (!_stricmp(tbl->
pProperties[0],
"Light")) {
65 }
else if (!_stricmp(tbl->
pProperties[0],
"Toxic")) {
68 }
else if (!_stricmp(tbl->
pProperties[0],
"ShrapMetal")) {
70 }
else if (!_stricmp(tbl->
pProperties[0],
"Paralyze")) {
72 }
else if (!_stricmp(tbl->
pProperties[0],
"Fireball")) {
74 }
else if (!_stricmp(tbl->
pProperties[0],
"Incinerate")) {
76 }
else if (!_stricmp(tbl->
pProperties[0],
"Fire")) {
79 }
else if (!_stricmp(tbl->
pProperties[0],
"Rock")) {
82 }
else if (!_stricmp(tbl->
pProperties[0],
"Mass")) {
88 }
else if (!_stricmp(tbl->
pProperties[0],
"Acid")) {
91 }
else if (!_stricmp(tbl->
pProperties[0],
"Bless")) {
93 }
else if (!_stricmp(tbl->
pProperties[0],
"Dragon")) {
96 }
else if (!_stricmp(tbl->
pProperties[0],
"Reanimate")) {
98 }
else if (!_stricmp(tbl->
pProperties[0],
"Summon")) {
101 }
else if (!_stricmp(tbl->
pProperties[0],
"Fate")) {
103 }
else if (!_stricmp(tbl->
pProperties[0],
"Harm")) {
105 }
else if (!_stricmp(tbl->
pProperties[0],
"Mind")) {
108 }
else if (!_stricmp(tbl->
pProperties[0],
"Blades")) {
110 }
else if (!_stricmp(tbl->
pProperties[0],
"Psychic")) {
113 }
else if (!_stricmp(tbl->
pProperties[0],
"Hammerhands")) {
126 switch (tolower(*damage_type_str)) {
152 unsigned __int8 *dice_sides,
unsigned __int8 *dmg_bonus) {
155 bool dice_flag =
false;
161 str_len = strlen(damage_str);
162 if (str_len <= 0)
return;
163 for (str_pos = 0; str_pos < str_len; ++str_pos) {
164 if (tolower(damage_str[str_pos]) ==
'd') {
165 damage_str[str_pos] =
'\0';
166 *dice_rolls = atoi(damage_str);
167 *dice_sides = atoi(&damage_str[str_pos + 1]);
169 damage_str[str_pos] =
'd';
170 }
else if (tolower(damage_str[str_pos]) ==
'+') {
171 *dmg_bonus = atoi(&damage_str[str_pos + 1]);
175 if ((*damage_str >=
'0') && (*damage_str <=
'9')) {
176 *dice_rolls = atoi(damage_str);
184 if (!_stricmp(missle_attack_str,
"ARROW"))
186 else if (!_stricmp(missle_attack_str,
"ARROWF"))
188 else if (!_stricmp(missle_attack_str,
"FIRE"))
190 else if (!_stricmp(missle_attack_str,
"AIR"))
192 else if (!_stricmp(missle_attack_str,
"WATER"))
194 else if (!_stricmp(missle_attack_str,
"EARTH"))
196 else if (!_stricmp(missle_attack_str,
"SPIRIT"))
198 else if (!_stricmp(missle_attack_str,
"MIND"))
200 else if (!_stricmp(missle_attack_str,
"BODY"))
202 else if (!_stricmp(missle_attack_str,
"LIGHT"))
204 else if (!_stricmp(missle_attack_str,
"DARK"))
206 else if (!_stricmp(missle_attack_str,
"ENER"))
214 if (strstr(spec_att_str,
"curse"))
216 else if (strstr(spec_att_str,
"weak"))
218 else if (strstr(spec_att_str,
"asleep"))
220 else if (strstr(spec_att_str,
"afraid"))
222 else if (strstr(spec_att_str,
"drunk"))
224 else if (strstr(spec_att_str,
"insane"))
226 else if (strstr(spec_att_str,
"poison weak"))
228 else if (strstr(spec_att_str,
"poison medium"))
230 else if (strstr(spec_att_str,
"poison severe"))
232 else if (strstr(spec_att_str,
"disease weak"))
234 else if (strstr(spec_att_str,
"disease medium"))
236 else if (strstr(spec_att_str,
"disease severe"))
238 else if (strstr(spec_att_str,
"paralyze"))
240 else if (strstr(spec_att_str,
"uncon"))
242 else if (strstr(spec_att_str,
"dead"))
244 else if (strstr(spec_att_str,
"stone"))
246 else if (strstr(spec_att_str,
"errad"))
248 else if (strstr(spec_att_str,
"brkitem"))
250 else if (strstr(spec_att_str,
"brkarmor"))
252 else if (strstr(spec_att_str,
"brkweapon"))
254 else if (strstr(spec_att_str,
"steal"))
256 else if (strstr(spec_att_str,
"age"))
258 else if (strstr(spec_att_str,
"drainsp"))
275 unsigned __int16 v11;
277 unsigned __int16 v13;
284 unsigned __int16 v20;
311 v3 = fopen(Args,
"r");
313 if (!
v3) Error(
"MonsterRaceListStruct::load - Unable to open file: %s.");
317 if (fgets(&Buf, 490,
v3)) {
319 *strchr(&Buf, 10) = 0;
322 }
while (fgets(&Buf, 490, File));
325 v2->uNumMonsters = v4;
328 if (!v5) Error(
"MonsterRaceListStruct::load - Out of Memory!");
331 v2->uNumMonsters = 0;
333 for (i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File)) {
334 *strchr(&Buf, 10) = 0;
338 strcpy(
v2->pMonsters[
v2->uNumMonsters].pMonsterName,
357 strcpy(
v2->pMonsters[
v2->uNumMonsters]
358 .pSpriteNames[(
unsigned __int8)*(&v35 + v8)],
364 v2->pMonsters[
v2->uNumMonsters].uMonsterHeight = v9;
367 v2->pMonsters[
v2->uNumMonsters].uMovementSpeed = v11;
370 v2->pMonsters[
v2->uNumMonsters].uMonsterRadius = v13;
373 v2->pMonsters[
v2->uNumMonsters].uToHitRadius = v15;
374 v17 = (
unsigned __int8)atoi(v16);
378 v2->pMonsters[
v2->uNumMonsters].sTintColor =
379 v18 | ((v26 | ((Argsb | (v17 << 8)) << 8)) << 8);
384 v2->pMonsters[
v2->uNumMonsters].pSoundSampleIDs[v21] = v20;
395 uint num_mm6_monsters = data_mm6 ? *(
int *)data_mm6 : 0,
396 num_mm7_monsters = data_mm7 ? *(
int *)data_mm7 : 0,
397 num_mm8_monsters = data_mm8 ? *(
int *)data_mm8 : 0;
399 uNumMonsters = num_mm6_monsters + num_mm7_monsters + num_mm8_monsters;
401 Assert(!num_mm8_monsters);
406 for (
uint i = 0; i < num_mm6_monsters; ++i) {
411 dst->uMonsterRadius =
src->uMonsterRadius;
412 dst->uMovementSpeed =
src->uMovementSpeed;
413 dst->uToHitRadius =
src->uToHitRadius;
414 dst->sTintColor = -1;
415 memcpy(
dst->pSoundSampleIDs,
src->pSoundSampleIDs,
416 sizeof(
src->pSoundSampleIDs));
417 memcpy(
dst->pMonsterName,
src->pMonsterName,
sizeof(
src->pMonsterName));
418 memcpy(
dst->pSpriteNames,
src->pSpriteNames,
sizeof(
src->pSpriteNames));
420 memcpy(
pMonsters + num_mm6_monsters + num_mm7_monsters,
421 (
char *)data_mm8 + 4, num_mm8_monsters *
sizeof(
MonsterDesc));
431 v2 = fopen(
"data\\dmonlist.bin",
"wb");
433 if (!
v2) Error(
"Unable to save dmonlist.bin!");
434 fwrite(
v1, 4u, 1u,
v2);
435 fwrite(
v1->pMonsters, 0x98u,
v1->uNumMonsters,
v3);
441 const char *monster_textr_name) {
444 (!_stricmp(
pInfos[i].pPictureName, monster_textr_name)))
456 unsigned int temp_str_len;
463 for (i = 1; i < 31; ++i) {
464 test_string = strtok(NULL,
"\r") + 1;
468 c = *(
unsigned char *)test_string;
470 while ((
c !=
'\t') && (
c > 0)) {
472 c = test_string[temp_str_len];
474 tmp_pos = test_string + temp_str_len;
475 if (*tmp_pos == 0) break_loop =
true;
478 if (decode_step == 1)
484 test_string = tmp_pos + 1;
485 }
while ((decode_step < 3) && !break_loop);
496 unsigned int temp_str_len;
515 test_string = strtok(NULL,
"\r") + 1;
519 c = *(
unsigned char *)test_string;
521 while ((
c !=
'\t') && (
c > 0)) {
523 c = test_string[temp_str_len];
525 tmp_pos = test_string + temp_str_len;
526 if (*tmp_pos == 0) break_loop =
true;
529 switch (decode_step) {
531 curr_rec_num = atoi(test_string);
548 if (test_string[0] ==
'"') test_string[0] =
' ';
549 str_len = strlen(test_string);
550 if (str_len == 0)
break;
551 while ((test_string[str_pos] !=
',') &&
554 if (str_len == str_pos) {
555 pInfos[curr_rec_num].
uHP = atoi(test_string);
557 test_string[str_pos] =
'\0';
558 pInfos[curr_rec_num].
uHP = 1000 * atoi(test_string);
560 atoi(&test_string[str_pos + 1]);
561 test_string[str_pos] =
',';
565 pInfos[curr_rec_num].
uAC = atoi(test_string);
571 if (test_string[0] ==
'"') test_string[0] =
' ';
572 str_len = strlen(test_string);
573 if (str_len == 0)
break;
574 while ((test_string[str_pos] !=
',') &&
577 if (str_len == str_pos) {
578 pInfos[curr_rec_num].
uExp = atoi(test_string);
580 test_string[str_pos] =
'\0';
582 1000 * atoi(test_string);
584 atoi(&test_string[str_pos + 1]);
585 test_string[str_pos] =
',';
591 bool chance_flag =
false;
592 bool dice_flag =
false;
593 bool item_type_flag =
false;
600 if (test_string[0] ==
'"') test_string[0] =
' ';
601 str_len = strlen(test_string);
603 switch (tolower(test_string[str_pos])) {
611 item_type_flag =
true;
615 }
while (str_pos < str_len);
620 if ((!dice_flag) && (!item_type_flag))
break;
627 switch (tolower(test_string[str_pos])) {
631 atoi(&test_string[str_pos + 1]);
641 atoi(&test_string[str_pos + 1]);
646 }
while (str_pos < str_len);
648 if (item_type_flag) {
651 if (tolower(test_string[str_pos]) ==
'l')
break;
653 }
while (str_pos < str_len);
656 test_string[str_pos + 1] -
'0';
657 item_name = &test_string[str_pos + 2];
659 if (!_stricmp(item_name,
"WEAPON"))
661 else if (!_stricmp(item_name,
"ARMOR"))
663 else if (!_stricmp(item_name,
"MISC"))
665 else if (!_stricmp(item_name,
"SWORD"))
667 else if (!_stricmp(item_name,
"DAGGER"))
669 else if (!_stricmp(item_name,
"AXE"))
671 else if (!_stricmp(item_name,
"SPEAR"))
673 else if (!_stricmp(item_name,
"BOW"))
675 else if (!_stricmp(item_name,
"MACE"))
677 else if (!_stricmp(item_name,
"CLUB"))
679 else if (!_stricmp(item_name,
"STAFF"))
681 else if (!_stricmp(item_name,
"LEATHER"))
683 else if (!_stricmp(item_name,
"CHAIN"))
685 else if (!_stricmp(item_name,
"PLATE"))
687 else if (!_stricmp(item_name,
"SHIELD"))
689 else if (!_stricmp(item_name,
"HELM"))
691 else if (!_stricmp(item_name,
"BELT"))
693 else if (!_stricmp(item_name,
"CAPE"))
695 else if (!_stricmp(item_name,
"GAUNTLETS"))
697 else if (!_stricmp(item_name,
"BOOTS"))
699 else if (!_stricmp(item_name,
"RING"))
701 else if (!_stricmp(item_name,
"AMULET"))
703 else if (!_stricmp(item_name,
"WAND"))
705 else if (!_stricmp(item_name,
"SCROLL"))
707 else if (!_stricmp(item_name,
"GEM"))
714 if (atoi(test_string))
719 if (_strnicmp(test_string,
"n", 1))
723 switch (tolower(test_string[0])) {
727 if (tolower(test_string[1]) !=
'h')
749 switch (tolower(test_string[0])) {
779 str_len = strlen(test_string);
780 for (str_pos = 0; str_pos < str_len; ++str_pos) {
781 switch (tolower(test_string[str_pos])) {
866 str_len = strlen(test_string);
868 for (str_pos = 0; str_pos < str_len; ++str_pos) {
869 if (tolower(test_string[str_pos]) ==
'x') {
870 test_string[str_pos] =
'\0';
872 atoi(&test_string[str_pos + 1]);
873 test_string[str_pos] =
'x';
889 &
pInfos[curr_rec_num].uAttack1DamageDiceRolls,
890 &
pInfos[curr_rec_num].uAttack1DamageDiceSides,
891 &
pInfos[curr_rec_num].uAttack1DamageBonus);
907 &
pInfos[curr_rec_num].uAttack2DamageDiceRolls,
908 &
pInfos[curr_rec_num].uAttack2DamageDiceSides,
909 &
pInfos[curr_rec_num].uAttack2DamageBonus);
922 strcpy(parse_str, test_string);
924 parse_str[strlen(parse_str) - 1] =
' ';
960 strcpy(parse_str, test_string);
962 parse_str[strlen(parse_str) - 1] =
' ';
992 if (tolower(test_string[0]) ==
'i')
998 if (tolower(test_string[0]) ==
'i')
1004 if (tolower(test_string[0]) ==
'i')
1010 if (tolower(test_string[0]) ==
'i')
1016 if (tolower(test_string[0]) ==
'i')
1022 if (tolower(test_string[0]) ==
'i')
1028 if (tolower(test_string[0]) ==
'i')
1034 if (tolower(test_string[0]) ==
'i')
1040 if (tolower(test_string[0]) ==
'i')
1046 if (tolower(test_string[0]) ==
'i')
1057 strcpy(parse_str, test_string);
1059 parse_str[strlen(parse_str) - 1] =
' ';
1072 }
else if (!_stricmp(
1135 .field_3C_some_special_attack ==
1140 "Can't create random "
1141 "monster: '%s' See "
1155 .field_3C_some_special_attack ==
1160 }
else if (!_stricmp(
1185 test_string = tmp_pos + 1;
1186 }
while ((decode_step < 39) && !break_loop);
1193 if (!pMonsterName)
return -1;
1195 if ((!_stricmp(
pMonsters[i].pMonsterName, pMonsterName)))
return i;
1197 Error(
"Monster not found: %s", pMonsterName);
1202 switch (eSupertype) {
1231 (
signed int)uMonsterInfoID <=
1237 (
signed int)uMonsterInfoID <=
1248 (
signed int)uMonsterInfoID <=