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