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