annotate Engine/Party.cpp @ 2511:fb1c61a82a55

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