Mercurial > mm7
comparison UI/UIArena.cpp @ 2374:802460e60eee
add UIArena.cpp and UIArena.h and other
author | Ritor1 |
---|---|
date | Sun, 01 Jun 2014 18:37:09 +0600 |
parents | |
children | 8cee51ce4382 |
comparison
equal
deleted
inserted
replaced
2373:b4a79e3ef2f0 | 2374:802460e60eee |
---|---|
1 #define _CRT_SECURE_NO_WARNINGS | |
2 | |
3 #include "mm7_data.h" | |
4 #include "Sprites.h" | |
5 | |
6 #include "GUIWindow.h" | |
7 #include "GUIFont.h" | |
8 #include "Party.h" | |
9 #include "AudioPlayer.h" | |
10 #include "Outdoor.h" | |
11 #include "LOD.h" | |
12 #include "Actor.h" | |
13 #include "Events.h" | |
14 #include "Viewport.h" | |
15 #include "texts.h" | |
16 #include "MM7.h" | |
17 | |
18 std::array<Vec2_int_, 20> pMonsterArenaPlacements = | |
19 {{ | |
20 Vec2_int_(1524, 8332), | |
21 Vec2_int_(2186, 8844), | |
22 Vec2_int_(3219, 9339), | |
23 Vec2_int_(4500, 9339), | |
24 Vec2_int_(5323, 9004), | |
25 Vec2_int_(0x177D, 0x2098), | |
26 Vec2_int_(0x50B, 0x1E15), | |
27 Vec2_int_(0x18FF, 0x1E15), | |
28 Vec2_int_(0x50B, 0xD69), | |
29 Vec2_int_(0x18FF, 0x1B15), | |
30 Vec2_int_(0x50B, 0x1021), | |
31 Vec2_int_(0x18FF, 0x1848), | |
32 Vec2_int_(0x50B, 0x12D7), | |
33 Vec2_int_(0x18FF, 0x15A3), | |
34 Vec2_int_(0x50B, 0x14DB), | |
35 Vec2_int_(0x18FF, 0x12D7), | |
36 Vec2_int_(0x50B, 0x1848), | |
37 Vec2_int_(0x18FF, 0x1021), | |
38 Vec2_int_(0x50B, 0x1B15), | |
39 Vec2_int_(0x18FF, 0xD69), | |
40 }} | |
41 ; | |
42 | |
43 //----- (004BBCDD) -------------------------------------------------------- | |
44 void Arena_SelectionFightLevel() | |
45 { | |
46 signed int v0; // ebp@3 | |
47 GUIButton *v5; // eax@18 | |
48 GUIButton *v6; // esi@19 | |
49 | |
50 if ( pParty->field_7B5_in_arena_quest ) | |
51 { | |
52 if ( pParty->field_7B5_in_arena_quest == -1 ) | |
53 { | |
54 uDialogueType = DIALOGUE_ARENA_ALREADY_WON; | |
55 } | |
56 else | |
57 { | |
58 v0 = 0; | |
59 for (size_t i = 0; i < uNumActors; i++ ) | |
60 { | |
61 if ( pActors[i].uAIState == Dead | |
62 || pActors[i].uAIState == Removed | |
63 || pActors[i].uAIState == Disabled | |
64 || pActors[i].uSummonerID != 0 && PID_TYPE(pActors[i].uSummonerID) == OBJECT_Player) | |
65 ++v0; | |
66 } | |
67 if ( v0 >= (signed int)uNumActors || (signed int)uNumActors <= 0) | |
68 { | |
69 uDialogueType = DIALOGUE_ARENA_REWARD; | |
70 ++*((char *)&pParty->monster_for_hunting_killed[3] + (unsigned __int8)pParty->field_7B5_in_arena_quest + 1);//Ritor1:I dont know | |
71 for ( uint i= 0; i < 4; i++ ) | |
72 pParty->pPlayers[i].SetVariable(VAR_Award, (unsigned __int8)pParty->field_7B5_in_arena_quest + 3); | |
73 pParty->PartyFindsGold(gold_transaction_amount, 0); | |
74 pAudioPlayer->PlaySound(SOUND_Arena_Welcome, 0, 0, -1, 0, 0, 0, 0); | |
75 pParty->field_7B5_in_arena_quest = -1; | |
76 } | |
77 else | |
78 { | |
79 uDialogueType = DIALOGUE_ARENA_WELCOME; | |
80 pParty->vPosition.x = 3849; | |
81 pParty->vPosition.y = 5770; | |
82 pParty->vPosition.z = 1; | |
83 pParty->uFallStartY = 1; | |
84 pParty->sRotationY = 512; | |
85 pParty->sRotationX = 0; | |
86 pParty->uFallSpeed = 0; | |
87 pAudioPlayer->PlaySound(SOUND_Arena_Welcome, 0, 0, -1, 0, 0, 0, 0); | |
88 } | |
89 } | |
90 } | |
91 else | |
92 { | |
93 uDialogueType = DIALOGUE_ARENA_WELCOME; | |
94 v5 = pDialogueWindow->pControlsHead; | |
95 if ( v5 ) | |
96 { | |
97 do | |
98 { | |
99 v6 = v5->pNext; | |
100 free(v5); | |
101 v5 = v6; | |
102 } | |
103 while ( v6 ); | |
104 } | |
105 pDialogueWindow->pControlsHead = 0; | |
106 pDialogueWindow->pControlsTail = 0; | |
107 pDialogueWindow->uNumControls = 0; | |
108 pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, | |
109 pGlobalTXT_LocalizationStrings[79], //Close, Закрыть | |
110 pIcons_LOD->GetTexture(uExitCancelTextureId), 0); | |
111 pDialogueWindow->CreateButton(480, 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 85, 0, "", 0); | |
112 pDialogueWindow->CreateButton(480, 190, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 86, 0, "", 0); | |
113 pDialogueWindow->CreateButton(480, 220, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 87, 0, "", 0); | |
114 pDialogueWindow->CreateButton(480, 250, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 88, 0, "", 0); | |
115 pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 1); | |
116 } | |
117 } | |
118 | |
119 | |
120 //----- (004BC109) -------------------------------------------------------- | |
121 void ArenaFight() | |
122 { | |
123 int v0; // edi@1 | |
124 char *v1; // eax@7 | |
125 int v3; // eax@10 | |
126 signed int v4; // esi@10 | |
127 signed int v6; // ebx@34 | |
128 signed int v13; // eax@49 | |
129 int v14; // esi@49 | |
130 int v15; // edx@50 | |
131 int v16; // eax@51 | |
132 signed int v17; // ecx@51 | |
133 int v18; // edx@53 | |
134 int i; // edi@55 | |
135 signed int v22; // [sp-4h] [bp-144h]@51 | |
136 __int16 v23[100]; // [sp+Ch] [bp-134h]@39 | |
137 GUIWindow window; // [sp+D4h] [bp-6Ch]@1 | |
138 __int16 monster_ids[6]; // [sp+128h] [bp-18h]@56 | |
139 int v26; // [sp+134h] [bp-Ch]@1 | |
140 int num_monsters; // [sp+13Ch] [bp-4h]@17 | |
141 | |
142 v26 = 0; | |
143 pParty->field_7B5_in_arena_quest = uDialogueType; | |
144 memcpy(&window, pDialogueWindow, sizeof(window)); | |
145 window.uFrameWidth = game_viewport_width; | |
146 window.uFrameZ = 452; | |
147 v0 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[575], &window, 13, 0) + 7;// Пожалуйста, подождите пока я вызываю существ. Удачи. | |
148 pRenderer->BeginSceneD3D(); | |
149 | |
150 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
151 pIndoor->Draw(); | |
152 else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
153 pOutdoor->Draw(); | |
154 | |
155 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
156 pRenderer->BeginScene(); | |
157 //if ( pRenderer->pRenderD3D ) | |
158 pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, | |
159 pViewport->uViewportBR_X - pViewport->uViewportTL_X, | |
160 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, | |
161 0x7FF); | |
162 | |
163 Texture* pTex = pIcons_LOD->GetTexture(uTextureID_Leather); | |
164 pRenderer->GetLeather(8, 352 - v0, pTex, pTex->uTextureHeight - v0); | |
165 | |
166 pRenderer->DrawTextureIndexed(8, 347 - v0, pTexture_591428); | |
167 v1 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[575], pFontArrus, &window, 0xDu, 0);//Пожалуйста, подождите пока я вызываю существ. Удачи. | |
168 pDialogueWindow->DrawText(pFontArrus, 13, 354 - v0, 0, v1, 0, 0, 0); | |
169 pRenderer->EndScene(); | |
170 pRenderer->Present(); | |
171 pParty->vPosition.x = 3849; | |
172 pParty->vPosition.y = 5770; | |
173 pParty->vPosition.z = 1; | |
174 pParty->uFallStartY = 1; | |
175 pParty->sRotationY = 512; | |
176 pParty->sRotationX = 0; | |
177 pParty->uFallSpeed = 0; | |
178 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
179 { | |
180 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; | |
181 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
182 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
183 ++pMessageQueue_50CBD0->uNumMessages; | |
184 }*/ | |
185 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); | |
186 //v2 = pParty->pPlayers.data(); | |
187 for ( uint i = 0; i < 4; i++ ) | |
188 { | |
189 v3 = pParty->pPlayers[i].GetActualLevel(); | |
190 v4 = v26; | |
191 if ( v3 > v26 ) | |
192 { | |
193 v26 = pParty->pPlayers[i].GetActualLevel(); | |
194 v4 = pParty->pPlayers[i].GetActualLevel(); | |
195 } | |
196 //++v2; | |
197 } | |
198 //while ( (signed int)v2 < (signed int)pParty->pHirelings.data() ); | |
199 if ( uDialogueType == DIALOGUE_ARENA_SELECT_PAGE ) | |
200 { | |
201 num_monsters = v4; | |
202 v4 /= 2; | |
203 } | |
204 else if ( uDialogueType == DIALOGUE_ARENA_SELECT_SQUIRE ) | |
205 { | |
206 //v5 = (signed __int64)((double)v26 * 1.5); | |
207 num_monsters = (int)((double)v26 * 1.5); | |
208 v4 /= 2; | |
209 } | |
210 else if ( uDialogueType == DIALOGUE_ARENA_SELECT_KNIGHT ) | |
211 { | |
212 //LODWORD(v5) = 2 * v4; | |
213 num_monsters = 2 * v4; | |
214 v4 /= 2; | |
215 } | |
216 else if ( uDialogueType == DIALOGUE_ARENA_SELECT_CHAMPION ) | |
217 { | |
218 num_monsters = 2 * v4; | |
219 v4 /= 2; | |
220 } | |
221 if ( v4 < 1 ) | |
222 v4 = 1; | |
223 if ( v4 > 100 ) | |
224 v4 = 100; | |
225 if ( num_monsters > 100 ) | |
226 num_monsters = 100; | |
227 if ( v4 < 2 ) | |
228 v4 = 2; | |
229 if ( num_monsters < 2 ) | |
230 num_monsters = 2; | |
231 v6 = 0; | |
232 //v27 = 1; | |
233 //v7 = (char *)&pMonsterStats->pInfos[1].uLevel; | |
234 for ( uint i = 1; i <= 258; i++ ) | |
235 { | |
236 if ( pMonsterStats->pInfos[i].uAIType != 1 )//if ( v7[8] != 1 ) | |
237 { | |
238 if ( !MonsterStats::BelongsToSupertype(pMonsterStats->pInfos[i].uID, MONSTER_SUPERTYPE_8) ) //!MonsterStats::BelongsToSupertype(*((short *)v7 + 22), MONSTER_SUPERTYPE_8) | |
239 { | |
240 //v8 = (unsigned __int8)pMonsterStats->pInfos[i].uLevel; | |
241 if ( pMonsterStats->pInfos[i].uLevel >= v4 ) | |
242 { | |
243 if ( pMonsterStats->pInfos[i].uLevel <= num_monsters ) | |
244 v23[v6++] = i; | |
245 } | |
246 } | |
247 } | |
248 // ++v27; | |
249 //v7 += 88; | |
250 } | |
251 //while ( (signed int)v7 <= (signed int)&pMonsterStats->pInfos[258].uLevel ); | |
252 num_monsters = 6; | |
253 if ( v6 < 6 ) | |
254 num_monsters = v6; | |
255 //v9 = 0; | |
256 if ( num_monsters > 0 ) | |
257 { | |
258 for ( uint i = 0; i < num_monsters; i++ ) | |
259 { | |
260 //v10 = rand(); | |
261 //++v9; | |
262 //v12 = __OFSUB__(v9, num_monsters); | |
263 //v11 = v9 - num_monsters < 0; | |
264 //*((short *)&window.pControlsTail + v9 + 1) = v23[rand() % v6]; | |
265 monster_ids[i] = v23[rand() % v6]; | |
266 } | |
267 //while ( v11 ^ v12 ); | |
268 } | |
269 if ( uDialogueType == DIALOGUE_ARENA_SELECT_PAGE ) | |
270 { | |
271 v16 = rand(); | |
272 v17 = 3; | |
273 v22 = 50; | |
274 v18 = v16 % v17; | |
275 v13 = v22; | |
276 v14 = v18 + 6; | |
277 } | |
278 else if ( uDialogueType == DIALOGUE_ARENA_SELECT_SQUIRE ) | |
279 { | |
280 v16 = rand(); | |
281 v17 = 7; | |
282 v22 = 100; | |
283 v18 = v16 % v17; | |
284 v13 = v22; | |
285 v14 = v18 + 6; | |
286 } | |
287 else if ( uDialogueType == DIALOGUE_ARENA_SELECT_KNIGHT ) | |
288 { | |
289 v15 = rand() % 11; | |
290 v13 = 200; | |
291 v14 = v15 + 10; | |
292 } | |
293 else | |
294 { | |
295 if ( uDialogueType == DIALOGUE_ARENA_SELECT_CHAMPION ) | |
296 { | |
297 v13 = 500; | |
298 v14 = 20; | |
299 } | |
300 //else | |
301 //{ | |
302 //v14 = v27; | |
303 //v13 = gold_transaction_amount; | |
304 //} | |
305 } | |
306 gold_transaction_amount = v26 * v13; | |
307 for ( i = 0; i < v14; ++i ) | |
308 Actor::Arena_summon_actor(monster_ids[rand() % num_monsters], pMonsterArenaPlacements[i].x, pMonsterArenaPlacements[i].y, 1); | |
309 pAudioPlayer->PlaySound(SOUND_Arena_Welcome, 0, 0, -1, 0, 0, 0, 0); | |
310 } |