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