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