Mercurial > mm7
annotate Party.cpp @ 1306:13b7be8b06a0
Слияние
author | Ritor1 |
---|---|
date | Sun, 23 Jun 2013 14:27:57 +0600 |
parents | 5450af4f57ef |
children | 0665a061132b |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1071
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1071
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1071
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1071
diff
changeset
|
4 |
130 | 5 #include <assert.h> |
6 | |
0 | 7 #include "Party.h" |
8 #include "MapInfo.h" | |
9 #include "Time.h" | |
10 #include "AudioPlayer.h" | |
11 #include "IconFrameTable.h" | |
12 #include "Mouse.h" | |
13 #include "PlayerFrameTable.h" | |
14 #include "TurnEngine.h" | |
15 #include "Viewport.h" | |
16 #include "Actor.h" | |
17 #include "GUIWindow.h" | |
189 | 18 #include "texts.h" |
0 | 19 |
20 #include "mm7_data.h" | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
783
diff
changeset
|
21 #include "MM7.h" |
1295 | 22 #include "Outdoor.h" |
23 #include "Indoor.h" | |
1297 | 24 #include "Texture.h" |
25 #include "LOD.h" | |
26 #include "Sprites.h" | |
27 #include "SpriteObject.h" | |
28 #include "ObjectList.h" | |
0 | 29 |
30 Party *pParty; // idb | |
31 | |
32 struct ActionQueue *pPartyActionQueue = new ActionQueue; | |
33 | |
34 | |
35 | |
1035 | 36 |
37 | |
38 //----- (0044A56A) -------------------------------------------------------- | |
39 void Party::CountHirelings() | |
40 { | |
41 field_70A = 0; | |
42 | |
43 for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i) | |
44 { | |
45 auto npc = pNPCStats->pNewNPCData + i; | |
46 if (npc->Hired() && | |
47 (!pHirelings[0].pName || strcmp(npc->pName, pHirelings[0].pName))) | |
48 { | |
49 if (!pHirelings[1].pName || strcmp(npc->pName, pHirelings[1].pName)) | |
50 ++field_70A; | |
51 } | |
52 } | |
53 } | |
54 | |
55 | |
783 | 56 // inlined |
57 //----- (mm6c::004858D0) -------------------------------------------------- | |
58 void Party::Zero() | |
59 { | |
60 | |
61 uFlags2 = 0; | |
62 uNumGoldInBank = 0; | |
63 | |
64 uCurrentYear = 0; | |
65 uCurrentMonth = 0; | |
66 uCurrentMonthWeek = 0; | |
67 uDaysPlayed = 0; | |
68 uCurrentHour = 0; | |
69 uCurrentMinute = 0; | |
70 uCurrentTimeSecond = 0; | |
71 | |
72 field_6FC = 0; | |
73 days_played_without_rest = 0; | |
74 | |
75 vPosition.y = 0; | |
76 vPosition.z = 0; | |
77 vPosition.x = 0; | |
78 uFallStartY = 0; | |
79 sRotationY = 0; | |
80 sRotationX = 0; | |
81 uFallSpeed = 0; | |
82 field_28 = 0; | |
83 uDefaultPartyHeight = 120; | |
84 field_14 = 37; | |
85 y_rotation_granularity = 25; | |
86 uWalkSpeed = 384; | |
87 y_rotation_speed = 90; | |
88 field_24 = 5; | |
89 field_6FC = 0; | |
90 field_708 = 15; | |
91 field_0 = 25; | |
92 } | |
93 | |
94 //inlined | |
95 //----- (mm6c::0045BE90) -------------------------------------------------- | |
96 void ActionQueue::Reset() | |
97 { | |
98 uNumActions = 0; | |
99 } | |
0 | 100 |
101 //----- (004760C1) -------------------------------------------------------- | |
102 void ActionQueue::Add(PartyAction action) | |
103 { | |
104 if (uNumActions < 30) | |
105 pActions[uNumActions++] = action; | |
106 } | |
107 | |
108 //----- (00497FC5) -------------------------------------------------------- | |
109 bool Party::_497FC5_check_party_perception_against_level() | |
110 { | |
111 int uMaxPerception; // edi@1 | |
112 Player *v2; // esi@1 | |
113 signed int v3; // ebx@1 | |
114 Player *v4; // ecx@2 | |
115 signed int v5; // eax@3 | |
116 bool result; // eax@7 | |
117 | |
118 uMaxPerception = 0; | |
119 v2 = this->pPlayers; | |
120 v3 = 4; | |
121 do | |
122 { | |
123 if ( v2->CanAct() ) | |
124 { | |
125 v5 = v2->GetPerception(); | |
126 if ( v5 > uMaxPerception ) | |
127 uMaxPerception = v5; | |
128 } | |
129 ++v2; | |
130 --v3; | |
131 } | |
132 while ( v3 ); | |
133 if ( uLevelMapStatsID && (signed int)uLevelMapStatsID < 77 ) | |
134 result = uMaxPerception >= 2 * pMapStats->pInfos[uLevelMapStatsID]._per; | |
135 else | |
136 result = 0; | |
137 return result; | |
138 } | |
139 | |
140 //----- (004936E1) -------------------------------------------------------- | |
141 void Party::SetHoldingItem(ItemGen *pItem) | |
142 { | |
143 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
201 | 144 memcpy(&pPickedItem, pItem, sizeof(pPickedItem)); |
145 pMouse->SetCursorBitmapFromItemID(pPickedItem.uItemID); | |
0 | 146 } |
147 | |
148 //----- (0049370F) -------------------------------------------------------- | |
149 int Party::GetNextActiveCharacter() | |
150 { | |
151 Party *v1; // esi@1 | |
152 int v2; // eax@4 | |
153 signed int v4; // ecx@6 | |
89 | 154 Player *v5; // edx@6 |
0 | 155 Player *v6; // eax@7 |
89 | 156 Player *v7; // ecx@23 |
0 | 157 signed int v8; // esi@23 |
158 signed int v9; // edx@23 | |
159 Player **v10; // edi@23 | |
160 Player *v11; // eax@24 | |
161 int v12; // [sp+Ch] [bp-4h]@1 | |
162 | |
163 v1 = this; | |
164 v12 = 0; | |
165 if ( pParty->bTurnBasedModeOn == 1 ) | |
166 { | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
783
diff
changeset
|
167 if ( pTurnEngine->field_4 != 2 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) != OBJECT_Player) |
0 | 168 return 0; |
848 | 169 v2 = PID_ID(pTurnEngine->pQueue[0].uPackedID); |
0 | 170 return v2 + 1; |
171 } | |
172 v4 = 0; | |
89 | 173 v5 = v1->pPlayers;//[0].uTimeToRecovery; |
0 | 174 while ( 1 ) |
175 { | |
176 v6 = ::pPlayers[v4 + 1]; | |
177 if ( v6->pConditions[2] | |
178 || v6->pConditions[12] | |
179 || v6->pConditions[13] | |
180 || v6->pConditions[14] | |
181 || v6->pConditions[15] | |
182 || v6->pConditions[16] | |
89 | 183 || v5->uTimeToRecovery ) |
0 | 184 { |
185 byte_AE3368[v4] = 1; | |
186 } | |
89 | 187 else if ( !byte_AE3368[v4] ) |
0 | 188 break; |
189 ++v4; | |
89 | 190 ++v5; |
0 | 191 if ( v4 >= 4 ) |
89 | 192 break; |
0 | 193 } |
89 | 194 if(v4<4) |
195 { | |
196 v12 = v4; | |
197 byte_AE3368[v4] = 1; | |
198 } | |
0 | 199 if ( (unsigned __int8)(byte_AE3369 & byte_AE336A & byte_AE336B) & byte_AE3368[0] ) |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
200 memset(byte_AE3368.data(), 0, 4u); |
0 | 201 v2 = v12; |
202 if ( v12 ) | |
203 return v2 + 1; | |
89 | 204 v7 = v1->pPlayers;//[0].uSpeedBonus; |
0 | 205 v8 = 0; |
206 v9 = 1; | |
207 v10 = &::pPlayers[1]; | |
208 while ( 2 ) | |
209 { | |
210 v11 = *v10; | |
211 if ( !(*v10)->pConditions[2] | |
212 && !v11->pConditions[12] | |
213 && !v11->pConditions[13] | |
214 && !v11->pConditions[14] | |
215 && !v11->pConditions[15] | |
216 && !v11->pConditions[16] | |
89 | 217 && !v7->uTimeToRecovery ) |
0 | 218 { |
219 if ( v12 ) | |
220 { | |
89 | 221 if ( v7->uSpeedBonus > v8 ) |
0 | 222 { |
89 | 223 v8 = v7->uSpeedBonus; |
224 v12 = v9; | |
0 | 225 } |
226 } | |
227 else | |
228 { | |
229 v8 = *(short *)v7; | |
230 v12 = v9; | |
231 } | |
232 } | |
233 ++v10; | |
234 ++v9; | |
89 | 235 ++v7; |
0 | 236 if ( v9 - 1 < 4 ) |
237 continue; | |
238 return v12; | |
239 } | |
240 } | |
241 | |
242 | |
243 //----- (00493244) -------------------------------------------------------- | |
244 bool Party::HasItem(unsigned int uItemID) | |
245 { | |
89 | 246 Player *v2; // edx@1 |
0 | 247 signed int v3; // ecx@2 |
248 ItemGen *v4; // eax@2 | |
249 | |
89 | 250 v2 = pParty->pPlayers;//[0].pInventoryItems; |
251 while ( v2 <= &pParty->pPlayers[3] ) | |
0 | 252 { |
253 v3 = 0; | |
89 | 254 v4 = v2->pInventoryItems; |
0 | 255 do |
256 { | |
257 if ( v4->uItemID == uItemID ) | |
258 return 1; | |
259 ++v3; | |
260 ++v4; | |
261 } | |
262 while ( v3 < 138 ); | |
89 | 263 ++v2; |
0 | 264 } |
265 return 0; | |
266 } | |
267 | |
268 | |
269 //----- (00492AD5) -------------------------------------------------------- | |
593 | 270 void Party::SetFood(unsigned int uNumFood) |
0 | 271 { |
272 pUIAnim_Food->uAnimTime = 0; | |
273 pParty->uNumFoodRations = uNumFood; | |
592 | 274 pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; |
0 | 275 } |
276 | |
277 //----- (00492B03) -------------------------------------------------------- | |
278 void Party::TakeFood(unsigned int uNumFood) | |
279 { | |
592 | 280 if (pParty->uNumFoodRations <= uNumFood) |
281 pParty->uNumFoodRations = 0; | |
0 | 282 else |
592 | 283 pParty->uNumFoodRations -= uNumFood; |
284 | |
0 | 285 pUIAnim_Food->uAnimTime = 0; |
592 | 286 pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; |
0 | 287 } |
288 | |
289 //----- (00492B42) -------------------------------------------------------- | |
592 | 290 void Party::GiveFood(unsigned int _this) |
0 | 291 { |
292 pParty->uNumFoodRations += _this; | |
293 pUIAnim_Food->uAnimTime = 0; | |
592 | 294 pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; |
0 | 295 } |
296 | |
297 //----- (00492B70) -------------------------------------------------------- | |
298 void Party::SetGold(unsigned int uNumGold) | |
299 { | |
300 pParty->uNumGold = uNumGold; | |
301 pUIAnim_Gold->uAnimTime = 0; | |
592 | 302 pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; |
0 | 303 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); |
304 } | |
305 | |
306 //----- (00492BB6) -------------------------------------------------------- | |
307 void Party::TakeGold(unsigned int uNumGold) | |
308 { | |
309 if ( uNumGold <= pParty->uNumGold ) | |
310 pParty->uNumGold -= uNumGold; | |
311 else | |
312 pParty->uNumGold = 0; | |
313 pUIAnim_Gold->uAnimTime = 0; | |
592 | 314 pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; |
0 | 315 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); |
316 } | |
317 | |
318 //----- (0049135E) -------------------------------------------------------- | |
319 unsigned int Party::GetPartyFame() | |
320 { | |
566 | 321 unsigned __int64 total_exp = 0; |
322 for (uint i = 0; i < 4; ++i) | |
323 total_exp += pPlayers[i].uExperience; | |
324 return total_exp / 1000; | |
0 | 325 } |
326 | |
327 //----- (0049137D) -------------------------------------------------------- | |
328 void Party::CreateDefaultParty(char bGiveItems) | |
329 { | |
330 Party *pParty; // esi@1 | |
331 signed __int16 v3; // ax@1 | |
135 | 332 //int pResMagicBase; // ecx@1 |
0 | 333 Player *pCharacter; // esi@3 |
321 | 334 //signed int uSpellBookPageCount; // edx@5 |
0 | 335 int pMagicSkills; // eax@5 |
336 int uSkillIdx; // eax@11 | |
337 //unsigned __int8 v9; // zf@37 | |
338 //char v10; // sf@37 | |
339 //unsigned __int8 v11; // of@37 | |
1071 | 340 ItemGen *pItems; // eax@38 |
0 | 341 signed int v13; // ecx@38 |
342 int uMaxSP; // eax@42 | |
343 unsigned int v15; // [sp-4h] [bp-44h]@14 | |
344 unsigned int v16; // [sp-4h] [bp-44h]@26 | |
345 int v17; // [sp+10h] [bp-30h]@1 | |
346 int v18; // [sp+14h] [bp-2Ch]@11 | |
347 signed int uNumPlayers; // [sp+18h] [bp-28h]@1 | |
348 ItemGen Dst; // [sp+1Ch] [bp-24h]@10 | |
349 | |
130 | 350 |
0 | 351 pParty = this; |
130 | 352 |
353 pHireling1Name[0] = 0; | |
354 pHireling2Name[0] = 0; | |
134 | 355 pParty->field_709 = 0; |
130 | 356 memset(pHirelings, 0, 2 * sizeof(*pHirelings)); |
357 | |
0 | 358 strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); //Zoltan |
1014 | 359 pParty->pPlayers[0].uPrevFace = 17; |
360 pParty->pPlayers[0].uCurrentFace = 17; | |
361 pParty->pPlayers[0].uPrevVoiceID = 17; | |
0 | 362 pParty->pPlayers[0].uVoiceID = 17; |
363 pParty->pPlayers[0].uMight = 30; | |
364 pParty->pPlayers[0].uIntelligence = 5; | |
365 pParty->pPlayers[0].uWillpower = 5; | |
366 pParty->pPlayers[0].uEndurance = 13; | |
367 pParty->pPlayers[0].uAccuracy = 13; | |
368 pParty->pPlayers[0].uSpeed = 14; | |
369 pParty->pPlayers[0].uLuck = 7; | |
135 | 370 pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather |
371 pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1; // armsmaster | |
372 pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1; // bow | |
373 pParty->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1; // sword | |
1014 | 374 pParty->pPlayers[1].uPrevFace = 3; |
375 pParty->pPlayers[1].uCurrentFace = 3; | |
376 pParty->pPlayers[1].uPrevVoiceID = 3; | |
0 | 377 pParty->pPlayers[1].uVoiceID = 3; |
378 strcpy(pParty->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); //Roderic | |
379 pParty->pPlayers[1].uMight = 13; | |
380 pParty->pPlayers[1].uIntelligence = 9; | |
381 pParty->pPlayers[1].uWillpower = 9; | |
382 pParty->pPlayers[1].uEndurance = 13; | |
383 pParty->pPlayers[1].uAccuracy = 13; | |
384 pParty->pPlayers[1].uSpeed = 13; | |
385 pParty->pPlayers[1].uLuck = 13; | |
135 | 386 pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather |
387 pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1; // stealing | |
388 pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1; // dagger | |
389 pParty->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1; // disarm trap | |
1014 | 390 pParty->pPlayers[2].uPrevFace = 14; |
391 pParty->pPlayers[2].uCurrentFace = 14; | |
392 pParty->pPlayers[2].uPrevVoiceID = 14; | |
0 | 393 pParty->pPlayers[2].uVoiceID = 14; |
394 strcpy(pParty->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena | |
395 pParty->pPlayers[2].uMight = 12; | |
396 pParty->pPlayers[2].uIntelligence = 9; | |
397 pParty->pPlayers[2].uWillpower = 20; | |
398 pParty->pPlayers[2].uEndurance = 22; | |
399 pParty->pPlayers[2].uAccuracy = 7; | |
400 pParty->pPlayers[2].uSpeed = 13; | |
401 pParty->pPlayers[2].uLuck = 7; | |
135 | 402 pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1; // alchemy |
403 pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather | |
404 pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1; // body | |
405 pParty->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1; // mace | |
0 | 406 strcpy(pParty->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis |
407 v3 = 10; | |
1014 | 408 pParty->pPlayers[3].uPrevFace = 10; |
409 pParty->pPlayers[3].uCurrentFace = 10; | |
135 | 410 //pResMagicBase = (int)&pParty->pPlayers[0].sResMagicBase; |
0 | 411 pParty->pPlayers[3].uEndurance = 13; |
412 pParty->pPlayers[3].uAccuracy = 13; | |
413 pParty->pPlayers[3].uSpeed = 13; | |
1014 | 414 pParty->pPlayers[3].uPrevVoiceID = 10; |
0 | 415 pParty->pPlayers[3].uVoiceID = 10; |
416 pParty->pPlayers[3].uMight = 5; | |
417 pParty->pPlayers[3].uIntelligence = 30; | |
418 pParty->pPlayers[3].uWillpower = 9; | |
419 pParty->pPlayers[3].uLuck = 7; | |
135 | 420 pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather |
421 pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_AIR] = 1; // air | |
422 pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_FIRE] = 1; // fire | |
423 pParty->pPlayers[3].pActiveSkills[PLAYER_SKILL_STAFF] = 1; // staff | |
0 | 424 //uNumPlayers = 4; |
425 //while ( 1 ) | |
426 for (uNumPlayers = 0; uNumPlayers < 4; uNumPlayers++) | |
427 { | |
135 | 428 pCharacter = &pParty->pPlayers[uNumPlayers]; |
429 if (pCharacter->classType == PLAYER_CLASS_KNIGHT) | |
430 pCharacter->sResMagicBase = v3; //player[i].pResMagicBase | |
321 | 431 //uSpellBookPageCount = 0; |
0 | 432 //pMagicSkills = pPlayers[uNumPlayers].pActiveSkills[12];// Skills |
433 //while ( !*(short *)pMagicSkills ) //player[i].skillFire | |
321 | 434 pCharacter->lastOpenedSpellbookPage = 0; |
0 | 435 for (int i = 0; i < 9; i++)//for Magic Book |
436 { | |
437 //++uSpellBookPageCount; | |
438 //pMagicSkills++; | |
439 //if ( uSpellBookPageCount >= 9 ) | |
440 //goto LABEL_10; | |
441 if (pPlayers[uNumPlayers].pActiveSkills[12+i]) | |
321 | 442 { |
443 pCharacter->lastOpenedSpellbookPage = i; | |
444 break; | |
445 } | |
0 | 446 } |
447 //LABEL_10: | |
448 pCharacter->uExpressionTimePassed = 0; | |
449 Dst.Reset(); | |
450 if ( bGiveItems ) | |
451 { | |
439 | 452 pItemsTable->GenerateItem(2, 40, &Dst); //ring |
0 | 453 pCharacter->AddItem2(-1, &Dst); |
454 //uSkillIdx = 0; | |
455 //v18 = 0; | |
456 //do | |
457 for (uSkillIdx = 0; uSkillIdx < 36; uSkillIdx++) | |
458 { | |
459 if ( pCharacter->pActiveSkills[uSkillIdx] ) | |
460 { | |
461 switch ( uSkillIdx ) | |
462 { | |
463 case PLAYER_SKILL_STAFF: | |
464 v15 = ITEM_STAFF_1; | |
465 pCharacter->WearItem(v15); | |
466 break; | |
467 case PLAYER_SKILL_SWORD: | |
468 v15 = ITEM_LONGSWORD_1; | |
469 pCharacter->WearItem(v15); | |
470 break; | |
471 case PLAYER_SKILL_DAGGER: | |
472 v15 = ITEM_DAGGER_1; | |
473 pCharacter->WearItem(v15); | |
474 break; | |
475 case PLAYER_SKILL_AXE: | |
476 v15 = ITEM_AXE_1; | |
477 pCharacter->WearItem(v15); | |
478 break; | |
479 case PLAYER_SKILL_SPEAR: | |
480 v15 = ITEM_SPEAR_1; | |
481 pCharacter->WearItem(v15); | |
482 break; | |
483 case PLAYER_SKILL_BOW: | |
484 v15 = ITEM_CROSSBOW_1; | |
485 pCharacter->WearItem(v15); | |
486 break; | |
487 case PLAYER_SKILL_MACE: | |
488 v15 = ITEM_MACE_1; | |
489 pCharacter->WearItem(v15); | |
490 break; | |
491 case PLAYER_SKILL_SHIELD: | |
492 v15 = ITEM_BUCKLER_1; | |
493 pCharacter->WearItem(v15); | |
494 break; | |
495 case PLAYER_SKILL_LEATHER: | |
496 v15 = ITEM_LEATHER_1; | |
497 pCharacter->WearItem(v15); | |
498 break; | |
499 case PLAYER_SKILL_CHAIN: | |
500 v15 = ITEM_CHAINMAIL_1; | |
501 pCharacter->WearItem(v15); | |
502 break; | |
503 case PLAYER_SKILL_PLATE: | |
504 v15 = ITEM_PLATE_1; | |
505 pCharacter->WearItem(v15); | |
506 break; | |
507 case PLAYER_SKILL_FIRE: | |
508 v16 = ITEM_SPELLBOOK_FIRE_STRIKE; | |
509 pCharacter->AddItem(-1, v16); | |
510 break; | |
511 case PLAYER_SKILL_AIR: | |
512 v16 = ITEM_SPELLBOOK_AIR_FEATHER_FALL; | |
513 pCharacter->AddItem(-1, v16); | |
514 break; | |
515 case PLAYER_SKILL_WATER: | |
516 v16 = ITEM_SPELLBOOK_WATER_POISON_SPRAY; | |
517 pCharacter->AddItem(-1, v16); | |
518 break; | |
519 case PLAYER_SKILL_EARTH: | |
520 v16 = ITEM_SPELLBOOK_EARTH_SLOW; | |
521 pCharacter->AddItem(-1, v16); | |
522 break; | |
523 case PLAYER_SKILL_SPIRIT: | |
524 v16 = ITEM_SPELLBOOK_SPIRIT_BLESS; | |
525 pCharacter->AddItem(-1, v16); | |
526 break; | |
527 case PLAYER_SKILL_MIND: | |
528 v16 = ITEM_SPELLBOOK_MIND_MIND_BLAST; | |
529 pCharacter->AddItem(-1, v16); | |
530 break; | |
531 case PLAYER_SKILL_BODY: | |
532 v16 = ITEM_SPELLBOOK_BODY_FIRST_AID; | |
533 pCharacter->AddItem(-1, v16); | |
534 break; | |
535 case PLAYER_SKILL_ITEM_ID: | |
536 case PLAYER_SKILL_REPAIR: | |
537 case PLAYER_SKILL_MEDITATION: | |
538 case PLAYER_SKILL_PERCEPTION: | |
539 case PLAYER_SKILL_DIPLOMACY: | |
540 case PLAYER_SKILL_TRAP_DISARM: | |
541 case PLAYER_SKILL_LEARNING: | |
542 pCharacter->AddItem(-1, ITEM_POTION_BOTTLE); | |
543 v16 = 5 * (rand() % 3 + 40); // simple reagent | |
544 pCharacter->AddItem(-1, v16); | |
545 break; | |
546 case PLAYER_SKILL_DODGE: | |
547 v16 = ITEM_BOOTS_1; | |
548 pCharacter->AddItem(-1, v16); | |
549 break; | |
550 case PLAYER_SKILL_UNARMED: | |
551 v16 = ITEM_GAUNTLETS_1; | |
552 pCharacter->AddItem(-1, v16); | |
553 break; | |
554 default: | |
555 break; | |
556 } | |
557 } | |
558 //uSkillIdx = v18 + 1; | |
559 //v11 = uSkillIdx > 36; | |
560 //v9 = v18 == 35; | |
561 //v10 = uSkillIdx - 35 < 0; | |
562 } | |
563 //while (uSkillIdx < 36); | |
1071 | 564 pItems = pCharacter->pInventoryItems; |
0 | 565 //v13 = 138; |
1071 | 566 for (int i = 0; i < 138; i++) |
0 | 567 { |
1071 | 568 if ( pItems->uItemID ) |
569 pItems->uAttributes |= 1; | |
570 ++pItems; | |
0 | 571 //--v13; |
572 } | |
573 //while ( v13 ); | |
574 } | |
575 pCharacter->sHealth = pCharacter->GetMaxHealth(); | |
576 pCharacter->sMana = pCharacter->GetMaxMana(); | |
135 | 577 //pCharacter++; |
0 | 578 //uNumPlayers--; |
579 //if (!uNumPlayers) | |
580 //break; | |
135 | 581 //pResMagicBase = (int)pCharacter; |
0 | 582 v3 = 10; |
583 } | |
584 } | |
585 | |
586 //----- (004917CE) -------------------------------------------------------- | |
587 int Party::Reset() | |
588 { | |
589 //Party *v1; // esi@1 | |
590 //unsigned __int64 *pTimePlayed; // edi@1 | |
591 //bool v3; // edx@1 | |
592 //Player **v4; // eax@1 | |
593 //Player *v5; // ecx@1 | |
594 PLAYER_SEX pSex; // cl@3 | |
595 PLAYER_SEX v7; // al@6 | |
596 PLAYER_SEX v8; // al@9 | |
597 PLAYER_SEX v9; // cl@12 | |
598 //Player *v12; // edx@17 | |
599 //signed int v13; // edi@18 | |
600 SpellBuff *v14; // ebx@21 | |
601 signed int v15; // edi@21 | |
783 | 602 |
603 Zero(); | |
0 | 604 |
605 field_708 = 15; | |
606 sEyelevel = 160; | |
607 uNumGold = 200; | |
608 uNumFoodRations = 7; | |
609 | |
783 | 610 |
373 | 611 alignment = PartyAlignment_Neutral; |
612 SetUserInterface(alignment, true); | |
0 | 613 |
614 uTimePlayed = 0x21C00u; | |
615 uLastRegenerationTime = 0x21C00; | |
616 | |
617 bTurnBasedModeOn = false; | |
618 | |
619 uActiveCharacter = 1; | |
620 ::pPlayers[0] = pPlayers; | |
621 for (uint i = 0; i < 4; ++i) | |
622 ::pPlayers[i + 1] = &pPlayers[i]; | |
623 | |
135 | 624 pPlayers[0].Reset(PLAYER_CLASS_KNIGHT); |
625 pPlayers[1].Reset(PLAYER_CLASS_THEIF); | |
626 pPlayers[2].Reset(PLAYER_CLASS_CLERIC); | |
627 pPlayers[3].Reset(PLAYER_CLASS_SORCERER); | |
1014 | 628 pPlayers[0].uCurrentFace = 17; |
629 pPlayers[0].uPrevVoiceID = 17; | |
0 | 630 pPlayers[0].uVoiceID = 17; |
631 pPlayers[0].SetInitialStats(); | |
632 | |
633 switch ( pPlayers[0].uVoiceID ) | |
634 { | |
635 case 0: | |
636 case 1: | |
637 case 2: | |
638 case 3: | |
639 case 8: | |
640 case 9: | |
641 case 12: | |
642 case 13: | |
643 case 16: | |
644 case 17: | |
645 case 20: | |
646 case 23: | |
647 default: | |
648 pSex = SEX_MALE; | |
649 break; | |
650 case 4: | |
651 case 5: | |
652 case 6: | |
653 case 7: | |
654 case 10: | |
655 case 11: | |
656 case 14: | |
657 case 15: | |
658 case 18: | |
659 case 19: | |
660 case 21: | |
661 case 24: | |
662 pSex = SEX_FEMALE; | |
663 break; | |
664 } | |
665 pPlayers[0].uSex = pSex; | |
666 pPlayers[0].RandomizeName(); | |
667 strcpy(pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); | |
668 | |
669 | |
1014 | 670 pPlayers[1].uCurrentFace = 3; |
671 pPlayers[1].uPrevVoiceID = 3; | |
0 | 672 pPlayers[1].uVoiceID = 3; |
673 pPlayers[1].SetInitialStats(); | |
674 v7 = SEX_MALE; | |
675 switch (pPlayers[1].uVoiceID) | |
676 { | |
677 case 0: | |
678 case 1: | |
679 case 2: | |
680 case 3: | |
681 case 8: | |
682 case 9: | |
683 case 0xCu: | |
684 case 0xDu: | |
685 case 0x10u: | |
686 case 0x11u: | |
687 case 0x14u: | |
688 case 0x17u: | |
689 v7 = SEX_MALE; | |
690 break; | |
691 case 4: | |
692 case 5: | |
693 case 6: | |
694 case 7: | |
695 case 0xAu: | |
696 case 0xBu: | |
697 case 0xEu: | |
698 case 0xFu: | |
699 case 0x12u: | |
700 case 0x13u: | |
701 case 0x15u: | |
702 case 0x18u: | |
703 v7 = SEX_FEMALE; | |
704 break; | |
705 default: | |
706 break; | |
707 } | |
708 pPlayers[1].uSex = v7; | |
709 pPlayers[1].RandomizeName(); | |
710 strcpy(pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); | |
1014 | 711 pPlayers[2].uCurrentFace = 14; |
712 pPlayers[2].uPrevVoiceID = 14; | |
0 | 713 pPlayers[2].uVoiceID = 14; |
714 pPlayers[2].SetInitialStats(); | |
715 v8 = SEX_MALE; | |
716 switch (pPlayers[2].uVoiceID) | |
717 { | |
718 case 0: | |
719 case 1: | |
720 case 2: | |
721 case 3: | |
722 case 8: | |
723 case 9: | |
724 case 0xCu: | |
725 case 0xDu: | |
726 case 0x10u: | |
727 case 0x11u: | |
728 case 0x14u: | |
729 case 0x17u: | |
730 v8 = SEX_MALE; | |
731 break; | |
732 case 4: | |
733 case 5: | |
734 case 6: | |
735 case 7: | |
736 case 0xAu: | |
737 case 0xBu: | |
738 case 0xEu: | |
739 case 0xFu: | |
740 case 0x12u: | |
741 case 0x13u: | |
742 case 0x15u: | |
743 case 0x18u: | |
744 v8 = SEX_FEMALE; | |
745 break; | |
746 default: | |
747 break; | |
748 } | |
749 pPlayers[2].uSex = v8; | |
750 pPlayers[2].RandomizeName(); | |
751 strcpy(pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); | |
1014 | 752 pPlayers[3].uCurrentFace = 10; |
753 pPlayers[3].uPrevVoiceID = 10; | |
0 | 754 pPlayers[3].uVoiceID = 10; |
755 pPlayers[3].SetInitialStats(); | |
756 v9 = SEX_MALE; | |
757 switch (pPlayers[3].uVoiceID) | |
758 { | |
759 case 0u: | |
760 case 1u: | |
761 case 2u: | |
762 case 3u: | |
763 case 8u: | |
764 case 9u: | |
765 case 0xCu: | |
766 case 0xDu: | |
767 case 0x10u: | |
768 case 0x11u: | |
769 case 0x14u: | |
770 case 0x17u: | |
771 v9 = SEX_MALE; | |
772 break; | |
773 case 4u: | |
774 case 5u: | |
775 case 6u: | |
776 case 7u: | |
777 case 0xAu: | |
778 case 0xBu: | |
779 case 0xEu: | |
780 case 0xFu: | |
781 case 0x12u: | |
782 case 0x13u: | |
783 case 0x15u: | |
784 case 0x18u: | |
785 v9 = SEX_FEMALE; | |
786 break; | |
787 default: | |
788 break; | |
789 } | |
790 pPlayers[3].uSex = v9; | |
791 pPlayers[3].RandomizeName(); | |
792 strcpy(pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); | |
793 | |
794 | |
795 | |
796 for (uint i = 0; i < 4; ++i) | |
797 { | |
798 pPlayers[i].uTimeToRecovery = 0; | |
799 for (uint j = 0; j < 20; ++j) | |
800 pPlayers[i].pConditions[j] = 0; | |
801 | |
802 for (uint j = 0; j < 24; ++j) | |
803 pPlayers[i].pPlayerBuffs[j].Reset(); | |
804 | |
130 | 805 pPlayers[i].expression = CHARACTER_EXPRESSION_1; |
0 | 806 pPlayers[i].uExpressionTimePassed = 0; |
807 pPlayers[i].uExpressionTimeLength = rand() % 256 + 128; | |
808 } | |
809 | |
810 for (uint i = 1; i < 20; ++i) | |
811 pPartyBuffs[i].Reset(); | |
812 | |
813 | |
1035 | 814 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100; // default character ui - stats |
0 | 815 uFlags = 0; |
484 | 816 memset(_autonote_bits, 0, 12); |
817 memset(_quest_bits, 0, 64); | |
598 | 818 memset(pIsArtifactFound, 0, 29); |
1035 | 819 _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_RED_POTION_ACTIVE, 1); |
820 _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_SEASHELL_ACTIVE, 1); | |
821 _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LONGBOW_ACTIVE, 1); | |
822 _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_PLATE_ACTIVE, 1); | |
823 _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LUTE_ACTIVE, 1); | |
824 _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_HAT_ACTIVE, 1); | |
0 | 825 |
487 | 826 memset(field_3C._shop_ban_times,0,53*sizeof(__int64)); |
0 | 827 |
828 memcpy(pNPCStats->pNewNPCData, pNPCStats->pNPCData, 0x94BCu); | |
829 memcpy(pNPCStats->pGroups_copy, pNPCStats->pGroups, 0x66u); | |
655 | 830 pNPCStats->pNewNPCData[3].uFlags |= 128;//|= 0x80u; Lady Margaret |
0 | 831 _494035_timed_effects__water_walking_damage__etc(); |
832 pEventTimer->Pause(); | |
833 return 0; | |
834 } | |
835 | |
836 | |
837 //----- (0043AD34) -------------------------------------------------------- | |
838 void Party::Yell() | |
839 { | |
90 | 840 Actor *v0; // esi@5 |
0 | 841 int v1; // edi@9 |
842 int v2; // ebx@9 | |
843 int v3; // eax@9 | |
844 unsigned int v4; // [sp+8h] [bp-4h]@4 | |
845 | |
1167 | 846 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ) |
847 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
0 | 848 if ( pParty->bTurnBasedModeOn != 1 ) |
849 { | |
850 v4 = 0; | |
851 if ( (signed int)uNumActors > 0 ) | |
852 { | |
1202 | 853 v0 = pActors.data();//[0].pMonsterInfo.uMovementType; |
0 | 854 do |
855 { | |
1035 | 856 if ( v0->Actor::CanAct() && v0->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long && v0->pMonsterInfo.uMovementType != 5 ) |
0 | 857 { |
90 | 858 v1 = abs(v0->vPosition.x - pParty->vPosition.x); |
859 v2 = abs(v0->vPosition.y - pParty->vPosition.y); | |
860 v3 = abs(v0->vPosition.z - pParty->vPosition.z); | |
322 | 861 if (int_get_vector_length(v1, v2, v3) < 512) |
1060 | 862 Actor::AI_Flee(v4, 4, 0, 0); |
0 | 863 } |
864 ++v4; | |
90 | 865 ++v0; |
0 | 866 } |
867 while ( (signed int)v4 < (signed int)uNumActors ); | |
868 } | |
869 } | |
870 } | |
871 | |
872 //----- (00491BF9) -------------------------------------------------------- | |
873 void Party::ResetPosMiscAndSpellBuffs() | |
874 { | |
875 Party *v1; // esi@1 | |
89 | 876 Player *v2; // edi@1 |
0 | 877 SpellBuff *v3; // ebx@2 |
878 SpellBuff *v4; // esi@5 | |
879 signed int v5; // edi@5 | |
880 signed int v6; // [sp+8h] [bp-8h]@1 | |
881 signed int v7; // [sp+Ch] [bp-4h]@2 | |
882 | |
883 v1 = this; | |
884 this->vPosition.y = 0; | |
885 this->vPosition.z = 0; | |
886 this->vPosition.x = 0; | |
887 this->uFallStartY = 0; | |
888 this->sRotationY = 0; | |
889 this->sRotationX = 0; | |
890 this->uFallSpeed = 0; | |
891 this->field_28 = 0; | |
892 this->uDefaultPartyHeight = 120; | |
893 this->field_14 = 37; | |
120 | 894 this->y_rotation_granularity = 25; |
0 | 895 this->uWalkSpeed = 384; |
122 | 896 this->y_rotation_speed = 90; |
0 | 897 this->field_24 = 5; |
898 this->field_6FC = 0; | |
899 this->field_708 = 15; | |
900 this->field_0 = 25; | |
89 | 901 v2 = this->pPlayers;//[0].pPlayerBuffs; |
0 | 902 v6 = 4; |
903 do | |
904 { | |
89 | 905 v3 = v2->pPlayerBuffs; |
0 | 906 v7 = 24; |
907 do | |
908 { | |
909 v3->Reset(); | |
910 ++v3; | |
911 --v7; | |
912 } | |
913 while ( v7 ); | |
89 | 914 ++v2; |
0 | 915 --v6; |
916 } | |
917 while ( v6 ); | |
918 v4 = v1->pPartyBuffs; | |
919 v5 = 20; | |
920 do | |
921 { | |
922 v4->Reset(); | |
923 ++v4; | |
924 --v5; | |
925 } | |
926 while ( v5 ); | |
927 } | |
928 | |
929 //----- (004909F4) -------------------------------------------------------- | |
130 | 930 void Party::UpdatePlayersAndHirelingsEmotions() |
0 | 931 { |
130 | 932 //Player *v1; // esi@2 |
933 //unsigned int v2; // eax@3 | |
934 //__int16 v3; // cx@5 | |
0 | 935 int v4; // edx@27 |
130 | 936 //signed int v5; // eax@52 |
937 //PlayerFrame *v6; // edx@53 | |
938 //NPCData *v7; // esi@60 | |
939 //signed int v8; // ebp@61 | |
940 //int v9; // ebx@62 | |
941 //unsigned int v10; // edi@62 | |
942 //signed int v11; // [sp+0h] [bp-4h]@2 | |
943 | |
944 //v1 = this->pPlayers;//(char *)&this->pPlayers[0].uExpressionID; | |
945 for (int i = 0; i < 4; ++i) | |
0 | 946 { |
130 | 947 auto player = pPlayers + i; |
948 player->uExpressionTimePassed += (unsigned short)pMiscTimer->uTimeElapsed; | |
949 | |
950 | |
951 auto condition = player->GetMajorConditionIdx(); | |
952 if (condition == Player::Condition_Good || condition == Player::Condition_Zombie) | |
0 | 953 { |
130 | 954 if (player->uExpressionTimePassed < player->uExpressionTimeLength) |
955 continue; | |
956 | |
957 player->uExpressionTimePassed = 0; | |
958 if (player->expression != 1 || rand() % 5) | |
0 | 959 { |
130 | 960 player->expression = CHARACTER_EXPRESSION_1; |
961 player->uExpressionTimeLength = rand() % 256 + 32; | |
0 | 962 } |
963 else | |
964 { | |
130 | 965 v4 = rand() % 100; |
966 if (v4 < 25) player->expression = CHARACTER_EXPRESSION_13; | |
967 else if (v4 < 31) player->expression = CHARACTER_EXPRESSION_14; | |
968 else if (v4 < 37) player->expression = CHARACTER_EXPRESSION_15; | |
969 else if (v4 < 43) player->expression = CHARACTER_EXPRESSION_16; | |
970 else if (v4 < 46) player->expression = CHARACTER_EXPRESSION_17; | |
971 else if (v4 < 52) player->expression = CHARACTER_EXPRESSION_18; | |
972 else if (v4 < 58) player->expression = CHARACTER_EXPRESSION_19; | |
973 else if (v4 < 64) player->expression = CHARACTER_EXPRESSION_20; | |
974 else if (v4 < 70) player->expression = CHARACTER_EXPRESSION_54; | |
975 else if (v4 < 76) player->expression = CHARACTER_EXPRESSION_55; | |
976 else if (v4 < 82) player->expression = CHARACTER_EXPRESSION_56; | |
977 else if (v4 < 88) player->expression = CHARACTER_EXPRESSION_57; | |
978 else if (v4 < 94) player->expression = CHARACTER_EXPRESSION_29; | |
979 else player->expression = CHARACTER_EXPRESSION_30; | |
980 } | |
981 | |
982 for (int j = 0; j < pPlayerFrameTable->uNumFrames; ++j) | |
983 { | |
984 auto frame = pPlayerFrameTable->pFrames + j; | |
985 if (frame->expression == player->expression) | |
0 | 986 { |
130 | 987 player->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[j].uAnimLength; |
988 break; | |
0 | 989 } |
990 } | |
991 } | |
130 | 992 else if (player->expression != 34 && |
993 player->expression != 35 && | |
994 player->expression != 36 || | |
995 player->uExpressionTimePassed >= player->uExpressionTimeLength) | |
0 | 996 { |
130 | 997 player->uExpressionTimeLength = 0; |
998 player->uExpressionTimePassed = 0; | |
999 | |
1000 switch (condition) | |
0 | 1001 { |
130 | 1002 case Player::Condition_Dead: player->expression = CHARACTER_EXPRESSION_DEAD; break; |
1003 case Player::Condition_Pertified: player->expression = CHARACTER_EXPRESSION_PERTIFIED; break; | |
1004 case Player::Condition_Eradicated: player->expression = CHARACTER_EXPRESSION_ERADICATED; break; | |
1005 case Player::Condition_Cursed: player->expression = CHARACTER_EXPRESSION_CURSED; break; | |
1006 case Player::Condition_Weak: player->expression = CHARACTER_EXPRESSION_WEAK; break; | |
1007 case Player::Condition_Sleep: player->expression = CHARACTER_EXPRESSION_SLEEP; break; | |
1008 case Player::Condition_Fear: player->expression = CHARACTER_EXPRESSION_FEAR; break; | |
1009 case Player::Condition_Drunk: player->expression = CHARACTER_EXPRESSION_DRUNK; break; | |
1010 case Player::Condition_Insane: player->expression = CHARACTER_EXPRESSION_INSANE; break; | |
1011 case Player::Condition_Poison1: | |
1012 case Player::Condition_Poison2: | |
1013 case Player::Condition_Poison3: player->expression = CHARACTER_EXPRESSION_POISONED; break; | |
1014 case Player::Condition_Disease1: | |
1015 case Player::Condition_Disease2: | |
1016 case Player::Condition_Disease3: player->expression = CHARACTER_EXPRESSION_DISEASED; break; | |
1017 case Player::Condition_Paralyzed: player->expression = CHARACTER_EXPRESSION_PARALYZED; break; | |
1018 case Player::Condition_Unconcious: player->expression = CHARACTER_EXPRESSION_UNCONCIOUS; break; | |
1019 default: | |
1020 assert(false); | |
0 | 1021 } |
1022 } | |
130 | 1023 } |
1024 | |
1025 | |
1026 for (int i = 0; i < 2; ++i) | |
1027 { | |
1028 auto hireling = pParty->pHirelings + i; | |
291 | 1029 if (!hireling->evt_C) |
130 | 1030 continue; |
1031 | |
291 | 1032 hireling->evt_B += pMiscTimer->uTimeElapsed; |
1033 if (hireling->evt_B >= hireling->evt_C) | |
130 | 1034 { |
291 | 1035 hireling->evt_A = 0; |
1036 hireling->evt_B = 0; | |
1037 hireling->evt_C = 0; | |
130 | 1038 |
1039 assert(sizeof(NPCData) == 0x4C); | |
1040 memset(hireling, 0, sizeof(*hireling)); | |
1041 | |
1042 pParty->field_709 = 0; | |
1035 | 1043 pParty->CountHirelings(); |
1044 viewparams->bRedrawGameUI = true; | |
130 | 1045 } |
0 | 1046 } |
1047 } | |
1048 | |
1049 //----- (00490D02) -------------------------------------------------------- | |
1050 void Party::RestAndHeal() | |
1051 { | |
910 | 1052 Player *pPlayer; // esi@4 |
83 | 1053 ItemGen *v7; // eax@10 |
0 | 1054 signed int v11; // ecx@26 |
1055 signed int v12; // [sp-4h] [bp-1Ch]@26 | |
910 | 1056 bool have_vessels_soul; // [sp+10h] [bp-8h]@10 |
0 | 1057 |
910 | 1058 /* v1 = pParty->pPartyBuffs; |
0 | 1059 do |
1060 { | |
1061 v1->Reset(); | |
1062 ++v1; | |
1063 } | |
1064 while ( (signed int)v1 < (signed int)pParty->pPlayers ); | |
1065 v15 = 0; | |
1066 do | |
1067 { | |
910 | 1068 pPlayer = &pParty->pPlayers[v15]; |
0 | 1069 v3 = 20; |
910 | 1070 v4 = pPlayer->pPlayerBuffs; |
0 | 1071 do |
1072 { | |
1073 v4->Reset(); | |
1074 ++v4; | |
1075 --v3; | |
1076 } | |
910 | 1077 while ( v3 );*/ |
1078 for ( uint i = 0; i < 20; ++i ) | |
1079 pParty->pPartyBuffs[i].Reset(); | |
1080 for ( int pPlayerID = 0; pPlayerID < 4; ++pPlayerID ) | |
1081 { | |
1082 pPlayer = &pParty->pPlayers[pPlayerID]; | |
1083 for ( uint i = 0; i < 20; ++i ) | |
1084 pPlayer->pPlayerBuffs[i].Reset(); | |
1085 | |
1086 pPlayer->Zero(); | |
1087 if ( pPlayer->pConditions[14] || pPlayer->pConditions[15] || pPlayer->pConditions[16] )//Dead/Petrified/Eradicated | |
1088 continue; | |
1089 pPlayer->pConditions[13] = 0;//Unconcious | |
1090 pPlayer->pConditions[4] = 0;//Drunk | |
1091 pPlayer->pConditions[3] = 0;//Fear | |
1092 pPlayer->pConditions[2] = 0;//Sleep | |
1093 pPlayer->pConditions[1] = 0;//Weak | |
1094 pPlayer->uTimeToRecovery = 0; | |
1095 pPlayer->sHealth = pPlayer->GetMaxHealth(); | |
1096 pPlayer->sMana = pPlayer->GetMaxMana(); | |
1097 if ( pPlayer->classType == PLAYER_CLASS_LICH ) | |
0 | 1098 { |
910 | 1099 have_vessels_soul = false; |
1100 v7 = pPlayer->pInventoryItems;//[0].field_1A; | |
1101 for ( uint i = 138; i; --i ) | |
0 | 1102 { |
910 | 1103 if ( v7->uItemID == 601 && (unsigned __int8)v7->uHolderPlayer == pPlayerID + 1 ) |
1104 have_vessels_soul = true; | |
83 | 1105 ++v7; |
0 | 1106 } |
910 | 1107 if ( !have_vessels_soul ) |
0 | 1108 { |
910 | 1109 pPlayer->sHealth = pPlayer->GetMaxHealth() / 2; |
1110 pPlayer->sMana = pPlayer->GetMaxMana() / 2; | |
0 | 1111 } |
1112 } | |
910 | 1113 if ( !pPlayer->pConditions[17] )// Zombie |
0 | 1114 { |
910 | 1115 if ( pPlayer->pConditions[10] || pPlayer->pConditions[11] ) |
0 | 1116 { |
1117 v11 = 4; | |
1118 v12 = 4; | |
1119 } | |
1120 else | |
1121 { | |
910 | 1122 if ( !pPlayer->pConditions[8] && !pPlayer->pConditions[9] ) |
0 | 1123 { |
910 | 1124 if ( !pPlayer->pConditions[6] && !pPlayer->pConditions[7] ) |
1125 { | |
1126 if ( pPlayer->pConditions[5] ) | |
1127 pPlayer->sMana = 0; | |
1128 UpdatePlayersAndHirelingsEmotions(); | |
1129 continue; | |
1130 } | |
1131 pPlayer->sHealth /= 2; | |
1132 pPlayer->sMana = pPlayer->sMana / 2; | |
1133 if ( pPlayer->pConditions[5] ) | |
1134 pPlayer->sMana = 0; | |
1135 UpdatePlayersAndHirelingsEmotions(); | |
1136 continue; | |
0 | 1137 } |
1138 v11 = 3; | |
1139 v12 = 3; | |
1140 } | |
910 | 1141 pPlayer->sHealth /= v11; |
1142 pPlayer->sMana = pPlayer->sMana / v12; | |
1143 if ( pPlayer->pConditions[5] ) | |
1144 pPlayer->sMana = 0; | |
1145 UpdatePlayersAndHirelingsEmotions(); | |
1146 continue; | |
0 | 1147 } |
910 | 1148 pPlayer->sMana = 0; |
1149 pPlayer->sHealth = pPlayer->sHealth / 2; | |
1150 if ( pPlayer->pConditions[5] ) | |
1151 pPlayer->sMana = 0; | |
130 | 1152 UpdatePlayersAndHirelingsEmotions(); |
0 | 1153 } |
766 | 1154 pParty->days_played_without_rest = 0; |
1295 | 1155 } |
1156 //----- (004938D1) -------------------------------------------------------- | |
1157 void __fastcall Rest(unsigned int uHoursToSleep) | |
1158 { | |
1159 unsigned int v1; // esi@1 | |
1160 double v2; // st7@3 | |
1161 Player **v3; // esi@3 | |
1162 | |
1163 v1 = uHoursToSleep; | |
1164 if ( uHoursToSleep > 240 ) | |
1165 InitializeActors(); | |
1166 v2 = (double)(7680 * v1) * 0.033333335; | |
1167 pParty->uTimePlayed += (signed __int64)v2; | |
1168 v3 = &pPlayers[1]; | |
1169 do | |
1170 { | |
1171 (*v3)->Recover((signed __int64)v2); | |
1172 ++v3; | |
1173 } | |
1174 while ( (signed int)v3 <= (signed int)&pPlayers[4] ); | |
1175 _494035_timed_effects__water_walking_damage__etc(); | |
1176 } | |
1177 //----- (004B1BDB) -------------------------------------------------------- | |
1178 void __stdcall RestAndHeal(__int64 uNumMinutes) | |
1179 { | |
1180 signed __int64 v1; // ST2C_8@1 | |
1181 signed __int64 v2; // qax@1 | |
1182 signed __int64 v3; // ST1C_8@1 | |
1183 unsigned __int64 v4; // qax@1 | |
1184 unsigned int v5; // ebx@1 | |
1185 Player *v6; // ebx@1 | |
1186 | |
1187 pParty->pHirelings[0].bHasUsedTheAbility = 0; | |
1188 pParty->pHirelings[1].bHasUsedTheAbility = 0; | |
1189 pParty->uTimePlayed += (signed __int64)((double)(7680 * uNumMinutes) * 0.033333335); | |
1190 v1 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); | |
1191 v2 = v1 / 60 / 60; | |
1192 v3 = v2; | |
1193 v4 = (unsigned int)v2 / 0x18; | |
1194 v5 = (unsigned int)(v4 / 7) >> 2; | |
1195 pParty->uCurrentTimeSecond = v1 % 60; | |
1196 pParty->uCurrentMinute = v1 / 60 % 60; | |
1197 pParty->uCurrentHour = v3 % 24; | |
1198 pParty->uCurrentMonthWeek = v4 / 7 & 3; | |
1199 pParty->uDaysPlayed = (unsigned int)v4 % 0x1C; | |
1200 pParty->uCurrentMonth = v5 % 0xC; | |
1201 pParty->uCurrentYear = v5 / 0xC + game_starting_year; | |
1202 pParty->RestAndHeal(); | |
1203 dword_507B94 = 1; | |
1204 v6 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay; | |
1205 do | |
1206 { | |
1207 v6->uTimeToRecovery = 0; | |
1208 memset(&v6->uTimeToRecovery, 0, 4u); | |
1209 ++v6; | |
1210 } | |
1211 while ( v6 <= &pParty->pPlayers[3] ); | |
1212 pParty->UpdatePlayersAndHirelingsEmotions(); | |
1213 } | |
1297 | 1214 //----- (0041F5BE) -------------------------------------------------------- |
1215 void __cdecl Sleep6Hours() | |
1216 { | |
1217 if ( _506F18_num_hours_to_sleep < 6 ) | |
1218 { | |
1219 pParty->pPlayers[3].SetAsleep(false); | |
1220 pParty->pPlayers[2].SetAsleep(false); | |
1221 pParty->pPlayers[1].SetAsleep(false); | |
1222 pParty->pPlayers[0].SetAsleep(false); | |
1223 if ( _506F18_num_hours_to_sleep ) | |
1224 { | |
1225 Rest(_506F18_num_hours_to_sleep); | |
1226 _506F18_num_hours_to_sleep = 0; | |
1227 LoadActualSkyFrame(); | |
1228 } | |
1229 if ( dword_506F14 == 2 ) | |
1230 { | |
1231 pGUIWindow_CurrentMenu->Release(); | |
1232 pEventTimer->Resume(); | |
1233 if ( pTexture_RestUI_CurrentSkyFrame ) | |
1234 pTexture_RestUI_CurrentSkyFrame->Release(); | |
1235 if ( pTexture_RestUI_CurrentHourglassFrame ) | |
1236 pTexture_RestUI_CurrentHourglassFrame->Release(); | |
1237 pTexture_RestUI_CurrentHourglassFrame = 0; | |
1238 pTexture_RestUI_CurrentSkyFrame = 0; | |
1239 pIcons_LOD->_4114F2(); | |
1240 pIcons_LOD->SyncLoadedFilesCount(); | |
1241 pCurrentScreen = SCREEN_GAME; | |
1242 viewparams->bRedrawGameUI = 1; | |
1243 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
1244 { | |
1245 pOutdoor->UpdateSunlightVectors(); | |
1246 pOutdoor->UpdateFog(); | |
1247 } | |
1248 } | |
1249 dword_506F14 = 0; | |
1250 } | |
1251 else | |
1252 { | |
1253 Rest(6u); | |
1254 _506F18_num_hours_to_sleep -= 6; | |
1255 LoadActualSkyFrame(); | |
1256 } | |
1257 viewparams->bRedrawGameUI = 1; | |
1258 } | |
1259 | |
1295 | 1260 //----- (0047752B) -------------------------------------------------------- |
1261 int __cdecl GetPartyReputation() | |
1262 { | |
1263 DDM_DLV_Header *v0; // ebx@1 | |
1264 signed int v1; // esi@3 | |
1265 | |
1266 v0 = &pOutdoor->ddm; | |
1267 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
1268 v0 = &pIndoor->dlv; | |
1269 v1 = 0; | |
1270 if ( CheckHiredNPCSpeciality(Pirate) ) | |
1271 v1 += 5; | |
1272 if ( CheckHiredNPCSpeciality(Burglar) ) | |
1273 v1 += 5; | |
1274 if ( CheckHiredNPCSpeciality(Gypsy) ) | |
1275 v1 += 5; | |
1276 if ( CheckHiredNPCSpeciality(Duper) ) | |
1277 v1 += 5; | |
1278 if ( CheckHiredNPCSpeciality(FallenWizard) ) | |
1279 v1 += 5; | |
1280 return v1 + v0->uReputation; | |
1296 | 1281 } |
1282 //----- (004269A2) -------------------------------------------------------- | |
1283 void __fastcall GivePartyExp(unsigned int pEXPNum) | |
1284 { | |
1285 signed int pActivePlayerCount; // ecx@1 | |
1286 int pLearningPercent; // eax@13 | |
1287 | |
1288 pActivePlayerCount = 0; | |
1289 for ( uint i = 0; i < 4; ++i ) | |
1290 { | |
1291 if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] ) | |
1292 pActivePlayerCount ++; | |
1293 } | |
1294 if ( pActivePlayerCount ) | |
1295 { | |
1296 pEXPNum = pEXPNum / pActivePlayerCount; | |
1297 for ( uint i = 0; i < 4; ++i ) | |
1298 { | |
1299 if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] ) | |
1300 { | |
1301 if ( pEXPNum ) | |
1302 { | |
1303 pLearningPercent = pParty->pPlayers[i].GetLearningPercent(); | |
1304 pEXPNum = pEXPNum + pEXPNum * pLearningPercent / 100; | |
1305 pParty->pPlayers[i].uExperience += pEXPNum; | |
1306 if ( pParty->pPlayers[i].uExperience > 4000000000i64 ) | |
1307 { | |
1308 pParty->pPlayers[i].uExperience = 0; | |
1309 } | |
1310 } | |
1311 } | |
1312 } | |
1313 } | |
1314 } | |
1297 | 1315 //----- (00420C05) -------------------------------------------------------- |
1316 void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) | |
1317 { | |
1318 unsigned int v2; // edi@1 | |
1319 int v3; // ebp@1 | |
1320 unsigned int v4; // esi@1 | |
1321 int v5; // ecx@6 | |
1322 NPCData *v6; // eax@6 | |
1323 signed int v7; // edx@8 | |
1324 signed int v8; // ebx@10 | |
1325 char *v9; // edi@11 | |
1326 signed int v10; // ecx@17 | |
1327 int v11; // eax@21 | |
1328 NPCData *v12; // ecx@21 | |
1329 unsigned int v13; // ecx@23 | |
1330 signed int v14; // [sp+Ch] [bp-4h]@6 | |
1331 | |
1332 v2 = 0; | |
1333 v3 = 0; | |
1334 v4 = uNumGold; | |
1335 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal ) | |
1336 { | |
1337 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) | |
1338 { | |
1339 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! | |
1340 } | |
1341 else | |
1342 { | |
1343 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) | |
1344 pTmpBuf2[0] = 0; | |
1345 } | |
1346 } | |
1347 else | |
1348 { | |
1349 v14 = 0; | |
1350 v5 = 0; | |
1351 v6 = pParty->pHirelings; | |
1352 do | |
1353 { | |
1354 if ( v6->pName ) | |
1355 { | |
1356 v7 = v14++; | |
1357 pTmpBuf[v7] = v5; | |
1358 } | |
1359 ++v6; | |
1360 ++v5; | |
1361 } | |
1362 while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); | |
1363 v8 = 0; | |
1364 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
1365 { | |
1366 v9 = (char *)pNPCStats->pNewNPCData; | |
1367 do | |
1368 { | |
1369 if ( v9[8] & 0x80 | |
1370 && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v9, pParty->pHirelings[0].pName)) | |
1371 && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v9, pParty->pHirelings[1].pName)) ) | |
1372 { | |
1373 v10 = v14++; | |
1374 pTmpBuf[v10] = v8 + 2; | |
1375 } | |
1376 ++v8; | |
1377 v9 += 76; | |
1378 } | |
1379 while ( v8 < (signed int)pNPCStats->uNumNewNPCs ); | |
1380 v2 = 0; | |
1381 } | |
1382 if ( v14 > 0 ) | |
1383 { | |
1384 do | |
1385 { | |
1386 v11 = (unsigned __int8)pTmpBuf[v2]; | |
1387 v12 = &pNPCStats->pNPCData[v11 + 499]; | |
1388 if ( (unsigned __int8)pTmpBuf[v2] < 2 ) | |
1389 v12 = &pParty->pHirelings[v11]; | |
1390 v13 = v12->uProfession; | |
1391 if ( v13 ) | |
1392 v3 += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); | |
1393 ++v2; | |
1394 } | |
1395 while ( (signed int)v2 < v14 ); | |
1396 } | |
1397 if ( CheckHiredNPCSpeciality(Factor) ) | |
1398 v4 += (signed int)(10 * v4) / 100; | |
1399 if ( CheckHiredNPCSpeciality(Banker) ) | |
1400 v4 += (signed int)(20 * v4) / 100; | |
1401 if ( CheckHiredNPCSpeciality(Pirate) ) | |
1402 v4 += (signed int)(10 * v4) / 100; | |
1403 if ( v3 ) | |
1404 { | |
1405 v3 = (signed int)(v4 * v3 / 100) / 100; | |
1406 if ( v3 < 1 ) | |
1407 v3 = 1; | |
1408 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)! | |
1409 } | |
1410 else | |
1411 { | |
1412 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold! | |
1413 } | |
1414 v2 = 0; | |
1415 } | |
1416 pParty->uNumGold += v4 - v3; | |
1417 pUIAnim_Gold->uAnimTime = v2; | |
1418 pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; | |
1419 if ( pTmpBuf2[0] ) | |
1420 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
1421 pAudioPlayer->PlaySound(SOUND_GoldReceived, v2, v2, -1, v2, v2, v2, v2); | |
1422 } | |
1423 //----- (00421B2C) -------------------------------------------------------- | |
1424 bool __cdecl sub_421B2C_PlaceInInventory_or_DropPickedItem() | |
1425 { | |
1426 unsigned int v0; // eax@2 | |
1427 Texture *v1; // ebx@2 | |
1428 int v2; // eax@3 | |
1429 Player *v3; // esi@5 | |
1430 int v4; // eax@6 | |
1431 unsigned __int16 v5; // dx@11 | |
1432 signed int v6; // eax@11 | |
1433 char *v7; // edi@12 | |
1434 __int16 v8; // ax@16 | |
1435 SpriteObject a1; // [sp+4h] [bp-78h]@11 | |
1436 int v11; // [sp+74h] [bp-8h]@2 | |
1437 int v12; // [sp+78h] [bp-4h]@5 | |
1438 | |
1439 if ( !pParty->pPickedItem.uItemID ) | |
1440 return 1; | |
1441 v0 = pIcons_LOD->LoadTexture( | |
1442 pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, | |
1443 TEXTURE_16BIT_PALETTE); | |
1444 v1 = pIcons_LOD->GetTexture(v0); | |
1445 v11 = areWeLoadingTexture; | |
1446 if ( uActiveCharacter | |
1447 && (v2 = pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) | |
1448 { | |
1449 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u); | |
1450 pMouse->RemoveHoldingItem(); | |
1451 } | |
1452 else | |
1453 { | |
1454 v12 = 0; | |
1455 v3 = pParty->pPlayers; | |
1456 while ( v3 <= &pParty->pPlayers[3] ) | |
1457 { | |
1458 v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID); | |
1459 if ( v4 ) | |
1460 { | |
1461 memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u); | |
1462 pMouse->RemoveHoldingItem(); | |
1463 break; | |
1464 } | |
1465 ++v12; | |
1466 ++v3; | |
1467 } | |
1468 if ( v12 == 4 ) | |
1469 { | |
1470 v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
1471 v6 = 0; | |
1472 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
1473 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
1474 { | |
1475 LOWORD(v6) = 0; | |
1476 } | |
1477 else | |
1478 { | |
1479 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
1480 while ( v5 != *(short *)v7 ) | |
1481 { | |
1482 ++v6; | |
1483 v7 += 56; | |
1484 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
1485 { | |
1486 LOWORD(v6) = 0; | |
1487 break; | |
1488 } | |
1489 } | |
1490 } | |
1491 a1.spell_caster_pid = OBJECT_Player; | |
1492 a1.uObjectDescID = v6; | |
1493 a1.vPosition.y = pParty->vPosition.y; | |
1494 a1.vPosition.x = pParty->vPosition.x; | |
1495 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
1496 a1.uSoundID = 0; | |
1497 a1.uFacing = 0; | |
1498 a1.uAttributes = 8; | |
1499 v8 = pIndoor->GetSector( | |
1500 pParty->vPosition.x, | |
1501 pParty->vPosition.y, | |
1502 pParty->sEyelevel + pParty->vPosition.z); | |
1503 a1.uSpriteFrameID = 0; | |
1504 a1.uSectorID = v8; | |
1505 memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); | |
1506 a1.Create(pParty->sRotationY, 184, 200, 0); | |
1507 pMouse->RemoveHoldingItem(); | |
1508 } | |
1509 } | |
1510 if ( !v11 ) | |
1511 { | |
1512 v1->Release(); | |
1513 pIcons_LOD->SyncLoadedFilesCount(); | |
1514 } | |
1515 return 1; | |
1516 } |