Mercurial > mm7
annotate Engine/Party.cpp @ 2575:a76d408c5132 tip
DrawTranslucent -> DrawTextureGrayShade
Removed old texture drawing stuff
author | a.parshin |
---|---|
date | Wed, 09 Mar 2016 01:39:52 +0200 |
parents | dd36326a9994 |
children |
rev | line source |
---|---|
2499 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
2541 | 6 |
7 #include "Engine/Engine.h" | |
2499 | 8 |
9 #include "Party.h" | |
10 #include "Timer.h" | |
2502 | 11 #include "Media/Audio/AudioPlayer.h" |
2499 | 12 #include "Engine/Tables/IconFrameTable.h" |
2502 | 13 #include "IO/Mouse.h" |
2499 | 14 #include "Engine/Tables/PlayerFrameTable.h" |
15 #include "Engine/TurnEngine/TurnEngine.h" | |
16 #include "Engine/Graphics/Viewport.h" | |
17 #include "Engine/Objects/Actor.h" | |
2502 | 18 #include "GUI/GUIWindow.h" |
2499 | 19 #include "texts.h" |
20 #include "Engine/Graphics/Outdoor.h" | |
21 #include "LOD.h" | |
22 #include "Engine/Objects/SpriteObject.h" | |
23 #include "Engine/Objects/ObjectList.h" | |
24 | |
25 | |
2541 | 26 |
2499 | 27 |
2541 | 28 Party *pParty = nullptr; |
2499 | 29 |
30 struct ActionQueue *pPartyActionQueue = new ActionQueue; | |
31 | |
32 | |
33 std::array<bool, 4> playerAlreadyPicked; // byte_AE3368_ | |
34 char PickedPlayer2_unused; // byte_AE3369_ | |
35 char PickedPlayer3_unused; // byte_AE336A_ | |
36 char PickedPlayer4_unused; // byte_AE336B_ | |
37 | |
38 | |
39 | |
2575 | 40 struct |
41 { | |
42 struct UIAnimation _pUIAnim_Food; | |
43 struct UIAnimation _pUIAnim_Gold; | |
44 struct UIAnimation _pUIAnum_Torchlight; | |
45 struct UIAnimation _pUIAnim_WizardEye; | |
46 } _uianim; | |
47 | |
48 struct UIAnimation *pUIAnim_Food = &_uianim._pUIAnim_Food; | |
49 struct UIAnimation *pUIAnim_Gold = &_uianim._pUIAnim_Gold; | |
50 struct UIAnimation *pUIAnum_Torchlight = &_uianim._pUIAnum_Torchlight; | |
51 struct UIAnimation *pUIAnim_WizardEye = &_uianim._pUIAnim_WizardEye; | |
52 | |
53 std::array<struct UIAnimation *, 4> pUIAnims = | |
54 { | |
55 &_uianim._pUIAnim_Food, | |
56 &_uianim._pUIAnim_Gold, | |
57 &_uianim._pUIAnum_Torchlight, | |
58 &_uianim._pUIAnim_WizardEye | |
59 }; | |
60 | |
61 | |
62 | |
2499 | 63 //----- (0044A56A) -------------------------------------------------------- |
64 void Party::CountHirelings() | |
65 { | |
66 field_70A = 0; | |
67 | |
68 for (unsigned int i = 0; i < pNPCStats->uNumNewNPCs; ++i) | |
69 { | |
70 NPCData* npc = &pNPCStats->pNewNPCData[i]; | |
71 if (npc->Hired() && | |
72 (!pHirelings[0].pName || strcmp(npc->pName, pHirelings[0].pName))) | |
73 { | |
74 if (!pHirelings[1].pName || strcmp(npc->pName, pHirelings[1].pName)) | |
75 ++field_70A; | |
76 } | |
77 } | |
78 } | |
79 | |
80 | |
81 // inlined | |
82 //----- (mm6c::004858D0) -------------------------------------------------- | |
83 void Party::Zero() | |
84 { | |
85 uFlags2 = 0; | |
86 uNumGoldInBank = 0; | |
87 | |
88 uCurrentYear = 0; | |
89 uCurrentMonth = 0; | |
90 uCurrentMonthWeek = 0; | |
91 uDaysPlayed = 0; | |
92 uCurrentHour = 0; | |
93 uCurrentMinute = 0; | |
94 uCurrentTimeSecond = 0; | |
95 | |
96 field_6FC = 0; | |
97 days_played_without_rest = 0; | |
98 vPosition.x = 0; | |
99 vPosition.y = 0; | |
100 vPosition.z = 0; | |
101 uFallStartY = 0; | |
102 sRotationY = 0; | |
103 sRotationX = 0; | |
104 uFallSpeed = 0; | |
105 field_28 = 0; | |
106 uDefaultPartyHeight = 192; | |
107 field_14_radius = 37; | |
108 y_rotation_granularity = 25; | |
109 y_rotation_speed = 90; | |
110 | |
111 uWalkSpeed = 384; | |
112 walk_sound_timer = 0; | |
113 | |
114 field_24 = 5; | |
115 field_6FC = 0; | |
116 field_708 = 15; | |
117 field_0 = 25; | |
118 | |
119 uNumDeaths = 0; | |
120 uNumPrisonTerms = 0; | |
121 uNumBountiesCollected = 0; | |
122 monster_for_hunting_killed.fill(0); | |
123 monster_id_for_hunting.fill(0); | |
124 memset(_quest_bits, 0, sizeof(_quest_bits)); | |
125 pArcomageWins.fill(0); | |
126 uNumArenaPageWins = 0; | |
127 uNumArenaSquireWins = 0; | |
128 uNumArenaKnightWins = 0; | |
129 uNumArenaLordWins = 0; | |
130 } | |
131 | |
132 //inlined | |
133 //----- (mm6c::0045BE90) -------------------------------------------------- | |
134 void ActionQueue::Reset() | |
135 { | |
136 uNumActions = 0; | |
137 } | |
138 | |
139 //----- (004760C1) -------------------------------------------------------- | |
140 void ActionQueue::Add(PartyAction action) | |
141 { | |
142 if (uNumActions < 30) | |
143 pActions[uNumActions++] = action; | |
144 } | |
145 | |
146 //----- (00497FC5) -------------------------------------------------------- | |
147 bool Party::_497FC5_check_party_perception_against_level() | |
148 { | |
149 int uMaxPerception; // edi@1 | |
150 signed int v5; // eax@3 | |
151 bool result; // eax@7 | |
152 | |
153 uMaxPerception = 0; | |
154 for (int i = 0; i < 4; i++) | |
155 { | |
156 if ( this->pPlayers[i].CanAct() ) | |
157 { | |
158 v5 = this->pPlayers[i].GetPerception(); | |
159 if ( v5 > uMaxPerception ) | |
160 uMaxPerception = v5; | |
161 } | |
162 } | |
163 if ( uLevelMapStatsID && (signed int)uLevelMapStatsID < 77 ) | |
164 result = uMaxPerception >= 2 * pMapStats->pInfos[uLevelMapStatsID]._per; | |
165 else | |
166 result = 0; | |
167 return result; | |
168 } | |
169 | |
170 //----- (004936E1) -------------------------------------------------------- | |
171 void Party::SetHoldingItem(ItemGen *pItem) | |
172 { | |
173 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
174 memcpy(&pPickedItem, pItem, sizeof(pPickedItem)); | |
175 pMouse->SetCursorBitmapFromItemID(pPickedItem.uItemID); | |
176 } | |
177 | |
178 //----- (0049370F) -------------------------------------------------------- | |
179 int Party::GetNextActiveCharacter() | |
180 { | |
181 int v2; // eax@4 | |
182 signed int v8; // esi@23 | |
183 int v12; // [sp+Ch] [bp-4h]@1 | |
184 | |
185 v12 = 0; | |
186 if ( pParty->bTurnBasedModeOn == 1 ) | |
187 { | |
188 if ( pTurnEngine->turn_stage != TE_ATTACK || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) != OBJECT_Player) | |
189 return 0; | |
190 v2 = PID_ID(pTurnEngine->pQueue[0].uPackedID); | |
191 return v2 + 1; | |
192 } | |
193 | |
194 if ( playerAlreadyPicked[0] && playerAlreadyPicked[1] && playerAlreadyPicked[2] && playerAlreadyPicked[3] ) | |
195 playerAlreadyPicked.fill(false); | |
196 for (int i = 0; i < 4; i++) | |
197 { | |
198 if ( !this->pPlayers[i].CanAct() || this->pPlayers[i].uTimeToRecovery > 0) | |
199 playerAlreadyPicked[i] = true; | |
200 else if ( !playerAlreadyPicked[i] ) | |
201 { | |
202 playerAlreadyPicked[i] = true; | |
203 if (i > 0) //TODO check if this condition really should be here. it is equal to the original source but still seems kind of weird | |
204 return i + 1; | |
205 break; | |
206 } | |
207 } | |
208 | |
209 for (int i = 0; i < 4; i++) | |
210 { | |
211 if ( this->pPlayers[i].CanAct() && this->pPlayers[i].uTimeToRecovery == 0 ) | |
212 { | |
213 if ( v12 == 0 || this->pPlayers[i].uSpeedBonus > v8 ) | |
214 { | |
215 v8 = this->pPlayers[i].uSpeedBonus; | |
216 v12 = i + 1; | |
217 } | |
218 } | |
219 } | |
220 return v12; | |
221 } | |
222 | |
223 | |
224 //----- (00493244) -------------------------------------------------------- | |
225 bool Party::HasItem(unsigned int uItemID) | |
226 { | |
227 for (int player = 0; player < 4; player++) | |
228 { | |
229 for (int itemPos = 0; itemPos < 138; itemPos++) | |
230 { | |
231 if (pParty->pPlayers[player].pOwnItems[itemPos].uItemID == uItemID) | |
232 return true; | |
233 } | |
234 } | |
235 return false; | |
236 } | |
237 | |
238 | |
239 //----- (00492AD5) -------------------------------------------------------- | |
240 void Party::SetFood(unsigned int uNumFood) | |
241 { | |
242 pUIAnim_Food->uAnimTime = 0; | |
243 pParty->uNumFoodRations = uNumFood; | |
2575 | 244 pUIAnim_Food->uAnimLength = pUIAnim_Food->icon->GetAnimLength(); |
2499 | 245 } |
246 | |
247 //----- (00492B03) -------------------------------------------------------- | |
248 void Party::TakeFood(unsigned int uNumFood) | |
249 { | |
250 if (pParty->uNumFoodRations <= uNumFood) | |
251 pParty->uNumFoodRations = 0; | |
252 else | |
253 pParty->uNumFoodRations -= uNumFood; | |
254 | |
255 pUIAnim_Food->uAnimTime = 0; | |
2575 | 256 pUIAnim_Food->uAnimLength = pUIAnim_Food->icon->GetAnimLength(); |
2499 | 257 } |
258 | |
259 //----- (00492B42) -------------------------------------------------------- | |
260 void Party::GiveFood(unsigned int _this) | |
261 { | |
262 pParty->uNumFoodRations += _this; | |
263 pUIAnim_Food->uAnimTime = 0; | |
2575 | 264 pUIAnim_Food->uAnimLength = pUIAnim_Food->icon->GetAnimLength(); |
2499 | 265 } |
266 | |
267 //----- (00492B70) -------------------------------------------------------- | |
268 void Party::SetGold(unsigned int uNumGold) | |
269 { | |
270 pParty->uNumGold = uNumGold; | |
271 pUIAnim_Gold->uAnimTime = 0; | |
2575 | 272 pUIAnim_Gold->uAnimLength = pUIAnim_Gold->icon->GetAnimLength(); |
2534 | 273 pAudioPlayer->PlaySound(SOUND_gold01, 0, 0, -1, 0, 0, 0, 0); |
2499 | 274 } |
275 | |
276 //----- (00492BB6) -------------------------------------------------------- | |
277 void Party::TakeGold(unsigned int uNumGold) | |
278 { | |
279 if ( uNumGold <= pParty->uNumGold ) | |
280 pParty->uNumGold -= uNumGold; | |
281 else | |
282 pParty->uNumGold = 0; | |
283 pUIAnim_Gold->uAnimTime = 0; | |
2575 | 284 pUIAnim_Gold->uAnimLength = pUIAnim_Gold->icon->GetAnimLength(); |
2534 | 285 pAudioPlayer->PlaySound(SOUND_gold01, 0, 0, -1, 0, 0, 0, 0); |
2499 | 286 } |
287 | |
288 //----- (0049135E) -------------------------------------------------------- | |
289 unsigned int Party::GetPartyFame() | |
290 { | |
291 unsigned __int64 total_exp = 0; | |
292 for (uint i = 0; i < 4; ++i) | |
293 total_exp += pPlayers[i].uExperience; | |
294 return (unsigned int)(min(total_exp / 1000, UINT_MAX)); //min wasn't present, but could be incorrect without it | |
295 } | |
296 | |
297 //----- (0049137D) -------------------------------------------------------- | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
298 void Party::CreateDefaultParty(bool bDebugGiveItems) |
2499 | 299 { |
300 Player *pCharacter; // esi@3 | |
301 int uSkillIdx; // eax@11 | |
302 unsigned int v16; // [sp-4h] [bp-44h]@26 | |
303 signed int uNumPlayers; // [sp+18h] [bp-28h]@1 | |
304 ItemGen Dst; // [sp+1Ch] [bp-24h]@10 | |
305 | |
306 pHireling1Name[0] = 0; | |
307 pHireling2Name[0] = 0; | |
308 this->hirelingScrollPosition = 0; | |
309 memset(&pHirelings, 0, sizeof(pHirelings)); | |
310 | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
311 strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); // Zoltan |
2499 | 312 this->pPlayers[0].uPrevFace = 17; |
313 this->pPlayers[0].uCurrentFace = 17; | |
314 this->pPlayers[0].uPrevVoiceID = 17; | |
315 this->pPlayers[0].uVoiceID = 17; | |
316 this->pPlayers[0].uMight = 30; | |
317 this->pPlayers[0].uIntelligence = 5; | |
318 this->pPlayers[0].uWillpower = 5; | |
319 this->pPlayers[0].uEndurance = 13; | |
320 this->pPlayers[0].uAccuracy = 13; | |
321 this->pPlayers[0].uSpeed = 14; | |
322 this->pPlayers[0].uLuck = 7; | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
323 this->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
324 this->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
325 this->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
326 this->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
327 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
328 strcpy(this->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); // Roderic |
2499 | 329 this->pPlayers[1].uPrevFace = 3; |
330 this->pPlayers[1].uCurrentFace = 3; | |
331 this->pPlayers[1].uPrevVoiceID = 3; | |
332 this->pPlayers[1].uVoiceID = 3; | |
333 this->pPlayers[1].uMight = 13; | |
334 this->pPlayers[1].uIntelligence = 9; | |
335 this->pPlayers[1].uWillpower = 9; | |
336 this->pPlayers[1].uEndurance = 13; | |
337 this->pPlayers[1].uAccuracy = 13; | |
338 this->pPlayers[1].uSpeed = 13; | |
339 this->pPlayers[1].uLuck = 13; | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
340 this->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
341 this->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
342 this->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
343 this->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
344 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
345 strcpy(this->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena |
2499 | 346 this->pPlayers[2].uPrevFace = 14; |
347 this->pPlayers[2].uCurrentFace = 14; | |
348 this->pPlayers[2].uPrevVoiceID = 14; | |
349 this->pPlayers[2].uVoiceID = 14; | |
350 this->pPlayers[2].uMight = 12; | |
351 this->pPlayers[2].uIntelligence = 9; | |
352 this->pPlayers[2].uWillpower = 20; | |
353 this->pPlayers[2].uEndurance = 22; | |
354 this->pPlayers[2].uAccuracy = 7; | |
355 this->pPlayers[2].uSpeed = 13; | |
356 this->pPlayers[2].uLuck = 7; | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
357 this->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
358 this->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
359 this->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
360 this->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
361 |
2499 | 362 strcpy(this->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis |
363 this->pPlayers[3].uPrevFace = 10; | |
364 this->pPlayers[3].uCurrentFace = 10; | |
365 this->pPlayers[3].uEndurance = 13; | |
366 this->pPlayers[3].uAccuracy = 13; | |
367 this->pPlayers[3].uSpeed = 13; | |
368 this->pPlayers[3].uPrevVoiceID = 10; | |
369 this->pPlayers[3].uVoiceID = 10; | |
370 this->pPlayers[3].uMight = 5; | |
371 this->pPlayers[3].uIntelligence = 30; | |
372 this->pPlayers[3].uWillpower = 9; | |
373 this->pPlayers[3].uLuck = 7; | |
2566 | 374 this->pPlayers[3].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; |
375 this->pPlayers[3].pActiveSkills[PLAYER_SKILL_AIR] = 1; | |
376 this->pPlayers[3].pActiveSkills[PLAYER_SKILL_FIRE] = 1; | |
377 this->pPlayers[3].pActiveSkills[PLAYER_SKILL_STAFF] = 1; | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
378 |
2499 | 379 for (uNumPlayers = 0; uNumPlayers < 4; uNumPlayers++) |
380 { | |
381 pCharacter = &pParty->pPlayers[uNumPlayers]; | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
382 |
2499 | 383 if (pCharacter->classType == PLAYER_CLASS_KNIGHT) |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
384 pCharacter->sResMagicBase = 10; |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
385 |
2499 | 386 pCharacter->lastOpenedSpellbookPage = 0; |
387 for (int i = 0; i < 9; i++)//for Magic Book | |
388 { | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
389 if (pPlayers[uNumPlayers].pActiveSkills[12+i]) |
2499 | 390 { |
391 pCharacter->lastOpenedSpellbookPage = i; | |
392 break; | |
393 } | |
394 } | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
395 |
2499 | 396 pCharacter->uExpressionTimePassed = 0; |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
397 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
398 if (bDebugGiveItems) |
2499 | 399 { |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
400 Dst.Reset(); |
2499 | 401 pItemsTable->GenerateItem(2, 40, &Dst); //ring |
402 pCharacter->AddItem2(-1, &Dst); | |
403 for (uSkillIdx = 0; uSkillIdx < 36; uSkillIdx++) | |
404 { | |
405 if ( pCharacter->pActiveSkills[uSkillIdx] ) | |
406 { | |
407 switch ( uSkillIdx ) | |
408 { | |
409 case PLAYER_SKILL_STAFF: | |
410 pCharacter->WearItem(ITEM_STAFF_1); | |
411 break; | |
412 case PLAYER_SKILL_SWORD: | |
413 pCharacter->WearItem(ITEM_LONGSWORD_1); | |
414 break; | |
415 case PLAYER_SKILL_DAGGER: | |
416 pCharacter->WearItem(ITEM_DAGGER_1); | |
417 break; | |
418 case PLAYER_SKILL_AXE: | |
419 pCharacter->WearItem(ITEM_AXE_1); | |
420 break; | |
421 case PLAYER_SKILL_SPEAR: | |
422 pCharacter->WearItem(ITEM_SPEAR_1); | |
423 break; | |
424 case PLAYER_SKILL_BOW: | |
425 pCharacter->WearItem(ITEM_CROSSBOW_1); | |
426 break; | |
427 case PLAYER_SKILL_MACE: | |
428 pCharacter->WearItem(ITEM_MACE_1); | |
429 break; | |
430 case PLAYER_SKILL_SHIELD: | |
431 pCharacter->WearItem(ITEM_BUCKLER_1); | |
432 break; | |
433 case PLAYER_SKILL_LEATHER: | |
434 pCharacter->WearItem(ITEM_LEATHER_1); | |
435 break; | |
436 case PLAYER_SKILL_CHAIN: | |
437 pCharacter->WearItem(ITEM_CHAINMAIL_1); | |
438 break; | |
439 case PLAYER_SKILL_PLATE: | |
440 pCharacter->WearItem(ITEM_PLATE_1); | |
441 break; | |
442 case PLAYER_SKILL_FIRE: | |
443 pCharacter->AddItem(-1, ITEM_SPELLBOOK_FIRE_STRIKE); | |
444 break; | |
445 case PLAYER_SKILL_AIR: | |
446 pCharacter->AddItem(-1, ITEM_SPELLBOOK_AIR_FEATHER_FALL); | |
447 break; | |
448 case PLAYER_SKILL_WATER: | |
449 pCharacter->AddItem(-1, ITEM_SPELLBOOK_WATER_POISON_SPRAY); | |
450 break; | |
451 case PLAYER_SKILL_EARTH: | |
452 pCharacter->AddItem(-1, ITEM_SPELLBOOK_EARTH_SLOW); | |
453 break; | |
454 case PLAYER_SKILL_SPIRIT: | |
455 pCharacter->AddItem(-1, ITEM_SPELLBOOK_SPIRIT_BLESS); | |
456 break; | |
457 case PLAYER_SKILL_MIND: | |
458 pCharacter->AddItem(-1, ITEM_SPELLBOOK_MIND_MIND_BLAST); | |
459 break; | |
460 case PLAYER_SKILL_BODY: | |
461 pCharacter->AddItem(-1, ITEM_SPELLBOOK_BODY_FIRST_AID); | |
462 break; | |
463 case PLAYER_SKILL_ITEM_ID: | |
464 case PLAYER_SKILL_REPAIR: | |
465 case PLAYER_SKILL_MEDITATION: | |
466 case PLAYER_SKILL_PERCEPTION: | |
467 case PLAYER_SKILL_DIPLOMACY: | |
468 case PLAYER_SKILL_TRAP_DISARM: | |
469 case PLAYER_SKILL_LEARNING: | |
470 pCharacter->AddItem(-1, ITEM_POTION_BOTTLE); | |
471 v16 = 5 * (rand() % 3 + 40); // simple reagent | |
472 pCharacter->AddItem(-1, v16); | |
473 break; | |
474 case PLAYER_SKILL_DODGE: | |
475 pCharacter->AddItem(-1, ITEM_BOOTS_1); | |
476 break; | |
477 case PLAYER_SKILL_UNARMED: | |
478 pCharacter->AddItem(-1, ITEM_GAUNTLETS_1); | |
479 break; | |
480 default: | |
481 break; | |
482 } | |
483 } | |
484 } | |
485 for (int i = 0; i < 138; i++) | |
486 { | |
487 if ( pCharacter->pInventoryItemList[i].uItemID != 0) | |
488 pCharacter->pInventoryItemList[i].SetIdentified(); | |
489 } | |
490 } | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
491 |
2499 | 492 pCharacter->sHealth = pCharacter->GetMaxHealth(); |
493 pCharacter->sMana = pCharacter->GetMaxMana(); | |
494 } | |
495 } | |
496 | |
497 //----- (004917CE) -------------------------------------------------------- | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
498 void Party::Reset() |
2499 | 499 { |
500 Zero(); | |
501 | |
502 field_708 = 15; | |
503 sEyelevel = 160; | |
504 uNumGold = 200; | |
505 uNumFoodRations = 7; | |
506 | |
507 alignment = PartyAlignment_Neutral; | |
508 SetUserInterface(alignment, true); | |
509 | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
510 // 0x21C00 = 138240 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
511 // 138240 x 0.234375 = 32400 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
512 // 32400 / 60 / 60 = 9 am |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
513 uTimePlayed = 0x21C00; |
2499 | 514 uLastRegenerationTime = 0x21C00; |
515 | |
516 bTurnBasedModeOn = false; | |
517 | |
518 uActiveCharacter = 1; | |
519 ::pPlayers.ZerothIndex() = &pPlayers[0]; | |
520 for (uint i = 0; i < 4; ++i) | |
521 ::pPlayers[i + 1] = &pPlayers[i]; | |
522 | |
523 pPlayers[0].Reset(PLAYER_CLASS_KNIGHT); | |
524 pPlayers[0].uCurrentFace = 17; | |
525 pPlayers[0].uPrevVoiceID = 17; | |
526 pPlayers[0].uVoiceID = 17; | |
527 pPlayers[0].SetInitialStats(); | |
528 | |
529 pPlayers[0].uSex = pPlayers[0].GetSexByVoice(); | |
530 pPlayers[0].RandomizeName(); | |
531 strcpy(pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); | |
532 | |
533 | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
534 pPlayers[1].Reset(PLAYER_CLASS_THEIF); |
2499 | 535 pPlayers[1].uCurrentFace = 3; |
536 pPlayers[1].uPrevVoiceID = 3; | |
537 pPlayers[1].uVoiceID = 3; | |
538 pPlayers[1].SetInitialStats(); | |
539 pPlayers[1].uSex = pPlayers[1].GetSexByVoice(); | |
540 pPlayers[1].RandomizeName(); | |
541 strcpy(pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
542 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
543 pPlayers[2].Reset(PLAYER_CLASS_CLERIC); |
2499 | 544 pPlayers[2].uCurrentFace = 14; |
545 pPlayers[2].uPrevVoiceID = 14; | |
546 pPlayers[2].uVoiceID = 14; | |
547 pPlayers[2].SetInitialStats(); | |
548 pPlayers[2].uSex = pPlayers[3].GetSexByVoice(); | |
549 pPlayers[2].RandomizeName(); | |
550 strcpy(pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
551 |
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2544
diff
changeset
|
552 pPlayers[3].Reset(PLAYER_CLASS_SORCERER); |
2499 | 553 pPlayers[3].uCurrentFace = 10; |
554 pPlayers[3].uPrevVoiceID = 10; | |
555 pPlayers[3].uVoiceID = 10; | |
556 pPlayers[3].SetInitialStats(); | |
557 pPlayers[3].uSex = pPlayers[3].GetSexByVoice(); | |
558 pPlayers[3].RandomizeName(); | |
559 strcpy(pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); | |
560 | |
561 for (uint i = 0; i < 4; ++i) | |
562 { | |
563 pPlayers[i].uTimeToRecovery = 0; | |
564 for (uint j = 0; j < 20; ++j) | |
565 pPlayers[i].pConditions[j] = 0; | |
566 | |
567 for (uint j = 0; j < 24; ++j) | |
568 pPlayers[i].pPlayerBuffs[j].Reset(); | |
569 | |
570 pPlayers[i].expression = CHARACTER_EXPRESSION_1; | |
571 pPlayers[i].uExpressionTimePassed = 0; | |
572 pPlayers[i].uExpressionTimeLength = rand() % 256 + 128; | |
573 } | |
574 | |
575 for (uint i = 1; i < 20; ++i) | |
576 pPartyBuffs[i].Reset(); | |
577 | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2542
diff
changeset
|
578 current_character_screen_window = WINDOW_CharacterWindow_Stats; // default character ui - stats |
2499 | 579 uFlags = 0; |
580 memset(_autonote_bits, 0, sizeof(_autonote_bits)); | |
581 memset(_quest_bits, 0, sizeof(_quest_bits)); | |
582 pIsArtifactFound.fill(0); | |
583 | |
584 PartyTimes._shop_ban_times.fill(0); | |
585 | |
586 memcpy(pNPCStats->pNewNPCData, pNPCStats->pNPCData, 0x94BCu); | |
587 memcpy(pNPCStats->pGroups_copy, pNPCStats->pGroups, 0x66u); | |
588 pNPCStats->pNewNPCData[3].uFlags |= 128;//|= 0x80u; Lady Margaret | |
589 _494035_timed_effects__water_walking_damage__etc(); | |
590 pEventTimer->Pause(); | |
591 } | |
592 | |
593 | |
594 //----- (0043AD34) -------------------------------------------------------- | |
595 void Party::Yell() | |
596 { | |
597 Actor *v0; // esi@5 | |
598 int v1; // edi@9 | |
599 int v2; // ebx@9 | |
600 int v3; // eax@9 | |
601 | |
602 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ) | |
603 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
604 if ( pParty->bTurnBasedModeOn != 1 ) | |
605 { | |
606 for (unsigned int i = 0; i < uNumActors; i++) | |
607 { | |
608 v0 = &pActors[i]; | |
609 if ( v0->Actor::CanAct() && v0->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long | |
610 && v0->pMonsterInfo.uMovementType != MONSTER_MOVEMENT_TYPE_STAIONARY ) | |
611 { | |
612 v1 = abs(v0->vPosition.x - pParty->vPosition.x); | |
613 v2 = abs(v0->vPosition.y - pParty->vPosition.y); | |
614 v3 = abs(v0->vPosition.z - pParty->vPosition.z); | |
615 if (int_get_vector_length(v1, v2, v3) < 512) | |
616 Actor::AI_Flee(i, 4, 0, 0); | |
617 } | |
618 } | |
619 } | |
620 } | |
621 | |
622 //----- (00491BF9) -------------------------------------------------------- | |
623 void Party::ResetPosMiscAndSpellBuffs() | |
624 { | |
625 this->vPosition.y = 0; | |
626 this->vPosition.z = 0; | |
627 this->vPosition.x = 0; | |
628 this->uFallStartY = 0; | |
629 this->sRotationY = 0; | |
630 this->sRotationX = 0; | |
631 this->uFallSpeed = 0; | |
632 this->field_28 = 0; | |
633 this->uDefaultPartyHeight = 120; | |
634 this->field_14_radius = 37; | |
635 this->y_rotation_granularity = 25; | |
636 this->uWalkSpeed = 384; | |
637 this->y_rotation_speed = 90; | |
638 this->field_24 = 5; | |
639 this->field_6FC = 0; | |
640 this->field_708 = 15; | |
641 this->field_0 = 25; | |
642 | |
643 for (int playerId = 0; playerId < 4; playerId++) | |
644 { | |
645 for (int buffId = 0; buffId < 24; buffId++) | |
646 { | |
647 this->pPlayers[playerId].pPlayerBuffs[buffId].Reset(); | |
648 } | |
649 } | |
650 for (int buffId = 0; buffId < 20; buffId++) | |
651 { | |
652 this->pPartyBuffs[buffId].Reset(); | |
653 } | |
654 } | |
655 | |
656 //----- (004909F4) -------------------------------------------------------- | |
657 void Party::UpdatePlayersAndHirelingsEmotions() | |
658 { | |
659 int v4; // edx@27 | |
660 | |
661 for (int i = 0; i < 4; ++i) | |
662 { | |
663 Player* player = &pPlayers[i]; | |
664 player->uExpressionTimePassed += (unsigned short)pMiscTimer->uTimeElapsed; | |
665 | |
666 uint condition = player->GetMajorConditionIdx(); | |
667 if (condition == Condition_Good || condition == Condition_Zombie) | |
668 { | |
669 if (player->uExpressionTimePassed < player->uExpressionTimeLength) | |
670 continue; | |
671 | |
672 player->uExpressionTimePassed = 0; | |
673 if (player->expression != 1 || rand() % 5) | |
674 { | |
675 player->expression = CHARACTER_EXPRESSION_1; | |
676 player->uExpressionTimeLength = rand() % 256 + 32; | |
677 } | |
678 else | |
679 { | |
680 v4 = rand() % 100; | |
681 if (v4 < 25) player->expression = CHARACTER_EXPRESSION_13; | |
682 else if (v4 < 31) player->expression = CHARACTER_EXPRESSION_14; | |
683 else if (v4 < 37) player->expression = CHARACTER_EXPRESSION_15; | |
684 else if (v4 < 43) player->expression = CHARACTER_EXPRESSION_16; | |
685 else if (v4 < 46) player->expression = CHARACTER_EXPRESSION_17; | |
686 else if (v4 < 52) player->expression = CHARACTER_EXPRESSION_18; | |
687 else if (v4 < 58) player->expression = CHARACTER_EXPRESSION_19; | |
688 else if (v4 < 64) player->expression = CHARACTER_EXPRESSION_20; | |
689 else if (v4 < 70) player->expression = CHARACTER_EXPRESSION_54; | |
690 else if (v4 < 76) player->expression = CHARACTER_EXPRESSION_55; | |
691 else if (v4 < 82) player->expression = CHARACTER_EXPRESSION_56; | |
692 else if (v4 < 88) player->expression = CHARACTER_EXPRESSION_57; | |
693 else if (v4 < 94) player->expression = CHARACTER_EXPRESSION_29; | |
694 else player->expression = CHARACTER_EXPRESSION_30; | |
695 } | |
696 | |
697 for (unsigned int j = 0; j < pPlayerFrameTable->uNumFrames; ++j) | |
698 { | |
699 PlayerFrame* frame = &pPlayerFrameTable->pFrames[j]; | |
700 if (frame->expression == player->expression) | |
701 { | |
702 player->uExpressionTimeLength = 8 * frame->uAnimLength; | |
703 break; | |
704 } | |
705 } | |
706 } | |
707 else if (player->expression != CHARACTER_EXPRESSION_DMGRECVD_MINOR && | |
708 player->expression != CHARACTER_EXPRESSION_DMGRECVD_MODERATE && | |
709 player->expression != CHARACTER_EXPRESSION_DMGRECVD_MAJOR || | |
710 player->uExpressionTimePassed >= player->uExpressionTimeLength) | |
711 { | |
712 player->uExpressionTimeLength = 0; | |
713 player->uExpressionTimePassed = 0; | |
714 | |
715 switch (condition) | |
716 { | |
717 case Condition_Dead: player->expression = CHARACTER_EXPRESSION_DEAD; break; | |
718 case Condition_Pertified: player->expression = CHARACTER_EXPRESSION_PERTIFIED; break; | |
719 case Condition_Eradicated: player->expression = CHARACTER_EXPRESSION_ERADICATED; break; | |
720 case Condition_Cursed: player->expression = CHARACTER_EXPRESSION_CURSED; break; | |
721 case Condition_Weak: player->expression = CHARACTER_EXPRESSION_WEAK; break; | |
722 case Condition_Sleep: player->expression = CHARACTER_EXPRESSION_SLEEP; break; | |
723 case Condition_Fear: player->expression = CHARACTER_EXPRESSION_FEAR; break; | |
724 case Condition_Drunk: player->expression = CHARACTER_EXPRESSION_DRUNK; break; | |
725 case Condition_Insane: player->expression = CHARACTER_EXPRESSION_INSANE; break; | |
726 case Condition_Poison_Weak: | |
727 case Condition_Poison_Medium: | |
728 case Condition_Poison_Severe: player->expression = CHARACTER_EXPRESSION_POISONED; break; | |
729 case Condition_Disease_Weak: | |
730 case Condition_Disease_Medium: | |
731 case Condition_Disease_Severe: player->expression = CHARACTER_EXPRESSION_DISEASED; break; | |
732 case Condition_Paralyzed: player->expression = CHARACTER_EXPRESSION_PARALYZED; break; | |
733 case Condition_Unconcious: player->expression = CHARACTER_EXPRESSION_UNCONCIOUS; break; | |
734 default: | |
735 Error("Invalid condition: %u", condition); | |
736 } | |
737 } | |
738 } | |
739 | |
740 for (int i = 0; i < 2; ++i) | |
741 { | |
742 NPCData* hireling = &pParty->pHirelings[i]; | |
743 if (!hireling->evt_C) | |
744 continue; | |
745 | |
746 hireling->evt_B += pMiscTimer->uTimeElapsed; | |
747 if (hireling->evt_B >= hireling->evt_C) | |
748 { | |
749 hireling->evt_A = 0; | |
750 hireling->evt_B = 0; | |
751 hireling->evt_C = 0; | |
752 | |
753 Assert(sizeof(NPCData) == 0x4C); | |
754 memset(hireling, 0, sizeof(*hireling)); | |
755 | |
756 pParty->hirelingScrollPosition = 0; | |
757 pParty->CountHirelings(); | |
758 viewparams->bRedrawGameUI = true; | |
759 } | |
760 } | |
761 } | |
762 | |
763 //----- (00490D02) -------------------------------------------------------- | |
764 void Party::RestAndHeal() | |
765 { | |
766 Player *pPlayer; // esi@4 | |
767 bool have_vessels_soul; // [sp+10h] [bp-8h]@10 | |
768 | |
769 for ( uint i = 0; i < 20; ++i ) | |
770 pParty->pPartyBuffs[i].Reset(); | |
771 | |
772 for ( int pPlayerID = 0; pPlayerID < 4; ++pPlayerID ) | |
773 { | |
774 pPlayer = &pParty->pPlayers[pPlayerID]; | |
775 for ( uint i = 0; i < 20; ++i ) | |
776 pPlayer->pPlayerBuffs[i].Reset(); | |
777 | |
778 pPlayer->Zero(); | |
779 if ( pPlayer->pConditions[Condition_Dead] || pPlayer->pConditions[Condition_Pertified] || pPlayer->pConditions[Condition_Eradicated] )//Dead/Petrified/Eradicated | |
780 continue; | |
781 pPlayer->pConditions[Condition_Unconcious] = 0;//Unconcious | |
782 pPlayer->pConditions[Condition_Drunk] = 0;//Drunk | |
783 pPlayer->pConditions[Condition_Fear] = 0;//Fear | |
784 pPlayer->pConditions[Condition_Sleep] = 0;//Sleep | |
785 pPlayer->pConditions[Condition_Weak] = 0;//Weak | |
786 pPlayer->uTimeToRecovery = 0; | |
787 pPlayer->sHealth = pPlayer->GetMaxHealth(); | |
788 pPlayer->sMana = pPlayer->GetMaxMana(); | |
789 if ( pPlayer->classType == PLAYER_CLASS_LICH ) | |
790 { | |
791 have_vessels_soul = false; | |
792 for ( uint i = 0; i < 126; i++ ) | |
793 { | |
794 if ( pPlayer->pInventoryItemList[i].uItemID == ITEM_LICH_JAR_FULL && pPlayer->pInventoryItemList[i].uHolderPlayer == pPlayerID + 1 ) | |
795 have_vessels_soul = true; | |
796 } | |
797 if ( !have_vessels_soul ) | |
798 { | |
799 pPlayer->sHealth = pPlayer->GetMaxHealth() / 2; | |
800 pPlayer->sMana = pPlayer->GetMaxMana() / 2; | |
801 } | |
802 } | |
803 | |
804 if (pPlayer->pConditions[Condition_Zombie]) | |
805 { | |
806 pPlayer->sMana = 0; | |
807 pPlayer->sHealth /= 2; | |
808 } | |
809 else if ( pPlayer->pConditions[Condition_Poison_Severe] || pPlayer->pConditions[Condition_Disease_Severe] ) | |
810 { | |
811 pPlayer->sHealth /= 4; | |
812 pPlayer->sMana /= 4; | |
813 } | |
814 else if ( pPlayer->pConditions[Condition_Poison_Medium] || pPlayer->pConditions[Condition_Disease_Medium] ) | |
815 { | |
816 pPlayer->sHealth /= 3; | |
817 pPlayer->sMana /= 3; | |
818 } | |
819 else if ( pPlayer->pConditions[Condition_Poison_Weak] || pPlayer->pConditions[Condition_Disease_Weak] ) | |
820 { | |
821 pPlayer->sHealth /= 2; | |
822 pPlayer->sMana /= 2; | |
823 } | |
824 if ( pPlayer->pConditions[Condition_Insane] ) | |
825 pPlayer->sMana = 0; | |
826 UpdatePlayersAndHirelingsEmotions(); | |
827 } | |
828 pParty->days_played_without_rest = 0; | |
829 } | |
830 | |
831 //----- (004938D1) -------------------------------------------------------- | |
832 void __fastcall Rest(unsigned int uHoursToSleep) | |
833 { | |
834 signed __int64 v2; // st7@3 | |
835 | |
836 if ( uHoursToSleep > 240 ) | |
837 Actor::InitializeActors(); | |
838 v2 = (signed __int64)((7680 * uHoursToSleep) * 0.033333335); | |
839 pParty->uTimePlayed += v2; | |
840 for (int i = 1; i <= 4; i++) | |
841 { | |
842 pPlayers[i]->Recover((int)v2); | |
843 } | |
844 _494035_timed_effects__water_walking_damage__etc(); | |
845 } | |
846 //----- (004B1BDB) -------------------------------------------------------- | |
847 void RestAndHeal(__int64 uNumMinutes) | |
848 { | |
849 signed __int64 v1; // ST2C_8@1 | |
850 signed __int64 v2; // qax@1 | |
851 unsigned __int64 v4; // qax@1 | |
852 unsigned int v5; // ebx@1 | |
853 | |
854 pParty->pHirelings[0].bHasUsedTheAbility = 0; | |
855 pParty->pHirelings[1].bHasUsedTheAbility = 0; | |
856 pParty->uTimePlayed += (signed __int64)((double)(7680 * uNumMinutes) * 0.033333335); | |
857 v1 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); | |
858 v2 = v1 / 60 / 60; | |
859 v4 = (unsigned int)v2 / 0x18; | |
860 v5 = (unsigned int)(v4 / 7) >> 2; | |
861 pParty->uCurrentTimeSecond = v1 % 60; | |
862 pParty->uCurrentMinute = v1 / 60 % 60; | |
863 pParty->uCurrentHour = v2 % 24; | |
864 pParty->uCurrentMonthWeek = v4 / 7 & 3; | |
865 pParty->uDaysPlayed = (unsigned int)v4 % 0x1C; | |
866 pParty->uCurrentMonth = v5 % 0xC; | |
867 pParty->uCurrentYear = v5 / 0xC + game_starting_year; | |
868 pParty->RestAndHeal(); | |
869 | |
870 for (int i = 0; i < 4; i++) | |
871 { | |
872 pParty->pPlayers[i].uTimeToRecovery = 0; | |
873 pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; | |
874 pParty->pPlayers[i].uNumArmageddonCasts = 0; | |
875 pParty->pPlayers[i].uNumFireSpikeCasts = 0; | |
876 pParty->pPlayers[i].field_1B3B = 0; | |
877 } | |
878 pParty->UpdatePlayersAndHirelingsEmotions(); | |
879 } | |
880 //----- (0041F5BE) -------------------------------------------------------- | |
881 void Party::Sleep6Hours() | |
882 { | |
883 if ( _506F18_num_minutes_to_sleep < 6 ) | |
884 { | |
885 if ( _506F18_num_minutes_to_sleep ) | |
886 { | |
887 Rest(_506F18_num_minutes_to_sleep); | |
888 _506F18_num_minutes_to_sleep = 0; | |
889 OutdoorLocation::LoadActualSkyFrame(); | |
890 } | |
2542 | 891 if ( _506F14_resting_stage == 2 ) |
2499 | 892 { |
893 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); | |
894 } | |
895 } | |
896 else | |
897 { | |
898 Rest(6u); | |
899 _506F18_num_minutes_to_sleep -= 6; | |
900 OutdoorLocation::LoadActualSkyFrame(); | |
901 } | |
902 viewparams->bRedrawGameUI = 1; | |
903 } | |
904 | |
905 bool TestPartyQuestBit( PARTY_QUEST_BITS bit ) | |
906 { | |
907 return _449B57_test_bit(pParty->_quest_bits, bit); | |
908 } | |
909 | |
910 //----- (0047752B) -------------------------------------------------------- | |
911 int Party::GetPartyReputation() | |
912 { | |
913 DDM_DLV_Header *v0; // ebx@1 | |
914 signed int v1; // esi@3 | |
915 | |
916 v0 = &pOutdoor->ddm; | |
917 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
918 v0 = &pIndoor->dlv; | |
919 v1 = 0; | |
920 if ( CheckHiredNPCSpeciality(Pirate) ) | |
921 v1 += 5; | |
922 if ( CheckHiredNPCSpeciality(Burglar) ) | |
923 v1 += 5; | |
924 if ( CheckHiredNPCSpeciality(Gypsy) ) | |
925 v1 += 5; | |
926 if ( CheckHiredNPCSpeciality(Duper) ) | |
927 v1 += 5; | |
928 if ( CheckHiredNPCSpeciality(FallenWizard) ) | |
929 v1 += 5; | |
930 return v1 + v0->uReputation; | |
931 } | |
932 //----- (004269A2) -------------------------------------------------------- | |
933 void Party::GivePartyExp(unsigned int pEXPNum) | |
934 { | |
935 signed int pActivePlayerCount; // ecx@1 | |
936 int pLearningPercent; // eax@13 | |
937 | |
938 if ( pEXPNum > 0) | |
939 { | |
940 pActivePlayerCount = 0; | |
941 for ( uint i = 0; i < 4; ++i ) | |
942 { | |
943 if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && | |
944 !pParty->pPlayers[i].pConditions[Condition_Dead] && | |
945 !pParty->pPlayers[i].pConditions[Condition_Pertified] && | |
946 !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) | |
947 pActivePlayerCount ++; | |
948 } | |
949 if ( pActivePlayerCount ) | |
950 { | |
951 pEXPNum = pEXPNum / pActivePlayerCount; | |
952 for ( uint i = 0; i < 4; ++i ) | |
953 { | |
954 if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && | |
955 !pParty->pPlayers[i].pConditions[Condition_Dead] && | |
956 !pParty->pPlayers[i].pConditions[Condition_Pertified] && | |
957 !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) | |
958 { | |
959 pLearningPercent = pParty->pPlayers[i].GetLearningPercent(); | |
960 pEXPNum = pEXPNum + pEXPNum * pLearningPercent / 100; | |
961 pParty->pPlayers[i].uExperience += pEXPNum; | |
962 if ( pParty->pPlayers[i].uExperience > 4000000000i64 ) | |
963 { | |
964 pParty->pPlayers[i].uExperience = 0; | |
965 } | |
966 } | |
967 } | |
968 } | |
969 } | |
970 } | |
971 //----- (00420C05) -------------------------------------------------------- | |
972 void Party::PartyFindsGold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) | |
973 { | |
974 int hirelingSalaries; // ebp@1 | |
975 unsigned int goldToGain; // esi@1 | |
976 NPCData *v12; // ecx@21 | |
977 unsigned int v13; // ecx@23 | |
978 signed int hirelingCount; // [sp+Ch] [bp-4h]@6 | |
979 | |
980 hirelingSalaries = 0; | |
981 goldToGain = uNumGold; | |
982 | |
983 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) | |
984 pTmpBuf2[0] = 0; | |
985 else if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) | |
986 { | |
987 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! | |
988 } | |
989 else | |
990 { | |
991 hirelingCount = 0; | |
992 for (int i = 0; i < 2; i++) | |
993 { | |
994 if (this->pHirelings[i].pName) | |
995 { | |
996 hirelingCount++; | |
997 pTmpBuf[hirelingCount] = i; | |
998 } | |
999 } | |
1000 for (uint i = 0; i < pNPCStats->uNumNewNPCs; i++) | |
1001 { | |
1002 if ( pNPCStats->pNewNPCData[i].uFlags & 0x80 | |
1003 && (!this->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, this->pHirelings[0].pName)) | |
1004 && (!this->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, this->pHirelings[1].pName)) ) | |
1005 { | |
1006 hirelingCount++; | |
1007 pTmpBuf[hirelingCount] = i + 2; | |
1008 } | |
1009 } | |
1010 for (int i = 0; i < hirelingCount; i++) | |
1011 { | |
1012 uchar thisBufId = (uchar)pTmpBuf[i]; | |
1013 if (thisBufId < 2) | |
1014 v12 = &this->pHirelings[thisBufId]; | |
1015 else | |
1016 v12 = &pNPCStats->pNPCData[thisBufId + 499]; | |
1017 v13 = v12->uProfession; | |
1018 if ( v13 ) | |
1019 hirelingSalaries += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); | |
1020 } | |
1021 if ( CheckHiredNPCSpeciality(Factor) ) | |
1022 goldToGain += (signed int)(10 * goldToGain) / 100; | |
1023 if ( CheckHiredNPCSpeciality(Banker) ) | |
1024 goldToGain += (signed int)(20 * goldToGain) / 100; | |
1025 if ( CheckHiredNPCSpeciality(Pirate) ) | |
1026 goldToGain += (signed int)(10 * goldToGain) / 100; | |
1027 if ( hirelingSalaries ) | |
1028 { | |
1029 hirelingSalaries = (signed int)(goldToGain * hirelingSalaries / 100) / 100; | |
1030 if ( hirelingSalaries < 1 ) | |
1031 hirelingSalaries = 1; | |
1032 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], goldToGain, hirelingSalaries);// You found %lu gold (followers take %lu)! | |
1033 } | |
1034 else | |
1035 { | |
1036 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], goldToGain);// You found %lu gold! | |
1037 } | |
1038 } | |
1039 this->uNumGold += goldToGain - hirelingSalaries; | |
1040 pUIAnim_Gold->uAnimTime = 0; | |
2575 | 1041 pUIAnim_Gold->uAnimLength = pUIAnim_Gold->icon->GetAnimLength(); |
2499 | 1042 if ( pTmpBuf2[0] ) |
1043 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
2534 | 1044 pAudioPlayer->PlaySound(SOUND_gold01, 0, 0, -1, 0, 0, 0, 0); |
2499 | 1045 } |
1046 //----- (00421B2C) -------------------------------------------------------- | |
1047 void Party::sub_421B2C_PlaceInInventory_or_DropPickedItem() | |
1048 { | |
2575 | 1049 //unsigned int v0; // eax@2 |
1050 //Texture_MM7 *v1; // ebx@2 | |
2499 | 1051 int v2; // eax@3 |
1052 int v4; // eax@6 | |
1053 unsigned __int16 v5; // dx@11 | |
1054 signed int v6; // eax@11 | |
1055 __int16 v8; // ax@16 | |
1056 SpriteObject a1; // [sp+4h] [bp-78h]@11 | |
2575 | 1057 //int v11; // [sp+74h] [bp-8h]@2 |
2499 | 1058 int v12; // [sp+78h] [bp-4h]@5 |
1059 | |
1060 if ( !pParty->pPickedItem.uItemID ) | |
1061 return; | |
2575 | 1062 |
1063 auto texture = assets->GetImage_16BitColorKey(pParty->pPickedItem.GetIconName(), 0x7FF); | |
1064 //v0 = pIcons_LOD->LoadTexture( | |
1065 // pParty->pPickedItem.GetIconName(), | |
1066 // TEXTURE_16BIT_PALETTE); | |
1067 //v1 = pIcons_LOD->GetTexture(v0); | |
1068 //v11 = areWeLoadingTexture; | |
2499 | 1069 if ( uActiveCharacter |
1070 && (v2 = ::pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) | |
1071 { | |
1072 memcpy(&::pPlayers[uActiveCharacter]->pInventoryItemList[v2-1], &pParty->pPickedItem, 0x24u); | |
1073 pMouse->RemoveHoldingItem(); | |
1074 } | |
1075 else | |
1076 { | |
1077 for (v12 = 0; v12 < 4; v12++) | |
1078 { | |
1079 v4 = pParty->pPlayers[v12].AddItem(-1, pParty->pPickedItem.uItemID); | |
1080 if ( v4 ) | |
1081 { | |
1082 memcpy(&pParty->pPlayers[v12].pInventoryItemList[v4 - 1], &pParty->pPickedItem, sizeof(ItemGen)); | |
1083 pMouse->RemoveHoldingItem(); | |
1084 break; | |
1085 } | |
1086 } | |
1087 if ( v12 == 4 ) | |
1088 { | |
1089 v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
1090 v6 = 0; | |
2566 | 1091 a1.uType = (SPRITE_OBJECT_TYPE)pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; |
2499 | 1092 for ( uint i = 0; i < pObjectList->uNumObjects; i++ ) |
1093 { | |
1094 if ( v5 == pObjectList->pObjects[i].uObjectID ) | |
1095 { | |
1096 v6 = i; | |
1097 break; | |
1098 } | |
1099 } | |
1100 a1.spell_caster_pid = OBJECT_Player; | |
1101 a1.uObjectDescID = v6; | |
1102 a1.vPosition.y = pParty->vPosition.y; | |
1103 a1.vPosition.x = pParty->vPosition.x; | |
1104 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
1105 a1.uSoundID = 0; | |
1106 a1.uFacing = 0; | |
1107 a1.uAttributes = 8; | |
1108 v8 = pIndoor->GetSector( | |
1109 pParty->vPosition.x, | |
1110 pParty->vPosition.y, | |
1111 pParty->sEyelevel + pParty->vPosition.z); | |
1112 a1.uSpriteFrameID = 0; | |
1113 a1.uSectorID = v8; | |
2566 | 1114 memcpy(&a1.containing_item, &pParty->pPickedItem, sizeof(a1.containing_item)); |
2499 | 1115 a1.Create(pParty->sRotationY, 184, 200, 0); |
1116 pMouse->RemoveHoldingItem(); | |
1117 } | |
1118 } | |
2575 | 1119 |
1120 if (texture) | |
2499 | 1121 { |
2575 | 1122 texture->Release(); |
1123 texture = nullptr; | |
2499 | 1124 } |
1125 } | |
1126 | |
1127 | |
1128 //----- (0048C6F6) -------------------------------------------------------- | |
1129 bool Party::AddItemToParty(ItemGen *pItem) | |
1130 { | |
1131 unsigned int v2; // eax@1 | |
1132 char *v5; // eax@8 | |
2575 | 1133 //Texture_MM7 *v7; // ebx@10 |
2499 | 1134 signed int v8; // esi@10 |
1135 Player *v9; // edi@11 | |
1136 int v10; // eax@11 | |
2575 | 1137 //int v21; // [sp+24h] [bp-4h]@10 |
2499 | 1138 |
1139 v2 = pItem->uItemID; | |
1140 if ( !pItemsTable->pItems[v2].uItemID_Rep_St ) | |
1141 pItem->SetIdentified(); | |
1142 | |
1143 v5 = pItemsTable->pItems[v2].pIconName; | |
1144 if ( v5 ) | |
1145 { | |
2575 | 1146 auto texture = assets->GetImage_16BitColorKey(v5, 0x7FF); |
1147 //v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE); | |
1148 //v21 = areWeLoadingTexture; | |
2499 | 1149 v8 = 0; |
1150 uint current_player = uActiveCharacter; | |
1151 for (int i = 0; i < 4; i++) | |
1152 { | |
1153 current_player = current_player + i; | |
1154 if ( current_player > 4 ) | |
1155 current_player = current_player - 4; | |
1156 v9 = ::pPlayers[current_player]; | |
1157 v10 = v9->AddItem(-1, pItem->uItemID); | |
1158 if ( v10 ) | |
1159 { | |
1160 memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u); | |
1161 pItem->Reset(); | |
2534 | 1162 pAudioPlayer->PlaySound(SOUND_gold01, 0, 0, -1, 0, 0, 0, 0); |
2499 | 1163 v9->PlaySound(SPEECH_60, 0); |
2575 | 1164 |
1165 if (texture) | |
2499 | 1166 { |
2575 | 1167 texture->Release(); |
1168 texture = nullptr; | |
2499 | 1169 } |
1170 return true; | |
1171 } | |
1172 } | |
2575 | 1173 if (texture) |
2499 | 1174 { |
2575 | 1175 texture->Release(); |
1176 texture = nullptr; | |
2499 | 1177 } |
1178 } | |
1179 else | |
1180 { | |
1181 MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0); | |
1182 } | |
2575 | 1183 return false; |
2499 | 1184 } |
2575 | 1185 |
2499 | 1186 |
1187 bool Party::IsPartyEvil() | |
1188 { | |
1189 return _449B57_test_bit(_quest_bits, 100); | |
1190 } | |
1191 | |
1192 bool Party::IsPartyGood() | |
1193 { | |
1194 return _449B57_test_bit(_quest_bits, 99); | |
1195 } | |
1196 | |
1197 | |
1198 | |
1199 //----- (0046A89E) -------------------------------------------------------- | |
1200 int Party::_46A89E_immolation_effect(int* affected, int affectedArrSize, int effectRange) | |
1201 { | |
1202 int v5; // ebx@3 | |
1203 int v17; // [sp+Ch] [bp-10h]@3 | |
1204 int v18; // [sp+10h] [bp-Ch]@3 | |
1205 int affectedCount; // [sp+18h] [bp-4h]@1 | |
1206 | |
1207 affectedCount = 0; | |
1208 for ( size_t i = 0; i < uNumActors; ++i ) | |
1209 { | |
1210 v5 = abs(pActors[i].vPosition.x - this->vPosition.x); | |
1211 v17 = abs(pActors[i].vPosition.y - this->vPosition.y); | |
1212 v18 = abs(pActors[i].vPosition.z - this->vPosition.z); | |
1213 if ( int_get_vector_length(v5, v17, v18) <= effectRange ) | |
1214 { | |
1215 if ( pActors[i].uAIState != Dead && pActors[i].uAIState != Dying && pActors[i].uAIState != Removed | |
1216 && pActors[i].uAIState != Disabled && pActors[i].uAIState != Summoned ) | |
1217 { | |
1218 affected[affectedCount] = i; | |
1219 affectedCount++; | |
1220 if ( affectedCount >= affectedArrSize ) | |
1221 break; | |
1222 } | |
1223 } | |
1224 } | |
1225 return affectedCount; | |
1226 } | |
1227 | |
1228 //----- (00444D80) -------------------------------------------------------- | |
1229 int GetTravelTime() | |
1230 { | |
1231 signed int new_travel_time; // esi@1 | |
1232 | |
1233 new_travel_time = uDefaultTravelTime_ByFoot; | |
1234 if ( CheckHiredNPCSpeciality(Guide) ) | |
1235 --new_travel_time; | |
1236 if ( CheckHiredNPCSpeciality(Tracker) ) | |
1237 new_travel_time -= 2; | |
1238 if ( CheckHiredNPCSpeciality(Pathfinder) ) | |
1239 new_travel_time -= 3; | |
1240 if ( CheckHiredNPCSpeciality(Explorer) ) | |
1241 --new_travel_time; | |
1242 if ( new_travel_time < 1 ) | |
1243 new_travel_time = 1; | |
1244 return new_travel_time; | |
1245 } | |
1246 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; | |
1247 | |
1248 //----- (00449B57) -------------------------------------------------------- | |
1249 bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2) | |
1250 { | |
1251 return (a1[(a2 - 1) >> 3] & (0x80 >> (a2 - 1) % 8)) != 0; | |
1252 } | |
1253 | |
1254 //----- (00449B7E) -------------------------------------------------------- | |
1255 void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle) | |
1256 { | |
1257 signed int v3; // esi@1 | |
1258 unsigned char set_bit; // edx@1 | |
1259 | |
1260 v3 = a2 - 1; | |
1261 set_bit = 0x80 >> v3 % 8; | |
1262 if (bToggle) | |
1263 pArray[v3 / 8] |= set_bit; | |
1264 else | |
1265 pArray[v3 / 8] &= ~set_bit; | |
1266 } | |
1267 | |
1268 //----- (004760D5) -------------------------------------------------------- | |
1269 PartyAction ActionQueue::Next() | |
1270 { | |
1271 if (!uNumActions) | |
1272 return PARTY_INVALID; | |
1273 | |
1274 PartyAction result = pActions[0]; | |
1275 for (unsigned int i = 0; i < uNumActions - 1; ++i) | |
1276 pActions[i] = pActions[i + 1]; | |
1277 --uNumActions; | |
1278 | |
1279 return result; | |
1280 } |