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