annotate Engine/Party.cpp @ 2559:6ab1273bc507

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