Mercurial > mm7
comparison Engine/Objects/Player.cpp @ 2498:92eeeb5200f2
.
author | Ritor1 |
---|---|
date | Fri, 19 Sep 2014 00:03:04 +0600 |
parents | |
children | 68cdef6879a0 |
comparison
equal
deleted
inserted
replaced
2497:82d5d92a097c | 2498:92eeeb5200f2 |
---|---|
1 #define _CRTDBG_MAP_ALLOC | |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
6 #include "stru6.h" | |
7 | |
8 #include "ErrorHandling.h" | |
9 | |
10 #include "Player.h" | |
11 #include "PlayerFrameTable.h" | |
12 #include "AudioPlayer.h" | |
13 #include "Party.h" | |
14 #include "LOD.h" | |
15 #include "GUIWindow.h" | |
16 #include "Engine/Graphics/Viewport.h" | |
17 #include "Actor.h" | |
18 #include "Game.h" | |
19 #include "Mouse.h" | |
20 #include "TurnEngine.h" | |
21 #include "Events.h" | |
22 #include "Events2D.h" | |
23 #include "Engine/Graphics/Outdoor.h" | |
24 #include "StorylineTextTable.h" | |
25 #include "Autonotes.h" | |
26 #include "Awards.h" | |
27 #include "texts.h" | |
28 | |
29 #include "stru123.h" | |
30 #include "stru298.h" | |
31 #include "ObjectList.h" | |
32 #include "MM7.h" | |
33 #include "SpriteObject.h" | |
34 #include "Engine/Graphics/DecalBuilder.h" | |
35 #include "CastSpellInfo.h" | |
36 #include "OurMath.h" | |
37 #include "UI\UIPartyCreation.h" | |
38 | |
39 | |
40 | |
41 | |
42 NZIArray<struct Player *, 5> pPlayers; | |
43 | |
44 | |
45 /* 381 */ | |
46 #pragma pack(push, 1) | |
47 struct PlayerCreation_AttributeProps | |
48 { | |
49 unsigned __int8 uBaseValue; | |
50 char uMaxValue; | |
51 char uDroppedStep; | |
52 char uBaseStep; | |
53 }; | |
54 #pragma pack(pop) | |
55 | |
56 | |
57 #pragma pack(push, 1) | |
58 | |
59 | |
60 | |
61 #pragma pack(pop) | |
62 PlayerCreation_AttributeProps StatTable[4][7] = //0x4ED7B0 | |
63 { | |
64 {{11, 25, 1, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, { 9, 25, 1, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, {9, 25, 1, 1},}, | |
65 {{ 7, 15, 2, 1}, {14, 30, 1, 2}, {11, 25, 1, 1}, { 7, 15, 2, 1}, {14, 30, 1, 2}, {11, 25, 1, 1}, {9, 20, 1, 1},}, | |
66 {{14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, {9, 20, 1, 1},}, | |
67 {{14, 30, 1, 2}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {9, 20, 1, 1}} | |
68 }; | |
69 | |
70 | |
71 | |
72 std::array<int, 5> StealingMasteryBonuses = {0, 100, 200, 300, 500}; //dword_4EDEA0 //the zeroth element isn't accessed, it just helps avoid -1 indexing, originally 4 element array off by one | |
73 std::array<int, 5> StealingRandomBonuses = {-200, -100, 0, 100, 200}; //dword_4EDEB4 | |
74 std::array<int, 5> StealingEnchantmentBonusForSkill = {0, 2, 4, 6, 10}; //dword_4EDEC4 //the zeroth element isn't accessed, it just helps avoid -1 indexing, originally 4 element array off by one | |
75 | |
76 | |
77 | |
78 // available skills per class ( 9 classes X 37 skills ) | |
79 // 0 - not available | |
80 // 1 - available | |
81 // 2 - primary skill | |
82 unsigned char pSkillAvailabilityPerClass[9][37] = // byte[] @ MM7.exe::004ED820 | |
83 { | |
84 {0, 2, 0, 1, 1, 1, 1, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, | |
85 {0, 1, 2, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 2, 1, 0}, | |
86 {1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 2, 2, 1, 1, 0, 0, 0}, | |
87 {0, 1, 1, 1, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, | |
88 {0, 1, 0, 1, 1, 2, 0, 0, 0, 1, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1}, | |
89 {0, 1, 1, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0}, | |
90 {0, 0, 0, 0, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, | |
91 {0, 0, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, | |
92 {2, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0} // some of these are started at 4ED94C, but needs to be here | |
93 }; | |
94 | |
95 | |
96 unsigned char pEquipTypeToBodyAnchor[21] = // 4E8398 | |
97 { | |
98 1, // EQUIP_SINGLE_HANDED | |
99 1, // EQUIP_TWO_HANDED | |
100 2, // EQUIP_BOW | |
101 3, // EQUIP_ARMOUR | |
102 0, // EQUIP_SHIELD | |
103 4, // EQUIP_HELMET | |
104 5, // EQUIP_BELT | |
105 6, // EQUIP_CLOAK | |
106 7, // EQUIP_GAUNTLETS | |
107 8, // EQUIP_BOOTS | |
108 10, // EQUIP_RING | |
109 9, // EQUIP_AMULET | |
110 1, // EQUIP_WAND | |
111 0, // EQUIP_REAGENT | |
112 0, // EQUIP_POTION | |
113 0, // EQUIP_SPELL_SCROLL | |
114 0, // EQUIP_BOOK | |
115 0, // EQUIP_MESSAGE_SCROLL | |
116 0, // EQUIP_GOLD | |
117 0, // EQUIP_GEM | |
118 0 // EQUIP_NONE | |
119 }; | |
120 | |
121 | |
122 unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, 25, 20, 20, 0, 0, 0}; | |
123 unsigned char pBaseManaByClass[12] = { 0, 0, 0, 5, 5, 0, 10, 10, 15, 0, 0, 0}; | |
124 unsigned char pBaseHealthPerLevelByClass[36] = {5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4, 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3}; | |
125 unsigned char pBaseManaPerLevelByClass[36] = {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 3, 3, 1, 2, 3, 3, 0, 2, 3, 3, 3, 4, 5, 5, 3, 4, 5, 5, 3, 4, 6, 6}; | |
126 | |
127 unsigned char pConditionAttributeModifier[7][19] = | |
128 {{100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Might | |
129 {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Intelligence | |
130 {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Willpower | |
131 {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Endurance | |
132 {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Accuracy | |
133 {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Speed | |
134 {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}}; //Luck | |
135 | |
136 unsigned char pAgingAttributeModifier[7][4] = | |
137 {{100, 75, 40, 10}, //Might | |
138 {100, 150, 100, 10}, //Intelligence | |
139 {100, 150, 100, 10}, //Willpower | |
140 {100, 75, 40, 10}, //Endurance | |
141 {100, 100, 40, 10}, //Accuracy | |
142 {100, 100, 40, 10}, //Speed | |
143 {100, 100, 100, 100}}; //Luck | |
144 | |
145 unsigned int pAgeingTable[4] = {50, 100, 150, 0xFFFF}; | |
146 | |
147 std::array<unsigned int, 18> pConditionImportancyTable = {{16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0}}; | |
148 | |
149 short param_to_bonus_table[29] = {500, 400, 350, 300, 275, 250, 225, 200, 175, | |
150 150, 125, 100, 75, 50, 40, 35, 30, 25, 21, | |
151 19, 17, 15, 13, 11, 9, 7, 5, 3, 0}; | |
152 signed int parameter_to_bonus_value[29] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6}; | |
153 | |
154 | |
155 unsigned short base_recovery_times_per_weapon_type[12] = | |
156 { | |
157 100, // PLAYER_SKILL_STAFF && Unarmed withoud skill | |
158 90, // PLAYER_SKILL_SWORD && Unarmed with skill | |
159 60, // PLAYER_SKILL_DAGGER | |
160 100, // PLAYER_SKILL_AXE | |
161 80, // PLAYER_SKILL_SPEAR | |
162 100, // PLAYER_SKILL_BOW | |
163 80, // PLAYER_SKILL_MACE | |
164 30, // PLAYER_SKILL_BLASTER | |
165 10, // PLAYER_SKILL_SHIELD | |
166 10, // PLAYER_SKILL_LEATHER | |
167 20, // PLAYER_SKILL_CHAIN | |
168 30 // PLAYER_SKILL_PLATE | |
169 }; | |
170 | |
171 //----- (00490913) -------------------------------------------------------- | |
172 int PlayerCreation_GetUnspentAttributePointCount() | |
173 { | |
174 signed int v0; // edi@1 | |
175 int raceId; // ebx@2 | |
176 signed int v4; // eax@17 | |
177 int v5; // edx@18 | |
178 signed int v6; // ecx@18 | |
179 signed int remainingStatPoints; // [sp+Ch] [bp-8h]@1 | |
180 | |
181 remainingStatPoints = 50; | |
182 v0 = 50; | |
183 for (int playerNum = 0; playerNum < 4; playerNum++) | |
184 { | |
185 raceId = pParty->pPlayers[playerNum].GetRace(); | |
186 for (int statNum = 0; statNum <= 6; statNum++) | |
187 { | |
188 switch ( statNum ) | |
189 { | |
190 case 0: | |
191 v0 = pParty->pPlayers[playerNum].uMight; | |
192 break; | |
193 case 1: | |
194 v0 = pParty->pPlayers[playerNum].uIntelligence; | |
195 break; | |
196 case 2: | |
197 v0 = pParty->pPlayers[playerNum].uWillpower; | |
198 break; | |
199 case 3: | |
200 v0 = pParty->pPlayers[playerNum].uEndurance; | |
201 break; | |
202 case 4: | |
203 v0 = pParty->pPlayers[playerNum].uAccuracy; | |
204 break; | |
205 case 5: | |
206 v0 = pParty->pPlayers[playerNum].uSpeed; | |
207 break; | |
208 case 6: | |
209 v0 = pParty->pPlayers[playerNum].uLuck; | |
210 break; | |
211 } | |
212 v4 = StatTable[raceId][statNum].uBaseValue; | |
213 if ( v0 >= v4 ) | |
214 { | |
215 v5 = StatTable[raceId][statNum].uDroppedStep; | |
216 v6 = StatTable[raceId][statNum].uBaseStep; | |
217 } | |
218 else | |
219 { | |
220 v5 = StatTable[raceId][statNum].uBaseStep; | |
221 v6 = StatTable[raceId][statNum].uDroppedStep; | |
222 } | |
223 remainingStatPoints += v5 * (v4 - v0) / v6; | |
224 } | |
225 } | |
226 return remainingStatPoints; | |
227 } | |
228 | |
229 //----- (00427730) -------------------------------------------------------- | |
230 bool Player::CanCastSpell(unsigned int uRequiredMana) | |
231 { | |
232 if (sMana >= (signed int)uRequiredMana) | |
233 { | |
234 sMana -= (signed int)uRequiredMana; | |
235 return true; | |
236 } | |
237 | |
238 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); | |
239 return false; | |
240 } | |
241 | |
242 //----- (004BE2DD) -------------------------------------------------------- | |
243 void Player::SalesProcess( unsigned int inventory_idnx, int item_index, int _2devent_idx ) | |
244 { | |
245 float v6; // ST04_4@1 | |
246 signed int item_value; // eax@1 | |
247 signed int sell_price; // ebx@1 | |
248 | |
249 item_value =pOwnItems[item_index].GetValue(); | |
250 v6 = p2DEvents[ _2devent_idx - 1].fPriceMultiplier; | |
251 sell_price = GetPriceSell(item_value, v6); | |
252 if ( pOwnItems[item_index].IsBroken() ) | |
253 sell_price = 1; | |
254 if ( sell_price < 1 ) | |
255 sell_price = 1; | |
256 RemoveItemAtInventoryIndex(inventory_idnx); | |
257 Party::SetGold(pParty->uNumGold + sell_price); | |
258 } | |
259 | |
260 //----- (0043EEF3) -------------------------------------------------------- | |
261 bool Player::NothingOrJustBlastersEquipped() | |
262 { | |
263 signed int item_idx; // esi@1 | |
264 signed int item_id; // esi@1 | |
265 for (int i = 0; i < 16; ++i) | |
266 { | |
267 item_idx = pEquipment.pIndices[i]; | |
268 if (item_idx) | |
269 { | |
270 item_id = pOwnItems[item_idx - 1].uItemID; | |
271 if ( item_id != ITEM_BLASTER && item_id != ITEM_LASER_RIFLE ) //blaster& blaster rifle | |
272 return false; | |
273 } | |
274 } | |
275 return true; | |
276 } | |
277 | |
278 //----- (004B8040) -------------------------------------------------------- | |
279 int Player::GetConditionDayOfWeek( unsigned int uCondition ) | |
280 { | |
281 return (unsigned int)(((signed __int64)((double)this->pConditions[uCondition] * 0.234375) / 60 / 60) / 24) % 7 + 1; | |
282 } | |
283 | |
284 //----- (004B807C) -------------------------------------------------------- | |
285 int Player::GetTempleHealCostModifier(float a2) | |
286 { | |
287 unsigned int conditionIdx; // eax@1 | |
288 int conditionTimeMultiplier; // esi@1 | |
289 int v6; // eax@8 | |
290 signed int result; // qax@13 | |
291 signed int baseConditionMultiplier; // [sp+8h] [bp-8h]@4 | |
292 | |
293 conditionIdx = GetMajorConditionIdx(); | |
294 if ( conditionIdx >= 14 && conditionIdx <= 16) | |
295 { | |
296 if ( conditionIdx <= 15 ) | |
297 baseConditionMultiplier = 5; | |
298 else //if ( conditionIdx == 16 ) | |
299 baseConditionMultiplier = 10; | |
300 conditionTimeMultiplier = GetConditionDayOfWeek(conditionIdx); | |
301 } | |
302 else | |
303 { | |
304 conditionTimeMultiplier = 1; | |
305 baseConditionMultiplier = 1; | |
306 if (conditionIdx < 14) | |
307 { | |
308 for (int i = 0; i <= 13; i++) | |
309 { | |
310 v6 = GetConditionDayOfWeek(i); | |
311 if ( v6 > conditionTimeMultiplier ) | |
312 conditionTimeMultiplier = v6; | |
313 } | |
314 } | |
315 } | |
316 result = (int)((double)conditionTimeMultiplier * (double)baseConditionMultiplier * a2); | |
317 if ( result < 1 ) | |
318 result = 1; | |
319 return result; | |
320 } | |
321 | |
322 //----- (004B8102) -------------------------------------------------------- | |
323 int Player::GetPriceSell(int uRealValue, float price_multiplier) | |
324 { | |
325 signed int v3; // esi@1 | |
326 signed int result; // eax@3 | |
327 | |
328 v3 = (signed int)((signed __int64)((double)uRealValue / (price_multiplier + 2.0)) + uRealValue * GetMerchant() / 100); | |
329 if ( v3 > uRealValue ) | |
330 v3 = uRealValue; | |
331 result = 1; | |
332 if ( v3 >= 1 ) | |
333 result = v3; | |
334 return result; | |
335 } | |
336 | |
337 //----- (004B8142) -------------------------------------------------------- | |
338 int Player::GetBuyingPrice(unsigned int uRealValue, float price_multiplier) | |
339 { | |
340 uint price = (uint)(((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100); | |
341 | |
342 if (price < uRealValue) | |
343 price = uRealValue; | |
344 return price; | |
345 } | |
346 | |
347 //----- (004B8179) -------------------------------------------------------- | |
348 int Player::GetPriceIdentification(float a2) | |
349 { | |
350 signed int v2; // esi@1 | |
351 int v3; // ecx@1 | |
352 signed int result; // eax@3 | |
353 | |
354 v2 = (signed int)(a2 * 50.0); | |
355 v3 = v2 * (100 - GetMerchant()) / 100; | |
356 if ( v3 < v2 / 3 ) | |
357 v3 = v2 / 3; | |
358 result = 1; | |
359 if ( v3 >= 1 ) | |
360 result = v3; | |
361 return result; | |
362 } | |
363 | |
364 //----- (004B81C3) -------------------------------------------------------- | |
365 int Player::GetPriceRepair(int a2, float a3) | |
366 { | |
367 signed int v3; // esi@1 | |
368 int v4; // ecx@1 | |
369 signed int result; // eax@3 | |
370 | |
371 v3 = (signed int)((double)a2 / (6.0 - a3)); | |
372 v4 = v3 * (100 - GetMerchant()) / 100; | |
373 if ( v4 < v3 / 3 ) | |
374 v4 = v3 / 3; | |
375 result = 1; | |
376 if ( v4 >= 1 ) | |
377 result = v4; | |
378 return result; | |
379 } | |
380 | |
381 //----- (004B8213) -------------------------------------------------------- | |
382 int Player::GetBaseSellingPrice(int a2, float a3) | |
383 { | |
384 signed int v3; // qax@1 | |
385 | |
386 v3 = (signed int)((double)a2 / (a3 + 2.0)); | |
387 if ( v3 < 1 ) | |
388 v3 = 1; | |
389 return v3; | |
390 } | |
391 | |
392 //----- (004B8233) -------------------------------------------------------- | |
393 int Player::GetBaseBuyingPrice(int a2, float a3) | |
394 { | |
395 signed int v3; // qax@1 | |
396 | |
397 v3 = (signed int)((double)a2 * a3); | |
398 if ( v3 < 1 ) | |
399 v3 = 1; | |
400 return v3; | |
401 } | |
402 | |
403 //----- (004B824B) -------------------------------------------------------- | |
404 int Player::GetBaseIdentifyPrice(float a2) | |
405 { | |
406 signed int v2; // qax@1 | |
407 | |
408 v2 = (signed int)(a2 * 50.0); | |
409 if ( v2 < 1 ) | |
410 v2 = 1; | |
411 return v2; | |
412 } | |
413 | |
414 //----- (004B8265) -------------------------------------------------------- | |
415 int Player::GetBaseRepairPrice(int a2, float a3) | |
416 { | |
417 signed int v3; // qax@1 | |
418 | |
419 v3 = (signed int)((double)a2 / (6.0 - a3)); | |
420 if ( v3 < 1 ) | |
421 v3 = 1; | |
422 return v3; | |
423 } | |
424 | |
425 //----- (004B6FF9) -------------------------------------------------------- | |
426 bool Player::IsPlayerHealableByTemple() | |
427 { | |
428 if (this->sHealth >= GetMaxHealth() && this->sMana >= GetMaxMana() && GetMajorConditionIdx() == Condition_Good) | |
429 return false; | |
430 else | |
431 { | |
432 if (GetMajorConditionIdx() == Condition_Zombie) | |
433 { | |
434 if (((signed int)window_SpeakInHouse->ptr_1C == 78 || (signed int)window_SpeakInHouse->ptr_1C == 81 || (signed int)window_SpeakInHouse->ptr_1C == 82)) | |
435 return false; | |
436 else | |
437 return true; | |
438 } | |
439 else | |
440 return true; | |
441 } | |
442 } | |
443 | |
444 //----- (00421E75) -------------------------------------------------------- | |
445 unsigned int Player::GetItemIDAtInventoryIndex(int *pitem_index) | |
446 { | |
447 int item_idx; // eax@1 | |
448 int inv_index; // eax@3 | |
449 | |
450 item_idx = *pitem_index; | |
451 if ( item_idx >125 || item_idx < 0 ) | |
452 return 0; | |
453 inv_index = this->pInventoryMatrix[item_idx]; | |
454 if ( inv_index < 0 ) | |
455 { | |
456 *pitem_index = -1 - inv_index; | |
457 inv_index = this->pInventoryMatrix[-1 - inv_index]; | |
458 } | |
459 return inv_index; | |
460 } | |
461 | |
462 //----- (004160CA) -------------------------------------------------------- | |
463 void Player::ItemsEnchant( int enchant_count ) | |
464 { | |
465 int avalible_items; // ebx@1 | |
466 int i; // edx@8 | |
467 __int16 item_index_tabl[138]; // [sp+Ch] [bp-118h]@1 | |
468 | |
469 avalible_items = 0; | |
470 memset (item_index_tabl,0,sizeof(item_index_tabl)); | |
471 | |
472 for (i = 0; i < 138; ++i) | |
473 { | |
474 if (( pOwnItems[i].uItemID>0)&&(pOwnItems[i].uItemID <= 134)) | |
475 item_index_tabl[avalible_items++] = i; | |
476 } | |
477 | |
478 if ( avalible_items ) | |
479 { | |
480 if ( enchant_count ) | |
481 { | |
482 for ( i = 0; i < enchant_count; ++i ) | |
483 { | |
484 if (!(pInventoryItemList[item_index_tabl[i]].uAttributes&ITEM_HARDENED)) | |
485 pInventoryItemList[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_HARDENED; | |
486 } | |
487 } | |
488 else | |
489 { | |
490 for ( i = 0; i < avalible_items; ++i ) | |
491 { | |
492 pInventoryItemList[item_index_tabl[i]].uAttributes |= ITEM_HARDENED; | |
493 } | |
494 } | |
495 } | |
496 } | |
497 | |
498 //----- (004948B1) -------------------------------------------------------- | |
499 void Player::PlaySound(PlayerSpeech speech, int a3) | |
500 { | |
501 signed int speechCount = 0; // esi@4 | |
502 signed int expressionCount = 0; // esi@4 | |
503 int pickedVariant; // esi@10 | |
504 CHARACTER_EXPRESSION_ID expression; // ebx@17 | |
505 signed int pSoundID; // ecx@19 | |
506 int speechVariantArray[5]; // [sp+Ch] [bp-1Ch]@7 | |
507 int expressionVariantArray[5]; | |
508 unsigned int pickedSoundID; // [sp+30h] [bp+8h]@4 | |
509 unsigned int expressionDuration = 0; | |
510 | |
511 pickedSoundID = 0; | |
512 if (uVoicesVolumeMultiplier) | |
513 { | |
514 for (int i = 0; i < 2; i++) | |
515 { | |
516 if ( SoundSetAction[speech][i] ) | |
517 { | |
518 speechVariantArray[speechCount] = SoundSetAction[speech][i]; | |
519 speechCount++; | |
520 } | |
521 } | |
522 if ( speechCount ) | |
523 { | |
524 pickedVariant = speechVariantArray[rand() % speechCount]; | |
525 int numberOfSubvariants = byte_4ECF08[pickedVariant - 1][uVoiceID]; | |
526 if (numberOfSubvariants > 0) | |
527 { | |
528 pickedSoundID = rand() % numberOfSubvariants + 2 * (pickedVariant + 50 * uVoiceID) + 4998; | |
529 pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, uActiveCharacter + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0); | |
530 } | |
531 } | |
532 } | |
533 | |
534 for (int i = 0; i < 5; i++) | |
535 { | |
536 if ( SoundSetAction[speech][i + 3] ) | |
537 { | |
538 expressionVariantArray[expressionCount] = SoundSetAction[speech][i + 3]; | |
539 expressionCount++; | |
540 } | |
541 } | |
542 if ( expressionCount ) | |
543 { | |
544 expression = (CHARACTER_EXPRESSION_ID)expressionVariantArray[rand() % expressionCount]; | |
545 if (expression == CHARACTER_EXPRESSION_21 && pickedSoundID ) | |
546 { | |
547 pSoundID = 0; | |
548 if ( pSoundList->sNumSounds ) | |
549 { | |
550 for (int i = 0; i < pSoundList->sNumSounds; i++) | |
551 { | |
552 if (pSoundList->pSL_Sounds[i].uSoundID == pickedSoundID) | |
553 pSoundID = i; | |
554 } | |
555 } | |
556 if ( pSoundList->pSL_Sounds[pSoundID].pSoundData[0] ) | |
557 expressionDuration = (sLastTrackLengthMS << 7) / 1000; | |
558 } | |
559 PlayEmotion(expression, expressionDuration); | |
560 } | |
561 } | |
562 // 4948B1: using guessed type int var_1C[5]; | |
563 | |
564 //----- (00494A25) -------------------------------------------------------- | |
565 void Player::PlayEmotion(CHARACTER_EXPRESSION_ID new_expression, int a3) | |
566 { | |
567 unsigned int v3 = expression; | |
568 if (expression == CHARACTER_EXPRESSION_DEAD || expression == CHARACTER_EXPRESSION_ERADICATED) | |
569 { | |
570 return; | |
571 } | |
572 else if (expression == CHARACTER_EXPRESSION_PERTIFIED && new_expression != CHARACTER_EXPRESSION_FALLING) | |
573 { | |
574 return; | |
575 } | |
576 else | |
577 { | |
578 if (expression != CHARACTER_EXPRESSION_SLEEP || new_expression != CHARACTER_EXPRESSION_FALLING) | |
579 { | |
580 if (v3 >= 2 && v3 <= 11 && v3 != 8 && !(new_expression == CHARACTER_EXPRESSION_DMGRECVD_MINOR || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MODERATE || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MAJOR)) | |
581 { | |
582 return; | |
583 } | |
584 } | |
585 } | |
586 this->uExpressionTimePassed = 0; | |
587 if ( !a3 ) | |
588 { | |
589 this->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[a3].uAnimLength; | |
590 } | |
591 else | |
592 { | |
593 this->uExpressionTimeLength = 0; | |
594 } | |
595 expression = new_expression; | |
596 viewparams->bRedrawGameUI = 1; | |
597 } | |
598 | |
599 //----- (0049327B) -------------------------------------------------------- | |
600 bool Player::ProfessionOrGuildFlagsCorrect( unsigned int uClass, int a3 ) | |
601 { | |
602 if ( this->classType == uClass ) | |
603 { | |
604 return true; | |
605 } | |
606 else | |
607 { | |
608 if (!a3) | |
609 { | |
610 return false; | |
611 } | |
612 switch ( uClass ) | |
613 { | |
614 case 0x1Au: | |
615 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 65)); | |
616 case 0x1Bu: | |
617 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 67)); | |
618 case 0x22u: | |
619 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 77)); | |
620 case 0x23u: | |
621 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 79)); | |
622 break; | |
623 default: | |
624 Error("Should not be able to get here (%u)", uClass); | |
625 break; | |
626 } | |
627 return false; | |
628 } | |
629 } | |
630 | |
631 | |
632 //----- (00492C0B) -------------------------------------------------------- | |
633 bool Player::CanAct() | |
634 { | |
635 if ( this->IsAsleep() || this->IsParalyzed() || | |
636 this->IsUnconcious() || this->IsDead() || | |
637 this->IsPertified() || this->IsEradicated() ) | |
638 return false; | |
639 else | |
640 return true; | |
641 } | |
642 | |
643 //----- (00492C40) -------------------------------------------------------- | |
644 bool Player::CanSteal() | |
645 { | |
646 return GetActualSkillLevel(PLAYER_SKILL_STEALING) != 0; | |
647 } | |
648 | |
649 //----- (00492C4E) -------------------------------------------------------- | |
650 bool Player::CanEquip_RaceAndAlignmentCheck(unsigned int uItemID) | |
651 { | |
652 switch (uItemID) | |
653 { | |
654 case ITEM_RELIC_ETHRICS_STAFF: | |
655 case ITEM_RELIC_OLD_NICK: | |
656 case ITEM_RELIC_TWILIGHT: return pParty->IsPartyEvil(); break; | |
657 case ITEM_RELIC_TALEDONS_HELM: | |
658 case ITEM_RELIC_JUSTICE: return pParty->IsPartyGood(); break; | |
659 case ITEM_ARTIFACT_ELFBANE: return IsRaceGoblin(); break; | |
660 case ITEM_ARTIFACT_MINDS_EYE: return IsRaceHuman(); break; | |
661 case ITEM_ELVEN_CHAINMAIL: return IsRaceElf(); break; | |
662 case ITEM_FORGE_GAUNTLETS: return IsRaceDwarf(); break; | |
663 case ITEM_ARTIFACT_HEROS_BELT: return IsMale(); break; | |
664 case ITEM_ARTIFACT_LADYS_ESCORT: return IsFemale(); break; | |
665 case ITEM_WETSUIT: return NothingOrJustBlastersEquipped(); break; | |
666 default: return 1; break; | |
667 } | |
668 } | |
669 | |
670 //----- (00492D65) -------------------------------------------------------- | |
671 void Player::SetCondition( unsigned int uConditionIdx, int a3 ) | |
672 { | |
673 signed int player_sex; // ecx@77 | |
674 signed int remainig_player; // ebx@82 | |
675 int players_before; // [sp+10h] [bp-4h]@2 | |
676 int players_after; // [sp+20h] [bp+Ch]@82 | |
677 | |
678 if ( pConditions[uConditionIdx] ) | |
679 return; | |
680 | |
681 if (!ConditionProcessor::IsPlayerAffected(this, uConditionIdx, a3)) | |
682 { | |
683 return; | |
684 } | |
685 | |
686 switch ( uConditionIdx ) | |
687 { | |
688 case Condition_Cursed: PlaySound(SPEECH_30, 0); break; | |
689 case Condition_Weak: PlaySound(SPEECH_25, 0); break; | |
690 case Condition_Sleep: break; //nosound | |
691 case Condition_Fear: PlaySound(SPEECH_26, 0); break; | |
692 case Condition_Drunk: PlaySound(SPEECH_31, 0); break; | |
693 case Condition_Insane: PlaySound(SPEECH_29, 0); break; | |
694 case Condition_Poison_Weak: | |
695 case Condition_Poison_Medium: | |
696 case Condition_Poison_Severe: PlaySound(SPEECH_27, 0); break; | |
697 case Condition_Disease_Weak: | |
698 case Condition_Disease_Medium: | |
699 case Condition_Disease_Severe: PlaySound(SPEECH_28, 0);break; | |
700 case Condition_Paralyzed: break; //nosound | |
701 case Condition_Unconcious: | |
702 PlaySound(SPEECH_32, 0); | |
703 if ( sHealth > 0 ) | |
704 sHealth = 0; | |
705 break; | |
706 case Condition_Dead: | |
707 PlaySound(SPEECH_33, 0); | |
708 if ( sHealth > 0 ) | |
709 sHealth = 0; | |
710 if ( sMana > 0 ) | |
711 sMana = 0; | |
712 break; | |
713 case Condition_Pertified: | |
714 PlaySound(SPEECH_34, 0); | |
715 break; | |
716 case Condition_Eradicated: | |
717 PlaySound(SPEECH_35, 0); | |
718 if (sHealth > 0 ) | |
719 sHealth = 0; | |
720 if ( sMana > 0 ) | |
721 sMana = 0; | |
722 break; | |
723 case Condition_Zombie: | |
724 if ( classType == PLAYER_CLASS_LICH || IsEradicated() || IsZombie() || !IsDead()) | |
725 return; | |
726 pConditions.fill(0); | |
727 sHealth = GetMaxHealth(); | |
728 sMana = 0; | |
729 player_sex = 0; | |
730 uPrevFace = uCurrentFace; | |
731 uPrevVoiceID = uVoiceID; | |
732 if (IsMale()) | |
733 { | |
734 uCurrentFace = 23; | |
735 uVoiceID = 23; | |
736 } | |
737 else | |
738 { | |
739 uCurrentFace = 24; | |
740 uVoiceID = 24; | |
741 } | |
742 PlaySound(SPEECH_99, 0); | |
743 break; | |
744 } | |
745 | |
746 players_before = 0; | |
747 for (int i = 1; i < 5; ++i) | |
748 { | |
749 if ( pPlayers[i]->CanAct() ) | |
750 ++players_before; | |
751 } | |
752 | |
753 pConditions[uConditionIdx] = pParty->uTimePlayed; | |
754 | |
755 remainig_player = 0; | |
756 players_after = 0; | |
757 for (int i = 1; i < 5; ++i) | |
758 { | |
759 if ( pPlayers[i]->CanAct() ) | |
760 { | |
761 remainig_player = i; | |
762 ++players_after; | |
763 } | |
764 } | |
765 if (( players_before == 2 ) && ( players_after == 1 )) | |
766 pPlayers[remainig_player]->PlaySound(SPEECH_107, 0);//ñêîðåå âñåãî îáíàä¸æûâàþùèé âîçãëàñ ïîñëåäíåãî | |
767 return; | |
768 } | |
769 | |
770 //----- (00492528) -------------------------------------------------------- | |
771 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID) | |
772 { | |
773 Texture *texture; // esi@1 | |
774 unsigned int slotWidth; // ebx@1 | |
775 unsigned int slotHeight; // [sp+1Ch] [bp+Ch]@1 | |
776 | |
777 texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); | |
778 slotWidth = GetSizeInInventorySlots(texture->uTextureWidth); | |
779 slotHeight = GetSizeInInventorySlots(texture->uTextureHeight); | |
780 if ( !areWeLoadingTexture ) | |
781 { | |
782 texture->Release(); | |
783 pIcons_LOD->SyncLoadedFilesCount(); | |
784 } | |
785 Assert(slotHeight > 0 && slotWidth > 0, "Items should have nonzero dimensions"); | |
786 if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT ) | |
787 { | |
788 for (unsigned int x = 0; x < slotWidth; x++) | |
789 { | |
790 for (unsigned int y = 0; y < slotHeight; y++) | |
791 { | |
792 if (pInventoryMatrix[y * INVETORYSLOTSWIDTH + x + uSlot] != 0) | |
793 { | |
794 return false; | |
795 } | |
796 } | |
797 } | |
798 return true; | |
799 } | |
800 return false; | |
801 } | |
802 // 506128: using guessed type int areWeLoadingTexture; | |
803 | |
804 //----- (004925E6) -------------------------------------------------------- | |
805 int Player::FindFreeInventoryListSlot() | |
806 { | |
807 for (int i = 0; i < 126; i++ ) | |
808 { | |
809 if (pInventoryItemList[i].uItemID == 0) | |
810 { | |
811 return i; | |
812 } | |
813 } | |
814 return -1; | |
815 } | |
816 | |
817 //----- (00492600) -------------------------------------------------------- | |
818 int Player::CreateItemInInventory(unsigned int uSlot, unsigned int uItemID) | |
819 { | |
820 int result; // eax@8 | |
821 signed int freeSlot; // [sp+8h] [bp-4h]@4 | |
822 | |
823 freeSlot = FindFreeInventoryListSlot(); | |
824 if ( freeSlot == -1 ) | |
825 { | |
826 if ( uActiveCharacter ) | |
827 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); | |
828 return 0; | |
829 } | |
830 else | |
831 { | |
832 PutItemArInventoryIndex(uItemID, freeSlot, uSlot); | |
833 result = freeSlot + 1; | |
834 this->pInventoryItemList[freeSlot].uItemID = uItemID; | |
835 } | |
836 return result; | |
837 } | |
838 // 506128: using guessed type int areWeLoadingTexture; | |
839 | |
840 //----- (00492700) -------------------------------------------------------- | |
841 int Player::HasSkill(unsigned int uSkillType) | |
842 { | |
843 if ( uSkillType >= 37 || this->pActiveSkills[uSkillType] ) | |
844 { | |
845 return 1; | |
846 } | |
847 else | |
848 { | |
849 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[67], this->pName); | |
850 ShowStatusBarString(pTmpBuf.data(), 2u); | |
851 return 0; | |
852 } | |
853 } | |
854 | |
855 //----- (00492745) -------------------------------------------------------- | |
856 void Player::WearItem( unsigned int uItemID ) | |
857 { | |
858 int item_body_anch; // edi@6 | |
859 int item_indx; | |
860 item_indx = FindFreeInventoryListSlot(); | |
861 | |
862 if ( item_indx != -1 ) | |
863 { | |
864 pInventoryItemList[item_indx].uItemID = uItemID; | |
865 item_body_anch = pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType]; | |
866 pEquipment.pIndices[item_body_anch] = item_indx + 1; | |
867 pInventoryItemList[item_indx].uBodyAnchor = item_body_anch + 1; | |
868 } | |
869 } | |
870 | |
871 //----- (004927A8) -------------------------------------------------------- | |
872 int Player::AddItem(int index, unsigned int uItemID) | |
873 { | |
874 if ( index == -1 ) | |
875 { | |
876 for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++) | |
877 { | |
878 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) | |
879 { | |
880 if ( CanFitItem(ycoord * INVETORYSLOTSWIDTH + xcoord, uItemID) ) | |
881 { | |
882 return CreateItemInInventory(ycoord * INVETORYSLOTSWIDTH + xcoord, uItemID); | |
883 } | |
884 } | |
885 } | |
886 return 0; | |
887 } | |
888 if ( !CanFitItem(index, uItemID) ) | |
889 { | |
890 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); | |
891 return 0; | |
892 } | |
893 return CreateItemInInventory(index, uItemID); | |
894 } | |
895 | |
896 //----- (00492826) -------------------------------------------------------- | |
897 int Player::AddItem2(int index, ItemGen *Src) | |
898 { | |
899 pItemsTable->SetSpecialBonus(Src); | |
900 | |
901 if ( index == -1 ) | |
902 { | |
903 for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++) | |
904 { | |
905 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) //TODO: change pInventoryMatrix to 2 dimensional array. | |
906 { | |
907 if ( CanFitItem(ycoord * INVETORYSLOTSWIDTH + xcoord, Src->uItemID) ) | |
908 { | |
909 return CreateItemInInventory2(ycoord * INVETORYSLOTSWIDTH + xcoord, Src); | |
910 } | |
911 } | |
912 } | |
913 return 0; | |
914 } | |
915 if ( !CanFitItem(index, Src->uItemID) ) | |
916 return 0; | |
917 return CreateItemInInventory2(index, Src); | |
918 } | |
919 | |
920 //----- (0049289C) -------------------------------------------------------- | |
921 int Player::CreateItemInInventory2( unsigned int index, ItemGen *Src ) | |
922 { | |
923 signed int freeSlot; // ebx@1 | |
924 int result; // eax@6 | |
925 | |
926 freeSlot = FindFreeInventoryListSlot(); | |
927 if ( freeSlot == -1 ) | |
928 { | |
929 result = 0; | |
930 } | |
931 else | |
932 { | |
933 PutItemArInventoryIndex(Src->uItemID, freeSlot, index); | |
934 memcpy(&pInventoryItemList[freeSlot], Src, sizeof(ItemGen)); | |
935 result = freeSlot + 1; | |
936 } | |
937 return result; | |
938 } | |
939 // 506128: using guessed type int areWeLoadingTexture; | |
940 | |
941 //----- (0049298B) -------------------------------------------------------- | |
942 void Player::PutItemArInventoryIndex( int uItemID, int itemListPos, int index ) //originally accepted ItemGen* but needed only its uItemID | |
943 { | |
944 Texture *item_texture; // esi@1 | |
945 int *pInvPos; // esi@4 | |
946 unsigned int slot_width; // [sp+Ch] [bp-4h]@1 | |
947 unsigned int slot_height; // [sp+18h] [bp+8h]@1 | |
948 | |
949 item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); | |
950 slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); | |
951 slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight); | |
952 if ( !areWeLoadingTexture ) | |
953 { | |
954 item_texture->Release(); | |
955 pIcons_LOD->SyncLoadedFilesCount(); | |
956 } | |
957 if ( slot_width > 0 ) | |
958 { | |
959 pInvPos = &pInventoryMatrix[index]; | |
960 for (unsigned int i = 0; i < slot_height; i++) | |
961 { | |
962 memset32(pInvPos, -1 - index, slot_width);//TODO: try to come up with a better solution. negative values are used when drawing the inventory - nothing is drawn | |
963 pInvPos += INVETORYSLOTSWIDTH; | |
964 } | |
965 } | |
966 pInventoryMatrix[index] = itemListPos + 1; | |
967 } | |
968 | |
969 // 506128: using guessed type int areWeLoadingTexture; | |
970 | |
971 //----- (00492A36) -------------------------------------------------------- | |
972 void Player::RemoveItemAtInventoryIndex( unsigned int index ) | |
973 { | |
974 ItemGen *item_in_slot; // ecx@1 | |
975 Texture *item_texture; // esi@1 | |
976 unsigned int slot_height; // ebp@1 | |
977 int *pInvPos; // edx@4 | |
978 unsigned int slot_width; // [sp+14h] [bp+4h]@1 | |
979 | |
980 item_in_slot = &this->pInventoryItemList[pInventoryMatrix[index]-1]; | |
981 item_texture = pIcons_LOD->LoadTexturePtr(item_in_slot->GetIconName(), TEXTURE_16BIT_PALETTE); | |
982 item_in_slot->Reset(); | |
983 slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); | |
984 slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight); | |
985 if ( !areWeLoadingTexture ) | |
986 { | |
987 item_texture->Release(); | |
988 pIcons_LOD->SyncLoadedFilesCount(); | |
989 } | |
990 if ( slot_width > 0 ) | |
991 { | |
992 pInvPos = &pInventoryMatrix[index]; | |
993 for (unsigned int i = 0; i < slot_height; i++) | |
994 { | |
995 memset32(pInvPos, 0, slot_width); | |
996 pInvPos += INVETORYSLOTSWIDTH; | |
997 } | |
998 } | |
999 } | |
1000 // 506128: using guessed type int areWeLoadingTexture; | |
1001 | |
1002 //----- (00490EEE) -------------------------------------------------------- | |
1003 int Player::SelectPhrasesTransaction(ItemGen *pItem, int building_type, int BuildID_2Events, int ShopMenuType) //TODO: probably move this somewhere else, not really Player:: stuff | |
1004 { | |
1005 unsigned int idemId; // edx@1 | |
1006 signed int equipType; // esi@1 | |
1007 float multiplier; // ST04_4@26 | |
1008 int price; // edi@26 | |
1009 int merchantLevel; // [sp+10h] [bp-8h]@1 | |
1010 int itemValue; | |
1011 | |
1012 merchantLevel = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); | |
1013 idemId = pItem->uItemID; | |
1014 equipType = pItem->GetItemEquipType(); | |
1015 itemValue = pItem->GetValue(); | |
1016 | |
1017 switch (building_type) | |
1018 { | |
1019 case BuildingType_WeaponShop: | |
1020 if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) | |
1021 return 5; | |
1022 if (equipType > EQUIP_BOW) | |
1023 return 4; | |
1024 break; | |
1025 case BuildingType_ArmorShop: | |
1026 if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) | |
1027 return 5; | |
1028 if ( equipType < EQUIP_ARMOUR || equipType > EQUIP_BOOTS) | |
1029 return 4; | |
1030 break; | |
1031 case BuildingType_MagicShop: | |
1032 if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) | |
1033 return 5; | |
1034 if ( pItemsTable->pItems[idemId].uSkillType != PLAYER_SKILL_MISC ) | |
1035 return 4; | |
1036 break; | |
1037 case BuildingType_AlchemistShop: | |
1038 if ((idemId >= ITEM_ARTIFACT_HERMES_SANDALS && idemId < ITEM_RECIPE_REJUVENATION) || idemId > ITEM_RECIPE_BODY_RESISTANCE) | |
1039 return 5; | |
1040 if ( !(equipType == EQUIP_REAGENT || equipType == EQUIP_POTION || equipType == EQUIP_MESSAGE_SCROLL)) | |
1041 return 4; | |
1042 break; | |
1043 default: | |
1044 Error("(%u)", building_type); | |
1045 break; | |
1046 } | |
1047 if (pItem->IsStolen()) | |
1048 return 6; | |
1049 | |
1050 multiplier = p2DEvents[BuildID_2Events - 1].fPriceMultiplier; | |
1051 switch (ShopMenuType) | |
1052 { | |
1053 case 2: | |
1054 price = GetBuyingPrice(itemValue, multiplier); | |
1055 break; | |
1056 case 3: | |
1057 if (pItem->IsBroken()) | |
1058 price = 1; | |
1059 else | |
1060 price = this->GetPriceSell(itemValue, multiplier); | |
1061 break; | |
1062 case 4: | |
1063 price = this->GetPriceIdentification(multiplier); | |
1064 break; | |
1065 case 5: | |
1066 price = this->GetPriceRepair(itemValue, multiplier); | |
1067 break; | |
1068 default: | |
1069 Error("(%u)", ShopMenuType); | |
1070 break; | |
1071 } | |
1072 if ( merchantLevel ) | |
1073 { | |
1074 if (price == itemValue) | |
1075 { | |
1076 return 3; | |
1077 } | |
1078 else | |
1079 { | |
1080 return 2; | |
1081 } | |
1082 } | |
1083 else | |
1084 { | |
1085 return 1; | |
1086 } | |
1087 } | |
1088 | |
1089 //----- (0049107D) -------------------------------------------------------- | |
1090 int Player::GetBodybuilding() | |
1091 { | |
1092 int v1; // al@1 | |
1093 | |
1094 v1 = GetActualSkillLevel(PLAYER_SKILL_BODYBUILDING); | |
1095 int multiplier = GetMultiplierForSkillLevel(v1, 1, 2, 3, 5); | |
1096 return multiplier * (v1 & 0x3F); | |
1097 } | |
1098 | |
1099 //----- (004910A8) -------------------------------------------------------- | |
1100 int Player::GetMeditation() | |
1101 { | |
1102 int v1; // al@1 | |
1103 | |
1104 v1 = GetActualSkillLevel(PLAYER_SKILL_MEDITATION); | |
1105 int multiplier = GetMultiplierForSkillLevel(v1, 1, 2, 3, 5); | |
1106 return multiplier * (v1 & 0x3F); | |
1107 } | |
1108 | |
1109 //----- (004910D3) -------------------------------------------------------- | |
1110 bool Player::CanIdentify( ItemGen *pItem ) | |
1111 { | |
1112 unsigned __int16 v2; // ax@1 | |
1113 int v5; // edi@7 | |
1114 if (CheckHiredNPCSpeciality(Scholar)) | |
1115 return true; | |
1116 | |
1117 v2 = GetActualSkillLevel(PLAYER_SKILL_ITEM_ID); | |
1118 if ( (signed int)SkillToMastery(v2) >= 4 ) | |
1119 return true; | |
1120 | |
1121 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); | |
1122 v5 = multiplier * (v2 & 0x3F); | |
1123 return v5 >= pItemsTable->pItems[pItem->uItemID].uItemID_Rep_St; | |
1124 } | |
1125 | |
1126 //----- (00491151) -------------------------------------------------------- | |
1127 bool Player::CanRepair( ItemGen *pItem ) | |
1128 { | |
1129 unsigned __int16 v2; // ax@1 | |
1130 int v5; // edi@7 | |
1131 | |
1132 ITEM_EQUIP_TYPE equipType = pItem->GetItemEquipType(); | |
1133 if (CheckHiredNPCSpeciality(Smith) && equipType <= 2 || | |
1134 CheckHiredNPCSpeciality(Armorer) && equipType >= 3 && equipType <= 9 || | |
1135 CheckHiredNPCSpeciality(Alchemist) && equipType >= 9 ) | |
1136 return true; | |
1137 | |
1138 v2 = GetActualSkillLevel(PLAYER_SKILL_REPAIR); | |
1139 if ( (signed int)SkillToMastery(v2) >= 4 ) | |
1140 return true; | |
1141 | |
1142 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); | |
1143 v5 = multiplier * (v2 & 0x3F); | |
1144 return v5 >= pItemsTable->pItems[pItem->uItemID].uItemID_Rep_St; | |
1145 } | |
1146 | |
1147 //----- (004911F3) -------------------------------------------------------- | |
1148 int Player::GetMerchant() | |
1149 { | |
1150 unsigned __int16 v2; // ax@1 | |
1151 int v5; // edi@1 | |
1152 int v7; // eax@3 | |
1153 | |
1154 v2 = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); | |
1155 if ( SkillToMastery(v2) >= 4 ) | |
1156 return 10000; | |
1157 | |
1158 v7 = pParty->GetPartyReputation(); | |
1159 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); | |
1160 v5 = multiplier * (v2 & 0x3F); | |
1161 if (v5 == 0) | |
1162 { | |
1163 return -v7; | |
1164 } | |
1165 return v5 - v7 + 7; | |
1166 } | |
1167 | |
1168 //----- (0049125A) -------------------------------------------------------- | |
1169 int Player::GetPerception() | |
1170 { | |
1171 unsigned __int16 v2; // ax@1 | |
1172 int v5; // edi@1 | |
1173 | |
1174 v2 = GetActualSkillLevel(PLAYER_SKILL_PERCEPTION); | |
1175 if ( SkillToMastery(v2) >= 4 ) | |
1176 return 10000; | |
1177 | |
1178 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); | |
1179 v5 = multiplier * (v2 & 0x3F); | |
1180 return v5; | |
1181 } | |
1182 | |
1183 //----- (004912B0) -------------------------------------------------------- | |
1184 int Player::GetDisarmTrap() | |
1185 { | |
1186 unsigned __int16 v2; // ax@1 | |
1187 int v5; // edi@1 | |
1188 | |
1189 v2 = GetActualSkillLevel(PLAYER_SKILL_TRAP_DISARM); | |
1190 if ( (signed int)SkillToMastery(v2) >= 4 ) | |
1191 return 10000; | |
1192 | |
1193 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); | |
1194 if ( HasEnchantedItemEquipped(35) ) //only the real skill level is supposed to be added again, not the multiplied value | |
1195 multiplier++; | |
1196 v5 = multiplier * (v2 & 0x3F); | |
1197 return v5; | |
1198 } | |
1199 | |
1200 //----- (00491317) -------------------------------------------------------- | |
1201 char Player::GetLearningPercent() | |
1202 { | |
1203 int v2; // eax@1 | |
1204 | |
1205 v2 = GetActualSkillLevel(PLAYER_SKILL_LEARNING); | |
1206 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); | |
1207 return multiplier * v2 + 9; | |
1208 } | |
1209 | |
1210 //----- (0048C6AF) -------------------------------------------------------- | |
1211 Player::Player() | |
1212 { | |
1213 memset(&pEquipment, 0, sizeof(PlayerEquipment)); | |
1214 pInventoryMatrix.fill(0); | |
1215 for (uint i = 0; i < 126; ++i) | |
1216 pInventoryItemList[i].Reset(); | |
1217 for (uint i = 0; i < 12; ++i) | |
1218 pEquippedItems[i].Reset(); | |
1219 | |
1220 | |
1221 for (uint i = 0; i < 24; ++i) | |
1222 { | |
1223 pPlayerBuffs[i].uSkill = 0; | |
1224 pPlayerBuffs[i].uSkill = 0; | |
1225 pPlayerBuffs[i].uPower = 0; | |
1226 pPlayerBuffs[i].uExpireTime = 0; | |
1227 pPlayerBuffs[i].uCaster = 0; | |
1228 pPlayerBuffs[i].uFlags = 0; | |
1229 } | |
1230 | |
1231 pName[0] = 0; | |
1232 uCurrentFace = 0; | |
1233 uVoiceID = 0; | |
1234 pConditions.fill(0); | |
1235 | |
1236 field_BB = 0; | |
1237 | |
1238 uMight = uMightBonus = 0; | |
1239 uIntelligence = uIntelligenceBonus = 0; | |
1240 uWillpower = uWillpowerBonus = 0; | |
1241 uEndurance = uEnduranceBonus = 0; | |
1242 uSpeed = uSpeedBonus = 0; | |
1243 uAccuracy = uAccuracyBonus = 0; | |
1244 uLuck = uLuckBonus = 0; | |
1245 uLevel = sLevelModifier = 0; | |
1246 sAgeModifier = 0; | |
1247 sACModifier = 0; | |
1248 | |
1249 // memset(field_1F5, 0, 30); | |
1250 pure_luck_used=0; | |
1251 pure_speed_used=0; | |
1252 pure_intellect_used=0; | |
1253 pure_endurance_used=0; | |
1254 pure_willpower_used=0; | |
1255 pure_accuracy_used=0; | |
1256 pure_might_used=0; | |
1257 | |
1258 sResFireBase = sResFireBonus = 0; | |
1259 sResAirBase = sResAirBonus = 0; | |
1260 sResWaterBase = sResWaterBonus = 0; | |
1261 sResEarthBase = sResEarthBonus = 0; | |
1262 sResMagicBase = sResMagicBonus = 0; | |
1263 sResSpiritBase = sResSpiritBonus = 0; | |
1264 sResMindBase = sResMindBonus = 0; | |
1265 sResBodyBase = sResBodyBonus = 0; | |
1266 sResLightBase = sResLightBonus = 0; | |
1267 sResDarkBase = sResDarkBonus = 0; | |
1268 | |
1269 uTimeToRecovery = 0; | |
1270 | |
1271 uSkillPoints = 0; | |
1272 | |
1273 sHealth = 0; | |
1274 uFullHealthBonus = 0; | |
1275 _health_related = 0; | |
1276 | |
1277 sMana = 0; | |
1278 uFullManaBonus = 0; | |
1279 _mana_related = 0; | |
1280 | |
1281 uQuickSpell = 0; | |
1282 memset(pInstalledBeacons.data(), 0, 5 * sizeof(LloydBeacon)); | |
1283 | |
1284 _some_attack_bonus = 0; | |
1285 field_1A91 = 0; | |
1286 _melee_dmg_bonus = 0; | |
1287 field_1A93 = 0; | |
1288 _ranged_atk_bonus = 0; | |
1289 field_1A95 = 0; | |
1290 _ranged_dmg_bonus = 0; | |
1291 field_1A97 = 0; | |
1292 | |
1293 expression = CHARACTER_EXPRESSION_INVALID; | |
1294 uExpressionTimePassed = 0; | |
1295 uExpressionTimeLength = 0; | |
1296 | |
1297 uNumDivineInterventionCastsThisDay = 0; | |
1298 uNumArmageddonCasts = 0; | |
1299 uNumFireSpikeCasts = 0; | |
1300 | |
1301 memset(field_1988, 0, sizeof(field_1988)); | |
1302 memset(playerEventBits, 0, sizeof(playerEventBits)); | |
1303 | |
1304 field_E0 = 0; | |
1305 field_E4 = 0; | |
1306 field_E8 = 0; | |
1307 field_EC = 0; | |
1308 field_F0 = 0; | |
1309 field_F4 = 0; | |
1310 field_F8 = 0; | |
1311 field_FC = 0; | |
1312 field_100 = 0; | |
1313 field_104 = 0; | |
1314 | |
1315 _expression21_animtime = 0; | |
1316 _expression21_frameset = 0; | |
1317 | |
1318 lastOpenedSpellbookPage = 0; | |
1319 } | |
1320 | |
1321 | |
1322 //----- (0048C855) -------------------------------------------------------- | |
1323 int Player::GetBaseStrength() | |
1324 { | |
1325 return this->uMight + GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH); | |
1326 } | |
1327 | |
1328 //----- (0048C86C) -------------------------------------------------------- | |
1329 int Player::GetBaseIntelligence() | |
1330 { | |
1331 return this->uIntelligence + GetItemsBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE); | |
1332 } | |
1333 | |
1334 //----- (0048C883) -------------------------------------------------------- | |
1335 int Player::GetBaseWillpower() | |
1336 { | |
1337 return this->uWillpower + GetItemsBonus(CHARACTER_ATTRIBUTE_WILLPOWER); | |
1338 } | |
1339 | |
1340 //----- (0048C89A) -------------------------------------------------------- | |
1341 int Player::GetBaseEndurance() | |
1342 { | |
1343 return this->uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE); | |
1344 } | |
1345 | |
1346 //----- (0048C8B1) -------------------------------------------------------- | |
1347 int Player::GetBaseAccuracy() | |
1348 { | |
1349 return this->uAccuracy + GetItemsBonus(CHARACTER_ATTRIBUTE_ACCURACY); | |
1350 } | |
1351 | |
1352 //----- (0048C8C8) -------------------------------------------------------- | |
1353 int Player::GetBaseSpeed() | |
1354 { | |
1355 return this->uSpeed + GetItemsBonus(CHARACTER_ATTRIBUTE_SPEED); | |
1356 } | |
1357 | |
1358 //----- (0048C8DF) -------------------------------------------------------- | |
1359 int Player::GetBaseLuck() | |
1360 { | |
1361 return this->uLuck + GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK); | |
1362 } | |
1363 | |
1364 //----- (0048C8F6) -------------------------------------------------------- | |
1365 int Player::GetBaseLevel() | |
1366 { | |
1367 return this->uLevel + GetItemsBonus(CHARACTER_ATTRIBUTE_LEVEL); | |
1368 } | |
1369 | |
1370 //----- (0048C90D) -------------------------------------------------------- | |
1371 int Player::GetActualLevel() | |
1372 { | |
1373 return uLevel + sLevelModifier + | |
1374 GetMagicalBonus(CHARACTER_ATTRIBUTE_LEVEL) + | |
1375 GetItemsBonus(CHARACTER_ATTRIBUTE_LEVEL); | |
1376 } | |
1377 | |
1378 //----- (0048C93C) -------------------------------------------------------- | |
1379 int Player::GetActualMight() | |
1380 { | |
1381 return GetActualAttribute(CHARACTER_ATTRIBUTE_STRENGTH, &Player::uMight, &Player::uMightBonus); | |
1382 } | |
1383 | |
1384 //----- (0048C9C2) -------------------------------------------------------- | |
1385 int Player::GetActualIntelligence() | |
1386 { | |
1387 return GetActualAttribute(CHARACTER_ATTRIBUTE_INTELLIGENCE, &Player::uIntelligence, &Player::uIntelligenceBonus); | |
1388 } | |
1389 | |
1390 //----- (0048CA3F) -------------------------------------------------------- | |
1391 int Player::GetActualWillpower() | |
1392 { | |
1393 return GetActualAttribute(CHARACTER_ATTRIBUTE_WILLPOWER, &Player::uWillpower, &Player::uWillpowerBonus); | |
1394 } | |
1395 | |
1396 //----- (0048CABC) -------------------------------------------------------- | |
1397 int Player::GetActualEndurance() | |
1398 { | |
1399 return GetActualAttribute(CHARACTER_ATTRIBUTE_ENDURANCE, &Player::uEndurance, &Player::uEnduranceBonus); | |
1400 } | |
1401 | |
1402 //----- (0048CB39) -------------------------------------------------------- | |
1403 int Player::GetActualAccuracy() | |
1404 { | |
1405 return GetActualAttribute(CHARACTER_ATTRIBUTE_ACCURACY, &Player::uAccuracy, &Player::uAccuracyBonus); | |
1406 } | |
1407 | |
1408 //----- (0048CBB6) -------------------------------------------------------- | |
1409 int Player::GetActualSpeed() | |
1410 { | |
1411 return GetActualAttribute(CHARACTER_ATTRIBUTE_SPEED, &Player::uSpeed, &Player::uSpeedBonus); | |
1412 } | |
1413 | |
1414 //----- (0048CC33) -------------------------------------------------------- | |
1415 int Player::GetActualLuck() | |
1416 { | |
1417 signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1 | |
1418 | |
1419 npc_luck_bonus = 0; | |
1420 if ( CheckHiredNPCSpeciality(Fool) ) | |
1421 npc_luck_bonus = 5; | |
1422 if ( CheckHiredNPCSpeciality(ChimneySweep) ) | |
1423 npc_luck_bonus += 20; | |
1424 if ( CheckHiredNPCSpeciality(Psychic) ) | |
1425 npc_luck_bonus += 10; | |
1426 | |
1427 return GetActualAttribute(CHARACTER_ATTRIBUTE_LUCK, &Player::uLuck, &Player::uLuckBonus) | |
1428 + npc_luck_bonus; | |
1429 } | |
1430 | |
1431 //----- (new function) -------------------------------------------------------- | |
1432 int Player::GetActualAttribute( CHARACTER_ATTRIBUTE_TYPE attrId, unsigned short Player::* attrValue, unsigned short Player::* attrBonus ) | |
1433 { | |
1434 uint uActualAge = this->sAgeModifier + GetBaseAge(); | |
1435 uint uAgeingMultiplier = 100; | |
1436 for (uint i = 0; i < 4; ++i) | |
1437 { | |
1438 if (uActualAge >= pAgeingTable[i]) | |
1439 uAgeingMultiplier = pAgingAttributeModifier[attrId][i]; | |
1440 else | |
1441 break; | |
1442 } | |
1443 | |
1444 uchar uConditionMult = pConditionAttributeModifier[attrId][GetMajorConditionIdx()]; | |
1445 int magicBonus = GetMagicalBonus(attrId); | |
1446 int itemBonus = GetItemsBonus(attrId); | |
1447 return uConditionMult * uAgeingMultiplier * this->*attrValue / 100 / 100 | |
1448 + magicBonus | |
1449 + itemBonus | |
1450 + this->*attrBonus; | |
1451 } | |
1452 | |
1453 //----- (0048CCF5) -------------------------------------------------------- | |
1454 int Player::GetActualAttack( bool a2 ) | |
1455 { | |
1456 int v3; // eax@1 | |
1457 int v4; // edi@1 | |
1458 int v5; // ebx@1 | |
1459 int v6; // ebp@1 | |
1460 | |
1461 v3 = GetActualAccuracy(); | |
1462 v4 = GetParameterBonus(v3); | |
1463 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK); | |
1464 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2); | |
1465 return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + this->_some_attack_bonus; | |
1466 } | |
1467 | |
1468 //----- (0048CD45) -------------------------------------------------------- | |
1469 int Player::GetMeleeDamageMinimal() | |
1470 { | |
1471 int v2; // eax@1 | |
1472 int v3; // esi@1 | |
1473 int v4; // esi@1 | |
1474 int v5; // esi@1 | |
1475 signed int result; // eax@1 | |
1476 | |
1477 v2 = GetActualMight(); | |
1478 v3 = GetParameterBonus(v2); | |
1479 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN) + v3; | |
1480 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; | |
1481 result = _melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; | |
1482 if ( result < 1 ) | |
1483 result = 1; | |
1484 return result; | |
1485 } | |
1486 | |
1487 //----- (0048CD90) -------------------------------------------------------- | |
1488 int Player::GetMeleeDamageMaximal() | |
1489 { | |
1490 int v2; // eax@1 | |
1491 int v3; // esi@1 | |
1492 int v4; // esi@1 | |
1493 int v5; // esi@1 | |
1494 int v6; // esi@1 | |
1495 signed int result; // eax@1 | |
1496 | |
1497 v2 = GetActualMight(); | |
1498 v3 = GetParameterBonus(v2); | |
1499 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX) + v3; | |
1500 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; | |
1501 v6 = this->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; | |
1502 result = 1; | |
1503 if ( v6 >= 1 ) | |
1504 result = v6; | |
1505 return result; | |
1506 } | |
1507 | |
1508 //----- (0048CDDB) -------------------------------------------------------- | |
1509 int Player::CalculateMeleeDamageTo( bool ignoreSkillBonus, bool ignoreOffhand, unsigned int uTargetActorID ) | |
1510 { | |
1511 int dmgSum; // esi@62 | |
1512 signed int result; // eax@64 | |
1513 int mainWpnDmg; // [sp+18h] [bp-8h]@1 | |
1514 int offHndWpnDmg; // [sp+1Ch] [bp-4h]@1 | |
1515 | |
1516 offHndWpnDmg = 0; | |
1517 mainWpnDmg = 0; | |
1518 if ( IsUnarmed() ) | |
1519 { | |
1520 mainWpnDmg = rand() % 3 + 1; | |
1521 } | |
1522 else | |
1523 { | |
1524 if ( HasItemEquipped(EQUIP_TWO_HANDED) ) | |
1525 { | |
1526 ItemGen *mainHandItemGen = this->GetMainHandItem(); | |
1527 int itemId = mainHandItemGen->uItemID; | |
1528 bool addOneDice = false; | |
1529 if ( pItemsTable->pItems[itemId].uSkillType == PLAYER_SKILL_SPEAR && !this->pEquipment.uShield ) | |
1530 addOneDice = true; | |
1531 mainWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(mainHandItemGen, uTargetActorID, addOneDice); | |
1532 } | |
1533 if ( !ignoreOffhand ) | |
1534 { | |
1535 if ( this->HasItemEquipped(EQUIP_SINGLE_HANDED) ) | |
1536 { | |
1537 ItemGen *offHandItemGen = (ItemGen *)&this->pInventoryItemList[this->pEquipment.uShield - 1]; | |
1538 if ( offHandItemGen->GetItemEquipType() != EQUIP_SHIELD ) | |
1539 { | |
1540 offHndWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(offHandItemGen, uTargetActorID, false); | |
1541 } | |
1542 } | |
1543 } | |
1544 } | |
1545 dmgSum = mainWpnDmg + offHndWpnDmg; | |
1546 if ( !ignoreSkillBonus ) | |
1547 { | |
1548 int might = GetActualMight(); | |
1549 int mightBonus = GetParameterBonus(might); | |
1550 int mightAndSkillbonus = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + mightBonus; | |
1551 dmgSum += this->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + mightAndSkillbonus; | |
1552 } | |
1553 result = 1; | |
1554 if ( dmgSum >= 1 ) | |
1555 result = dmgSum; | |
1556 return result; | |
1557 } | |
1558 | |
1559 | |
1560 int Player::CalculateMeleeDmgToEnemyWithWeapon( ItemGen * weapon, unsigned int uTargetActorID , bool addOneDice ) | |
1561 { | |
1562 int itemId = weapon->uItemID; | |
1563 int diceCount = pItemsTable->pItems[itemId].uDamageDice; | |
1564 if (addOneDice) | |
1565 { | |
1566 diceCount++; | |
1567 } | |
1568 int diceSides = pItemsTable->pItems[itemId].uDamageRoll; | |
1569 int diceResult = 0; | |
1570 for (int i = 0; i < diceCount; i++) | |
1571 { | |
1572 diceResult += rand() % diceSides + 1; | |
1573 } | |
1574 int totalDmg = pItemsTable->pItems[itemId].uDamageMod + diceResult; | |
1575 if ( uTargetActorID > 0) | |
1576 { | |
1577 int enchType = weapon->uSpecEnchantmentType; | |
1578 if ( MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_UNDEAD) && (enchType == 64 || itemId == ITEM_ARTIFACT_GHOULSBANE || itemId == ITEM_ARTIFACT_GIBBET || itemId == ITEM_RELIC_JUSTICE) ) | |
1579 { | |
1580 totalDmg *= 2; | |
1581 } | |
1582 else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_KREEGAN) && ( enchType == 39 || itemId == ITEM_ARTIFACT_GIBBET)) | |
1583 { | |
1584 totalDmg *= 2; | |
1585 } | |
1586 else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_DRAGON) && ( enchType == 40 || itemId == ITEM_ARTIFACT_GIBBET)) | |
1587 { | |
1588 totalDmg *= 2; | |
1589 } | |
1590 else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_ELF) && ( enchType == 63 || itemId == ITEM_RELIC_OLD_NICK)) | |
1591 { | |
1592 totalDmg *= 2; | |
1593 } | |
1594 else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_TITAN) && ( enchType == 65 )) | |
1595 { | |
1596 totalDmg *= 2; | |
1597 } | |
1598 } | |
1599 if ( (signed int)SkillToMastery(this->pActiveSkills[PLAYER_SKILL_DAGGER]) >= 3 | |
1600 && pItemsTable->pItems[itemId].uSkillType == 2 | |
1601 && rand() % 100 < 10 ) | |
1602 totalDmg *= 3; | |
1603 return totalDmg; | |
1604 } | |
1605 | |
1606 | |
1607 //----- (0048D0B9) -------------------------------------------------------- | |
1608 int Player::GetRangedAttack() | |
1609 { | |
1610 int v3; // edi@3 | |
1611 //int v4; // eax@4 | |
1612 //int v5; // edi@4 | |
1613 int v6; // edi@4 | |
1614 int v7; // edi@4 | |
1615 | |
1616 ItemGen* mainHandItem = GetMainHandItem(); | |
1617 if ( mainHandItem != nullptr && ( mainHandItem->uItemID < ITEM_BLASTER || mainHandItem->uItemID > ITEM_LASER_RIFLE )) | |
1618 { | |
1619 //v4 = GetActualAccuracy(); | |
1620 //v5 = GetParameterBonus(GetActualAccuracy()); | |
1621 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + GetParameterBonus(GetActualAccuracy()); | |
1622 v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6; | |
1623 v3 = this->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7; | |
1624 } | |
1625 else | |
1626 { | |
1627 v3 = GetActualAttack(true); | |
1628 } | |
1629 return v3; | |
1630 } | |
1631 | |
1632 //----- (0048D124) -------------------------------------------------------- | |
1633 int Player::GetRangedDamageMin() | |
1634 { | |
1635 int v2; // edi@1 | |
1636 int v3; // edi@1 | |
1637 int v4; // edi@1 | |
1638 int result; // eax@6 | |
1639 | |
1640 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MIN); | |
1641 v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; | |
1642 v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; | |
1643 if ( v4 >= 1 ) | |
1644 result = v4; | |
1645 else | |
1646 result = 0; | |
1647 return result; | |
1648 } | |
1649 | |
1650 //----- (0048D191) -------------------------------------------------------- | |
1651 int Player::GetRangedDamageMax() | |
1652 { | |
1653 int v2; // edi@1 | |
1654 int v3; // edi@1 | |
1655 int v4; // edi@1 | |
1656 int result; // eax@6 | |
1657 | |
1658 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MAX); | |
1659 v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; | |
1660 v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; | |
1661 if ( v4 >= 1 ) | |
1662 result = v4; | |
1663 else | |
1664 result = 0; | |
1665 return result; | |
1666 } | |
1667 | |
1668 //----- (0048D1FE) -------------------------------------------------------- | |
1669 int Player::CalculateRangedDamageTo( int a2 ) | |
1670 { | |
1671 ItemGen *v4; // ebx@2 | |
1672 unsigned int v5; // edi@2 | |
1673 int v9; // esi@5 | |
1674 int v10; // ebx@6 | |
1675 signed int v15; // [sp+8h] [bp-Ch]@2 | |
1676 int v17; // [sp+10h] [bp-4h]@1 | |
1677 | |
1678 v17 = 0; | |
1679 if ( !HasItemEquipped(EQUIP_BOW) ) | |
1680 return 0; | |
1681 v4 = (ItemGen *)&this->pInventoryItemList[this->pEquipment.uBow-1]; | |
1682 v5 = v4->uItemID; | |
1683 v15 = pItemsTable->pItems[v5].uDamageRoll; | |
1684 for( int i = 0; i < pItemsTable->pItems[v5].uDamageDice; i++ ) | |
1685 { | |
1686 int v7 = rand() % v15; | |
1687 v17 += v7 + 1; | |
1688 } | |
1689 v9 = pItemsTable->pItems[v5].uDamageMod + v17; | |
1690 if ( a2 ) | |
1691 { | |
1692 v10 = v4->uSpecEnchantmentType; | |
1693 if ( v10 == 64 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_UNDEAD)) | |
1694 { | |
1695 v9 *= 2; | |
1696 } | |
1697 else if ( v10 == 39 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_KREEGAN)) | |
1698 { | |
1699 v9 *= 2; | |
1700 } | |
1701 else if ( v10 == 40 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_DRAGON)) | |
1702 { | |
1703 v9 *= 2; | |
1704 } | |
1705 else if ( v10 == 63 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_ELF)) | |
1706 { | |
1707 v9 *= 2; | |
1708 } | |
1709 } | |
1710 return v9 + this->GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS); | |
1711 } | |
1712 | |
1713 //----- (0048D2EA) -------------------------------------------------------- | |
1714 char *Player::GetMeleeDamageString() | |
1715 { | |
1716 int min_damage; // edi@3 | |
1717 int max_damage; // eax@3 | |
1718 | |
1719 static char player__getmeleedamagestring_static_buff[40]; // idb | |
1720 | |
1721 ItemGen* mainHandItem = GetMainHandItem(); | |
1722 | |
1723 if (mainHandItem != nullptr && ( mainHandItem->uItemID >= 135 ) && ( mainHandItem->uItemID <= 159 )) | |
1724 { | |
1725 strcpy(player__getmeleedamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" | |
1726 return player__getmeleedamagestring_static_buff; | |
1727 } | |
1728 else if (mainHandItem != nullptr && (mainHandItem->uItemID == ITEM_BLASTER || mainHandItem->uItemID == ITEM_LASER_RIFLE)) | |
1729 { | |
1730 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true); | |
1731 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true); | |
1732 } | |
1733 else | |
1734 { | |
1735 min_damage = GetMeleeDamageMinimal(); | |
1736 max_damage = GetMeleeDamageMaximal(); | |
1737 } | |
1738 if ( min_damage == max_damage ) | |
1739 { | |
1740 sprintf(player__getmeleedamagestring_static_buff, "%d", min_damage); | |
1741 } | |
1742 else | |
1743 { | |
1744 sprintf(player__getmeleedamagestring_static_buff, "%d - %d", min_damage, max_damage); | |
1745 } | |
1746 return player__getmeleedamagestring_static_buff; | |
1747 } | |
1748 | |
1749 //----- (0048D396) -------------------------------------------------------- | |
1750 char *Player::GetRangedDamageString() | |
1751 { | |
1752 int min_damage; // edi@3 | |
1753 int max_damage; // eax@3 | |
1754 | |
1755 static char player__getrangeddamagestring_static_buff[40]; // idb | |
1756 | |
1757 ItemGen* mainHandItem = GetMainHandItem(); | |
1758 | |
1759 if (mainHandItem != nullptr && ( mainHandItem->uItemID >= 135 ) && ( mainHandItem->uItemID <= 159 )) | |
1760 { | |
1761 strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" | |
1762 return player__getrangeddamagestring_static_buff; | |
1763 } | |
1764 else if (mainHandItem != nullptr && (mainHandItem->uItemID == ITEM_BLASTER || mainHandItem->uItemID == ITEM_LASER_RIFLE)) | |
1765 { | |
1766 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true); | |
1767 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true); | |
1768 } | |
1769 else | |
1770 { | |
1771 min_damage = GetRangedDamageMin(); | |
1772 max_damage = GetRangedDamageMax(); | |
1773 } | |
1774 if ( max_damage > 0) | |
1775 { | |
1776 if ( min_damage == max_damage ) | |
1777 { | |
1778 sprintf(player__getrangeddamagestring_static_buff, "%d", min_damage); | |
1779 } | |
1780 else | |
1781 { | |
1782 sprintf(player__getrangeddamagestring_static_buff, "%d - %d", min_damage, max_damage); | |
1783 } | |
1784 } | |
1785 else | |
1786 { | |
1787 strcpy(player__getrangeddamagestring_static_buff, "N/A"); | |
1788 } | |
1789 return player__getrangeddamagestring_static_buff; | |
1790 } | |
1791 | |
1792 //----- (0048D45A) -------------------------------------------------------- | |
1793 bool Player::CanTrainToNextLevel() | |
1794 { | |
1795 int lvl = this->uLevel + 1; | |
1796 int neededExp = ((lvl * (lvl - 1)) / 2 * 1000); | |
1797 return this->uExperience >= neededExp; | |
1798 } | |
1799 | |
1800 //----- (0048D498) -------------------------------------------------------- | |
1801 unsigned int Player::GetExperienceDisplayColor() | |
1802 { | |
1803 if ( CanTrainToNextLevel() ) | |
1804 return ui_character_bonus_text_color; | |
1805 else | |
1806 return ui_character_default_text_color; | |
1807 } | |
1808 | |
1809 //----- (0048D4B3) -------------------------------------------------------- | |
1810 int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int dmg ) | |
1811 { | |
1812 int resist_value; // edi@8 | |
1813 int player_luck; // eax@21 | |
1814 signed int res_rand_divider; // ebx@2 | |
1815 int armor_skill; // eax@29 | |
1816 | |
1817 if ( classType == PLAYER_CLASS_LICH && (dmg_type == CHARACTER_ATTRIBUTE_RESIST_MIND || dmg_type == CHARACTER_ATTRIBUTE_RESIST_BODY || dmg_type == CHARACTER_ATTRIBUTE_RESIST_SPIRIT )) //TODO: determine if spirit resistance should be handled by body res. modifier | |
1818 return 0; | |
1819 | |
1820 resist_value = 0; | |
1821 switch(dmg_type) | |
1822 { | |
1823 case DMGT_FIRE: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE); break; | |
1824 case DMGT_ELECTR: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR); break; | |
1825 case DMGT_COLD: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER); break; | |
1826 case DMGT_EARTH: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); break; | |
1827 | |
1828 case DMGT_SPIRIT: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_SPIRIT);break; | |
1829 case DMGT_MIND: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); break; | |
1830 case DMGT_BODY: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); break; | |
1831 } | |
1832 | |
1833 player_luck = GetActualLuck(); | |
1834 res_rand_divider = GetParameterBonus(player_luck) + resist_value + 30; | |
1835 | |
1836 if ( GetParameterBonus(player_luck) + resist_value > 0 ) | |
1837 { | |
1838 for (int i = 0; i < 4; i++) | |
1839 { | |
1840 if ( rand() % res_rand_divider >= 30 ) | |
1841 dmg >>= 1; | |
1842 else | |
1843 break; | |
1844 } | |
1845 } | |
1846 ItemGen* equippedArmor = GetArmorItem(); | |
1847 if (( dmg_type == DMGT_PHISYCAL ) && ( equippedArmor != nullptr )) | |
1848 { | |
1849 if (!equippedArmor->IsBroken()) | |
1850 { | |
1851 armor_skill = equippedArmor->GetPlayerSkillType(); | |
1852 if ( armor_skill==PLAYER_SKILL_PLATE ) | |
1853 { | |
1854 if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 ) | |
1855 return dmg / 2; | |
1856 } | |
1857 if (armor_skill==PLAYER_SKILL_CHAIN ) | |
1858 { | |
1859 if (SkillToMastery(pActiveSkills[PLAYER_SKILL_CHAIN]) == 4) | |
1860 return dmg * 2 / 3; | |
1861 } | |
1862 } | |
1863 } | |
1864 return dmg; | |
1865 } | |
1866 | |
1867 //----- (0048D62C) -------------------------------------------------------- | |
1868 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) | |
1869 { | |
1870 return GetNthEquippedIndexItem(uEquipSlot)->GetItemEquipType(); | |
1871 } | |
1872 | |
1873 //----- (0048D651) -------------------------------------------------------- | |
1874 PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot) | |
1875 { | |
1876 return (PLAYER_SKILL_TYPE)GetNthEquippedIndexItem(uEquipSlot)->GetPlayerSkillType(); | |
1877 } | |
1878 | |
1879 //----- (0048D676) -------------------------------------------------------- | |
1880 bool Player::IsUnarmed() | |
1881 { | |
1882 return !HasItemEquipped(EQUIP_TWO_HANDED) && | |
1883 (!HasItemEquipped(EQUIP_SINGLE_HANDED) || GetOffHandItem()->GetItemEquipType() == EQUIP_SHIELD); | |
1884 } | |
1885 | |
1886 //----- (0048D6AA) -------------------------------------------------------- | |
1887 bool Player::HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex) | |
1888 { | |
1889 uint i = pEquipment.pIndices[uEquipIndex]; | |
1890 if (i) | |
1891 return !pOwnItems[i - 1].IsBroken(); | |
1892 else | |
1893 return false; | |
1894 } | |
1895 | |
1896 //----- (0048D6D0) -------------------------------------------------------- | |
1897 bool Player::HasEnchantedItemEquipped(int uEnchantment) | |
1898 { | |
1899 for (uint i = 0; i < 16; ++i) | |
1900 { | |
1901 if (HasItemEquipped((ITEM_EQUIP_TYPE)i) && | |
1902 GetNthEquippedIndexItem(i)->uSpecEnchantmentType == uEnchantment) | |
1903 return true; | |
1904 } | |
1905 return false; | |
1906 } | |
1907 | |
1908 //----- (0048D709) -------------------------------------------------------- | |
1909 bool Player::WearsItem( int item_id, ITEM_EQUIP_TYPE equip_type ) | |
1910 { | |
1911 return ( HasItemEquipped(equip_type) && GetNthEquippedIndexItem(equip_type)->uItemID == item_id ); | |
1912 } | |
1913 | |
1914 bool Player::WearsItemAnyWhere(int item_id) | |
1915 { | |
1916 for (int i = 0; i < 16; i++) | |
1917 { | |
1918 if (WearsItem(item_id, (ITEM_EQUIP_TYPE) i)) | |
1919 { | |
1920 return true; | |
1921 } | |
1922 } | |
1923 return false; | |
1924 } | |
1925 | |
1926 //----- (0048D76C) -------------------------------------------------------- | |
1927 int Player::StealFromShop( ItemGen *itemToSteal, int extraStealDifficulty, int reputation, int a5, int *fineIfFailed ) //returns an int, but is the return value is compared to zero, so might change to bool | |
1928 { | |
1929 unsigned __int16 v6; // cx@8 | |
1930 int v7; // edi@8 | |
1931 unsigned int v8; // ebx@8 | |
1932 unsigned int itemvalue; // esi@8 | |
1933 int v10; // eax@8 | |
1934 int currMaxItemValue; // edi@12 | |
1935 | |
1936 if ( !itemToSteal | |
1937 || this->IsEradicated() | |
1938 || this->IsDead() | |
1939 || this->IsPertified() | |
1940 || this->IsDrunk() | |
1941 || this->IsUnconcious() | |
1942 || this->IsAsleep() ) | |
1943 { | |
1944 return 0; | |
1945 } | |
1946 else | |
1947 { | |
1948 v6 = this->pActiveSkills[PLAYER_SKILL_STEALING]; | |
1949 v7 = v6 & 0x3F; | |
1950 v8 = SkillToMastery(v6); | |
1951 itemvalue = itemToSteal->GetValue(); | |
1952 v10 = itemToSteal->GetItemEquipType(); | |
1953 if ( v10 == EQUIP_SINGLE_HANDED || v10 == EQUIP_TWO_HANDED || v10 == EQUIP_BOW ) | |
1954 itemvalue *= 3; | |
1955 currMaxItemValue = StealingRandomBonuses[rand() % 5] + v7 * StealingMasteryBonuses[v8]; | |
1956 *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue; | |
1957 if (a5) | |
1958 { | |
1959 *fineIfFailed += 500; | |
1960 } | |
1961 if ( rand() % 100 >= 5 ) | |
1962 { | |
1963 if ( *fineIfFailed > currMaxItemValue ) | |
1964 if (*fineIfFailed - currMaxItemValue < 500) | |
1965 { | |
1966 return 1; | |
1967 } | |
1968 else | |
1969 { | |
1970 return 0; | |
1971 } | |
1972 else | |
1973 return 2; | |
1974 } | |
1975 else | |
1976 { | |
1977 return 0; | |
1978 } | |
1979 } | |
1980 } | |
1981 | |
1982 //----- (0048D88B) -------------------------------------------------------- | |
1983 int Player::StealFromActor(unsigned int uActorID, int _steal_perm, int reputation) | |
1984 { | |
1985 Actor *actroPtr; // edi@1 | |
1986 int v7; // ebx@10 | |
1987 unsigned int stealingMastery; // esi@10 | |
1988 int fineIfFailed; // esi@10 | |
1989 int v11; // eax@13 | |
1990 bool HasFullItemSlots; // ebx@15 | |
1991 unsigned __int16 carriedItemId; // si@21 | |
1992 unsigned int enchBonusSum; // esi@31 | |
1993 int *enchTypePtr; // eax@34 | |
1994 ItemGen tempItem; // [sp+8h] [bp-34h]@15 | |
1995 int currMaxItemValue; | |
1996 | |
1997 actroPtr = &pActors[uActorID]; | |
1998 if ( !actroPtr | |
1999 || this->IsEradicated() | |
2000 || this->IsDead() | |
2001 || this->IsPertified() | |
2002 || this->IsDrunk() | |
2003 || this->IsUnconcious() | |
2004 || this->IsAsleep() ) | |
2005 { | |
2006 return 0; | |
2007 } | |
2008 if ( !actroPtr->ActorHasItem() ) | |
2009 actroPtr->SetRandomGoldIfTheresNoItem(); | |
2010 unsigned __int16 v6 = this->pActiveSkills[PLAYER_SKILL_STEALING]; | |
2011 v7 = v6 & 0x3F; | |
2012 stealingMastery = SkillToMastery(v6); | |
2013 int v30 = StealingMasteryBonuses[stealingMastery]; | |
2014 int v29 = StealingRandomBonuses[rand() % 5]; | |
2015 fineIfFailed = actroPtr->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation); | |
2016 currMaxItemValue = v29 + v7 * v30; | |
2017 if ( rand() % 100 < 5 || fineIfFailed > currMaxItemValue || actroPtr->ActorEnemy() ) | |
2018 { | |
2019 Actor::AggroSurroundingPeasants(uActorID, 1); | |
2020 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[376], this->pName);//"%s was caught stealing!" | |
2021 ShowStatusBarString(pTmpBuf2.data(), 2); | |
2022 return 0; | |
2023 } | |
2024 else | |
2025 { | |
2026 v11 = rand(); | |
2027 if ( v11 % 100 >= 70 ) //stealing gold | |
2028 { | |
2029 enchBonusSum = 0; | |
2030 for (int i = 0; i < v7; i++) | |
2031 enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; | |
2032 if ( actroPtr->ActorHasItems[3].GetItemEquipType() != EQUIP_GOLD ) | |
2033 return 2; | |
2034 enchTypePtr = &actroPtr->ActorHasItems[3].uSpecEnchantmentType; | |
2035 if ( (int)enchBonusSum >= *enchTypePtr ) | |
2036 { | |
2037 actroPtr->ActorHasItems[3].uItemID = 0; | |
2038 *enchTypePtr = 0; | |
2039 } | |
2040 else | |
2041 *enchTypePtr -= enchBonusSum; | |
2042 if ( enchBonusSum ) | |
2043 { | |
2044 pParty->PartyFindsGold(enchBonusSum, 2); | |
2045 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold | |
2046 } | |
2047 else | |
2048 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything | |
2049 ShowStatusBarString(pTmpBuf2.data(), 2); | |
2050 return 2; | |
2051 } | |
2052 else if ( v11 % 100 >= 40 ) //stealing an item | |
2053 { | |
2054 tempItem.Reset(); | |
2055 HasFullItemSlots = false; | |
2056 int i; | |
2057 for (i = 0; i < 4; i++) | |
2058 { | |
2059 if ( actroPtr->ActorHasItems[i].uItemID != 0 && actroPtr->ActorHasItems[i].GetItemEquipType() != EQUIP_GOLD ) | |
2060 break; | |
2061 } | |
2062 if (i == 4) | |
2063 HasFullItemSlots = true; | |
2064 carriedItemId = actroPtr->uCarriedItemID; | |
2065 if ( carriedItemId != 0 || HasFullItemSlots ) | |
2066 { | |
2067 tempItem.Reset(); | |
2068 if ( carriedItemId != 0 ) | |
2069 { | |
2070 actroPtr->uCarriedItemID = 0; | |
2071 tempItem.uItemID = carriedItemId; | |
2072 if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_WAND ) | |
2073 tempItem.uNumCharges = rand() % 6 + pItemsTable->pItems[carriedItemId].uDamageMod + 1; | |
2074 else if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_POTION && carriedItemId != ITEM_POTION_BOTTLE) | |
2075 tempItem.uEnchantmentType = 2 * rand() % 4 + 2; | |
2076 } | |
2077 else | |
2078 { | |
2079 ItemGen* itemToSteal = &actroPtr->ActorHasItems[rand() % 4]; | |
2080 memcpy(&tempItem, itemToSteal, sizeof(tempItem)); | |
2081 itemToSteal->Reset(); | |
2082 carriedItemId = tempItem.uItemID; | |
2083 } | |
2084 if (carriedItemId != 0) // looks odd in current context, but avoids accessing zeroth element of pItemsTable->pItems | |
2085 { | |
2086 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
2087 sprintf( | |
2088 pTmpBuf2.data(), | |
2089 pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message | |
2090 this->pName, | |
2091 pItemsTable->pItems[carriedItemId].pUnidentifiedName); | |
2092 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
2093 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
2094 memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); | |
2095 pMouse->SetCursorBitmapFromItemID(carriedItemId); | |
2096 return 2; | |
2097 } | |
2098 } | |
2099 } | |
2100 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything | |
2101 ShowStatusBarString(pTmpBuf2.data(), 2); | |
2102 return 2; | |
2103 } | |
2104 } | |
2105 // 4EDEA0: using guessed type int dword_4EDEA0[]; | |
2106 // 4EDEB4: using guessed type int dword_4EDEB4[]; | |
2107 // 4EDEC4: using guessed type int dword_4EDEC4[]; | |
2108 | |
2109 //----- (0048DBB9) -------------------------------------------------------- | |
2110 void Player::Heal(int amount) | |
2111 { | |
2112 signed int max_health; // eax@3 | |
2113 | |
2114 if ( !IsEradicated() && !IsDead() ) | |
2115 { | |
2116 max_health = GetMaxHealth(); | |
2117 if ( IsZombie() ) | |
2118 max_health /= 2; | |
2119 sHealth += amount; | |
2120 if ( sHealth > max_health ) | |
2121 sHealth = max_health; | |
2122 if ( IsUnconcious() ) | |
2123 { | |
2124 if ( sHealth > 0 ) | |
2125 { | |
2126 SetUnconcious(false); | |
2127 } | |
2128 } | |
2129 } | |
2130 } | |
2131 | |
2132 //----- (0048DC1E) -------------------------------------------------------- | |
2133 int Player::ReceiveDamage( signed int amount, DAMAGE_TYPE dmg_type ) | |
2134 { | |
2135 signed int recieved_dmg; // eax@1 | |
2136 bool broke_armor; | |
2137 | |
2138 SetAsleep(false); | |
2139 recieved_dmg = CalculateIncommingDamage(dmg_type, amount); | |
2140 sHealth -= recieved_dmg; | |
2141 broke_armor = sHealth <= -10; | |
2142 if ( sHealth < 1 ) // | |
2143 { | |
2144 if ( (sHealth + uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1) | |
2145 || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 ) | |
2146 { | |
2147 SetCondUnconsciousWithBlockCheck(false); | |
2148 } | |
2149 else | |
2150 { | |
2151 SetCondDeadWithBlockCheck(false); | |
2152 if ( sHealth > 0 ) | |
2153 sHealth = 0; | |
2154 } | |
2155 if (broke_armor ) | |
2156 { | |
2157 ItemGen* equippedArmor = GetArmorItem(); | |
2158 if ( equippedArmor != nullptr ) | |
2159 { | |
2160 if ( !(equippedArmor->uAttributes & ITEM_HARDENED)) | |
2161 { | |
2162 equippedArmor->SetBroken(); | |
2163 } | |
2164 } | |
2165 } | |
2166 } | |
2167 if ( recieved_dmg && CanAct() ) | |
2168 PlaySound(SPEECH_24, 0); | |
2169 return recieved_dmg; | |
2170 } | |
2171 | |
2172 //----- (0048DCF6) -------------------------------------------------------- | |
2173 int Player::ReceiveSpecialAttackEffect( int attType, struct Actor *pActor ) | |
2174 { | |
2175 SPECIAL_ATTACK_TYPE attTypeCast = (SPECIAL_ATTACK_TYPE) attType; | |
2176 signed int v3; // edi@1 | |
2177 signed int v4; // ebx@1 | |
2178 int v6; // eax@2 | |
2179 int v8; // eax@8 | |
2180 int v10; // eax@8 | |
2181 int v11; // ebx@8 | |
2182 ItemGen *v13; // eax@9 | |
2183 int v22; // eax@49 | |
2184 signed int v23; // ebx@49 | |
2185 void *v27; // ecx@76 | |
2186 char v46[140]; // [sp+Ch] [bp-94h]@13 | |
2187 unsigned int v47; // [sp+98h] [bp-8h]@1 | |
2188 ItemGen* v48; // [sp+9Ch] [bp-4h]@1 | |
2189 | |
2190 v4 = 0; | |
2191 v47 = 0; | |
2192 v48 = nullptr; | |
2193 switch ( attTypeCast ) | |
2194 { | |
2195 case SPECIAL_ATTACK_CURSE: | |
2196 v6 = GetActualWillpower(); | |
2197 v11 = GetParameterBonus(v6); | |
2198 break; | |
2199 case SPECIAL_ATTACK_WEAK: | |
2200 case SPECIAL_ATTACK_SLEEP: | |
2201 case SPECIAL_ATTACK_DRUNK: | |
2202 case SPECIAL_ATTACK_DISEASE_WEAK: | |
2203 case SPECIAL_ATTACK_DISEASE_MEDIUM: | |
2204 case SPECIAL_ATTACK_DISEASE_SEVERE: | |
2205 case SPECIAL_ATTACK_UNCONSCIOUS: | |
2206 case SPECIAL_ATTACK_AGING: | |
2207 v6 = GetActualEndurance(); | |
2208 v11 = GetParameterBonus(v6); | |
2209 break; | |
2210 case SPECIAL_ATTACK_INSANE: | |
2211 case SPECIAL_ATTACK_PARALYZED: | |
2212 case SPECIAL_ATTACK_FEAR: | |
2213 v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); | |
2214 break; | |
2215 case SPECIAL_ATTACK_PETRIFIED: | |
2216 v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); | |
2217 break; | |
2218 case SPECIAL_ATTACK_POISON_WEAK: | |
2219 case SPECIAL_ATTACK_POISON_MEDIUM: | |
2220 case SPECIAL_ATTACK_POISON_SEVERE: | |
2221 case SPECIAL_ATTACK_DEAD: | |
2222 case SPECIAL_ATTACK_ERADICATED: | |
2223 v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); | |
2224 break; | |
2225 case SPECIAL_ATTACK_MANA_DRAIN: | |
2226 v8 = GetActualWillpower(); | |
2227 v10 = GetActualIntelligence(); | |
2228 v11 = (GetParameterBonus(v10) + GetParameterBonus(v8)) / 2; | |
2229 break; | |
2230 case SPECIAL_ATTACK_BREAK_ANY: | |
2231 for (int i = 0; i < 138; i++) | |
2232 { | |
2233 v13 = &this->pInventoryItemList[i]; | |
2234 if ( v13->uItemID > 0 && v13->uItemID <= 134 && !v13->IsBroken()) | |
2235 v46[v4++] = i; | |
2236 } | |
2237 if ( !v4 ) | |
2238 return 0; | |
2239 v48 = &this->pInventoryItemList[v46[rand() % v4]]; | |
2240 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod()); | |
2241 break; | |
2242 case SPECIAL_ATTACK_BREAK_ARMOR: | |
2243 for (int i = 0; i < 16; i++ ) | |
2244 { | |
2245 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
2246 { | |
2247 if ( i == EQUIP_ARMOUR ) | |
2248 v46[v4++] = this->pEquipment.uArmor - 1; | |
2249 if ( (i == EQUIP_SINGLE_HANDED || i == EQUIP_TWO_HANDED) && GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_SHIELD ) | |
2250 v46[v4++] = this->pEquipment.pIndices[i] - 1; | |
2251 } | |
2252 } | |
2253 if ( !v4 ) | |
2254 return 0; | |
2255 v48 = &this->pInventoryItemList[v46[rand() % v4]]; | |
2256 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod()); | |
2257 break; | |
2258 case SPECIAL_ATTACK_BREAK_WEAPON: | |
2259 for (int i = 0; i < 16; i++ ) | |
2260 { | |
2261 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
2262 { | |
2263 if ( i == EQUIP_BOW ) | |
2264 v46[v4++] = LOBYTE(this->pEquipment.uBow) - 1; | |
2265 if ( (i == EQUIP_SINGLE_HANDED || i == EQUIP_TWO_HANDED) | |
2266 && (GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_SINGLE_HANDED || GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_TWO_HANDED) ) | |
2267 v46[v4++] = this->pEquipment.pIndices[i] - 1; | |
2268 } | |
2269 } | |
2270 if ( !v4 ) | |
2271 return 0; | |
2272 v48 = &this->pInventoryItemList[v46[rand() % v4]]; | |
2273 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod()); | |
2274 break; | |
2275 case SPECIAL_ATTACK_STEAL: | |
2276 for ( int i = 0; i < 126; i++ ) | |
2277 { | |
2278 int ItemPosInList = this->pInventoryMatrix[i]; | |
2279 if (ItemPosInList > 0) | |
2280 { | |
2281 ItemGen* v21 = &this->pInventoryItemList[ItemPosInList - 1]; | |
2282 if ( v21->uItemID > 0 && v21->uItemID <= 134 ) | |
2283 { | |
2284 v46[v4++] = i; | |
2285 } | |
2286 } | |
2287 } | |
2288 if ( !v4 ) | |
2289 return 0; | |
2290 v47 = v46[rand() % v4]; | |
2291 v6 = GetActualAccuracy(); | |
2292 v11 = GetParameterBonus(v6); | |
2293 break; | |
2294 default: | |
2295 v11 = 0; | |
2296 break; | |
2297 } | |
2298 v22 = GetActualLuck(); | |
2299 v23 = GetParameterBonus(v22) + v11 + 30; | |
2300 if ( rand() % v23 >= 30 ) | |
2301 { | |
2302 return 0; | |
2303 } | |
2304 else | |
2305 { | |
2306 for ( v3 = 0; v3 < 4; v3++ ) | |
2307 { | |
2308 if ( this == pPlayers[v3 + 1] ) | |
2309 break; | |
2310 } | |
2311 | |
2312 switch ( attTypeCast ) | |
2313 { | |
2314 case SPECIAL_ATTACK_CURSE: | |
2315 SetCondition(Condition_Cursed, 1); | |
2316 pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); | |
2317 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2318 return 1; | |
2319 break; | |
2320 case SPECIAL_ATTACK_WEAK: | |
2321 SetCondition(Condition_Weak, 1); | |
2322 pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); | |
2323 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2324 return 1; | |
2325 break; | |
2326 case SPECIAL_ATTACK_SLEEP: | |
2327 SetCondition(Condition_Sleep, 1); | |
2328 pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); | |
2329 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2330 return 1; | |
2331 break; | |
2332 case SPECIAL_ATTACK_DRUNK: | |
2333 SetCondition(Condition_Drunk, 1); | |
2334 pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); | |
2335 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2336 return 1; | |
2337 break; | |
2338 case SPECIAL_ATTACK_INSANE: | |
2339 SetCondition(Condition_Insane, 1); | |
2340 pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0); | |
2341 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2342 return 1; | |
2343 break; | |
2344 case SPECIAL_ATTACK_POISON_WEAK: | |
2345 SetCondition(Condition_Poison_Weak, 1); | |
2346 pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); | |
2347 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2348 return 1; | |
2349 break; | |
2350 case SPECIAL_ATTACK_POISON_MEDIUM: | |
2351 SetCondition(Condition_Poison_Medium, 1); | |
2352 pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); | |
2353 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2354 return 1; | |
2355 break; | |
2356 case SPECIAL_ATTACK_POISON_SEVERE: | |
2357 SetCondition(Condition_Poison_Severe, 1); | |
2358 pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); | |
2359 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2360 return 1; | |
2361 break; | |
2362 case SPECIAL_ATTACK_DISEASE_WEAK: | |
2363 SetCondition(Condition_Disease_Weak, 1); | |
2364 pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); | |
2365 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2366 return 1; | |
2367 break; | |
2368 case SPECIAL_ATTACK_DISEASE_MEDIUM: | |
2369 SetCondition(Condition_Disease_Medium, 1); | |
2370 pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); | |
2371 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2372 return 1; | |
2373 break; | |
2374 case SPECIAL_ATTACK_DISEASE_SEVERE: | |
2375 SetCondition(Condition_Disease_Severe, 1); | |
2376 pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); | |
2377 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2378 return 1; | |
2379 break; | |
2380 case SPECIAL_ATTACK_PARALYZED: | |
2381 SetCondition(Condition_Paralyzed, 1); | |
2382 pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0); | |
2383 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2384 return 1; | |
2385 break; | |
2386 case SPECIAL_ATTACK_UNCONSCIOUS: | |
2387 SetCondition(Condition_Unconcious, 1); | |
2388 pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0); | |
2389 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2390 return 1; | |
2391 break; | |
2392 case SPECIAL_ATTACK_DEAD: | |
2393 SetCondition(Condition_Dead, 1); | |
2394 pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0); | |
2395 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2396 return 1; | |
2397 break; | |
2398 case SPECIAL_ATTACK_PETRIFIED: | |
2399 SetCondition(Condition_Pertified, 1); | |
2400 pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0); | |
2401 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2402 return 1; | |
2403 break; | |
2404 case SPECIAL_ATTACK_ERADICATED: | |
2405 SetCondition(Condition_Eradicated, 1); | |
2406 pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0); | |
2407 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2408 return 1; | |
2409 break; | |
2410 case SPECIAL_ATTACK_BREAK_ANY: | |
2411 case SPECIAL_ATTACK_BREAK_ARMOR: | |
2412 case SPECIAL_ATTACK_BREAK_WEAPON: | |
2413 if ( !(v48->uAttributes & ITEM_HARDENED) ) | |
2414 { | |
2415 PlaySound(SPEECH_40, 0); | |
2416 v48->SetBroken(); | |
2417 pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0); | |
2418 } | |
2419 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2420 return 1; | |
2421 break; | |
2422 case SPECIAL_ATTACK_STEAL: | |
2423 PlaySound(SPEECH_40, 0); | |
2424 v27 = pActor->ActorHasItems; | |
2425 if ( pActor->ActorHasItems[0].uItemID ) | |
2426 { | |
2427 v27 = &pActor->ActorHasItems[1]; | |
2428 if ( pActor->ActorHasItems[1].uItemID ) | |
2429 { | |
2430 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2431 return 1; | |
2432 } | |
2433 } | |
2434 memcpy(v27, &this->pInventoryItemList[this->pInventoryMatrix[v47]-1], 0x24u); | |
2435 RemoveItemAtInventoryIndex(v47); | |
2436 pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0); | |
2437 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2438 return 1; | |
2439 break; | |
2440 case SPECIAL_ATTACK_AGING: | |
2441 PlaySound(SPEECH_42, 0); | |
2442 ++this->sAgeModifier; | |
2443 pAudioPlayer->PlaySound((SoundID)226, 0, 0, -1, 0, 0, 0, 0); | |
2444 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2445 return 1; | |
2446 break; | |
2447 case SPECIAL_ATTACK_MANA_DRAIN: | |
2448 PlaySound(SPEECH_41, 0); | |
2449 this->sMana = 0; | |
2450 pAudioPlayer->PlaySound((SoundID)226, 0, 0, -1, 0, 0, 0, 0); | |
2451 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2452 return 1; | |
2453 break; | |
2454 case SPECIAL_ATTACK_FEAR: | |
2455 SetCondition(Condition_Fear, 1); | |
2456 pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); | |
2457 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); | |
2458 return 1; | |
2459 break; | |
2460 default: | |
2461 return 0; | |
2462 } | |
2463 } | |
2464 } | |
2465 | |
2466 // 48DCF6: using guessed type char var_94[140]; | |
2467 | |
2468 //----- (0048E1A3) -------------------------------------------------------- | |
2469 unsigned int Player::GetSpellSchool(unsigned int uSpellID) | |
2470 { | |
2471 return pSpellStats->pInfos[uSpellID].uSchool; | |
2472 } | |
2473 | |
2474 //----- (0048E1B5) -------------------------------------------------------- | |
2475 int Player::GetAttackRecoveryTime(bool bRangedAttack) | |
2476 { | |
2477 ItemGen *weapon = nullptr; | |
2478 uint weapon_recovery = base_recovery_times_per_weapon_type[0]; | |
2479 if (bRangedAttack) | |
2480 { | |
2481 if ( HasItemEquipped(EQUIP_BOW) ) | |
2482 { | |
2483 weapon = GetBowItem(); | |
2484 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; | |
2485 } | |
2486 } | |
2487 else if ( IsUnarmed() == 1 && GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) | |
2488 { | |
2489 weapon_recovery = base_recovery_times_per_weapon_type[1]; | |
2490 } | |
2491 else if ( HasItemEquipped(EQUIP_TWO_HANDED) ) | |
2492 { | |
2493 weapon = GetMainHandItem(); | |
2494 if (weapon->GetItemEquipType() == EQUIP_WAND) | |
2495 { | |
2496 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 | |
2497 __debugbreak(); // looks like wands were two-handed weapons once, or supposed to be. should not get here now | |
2498 weapon_recovery = pSpellDatas[wand_spell_ids[weapon->uItemID - ITEM_WAND_FIRE]].uExpertLevelRecovery; | |
2499 } | |
2500 else | |
2501 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; | |
2502 } | |
2503 if (HasItemEquipped(EQUIP_SINGLE_HANDED) && GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) != EQUIP_SHIELD) | |
2504 // ADD: shield check because shield recovery is added later and can be accidentally doubled | |
2505 { | |
2506 if (base_recovery_times_per_weapon_type[GetOffHandItem()->GetPlayerSkillType()] > weapon_recovery) | |
2507 { | |
2508 weapon = GetOffHandItem(); | |
2509 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; | |
2510 } | |
2511 } | |
2512 | |
2513 uint armour_recovery = 0; | |
2514 if ( HasItemEquipped(EQUIP_ARMOUR) ) | |
2515 { | |
2516 uchar armour_skill_type = GetArmorItem()->GetPlayerSkillType(); | |
2517 uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type]; | |
2518 float multiplier; | |
2519 | |
2520 if (armour_skill_type == PLAYER_SKILL_LEATHER) | |
2521 { | |
2522 multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 0, 0, 0); | |
2523 } | |
2524 else if (armour_skill_type == PLAYER_SKILL_CHAIN) | |
2525 { | |
2526 multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 0.5f, 0, 0); | |
2527 } | |
2528 else if (armour_skill_type == PLAYER_SKILL_PLATE) | |
2529 { | |
2530 multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 0.5f, 0.5f, 0); | |
2531 } | |
2532 else | |
2533 { | |
2534 Error("Unknown armour type"); // what kind of armour is that? | |
2535 multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 1.0f, 1.0f, 1.0f); | |
2536 } | |
2537 | |
2538 armour_recovery = (uint)(base_armour_recovery * multiplier); | |
2539 } | |
2540 | |
2541 uint shield_recovery = 0; | |
2542 if (HasItemEquipped(EQUIP_SINGLE_HANDED) && GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) == EQUIP_SHIELD) | |
2543 { | |
2544 uchar skill_type = GetOffHandItem()->GetPlayerSkillType(); | |
2545 | |
2546 uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; | |
2547 float multiplier = GetArmorRecoveryMultiplierFromSkillLevel(skill_type, 1.0f, 0, 0, 0); | |
2548 shield_recovery = (uint)(shield_base_recovery * multiplier); | |
2549 } | |
2550 | |
2551 uint player_speed_recovery_reduction = GetParameterBonus(GetActualSpeed()), | |
2552 sword_axe_bow_recovery_reduction = 0; | |
2553 bool shooting_laser = false; | |
2554 if (weapon != nullptr) | |
2555 { | |
2556 if (GetActualSkillLevel((PLAYER_SKILL_TYPE)weapon->GetPlayerSkillType()) && | |
2557 (weapon->GetPlayerSkillType() == PLAYER_SKILL_SWORD || weapon->GetPlayerSkillType() == PLAYER_SKILL_AXE || weapon->GetPlayerSkillType() == PLAYER_SKILL_BOW) ) | |
2558 { | |
2559 if (SkillToMastery(pActiveSkills[weapon->GetPlayerSkillType()]) >= 2 ) // Expert Sword, Axe & Bow reduce recovery | |
2560 sword_axe_bow_recovery_reduction = pActiveSkills[weapon->GetPlayerSkillType()] & 0x3F; | |
2561 } | |
2562 if (weapon->GetPlayerSkillType() == PLAYER_SKILL_BLASTER) | |
2563 shooting_laser = true; | |
2564 } | |
2565 | |
2566 uint armsmaster_recovery_reduction = 0; | |
2567 if (!bRangedAttack && !shooting_laser) | |
2568 { | |
2569 if (uint armsmaster_level = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER)) | |
2570 { | |
2571 armsmaster_recovery_reduction = armsmaster_level & 0x3F; | |
2572 if (SkillToMastery(armsmaster_level) >= 4) | |
2573 armsmaster_recovery_reduction *= 2; | |
2574 } | |
2575 } | |
2576 | |
2577 uint hasteRecoveryReduction = 0; | |
2578 if (pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime > 0 || pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0 ) | |
2579 hasteRecoveryReduction = 25; | |
2580 | |
2581 uint weapon_enchantment_recovery_reduction = 0; | |
2582 if ( weapon ) | |
2583 { | |
2584 if (weapon->uSpecEnchantmentType == 59 || | |
2585 weapon->uSpecEnchantmentType == 41 || | |
2586 weapon->uSpecEnchantmentType == 500) | |
2587 weapon_enchantment_recovery_reduction = 20; | |
2588 } | |
2589 | |
2590 int recovery = weapon_recovery + | |
2591 armour_recovery + | |
2592 shield_recovery | |
2593 - armsmaster_recovery_reduction | |
2594 - weapon_enchantment_recovery_reduction | |
2595 - hasteRecoveryReduction | |
2596 - sword_axe_bow_recovery_reduction | |
2597 - player_speed_recovery_reduction; | |
2598 | |
2599 if (recovery < 0) | |
2600 recovery = 0; | |
2601 return recovery; | |
2602 } | |
2603 | |
2604 | |
2605 //----- new -------------------------------------------------------- | |
2606 float Player::GetArmorRecoveryMultiplierFromSkillLevel( unsigned char armour_skill_type, float mult1, float mult2, float mult3, float mult4 ) | |
2607 { | |
2608 uint skill_mastery = SkillToMastery(pActiveSkills[armour_skill_type]); | |
2609 switch (skill_mastery) | |
2610 { | |
2611 case 1: return mult1; break; | |
2612 case 2: return mult2; break; | |
2613 case 3: return mult3; break; | |
2614 case 4: return mult4; break; | |
2615 } | |
2616 Error("Unexpected input value: %d", armour_skill_type); | |
2617 return 0; | |
2618 } | |
2619 | |
2620 //----- (0048E4F8) -------------------------------------------------------- | |
2621 int Player::GetMaxHealth() | |
2622 { | |
2623 int v3; // esi@1 | |
2624 int v4; // esi@1 | |
2625 int v6; // esi@1 | |
2626 | |
2627 v3 = GetParameterBonus(GetActualEndurance()); | |
2628 v4 = pBaseHealthPerLevelByClass[classType] * (GetActualLevel() + v3); | |
2629 v6 = uFullHealthBonus | |
2630 + pBaseHealthByClass[classType / 4] | |
2631 + GetSkillBonus(CHARACTER_ATTRIBUTE_HEALTH) | |
2632 + GetItemsBonus(CHARACTER_ATTRIBUTE_HEALTH) + v4; | |
2633 return max(1, v6); | |
2634 } | |
2635 | |
2636 //----- (0048E565) -------------------------------------------------------- | |
2637 int Player::GetMaxMana() | |
2638 { | |
2639 int v2; // eax@2 | |
2640 int v3; // esi@4 | |
2641 int v4; // eax@5 | |
2642 int v5; // esi@5 | |
2643 int v6; // eax@5 | |
2644 int v7; // esi@6 | |
2645 int v8; // esi@6 | |
2646 int v9; // esi@6 | |
2647 | |
2648 switch (classType) | |
2649 { | |
2650 case PLAYER_CLASS_ROGUE: | |
2651 case PLAYER_CLASS_SPY: | |
2652 case PLAYER_CLASS_ASSASSIN: | |
2653 case PLAYER_CLASS_ARCHER: | |
2654 case PLAYER_CLASS_WARRIOR_MAGE: | |
2655 case PLAYER_CLASS_MASTER_ARCHER: | |
2656 case PLAYER_CLASS_SNIPER: | |
2657 case PLAYER_CLASS_SORCERER: | |
2658 case PLAYER_CLASS_WIZARD: | |
2659 case PLAYER_CLASS_ARCHMAGE: | |
2660 case PLAYER_CLASS_LICH: | |
2661 v2 = GetActualIntelligence(); | |
2662 v3 = GetParameterBonus(v2); | |
2663 break; | |
2664 case PLAYER_CLASS_INITIATE: | |
2665 case PLAYER_CLASS_MASTER: | |
2666 case PLAYER_CLASS_NINJA: | |
2667 case PLAYER_CLASS_PALADIN: | |
2668 case PLAYER_CLASS_CRUSADER: | |
2669 case PLAYER_CLASS_HERO: | |
2670 case PLAYER_CLASS_VILLIAN: | |
2671 case PLAYER_CLASS_CLERIC: | |
2672 case PLAYER_CLASS_PRIEST: | |
2673 case PLAYER_CLASS_PRIEST_OF_SUN: | |
2674 case PLAYER_CLASS_PRIEST_OF_MOON: | |
2675 v2 = GetActualWillpower(); | |
2676 v3 = GetParameterBonus(v2); | |
2677 break; | |
2678 case PLAYER_CLASS_HUNTER: | |
2679 case PLAYER_CLASS_RANGER_LORD: | |
2680 case PLAYER_CLASS_BOUNTY_HUNTER: | |
2681 case PLAYER_CLASS_DRUID: | |
2682 case PLAYER_CLASS_GREAT_DRUID: | |
2683 case PLAYER_CLASS_ARCH_DRUID: | |
2684 case PLAYER_CLASS_WARLOCK: | |
2685 v4 = GetActualWillpower(); | |
2686 v5 = GetParameterBonus(v4); | |
2687 v6 = GetActualIntelligence(); | |
2688 v3 = GetParameterBonus(v6) + v5; | |
2689 break; | |
2690 default: | |
2691 return 0; | |
2692 break; | |
2693 } | |
2694 v7 = pBaseManaPerLevelByClass[classType] * (GetActualLevel() + v3); | |
2695 v8 = GetItemsBonus(CHARACTER_ATTRIBUTE_MANA) + v7; | |
2696 v9 = uFullManaBonus | |
2697 + pBaseManaByClass[classType / 4] | |
2698 + GetSkillBonus(CHARACTER_ATTRIBUTE_MANA) | |
2699 + v8; | |
2700 return max(0,v9); | |
2701 } | |
2702 | |
2703 //----- (0048E656) -------------------------------------------------------- | |
2704 int Player::GetBaseAC() | |
2705 { | |
2706 int v2; // eax@1 | |
2707 int v3; // esi@1 | |
2708 int v4; // esi@1 | |
2709 int v5; // esi@1 | |
2710 | |
2711 v2 = GetActualSpeed(); | |
2712 v3 = GetParameterBonus(v2); | |
2713 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v3; | |
2714 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4; | |
2715 return max(0, v5); | |
2716 } | |
2717 | |
2718 //----- (0048E68F) -------------------------------------------------------- | |
2719 int Player::GetActualAC() | |
2720 { | |
2721 int v2; // eax@1 | |
2722 int v3; // esi@1 | |
2723 int v4; // esi@1 | |
2724 int v5; // esi@1 | |
2725 int v6; // esi@1 | |
2726 | |
2727 v2 = GetActualSpeed(); | |
2728 v3 = GetParameterBonus(v2); | |
2729 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v3; | |
2730 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4; | |
2731 v6 = this->sACModifier + GetMagicalBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v5; | |
2732 return max(0, v6); | |
2733 } | |
2734 | |
2735 //----- (0048E6DC) -------------------------------------------------------- | |
2736 unsigned int Player::GetBaseAge() | |
2737 { | |
2738 return (unsigned int)(((__int64)(pParty->uTimePlayed * 0.234375) / 60 / 60 / 24) / 7 / 4 / 12 - uBirthYear + game_starting_year); | |
2739 } | |
2740 | |
2741 //----- (0048E72C) -------------------------------------------------------- | |
2742 unsigned int Player::GetActualAge() | |
2743 { | |
2744 return this->sAgeModifier + GetBaseAge(); | |
2745 } | |
2746 | |
2747 //----- (0048E73F) -------------------------------------------------------- | |
2748 int Player::GetBaseResistance(enum CHARACTER_ATTRIBUTE_TYPE a2) | |
2749 { | |
2750 int v7; // esi@20 | |
2751 int racialBonus = 0; | |
2752 __int16* resStat; | |
2753 int result; | |
2754 | |
2755 switch (a2) | |
2756 { | |
2757 case CHARACTER_ATTRIBUTE_RESIST_FIRE: | |
2758 resStat = &sResFireBase; | |
2759 if (IsRaceGoblin()) | |
2760 racialBonus = 5; | |
2761 break; | |
2762 case CHARACTER_ATTRIBUTE_RESIST_AIR: | |
2763 resStat = &sResAirBase; | |
2764 if (IsRaceGoblin()) | |
2765 racialBonus = 5; | |
2766 break; | |
2767 case CHARACTER_ATTRIBUTE_RESIST_WATER: | |
2768 resStat = &sResWaterBase; | |
2769 if (IsRaceDwarf()) | |
2770 racialBonus = 5; | |
2771 break; | |
2772 case CHARACTER_ATTRIBUTE_RESIST_EARTH: | |
2773 resStat = &sResEarthBase; | |
2774 if (IsRaceDwarf()) | |
2775 racialBonus = 5; | |
2776 break; | |
2777 case CHARACTER_ATTRIBUTE_RESIST_MIND: | |
2778 resStat = &sResMindBase; | |
2779 if (IsRaceElf()) | |
2780 racialBonus = 10; | |
2781 break; | |
2782 case CHARACTER_ATTRIBUTE_RESIST_BODY: | |
2783 case CHARACTER_ATTRIBUTE_RESIST_SPIRIT: | |
2784 resStat = &sResBodyBase; | |
2785 if (IsRaceHuman()) | |
2786 racialBonus = 5; | |
2787 break; | |
2788 default: | |
2789 Error("Unknown attribute"); | |
2790 } | |
2791 v7 = GetItemsBonus(a2) + racialBonus; | |
2792 result = v7 + *resStat; | |
2793 if ( classType == PLAYER_CLASS_LICH ) | |
2794 { | |
2795 if ( result > 200 ) | |
2796 result = 200; | |
2797 } | |
2798 return result; | |
2799 } | |
2800 | |
2801 //----- (0048E7D0) -------------------------------------------------------- | |
2802 int Player::GetActualResistance(enum CHARACTER_ATTRIBUTE_TYPE a2) | |
2803 { | |
2804 signed int v10 = 0; // [sp+14h] [bp-4h]@1 | |
2805 __int16* resStat; | |
2806 int result; | |
2807 int baseRes; | |
2808 | |
2809 int leatherArmorSkillLevel = GetActualSkillLevel(PLAYER_SKILL_LEATHER); | |
2810 if ( CheckHiredNPCSpeciality(Enchanter) ) | |
2811 v10 = 20; | |
2812 if ( (a2 == CHARACTER_ATTRIBUTE_RESIST_FIRE | |
2813 || a2 == CHARACTER_ATTRIBUTE_RESIST_AIR | |
2814 || a2 == CHARACTER_ATTRIBUTE_RESIST_WATER | |
2815 || a2 == CHARACTER_ATTRIBUTE_RESIST_EARTH) | |
2816 && SkillToMastery(leatherArmorSkillLevel) == 4 | |
2817 && HasItemEquipped(EQUIP_ARMOUR) | |
2818 && GetEquippedItemSkillType(EQUIP_ARMOUR) == PLAYER_SKILL_LEATHER ) | |
2819 v10 += leatherArmorSkillLevel & 0x3F; | |
2820 switch (a2) | |
2821 { | |
2822 case CHARACTER_ATTRIBUTE_RESIST_FIRE: | |
2823 resStat = &sResFireBonus; | |
2824 break; | |
2825 case CHARACTER_ATTRIBUTE_RESIST_AIR: | |
2826 resStat = &sResAirBonus; | |
2827 break; | |
2828 case CHARACTER_ATTRIBUTE_RESIST_WATER: | |
2829 resStat = &sResWaterBonus; | |
2830 break; | |
2831 case CHARACTER_ATTRIBUTE_RESIST_EARTH: | |
2832 resStat = &sResEarthBonus; | |
2833 break; | |
2834 case CHARACTER_ATTRIBUTE_RESIST_MIND: | |
2835 resStat = &sResMindBonus; | |
2836 break; | |
2837 case CHARACTER_ATTRIBUTE_RESIST_BODY: | |
2838 case CHARACTER_ATTRIBUTE_RESIST_SPIRIT: | |
2839 resStat = &sResBodyBonus; | |
2840 break; | |
2841 default: Error("Unexpected attribute"); | |
2842 } | |
2843 baseRes = GetBaseResistance(a2); | |
2844 result = v10 + GetMagicalBonus(a2) + baseRes + *(resStat); | |
2845 if ( classType == PLAYER_CLASS_LICH ) | |
2846 { | |
2847 if ( result > 200 ) | |
2848 result = 200; | |
2849 } | |
2850 return result; | |
2851 } | |
2852 | |
2853 //----- (0048E8F5) -------------------------------------------------------- | |
2854 bool Player::Recover(int dt) | |
2855 { | |
2856 int v3; // qax@1 | |
2857 | |
2858 v3 = (int)(dt * GetSpecialItemBonus(17) * 0.01 + dt); | |
2859 | |
2860 //Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery); | |
2861 | |
2862 if (uTimeToRecovery > v3) | |
2863 { | |
2864 uTimeToRecovery -= v3; | |
2865 return true; | |
2866 } | |
2867 else | |
2868 { | |
2869 uTimeToRecovery = 0; | |
2870 viewparams->bRedrawGameUI = true; | |
2871 if (!uActiveCharacter) | |
2872 uActiveCharacter = pParty->GetNextActiveCharacter(); | |
2873 return false; | |
2874 } | |
2875 } | |
2876 | |
2877 //----- (0048E96A) -------------------------------------------------------- | |
2878 void Player::SetRecoveryTime(signed int rec) | |
2879 { | |
2880 Assert(rec >= 0); | |
2881 | |
2882 if (rec > uTimeToRecovery) | |
2883 uTimeToRecovery = rec; | |
2884 | |
2885 if (uActiveCharacter != 0 && pPlayers[uActiveCharacter] == this && !some_active_character) | |
2886 uActiveCharacter = pParty->GetNextActiveCharacter(); | |
2887 | |
2888 viewparams->bRedrawGameUI = true; | |
2889 } | |
2890 // 50C0C4: using guessed type int some_active_character; | |
2891 | |
2892 //----- (0048E9B7) -------------------------------------------------------- | |
2893 void Player::RandomizeName() | |
2894 { | |
2895 if (!uExpressionTimePassed) | |
2896 strcpy(pName, pNPCStats->pNPCNames[rand() % pNPCStats->uNumNPCNames[uSex]][uSex]); | |
2897 } | |
2898 | |
2899 //----- (0048E9F4) -------------------------------------------------------- | |
2900 unsigned int Player::GetMajorConditionIdx() | |
2901 { | |
2902 for (uint i = 0; i < 18; ++i) | |
2903 if (pConditions[pConditionImportancyTable[i]] != 0) | |
2904 return pConditionImportancyTable[i]; | |
2905 | |
2906 return 18; | |
2907 } | |
2908 | |
2909 //----- (0048EA1B) -------------------------------------------------------- | |
2910 int Player::GetParameterBonus( int player_parameter ) | |
2911 { | |
2912 int i; // eax@1 | |
2913 i = 0; | |
2914 while (param_to_bonus_table[i]) | |
2915 { | |
2916 if (player_parameter >= param_to_bonus_table[i]) | |
2917 break; | |
2918 ++i; | |
2919 } | |
2920 return parameter_to_bonus_value[i]; | |
2921 } | |
2922 | |
2923 //----- (0048EA46) -------------------------------------------------------- | |
2924 int Player::GetSpecialItemBonus( int enchantmentId ) | |
2925 { | |
2926 for (int i = EQUIP_SINGLE_HANDED; i < EQUIP_BOOK; ++i ) | |
2927 { | |
2928 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
2929 { | |
2930 if (enchantmentId == 17) | |
2931 { | |
2932 if ((GetNthEquippedIndexItem(i)->uSpecEnchantmentType == 17) || (GetNthEquippedIndexItem(i)->uItemID == 533)) //Elven Chainmail+Increases rate of Recovery | |
2933 return 50; | |
2934 } | |
2935 if (enchantmentId == 24) | |
2936 { | |
2937 if (GetNthEquippedIndexItem(i)->uSpecEnchantmentType == 24) //Increased Knockback. | |
2938 return 5; | |
2939 } | |
2940 } | |
2941 } | |
2942 return 0; | |
2943 } | |
2944 | |
2945 //----- (0048EAAE) -------------------------------------------------------- | |
2946 int Player::GetItemsBonus( enum CHARACTER_ATTRIBUTE_TYPE attr, bool getOnlyMainHandDmg /*= false*/ ) | |
2947 { | |
2948 int v5; // edi@1 | |
2949 int v9; // eax@49 | |
2950 int v14; // ecx@58 | |
2951 int v15; // eax@58 | |
2952 int v17; // eax@62 | |
2953 int v22; // eax@76 | |
2954 int v25; // ecx@80 | |
2955 int v26; // edi@80 | |
2956 int v32; // eax@98 | |
2957 int v56; // eax@365 | |
2958 signed int v58; // [sp-4h] [bp-20h]@10 | |
2959 int v61; // [sp+10h] [bp-Ch]@1 | |
2960 int v62; // [sp+14h] [bp-8h]@1 | |
2961 ItemGen *currEquippedItem; // [sp+20h] [bp+4h]@101 | |
2962 bool no_skills; | |
2963 | |
2964 v5 = 0; | |
2965 v62 = 0; | |
2966 v61 = 0; | |
2967 | |
2968 no_skills=false; | |
2969 switch (attr) | |
2970 { | |
2971 case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY: v58 = PLAYER_SKILL_ALCHEMY; break; | |
2972 case CHARACTER_ATTRIBUTE_SKILL_STEALING: v58 = PLAYER_SKILL_STEALING; break; | |
2973 case CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM: v58 = PLAYER_SKILL_TRAP_DISARM; break; | |
2974 case CHARACTER_ATTRIBUTE_SKILL_ITEM_ID: v58 = PLAYER_SKILL_ITEM_ID; break; | |
2975 case CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID: v58 = PLAYER_SKILL_MONSTER_ID; break; | |
2976 case CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER: v58 = PLAYER_SKILL_ARMSMASTER; break; | |
2977 case CHARACTER_ATTRIBUTE_SKILL_DODGE: v58 = PLAYER_SKILL_DODGE; break; | |
2978 case CHARACTER_ATTRIBUTE_SKILL_UNARMED: v58 = PLAYER_SKILL_UNARMED; break; | |
2979 case CHARACTER_ATTRIBUTE_SKILL_FIRE: v58 = PLAYER_SKILL_FIRE; break; | |
2980 case CHARACTER_ATTRIBUTE_SKILL_AIR: v58 = PLAYER_SKILL_AIR; break; | |
2981 case CHARACTER_ATTRIBUTE_SKILL_WATER: v58 = PLAYER_SKILL_WATER; break; | |
2982 case CHARACTER_ATTRIBUTE_SKILL_EARTH: v58 = PLAYER_SKILL_EARTH; break; | |
2983 case CHARACTER_ATTRIBUTE_SKILL_SPIRIT: v58 = PLAYER_SKILL_SPIRIT; break; | |
2984 case CHARACTER_ATTRIBUTE_SKILL_MIND: v58 = PLAYER_SKILL_MIND; break; | |
2985 case CHARACTER_ATTRIBUTE_SKILL_BODY: v58 = PLAYER_SKILL_BODY; break; | |
2986 case CHARACTER_ATTRIBUTE_SKILL_LIGHT: v58 = PLAYER_SKILL_LIGHT; break; | |
2987 case CHARACTER_ATTRIBUTE_SKILL_DARK: v58 = PLAYER_SKILL_DARK; break; | |
2988 case CHARACTER_ATTRIBUTE_SKILL_MEDITATION: v58 = PLAYER_SKILL_MEDITATION; break; | |
2989 case CHARACTER_ATTRIBUTE_SKILL_BOW: v58 = PLAYER_SKILL_BOW; break; | |
2990 case CHARACTER_ATTRIBUTE_SKILL_SHIELD: v58 = PLAYER_SKILL_SHIELD; break; | |
2991 case CHARACTER_ATTRIBUTE_SKILL_LEARNING: v58 = PLAYER_SKILL_LEARNING; break; | |
2992 default: | |
2993 no_skills=true; | |
2994 } | |
2995 if (!no_skills) | |
2996 { | |
2997 if ( !this->pActiveSkills[v58] ) | |
2998 return 0; | |
2999 } | |
3000 | |
3001 switch(attr) //TODO would be nice to move these into separate functions | |
3002 { | |
3003 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: | |
3004 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: | |
3005 if ( HasItemEquipped(EQUIP_BOW) ) | |
3006 v5 = GetBowItem()->GetDamageMod(); | |
3007 return v5; | |
3008 break; | |
3009 | |
3010 case CHARACTER_ATTRIBUTE_RANGED_DMG_MIN: | |
3011 if ( !HasItemEquipped(EQUIP_BOW) ) | |
3012 return 0; | |
3013 v5 = GetBowItem()->GetDamageMod(); | |
3014 v56 = GetBowItem()->GetDamageDice(); | |
3015 return v5 + v56; | |
3016 break; | |
3017 | |
3018 case CHARACTER_ATTRIBUTE_RANGED_DMG_MAX: | |
3019 if ( !HasItemEquipped(EQUIP_BOW) ) | |
3020 return 0; | |
3021 v5 = GetBowItem()->GetDamageDice() * GetBowItem()->GetDamageRoll(); | |
3022 v56 = GetBowItem()->GetDamageMod(); | |
3023 return v5 + v56; | |
3024 | |
3025 case CHARACTER_ATTRIBUTE_LEVEL: | |
3026 if ( !Player::HasEnchantedItemEquipped(25) ) | |
3027 return 0; | |
3028 return 5; | |
3029 break; | |
3030 | |
3031 case CHARACTER_ATTRIBUTE_MELEE_DMG_MAX: | |
3032 if ( IsUnarmed() ) | |
3033 { | |
3034 return 3; | |
3035 } | |
3036 else | |
3037 { | |
3038 if ( this->HasItemEquipped(EQUIP_TWO_HANDED) ) | |
3039 { | |
3040 v22 = this->GetEquippedItemEquipType(EQUIP_TWO_HANDED); | |
3041 if ( v22 >= 0 && v22 <= 2) | |
3042 { | |
3043 ItemGen* mainHandItem = GetMainHandItem(); | |
3044 v26 = mainHandItem->GetDamageRoll(); | |
3045 if ( GetOffHandItem() != nullptr || mainHandItem->GetPlayerSkillType() != 4 ) | |
3046 { | |
3047 v25 = mainHandItem->GetDamageDice(); | |
3048 } | |
3049 else | |
3050 { | |
3051 v25 = mainHandItem->GetDamageDice() + 1; | |
3052 } | |
3053 v5 = mainHandItem->GetDamageMod() + v25 * v26; | |
3054 } | |
3055 } | |
3056 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_SINGLE_HANDED) || (GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) < 0 || GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) > 2)) | |
3057 { | |
3058 return v5; | |
3059 } | |
3060 else | |
3061 { | |
3062 ItemGen* offHandItem = GetOffHandItem(); | |
3063 v15 = offHandItem->GetDamageMod(); | |
3064 v14 = offHandItem->GetDamageDice() * offHandItem->GetDamageRoll(); | |
3065 return v5 + v15 + v14; | |
3066 } | |
3067 } | |
3068 break; | |
3069 | |
3070 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS: | |
3071 case CHARACTER_ATTRIBUTE_ATTACK: | |
3072 if ( IsUnarmed() ) | |
3073 { | |
3074 return 0; | |
3075 } | |
3076 if ( this->HasItemEquipped(EQUIP_TWO_HANDED) ) | |
3077 { | |
3078 v17 = this->GetEquippedItemEquipType(EQUIP_TWO_HANDED); | |
3079 if ( v17 >= 0 && v17 <= 2) | |
3080 { | |
3081 v5 = GetMainHandItem()->GetDamageMod(); | |
3082 } | |
3083 } | |
3084 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_SINGLE_HANDED) || (this->GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) < 0) || this->GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) > 2 ) | |
3085 return v5; | |
3086 else | |
3087 { | |
3088 v56 = GetOffHandItem()->GetDamageMod(); | |
3089 return v5 + v56; | |
3090 } | |
3091 break; | |
3092 | |
3093 case CHARACTER_ATTRIBUTE_MELEE_DMG_MIN: | |
3094 if ( IsUnarmed() ) | |
3095 { | |
3096 return 1; | |
3097 } | |
3098 if ( this->HasItemEquipped(EQUIP_TWO_HANDED) ) | |
3099 { | |
3100 v9 = this->GetEquippedItemEquipType(EQUIP_TWO_HANDED); | |
3101 if ( v9 >= 0 && v9 <= 2) | |
3102 { | |
3103 ItemGen* mainHandItem = GetMainHandItem(); | |
3104 v5 = mainHandItem->GetDamageDice() + | |
3105 mainHandItem->GetDamageMod(); | |
3106 if ( GetOffHandItem() == nullptr && mainHandItem->GetPlayerSkillType() == 4) | |
3107 { | |
3108 ++v5; | |
3109 } | |
3110 } | |
3111 } | |
3112 | |
3113 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_SINGLE_HANDED) || (this->GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) < 0) || this->GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) > 2 ) | |
3114 { | |
3115 return v5; | |
3116 } | |
3117 else | |
3118 { | |
3119 ItemGen* offHandItem = GetOffHandItem(); | |
3120 v14 = offHandItem->GetDamageMod(); | |
3121 v15 = offHandItem->GetDamageDice(); | |
3122 return v5 + v15 + v14; | |
3123 } | |
3124 break; | |
3125 | |
3126 case CHARACTER_ATTRIBUTE_STRENGTH: | |
3127 case CHARACTER_ATTRIBUTE_INTELLIGENCE: | |
3128 case CHARACTER_ATTRIBUTE_WILLPOWER: | |
3129 case CHARACTER_ATTRIBUTE_ENDURANCE: | |
3130 case CHARACTER_ATTRIBUTE_ACCURACY: | |
3131 case CHARACTER_ATTRIBUTE_SPEED: | |
3132 case CHARACTER_ATTRIBUTE_LUCK: | |
3133 case CHARACTER_ATTRIBUTE_HEALTH: | |
3134 case CHARACTER_ATTRIBUTE_MANA: | |
3135 case CHARACTER_ATTRIBUTE_AC_BONUS: | |
3136 | |
3137 case CHARACTER_ATTRIBUTE_RESIST_FIRE: | |
3138 case CHARACTER_ATTRIBUTE_RESIST_AIR: | |
3139 case CHARACTER_ATTRIBUTE_RESIST_WATER: | |
3140 case CHARACTER_ATTRIBUTE_RESIST_EARTH: | |
3141 case CHARACTER_ATTRIBUTE_RESIST_MIND: | |
3142 case CHARACTER_ATTRIBUTE_RESIST_BODY: | |
3143 case CHARACTER_ATTRIBUTE_RESIST_SPIRIT: | |
3144 | |
3145 case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY: | |
3146 case CHARACTER_ATTRIBUTE_SKILL_STEALING: | |
3147 case CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM: | |
3148 case CHARACTER_ATTRIBUTE_SKILL_ITEM_ID: | |
3149 case CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID: | |
3150 case CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER: | |
3151 case CHARACTER_ATTRIBUTE_SKILL_DODGE: | |
3152 case CHARACTER_ATTRIBUTE_SKILL_UNARMED: | |
3153 | |
3154 case CHARACTER_ATTRIBUTE_SKILL_FIRE: | |
3155 case CHARACTER_ATTRIBUTE_SKILL_AIR: | |
3156 case CHARACTER_ATTRIBUTE_SKILL_WATER: | |
3157 case CHARACTER_ATTRIBUTE_SKILL_EARTH: | |
3158 case CHARACTER_ATTRIBUTE_SKILL_SPIRIT: | |
3159 case CHARACTER_ATTRIBUTE_SKILL_MIND: | |
3160 case CHARACTER_ATTRIBUTE_SKILL_BODY: | |
3161 case CHARACTER_ATTRIBUTE_SKILL_LIGHT: | |
3162 case CHARACTER_ATTRIBUTE_SKILL_DARK: | |
3163 case CHARACTER_ATTRIBUTE_SKILL_MEDITATION: | |
3164 case CHARACTER_ATTRIBUTE_SKILL_BOW: | |
3165 case CHARACTER_ATTRIBUTE_SKILL_SHIELD: | |
3166 case CHARACTER_ATTRIBUTE_SKILL_LEARNING: | |
3167 for (int i = 0; i < 16; i++) | |
3168 { | |
3169 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
3170 { | |
3171 currEquippedItem = GetNthEquippedIndexItem(i); | |
3172 if ( attr == CHARACTER_ATTRIBUTE_AC_BONUS ) | |
3173 { | |
3174 v32 = currEquippedItem->GetItemEquipType(); | |
3175 if ( v32 >= 3 && v32 <= 11 ) | |
3176 { | |
3177 v5 += currEquippedItem->GetDamageDice() + currEquippedItem->GetDamageMod(); | |
3178 } | |
3179 } | |
3180 if ( pItemsTable->IsMaterialNonCommon(currEquippedItem) | |
3181 && !pItemsTable->IsMaterialSpecial(currEquippedItem) ) | |
3182 { | |
3183 currEquippedItem->GetItemBonusArtifact(this, attr, &v62); | |
3184 } | |
3185 else if ( currEquippedItem->uEnchantmentType != 0 ) | |
3186 { | |
3187 if (this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uEnchantmentType - 1 == attr)//if (currEquippedItem->IsRegularEnchanmentForAttribute(attr)) | |
3188 { | |
3189 if ( attr > CHARACTER_ATTRIBUTE_RESIST_BODY && v5 < currEquippedItem->m_enchantmentStrength )//for skills bonuses | |
3190 v5 = currEquippedItem->m_enchantmentStrength; | |
3191 else // for resists and attributes bonuses | |
3192 v5 += currEquippedItem->m_enchantmentStrength; | |
3193 } | |
3194 } | |
3195 else | |
3196 { | |
3197 currEquippedItem->GetItemBonusSpecialEnchantment(this, attr, &v5, &v61); | |
3198 } | |
3199 } | |
3200 } | |
3201 return v5 + v62 + v61; | |
3202 break; | |
3203 default: | |
3204 return 0; | |
3205 } | |
3206 } | |
3207 | |
3208 //----- (0048F73C) -------------------------------------------------------- | |
3209 int Player::GetMagicalBonus(enum CHARACTER_ATTRIBUTE_TYPE a2) | |
3210 { | |
3211 int v3 = 0; // eax@4 | |
3212 int v4 = 0; // ecx@5 | |
3213 | |
3214 switch ( a2 ) | |
3215 { | |
3216 case CHARACTER_ATTRIBUTE_RESIST_FIRE: | |
3217 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_FIRE].uPower; | |
3218 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].uPower; | |
3219 break; | |
3220 case CHARACTER_ATTRIBUTE_RESIST_AIR: | |
3221 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_AIR].uPower; | |
3222 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].uPower; | |
3223 break; | |
3224 case CHARACTER_ATTRIBUTE_RESIST_BODY: | |
3225 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_BODY].uPower; | |
3226 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_BODY].uPower; | |
3227 break; | |
3228 case CHARACTER_ATTRIBUTE_RESIST_WATER: | |
3229 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_WATER].uPower; | |
3230 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].uPower; | |
3231 break; | |
3232 case CHARACTER_ATTRIBUTE_RESIST_EARTH: | |
3233 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_EARTH].uPower; | |
3234 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].uPower; | |
3235 break; | |
3236 case CHARACTER_ATTRIBUTE_RESIST_MIND: | |
3237 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_MIND].uPower; | |
3238 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].uPower; | |
3239 break; | |
3240 case CHARACTER_ATTRIBUTE_ATTACK: | |
3241 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: | |
3242 v3 = this->pPlayerBuffs[PLAYER_BUFF_BLESS].uPower; //only player effect spell in both VI and VII | |
3243 break; | |
3244 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS: | |
3245 v3 = this->pPlayerBuffs[PLAYER_BUFF_HEROISM].uPower; | |
3246 v4 = pParty->pPartyBuffs[PARTY_BUFF_HEROISM].uPower; | |
3247 break; | |
3248 case CHARACTER_ATTRIBUTE_STRENGTH: | |
3249 v3 = pPlayerBuffs[PLAYER_BUFF_STRENGTH].uPower; | |
3250 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; | |
3251 break; | |
3252 case CHARACTER_ATTRIBUTE_INTELLIGENCE: | |
3253 v3 = pPlayerBuffs[PLAYER_BUFF_INTELLIGENCE].uPower; | |
3254 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; | |
3255 break; | |
3256 case CHARACTER_ATTRIBUTE_WILLPOWER: | |
3257 v3 = pPlayerBuffs[PLAYER_BUFF_WILLPOWER].uPower; | |
3258 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; | |
3259 break; | |
3260 case CHARACTER_ATTRIBUTE_ENDURANCE: | |
3261 v3 = pPlayerBuffs[PLAYER_BUFF_ENDURANCE].uPower; | |
3262 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; | |
3263 break; | |
3264 case CHARACTER_ATTRIBUTE_ACCURACY: | |
3265 v3 = pPlayerBuffs[PLAYER_BUFF_ACCURACY].uPower; | |
3266 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; | |
3267 break; | |
3268 case CHARACTER_ATTRIBUTE_SPEED: | |
3269 v3 = pPlayerBuffs[PLAYER_BUFF_SPEED].uPower; | |
3270 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; | |
3271 break; | |
3272 case CHARACTER_ATTRIBUTE_LUCK: | |
3273 v3 = pPlayerBuffs[PLAYER_BUFF_LUCK].uPower; | |
3274 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; | |
3275 break; | |
3276 case CHARACTER_ATTRIBUTE_AC_BONUS: | |
3277 v3 = this->pPlayerBuffs[PLAYER_BUFF_STONESKIN].uPower; | |
3278 v4 = pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].uPower; | |
3279 break; | |
3280 } | |
3281 return v3 + v4; | |
3282 } | |
3283 | |
3284 //----- (0048F882) -------------------------------------------------------- | |
3285 int Player::GetActualSkillLevel( PLAYER_SKILL_TYPE uSkillType ) | |
3286 { | |
3287 signed int bonus_value; // esi@1 | |
3288 unsigned __int16 skill_value; // ax@126 | |
3289 int result; // al@127 | |
3290 | |
3291 bonus_value = 0; | |
3292 switch (uSkillType) | |
3293 { | |
3294 case PLAYER_SKILL_MONSTER_ID: | |
3295 { | |
3296 if ( CheckHiredNPCSpeciality(Hunter) ) | |
3297 bonus_value = 6; | |
3298 if ( CheckHiredNPCSpeciality(Sage) ) | |
3299 bonus_value += 6; | |
3300 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID); | |
3301 } | |
3302 break; | |
3303 | |
3304 case PLAYER_SKILL_ARMSMASTER: | |
3305 { | |
3306 if ( CheckHiredNPCSpeciality(Armsmaster) ) | |
3307 bonus_value = 2; | |
3308 if ( CheckHiredNPCSpeciality(Weaponsmaster) ) | |
3309 bonus_value += 3; | |
3310 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER); | |
3311 } | |
3312 break; | |
3313 | |
3314 case PLAYER_SKILL_STEALING: | |
3315 { | |
3316 if (CheckHiredNPCSpeciality(Burglar)) | |
3317 bonus_value = 8; | |
3318 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_STEALING); | |
3319 } | |
3320 break; | |
3321 | |
3322 | |
3323 case PLAYER_SKILL_ALCHEMY: | |
3324 { | |
3325 if ( CheckHiredNPCSpeciality(Herbalist) ) | |
3326 bonus_value = 4; | |
3327 if ( CheckHiredNPCSpeciality(Apothecary) ) | |
3328 bonus_value += 8; | |
3329 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY); | |
3330 } | |
3331 break; | |
3332 | |
3333 case PLAYER_SKILL_LEARNING: | |
3334 { | |
3335 if ( CheckHiredNPCSpeciality(Teacher) ) | |
3336 bonus_value = 10; | |
3337 if ( CheckHiredNPCSpeciality(Instructor) ) | |
3338 bonus_value += 15; | |
3339 if ( CheckHiredNPCSpeciality(Scholar) ) | |
3340 bonus_value += 5; | |
3341 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LEARNING); | |
3342 } | |
3343 break; | |
3344 | |
3345 case PLAYER_SKILL_UNARMED: | |
3346 { | |
3347 if (CheckHiredNPCSpeciality(Monk) ) | |
3348 bonus_value = 2; | |
3349 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_UNARMED); | |
3350 } | |
3351 break; | |
3352 | |
3353 case PLAYER_SKILL_DODGE: | |
3354 { | |
3355 if ( CheckHiredNPCSpeciality(Monk) ) | |
3356 bonus_value = 2; | |
3357 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DODGE); | |
3358 } | |
3359 break; | |
3360 | |
3361 case PLAYER_SKILL_BOW: | |
3362 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BOW); | |
3363 break; | |
3364 case PLAYER_SKILL_SHIELD: | |
3365 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SHIELD); | |
3366 break; | |
3367 | |
3368 case PLAYER_SKILL_EARTH: | |
3369 if ( CheckHiredNPCSpeciality(Apprentice) ) | |
3370 bonus_value = 2; | |
3371 if ( CheckHiredNPCSpeciality(Mystic) ) | |
3372 bonus_value += 3; | |
3373 if ( CheckHiredNPCSpeciality(Spellmaster) ) | |
3374 bonus_value += 4; | |
3375 if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) | |
3376 bonus_value += 3; | |
3377 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_EARTH); | |
3378 break; | |
3379 case PLAYER_SKILL_FIRE: | |
3380 if ( CheckHiredNPCSpeciality(Apprentice) ) | |
3381 bonus_value = 2; | |
3382 if ( CheckHiredNPCSpeciality(Mystic) ) | |
3383 bonus_value += 3; | |
3384 if ( CheckHiredNPCSpeciality(Spellmaster) ) | |
3385 bonus_value += 4; | |
3386 if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) | |
3387 bonus_value += 3; | |
3388 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_FIRE); | |
3389 break; | |
3390 case PLAYER_SKILL_AIR: | |
3391 if ( CheckHiredNPCSpeciality(Apprentice) ) | |
3392 bonus_value = 2; | |
3393 if ( CheckHiredNPCSpeciality(Mystic) ) | |
3394 bonus_value += 3; | |
3395 if ( CheckHiredNPCSpeciality(Spellmaster) ) | |
3396 bonus_value += 4; | |
3397 if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) | |
3398 bonus_value += 3; | |
3399 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_AIR); | |
3400 break; | |
3401 case PLAYER_SKILL_WATER: | |
3402 if ( CheckHiredNPCSpeciality(Apprentice) ) | |
3403 bonus_value = 2; | |
3404 if ( CheckHiredNPCSpeciality(Mystic) ) | |
3405 bonus_value += 3; | |
3406 if ( CheckHiredNPCSpeciality(Spellmaster) ) | |
3407 bonus_value += 4; | |
3408 if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) | |
3409 bonus_value += 3; | |
3410 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_WATER); | |
3411 break; | |
3412 case PLAYER_SKILL_SPIRIT: | |
3413 if ( CheckHiredNPCSpeciality(Acolyte2) ) | |
3414 bonus_value = 2; | |
3415 if ( CheckHiredNPCSpeciality(Initiate) ) | |
3416 bonus_value += 3; | |
3417 if ( CheckHiredNPCSpeciality(Prelate) ) | |
3418 bonus_value += 4; | |
3419 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SPIRIT); | |
3420 break; | |
3421 case PLAYER_SKILL_MIND: | |
3422 if ( CheckHiredNPCSpeciality(Acolyte2) ) | |
3423 bonus_value = 2; | |
3424 if ( CheckHiredNPCSpeciality(Initiate) ) | |
3425 bonus_value += 3; | |
3426 if ( CheckHiredNPCSpeciality(Prelate) ) | |
3427 bonus_value += 4; | |
3428 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MIND); | |
3429 break; | |
3430 case PLAYER_SKILL_BODY: | |
3431 if ( CheckHiredNPCSpeciality(Acolyte2) ) | |
3432 bonus_value = 2; | |
3433 if ( CheckHiredNPCSpeciality(Initiate) ) | |
3434 bonus_value += 3; | |
3435 if ( CheckHiredNPCSpeciality(Prelate) ) | |
3436 bonus_value += 4; | |
3437 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BODY); | |
3438 break; | |
3439 case PLAYER_SKILL_LIGHT: | |
3440 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LIGHT); | |
3441 break; | |
3442 case PLAYER_SKILL_DARK: | |
3443 { | |
3444 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DARK); | |
3445 } | |
3446 break; | |
3447 | |
3448 case PLAYER_SKILL_MERCHANT: | |
3449 { | |
3450 if ( CheckHiredNPCSpeciality(Trader) ) | |
3451 bonus_value = 4; | |
3452 if ( CheckHiredNPCSpeciality(Merchant) ) | |
3453 bonus_value += 6; | |
3454 if ( CheckHiredNPCSpeciality(Gypsy) ) | |
3455 bonus_value += 3; | |
3456 if ( CheckHiredNPCSpeciality(Duper) ) | |
3457 bonus_value += 8; | |
3458 } | |
3459 break; | |
3460 | |
3461 case PLAYER_SKILL_PERCEPTION: | |
3462 { | |
3463 if ( CheckHiredNPCSpeciality(Scout) ) | |
3464 bonus_value = 6; | |
3465 if ( CheckHiredNPCSpeciality(Psychic) ) | |
3466 bonus_value += 5; | |
3467 } | |
3468 break; | |
3469 | |
3470 case PLAYER_SKILL_ITEM_ID: | |
3471 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID); | |
3472 break; | |
3473 case PLAYER_SKILL_MEDITATION: | |
3474 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MEDITATION); | |
3475 break; | |
3476 case PLAYER_SKILL_TRAP_DISARM: | |
3477 { | |
3478 if ( CheckHiredNPCSpeciality(Tinker) ) | |
3479 bonus_value = 4; | |
3480 if ( CheckHiredNPCSpeciality(Locksmith) ) | |
3481 bonus_value += 6; | |
3482 if ( CheckHiredNPCSpeciality(Burglar) ) | |
3483 bonus_value += 8; | |
3484 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM); | |
3485 } | |
3486 break; | |
3487 } | |
3488 | |
3489 skill_value = pActiveSkills[uSkillType]; | |
3490 if ( bonus_value + (skill_value & 0x3F) < 60 ) | |
3491 result = bonus_value + skill_value; | |
3492 else | |
3493 result = skill_value & 0xFFFC | 0x3C; //al | |
3494 return result; | |
3495 } | |
3496 | |
3497 | |
3498 //----- (0048FC00) -------------------------------------------------------- | |
3499 int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE inSkill) //TODO: move the individual implementations to attribute classes once possible | |
3500 { | |
3501 int armsMasterBonus; | |
3502 | |
3503 armsMasterBonus = 0; | |
3504 int armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); | |
3505 if ( armmaster_skill > 0 ) | |
3506 { | |
3507 int multiplier = 0; | |
3508 if ( inSkill == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS ) | |
3509 { | |
3510 multiplier = GetMultiplierForSkillLevel(armmaster_skill, 0, 0, 1, 2); | |
3511 } | |
3512 else if ( inSkill == CHARACTER_ATTRIBUTE_ATTACK ) | |
3513 { | |
3514 multiplier = GetMultiplierForSkillLevel(armmaster_skill, 0, 1, 1, 2); | |
3515 } | |
3516 armsMasterBonus = multiplier * (armmaster_skill & 0x3F); | |
3517 } | |
3518 | |
3519 switch(inSkill) | |
3520 { | |
3521 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: | |
3522 if (HasItemEquipped(EQUIP_BOW)) | |
3523 { | |
3524 int bowSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); | |
3525 int multiplier = GetMultiplierForSkillLevel(bowSkillLevel, 0, 0, 0, 1); | |
3526 return multiplier * (bowSkillLevel & 0x3F); | |
3527 } | |
3528 return 0; | |
3529 break; | |
3530 case CHARACTER_ATTRIBUTE_HEALTH: | |
3531 { | |
3532 int base_value = pBaseHealthPerLevelByClass[classType]; | |
3533 int attrib_modif = GetBodybuilding(); | |
3534 return base_value * attrib_modif; | |
3535 } | |
3536 break; | |
3537 case CHARACTER_ATTRIBUTE_MANA: | |
3538 { | |
3539 int base_value = pBaseManaPerLevelByClass[classType]; | |
3540 int attrib_modif = GetMeditation(); | |
3541 return base_value * attrib_modif; | |
3542 } | |
3543 break; | |
3544 case CHARACTER_ATTRIBUTE_AC_BONUS: | |
3545 { | |
3546 bool wearingArmor = false; | |
3547 bool wearingLeather = false; | |
3548 unsigned int ACSum = 0; | |
3549 | |
3550 for (int j = 0; j < 16; ++j) | |
3551 { | |
3552 ItemGen* currItem = GetNthEquippedIndexItem(j); | |
3553 if (currItem != nullptr && (!currItem->IsBroken())) | |
3554 { | |
3555 PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)currItem->GetPlayerSkillType(); | |
3556 int currArmorSkillLevel = 0; | |
3557 int multiplier = 0; | |
3558 switch (itemSkillType) | |
3559 { | |
3560 case PLAYER_SKILL_STAFF: | |
3561 currArmorSkillLevel = GetActualSkillLevel(itemSkillType); | |
3562 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 0, 1, 1, 1); | |
3563 break; | |
3564 case PLAYER_SKILL_SWORD: | |
3565 case PLAYER_SKILL_SPEAR: | |
3566 currArmorSkillLevel = GetActualSkillLevel(itemSkillType); | |
3567 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 0, 0, 0, 1); | |
3568 break; | |
3569 case PLAYER_SKILL_SHIELD: | |
3570 currArmorSkillLevel = GetActualSkillLevel(itemSkillType); | |
3571 wearingArmor = true; | |
3572 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 2, 2); | |
3573 break; | |
3574 case PLAYER_SKILL_LEATHER: | |
3575 currArmorSkillLevel = GetActualSkillLevel(itemSkillType); | |
3576 wearingLeather = true; | |
3577 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 2, 2); | |
3578 break; | |
3579 case PLAYER_SKILL_CHAIN: | |
3580 currArmorSkillLevel = GetActualSkillLevel(itemSkillType); | |
3581 wearingArmor = true; | |
3582 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 1, 1); | |
3583 break; | |
3584 case PLAYER_SKILL_PLATE: | |
3585 currArmorSkillLevel = GetActualSkillLevel(itemSkillType); | |
3586 wearingArmor = true; | |
3587 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 1, 1); | |
3588 break; | |
3589 } | |
3590 ACSum += multiplier * (currArmorSkillLevel & 0x3F); | |
3591 } | |
3592 } | |
3593 | |
3594 int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); | |
3595 int dodgeMastery = SkillToMastery(dodgeSkillLevel); | |
3596 int multiplier = GetMultiplierForSkillLevel(dodgeSkillLevel, 1, 2, 3, 3); | |
3597 if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) ) | |
3598 { | |
3599 ACSum += multiplier * (dodgeSkillLevel & 0x3F); | |
3600 } | |
3601 return ACSum; | |
3602 } | |
3603 break; | |
3604 case CHARACTER_ATTRIBUTE_ATTACK: | |
3605 if ( this->IsUnarmed() ) | |
3606 { | |
3607 int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
3608 if (!unarmedSkill) | |
3609 { | |
3610 return 0; | |
3611 } | |
3612 int multiplier = GetMultiplierForSkillLevel(unarmedSkill, 0, 1, 2, 2); | |
3613 return armsMasterBonus + multiplier * (unarmedSkill & 0x3F); | |
3614 } | |
3615 for (int i = 0; i < 16; ++i) | |
3616 { | |
3617 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
3618 { | |
3619 ItemGen* currItem = GetNthEquippedIndexItem(i); | |
3620 if ( currItem->GetItemEquipType() <= EQUIP_TWO_HANDED) | |
3621 { | |
3622 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItem->GetPlayerSkillType(); | |
3623 int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); | |
3624 if (currItemSkillType == PLAYER_SKILL_BLASTER) | |
3625 { | |
3626 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5); | |
3627 return multiplier * (currentItemSkillLevel & 0x3F); | |
3628 } | |
3629 else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) | |
3630 { | |
3631 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
3632 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 2, 2); | |
3633 return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F); | |
3634 } | |
3635 else | |
3636 { | |
3637 return armsMasterBonus + (currentItemSkillLevel & 0x3F); | |
3638 } | |
3639 } | |
3640 } | |
3641 } | |
3642 return 0; | |
3643 break; | |
3644 | |
3645 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: | |
3646 for (int i = 0; i < 16; i++) | |
3647 { | |
3648 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
3649 { | |
3650 ItemGen* currItemPtr = GetNthEquippedIndexItem(i); | |
3651 if ( currItemPtr->GetItemEquipType() == EQUIP_TWO_HANDED || currItemPtr->GetItemEquipType() == EQUIP_SINGLE_HANDED ) | |
3652 { | |
3653 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)GetNthEquippedIndexItem(i)->GetPlayerSkillType(); | |
3654 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); | |
3655 if ( currentItemSkillType == PLAYER_SKILL_BOW ) | |
3656 { | |
3657 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 1, 1); | |
3658 return multiplier * (currentItemSkillLevel & 0x3F); | |
3659 } | |
3660 else if ( currentItemSkillType == PLAYER_SKILL_BLASTER ) | |
3661 { | |
3662 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5); | |
3663 return multiplier * (currentItemSkillLevel & 0x3F); | |
3664 } | |
3665 } | |
3666 } | |
3667 } | |
3668 return 0; | |
3669 break; | |
3670 | |
3671 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS: | |
3672 if ( this->IsUnarmed() ) | |
3673 { | |
3674 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
3675 if ( !unarmedSkillLevel ) | |
3676 { | |
3677 return 0; | |
3678 } | |
3679 int multiplier = GetMultiplierForSkillLevel(unarmedSkillLevel, 0, 1, 2, 2); | |
3680 return multiplier * (unarmedSkillLevel & 0x3F); | |
3681 } | |
3682 for (int i = 0; i < 16; i++) | |
3683 { | |
3684 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | |
3685 { | |
3686 ItemGen* currItemPtr = GetNthEquippedIndexItem(i); | |
3687 if ( currItemPtr->GetItemEquipType() == EQUIP_TWO_HANDED || currItemPtr->GetItemEquipType() == EQUIP_SINGLE_HANDED ) | |
3688 { | |
3689 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItemPtr->GetPlayerSkillType(); | |
3690 int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); | |
3691 int baseSkillBonus; | |
3692 int multiplier; | |
3693 switch (currItemSkillType) | |
3694 { | |
3695 case PLAYER_SKILL_STAFF: | |
3696 if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) | |
3697 { | |
3698 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
3699 int multiplier = GetMultiplierForSkillLevel(unarmedSkillLevel, 0, 1, 2, 2); | |
3700 return multiplier * (unarmedSkillLevel & 0x3F); | |
3701 } | |
3702 else | |
3703 { | |
3704 return armsMasterBonus; | |
3705 } | |
3706 break; | |
3707 | |
3708 case PLAYER_SKILL_DAGGER: | |
3709 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 0, 1); | |
3710 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
3711 return armsMasterBonus + baseSkillBonus; | |
3712 break; | |
3713 case PLAYER_SKILL_SWORD: | |
3714 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 0, 0); | |
3715 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
3716 return armsMasterBonus + baseSkillBonus; | |
3717 break; | |
3718 case PLAYER_SKILL_MACE: | |
3719 case PLAYER_SKILL_SPEAR: | |
3720 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 1, 1, 1); | |
3721 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
3722 return armsMasterBonus + baseSkillBonus; | |
3723 break; | |
3724 case PLAYER_SKILL_AXE: | |
3725 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 1, 1); | |
3726 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); | |
3727 return armsMasterBonus + baseSkillBonus; | |
3728 break; | |
3729 } | |
3730 } | |
3731 } | |
3732 } | |
3733 return 0; | |
3734 break; | |
3735 default: | |
3736 return 0; | |
3737 } | |
3738 } | |
3739 | |
3740 unsigned int Player::GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4) | |
3741 { | |
3742 int masteryLvl = SkillToMastery(skillValue); | |
3743 switch (masteryLvl) | |
3744 { | |
3745 case 1: return mult1; | |
3746 case 2: return mult2; | |
3747 case 3: return mult3; | |
3748 case 4: return mult4; | |
3749 } | |
3750 Error("(%u)", masteryLvl); | |
3751 return 0; | |
3752 } | |
3753 //----- (00490109) -------------------------------------------------------- | |
3754 // faces are: 0 1 2 3 human males | |
3755 // 4 5 6 7 human females | |
3756 // 8 9 elf males | |
3757 // 10 11 elf females | |
3758 // 12 13 dwarf males | |
3759 // 14 15 dwarf females | |
3760 // 16 17 goblin males | |
3761 // 18 19 goblin females | |
3762 // 20 lich male | |
3763 // 21 lich female | |
3764 // 22 underwater suits (unused) | |
3765 // 23 zombie male | |
3766 // 24 zombie female | |
3767 enum CHARACTER_RACE Player::GetRace() | |
3768 { | |
3769 if ( uCurrentFace <= 7 ) | |
3770 { | |
3771 return CHARACTER_RACE_HUMAN; | |
3772 } | |
3773 else if ( uCurrentFace <= 11 ) | |
3774 { | |
3775 return CHARACTER_RACE_ELF; | |
3776 } | |
3777 else if ( uCurrentFace <= 15 ) | |
3778 { | |
3779 return CHARACTER_RACE_DWARF; | |
3780 } | |
3781 else if ( uCurrentFace <= 19 ) | |
3782 { | |
3783 return CHARACTER_RACE_GOBLIN; | |
3784 } | |
3785 else | |
3786 { | |
3787 return CHARACTER_RACE_HUMAN; | |
3788 } | |
3789 } | |
3790 | |
3791 //----- (00490141) -------------------------------------------------------- | |
3792 PLAYER_SEX Player::GetSexByVoice() | |
3793 { | |
3794 switch ( this->uVoiceID ) | |
3795 { | |
3796 case 0u: | |
3797 case 1u: | |
3798 case 2u: | |
3799 case 3u: | |
3800 case 8u: | |
3801 case 9u: | |
3802 case 0xCu: | |
3803 case 0xDu: | |
3804 case 0x10u: | |
3805 case 0x11u: | |
3806 case 0x14u: | |
3807 case 0x17u: | |
3808 return SEX_MALE; | |
3809 | |
3810 case 4u: | |
3811 case 5u: | |
3812 case 6u: | |
3813 case 7u: | |
3814 case 0xAu: | |
3815 case 0xBu: | |
3816 case 0xEu: | |
3817 case 0xFu: | |
3818 case 0x12u: | |
3819 case 0x13u: | |
3820 case 0x15u: | |
3821 case 0x18u: | |
3822 return SEX_FEMALE; | |
3823 } | |
3824 Error("(%u)", this->uVoiceID); | |
3825 return SEX_MALE; | |
3826 } | |
3827 | |
3828 //----- (00490188) -------------------------------------------------------- | |
3829 void Player::SetInitialStats() | |
3830 { | |
3831 CHARACTER_RACE v1 = GetRace(); | |
3832 uMight = StatTable[v1][0].uBaseValue; | |
3833 uIntelligence = StatTable[v1][1].uBaseValue; | |
3834 uWillpower = StatTable[v1][2].uBaseValue; | |
3835 uEndurance = StatTable[v1][3].uBaseValue; | |
3836 uAccuracy = StatTable[v1][4].uBaseValue; | |
3837 uSpeed = StatTable[v1][5].uBaseValue; | |
3838 uLuck = StatTable[v1][6].uBaseValue; | |
3839 } | |
3840 | |
3841 //----- (004901FC) -------------------------------------------------------- | |
3842 void Player::SetSexByVoice() | |
3843 { | |
3844 switch ( this->uVoiceID) | |
3845 { | |
3846 case 0: | |
3847 case 1: | |
3848 case 2: | |
3849 case 3: | |
3850 case 8: | |
3851 case 9: | |
3852 case 0xC: | |
3853 case 0xD: | |
3854 case 0x10: | |
3855 case 0x11: | |
3856 case 0x14: | |
3857 case 0x17: | |
3858 this->uSex = SEX_MALE; | |
3859 break; | |
3860 case 4: | |
3861 case 5: | |
3862 case 6: | |
3863 case 7: | |
3864 case 0xA: | |
3865 case 0xB: | |
3866 case 0xE: | |
3867 case 0xF: | |
3868 case 0x12: | |
3869 case 0x13: | |
3870 case 0x15: | |
3871 case 0x18: | |
3872 this->uSex = SEX_FEMALE; | |
3873 break; | |
3874 default: | |
3875 Error("(%u)", this->uVoiceID); | |
3876 break; | |
3877 } | |
3878 | |
3879 } | |
3880 | |
3881 //----- (0049024A) -------------------------------------------------------- | |
3882 void Player::Reset(PLAYER_CLASS_TYPE cls) | |
3883 { | |
3884 sLevelModifier = 0; | |
3885 sAgeModifier = 0; | |
3886 | |
3887 classType = cls; | |
3888 uLuckBonus = 0; | |
3889 uSpeedBonus = 0; | |
3890 uAccuracyBonus = 0; | |
3891 uEnduranceBonus = 0; | |
3892 uWillpowerBonus = 0; | |
3893 uIntelligenceBonus = 0; | |
3894 uMightBonus = 0; | |
3895 uLevel = 1; | |
3896 uExperience = 251 + rand() % 100; | |
3897 uBirthYear = 1147 - rand() % 6; | |
3898 pActiveSkills.fill(0); | |
3899 memset(_achieved_awards_bits, 0, sizeof(_achieved_awards_bits)); | |
3900 memset(&spellbook, 0, sizeof(spellbook)); | |
3901 | |
3902 for (uint i = 0; i < 37; ++i) | |
3903 { | |
3904 if (pSkillAvailabilityPerClass[classType / 4][i] != 2) | |
3905 continue; | |
3906 | |
3907 pActiveSkills[i] = 1; | |
3908 | |
3909 switch (i) | |
3910 { | |
3911 case PLAYER_SKILL_FIRE: | |
3912 spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;//its temporary, for test spells | |
3913 | |
3914 extern bool all_magic; | |
3915 if ( all_magic == true ) | |
3916 { | |
3917 pActiveSkills[PLAYER_SKILL_AIR] = 1; | |
3918 pActiveSkills[PLAYER_SKILL_WATER] = 1; | |
3919 pActiveSkills[PLAYER_SKILL_EARTH] = 1; | |
3920 spellbook.pFireSpellbook.bIsSpellAvailable[1] = true; | |
3921 spellbook.pFireSpellbook.bIsSpellAvailable[2] = true; | |
3922 spellbook.pFireSpellbook.bIsSpellAvailable[3] = true; | |
3923 spellbook.pFireSpellbook.bIsSpellAvailable[4] = true; | |
3924 spellbook.pFireSpellbook.bIsSpellAvailable[5] = true; | |
3925 spellbook.pFireSpellbook.bIsSpellAvailable[6] = true; | |
3926 spellbook.pFireSpellbook.bIsSpellAvailable[7] = true; | |
3927 spellbook.pFireSpellbook.bIsSpellAvailable[8] = true; | |
3928 spellbook.pFireSpellbook.bIsSpellAvailable[9] = true; | |
3929 spellbook.pFireSpellbook.bIsSpellAvailable[10] = true; | |
3930 spellbook.pAirSpellbook.bIsSpellAvailable[0] = true; | |
3931 spellbook.pAirSpellbook.bIsSpellAvailable[1] = true; | |
3932 spellbook.pAirSpellbook.bIsSpellAvailable[2] = true; | |
3933 spellbook.pAirSpellbook.bIsSpellAvailable[3] = true; | |
3934 spellbook.pAirSpellbook.bIsSpellAvailable[4] = true; | |
3935 spellbook.pAirSpellbook.bIsSpellAvailable[5] = true; | |
3936 spellbook.pAirSpellbook.bIsSpellAvailable[6] = true; | |
3937 spellbook.pAirSpellbook.bIsSpellAvailable[7] = true; | |
3938 spellbook.pAirSpellbook.bIsSpellAvailable[8] = true; | |
3939 spellbook.pAirSpellbook.bIsSpellAvailable[9] = true; | |
3940 spellbook.pAirSpellbook.bIsSpellAvailable[10] = true; | |
3941 spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true; | |
3942 spellbook.pWaterSpellbook.bIsSpellAvailable[1] = true; | |
3943 spellbook.pWaterSpellbook.bIsSpellAvailable[2] = true; | |
3944 spellbook.pWaterSpellbook.bIsSpellAvailable[3] = true; | |
3945 spellbook.pWaterSpellbook.bIsSpellAvailable[4] = true; | |
3946 spellbook.pWaterSpellbook.bIsSpellAvailable[5] = true; | |
3947 spellbook.pWaterSpellbook.bIsSpellAvailable[6] = true; | |
3948 spellbook.pWaterSpellbook.bIsSpellAvailable[7] = true; | |
3949 spellbook.pWaterSpellbook.bIsSpellAvailable[8] = true; | |
3950 spellbook.pWaterSpellbook.bIsSpellAvailable[9] = true; | |
3951 spellbook.pWaterSpellbook.bIsSpellAvailable[10] = true; | |
3952 spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true; | |
3953 spellbook.pEarthSpellbook.bIsSpellAvailable[1] = true; | |
3954 spellbook.pEarthSpellbook.bIsSpellAvailable[2] = true; | |
3955 spellbook.pEarthSpellbook.bIsSpellAvailable[3] = true; | |
3956 spellbook.pEarthSpellbook.bIsSpellAvailable[4] = true; | |
3957 spellbook.pEarthSpellbook.bIsSpellAvailable[5] = true; | |
3958 spellbook.pEarthSpellbook.bIsSpellAvailable[6] = true; | |
3959 spellbook.pEarthSpellbook.bIsSpellAvailable[7] = true; | |
3960 spellbook.pEarthSpellbook.bIsSpellAvailable[8] = true; | |
3961 spellbook.pEarthSpellbook.bIsSpellAvailable[9] = true; | |
3962 spellbook.pEarthSpellbook.bIsSpellAvailable[10] = true; | |
3963 } | |
3964 break; | |
3965 case PLAYER_SKILL_AIR: | |
3966 spellbook.pAirSpellbook.bIsSpellAvailable[0] = true; | |
3967 break; | |
3968 case PLAYER_SKILL_WATER: | |
3969 spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true; | |
3970 break; | |
3971 case PLAYER_SKILL_EARTH: | |
3972 spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true; | |
3973 break; | |
3974 case PLAYER_SKILL_SPIRIT: | |
3975 spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true; | |
3976 break; | |
3977 case PLAYER_SKILL_MIND: | |
3978 spellbook.pMindSpellbook.bIsSpellAvailable[0] = true; | |
3979 break; | |
3980 case PLAYER_SKILL_BODY: | |
3981 spellbook.pBodySpellbook.bIsSpellAvailable[0] = true; | |
3982 | |
3983 if ( all_magic == true ) | |
3984 { | |
3985 pActiveSkills[PLAYER_SKILL_MIND] = 1; | |
3986 pActiveSkills[PLAYER_SKILL_SPIRIT] = 1; | |
3987 spellbook.pBodySpellbook.bIsSpellAvailable[1] = true; | |
3988 spellbook.pBodySpellbook.bIsSpellAvailable[2] = true; | |
3989 spellbook.pBodySpellbook.bIsSpellAvailable[3] = true; | |
3990 spellbook.pBodySpellbook.bIsSpellAvailable[4] = true; | |
3991 spellbook.pBodySpellbook.bIsSpellAvailable[5] = true; | |
3992 spellbook.pBodySpellbook.bIsSpellAvailable[6] = true; | |
3993 spellbook.pBodySpellbook.bIsSpellAvailable[7] = true; | |
3994 spellbook.pBodySpellbook.bIsSpellAvailable[8] = true; | |
3995 spellbook.pBodySpellbook.bIsSpellAvailable[9] = true; | |
3996 spellbook.pBodySpellbook.bIsSpellAvailable[10] = true; | |
3997 spellbook.pMindSpellbook.bIsSpellAvailable[0] = true; | |
3998 spellbook.pMindSpellbook.bIsSpellAvailable[1] = true; | |
3999 spellbook.pMindSpellbook.bIsSpellAvailable[2] = true; | |
4000 spellbook.pMindSpellbook.bIsSpellAvailable[3] = true; | |
4001 spellbook.pMindSpellbook.bIsSpellAvailable[4] = true; | |
4002 spellbook.pMindSpellbook.bIsSpellAvailable[5] = true; | |
4003 spellbook.pMindSpellbook.bIsSpellAvailable[6] = true; | |
4004 spellbook.pMindSpellbook.bIsSpellAvailable[7] = true; | |
4005 spellbook.pMindSpellbook.bIsSpellAvailable[8] = true; | |
4006 spellbook.pMindSpellbook.bIsSpellAvailable[9] = true; | |
4007 spellbook.pMindSpellbook.bIsSpellAvailable[10] = true; | |
4008 spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true; | |
4009 spellbook.pSpiritSpellbook.bIsSpellAvailable[1] = true; | |
4010 spellbook.pSpiritSpellbook.bIsSpellAvailable[2] = true; | |
4011 spellbook.pSpiritSpellbook.bIsSpellAvailable[3] = true; | |
4012 spellbook.pSpiritSpellbook.bIsSpellAvailable[4] = true; | |
4013 spellbook.pSpiritSpellbook.bIsSpellAvailable[5] = true; | |
4014 spellbook.pSpiritSpellbook.bIsSpellAvailable[6] = true; | |
4015 spellbook.pSpiritSpellbook.bIsSpellAvailable[7] = true; | |
4016 spellbook.pSpiritSpellbook.bIsSpellAvailable[8] = true; | |
4017 spellbook.pSpiritSpellbook.bIsSpellAvailable[9] = true; | |
4018 spellbook.pSpiritSpellbook.bIsSpellAvailable[10] = true; | |
4019 } | |
4020 break; | |
4021 case PLAYER_SKILL_LIGHT: | |
4022 spellbook.pLightSpellbook.bIsSpellAvailable[0] = true; | |
4023 break; | |
4024 case PLAYER_SKILL_DARK: | |
4025 spellbook.pDarkSpellbook.bIsSpellAvailable[0] = true; | |
4026 break; | |
4027 } | |
4028 } | |
4029 | |
4030 memset(&pEquipment, 0, sizeof(PlayerEquipment)); | |
4031 pInventoryMatrix.fill(0); | |
4032 for (uint i = 0; i < 126; ++i) | |
4033 pInventoryItemList[i].Reset(); | |
4034 for (uint i = 0; i < 12; ++i) | |
4035 pEquippedItems[i].Reset(); | |
4036 | |
4037 sHealth = GetMaxHealth(); | |
4038 sMana = GetMaxMana(); | |
4039 } | |
4040 | |
4041 //----- (004903C9) -------------------------------------------------------- | |
4042 PLAYER_SKILL_TYPE Player::GetSkillIdxByOrder(signed int order) | |
4043 { | |
4044 int counter; // edx@5 | |
4045 bool canBeInactive; | |
4046 unsigned char requiredValue; | |
4047 signed int offset; | |
4048 | |
4049 if ( order <= 1 ) | |
4050 { | |
4051 canBeInactive = false; | |
4052 requiredValue = 2; // 2 - primary skill | |
4053 offset = 0; | |
4054 } | |
4055 else if ( order <= 3 ) | |
4056 { | |
4057 canBeInactive = false; | |
4058 requiredValue = 1; // 1 - available | |
4059 offset = 2; | |
4060 } | |
4061 else if ( order <= 12 ) | |
4062 { | |
4063 canBeInactive = true; | |
4064 requiredValue = 1; // 1 - available | |
4065 offset = 4; | |
4066 } | |
4067 else | |
4068 { | |
4069 return (PLAYER_SKILL_TYPE)37; | |
4070 } | |
4071 counter = 0; | |
4072 for (int i = 0; i < 37; i++) | |
4073 { | |
4074 if ( (this->pActiveSkills[i] || canBeInactive) && pSkillAvailabilityPerClass[classType / 4][i] == requiredValue ) | |
4075 { | |
4076 if ( counter == order - offset ) | |
4077 return (PLAYER_SKILL_TYPE)i; | |
4078 ++counter; | |
4079 } | |
4080 } | |
4081 | |
4082 return (PLAYER_SKILL_TYPE)37; | |
4083 } | |
4084 | |
4085 | |
4086 | |
4087 //----- (0049048D) -------------------------------------------------------- | |
4088 //unsigned __int16 PartyCreation_BtnMinusClick(Player *_this, int eAttribute) | |
4089 void Player::DecreaseAttribute(int eAttribute) | |
4090 { | |
4091 int pBaseValue; // ecx@1 | |
4092 int pDroppedStep; // ebx@1 | |
4093 int pStep; // esi@1 | |
4094 int uMinValue; // [sp+Ch] [bp-4h]@1 | |
4095 | |
4096 int raceId = GetRace(); | |
4097 pBaseValue = StatTable[raceId][eAttribute].uBaseValue; | |
4098 pDroppedStep = StatTable[raceId][eAttribute].uDroppedStep; | |
4099 uMinValue = pBaseValue - 2; | |
4100 pStep = StatTable[raceId][eAttribute].uBaseStep; | |
4101 unsigned short* AttrToChange = nullptr; | |
4102 switch ( eAttribute ) | |
4103 { | |
4104 case CHARACTER_ATTRIBUTE_STRENGTH: | |
4105 AttrToChange = &this->uMight; | |
4106 break; | |
4107 case CHARACTER_ATTRIBUTE_INTELLIGENCE: | |
4108 AttrToChange = &this->uIntelligence; | |
4109 break; | |
4110 case CHARACTER_ATTRIBUTE_WILLPOWER: | |
4111 AttrToChange = &this->uWillpower; | |
4112 break; | |
4113 case CHARACTER_ATTRIBUTE_ENDURANCE: | |
4114 AttrToChange = &this->uEndurance; | |
4115 break; | |
4116 case CHARACTER_ATTRIBUTE_ACCURACY: | |
4117 AttrToChange = &this->uAccuracy; | |
4118 break; | |
4119 case CHARACTER_ATTRIBUTE_SPEED: | |
4120 AttrToChange = &this->uSpeed; | |
4121 break; | |
4122 case CHARACTER_ATTRIBUTE_LUCK: | |
4123 AttrToChange = &this->uLuck; | |
4124 break; | |
4125 } | |
4126 if ( *AttrToChange <= pBaseValue ) | |
4127 pStep = pDroppedStep; | |
4128 if ( *AttrToChange - pStep >= uMinValue ) | |
4129 *AttrToChange -= pStep; | |
4130 } | |
4131 | |
4132 //----- (004905F5) -------------------------------------------------------- | |
4133 //signed int PartyCreation_BtnPlusClick(Player *this, int eAttribute) | |
4134 void Player::IncreaseAttribute( int eAttribute ) | |
4135 { | |
4136 int raceId; // eax@1 | |
4137 int maxValue; // ebx@1 | |
4138 signed int baseStep; // edi@1 | |
4139 signed int tmp; // eax@17 | |
4140 signed int result; // eax@18 | |
4141 int baseValue; // [sp+Ch] [bp-8h]@1 | |
4142 signed int droppedStep; // [sp+10h] [bp-4h]@1 | |
4143 unsigned short* statToChange; | |
4144 | |
4145 raceId = GetRace(); | |
4146 maxValue = StatTable[raceId][eAttribute].uMaxValue; | |
4147 baseStep = StatTable[raceId][eAttribute].uBaseStep; | |
4148 baseValue = StatTable[raceId][eAttribute].uBaseValue; | |
4149 droppedStep = StatTable[raceId][eAttribute].uDroppedStep; | |
4150 PlayerCreation_GetUnspentAttributePointCount(); | |
4151 switch ( eAttribute ) | |
4152 { | |
4153 case 0: | |
4154 statToChange = &this->uMight; | |
4155 break; | |
4156 case 1: | |
4157 statToChange = &this->uIntelligence; | |
4158 break; | |
4159 case 2: | |
4160 statToChange = &this->uWillpower; | |
4161 break; | |
4162 case 3: | |
4163 statToChange = &this->uEndurance; | |
4164 break; | |
4165 case 4: | |
4166 statToChange = &this->uAccuracy; | |
4167 break; | |
4168 case 5: | |
4169 statToChange = &this->uSpeed; | |
4170 break; | |
4171 case 6: | |
4172 statToChange = &this->uLuck; | |
4173 break; | |
4174 default: | |
4175 Error("(%u)", eAttribute); | |
4176 break; | |
4177 } | |
4178 if ( *statToChange < baseValue ) | |
4179 { | |
4180 tmp = baseStep; | |
4181 baseStep = droppedStep; | |
4182 droppedStep = tmp; | |
4183 } | |
4184 result = PlayerCreation_GetUnspentAttributePointCount(); | |
4185 if ( result >= droppedStep ) | |
4186 { | |
4187 if ( baseStep + *statToChange <= maxValue ) | |
4188 *statToChange += baseStep; | |
4189 } | |
4190 } | |
4191 | |
4192 //----- (0049070F) -------------------------------------------------------- | |
4193 void Player::Zero() | |
4194 { | |
4195 this->sLevelModifier = 0; | |
4196 this->sACModifier = 0; | |
4197 this->uLuckBonus = 0; | |
4198 this->uAccuracyBonus = 0; | |
4199 this->uSpeedBonus = 0; | |
4200 this->uEnduranceBonus = 0; | |
4201 this->uWillpowerBonus = 0; | |
4202 this->uIntelligenceBonus = 0; | |
4203 this->uMightBonus = 0; | |
4204 this->field_100 = 0; | |
4205 this->field_FC = 0; | |
4206 this->field_F8 = 0; | |
4207 this->field_F4 = 0; | |
4208 this->field_F0 = 0; | |
4209 this->field_EC = 0; | |
4210 this->field_E8 = 0; | |
4211 this->field_E4 = 0; | |
4212 this->field_E0 = 0; | |
4213 memset(&this->sResFireBonus, 0, 0x16u); | |
4214 this->field_1A97 = 0; | |
4215 this->_ranged_dmg_bonus = 0; | |
4216 this->field_1A95 = 0; | |
4217 this->_ranged_atk_bonus = 0; | |
4218 this->field_1A93 = 0; | |
4219 this->_melee_dmg_bonus = 0; | |
4220 this->field_1A91 = 0; | |
4221 this->_some_attack_bonus = 0; | |
4222 this->_mana_related = 0; | |
4223 this->uFullManaBonus = 0; | |
4224 this->_health_related = 0; | |
4225 this->uFullHealthBonus = 0; | |
4226 } | |
4227 | |
4228 //----- (004907E7) -------------------------------------------------------- | |
4229 unsigned int Player::GetStatColor(int uStat) | |
4230 { | |
4231 int attribute_value; // edx@1 | |
4232 | |
4233 int base_attribute_value = StatTable[GetRace()][uStat].uBaseValue; | |
4234 switch (uStat) | |
4235 { | |
4236 case 0: attribute_value = uMight; break; | |
4237 case 1: attribute_value = uIntelligence; break; | |
4238 case 2: attribute_value = uWillpower; break; | |
4239 case 3: attribute_value = uEndurance; break; | |
4240 case 4: attribute_value = uAccuracy; break; | |
4241 case 5: attribute_value = uSpeed; break; | |
4242 case 6: attribute_value = uLuck; break; | |
4243 default: Error("Unexpected attribute"); | |
4244 }; | |
4245 | |
4246 if (attribute_value == base_attribute_value) | |
4247 return ui_character_stat_default_color; | |
4248 else if (attribute_value > base_attribute_value) | |
4249 return ui_character_stat_buffed_color; | |
4250 else | |
4251 return ui_character_stat_debuffed_color; | |
4252 } | |
4253 | |
4254 //----- (004908A8) -------------------------------------------------------- | |
4255 bool Player::DiscardConditionIfLastsLongerThan(unsigned int uCondition, signed __int64 uTime) | |
4256 { | |
4257 if ( pConditions[uCondition] && (uTime < (signed long long)pConditions[uCondition]) ) | |
4258 { | |
4259 pConditions[uCondition] = 0i64; | |
4260 return true; | |
4261 } | |
4262 else | |
4263 return false; | |
4264 } | |
4265 | |
4266 //----- (004680ED) -------------------------------------------------------- | |
4267 void Player::UseItem_DrinkPotion_etc(signed int player_num, int a3) | |
4268 { | |
4269 Player *playerAffected; // esi@1 | |
4270 signed int v5; // eax@17 | |
4271 int v8; // edx@39 | |
4272 const char *v13; // eax@45 | |
4273 signed int v15; // edi@68 | |
4274 int v16; // edx@73 | |
4275 unsigned __int16 v17; // edi@73 | |
4276 unsigned int v18; // eax@73 | |
4277 const char *v22; // eax@84 | |
4278 int scroll_id; // esi@96 | |
4279 int v25; // eax@109 | |
4280 int v26; // eax@113 | |
4281 int new_mana_val; // edi@114 | |
4282 signed __int64 v28; // qax@120 | |
4283 __int64 v30; // edi@137 | |
4284 __int64 v32; // ST3C_4@137 | |
4285 __int64 v34; // ST34_4@137 | |
4286 unsigned __int16 v50; // [sp-Ch] [bp-38h]@120 | |
4287 const char *v66; // [sp-4h] [bp-30h]@69 | |
4288 signed int v67; // [sp-4h] [bp-30h]@77 | |
4289 const char *v68; // [sp-4h] [bp-30h]@89 | |
4290 char v72; // [sp+20h] [bp-Ch]@68 | |
4291 signed int v73; // [sp+24h] [bp-8h]@1 | |
4292 const char* v74; // [sp+24h] [bp-8h]@23 | |
4293 //Player *thisb; // [sp+28h] [bp-4h]@1 | |
4294 unsigned int thisa; // [sp+28h] [bp-4h]@22 | |
4295 | |
4296 //thisb = this; | |
4297 playerAffected = &pParty->pPlayers[player_num-1]; | |
4298 v73 = 1; | |
4299 if ( pParty->bTurnBasedModeOn == true && (pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_MOVEMENT) ) | |
4300 return; | |
4301 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_REAGENT ) | |
4302 { | |
4303 if ( pParty->pPickedItem.uItemID == 160 ) | |
4304 { | |
4305 playerAffected->SetCondition(Condition_Poison_Weak, 1); | |
4306 } | |
4307 else if ( pParty->pPickedItem.uItemID == 161 ) | |
4308 { | |
4309 new_mana_val = playerAffected->sMana; | |
4310 new_mana_val += 2; | |
4311 if ( new_mana_val > playerAffected->GetMaxMana() ) | |
4312 new_mana_val = playerAffected->GetMaxMana(); | |
4313 playerAffected->PlaySound(SPEECH_36, 0); | |
4314 } | |
4315 else if ( pParty->pPickedItem.uItemID == 162 ) | |
4316 { | |
4317 playerAffected->Heal(2); | |
4318 playerAffected->PlaySound(SPEECH_36, 0); | |
4319 } | |
4320 else | |
4321 { | |
4322 v68 = pParty->pPickedItem.GetDisplayName(); | |
4323 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" | |
4324 ShowStatusBarString(pTmpBuf.data(), 2); | |
4325 pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); | |
4326 return; | |
4327 } | |
4328 pAudioPlayer->PlaySound((SoundID)211, 0, 0, -1, 0, 0, 0, 0); | |
4329 | |
4330 if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) | |
4331 { | |
4332 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); | |
4333 } | |
4334 if ( v73 ) | |
4335 { | |
4336 if ( pParty->bTurnBasedModeOn ) | |
4337 { | |
4338 pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; | |
4339 this->SetRecoveryTime(100); | |
4340 pTurnEngine->ApplyPlayerAction(); | |
4341 } | |
4342 else | |
4343 { | |
4344 this->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); | |
4345 } | |
4346 } | |
4347 pMouse->RemoveHoldingItem(); | |
4348 return; | |
4349 } | |
4350 | |
4351 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_POTION ) | |
4352 { | |
4353 switch ( pParty->pPickedItem.uItemID ) | |
4354 { | |
4355 case 221: //Catalyst | |
4356 playerAffected->SetCondition(Condition_Poison_Weak, 1); | |
4357 break; | |
4358 case 222: //Cure Wounds | |
4359 v25 = pParty->pPickedItem.uEnchantmentType + 10; | |
4360 playerAffected->Heal(v25); | |
4361 playerAffected->PlaySound(SPEECH_36, 0); | |
4362 break; | |
4363 case 223: //Magic Potion | |
4364 v26 = pParty->pPickedItem.uEnchantmentType + 10; | |
4365 new_mana_val = playerAffected->sMana; | |
4366 new_mana_val += v26; | |
4367 if ( new_mana_val > playerAffected->GetMaxMana() ) | |
4368 new_mana_val = playerAffected->GetMaxMana(); | |
4369 playerAffected->PlaySound(SPEECH_36, 0); | |
4370 playerAffected->sMana = new_mana_val; | |
4371 break; | |
4372 case 224: //Cure Weakness | |
4373 playerAffected->pConditions[Condition_Weak] = 0i64; | |
4374 playerAffected->PlaySound(SPEECH_36, 0); | |
4375 break; | |
4376 case 225: //Cure Disease | |
4377 playerAffected->pConditions[Condition_Disease_Severe] = 0i64; | |
4378 playerAffected->pConditions[Condition_Disease_Medium] = 0i64; | |
4379 playerAffected->pConditions[Condition_Disease_Weak] = 0i64; | |
4380 playerAffected->PlaySound(SPEECH_36, 0); | |
4381 break; | |
4382 case 226: //Cure Poison | |
4383 playerAffected->pConditions[Condition_Poison_Severe] = 0i64; | |
4384 playerAffected->pConditions[Condition_Poison_Medium] = 0i64; | |
4385 playerAffected->pConditions[Condition_Poison_Weak] = 0i64; | |
4386 playerAffected->PlaySound(SPEECH_36, 0); | |
4387 break; | |
4388 case 227: //Awaken | |
4389 playerAffected->pConditions[Condition_Sleep] = 0i64; | |
4390 playerAffected->PlaySound(SPEECH_36, 0); | |
4391 break; | |
4392 case 228: //Haste | |
4393 if ( !playerAffected->pConditions[Condition_Weak] ) | |
4394 { | |
4395 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4396 playerAffected->pPlayerBuffs[PLAYER_BUFF_HASTE].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); | |
4397 playerAffected->PlaySound(SPEECH_36, 0); | |
4398 } | |
4399 break; | |
4400 case 229: //Heroism | |
4401 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4402 playerAffected->pPlayerBuffs[PLAYER_BUFF_HEROISM].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); | |
4403 playerAffected->PlaySound(SPEECH_36, 0); | |
4404 break; | |
4405 case 230: //Bless | |
4406 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4407 playerAffected->pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); | |
4408 playerAffected->PlaySound(SPEECH_36, 0); | |
4409 break; | |
4410 case 231: //Preservation | |
4411 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4412 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4413 playerAffected->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4414 playerAffected->PlaySound(SPEECH_36, 0); | |
4415 break; | |
4416 case 232: //Shield | |
4417 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4418 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4419 playerAffected->pPlayerBuffs[PLAYER_BUFF_SHIELD].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4420 playerAffected->PlaySound(SPEECH_36, 0); | |
4421 break; | |
4422 case 234: //Stoneskin | |
4423 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4424 playerAffected->pPlayerBuffs[PLAYER_BUFF_STONESKIN].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); | |
4425 playerAffected->PlaySound(SPEECH_36, 0); | |
4426 break; | |
4427 case 235: //Water Breathing | |
4428 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335), | |
4429 playerAffected->pPlayerBuffs[PLAYER_BUFF_WATER_WALK].Apply(pParty->uTimePlayed +v28, 3, 5, 0, 0); | |
4430 break; | |
4431 case 237: //Remove Fear | |
4432 playerAffected->pConditions[Condition_Fear] = 0i64; | |
4433 playerAffected->PlaySound(SPEECH_36, 0); | |
4434 break; | |
4435 case 238: //Remove Curse | |
4436 playerAffected->pConditions[Condition_Cursed] = 0i64; | |
4437 playerAffected->PlaySound(SPEECH_36, 0); | |
4438 break; | |
4439 case 239: //Cure Insanity | |
4440 playerAffected->pConditions[Condition_Insane] = 0i64; | |
4441 playerAffected->PlaySound(SPEECH_36, 0); | |
4442 break; | |
4443 case 240: //Might Boost | |
4444 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4445 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4446 playerAffected->pPlayerBuffs[PLAYER_BUFF_STRENGTH].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4447 playerAffected->PlaySound(SPEECH_36, 0); | |
4448 break; | |
4449 case 241: //Intellect Boost | |
4450 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4451 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4452 playerAffected->pPlayerBuffs[PLAYER_BUFF_INTELLIGENCE].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4453 playerAffected->PlaySound(SPEECH_36, 0); | |
4454 break; | |
4455 case 242: //Personality Boost | |
4456 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4457 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4458 playerAffected->pPlayerBuffs[PLAYER_BUFF_WILLPOWER].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4459 playerAffected->PlaySound(SPEECH_36, 0); | |
4460 break; | |
4461 case 243://Endurance Boost | |
4462 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4463 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4464 playerAffected->pPlayerBuffs[PLAYER_BUFF_ENDURANCE].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4465 playerAffected->PlaySound(SPEECH_36, 0); | |
4466 break; | |
4467 case 244: //Speed Boost | |
4468 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4469 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4470 playerAffected->pPlayerBuffs[PLAYER_BUFF_SPEED].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4471 playerAffected->PlaySound(SPEECH_36, 0); | |
4472 break; | |
4473 case 245: //Accuracy Boost | |
4474 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4475 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4476 playerAffected->pPlayerBuffs[PLAYER_BUFF_ACCURACY].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4477 playerAffected->PlaySound(SPEECH_36, 0); | |
4478 break; | |
4479 case 251: //Cure Paralysis | |
4480 playerAffected->pConditions[Condition_Paralyzed] = 0i64; | |
4481 playerAffected->PlaySound(SPEECH_36, 0); | |
4482 break; | |
4483 case 252://Divine Restoration | |
4484 v30 = playerAffected->pConditions[Condition_Dead]; | |
4485 v32 = playerAffected->pConditions[Condition_Pertified]; | |
4486 v34 = playerAffected->pConditions[Condition_Eradicated]; | |
4487 pConditions.fill(0); | |
4488 playerAffected->pConditions[Condition_Dead] = v30; | |
4489 playerAffected->pConditions[Condition_Pertified] = v32; | |
4490 playerAffected->pConditions[Condition_Eradicated] = v34; | |
4491 playerAffected->PlaySound(SPEECH_36, 0); | |
4492 break; | |
4493 case 253: //Divine Cure | |
4494 v25 = 5 * pParty->pPickedItem.uEnchantmentType; | |
4495 playerAffected->Heal(v25); | |
4496 playerAffected->PlaySound(SPEECH_36, 0); | |
4497 break; | |
4498 case 254: //Divine Power | |
4499 v26 = 5 * pParty->pPickedItem.uEnchantmentType; | |
4500 new_mana_val = playerAffected->sMana; | |
4501 new_mana_val += v26; | |
4502 if ( new_mana_val > playerAffected->GetMaxMana() ) | |
4503 new_mana_val = playerAffected->GetMaxMana(); | |
4504 playerAffected->PlaySound(SPEECH_36, 0); | |
4505 break; | |
4506 case 255: //Luck Boost | |
4507 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4508 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4509 playerAffected->pPlayerBuffs[PLAYER_BUFF_LUCK].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4510 playerAffected->PlaySound(SPEECH_36, 0); | |
4511 break; | |
4512 case 256: //Fire Resistance | |
4513 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4514 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4515 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_FIRE].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4516 playerAffected->PlaySound(SPEECH_36, 0); | |
4517 break; | |
4518 case 257: //Air Resistance | |
4519 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4520 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4521 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_AIR].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4522 playerAffected->PlaySound(SPEECH_36, 0); | |
4523 break; | |
4524 case 258: //Water Resistance | |
4525 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4526 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4527 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_WATER].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4528 playerAffected->PlaySound(SPEECH_36, 0); | |
4529 break; | |
4530 case 259: //Earth Resistance | |
4531 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4532 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4533 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_EARTH].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4534 playerAffected->PlaySound(SPEECH_36, 0); | |
4535 break; | |
4536 case 260: //Mind Resistance | |
4537 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4538 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4539 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_MIND].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4540 playerAffected->PlaySound(SPEECH_36, 0); | |
4541 break; | |
4542 case 261: //Body Resistance | |
4543 v50 = 3 * pParty->pPickedItem.uEnchantmentType; | |
4544 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); | |
4545 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_BODY].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); | |
4546 playerAffected->PlaySound(SPEECH_36, 0); | |
4547 break; | |
4548 case 262: //Stone to Flesh | |
4549 playerAffected->pConditions[Condition_Pertified] = 0i64; | |
4550 playerAffected->PlaySound(SPEECH_36, 0); | |
4551 break; | |
4552 case 264: //Pure Luck | |
4553 if ( !playerAffected->pure_luck_used ) | |
4554 { | |
4555 playerAffected->uLuck += 50; | |
4556 playerAffected->pure_luck_used = 1; | |
4557 } | |
4558 playerAffected->PlaySound(SPEECH_36, 0); | |
4559 break; | |
4560 case 265: //Pure Speed | |
4561 if ( !playerAffected->pure_speed_used ) | |
4562 { | |
4563 playerAffected->uSpeed += 50; | |
4564 playerAffected->pure_speed_used = 1; | |
4565 } | |
4566 playerAffected->PlaySound(SPEECH_36, 0); | |
4567 break; | |
4568 case 266: //Pure Intellect | |
4569 if ( !playerAffected->pure_intellect_used ) | |
4570 { | |
4571 playerAffected->uIntelligence += 50; | |
4572 playerAffected->pure_intellect_used = 1; | |
4573 } | |
4574 playerAffected->PlaySound(SPEECH_36, 0); | |
4575 break; | |
4576 case 267: //Pure Endurance | |
4577 if ( !playerAffected->pure_endurance_used ) | |
4578 { | |
4579 playerAffected->uEndurance += 50; | |
4580 playerAffected->pure_endurance_used = 1; | |
4581 } | |
4582 playerAffected->PlaySound(SPEECH_36, 0); | |
4583 break; | |
4584 case 268: //Pure Personality | |
4585 if ( !playerAffected->pure_willpower_used ) | |
4586 { | |
4587 playerAffected->uWillpower += 50; | |
4588 playerAffected->pure_willpower_used = 1; | |
4589 } | |
4590 playerAffected->PlaySound(SPEECH_36, 0); | |
4591 break; | |
4592 case 269: //Pure Accuracy | |
4593 if ( !playerAffected->pure_accuracy_used ) | |
4594 { | |
4595 playerAffected->uAccuracy += 50; | |
4596 playerAffected->pure_accuracy_used = 1; | |
4597 } | |
4598 playerAffected->PlaySound(SPEECH_36, 0); | |
4599 break; | |
4600 case 270: //Pure Might | |
4601 if ( !playerAffected->pure_might_used ) | |
4602 { | |
4603 playerAffected->uMight += 50; | |
4604 playerAffected->pure_might_used = 1; | |
4605 } | |
4606 playerAffected->PlaySound(SPEECH_36, 0); | |
4607 break; | |
4608 case 271: //Rejuvenation | |
4609 playerAffected->sAgeModifier = 0; | |
4610 playerAffected->PlaySound(SPEECH_36, 0); | |
4611 break; | |
4612 | |
4613 default: | |
4614 v68 = pParty->pPickedItem.GetDisplayName(); | |
4615 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" | |
4616 ShowStatusBarString(pTmpBuf.data(), 2u); | |
4617 pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); | |
4618 return; | |
4619 } | |
4620 pAudioPlayer->PlaySound((SoundID)210, 0, 0, -1, 0, 0, 0, 0); | |
4621 if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) | |
4622 { | |
4623 // if ( !v73 ) v73 is always 1 at this point | |
4624 // { | |
4625 // pMouse->RemoveHoldingItem(); | |
4626 // return; | |
4627 // } | |
4628 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); | |
4629 } | |
4630 if ( v73 ) | |
4631 { | |
4632 if ( pParty->bTurnBasedModeOn ) | |
4633 { | |
4634 pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; | |
4635 this->SetRecoveryTime(100); | |
4636 pTurnEngine->ApplyPlayerAction(); | |
4637 } | |
4638 else | |
4639 { | |
4640 this->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); | |
4641 } | |
4642 } | |
4643 pMouse->RemoveHoldingItem(); | |
4644 return; | |
4645 } | |
4646 | |
4647 | |
4648 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_SPELL_SCROLL ) | |
4649 { | |
4650 if ( pCurrentScreen == SCREEN_CASTING ) | |
4651 return; | |
4652 if ( !playerAffected->CanAct() ) | |
4653 { | |
4654 | |
4655 v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()]; | |
4656 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68); | |
4657 ShowStatusBarString(pTmpBuf.data(), 2u); | |
4658 pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); | |
4659 return; | |
4660 } | |
4661 if ( bUnderwater == 1 ) | |
4662 { | |
4663 ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2u);//"You can not do that while you are underwater!" | |
4664 pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); | |
4665 return; | |
4666 } | |
4667 | |
4668 scroll_id = pParty->pPickedItem.uItemID - 299; | |
4669 if ( scroll_id == 30 || scroll_id == 4 || scroll_id == 91 || scroll_id == 28 ) //Enchant Item scroll, Vampiric Weapon scroll ,Recharge Item ,Fire Aura | |
4670 { | |
4671 pMouse->RemoveHoldingItem(); | |
4672 pGUIWindow_CurrentMenu->Release(); | |
4673 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
4674 pCurrentScreen = SCREEN_GAME; | |
4675 viewparams->bRedrawGameUI = 1; | |
4676 _42777D_CastSpell_UseWand_ShootArrow(scroll_id, player_num - 1, 0x85u, 1, 0); | |
4677 } | |
4678 else | |
4679 { | |
4680 pMouse->RemoveHoldingItem(); | |
4681 pMessageQueue_50C9E8->AddGUIMessage(UIMSG_SpellScrollUse, scroll_id, player_num - 1); | |
4682 if ( pCurrentScreen && pGUIWindow_CurrentMenu | |
4683 && (pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)) | |
4684 { | |
4685 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); | |
4686 } | |
4687 } | |
4688 return; | |
4689 } | |
4690 | |
4691 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_BOOK ) | |
4692 { | |
4693 v15 = pParty->pPickedItem.uItemID - 400; | |
4694 v72 = playerAffected->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400];//(char *)&v3->pConditions[0] + pParty->pPickedItem.uItemID + 2; | |
4695 if ( v72 ) | |
4696 { | |
4697 v66 = pParty->pPickedItem.GetDisplayName(); | |
4698 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[380], v66);//"You already know the %s spell" | |
4699 ShowStatusBarString(pTmpBuf.data(), 2u); | |
4700 pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); | |
4701 return; | |
4702 } | |
4703 if ( !playerAffected->CanAct() ) | |
4704 { | |
4705 v66 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()]; | |
4706 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v66);//"That player is %s" | |
4707 ShowStatusBarString(pTmpBuf.data(), 2); | |
4708 pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); | |
4709 return; | |
4710 } | |
4711 v16 = v15 % 11 + 1; | |
4712 v17 = playerAffected->pActiveSkills[v15 / 11 + 12]; | |
4713 v18 = SkillToMastery(v17) - 1; | |
4714 switch (v18) | |
4715 { | |
4716 case 0: v67 = 4; break; | |
4717 case 1: v67 = 7; break; | |
4718 case 2: v67 = 10; break; | |
4719 case 3: v67 = 11; break; | |
4720 default: | |
4721 v67 = player_num; | |
4722 } | |
4723 | |
4724 if ( v16 > v67 || !v17 ) | |
4725 { | |
4726 v22 = pParty->pPickedItem.GetDisplayName(); | |
4727 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[381], v22); //"You don't have the skill to learn %s" | |
4728 ShowStatusBarString(pTmpBuf.data(), 2); | |
4729 playerAffected->PlaySound((PlayerSpeech)20, 0); | |
4730 return; | |
4731 } | |
4732 playerAffected->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400] = 1; | |
4733 playerAffected->PlaySound(SPEECH_21, 0); | |
4734 v73 = 0; | |
4735 | |
4736 | |
4737 if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) | |
4738 { | |
4739 if ( !v73 ) | |
4740 { | |
4741 pMouse->RemoveHoldingItem(); | |
4742 return; | |
4743 } | |
4744 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); | |
4745 } | |
4746 // if ( v73 ) v73 is always 0 at this point | |
4747 // { | |
4748 // if ( pParty->bTurnBasedModeOn ) | |
4749 // { | |
4750 // pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; | |
4751 // thisb->SetRecoveryTime(100); | |
4752 // pTurnEngine->ApplyPlayerAction(); | |
4753 // } | |
4754 // else | |
4755 // { | |
4756 // thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333); | |
4757 // } | |
4758 // } | |
4759 pMouse->RemoveHoldingItem(); | |
4760 return; | |
4761 } | |
4762 | |
4763 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_MESSAGE_SCROLL ) | |
4764 { | |
4765 if ( playerAffected->CanAct() ) | |
4766 { | |
4767 CreateMsgScrollWindow(pParty->pPickedItem.uItemID); | |
4768 playerAffected->PlaySound(SPEECH_37, 0); | |
4769 return; | |
4770 } | |
4771 v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()]; | |
4772 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68);//That player is %s | |
4773 ShowStatusBarString(pTmpBuf.data(), 2); | |
4774 pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); | |
4775 return; | |
4776 } | |
4777 else | |
4778 { | |
4779 if (pParty->pPickedItem.uItemID == 616) //Genie Lamp | |
4780 { | |
4781 thisa = pParty->uCurrentMonthWeek + 1; | |
4782 if ( pParty->uCurrentMonth >= 7 ) | |
4783 v74 = nullptr; | |
4784 else | |
4785 v74 = aAttributeNames[pParty->uCurrentMonth]; | |
4786 switch ( pParty->uCurrentMonth ) | |
4787 { | |
4788 case 0: | |
4789 playerAffected->uMight += thisa; | |
4790 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" | |
4791 break; | |
4792 case 1: | |
4793 playerAffected->uIntelligence += thisa; | |
4794 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" | |
4795 break; | |
4796 case 2: | |
4797 playerAffected->uWillpower += thisa; | |
4798 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" | |
4799 break; | |
4800 case 3: | |
4801 playerAffected->uEndurance += thisa; | |
4802 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" | |
4803 break; | |
4804 case 4: | |
4805 playerAffected->uAccuracy += thisa; | |
4806 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" | |
4807 break; | |
4808 case 5: | |
4809 playerAffected->uSpeed += thisa; | |
4810 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" | |
4811 break; | |
4812 case 6: | |
4813 playerAffected->uLuck += thisa; | |
4814 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" | |
4815 break; | |
4816 case 7: | |
4817 pParty->PartyFindsGold(1000 * thisa, 0); | |
4818 sprintf(pTmpBuf.data(), "+%u %s", 1000 * thisa, pGlobalTXT_LocalizationStrings[97]);//"Gold" | |
4819 break; | |
4820 case 8: | |
4821 Party::GiveFood(5 * thisa); | |
4822 sprintf(pTmpBuf.data(), "+%u %s",5 * thisa , pGlobalTXT_LocalizationStrings[653]);//"Food" | |
4823 break; | |
4824 case 9u: | |
4825 playerAffected->uSkillPoints += 2 * thisa; | |
4826 sprintf(pTmpBuf.data(), "+%u %s", 2 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_SKILL_POINTS]); | |
4827 break; | |
4828 case 10: | |
4829 playerAffected->uExperience += 2500 * thisa; | |
4830 sprintf(pTmpBuf.data(), "+%u %s", 2500 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_EXPIRIENCE]); | |
4831 break; | |
4832 case 11: | |
4833 v8 = rand() % 6; | |
4834 switch (v8) | |
4835 { | |
4836 case 0: | |
4837 playerAffected->sResFireBase += thisa; | |
4838 v13 = pGlobalTXT_LocalizationStrings[87];//Fire | |
4839 break; | |
4840 case 1: | |
4841 playerAffected->sResAirBase += thisa; | |
4842 v13 = pGlobalTXT_LocalizationStrings[6];//Air | |
4843 break; | |
4844 case 2: | |
4845 playerAffected->sResWaterBase += thisa; | |
4846 v13 = pGlobalTXT_LocalizationStrings[240];//Water | |
4847 break; | |
4848 case 3: | |
4849 playerAffected->sResEarthBase += thisa; | |
4850 v13 = pGlobalTXT_LocalizationStrings[70];//Earth | |
4851 break; | |
4852 case 4: | |
4853 playerAffected->sResMindBase += thisa; | |
4854 v13 = pGlobalTXT_LocalizationStrings[142];//Mind | |
4855 break; | |
4856 case 5: | |
4857 playerAffected->sResBodyBase += thisa; | |
4858 v13 = pGlobalTXT_LocalizationStrings[29];//Body | |
4859 break; | |
4860 default: ("Unexpected attribute"); | |
4861 return; | |
4862 } | |
4863 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]);//Permanent | |
4864 break; | |
4865 | |
4866 } | |
4867 ShowStatusBarString(pTmpBuf.data(), 2u); | |
4868 pMouse->RemoveHoldingItem(); | |
4869 pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1); | |
4870 playerAffected->PlaySound(SPEECH_93, 0); | |
4871 pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0); | |
4872 if ( pParty->uDaysPlayed == 6 || pParty->uDaysPlayed == 20 ) | |
4873 { | |
4874 playerAffected->SetCondition(Condition_Eradicated, 0); | |
4875 pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); | |
4876 } | |
4877 else if ( pParty->uDaysPlayed == 12 || pParty->uDaysPlayed == 26 ) | |
4878 { | |
4879 playerAffected->SetCondition(Condition_Dead, 0); | |
4880 pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); | |
4881 } | |
4882 else if ( pParty->uDaysPlayed == 4 || pParty->uDaysPlayed == 25 ) | |
4883 { | |
4884 playerAffected->SetCondition(Condition_Pertified, 0); | |
4885 pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); | |
4886 } | |
4887 return; | |
4888 } | |
4889 else if ( pParty->pPickedItem.uItemID == 630 ) //Red Apple | |
4890 { | |
4891 Party::GiveFood(1u); | |
4892 pAudioPlayer->PlaySound(SOUND_EatApple, 0, 0, -1, 0, 0, 0, 0); | |
4893 } | |
4894 else if ( pParty->pPickedItem.uItemID == 632 ) //Lute | |
4895 { | |
4896 pAudioPlayer->PlaySound(SOUND_PlayLute, 0, 0, -1, 0, 0, 0, 0); | |
4897 return; | |
4898 } | |
4899 else if ( pParty->pPickedItem.uItemID == 633 ) //Faerie Pipes | |
4900 { | |
4901 pAudioPlayer->PlaySound(SOUND_PlayFaeriePipes, 0, 0, -1, 0, 0, 0, 0); | |
4902 return; | |
4903 } | |
4904 else if ( pParty->pPickedItem.uItemID == 634 ) //Gryphonheart's Trumpet | |
4905 { | |
4906 pAudioPlayer->PlaySound(SOUND_PlayGryphonheartsTrumpet, 0, 0, -1, 0, 0, 0, 0); | |
4907 return; | |
4908 } | |
4909 else if ( pParty->pPickedItem.uItemID == 646 ) //Horseshoe | |
4910 { | |
4911 pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1); | |
4912 v5 = PID(OBJECT_Player, player_num + 49); | |
4913 pAudioPlayer->PlaySound(SOUND_20001, v5, 0, -1, 0, 0, 0, 0); | |
4914 playerAffected->AddVariable(VAR_NumSkillPoints, 2); | |
4915 } | |
4916 else if ( pParty->pPickedItem.uItemID == 650 ) //Temple in a Bottle | |
4917 { | |
4918 TeleportToNWCDungeon(); | |
4919 return; | |
4920 } | |
4921 else | |
4922 { | |
4923 v68 = pParty->pPickedItem.GetDisplayName(); | |
4924 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36],v68);//"%s can not be used that way" | |
4925 ShowStatusBarString(pTmpBuf.data(), 2u); | |
4926 pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); | |
4927 return; | |
4928 } | |
4929 | |
4930 pMouse->RemoveHoldingItem(); | |
4931 return; | |
4932 } | |
4933 } | |
4934 | |
4935 bool CmpSkillValue(int valToCompare, int skillValue) | |
4936 { | |
4937 int v4; | |
4938 if ( valToCompare <= 63 ) | |
4939 v4 = skillValue & 0x3F; | |
4940 else | |
4941 v4 = skillValue & skillValue; | |
4942 return v4 >= valToCompare; | |
4943 } | |
4944 | |
4945 //----- (00449BB4) -------------------------------------------------------- | |
4946 bool Player::CompareVariable( enum VariableType VarNum, signed int pValue ) // in some cases this calls only calls v4 >= pValue, which i've changed to return false, since these values are supposed to be positive and v4 was -1 by default | |
4947 { | |
4948 Assert(pValue >= 0, "Compare variable shouldn't have negative arguments"); | |
4949 | |
4950 signed int v4; // edi@1 | |
4951 unsigned __int8 test_bit_value; // eax@25 | |
4952 unsigned __int8 byteWithRequestedBit; // cl@25 | |
4953 DDM_DLV_Header *v19; // eax@122 | |
4954 DDM_DLV_Header *v21; // eax@126 | |
4955 int actStat; // ebx@161 | |
4956 int baseStat; // eax@161 | |
4957 | |
4958 | |
4959 if ( (signed int)VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_74 ) | |
4960 return (unsigned __int8)stru_5E4C90_MapPersistVars.field_0[VarNum - VAR_MapPersistentVariable_0] > 0; // originally (unsigned __int8)byte_5E4C15[VarNum]; | |
4961 if ( (signed int)VarNum >= VAR_MapPersistentVariable_75 && VarNum <= VAR_MapPersistentVariable_99 ) | |
4962 return (unsigned __int8)stru_5E4C90_MapPersistVars._decor_events[VarNum - VAR_MapPersistentVariable_75] > 0; //not really sure whether the number gets up to 99, but can't ignore the possibility | |
4963 | |
4964 switch ( VarNum ) | |
4965 { | |
4966 case VAR_Sex: | |
4967 return ( pValue == this->uSex ); | |
4968 case VAR_Class: | |
4969 return ( pValue == this->classType ); | |
4970 case VAR_Race: | |
4971 return pValue == GetRace(); | |
4972 case VAR_CurrentHP: | |
4973 return this->sHealth >= pValue; | |
4974 case VAR_MaxHP: | |
4975 return (this->sHealth >= GetMaxHealth()); | |
4976 case VAR_CurrentSP: | |
4977 return this->sMana >= pValue; | |
4978 case VAR_MaxSP: | |
4979 return (this->sMana >= GetMaxMana()); | |
4980 case VAR_ActualAC: | |
4981 return GetActualAC() >= pValue; | |
4982 case VAR_ACModifier: | |
4983 return this->sACModifier >= pValue; | |
4984 case VAR_BaseLevel: | |
4985 return this->uLevel >= pValue; | |
4986 case VAR_LevelModifier: | |
4987 return this->sLevelModifier >= pValue; | |
4988 case VAR_Age: | |
4989 return GetActualAge() >= (unsigned int)pValue; | |
4990 case VAR_Award: | |
4991 return _449B57_test_bit(this->_achieved_awards_bits, pValue); | |
4992 case VAR_Experience: | |
4993 return this->uExperience >= pValue; //TODO change pValue to long long | |
4994 case VAR_QBits_QuestsDone: | |
4995 return _449B57_test_bit(pParty->_quest_bits, pValue); | |
4996 case VAR_PlayerItemInHands: | |
4997 //for (int i = 0; i < 138; i++) | |
4998 for (int i = 0; i < 126; i++) | |
4999 { | |
5000 if (pInventoryItemList[i].uItemID == pValue) | |
5001 { | |
5002 return true; | |
5003 } | |
5004 } | |
5005 return pParty->pPickedItem.uItemID == pValue; | |
5006 case VAR_Hour: | |
5007 if ( (long long)(pParty->uTimePlayed * 0.234375) / 60 / 60 % 24 == pValue ) | |
5008 return true; | |
5009 return false; | |
5010 case VAR_DayOfYear: | |
5011 if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 336 + 1 == pValue) | |
5012 return true; | |
5013 return false; | |
5014 case VAR_DayOfWeek: | |
5015 if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 7) | |
5016 return true; | |
5017 return false; | |
5018 case VAR_FixedGold: | |
5019 return pParty->uNumGold >= (unsigned int)pValue; | |
5020 case VAR_FixedFood: | |
5021 return pParty->uNumFoodRations >= (unsigned int)pValue; | |
5022 case VAR_MightBonus: | |
5023 return this->uMightBonus >= pValue; | |
5024 case VAR_IntellectBonus: | |
5025 return this->uIntelligenceBonus >= pValue; | |
5026 case VAR_PersonalityBonus: | |
5027 return this->uWillpowerBonus >= pValue; | |
5028 case VAR_EnduranceBonus: | |
5029 return this->uEnduranceBonus >= pValue; | |
5030 case VAR_SpeedBonus: | |
5031 return this->uSpeedBonus >= pValue; | |
5032 case VAR_AccuracyBonus: | |
5033 return this->uAccuracyBonus >= pValue; | |
5034 case VAR_LuckBonus: | |
5035 return this->uLuckBonus >= pValue; | |
5036 case VAR_BaseMight: | |
5037 return this->uMight >= pValue; | |
5038 case VAR_BaseIntellect: | |
5039 return this->uIntelligence >= pValue; | |
5040 case VAR_BasePersonality: | |
5041 return this->uWillpower >= pValue; | |
5042 case VAR_BaseEndurance: | |
5043 return this->uEndurance >= pValue; | |
5044 case VAR_BaseSpeed: | |
5045 return this->uSpeed >= pValue; | |
5046 case VAR_BaseAccuracy: | |
5047 return this->uAccuracy >= pValue; | |
5048 case VAR_BaseLuck: | |
5049 return this->uLuck >= pValue; | |
5050 case VAR_ActualMight: | |
5051 return GetActualMight() >= pValue; | |
5052 case VAR_ActualIntellect: | |
5053 return GetActualIntelligence() >= pValue; | |
5054 case VAR_ActualPersonality: | |
5055 return GetActualWillpower() >= pValue; | |
5056 case VAR_ActualEndurance: | |
5057 return GetActualEndurance() >= pValue; | |
5058 case VAR_ActualSpeed: | |
5059 return GetActualSpeed() >= pValue; | |
5060 case VAR_ActualAccuracy: | |
5061 return GetActualAccuracy() >= pValue; | |
5062 case VAR_ActualLuck: | |
5063 return GetActualLuck() >= pValue; | |
5064 case VAR_FireResistance: | |
5065 return this->sResFireBase >= pValue; | |
5066 case VAR_AirResistance: | |
5067 return this->sResAirBase >= pValue; | |
5068 case VAR_WaterResistance: | |
5069 return this->sResWaterBase >= pValue; | |
5070 case VAR_EarthResistance: | |
5071 return this->sResEarthBase >= pValue; | |
5072 case VAR_SpiritResistance: | |
5073 return this->sResSpiritBase >= pValue; | |
5074 case VAR_MindResistance: | |
5075 return this->sResMindBase >= pValue; | |
5076 case VAR_BodyResistance: | |
5077 return this->sResBodyBase >= pValue; | |
5078 case VAR_LightResistance: | |
5079 return this->sResLightBase >= pValue; | |
5080 case VAR_DarkResistance: | |
5081 return this->sResDarkBase >= pValue; | |
5082 case VAR_PhysicalResistance: | |
5083 Error("Physical resistance isn't used in events"); | |
5084 return false; | |
5085 case VAR_MagicResistance: | |
5086 return this->sResMagicBase >= pValue; | |
5087 case VAR_FireResistanceBonus: | |
5088 return this->sResFireBonus >= pValue; | |
5089 case VAR_AirResistanceBonus: | |
5090 return this->sResAirBonus >= pValue; | |
5091 case VAR_WaterResistanceBonus: | |
5092 return this->sResWaterBonus >= pValue; | |
5093 case VAR_EarthResistanceBonus: | |
5094 return this->sResEarthBonus >= pValue; | |
5095 case VAR_SpiritResistanceBonus: | |
5096 return this->sResSpiritBonus >= pValue; | |
5097 case VAR_MindResistanceBonus: | |
5098 return this->sResMindBonus >= pValue; | |
5099 case VAR_BodyResistanceBonus: | |
5100 return this->sResBodyBonus >= pValue; | |
5101 case VAR_LightResistanceBonus: | |
5102 return this->sResLightBonus >= pValue; | |
5103 case VAR_DarkResistanceBonus: | |
5104 return this->sResDarkBonus >= pValue; | |
5105 case VAR_MagicResistanceBonus: | |
5106 return this->sResMagicBonus >= pValue; | |
5107 case VAR_StaffSkill: | |
5108 return CmpSkillValue(pValue, this->skillStaff); | |
5109 case VAR_SwordSkill: | |
5110 return CmpSkillValue(pValue, this->skillSword); | |
5111 case VAR_DaggerSkill: | |
5112 return CmpSkillValue(pValue, this->skillDagger); | |
5113 case VAR_AxeSkill: | |
5114 return CmpSkillValue(pValue, this->skillAxe); | |
5115 case VAR_SpearSkill: | |
5116 return CmpSkillValue(pValue, this->skillSpear); | |
5117 case VAR_BowSkill: | |
5118 return CmpSkillValue(pValue, this->skillBow); | |
5119 case VAR_MaceSkill: | |
5120 return CmpSkillValue(pValue, this->skillMace); | |
5121 case VAR_BlasterSkill: | |
5122 return CmpSkillValue(pValue, this->skillBlaster); | |
5123 case VAR_ShieldSkill: | |
5124 return CmpSkillValue(pValue, this->skillShield); | |
5125 case VAR_LeatherSkill: | |
5126 return CmpSkillValue(pValue, this->skillLeather); | |
5127 case VAR_SkillChain: | |
5128 return CmpSkillValue(pValue, this->skillChain); | |
5129 case VAR_PlateSkill: | |
5130 return CmpSkillValue(pValue, this->skillPlate); | |
5131 case VAR_FireSkill: | |
5132 return CmpSkillValue(pValue, this->skillFire); | |
5133 case VAR_AirSkill: | |
5134 return CmpSkillValue(pValue, this->skillAir); | |
5135 case VAR_WaterSkill: | |
5136 return CmpSkillValue(pValue, this->skillWater); | |
5137 case VAR_EarthSkill: | |
5138 return CmpSkillValue(pValue, this->skillEarth); | |
5139 case VAR_SpiritSkill: | |
5140 return CmpSkillValue(pValue, this->skillSpirit); | |
5141 case VAR_MindSkill: | |
5142 return CmpSkillValue(pValue, this->skillMind); | |
5143 case VAR_BodySkill: | |
5144 return CmpSkillValue(pValue, this->skillBody); | |
5145 case VAR_LightSkill: | |
5146 return CmpSkillValue(pValue, this->skillLight); | |
5147 case VAR_DarkSkill: | |
5148 return CmpSkillValue(pValue, this->skillDark); | |
5149 case VAR_IdentifyItemSkill: | |
5150 return CmpSkillValue(pValue, this->skillItemId); | |
5151 case VAR_MerchantSkill: | |
5152 return CmpSkillValue(pValue, this->skillMerchant); | |
5153 case VAR_RepairSkill: | |
5154 return CmpSkillValue(pValue, this->skillRepair); | |
5155 case VAR_BodybuildingSkill: | |
5156 return CmpSkillValue(pValue, this->skillBodybuilding); | |
5157 case VAR_MeditationSkill: | |
5158 return CmpSkillValue(pValue, this->skillMeditation); | |
5159 case VAR_PerceptionSkill: | |
5160 return CmpSkillValue(pValue, this->skillPerception); | |
5161 case VAR_DiplomacySkill: | |
5162 return CmpSkillValue(pValue, this->skillDiplomacy); | |
5163 case VAR_ThieverySkill: | |
5164 Error("Thievery isn't used in events"); | |
5165 return false; | |
5166 case VAR_DisarmTrapSkill: //wasn't in the original | |
5167 return CmpSkillValue(pValue, this->skillDisarmTrap); | |
5168 case VAR_DodgeSkill: //wasn't in the original | |
5169 return CmpSkillValue(pValue, this->skillDodge); | |
5170 case VAR_UnarmedSkill: //wasn't in the original | |
5171 return CmpSkillValue(pValue, this->skillUnarmed); | |
5172 case VAR_IdentifyMonsterSkill: //wasn't in the original | |
5173 return CmpSkillValue(pValue, this->skillMonsterId); | |
5174 case VAR_ArmsmasterSkill: //wasn't in the original | |
5175 return CmpSkillValue(pValue, this->skillArmsmaster); | |
5176 case VAR_StealingSkill: //wasn't in the original | |
5177 return CmpSkillValue(pValue, this->skillStealing); | |
5178 case VAR_AlchemySkill: //wasn't in the original | |
5179 return CmpSkillValue(pValue, this->skillAlchemy); | |
5180 case VAR_LearningSkill: | |
5181 return CmpSkillValue(pValue, this->skillLearning); | |
5182 case VAR_Cursed: | |
5183 return pConditions[Condition_Cursed] > 0; | |
5184 case VAR_Weak: | |
5185 return pConditions[Condition_Weak] > 0; | |
5186 case VAR_Asleep: | |
5187 return pConditions[Condition_Sleep] > 0; | |
5188 case VAR_Afraid: | |
5189 return pConditions[Condition_Fear] > 0; | |
5190 case VAR_Drunk: | |
5191 return pConditions[Condition_Drunk] > 0; | |
5192 case VAR_Insane: | |
5193 return pConditions[Condition_Insane] > 0; | |
5194 case VAR_PoisonedGreen: | |
5195 return pConditions[Condition_Poison_Weak] > 0; | |
5196 case VAR_DiseasedGreen: | |
5197 return pConditions[Condition_Disease_Weak] > 0; | |
5198 case VAR_PoisonedYellow: | |
5199 return pConditions[Condition_Poison_Medium] > 0; | |
5200 case VAR_DiseasedYellow: | |
5201 return pConditions[Condition_Disease_Medium] > 0; | |
5202 case VAR_PoisonedRed: | |
5203 return pConditions[Condition_Poison_Severe] > 0; | |
5204 case VAR_DiseasedRed: | |
5205 return pConditions[Condition_Disease_Severe] > 0; | |
5206 case VAR_Paralyzed: | |
5207 return pConditions[Condition_Paralyzed] > 0; | |
5208 case VAR_Unconsious: | |
5209 return pConditions[Condition_Unconcious] > 0; | |
5210 case VAR_Dead: | |
5211 return pConditions[Condition_Dead] > 0; | |
5212 case VAR_Stoned: | |
5213 return pConditions[Condition_Pertified] > 0; | |
5214 case VAR_Eradicated: | |
5215 return pConditions[Condition_Eradicated] > 0; | |
5216 case VAR_MajorCondition: | |
5217 v4 = GetMajorConditionIdx(); | |
5218 if ( v4 != 18 ) | |
5219 { | |
5220 return v4 >= pValue; | |
5221 } | |
5222 return true; | |
5223 case VAR_AutoNotes : //TODO: find out why the double subtraction. or whether this is even used | |
5224 test_bit_value = 0x80u >> (pValue - 2) % 8; | |
5225 byteWithRequestedBit = pParty->_autonote_bits[(pValue - 2) /8]; | |
5226 return (test_bit_value & byteWithRequestedBit) != 0; | |
5227 case VAR_IsMightMoreThanBase: | |
5228 actStat = GetActualMight(); | |
5229 baseStat = GetBaseStrength(); | |
5230 return (actStat >= baseStat); | |
5231 case VAR_IsIntellectMoreThanBase: | |
5232 actStat = GetActualIntelligence(); | |
5233 baseStat = GetBaseIntelligence(); | |
5234 return (actStat >= baseStat); | |
5235 case VAR_IsPersonalityMoreThanBase: | |
5236 actStat = GetActualWillpower(); | |
5237 baseStat = GetBaseWillpower(); | |
5238 return (actStat >= baseStat); | |
5239 case VAR_IsEnduranceMoreThanBase: | |
5240 actStat = GetActualEndurance(); | |
5241 baseStat = GetBaseEndurance(); | |
5242 return (actStat >= baseStat); | |
5243 case VAR_IsSpeedMoreThanBase: | |
5244 actStat = GetActualSpeed(); | |
5245 baseStat = GetBaseSpeed(); | |
5246 return (actStat >= baseStat); | |
5247 case VAR_IsAccuracyMoreThanBase: | |
5248 actStat = GetActualAccuracy(); | |
5249 baseStat = GetBaseAccuracy(); | |
5250 return (actStat >= baseStat); | |
5251 case VAR_IsLuckMoreThanBase: | |
5252 actStat = GetActualLuck(); | |
5253 baseStat = GetBaseLuck(); | |
5254 return (actStat >= baseStat); | |
5255 case VAR_PlayerBits: | |
5256 test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8; | |
5257 byteWithRequestedBit = this->playerEventBits[((signed __int16)pValue - 1)/8]; | |
5258 return ( test_bit_value & byteWithRequestedBit ) != 0; | |
5259 case VAR_NPCs2: | |
5260 return pNPCStats->pNewNPCData[pValue].Hired(); | |
5261 case VAR_IsFlying: | |
5262 if ( pParty->bFlying | |
5263 && (pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime> 0) ) | |
5264 return true; | |
5265 return false; | |
5266 case VAR_HiredNPCHasSpeciality: | |
5267 return CheckHiredNPCSpeciality(pValue); | |
5268 case VAR_CircusPrises: //isn't used in MM6 since 0x1D6u is a book of regeneration | |
5269 v4 = 0; | |
5270 for (int playerNum = 0; playerNum < 4; playerNum++) | |
5271 { | |
5272 for (int invPos = 0; invPos < 138; invPos++) | |
5273 { | |
5274 int itemId = pParty->pPlayers[playerNum].pInventoryItemList[invPos].uItemID; | |
5275 switch ( itemId ) | |
5276 { | |
5277 case 0x1D6u: | |
5278 ++v4; | |
5279 break; | |
5280 case 0x1D7u: | |
5281 v4 += 3; | |
5282 break; | |
5283 case 0x1DDu: | |
5284 v4 += 5; | |
5285 break; | |
5286 } | |
5287 } | |
5288 } | |
5289 return v4 >= pValue; | |
5290 case VAR_NumSkillPoints: | |
5291 return this->uSkillPoints >= (unsigned int)pValue; | |
5292 case VAR_MonthIs: | |
5293 return (pParty->uCurrentMonth == (unsigned int)pValue); | |
5294 case VAR_Counter1: | |
5295 case VAR_Counter2: | |
5296 case VAR_Counter3: | |
5297 case VAR_Counter4: | |
5298 case VAR_Counter5: | |
5299 case VAR_Counter6: | |
5300 case VAR_Counter7: | |
5301 case VAR_Counter8: | |
5302 case VAR_Counter9: | |
5303 case VAR_Counter10: | |
5304 if (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1]) //originally (signed __int64)(__PAIR__(*(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44304], *(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44300]) | |
5305 { | |
5306 return (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1] + 460800 * pValue * 0.033333335) <= pParty->uTimePlayed ; | |
5307 } | |
5308 case VAR_ReputationInCurrentLocation: | |
5309 v19 = &pOutdoor->ddm; | |
5310 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
5311 v19 = &pIndoor->dlv; | |
5312 return (v19->uReputation >= pValue); | |
5313 case VAR_Unknown1: | |
5314 v21 = &pOutdoor->ddm; | |
5315 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
5316 v21 = &pIndoor->dlv; | |
5317 return (v21->field_C_alert == pValue); //yes, equality, not >= | |
5318 case VAR_GoldInBank: | |
5319 return pParty->uNumGoldInBank >= (unsigned int)pValue; | |
5320 case VAR_NumDeaths: | |
5321 return pParty->uNumDeaths >= (unsigned int)pValue; | |
5322 case VAR_NumBounties: | |
5323 return pParty->uNumBountiesCollected >= (unsigned int)pValue; | |
5324 case VAR_PrisonTerms: | |
5325 return pParty->uNumPrisonTerms >= pValue; | |
5326 case VAR_ArenaWinsPage: | |
5327 return (unsigned __int8)pParty->uNumArenaPageWins >= pValue; | |
5328 case VAR_ArenaWinsSquire: | |
5329 return (unsigned __int8)pParty->uNumArenaSquireWins >= pValue; | |
5330 case VAR_ArenaWinsKnight: | |
5331 return (unsigned __int8)pParty->uNumArenaKnightWins >= pValue; | |
5332 case VAR_ArenaWinsLord: | |
5333 return pParty->uNumArenaLordWins >= pValue; | |
5334 case VAR_Invisible: | |
5335 return ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ); | |
5336 case VAR_ItemEquipped: | |
5337 for (int i = 0; i < 16; i++) | |
5338 { | |
5339 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) && GetNthEquippedIndexItem(i)->uItemID == pValue ) | |
5340 { | |
5341 return true; | |
5342 } | |
5343 } | |
5344 return false; | |
5345 } | |
5346 | |
5347 return false; | |
5348 } | |
5349 | |
5350 | |
5351 //----- (0044A5CB) -------------------------------------------------------- | |
5352 void Player::SetVariable(enum VariableType var_type, signed int var_value) | |
5353 { | |
5354 unsigned int v6; // esi@13 | |
5355 unsigned int v7; // esi@14 | |
5356 signed int v11; // eax@30 | |
5357 DDM_DLV_Header *v24; // ecx@148 | |
5358 ItemGen item; // [sp+Ch] [bp-28h]@52 | |
5359 | |
5360 | |
5361 if ( var_type >= VAR_History_0 && var_type <= VAR_History_28) | |
5362 { | |
5363 if (!pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0]) | |
5364 { | |
5365 pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0] = pParty->uTimePlayed; | |
5366 if (pStorylineText->StoreLine[var_type - VAR_History_0].pText) | |
5367 { | |
5368 bFlashHistoryBook = 1; | |
5369 PlayAwardSound(); | |
5370 } | |
5371 } | |
5372 return; | |
5373 } | |
5374 | |
5375 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 ) | |
5376 { | |
5377 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_74 ) | |
5378 stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0] = (char)var_value; // originally (unsigned __int8)byte_5E4C15[VarNum]; | |
5379 if ( var_type >= VAR_MapPersistentVariable_75 && var_type <= VAR_MapPersistentVariable_99 ) | |
5380 stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75] = (unsigned char)var_value; //not really sure whether the number gets up to 99, but can't ignore the possibility | |
5381 return; | |
5382 } | |
5383 | |
5384 if ( var_type >= VAR_UnknownTimeEvent0 && var_type <= VAR_UnknownTimeEvent19 ) | |
5385 { | |
5386 pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed; //*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed);, *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed | |
5387 PlayAwardSound(); | |
5388 return; | |
5389 } | |
5390 | |
5391 switch ( var_type ) | |
5392 { | |
5393 case VAR_Sex: | |
5394 this->uSex = (PLAYER_SEX)var_value; | |
5395 PlayAwardSound_Anim(); | |
5396 return; | |
5397 case VAR_Class: | |
5398 this->classType = (PLAYER_CLASS_TYPE)var_value; | |
5399 if ( (PLAYER_CLASS_TYPE)var_value == PLAYER_CLASS_LICH ) | |
5400 { | |
5401 for (int i = 0; i < 138; i++) | |
5402 { | |
5403 if (this->pOwnItems[i].uItemID == ITEM_LICH_JAR_EMPTY) | |
5404 { | |
5405 this->pOwnItems[i].uItemID = ITEM_LICH_JAR_FULL; | |
5406 this->pOwnItems[i].uHolderPlayer = GetPlayerIndex() + 1; | |
5407 } | |
5408 } | |
5409 if ( this->sResFireBase < 20 ) | |
5410 this->sResFireBase = 20; | |
5411 if ( this->sResAirBase < 20 ) | |
5412 this->sResAirBase = 20; | |
5413 if ( this->sResWaterBase < 20 ) | |
5414 this->sResWaterBase = 20; | |
5415 if ( this->sResEarthBase < 20 ) | |
5416 this->sResEarthBase = 20; | |
5417 this->sResMindBase = 200; | |
5418 this->sResBodyBase = 200; | |
5419 v11 = this->GetSexByVoice(); | |
5420 this->uPrevVoiceID = this->uVoiceID; | |
5421 this->uPrevFace = this->uCurrentFace; | |
5422 if ( v11 ) | |
5423 { | |
5424 this->uCurrentFace = 21; | |
5425 this->uVoiceID = 21; | |
5426 } | |
5427 else | |
5428 { | |
5429 this->uCurrentFace = 20; | |
5430 this->uVoiceID = 20; | |
5431 } | |
5432 ReloadPlayerPortraits(GetPlayerIndex(), this->uCurrentFace); | |
5433 } | |
5434 PlayAwardSound_Anim(); | |
5435 return; | |
5436 case VAR_CurrentHP: | |
5437 this->sHealth = var_value; | |
5438 PlayAwardSound_Anim(); | |
5439 return; | |
5440 case VAR_MaxHP: | |
5441 this->sHealth = GetMaxHealth(); | |
5442 return; | |
5443 case VAR_CurrentSP: | |
5444 this->sMana = var_value; | |
5445 PlayAwardSound_Anim(); | |
5446 return; | |
5447 case VAR_MaxSP: | |
5448 this->sMana = GetMaxMana(); | |
5449 return; | |
5450 case VAR_ACModifier: | |
5451 this->sACModifier = (unsigned __int8)var_value; | |
5452 PlayAwardSound_Anim(); | |
5453 return; | |
5454 case VAR_BaseLevel: | |
5455 this->uLevel = (unsigned __int8)var_value; | |
5456 PlayAwardSound_Anim(); | |
5457 return; | |
5458 case VAR_LevelModifier: | |
5459 this->sLevelModifier = (unsigned __int8)var_value; | |
5460 PlayAwardSound_Anim(); | |
5461 return; | |
5462 case VAR_Age: | |
5463 this->sAgeModifier = var_value; | |
5464 return; | |
5465 case VAR_Award: | |
5466 if ( !_449B57_test_bit(this->_achieved_awards_bits, var_value) && pAwards[var_value].pText ) | |
5467 { | |
5468 PlayAwardSound_Anim(); | |
5469 this->PlaySound(SPEECH_96, 0); | |
5470 } | |
5471 _449B7E_toggle_bit(this->_achieved_awards_bits, var_value, 1u); | |
5472 return; | |
5473 case VAR_Experience: | |
5474 this->uExperience = var_value; | |
5475 PlayAwardSound_Anim(); | |
5476 return; | |
5477 case VAR_QBits_QuestsDone: | |
5478 if ( !_449B57_test_bit(pParty->_quest_bits, var_value) && pQuestTable[var_value-1] ) | |
5479 { | |
5480 bFlashQuestBook = 1; | |
5481 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, GetPlayerIndex()); | |
5482 PlayAwardSound(); | |
5483 this->PlaySound(SPEECH_93, 0); | |
5484 } | |
5485 _449B7E_toggle_bit(pParty->_quest_bits, var_value, 1u); | |
5486 return; | |
5487 case VAR_PlayerItemInHands: | |
5488 item.Reset(); | |
5489 item.uItemID = var_value; | |
5490 item.uAttributes = 1; | |
5491 pParty->SetHoldingItem(&item); | |
5492 if ( var_value >= ITEM_ARTIFACT_PUCK && var_value <= ITEM_RELIC_MEKORIGS_HAMMER ) | |
5493 pParty->pIsArtifactFound[var_value-500] = 1; | |
5494 return; | |
5495 case VAR_FixedGold: | |
5496 Party::SetGold(var_value); | |
5497 return; | |
5498 case VAR_RandomGold: | |
5499 v6 = rand() % var_value + 1; | |
5500 Party::SetGold(v6); | |
5501 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[500], v6);// You have %lu gold | |
5502 ShowStatusBarString(pTmpBuf.data(), 2u); | |
5503 GameUI_DrawFoodAndGold(); | |
5504 return; | |
5505 case VAR_FixedFood: | |
5506 Party::SetFood(var_value); | |
5507 PlayAwardSound_Anim(); | |
5508 return; | |
5509 case VAR_RandomFood: | |
5510 v7 = rand() % var_value + 1; | |
5511 Party::SetFood(v7); | |
5512 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], v7);// You have %lu food | |
5513 ShowStatusBarString(pTmpBuf.data(), 2u); | |
5514 GameUI_DrawFoodAndGold(); | |
5515 PlayAwardSound_Anim(); | |
5516 return; | |
5517 case VAR_BaseMight: | |
5518 this->uMight = (unsigned __int8)var_value; | |
5519 PlayAwardSound_Anim_Face(SPEECH_92); | |
5520 return; | |
5521 case VAR_BaseIntellect: | |
5522 this->uIntelligence = (unsigned __int8)var_value; | |
5523 PlayAwardSound_Anim_Face(SPEECH_92); | |
5524 return; | |
5525 case VAR_BasePersonality: | |
5526 this->uWillpower = (unsigned __int8)var_value; | |
5527 PlayAwardSound_Anim_Face(SPEECH_92); | |
5528 return; | |
5529 case VAR_BaseEndurance: | |
5530 this->uEndurance = (unsigned __int8)var_value; | |
5531 PlayAwardSound_Anim_Face(SPEECH_92); | |
5532 return; | |
5533 case VAR_BaseSpeed: | |
5534 this->uSpeed = (unsigned __int8)var_value; | |
5535 PlayAwardSound_Anim_Face(SPEECH_92); | |
5536 return; | |
5537 case VAR_BaseAccuracy: | |
5538 this->uAccuracy = (unsigned __int8)var_value; | |
5539 PlayAwardSound_Anim_Face(SPEECH_92); | |
5540 return; | |
5541 case VAR_BaseLuck: | |
5542 this->uLuck = (unsigned __int8)var_value; | |
5543 PlayAwardSound_Anim_Face(SPEECH_92); | |
5544 return; | |
5545 case VAR_MightBonus: | |
5546 case VAR_ActualMight: | |
5547 this->uMightBonus = (unsigned __int8)var_value; | |
5548 PlayAwardSound_Anim_Face(SPEECH_91); | |
5549 return; | |
5550 case VAR_IntellectBonus: | |
5551 case VAR_ActualIntellect: | |
5552 this->uIntelligenceBonus = (unsigned __int8)var_value; | |
5553 PlayAwardSound_Anim_Face(SPEECH_91); | |
5554 return; | |
5555 case VAR_PersonalityBonus: | |
5556 case VAR_ActualPersonality: | |
5557 this->uWillpowerBonus = (unsigned __int8)var_value; | |
5558 PlayAwardSound_Anim_Face(SPEECH_91); | |
5559 return; | |
5560 case VAR_EnduranceBonus: | |
5561 case VAR_ActualEndurance: | |
5562 this->uEnduranceBonus = (unsigned __int8)var_value; | |
5563 PlayAwardSound_Anim_Face(SPEECH_91); | |
5564 return; | |
5565 case VAR_SpeedBonus: | |
5566 case VAR_ActualSpeed: | |
5567 this->uSpeedBonus = (unsigned __int8)var_value; | |
5568 PlayAwardSound_Anim_Face(SPEECH_91); | |
5569 return; | |
5570 case VAR_AccuracyBonus: | |
5571 case VAR_ActualAccuracy: | |
5572 this->uAccuracyBonus = (unsigned __int8)var_value; | |
5573 PlayAwardSound_Anim_Face(SPEECH_92); | |
5574 return; | |
5575 case VAR_LuckBonus: | |
5576 case VAR_ActualLuck: | |
5577 this->uLuckBonus = (unsigned __int8)var_value; | |
5578 PlayAwardSound_Anim_Face(SPEECH_92); | |
5579 return; | |
5580 case VAR_FireResistance: | |
5581 this->sResFireBase = (unsigned __int8)var_value; | |
5582 PlayAwardSound_Anim_Face(SPEECH_92); | |
5583 return; | |
5584 case VAR_AirResistance: | |
5585 this->sResAirBase = (unsigned __int8)var_value; | |
5586 PlayAwardSound_Anim_Face(SPEECH_92); | |
5587 return; | |
5588 case VAR_WaterResistance: | |
5589 this->sResWaterBase = (unsigned __int8)var_value; | |
5590 PlayAwardSound_Anim_Face(SPEECH_92); | |
5591 return; | |
5592 case VAR_EarthResistance: | |
5593 this->sResEarthBase = (unsigned __int8)var_value; | |
5594 PlayAwardSound_Anim_Face(SPEECH_92); | |
5595 return; | |
5596 case VAR_SpiritResistance: | |
5597 this->sResSpiritBase = (unsigned __int8)var_value; | |
5598 PlayAwardSound_Anim_Face(SPEECH_92); | |
5599 return; | |
5600 case VAR_MindResistance: | |
5601 this->sResMindBase = (unsigned __int8)var_value; | |
5602 PlayAwardSound_Anim_Face(SPEECH_92); | |
5603 return; | |
5604 case VAR_BodyResistance: | |
5605 this->sResBodyBase = (unsigned __int8)var_value; | |
5606 PlayAwardSound_Anim_Face(SPEECH_92); | |
5607 return; | |
5608 case VAR_LightResistance: | |
5609 this->sResLightBase = (unsigned __int8)var_value; | |
5610 PlayAwardSound_Anim_Face(SPEECH_92); | |
5611 return; | |
5612 case VAR_DarkResistance: | |
5613 this->sResDarkBase = (unsigned __int8)var_value; | |
5614 PlayAwardSound_Anim_Face(SPEECH_92); | |
5615 return; | |
5616 case VAR_MagicResistance: | |
5617 this->sResMagicBase = (unsigned __int8)var_value; | |
5618 PlayAwardSound_Anim_Face(SPEECH_92); | |
5619 return; | |
5620 case VAR_FireResistanceBonus: | |
5621 this->sResFireBonus = (unsigned __int8)var_value; | |
5622 PlayAwardSound_Anim_Face(SPEECH_91); | |
5623 return; | |
5624 case VAR_AirResistanceBonus: | |
5625 this->sResAirBonus = (unsigned __int8)var_value; | |
5626 PlayAwardSound_Anim_Face(SPEECH_91); | |
5627 return; | |
5628 case VAR_WaterResistanceBonus: | |
5629 this->sResWaterBonus = (unsigned __int8)var_value; | |
5630 PlayAwardSound_Anim_Face(SPEECH_91); | |
5631 return; | |
5632 case VAR_EarthResistanceBonus: | |
5633 this->sResEarthBonus = (unsigned __int8)var_value; | |
5634 PlayAwardSound_Anim_Face(SPEECH_91); | |
5635 return; | |
5636 case VAR_SpiritResistanceBonus: | |
5637 this->sResSpiritBonus = (unsigned __int8)var_value; | |
5638 PlayAwardSound_Anim_Face(SPEECH_91); | |
5639 return; | |
5640 case VAR_MindResistanceBonus: | |
5641 this->sResMindBonus = (unsigned __int8)var_value; | |
5642 PlayAwardSound_Anim_Face(SPEECH_91); | |
5643 return; | |
5644 case VAR_BodyResistanceBonus: | |
5645 this->sResBodyBonus = (unsigned __int8)var_value; | |
5646 PlayAwardSound_Anim_Face(SPEECH_91); | |
5647 return; | |
5648 case VAR_LightResistanceBonus: | |
5649 this->sResLightBonus = (unsigned __int8)var_value; | |
5650 PlayAwardSound_Anim_Face(SPEECH_91); | |
5651 return; | |
5652 case VAR_DarkResistanceBonus: | |
5653 this->sResDarkBonus = (unsigned __int8)var_value; | |
5654 PlayAwardSound_Anim_Face(SPEECH_91); | |
5655 return; | |
5656 case VAR_PhysicalResistanceBonus: | |
5657 Error("Physical res. bonus not used"); | |
5658 return; | |
5659 case VAR_MagicResistanceBonus: | |
5660 this->sResMagicBonus = (unsigned __int8)var_value; | |
5661 PlayAwardSound_Anim_Face(SPEECH_91); | |
5662 return; | |
5663 case VAR_Cursed: | |
5664 this->SetCondition(Condition_Cursed, 1); | |
5665 PlayAwardSound_Anim(); | |
5666 return; | |
5667 case VAR_Weak: | |
5668 this->SetCondition(Condition_Weak, 1); | |
5669 PlayAwardSound_Anim(); | |
5670 return; | |
5671 case VAR_Asleep: | |
5672 this->SetCondition(Condition_Sleep, 1); | |
5673 PlayAwardSound_Anim(); | |
5674 return; | |
5675 case VAR_Afraid: | |
5676 this->SetCondition(Condition_Fear, 1); | |
5677 PlayAwardSound_Anim(); | |
5678 return; | |
5679 case VAR_Drunk: | |
5680 this->SetCondition(Condition_Drunk, 1); | |
5681 PlayAwardSound_Anim(); | |
5682 return; | |
5683 case VAR_Insane: | |
5684 this->SetCondition(Condition_Insane, 1); | |
5685 PlayAwardSound_Anim(); | |
5686 return; | |
5687 case VAR_PoisonedGreen: | |
5688 this->SetCondition(Condition_Poison_Weak, 1); | |
5689 PlayAwardSound_Anim(); | |
5690 return; | |
5691 case VAR_DiseasedGreen: | |
5692 this->SetCondition(Condition_Disease_Weak, 1); | |
5693 PlayAwardSound_Anim(); | |
5694 return; | |
5695 case VAR_PoisonedYellow: | |
5696 this->SetCondition(Condition_Poison_Medium, 1); | |
5697 PlayAwardSound_Anim(); | |
5698 return; | |
5699 case VAR_DiseasedYellow: | |
5700 this->SetCondition(Condition_Disease_Medium, 1); | |
5701 PlayAwardSound_Anim(); | |
5702 return; | |
5703 case VAR_PoisonedRed: | |
5704 this->SetCondition(Condition_Poison_Severe, 1); | |
5705 PlayAwardSound_Anim(); | |
5706 return; | |
5707 case VAR_DiseasedRed: | |
5708 this->SetCondition(Condition_Disease_Severe, 1); | |
5709 PlayAwardSound_Anim(); | |
5710 return; | |
5711 case VAR_Paralyzed: | |
5712 this->SetCondition(Condition_Paralyzed, 1); | |
5713 PlayAwardSound_Anim(); | |
5714 return; | |
5715 case VAR_Unconsious: | |
5716 this->SetCondition(Condition_Unconcious, 1); | |
5717 PlayAwardSound_Anim(); | |
5718 return; | |
5719 case VAR_Dead: | |
5720 this->SetCondition(Condition_Dead, 1); | |
5721 PlayAwardSound_Anim(); | |
5722 return; | |
5723 case VAR_Stoned: | |
5724 this->SetCondition(Condition_Pertified, 1); | |
5725 PlayAwardSound_Anim(); | |
5726 return; | |
5727 case VAR_Eradicated: | |
5728 this->SetCondition(Condition_Eradicated, 1); | |
5729 PlayAwardSound_Anim(); | |
5730 return; | |
5731 case VAR_MajorCondition: | |
5732 pConditions.fill(0); | |
5733 PlayAwardSound_Anim(); | |
5734 return; | |
5735 case VAR_AutoNotes: | |
5736 if ( !_449B57_test_bit(pParty->_autonote_bits, var_value) && pAutonoteTxt[var_value-1].pText ) | |
5737 { | |
5738 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, GetPlayerIndex()); | |
5739 this->PlaySound(SPEECH_96, 0); | |
5740 bFlashAutonotesBook = 1; | |
5741 _506568_autonote_type = pAutonoteTxt[var_value-1].eType;// dword_72371C[2 * a3]; | |
5742 } | |
5743 _449B7E_toggle_bit(pParty->_autonote_bits, var_value, 1u); | |
5744 PlayAwardSound(); | |
5745 return; | |
5746 case VAR_PlayerBits: | |
5747 _449B7E_toggle_bit((unsigned char *)playerEventBits, var_value, 1u); | |
5748 return; | |
5749 case VAR_NPCs2: | |
5750 pParty->hirelingScrollPosition = 0; | |
5751 LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u; | |
5752 pParty->CountHirelings(); | |
5753 viewparams->bRedrawGameUI = true; | |
5754 return; | |
5755 case VAR_NumSkillPoints: | |
5756 this->uSkillPoints = var_value; | |
5757 return; | |
5758 case VAR_Counter1: | |
5759 case VAR_Counter2: | |
5760 case VAR_Counter3: | |
5761 case VAR_Counter4: | |
5762 case VAR_Counter5: | |
5763 case VAR_Counter6: | |
5764 case VAR_Counter7: | |
5765 case VAR_Counter8: | |
5766 case VAR_Counter9: | |
5767 case VAR_Counter10: | |
5768 pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed; // *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed);*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed); | |
5769 return; | |
5770 case VAR_ReputationInCurrentLocation: | |
5771 v24 = &pOutdoor->ddm; | |
5772 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
5773 v24 = &pIndoor->dlv; | |
5774 v24->uReputation = var_value; | |
5775 if ( var_value > 10000 ) | |
5776 v24->uReputation = 10000; | |
5777 return; | |
5778 case VAR_GoldInBank: | |
5779 pParty->uNumGoldInBank = var_value; | |
5780 return; | |
5781 case VAR_NumDeaths: | |
5782 pParty->uNumDeaths = var_value; | |
5783 return; | |
5784 case VAR_NumBounties: | |
5785 pParty->uNumBountiesCollected = var_value; | |
5786 return; | |
5787 case VAR_PrisonTerms: | |
5788 pParty->uNumPrisonTerms = var_value; | |
5789 return; | |
5790 case VAR_ArenaWinsPage: | |
5791 pParty->uNumArenaPageWins = var_value; | |
5792 return; | |
5793 case VAR_ArenaWinsSquire: | |
5794 pParty->uNumArenaSquireWins = var_value; | |
5795 return; | |
5796 case VAR_ArenaWinsKnight: | |
5797 pParty->uNumArenaKnightWins = var_value; | |
5798 return; | |
5799 case VAR_ArenaWinsLord: | |
5800 pParty->uNumArenaLordWins = var_value; | |
5801 return; | |
5802 case VAR_StaffSkill: | |
5803 SetSkillByEvent(&Player::skillStaff, var_value); | |
5804 return; | |
5805 case VAR_SwordSkill: | |
5806 SetSkillByEvent(&Player::skillSword, var_value); | |
5807 return; | |
5808 case VAR_DaggerSkill: | |
5809 SetSkillByEvent(&Player::skillDagger, var_value); | |
5810 return; | |
5811 case VAR_AxeSkill: | |
5812 SetSkillByEvent(&Player::skillAxe, var_value); | |
5813 return; | |
5814 case VAR_SpearSkill: | |
5815 SetSkillByEvent(&Player::skillSpear, var_value); | |
5816 return; | |
5817 case VAR_BowSkill: | |
5818 SetSkillByEvent(&Player::skillBow, var_value); | |
5819 return; | |
5820 case VAR_MaceSkill: | |
5821 SetSkillByEvent(&Player::skillMace, var_value); | |
5822 return; | |
5823 case VAR_BlasterSkill: | |
5824 SetSkillByEvent(&Player::skillBlaster, var_value); | |
5825 return; | |
5826 case VAR_ShieldSkill: | |
5827 SetSkillByEvent(&Player::skillShield, var_value); | |
5828 return; | |
5829 case VAR_LeatherSkill: | |
5830 SetSkillByEvent(&Player::skillLeather, var_value); | |
5831 return; | |
5832 case VAR_SkillChain: | |
5833 SetSkillByEvent(&Player::skillChain, var_value); | |
5834 return; | |
5835 case VAR_PlateSkill: | |
5836 SetSkillByEvent(&Player::skillPlate, var_value); | |
5837 return; | |
5838 case VAR_FireSkill: | |
5839 SetSkillByEvent(&Player::skillFire, var_value); | |
5840 return; | |
5841 case VAR_AirSkill: | |
5842 SetSkillByEvent(&Player::skillAir, var_value); | |
5843 return; | |
5844 case VAR_WaterSkill: | |
5845 SetSkillByEvent(&Player::skillWater, var_value); | |
5846 return; | |
5847 case VAR_EarthSkill: | |
5848 SetSkillByEvent(&Player::skillEarth, var_value); | |
5849 return; | |
5850 case VAR_SpiritSkill: | |
5851 SetSkillByEvent(&Player::skillSpirit, var_value); | |
5852 return; | |
5853 case VAR_MindSkill: | |
5854 SetSkillByEvent(&Player::skillMind, var_value); | |
5855 return; | |
5856 case VAR_BodySkill: | |
5857 SetSkillByEvent(&Player::skillBody, var_value); | |
5858 return; | |
5859 case VAR_LightSkill: | |
5860 SetSkillByEvent(&Player::skillLight, var_value); | |
5861 return; | |
5862 case VAR_DarkSkill: | |
5863 SetSkillByEvent(&Player::skillDark, var_value); | |
5864 return; | |
5865 case VAR_IdentifyItemSkill: | |
5866 SetSkillByEvent(&Player::skillItemId, var_value); | |
5867 return; | |
5868 case VAR_MerchantSkill: | |
5869 SetSkillByEvent(&Player::skillMerchant, var_value); | |
5870 return; | |
5871 case VAR_RepairSkill: | |
5872 SetSkillByEvent(&Player::skillRepair, var_value); | |
5873 return; | |
5874 case VAR_BodybuildingSkill: | |
5875 SetSkillByEvent(&Player::skillBodybuilding, var_value); | |
5876 return; | |
5877 case VAR_MeditationSkill: | |
5878 SetSkillByEvent(&Player::skillMeditation, var_value); | |
5879 return; | |
5880 case VAR_PerceptionSkill: | |
5881 SetSkillByEvent(&Player::skillPerception, var_value); | |
5882 return; | |
5883 case VAR_DiplomacySkill: | |
5884 SetSkillByEvent(&Player::skillDiplomacy, var_value); | |
5885 return; | |
5886 case VAR_ThieverySkill: | |
5887 Error ("Thieving unsupported"); | |
5888 return; | |
5889 case VAR_DisarmTrapSkill: | |
5890 SetSkillByEvent(&Player::skillDisarmTrap, var_value); | |
5891 return; | |
5892 case VAR_DodgeSkill: | |
5893 SetSkillByEvent(&Player::skillDodge, var_value); | |
5894 return; | |
5895 case VAR_UnarmedSkill: | |
5896 SetSkillByEvent(&Player::skillUnarmed, var_value); | |
5897 return; | |
5898 case VAR_IdentifyMonsterSkill: | |
5899 SetSkillByEvent(&Player::skillMonsterId, var_value); | |
5900 return; | |
5901 case VAR_ArmsmasterSkill: | |
5902 SetSkillByEvent(&Player::skillArmsmaster, var_value); | |
5903 return; | |
5904 case VAR_StealingSkill: | |
5905 SetSkillByEvent(&Player::skillStealing, var_value); | |
5906 return; | |
5907 case VAR_AlchemySkill: | |
5908 SetSkillByEvent(&Player::skillAlchemy, var_value); | |
5909 return; | |
5910 case VAR_LearningSkill: | |
5911 SetSkillByEvent(&Player::skillLearning, var_value); | |
5912 return; | |
5913 } | |
5914 } | |
5915 | |
5916 | |
5917 //----- (new function) -------------------------------------------------------- | |
5918 void Player::PlayAwardSound() | |
5919 { | |
5920 int playerIndex = GetPlayerIndex(); | |
5921 signed int v25 = 8 * playerIndex + 400; | |
5922 LOBYTE(v25) = PID(OBJECT_Player,playerIndex - 112); | |
5923 pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); | |
5924 } | |
5925 | |
5926 //----- (new function) -------------------------------------------------------- | |
5927 void Player::PlayAwardSound_Anim() | |
5928 { | |
5929 int playerIndex = GetPlayerIndex(); | |
5930 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, playerIndex); | |
5931 PlayAwardSound(); | |
5932 } | |
5933 | |
5934 //----- (new function) -------------------------------------------------------- | |
5935 void Player::PlayAwardSound_Anim_Face( PlayerSpeech speech ) | |
5936 { | |
5937 this->PlaySound(speech, 0); | |
5938 PlayAwardSound_Anim(); | |
5939 } | |
5940 | |
5941 //----- (new function) -------------------------------------------------------- | |
5942 void Player::SetSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 skillValue ) | |
5943 { | |
5944 unsigned __int16 currSkillValue = this->*skillToSet; | |
5945 if ( skillValue > 63 ) //the original had the condition reversed which was probably wrong | |
5946 { | |
5947 this->*skillToSet = skillValue | currSkillValue & 63; | |
5948 } | |
5949 else | |
5950 { | |
5951 this->*skillToSet = skillValue | currSkillValue & 0xC0; | |
5952 } | |
5953 int playerIndex = GetPlayerIndex(); | |
5954 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, playerIndex); | |
5955 PlayAwardSound(); | |
5956 } | |
5957 | |
5958 //----- (0044AFFB) -------------------------------------------------------- | |
5959 void Player::AddVariable(enum VariableType var_type, signed int val) | |
5960 { | |
5961 int v6; // eax@15 | |
5962 unsigned int v7; // esi@18 | |
5963 DDM_DLV_Header *v27; // eax@153 | |
5964 ItemGen item; // [sp+Ch] [bp-2Ch]@45 | |
5965 | |
5966 if ( var_type >= VAR_Counter1 && var_type <= VAR_Counter10) | |
5967 { | |
5968 pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed; | |
5969 return; | |
5970 } | |
5971 | |
5972 if ( var_type >= VAR_UnknownTimeEvent0 && var_type <= VAR_UnknownTimeEvent19 ) | |
5973 { | |
5974 pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed; | |
5975 PlayAwardSound(); | |
5976 return; | |
5977 } | |
5978 | |
5979 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 ) | |
5980 { | |
5981 | |
5982 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_74 ) | |
5983 { | |
5984 if (255 - val > stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0]) | |
5985 stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0] += val; | |
5986 else | |
5987 stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0] = 255; | |
5988 } | |
5989 if ( (signed int)var_type >= VAR_MapPersistentVariable_75 && var_type <= VAR_MapPersistentVariable_99 ) | |
5990 { | |
5991 if (255 - val > stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75]) | |
5992 stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75] += val; | |
5993 else | |
5994 stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75] = 255; | |
5995 } | |
5996 return; | |
5997 } | |
5998 | |
5999 if ( var_type >= VAR_History_0 && var_type <= VAR_History_28) | |
6000 { | |
6001 if (!pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0]) | |
6002 { | |
6003 pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0] = pParty->uTimePlayed; | |
6004 if (pStorylineText->StoreLine[var_type - VAR_History_0].pText = 0) | |
6005 { | |
6006 bFlashHistoryBook = 1; | |
6007 PlayAwardSound(); | |
6008 } | |
6009 } | |
6010 return; | |
6011 } | |
6012 | |
6013 switch ( var_type ) | |
6014 { | |
6015 case VAR_RandomGold: | |
6016 if ( val == 0 ) | |
6017 val = 1; | |
6018 v6 = rand(); | |
6019 pParty->PartyFindsGold(v6 % val + 1, 1); | |
6020 GameUI_DrawFoodAndGold(); | |
6021 return; | |
6022 case VAR_RandomFood: | |
6023 if ( val == 0 ) | |
6024 val = 1; | |
6025 v7 = rand() % val + 1; | |
6026 Party::GiveFood(v7); | |
6027 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], v7);// You find %lu food | |
6028 ShowStatusBarString(pTmpBuf.data(), 2u); | |
6029 GameUI_DrawFoodAndGold(); | |
6030 PlayAwardSound(); | |
6031 return; | |
6032 case VAR_Sex: | |
6033 this->uSex = (PLAYER_SEX)val; | |
6034 PlayAwardSound_Anim97(); | |
6035 return; | |
6036 case VAR_Class: | |
6037 this->classType = (PLAYER_CLASS_TYPE)val; | |
6038 PlayAwardSound_Anim97(); | |
6039 return; | |
6040 case VAR_CurrentHP: | |
6041 this->sHealth = min(this->sHealth + val, this->GetMaxHealth() ); | |
6042 PlayAwardSound_Anim97(); | |
6043 return; | |
6044 case VAR_MaxHP: | |
6045 this->_health_related = 0; | |
6046 this->uFullHealthBonus = 0; | |
6047 this->sHealth = this->GetMaxHealth(); | |
6048 return; | |
6049 case VAR_CurrentSP: | |
6050 this->sMana = min(this->sMana + val, this->GetMaxMana() ); | |
6051 PlayAwardSound_Anim97(); | |
6052 return; | |
6053 case VAR_MaxSP: | |
6054 this->_mana_related = 0; | |
6055 this->uFullManaBonus = 0; | |
6056 this->sMana = GetMaxMana(); | |
6057 return; | |
6058 case VAR_ACModifier: | |
6059 this->sACModifier = min(this->sACModifier + val, 255); | |
6060 PlayAwardSound_Anim97(); | |
6061 return; | |
6062 case VAR_BaseLevel: | |
6063 this->uLevel = min(this->uLevel + val, 255); | |
6064 PlayAwardSound_Anim97(); | |
6065 return; | |
6066 case VAR_LevelModifier: | |
6067 this->sLevelModifier = min(this->sLevelModifier + val, 255); | |
6068 PlayAwardSound_Anim97(); | |
6069 return; | |
6070 case VAR_Age: | |
6071 this->sAgeModifier += val; | |
6072 return; | |
6073 case VAR_Award: | |
6074 if (_449B57_test_bit(this->_achieved_awards_bits, val) && pAwards[val].pText ) | |
6075 { | |
6076 PlayAwardSound_Anim97_Face(SPEECH_96); | |
6077 } | |
6078 _449B7E_toggle_bit(this->_achieved_awards_bits, val, 1); | |
6079 return; | |
6080 case VAR_Experience: | |
6081 this->uExperience = min(this->uExperience + val, 4000000000i64); | |
6082 PlayAwardSound_Anim97(); | |
6083 return; | |
6084 case VAR_QBits_QuestsDone: | |
6085 if ( !_449B57_test_bit(pParty->_quest_bits, val) && pQuestTable[val] ) | |
6086 { | |
6087 bFlashQuestBook = 1; | |
6088 PlayAwardSound_Anim97_Face(SPEECH_93); | |
6089 } | |
6090 _449B7E_toggle_bit(pParty->_quest_bits, val, 1); | |
6091 return; | |
6092 case VAR_PlayerItemInHands: | |
6093 item.Reset(); | |
6094 item.uAttributes = 1; | |
6095 item.uItemID = val; | |
6096 if ( val >= ITEM_ARTIFACT_PUCK && val <= ITEM_RELIC_MEKORIGS_HAMMER ) | |
6097 pParty->pIsArtifactFound[val-500] = 1; | |
6098 else if ( val >= ITEM_WAND_FIRE && val <= ITEM_WAND_INCENERATION ) | |
6099 { | |
6100 item.uNumCharges = rand() % 6 + item.GetDamageMod() + 1; | |
6101 item.uMaxCharges = LOBYTE(item.uNumCharges); | |
6102 } | |
6103 pParty->SetHoldingItem(&item); | |
6104 return; | |
6105 case VAR_FixedGold: | |
6106 pParty->PartyFindsGold(val, 1); | |
6107 return; | |
6108 case VAR_BaseMight: | |
6109 this->uMight = min(this->uMight + val, 255); | |
6110 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6111 return; | |
6112 case VAR_BaseIntellect: | |
6113 this->uIntelligence = min(this->uIntelligence + val, 255); | |
6114 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6115 return; | |
6116 case VAR_BasePersonality: | |
6117 this->uWillpower = min(this->uWillpower + val, 255); | |
6118 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6119 return; | |
6120 case VAR_BaseEndurance: | |
6121 this->uEndurance = min(this->uEndurance + val, 255); | |
6122 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6123 return; | |
6124 case VAR_BaseSpeed: | |
6125 this->uSpeed = min(this->uSpeed + val, 255); | |
6126 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6127 return; | |
6128 case VAR_BaseAccuracy: | |
6129 this->uAccuracy = min(this->uAccuracy + val, 255); | |
6130 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6131 return; | |
6132 case VAR_BaseLuck: | |
6133 this->uLuck = min(this->uLuck + val, 255); | |
6134 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6135 return; | |
6136 case VAR_FixedFood: | |
6137 Party::GiveFood(val); | |
6138 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], val); | |
6139 ShowStatusBarString(pTmpBuf.data(), 2u); | |
6140 if ( pParty->uNumFoodRations > 0xFFFF ) | |
6141 Party::SetFood(0xFFFFu); | |
6142 PlayAwardSound(); | |
6143 return; | |
6144 case VAR_MightBonus: | |
6145 case VAR_ActualMight: | |
6146 this->uMightBonus = min(this->uMightBonus + val, 255); | |
6147 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6148 return; | |
6149 case VAR_IntellectBonus: | |
6150 case VAR_ActualIntellect: | |
6151 this->uIntelligenceBonus = min(this->uIntelligenceBonus + val, 255); | |
6152 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6153 return; | |
6154 case VAR_PersonalityBonus: | |
6155 case VAR_ActualPersonality: | |
6156 this->uWillpowerBonus = min(this->uWillpowerBonus + val, 255); | |
6157 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6158 return; | |
6159 case VAR_EnduranceBonus: | |
6160 case VAR_ActualEndurance: | |
6161 this->uEnduranceBonus = min(this->uEnduranceBonus + val, 255); | |
6162 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6163 return; | |
6164 case VAR_SpeedBonus: | |
6165 case VAR_ActualSpeed: | |
6166 this->uSpeedBonus = min(this->uSpeedBonus + val, 255); | |
6167 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6168 return; | |
6169 case VAR_AccuracyBonus: | |
6170 case VAR_ActualAccuracy: | |
6171 this->uAccuracyBonus = min(this->uAccuracyBonus + val, 255); | |
6172 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6173 return; | |
6174 case VAR_LuckBonus: | |
6175 case VAR_ActualLuck: | |
6176 this->uLuckBonus = min(this->uLuckBonus + val, 255); | |
6177 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6178 return; | |
6179 case VAR_FireResistance: | |
6180 this->sResFireBase = min(this->sResFireBase + val, 255); | |
6181 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6182 return; | |
6183 case VAR_AirResistance: | |
6184 this->sResAirBase = min(this->sResAirBase + val, 255); | |
6185 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6186 return; | |
6187 case VAR_WaterResistance: | |
6188 this->sResWaterBase = min(this->sResWaterBase + val, 255); | |
6189 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6190 return; | |
6191 case VAR_EarthResistance: | |
6192 this->sResEarthBase = min(this->sResEarthBase + val, 255); | |
6193 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6194 return; | |
6195 case VAR_SpiritResistance: | |
6196 this->sResSpiritBase = min(this->sResSpiritBase + val, 255); | |
6197 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6198 return; | |
6199 case VAR_MindResistance: | |
6200 this->sResMindBase = min(this->sResMindBase + val, 255); | |
6201 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6202 return; | |
6203 case VAR_BodyResistance: | |
6204 this->sResBodyBase = min(this->sResBodyBase + val, 255); | |
6205 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6206 return; | |
6207 case VAR_LightResistance: | |
6208 this->sResLightBase = min(this->sResLightBase + val, 255); | |
6209 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6210 return; | |
6211 case VAR_DarkResistance: | |
6212 this->sResDarkBase = min(this->sResDarkBase + val, 255); | |
6213 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6214 return; | |
6215 case VAR_MagicResistance: | |
6216 this->sResMagicBase = min(this->sResMagicBase + val, 255); | |
6217 PlayAwardSound_Anim97_Face(SPEECH_92); | |
6218 return; | |
6219 case VAR_FireResistanceBonus: | |
6220 this->sResFireBonus = min(this->sResFireBonus + val, 255); | |
6221 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6222 return; | |
6223 case VAR_AirResistanceBonus: | |
6224 this->sResAirBonus = min(this->sResAirBonus + val, 255); | |
6225 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6226 return; | |
6227 case VAR_WaterResistanceBonus: | |
6228 this->sResWaterBonus = min(this->sResWaterBonus + val, 255); | |
6229 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6230 return; | |
6231 case VAR_EarthResistanceBonus: | |
6232 this->sResEarthBonus = min(this->sResEarthBonus + val, 255); | |
6233 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6234 return; | |
6235 case VAR_SpiritResistanceBonus: | |
6236 this->sResSpiritBonus = min(this->sResSpiritBonus + val, 255); | |
6237 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6238 return; | |
6239 case VAR_MindResistanceBonus: | |
6240 this->sResMindBonus = min(this->sResMindBonus + val, 255); | |
6241 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6242 return; | |
6243 case VAR_BodyResistanceBonus: | |
6244 this->sResBodyBonus = min(this->sResBodyBonus + val, 255); | |
6245 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6246 return; | |
6247 case VAR_LightResistanceBonus: | |
6248 this->sResLightBonus = min(this->sResLightBonus + val, 255); | |
6249 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6250 return; | |
6251 case VAR_DarkResistanceBonus: | |
6252 this->sResDarkBonus = min(this->sResDarkBonus + val, 255); | |
6253 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6254 return; | |
6255 case VAR_MagicResistanceBonus: | |
6256 this->sResMagicBonus = min(this->sResMagicBonus + val, 255); | |
6257 PlayAwardSound_Anim97_Face(SPEECH_91); | |
6258 return; | |
6259 case VAR_Cursed: | |
6260 this->SetCondition(Condition_Cursed, 1); | |
6261 PlayAwardSound_Anim97(); | |
6262 return; | |
6263 case VAR_Weak: | |
6264 this->SetCondition(Condition_Weak, 1); | |
6265 PlayAwardSound_Anim97(); | |
6266 return; | |
6267 case VAR_Asleep: | |
6268 this->SetCondition(Condition_Sleep, 1); | |
6269 PlayAwardSound_Anim97(); | |
6270 return; | |
6271 case VAR_Afraid: | |
6272 this->SetCondition(Condition_Fear, 1); | |
6273 PlayAwardSound_Anim97(); | |
6274 return; | |
6275 case VAR_Drunk: | |
6276 this->SetCondition(Condition_Drunk, 1); | |
6277 PlayAwardSound_Anim97(); | |
6278 return; | |
6279 case VAR_Insane: | |
6280 this->SetCondition(Condition_Insane, 1); | |
6281 PlayAwardSound_Anim97(); | |
6282 return; | |
6283 case VAR_PoisonedGreen: | |
6284 this->SetCondition(Condition_Poison_Weak, 1); | |
6285 PlayAwardSound_Anim97(); | |
6286 return; | |
6287 case VAR_DiseasedGreen: | |
6288 this->SetCondition(Condition_Disease_Weak, 1); | |
6289 PlayAwardSound_Anim97(); | |
6290 return; | |
6291 case VAR_PoisonedYellow: | |
6292 this->SetCondition(Condition_Poison_Medium, 1); | |
6293 PlayAwardSound_Anim97(); | |
6294 return; | |
6295 case VAR_DiseasedYellow: | |
6296 this->SetCondition(Condition_Disease_Medium, 1); | |
6297 PlayAwardSound_Anim97(); | |
6298 return; | |
6299 case VAR_PoisonedRed: | |
6300 this->SetCondition(Condition_Poison_Severe, 1); | |
6301 PlayAwardSound_Anim97(); | |
6302 return; | |
6303 case VAR_DiseasedRed: | |
6304 this->SetCondition(Condition_Disease_Severe, 1); | |
6305 PlayAwardSound_Anim97(); | |
6306 return; | |
6307 case VAR_Paralyzed: | |
6308 this->SetCondition(Condition_Paralyzed, 1); | |
6309 PlayAwardSound_Anim97(); | |
6310 return; | |
6311 case VAR_Unconsious: | |
6312 this->SetCondition(Condition_Unconcious, 1); | |
6313 PlayAwardSound_Anim97(); | |
6314 return; | |
6315 case VAR_Dead: | |
6316 this->SetCondition(Condition_Dead, 1); | |
6317 PlayAwardSound_Anim97(); | |
6318 return; | |
6319 case VAR_Stoned: | |
6320 this->SetCondition(Condition_Pertified, 1); | |
6321 PlayAwardSound_Anim97(); | |
6322 return; | |
6323 case VAR_Eradicated: | |
6324 this->SetCondition(Condition_Eradicated, 1); | |
6325 PlayAwardSound_Anim97(); | |
6326 return; | |
6327 case VAR_MajorCondition : | |
6328 pConditions.fill(0); | |
6329 PlayAwardSound_Anim97(); | |
6330 return; | |
6331 case VAR_AutoNotes: | |
6332 if ( !_449B57_test_bit(pParty->_autonote_bits, val) && pAutonoteTxt[val].pText ) | |
6333 { | |
6334 this->PlaySound(SPEECH_96, 0); | |
6335 bFlashAutonotesBook = 1; | |
6336 _506568_autonote_type = pAutonoteTxt[val].eType; | |
6337 pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, GetPlayerIndex()); | |
6338 } | |
6339 _449B7E_toggle_bit(pParty->_autonote_bits, val, 1); | |
6340 PlayAwardSound(); | |
6341 return; | |
6342 case VAR_PlayerBits: | |
6343 _449B7E_toggle_bit((unsigned char *)this->playerEventBits, val, 1u); | |
6344 return; | |
6345 case VAR_NPCs2: | |
6346 pParty->hirelingScrollPosition = 0; | |
6347 LOBYTE(pNPCStats->pNewNPCData[val].uFlags) |= 0x80u; | |
6348 pParty->CountHirelings(); | |
6349 viewparams->bRedrawGameUI = true; | |
6350 return; | |
6351 case VAR_NumSkillPoints: | |
6352 this->uSkillPoints += val; | |
6353 return; | |
6354 case VAR_ReputationInCurrentLocation: | |
6355 v27 = &pOutdoor->ddm; | |
6356 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
6357 v27 = &pIndoor->dlv; | |
6358 v27->uReputation += val; | |
6359 if ( v27->uReputation > 10000 ) | |
6360 v27->uReputation = 10000; | |
6361 return; | |
6362 case VAR_GoldInBank: | |
6363 pParty->uNumGoldInBank += val; | |
6364 return; | |
6365 case VAR_NumDeaths: | |
6366 pParty->uNumDeaths += val; | |
6367 return; | |
6368 case VAR_NumBounties: | |
6369 pParty->uNumBountiesCollected += val; | |
6370 return; | |
6371 case VAR_PrisonTerms: | |
6372 pParty->uNumPrisonTerms += val; | |
6373 return; | |
6374 case VAR_ArenaWinsPage: | |
6375 pParty->uNumArenaPageWins += val; | |
6376 return; | |
6377 case VAR_ArenaWinsSquire: | |
6378 pParty->uNumArenaSquireWins += val; | |
6379 return; | |
6380 case VAR_ArenaWinsKnight: | |
6381 pParty->uNumArenaKnightWins += val; | |
6382 return; | |
6383 case VAR_ArenaWinsLord: | |
6384 pParty->uNumArenaLordWins += val; | |
6385 return; | |
6386 case VAR_StaffSkill: | |
6387 AddSkillByEvent(&Player::skillStaff, val); | |
6388 return; | |
6389 case VAR_SwordSkill: | |
6390 AddSkillByEvent(&Player::skillSword, val); | |
6391 return; | |
6392 case VAR_DaggerSkill: | |
6393 AddSkillByEvent(&Player::skillDagger, val); | |
6394 return; | |
6395 case VAR_AxeSkill: | |
6396 AddSkillByEvent(&Player::skillAxe, val); | |
6397 return; | |
6398 case VAR_SpearSkill: | |
6399 AddSkillByEvent(&Player::skillSpear, val); | |
6400 return; | |
6401 case VAR_BowSkill: | |
6402 AddSkillByEvent(&Player::skillBow, val); | |
6403 return; | |
6404 case VAR_MaceSkill: | |
6405 AddSkillByEvent(&Player::skillMace, val); | |
6406 return; | |
6407 case VAR_BlasterSkill: | |
6408 AddSkillByEvent(&Player::skillBlaster, val); | |
6409 return; | |
6410 case VAR_ShieldSkill: | |
6411 AddSkillByEvent(&Player::skillShield, val); | |
6412 return; | |
6413 case VAR_LeatherSkill: | |
6414 AddSkillByEvent(&Player::skillLeather, val); | |
6415 return; | |
6416 case VAR_SkillChain: | |
6417 AddSkillByEvent(&Player::skillChain, val); | |
6418 return; | |
6419 case VAR_PlateSkill: | |
6420 AddSkillByEvent(&Player::skillPlate, val); | |
6421 return; | |
6422 case VAR_FireSkill: | |
6423 AddSkillByEvent(&Player::skillFire, val); | |
6424 return; | |
6425 case VAR_AirSkill: | |
6426 AddSkillByEvent(&Player::skillAir, val); | |
6427 return; | |
6428 case VAR_WaterSkill: | |
6429 AddSkillByEvent(&Player::skillWater, val); | |
6430 return; | |
6431 case VAR_EarthSkill: | |
6432 AddSkillByEvent(&Player::skillEarth, val); | |
6433 return; | |
6434 case VAR_SpiritSkill: | |
6435 AddSkillByEvent(&Player::skillSpirit, val); | |
6436 return; | |
6437 case VAR_MindSkill: | |
6438 AddSkillByEvent(&Player::skillMind, val); | |
6439 return; | |
6440 case VAR_BodySkill: | |
6441 AddSkillByEvent(&Player::skillBody, val); | |
6442 return; | |
6443 case VAR_LightSkill: | |
6444 AddSkillByEvent(&Player::skillLight, val); | |
6445 return; | |
6446 case VAR_DarkSkill: | |
6447 AddSkillByEvent(&Player::skillDark, val); | |
6448 return; | |
6449 case VAR_IdentifyItemSkill: | |
6450 AddSkillByEvent(&Player::skillItemId, val); | |
6451 return; | |
6452 case VAR_MerchantSkill: | |
6453 AddSkillByEvent(&Player::skillMerchant, val); | |
6454 return; | |
6455 case VAR_RepairSkill: | |
6456 AddSkillByEvent(&Player::skillRepair, val); | |
6457 return; | |
6458 case VAR_BodybuildingSkill: | |
6459 AddSkillByEvent(&Player::skillBodybuilding, val); | |
6460 return; | |
6461 case VAR_MeditationSkill: | |
6462 AddSkillByEvent(&Player::skillMeditation, val); | |
6463 return; | |
6464 case VAR_PerceptionSkill: | |
6465 AddSkillByEvent(&Player::skillPerception, val); | |
6466 return; | |
6467 case VAR_DiplomacySkill: | |
6468 AddSkillByEvent(&Player::skillDiplomacy, val); | |
6469 return; | |
6470 case VAR_ThieverySkill: | |
6471 Error ("Thieving unsupported"); | |
6472 return; | |
6473 case VAR_DisarmTrapSkill: | |
6474 AddSkillByEvent(&Player::skillDisarmTrap, val); | |
6475 return; | |
6476 case VAR_DodgeSkill: | |
6477 AddSkillByEvent(&Player::skillDodge, val); | |
6478 return; | |
6479 case VAR_UnarmedSkill: | |
6480 AddSkillByEvent(&Player::skillUnarmed, val); | |
6481 return; | |
6482 case VAR_IdentifyMonsterSkill: | |
6483 AddSkillByEvent(&Player::skillMonsterId, val); | |
6484 return; | |
6485 case VAR_ArmsmasterSkill: | |
6486 AddSkillByEvent(&Player::skillArmsmaster, val); | |
6487 return; | |
6488 case VAR_StealingSkill: | |
6489 AddSkillByEvent(&Player::skillStealing, val); | |
6490 return; | |
6491 case VAR_AlchemySkill: | |
6492 AddSkillByEvent(&Player::skillAlchemy, val); | |
6493 return; | |
6494 case VAR_LearningSkill: | |
6495 AddSkillByEvent(&Player::skillLearning, val); | |
6496 return; | |
6497 default: | |
6498 return; | |
6499 } | |
6500 } | |
6501 | |
6502 //----- (new function) -------------------------------------------------------- | |
6503 void Player::PlayAwardSound_Anim97() | |
6504 { | |
6505 int playerIndex = GetPlayerIndex(); | |
6506 pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, playerIndex); | |
6507 PlayAwardSound(); | |
6508 } | |
6509 | |
6510 //----- (new function) -------------------------------------------------------- | |
6511 void Player::PlayAwardSound_Anim97_Face( PlayerSpeech speech ) | |
6512 { | |
6513 this->PlaySound(speech, 0); | |
6514 PlayAwardSound_Anim97(); | |
6515 } | |
6516 | |
6517 //----- (new function) -------------------------------------------------------- | |
6518 void Player::AddSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 addSkillValue ) | |
6519 { | |
6520 if ( addSkillValue > 63 ) | |
6521 { | |
6522 this->*skillToSet = (unsigned __int8)addSkillValue | this->*skillToSet & 63; | |
6523 } | |
6524 else | |
6525 { | |
6526 this->*skillToSet = min(this->*skillToSet + addSkillValue, 60) | this->*skillToSet & 0xC0; | |
6527 } | |
6528 PlayAwardSound_Anim97(); | |
6529 return; | |
6530 } | |
6531 | |
6532 //----- (0044B9C4) -------------------------------------------------------- | |
6533 void Player::SubtractVariable( enum VariableType VarNum, signed int pValue ) | |
6534 { | |
6535 DDM_DLV_Header *locationHeader; // eax@90 | |
6536 int randGold; | |
6537 int randFood; | |
6538 int npcIndex; | |
6539 | |
6540 if ( VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_99 ) | |
6541 { | |
6542 if ( VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_74 ) | |
6543 { | |
6544 stru_5E4C90_MapPersistVars.field_0[VarNum - VAR_MapPersistentVariable_0] -= pValue; | |
6545 } | |
6546 if ( (signed int)VarNum >= VAR_MapPersistentVariable_75 && VarNum <= VAR_MapPersistentVariable_99 ) | |
6547 { | |
6548 stru_5E4C90_MapPersistVars._decor_events[VarNum - VAR_MapPersistentVariable_75] -= pValue; | |
6549 } | |
6550 return; | |
6551 } | |
6552 | |
6553 switch (VarNum) | |
6554 { | |
6555 case VAR_CurrentHP: | |
6556 ReceiveDamage((signed int)pValue, DMGT_PHISYCAL); | |
6557 PlayAwardSound_Anim98(); | |
6558 return; | |
6559 case VAR_CurrentSP: | |
6560 this->sMana = max(this->sMana - pValue, 0); | |
6561 PlayAwardSound_Anim98(); | |
6562 return; | |
6563 case VAR_ACModifier: | |
6564 this->sACModifier -= (unsigned __int8)pValue; | |
6565 PlayAwardSound_Anim98(); | |
6566 return; | |
6567 case VAR_BaseLevel: | |
6568 this->uLevel -= (unsigned __int8)pValue; | |
6569 PlayAwardSound_Anim98(); | |
6570 return; | |
6571 case VAR_LevelModifier: | |
6572 this->sLevelModifier -= (unsigned __int8)pValue; | |
6573 PlayAwardSound_Anim98(); | |
6574 return; | |
6575 case VAR_Age: | |
6576 this->sAgeModifier -= (signed __int16)pValue; | |
6577 return; | |
6578 case VAR_Award: | |
6579 _449B7E_toggle_bit(this->_achieved_awards_bits, (signed __int16)pValue, 0); | |
6580 return; | |
6581 case VAR_Experience: | |
6582 this->uExperience -= pValue; | |
6583 PlayAwardSound_Anim98(); | |
6584 return; | |
6585 case VAR_QBits_QuestsDone: | |
6586 _449B7E_toggle_bit(pParty->_quest_bits, (__int16)pValue, 0); | |
6587 this->PlaySound(SPEECH_96, 0); | |
6588 return; | |
6589 case VAR_PlayerItemInHands: | |
6590 for ( uint i = 0; i < 16; ++i ) | |
6591 { | |
6592 int id_ = this->pEquipment.pIndices[i]; | |
6593 if ( id_ > 0 ) | |
6594 { | |
6595 if ( this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID == pValue ) | |
6596 { | |
6597 this->pEquipment.pIndices[i] = 0; | |
6598 } | |
6599 } | |
6600 } | |
6601 for (int i = 0; i < 126; i++) | |
6602 { | |
6603 int id_ = this->pInventoryMatrix[i]; | |
6604 if ( id_ > 0 ) | |
6605 { | |
6606 if ( this->pInventoryItemList[id_ - 1].uItemID == pValue ) | |
6607 { | |
6608 RemoveItemAtInventoryIndex(i); | |
6609 return; | |
6610 } | |
6611 } | |
6612 } | |
6613 if ( pParty->pPickedItem.uItemID == pValue ) | |
6614 { | |
6615 pMouse->RemoveHoldingItem(); | |
6616 return; | |
6617 } | |
6618 return; | |
6619 case VAR_FixedGold: | |
6620 if ( (unsigned int)pValue > pParty->uNumGold ) | |
6621 { | |
6622 dword_5B65C4_cancelEventProcessing = 1; | |
6623 return; | |
6624 } | |
6625 Party::TakeGold((unsigned int)pValue); | |
6626 return; | |
6627 case VAR_RandomGold: | |
6628 randGold = rand() % (signed int)pValue + 1; | |
6629 if ( (unsigned int)randGold > pParty->uNumGold ) | |
6630 randGold = pParty->uNumGold; | |
6631 Party::TakeGold(randGold); | |
6632 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[503], randGold); | |
6633 ShowStatusBarString(pTmpBuf.data(), 2); | |
6634 GameUI_DrawFoodAndGold(); | |
6635 return; | |
6636 case VAR_FixedFood: | |
6637 Party::TakeFood((unsigned int)pValue); | |
6638 PlayAwardSound_Anim98(); | |
6639 return; | |
6640 case VAR_RandomFood: | |
6641 randFood = rand() % (signed int)pValue + 1; | |
6642 if ( (unsigned int)randFood > pParty->uNumFoodRations ) | |
6643 randFood = pParty->uNumFoodRations; | |
6644 Party::TakeFood(randFood); | |
6645 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[504], randFood); | |
6646 ShowStatusBarString(pTmpBuf.data(), 2u); | |
6647 GameUI_DrawFoodAndGold(); | |
6648 PlayAwardSound_Anim98(); | |
6649 return; | |
6650 case VAR_MightBonus: | |
6651 case VAR_ActualMight: | |
6652 this->uMightBonus -= (unsigned __int16)pValue; | |
6653 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6654 return; | |
6655 case VAR_IntellectBonus: | |
6656 case VAR_ActualIntellect: | |
6657 this->uIntelligenceBonus -= (unsigned __int16)pValue; | |
6658 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6659 return; | |
6660 case VAR_PersonalityBonus: | |
6661 case VAR_ActualPersonality: | |
6662 this->uWillpowerBonus -= (unsigned __int16)pValue; | |
6663 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6664 return; | |
6665 case VAR_EnduranceBonus: | |
6666 case VAR_ActualEndurance: | |
6667 this->uEnduranceBonus -= (unsigned __int16)pValue; | |
6668 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6669 return; | |
6670 case VAR_SpeedBonus: | |
6671 case VAR_ActualSpeed: | |
6672 this->uSpeedBonus -= (unsigned __int16)pValue; | |
6673 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6674 return; | |
6675 case VAR_AccuracyBonus: | |
6676 case VAR_ActualAccuracy: | |
6677 this->uAccuracyBonus -= (unsigned __int16)pValue; | |
6678 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6679 return; | |
6680 case VAR_LuckBonus: | |
6681 case VAR_ActualLuck: | |
6682 this->uLuckBonus -= (unsigned __int16)pValue; | |
6683 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6684 return; | |
6685 case VAR_BaseMight: | |
6686 this->uMight -= (unsigned __int16)pValue; | |
6687 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6688 return; | |
6689 case VAR_BaseIntellect: | |
6690 this->uIntelligence -= (unsigned __int16)pValue; | |
6691 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6692 return; | |
6693 case VAR_BasePersonality: | |
6694 this->uWillpower -= (unsigned __int16)pValue; | |
6695 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6696 return; | |
6697 case VAR_BaseEndurance: | |
6698 this->uEndurance -= (unsigned __int16)pValue; | |
6699 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6700 return; | |
6701 case VAR_BaseSpeed: | |
6702 this->uSpeed -= (unsigned __int16)pValue; | |
6703 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6704 return; | |
6705 case VAR_BaseAccuracy: | |
6706 this->uAccuracy -= (unsigned __int16)pValue; | |
6707 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6708 return; | |
6709 case VAR_BaseLuck: | |
6710 this->uLuck -= (unsigned __int16)pValue; | |
6711 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6712 return; | |
6713 case VAR_FireResistance: | |
6714 this->sResFireBase -= (signed __int16)pValue; | |
6715 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6716 return; | |
6717 case VAR_AirResistance: | |
6718 this->sResAirBase -= (signed __int16)pValue; | |
6719 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6720 return; | |
6721 case VAR_WaterResistance: | |
6722 this->sResWaterBase -= (signed __int16)pValue; | |
6723 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6724 return; | |
6725 case VAR_EarthResistance: | |
6726 this->sResEarthBase -= (signed __int16)pValue; | |
6727 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6728 return; | |
6729 case VAR_SpiritResistance: | |
6730 this->sResSpiritBase -= (signed __int16)pValue; | |
6731 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6732 return; | |
6733 case VAR_MindResistance: | |
6734 this->sResMindBase -= (signed __int16)pValue; | |
6735 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6736 return; | |
6737 case VAR_BodyResistance: | |
6738 this->sResBodyBase -= (signed __int16)pValue; | |
6739 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6740 return; | |
6741 case VAR_LightResistance: | |
6742 this->sResLightBase -= (signed __int16)pValue; | |
6743 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6744 return; | |
6745 case VAR_DarkResistance: | |
6746 this->sResDarkBase -= (signed __int16)pValue; | |
6747 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6748 return; | |
6749 case VAR_MagicResistance: | |
6750 this->sResMagicBase -= (signed __int16)pValue; | |
6751 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6752 return; | |
6753 case VAR_FireResistanceBonus: | |
6754 this->sResFireBonus -= (signed __int16)pValue; | |
6755 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6756 return; | |
6757 case VAR_AirResistanceBonus: | |
6758 this->sResAirBonus -= (signed __int16)pValue; | |
6759 this->PlayAwardSound_Anim98_Face(SPEECH_92); | |
6760 return; | |
6761 case VAR_WaterResistanceBonus: | |
6762 this->sResWaterBonus -= (signed __int16)pValue; | |
6763 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6764 return; | |
6765 case VAR_EarthResistanceBonus: | |
6766 this->sResEarthBonus -= (signed __int16)pValue; | |
6767 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6768 return; | |
6769 case VAR_SpiritResistanceBonus: | |
6770 this->sResSpiritBonus -= (signed __int16)pValue; | |
6771 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6772 return; | |
6773 case VAR_MindResistanceBonus: | |
6774 this->sResMindBonus -= (signed __int16)pValue; | |
6775 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6776 return; | |
6777 case VAR_BodyResistanceBonus: | |
6778 this->sResBodyBonus -= (signed __int16)pValue; | |
6779 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6780 return; | |
6781 case VAR_LightResistanceBonus: | |
6782 this->sResLightBonus -= (signed __int16)pValue; | |
6783 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6784 return; | |
6785 case VAR_DarkResistanceBonus: | |
6786 this->sResDarkBonus -= (signed __int16)pValue; | |
6787 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6788 return; | |
6789 case VAR_MagicResistanceBonus: | |
6790 this->sResMagicBonus -= (signed __int16)pValue; | |
6791 this->PlayAwardSound_Anim98_Face(SPEECH_91); | |
6792 return; | |
6793 case VAR_StaffSkill: | |
6794 this->skillStaff -= (unsigned __int8)pValue; | |
6795 PlayAwardSound_Anim98(); | |
6796 return; | |
6797 case VAR_SwordSkill: | |
6798 this->skillSword -= (unsigned __int8)pValue; | |
6799 PlayAwardSound_Anim98(); | |
6800 return; | |
6801 case VAR_DaggerSkill: | |
6802 this->skillDagger -= (unsigned __int8)pValue; | |
6803 PlayAwardSound_Anim98(); | |
6804 return; | |
6805 case VAR_AxeSkill: | |
6806 this->skillAxe -= (unsigned __int8)pValue; | |
6807 PlayAwardSound_Anim98(); | |
6808 return; | |
6809 case VAR_SpearSkill: | |
6810 this->skillSpear -= (unsigned __int8)pValue; | |
6811 PlayAwardSound_Anim98(); | |
6812 return; | |
6813 case VAR_BowSkill: | |
6814 this->skillBow -= (unsigned __int8)pValue; | |
6815 PlayAwardSound_Anim98(); | |
6816 return; | |
6817 case VAR_MaceSkill: | |
6818 this->skillMace -= (unsigned __int8)pValue; | |
6819 PlayAwardSound_Anim98(); | |
6820 return; | |
6821 case VAR_BlasterSkill: | |
6822 this->skillBlaster -= (unsigned __int8)pValue; | |
6823 PlayAwardSound_Anim98(); | |
6824 return; | |
6825 case VAR_ShieldSkill: | |
6826 this->skillShield -= (unsigned __int8)pValue; | |
6827 PlayAwardSound_Anim98(); | |
6828 return; | |
6829 case VAR_LeatherSkill: | |
6830 this->skillLearning -= (unsigned __int8)pValue; | |
6831 PlayAwardSound_Anim98(); | |
6832 return; | |
6833 case VAR_SkillChain: | |
6834 this->skillChain -= (unsigned __int8)pValue; | |
6835 PlayAwardSound_Anim98(); | |
6836 return; | |
6837 case VAR_PlateSkill: | |
6838 this->skillPlate -= (unsigned __int8)pValue; | |
6839 PlayAwardSound_Anim98(); | |
6840 return; | |
6841 case VAR_FireSkill: | |
6842 this->skillFire -= (unsigned __int8)pValue; | |
6843 PlayAwardSound_Anim98(); | |
6844 return; | |
6845 case VAR_AirSkill: | |
6846 this->skillAir -= (unsigned __int8)pValue; | |
6847 PlayAwardSound_Anim98(); | |
6848 return; | |
6849 case VAR_WaterSkill: | |
6850 this->skillWater -= (unsigned __int8)pValue; | |
6851 PlayAwardSound_Anim98(); | |
6852 return; | |
6853 case VAR_EarthSkill: | |
6854 this->skillEarth -= (unsigned __int8)pValue; | |
6855 PlayAwardSound_Anim98(); | |
6856 return; | |
6857 case VAR_SpiritSkill: | |
6858 this->skillSpirit -= (unsigned __int8)pValue; | |
6859 PlayAwardSound_Anim98(); | |
6860 return; | |
6861 case VAR_MindSkill: | |
6862 this->skillMind -= (unsigned __int8)pValue; | |
6863 PlayAwardSound_Anim98(); | |
6864 return; | |
6865 case VAR_BodySkill: | |
6866 this->skillBody -= (unsigned __int8)pValue; | |
6867 PlayAwardSound_Anim98(); | |
6868 return; | |
6869 case VAR_LightSkill: | |
6870 this->skillLight -= (unsigned __int8)pValue; | |
6871 PlayAwardSound_Anim98(); | |
6872 return; | |
6873 case VAR_DarkSkill: | |
6874 this->skillDark -= (unsigned __int8)pValue; | |
6875 PlayAwardSound_Anim98(); | |
6876 return; | |
6877 case VAR_IdentifyItemSkill: | |
6878 this->skillItemId -= (unsigned __int8)pValue; | |
6879 PlayAwardSound_Anim98(); | |
6880 return; | |
6881 case VAR_MerchantSkill: | |
6882 this->skillMerchant -= (unsigned __int8)pValue; | |
6883 PlayAwardSound_Anim98(); | |
6884 return; | |
6885 case VAR_RepairSkill: | |
6886 this->skillRepair -= (unsigned __int8)pValue; | |
6887 PlayAwardSound_Anim98(); | |
6888 return; | |
6889 case VAR_BodybuildingSkill: | |
6890 this->skillBodybuilding -= (unsigned __int8)pValue; | |
6891 PlayAwardSound_Anim98(); | |
6892 return; | |
6893 case VAR_MeditationSkill: | |
6894 this->skillMeditation -= (unsigned __int8)pValue; | |
6895 PlayAwardSound_Anim98(); | |
6896 return; | |
6897 case VAR_PerceptionSkill: | |
6898 this->skillPerception -= (unsigned __int8)pValue; | |
6899 PlayAwardSound_Anim98(); | |
6900 return; | |
6901 case VAR_DiplomacySkill: | |
6902 this->skillDiplomacy -= (unsigned __int8)pValue; | |
6903 PlayAwardSound_Anim98(); | |
6904 return; | |
6905 case VAR_ThieverySkill: | |
6906 Error ("Thieving unsupported"); | |
6907 return; | |
6908 case VAR_DisarmTrapSkill: | |
6909 this->skillDisarmTrap -= (unsigned __int8)pValue; | |
6910 PlayAwardSound_Anim98(); | |
6911 return; | |
6912 case VAR_DodgeSkill: | |
6913 this->skillDodge -= (unsigned __int8)pValue; | |
6914 PlayAwardSound_Anim98(); | |
6915 return; | |
6916 case VAR_UnarmedSkill: | |
6917 this->skillUnarmed -= (unsigned __int8)pValue; | |
6918 PlayAwardSound_Anim98(); | |
6919 return; | |
6920 case VAR_IdentifyMonsterSkill: | |
6921 this->skillMonsterId -= (unsigned __int8)pValue; | |
6922 PlayAwardSound_Anim98(); | |
6923 return; | |
6924 case VAR_ArmsmasterSkill: | |
6925 this->skillArmsmaster -= (unsigned __int8)pValue; | |
6926 PlayAwardSound_Anim98(); | |
6927 return; | |
6928 case VAR_StealingSkill: | |
6929 this->skillStealing -= (unsigned __int8)pValue; | |
6930 PlayAwardSound_Anim98(); | |
6931 return; | |
6932 case VAR_AlchemySkill: | |
6933 this->skillAlchemy -= (unsigned __int8)pValue; | |
6934 PlayAwardSound_Anim98(); | |
6935 return; | |
6936 case VAR_LearningSkill: | |
6937 this->skillLearning -= (unsigned __int8)pValue; | |
6938 PlayAwardSound_Anim98(); | |
6939 return; | |
6940 case VAR_Cursed: | |
6941 this->pConditions[Condition_Cursed] = 0; | |
6942 PlayAwardSound_Anim98(); | |
6943 return; | |
6944 case VAR_Weak: | |
6945 this->pConditions[Condition_Weak] = 0; | |
6946 PlayAwardSound_Anim98(); | |
6947 return; | |
6948 case VAR_Asleep: | |
6949 this->pConditions[Condition_Sleep] = 0; | |
6950 PlayAwardSound_Anim98(); | |
6951 return; | |
6952 case VAR_Afraid: | |
6953 this->pConditions[Condition_Fear] = 0; | |
6954 PlayAwardSound_Anim98(); | |
6955 return; | |
6956 case VAR_Drunk: | |
6957 this->pConditions[Condition_Drunk] = 0; | |
6958 PlayAwardSound_Anim98(); | |
6959 return; | |
6960 case VAR_Insane: | |
6961 this->pConditions[Condition_Insane] = 0; | |
6962 PlayAwardSound_Anim98(); | |
6963 return; | |
6964 case VAR_PoisonedGreen: | |
6965 this->pConditions[Condition_Poison_Weak] = 0; | |
6966 PlayAwardSound_Anim98(); | |
6967 return; | |
6968 case VAR_DiseasedGreen: | |
6969 this->pConditions[Condition_Disease_Weak] = 0; | |
6970 PlayAwardSound_Anim98(); | |
6971 return; | |
6972 case VAR_PoisonedYellow: | |
6973 this->pConditions[Condition_Poison_Medium] = 0; | |
6974 PlayAwardSound_Anim98(); | |
6975 return; | |
6976 case VAR_DiseasedYellow: | |
6977 this->pConditions[Condition_Disease_Medium] = 0; | |
6978 PlayAwardSound_Anim98(); | |
6979 return; | |
6980 case VAR_PoisonedRed: | |
6981 this->pConditions[Condition_Poison_Severe] = 0; | |
6982 PlayAwardSound_Anim98(); | |
6983 return; | |
6984 case VAR_DiseasedRed: | |
6985 this->pConditions[Condition_Disease_Severe] = 0; | |
6986 PlayAwardSound_Anim98(); | |
6987 return; | |
6988 case VAR_Paralyzed: | |
6989 this->pConditions[Condition_Paralyzed] = 0; | |
6990 PlayAwardSound_Anim98(); | |
6991 return; | |
6992 case VAR_Unconsious: | |
6993 this->pConditions[Condition_Unconcious] = 0; | |
6994 PlayAwardSound_Anim98(); | |
6995 return; | |
6996 case VAR_Dead: | |
6997 this->pConditions[Condition_Dead] = 0; | |
6998 PlayAwardSound_Anim98(); | |
6999 return; | |
7000 case VAR_Stoned: | |
7001 this->pConditions[Condition_Pertified] = 0; | |
7002 PlayAwardSound_Anim98(); | |
7003 return; | |
7004 case VAR_Eradicated: | |
7005 this->pConditions[Condition_Eradicated] = 0; | |
7006 PlayAwardSound_Anim98(); | |
7007 return; | |
7008 case VAR_AutoNotes: | |
7009 _449B7E_toggle_bit(pParty->_autonote_bits, pValue - 1, 0); | |
7010 return; | |
7011 case VAR_NPCs2: | |
7012 npcIndex = 0; | |
7013 GetNewNPCData(sDialogue_SpeakingActorNPC_ID, &npcIndex); | |
7014 if ( npcIndex == pValue ) | |
7015 { | |
7016 npcIdToDismissAfterDialogue = pValue; | |
7017 } | |
7018 else | |
7019 { | |
7020 npcIdToDismissAfterDialogue = 0; | |
7021 pParty->hirelingScrollPosition = 0; | |
7022 LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu; | |
7023 pParty->CountHirelings(); | |
7024 viewparams->bRedrawGameUI = true; | |
7025 } | |
7026 return; | |
7027 case VAR_HiredNPCHasSpeciality: | |
7028 for (unsigned int i = 0; i < pNPCStats->uNumNewNPCs; i++) | |
7029 { | |
7030 if (pNPCStats->pNewNPCData[i].uProfession == pValue) | |
7031 { | |
7032 LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu; | |
7033 } | |
7034 } | |
7035 if ( pParty->pHirelings[0].uProfession == pValue ) | |
7036 memset(&pParty->pHirelings[0], 0, sizeof(NPCData)); | |
7037 if ( pParty->pHirelings[1].uProfession == pValue ) | |
7038 memset(&pParty->pHirelings[1], 0, sizeof(NPCData)); | |
7039 pParty->hirelingScrollPosition = 0; | |
7040 pParty->CountHirelings(); | |
7041 return; | |
7042 case VAR_NumSkillPoints: | |
7043 if ((unsigned int)pValue <= this->uSkillPoints) | |
7044 { | |
7045 this->uSkillPoints -= pValue; | |
7046 } | |
7047 else | |
7048 { | |
7049 this->uSkillPoints = 0; | |
7050 } | |
7051 return; | |
7052 case VAR_ReputationInCurrentLocation: | |
7053 locationHeader = &pOutdoor->ddm; | |
7054 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
7055 locationHeader = &pIndoor->dlv; | |
7056 locationHeader->uReputation -= pValue; | |
7057 if (locationHeader->uReputation < -10000) | |
7058 locationHeader->uReputation = -10000; | |
7059 return; | |
7060 case VAR_GoldInBank: | |
7061 if ( (unsigned int)pValue <= pParty->uNumGoldInBank ) | |
7062 { | |
7063 pParty->uNumGoldInBank -= (unsigned int)pValue; | |
7064 } | |
7065 else | |
7066 { | |
7067 dword_5B65C4_cancelEventProcessing = 1; | |
7068 } | |
7069 return; | |
7070 case VAR_NumDeaths: | |
7071 pParty->uNumDeaths -= (unsigned int)pValue; | |
7072 return; | |
7073 case VAR_NumBounties: | |
7074 pParty->uNumBountiesCollected -= (unsigned int)pValue; | |
7075 return; | |
7076 case VAR_PrisonTerms: | |
7077 pParty->uNumPrisonTerms -= (int)pValue; | |
7078 return; | |
7079 case VAR_ArenaWinsPage: | |
7080 pParty->uNumArenaPageWins -= (char)pValue; | |
7081 return; | |
7082 case VAR_ArenaWinsSquire: | |
7083 pParty->uNumArenaSquireWins -= (char)pValue; | |
7084 return; | |
7085 case VAR_ArenaWinsKnight: | |
7086 pParty->uNumArenaKnightWins -= (char)pValue; | |
7087 return; | |
7088 case VAR_ArenaWinsLord: | |
7089 pParty->uNumArenaLordWins -= (char)pValue; | |
7090 return; | |
7091 } | |
7092 } | |
7093 // 5B65C4: using guessed type int dword_5B65C4; | |
7094 // 5B65CC: using guessed type int dword_5B65CC; | |
7095 | |
7096 //----- (new function) -------------------------------------------------------- | |
7097 void Player::PlayAwardSound_Anim98() | |
7098 { | |
7099 int playerIndex = GetPlayerIndex(); | |
7100 pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, playerIndex); | |
7101 PlayAwardSound(); | |
7102 } | |
7103 | |
7104 //----- (new function) -------------------------------------------------------- | |
7105 void Player::PlayAwardSound_Anim98_Face( PlayerSpeech speech ) | |
7106 { | |
7107 this->PlaySound(speech, 0); | |
7108 PlayAwardSound_Anim98(); | |
7109 } | |
7110 | |
7111 //----- (00467E7F) -------------------------------------------------------- | |
7112 void Player::EquipBody(ITEM_EQUIP_TYPE uEquipType) | |
7113 { | |
7114 int itemAnchor; // ebx@1 | |
7115 int itemInvLocation; // edx@1 | |
7116 int freeSlot; // eax@3 | |
7117 ItemGen tempPickedItem; // [sp+Ch] [bp-30h]@1 | |
7118 | |
7119 tempPickedItem.Reset(); | |
7120 itemAnchor = pEquipTypeToBodyAnchor[uEquipType]; | |
7121 itemInvLocation = pPlayers[uActiveCharacter]->pEquipment.pIndices[itemAnchor]; | |
7122 if ( itemInvLocation )//ïåðåîäåòüñÿ â äðóãóþ âåùü | |
7123 { | |
7124 memcpy(&tempPickedItem, &pParty->pPickedItem, sizeof(tempPickedItem)); | |
7125 pPlayers[uActiveCharacter]->pInventoryItemList[itemInvLocation - 1].uBodyAnchor = 0; | |
7126 pParty->pPickedItem.Reset(); | |
7127 pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[itemInvLocation - 1]); | |
7128 tempPickedItem.uBodyAnchor = itemAnchor + 1; | |
7129 memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[itemInvLocation - 1], &tempPickedItem, sizeof(ItemGen)); | |
7130 pPlayers[uActiveCharacter]->pEquipment.pIndices[itemAnchor] = itemInvLocation; | |
7131 } | |
7132 else//îäåòü âåùü | |
7133 { | |
7134 freeSlot = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot(); | |
7135 if (freeSlot >= 0) | |
7136 { | |
7137 pParty->pPickedItem.uBodyAnchor = itemAnchor + 1; | |
7138 memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[freeSlot], &pParty->pPickedItem, sizeof(ItemGen)); | |
7139 pPlayers[uActiveCharacter]->pEquipment.pIndices[itemAnchor] = freeSlot + 1; | |
7140 pMouse->RemoveHoldingItem(); | |
7141 } | |
7142 } | |
7143 } | |
7144 | |
7145 //----- (0049387A) -------------------------------------------------------- | |
7146 int CycleCharacter(bool backwards) | |
7147 { | |
7148 const int PARTYSIZE = 4; | |
7149 int valToAdd = backwards ? (PARTYSIZE - 2) : 0; | |
7150 int mult = backwards ? -1 : 1; | |
7151 | |
7152 for (int i = 0; i < (PARTYSIZE - 1); i++) | |
7153 { | |
7154 int currCharId = ((uActiveCharacter + mult * i + valToAdd) % PARTYSIZE) + 1; | |
7155 if ( pPlayers[currCharId]->uTimeToRecovery == 0 ) | |
7156 { | |
7157 return currCharId; | |
7158 } | |
7159 } | |
7160 return uActiveCharacter; | |
7161 } | |
7162 | |
7163 //----- (0043EE77) -------------------------------------------------------- | |
7164 bool Player::HasUnderwaterSuitEquipped() //the original function took the player number as a parameter. if it was 0, the whole party was checked. calls with the parameter 0 have been changed to calls to this for every player | |
7165 { | |
7166 if (GetArmorItem() == nullptr || GetArmorItem()->uItemID != 604) | |
7167 { | |
7168 return false; | |
7169 } | |
7170 return true; | |
7171 } | |
7172 | |
7173 //----- (0043EE15) -------------------------------------------------------- | |
7174 bool Player::HasItem( unsigned int uItemID, bool checkHeldItem ) | |
7175 { | |
7176 if ( !checkHeldItem || pParty->pPickedItem.uItemID != uItemID ) | |
7177 { | |
7178 for ( uint i = 0; i < 126; ++i ) | |
7179 { | |
7180 if ( this->pInventoryMatrix[i] > 0 ) | |
7181 { | |
7182 if ( (unsigned int)this->pInventoryItemList[this->pInventoryMatrix[i] - 1].uItemID == uItemID ) | |
7183 return true; | |
7184 } | |
7185 } | |
7186 for ( uint i = 0; i < 16; ++i ) | |
7187 { | |
7188 if ( this->pEquipment.pIndices[i] ) | |
7189 { | |
7190 if ( (unsigned int)this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID == uItemID ) | |
7191 return true; | |
7192 } | |
7193 } | |
7194 return false; | |
7195 } | |
7196 else | |
7197 { | |
7198 return true; | |
7199 } | |
7200 } | |
7201 //----- (0043EDB9) -------------------------------------------------------- | |
7202 bool ShouldLoadTexturesForRaceAndGender(unsigned int _this) | |
7203 { | |
7204 CHARACTER_RACE race; // edi@2 | |
7205 PLAYER_SEX sex; // eax@2 | |
7206 | |
7207 for (int i = 1; i <= 4; i++) | |
7208 { | |
7209 race = pPlayers[i]->GetRace(); | |
7210 sex = pPlayers[i]->GetSexByVoice(); | |
7211 switch(_this) | |
7212 { | |
7213 case 0: | |
7214 if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_MALE ) | |
7215 return true; | |
7216 break; | |
7217 case 1: | |
7218 if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_FEMALE ) | |
7219 return true; | |
7220 break; | |
7221 case 2: | |
7222 if ( race == CHARACTER_RACE_DWARF && sex == SEX_MALE ) | |
7223 return true; | |
7224 break; | |
7225 case 3: | |
7226 if ( race == CHARACTER_RACE_DWARF && sex == SEX_FEMALE ) | |
7227 return true; | |
7228 break; | |
7229 } | |
7230 } | |
7231 return false; | |
7232 } | |
7233 | |
7234 //----- (0043ED6F) -------------------------------------------------------- | |
7235 bool IsDwarfPresentInParty(bool a1) | |
7236 { | |
7237 for (uint i = 0; i < 4; ++i) | |
7238 { | |
7239 CHARACTER_RACE race = pParty->pPlayers[i].GetRace(); | |
7240 | |
7241 if (race == CHARACTER_RACE_DWARF && a1) | |
7242 return true; | |
7243 else if (race != CHARACTER_RACE_DWARF && !a1) | |
7244 return true; | |
7245 } | |
7246 return false; | |
7247 } | |
7248 | |
7249 //----- (00439FCB) -------------------------------------------------------- | |
7250 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int dmgSource, Vec3_int_ *pPos, signed int a4) | |
7251 { | |
7252 Player *playerPtr; // ebx@3 | |
7253 Actor *actorPtr; // esi@3 | |
7254 int spellId; // eax@38 | |
7255 signed int recvdMagicDmg; // eax@139 | |
7256 int v72[4]; // [sp+30h] [bp-24h]@164 | |
7257 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3 | |
7258 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 | |
7259 | |
7260 uActorID = PID_ID(uObjID); | |
7261 if ( PID_TYPE(uObjID) != 2) | |
7262 { | |
7263 playerPtr = &pParty->pPlayers[a4]; | |
7264 actorPtr = &pActors[uActorID]; | |
7265 healthBeforeRecvdDamage = playerPtr->sHealth; | |
7266 if ( PID_TYPE(uObjID) != 3 || !actorPtr->ActorHitOrMiss(playerPtr) ) | |
7267 return; | |
7268 ItemGen* equippedArmor = playerPtr->GetArmorItem(); | |
7269 SoundID soundToPlay; | |
7270 if ( !equippedArmor | |
7271 || equippedArmor->IsBroken() | |
7272 || | |
7273 (equippedArmor->GetPlayerSkillType() != PLAYER_SKILL_CHAIN | |
7274 && equippedArmor->GetPlayerSkillType() != PLAYER_SKILL_PLATE | |
7275 ) | |
7276 ) | |
7277 { | |
7278 int randVal = rand() % 4; | |
7279 switch (randVal) | |
7280 { | |
7281 case 0 : soundToPlay = (SoundID)108; break; | |
7282 case 1 : soundToPlay = (SoundID)109; break; | |
7283 case 2 : soundToPlay = (SoundID)110; break; | |
7284 case 3 : soundToPlay = (SoundID)44; break; | |
7285 default: Error("Unexpected sound value"); | |
7286 } | |
7287 } | |
7288 else | |
7289 { | |
7290 int randVal = rand() % 4; | |
7291 switch (randVal) | |
7292 { | |
7293 case 0 : soundToPlay = (SoundID)105; break; | |
7294 case 1 : soundToPlay = (SoundID)106; break; | |
7295 case 2 : soundToPlay = (SoundID)107; break; | |
7296 case 3 : soundToPlay = (SoundID)45; break; | |
7297 default: Error("Unexpected sound value"); | |
7298 } | |
7299 } | |
7300 pAudioPlayer->PlaySound(soundToPlay, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0); | |
7301 int dmgToReceive = actorPtr->_43B3E0_CalcDamage(dmgSource); | |
7302 if ( actorPtr->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 ) | |
7303 { | |
7304 __int16 spellPower = actorPtr->pActorBuffs[ACTOR_BUFF_SHRINK].uPower; | |
7305 if ( spellPower ) | |
7306 dmgToReceive /= (signed int)spellPower; | |
7307 } | |
7308 int damageType; | |
7309 switch (dmgSource) | |
7310 { | |
7311 case 0: damageType = actorPtr->pMonsterInfo.uAttack1Type; | |
7312 break; | |
7313 case 1: damageType = actorPtr->pMonsterInfo.uAttack2Type; | |
7314 break; | |
7315 case 2: spellId = actorPtr->pMonsterInfo.uSpell1ID; | |
7316 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); | |
7317 break; | |
7318 case 3: spellId = actorPtr->pMonsterInfo.uSpell2ID; | |
7319 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); | |
7320 break; | |
7321 case 4: damageType = actorPtr->pMonsterInfo.field_3C_some_special_attack; | |
7322 break; | |
7323 default: | |
7324 case 5: damageType = 4; //yes, the original just assigned the value 4 | |
7325 break; | |
7326 } | |
7327 if ( !(dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DAMAGE) ) | |
7328 { | |
7329 dmgToReceive = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType); | |
7330 if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime > 0 ) | |
7331 { | |
7332 int actorState = actorPtr->uAIState; | |
7333 if ( actorState != Dying && actorState != Dead) | |
7334 { | |
7335 int reflectedDamage = actorPtr->CalcMagicalDamageToActor((DAMAGE_TYPE)damageType, dmgToReceive); | |
7336 actorPtr->sCurrentHP -= reflectedDamage; | |
7337 if ( reflectedDamage >= 0 ) | |
7338 { | |
7339 if ( actorPtr->sCurrentHP >= 1 ) | |
7340 { | |
7341 Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); //todo extract this branch to a function once Actor::functions are changed to nonstatic actor functions | |
7342 Actor::AggroSurroundingPeasants(uActorID, 1); | |
7343 } | |
7344 else | |
7345 { | |
7346 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS) | |
7347 { | |
7348 int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; | |
7349 pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0); | |
7350 } | |
7351 Actor::Die(uActorID); | |
7352 Actor::ApplyFineForKillingPeasant(uActorID); | |
7353 Actor::AggroSurroundingPeasants(uActorID, 1); | |
7354 if ( actorPtr->pMonsterInfo.uExp ) | |
7355 pParty->GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); | |
7356 int speechToPlay = SPEECH_51; | |
7357 if ( rand() % 100 < 20 ) | |
7358 speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1; | |
7359 playerPtr->PlaySound((PlayerSpeech)speechToPlay, 0); | |
7360 } | |
7361 } | |
7362 } | |
7363 } | |
7364 if ( !(dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DAMAGE) | |
7365 && actorPtr->pMonsterInfo.uSpecialAttackType | |
7366 && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackLevel ) | |
7367 { | |
7368 playerPtr->ReceiveSpecialAttackEffect(actorPtr->pMonsterInfo.uSpecialAttackType, actorPtr); | |
7369 } | |
7370 } | |
7371 if ( !pParty->bTurnBasedModeOn ) | |
7372 { | |
7373 int actEndurance = playerPtr->GetActualEndurance(); | |
7374 int recoveryTime = (int)((20 - playerPtr->GetParameterBonus(actEndurance)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333); | |
7375 playerPtr->SetRecoveryTime(recoveryTime); | |
7376 } | |
7377 int yellThreshold = playerPtr->GetMaxHealth() / 4; | |
7378 if ( yellThreshold < playerPtr->sHealth && yellThreshold >= healthBeforeRecvdDamage && playerPtr->sHealth > 0 ) | |
7379 { | |
7380 playerPtr->PlaySound(SPEECH_48, 0); | |
7381 } | |
7382 viewparams->bRedrawGameUI = 1; | |
7383 return; | |
7384 } | |
7385 else | |
7386 { | |
7387 SpriteObject* v37 = &pSpriteObjects[uActorID]; | |
7388 int uActorType = PID_TYPE(v37->spell_caster_pid); | |
7389 int uActorID = PID_ID(v37->spell_caster_pid); | |
7390 if ( uActorType == 2 ) | |
7391 { | |
7392 Player *playerPtr; // eax@81 | |
7393 if ( a4 != -1 ) | |
7394 { | |
7395 playerPtr = &pParty->pPlayers[a4]; | |
7396 } | |
7397 else | |
7398 { | |
7399 int activePlayerCounter = 0; | |
7400 for (int i = 1; i <= 4; i++) | |
7401 { | |
7402 if (pPlayers[i]->CanAct()) | |
7403 { | |
7404 v72[activePlayerCounter] = i; | |
7405 activePlayerCounter++; | |
7406 } | |
7407 } | |
7408 if ( activePlayerCounter ) | |
7409 { | |
7410 playerPtr = &pParty->pPlayers[v72[rand() % activePlayerCounter] - 1];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552]; | |
7411 } | |
7412 } | |
7413 int v68; | |
7414 int v69; | |
7415 if ( uActorType != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW) | |
7416 { | |
7417 int playerMaxHp = playerPtr->GetMaxHealth(); | |
7418 v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, playerMaxHp); | |
7419 v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool); | |
7420 } | |
7421 else | |
7422 { | |
7423 v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0); | |
7424 v69 = 0; | |
7425 } | |
7426 playerPtr->ReceiveDamage(v68, (DAMAGE_TYPE)v69); | |
7427 if ( uActorType == OBJECT_Player && !_A750D8_player_speech_timer ) | |
7428 { | |
7429 _A750D8_player_speech_timer = 256i64; | |
7430 PlayerSpeechID = SPEECH_44; | |
7431 uSpeakingCharacter = uActorID + 1; | |
7432 } | |
7433 return; | |
7434 } | |
7435 else if ( uActorType == 3 ) | |
7436 { | |
7437 Actor *actorPtr = &pActors[uActorID]; | |
7438 if ( a4 == -1 ) | |
7439 a4 = stru_50C198.which_player_to_attack(actorPtr); | |
7440 Player *playerPtr = &pParty->pPlayers[a4]; | |
7441 int dmgToReceive = actorPtr->_43B3E0_CalcDamage(dmgSource); | |
7442 unsigned __int16 spriteType = v37->uType; | |
7443 if ( v37->uType == 545 ) | |
7444 { | |
7445 __int16 skillLevel = playerPtr->GetActualSkillLevel(PLAYER_SKILL_UNARMED); | |
7446 if ( SkillToMastery(skillLevel) >= 4 && rand() % 100 < (skillLevel & 0x3F) ) | |
7447 { | |
7448 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[637], playerPtr->pName); | |
7449 ShowStatusBarString(pTmpBuf.data(), 2u); | |
7450 playerPtr->PlaySound(SPEECH_6, 0); | |
7451 return; | |
7452 } | |
7453 } | |
7454 else if ( spriteType == 555 | |
7455 || spriteType == 510 | |
7456 || spriteType == 500 | |
7457 || spriteType == 515 | |
7458 || spriteType == 505 | |
7459 || spriteType == 530 | |
7460 || spriteType == 525 | |
7461 || spriteType == 520 | |
7462 || spriteType == 535 | |
7463 || spriteType == 540 ) | |
7464 { | |
7465 if ( !actorPtr->ActorHitOrMiss(playerPtr) ) | |
7466 return; | |
7467 if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime > 0 ) | |
7468 dmgToReceive >>= 1; | |
7469 if ( playerPtr->HasEnchantedItemEquipped(36) ) | |
7470 dmgToReceive >>= 1; | |
7471 if ( playerPtr->HasEnchantedItemEquipped(69) ) | |
7472 dmgToReceive >>= 1; | |
7473 if ( playerPtr->HasItemEquipped(EQUIP_ARMOUR) | |
7474 && playerPtr->GetArmorItem()->uItemID == ITEM_ARTIFACT_GOVERNORS_ARMOR ) | |
7475 dmgToReceive >>= 1; | |
7476 if ( playerPtr->HasItemEquipped(EQUIP_TWO_HANDED)) | |
7477 { | |
7478 ItemGen* mainHandItem = playerPtr->GetMainHandItem(); | |
7479 if ( mainHandItem->uItemID == ITEM_RELIC_KELEBRIM || mainHandItem->uItemID == ITEM_ARTIFACT_ELFBANE || (mainHandItem->GetItemEquipType() == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) | |
7480 dmgToReceive >>= 1; | |
7481 } | |
7482 if ( playerPtr->HasItemEquipped(EQUIP_SINGLE_HANDED)) | |
7483 { | |
7484 ItemGen* offHandItem = playerPtr->GetOffHandItem(); | |
7485 if ( offHandItem->uItemID == ITEM_RELIC_KELEBRIM || offHandItem->uItemID == ITEM_ARTIFACT_ELFBANE || (offHandItem->GetItemEquipType() == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) | |
7486 dmgToReceive >>= 1; | |
7487 } | |
7488 } | |
7489 if ( actorPtr->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 ) | |
7490 { | |
7491 int spellPower = actorPtr->pActorBuffs[ACTOR_BUFF_SHRINK].uPower; | |
7492 if ( spellPower ) | |
7493 dmgToReceive /= (signed int)spellPower; | |
7494 } | |
7495 int damageType; | |
7496 switch(dmgSource) | |
7497 { | |
7498 case 0: | |
7499 damageType = actorPtr->pMonsterInfo.uAttack1Type; | |
7500 break; | |
7501 case 1: | |
7502 damageType = actorPtr->pMonsterInfo.uAttack2Type; | |
7503 break; | |
7504 case 2: | |
7505 spellId = actorPtr->pMonsterInfo.uSpell1ID; | |
7506 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); | |
7507 break; | |
7508 case 3: | |
7509 spellId = actorPtr->pMonsterInfo.uSpell2ID; | |
7510 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); | |
7511 break; | |
7512 case 4: | |
7513 damageType = actorPtr->pMonsterInfo.field_3C_some_special_attack; | |
7514 break; | |
7515 case 5: | |
7516 damageType = 4; | |
7517 break; | |
7518 } | |
7519 if ( !(dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DAMAGE) ) | |
7520 { | |
7521 int reflectedDmg = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType); | |
7522 if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime > 0 ) | |
7523 { | |
7524 unsigned __int16 actorState = actorPtr->uAIState; | |
7525 if ( actorState != Dying && actorState != Dead) | |
7526 { | |
7527 recvdMagicDmg = actorPtr->CalcMagicalDamageToActor((DAMAGE_TYPE)damageType, reflectedDmg); | |
7528 actorPtr->sCurrentHP -= recvdMagicDmg; | |
7529 if ( recvdMagicDmg >= 0 ) | |
7530 { | |
7531 if ( actorPtr->sCurrentHP >= 1 ) | |
7532 { | |
7533 Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); | |
7534 Actor::AggroSurroundingPeasants(uActorID, 1); | |
7535 } | |
7536 else | |
7537 { | |
7538 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) | |
7539 { | |
7540 int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; | |
7541 pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0); | |
7542 } | |
7543 Actor::Die(uActorID); | |
7544 Actor::ApplyFineForKillingPeasant(uActorID); | |
7545 Actor::AggroSurroundingPeasants(uActorID, 1); | |
7546 if ( actorPtr->pMonsterInfo.uExp ) | |
7547 pParty->GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); | |
7548 int speechToPlay = SPEECH_51; | |
7549 if ( rand() % 100 < 20 ) | |
7550 speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1; | |
7551 playerPtr->PlaySound((PlayerSpeech)speechToPlay, 0); | |
7552 } | |
7553 } | |
7554 } | |
7555 } | |
7556 } | |
7557 if ( !dmgSource | |
7558 && !(dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DAMAGE) | |
7559 && actorPtr->pMonsterInfo.uSpecialAttackType | |
7560 && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackLevel ) | |
7561 { | |
7562 playerPtr->ReceiveSpecialAttackEffect(actorPtr->pMonsterInfo.uSpecialAttackType, actorPtr); | |
7563 } | |
7564 if ( !pParty->bTurnBasedModeOn ) | |
7565 { | |
7566 int actEnd = playerPtr->GetActualEndurance(); | |
7567 int recTime = (int)((20 - playerPtr->GetParameterBonus(actEnd)) | |
7568 * flt_6BE3A4_debug_recmod1 | |
7569 * 2.133333333333333); | |
7570 playerPtr->SetRecoveryTime(recTime); | |
7571 } | |
7572 return; | |
7573 } | |
7574 else | |
7575 { | |
7576 return; | |
7577 } | |
7578 } | |
7579 } | |
7580 //----- (00421EA6) -------------------------------------------------------- | |
7581 void Player::OnInventoryLeftClick() | |
7582 { | |
7583 signed int inventoryXCoord; // ecx@2 | |
7584 int inventoryYCoord; // eax@2 | |
7585 int invMatrixIndex; // eax@2 | |
7586 unsigned int enchantedItemPos; // eax@7 | |
7587 unsigned int pickedItemId; // esi@12 | |
7588 unsigned int invItemIndex; // eax@12 | |
7589 unsigned int itemPos; // eax@18 | |
7590 ItemGen tmpItem; // [sp+Ch] [bp-3Ch]@1 | |
7591 unsigned int pY; // [sp+3Ch] [bp-Ch]@2 | |
7592 unsigned int pX; // [sp+40h] [bp-8h]@2 | |
7593 CastSpellInfo *pSpellInfo; | |
7594 | |
7595 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 ) | |
7596 { | |
7597 pMouse->GetClickPos(&pX, &pY); | |
7598 inventoryYCoord = (pY - 17) / 32; | |
7599 inventoryXCoord = (pX - 14) / 32; | |
7600 invMatrixIndex = inventoryXCoord + (INVETORYSLOTSWIDTH * inventoryYCoord); | |
7601 if ( inventoryYCoord >= 0 && inventoryYCoord < INVETORYSLOTSHEIGHT && inventoryXCoord >= 0 && inventoryXCoord < INVETORYSLOTSWIDTH) | |
7602 { | |
7603 if ( _50C9A0_IsEnchantingInProgress ) | |
7604 { | |
7605 enchantedItemPos = this->GetItemIDAtInventoryIndex(&invMatrixIndex); | |
7606 if ( enchantedItemPos ) | |
7607 { | |
7608 /* *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; | |
7609 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; | |
7610 *((int *)pGUIWindow_Settings->ptr_1C + 3) = enchantedItemPos - 1; | |
7611 *((short *)pGUIWindow_Settings->ptr_1C + 3) = invMatrixIndex;*/ | |
7612 pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; | |
7613 pSpellInfo->uFlags &= 0x7F; | |
7614 pSpellInfo->uPlayerID_2 = uActiveCharacter - 1; | |
7615 pSpellInfo->spell_target_pid = enchantedItemPos - 1; | |
7616 pSpellInfo->field_6 = invMatrixIndex; | |
7617 ptr_50C9A4_ItemToEnchant = &this->pInventoryItemList[enchantedItemPos-1]; | |
7618 _50C9A0_IsEnchantingInProgress = 0; | |
7619 if ( pMessageQueue_50CBD0->uNumMessages ) | |
7620 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
7621 pMouse->SetCursorBitmap("MICON1"); | |
7622 _50C9D0_AfterEnchClickEventId = 113; | |
7623 _50C9D4_AfterEnchClickEventSecondParam = 0; | |
7624 _50C9D8_AfterEnchClickEventTimeout = 256; | |
7625 } | |
7626 return; | |
7627 } | |
7628 if ( ptr_50C9A4_ItemToEnchant ) | |
7629 return; | |
7630 pickedItemId = pParty->pPickedItem.uItemID; | |
7631 invItemIndex = this->GetItemIDAtInventoryIndex(&invMatrixIndex); | |
7632 if (!pickedItemId) | |
7633 { | |
7634 if ( !invItemIndex ) | |
7635 return; | |
7636 else | |
7637 { | |
7638 memcpy(&pParty->pPickedItem, &this->pInventoryItemList[invItemIndex-1], sizeof(pParty->pPickedItem)); | |
7639 this->RemoveItemAtInventoryIndex(invMatrixIndex); | |
7640 pickedItemId = pParty->pPickedItem.uItemID; | |
7641 pMouse->SetCursorBitmap(pItemsTable->pItems[pickedItemId].pIconName); | |
7642 return; | |
7643 } | |
7644 } | |
7645 else | |
7646 { | |
7647 if ( invItemIndex ) | |
7648 { | |
7649 ItemGen* invItemPtr = &this->pInventoryItemList[invItemIndex-1]; | |
7650 memcpy(&tmpItem, invItemPtr, sizeof(tmpItem)); | |
7651 this->RemoveItemAtInventoryIndex(invMatrixIndex); | |
7652 int emptyIndex = this->AddItem2(invMatrixIndex, &pParty->pPickedItem); | |
7653 if ( !emptyIndex ) | |
7654 { | |
7655 emptyIndex = this->AddItem2(-1, &pParty->pPickedItem); | |
7656 if ( !emptyIndex ) | |
7657 { | |
7658 this->PutItemArInventoryIndex(tmpItem.uItemID, invItemIndex - 1, invMatrixIndex); | |
7659 memcpy(invItemPtr, &tmpItem, sizeof(ItemGen)); | |
7660 return; | |
7661 } | |
7662 } | |
7663 memcpy(&pParty->pPickedItem, &tmpItem, sizeof(ItemGen)); | |
7664 pMouse->SetCursorBitmap(pParty->pPickedItem.GetIconName()); | |
7665 return; | |
7666 } | |
7667 else | |
7668 { | |
7669 itemPos = this->AddItem(invMatrixIndex, pickedItemId); | |
7670 if ( itemPos ) | |
7671 { | |
7672 memcpy(&this->pInventoryItemList[itemPos-1], &pParty->pPickedItem, sizeof(ItemGen)); | |
7673 pMouse->RemoveHoldingItem(); | |
7674 return; | |
7675 } | |
7676 itemPos = this->AddItem(-1, pickedItemId); | |
7677 if ( itemPos ) | |
7678 { | |
7679 memcpy(&this->pInventoryItemList[itemPos-1], &pParty->pPickedItem, sizeof(ItemGen)); | |
7680 pMouse->RemoveHoldingItem(); | |
7681 return; | |
7682 } | |
7683 } | |
7684 } | |
7685 } | |
7686 } | |
7687 } | |
7688 | |
7689 | |
7690 bool Player::IsWeak() | |
7691 { | |
7692 return pConditions[Condition_Weak] != 0; | |
7693 } | |
7694 | |
7695 bool Player::IsDead() | |
7696 { | |
7697 return pConditions[Condition_Dead] != 0; | |
7698 } | |
7699 | |
7700 bool Player::IsEradicated() | |
7701 { | |
7702 return pConditions[Condition_Eradicated] != 0; | |
7703 } | |
7704 | |
7705 bool Player::IsZombie() | |
7706 { | |
7707 return pConditions[Condition_Zombie] != 0; | |
7708 } | |
7709 | |
7710 bool Player::IsCursed() | |
7711 { | |
7712 return pConditions[Condition_Cursed] != 0; | |
7713 } | |
7714 | |
7715 bool Player::IsPertified() | |
7716 { | |
7717 return pConditions[Condition_Pertified] != 0; | |
7718 } | |
7719 | |
7720 bool Player::IsUnconcious() | |
7721 { | |
7722 return pConditions[Condition_Unconcious] != 0; | |
7723 } | |
7724 | |
7725 bool Player::IsAsleep() | |
7726 { | |
7727 return pConditions[Condition_Sleep] != 0; | |
7728 } | |
7729 | |
7730 bool Player::IsParalyzed() | |
7731 { | |
7732 return pConditions[Condition_Paralyzed] != 0; | |
7733 } | |
7734 | |
7735 bool Player::IsDrunk() | |
7736 { | |
7737 return pConditions[Condition_Drunk] != 0; | |
7738 } | |
7739 | |
7740 void Player::SetCursed( unsigned long long state ) | |
7741 { | |
7742 pConditions[Condition_Cursed] = state; | |
7743 } | |
7744 | |
7745 void Player::SetWeak( unsigned long long state ) | |
7746 { | |
7747 pConditions[Condition_Weak] = state; | |
7748 } | |
7749 | |
7750 void Player::SetAsleep( unsigned long long state ) | |
7751 { | |
7752 pConditions[Condition_Sleep] = state; | |
7753 } | |
7754 | |
7755 void Player::SetAfraid( unsigned long long state ) | |
7756 { | |
7757 pConditions[Condition_Fear] = state; | |
7758 } | |
7759 | |
7760 void Player::SetDrunk( unsigned long long state ) | |
7761 { | |
7762 pConditions[Condition_Drunk] = state; | |
7763 } | |
7764 | |
7765 void Player::SetInsane( unsigned long long state ) | |
7766 { | |
7767 pConditions[Condition_Insane] = state; | |
7768 } | |
7769 | |
7770 void Player::SetPoisonWeak( unsigned long long state ) | |
7771 { | |
7772 pConditions[Condition_Poison_Weak] = state; | |
7773 } | |
7774 | |
7775 void Player::SetDiseaseWeak( unsigned long long state ) | |
7776 { | |
7777 pConditions[Condition_Disease_Weak] = state; | |
7778 } | |
7779 | |
7780 void Player::SetPoisonMedium( unsigned long long state ) | |
7781 { | |
7782 pConditions[Condition_Poison_Medium] = state; | |
7783 } | |
7784 | |
7785 void Player::SetDiseaseMedium( unsigned long long state ) | |
7786 { | |
7787 pConditions[Condition_Disease_Medium] = state; | |
7788 } | |
7789 | |
7790 void Player::SetPoisonSevere( unsigned long long state ) | |
7791 { | |
7792 pConditions[Condition_Poison_Severe] = state; | |
7793 } | |
7794 | |
7795 void Player::SetDiseaseSevere( unsigned long long state ) | |
7796 { | |
7797 pConditions[Condition_Disease_Severe] = state; | |
7798 } | |
7799 | |
7800 void Player::SetParalyzed( unsigned long long state ) | |
7801 { | |
7802 pConditions[Condition_Paralyzed] = state; | |
7803 } | |
7804 | |
7805 void Player::SetUnconcious( unsigned long long state ) | |
7806 { | |
7807 pConditions[Condition_Unconcious] = state; | |
7808 } | |
7809 | |
7810 void Player::SetDead( unsigned long long state ) | |
7811 { | |
7812 pConditions[Condition_Dead] = state; | |
7813 } | |
7814 | |
7815 void Player::SetPertified( unsigned long long state ) | |
7816 { | |
7817 pConditions[Condition_Pertified] = state; | |
7818 } | |
7819 | |
7820 void Player::SetEradicated( unsigned long long state ) | |
7821 { | |
7822 pConditions[Condition_Eradicated] = state; | |
7823 } | |
7824 | |
7825 void Player::SetZombie( unsigned long long state ) | |
7826 { | |
7827 pConditions[Condition_Zombie] = state; | |
7828 } | |
7829 | |
7830 void Player::SetCondWeakWithBlockCheck( int blockable ) | |
7831 { | |
7832 SetCondition(Condition_Weak, blockable); | |
7833 } | |
7834 | |
7835 void Player::SetCondInsaneWithBlockCheck( int blockable ) | |
7836 { | |
7837 SetCondition(Condition_Insane, blockable); | |
7838 } | |
7839 | |
7840 void Player::SetCondDeadWithBlockCheck( int blockable ) | |
7841 { | |
7842 SetCondition(Condition_Dead, blockable); | |
7843 } | |
7844 | |
7845 void Player::SetCondUnconsciousWithBlockCheck( int blockable ) | |
7846 { | |
7847 SetCondition(Condition_Dead, blockable); | |
7848 } | |
7849 | |
7850 ItemGen* Player::GetOffHandItem() | |
7851 { | |
7852 return GetItem(&PlayerEquipment::uShield); | |
7853 } | |
7854 | |
7855 ItemGen* Player::GetMainHandItem() | |
7856 { | |
7857 return GetItem(&PlayerEquipment::uMainHand); | |
7858 } | |
7859 | |
7860 ItemGen* Player::GetBowItem() | |
7861 { | |
7862 return GetItem(&PlayerEquipment::uBow); | |
7863 } | |
7864 | |
7865 ItemGen* Player::GetArmorItem() | |
7866 { | |
7867 return GetItem(&PlayerEquipment::uArmor); | |
7868 } | |
7869 | |
7870 ItemGen* Player::GetHelmItem() | |
7871 { | |
7872 return GetItem(&PlayerEquipment::uHelm); | |
7873 } | |
7874 | |
7875 ItemGen* Player::GetBeltItem() | |
7876 { | |
7877 return GetItem(&PlayerEquipment::uBelt); | |
7878 } | |
7879 | |
7880 ItemGen* Player::GetCloakItem() | |
7881 { | |
7882 return GetItem(&PlayerEquipment::uCloak); | |
7883 } | |
7884 | |
7885 ItemGen* Player::GetGloveItem() | |
7886 { | |
7887 return GetItem(&PlayerEquipment::uGlove); | |
7888 } | |
7889 | |
7890 ItemGen* Player::GetBootItem() | |
7891 { | |
7892 return GetItem(&PlayerEquipment::uBoot); | |
7893 } | |
7894 | |
7895 ItemGen* Player::GetAmuletItem() | |
7896 { | |
7897 return GetItem(&PlayerEquipment::uAmulet); | |
7898 } | |
7899 | |
7900 ItemGen* Player::GetNthRingItem(int ringNum) | |
7901 { | |
7902 return GetNthEquippedIndexItem(ringNum + 10); | |
7903 } | |
7904 | |
7905 ItemGen* Player::GetNthEquippedIndexItem(int index) | |
7906 { | |
7907 if (this->pEquipment.pIndices[index] == 0) | |
7908 { | |
7909 return nullptr; | |
7910 } | |
7911 return &this->pInventoryItemList[this->pEquipment.pIndices[index] - 1]; | |
7912 } | |
7913 | |
7914 ItemGen* Player::GetItem(unsigned int PlayerEquipment::* itemPos) | |
7915 { | |
7916 if (this->pEquipment.*itemPos == 0) | |
7917 { | |
7918 return nullptr; | |
7919 } | |
7920 return &this->pInventoryItemList[this->pEquipment.*itemPos - 1]; | |
7921 } | |
7922 | |
7923 int Player::GetPlayerIndex() | |
7924 { | |
7925 int uPlayerIdx = 0; | |
7926 if ( this == pPlayers[1] ) | |
7927 uPlayerIdx = 0; | |
7928 else if( this == pPlayers[2] ) | |
7929 uPlayerIdx = 1; | |
7930 else if ( this == pPlayers[3] ) | |
7931 uPlayerIdx = 2; | |
7932 else if ( this == pPlayers[4] ) | |
7933 uPlayerIdx = 3; | |
7934 else | |
7935 Error("Unexpected player pointer"); | |
7936 return uPlayerIdx; | |
7937 } | |
7938 | |
7939 //----- (004272F5) -------------------------------------------------------- | |
7940 bool Player::PlayerHitOrMiss(Actor *pActor, int a3, int a4) | |
7941 { | |
7942 signed int naturalArmor; // esi@1 | |
7943 signed int armorBuff; // edi@1 | |
7944 int effectiveActorArmor; // esi@8 | |
7945 int attBonus; // eax@9 | |
7946 int v9; // edx@11 | |
7947 // unsigned __int8 v12; // sf@13 | |
7948 // unsigned __int8 v13; // of@13 | |
7949 int attPositiveMod; // edx@14 | |
7950 int attNegativeMod; // eax@14 | |
7951 // signed int result; // eax@17 | |
7952 | |
7953 naturalArmor = pActor->pMonsterInfo.uAC; | |
7954 armorBuff = 0; | |
7955 if ( pActor->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime > 0 ) | |
7956 naturalArmor /= 2; | |
7957 if ( pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) | |
7958 armorBuff = pActor->pActorBuffs[ACTOR_BUFF_SHIELD].uPower; | |
7959 if ( pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uExpireTime > 0 && pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower > armorBuff ) | |
7960 armorBuff = pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower; | |
7961 effectiveActorArmor = armorBuff + naturalArmor; | |
7962 if ( a3 ) | |
7963 attBonus = this->GetRangedAttack(); | |
7964 else | |
7965 attBonus = this->GetActualAttack(false); | |
7966 v9 = rand() % (effectiveActorArmor + 2 * attBonus + 30); | |
7967 attPositiveMod = a4 + v9; | |
7968 if ( a3 == 2 ) | |
7969 { | |
7970 attNegativeMod = ((effectiveActorArmor + 15) / 2) + effectiveActorArmor + 15; | |
7971 } | |
7972 else if ( a3 == 3 ) | |
7973 { | |
7974 attNegativeMod = 2 * effectiveActorArmor + 30; | |
7975 } | |
7976 else | |
7977 { | |
7978 attNegativeMod = effectiveActorArmor + 15; | |
7979 } | |
7980 return (attPositiveMod > attNegativeMod); | |
7981 } | |
7982 | |
7983 | |
7984 //----- (0042ECB5) -------------------------------------------------------- | |
7985 void Player::_42ECB5_PlayerAttacksActor() | |
7986 { | |
7987 // char *v5; // eax@8 | |
7988 // unsigned int v9; // ecx@21 | |
7989 // char *v11; // eax@26 | |
7990 // unsigned int v12; // eax@47 | |
7991 // SoundID v24; // [sp-4h] [bp-40h]@58 | |
7992 | |
7993 //result = pParty->pPlayers[uActiveCharacter-1].CanAct(); | |
7994 Player* player = &pParty->pPlayers[uActiveCharacter - 1]; | |
7995 if (!player->CanAct()) | |
7996 return; | |
7997 | |
7998 CastSpellInfoHelpers::_427D48(); | |
7999 //v3 = 0; | |
8000 if (pParty->Invisible()) | |
8001 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
8002 | |
8003 //v31 = player->pEquipment.uBow; | |
8004 int bow_idx = player->pEquipment.uBow; | |
8005 if (bow_idx && player->pInventoryItemList[bow_idx - 1].IsBroken()) | |
8006 bow_idx = 0; | |
8007 | |
8008 //v32 = 0; | |
8009 int wand_item_id = 0; | |
8010 //v33 = 0; | |
8011 //v4 = v1->pEquipment.uMainHand; | |
8012 int laser_weapon_item_id = 0; | |
8013 | |
8014 int main_hand_idx = player->pEquipment.uMainHand; | |
8015 if (main_hand_idx) | |
8016 { | |
8017 ItemGen* item = &player->pInventoryItemList[main_hand_idx - 1]; | |
8018 //v5 = (char *)v1 + 36 * v4; | |
8019 if (!item->IsBroken()) | |
8020 { | |
8021 //v28b = &v1->pInventoryItems[v4].uItemID; | |
8022 //v6 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124); | |
8023 if (item->GetItemEquipType() == EQUIP_WAND) | |
8024 { | |
8025 if (item->uNumCharges <= 0) | |
8026 player->pEquipment.uMainHand = 0; // wand discharged - unequip | |
8027 else | |
8028 wand_item_id = item->uItemID;//*((int *)v5 + 124); | |
8029 } | |
8030 else if (item->uItemID == ITEM_BLASTER || item->uItemID == ITEM_LASER_RIFLE) | |
8031 laser_weapon_item_id = item->uItemID;//*((int *)v5 + 124); | |
8032 } | |
8033 } | |
8034 | |
8035 //v30 = 0; | |
8036 //v29 = 0; | |
8037 //v28 = 0; | |
8038 //v7 = pMouse->uPointingObjectID; | |
8039 | |
8040 int target_pid = pMouse->uPointingObjectID; | |
8041 int target_type = PID_TYPE(target_pid), | |
8042 target_id = PID_ID(target_pid); | |
8043 if (target_type != OBJECT_Actor || !pActors[target_id].CanAct()) | |
8044 { | |
8045 target_pid = stru_50C198.FindClosestActor(5120, 0, 0); | |
8046 target_type = PID_TYPE(target_pid); | |
8047 target_id = PID_ID(target_pid); | |
8048 } | |
8049 | |
8050 Actor* actor = &pActors[target_id]; | |
8051 int actor_distance = 0; | |
8052 if (target_type == OBJECT_Actor) | |
8053 { | |
8054 int distance_x = actor->vPosition.x - pParty->vPosition.x, | |
8055 distance_y = actor->vPosition.y - pParty->vPosition.y, | |
8056 distance_z = actor->vPosition.z - pParty->vPosition.z; | |
8057 actor_distance = integer_sqrt(distance_x * distance_x + distance_y * distance_y + distance_z * distance_z) - actor->uActorRadius; | |
8058 if (actor_distance < 0) | |
8059 actor_distance = 0; | |
8060 } | |
8061 | |
8062 bool shooting_bow = false, | |
8063 shotting_laser = false, | |
8064 shooting_wand = false, | |
8065 melee_attack = false; | |
8066 if (laser_weapon_item_id) | |
8067 { | |
8068 shotting_laser = true; | |
8069 _42777D_CastSpell_UseWand_ShootArrow(SPELL_LASER_PROJECTILE, uActiveCharacter - 1, 0, 0, uActiveCharacter + 8); | |
8070 } | |
8071 else if (wand_item_id) | |
8072 { | |
8073 shooting_wand = true; | |
8074 | |
8075 int main_hand_idx = player->pEquipment.uMainHand; | |
8076 _42777D_CastSpell_UseWand_ShootArrow(wand_spell_ids[player->pInventoryItemList[main_hand_idx - 1].uItemID - ITEM_WAND_FIRE], uActiveCharacter - 1, 8, 0, uActiveCharacter + 8); | |
8077 | |
8078 if (!--player->pInventoryItemList[main_hand_idx - 1].uNumCharges) | |
8079 player->pEquipment.uMainHand = 0; | |
8080 } | |
8081 else if (target_type == OBJECT_Actor && actor_distance <= 407.2) | |
8082 { | |
8083 melee_attack = true; | |
8084 | |
8085 Vec3_int_ a3; | |
8086 a3.x = actor->vPosition.x - pParty->vPosition.x; | |
8087 a3.y = actor->vPosition.y - pParty->vPosition.y; | |
8088 a3.z = actor->vPosition.z - pParty->vPosition.z; | |
8089 Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z); | |
8090 | |
8091 Actor::DamageMonsterFromParty(PID(OBJECT_Player, uActiveCharacter - 1), target_id, &a3); | |
8092 if (player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_TWO_HANDED) || player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_SINGLE_HANDED)) | |
8093 _42FA66_do_explosive_impact(actor->vPosition.x, actor->vPosition.y, actor->vPosition.z + actor->uActorHeight / 2, 0, 512, uActiveCharacter); | |
8094 } | |
8095 else if (bow_idx) | |
8096 { | |
8097 shooting_bow = true; | |
8098 _42777D_CastSpell_UseWand_ShootArrow(SPELL_BOW_ARROW, uActiveCharacter - 1, 0, 0, 0); | |
8099 } | |
8100 else | |
8101 { | |
8102 melee_attack = true; | |
8103 ; // actor out of range or no actor; no ranged weapon so melee attacking air | |
8104 } | |
8105 | |
8106 if (!pParty->bTurnBasedModeOn && melee_attack) // wands, bows & lasers will add recovery while shooting spell effect | |
8107 { | |
8108 int recovery = player->GetAttackRecoveryTime(false); | |
8109 if (recovery < 30 ) | |
8110 recovery = 30; | |
8111 player->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * (double)recovery * 2.133333333333333); | |
8112 } | |
8113 | |
8114 int v34 = 0; | |
8115 if (shooting_wand) | |
8116 return; | |
8117 else if (shooting_bow) | |
8118 { | |
8119 v34 = 5; | |
8120 player->PlaySound(SPEECH_50, 0); | |
8121 } | |
8122 if (shotting_laser) | |
8123 v34 = 7; | |
8124 else | |
8125 { | |
8126 int main_hand_idx = player->pEquipment.uMainHand; | |
8127 if (player->HasItemEquipped(EQUIP_TWO_HANDED)) | |
8128 v34 = player->pInventoryItemList[main_hand_idx - 1].GetPlayerSkillType(); | |
8129 pTurnEngine->ApplyPlayerAction(); | |
8130 } | |
8131 | |
8132 switch (v34) | |
8133 { | |
8134 case 0: pAudioPlayer->PlaySound(SOUND_81, 0, 0, -1, 0, 0, 0, 0); break; | |
8135 case 1: pAudioPlayer->PlaySound(SOUND_84, 0, 0, -1, 0, 0, 0, 0); break; | |
8136 case 2: pAudioPlayer->PlaySound(SOUND_85, 0, 0, -1, 0, 0, 0, 0); break; | |
8137 case 3: pAudioPlayer->PlaySound(SOUND_78, 0, 0, -1, 0, 0, 0, 0); break; | |
8138 case 4: pAudioPlayer->PlaySound(SOUND_80, 0, 0, -1, 0, 0, 0, 0); break; | |
8139 case 5: pAudioPlayer->PlaySound(SOUND_71, 0, 0, -1, 0, 0, 0, 0); break; | |
8140 case 6: pAudioPlayer->PlaySound(SOUND_83, 0, 0, -1, 0, 0, 0, 0); break; | |
8141 case 7: pAudioPlayer->PlaySound(SOUND_67, 0, 0, -1, 0, 0, 0, 0); break; | |
8142 } | |
8143 } | |
8144 | |
8145 | |
8146 //----- (0042FA66) -------------------------------------------------------- | |
8147 void Player::_42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6) | |
8148 { | |
8149 unsigned __int16 v9; // ax@5 | |
8150 | |
8151 SpriteObject a1a; // [sp+Ch] [bp-74h]@1 | |
8152 //SpriteObject::SpriteObject(&a1a); | |
8153 a1a.uType = 600; | |
8154 a1a.stru_24.Reset(); | |
8155 | |
8156 a1a.spell_id = SPELL_FIRE_FIREBALL; | |
8157 a1a.spell_level = 8; | |
8158 a1a.spell_skill = 3; | |
8159 v9 = 0; | |
8160 for ( uint i = 0; i < pObjectList->uNumObjects; ++i ) | |
8161 { | |
8162 if ( a1a.uType == pObjectList->pObjects[i].uObjectID ) | |
8163 v9 = i; | |
8164 } | |
8165 a1a.uObjectDescID = v9; | |
8166 a1a.vPosition.x = a1; | |
8167 a1a.vPosition.y = a2; | |
8168 a1a.vPosition.z = a3; | |
8169 a1a.uAttributes = 0; | |
8170 a1a.uSectorID = pIndoor->GetSector(a1, a2, a3); | |
8171 a1a.uSpriteFrameID = 0; | |
8172 a1a.spell_target_pid = 0; | |
8173 a1a.field_60_distance_related_prolly_lod = 0; | |
8174 a1a.uFacing = 0; | |
8175 a1a.uSoundID = 0; | |
8176 if ( a6 >= 1 || a6 <= 4 ) | |
8177 a1a.spell_caster_pid = PID(OBJECT_Player, a6 - 1); | |
8178 else | |
8179 a1a.spell_caster_pid = 0; | |
8180 | |
8181 int id = a1a.Create(0, 0, 0, 0); | |
8182 if (id != -1) | |
8183 AttackerInfo.Add(PID(OBJECT_Item, id), a5, SLOWORD(a1a.vPosition.x), SLOWORD(a1a.vPosition.y), | |
8184 SLOWORD(a1a.vPosition.z), 0, 0); | |
8185 } | |
8186 | |
8187 //----- (00458244) -------------------------------------------------------- | |
8188 unsigned int SkillToMastery( unsigned int skill_value ) | |
8189 { | |
8190 switch (skill_value & 0x1C0) | |
8191 { | |
8192 case 0x100: return 4; // Grandmaster | |
8193 case 0x80: return 3; // Master | |
8194 case 0x40: return 2; // Expert | |
8195 case 0x00: return 1; // Normal | |
8196 } | |
8197 assert(false); | |
8198 return 0; | |
8199 } |