comparison Monsters.cpp @ 703:a9c1fb7483c2

monster parser almost complete.
author Gloval
date Tue, 19 Mar 2013 01:33:35 +0400
parents d5b16a44d9b3
children 6005142abce0
comparison
equal deleted inserted replaced
701:d5b16a44d9b3 703:a9c1fb7483c2
14 14
15 15
16 struct MonsterStats *pMonsterStats; 16 struct MonsterStats *pMonsterStats;
17 struct MonsterList *pMonsterList; 17 struct MonsterList *pMonsterList;
18 18
19 unsigned int __fastcall ParseSpellType(struct FrameTableTxtLine *, int a2); 19 unsigned int ParseSpellType(struct FrameTableTxtLine* tbl, int* next_token);
20 20
21 int ParseAttackType(const char *damage_type_str); 21 int ParseAttackType(const char *damage_type_str);
22 void ParseDamage( char *damage_str, unsigned __int8* dice_rolls, unsigned __int8* dice_sides, unsigned __int8* dmg_bonus ); 22 void ParseDamage( char *damage_str, unsigned __int8* dice_rolls, unsigned __int8* dice_sides, unsigned __int8* dmg_bonus );
23 int ParseMissleAttackType(const char *missle_attack_str); 23 int ParseMissleAttackType(const char *missle_attack_str);
24 int ParseSpecialAttack(const char *spec_att_str); 24 int ParseSpecialAttack(const char *spec_att_str);
25 25
26 //----- (004548E2) -------------------------------------------------------- 26 //----- (004548E2) --------------------------------------------------------
27 unsigned int __fastcall ParseSpellType(FrameTableTxtLine *a1, int a2) 27 unsigned int ParseSpellType( struct FrameTableTxtLine * tbl, int* next_token )
28 { 28 {
29 int v2; // edi@1 29
30 int v3; // esi@1 30 if (!tbl->pProperties[0] )
31 unsigned int result; // eax@1 31 {
32 std::string v5; // [sp-18h] [bp-28h]@75 32 ++*next_token;
33 const char *v6; // [sp-8h] [bp-18h]@75 33 return 0;
34 signed int v7; // [sp-4h] [bp-14h]@3 34 }
35 std::string *v8; // [sp+8h] [bp-8h]@75 35 if ( !_strcmpi(tbl->pProperties[0], "Dispel") ) //dispel magic
36 int a3; // [sp+Fh] [bp-1h]@75 36 {
37 37 ++*next_token;
38 v2 = (int)a1; 38 return 80;
39 v3 = a2; 39 }
40 result = (int)a1->pProperties[0]; 40 else if ( !_strcmpi(tbl->pProperties[0], "Day") ) //day of protection
41 if ( result ) 41 {
42 { 42 *next_token+=2;;
43 if ( !_strcmpi((const char *)result, "Dispel") ) 43 return 85;
44 { 44 }
45 v7 = 80; 45 else if ( !_strcmpi(tbl->pProperties[0], "Hour") ) //hour of power
46 LABEL_71: 46 {
47 result = v7; 47 *next_token+=2;;
48 LABEL_76: 48 return 86;
49 ++*(int *)v3; 49 }
50 return result; 50 else if ( !_strcmpi(tbl->pProperties[0], "Shield") )
51 } 51 return 17;
52 if ( _strcmpi(*(const char **)(v2 + 4), "Day") ) 52 else if ( !_strcmpi(tbl->pProperties[0], "Spirit") )
53 { 53 {
54 if ( _strcmpi(*(const char **)(v2 + 4), "Hour") ) 54 ++*next_token;
55 { 55 return 52;
56 if ( _strcmpi(*(const char **)(v2 + 4), "Shield") ) 56 }
57 { 57 else if ( !_strcmpi(tbl->pProperties[0], "Power") ) //power cure
58 if ( !_strcmpi(*(const char **)(v2 + 4), "Spirit") ) 58 {
59 { 59 ++*next_token;
60 v7 = 52; 60 return 77;
61 goto LABEL_71; 61 }
62 } 62 else if ( !_strcmpi(tbl->pProperties[0], "Meteor") ) //meteot shower
63 if ( !_strcmpi(*(const char **)(v2 + 4), "Power") ) 63 {
64 { 64 ++*next_token;
65 v7 = 77; 65 return 9;
66 goto LABEL_71; 66 }
67 } 67 else if ( !_strcmpi(tbl->pProperties[0], "Lightning") ) //Lightning bolt
68 if ( !_strcmpi(*(const char **)(v2 + 4), "Meteor") ) 68 {
69 { 69 ++*next_token;
70 v7 = 9; 70 return 18;
71 goto LABEL_71; 71 }
72 } 72 else if ( !_strcmpi(tbl->pProperties[0], "Implosion") )
73 if ( !_strcmpi(*(const char **)(v2 + 4), "Lightning") ) 73 return 20;
74 { 74 else if ( !_strcmpi(tbl->pProperties[0], "Stone") )
75 v7 = 18; 75 {
76 goto LABEL_71; 76 ++*next_token;
77 } 77 return 38;
78 if ( _strcmpi(*(const char **)(v2 + 4), "Implosion") ) 78 }
79 { 79 else if ( !_strcmpi(tbl->pProperties[0], "Haste") )
80 if ( !_strcmpi(*(const char **)(v2 + 4), "Stone") ) 80 return 5;
81 { 81 else if ( !_strcmpi(tbl->pProperties[0], "Heroism") )
82 v7 = 38; 82 return 51;
83 goto LABEL_71; 83 else if ( !_strcmpi(tbl->pProperties[0], "Pain") ) //pain reflection
84 } 84 {
85 if ( _strcmpi(*(const char **)(v2 + 4), "Haste") ) 85 ++*next_token;
86 { 86 return 95;
87 if ( _strcmpi(*(const char **)(v2 + 4), "Heroism") ) 87 }
88 { 88 else if ( !_strcmpi(tbl->pProperties[0], "Sparks") )
89 if ( !_strcmpi(*(const char **)(v2 + 4), "Pain") ) 89 return 15;
90 { 90 else if ( !_strcmpi(tbl->pProperties[0], "Light") )
91 v7 = 95; 91 {
92 goto LABEL_71; 92 ++*next_token;
93 } 93 return 78;
94 if ( _strcmpi(*(const char **)(v2 + 4), "Sparks") ) 94 }
95 { 95 else if ( !_strcmpi(tbl->pProperties[0], "Toxic") ) //toxic cloud
96 if ( !_strcmpi(*(const char **)(v2 + 4), "Light") ) 96 {
97 { 97 ++*next_token;
98 v7 = 78; 98 return 90;
99 goto LABEL_71; 99 }
100 } 100 else if ( !_strcmpi(tbl->pProperties[0], "ShrapMetal") )
101 if ( !_strcmpi(*(const char **)(v2 + 4), "Toxic") ) 101 return 93;
102 { 102 else if ( !_strcmpi(tbl->pProperties[0], "Paralyze") )
103 v7 = 90; 103 return 81;
104 goto LABEL_71; 104 else if ( !_strcmpi(tbl->pProperties[0], "Fireball") )
105 } 105 return 6;
106 if ( _strcmpi(*(const char **)(v2 + 4), "ShrapMetal") ) 106 else if ( !_strcmpi(tbl->pProperties[0], "Incinerate") )
107 { 107 return 11;
108 if ( _strcmpi(*(const char **)(v2 + 4), "Paralyze") ) 108 else if ( !_strcmpi(tbl->pProperties[0], "Fire") )
109 { 109 {
110 if ( _strcmpi(*(const char **)(v2 + 4), "Fireball") ) 110 ++*next_token;
111 { 111 return 2;
112 if ( _strcmpi(*(const char **)(v2 + 4), "Incinerate") ) 112 }
113 { 113 else if ( !_strcmpi(tbl->pProperties[0], "Rock") )
114 if ( !_strcmpi(*(const char **)(v2 + 4), "Fire") ) 114 {
115 { 115 ++*next_token;
116 v7 = 2; 116 return 41;
117 goto LABEL_71; 117 }
118 } 118 else if ( !_strcmpi(tbl->pProperties[0], "Mass") )
119 if ( !_strcmpi(*(const char **)(v2 + 4), "Rock") ) 119 {
120 { 120 ++*next_token;
121 v7 = 41; 121 return 44;
122 goto LABEL_71; 122 }
123 } 123 else if ( !_strcmpi(tbl->pProperties[0], "Ice") )
124 if ( !_strcmpi(*(const char **)(v2 + 4), "Mass") ) 124 {
125 { 125 ++*next_token;
126 v7 = 44; 126 return 26;
127 goto LABEL_71; 127 }
128 } 128 else if ( !_strcmpi(tbl->pProperties[0], "Acid") )
129 if ( !_strcmpi(*(const char **)(v2 + 4), "Ice") ) 129 {
130 { 130 ++*next_token;
131 v7 = 26; 131 return 29;
132 goto LABEL_71; 132 }
133 } 133 else if ( !_strcmpi(tbl->pProperties[0], "Bless") )
134 if ( !_strcmpi(*(const char **)(v2 + 4), "Acid") ) 134 return 46;
135 { 135 else if ( !_strcmpi(tbl->pProperties[0], "Dragon") )
136 v7 = 29; 136 {
137 goto LABEL_71; 137 ++*next_token;
138 } 138 return 97;
139 if ( _strcmpi(*(const char **)(v2 + 4), "Bless") ) 139 }
140 { 140 else if ( !_strcmpi(tbl->pProperties[0], "Reanimate") )
141 if ( !_strcmpi(*(const char **)(v2 + 4), "Dragon") ) 141 return 89;
142 { 142 else if ( !_strcmpi(tbl->pProperties[0], "Summon") )
143 v7 = 97; 143 {
144 goto LABEL_71; 144 ++*next_token;
145 } 145 return 82;
146 if ( _strcmpi(*(const char **)(v2 + 4), "Reanimate") ) 146 }
147 { 147 else if ( !_strcmpi(tbl->pProperties[0], "Fate") )
148 if ( !_strcmpi(*(const char **)(v2 + 4), "Summon") ) 148 return 47;
149 { 149 else if ( !_strcmpi(tbl->pProperties[0], "Harm") )
150 v7 = 82; 150 return 70;
151 goto LABEL_71; 151 else if ( !_strcmpi(tbl->pProperties[0], "Mind") )
152 } 152 {
153 if ( _strcmpi(*(const char **)(v2 + 4), "Fate") ) 153 ++*next_token;
154 { 154 return 57;
155 if ( _strcmpi(*(const char **)(v2 + 4), "Harm") ) 155 }
156 { 156 else if ( !_strcmpi(tbl->pProperties[0], "Blades") )
157 if ( !_strcmpi(*(const char **)(v2 + 4), "Mind") ) 157 return 39;
158 { 158 else if ( !_strcmpi(tbl->pProperties[0], "Psychic") )
159 v7 = 57; 159 {
160 goto LABEL_71; 160 ++*next_token;
161 } 161 return 65;
162 if ( _strcmpi(*(const char **)(v2 + 4), "Blades") ) 162 }
163 { 163 else if ( !_strcmpi(tbl->pProperties[0], "Hammerhands") )
164 if ( !_strcmpi(*(const char **)(v2 + 4), "Psychic") ) 164 return 73;
165 { 165 else
166 v7 = 65; 166 {
167 goto LABEL_71; 167 sprintf(pTmpBuf, "Unknown monster spell %s", tbl->pProperties[0]);
168 } 168 MessageBoxA(nullptr, pTmpBuf, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:1562", 0);
169 if ( _strcmpi(*(const char **)(v2 + 4), "Hammerhands") ) 169 ++*next_token;
170 { 170 return 0;
171 sprintf(pTmpBuf, "Unknown monster spell %s", *(int *)(v2 + 4)); 171 }
172 MessageBoxA(nullptr, pTmpBuf, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:1562", 0);
173 result = 0;
174 goto LABEL_76;
175 }
176 v7 = 73;
177 }
178 else
179 {
180 v7 = 39;
181 }
182 }
183 else
184 {
185 v7 = 70;
186 }
187 }
188 else
189 {
190 v7 = 47;
191 }
192 }
193 else
194 {
195 v7 = 89;
196 }
197 }
198 else
199 {
200 v7 = 46;
201 }
202 }
203 else
204 {
205 v7 = 11;
206 }
207 }
208 else
209 {
210 v7 = 6;
211 }
212 }
213 else
214 {
215 v7 = 81;
216 }
217 }
218 else
219 {
220 v7 = 93;
221 }
222 }
223 else
224 {
225 v7 = 15;
226 }
227 }
228 else
229 {
230 v7 = 51;
231 }
232 }
233 else
234 {
235 v7 = 5;
236 }
237 }
238 else
239 {
240 v7 = 20;
241 }
242 }
243 else
244 {
245 v7 = 17;
246 }
247 return v7;
248 }
249 v7 = 86;
250 }
251 else
252 {
253 v7 = 85;
254 }
255 *(int *)v3 += 2;
256 result = v7;
257 }
258 return result;
259 } 172 }
260 173
261 //----- (00454CB4) -------------------------------------------------------- 174 //----- (00454CB4) --------------------------------------------------------
262 int ParseAttackType( const char *damage_type_str ) 175 int ParseAttackType( const char *damage_type_str )
263 { 176 {
346 return 13; 259 return 13;
347 else return 0; 260 else return 0;
348 } 261 }
349 262
350 263
351 int ParseSpecialAttack(const char *spec_att_str) 264 int ParseSpecialAttack(char *spec_att_str)
352 { 265 {
266 _strlwr(spec_att_str);
353 if ( strstr(spec_att_str, "curse") ) 267 if ( strstr(spec_att_str, "curse") )
354 return 1; 268 return 1;
355 else if ( strstr(spec_att_str, "weak") ) 269 else if ( strstr(spec_att_str, "weak") )
356 return 2; 270 return 2;
357 else if ( strstr(spec_att_str, "asleep") ) 271 else if ( strstr(spec_att_str, "asleep") )
740 FrameTableTxtLine v86; // [sp+8Ch] [bp-3CCh]@249 654 FrameTableTxtLine v86; // [sp+8Ch] [bp-3CCh]@249
741 FrameTableTxtLine v87; // [sp+108h] [bp-350h]@240 655 FrameTableTxtLine v87; // [sp+108h] [bp-350h]@240
742 char Src[120]; // [sp+184h] [bp-2D4h]@317 656 char Src[120]; // [sp+184h] [bp-2D4h]@317
743 FrameTableTxtLine v89; // [sp+1FCh] [bp-25Ch]@249 657 FrameTableTxtLine v89; // [sp+1FCh] [bp-25Ch]@249
744 FrameTableTxtLine v90; // [sp+278h] [bp-1E0h]@240 658 FrameTableTxtLine v90; // [sp+278h] [bp-1E0h]@240
745 char Str[64]; // [sp+2F4h] [bp-164h]@240 659
746 char Dest[64]; // [sp+334h] [bp-124h]@249 660 char Dest[64]; // [sp+334h] [bp-124h]@249
747 char v93[64]; // [sp+374h] [bp-E4h]@297 661 char v93[64]; // [sp+374h] [bp-E4h]@297
748 FrameTableTxtLine v94; // [sp+3B4h] [bp-A4h]@297 662 FrameTableTxtLine v94; // [sp+3B4h] [bp-A4h]@297
749 int v95; // [sp+430h] [bp-28h]@317 663 int v95; // [sp+430h] [bp-28h]@317
750 int v96; // [sp+434h] [bp-24h]@9 664 int v96; // [sp+434h] [bp-24h]@9
763 unsigned int temp_str_len; 677 unsigned int temp_str_len;
764 char* tmp_pos; 678 char* tmp_pos;
765 int decode_step; 679 int decode_step;
766 int item_counter; 680 int item_counter;
767 int curr_rec_num; 681 int curr_rec_num;
682 char parse_str[64];
768 683
769 v1 = this; 684 v1 = this;
770 v102 = this; 685 v102 = this;
771 if ( pMonstersTXT_Raw ) 686 if ( pMonstersTXT_Raw )
772 pAllocator->FreeChunk(pMonstersTXT_Raw); 687 pAllocator->FreeChunk(pMonstersTXT_Raw);
1077 } 992 }
1078 } 993 }
1079 break; 994 break;
1080 case 16: 995 case 16:
1081 { 996 {
1082 997 int str_len=0;
998 int str_pos=0;
999 pInfos[curr_rec_num].uSpecialAttackType=1;
1000 pInfos[curr_rec_num].uSpecialAttack=0;
1001 str_len=strlen(test_string);
1002 if (str_len>1)
1003 {
1004 for (str_pos=0;str_pos<str_len;++str_pos )
1005 {
1006 if (tolower(test_string[str_pos])=='x')
1007 {
1008 test_string[str_pos]='\0';
1009 pInfos[curr_rec_num].uSpecialAttackType=atoi(&test_string[str_pos+1]);
1010 test_string[str_pos]='x';
1011 break;
1012 }
1013 }
1014 pInfos[curr_rec_num].uSpecialAttack=ParseSpecialAttack(test_string);
1015 }
1083 } 1016 }
1084 break; 1017 break;
1085 case 17: 1018 case 17:
1086 pInfos[curr_rec_num].uAttack1Type=ParseAttackType(test_string); 1019 pInfos[curr_rec_num].uAttack1Type=ParseAttackType(test_string);
1087 break; 1020 break;
1114 case 24: 1047 case 24:
1115 pInfos[curr_rec_num].uSpell1UseChance=atoi(test_string); 1048 pInfos[curr_rec_num].uSpell1UseChance=atoi(test_string);
1116 break; 1049 break;
1117 case 25: 1050 case 25:
1118 { 1051 {
1052 int param_num;
1053 char type_flag;
1054 strcpy(parse_str,test_string);
1055 parse_str[0]=' ';
1056 parse_str[strlen(parse_str)-1]=' ';
1057 frame_table_txt_parser(parse_str,&v85);
1058 if (v85.uPropCount>2)
1059 {
1060 param_num=1;
1061 pInfos[curr_rec_num].uSpell1ID=ParseSpellType(&v85,&param_num);
1062 type_flag=*v85.pProperties[param_num];
1063 pInfos[curr_rec_num].uSpellSkillAndMastery1=atoi(v85.pProperties[param_num+1])&0x003F;
1064 switch(type_flag)
1065 {
1066 case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0040; break;
1067 case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0080; break;
1068 case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0100; break;
1069 }
1070 }
1071 else
1072 {
1073 pInfos[curr_rec_num].uSpell1ID=0;
1074 pInfos[curr_rec_num].uSpellSkillAndMastery1=0;
1075 }
1119 1076
1120 } 1077 }
1121 break; 1078 break;
1122 case 26: 1079 case 26:
1123 pInfos[curr_rec_num].uSpell2UseChance=atoi(test_string); 1080 pInfos[curr_rec_num].uSpell2UseChance=atoi(test_string);
1124 break; 1081 break;
1125 case 27: 1082 case 27:
1126 { 1083 {
1127 1084 int param_num;
1085 char type_flag;
1086 strcpy(parse_str,test_string);
1087 parse_str[0]=' ';
1088 parse_str[strlen(parse_str)-1]=' ';
1089 frame_table_txt_parser(parse_str,&v85);
1090 if (v85.uPropCount>2)
1091 {
1092 param_num=1;
1093 pInfos[curr_rec_num].uSpell2ID=ParseSpellType(&v85,&param_num);
1094 type_flag=*v85.pProperties[param_num];
1095 pInfos[curr_rec_num].uSpellSkillAndMastery2=atoi(v85.pProperties[param_num+1])&0x003F;
1096 switch(type_flag)
1097 {
1098 case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0040; break;
1099 case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0080; break;
1100 case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0100; break;
1101 }
1102 }
1103 else
1104 {
1105 pInfos[curr_rec_num].uSpell2ID=0;
1106 pInfos[curr_rec_num].uSpellSkillAndMastery2=0;
1107 }
1128 } 1108 }
1129 break; 1109 break;
1130 case 28: 1110 case 28:
1131 { 1111 {
1132 if (tolower(test_string[0])=='i') 1112 if (tolower(test_string[0])=='i')