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