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