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