Mercurial > mm7
annotate Arcomage.cpp @ 2454:16f0278279a5
removed CShow.cpp/.h files
author | Ritor1 |
---|---|
date | Fri, 25 Jul 2014 15:47:11 +0600 |
parents | 2a8010d99cf8 |
children | e5c88c2b02ab |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2216
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
0 | 6 #include <string> |
2336 | 7 #include "mm7_unsorted_subs.h" |
0 | 8 |
1254 | 9 #include "Render.h" |
0 | 10 #include "Arcomage.h" |
2450 | 11 #include "MediaPlayer.h" |
0 | 12 #include "AudioPlayer.h" |
13 #include "Mouse.h" | |
14 #include "Game.h" | |
15 #include "Viewport.h" | |
2044 | 16 #include "Timer.h" |
0 | 17 #include "GUIFont.h" |
18 #include "Party.h" | |
19 #include "GUIWindow.h" | |
20 #include "Events2D.h" | |
21 #include "VectorTypes.h" | |
189 | 22 #include "texts.h" |
1183 | 23 #include <windef.h> |
1262 | 24 #include "mm7_data.h" |
2453 | 25 #include "UI/UIHouses.h" |
0 | 26 |
27 | |
28 | |
1197 | 29 void SetStartConditions(); |
30 void SetStartGameData(); | |
31 void FillPlayerDeck(); | |
1200 | 32 void InitalHandsFill(); |
33 void GetNextCardFromDeck(int player_num); | |
1185 | 34 int GetEmptyCardSlotIndex(int player_num); |
1197 | 35 void IncreaseResourcesInTurn(int player_num); |
1263 | 36 void TurnChange(); |
1256 | 37 bool IsGameOver(); |
38 int CalculateCardPower(ArcomagePlayer* player, ArcomagePlayer* enemy, ArcomageCard* pCard, int mastery); | |
39 char PlayerTurn(int player_num); | |
1263 | 40 void DrawGameUI(int animation_stage); |
41 void DrawSparks(); | |
1197 | 42 void DrawRectanglesForText(); |
43 void DrawPlayersText(); | |
1263 | 44 void DrawPlayerLevels(int a1, char *text, POINT *pXY); |
45 void DrawBricksCount(int a1, char* text, POINT *pXY); | |
1197 | 46 void DrawGemsCount(int a1, char* text, POINT* pXY); |
1263 | 47 void DrawBeastsCount(int a1, char *text, POINT *pXY); |
1209 | 48 void DrawPlayersTowers(); |
49 void DrawPlayersWall(); | |
50 void DrawCards(); | |
1218 | 51 void DrawCardAnimation(int a1); |
1185 | 52 int GetPlayerHandCardCount(int player_num); |
1679 | 53 int DrawCardsRectangles(int player_num); |
54 bool DiscardCard(int player_num, int card_slot_index); | |
55 bool PlayCard(int player_num, int card_slot_num); | |
1200 | 56 bool CanCardBePlayed(int player_num, int hand_card_indx); |
1263 | 57 void ApplyCardToPlayer(int player_num, unsigned int uCardID); |
1185 | 58 int am_40D2B4(POINT* a1, int a2); // weak |
1246 | 59 int ApplyDamageToBuildings(int player_num, int damage); // weak |
1218 | 60 void GameResultsApply(); |
1183 | 61 |
1679 | 62 void am_DrawText(int a1, const char *pText, POINT *pXY); |
2154 | 63 void am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3); // idb |
64 void am_EndScene(); | |
1263 | 65 void DrawRect(RECT *pXYZW, unsigned __int16 uColor, char bSolidFill); |
1679 | 66 void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor ); |
67 void DrawPixel(POINT *pTargetXY, unsigned __int16 uColor); | |
1263 | 68 int rand_interval(int min, int max); // idb |
1679 | 69 void __fastcall am_IntToString(int val, char *pOut); |
938 | 70 |
1393 | 71 //----- (0040DEDB) -------------------------------------------------------- |
72 unsigned int R8G8B8_to_TargetFormat(int uColor) | |
73 { | |
2069 | 74 return Color16(LOBYTE(uColor), BYTE1(uColor), BYTE2(uColor)); |
1393 | 75 } |
76 | |
938 | 77 /* 388 */ |
78 #pragma pack(push, 1) | |
1197 | 79 struct ArcomageStartConditions |
938 | 80 { |
1197 | 81 __int16 max_tower; |
82 __int16 max_resources; | |
83 __int16 tower_height; | |
84 __int16 wall_height; | |
85 __int16 quarry_level; | |
86 __int16 magic_level; | |
1200 | 87 __int16 zoo_level; |
1197 | 88 __int16 bricks_amount; |
89 __int16 gems_amount; | |
90 __int16 beasts_amount; | |
1256 | 91 int mastery_lvl; |
938 | 92 }; |
93 #pragma pack(pop) | |
1256 | 94 const ArcomageStartConditions start_conditions[13] = |
938 | 95 { |
96 { 30, 100, 15, 5, 2, 2, 2, 10, 10, 10, 0}, | |
97 { 50, 150, 20, 5, 2, 2, 2, 5, 5, 5, 1}, | |
98 { 50, 150, 20, 5, 2, 2, 2, 5, 5, 5, 2}, | |
99 { 75, 200, 25, 10, 3, 3, 3, 5, 5, 5, 2}, | |
100 { 75, 200, 20, 10, 3, 3, 3, 5, 5, 5, 1}, | |
101 {100, 300, 30, 15, 4, 4, 4, 10, 10, 10, 1}, | |
102 {100, 300, 30, 15, 4, 4, 4, 10, 10, 10, 2}, | |
103 {150, 400, 20, 10, 5, 5, 5, 25, 25, 25, 0}, | |
104 {200, 500, 20, 10, 1, 1, 1, 15, 15, 15, 2}, | |
105 {100, 300, 20, 50, 1, 1, 5, 5, 5, 25, 0}, | |
106 {125, 350, 10, 20, 3, 1, 2, 15, 5, 10, 2}, | |
107 {125, 350, 10, 20, 3, 1, 2, 15, 5, 10, 1}, | |
108 {100, 300, 50, 50, 5, 3, 5, 20, 10, 20, 0} | |
109 }; | |
110 | |
1184 | 111 #define SIG_trpg 0x67707274 |
112 #define SIG_xxxx 0x78787878 | |
0 | 113 |
114 ArcomageGame *pArcomageGame = new ArcomageGame; | |
1194 | 115 |
1679 | 116 ArcomagePlayer am_Players[2]; // 00505708 |
117 AcromageCardOnTable shown_cards[10]; // 004FAA78 | |
118 stru272 array_4FABD0[10]; // 4FABD0 | |
119 | |
120 | |
121 ArcomageDeck playDeck; // 00505288 | |
122 ArcomageDeck deckMaster; // 005054C8 | |
1201 | 123 |
124 char Player2Name[] = "Enemy"; | |
125 char Player1Name[] = "Player"; | |
0 | 126 |
127 /* 267 */ | |
128 #pragma pack(push, 1) | |
129 struct stru273 | |
130 { | |
131 bool _40DD2F(); | |
1185 | 132 bool Inside(RECT*pXYZW); |
0 | 133 |
134 int x; | |
135 int y; | |
1263 | 136 char curr_mouse_left; |
137 char mouse_left_state_changed; | |
138 char curr_mouse_right; | |
139 char mouse_right_state_changed; | |
0 | 140 }; |
141 #pragma pack(pop) | |
142 | |
1186 | 143 |
1256 | 144 #pragma pack(push, 1) |
145 struct am_2 | |
146 { | |
147 int slot_index; | |
148 int card_power; | |
149 }; | |
150 #pragma pack(pop) | |
151 | |
1263 | 152 am_2 cards_power[10]; |
1256 | 153 std::array<__int16, 12> am_sounds; |
154 | |
1218 | 155 char byte_4E185C = 1; // weak |
156 char am_byte_4E185D = 1; // weak | |
1263 | 157 char use_start_bonus = 1; // weak |
1185 | 158 |
1201 | 159 int start_tower_height; |
160 int start_wall_height; | |
161 int start_quarry_level; | |
162 int start_magic_level; | |
163 int start_zoo_level; | |
164 | |
165 | |
1679 | 166 int minimum_cards_at_hand = 5; // 004E1874 |
1201 | 167 int quarry_bonus = 1; |
168 int magic_bonus = 1; | |
169 int zoo_bonus = 1; | |
170 | |
171 int max_tower_height = 50; | |
172 int max_resources_amount = 100 ; | |
1185 | 173 |
1256 | 174 int opponent_mastery = 1 ; // weak |
1185 | 175 |
1679 | 176 bool am_gameover; // 004FAA2C |
1186 | 177 char byte_4FAA2D; // weak |
178 | |
2154 | 179 int am_default_starting_player = 0; // 505890 |
1679 | 180 int current_player_num; // 004FAA6C |
181 char need_to_discard_card; // 04FAA77 | |
182 | |
183 int current_card_slot_index; // 004FABBC | |
184 int played_card_id; // 4FABC0 | |
185 int uCardID; // 4FAA50 | |
186 | |
187 int deck_walk_index; // 004FABC8 | |
1201 | 188 |
189 int start_bricks_amount; | |
190 int start_gems_amount; | |
191 int start_beasts_amount; | |
1197 | 192 |
1209 | 193 POINT amuint_4FAA3C_blt_xy; |
194 POINT am_uint_4FAA44_blt_xy; | |
195 POINT amuint_4FAA54_blt_xy; | |
196 POINT amuint_4FAA5C_blt_xy; | |
197 | |
1245 | 198 int dword_4FAA64; // weak |
199 int dword_4FAA68; // weak | |
1209 | 200 |
201 int dword_4FABB8; // weak | |
202 | |
1256 | 203 char byte_4FAA00; // weak |
204 | |
205 int amuint_4FAA34; // weak | |
206 int amuint_4FAA38; // weak | |
207 int amuint_4FAA4C; // weak | |
208 | |
209 char byte_4FAA2E; // weak | |
210 | |
211 int dword_4FAA70; // weak | |
212 char byte_4FAA74; // weak | |
213 char am_byte_4FAA75; // weak | |
214 char am_byte_4FAA76; // weak | |
215 | |
216 int amuint_4FABC4; // weak | |
217 | |
218 | |
219 char byte_505880; // weak | |
220 char byte_505881; // weak | |
0 | 221 |
222 //----- (0040DD2F) -------------------------------------------------------- | |
223 bool stru273::_40DD2F() | |
224 { | |
225 | |
226 this->x = pArcomageGame->mouse_x; | |
227 this->y = pArcomageGame->mouse_y; | |
1263 | 228 this->curr_mouse_left = pArcomageGame->mouse_left; |
229 this->mouse_left_state_changed = pArcomageGame->mouse_left == pArcomageGame->prev_mouse_left; | |
230 this->curr_mouse_right = pArcomageGame->mouse_right; | |
231 this->mouse_right_state_changed = pArcomageGame->mouse_right == pArcomageGame->prev_mouse_right; | |
232 pArcomageGame->prev_mouse_left = pArcomageGame->mouse_left; | |
233 pArcomageGame->prev_mouse_right = pArcomageGame->mouse_right; | |
1183 | 234 return true; |
0 | 235 } |
236 | |
237 //----- (0040DD93) -------------------------------------------------------- | |
1185 | 238 bool stru273::Inside(RECT*pXYZW ) |
239 { | |
240 | |
241 return (x >= pXYZW->left) && (x <= pXYZW->right) && | |
242 (y>= pXYZW->top) && (y <= pXYZW->bottom); | |
0 | 243 } |
244 | |
1184 | 245 //----- (0040DFD1) -------------------------------------------------------- |
1679 | 246 stru272_stru0 *stru272_stru0::New() |
247 { | |
248 stru272_stru0 *v2 = (stru272_stru0 *)malloc(0x5Cu); | |
1184 | 249 v2->signature = SIG_trpg; |
1263 | 250 v2->position_in_sparks_arr = 0; |
1184 | 251 v2->field_30 = 0.0; |
252 v2->field_58 = 0; | |
253 v2->field_59 = 0; | |
1679 | 254 |
255 return v2; | |
256 } | |
1184 | 257 |
258 //----- (0040DFFE) -------------------------------------------------------- | |
1679 | 259 int stru272_stru0::Free() |
2213 | 260 { |
261 if ( this->signature == SIG_trpg ) | |
262 { | |
263 this->signature = SIG_xxxx; | |
264 free(this); | |
265 return 0; | |
266 } | |
267 else | |
268 return 2; | |
269 } | |
1184 | 270 |
271 //----- (0040E01A) -------------------------------------------------------- | |
1263 | 272 int stru272_stru0::StartFill( stru272_stru2* a2 ) |
2213 | 273 { |
274 //stru272_stru0* a1 = this; | |
275 if ( this->signature == SIG_trpg ) | |
276 { | |
277 this->field_4 = a2->field_20; | |
278 this->field_C = a2->effect_area.left << 16; | |
279 this->field_10 = a2->effect_area.top << 16; | |
280 this->field_14 = a2->effect_area.right << 16; | |
281 this->field_18 = a2->effect_area.bottom << 16; | |
282 this->field_1C = a2->field_10; | |
283 this->field_20 = a2->field_14; | |
284 this->field_24 = a2->field_18; | |
285 this->field_28 = (float)(a2->field_1Cf * 65536.0); | |
286 this->field_2C = a2->field_24f; | |
287 this->field_34 = (int)(a2->field_28f * 65536.0); | |
288 this->field_38 = (int)(a2->field_2Cf * 65536.0); | |
289 this->field_3C = a2->field_30; | |
290 this->field_40 = a2->field_34; | |
291 this->field_54 = a2->sparks_array; | |
292 this->field_59 = 1; | |
293 return 0; | |
294 } | |
295 else | |
296 return 2; | |
297 } | |
1184 | 298 |
299 //----- (0040E0F5) -------------------------------------------------------- | |
1679 | 300 int stru272_stru0::Clear(char a2, char a3) |
1184 | 301 { |
1185 | 302 if ( signature == SIG_trpg) |
1184 | 303 { |
304 if ( a2 ) | |
305 { | |
1263 | 306 position_in_sparks_arr = 0; |
1185 | 307 field_30 = 0.0; |
1184 | 308 } |
1185 | 309 if ( field_59 && a3 ) |
1184 | 310 { |
1185 | 311 |
312 for (int i=0; i<field_4; ++i) | |
1263 | 313 field_54[i].have_spark = 0; |
1185 | 314 field_58 = 0; |
1184 | 315 } |
1185 | 316 return 0; |
1184 | 317 } |
318 else | |
1185 | 319 return 2; |
1184 | 320 } |
321 | |
322 //----- (0040E133) -------------------------------------------------------- | |
1263 | 323 int stru272_stru0::DrawEffect() |
2213 | 324 { |
325 // stru272_stru0 *v1; // edi@1 | |
326 int v3; // ST18_4@3 | |
327 double v4; // st7@3 | |
328 double v5; // st6@4 | |
329 char v6; // bl@8 | |
330 stru272_stru1 *v7; // esi@8 | |
331 int v8; // ecx@10 | |
332 signed int v9; // eax@10 | |
333 int v10; // ecx@10 | |
334 signed int v11; // eax@10 | |
335 int v12; // ebx@12 | |
336 int v13; // ST1C_4@12 | |
337 int v14; // ebx@12 | |
338 int v15; // ST1C_4@12 | |
339 signed int v16; // edx@12 | |
340 int v17; // ebx@12 | |
341 int v18; // ST1C_4@12 | |
342 signed int v19; // edx@12 | |
343 int v20; // [sp+8h] [bp-10h]@8 | |
344 int v21; // [sp+Ch] [bp-Ch]@8 | |
345 float v22; // [sp+14h] [bp-4h]@3 | |
346 | |
347 if ( this->signature != SIG_trpg ) | |
348 return 2; | |
349 v3 = this->position_in_sparks_arr; | |
350 v22 = this->field_30; | |
351 v4 = v3; | |
352 if ( v3 > 0 ) | |
353 { | |
354 v5 = v22 + this->field_2C; | |
355 v22 = v5; | |
356 if ( v5 > v4 ) | |
357 v22 = v4; | |
358 } | |
359 if ( v22 >= 1.0 || this->field_58 ) | |
360 { | |
361 v6 = 0; | |
362 v7 = this->field_54; | |
363 v20 = this->field_28; | |
364 | |
365 for ( v21 = this->field_4; v21; v21-- ) | |
1184 | 366 { |
2213 | 367 if ( v7->have_spark > 0 ) |
368 { | |
369 v8 = v7->field_14; | |
370 --v7->have_spark; | |
371 v9 = v8 + v7->field_C; | |
372 v10 = v20 + v7->field_18; | |
373 v7->field_C = v9; | |
374 v7->spark_position.x = v9 >> 16; | |
375 v11 = v10 + v7->field_10; | |
376 v7->field_18 = v10; | |
377 v7->field_10 = v11; | |
378 v7->spark_position.y = v11 >> 16; | |
379 v6 = 1; | |
380 //goto LABEL_14; | |
381 } | |
382 else | |
383 { | |
384 if ( v22 >= 1.0 ) | |
385 { | |
386 v12 = this->field_40; | |
387 v13 = this->field_3C; | |
388 v7->have_spark = rand_interval(v13,v12); | |
389 v7->field_14 = (rand() % 17 - 8) << 16; | |
390 v7->field_18 = (rand() % 17 - 8) << 16; | |
391 v14 = this->field_14 - 1; | |
392 v15 = this->field_C; | |
393 v16 = rand_interval(v15,v14); | |
394 v7->field_C = v16; | |
395 v7->spark_position.x = v16 >> 16; | |
396 v17 = this->field_18 - 1; | |
397 v18 = this->field_10; | |
398 v19 = rand_interval(v17, v18); | |
399 v7->field_10 = v19; | |
400 v7->spark_position.y = v19 >> 16; | |
401 --this->position_in_sparks_arr; | |
402 v22 = v22 - 1.0; | |
1184 | 403 v6 = 1; |
2213 | 404 } |
405 } | |
406 //LABEL_14: | |
407 ++v7; | |
408 //--v21; | |
409 //if ( !v21 ) | |
410 //{ | |
411 //this->field_58 = v6; | |
412 //this->field_30 = v22; | |
413 //return 0; | |
414 //} | |
1184 | 415 } |
2213 | 416 this->field_58 = v6; |
417 this->field_30 = v22; | |
418 } | |
419 return 0; | |
420 } | |
1184 | 421 |
422 //----- (0040E2A7) -------------------------------------------------------- | |
423 int stru272_stru0::_40E2A7() | |
2213 | 424 { |
425 if (signature == SIG_trpg ) | |
426 { | |
427 if ( position_in_sparks_arr <= 0 ) | |
428 return field_58 != 0 ? 2 : 0; | |
1184 | 429 else |
2213 | 430 return 1; |
431 } | |
432 else | |
433 return 3; | |
434 } | |
0 | 435 |
436 //----- (0040DFAF) -------------------------------------------------------- | |
437 void ArcomageGame::OnMouseClick(char right_left, bool bDown) | |
438 { | |
439 if ( right_left ) | |
440 pArcomageGame->mouse_right = bDown; | |
441 else | |
442 pArcomageGame->mouse_left = bDown; | |
443 } | |
444 | |
445 //----- (0040DFC1) -------------------------------------------------------- | |
1532 | 446 void ArcomageGame::OnMouseMove(int x, int y) |
0 | 447 { |
1532 | 448 pArcomageGame->mouse_x = x; |
449 pArcomageGame->mouse_y = y; | |
0 | 450 } |
451 | |
452 //----- (0040DF47) -------------------------------------------------------- | |
453 void DoBlt_Copy(unsigned __int16 *pPixels) | |
454 { | |
1183 | 455 RECT pSrcRect; |
456 POINT pTargetPoint; // [sp+1Ch] [bp-8h]@1 | |
457 | |
0 | 458 pRenderer->Present(); |
1183 | 459 |
460 pTargetPoint.x = 0; | |
461 pTargetPoint.y = 0; | |
462 | |
1256 | 463 pSrcRect.left = 0; |
464 pSrcRect.top = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
465 pSrcRect.right = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
466 pSrcRect.bottom = window->GetHeight(); |
1183 | 467 |
0 | 468 pRenderer->BeginScene(); |
1183 | 469 pArcomageGame->pBlit_Copy_pixels = pPixels; |
2154 | 470 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2); |
0 | 471 pRenderer->EndScene(); |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2356
diff
changeset
|
472 pArcomageGame->pBlit_Copy_pixels = nullptr; |
0 | 473 } |
474 | |
475 //----- (0040DDC9) -------------------------------------------------------- | |
1183 | 476 void ArcomageGame::PlaySound( unsigned int event_id ) |
2213 | 477 { |
1183 | 478 SoundID play_sound_id; // eax@10 |
479 | |
480 switch ( event_id ) | |
481 { | |
482 case 40: | |
483 case 43: | |
484 case 46: | |
485 play_sound_id = SOUND_Arcomage_LoseResources; | |
486 break; | |
487 case 39: | |
488 case 41: | |
489 case 42: | |
490 case 44: | |
491 case 45: | |
492 case 47: | |
493 play_sound_id = SOUND_Arcomage_AddResources; | |
494 break; | |
495 case 0: | |
496 case 12: | |
497 case 14: | |
498 case 15: | |
499 case 16: | |
500 case 48: | |
501 case 50: | |
502 case 53: | |
503 play_sound_id = SOUND_Arcomage_TowerWallDamage; | |
504 break; | |
505 case 21: | |
506 case 22: | |
507 case 23: | |
508 play_sound_id = SOUND_Arcomage_DrawCard; | |
509 break; | |
510 case 56: | |
511 play_sound_id = SOUND_Arcomage_124; | |
0 | 512 break; |
1183 | 513 case 31: |
514 case 34: | |
515 case 37: | |
516 play_sound_id = SOUND_Arcomage_ProductionDamage; | |
517 break; | |
518 case 1: | |
519 case 30: | |
520 case 32: | |
521 case 33: | |
522 case 35: | |
523 case 36: | |
524 case 38: | |
525 play_sound_id = SOUND_Arcomage_ProductionUpgrade; | |
526 break; | |
527 case 20: | |
528 play_sound_id = SOUND_Arcomage_127; | |
529 break; | |
530 case 3: | |
531 play_sound_id = SOUND_Arcomage_128; | |
532 break; | |
533 case 52: | |
534 case 54: | |
535 play_sound_id = SOUND_Arcomage_TowerUpgrade; | |
536 break; | |
537 case 10: | |
538 case 11: | |
539 case 13: | |
540 play_sound_id = SOUND_Arcomage_130; | |
541 break; | |
542 case 55u: | |
543 play_sound_id = SOUND_Arcomage_131; | |
544 break; | |
545 case 49: | |
546 case 51: | |
547 play_sound_id = SOUND_Arcomage_WallUpgrade; | |
548 break; | |
549 default: | |
0 | 550 return; |
2213 | 551 } |
1183 | 552 pAudioPlayer->PlaySound(play_sound_id, 0, 0, -1, 0, 0, 0, 0); |
0 | 553 } |
554 | |
555 //----- (0040DC2D) -------------------------------------------------------- | |
556 bool ArcomageGame::MsgLoop(int a1, ArcomageGame_stru1 *a2) | |
557 { | |
558 void *v2; // ebp@1 | |
559 BOOL v3; // eax@1 | |
560 | |
561 v2 = a2; | |
562 pArcomageGame->field_0 = 0; | |
563 pArcomageGame->stru1.field_0 = 0; | |
564 v3 = PeekMessageA(&pArcomageGame->msg, 0, 0, 0, PM_REMOVE); | |
565 if ( pArcomageGame->msg.message == WM_QUIT ) | |
566 Game_DeinitializeAndTerminate(0); | |
567 if ( v3 > 0 ) | |
568 { | |
569 TranslateMessage(&pArcomageGame->msg); | |
570 DispatchMessageA(&pArcomageGame->msg); | |
571 } | |
1038 | 572 /*if (pAsyncMouse) |
0 | 573 { |
574 EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); | |
575 v4 = *((unsigned int *)pAsyncMouse + 7); | |
576 pArcomageGame->mouse_x = *((unsigned int *)pAsyncMouse + 6); | |
577 pArcomageGame->mouse_y = v4; | |
578 v5 = *((unsigned int *)pAsyncMouse + 27); | |
579 v6 = *(unsigned int *)v5; | |
580 if ( *(unsigned int *)v5 != v5 ) | |
581 { | |
582 do | |
583 { | |
584 v7 = *(unsigned int *)(v6 + 20); | |
585 if ( v7 & 1 ) | |
586 { | |
587 pArcomageGame->stru1.field_0 = 7; | |
588 } | |
589 else | |
590 { | |
591 if ( v7 & 2 ) | |
592 pArcomageGame->stru1.field_0 = 8; | |
593 } | |
594 v6 = *(unsigned int *)v6; | |
595 } | |
596 while ( v6 != *((unsigned int *)pAsyncMouse + 27) ); | |
597 } | |
598 pAsyncMouse->_46B944(); | |
599 if ( !*((unsigned char *)pAsyncMouse + 90) ) | |
600 pArcomageGame->field_F6 = 1; | |
601 LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse); | |
1038 | 602 }*/ |
0 | 603 memcpy(v2, &pArcomageGame->stru1, 0xCu); |
604 return pArcomageGame->stru1.field_0 != 0; | |
605 } | |
606 | |
607 //----- (0040D7D5) -------------------------------------------------------- | |
608 void am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3) | |
609 { | |
610 pRenderer->BeginScene(); | |
1183 | 611 pArcomageGame->pBlit_Copy_pixels = pPcxPixels; |
0 | 612 } |
613 | |
614 //----- (0040D7EC) -------------------------------------------------------- | |
2154 | 615 void Render::am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode) |
0 | 616 { |
2213 | 617 unsigned __int16 *pSrc; // eax@2 |
618 int uSrcTotalWidth; // ecx@4 | |
619 unsigned int v10; // esi@9 | |
620 int v21; // [sp+Ch] [bp-18h]@8 | |
621 unsigned __int16 *src_surf_pos; // [sp+10h] [bp-14h]@9 | |
622 __int32 src_width; // [sp+14h] [bp-10h]@3 | |
623 __int32 src_height; // [sp+18h] [bp-Ch]@3 | |
624 int uSrcPitch; // [sp+1Ch] [bp-8h]@5 | |
625 | |
626 if ( !uNumSceneBegins ) | |
1183 | 627 return; |
2213 | 628 if ( !pArcomageGame->pBlit_Copy_pixels ) |
0 | 629 return; |
1183 | 630 |
2213 | 631 //dest_surf_pos = &pRenderer->pTargetSurface[pTargetPoint->x + pTargetPoint->y * pRenderer->uTargetSurfacePitch]; |
632 src_width = pSrcRect->right - pSrcRect->left; | |
633 src_height = pSrcRect->bottom - pSrcRect->top; | |
634 | |
635 if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pBackgroundPixels ) | |
1183 | 636 uSrcTotalWidth = pArcomageGame->pGameBackground.uWidth; |
2213 | 637 else if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pSpritesPixels ) |
1183 | 638 uSrcTotalWidth = pArcomageGame->pSprites.uWidth; |
639 | |
2213 | 640 //v20 = 157; |
641 //v19 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\am_nw.cpp"; | |
642 //v21 = &v18; | |
643 //std__string_char_40E2C8(&v18, "Problem in Blit_Chroma", &a3a); | |
644 //466D09_xcpt_string(&v21, v18, v19, v20); | |
645 //pSrc = pArcomageGame.pBlit_Copy_pixels; | |
646 //LABEL_9: | |
647 pSrc = pArcomageGame->pBlit_Copy_pixels; | |
648 uSrcPitch = uSrcTotalWidth; | |
649 src_surf_pos = &pSrc[pSrcRect->left + uSrcPitch * pSrcRect->top]; | |
650 v10 = 0x1F;//0xFF >> (8 - (unsigned __int8)uTargetBBits); | |
651 v21 = (uTargetGBits != 6 ? 0x31EF : 0x7BEF); | |
652 if ( blend_mode == 2 ) | |
653 { | |
654 uSrcPitch = (uSrcPitch - src_width); | |
655 for ( int i = 0; i < src_height; ++i ) | |
0 | 656 { |
2213 | 657 for ( int j = 0; j < src_width; ++j ) |
658 { | |
659 if ( *src_surf_pos != v10 ) | |
660 { | |
2216 | 661 if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 |
662 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1) | |
2213 | 663 WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos); |
664 } | |
665 ++src_surf_pos; | |
666 } | |
667 src_surf_pos += uSrcPitch; | |
0 | 668 } |
2213 | 669 } |
670 else | |
671 { | |
672 uSrcPitch = (uSrcPitch - src_width); | |
673 for ( int i = 0; i < src_height; ++i ) | |
0 | 674 { |
2213 | 675 for ( int j = 0; j < src_width; ++j ) |
676 { | |
677 if ( *src_surf_pos != v10 ) | |
0 | 678 { |
2216 | 679 if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 |
680 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1) | |
2213 | 681 //WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) >> 1)) + (v21 & (*src_surf_pos >> 1))); |
682 WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (0x7BEF & (*src_surf_pos / 2))); | |
0 | 683 } |
2213 | 684 ++src_surf_pos; |
685 } | |
686 src_surf_pos+=uSrcPitch; | |
0 | 687 } |
2213 | 688 } |
0 | 689 } |
690 | |
691 //----- (0040D9B1) -------------------------------------------------------- | |
2154 | 692 void Render::am_Blt_Copy( RECT *pSrcRect, POINT *pTargetPoint, int blend_mode ) |
2213 | 693 { |
694 unsigned __int16 *pSrc; // eax@2 | |
695 int uSrcTotalWidth; // ecx@4 | |
696 int v21; // [sp+Ch] [bp-18h]@8 | |
697 unsigned __int16 *src_surf_pos; // [sp+10h] [bp-14h]@9 | |
698 __int32 src_width; // [sp+14h] [bp-10h]@3 | |
699 __int32 src_height; // [sp+18h] [bp-Ch]@3 | |
700 int uSrcPitch; // [sp+1Ch] [bp-8h]@5 | |
701 | |
702 if ( !uNumSceneBegins ) | |
703 return; | |
704 if ( !pArcomageGame->pBlit_Copy_pixels ) | |
705 return; | |
1183 | 706 |
2069 | 707 //dest_surf_pos = &pRenderer->pTargetSurface[pTargetPoint->x + pTargetPoint->y * pRenderer->uTargetSurfacePitch]; |
2213 | 708 src_width = pSrcRect->right - pSrcRect->left; |
709 src_height = pSrcRect->bottom - pSrcRect->top; | |
710 if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pBackgroundPixels ) | |
711 uSrcTotalWidth = pArcomageGame->pGameBackground.uWidth; | |
712 else if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pSpritesPixels ) | |
713 uSrcTotalWidth = pArcomageGame->pSprites.uWidth; | |
714 | |
715 //v20 = 157; | |
716 //v19 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\am_nw.cpp"; | |
717 //v21 = &v18; | |
718 //std__string_char_40E2C8(&v18, "Problem in Blit_Chroma", &a3a); | |
719 //466D09_xcpt_string(&v21, v18, v19, v20); | |
720 //pSrc = pArcomageGame.pBlit_Copy_pixels; | |
721 //LABEL_9: | |
722 pSrc = pArcomageGame->pBlit_Copy_pixels; | |
723 uSrcPitch = uSrcTotalWidth; | |
724 src_surf_pos = &pSrc[pSrcRect->left + uSrcPitch * pSrcRect->top]; | |
725 v21 = (uTargetGBits != 6 ? 0x31EF : 0x7BEF); | |
726 | |
727 if ( blend_mode == 2 ) | |
728 { | |
729 uSrcPitch = (uSrcPitch - src_width); | |
730 for ( int i = 0; i < src_height; ++i ) | |
731 { | |
732 for ( int j = 0; j < src_width; ++j ) | |
733 { | |
734 if ( *src_surf_pos != v21 ) | |
0 | 735 { |
2216 | 736 if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 |
737 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1) | |
2213 | 738 WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos); |
0 | 739 } |
2213 | 740 ++src_surf_pos; |
741 } | |
742 src_surf_pos += uSrcPitch; | |
743 } | |
744 } | |
745 else | |
746 { | |
747 uSrcPitch = (uSrcPitch - src_width); | |
748 for ( int i = 0; i < src_height; ++i ) | |
749 { | |
750 for ( int j = 0; j < src_width; ++j ) | |
751 { | |
752 if ( *src_surf_pos != v21 ) | |
0 | 753 { |
2216 | 754 if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 |
755 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1) | |
2213 | 756 //WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) / 2)) + (v21 & (*src_surf_pos / 2))); |
757 WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (0x7BEF & (*src_surf_pos / 2))); | |
0 | 758 } |
2213 | 759 ++src_surf_pos; |
760 } | |
761 src_surf_pos += uSrcPitch; | |
762 } | |
763 } | |
0 | 764 } |
765 | |
766 //----- (0040DB10) -------------------------------------------------------- | |
2154 | 767 void am_EndScene() |
0 | 768 { |
769 pRenderer->EndScene(); | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2356
diff
changeset
|
770 pArcomageGame->pBlit_Copy_pixels = nullptr; |
0 | 771 } |
772 | |
773 //----- (0040D7B7) -------------------------------------------------------- | |
774 bool ArcomageGame::LoadSprites() | |
775 { | |
776 pArcomageGame->pSprites.Load("sprites.pcx", 2); | |
777 pArcomageGame->pSpritesPixels = pArcomageGame->pSprites.pPixels; | |
1183 | 778 return true; |
0 | 779 } |
780 | |
781 //----- (0040D799) -------------------------------------------------------- | |
782 bool ArcomageGame::LoadBackground() | |
783 { | |
784 pArcomageGame->pGameBackground.Load("layout.pcx", 2); | |
785 pArcomageGame->pBackgroundPixels = pArcomageGame->pGameBackground.pPixels; | |
1183 | 786 return true; |
0 | 787 } |
788 | |
1256 | 789 int CalculateCardPower(ArcomagePlayer* player, ArcomagePlayer* enemy, ArcomageCard* pCard, int mastery) |
2213 | 790 { |
791 enum V_INDX{ | |
1256 | 792 P_TOWER_M10, |
793 P_WALL_M10, | |
794 E_TOWER, | |
795 E_WALL, | |
796 E_BUILDINGS, | |
797 E_QUARRY, | |
798 E_MAGIC, | |
799 E_ZOO, | |
800 E_RES, | |
801 V_INDEX_MAX | |
802 }; | |
803 | |
804 const int mastery_coeff[V_INDEX_MAX][2]= {{10, 5}, //P_TOWER_M10 | |
805 {2, 1}, //P_WALL_M10 | |
806 {1, 10}, //E_TOWER | |
807 {1, 3}, //E_WALL | |
808 {1, 7}, //E_BUILDINGS | |
809 {1, 5}, //E_QUARRY | |
810 {1, 40}, //E_MAGIC | |
811 {1, 40}, //E_ZOO | |
812 {1, 2} //E_RES | |
813 }; | |
814 int card_power= 0; | |
815 int element_power; | |
816 | |
817 if ( pCard->to_player_tower == 99 || pCard->to_pl_enm_tower == 99|| | |
818 pCard->to_player_tower2 == 99 || pCard->to_pl_enm_tower2 == 99 ) | |
819 element_power = enemy->tower_height - player->tower_height; | |
820 else | |
821 element_power = pCard->to_player_tower + pCard->to_pl_enm_tower + pCard->to_player_tower2 + pCard->to_pl_enm_tower2; | |
822 | |
823 if ( player->tower_height >= 10 ) | |
824 card_power += mastery_coeff[P_TOWER_M10][mastery]*element_power; | |
825 else | |
826 card_power += 20*element_power; | |
827 | |
828 | |
829 if ( pCard->to_player_wall == 99 || pCard->to_pl_enm_wall == 99 || | |
830 pCard->to_player_wall2 == 99 || pCard->to_pl_enm_wall2 == 99 ) | |
831 element_power = enemy->wall_height - player->wall_height; | |
832 else | |
833 element_power = pCard->to_player_wall + pCard->to_pl_enm_wall + | |
834 pCard->to_player_wall2 + pCard->to_pl_enm_wall2; | |
835 if ( player->wall_height >= 10 ) | |
836 card_power += mastery_coeff[P_WALL_M10][mastery]*element_power; //1 | |
837 else | |
838 card_power += 5*element_power; | |
839 | |
840 | |
841 card_power += 7 * (pCard->to_player_buildings + pCard->to_pl_enm_buildings + | |
842 pCard->to_player_buildings2 + pCard->to_pl_enm_buildings2); | |
843 | |
844 if ( pCard->to_player_quarry_lvl == 99 || pCard->to_pl_enm_quarry_lvl == 99 || | |
845 pCard->to_player_quarry_lvl2 == 99 || pCard->to_pl_enm_quarry_lvl2 == 99 ) | |
846 element_power = enemy->quarry_level - player->quarry_level; | |
847 else | |
848 element_power = pCard->to_player_quarry_lvl + pCard->to_pl_enm_quarry_lvl + | |
849 pCard->to_player_quarry_lvl2 + pCard->to_pl_enm_quarry_lvl; | |
850 | |
851 card_power += 40 * element_power; | |
852 | |
853 if ( pCard->to_player_magic_lvl == 99 || pCard->to_pl_enm_magic_lvl == 99 || | |
854 pCard->to_player_magic_lvl2 == 99 || pCard->to_pl_enm_magic_lvl2 == 99 ) | |
855 element_power = enemy->magic_level - player->magic_level; | |
856 else | |
857 element_power = pCard->to_player_magic_lvl + pCard->to_pl_enm_magic_lvl + | |
858 pCard->to_player_magic_lvl2 + pCard->to_pl_enm_magic_lvl2; | |
859 card_power += 40 *element_power; | |
860 | |
861 if ( pCard->to_player_zoo_lvl == 99 || pCard->to_pl_enm_zoo_lvl == 99 || | |
862 pCard->to_player_zoo_lvl2 == 99 || pCard->to_pl_enm_zoo_lvl2 == 99 ) | |
863 element_power = enemy->zoo_level - player->zoo_level; | |
864 else | |
865 element_power = pCard->to_player_zoo_lvl + pCard->to_pl_enm_zoo_lvl + | |
866 pCard->to_player_zoo_lvl2 + pCard->to_pl_enm_zoo_lvl2; | |
867 card_power += 40 *element_power; | |
868 | |
869 if ( pCard->to_player_bricks == 99 || pCard->to_pl_enm_bricks == 99 || | |
870 pCard->to_player_bricks2 == 99 || pCard->to_pl_enm_bricks2 == 99 ) | |
871 element_power = enemy->resource_bricks - player->resource_bricks; | |
872 else | |
873 element_power = pCard->to_player_bricks + pCard->to_pl_enm_bricks + | |
874 pCard->to_player_bricks2 + pCard->to_pl_enm_bricks2; | |
875 card_power += 2 *element_power; | |
876 | |
877 | |
878 if ( pCard->to_player_gems == 99 || pCard->to_pl_enm_gems == 99 || | |
879 pCard->to_player_gems2 == 99 || pCard->to_pl_enm_gems2 == 99 ) | |
880 element_power = enemy->resource_gems - player->resource_gems; | |
881 else | |
882 element_power = pCard->to_player_gems + pCard->to_pl_enm_gems + | |
883 pCard->to_player_gems2 + pCard->to_pl_enm_gems2; | |
884 card_power += 2 *element_power; | |
885 | |
886 if ( pCard->to_player_beasts == 99 || pCard->to_pl_enm_beasts == 99 || | |
887 pCard->to_player_beasts2 == 99 || pCard->to_pl_enm_beasts2 == 99 ) | |
888 element_power = enemy->resource_beasts - player->resource_beasts; | |
889 else | |
890 element_power = pCard->to_player_beasts + pCard->to_pl_enm_beasts + | |
891 pCard->to_player_beasts2 + pCard->to_pl_enm_beasts2; | |
892 card_power += 2 *element_power; | |
893 | |
894 if ( pCard->to_enemy_tower == 99 || pCard->to_enemy_tower2 == 99 ) | |
895 element_power = player->tower_height - enemy->tower_height; | |
896 else | |
897 element_power = -(pCard->to_enemy_tower + pCard->to_enemy_tower2); | |
898 card_power += mastery_coeff[E_TOWER][mastery]*element_power; | |
899 | |
900 if ( pCard->to_enemy_wall == 99 || pCard->to_enemy_wall2 == 99 ) | |
901 element_power = player->wall_height - enemy->wall_height; | |
902 else | |
903 element_power = -(pCard->to_enemy_wall + pCard->to_enemy_wall2); | |
904 card_power += mastery_coeff[E_WALL][mastery]*element_power; | |
905 | |
906 card_power -= mastery_coeff[E_BUILDINGS][mastery]*(pCard->to_enemy_buildings + pCard->to_enemy_buildings2); | |
907 | |
908 if ( pCard->to_enemy_quarry_lvl == 99 || pCard->to_enemy_quarry_lvl2 == 99 ) | |
909 element_power = player->quarry_level - enemy->quarry_level; //5 | |
910 else | |
911 element_power = -(pCard->to_enemy_quarry_lvl + pCard->to_enemy_quarry_lvl2); //5 | |
912 card_power += mastery_coeff[E_QUARRY][mastery]*element_power; | |
913 | |
914 if ( pCard->to_enemy_magic_lvl == 99 || pCard->to_enemy_magic_lvl2 == 99 ) | |
915 element_power = player->magic_level - enemy->magic_level; //40 | |
916 else | |
917 element_power = -(pCard->to_enemy_magic_lvl + pCard->to_enemy_magic_lvl2); | |
918 card_power += mastery_coeff[E_MAGIC][mastery]*element_power; | |
919 | |
920 if ( pCard->to_enemy_zoo_lvl == 99 || pCard->to_enemy_zoo_lvl2 == 99 ) | |
921 element_power = player->zoo_level - enemy->zoo_level; //40 | |
922 else | |
923 element_power = -(pCard->to_enemy_zoo_lvl + pCard->to_enemy_zoo_lvl2); | |
924 card_power += mastery_coeff[E_ZOO][mastery]*element_power; | |
925 | |
926 if ( pCard->to_enemy_bricks == 99 || pCard->to_enemy_bricks2 == 99 ) | |
927 element_power = player->resource_bricks - enemy->resource_bricks; //2 | |
928 else | |
929 element_power = -(pCard->to_enemy_bricks + pCard->to_enemy_bricks2); | |
930 card_power += mastery_coeff[E_RES][mastery]*element_power; | |
931 | |
932 if ( pCard->to_enemy_gems == 99 || pCard->to_enemy_gems2 == 99 ) | |
933 element_power = player->resource_gems - enemy->resource_gems; //2 | |
934 else | |
935 element_power = -(pCard->to_enemy_gems + pCard->to_enemy_gems2); | |
936 card_power += mastery_coeff[E_RES][mastery]*element_power; | |
937 | |
938 if ( pCard->to_enemy_beasts == 99 || pCard->to_enemy_beasts2 == 99 ) | |
939 element_power = player->resource_beasts - enemy->resource_beasts; //2 | |
940 else | |
941 element_power = -(pCard->to_enemy_beasts + pCard->to_enemy_beasts2); | |
942 card_power += mastery_coeff[E_RES][mastery]*element_power; | |
943 | |
944 if ( pCard->field_30 || pCard->field_4D ) | |
945 card_power *= 10; | |
946 | |
947 if ( pCard->field_24 == 1 ) | |
948 element_power = player->resource_bricks - pCard->needed_bricks; | |
949 else if ( pCard->field_24 == 2 ) | |
950 element_power = player->resource_gems - pCard->needed_gems; | |
951 else if (pCard->field_24 == 3) | |
952 element_power = player->resource_beasts - pCard->needed_beasts; | |
953 if ( element_power > 3 ) | |
954 element_power = 3; | |
955 card_power += 5 * element_power; | |
956 | |
957 if ( enemy->tower_height <= pCard->to_enemy_tower2 + pCard->to_enemy_tower ) | |
958 card_power += 9999; | |
2213 | 959 |
1256 | 960 if (pCard->to_enemy_tower2 + pCard->to_enemy_tower + |
961 pCard->to_enemy_wall + pCard->to_enemy_wall2 + | |
962 pCard->to_enemy_buildings + pCard->to_enemy_buildings2 >= enemy->wall_height + enemy->tower_height) | |
963 card_power += 9999; | |
964 | |
2213 | 965 if ( (pCard->to_player_tower2 + pCard->to_pl_enm_tower2 + pCard->to_player_tower + pCard->to_pl_enm_tower + player->tower_height) |
966 >= max_tower_height ) | |
967 card_power += 9999; | |
968 | |
969 return card_power; | |
970 } | |
1256 | 971 |
0 | 972 //----- (00408BB4) -------------------------------------------------------- |
1256 | 973 bool OpponentsAITurn(int player_num) |
0 | 974 { |
2213 | 975 int all_player_cards_count; // eax@9 |
976 int random_card_slot; // edi@9 | |
977 ArcomageCard *v12; // ecx@20 | |
978 int v56; // ecx@141 | |
979 int v57; // edx@141 | |
2334 | 980 // int v64; // eax@169 |
981 // ArcomageCard *pCard; // ecx@169 | |
982 // char v66; // dl@169 | |
983 // char v67; // dl@173 | |
984 // int v68; // edx@174 | |
2213 | 985 int v132; // [sp-14h] [bp-14h]@0 |
986 ArcomagePlayer *enemy; // [sp-10h] [bp-10h]@5 | |
987 ArcomagePlayer *player; // [sp-Ch] [bp-Ch]@5 | |
988 | |
989 byte_4FAA00 = 1; | |
990 if ( opponent_mastery == 0) | |
991 { | |
992 if ( need_to_discard_card == 0 ) //am_byte_4FAA77 | |
993 { | |
994 for(int i = 0; i < 10; ++i ) | |
995 { | |
996 all_player_cards_count = GetPlayerHandCardCount(player_num); | |
997 random_card_slot = rand_interval(0, all_player_cards_count - 1); | |
998 if ( CanCardBePlayed(player_num, random_card_slot) ) | |
999 return PlayCard(player_num, random_card_slot); | |
1000 } | |
1001 } | |
1002 all_player_cards_count = GetPlayerHandCardCount(player_num); | |
1003 random_card_slot= rand_interval(0, all_player_cards_count - 1); | |
1004 return DiscardCard(player_num, random_card_slot); | |
1005 } | |
1006 else if (( opponent_mastery == 1 )|| ( opponent_mastery == 2 )) | |
1007 { | |
1008 player = &am_Players[player_num]; | |
1009 enemy = &am_Players[(player_num + 1) % 2]; | |
1010 all_player_cards_count = GetPlayerHandCardCount(player_num); | |
1011 for(int i = 0; i < 10 ; ++i ) | |
1012 { | |
1013 if ( i >= all_player_cards_count ) | |
1014 { | |
1015 cards_power[i].slot_index = -1; | |
1016 cards_power[i].card_power = -9999; | |
1017 } | |
1018 else | |
1019 { | |
1020 cards_power[i].slot_index = i; | |
1021 cards_power[i].card_power = 0; | |
1022 } | |
1023 } | |
1024 for(int i = 0; i < all_player_cards_count ; ++i ) | |
1025 { | |
1026 v12 = &pCards[am_Players[player_num].cards_at_hand[cards_power[i].slot_index]]; | |
1027 cards_power[i].card_power = CalculateCardPower(player, enemy, v12, opponent_mastery-1); | |
1028 } | |
1029 | |
1030 for (int j = all_player_cards_count - 1; j >= 0; --j ) | |
1031 { | |
1032 for (int m = 0; m < j; ++m ) | |
1033 { | |
1034 if ( cards_power[m].card_power < cards_power[m + 1].card_power ) | |
1256 | 1035 { |
2213 | 1036 v56 = cards_power[m].slot_index; |
1037 v57 = cards_power[m].card_power; | |
1038 cards_power[m].slot_index = cards_power[m + 1].slot_index; | |
1039 cards_power[m].card_power = cards_power[m + 1].card_power; | |
1040 cards_power[m + 1].slot_index = cards_power[m].slot_index; | |
1041 cards_power[m + 1].card_power = cards_power[m].card_power; | |
1256 | 1042 } |
2213 | 1043 } |
1044 } | |
1045 if ( need_to_discard_card ) | |
1046 { | |
1047 for ( int i = all_player_cards_count - 1; i; --i ) | |
1048 { | |
1049 if ( pCards[am_Players[player_num].cards_at_hand[cards_power[i].slot_index]].can_be_discarded ) | |
1050 v132 = cards_power[i].slot_index; | |
1051 } | |
1052 } | |
1053 else | |
1054 { | |
1055 for ( int i = all_player_cards_count - 1; i; --i ) | |
1056 { | |
1057 if ( pCards[am_Players[player_num].cards_at_hand[cards_power[i].slot_index]].can_be_discarded ) | |
1058 v132 = cards_power[i].slot_index; | |
1059 } | |
1060 for ( int i = 0; i < all_player_cards_count - 1; ++i ) | |
1061 { | |
1062 if ( CanCardBePlayed(player_num, cards_power[i].slot_index) && cards_power[i].card_power ) | |
1063 return PlayCard(player_num, cards_power[i].slot_index); | |
1064 } | |
1065 } | |
1066 return DiscardCard(player_num, v132); | |
1067 } | |
1183 | 1068 return true;//result != 0; |
0 | 1069 } |
1070 | |
1071 //----- (00409E6A) -------------------------------------------------------- | |
1072 void ArcomageGame::Loop() | |
1073 { | |
1197 | 1074 while ( !pArcomageGame->GameOver ) |
0 | 1075 { |
1076 pArcomageGame->field_F6 = 1; | |
1077 byte_4FAA24 = 1; | |
1197 | 1078 IncreaseResourcesInTurn(current_player_num); |
0 | 1079 LABEL_8: |
1185 | 1080 while ( byte_4FAA24 ) |
0 | 1081 { |
1200 | 1082 played_card_id = -1; |
1083 GetNextCardFromDeck(current_player_num); | |
0 | 1084 while ( 1 ) |
1085 { | |
1256 | 1086 byte_4FAA24 = PlayerTurn(current_player_num); |
1200 | 1087 if ( GetPlayerHandCardCount(current_player_num) <= minimum_cards_at_hand ) |
0 | 1088 break; |
1263 | 1089 need_to_discard_card = 1; |
0 | 1090 if ( pArcomageGame->field_F4 ) |
1091 goto LABEL_8; | |
1092 } | |
1263 | 1093 need_to_discard_card = 0; |
1185 | 1094 } |
1197 | 1095 pArcomageGame->GameOver = IsGameOver(); |
1096 if ( !pArcomageGame->GameOver ) | |
1256 | 1097 TurnChange(); |
0 | 1098 if ( pArcomageGame->field_F4 ) |
1197 | 1099 pArcomageGame->GameOver = 1; |
0 | 1100 } |
1197 | 1101 GameResultsApply(); |
1679 | 1102 if ( am_gameover ) |
1183 | 1103 dword_4FAA70 = 0; |
0 | 1104 else |
1105 dword_4FAA70 = -1; | |
2213 | 1106 |
1107 for( int i = 0; i < 10; ++i ) | |
1679 | 1108 { |
1109 array_4FABD0[i].field_40->Clear(1, 1); | |
1110 array_4FABD0[i].field_40->Free(); | |
1111 } | |
1038 | 1112 |
0 | 1113 pArcomageGame->pGameBackground.Release(); |
1114 pArcomageGame->pSprites.Release(); | |
1679 | 1115 pArcomageGame->bGameInProgress = false; |
1116 viewparams->bRedrawGameUI = true; | |
2394 | 1117 if ( pMovie_Track ) |
2453 | 1118 BackToHouseMenu(); |
2213 | 1119 for( int i = 0; i < 12; ++i ) |
1183 | 1120 pSoundList->UnloadSound(am_sounds[i], 1); |
0 | 1121 } |
938 | 1122 |
0 | 1123 //----- (00409FE9) -------------------------------------------------------- |
1197 | 1124 void SetStartGameData() |
1679 | 1125 { |
1194 | 1126 signed int j; // edx@7 |
1127 int card_id_counter; // edx@13 | |
1128 signed int i; // ecx@13 | |
1129 signed int card_dispenser_counter; // eax@13 | |
0 | 1130 |
2154 | 1131 current_player_num = am_default_starting_player; |
1197 | 1132 SetStartConditions(); |
2213 | 1133 for( i = 0; i < 2; ++i ) |
0 | 1134 { |
1194 | 1135 if ( i ) |
0 | 1136 { |
1194 | 1137 strcpy(am_Players[1].pPlayerName, pArcomageGame->pPlayer2Name); |
0 | 1138 if ( byte_4E185C ) |
1197 | 1139 am_Players[1].IsHisTurn = 0; |
0 | 1140 else |
1197 | 1141 am_Players[1].IsHisTurn = 1; |
0 | 1142 } |
1143 else | |
1144 { | |
1194 | 1145 strcpy(am_Players[0].pPlayerName, pArcomageGame->pPlayer1Name); |
1197 | 1146 am_Players[0].IsHisTurn = 1; |
0 | 1147 } |
1200 | 1148 am_Players[i].tower_height = start_tower_height; |
1149 am_Players[i].wall_height = start_wall_height; | |
1150 am_Players[i].quarry_level = start_quarry_level; | |
1151 am_Players[i].magic_level = start_magic_level; | |
1152 am_Players[i].zoo_level = start_zoo_level; | |
1197 | 1153 am_Players[i].resource_bricks = start_bricks_amount; |
1154 am_Players[i].resource_gems = start_gems_amount; | |
1155 am_Players[i].resource_beasts = start_beasts_amount; | |
1194 | 1156 |
2213 | 1157 for ( j = 0; j < 10; ++j ) |
0 | 1158 { |
1194 | 1159 am_Players[i].cards_at_hand[j] = -1; |
0 | 1160 if ( am_byte_4E185D ) |
1161 { | |
1256 | 1162 am_Players[i].card_shift[j].x = -1; |
1163 am_Players[i].card_shift[j].y = -1; | |
0 | 1164 } |
1165 else | |
1166 { | |
1256 | 1167 am_Players[i].card_shift[j].x = 0; |
1168 am_Players[i].card_shift[j].y = 0; | |
0 | 1169 } |
1263 | 1170 } |
0 | 1171 } |
1679 | 1172 strcpy(deckMaster.name, "Master Deck"); |
2213 | 1173 for ( i = 0, card_dispenser_counter = -2, card_id_counter = 0; i < DECK_SIZE; ++i, ++card_dispenser_counter) |
1174 { | |
1175 deckMaster.cardsInUse[i] = 0; | |
1176 deckMaster.cards_IDs[i] = card_id_counter; | |
1177 switch ( card_dispenser_counter ) | |
1178 { | |
0 | 1179 case 0: |
1180 case 2: | |
1181 case 6: | |
1182 case 9: | |
1183 case 13: | |
1184 case 18: | |
1185 case 23: | |
1186 case 33: | |
1187 case 36: | |
1188 case 38: | |
1189 case 44: | |
1190 case 46: | |
1191 case 52: | |
1192 case 57: | |
1193 case 69: | |
1194 case 71: | |
1195 case 75: | |
1196 case 79: | |
1197 case 81: | |
1198 case 84: | |
1199 case 89: | |
2213 | 1200 break; |
1185 | 1201 default: |
2213 | 1202 ++card_id_counter; |
1203 } | |
1204 } | |
1205 FillPlayerDeck(); | |
0 | 1206 } |
1207 | |
1208 //----- (0040A198) -------------------------------------------------------- | |
1197 | 1209 void FillPlayerDeck() |
1194 | 1210 { |
1263 | 1211 signed int m; |
1212 int rand_deck_pos; | |
1213 char card_taken_flags[DECK_SIZE]; | |
1194 | 1214 int i,j; |
0 | 1215 |
1218 | 1216 ArcomageGame::PlaySound(20); |
1194 | 1217 memset(deckMaster.cardsInUse, 0,DECK_SIZE ); |
1218 memset(card_taken_flags, 0, DECK_SIZE); | |
1219 | |
2213 | 1220 for ( i = 0; i < 2; ++i ) |
0 | 1221 { |
2213 | 1222 for ( j = 0; j < 10; ++j ) |
0 | 1223 { |
1194 | 1224 if ( am_Players[i].cards_at_hand[j] > -1 ) |
0 | 1225 { |
1263 | 1226 for (m = 0; m<DECK_SIZE; ++m) |
2213 | 1227 { |
1228 if (deckMaster.cards_IDs[m] == am_Players[i].cards_at_hand[j] && deckMaster.cardsInUse[m] == 0) | |
1229 { | |
1230 deckMaster.cardsInUse[m] = 1; | |
1231 break; | |
1232 } | |
1233 } | |
0 | 1234 } |
1235 } | |
1236 } | |
1194 | 1237 |
2213 | 1238 for ( i = 0; i < DECK_SIZE; ++i ) |
0 | 1239 { |
1240 do | |
1263 | 1241 rand_deck_pos = rand() % DECK_SIZE; |
1242 while (card_taken_flags[rand_deck_pos] == 1 ); | |
1243 | |
1244 card_taken_flags[rand_deck_pos]=1; | |
1245 playDeck.cards_IDs[i] = deckMaster.cards_IDs[rand_deck_pos]; | |
1246 playDeck.cardsInUse[i] = deckMaster.cardsInUse[rand_deck_pos]; | |
0 | 1247 } |
1194 | 1248 |
1200 | 1249 deck_walk_index = 0; |
0 | 1250 amuint_4FABC4 = -1; |
1251 pArcomageGame->field_F6 = 1; | |
1194 | 1252 |
0 | 1253 } |
1254 | |
1255 //----- (0040A255) -------------------------------------------------------- | |
1200 | 1256 void InitalHandsFill() |
2213 | 1257 { |
1200 | 1258 for (int i = 0; i < minimum_cards_at_hand; ++i ) |
0 | 1259 { |
2213 | 1260 GetNextCardFromDeck(0); |
1261 GetNextCardFromDeck(1); | |
0 | 1262 } |
1263 pArcomageGame->field_F6 = 1; | |
1264 } | |
1265 // 4E1874: using guessed type int dword_4E1874; | |
1266 | |
1267 //----- (0040A283) -------------------------------------------------------- | |
1200 | 1268 void GetNextCardFromDeck( int player_num ) |
2213 | 1269 { |
1200 | 1270 signed int deck_index; // eax@1 |
1271 int new_card_id; // edi@1 | |
1272 signed int card_slot_indx; // eax@7 | |
1273 | |
1274 deck_index = deck_walk_index; | |
1275 for(;;) | |
0 | 1276 { |
1200 | 1277 if ( deck_index >= DECK_SIZE ) |
0 | 1278 { |
1197 | 1279 FillPlayerDeck(); |
1200 | 1280 deck_index = deck_walk_index; |
0 | 1281 } |
1200 | 1282 if ( !playDeck.cardsInUse[deck_index] ) |
2213 | 1283 { |
1284 new_card_id = playDeck.cards_IDs[deck_index]; | |
1285 ++deck_index; | |
1286 deck_walk_index = deck_index; | |
1287 break; | |
1288 } | |
1200 | 1289 ++deck_index; |
1290 deck_walk_index = deck_index; | |
0 | 1291 } |
2213 | 1292 |
1197 | 1293 ArcomageGame::PlaySound(21); |
1200 | 1294 card_slot_indx = GetEmptyCardSlotIndex(player_num); |
1295 if ( card_slot_indx != -1 ) | |
0 | 1296 { |
1200 | 1297 amuint_4FAA4C = card_slot_indx; |
1298 am_Players[player_num].cards_at_hand[card_slot_indx] = new_card_id; | |
1256 | 1299 am_Players[player_num].card_shift[card_slot_indx].x = rand_interval(-4, 4); |
1300 am_Players[player_num].card_shift[card_slot_indx].y = rand_interval(-4, 4); | |
0 | 1301 pArcomageGame->field_F6 = 1; |
1302 byte_4FAA2D = 1; | |
1303 } | |
1304 } | |
1186 | 1305 |
0 | 1306 //----- (0040A324) -------------------------------------------------------- |
1185 | 1307 int GetEmptyCardSlotIndex( int player_num ) |
2213 | 1308 { |
1309 for ( int i = 0; i < 10; ++i ) | |
1310 { | |
1311 if (am_Players[player_num].cards_at_hand[i] == -1) | |
1312 return i; | |
1313 } | |
1314 return -1; | |
0 | 1315 } |
1316 | |
1317 //----- (0040A346) -------------------------------------------------------- | |
1679 | 1318 void IncreaseResourcesInTurn(int player_num) |
1185 | 1319 { |
1197 | 1320 am_Players[player_num].resource_bricks += quarry_bonus + am_Players[player_num].quarry_level; |
1321 am_Players[player_num].resource_gems += magic_bonus + am_Players[player_num].magic_level; | |
1263 | 1322 am_Players[player_num].resource_beasts += zoo_bonus + am_Players[player_num].zoo_level; |
0 | 1323 } |
1183 | 1324 |
0 | 1325 |
1326 //----- (0040A383) -------------------------------------------------------- | |
1256 | 1327 void TurnChange() |
1679 | 1328 { |
1263 | 1329 char player_name[64]; // [sp+4h] [bp-64h]@4 |
1330 // RECT v6; // [sp+44h] [bp-24h]@6 | |
0 | 1331 ArcomageGame_stru1 v10; // [sp+54h] [bp-14h]@7 |
1194 | 1332 POINT v11; // [sp+60h] [bp-8h]@4 |
0 | 1333 |
1334 if ( !pArcomageGame->field_F4 ) | |
1335 { | |
1197 | 1336 if ( am_Players[0].IsHisTurn != 1 || am_Players[1].IsHisTurn != 1 ) |
0 | 1337 { |
1197 | 1338 ++current_player_num; |
0 | 1339 am_byte_4FAA75 = 1; |
1197 | 1340 if ( current_player_num >= 2 ) |
1341 current_player_num = 0; | |
0 | 1342 } |
1343 else | |
1344 { | |
1345 //nullsub_1(); | |
1218 | 1346 // v11.x = 0; |
1347 // v11.y = 0; | |
1679 | 1348 strcpy(player_name, "The Next Player is: ");//"Ñëåä" |
2213 | 1349 // v0 = 0; |
1194 | 1350 v11.y = 200; |
1218 | 1351 v11.x = 320; // - 12 * v0 / 2; |
1679 | 1352 am_DrawText(-1, player_name, &v11); |
0 | 1353 am_byte_4FAA75 = 1; |
1263 | 1354 ++current_player_num; |
1355 if ( current_player_num >= 2 ) | |
1197 | 1356 current_player_num = 0; |
1263 | 1357 strcpy(player_name, am_Players[current_player_num].pPlayerName); |
2213 | 1358 // v4 = 0; |
1194 | 1359 v11.y = 260; |
1218 | 1360 v11.x = 320;// - 12 * v4 / 2; |
1679 | 1361 am_DrawText(-1, player_name, &v11); |
2213 | 1362 /* v6.left = 0; |
1194 | 1363 v6.right = 640; |
1364 v6.top = 0; | |
1197 | 1365 v6.bottom = 480;*/ |
0 | 1366 //nullsub_1(); |
1679 | 1367 pRenderer->Present(); |
0 | 1368 //nullsub_1(); |
1369 while ( 1 ) | |
2213 | 1370 { |
1371 while ( !ArcomageGame::MsgLoop(20, &v10) ) | |
1372 ; | |
1373 if ( v10.field_0 == 1 ) | |
1374 { | |
1375 if ( v10.field_4 ) | |
1376 break; | |
1377 //nullsub_1(); | |
1378 continue; | |
1379 } | |
1380 if (( v10.field_0 > 4 ) && ( v10.field_0 <= 8 )) | |
1381 break; | |
1382 if ( v10.field_0 == 10 ) | |
1383 { | |
1384 pArcomageGame->field_F4 = 1; | |
1385 byte_4FAA74 = 1; | |
1386 break; | |
1387 } | |
0 | 1388 } |
1197 | 1389 /* v11.x = 0; |
1194 | 1390 v11.y = 0; |
1391 v6.left = 0; | |
1392 v6.right = 640; | |
1393 v6.top = 0; | |
1197 | 1394 v6.bottom = 480;*/ |
0 | 1395 //nullsub_1(); |
1679 | 1396 pRenderer->Present(); |
0 | 1397 } |
1398 } | |
1399 } | |
1400 | |
1401 //----- (0040A514) -------------------------------------------------------- | |
1197 | 1402 bool IsGameOver() |
1679 | 1403 { |
0 | 1404 bool result; // eax@1 |
1183 | 1405 |
1406 result = false; | |
2213 | 1407 for( int i = 0; i < 2; ++i ) |
0 | 1408 { |
1197 | 1409 if ( am_Players[i].tower_height <= 0 ) |
1410 result = true; | |
1411 if ( am_Players[i].tower_height >= max_tower_height ) | |
1183 | 1412 result = true; |
1197 | 1413 if ( am_Players[i].resource_bricks >= max_resources_amount |
1414 || am_Players[i].resource_gems >= max_resources_amount | |
1415 || am_Players[i].resource_beasts >= max_resources_amount ) | |
1183 | 1416 result = true; |
0 | 1417 } |
1679 | 1418 |
1419 return am_gameover = result; | |
0 | 1420 } |
1197 | 1421 |
0 | 1422 //----- (0040A560) -------------------------------------------------------- |
1256 | 1423 char PlayerTurn( int player_num ) |
2213 | 1424 { |
2334 | 1425 // int v1; // ebp@0 |
1426 // unsigned __int64 v2; // qax@3 | |
0 | 1427 unsigned __int64 v3; // kr00_8@3 |
1218 | 1428 |
2334 | 1429 // int v5; // esi@67 |
1430 // char Dest[100]; // [sp+8h] [bp-A8h]@67 | |
1431 // int v8; // [sp+6Ch] [bp-44h]@3 | |
1194 | 1432 RECT pSrcXYZW; // [sp+70h] [bp-40h]@75 |
2334 | 1433 // int v10[4]; // [sp+80h] [bp-30h]@69 |
1194 | 1434 POINT pTargetXY; // [sp+90h] [bp-20h]@75 |
0 | 1435 ArcomageGame_stru1 a2; // [sp+98h] [bp-18h]@8 |
1263 | 1436 int animation_stage; // [sp+A4h] [bp-Ch]@1 |
2334 | 1437 // char v15; // [sp+AEh] [bp-2h]@63 |
1263 | 1438 bool break_loop; // [sp+AFh] [bp-1h]@1 |
0 | 1439 |
1440 uCardID = -1; | |
1263 | 1441 break_loop = false; |
1442 animation_stage = 20; | |
0 | 1443 byte_4FAA00 = 0; |
1444 dword_4FAA68 = 0; | |
1445 amuint_4FAA38 = 10; | |
1446 amuint_4FAA34 = 5; | |
1447 if ( amuint_4FAA4C != -1 ) | |
1448 byte_4FAA2D = 1; | |
1449 do | |
1450 { | |
2213 | 1451 do |
1452 { | |
1453 v3 = pEventTimer->Time() - pArcomageGame->event_timer_time; | |
1454 } | |
1455 while (v3 < 6); | |
1679 | 1456 pArcomageGame->event_timer_time = (unsigned int)pEventTimer->Time(); |
0 | 1457 if ( pArcomageGame->field_F4 ) |
2213 | 1458 break_loop = true; |
0 | 1459 ArcomageGame::MsgLoop(0, &a2); |
1460 switch ( a2.field_0 ) | |
1461 { | |
1462 case 2: | |
1463 if ( a2.field_4 == 129 && a2.field_8 == 1 ) | |
1464 { | |
1465 pAudioPlayer->StopChannels(-1, -1); | |
1466 dword_4FAA68 = 0; | |
1263 | 1467 break_loop = true; |
1185 | 1468 pArcomageGame->field_F4 = 1; |
0 | 1469 } |
1470 break; | |
1471 case 9: | |
1472 pArcomageGame->field_F6 = 1; | |
1473 break; | |
1194 | 1474 case 10: |
0 | 1475 pAudioPlayer->StopChannels(-1, -1); |
1476 byte_4FAA74 = 1; | |
1263 | 1477 break_loop = true; |
0 | 1478 pArcomageGame->field_F4 = 1; |
1479 break; | |
1480 } | |
1218 | 1481 |
1263 | 1482 if (am_Players[current_player_num].IsHisTurn != 1 && |
1483 !byte_4FAA00 && !byte_4FAA2E && !byte_4FAA2D ) | |
0 | 1484 { |
1485 if ( am_byte_4FAA75 ) | |
1486 am_byte_4FAA76 = 1; | |
1256 | 1487 OpponentsAITurn(current_player_num); |
0 | 1488 byte_4FAA2E = 1; |
1489 } | |
1490 if ( amuint_4FAA4C != -1 && amuint_4FAA38 > 10 ) | |
1491 amuint_4FAA38 = 10; | |
1218 | 1492 if ( byte_4FAA2E || byte_4FAA2D ||am_Players[current_player_num].IsHisTurn != 1 ) |
0 | 1493 { |
1494 pArcomageGame->field_F6 = 1; | |
1495 if ( byte_4FAA2D ) | |
1496 { | |
1497 --amuint_4FAA38; | |
1498 if ( amuint_4FAA38 < 0 ) | |
1499 { | |
1500 byte_4FAA2D = 0; | |
1501 amuint_4FAA38 = 10; | |
1263 | 1502 break_loop = false; |
0 | 1503 } |
1504 } | |
1505 if ( byte_4FAA2E ) | |
1506 { | |
1263 | 1507 --animation_stage; |
1508 if ( animation_stage < 0 ) | |
0 | 1509 { |
1510 if ( dword_4FAA68 > 1 ) | |
1511 { | |
1512 --dword_4FAA68; | |
1513 byte_4FAA00 = 0; | |
1514 } | |
1515 else | |
1263 | 1516 break_loop = true; |
0 | 1517 byte_4FAA2E = 0; |
1263 | 1518 animation_stage = 20; |
0 | 1519 } |
1520 } | |
1521 } | |
1522 else | |
1523 { | |
1263 | 1524 if ( need_to_discard_card ) |
0 | 1525 { |
1256 | 1526 if ( a2.field_0 == 7 && DiscardCard(player_num, current_card_slot_index) ) |
0 | 1527 { |
1528 if ( am_byte_4FAA75 ) | |
1529 am_byte_4FAA76 = 1; | |
1530 if ( dword_4FAA64 > 0 ) | |
1531 { | |
1532 --dword_4FAA64; | |
1263 | 1533 need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand; |
0 | 1534 } |
1535 byte_4FAA2E = 1; | |
1536 } | |
1256 | 1537 if ( a2.field_0 == 8 && DiscardCard(player_num, current_card_slot_index) ) |
0 | 1538 { |
1539 if ( am_byte_4FAA75 ) | |
1540 am_byte_4FAA76 = 1; | |
1541 if ( dword_4FAA64 > 0 ) | |
1542 { | |
1543 --dword_4FAA64; | |
1263 | 1544 need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand; |
0 | 1545 } |
1546 byte_4FAA2E = 1; | |
1547 } | |
1548 } | |
1549 else | |
1550 { | |
1551 if ( a2.field_0 == 7 ) | |
1552 { | |
1200 | 1553 if ( PlayCard(player_num, current_card_slot_index) ) |
0 | 1554 { |
1555 byte_4FAA2E = 1; | |
1556 if ( am_byte_4FAA75 ) | |
1557 am_byte_4FAA76 = 1; | |
1558 } | |
1559 } | |
1560 if ( a2.field_0 == 8 ) | |
1561 { | |
1256 | 1562 if ( DiscardCard(player_num, current_card_slot_index) ) |
0 | 1563 { |
1564 byte_4FAA2E = 1; | |
1565 if ( am_byte_4FAA75 ) | |
1566 am_byte_4FAA76 = 1; | |
1567 } | |
1568 } | |
1569 } | |
1570 } | |
1571 //nullsub_1(); | |
1218 | 1572 //if ( false ) |
1573 //{ | |
1574 // if ( !v15 ) | |
1575 // { | |
1576 // //nullsub_1(); | |
1577 // v15 = 1; | |
1578 // } | |
1579 //} | |
1580 //else | |
1581 //{ | |
1582 // v15 = 0; | |
1583 // } | |
1584 //if ( false ) | |
1585 //{ | |
1586 // //nullsub_1(); | |
1587 // //nullsub_1(); | |
1588 // // assert(false && "Invalid strcpy params"); | |
1589 // // inv_strcpy(nullptr, Dest); | |
1590 // v5 = 0;//unk::const_0(&unk_4E19FC, 0); | |
1591 // //nullsub_1(); | |
1592 // if ( v5 == 1 ) | |
1593 // { | |
1594 // pAudioPlayer->StopChannels(-1, -1); | |
1595 // v16 = 1; | |
1596 // pArcomageGame->field_F4 = 1; | |
1597 // dword_4FAA68 = 0; | |
1598 // } | |
1599 // /*v10[0] = 0; | |
1600 // v10[2] = 640; | |
1601 // v10[1] = 0; | |
1602 // v10[3] = 480;*/ | |
1603 // //nullsub_1(); | |
1604 //} | |
1209 | 1605 if ( dword_4FABB8 != DrawCardsRectangles(player_num) ) |
0 | 1606 { |
1263 | 1607 dword_4FABB8 = DrawCardsRectangles(player_num); |
1608 pArcomageGame->field_F6 = 1; | |
1209 | 1609 } |
0 | 1610 if ( pArcomageGame->field_F6 ) |
1611 { | |
1263 | 1612 DrawGameUI(animation_stage); |
0 | 1613 DoBlt_Copy(pArcomageGame->pBackgroundPixels); |
1614 pArcomageGame->field_F6 = 0; | |
1615 } | |
1616 if ( pArcomageGame->field_F9 ) | |
1617 { | |
1194 | 1618 pTargetXY.x = 0; |
1619 pTargetXY.y = 0; | |
1620 pSrcXYZW.left = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
1621 pSrcXYZW.right = window->GetWidth(); |
1194 | 1622 pSrcXYZW.top = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
1623 pSrcXYZW.bottom = window->GetHeight(); |
0 | 1624 am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1); |
2154 | 1625 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); |
0 | 1626 am_EndScene(); |
1263 | 1627 DrawGameUI(animation_stage); |
0 | 1628 pRenderer->Present(); |
1629 pArcomageGame->field_F9 = 0; | |
1630 } | |
1631 } | |
1263 | 1632 while ( !break_loop ); |
0 | 1633 return dword_4FAA68 > 0; |
1634 } | |
1194 | 1635 |
0 | 1636 |
1637 //----- (0040A9AF) -------------------------------------------------------- | |
1263 | 1638 void DrawGameUI( int animation_stage ) |
1679 | 1639 { |
0 | 1640 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); |
1197 | 1641 DrawRectanglesForText(); |
0 | 1642 am_EndScene(); |
1197 | 1643 |
0 | 1644 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); |
2213 | 1645 DrawCards();//ðèñóåì êàðòû |
1646 DrawPlayersTowers();//ðèñóåì áàøíþ | |
1647 DrawPlayersWall();//ðèñóåì ñòåíó | |
1648 DrawPlayersText();//ðèñóåì òåêñò | |
0 | 1649 am_EndScene(); |
1197 | 1650 |
0 | 1651 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); |
1263 | 1652 DrawCardAnimation(animation_stage); |
1185 | 1653 |
2213 | 1654 for( int i = 0; i < 10; ++i ) |
1655 { | |
1656 if (array_4FABD0[i].have_effect) | |
1657 array_4FABD0[i].field_40->DrawEffect(); | |
1658 } | |
1200 | 1659 current_card_slot_index = DrawCardsRectangles(current_player_num); |
1263 | 1660 DrawSparks(); |
0 | 1661 am_EndScene(); |
1662 } | |
1663 | |
1664 //----- (0040AA4E) -------------------------------------------------------- | |
1263 | 1665 void DrawSparks() |
2213 | 1666 { |
1263 | 1667 int rgb_pixel_color; // [sp-4h] [bp-2Ch]@4 |
1668 unsigned int pixel_color; | |
1185 | 1669 |
2213 | 1670 for ( int i = 0; i < 10; ++i ) |
1671 { | |
1672 if(array_4FABD0[i].have_effect && (array_4FABD0[i].field_40->_40E2A7()==2)) | |
1673 { | |
1674 rgb_pixel_color = 0x0000FF00; | |
1675 if ( !array_4FABD0[i].effect_sign ) | |
1676 rgb_pixel_color = 0x000000FF; | |
1677 pixel_color = R8G8B8_to_TargetFormat(rgb_pixel_color); | |
1678 for( int j = 0; j < 150; ++j ) | |
0 | 1679 { |
2213 | 1680 if (array_4FABD0[i].effect_sparks[j].have_spark > 0) |
1681 { | |
1682 if ( j%2 ) | |
1683 DrawPixel(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color); | |
1684 else | |
1685 DrawSquare(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color); | |
1686 } | |
0 | 1687 } |
2213 | 1688 } |
1689 } | |
0 | 1690 } |
1691 | |
1692 //----- (0040AB0A) -------------------------------------------------------- | |
1197 | 1693 void DrawRectanglesForText() |
2213 | 1694 { |
1183 | 1695 RECT pSrcRect; // [sp+Ch] [bp-18h]@1 |
1696 POINT pTargetXY; // [sp+1Ch] [bp-8h]@1 | |
1679 | 1697 |
1197 | 1698 //resources rectangles |
1263 | 1699 pSrcRect.left = 765; |
1183 | 1700 pSrcRect.top = 0; |
1701 pSrcRect.right = 843; | |
1702 pSrcRect.bottom = 216; | |
1703 | |
1704 pTargetXY.x = 8; | |
1705 pTargetXY.y = 56; | |
2154 | 1706 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetXY, 2); |
1183 | 1707 |
1708 pTargetXY.x = 555; | |
1709 pTargetXY.y = 56; | |
2154 | 1710 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetXY, 2); |
1183 | 1711 |
1197 | 1712 //players name rectangle |
1183 | 1713 pSrcRect.left = 283; |
1263 | 1714 pSrcRect.top = 166; |
1183 | 1715 pSrcRect.right = 361; |
1716 pSrcRect.bottom = 190; | |
1717 pTargetXY.x = 8; | |
1718 pTargetXY.y = 13; | |
2154 | 1719 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1720 |
1721 pTargetXY.x = 555; | |
1722 pTargetXY.y = 13; | |
2154 | 1723 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1724 |
1241 | 1725 //tower height rectangle |
1183 | 1726 pSrcRect.left = 234; |
1263 | 1727 pSrcRect.top = 166; |
1183 | 1728 pSrcRect.right = 283; |
1729 pSrcRect.bottom = 190; | |
1730 pTargetXY.x = 100; | |
1731 pTargetXY.y = 296; | |
2154 | 1732 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1733 |
1734 pTargetXY.x = 492; | |
1735 pTargetXY.y = 296; | |
2154 | 1736 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1737 |
1241 | 1738 //wall height rectangle |
1263 | 1739 pSrcRect.left = 192; |
1740 pSrcRect.top = 166; | |
1183 | 1741 pSrcRect.right = 234; |
1742 pSrcRect.bottom = 190; | |
1743 pTargetXY.x = 168; | |
1744 pTargetXY.y = 296; | |
2154 | 1745 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
1183 | 1746 |
1747 pTargetXY.x = 430; | |
1748 pTargetXY.y = 296; | |
2154 | 1749 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); |
0 | 1750 } |
1751 | |
1752 //----- (0040AC5F) -------------------------------------------------------- | |
1197 | 1753 void DrawPlayersText() |
2213 | 1754 { |
1197 | 1755 int res_value; // ecx@18 |
1756 char text_buff[32]; // [sp+Ch] [bp-28h]@2 | |
1757 POINT text_position; // [sp+2Ch] [bp-8h]@2 | |
0 | 1758 |
1263 | 1759 if ( need_to_discard_card ) |
0 | 1760 { |
1209 | 1761 strcpy(text_buff, pGlobalTXT_LocalizationStrings[266]);// DISCARD A CARD |
1197 | 1762 text_position.x = 320 - pArcomageGame->pfntArrus->GetLineWidth(text_buff) / 2; |
1763 text_position.y = 306; | |
1679 | 1764 am_DrawText(-1, text_buff, &text_position); |
0 | 1765 } |
1209 | 1766 strcpy( text_buff, am_Players[0].pPlayerName); |
1197 | 1767 if ( !current_player_num ) |
1209 | 1768 strcat(text_buff, "***"); |
1197 | 1769 text_position.x = 47 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1770 text_position.y = 21; | |
1679 | 1771 am_DrawText(-1, text_buff, &text_position); |
1197 | 1772 |
1209 | 1773 strcpy(text_buff, am_Players[1].pPlayerName); |
1197 | 1774 if ( current_player_num == 1 ) |
1209 | 1775 strcat(text_buff, "***" ); |
1197 | 1776 text_position.x = 595 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1777 text_position.y = 21; | |
1679 | 1778 am_DrawText(-1, text_buff, &text_position); |
1779 | |
1780 am_IntToString(am_Players[0].tower_height, text_buff); | |
1197 | 1781 text_position.x = 123 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1782 text_position.y = 305; | |
1679 | 1783 am_DrawText(-1, text_buff, &text_position); |
1784 | |
1785 am_IntToString(am_Players[1].tower_height, text_buff); | |
1197 | 1786 text_position.x = 515 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1787 text_position.y = 305; | |
1679 | 1788 am_DrawText(-1, text_buff, &text_position); |
1789 | |
1790 am_IntToString(am_Players[0].wall_height, text_buff); | |
1197 | 1791 text_position.x = 188 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1792 text_position.y = 305; | |
1679 | 1793 am_DrawText(-1, text_buff, &text_position); |
1794 | |
1795 am_IntToString(am_Players[1].wall_height, text_buff); | |
1197 | 1796 text_position.x = 451 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; |
1797 text_position.y = 305; | |
1679 | 1798 am_DrawText(-1, text_buff, &text_position); |
1197 | 1799 |
1800 res_value = am_Players[0].quarry_level; | |
1263 | 1801 if ( use_start_bonus ) |
1197 | 1802 res_value =am_Players[0].quarry_level + quarry_bonus; |
1679 | 1803 am_IntToString(res_value, text_buff); |
1197 | 1804 text_position.x = 14;// - 6 * 0 / 2; |
1805 text_position.y = 92; | |
1806 DrawPlayerLevels(-1, text_buff, &text_position); | |
1807 | |
1808 res_value = am_Players[1].quarry_level; | |
1263 | 1809 if ( use_start_bonus ) |
1197 | 1810 res_value = am_Players[1].quarry_level + quarry_bonus; |
1679 | 1811 am_IntToString(res_value, text_buff); |
1197 | 1812 // v2 = 0; |
1813 text_position.y = 92; | |
1814 text_position.x = 561; //- 6 * v2 / 2; | |
1815 DrawPlayerLevels(-1, text_buff, &text_position); | |
1816 | |
1817 res_value = am_Players[0].magic_level; | |
1263 | 1818 if ( use_start_bonus ) |
1197 | 1819 res_value = am_Players[0].magic_level + magic_bonus; |
1679 | 1820 am_IntToString(res_value, text_buff); |
1197 | 1821 // v4 = 0; |
1822 text_position.y = 164; | |
1823 text_position.x = 14; //- 6 * v4 / 2; | |
1824 DrawPlayerLevels(-1, text_buff, &text_position); | |
1825 | |
1826 res_value = am_Players[1].magic_level; | |
1263 | 1827 if ( use_start_bonus ) |
1828 res_value = am_Players[1].magic_level + magic_bonus; | |
1679 | 1829 am_IntToString(res_value, text_buff); |
1197 | 1830 // v6 = 0; |
1831 text_position.y = 164; | |
1832 text_position.x = 561; //- 6 * v6 / 2; | |
1833 DrawPlayerLevels(-1, text_buff, &text_position); | |
1834 | |
1200 | 1835 res_value = am_Players[0].zoo_level; |
1263 | 1836 if ( use_start_bonus ) |
1201 | 1837 res_value = am_Players[0].zoo_level + zoo_bonus; |
1679 | 1838 am_IntToString(res_value, text_buff); |
1197 | 1839 // v8 = 0; |
1840 text_position.y = 236; | |
1841 text_position.x = 14;// - 6 * v8 / 2; | |
1842 DrawPlayerLevels(-1, text_buff, &text_position); | |
1843 | |
1200 | 1844 res_value = am_Players[1].zoo_level; |
1263 | 1845 if ( use_start_bonus ) |
1201 | 1846 res_value = am_Players[1].zoo_level + zoo_bonus; |
1679 | 1847 am_IntToString(res_value, text_buff); |
1197 | 1848 // v10 = 0; |
1849 text_position.y = 236; | |
1850 text_position.x = 561;// - 6 * v10 / 2; | |
1851 DrawPlayerLevels(-1, text_buff, &text_position); | |
1852 | |
1679 | 1853 am_IntToString(am_Players[0].resource_bricks, text_buff); |
1197 | 1854 text_position.y = 114; |
1855 text_position.x = 10; | |
1856 DrawBricksCount(-1, text_buff, &text_position); | |
1857 | |
1679 | 1858 am_IntToString(am_Players[1].resource_bricks, text_buff); |
1197 | 1859 text_position.x = 557; |
1860 text_position.y = 114; | |
1861 DrawBricksCount(-1, text_buff, &text_position); | |
1862 | |
1679 | 1863 am_IntToString(am_Players[0].resource_gems, text_buff); |
1197 | 1864 text_position.x = 10; |
1865 text_position.y = 186; | |
1866 DrawGemsCount(-1, text_buff, &text_position); | |
1867 | |
1679 | 1868 am_IntToString(am_Players[1].resource_gems, text_buff); |
1197 | 1869 text_position.x = 557; |
1870 text_position.y = 186; | |
1871 DrawGemsCount(-1, text_buff, &text_position); | |
1872 | |
1679 | 1873 am_IntToString(am_Players[0].resource_beasts, text_buff); |
1197 | 1874 text_position.x = 10; |
1875 text_position.y = 258; | |
1876 DrawBeastsCount(-1, text_buff, &text_position); | |
1877 | |
1679 | 1878 am_IntToString(am_Players[1].resource_beasts, text_buff); |
1197 | 1879 text_position.x = 557; |
1880 text_position.y = 258; | |
1881 DrawBeastsCount(-1, text_buff, &text_position); | |
0 | 1882 } |
1197 | 1883 |
0 | 1884 |
1885 //----- (0040B102) -------------------------------------------------------- | |
1197 | 1886 void DrawPlayerLevels( int a1, char *text, POINT *pXY ) |
2213 | 1887 { |
1194 | 1888 char *v3; // esi@1 |
1889 unsigned char test_char; // bl@2 | |
1890 int v7; // eax@3 | |
1891 RECT pSrcRect; | |
1892 POINT pTargetPoint; | |
1893 | |
1894 v3 = text; | |
1895 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); | |
1896 pTargetPoint.x = pXY->x; | |
1897 pTargetPoint.y = pXY->y; | |
1898 do | |
1899 { | |
1900 test_char = *v3; | |
1901 ++v3; | |
1902 if ( test_char ) | |
1903 { | |
1904 v7 = 22 * test_char; | |
1905 pSrcRect.right = v7 - 842; | |
1906 pSrcRect.left = v7 - 864; | |
1907 pSrcRect.top = 190; | |
1908 pSrcRect.bottom = 207; | |
2154 | 1909 pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetPoint, pArcomageGame->field_54, 1); |
1194 | 1910 pTargetPoint.x += 22; |
1911 } | |
1912 } | |
1913 while ( test_char!= 0 ); | |
1914 am_EndScene(); | |
0 | 1915 } |
1916 | |
1917 //----- (0040B17E) -------------------------------------------------------- | |
1197 | 1918 void DrawBricksCount( int a1, char* text, POINT *pXY ) |
2213 | 1919 { |
1920 char *v3; // esi@1 | |
1921 unsigned char test_char; // bl@2 | |
1922 int v7; // eax@3 | |
1923 RECT pSrcRect; | |
1924 POINT pTargetPoint; | |
1925 | |
1926 v3 = text; | |
1927 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); | |
1928 pTargetPoint.x = pXY->x; | |
1929 pTargetPoint.y = pXY->y; | |
1930 do | |
1931 { | |
1932 test_char = *v3; | |
1933 ++v3; | |
1934 if ( test_char ) | |
0 | 1935 { |
2213 | 1936 v7 = 13 * test_char; |
1937 pSrcRect.left = v7 - 370; | |
1938 pSrcRect.right = v7 - 357; | |
1939 pSrcRect.top = 128; | |
1940 pSrcRect.bottom = 138; | |
1941 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2); | |
1942 pTargetPoint.x += 13; | |
1943 } | |
1944 } | |
1945 while ( test_char!= 0 ); | |
1946 am_EndScene(); | |
0 | 1947 } |
1948 | |
1949 //----- (0040B1F3) -------------------------------------------------------- | |
1197 | 1950 void DrawGemsCount( int a1, char* text, POINT* pXY ) |
2213 | 1951 { |
1952 char *v3; // esi@1 | |
1953 unsigned char test_char; // bl@2 | |
1954 int v7; // eax@3 | |
1955 RECT pSrcRect; | |
1956 POINT pTargetPoint; | |
1957 | |
1958 v3 = text; | |
1959 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); | |
1960 pTargetPoint.x = pXY->x; | |
1961 pTargetPoint.y = pXY->y; | |
1962 do | |
1963 { | |
1964 test_char = *v3; | |
1965 ++v3; | |
1966 if ( test_char ) | |
0 | 1967 { |
2213 | 1968 v7 = 13 * test_char; |
1969 pSrcRect.left = v7 - 370; | |
1970 pSrcRect.right = v7 - 357; | |
1971 pSrcRect.top = 138; | |
1972 pSrcRect.bottom = 148; | |
1973 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2); | |
1974 pTargetPoint.x += 13; | |
1975 } | |
1976 } | |
1977 while ( test_char!= 0 ); | |
1978 am_EndScene(); | |
0 | 1979 } |
1980 | |
1981 //----- (0040B268) -------------------------------------------------------- | |
1197 | 1982 void DrawBeastsCount( int a1, char *text, POINT *pXY ) |
2213 | 1983 { |
1984 char *v3; // esi@1 | |
1985 unsigned char test_char; // bl@2 | |
1986 int v7; // eax@3 | |
1987 RECT pSrcRect; | |
1988 POINT pTargetPoint; | |
1989 | |
1990 v3 = text; | |
1991 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); | |
1992 pTargetPoint.x = pXY->x; | |
1993 pTargetPoint.y = pXY->y; | |
1994 do | |
1995 { | |
1996 test_char = *v3; | |
1997 ++v3; | |
1998 if ( test_char ) | |
0 | 1999 { |
2213 | 2000 v7 = 13 * test_char; |
2001 pSrcRect.left = v7 - 370; | |
2002 pSrcRect.right = v7 - 357; | |
2003 pSrcRect.top = 148; | |
2004 pSrcRect.bottom = 158; | |
2005 pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2); | |
2006 pTargetPoint.x += 13; | |
2007 } | |
2008 } | |
2009 while ( test_char!= 0 ); | |
2010 am_EndScene(); | |
0 | 2011 } |
2012 | |
2013 //----- (0040B2DD) -------------------------------------------------------- | |
1197 | 2014 void DrawPlayersTowers() |
2213 | 2015 { |
2016 int tower_height; // eax@1 | |
2017 int tower_top; // esi@3 | |
2018 RECT pSrcXYZW; // [sp+0h] [bp-18h]@3 | |
2019 POINT pTargetXY; // [sp+10h] [bp-8h]@3 | |
2020 | |
2021 tower_height= am_Players[0].tower_height; | |
2022 if ( am_Players[0].tower_height > max_tower_height ) | |
1197 | 2023 tower_height = max_tower_height; |
2213 | 2024 pSrcXYZW.top = 0; |
2025 pSrcXYZW.left = 892; | |
2026 pSrcXYZW.right = 937; | |
2027 tower_top = 200 * tower_height / max_tower_height; | |
2028 pSrcXYZW.bottom = tower_top; | |
2029 pTargetXY.x = 102; | |
2030 pTargetXY.y = 297 - tower_top; | |
2031 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);//ñòåíà áàøíè | |
2032 | |
2033 pSrcXYZW.top = 0; | |
2034 pSrcXYZW.left = 384; | |
2035 pSrcXYZW.right = 452; | |
2036 pSrcXYZW.bottom = 94; | |
2037 pTargetXY.y = 203 - tower_top; | |
2038 pTargetXY.x = 91; | |
2039 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);//âåðõóøêà áàøíè | |
2040 | |
2041 tower_height = am_Players[1].tower_height; | |
2042 if (am_Players[1].tower_height > max_tower_height ) | |
2043 tower_height = max_tower_height; | |
2044 tower_top = 200 * tower_height / max_tower_height; | |
2045 pSrcXYZW.top = 0; | |
2046 pSrcXYZW.left = 892; | |
2047 pSrcXYZW.right = 937; | |
2048 pSrcXYZW.bottom = tower_top; | |
2049 | |
2050 pTargetXY.x = 494; | |
2051 pTargetXY.y = 297 - tower_top; | |
2052 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); | |
2053 //draw tower up cone | |
2054 pSrcXYZW.left = 384; | |
2055 pSrcXYZW.right = 452; | |
2056 pSrcXYZW.top = 94; | |
2057 pSrcXYZW.bottom = 188; | |
2058 | |
2059 pTargetXY.x = 483; | |
2060 pTargetXY.y = 203 - tower_top; | |
2061 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); | |
0 | 2062 } |
2063 // 4E1884: using guessed type int dword_4E1884; | |
2064 | |
2065 //----- (0040B400) -------------------------------------------------------- | |
1197 | 2066 void DrawPlayersWall() |
2213 | 2067 { |
2068 int v0; // eax@1 | |
2069 int v1; // eax@4 | |
2334 | 2070 // LONG v2; // ecx@4 |
2213 | 2071 int v3; // eax@5 |
2072 int v4; // eax@8 | |
2334 | 2073 // LONG v5; // esi@8 |
2213 | 2074 RECT pSrcXYZW; // [sp+4h] [bp-18h]@4 |
2075 POINT pTargetXY; // [sp+14h] [bp-8h]@4 | |
2076 | |
2077 v0 = am_Players[0].wall_height; | |
2078 | |
2079 if ( am_Players[0].wall_height > 100 ) | |
1194 | 2080 v0 = 100; |
1218 | 2081 |
2213 | 2082 if ( am_Players[0].wall_height > 0 ) |
2083 { | |
2084 pSrcXYZW.top = 0; | |
2085 pSrcXYZW.left = 843; | |
2086 v1 = 200 * v0 / 100; | |
2087 pSrcXYZW.right = 867; | |
2088 pSrcXYZW.bottom = v1; | |
2089 pTargetXY.x = 177; | |
2090 pTargetXY.y = 297 - v1; | |
2091 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); | |
2092 } | |
2093 v3 = am_Players[1].wall_height; | |
2094 if ( am_Players[1].wall_height > 100 ) | |
2095 v3 = 100; | |
2096 if ( am_Players[1].wall_height > 0 ) | |
2097 { | |
2098 pSrcXYZW.top = 0; | |
2099 pSrcXYZW.left = 843; | |
2100 v4 = 200 * v3 / 100; | |
2101 pSrcXYZW.right = 867; | |
2102 pSrcXYZW.bottom = v4; | |
2103 pTargetXY.x = 439; | |
2104 pTargetXY.y = 297 - v4; | |
2105 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); | |
2106 } | |
0 | 2107 } |
2108 | |
2109 //----- (0040B4B9) -------------------------------------------------------- | |
1209 | 2110 void DrawCards() |
2213 | 2111 { |
2112 int v0; // esi@1 | |
2334 | 2113 // char v1; // bl@1 |
2213 | 2114 int v2; // edi@1 |
2115 //int v3; // edx@2 | |
2334 | 2116 // int v4; // eax@3 |
2117 // int v5; // ecx@3 | |
2118 // int v6; // eax@3 | |
2213 | 2119 unsigned int v7; // ecx@4 |
2334 | 2120 // int v8; // eax@16 |
2121 // int v9; // ecx@16 | |
2122 // int v10; // eax@16 | |
2213 | 2123 signed int v11; // edi@18 |
2334 | 2124 // signed int v12; // esi@20 |
2125 // int v13; // ecx@20 | |
2126 // int v14; // eax@23 | |
2127 // signed int v15; // eax@25 | |
2128 // int v16; // ecx@25 | |
2129 // POINT *v17; // esi@26 | |
2130 // signed int v18; // eax@29 | |
2131 // AcromageCardOnTable *v19; // ecx@29 | |
2132 // int v20; // ecx@31 | |
2133 // int v21; // [sp-4h] [bp-2Ch]@8 | |
2213 | 2134 RECT pSrcXYZW; // [sp+Ch] [bp-1Ch]@8 |
2135 POINT pTargetXY; // [sp+1Ch] [bp-Ch]@1 | |
2136 int v24; // [sp+24h] [bp-4h]@1 | |
2137 | |
2138 v0 = GetPlayerHandCardCount(current_player_num); | |
2139 pTargetXY.y = 327; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2140 v24 = (window->GetWidth() - 96 * v0) / (v0 + 1); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2141 pTargetXY.x = (window->GetWidth() - 96 * v0) / (v0 + 1); |
2213 | 2142 for ( v2 = 0; v2 < v0; ++v2 ) |
2143 { | |
2144 //v3 = current_player_num; | |
2145 if ( am_byte_4E185D) | |
1200 | 2146 { |
2213 | 2147 pTargetXY.x += am_Players[current_player_num].card_shift[v2].x; |
2148 pTargetXY.y += am_Players[current_player_num].card_shift[v2].y; | |
2149 } | |
1200 | 2150 v7 = am_Players[current_player_num].cards_at_hand[v2]; |
2213 | 2151 if ( am_Players[current_player_num].cards_at_hand[v2] == -1 ) |
2152 { | |
2153 ++v0; | |
2154 goto LABEL_15; | |
2155 } | |
1200 | 2156 if ( v2 != amuint_4FAA4C ) |
2213 | 2157 { |
2158 if ( am_Players[current_player_num].IsHisTurn == 0 && byte_505881 == 0 ) | |
2159 { | |
2160 pSrcXYZW.left = 192; | |
2161 pSrcXYZW.right = 288; | |
2162 pSrcXYZW.top = 0; | |
2163 pSrcXYZW.bottom = 128; | |
2164 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);//ðèñóåòñÿ îáîðîòíûå ñòîðîíû êàðò ïðîòèâíèêà | |
2165 pTargetXY.x += v24 + 96; | |
2166 goto LABEL_15; | |
2167 } | |
2168 pArcomageGame->GetCardRect(v7, &pSrcXYZW); | |
2169 if ( !CanCardBePlayed(current_player_num, v2) ) | |
2170 { | |
2171 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0);//ðèñóþòñÿ íåàêòèâíûå êàðòû | |
2172 pTargetXY.x += v24 + 96; | |
2173 goto LABEL_15; | |
2174 } | |
2175 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);//ðèñóþòñÿ àêòèâíûå êàðòû | |
2176 } | |
1200 | 2177 pTargetXY.x += v24 + 96; |
2178 LABEL_15: | |
1241 | 2179 if ( am_byte_4E185D ) |
2213 | 2180 { |
2181 pTargetXY.x -= am_Players[current_player_num].card_shift[v2].x; | |
2182 pTargetXY.y -= am_Players[current_player_num].card_shift[v2].y; | |
1200 | 2183 } |
2213 | 2184 } |
2185 | |
2186 for ( v11 = 0; v11 < 10; ++v11 ) | |
2187 { | |
1200 | 2188 if ( am_byte_4FAA76 == 0 ) |
2213 | 2189 { |
2190 if ( shown_cards[v11].uCardId != -1 ) | |
2191 { | |
2192 pArcomageGame->GetCardRect(shown_cards[v11].uCardId, &pSrcXYZW); | |
2193 pRenderer->am_Blt_Copy(&pSrcXYZW, &shown_cards[v11].field_18_point, 0); | |
2194 } | |
2195 if ( shown_cards[v11].field_4 != 0 ) | |
2196 { | |
2197 pTargetXY.x = shown_cards[v11].field_18_point.x + 12; | |
2198 pTargetXY.y = shown_cards[v11].field_18_point.y + 40; | |
2199 pSrcXYZW.left = 843; | |
2200 pSrcXYZW.right = 916; | |
2201 pSrcXYZW.top = 200; | |
2202 pSrcXYZW.bottom = 216; | |
2203 pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); | |
2204 } | |
2205 } | |
1200 | 2206 else if ( amuint_4FAA34 <= 0 ) |
2213 | 2207 { |
2208 if ( v11 == 9 ) | |
2209 { | |
2210 am_byte_4FAA76 = 0; | |
2211 am_byte_4FAA75 = 0; | |
2212 amuint_4FAA34 = 5; | |
2213 } | |
2214 if ( shown_cards[v11].uCardId != -1 ) | |
2215 amuint_4FABC4 = shown_cards[v11].uCardId; | |
2216 shown_cards[v11].uCardId = -1; | |
2217 shown_cards[v11].field_18_point.x = shown_cards[v11].field_8.x; | |
2218 shown_cards[v11].field_18_point.y = shown_cards[v11].field_8.y; | |
2219 shown_cards[v11].field_4 = 0; | |
2220 } | |
1200 | 2221 else |
2213 | 2222 { |
2223 if ( shown_cards[v11].uCardId != -1 ) | |
2224 { | |
2225 shown_cards[v11].field_18_point.x += shown_cards[v11].field_10_xplus; | |
2226 shown_cards[v11].field_18_point.y += shown_cards[v11].field_14_y_plus; | |
2227 pArcomageGame->GetCardRect(shown_cards[v11].uCardId, &pSrcXYZW); | |
2228 pRenderer->am_Blt_Copy(&pSrcXYZW, &shown_cards[v11].field_18_point, 0); | |
2229 } | |
1200 | 2230 } |
2213 | 2231 } |
2232 if ( am_byte_4FAA76 != 0 ) | |
2233 --amuint_4FAA34; | |
2234 pSrcXYZW.left = 192; | |
2235 pSrcXYZW.right = 288; | |
2236 pSrcXYZW.top = 0; | |
2237 pSrcXYZW.bottom = 128; | |
2238 pTargetXY.x = 120; | |
2239 pTargetXY.y = 18; | |
2240 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0); | |
0 | 2241 } |
2242 | |
2243 //----- (0040B76F) -------------------------------------------------------- | |
1218 | 2244 void DrawCardAnimation( int animation_stage ) |
2213 | 2245 { |
2246 int v1; // eax@3 | |
2247 int v2; // eax@3 | |
2334 | 2248 // int v3; // esi@4 |
2213 | 2249 int v4; // eax@4 |
2334 | 2250 // POINT *v5; // edx@6 |
2251 // RECT *v6; // ecx@6 | |
2213 | 2252 int v8; // eax@15 |
2334 | 2253 // AcromageCardOnTable *v9; // ecx@15 |
2254 // int v10; // ecx@19 | |
2255 // int v11; // eax@20 | |
2256 // int v12; // ecx@20 | |
2257 // int v13; // eax@20 | |
2258 // unsigned int v14; // ecx@21 | |
2213 | 2259 double v15; // st7@22 |
2334 | 2260 // POINT *v16; // edx@23 |
2213 | 2261 int v17; // eax@32 |
2262 char v18; // zf@37 | |
2263 int v19; // eax@41 | |
2334 | 2264 // int v20; // eax@46 |
2265 // int v21; // ecx@46 | |
2266 // int v22; // eax@46 | |
2267 // int v23; // [sp-4h] [bp-2Ch]@28 | |
2213 | 2268 RECT pSrcXYZW; // [sp+Ch] [bp-1Ch]@6 |
2269 POINT pTargetXY; // [sp+1Ch] [bp-Ch]@20 | |
2270 int v26; // [sp+24h] [bp-4h]@1 | |
2271 | |
2272 v26 = animation_stage; | |
2273 if ( amuint_4FAA4C != -1 ) | |
2274 { | |
2275 if ( amuint_4FAA38 >= 9 ) | |
1218 | 2276 { |
2213 | 2277 am_uint_4FAA44_blt_xy.y = 18; |
2278 am_uint_4FAA44_blt_xy.x = 120; | |
2279 v1 = GetPlayerHandCardCount(current_player_num); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2280 v2 = (window->GetWidth() - 96 * v1) / v1 + 96; |
2213 | 2281 if ( am_byte_4E185D ) |
2282 { | |
2283 // v3 = 188 * current_player_num + 8 * amuint_4FAA4C; | |
2284 // amuint_4FAA3C_blt_xy.x = (amuint_4FAA4C * v2 + *(am_Players[0].arr_6C[0] + v3) - 120) / 10; | |
2285 amuint_4FAA3C_blt_xy.x=(amuint_4FAA4C * v2 + am_Players[current_player_num].card_shift[amuint_4FAA4C].x-120)/10; | |
2286 v4 = (am_Players[current_player_num].card_shift[amuint_4FAA4C].y+309) /10;//(*(&am_Players[0].arr_6C[0][1] + v3) + 309) / 10; | |
2287 } | |
2288 else | |
2289 { | |
2290 amuint_4FAA3C_blt_xy.x = (amuint_4FAA4C * v2 - 120) / 10; | |
2291 v4 = 30; | |
2292 } | |
2293 am_uint_4FAA44_blt_xy.y += v4; | |
2294 am_uint_4FAA44_blt_xy.x += amuint_4FAA3C_blt_xy.x; | |
2295 amuint_4FAA3C_blt_xy.y = v4; | |
2296 pSrcXYZW.left = 192; | |
2297 pSrcXYZW.top = 0; | |
2298 pSrcXYZW.right = 288; | |
2299 pSrcXYZW.bottom = 128; | |
2300 pRenderer->am_Blt_Copy(&pSrcXYZW, &am_uint_4FAA44_blt_xy, 2); | |
2301 } | |
2302 else | |
1209 | 2303 { |
2213 | 2304 pSrcXYZW.left = 192; |
2305 pSrcXYZW.top = 0; | |
2306 pSrcXYZW.right = 288; | |
2307 pSrcXYZW.bottom = 128; | |
2308 am_uint_4FAA44_blt_xy.x += amuint_4FAA3C_blt_xy.x; | |
2309 am_uint_4FAA44_blt_xy.y += amuint_4FAA3C_blt_xy.y; | |
2310 pRenderer->am_Blt_Copy(&pSrcXYZW, &am_uint_4FAA44_blt_xy, 2); | |
2311 if ( !amuint_4FAA38 ) | |
2312 amuint_4FAA4C = -1; | |
2313 } | |
2314 } | |
2315 if ( uCardID != -1 ) | |
2316 { | |
2317 if ( v26 <= 10 ) | |
2318 { | |
2319 if ( v26 == 10 ) | |
2320 { | |
2321 pArcomageGame->GetCardRect(uCardID, &pSrcXYZW); | |
2322 // v8 = 0; | |
2323 for ( v8 = 0; v8 < 10; ++v8 ) | |
1209 | 2324 { |
2213 | 2325 if (shown_cards[v8].uCardId==-1) |
2326 { | |
2327 shown_cards[v8].uCardId = uCardID; | |
2328 shown_cards[v8].field_4 = 1; | |
2329 break; | |
2330 } | |
1209 | 2331 } |
2213 | 2332 /* v9 = shown_cards; |
2333 while ( v9->uCardId != -1 ) | |
1218 | 2334 { |
2213 | 2335 ++v9; |
2336 ++v8; | |
2337 if ( v9 >= &dword_4FABB8 ) | |
2338 goto LABEL_20; | |
1218 | 2339 } |
2213 | 2340 v10 = v8; |
2341 shown_cards[v10].uCardId = uCardID; | |
2342 shown_cards[v10].field_4 = 1;*/ | |
2343 //LABEL_20: | |
2344 pTargetXY.x = shown_cards[v8].field_8.x; | |
2345 pTargetXY.y = shown_cards[v8].field_8.y; | |
2346 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0); | |
2347 uCardID = -1; | |
2348 } | |
1209 | 2349 } |
2213 | 2350 else |
2351 { | |
2352 pArcomageGame->GetCardRect(uCardID, &pSrcXYZW); | |
2353 amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x; | |
2354 amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y; | |
2355 pRenderer->am_Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0); | |
2356 } | |
2357 } | |
2358 if ( played_card_id != -1 ) | |
2359 { | |
2360 v15 = v26; | |
2361 if ( v15 > 15.0 ) | |
2362 { | |
2363 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); | |
2364 amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x; | |
2365 amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y; | |
2366 pRenderer->am_Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 2); | |
2367 return; | |
2368 } | |
2369 if ( v15 == 15.0 ) | |
1209 | 2370 { |
2213 | 2371 ApplyCardToPlayer(current_player_num, played_card_id); |
2372 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); | |
2373 pTargetXY.x = 272; | |
2374 pTargetXY.y = 173; | |
2375 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); | |
2376 return; | |
2377 } | |
2378 if ( v15 == 5.0 ) | |
2379 { | |
2380 amuint_4FAA5C_blt_xy.x = 272; | |
2381 amuint_4FAA5C_blt_xy.y = 173; | |
2382 for ( v17 = 0; v17 < 10; ++v17 ) | |
2383 { | |
2384 if (shown_cards[v17].uCardId == -1) | |
2385 break; | |
2386 } | |
2387 amuint_4FAA54_blt_xy.x = (shown_cards[v17].field_8.x - 272) / 5; | |
2388 amuint_4FAA54_blt_xy.y = (shown_cards[v17].field_8.y - 173) / 5; | |
2389 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); | |
2390 pTargetXY.x = 272; | |
2391 pTargetXY.y = 173; | |
2392 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); | |
2393 return; | |
2394 } | |
2395 if ( v15 >= 5.0 ) | |
2396 v18 = v26 == 0; | |
1209 | 2397 else |
2213 | 2398 { |
2399 v18 = v26 == 0; | |
2400 if ( v26 > 0 ) | |
2401 { | |
2402 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); | |
1209 | 2403 amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x; |
2404 amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y; | |
2154 | 2405 pRenderer->am_Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0); |
2213 | 2406 return; |
2407 } | |
1209 | 2408 } |
2213 | 2409 if ( !v18 ) |
1209 | 2410 { |
2213 | 2411 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); |
2412 pTargetXY.x = 272; | |
2413 pTargetXY.y = 173; | |
2414 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2); | |
2415 return; | |
2416 } | |
1209 | 2417 pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); |
2213 | 2418 for ( v19 = 0; v19 < 10; ++v19 ) |
2419 { | |
2420 if (shown_cards[v19].uCardId == -1) | |
2421 { | |
2422 shown_cards[v19].uCardId = played_card_id; | |
2423 break; | |
2424 } | |
2425 } | |
2426 pTargetXY.x = shown_cards[v19].field_8.x; | |
1209 | 2427 pTargetXY.y = shown_cards[v19].field_8.y; |
2154 | 2428 pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0); |
1209 | 2429 played_card_id = -1; |
2213 | 2430 } |
0 | 2431 } |
2432 | |
2433 //----- (0040BB12) -------------------------------------------------------- | |
1183 | 2434 void ArcomageGame::GetCardRect(unsigned int uCardID, RECT *pCardRect) |
0 | 2435 { |
2436 int v3; // edx@1 | |
2437 int v4; // ecx@1 | |
2438 | |
2439 v3 = pCards[uCardID].slot % 10; | |
2440 v4 = (pCards[uCardID].slot / 10 << 7) + 220; | |
1183 | 2441 pCardRect->top = v4; |
2442 pCardRect->left = 96 * v3; | |
2443 pCardRect->bottom = v4 + 128; | |
2444 pCardRect->right = 96 * v3 + 96; | |
0 | 2445 } |
2446 | |
2447 //----- (0040BB49) -------------------------------------------------------- | |
1185 | 2448 int GetPlayerHandCardCount( int player_num ) |
2213 | 2449 { |
1185 | 2450 int card_count; // eax@1 |
2451 | |
2452 card_count = 0; | |
2453 for(int i=0; i<10; ++i) | |
2213 | 2454 { |
2455 if (am_Players[player_num].cards_at_hand[i]!=-1) | |
2456 ++card_count; | |
2457 } | |
1185 | 2458 return card_count; |
0 | 2459 } |
2460 | |
2461 //----- (0040BB67) -------------------------------------------------------- | |
1200 | 2462 signed int DrawCardsRectangles( int player_num ) |
1679 | 2463 { |
2213 | 2464 int v5; // eax@3 |
2334 | 2465 // int i; // ecx@6 |
2213 | 2466 int color; // ST00_4@19 |
2467 RECT pXYZW; // [sp+Ch] [bp-3Ch]@3 | |
2468 stru273 v26; // [sp+1Ch] [bp-2Ch]@2 | |
2469 __int32 var18; // [sp+30h] [bp-18h]@3 | |
2470 int hand_index; // [sp+3Ch] [bp-Ch]@3 | |
2209 | 2471 |
2472 //__debugbreak(); // need do fix rectangle not fit to card | |
2473 | |
2474 if ( am_Players[player_num].IsHisTurn ) | |
2475 { | |
2476 if ( v26._40DD2F() ) | |
1194 | 2477 { |
2209 | 2478 v5 = GetPlayerHandCardCount(player_num); |
2479 pXYZW.top = 327; | |
2480 pXYZW.bottom = 455; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2481 pXYZW.left = (window->GetWidth() - 96 * v5) / (v5 + 1); |
2209 | 2482 var18 = pXYZW.left + 96; |
2483 pXYZW.right = pXYZW.left + 96; | |
2213 | 2484 for( hand_index = 0; hand_index < v5; hand_index++) |
2209 | 2485 { |
2213 | 2486 //for ( i = 0; i < 10; ++i ) |
2487 //{ | |
2488 if (am_Players[player_num].cards_at_hand[hand_index] != -1 ) | |
0 | 2489 { |
2213 | 2490 //break; |
2491 //} | |
2209 | 2492 if ( am_byte_4E185D ) |
2493 { | |
2213 | 2494 pXYZW.left += am_Players[player_num].card_shift[hand_index].x; |
2495 pXYZW.right += am_Players[player_num].card_shift[hand_index].x; | |
2496 pXYZW.top += am_Players[player_num].card_shift[hand_index].y; | |
2497 pXYZW.bottom += am_Players[player_num].card_shift[hand_index].y; | |
2209 | 2498 } |
2213 | 2499 if ( v26.Inside(&pXYZW) ) |
2209 | 2500 { |
2501 if ( CanCardBePlayed(player_num, hand_index) ) | |
2213 | 2502 color = 0x00FFFFFF;//áåëûé öâåò |
1194 | 2503 else |
2213 | 2504 color = 0x000000FF;//êðàñíûé öâåò |
2505 DrawRect(&pXYZW, R8G8B8_to_TargetFormat(color), 0); | |
2209 | 2506 return hand_index; |
2507 } | |
2508 DrawRect(&pXYZW, R8G8B8_to_TargetFormat(0), 0);//ðàìêà ÷¸ðíîãî öâåòà | |
2509 if ( am_byte_4E185D ) | |
2510 { | |
2213 | 2511 pXYZW.left -= am_Players[player_num].card_shift[hand_index].x; |
2512 pXYZW.right -= am_Players[player_num].card_shift[hand_index].x; | |
2513 pXYZW.top -= am_Players[player_num].card_shift[hand_index].y; | |
2514 pXYZW.bottom -= am_Players[player_num].card_shift[hand_index].y; | |
2209 | 2515 } |
2213 | 2516 pXYZW.left += var18; |
2517 pXYZW.right += var18; | |
0 | 2518 } |
2209 | 2519 } |
0 | 2520 } |
2209 | 2521 } |
2213 | 2522 return -1; |
0 | 2523 } |
2524 // 4E185D: using guessed type char am_byte_4E185D; | |
2525 | |
2526 //----- (0040BCFB) -------------------------------------------------------- | |
1256 | 2527 bool DiscardCard( int player_num, signed int card_slot_index ) |
2213 | 2528 { |
0 | 2529 int v2; // esi@2 |
2334 | 2530 // signed int v3; // edi@2 |
2531 // char *v4; // eax@2 | |
2532 // int v5; // ecx@7 | |
2533 // int v6; // ebx@7 | |
2534 // int v7; // esi@8 | |
0 | 2535 int v8; // eax@8 |
2334 | 2536 // int v9; // esi@8 |
0 | 2537 int v10; // ecx@8 |
2334 | 2538 // int v11; // eax@8 |
0 | 2539 int v12; // eax@8 |
2334 | 2540 // signed int v13; // edx@9 |
2541 // unsigned int v14; // eax@12 | |
2542 // char result; // al@12 | |
1194 | 2543 int i; |
0 | 2544 |
1200 | 2545 if ( card_slot_index <= -1 ) |
1209 | 2546 return false; |
0 | 2547 v2 = 0; |
1194 | 2548 |
2213 | 2549 for( i = 0; i < 10; ++i ) |
0 | 2550 { |
1200 | 2551 if ( am_Players[player_num].cards_at_hand[i] != -1 ) |
0 | 2552 { |
1200 | 2553 if ( card_slot_index == v2 ) |
0 | 2554 break; |
2555 ++v2; | |
2556 } | |
2557 } | |
1194 | 2558 |
1263 | 2559 if ( pCards[am_Players[player_num].cards_at_hand[i]].can_be_discarded) |
0 | 2560 { |
1209 | 2561 ArcomageGame::PlaySound(22); |
1197 | 2562 v8 = GetPlayerHandCardCount(current_player_num); |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2563 v10 = am_Players[player_num].card_shift[i].x + (window->GetWidth() - 96 * v8) / (v8 + 1); |
1209 | 2564 amuint_4FAA5C_blt_xy.x = v10; |
1256 | 2565 amuint_4FAA5C_blt_xy.y = am_Players[player_num].card_shift[i].y + 327;//v11; |
0 | 2566 v12 = 0; |
1209 | 2567 |
0 | 2568 if ( !am_byte_4FAA75 ) |
2569 { | |
2213 | 2570 for ( v12 = 0; v12 < 10; ++v12 ) |
2571 { | |
2572 if (shown_cards[v12].uCardId == -1) | |
2573 break; | |
2574 } | |
0 | 2575 } |
2576 pArcomageGame->field_F6 = 1; | |
1209 | 2577 amuint_4FAA54_blt_xy.x = (shown_cards[v12].field_8.x - v10) / 10; |
2578 amuint_4FAA54_blt_xy.y = (shown_cards[v12].field_8.y - 327) / 10; | |
2579 uCardID = am_Players[player_num].cards_at_hand[i]; | |
2580 am_Players[player_num].cards_at_hand[i] = -1; | |
1263 | 2581 need_to_discard_card = 0; |
1209 | 2582 return true; |
0 | 2583 } |
2584 else | |
1209 | 2585 return false; |
0 | 2586 } |
1263 | 2587 |
0 | 2588 //----- (0040BE0E) -------------------------------------------------------- |
1679 | 2589 bool PlayCard( int player_num, int card_slot_num ) |
2590 { | |
2334 | 2591 // int v3; // ebp@1 |
0 | 2592 int v4; // ecx@2 |
2334 | 2593 // ArcomagePlayer *v5; // esi@2 |
1263 | 2594 int card_index; // edi@2 |
2334 | 2595 // int v7; // eax@2 |
2596 // int v8; // ebx@8 | |
1263 | 2597 int cards_at_hand; // eax@8 |
2334 | 2598 // int v10; // ebx@8 |
2599 // int v11; // ebp@8 | |
0 | 2600 int v12; // ecx@8 |
2334 | 2601 // int v13; // eax@8 |
1263 | 2602 ArcomageCard *pCard; // eax@8 |
2334 | 2603 // int v15; // ecx@8 |
2604 // int v16; // ecx@8 | |
0 | 2605 |
1197 | 2606 if ( card_slot_num <= -1 ) |
2607 return false; | |
1263 | 2608 |
0 | 2609 v4 = 0; |
1263 | 2610 for (card_index=0; card_index<10; ++card_index) |
0 | 2611 { |
1263 | 2612 if ( am_Players[player_num].cards_at_hand[card_index] != -1 ) |
0 | 2613 { |
1197 | 2614 if ( card_slot_num == v4 ) |
0 | 2615 break; |
2616 ++v4; | |
2617 } | |
2618 } | |
1209 | 2619 |
1263 | 2620 if (CanCardBePlayed(player_num, card_index) ) |
0 | 2621 { |
1209 | 2622 ArcomageGame::PlaySound(23); |
1263 | 2623 cards_at_hand = GetPlayerHandCardCount(current_player_num); |
0 | 2624 pArcomageGame->field_F6 = 1; |
1263 | 2625 v12 = am_Players[player_num].card_shift[card_index].x + |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
2626 (window->GetWidth() - 96 * cards_at_hand) / (cards_at_hand + 1)+ |
1263 | 2627 96 * card_index ; |
2628 | |
1185 | 2629 // v13 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v10) + 327; |
1218 | 2630 amuint_4FAA5C_blt_xy.x = v12;//v12; |
1263 | 2631 amuint_4FAA5C_blt_xy.y = am_Players[player_num].card_shift[card_index].y + 327;//v13; |
1209 | 2632 |
2633 amuint_4FAA54_blt_xy.x = (272 - v12) / 5; | |
2634 amuint_4FAA54_blt_xy.y = -30; | |
1200 | 2635 |
1263 | 2636 pCard = &pCards[am_Players[player_num].cards_at_hand[card_index]]; |
2637 am_Players[player_num].resource_bricks -= pCard->needed_bricks; | |
2638 am_Players[player_num].resource_beasts -= pCard->needed_beasts; | |
2639 am_Players[player_num].resource_gems -= pCard->needed_gems; | |
2640 played_card_id = am_Players[player_num].cards_at_hand[card_index]; | |
2641 am_Players[player_num].cards_at_hand[card_index] = -1; | |
2642 return true; | |
0 | 2643 } |
2644 else | |
1197 | 2645 return false; |
2646 | |
0 | 2647 } |
2648 | |
2649 //----- (0040BF15) -------------------------------------------------------- | |
1679 | 2650 bool CanCardBePlayed(int player_num, int hand_card_indx) |
2651 { | |
0 | 2652 bool result; // eax@1 |
1197 | 2653 ArcomageCard *test_card; // ecx@1 |
2654 ArcomagePlayer *pPlayer; // esi@1 | |
2655 | |
2656 pPlayer = &am_Players[player_num]; | |
1185 | 2657 result = true; |
1197 | 2658 test_card = &pCards[am_Players[player_num].cards_at_hand[hand_card_indx]]; |
2659 if ( test_card->needed_quarry_level > pPlayer->quarry_level ) | |
1185 | 2660 result = false; |
1197 | 2661 if ( test_card->needed_magic_level > pPlayer->magic_level ) |
1185 | 2662 result = false; |
1679 | 2663 if ( test_card->needed_zoo_level > pPlayer->zoo_level ) |
1185 | 2664 result = false; |
1197 | 2665 if ( test_card->needed_bricks > pPlayer->resource_bricks ) |
1185 | 2666 result = false; |
1197 | 2667 if ( test_card->needed_gems > pPlayer->resource_gems ) |
1185 | 2668 result = false; |
1197 | 2669 if ( test_card->needed_beasts > pPlayer->resource_beasts ) |
1185 | 2670 result = false; |
0 | 2671 return result; |
2672 } | |
2673 | |
2674 //----- (0040BF77) -------------------------------------------------------- | |
1218 | 2675 void ApplyCardToPlayer( int player_num, unsigned int uCardID ) |
2676 { | |
1245 | 2677 |
2678 | |
2679 #define APPLY_TO_PLAYER( PLAYER, ENEMY,FIELD, VAL, RES )\ | |
1246 | 2680 if (VAL != 0) {\ |
2681 if (VAL == 99) {\ | |
2682 if ( PLAYER->##FIELD < ENEMY->##FIELD ) {\ | |
2683 PLAYER->##FIELD = ENEMY->##FIELD;\ | |
2684 RES = ENEMY->##FIELD - PLAYER->##FIELD;\ | |
2685 }\ | |
2686 } else {\ | |
2687 PLAYER->##FIELD += (signed int)(VAL);\ | |
2688 if ( PLAYER->##FIELD<0 ) PLAYER->##FIELD= 0;\ | |
2689 RES = (signed int)(VAL);\ | |
1245 | 2690 }\ |
1246 | 2691 } |
1245 | 2692 |
2693 #define APPLY_TO_ENEMY( PLAYER, ENEMY,FIELD, VAL, RES ) APPLY_TO_PLAYER(ENEMY, PLAYER, FIELD, VAL, RES) | |
2694 | |
2695 #define APPLY_TO_BOTH( PLAYER, ENEMY, FIELD, VAL, RES_P, RES_E ) \ | |
1246 | 2696 if ( VAL != 0) {\ |
2697 if ( VAL == 99 ) { \ | |
1245 | 2698 if ( PLAYER->##FIELD != ENEMY->##FIELD ) { \ |
2699 if ( PLAYER->##FIELD <= ENEMY->##FIELD ) { \ | |
2700 PLAYER->##FIELD = ENEMY->##FIELD; \ | |
2701 RES_P = ENEMY->##FIELD - PLAYER->##FIELD; \ | |
2702 } else { \ | |
2703 ENEMY->##FIELD = PLAYER->##FIELD; \ | |
2704 RES_E = PLAYER->##FIELD - ENEMY->##FIELD; \ | |
2705 } \ | |
2706 }\ | |
1246 | 2707 } else { \ |
1245 | 2708 PLAYER->##FIELD += (signed int)(VAL);\ |
2709 ENEMY->##FIELD += (signed int)(VAL); if (PLAYER->##FIELD < 0 ) {PLAYER->##FIELD = 0;} \ | |
2710 if ( ENEMY->##FIELD < 0 ) {ENEMY->##FIELD = 0;} \ | |
1246 | 2711 RES_P = (signed int)(VAL); RES_E = (signed int)(VAL); \ |
2712 }\ | |
2713 } | |
1245 | 2714 ArcomagePlayer *player; // esi@1 |
2334 | 2715 // int v3; // eax@1 |
1245 | 2716 ArcomagePlayer *enemy; // edi@1 |
2334 | 2717 // int v5; // eax@2 |
2718 // char v6; // sf@2 | |
2719 // unsigned __int8 v7; // of@2 | |
2720 // int v8; // eax@3 | |
2721 // int v9; // eax@4 | |
2722 // char v10; // zf@5 | |
2723 // int v11; // eax@8 | |
2724 // unsigned __int8 v12; // zf@8 | |
2725 // char v13; // sf@8 | |
2726 // unsigned __int8 v14; // of@8 | |
2727 // int v15; // eax@9 | |
2728 // int v16; // eax@10 | |
2729 // char v17; // zf@12 | |
2730 // char v18; // al@15 | |
2731 // int v19; // eax@16 | |
2732 // int v20; // eax@17 | |
2733 // int v21; // eax@22 | |
2734 // int v22; // eax@23 | |
1245 | 2735 int v23; // eax@26 |
2736 signed int v24; // ebx@26 | |
2737 int v103; | |
2738 int v104; | |
2739 | |
2740 POINT v184; // [sp+Ch] [bp-64h]@488 | |
2741 int enemy_num; // [sp+14h] [bp-5Ch]@1 | |
2742 ArcomageCard *pCard; // [sp+18h] [bp-58h]@1 | |
2743 int buildings_e; // [sp+1Ch] [bp-54h]@1 | |
2744 int buildings_p; // [sp+20h] [bp-50h]@1 | |
2745 int quarry_p; // [sp+28h] [bp-48h]@1 | |
2746 int dmg_e; // [sp+2Ch] [bp-44h]@1 | |
2747 int dmg_p; // [sp+30h] [bp-40h]@1 | |
2748 int bricks_p; // [sp+34h] [bp-3Ch]@1 | |
2749 int tower_e; // [sp+38h] [bp-38h]@1 | |
2750 int tower_p; // [sp+3Ch] [bp-34h]@1 | |
2751 int wall_e; // [sp+40h] [bp-30h]@1 | |
2752 int wall_p; // [sp+44h] [bp-2Ch]@1 | |
2753 int beasts_e; // [sp+48h] [bp-28h]@1 | |
2754 int beasts_p; // [sp+4Ch] [bp-24h]@1 | |
2755 int gems_e; // [sp+50h] [bp-20h]@1 | |
2756 int gems_p; // [sp+54h] [bp-1Ch]@1 | |
2757 int bricks_e; // [sp+58h] [bp-18h]@1 | |
2758 int zoo_e; // [sp+5Ch] [bp-14h]@1 | |
2759 int zoo_p; // [sp+60h] [bp-10h]@1 | |
2760 int magic_e; // [sp+64h] [bp-Ch]@1 | |
2761 int magic_p; // [sp+68h] [bp-8h]@1 | |
2762 int quarry_e; // [sp+6Ch] [bp-4h]@1 | |
2763 | |
1246 | 2764 quarry_p = 0; |
2765 magic_p = 0; | |
2766 zoo_p = 0; | |
2767 bricks_p = 0; | |
2768 gems_p = 0; | |
2769 beasts_p = 0; | |
2770 wall_p = 0; | |
2771 tower_p = 0; | |
1245 | 2772 buildings_p = 0; |
1246 | 2773 dmg_p = 0; |
2774 quarry_e = 0; | |
2775 magic_e = 0; | |
2776 zoo_e = 0; | |
2777 bricks_e = 0; | |
2778 gems_e = 0; | |
2779 beasts_e = 0; | |
2780 wall_e = 0; | |
2781 tower_e = 0; | |
1245 | 2782 buildings_e = 0; |
1246 | 2783 dmg_e = 0; |
1245 | 2784 |
2785 player = &am_Players[player_num]; | |
2786 pCard = &pCards[uCardID]; | |
2787 enemy_num = (player_num + 1) % 2; | |
2788 enemy = &am_Players[enemy_num]; | |
2789 switch ( pCard->compare_param ) | |
2213 | 2790 { |
1245 | 2791 case 2: |
2213 | 2792 if ( player->quarry_level < enemy->quarry_level )//åñëè ðóäíèêè < ðóäíèêà âðàãà |
2793 goto LABEL_26; | |
2794 goto LABEL_231; | |
1245 | 2795 case 3: |
2213 | 2796 if ( player->magic_level < enemy->magic_level ) |
2797 goto LABEL_26; | |
2798 goto LABEL_231; | |
1245 | 2799 case 4: |
2213 | 2800 if ( player->zoo_level < enemy->zoo_level )//åñëè çâåðèíåö < çâåðèíöà âðàãà |
2801 goto LABEL_26; | |
2802 goto LABEL_231; | |
1245 | 2803 case 5: |
2213 | 2804 if ( player->quarry_level == enemy->quarry_level ) |
2805 goto LABEL_26; | |
2806 goto LABEL_231; | |
1245 | 2807 case 6: |
2213 | 2808 if ( player->magic_level == enemy->magic_level ) |
2809 goto LABEL_26; | |
2810 goto LABEL_231; | |
1245 | 2811 case 7: |
2213 | 2812 if ( player->zoo_level == enemy->zoo_level ) |
2813 goto LABEL_26; | |
2814 goto LABEL_231; | |
1245 | 2815 case 8: |
2213 | 2816 if ( player->quarry_level < enemy->quarry_level ) |
2817 goto LABEL_26; | |
2818 goto LABEL_231; | |
1245 | 2819 case 9: |
2213 | 2820 if ( player->magic_level < enemy->magic_level ) |
2821 goto LABEL_26; | |
2822 goto LABEL_231; | |
1245 | 2823 case 10: |
2213 | 2824 if ( player->zoo_level < enemy->zoo_level ) |
2825 goto LABEL_26; | |
2826 goto LABEL_231; | |
1245 | 2827 case 11: |
2213 | 2828 if ( !player->wall_height ) |
2829 goto LABEL_26; | |
2830 goto LABEL_231; | |
1245 | 2831 case 12: |
2213 | 2832 if ( player->wall_height ) |
2833 goto LABEL_26; | |
2834 goto LABEL_231; | |
1245 | 2835 case 13: |
2213 | 2836 if ( !enemy->wall_height ) |
2837 goto LABEL_26; | |
2838 goto LABEL_231; | |
1245 | 2839 case 14: |
2213 | 2840 if ( enemy->wall_height ) |
2841 goto LABEL_26; | |
2842 goto LABEL_231; | |
1245 | 2843 case 15: |
2213 | 2844 if ( player->wall_height < enemy->wall_height ) |
2845 goto LABEL_26; | |
2846 goto LABEL_231; | |
1245 | 2847 case 16: |
2213 | 2848 if ( player->tower_height < enemy->tower_height ) |
2849 goto LABEL_26; | |
2850 goto LABEL_231; | |
1245 | 2851 case 17: |
2213 | 2852 if ( player->wall_height == enemy->wall_height ) |
2853 goto LABEL_26; | |
2854 goto LABEL_231; | |
1245 | 2855 case 18: |
2213 | 2856 if ( player->tower_height == enemy->tower_height ) |
2857 goto LABEL_26; | |
2858 goto LABEL_231; | |
1245 | 2859 case 19: |
2213 | 2860 if ( player->wall_height < enemy->wall_height ) |
2861 goto LABEL_26; | |
2862 goto LABEL_231; | |
1245 | 2863 case 20: |
2213 | 2864 if ( player->tower_height < enemy->tower_height ) |
1245 | 2865 goto LABEL_26; |
2866 goto LABEL_231; | |
2867 default: | |
2868 LABEL_26: | |
1263 | 2869 v23 = pCard->draw_extra_card_count; |
1245 | 2870 v24 = 0; |
2871 dword_4FAA68 = v23 + (pCard->field_30 == 1); | |
2872 dword_4FAA64 = v23; | |
2873 if ( v23 > 0 ) | |
2213 | 2874 { |
2875 do | |
2876 { | |
2877 GetNextCardFromDeck(player_num); | |
2878 ++v24; | |
2879 } | |
2880 while ( v24 < pCard->draw_extra_card_count ); | |
2881 } | |
1245 | 2882 |
1263 | 2883 need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand; |
1245 | 2884 |
2885 APPLY_TO_PLAYER(player, enemy, quarry_level, pCard->to_player_quarry_lvl, quarry_p); | |
2886 APPLY_TO_PLAYER(player, enemy, magic_level, pCard->to_player_magic_lvl, magic_p); | |
2887 APPLY_TO_PLAYER(player, enemy, zoo_level, pCard->to_player_zoo_lvl, zoo_p); | |
2888 APPLY_TO_PLAYER(player, enemy, resource_bricks, pCard->to_player_bricks, bricks_p); | |
2889 APPLY_TO_PLAYER(player, enemy, resource_gems, pCard->to_player_gems, gems_p); | |
2890 APPLY_TO_PLAYER(player, enemy, resource_beasts, pCard->to_player_beasts, beasts_p); | |
1246 | 2891 if ( pCard->to_player_buildings ) |
1245 | 2892 { |
1246 | 2893 dmg_p = ApplyDamageToBuildings(player_num, (signed int)pCard->to_player_buildings); |
2894 buildings_p = (signed int)pCard->to_player_buildings - dmg_p; | |
1245 | 2895 } |
1246 | 2896 APPLY_TO_PLAYER(player, enemy, wall_height, pCard->to_player_wall, wall_p); |
2897 APPLY_TO_PLAYER(player, enemy, tower_height, pCard->to_player_tower, tower_p); | |
1245 | 2898 |
2899 APPLY_TO_ENEMY(player, enemy, quarry_level, pCard->to_enemy_quarry_lvl, quarry_e); | |
2900 APPLY_TO_ENEMY(player, enemy, magic_level, pCard->to_enemy_magic_lvl, magic_e); | |
2901 APPLY_TO_ENEMY(player, enemy, zoo_level, pCard->to_enemy_zoo_lvl, zoo_e); | |
2902 APPLY_TO_ENEMY(player, enemy, resource_bricks, pCard->to_enemy_bricks, bricks_e); | |
2903 APPLY_TO_ENEMY(player, enemy, resource_gems, pCard->to_enemy_gems, gems_e); | |
2904 APPLY_TO_ENEMY(player, enemy, resource_beasts, pCard->to_enemy_beasts, beasts_e); | |
2905 if ( pCard->to_enemy_buildings ) | |
2906 { | |
1246 | 2907 dmg_e = ApplyDamageToBuildings(enemy_num, (signed int)pCard->to_enemy_buildings); |
2908 buildings_e = (signed int)pCard->to_enemy_buildings - dmg_e; | |
1245 | 2909 } |
2910 APPLY_TO_ENEMY(player, enemy, wall_height, pCard->to_enemy_wall, wall_e); | |
2911 APPLY_TO_ENEMY(player, enemy, tower_height, pCard->to_enemy_tower, tower_e); | |
2912 | |
2913 APPLY_TO_BOTH(player, enemy, quarry_level, pCard->to_pl_enm_quarry_lvl, quarry_p, quarry_e); | |
2914 APPLY_TO_BOTH(player, enemy, magic_level, pCard->to_pl_enm_magic_lvl, magic_p, magic_e); | |
2915 APPLY_TO_BOTH(player, enemy, zoo_level, pCard->to_pl_enm_zoo_lvl, zoo_p, zoo_e); | |
2916 APPLY_TO_BOTH(player, enemy, resource_bricks, pCard->to_pl_enm_bricks, bricks_p, bricks_e); | |
2917 APPLY_TO_BOTH(player, enemy, resource_gems, pCard->to_pl_enm_gems, gems_p, gems_e); | |
2918 APPLY_TO_BOTH(player, enemy, resource_beasts, pCard->to_pl_enm_beasts, beasts_p, beasts_e); | |
2919 if ( pCard->to_pl_enm_buildings ) | |
2920 { | |
1246 | 2921 dmg_p = ApplyDamageToBuildings(player_num, (signed int)pCard->to_pl_enm_buildings); |
2922 dmg_e = ApplyDamageToBuildings(enemy_num, (signed int)pCard->to_pl_enm_buildings); | |
2923 buildings_p = (signed int)pCard->to_pl_enm_buildings - dmg_p; | |
2924 buildings_e = (signed int)pCard->to_pl_enm_buildings - dmg_e; | |
1245 | 2925 } |
2926 APPLY_TO_BOTH(player, enemy, wall_height, pCard->to_pl_enm_wall, wall_p, wall_e); | |
2927 APPLY_TO_BOTH(player, enemy, tower_height, pCard->to_pl_enm_tower, tower_p, tower_e); | |
2928 break; | |
2929 case 0: | |
2930 LABEL_231: | |
2931 v103 = pCard->can_draw_extra_card2; | |
2932 v104 = 0; | |
2933 dword_4FAA68 = v103 + (pCard->field_4D == 1); | |
2934 dword_4FAA64 = v103; | |
2935 if ( v103 > 0 ) | |
2936 { | |
2937 do | |
2938 { | |
2939 GetNextCardFromDeck(player_num); | |
2940 ++v104; | |
2941 } | |
2942 while ( v104 < pCard->can_draw_extra_card2 ); | |
2943 } | |
2944 | |
1263 | 2945 need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand; |
1245 | 2946 |
2947 APPLY_TO_PLAYER(player, enemy, quarry_level, pCard->to_player_quarry_lvl2, quarry_p); | |
2948 APPLY_TO_PLAYER(player, enemy, magic_level, pCard->to_player_magic_lvl2, magic_p); | |
2949 APPLY_TO_PLAYER(player, enemy, zoo_level, pCard->to_player_zoo_lvl2, zoo_p); | |
2950 APPLY_TO_PLAYER(player, enemy, resource_bricks, pCard->to_player_bricks2, bricks_p); | |
2951 APPLY_TO_PLAYER(player, enemy, resource_gems, pCard->to_player_gems2, gems_p); | |
2952 APPLY_TO_PLAYER(player, enemy, resource_beasts, pCard->to_player_beasts2, beasts_p); | |
2953 if ( pCard->to_player_buildings2 ) | |
2954 { | |
1246 | 2955 dmg_p = ApplyDamageToBuildings(player_num, (signed int)pCard->to_player_buildings2); |
2956 buildings_p = (signed int)pCard->to_player_buildings2 - dmg_p; | |
1245 | 2957 } |
2958 APPLY_TO_PLAYER(player, enemy, wall_height, pCard->to_player_wall2, wall_p); | |
2959 APPLY_TO_PLAYER(player, enemy, tower_height, pCard->to_player_tower2, tower_p); | |
2960 | |
2961 APPLY_TO_ENEMY(player, enemy, quarry_level, pCard->to_enemy_quarry_lvl2, quarry_e); | |
2962 APPLY_TO_ENEMY(player, enemy, magic_level, pCard->to_enemy_magic_lvl2, magic_e); | |
2963 APPLY_TO_ENEMY(player, enemy, zoo_level, pCard->to_enemy_zoo_lvl2, zoo_e); | |
2964 APPLY_TO_ENEMY(player, enemy, resource_bricks, pCard->to_enemy_bricks2, bricks_e); | |
2965 APPLY_TO_ENEMY(player, enemy, resource_gems, pCard->to_enemy_gems2, gems_e); | |
2966 APPLY_TO_ENEMY(player, enemy, resource_beasts, pCard->to_enemy_beasts2, beasts_e); | |
2967 if ( pCard->to_enemy_buildings2 ) | |
2968 { | |
1246 | 2969 dmg_e = ApplyDamageToBuildings(enemy_num, (signed int)pCard->to_enemy_buildings2); |
2970 buildings_e = (signed int)pCard->to_enemy_buildings2 - dmg_e; | |
1245 | 2971 } |
2972 APPLY_TO_ENEMY(player, enemy, wall_height, pCard->to_enemy_wall2, wall_e); | |
2973 APPLY_TO_ENEMY(player, enemy, tower_height, pCard->to_enemy_tower2, tower_e); | |
2974 | |
2975 APPLY_TO_BOTH(player, enemy, quarry_level, pCard->to_pl_enm_quarry_lvl2, quarry_p, quarry_e); | |
2976 APPLY_TO_BOTH(player, enemy, magic_level, pCard->to_pl_enm_magic_lvl2, magic_p, magic_e); | |
2977 APPLY_TO_BOTH(player, enemy, zoo_level, pCard->to_pl_enm_zoo_lvl2, zoo_p, zoo_e); | |
2978 APPLY_TO_BOTH(player, enemy, resource_bricks, pCard->to_pl_enm_bricks2, bricks_p, bricks_e); | |
2979 APPLY_TO_BOTH(player, enemy, resource_gems, pCard->to_pl_enm_gems2, gems_p, gems_e); | |
2980 APPLY_TO_BOTH(player, enemy, resource_beasts, pCard->to_pl_enm_beasts2, beasts_p, beasts_e); | |
2981 | |
2982 if ( pCard->to_pl_enm_buildings2 ) | |
2983 { | |
1246 | 2984 dmg_p = ApplyDamageToBuildings(player_num, (signed int)pCard->to_pl_enm_buildings2); |
2985 dmg_e = ApplyDamageToBuildings(enemy_num, (signed int)pCard->to_pl_enm_buildings2); | |
2986 buildings_p = (signed int)pCard->to_pl_enm_buildings2 - dmg_p; | |
2987 buildings_e = (signed int)pCard->to_pl_enm_buildings2 - dmg_e; | |
1245 | 2988 } |
2989 APPLY_TO_BOTH(player, enemy, wall_height, pCard->to_pl_enm_wall2, wall_p, wall_e); | |
2990 APPLY_TO_BOTH(player, enemy, tower_height, pCard->to_pl_enm_tower2, tower_p, tower_e); | |
2991 break; | |
2992 } | |
2993 // } | |
2994 if ( quarry_p > 0 || quarry_e > 0 ) | |
2995 pArcomageGame->PlaySound(30); | |
2996 if ( quarry_p < 0 || quarry_e < 0 ) | |
2997 pArcomageGame->PlaySound(31); | |
2998 if ( magic_p > 0 || magic_e > 0 ) | |
2999 pArcomageGame->PlaySound(33); | |
3000 if ( magic_p < 0 || magic_e < 0 ) | |
3001 pArcomageGame->PlaySound(34); | |
3002 if ( zoo_p > 0 || zoo_e > 0 ) | |
3003 pArcomageGame->PlaySound(36); | |
3004 if ( zoo_p < 0 || zoo_e < 0 ) | |
3005 pArcomageGame->PlaySound(37); | |
3006 if ( bricks_p > 0 || bricks_e > 0 ) | |
3007 pArcomageGame->PlaySound(39); | |
3008 if ( bricks_p < 0 || bricks_e < 0 ) | |
3009 pArcomageGame->PlaySound(40); | |
3010 if ( gems_p > 0 || gems_e > 0 ) | |
3011 pArcomageGame->PlaySound(42); | |
3012 if ( gems_p < 0 || gems_e < 0 ) | |
3013 pArcomageGame->PlaySound(43); | |
3014 if ( beasts_p > 0 || beasts_e > 0 ) | |
3015 pArcomageGame->PlaySound(45u); | |
3016 if ( beasts_p < 0 || beasts_e < 0 ) | |
3017 pArcomageGame->PlaySound(46); | |
3018 if ( buildings_p || buildings_e || dmg_p || dmg_e ) | |
3019 pArcomageGame->PlaySound(48); | |
3020 if ( wall_p > 0 || wall_e > 0 ) | |
3021 pArcomageGame->PlaySound(49); | |
3022 if ( wall_p < 0 || wall_e < 0 ) | |
3023 pArcomageGame->PlaySound(50); | |
3024 if ( tower_p > 0 || tower_e > 0 ) | |
3025 pArcomageGame->PlaySound(52); | |
3026 if ( tower_p < 0 || tower_e < 0 ) | |
3027 pArcomageGame->PlaySound(53); | |
3028 if ( player_num ) | |
3029 { | |
3030 if ( quarry_p ) | |
3031 { | |
3032 v184.x = 573; | |
3033 v184.y = 92; | |
3034 am_40D2B4(&v184, quarry_p); | |
3035 } | |
3036 if ( quarry_e ) | |
3037 { | |
3038 v184.x = 26; | |
3039 v184.y = 92; | |
3040 am_40D2B4(&v184, quarry_e); | |
3041 } | |
3042 if ( magic_p ) | |
3043 { | |
3044 v184.x = 573; | |
3045 v184.y = 164; | |
3046 am_40D2B4(&v184, magic_p); | |
3047 } | |
3048 if ( magic_e ) | |
3049 { | |
3050 v184.x = 26; | |
3051 v184.y = 164; | |
3052 am_40D2B4(&v184, magic_e); | |
3053 } | |
3054 if ( zoo_p ) | |
3055 { | |
3056 v184.x = 573; | |
3057 v184.y = 236; | |
3058 am_40D2B4(&v184, zoo_p); | |
3059 } | |
3060 if ( zoo_e ) | |
3061 { | |
3062 v184.x = 26; | |
3063 v184.y = 236; | |
3064 am_40D2B4(&v184, zoo_e); | |
3065 } | |
3066 if ( bricks_p ) | |
3067 { | |
3068 v184.x = 563; | |
3069 v184.y = 114; | |
3070 am_40D2B4(&v184, bricks_p); | |
3071 } | |
3072 if ( bricks_e ) | |
3073 { | |
3074 v184.x = 16; | |
3075 v184.y = 114; | |
3076 am_40D2B4(&v184, bricks_e); | |
3077 } | |
3078 if ( gems_p ) | |
3079 { | |
3080 v184.x = 563; | |
3081 v184.y = 186; | |
3082 am_40D2B4(&v184, gems_p); | |
3083 } | |
3084 if ( gems_e ) | |
3085 { | |
3086 v184.x = 16; | |
3087 v184.y = 186; | |
3088 am_40D2B4(&v184, gems_e); | |
3089 } | |
3090 if ( beasts_p ) | |
3091 { | |
3092 v184.x = 563; | |
3093 v184.y = 258; | |
3094 am_40D2B4(&v184, beasts_p); | |
3095 } | |
3096 if ( beasts_e ) | |
3097 { | |
3098 v184.x = 16; | |
3099 v184.y = 258; | |
3100 am_40D2B4(&v184, beasts_e); | |
3101 } | |
3102 if ( wall_p ) | |
3103 { | |
3104 v184.x = 442; | |
3105 v184.y = 296; | |
3106 am_40D2B4(&v184, wall_p); | |
3107 } | |
3108 if ( wall_e ) | |
3109 { | |
3110 v184.x = 180; | |
3111 v184.y = 296; | |
3112 am_40D2B4(&v184, wall_e); | |
3113 } | |
3114 if ( tower_p ) | |
3115 { | |
3116 v184.x = 514; | |
3117 v184.y = 296; | |
3118 am_40D2B4(&v184, tower_p); | |
3119 } | |
3120 if ( tower_e ) | |
3121 { | |
3122 v184.x = 122; | |
3123 v184.y = 296; | |
3124 am_40D2B4(&v184, tower_e); | |
3125 } | |
3126 if ( dmg_p ) | |
3127 { | |
3128 v184.x = 442; | |
3129 v184.y = 296; | |
3130 am_40D2B4(&v184, dmg_p); | |
3131 } | |
3132 if ( buildings_p ) | |
3133 { | |
3134 v184.x = 514; | |
3135 v184.y = 296; | |
3136 am_40D2B4(&v184, buildings_p); | |
3137 } | |
3138 if ( dmg_e ) | |
3139 { | |
3140 v184.x = 180; | |
3141 v184.y = 296; | |
3142 am_40D2B4(&v184, dmg_e); | |
3143 } | |
3144 if ( buildings_e ) | |
3145 { | |
3146 v184.x = 122; | |
3147 v184.y = 296; | |
3148 am_40D2B4(&v184, buildings_e); | |
3149 } | |
3150 } | |
3151 else | |
3152 { | |
3153 if ( quarry_p ) | |
3154 { | |
3155 v184.x = 26; | |
3156 v184.y = 92; | |
3157 am_40D2B4(&v184, quarry_p); | |
3158 } | |
3159 if ( quarry_e ) | |
3160 { | |
3161 v184.x = 573; | |
3162 v184.y = 92; | |
3163 am_40D2B4(&v184, quarry_e); | |
3164 } | |
3165 if ( magic_p ) | |
3166 { | |
3167 v184.x = 26; | |
3168 v184.y = 164; | |
3169 am_40D2B4(&v184, magic_p); | |
3170 } | |
3171 if ( magic_e ) | |
3172 { | |
3173 v184.x = 573; | |
3174 v184.y = 164; | |
3175 am_40D2B4(&v184, magic_e); | |
3176 } | |
3177 if ( zoo_p ) | |
3178 { | |
3179 v184.x = 26; | |
3180 v184.y = 236; | |
3181 am_40D2B4(&v184, zoo_p); | |
3182 } | |
3183 if ( zoo_e ) | |
3184 { | |
3185 v184.x = 573; | |
3186 v184.y = 236; | |
3187 am_40D2B4(&v184, zoo_e); | |
3188 } | |
3189 if ( bricks_p ) | |
3190 { | |
3191 v184.x = 16; | |
3192 v184.y = 114; | |
3193 am_40D2B4(&v184, bricks_p); | |
3194 } | |
3195 if ( bricks_e ) | |
3196 { | |
3197 v184.x = 563; | |
3198 v184.y = 114; | |
3199 am_40D2B4(&v184, bricks_e); | |
3200 } | |
3201 if ( gems_p ) | |
3202 { | |
3203 v184.x = 16; | |
3204 v184.y = 186; | |
3205 am_40D2B4(&v184, gems_p); | |
3206 } | |
3207 if ( gems_e ) | |
3208 { | |
3209 v184.x = 563; | |
3210 v184.y = 186; | |
3211 am_40D2B4(&v184, gems_e); | |
3212 } | |
3213 if ( beasts_p ) | |
3214 { | |
3215 v184.x = 16; | |
3216 v184.y = 258; | |
3217 am_40D2B4(&v184, beasts_p); | |
3218 } | |
3219 if ( beasts_e ) | |
3220 { | |
3221 v184.x = 563; | |
3222 v184.y = 258; | |
3223 am_40D2B4(&v184, beasts_e); | |
3224 } | |
3225 if ( wall_p ) | |
3226 { | |
3227 v184.x = 180; | |
3228 v184.y = 296; | |
3229 am_40D2B4(&v184, wall_p); | |
3230 } | |
3231 if ( wall_e ) | |
3232 { | |
3233 v184.x = 442; | |
3234 v184.y = 296; | |
3235 am_40D2B4(&v184, wall_e); | |
3236 } | |
3237 if ( tower_p ) | |
3238 { | |
3239 v184.x = 122; | |
3240 v184.y = 296; | |
3241 am_40D2B4(&v184, tower_p); | |
3242 } | |
3243 if ( tower_e ) | |
3244 { | |
3245 v184.x = 514; | |
3246 v184.y = 296; | |
3247 am_40D2B4(&v184, tower_e); | |
3248 } | |
3249 if ( dmg_p ) | |
3250 { | |
3251 v184.x = 180; | |
3252 v184.y = 296; | |
3253 am_40D2B4(&v184, dmg_p); | |
3254 } | |
3255 if ( buildings_p ) | |
3256 { | |
3257 v184.x = 122; | |
3258 v184.y = 296; | |
3259 am_40D2B4(&v184, buildings_p); | |
3260 } | |
3261 if ( dmg_e ) | |
3262 { | |
3263 v184.x = 442; | |
3264 v184.y = 296; | |
3265 am_40D2B4(&v184, dmg_e); | |
3266 } | |
3267 if ( buildings_e ) | |
3268 { | |
3269 v184.x = 514; | |
3270 v184.y = 296; | |
3271 am_40D2B4(&v184, buildings_e); | |
3272 } | |
3273 } | |
3274 #undef APPLY_TO_BOTH | |
2213 | 3275 #undef APPLY_TO_ENEMY |
1245 | 3276 #undef APPLY_TO_PLAYER |
3277 | |
0 | 3278 } |
3279 | |
3280 //----- (0040D2B4) -------------------------------------------------------- | |
1263 | 3281 int am_40D2B4( POINT* startXY, int effect_value ) |
2213 | 3282 { |
0 | 3283 int v2; // ebp@1 |
2334 | 3284 // POINT *v3; // edi@1 |
0 | 3285 int result; // eax@3 |
1194 | 3286 int v6; |
0 | 3287 stru272_stru0 *v8; // ecx@12 |
3288 signed int v11; // [sp+10h] [bp-8h]@1 | |
3289 | |
3290 v11 = 0; | |
1263 | 3291 v2 = effect_value; |
3292 | |
2213 | 3293 while ( array_4FABD0[v11].have_effect )//Ritor1: needed refactoring |
3294 { | |
3295 result = array_4FABD0[v11].field_40->_40E2A7(); | |
3296 if ( !result ) | |
3297 { | |
3298 array_4FABD0[v11].have_effect = 0; | |
3299 --v11; | |
3300 } | |
3301 ++v11; | |
3302 if ( v11 >= 10 ) | |
3303 return result; | |
3304 } | |
1185 | 3305 v6 = v11; |
1263 | 3306 array_4FABD0[v11].have_effect = 1; |
3307 if ( effect_value <= 0 ) | |
2213 | 3308 { |
3309 array_4FABD0[v6].effect_sign = 0; | |
3310 effect_value = -effect_value; | |
3311 } | |
0 | 3312 else |
2213 | 3313 array_4FABD0[v6].effect_sign = 1; |
1263 | 3314 array_4FABD0[v6].field_4.effect_area.left = startXY->x - 20; |
3315 array_4FABD0[v6].field_4.effect_area.right = startXY->x + 20; | |
3316 array_4FABD0[v6].field_4.effect_area.top = startXY->y - 20; | |
3317 array_4FABD0[v6].field_4.effect_area.bottom = startXY->y + 20; | |
1186 | 3318 array_4FABD0[v6].field_4.field_10 = -60; |
3319 array_4FABD0[v6].field_4.field_14 = 60; | |
3320 array_4FABD0[v6].field_4.field_18 = 180; | |
3321 array_4FABD0[v6].field_4.field_1Cf = 0.5; | |
3322 array_4FABD0[v6].field_4.field_20 = 150; | |
3323 array_4FABD0[v6].field_4.field_24f= 50.0; | |
3324 array_4FABD0[v6].field_4.field_28f = 3.0; | |
3325 array_4FABD0[v6].field_4.field_2Cf = 8.0; | |
3326 array_4FABD0[v6].field_4.field_30 = 5; | |
3327 array_4FABD0[v6].field_4.field_34 = 15; | |
1263 | 3328 array_4FABD0[v6].field_4.sparks_array = &array_4FABD0[v6].effect_sparks[0]; |
1185 | 3329 v8 = array_4FABD0[v6].field_40; |
1263 | 3330 v8->StartFill(&array_4FABD0[v6].field_4); |
3331 if ( 10 * effect_value > 150 ) | |
3332 effect_value = 15; | |
1185 | 3333 |
1184 | 3334 if ( v8->signature != SIG_trpg ) |
0 | 3335 return 2; |
3336 if ( !v8->field_59 ) | |
3337 return 3; | |
1263 | 3338 v8->position_in_sparks_arr = 10 * effect_value; |
0 | 3339 v8->field_30 = 0.0; |
3340 v8->field_58 = 0; | |
3341 v8->field_44 = 0; | |
3342 v8->field_4C = 0; | |
3343 v8->field_48 = 0; | |
3344 v8->field_50 = 0; | |
2213 | 3345 for (int i = 0; i < v8->field_4; ++i) |
3346 v8->field_54[i].have_spark = 0; | |
0 | 3347 return 0; |
3348 } | |
1185 | 3349 |
0 | 3350 //----- (0040D402) -------------------------------------------------------- |
1246 | 3351 int ApplyDamageToBuildings( int player_num, int damage ) |
2213 | 3352 { |
2334 | 3353 // ArcomagePlayer *v2; // ecx@1 |
0 | 3354 int v3; // esi@1 |
3355 int result; // eax@3 | |
3356 | |
1218 | 3357 v3 = am_Players[player_num].wall_height; |
2213 | 3358 //if ( v3 <= 0 ) |
0 | 3359 result = 0; |
2213 | 3360 //else |
3361 //{ | |
1218 | 3362 if ( v3 >= -damage ) |
0 | 3363 { |
1218 | 3364 result = damage; |
3365 am_Players[player_num].wall_height += damage; | |
0 | 3366 } |
1209 | 3367 else |
2213 | 3368 { |
3369 damage += v3; | |
3370 result = -v3; | |
3371 am_Players[player_num].wall_height = 0; | |
3372 am_Players[player_num].tower_height += damage; | |
3373 } | |
3374 //} | |
1218 | 3375 if ( am_Players[player_num].tower_height < 0 ) |
3376 am_Players[player_num].tower_height = 0; | |
0 | 3377 return result; |
3378 } | |
3379 // 40D402: using guessed type int __fastcall am_40D402(uint, uint); | |
3380 | |
3381 //----- (0040D444) -------------------------------------------------------- | |
1218 | 3382 void GameResultsApply() |
2213 | 3383 { |
2214 | 3384 int winner; // esi@1 |
3385 int victory_type; // edi@1 | |
3386 int pl_resource; // edx@25 | |
3387 int en_resource; // eax@28 | |
3388 unsigned int tavern_num; // eax@54 | |
2334 | 3389 // char pText[64]; // [sp+Ch] [bp-48h]@1 |
3390 // POINT xy; // [sp+4Ch] [bp-8h]@1 | |
0 | 3391 |
2214 | 3392 winner = -1; |
3393 victory_type = -1; | |
0 | 3394 //nullsub_1(); |
2214 | 3395 /*strcpy(pText, "The Winner is: ");//"Ïîáåäèë: " Ritor1: àðõàèçì |
1218 | 3396 xy.y = 160; |
3397 xy.x = 320; //- 12 * v2 / 2; | |
2214 | 3398 am_DrawText(-1, pText, &xy);*/ |
2213 | 3399 |
3400 //ïðîâåðêà ïîñòðîåíà ëè áàøíÿ | |
3401 if ( am_Players[0].tower_height < max_tower_height && am_Players[1].tower_height >= max_tower_height )//íàøà áàøíÿ íå ïîñòðîåíà, à ó âðàãà ïîñòðîåíà | |
2214 | 3402 { |
3403 winner = 2;//ïîáåäèë èãðîê 2(âðàã) | |
3404 victory_type = 0; | |
3405 } | |
2213 | 3406 else if ( am_Players[0].tower_height >= max_tower_height && am_Players[1].tower_height < max_tower_height )//íàøà áàøíÿ ïîñòðîåíà, à ó âðàãà íåò |
2214 | 3407 { |
3408 winner = 1;//ïîáåäèë èãðîê 1(ìû) | |
3409 victory_type = 0; | |
3410 } | |
2213 | 3411 else if ( am_Players[0].tower_height >= max_tower_height && am_Players[1].tower_height >= max_tower_height )//è ó íàñ, è ó âðàãà ïîñòðîåíà |
0 | 3412 { |
2213 | 3413 if ( am_Players[0].tower_height == am_Players[1].tower_height )//íàøè áàøíè ðàâíû |
0 | 3414 { |
2214 | 3415 winner = 0;//íèêòî íå ïîáåäèë |
3416 victory_type = 4;//íè÷üÿ | |
0 | 3417 } |
2214 | 3418 else//íàøè áàøíè íå ðàâíû |
3419 { | |
3420 winner = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;//ïîáåäèë òîò, ó êîãî âûøå | |
3421 victory_type = 0; | |
3422 } | |
2213 | 3423 } |
3424 | |
3425 //ïðîâåðêà ðàçðóøåíà ëè áàøíÿ | |
3426 if ( am_Players[0].tower_height <= 0 && am_Players[1].tower_height > 0 )//íàøà áàøíÿ ðàçðóøåíà, à ó âðàãà íåò | |
2214 | 3427 { |
3428 winner = 2;// ïîáåäèë èãðîê 2(âðàã) | |
3429 victory_type = 2;//ïîáåäèë ðàçðóøèâ áàøíþ âðàãà | |
3430 } | |
2213 | 3431 else if ( am_Players[0].tower_height > 0 && am_Players[1].tower_height <= 0 )//ó âðàãà áàøíÿ ðàçðóøåíà, à ó íàñ íåò |
3432 { | |
2214 | 3433 winner = 1;//ïîáåäèë èãðîê 1(ìû) |
3434 victory_type = 2;//ïîáåäèë ðàçðóøèâ áàøíþ âðàãà | |
2213 | 3435 } |
3436 else if ( am_Players[0].tower_height <= 0 && am_Players[1].tower_height <= 0 )//íàøà áàøíÿ ðàçðóøåíà, è ó âðàãà ðàçðóøåíà | |
3437 { | |
3438 if ( am_Players[0].tower_height == am_Players[1].tower_height )//åñëè áàøíè ðàâíû | |
0 | 3439 { |
2213 | 3440 if ( am_Players[0].wall_height == am_Players[1].wall_height )//åñëè ñòåíû ðàâíû |
0 | 3441 { |
2214 | 3442 winner = 0; |
3443 victory_type = 4; | |
0 | 3444 } |
2213 | 3445 else//åñëè ñòåíû íå ðàâíû |
3446 { | |
2214 | 3447 winner = (am_Players[0].wall_height <= am_Players[1].wall_height) + 1;//ïîáåäèë òîò, ó êîãî ñòåíà âûøå |
3448 victory_type = 1;//ïîáåäà êîãäà áîëüøå ñòåíà ïðè íè÷üå | |
2213 | 3449 } |
0 | 3450 } |
2214 | 3451 else//áàøíè íå ðàâíû |
0 | 3452 { |
2214 | 3453 winner = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;// ïîáåæäàåò òîò ó êîãî áàøíÿ áîëüøå |
3454 victory_type = 2;//ïîáåäèë ðàçðóøèâ áàøíþ âðàãà | |
0 | 3455 } |
3456 } | |
2214 | 3457 |
3458 //ïðîâåðêà íàáðàíû ëè ðåñóðñû | |
3459 //ïðîâåðêà êàêîãî ðåñóðñà áîëüøå âñåãî ó èãðîêà 1(íàñ) | |
3460 pl_resource = am_Players[0].resource_bricks;//êèðïè÷åé áîëüøå ÷åì äð. ðåñóðñîâ | |
3461 if ( am_Players[0].resource_gems > am_Players[0].resource_bricks | |
3462 && am_Players[0].resource_gems > am_Players[0].resource_beasts )//äðàã.êàìíåé áîëüøå âñåãî | |
3463 pl_resource = am_Players[0].resource_gems; | |
3464 else if ( am_Players[0].resource_beasts > am_Players[0].resource_gems | |
3465 && am_Players[0].resource_beasts > am_Players[0].resource_bricks )//çâåðåé áîëüøå âñåãî | |
3466 pl_resource = am_Players[0].resource_beasts; | |
3467 | |
3468 //ïðîâåðêà êàêîãî ðåñóðñà áîëüøå ó èãðîêà 2(âðàãà) | |
3469 en_resource = am_Players[1].resource_bricks;//êèðïè÷åé áîëüøå ÷åì äð. ðåñóðñîâ | |
3470 if ( am_Players[1].resource_gems > am_Players[1].resource_bricks | |
3471 && am_Players[1].resource_gems > am_Players[1].resource_beasts )//äðàã.êàìíåé áîëüøå âñåãî | |
3472 en_resource = am_Players[1].resource_gems; | |
3473 else if ( am_Players[1].resource_beasts > am_Players[1].resource_gems | |
3474 && am_Players[1].resource_beasts > am_Players[1].resource_bricks )//çâåðåé áîëüøå âñåãî | |
3475 en_resource = am_Players[1].resource_beasts; | |
3476 | |
3477 //ñðàâíåíèå ðåñóðñîâ èãðîêîâ | |
3478 if ( winner == -1 && victory_type == -1 )//íåò ïîáåäèòåëÿ ïî áàøíÿì | |
0 | 3479 { |
2214 | 3480 if ( pl_resource < max_resources_amount && en_resource >= max_resources_amount )//âðàã íàáðàë íóæíîå êîëè÷åñòâî |
3481 { | |
3482 winner = 2;// âðàã ïîáåäèë | |
3483 victory_type = 3;//ïîáåäà ñîáðàâ íóæíîå êîëè÷åñòâî ðåñóðñîâ | |
3484 } | |
3485 else if ( pl_resource >= max_resources_amount && en_resource < max_resources_amount )//ìû íàáðàëè íóæíîå êîëè÷åñòâî | |
0 | 3486 { |
2214 | 3487 winner = 1;// ìû ïîáåäèëè |
3488 victory_type = 3;//ïîáåäà ñîáðàâ íóæíîå êîëè÷åñòâî ðåñóðñîâ | |
0 | 3489 } |
2214 | 3490 else if ( pl_resource >= max_resources_amount && en_resource >= max_resources_amount )//è ó íàñ è ó âðàãà íóæíîå êîëè÷åñòâî ðåñóðñîâ |
0 | 3491 { |
2214 | 3492 if ( pl_resource == en_resource )// ðåñóðñû ðàâíû |
3493 { | |
3494 winner = 0;//ðåñóðñû ðàâíû | |
3495 victory_type = 4; //íè÷üÿ | |
3496 } | |
0 | 3497 else |
3498 { | |
2214 | 3499 winner = (pl_resource <= en_resource) + 1;//ðåñóðñû íå ðàâíû, ïîáåæäàåò òîò ó êîãî áîëüøå |
3500 victory_type = 3;//ïîáåäà ñîáðàâ íóæíîå êîëè÷åñòâî ðåñóðñîâ | |
0 | 3501 } |
3502 } | |
3503 } | |
2214 | 3504 else if ( winner == 0 && victory_type == 4 )// ïðè íè÷üå ïî áàøíÿì è ñòåíå |
0 | 3505 { |
2214 | 3506 if ( pl_resource != en_resource )//ðåñóðñû íå ðàâíû |
0 | 3507 { |
2214 | 3508 winner = (pl_resource <= en_resource) + 1;//ïîáåäèë òîò ó êîãî áîëüøå |
3509 victory_type = 5;//ïîáåäà êîãäà ïðè íè÷üå áîëüøåå êîëè÷åñòâî ðåñóðñîâ | |
0 | 3510 } |
2214 | 3511 else //ðåñóðñû ðàâíû |
3512 { | |
3513 winner = 0;//íåò ïîáåäèòåëÿ | |
3514 victory_type = 4; //íè÷üÿ | |
3515 } | |
0 | 3516 } |
2214 | 3517 |
3518 //ïîäâåäåíèå èòîãîâ | |
3519 pArcomageGame->Victory_type = victory_type; | |
3520 pArcomageGame->uGameWinner = winner; | |
3521 if ( winner == 1 )//ïîáåäèòåëü èãðîê 1(ìû) | |
0 | 3522 { |
2214 | 3523 if (( window_SpeakInHouse->par1C >= 108 ) && ( window_SpeakInHouse->par1C <= 120 ))//òàâåðíû |
0 | 3524 { |
2214 | 3525 if ( !pParty->pArcomageWins[window_SpeakInHouse->par1C - 108] ) |
3526 { | |
3527 pParty->pArcomageWins[window_SpeakInHouse->par1C - 108] = 1; | |
3528 pParty->PartyFindsGold(p2DEvents[ window_SpeakInHouse->par1C - 1].fPriceMultiplier * 100.0, 0);//âîçíàãðàæäåíèå | |
3529 } | |
0 | 3530 } |
2214 | 3531 //ïðîâåðêà âûïîëíåí ëè êâåñò ïî àðêîìàãó |
3532 tavern_num = 0; | |
3533 for ( uint i = 108; i <= 120; ++i ) | |
0 | 3534 { |
2214 | 3535 if ( !pParty->pArcomageWins[i - 108] ) |
0 | 3536 break; |
2214 | 3537 tavern_num++; |
0 | 3538 } |
2214 | 3539 if ( tavern_num == 13 ) |
3540 _449B7E_toggle_bit(pParty->_quest_bits, 238, 1);// 238 - Won all Arcomage games | |
3541 | |
3542 for ( int i = 0; i < 4; ++i )//âíåñåíèå çàïèñè â Çàñëóãè | |
0 | 3543 { |
2214 | 3544 if ( !_449B57_test_bit(pParty->pPlayers[i]._achieved_awards_bits, 1) ) |
3545 _449B7E_toggle_bit(pParty->pPlayers[i]._achieved_awards_bits, PLAYER_GUILD_BITS__ARCOMAGE_WIN, 1); | |
0 | 3546 } |
949 | 3547 ++pParty->uNumArcomageWins; |
2214 | 3548 if ( pParty->uNumArcomageWins > 1000000 )//îãðàíè÷åíèå êîëè÷åñòâà ïîáåä |
949 | 3549 pParty->uNumArcomageWins = 1000000; |
0 | 3550 } |
2214 | 3551 else//ïðîèãðûø |
0 | 3552 { |
2214 | 3553 for ( int i = 0; i < 4; ++i )//âíåñåíèå çàïèñè â Çàñëóãè |
2213 | 3554 { |
2214 | 3555 if ( !_449B57_test_bit(pParty->pPlayers[i]._achieved_awards_bits, 1) ) |
3556 _449B7E_toggle_bit(pParty->pPlayers[i]._achieved_awards_bits, PLAYER_GUILD_BITS__ARCOMAGE_LOSE, 1); | |
0 | 3557 } |
949 | 3558 ++pParty->uNumArcomageLoses; |
2214 | 3559 if ( pParty->uNumArcomageLoses > 1000000 )//îãðàíè÷åíèå êîëè÷åñòâà ïðîèãðûøåé |
949 | 3560 pParty->uNumArcomageLoses = 1000000; |
0 | 3561 } |
3562 } | |
3563 | |
3564 //----- (00409C8B) -------------------------------------------------------- | |
2339 | 3565 void ArcomageGame::PrepareArcomage() |
2213 | 3566 { |
2334 | 3567 // signed __int64 v1; // qax@4 |
0 | 3568 int v2; // esi@4 |
1183 | 3569 int v3; // esi@5 |
0 | 3570 signed int v4; // edi@5 |
2334 | 3571 // int v6; // edx@9 |
1183 | 3572 RECT pXYZW; // [sp+8h] [bp-1Ch]@5 |
3573 POINT pXY; // [sp+18h] [bp-Ch]@5 | |
0 | 3574 |
3575 pAudioPlayer->StopChannels(-1, -1); | |
1201 | 3576 strcpy(pArcomageGame->pPlayer1Name, Player1Name); |
3577 strcpy(pArcomageGame->pPlayer2Name, Player2Name); | |
0 | 3578 am_byte_4FAA76 = 0; |
3579 am_byte_4FAA75 = 0; | |
1183 | 3580 |
2213 | 3581 for (int i = 0; i < 10; ++i) |
3582 { | |
3583 v2 = (i+1) % 4; | |
3584 v3 = (i+1) / 4; | |
3585 shown_cards[i].uCardId = -1; | |
3586 shown_cards[i].field_4 = 0; | |
3587 shown_cards[i].field_8.x = 100 * v2 + 120; | |
3588 shown_cards[i].field_8.y = 138 * v3 + 18; | |
3589 shown_cards[i].field_10_xplus = -100 * v2 / 5; | |
3590 shown_cards[i].field_14_y_plus = -138 * v3 / 5; | |
3591 shown_cards[i].field_18_point.x = shown_cards[i].field_8.x; | |
3592 shown_cards[i].field_18_point.y = shown_cards[i].field_8.y; | |
3593 } | |
1183 | 3594 |
3595 pXY.x = 0; | |
3596 pXY.y = 0; | |
0 | 3597 ArcomageGame::LoadBackground(); |
1183 | 3598 pXYZW.left = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
3599 pXYZW.right = window->GetWidth(); |
1183 | 3600 pXYZW.top = 0; |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2214
diff
changeset
|
3601 pXYZW.bottom = window->GetHeight(); |
0 | 3602 am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1); |
2154 | 3603 pRenderer->am_Blt_Copy(&pXYZW, &pXY, 2); |
0 | 3604 am_EndScene(); |
3605 pRenderer->Present(); | |
3606 ArcomageGame::LoadSprites(); | |
1679 | 3607 pRenderer->Present(); |
1183 | 3608 |
0 | 3609 v4 = 120; |
2213 | 3610 for ( int i = 0; i < 12; ++i ) |
1183 | 3611 am_sounds[i] = pSoundList->LoadSound(v4++, 0); |
3612 | |
2213 | 3613 for (int i = 0; i < 10; ++i) |
1679 | 3614 array_4FABD0[i].field_40 = stru272_stru0::New(); |
1184 | 3615 |
1200 | 3616 current_card_slot_index = -1; |
0 | 3617 amuint_4FAA4C = -1; |
3618 byte_4FAA74 = 0; | |
3619 pArcomageGame->field_F4 = 0; | |
1679 | 3620 am_gameover = false; |
0 | 3621 byte_505880 = 0; |
3622 dword_4FAA70 = 0; | |
1263 | 3623 need_to_discard_card = 0; |
1197 | 3624 SetStartGameData(); |
1200 | 3625 InitalHandsFill(); |
0 | 3626 //nullsub_1(); |
1197 | 3627 pArcomageGame->GameOver = 0; |
1183 | 3628 pArcomageGame->pfntComic = pFontComic; |
3629 pArcomageGame->pfntArrus = pFontArrus; | |
0 | 3630 } |
3631 | |
3632 //----- (0040D711) -------------------------------------------------------- | |
3633 ArcomageGame::ArcomageGame() | |
3634 { | |
1183 | 3635 field_4 = 0; |
0 | 3636 //RGBTexture::RGBTexture(&this->pGameBackground); |
3637 //RGBTexture::RGBTexture(&v1->pSprites); | |
1183 | 3638 bGameInProgress = 0; |
3639 field_F9 = 0; | |
0 | 3640 } |
938 | 3641 |
3642 //----- (00409BE8) -------------------------------------------------------- | |
1197 | 3643 void SetStartConditions() |
938 | 3644 { |
1256 | 3645 const ArcomageStartConditions *st_cond; // eax@1 |
2213 | 3646 |
1200 | 3647 st_cond = &start_conditions[window_SpeakInHouse->par1C - 108]; |
3648 start_tower_height = st_cond->tower_height; | |
3649 start_wall_height = st_cond->wall_height; | |
3650 start_quarry_level = st_cond->quarry_level - 1; | |
3651 start_magic_level = st_cond->magic_level - 1; | |
3652 start_zoo_level = st_cond->zoo_level - 1; | |
3653 minimum_cards_at_hand = 5; | |
1197 | 3654 quarry_bonus = 1; |
3655 magic_bonus = 1; | |
1201 | 3656 zoo_bonus = 1; |
1200 | 3657 max_tower_height = st_cond->max_tower; |
3658 max_resources_amount = st_cond->max_resources; | |
3659 | |
1256 | 3660 opponent_mastery = st_cond->mastery_lvl; |
1200 | 3661 |
3662 start_bricks_amount = st_cond->bricks_amount; | |
3663 start_gems_amount = st_cond->gems_amount; | |
3664 start_beasts_amount = st_cond->beasts_amount; | |
1183 | 3665 } |
3666 | |
3667 //----- (0040D75D) -------------------------------------------------------- | |
1679 | 3668 void am_DrawText( int a1, const char *pText, POINT *pXY ) |
2213 | 3669 { |
2214 | 3670 pPrimaryWindow->DrawText( pFontComic, pXY->x, pXY->y - ((pFontComic->uFontHeight - 3) / 2) + 3, 0, pText, 0, 0, 0); |
2213 | 3671 } |
1183 | 3672 |
3673 //----- (0040DB27) -------------------------------------------------------- | |
1263 | 3674 void DrawRect( RECT *pXYZW, unsigned __int16 uColor, char bSolidFill ) |
2213 | 3675 { |
3676 pRenderer->BeginScene(); | |
2216 | 3677 pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1); |
2213 | 3678 if ( bSolidFill ) |
3679 { | |
2216 | 3680 for ( int i = pXYZW->top; i <= pXYZW->bottom; ++i ) |
3681 pRenderer->RasterLine2D(pXYZW->left, i, pXYZW->right, i, uColor); | |
2213 | 3682 } |
3683 else | |
3684 { | |
2216 | 3685 pRenderer->RasterLine2D(pXYZW->left, pXYZW->top, pXYZW->right, pXYZW->top, uColor); |
3686 pRenderer->RasterLine2D(pXYZW->right, pXYZW->top, pXYZW->right, pXYZW->bottom, uColor); | |
3687 pRenderer->RasterLine2D(pXYZW->right, pXYZW->bottom, pXYZW->left, pXYZW->bottom, uColor); | |
3688 pRenderer->RasterLine2D(pXYZW->left, pXYZW->bottom, pXYZW->left, pXYZW->top, uColor); | |
2213 | 3689 } |
3690 pRenderer->EndScene(); | |
3691 } | |
1183 | 3692 |
1679 | 3693 void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor ) |
2069 | 3694 { |
2213 | 3695 pRenderer->BeginScene(); |
3696 //if ( uNumSceneBegins ) | |
3697 { | |
2216 | 3698 if ( pTargetXY->x >= 0 && pTargetXY->x <= window->GetWidth() - 1 |
3699 && pTargetXY->y >= 0 && pTargetXY->y <= window->GetHeight() - 1) | |
2069 | 3700 { |
3701 pRenderer->WritePixel16(pTargetXY->x, pTargetXY->y, uColor); | |
3702 pRenderer->WritePixel16(pTargetXY->x + 1, pTargetXY->y, uColor); | |
3703 pRenderer->WritePixel16(pTargetXY->x, pTargetXY->y + 1, uColor); | |
3704 pRenderer->WritePixel16(pTargetXY->x + 1, pTargetXY->y + 1, uColor); | |
2213 | 3705 } |
3706 pRenderer->EndScene(); | |
3707 } | |
2069 | 3708 } |
1185 | 3709 |
3710 //----- (0040DBD3) -------------------------------------------------------- | |
1679 | 3711 void DrawPixel( POINT *pTargetXY, unsigned __int16 uColor ) |
2069 | 3712 { |
2213 | 3713 pRenderer->BeginScene(); |
3714 //if ( pRenderer->uNumSceneBegins ) | |
3715 { | |
2216 | 3716 if ( pTargetXY->x >= 0 && pTargetXY->x <= window->GetWidth() - 1 |
3717 && pTargetXY->y >= 0 && pTargetXY->y <= window->GetHeight() - 1) | |
2213 | 3718 { |
3719 pRenderer->WritePixel16(pTargetXY->x, pTargetXY->y, uColor); | |
3720 /*int xVal = pTargetXY->x; | |
3721 int yVal = pTargetXY->y; | |
3722 if ( xVal >= 0 && xVal <= 639 && yVal >= 0 && yVal <= 479) | |
3723 { | |
3724 pRenderer->pTargetSurface[xVal + pRenderer->uTargetSurfacePitch * yVal] = uColor; | |
3725 }*/ | |
3726 } | |
3727 pRenderer->EndScene(); | |
3728 } | |
2069 | 3729 } |
1185 | 3730 |
1183 | 3731 //----- (0040DDB1) -------------------------------------------------------- |
1263 | 3732 int rand_interval( int min, int max ) |
2213 | 3733 { |
3734 return min + rand() % (max - min + 1); | |
3735 } | |
1183 | 3736 |
3737 //----- (0040DEC8) -------------------------------------------------------- | |
1679 | 3738 void __fastcall am_IntToString(int val, char *pOut) |
2213 | 3739 { |
3740 sprintfex(pOut, "%d", val); | |
3741 } | |
1303 | 3742 |
3743 void set_stru1_field_8_InArcomage(int inValue) | |
3744 { | |
3745 switch(inValue) | |
3746 { | |
3747 case 91:LOBYTE(pArcomageGame->stru1.field_8) = 123;break; | |
3748 case 92:LOBYTE(pArcomageGame->stru1.field_8) = 124;break; | |
3749 case 93:LOBYTE(pArcomageGame->stru1.field_8) = 125;break; | |
3750 case 96:LOBYTE(pArcomageGame->stru1.field_8) = 126;break; | |
3751 case 61:LOBYTE(pArcomageGame->stru1.field_8) = 43;break; | |
3752 case 55:LOBYTE(pArcomageGame->stru1.field_8) = 38;break; | |
3753 case 56:LOBYTE(pArcomageGame->stru1.field_8) = 42;break; | |
3754 case 57:LOBYTE(pArcomageGame->stru1.field_8) = 40;break; | |
3755 case 59:LOBYTE(pArcomageGame->stru1.field_8) = 58;break; | |
3756 case 54:LOBYTE(pArcomageGame->stru1.field_8) = 94;break; | |
3757 case 50:LOBYTE(pArcomageGame->stru1.field_8) = 64;break; | |
3758 case 51:LOBYTE(pArcomageGame->stru1.field_8) = 35;break; | |
3759 case 52:LOBYTE(pArcomageGame->stru1.field_8) = 36;break; | |
3760 case 53:LOBYTE(pArcomageGame->stru1.field_8) = 37;break; | |
3761 case 49:LOBYTE(pArcomageGame->stru1.field_8) = 33;break; | |
3762 case 39:LOBYTE(pArcomageGame->stru1.field_8) = 34;break; | |
3763 case 44:LOBYTE(pArcomageGame->stru1.field_8) = 60;break; | |
3764 case 46:LOBYTE(pArcomageGame->stru1.field_8) = 62;break; | |
3765 case 47:LOBYTE(pArcomageGame->stru1.field_8) = 63;break; | |
3766 case 48:LOBYTE(pArcomageGame->stru1.field_8) = 41;break; | |
3767 default:LOBYTE(pArcomageGame->stru1.field_8) = inValue;break; | |
3768 } | |
3769 } |