annotate Engine/Objects/Player.cpp @ 2524:c7264ab7132f

Main menu rendered using d3d11
author a.parshin
date Fri, 10 Oct 2014 17:42:05 +0300
parents 9b96a51011fb
children 1bcadc6dd203
rev   line source
2498
Ritor1
parents:
diff changeset
1 #define _CRTDBG_MAP_ALLOC
Ritor1
parents:
diff changeset
2 #include <stdlib.h>
Ritor1
parents:
diff changeset
3 #include <crtdbg.h>
Ritor1
parents:
diff changeset
4
Ritor1
parents:
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
Ritor1
parents:
diff changeset
6 #include "stru6.h"
Ritor1
parents:
diff changeset
7
2499
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
8 #include "../ErrorHandling.h"
2498
Ritor1
parents:
diff changeset
9
Ritor1
parents:
diff changeset
10 #include "Player.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
11 #include "../Tables/PlayerFrameTable.h"
2502
a77c34acdbc9 Media folder
Ritor1
parents: 2501
diff changeset
12 #include "Media/Audio/AudioPlayer.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
13 #include "../Party.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
14 #include "../LOD.h"
2502
a77c34acdbc9 Media folder
Ritor1
parents: 2501
diff changeset
15 #include "GUI/GUIWindow.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
16 #include "../Graphics/Viewport.h"
2498
Ritor1
parents:
diff changeset
17 #include "Actor.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
18 #include "../Game.h"
2502
a77c34acdbc9 Media folder
Ritor1
parents: 2501
diff changeset
19 #include "IO/Mouse.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
20 #include "../TurnEngine/TurnEngine.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
21 #include "../Events.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
22 #include "../Events2D.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
23 #include "../Graphics/Outdoor.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
24 #include "../Tables/StorylineTextTable.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
25 #include "../Autonotes.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
26 #include "../Awards.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
27 #include "../texts.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
28
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
29 #include "../stru123.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
30 #include "../stru298.h"
2498
Ritor1
parents:
diff changeset
31 #include "ObjectList.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
32 #include "../MM7.h"
2498
Ritor1
parents:
diff changeset
33 #include "SpriteObject.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
34 #include "../Graphics/DecalBuilder.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
35 #include "../Spells/CastSpellInfo.h"
68cdef6879a0 engine folder
Ritor1
parents: 2498
diff changeset
36 #include "../OurMath.h"
2501
0ff6a9e9bf7f GUI folger
Ritor1
parents: 2499
diff changeset
37 #include "..\..\GUI\UI\UIPartyCreation.h"
2498
Ritor1
parents:
diff changeset
38
Ritor1
parents:
diff changeset
39
Ritor1
parents:
diff changeset
40
Ritor1
parents:
diff changeset
41
Ritor1
parents:
diff changeset
42 NZIArray<struct Player *, 5> pPlayers;
Ritor1
parents:
diff changeset
43
Ritor1
parents:
diff changeset
44
Ritor1
parents:
diff changeset
45 /* 381 */
Ritor1
parents:
diff changeset
46 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
47 struct PlayerCreation_AttributeProps
Ritor1
parents:
diff changeset
48 {
Ritor1
parents:
diff changeset
49 unsigned __int8 uBaseValue;
Ritor1
parents:
diff changeset
50 char uMaxValue;
Ritor1
parents:
diff changeset
51 char uDroppedStep;
Ritor1
parents:
diff changeset
52 char uBaseStep;
Ritor1
parents:
diff changeset
53 };
Ritor1
parents:
diff changeset
54 #pragma pack(pop)
Ritor1
parents:
diff changeset
55
Ritor1
parents:
diff changeset
56
Ritor1
parents:
diff changeset
57 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
58
Ritor1
parents:
diff changeset
59
Ritor1
parents:
diff changeset
60
Ritor1
parents:
diff changeset
61 #pragma pack(pop)
Ritor1
parents:
diff changeset
62 PlayerCreation_AttributeProps StatTable[4][7] = //0x4ED7B0
Ritor1
parents:
diff changeset
63 {
Ritor1
parents:
diff changeset
64 {{11, 25, 1, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, { 9, 25, 1, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, {9, 25, 1, 1},},
Ritor1
parents:
diff changeset
65 {{ 7, 15, 2, 1}, {14, 30, 1, 2}, {11, 25, 1, 1}, { 7, 15, 2, 1}, {14, 30, 1, 2}, {11, 25, 1, 1}, {9, 20, 1, 1},},
Ritor1
parents:
diff changeset
66 {{14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, {9, 20, 1, 1},},
Ritor1
parents:
diff changeset
67 {{14, 30, 1, 2}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {9, 20, 1, 1}}
Ritor1
parents:
diff changeset
68 };
Ritor1
parents:
diff changeset
69
Ritor1
parents:
diff changeset
70
Ritor1
parents:
diff changeset
71
Ritor1
parents:
diff changeset
72 std::array<int, 5> StealingMasteryBonuses = {0, 100, 200, 300, 500}; //dword_4EDEA0 //the zeroth element isn't accessed, it just helps avoid -1 indexing, originally 4 element array off by one
Ritor1
parents:
diff changeset
73 std::array<int, 5> StealingRandomBonuses = {-200, -100, 0, 100, 200}; //dword_4EDEB4
Ritor1
parents:
diff changeset
74 std::array<int, 5> StealingEnchantmentBonusForSkill = {0, 2, 4, 6, 10}; //dword_4EDEC4 //the zeroth element isn't accessed, it just helps avoid -1 indexing, originally 4 element array off by one
Ritor1
parents:
diff changeset
75
Ritor1
parents:
diff changeset
76
Ritor1
parents:
diff changeset
77
Ritor1
parents:
diff changeset
78 // available skills per class ( 9 classes X 37 skills )
Ritor1
parents:
diff changeset
79 // 0 - not available
Ritor1
parents:
diff changeset
80 // 1 - available
Ritor1
parents:
diff changeset
81 // 2 - primary skill
Ritor1
parents:
diff changeset
82 unsigned char pSkillAvailabilityPerClass[9][37] = // byte[] @ MM7.exe::004ED820
Ritor1
parents:
diff changeset
83 {
Ritor1
parents:
diff changeset
84 {0, 2, 0, 1, 1, 1, 1, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
Ritor1
parents:
diff changeset
85 {0, 1, 2, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 2, 1, 0},
Ritor1
parents:
diff changeset
86 {1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 2, 2, 1, 1, 0, 0, 0},
Ritor1
parents:
diff changeset
87 {0, 1, 1, 1, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
Ritor1
parents:
diff changeset
88 {0, 1, 0, 1, 1, 2, 0, 0, 0, 1, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1},
Ritor1
parents:
diff changeset
89 {0, 1, 1, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0},
Ritor1
parents:
diff changeset
90 {0, 0, 0, 0, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
Ritor1
parents:
diff changeset
91 {0, 0, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
Ritor1
parents:
diff changeset
92 {2, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0} // some of these are started at 4ED94C, but needs to be here
Ritor1
parents:
diff changeset
93 };
Ritor1
parents:
diff changeset
94
Ritor1
parents:
diff changeset
95
Ritor1
parents:
diff changeset
96 unsigned char pEquipTypeToBodyAnchor[21] = // 4E8398
Ritor1
parents:
diff changeset
97 {
Ritor1
parents:
diff changeset
98 1, // EQUIP_SINGLE_HANDED
Ritor1
parents:
diff changeset
99 1, // EQUIP_TWO_HANDED
Ritor1
parents:
diff changeset
100 2, // EQUIP_BOW
Ritor1
parents:
diff changeset
101 3, // EQUIP_ARMOUR
Ritor1
parents:
diff changeset
102 0, // EQUIP_SHIELD
Ritor1
parents:
diff changeset
103 4, // EQUIP_HELMET
Ritor1
parents:
diff changeset
104 5, // EQUIP_BELT
Ritor1
parents:
diff changeset
105 6, // EQUIP_CLOAK
Ritor1
parents:
diff changeset
106 7, // EQUIP_GAUNTLETS
Ritor1
parents:
diff changeset
107 8, // EQUIP_BOOTS
Ritor1
parents:
diff changeset
108 10, // EQUIP_RING
Ritor1
parents:
diff changeset
109 9, // EQUIP_AMULET
Ritor1
parents:
diff changeset
110 1, // EQUIP_WAND
Ritor1
parents:
diff changeset
111 0, // EQUIP_REAGENT
Ritor1
parents:
diff changeset
112 0, // EQUIP_POTION
Ritor1
parents:
diff changeset
113 0, // EQUIP_SPELL_SCROLL
Ritor1
parents:
diff changeset
114 0, // EQUIP_BOOK
Ritor1
parents:
diff changeset
115 0, // EQUIP_MESSAGE_SCROLL
Ritor1
parents:
diff changeset
116 0, // EQUIP_GOLD
Ritor1
parents:
diff changeset
117 0, // EQUIP_GEM
Ritor1
parents:
diff changeset
118 0 // EQUIP_NONE
Ritor1
parents:
diff changeset
119 };
Ritor1
parents:
diff changeset
120
Ritor1
parents:
diff changeset
121
Ritor1
parents:
diff changeset
122 unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, 25, 20, 20, 0, 0, 0};
Ritor1
parents:
diff changeset
123 unsigned char pBaseManaByClass[12] = { 0, 0, 0, 5, 5, 0, 10, 10, 15, 0, 0, 0};
Ritor1
parents:
diff changeset
124 unsigned char pBaseHealthPerLevelByClass[36] = {5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4, 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3};
Ritor1
parents:
diff changeset
125 unsigned char pBaseManaPerLevelByClass[36] = {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 3, 3, 1, 2, 3, 3, 0, 2, 3, 3, 3, 4, 5, 5, 3, 4, 5, 5, 3, 4, 6, 6};
Ritor1
parents:
diff changeset
126
Ritor1
parents:
diff changeset
127 unsigned char pConditionAttributeModifier[7][19] =
Ritor1
parents:
diff changeset
128 {{100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Might
Ritor1
parents:
diff changeset
129 {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Intelligence
Ritor1
parents:
diff changeset
130 {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Willpower
Ritor1
parents:
diff changeset
131 {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Endurance
Ritor1
parents:
diff changeset
132 {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Accuracy
Ritor1
parents:
diff changeset
133 {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Speed
Ritor1
parents:
diff changeset
134 {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}}; //Luck
Ritor1
parents:
diff changeset
135
Ritor1
parents:
diff changeset
136 unsigned char pAgingAttributeModifier[7][4] =
Ritor1
parents:
diff changeset
137 {{100, 75, 40, 10}, //Might
Ritor1
parents:
diff changeset
138 {100, 150, 100, 10}, //Intelligence
Ritor1
parents:
diff changeset
139 {100, 150, 100, 10}, //Willpower
Ritor1
parents:
diff changeset
140 {100, 75, 40, 10}, //Endurance
Ritor1
parents:
diff changeset
141 {100, 100, 40, 10}, //Accuracy
Ritor1
parents:
diff changeset
142 {100, 100, 40, 10}, //Speed
Ritor1
parents:
diff changeset
143 {100, 100, 100, 100}}; //Luck
Ritor1
parents:
diff changeset
144
Ritor1
parents:
diff changeset
145 unsigned int pAgeingTable[4] = {50, 100, 150, 0xFFFF};
Ritor1
parents:
diff changeset
146
Ritor1
parents:
diff changeset
147 std::array<unsigned int, 18> pConditionImportancyTable = {{16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0}};
Ritor1
parents:
diff changeset
148
Ritor1
parents:
diff changeset
149 short param_to_bonus_table[29] = {500, 400, 350, 300, 275, 250, 225, 200, 175,
Ritor1
parents:
diff changeset
150 150, 125, 100, 75, 50, 40, 35, 30, 25, 21,
Ritor1
parents:
diff changeset
151 19, 17, 15, 13, 11, 9, 7, 5, 3, 0};
Ritor1
parents:
diff changeset
152 signed int parameter_to_bonus_value[29] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6};
Ritor1
parents:
diff changeset
153
Ritor1
parents:
diff changeset
154
Ritor1
parents:
diff changeset
155 unsigned short base_recovery_times_per_weapon_type[12] =
Ritor1
parents:
diff changeset
156 {
Ritor1
parents:
diff changeset
157 100, // PLAYER_SKILL_STAFF && Unarmed withoud skill
Ritor1
parents:
diff changeset
158 90, // PLAYER_SKILL_SWORD && Unarmed with skill
Ritor1
parents:
diff changeset
159 60, // PLAYER_SKILL_DAGGER
Ritor1
parents:
diff changeset
160 100, // PLAYER_SKILL_AXE
Ritor1
parents:
diff changeset
161 80, // PLAYER_SKILL_SPEAR
Ritor1
parents:
diff changeset
162 100, // PLAYER_SKILL_BOW
Ritor1
parents:
diff changeset
163 80, // PLAYER_SKILL_MACE
Ritor1
parents:
diff changeset
164 30, // PLAYER_SKILL_BLASTER
Ritor1
parents:
diff changeset
165 10, // PLAYER_SKILL_SHIELD
Ritor1
parents:
diff changeset
166 10, // PLAYER_SKILL_LEATHER
Ritor1
parents:
diff changeset
167 20, // PLAYER_SKILL_CHAIN
Ritor1
parents:
diff changeset
168 30 // PLAYER_SKILL_PLATE
Ritor1
parents:
diff changeset
169 };
Ritor1
parents:
diff changeset
170
Ritor1
parents:
diff changeset
171 //----- (00490913) --------------------------------------------------------
Ritor1
parents:
diff changeset
172 int PlayerCreation_GetUnspentAttributePointCount()
Ritor1
parents:
diff changeset
173 {
Ritor1
parents:
diff changeset
174 signed int v0; // edi@1
Ritor1
parents:
diff changeset
175 int raceId; // ebx@2
Ritor1
parents:
diff changeset
176 signed int v4; // eax@17
Ritor1
parents:
diff changeset
177 int v5; // edx@18
Ritor1
parents:
diff changeset
178 signed int v6; // ecx@18
Ritor1
parents:
diff changeset
179 signed int remainingStatPoints; // [sp+Ch] [bp-8h]@1
Ritor1
parents:
diff changeset
180
Ritor1
parents:
diff changeset
181 remainingStatPoints = 50;
Ritor1
parents:
diff changeset
182 v0 = 50;
Ritor1
parents:
diff changeset
183 for (int playerNum = 0; playerNum < 4; playerNum++)
Ritor1
parents:
diff changeset
184 {
Ritor1
parents:
diff changeset
185 raceId = pParty->pPlayers[playerNum].GetRace();
Ritor1
parents:
diff changeset
186 for (int statNum = 0; statNum <= 6; statNum++)
Ritor1
parents:
diff changeset
187 {
Ritor1
parents:
diff changeset
188 switch ( statNum )
Ritor1
parents:
diff changeset
189 {
Ritor1
parents:
diff changeset
190 case 0:
Ritor1
parents:
diff changeset
191 v0 = pParty->pPlayers[playerNum].uMight;
Ritor1
parents:
diff changeset
192 break;
Ritor1
parents:
diff changeset
193 case 1:
Ritor1
parents:
diff changeset
194 v0 = pParty->pPlayers[playerNum].uIntelligence;
Ritor1
parents:
diff changeset
195 break;
Ritor1
parents:
diff changeset
196 case 2:
Ritor1
parents:
diff changeset
197 v0 = pParty->pPlayers[playerNum].uWillpower;
Ritor1
parents:
diff changeset
198 break;
Ritor1
parents:
diff changeset
199 case 3:
Ritor1
parents:
diff changeset
200 v0 = pParty->pPlayers[playerNum].uEndurance;
Ritor1
parents:
diff changeset
201 break;
Ritor1
parents:
diff changeset
202 case 4:
Ritor1
parents:
diff changeset
203 v0 = pParty->pPlayers[playerNum].uAccuracy;
Ritor1
parents:
diff changeset
204 break;
Ritor1
parents:
diff changeset
205 case 5:
Ritor1
parents:
diff changeset
206 v0 = pParty->pPlayers[playerNum].uSpeed;
Ritor1
parents:
diff changeset
207 break;
Ritor1
parents:
diff changeset
208 case 6:
Ritor1
parents:
diff changeset
209 v0 = pParty->pPlayers[playerNum].uLuck;
Ritor1
parents:
diff changeset
210 break;
Ritor1
parents:
diff changeset
211 }
Ritor1
parents:
diff changeset
212 v4 = StatTable[raceId][statNum].uBaseValue;
Ritor1
parents:
diff changeset
213 if ( v0 >= v4 )
Ritor1
parents:
diff changeset
214 {
Ritor1
parents:
diff changeset
215 v5 = StatTable[raceId][statNum].uDroppedStep;
Ritor1
parents:
diff changeset
216 v6 = StatTable[raceId][statNum].uBaseStep;
Ritor1
parents:
diff changeset
217 }
Ritor1
parents:
diff changeset
218 else
Ritor1
parents:
diff changeset
219 {
Ritor1
parents:
diff changeset
220 v5 = StatTable[raceId][statNum].uBaseStep;
Ritor1
parents:
diff changeset
221 v6 = StatTable[raceId][statNum].uDroppedStep;
Ritor1
parents:
diff changeset
222 }
Ritor1
parents:
diff changeset
223 remainingStatPoints += v5 * (v4 - v0) / v6;
Ritor1
parents:
diff changeset
224 }
Ritor1
parents:
diff changeset
225 }
Ritor1
parents:
diff changeset
226 return remainingStatPoints;
Ritor1
parents:
diff changeset
227 }
Ritor1
parents:
diff changeset
228
Ritor1
parents:
diff changeset
229 //----- (00427730) --------------------------------------------------------
Ritor1
parents:
diff changeset
230 bool Player::CanCastSpell(unsigned int uRequiredMana)
Ritor1
parents:
diff changeset
231 {
Ritor1
parents:
diff changeset
232 if (sMana >= (signed int)uRequiredMana)
Ritor1
parents:
diff changeset
233 {
Ritor1
parents:
diff changeset
234 sMana -= (signed int)uRequiredMana;
Ritor1
parents:
diff changeset
235 return true;
Ritor1
parents:
diff changeset
236 }
Ritor1
parents:
diff changeset
237
Ritor1
parents:
diff changeset
238 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
239 return false;
Ritor1
parents:
diff changeset
240 }
Ritor1
parents:
diff changeset
241
Ritor1
parents:
diff changeset
242 //----- (004BE2DD) --------------------------------------------------------
Ritor1
parents:
diff changeset
243 void Player::SalesProcess( unsigned int inventory_idnx, int item_index, int _2devent_idx )
Ritor1
parents:
diff changeset
244 {
Ritor1
parents:
diff changeset
245 float v6; // ST04_4@1
Ritor1
parents:
diff changeset
246 signed int item_value; // eax@1
Ritor1
parents:
diff changeset
247 signed int sell_price; // ebx@1
Ritor1
parents:
diff changeset
248
Ritor1
parents:
diff changeset
249 item_value =pOwnItems[item_index].GetValue();
Ritor1
parents:
diff changeset
250 v6 = p2DEvents[ _2devent_idx - 1].fPriceMultiplier;
Ritor1
parents:
diff changeset
251 sell_price = GetPriceSell(item_value, v6);
Ritor1
parents:
diff changeset
252 if ( pOwnItems[item_index].IsBroken() )
Ritor1
parents:
diff changeset
253 sell_price = 1;
Ritor1
parents:
diff changeset
254 if ( sell_price < 1 )
Ritor1
parents:
diff changeset
255 sell_price = 1;
Ritor1
parents:
diff changeset
256 RemoveItemAtInventoryIndex(inventory_idnx);
Ritor1
parents:
diff changeset
257 Party::SetGold(pParty->uNumGold + sell_price);
Ritor1
parents:
diff changeset
258 }
Ritor1
parents:
diff changeset
259
Ritor1
parents:
diff changeset
260 //----- (0043EEF3) --------------------------------------------------------
Ritor1
parents:
diff changeset
261 bool Player::NothingOrJustBlastersEquipped()
Ritor1
parents:
diff changeset
262 {
Ritor1
parents:
diff changeset
263 signed int item_idx; // esi@1
Ritor1
parents:
diff changeset
264 signed int item_id; // esi@1
Ritor1
parents:
diff changeset
265 for (int i = 0; i < 16; ++i)
Ritor1
parents:
diff changeset
266 {
Ritor1
parents:
diff changeset
267 item_idx = pEquipment.pIndices[i];
Ritor1
parents:
diff changeset
268 if (item_idx)
Ritor1
parents:
diff changeset
269 {
Ritor1
parents:
diff changeset
270 item_id = pOwnItems[item_idx - 1].uItemID;
Ritor1
parents:
diff changeset
271 if ( item_id != ITEM_BLASTER && item_id != ITEM_LASER_RIFLE ) //blaster& blaster rifle
Ritor1
parents:
diff changeset
272 return false;
Ritor1
parents:
diff changeset
273 }
Ritor1
parents:
diff changeset
274 }
Ritor1
parents:
diff changeset
275 return true;
Ritor1
parents:
diff changeset
276 }
Ritor1
parents:
diff changeset
277
Ritor1
parents:
diff changeset
278 //----- (004B8040) --------------------------------------------------------
Ritor1
parents:
diff changeset
279 int Player::GetConditionDayOfWeek( unsigned int uCondition )
Ritor1
parents:
diff changeset
280 {
Ritor1
parents:
diff changeset
281 return (unsigned int)(((signed __int64)((double)this->pConditions[uCondition] * 0.234375) / 60 / 60) / 24) % 7 + 1;
Ritor1
parents:
diff changeset
282 }
Ritor1
parents:
diff changeset
283
Ritor1
parents:
diff changeset
284 //----- (004B807C) --------------------------------------------------------
Ritor1
parents:
diff changeset
285 int Player::GetTempleHealCostModifier(float a2)
Ritor1
parents:
diff changeset
286 {
Ritor1
parents:
diff changeset
287 unsigned int conditionIdx; // eax@1
Ritor1
parents:
diff changeset
288 int conditionTimeMultiplier; // esi@1
Ritor1
parents:
diff changeset
289 int v6; // eax@8
Ritor1
parents:
diff changeset
290 signed int result; // qax@13
Ritor1
parents:
diff changeset
291 signed int baseConditionMultiplier; // [sp+8h] [bp-8h]@4
Ritor1
parents:
diff changeset
292
Ritor1
parents:
diff changeset
293 conditionIdx = GetMajorConditionIdx();
Ritor1
parents:
diff changeset
294 if ( conditionIdx >= 14 && conditionIdx <= 16)
Ritor1
parents:
diff changeset
295 {
Ritor1
parents:
diff changeset
296 if ( conditionIdx <= 15 )
Ritor1
parents:
diff changeset
297 baseConditionMultiplier = 5;
Ritor1
parents:
diff changeset
298 else //if ( conditionIdx == 16 )
Ritor1
parents:
diff changeset
299 baseConditionMultiplier = 10;
Ritor1
parents:
diff changeset
300 conditionTimeMultiplier = GetConditionDayOfWeek(conditionIdx);
Ritor1
parents:
diff changeset
301 }
Ritor1
parents:
diff changeset
302 else
Ritor1
parents:
diff changeset
303 {
Ritor1
parents:
diff changeset
304 conditionTimeMultiplier = 1;
Ritor1
parents:
diff changeset
305 baseConditionMultiplier = 1;
Ritor1
parents:
diff changeset
306 if (conditionIdx < 14)
Ritor1
parents:
diff changeset
307 {
Ritor1
parents:
diff changeset
308 for (int i = 0; i <= 13; i++)
Ritor1
parents:
diff changeset
309 {
Ritor1
parents:
diff changeset
310 v6 = GetConditionDayOfWeek(i);
Ritor1
parents:
diff changeset
311 if ( v6 > conditionTimeMultiplier )
Ritor1
parents:
diff changeset
312 conditionTimeMultiplier = v6;
Ritor1
parents:
diff changeset
313 }
Ritor1
parents:
diff changeset
314 }
Ritor1
parents:
diff changeset
315 }
Ritor1
parents:
diff changeset
316 result = (int)((double)conditionTimeMultiplier * (double)baseConditionMultiplier * a2);
Ritor1
parents:
diff changeset
317 if ( result < 1 )
Ritor1
parents:
diff changeset
318 result = 1;
Ritor1
parents:
diff changeset
319 return result;
Ritor1
parents:
diff changeset
320 }
Ritor1
parents:
diff changeset
321
Ritor1
parents:
diff changeset
322 //----- (004B8102) --------------------------------------------------------
Ritor1
parents:
diff changeset
323 int Player::GetPriceSell(int uRealValue, float price_multiplier)
Ritor1
parents:
diff changeset
324 {
Ritor1
parents:
diff changeset
325 signed int v3; // esi@1
Ritor1
parents:
diff changeset
326 signed int result; // eax@3
Ritor1
parents:
diff changeset
327
Ritor1
parents:
diff changeset
328 v3 = (signed int)((signed __int64)((double)uRealValue / (price_multiplier + 2.0)) + uRealValue * GetMerchant() / 100);
Ritor1
parents:
diff changeset
329 if ( v3 > uRealValue )
Ritor1
parents:
diff changeset
330 v3 = uRealValue;
Ritor1
parents:
diff changeset
331 result = 1;
Ritor1
parents:
diff changeset
332 if ( v3 >= 1 )
Ritor1
parents:
diff changeset
333 result = v3;
Ritor1
parents:
diff changeset
334 return result;
Ritor1
parents:
diff changeset
335 }
Ritor1
parents:
diff changeset
336
Ritor1
parents:
diff changeset
337 //----- (004B8142) --------------------------------------------------------
Ritor1
parents:
diff changeset
338 int Player::GetBuyingPrice(unsigned int uRealValue, float price_multiplier)
Ritor1
parents:
diff changeset
339 {
Ritor1
parents:
diff changeset
340 uint price = (uint)(((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100);
Ritor1
parents:
diff changeset
341
Ritor1
parents:
diff changeset
342 if (price < uRealValue)
Ritor1
parents:
diff changeset
343 price = uRealValue;
Ritor1
parents:
diff changeset
344 return price;
Ritor1
parents:
diff changeset
345 }
Ritor1
parents:
diff changeset
346
Ritor1
parents:
diff changeset
347 //----- (004B8179) --------------------------------------------------------
Ritor1
parents:
diff changeset
348 int Player::GetPriceIdentification(float a2)
Ritor1
parents:
diff changeset
349 {
Ritor1
parents:
diff changeset
350 signed int v2; // esi@1
Ritor1
parents:
diff changeset
351 int v3; // ecx@1
Ritor1
parents:
diff changeset
352 signed int result; // eax@3
Ritor1
parents:
diff changeset
353
Ritor1
parents:
diff changeset
354 v2 = (signed int)(a2 * 50.0);
Ritor1
parents:
diff changeset
355 v3 = v2 * (100 - GetMerchant()) / 100;
Ritor1
parents:
diff changeset
356 if ( v3 < v2 / 3 )
Ritor1
parents:
diff changeset
357 v3 = v2 / 3;
Ritor1
parents:
diff changeset
358 result = 1;
Ritor1
parents:
diff changeset
359 if ( v3 >= 1 )
Ritor1
parents:
diff changeset
360 result = v3;
Ritor1
parents:
diff changeset
361 return result;
Ritor1
parents:
diff changeset
362 }
Ritor1
parents:
diff changeset
363
Ritor1
parents:
diff changeset
364 //----- (004B81C3) --------------------------------------------------------
Ritor1
parents:
diff changeset
365 int Player::GetPriceRepair(int a2, float a3)
Ritor1
parents:
diff changeset
366 {
Ritor1
parents:
diff changeset
367 signed int v3; // esi@1
Ritor1
parents:
diff changeset
368 int v4; // ecx@1
Ritor1
parents:
diff changeset
369 signed int result; // eax@3
Ritor1
parents:
diff changeset
370
Ritor1
parents:
diff changeset
371 v3 = (signed int)((double)a2 / (6.0 - a3));
Ritor1
parents:
diff changeset
372 v4 = v3 * (100 - GetMerchant()) / 100;
Ritor1
parents:
diff changeset
373 if ( v4 < v3 / 3 )
Ritor1
parents:
diff changeset
374 v4 = v3 / 3;
Ritor1
parents:
diff changeset
375 result = 1;
Ritor1
parents:
diff changeset
376 if ( v4 >= 1 )
Ritor1
parents:
diff changeset
377 result = v4;
Ritor1
parents:
diff changeset
378 return result;
Ritor1
parents:
diff changeset
379 }
Ritor1
parents:
diff changeset
380
Ritor1
parents:
diff changeset
381 //----- (004B8213) --------------------------------------------------------
Ritor1
parents:
diff changeset
382 int Player::GetBaseSellingPrice(int a2, float a3)
Ritor1
parents:
diff changeset
383 {
Ritor1
parents:
diff changeset
384 signed int v3; // qax@1
Ritor1
parents:
diff changeset
385
Ritor1
parents:
diff changeset
386 v3 = (signed int)((double)a2 / (a3 + 2.0));
Ritor1
parents:
diff changeset
387 if ( v3 < 1 )
Ritor1
parents:
diff changeset
388 v3 = 1;
Ritor1
parents:
diff changeset
389 return v3;
Ritor1
parents:
diff changeset
390 }
Ritor1
parents:
diff changeset
391
Ritor1
parents:
diff changeset
392 //----- (004B8233) --------------------------------------------------------
Ritor1
parents:
diff changeset
393 int Player::GetBaseBuyingPrice(int a2, float a3)
Ritor1
parents:
diff changeset
394 {
Ritor1
parents:
diff changeset
395 signed int v3; // qax@1
Ritor1
parents:
diff changeset
396
Ritor1
parents:
diff changeset
397 v3 = (signed int)((double)a2 * a3);
Ritor1
parents:
diff changeset
398 if ( v3 < 1 )
Ritor1
parents:
diff changeset
399 v3 = 1;
Ritor1
parents:
diff changeset
400 return v3;
Ritor1
parents:
diff changeset
401 }
Ritor1
parents:
diff changeset
402
Ritor1
parents:
diff changeset
403 //----- (004B824B) --------------------------------------------------------
Ritor1
parents:
diff changeset
404 int Player::GetBaseIdentifyPrice(float a2)
Ritor1
parents:
diff changeset
405 {
Ritor1
parents:
diff changeset
406 signed int v2; // qax@1
Ritor1
parents:
diff changeset
407
Ritor1
parents:
diff changeset
408 v2 = (signed int)(a2 * 50.0);
Ritor1
parents:
diff changeset
409 if ( v2 < 1 )
Ritor1
parents:
diff changeset
410 v2 = 1;
Ritor1
parents:
diff changeset
411 return v2;
Ritor1
parents:
diff changeset
412 }
Ritor1
parents:
diff changeset
413
Ritor1
parents:
diff changeset
414 //----- (004B8265) --------------------------------------------------------
Ritor1
parents:
diff changeset
415 int Player::GetBaseRepairPrice(int a2, float a3)
Ritor1
parents:
diff changeset
416 {
Ritor1
parents:
diff changeset
417 signed int v3; // qax@1
Ritor1
parents:
diff changeset
418
Ritor1
parents:
diff changeset
419 v3 = (signed int)((double)a2 / (6.0 - a3));
Ritor1
parents:
diff changeset
420 if ( v3 < 1 )
Ritor1
parents:
diff changeset
421 v3 = 1;
Ritor1
parents:
diff changeset
422 return v3;
Ritor1
parents:
diff changeset
423 }
Ritor1
parents:
diff changeset
424
Ritor1
parents:
diff changeset
425 //----- (004B6FF9) --------------------------------------------------------
Ritor1
parents:
diff changeset
426 bool Player::IsPlayerHealableByTemple()
Ritor1
parents:
diff changeset
427 {
Ritor1
parents:
diff changeset
428 if (this->sHealth >= GetMaxHealth() && this->sMana >= GetMaxMana() && GetMajorConditionIdx() == Condition_Good)
Ritor1
parents:
diff changeset
429 return false;
Ritor1
parents:
diff changeset
430 else
Ritor1
parents:
diff changeset
431 {
Ritor1
parents:
diff changeset
432 if (GetMajorConditionIdx() == Condition_Zombie)
Ritor1
parents:
diff changeset
433 {
Ritor1
parents:
diff changeset
434 if (((signed int)window_SpeakInHouse->ptr_1C == 78 || (signed int)window_SpeakInHouse->ptr_1C == 81 || (signed int)window_SpeakInHouse->ptr_1C == 82))
Ritor1
parents:
diff changeset
435 return false;
Ritor1
parents:
diff changeset
436 else
Ritor1
parents:
diff changeset
437 return true;
Ritor1
parents:
diff changeset
438 }
Ritor1
parents:
diff changeset
439 else
Ritor1
parents:
diff changeset
440 return true;
Ritor1
parents:
diff changeset
441 }
Ritor1
parents:
diff changeset
442 }
Ritor1
parents:
diff changeset
443
Ritor1
parents:
diff changeset
444 //----- (00421E75) --------------------------------------------------------
Ritor1
parents:
diff changeset
445 unsigned int Player::GetItemIDAtInventoryIndex(int *pitem_index)
Ritor1
parents:
diff changeset
446 {
Ritor1
parents:
diff changeset
447 int item_idx; // eax@1
Ritor1
parents:
diff changeset
448 int inv_index; // eax@3
Ritor1
parents:
diff changeset
449
Ritor1
parents:
diff changeset
450 item_idx = *pitem_index;
Ritor1
parents:
diff changeset
451 if ( item_idx >125 || item_idx < 0 )
Ritor1
parents:
diff changeset
452 return 0;
Ritor1
parents:
diff changeset
453 inv_index = this->pInventoryMatrix[item_idx];
Ritor1
parents:
diff changeset
454 if ( inv_index < 0 )
Ritor1
parents:
diff changeset
455 {
Ritor1
parents:
diff changeset
456 *pitem_index = -1 - inv_index;
Ritor1
parents:
diff changeset
457 inv_index = this->pInventoryMatrix[-1 - inv_index];
Ritor1
parents:
diff changeset
458 }
Ritor1
parents:
diff changeset
459 return inv_index;
Ritor1
parents:
diff changeset
460 }
Ritor1
parents:
diff changeset
461
Ritor1
parents:
diff changeset
462 //----- (004160CA) --------------------------------------------------------
Ritor1
parents:
diff changeset
463 void Player::ItemsEnchant( int enchant_count )
Ritor1
parents:
diff changeset
464 {
Ritor1
parents:
diff changeset
465 int avalible_items; // ebx@1
Ritor1
parents:
diff changeset
466 int i; // edx@8
Ritor1
parents:
diff changeset
467 __int16 item_index_tabl[138]; // [sp+Ch] [bp-118h]@1
Ritor1
parents:
diff changeset
468
Ritor1
parents:
diff changeset
469 avalible_items = 0;
Ritor1
parents:
diff changeset
470 memset (item_index_tabl,0,sizeof(item_index_tabl));
Ritor1
parents:
diff changeset
471
Ritor1
parents:
diff changeset
472 for (i = 0; i < 138; ++i)
Ritor1
parents:
diff changeset
473 {
Ritor1
parents:
diff changeset
474 if (( pOwnItems[i].uItemID>0)&&(pOwnItems[i].uItemID <= 134))
Ritor1
parents:
diff changeset
475 item_index_tabl[avalible_items++] = i;
Ritor1
parents:
diff changeset
476 }
Ritor1
parents:
diff changeset
477
Ritor1
parents:
diff changeset
478 if ( avalible_items )
Ritor1
parents:
diff changeset
479 {
Ritor1
parents:
diff changeset
480 if ( enchant_count )
Ritor1
parents:
diff changeset
481 {
Ritor1
parents:
diff changeset
482 for ( i = 0; i < enchant_count; ++i )
Ritor1
parents:
diff changeset
483 {
Ritor1
parents:
diff changeset
484 if (!(pInventoryItemList[item_index_tabl[i]].uAttributes&ITEM_HARDENED))
Ritor1
parents:
diff changeset
485 pInventoryItemList[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_HARDENED;
Ritor1
parents:
diff changeset
486 }
Ritor1
parents:
diff changeset
487 }
Ritor1
parents:
diff changeset
488 else
Ritor1
parents:
diff changeset
489 {
Ritor1
parents:
diff changeset
490 for ( i = 0; i < avalible_items; ++i )
Ritor1
parents:
diff changeset
491 {
Ritor1
parents:
diff changeset
492 pInventoryItemList[item_index_tabl[i]].uAttributes |= ITEM_HARDENED;
Ritor1
parents:
diff changeset
493 }
Ritor1
parents:
diff changeset
494 }
Ritor1
parents:
diff changeset
495 }
Ritor1
parents:
diff changeset
496 }
Ritor1
parents:
diff changeset
497
Ritor1
parents:
diff changeset
498 //----- (004948B1) --------------------------------------------------------
Ritor1
parents:
diff changeset
499 void Player::PlaySound(PlayerSpeech speech, int a3)
Ritor1
parents:
diff changeset
500 {
Ritor1
parents:
diff changeset
501 signed int speechCount = 0; // esi@4
Ritor1
parents:
diff changeset
502 signed int expressionCount = 0; // esi@4
Ritor1
parents:
diff changeset
503 int pickedVariant; // esi@10
Ritor1
parents:
diff changeset
504 CHARACTER_EXPRESSION_ID expression; // ebx@17
Ritor1
parents:
diff changeset
505 signed int pSoundID; // ecx@19
Ritor1
parents:
diff changeset
506 int speechVariantArray[5]; // [sp+Ch] [bp-1Ch]@7
Ritor1
parents:
diff changeset
507 int expressionVariantArray[5];
Ritor1
parents:
diff changeset
508 unsigned int pickedSoundID; // [sp+30h] [bp+8h]@4
Ritor1
parents:
diff changeset
509 unsigned int expressionDuration = 0;
Ritor1
parents:
diff changeset
510
Ritor1
parents:
diff changeset
511 pickedSoundID = 0;
Ritor1
parents:
diff changeset
512 if (uVoicesVolumeMultiplier)
Ritor1
parents:
diff changeset
513 {
Ritor1
parents:
diff changeset
514 for (int i = 0; i < 2; i++)
Ritor1
parents:
diff changeset
515 {
Ritor1
parents:
diff changeset
516 if ( SoundSetAction[speech][i] )
Ritor1
parents:
diff changeset
517 {
Ritor1
parents:
diff changeset
518 speechVariantArray[speechCount] = SoundSetAction[speech][i];
Ritor1
parents:
diff changeset
519 speechCount++;
Ritor1
parents:
diff changeset
520 }
Ritor1
parents:
diff changeset
521 }
Ritor1
parents:
diff changeset
522 if ( speechCount )
Ritor1
parents:
diff changeset
523 {
Ritor1
parents:
diff changeset
524 pickedVariant = speechVariantArray[rand() % speechCount];
Ritor1
parents:
diff changeset
525 int numberOfSubvariants = byte_4ECF08[pickedVariant - 1][uVoiceID];
Ritor1
parents:
diff changeset
526 if (numberOfSubvariants > 0)
Ritor1
parents:
diff changeset
527 {
Ritor1
parents:
diff changeset
528 pickedSoundID = rand() % numberOfSubvariants + 2 * (pickedVariant + 50 * uVoiceID) + 4998;
Ritor1
parents:
diff changeset
529 pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, uActiveCharacter + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0);
Ritor1
parents:
diff changeset
530 }
Ritor1
parents:
diff changeset
531 }
Ritor1
parents:
diff changeset
532 }
Ritor1
parents:
diff changeset
533
Ritor1
parents:
diff changeset
534 for (int i = 0; i < 5; i++)
Ritor1
parents:
diff changeset
535 {
Ritor1
parents:
diff changeset
536 if ( SoundSetAction[speech][i + 3] )
Ritor1
parents:
diff changeset
537 {
Ritor1
parents:
diff changeset
538 expressionVariantArray[expressionCount] = SoundSetAction[speech][i + 3];
Ritor1
parents:
diff changeset
539 expressionCount++;
Ritor1
parents:
diff changeset
540 }
Ritor1
parents:
diff changeset
541 }
Ritor1
parents:
diff changeset
542 if ( expressionCount )
Ritor1
parents:
diff changeset
543 {
Ritor1
parents:
diff changeset
544 expression = (CHARACTER_EXPRESSION_ID)expressionVariantArray[rand() % expressionCount];
Ritor1
parents:
diff changeset
545 if (expression == CHARACTER_EXPRESSION_21 && pickedSoundID )
Ritor1
parents:
diff changeset
546 {
Ritor1
parents:
diff changeset
547 pSoundID = 0;
Ritor1
parents:
diff changeset
548 if ( pSoundList->sNumSounds )
Ritor1
parents:
diff changeset
549 {
Ritor1
parents:
diff changeset
550 for (int i = 0; i < pSoundList->sNumSounds; i++)
Ritor1
parents:
diff changeset
551 {
Ritor1
parents:
diff changeset
552 if (pSoundList->pSL_Sounds[i].uSoundID == pickedSoundID)
Ritor1
parents:
diff changeset
553 pSoundID = i;
Ritor1
parents:
diff changeset
554 }
Ritor1
parents:
diff changeset
555 }
Ritor1
parents:
diff changeset
556 if ( pSoundList->pSL_Sounds[pSoundID].pSoundData[0] )
Ritor1
parents:
diff changeset
557 expressionDuration = (sLastTrackLengthMS << 7) / 1000;
Ritor1
parents:
diff changeset
558 }
Ritor1
parents:
diff changeset
559 PlayEmotion(expression, expressionDuration);
Ritor1
parents:
diff changeset
560 }
Ritor1
parents:
diff changeset
561 }
Ritor1
parents:
diff changeset
562 // 4948B1: using guessed type int var_1C[5];
Ritor1
parents:
diff changeset
563
Ritor1
parents:
diff changeset
564 //----- (00494A25) --------------------------------------------------------
Ritor1
parents:
diff changeset
565 void Player::PlayEmotion(CHARACTER_EXPRESSION_ID new_expression, int a3)
Ritor1
parents:
diff changeset
566 {
Ritor1
parents:
diff changeset
567 unsigned int v3 = expression;
Ritor1
parents:
diff changeset
568 if (expression == CHARACTER_EXPRESSION_DEAD || expression == CHARACTER_EXPRESSION_ERADICATED)
Ritor1
parents:
diff changeset
569 {
Ritor1
parents:
diff changeset
570 return;
Ritor1
parents:
diff changeset
571 }
Ritor1
parents:
diff changeset
572 else if (expression == CHARACTER_EXPRESSION_PERTIFIED && new_expression != CHARACTER_EXPRESSION_FALLING)
Ritor1
parents:
diff changeset
573 {
Ritor1
parents:
diff changeset
574 return;
Ritor1
parents:
diff changeset
575 }
Ritor1
parents:
diff changeset
576 else
Ritor1
parents:
diff changeset
577 {
Ritor1
parents:
diff changeset
578 if (expression != CHARACTER_EXPRESSION_SLEEP || new_expression != CHARACTER_EXPRESSION_FALLING)
Ritor1
parents:
diff changeset
579 {
Ritor1
parents:
diff changeset
580 if (v3 >= 2 && v3 <= 11 && v3 != 8 && !(new_expression == CHARACTER_EXPRESSION_DMGRECVD_MINOR || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MODERATE || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MAJOR))
Ritor1
parents:
diff changeset
581 {
Ritor1
parents:
diff changeset
582 return;
Ritor1
parents:
diff changeset
583 }
Ritor1
parents:
diff changeset
584 }
Ritor1
parents:
diff changeset
585 }
Ritor1
parents:
diff changeset
586 this->uExpressionTimePassed = 0;
Ritor1
parents:
diff changeset
587 if ( !a3 )
Ritor1
parents:
diff changeset
588 {
Ritor1
parents:
diff changeset
589 this->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[a3].uAnimLength;
Ritor1
parents:
diff changeset
590 }
Ritor1
parents:
diff changeset
591 else
Ritor1
parents:
diff changeset
592 {
Ritor1
parents:
diff changeset
593 this->uExpressionTimeLength = 0;
Ritor1
parents:
diff changeset
594 }
Ritor1
parents:
diff changeset
595 expression = new_expression;
Ritor1
parents:
diff changeset
596 viewparams->bRedrawGameUI = 1;
Ritor1
parents:
diff changeset
597 }
Ritor1
parents:
diff changeset
598
Ritor1
parents:
diff changeset
599 //----- (0049327B) --------------------------------------------------------
Ritor1
parents:
diff changeset
600 bool Player::ProfessionOrGuildFlagsCorrect( unsigned int uClass, int a3 )
Ritor1
parents:
diff changeset
601 {
Ritor1
parents:
diff changeset
602 if ( this->classType == uClass )
Ritor1
parents:
diff changeset
603 {
Ritor1
parents:
diff changeset
604 return true;
Ritor1
parents:
diff changeset
605 }
Ritor1
parents:
diff changeset
606 else
Ritor1
parents:
diff changeset
607 {
Ritor1
parents:
diff changeset
608 if (!a3)
Ritor1
parents:
diff changeset
609 {
Ritor1
parents:
diff changeset
610 return false;
Ritor1
parents:
diff changeset
611 }
Ritor1
parents:
diff changeset
612 switch ( uClass )
Ritor1
parents:
diff changeset
613 {
Ritor1
parents:
diff changeset
614 case 0x1Au:
Ritor1
parents:
diff changeset
615 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 65));
Ritor1
parents:
diff changeset
616 case 0x1Bu:
Ritor1
parents:
diff changeset
617 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 67));
Ritor1
parents:
diff changeset
618 case 0x22u:
Ritor1
parents:
diff changeset
619 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 77));
Ritor1
parents:
diff changeset
620 case 0x23u:
Ritor1
parents:
diff changeset
621 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 79));
Ritor1
parents:
diff changeset
622 break;
Ritor1
parents:
diff changeset
623 default:
Ritor1
parents:
diff changeset
624 Error("Should not be able to get here (%u)", uClass);
Ritor1
parents:
diff changeset
625 break;
Ritor1
parents:
diff changeset
626 }
Ritor1
parents:
diff changeset
627 return false;
Ritor1
parents:
diff changeset
628 }
Ritor1
parents:
diff changeset
629 }
Ritor1
parents:
diff changeset
630
Ritor1
parents:
diff changeset
631
Ritor1
parents:
diff changeset
632 //----- (00492C0B) --------------------------------------------------------
Ritor1
parents:
diff changeset
633 bool Player::CanAct()
Ritor1
parents:
diff changeset
634 {
Ritor1
parents:
diff changeset
635 if ( this->IsAsleep() || this->IsParalyzed() ||
Ritor1
parents:
diff changeset
636 this->IsUnconcious() || this->IsDead() ||
Ritor1
parents:
diff changeset
637 this->IsPertified() || this->IsEradicated() )
Ritor1
parents:
diff changeset
638 return false;
Ritor1
parents:
diff changeset
639 else
Ritor1
parents:
diff changeset
640 return true;
Ritor1
parents:
diff changeset
641 }
Ritor1
parents:
diff changeset
642
Ritor1
parents:
diff changeset
643 //----- (00492C40) --------------------------------------------------------
Ritor1
parents:
diff changeset
644 bool Player::CanSteal()
Ritor1
parents:
diff changeset
645 {
Ritor1
parents:
diff changeset
646 return GetActualSkillLevel(PLAYER_SKILL_STEALING) != 0;
Ritor1
parents:
diff changeset
647 }
Ritor1
parents:
diff changeset
648
Ritor1
parents:
diff changeset
649 //----- (00492C4E) --------------------------------------------------------
Ritor1
parents:
diff changeset
650 bool Player::CanEquip_RaceAndAlignmentCheck(unsigned int uItemID)
Ritor1
parents:
diff changeset
651 {
Ritor1
parents:
diff changeset
652 switch (uItemID)
Ritor1
parents:
diff changeset
653 {
Ritor1
parents:
diff changeset
654 case ITEM_RELIC_ETHRICS_STAFF:
Ritor1
parents:
diff changeset
655 case ITEM_RELIC_OLD_NICK:
Ritor1
parents:
diff changeset
656 case ITEM_RELIC_TWILIGHT: return pParty->IsPartyEvil(); break;
Ritor1
parents:
diff changeset
657 case ITEM_RELIC_TALEDONS_HELM:
Ritor1
parents:
diff changeset
658 case ITEM_RELIC_JUSTICE: return pParty->IsPartyGood(); break;
Ritor1
parents:
diff changeset
659 case ITEM_ARTIFACT_ELFBANE: return IsRaceGoblin(); break;
Ritor1
parents:
diff changeset
660 case ITEM_ARTIFACT_MINDS_EYE: return IsRaceHuman(); break;
Ritor1
parents:
diff changeset
661 case ITEM_ELVEN_CHAINMAIL: return IsRaceElf(); break;
Ritor1
parents:
diff changeset
662 case ITEM_FORGE_GAUNTLETS: return IsRaceDwarf(); break;
Ritor1
parents:
diff changeset
663 case ITEM_ARTIFACT_HEROS_BELT: return IsMale(); break;
Ritor1
parents:
diff changeset
664 case ITEM_ARTIFACT_LADYS_ESCORT: return IsFemale(); break;
Ritor1
parents:
diff changeset
665 case ITEM_WETSUIT: return NothingOrJustBlastersEquipped(); break;
Ritor1
parents:
diff changeset
666 default: return 1; break;
Ritor1
parents:
diff changeset
667 }
Ritor1
parents:
diff changeset
668 }
Ritor1
parents:
diff changeset
669
Ritor1
parents:
diff changeset
670 //----- (00492D65) --------------------------------------------------------
Ritor1
parents:
diff changeset
671 void Player::SetCondition( unsigned int uConditionIdx, int a3 )
Ritor1
parents:
diff changeset
672 {
Ritor1
parents:
diff changeset
673 signed int player_sex; // ecx@77
Ritor1
parents:
diff changeset
674 signed int remainig_player; // ebx@82
Ritor1
parents:
diff changeset
675 int players_before; // [sp+10h] [bp-4h]@2
Ritor1
parents:
diff changeset
676 int players_after; // [sp+20h] [bp+Ch]@82
Ritor1
parents:
diff changeset
677
Ritor1
parents:
diff changeset
678 if ( pConditions[uConditionIdx] )
Ritor1
parents:
diff changeset
679 return;
Ritor1
parents:
diff changeset
680
Ritor1
parents:
diff changeset
681 if (!ConditionProcessor::IsPlayerAffected(this, uConditionIdx, a3))
Ritor1
parents:
diff changeset
682 {
Ritor1
parents:
diff changeset
683 return;
Ritor1
parents:
diff changeset
684 }
Ritor1
parents:
diff changeset
685
Ritor1
parents:
diff changeset
686 switch ( uConditionIdx )
Ritor1
parents:
diff changeset
687 {
Ritor1
parents:
diff changeset
688 case Condition_Cursed: PlaySound(SPEECH_30, 0); break;
Ritor1
parents:
diff changeset
689 case Condition_Weak: PlaySound(SPEECH_25, 0); break;
Ritor1
parents:
diff changeset
690 case Condition_Sleep: break; //nosound
Ritor1
parents:
diff changeset
691 case Condition_Fear: PlaySound(SPEECH_26, 0); break;
Ritor1
parents:
diff changeset
692 case Condition_Drunk: PlaySound(SPEECH_31, 0); break;
Ritor1
parents:
diff changeset
693 case Condition_Insane: PlaySound(SPEECH_29, 0); break;
Ritor1
parents:
diff changeset
694 case Condition_Poison_Weak:
Ritor1
parents:
diff changeset
695 case Condition_Poison_Medium:
Ritor1
parents:
diff changeset
696 case Condition_Poison_Severe: PlaySound(SPEECH_27, 0); break;
Ritor1
parents:
diff changeset
697 case Condition_Disease_Weak:
Ritor1
parents:
diff changeset
698 case Condition_Disease_Medium:
Ritor1
parents:
diff changeset
699 case Condition_Disease_Severe: PlaySound(SPEECH_28, 0);break;
Ritor1
parents:
diff changeset
700 case Condition_Paralyzed: break; //nosound
Ritor1
parents:
diff changeset
701 case Condition_Unconcious:
Ritor1
parents:
diff changeset
702 PlaySound(SPEECH_32, 0);
Ritor1
parents:
diff changeset
703 if ( sHealth > 0 )
Ritor1
parents:
diff changeset
704 sHealth = 0;
Ritor1
parents:
diff changeset
705 break;
Ritor1
parents:
diff changeset
706 case Condition_Dead:
Ritor1
parents:
diff changeset
707 PlaySound(SPEECH_33, 0);
Ritor1
parents:
diff changeset
708 if ( sHealth > 0 )
Ritor1
parents:
diff changeset
709 sHealth = 0;
Ritor1
parents:
diff changeset
710 if ( sMana > 0 )
Ritor1
parents:
diff changeset
711 sMana = 0;
Ritor1
parents:
diff changeset
712 break;
Ritor1
parents:
diff changeset
713 case Condition_Pertified:
Ritor1
parents:
diff changeset
714 PlaySound(SPEECH_34, 0);
Ritor1
parents:
diff changeset
715 break;
Ritor1
parents:
diff changeset
716 case Condition_Eradicated:
Ritor1
parents:
diff changeset
717 PlaySound(SPEECH_35, 0);
Ritor1
parents:
diff changeset
718 if (sHealth > 0 )
Ritor1
parents:
diff changeset
719 sHealth = 0;
Ritor1
parents:
diff changeset
720 if ( sMana > 0 )
Ritor1
parents:
diff changeset
721 sMana = 0;
Ritor1
parents:
diff changeset
722 break;
Ritor1
parents:
diff changeset
723 case Condition_Zombie:
Ritor1
parents:
diff changeset
724 if ( classType == PLAYER_CLASS_LICH || IsEradicated() || IsZombie() || !IsDead())
Ritor1
parents:
diff changeset
725 return;
Ritor1
parents:
diff changeset
726 pConditions.fill(0);
Ritor1
parents:
diff changeset
727 sHealth = GetMaxHealth();
Ritor1
parents:
diff changeset
728 sMana = 0;
Ritor1
parents:
diff changeset
729 player_sex = 0;
Ritor1
parents:
diff changeset
730 uPrevFace = uCurrentFace;
Ritor1
parents:
diff changeset
731 uPrevVoiceID = uVoiceID;
Ritor1
parents:
diff changeset
732 if (IsMale())
Ritor1
parents:
diff changeset
733 {
Ritor1
parents:
diff changeset
734 uCurrentFace = 23;
Ritor1
parents:
diff changeset
735 uVoiceID = 23;
Ritor1
parents:
diff changeset
736 }
Ritor1
parents:
diff changeset
737 else
Ritor1
parents:
diff changeset
738 {
Ritor1
parents:
diff changeset
739 uCurrentFace = 24;
Ritor1
parents:
diff changeset
740 uVoiceID = 24;
Ritor1
parents:
diff changeset
741 }
Ritor1
parents:
diff changeset
742 PlaySound(SPEECH_99, 0);
Ritor1
parents:
diff changeset
743 break;
Ritor1
parents:
diff changeset
744 }
Ritor1
parents:
diff changeset
745
Ritor1
parents:
diff changeset
746 players_before = 0;
Ritor1
parents:
diff changeset
747 for (int i = 1; i < 5; ++i)
Ritor1
parents:
diff changeset
748 {
Ritor1
parents:
diff changeset
749 if ( pPlayers[i]->CanAct() )
Ritor1
parents:
diff changeset
750 ++players_before;
Ritor1
parents:
diff changeset
751 }
Ritor1
parents:
diff changeset
752
Ritor1
parents:
diff changeset
753 pConditions[uConditionIdx] = pParty->uTimePlayed;
Ritor1
parents:
diff changeset
754
Ritor1
parents:
diff changeset
755 remainig_player = 0;
Ritor1
parents:
diff changeset
756 players_after = 0;
Ritor1
parents:
diff changeset
757 for (int i = 1; i < 5; ++i)
Ritor1
parents:
diff changeset
758 {
Ritor1
parents:
diff changeset
759 if ( pPlayers[i]->CanAct() )
Ritor1
parents:
diff changeset
760 {
Ritor1
parents:
diff changeset
761 remainig_player = i;
Ritor1
parents:
diff changeset
762 ++players_after;
Ritor1
parents:
diff changeset
763 }
Ritor1
parents:
diff changeset
764 }
Ritor1
parents:
diff changeset
765 if (( players_before == 2 ) && ( players_after == 1 ))
Ritor1
parents:
diff changeset
766 pPlayers[remainig_player]->PlaySound(SPEECH_107, 0);//ñêîðåå âñåãî îáíàä¸æûâàþùèé âîçãëàñ ïîñëåäíåãî
Ritor1
parents:
diff changeset
767 return;
Ritor1
parents:
diff changeset
768 }
Ritor1
parents:
diff changeset
769
Ritor1
parents:
diff changeset
770 //----- (00492528) --------------------------------------------------------
Ritor1
parents:
diff changeset
771 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID)
Ritor1
parents:
diff changeset
772 {
Ritor1
parents:
diff changeset
773 Texture *texture; // esi@1
Ritor1
parents:
diff changeset
774 unsigned int slotWidth; // ebx@1
Ritor1
parents:
diff changeset
775 unsigned int slotHeight; // [sp+1Ch] [bp+Ch]@1
Ritor1
parents:
diff changeset
776
Ritor1
parents:
diff changeset
777 texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
Ritor1
parents:
diff changeset
778 slotWidth = GetSizeInInventorySlots(texture->uTextureWidth);
Ritor1
parents:
diff changeset
779 slotHeight = GetSizeInInventorySlots(texture->uTextureHeight);
Ritor1
parents:
diff changeset
780 if ( !areWeLoadingTexture )
Ritor1
parents:
diff changeset
781 {
Ritor1
parents:
diff changeset
782 texture->Release();
Ritor1
parents:
diff changeset
783 pIcons_LOD->SyncLoadedFilesCount();
Ritor1
parents:
diff changeset
784 }
Ritor1
parents:
diff changeset
785 Assert(slotHeight > 0 && slotWidth > 0, "Items should have nonzero dimensions");
Ritor1
parents:
diff changeset
786 if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT )
Ritor1
parents:
diff changeset
787 {
Ritor1
parents:
diff changeset
788 for (unsigned int x = 0; x < slotWidth; x++)
Ritor1
parents:
diff changeset
789 {
Ritor1
parents:
diff changeset
790 for (unsigned int y = 0; y < slotHeight; y++)
Ritor1
parents:
diff changeset
791 {
Ritor1
parents:
diff changeset
792 if (pInventoryMatrix[y * INVETORYSLOTSWIDTH + x + uSlot] != 0)
Ritor1
parents:
diff changeset
793 {
Ritor1
parents:
diff changeset
794 return false;
Ritor1
parents:
diff changeset
795 }
Ritor1
parents:
diff changeset
796 }
Ritor1
parents:
diff changeset
797 }
Ritor1
parents:
diff changeset
798 return true;
Ritor1
parents:
diff changeset
799 }
Ritor1
parents:
diff changeset
800 return false;
Ritor1
parents:
diff changeset
801 }
Ritor1
parents:
diff changeset
802 // 506128: using guessed type int areWeLoadingTexture;
Ritor1
parents:
diff changeset
803
Ritor1
parents:
diff changeset
804 //----- (004925E6) --------------------------------------------------------
Ritor1
parents:
diff changeset
805 int Player::FindFreeInventoryListSlot()
Ritor1
parents:
diff changeset
806 {
Ritor1
parents:
diff changeset
807 for (int i = 0; i < 126; i++ )
Ritor1
parents:
diff changeset
808 {
Ritor1
parents:
diff changeset
809 if (pInventoryItemList[i].uItemID == 0)
Ritor1
parents:
diff changeset
810 {
Ritor1
parents:
diff changeset
811 return i;
Ritor1
parents:
diff changeset
812 }
Ritor1
parents:
diff changeset
813 }
Ritor1
parents:
diff changeset
814 return -1;
Ritor1
parents:
diff changeset
815 }
Ritor1
parents:
diff changeset
816
Ritor1
parents:
diff changeset
817 //----- (00492600) --------------------------------------------------------
Ritor1
parents:
diff changeset
818 int Player::CreateItemInInventory(unsigned int uSlot, unsigned int uItemID)
Ritor1
parents:
diff changeset
819 {
Ritor1
parents:
diff changeset
820 int result; // eax@8
Ritor1
parents:
diff changeset
821 signed int freeSlot; // [sp+8h] [bp-4h]@4
Ritor1
parents:
diff changeset
822
Ritor1
parents:
diff changeset
823 freeSlot = FindFreeInventoryListSlot();
Ritor1
parents:
diff changeset
824 if ( freeSlot == -1 )
Ritor1
parents:
diff changeset
825 {
Ritor1
parents:
diff changeset
826 if ( uActiveCharacter )
Ritor1
parents:
diff changeset
827 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
Ritor1
parents:
diff changeset
828 return 0;
Ritor1
parents:
diff changeset
829 }
Ritor1
parents:
diff changeset
830 else
Ritor1
parents:
diff changeset
831 {
Ritor1
parents:
diff changeset
832 PutItemArInventoryIndex(uItemID, freeSlot, uSlot);
Ritor1
parents:
diff changeset
833 result = freeSlot + 1;
Ritor1
parents:
diff changeset
834 this->pInventoryItemList[freeSlot].uItemID = uItemID;
Ritor1
parents:
diff changeset
835 }
Ritor1
parents:
diff changeset
836 return result;
Ritor1
parents:
diff changeset
837 }
Ritor1
parents:
diff changeset
838 // 506128: using guessed type int areWeLoadingTexture;
Ritor1
parents:
diff changeset
839
Ritor1
parents:
diff changeset
840 //----- (00492700) --------------------------------------------------------
Ritor1
parents:
diff changeset
841 int Player::HasSkill(unsigned int uSkillType)
Ritor1
parents:
diff changeset
842 {
Ritor1
parents:
diff changeset
843 if ( uSkillType >= 37 || this->pActiveSkills[uSkillType] )
Ritor1
parents:
diff changeset
844 {
Ritor1
parents:
diff changeset
845 return 1;
Ritor1
parents:
diff changeset
846 }
Ritor1
parents:
diff changeset
847 else
Ritor1
parents:
diff changeset
848 {
Ritor1
parents:
diff changeset
849 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[67], this->pName);
Ritor1
parents:
diff changeset
850 ShowStatusBarString(pTmpBuf.data(), 2u);
Ritor1
parents:
diff changeset
851 return 0;
Ritor1
parents:
diff changeset
852 }
Ritor1
parents:
diff changeset
853 }
Ritor1
parents:
diff changeset
854
Ritor1
parents:
diff changeset
855 //----- (00492745) --------------------------------------------------------
Ritor1
parents:
diff changeset
856 void Player::WearItem( unsigned int uItemID )
Ritor1
parents:
diff changeset
857 {
Ritor1
parents:
diff changeset
858 int item_body_anch; // edi@6
Ritor1
parents:
diff changeset
859 int item_indx;
Ritor1
parents:
diff changeset
860 item_indx = FindFreeInventoryListSlot();
Ritor1
parents:
diff changeset
861
Ritor1
parents:
diff changeset
862 if ( item_indx != -1 )
Ritor1
parents:
diff changeset
863 {
Ritor1
parents:
diff changeset
864 pInventoryItemList[item_indx].uItemID = uItemID;
Ritor1
parents:
diff changeset
865 item_body_anch = pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType];
Ritor1
parents:
diff changeset
866 pEquipment.pIndices[item_body_anch] = item_indx + 1;
Ritor1
parents:
diff changeset
867 pInventoryItemList[item_indx].uBodyAnchor = item_body_anch + 1;
Ritor1
parents:
diff changeset
868 }
Ritor1
parents:
diff changeset
869 }
Ritor1
parents:
diff changeset
870
Ritor1
parents:
diff changeset
871 //----- (004927A8) --------------------------------------------------------
Ritor1
parents:
diff changeset
872 int Player::AddItem(int index, unsigned int uItemID)
Ritor1
parents:
diff changeset
873 {
Ritor1
parents:
diff changeset
874 if ( index == -1 )
Ritor1
parents:
diff changeset
875 {
Ritor1
parents:
diff changeset
876 for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++)
Ritor1
parents:
diff changeset
877 {
Ritor1
parents:
diff changeset
878 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++)
Ritor1
parents:
diff changeset
879 {
Ritor1
parents:
diff changeset
880 if ( CanFitItem(ycoord * INVETORYSLOTSWIDTH + xcoord, uItemID) )
Ritor1
parents:
diff changeset
881 {
Ritor1
parents:
diff changeset
882 return CreateItemInInventory(ycoord * INVETORYSLOTSWIDTH + xcoord, uItemID);
Ritor1
parents:
diff changeset
883 }
Ritor1
parents:
diff changeset
884 }
Ritor1
parents:
diff changeset
885 }
Ritor1
parents:
diff changeset
886 return 0;
Ritor1
parents:
diff changeset
887 }
Ritor1
parents:
diff changeset
888 if ( !CanFitItem(index, uItemID) )
Ritor1
parents:
diff changeset
889 {
Ritor1
parents:
diff changeset
890 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
891 return 0;
Ritor1
parents:
diff changeset
892 }
Ritor1
parents:
diff changeset
893 return CreateItemInInventory(index, uItemID);
Ritor1
parents:
diff changeset
894 }
Ritor1
parents:
diff changeset
895
Ritor1
parents:
diff changeset
896 //----- (00492826) --------------------------------------------------------
Ritor1
parents:
diff changeset
897 int Player::AddItem2(int index, ItemGen *Src)
Ritor1
parents:
diff changeset
898 {
Ritor1
parents:
diff changeset
899 pItemsTable->SetSpecialBonus(Src);
Ritor1
parents:
diff changeset
900
Ritor1
parents:
diff changeset
901 if ( index == -1 )
Ritor1
parents:
diff changeset
902 {
Ritor1
parents:
diff changeset
903 for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++)
Ritor1
parents:
diff changeset
904 {
Ritor1
parents:
diff changeset
905 for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) //TODO: change pInventoryMatrix to 2 dimensional array.
Ritor1
parents:
diff changeset
906 {
Ritor1
parents:
diff changeset
907 if ( CanFitItem(ycoord * INVETORYSLOTSWIDTH + xcoord, Src->uItemID) )
Ritor1
parents:
diff changeset
908 {
Ritor1
parents:
diff changeset
909 return CreateItemInInventory2(ycoord * INVETORYSLOTSWIDTH + xcoord, Src);
Ritor1
parents:
diff changeset
910 }
Ritor1
parents:
diff changeset
911 }
Ritor1
parents:
diff changeset
912 }
Ritor1
parents:
diff changeset
913 return 0;
Ritor1
parents:
diff changeset
914 }
Ritor1
parents:
diff changeset
915 if ( !CanFitItem(index, Src->uItemID) )
Ritor1
parents:
diff changeset
916 return 0;
Ritor1
parents:
diff changeset
917 return CreateItemInInventory2(index, Src);
Ritor1
parents:
diff changeset
918 }
Ritor1
parents:
diff changeset
919
Ritor1
parents:
diff changeset
920 //----- (0049289C) --------------------------------------------------------
Ritor1
parents:
diff changeset
921 int Player::CreateItemInInventory2( unsigned int index, ItemGen *Src )
Ritor1
parents:
diff changeset
922 {
Ritor1
parents:
diff changeset
923 signed int freeSlot; // ebx@1
Ritor1
parents:
diff changeset
924 int result; // eax@6
Ritor1
parents:
diff changeset
925
Ritor1
parents:
diff changeset
926 freeSlot = FindFreeInventoryListSlot();
Ritor1
parents:
diff changeset
927 if ( freeSlot == -1 )
Ritor1
parents:
diff changeset
928 {
Ritor1
parents:
diff changeset
929 result = 0;
Ritor1
parents:
diff changeset
930 }
Ritor1
parents:
diff changeset
931 else
Ritor1
parents:
diff changeset
932 {
Ritor1
parents:
diff changeset
933 PutItemArInventoryIndex(Src->uItemID, freeSlot, index);
Ritor1
parents:
diff changeset
934 memcpy(&pInventoryItemList[freeSlot], Src, sizeof(ItemGen));
Ritor1
parents:
diff changeset
935 result = freeSlot + 1;
Ritor1
parents:
diff changeset
936 }
Ritor1
parents:
diff changeset
937 return result;
Ritor1
parents:
diff changeset
938 }
Ritor1
parents:
diff changeset
939 // 506128: using guessed type int areWeLoadingTexture;
Ritor1
parents:
diff changeset
940
Ritor1
parents:
diff changeset
941 //----- (0049298B) --------------------------------------------------------
Ritor1
parents:
diff changeset
942 void Player::PutItemArInventoryIndex( int uItemID, int itemListPos, int index ) //originally accepted ItemGen* but needed only its uItemID
Ritor1
parents:
diff changeset
943 {
Ritor1
parents:
diff changeset
944 Texture *item_texture; // esi@1
Ritor1
parents:
diff changeset
945 int *pInvPos; // esi@4
Ritor1
parents:
diff changeset
946 unsigned int slot_width; // [sp+Ch] [bp-4h]@1
Ritor1
parents:
diff changeset
947 unsigned int slot_height; // [sp+18h] [bp+8h]@1
Ritor1
parents:
diff changeset
948
Ritor1
parents:
diff changeset
949 item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
Ritor1
parents:
diff changeset
950 slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth);
Ritor1
parents:
diff changeset
951 slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight);
Ritor1
parents:
diff changeset
952 if ( !areWeLoadingTexture )
Ritor1
parents:
diff changeset
953 {
Ritor1
parents:
diff changeset
954 item_texture->Release();
Ritor1
parents:
diff changeset
955 pIcons_LOD->SyncLoadedFilesCount();
Ritor1
parents:
diff changeset
956 }
Ritor1
parents:
diff changeset
957 if ( slot_width > 0 )
Ritor1
parents:
diff changeset
958 {
Ritor1
parents:
diff changeset
959 pInvPos = &pInventoryMatrix[index];
Ritor1
parents:
diff changeset
960 for (unsigned int i = 0; i < slot_height; i++)
Ritor1
parents:
diff changeset
961 {
Ritor1
parents:
diff changeset
962 memset32(pInvPos, -1 - index, slot_width);//TODO: try to come up with a better solution. negative values are used when drawing the inventory - nothing is drawn
Ritor1
parents:
diff changeset
963 pInvPos += INVETORYSLOTSWIDTH;
Ritor1
parents:
diff changeset
964 }
Ritor1
parents:
diff changeset
965 }
Ritor1
parents:
diff changeset
966 pInventoryMatrix[index] = itemListPos + 1;
Ritor1
parents:
diff changeset
967 }
Ritor1
parents:
diff changeset
968
Ritor1
parents:
diff changeset
969 // 506128: using guessed type int areWeLoadingTexture;
Ritor1
parents:
diff changeset
970
Ritor1
parents:
diff changeset
971 //----- (00492A36) --------------------------------------------------------
Ritor1
parents:
diff changeset
972 void Player::RemoveItemAtInventoryIndex( unsigned int index )
Ritor1
parents:
diff changeset
973 {
Ritor1
parents:
diff changeset
974 ItemGen *item_in_slot; // ecx@1
Ritor1
parents:
diff changeset
975 Texture *item_texture; // esi@1
Ritor1
parents:
diff changeset
976 unsigned int slot_height; // ebp@1
Ritor1
parents:
diff changeset
977 int *pInvPos; // edx@4
Ritor1
parents:
diff changeset
978 unsigned int slot_width; // [sp+14h] [bp+4h]@1
Ritor1
parents:
diff changeset
979
Ritor1
parents:
diff changeset
980 item_in_slot = &this->pInventoryItemList[pInventoryMatrix[index]-1];
Ritor1
parents:
diff changeset
981 item_texture = pIcons_LOD->LoadTexturePtr(item_in_slot->GetIconName(), TEXTURE_16BIT_PALETTE);
Ritor1
parents:
diff changeset
982 item_in_slot->Reset();
Ritor1
parents:
diff changeset
983 slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth);
Ritor1
parents:
diff changeset
984 slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight);
Ritor1
parents:
diff changeset
985 if ( !areWeLoadingTexture )
Ritor1
parents:
diff changeset
986 {
Ritor1
parents:
diff changeset
987 item_texture->Release();
Ritor1
parents:
diff changeset
988 pIcons_LOD->SyncLoadedFilesCount();
Ritor1
parents:
diff changeset
989 }
Ritor1
parents:
diff changeset
990 if ( slot_width > 0 )
Ritor1
parents:
diff changeset
991 {
Ritor1
parents:
diff changeset
992 pInvPos = &pInventoryMatrix[index];
Ritor1
parents:
diff changeset
993 for (unsigned int i = 0; i < slot_height; i++)
Ritor1
parents:
diff changeset
994 {
Ritor1
parents:
diff changeset
995 memset32(pInvPos, 0, slot_width);
Ritor1
parents:
diff changeset
996 pInvPos += INVETORYSLOTSWIDTH;
Ritor1
parents:
diff changeset
997 }
Ritor1
parents:
diff changeset
998 }
Ritor1
parents:
diff changeset
999 }
Ritor1
parents:
diff changeset
1000 // 506128: using guessed type int areWeLoadingTexture;
Ritor1
parents:
diff changeset
1001
Ritor1
parents:
diff changeset
1002 //----- (00490EEE) --------------------------------------------------------
Ritor1
parents:
diff changeset
1003 int Player::SelectPhrasesTransaction(ItemGen *pItem, int building_type, int BuildID_2Events, int ShopMenuType) //TODO: probably move this somewhere else, not really Player:: stuff
Ritor1
parents:
diff changeset
1004 {
Ritor1
parents:
diff changeset
1005 unsigned int idemId; // edx@1
Ritor1
parents:
diff changeset
1006 signed int equipType; // esi@1
Ritor1
parents:
diff changeset
1007 float multiplier; // ST04_4@26
Ritor1
parents:
diff changeset
1008 int price; // edi@26
Ritor1
parents:
diff changeset
1009 int merchantLevel; // [sp+10h] [bp-8h]@1
Ritor1
parents:
diff changeset
1010 int itemValue;
Ritor1
parents:
diff changeset
1011
Ritor1
parents:
diff changeset
1012 merchantLevel = GetActualSkillLevel(PLAYER_SKILL_MERCHANT);
Ritor1
parents:
diff changeset
1013 idemId = pItem->uItemID;
Ritor1
parents:
diff changeset
1014 equipType = pItem->GetItemEquipType();
Ritor1
parents:
diff changeset
1015 itemValue = pItem->GetValue();
Ritor1
parents:
diff changeset
1016
Ritor1
parents:
diff changeset
1017 switch (building_type)
Ritor1
parents:
diff changeset
1018 {
Ritor1
parents:
diff changeset
1019 case BuildingType_WeaponShop:
Ritor1
parents:
diff changeset
1020 if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS)
Ritor1
parents:
diff changeset
1021 return 5;
Ritor1
parents:
diff changeset
1022 if (equipType > EQUIP_BOW)
Ritor1
parents:
diff changeset
1023 return 4;
Ritor1
parents:
diff changeset
1024 break;
Ritor1
parents:
diff changeset
1025 case BuildingType_ArmorShop:
Ritor1
parents:
diff changeset
1026 if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS)
Ritor1
parents:
diff changeset
1027 return 5;
Ritor1
parents:
diff changeset
1028 if ( equipType < EQUIP_ARMOUR || equipType > EQUIP_BOOTS)
Ritor1
parents:
diff changeset
1029 return 4;
Ritor1
parents:
diff changeset
1030 break;
Ritor1
parents:
diff changeset
1031 case BuildingType_MagicShop:
Ritor1
parents:
diff changeset
1032 if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS)
Ritor1
parents:
diff changeset
1033 return 5;
Ritor1
parents:
diff changeset
1034 if ( pItemsTable->pItems[idemId].uSkillType != PLAYER_SKILL_MISC )
Ritor1
parents:
diff changeset
1035 return 4;
Ritor1
parents:
diff changeset
1036 break;
Ritor1
parents:
diff changeset
1037 case BuildingType_AlchemistShop:
Ritor1
parents:
diff changeset
1038 if ((idemId >= ITEM_ARTIFACT_HERMES_SANDALS && idemId < ITEM_RECIPE_REJUVENATION) || idemId > ITEM_RECIPE_BODY_RESISTANCE)
Ritor1
parents:
diff changeset
1039 return 5;
Ritor1
parents:
diff changeset
1040 if ( !(equipType == EQUIP_REAGENT || equipType == EQUIP_POTION || equipType == EQUIP_MESSAGE_SCROLL))
Ritor1
parents:
diff changeset
1041 return 4;
Ritor1
parents:
diff changeset
1042 break;
Ritor1
parents:
diff changeset
1043 default:
Ritor1
parents:
diff changeset
1044 Error("(%u)", building_type);
Ritor1
parents:
diff changeset
1045 break;
Ritor1
parents:
diff changeset
1046 }
Ritor1
parents:
diff changeset
1047 if (pItem->IsStolen())
Ritor1
parents:
diff changeset
1048 return 6;
Ritor1
parents:
diff changeset
1049
Ritor1
parents:
diff changeset
1050 multiplier = p2DEvents[BuildID_2Events - 1].fPriceMultiplier;
Ritor1
parents:
diff changeset
1051 switch (ShopMenuType)
Ritor1
parents:
diff changeset
1052 {
Ritor1
parents:
diff changeset
1053 case 2:
Ritor1
parents:
diff changeset
1054 price = GetBuyingPrice(itemValue, multiplier);
Ritor1
parents:
diff changeset
1055 break;
Ritor1
parents:
diff changeset
1056 case 3:
Ritor1
parents:
diff changeset
1057 if (pItem->IsBroken())
Ritor1
parents:
diff changeset
1058 price = 1;
Ritor1
parents:
diff changeset
1059 else
Ritor1
parents:
diff changeset
1060 price = this->GetPriceSell(itemValue, multiplier);
Ritor1
parents:
diff changeset
1061 break;
Ritor1
parents:
diff changeset
1062 case 4:
Ritor1
parents:
diff changeset
1063 price = this->GetPriceIdentification(multiplier);
Ritor1
parents:
diff changeset
1064 break;
Ritor1
parents:
diff changeset
1065 case 5:
Ritor1
parents:
diff changeset
1066 price = this->GetPriceRepair(itemValue, multiplier);
Ritor1
parents:
diff changeset
1067 break;
Ritor1
parents:
diff changeset
1068 default:
Ritor1
parents:
diff changeset
1069 Error("(%u)", ShopMenuType);
Ritor1
parents:
diff changeset
1070 break;
Ritor1
parents:
diff changeset
1071 }
Ritor1
parents:
diff changeset
1072 if ( merchantLevel )
Ritor1
parents:
diff changeset
1073 {
Ritor1
parents:
diff changeset
1074 if (price == itemValue)
Ritor1
parents:
diff changeset
1075 {
Ritor1
parents:
diff changeset
1076 return 3;
Ritor1
parents:
diff changeset
1077 }
Ritor1
parents:
diff changeset
1078 else
Ritor1
parents:
diff changeset
1079 {
Ritor1
parents:
diff changeset
1080 return 2;
Ritor1
parents:
diff changeset
1081 }
Ritor1
parents:
diff changeset
1082 }
Ritor1
parents:
diff changeset
1083 else
Ritor1
parents:
diff changeset
1084 {
Ritor1
parents:
diff changeset
1085 return 1;
Ritor1
parents:
diff changeset
1086 }
Ritor1
parents:
diff changeset
1087 }
Ritor1
parents:
diff changeset
1088
Ritor1
parents:
diff changeset
1089 //----- (0049107D) --------------------------------------------------------
Ritor1
parents:
diff changeset
1090 int Player::GetBodybuilding()
Ritor1
parents:
diff changeset
1091 {
Ritor1
parents:
diff changeset
1092 int v1; // al@1
Ritor1
parents:
diff changeset
1093
Ritor1
parents:
diff changeset
1094 v1 = GetActualSkillLevel(PLAYER_SKILL_BODYBUILDING);
Ritor1
parents:
diff changeset
1095 int multiplier = GetMultiplierForSkillLevel(v1, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
1096 return multiplier * (v1 & 0x3F);
Ritor1
parents:
diff changeset
1097 }
Ritor1
parents:
diff changeset
1098
Ritor1
parents:
diff changeset
1099 //----- (004910A8) --------------------------------------------------------
Ritor1
parents:
diff changeset
1100 int Player::GetMeditation()
Ritor1
parents:
diff changeset
1101 {
Ritor1
parents:
diff changeset
1102 int v1; // al@1
Ritor1
parents:
diff changeset
1103
Ritor1
parents:
diff changeset
1104 v1 = GetActualSkillLevel(PLAYER_SKILL_MEDITATION);
Ritor1
parents:
diff changeset
1105 int multiplier = GetMultiplierForSkillLevel(v1, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
1106 return multiplier * (v1 & 0x3F);
Ritor1
parents:
diff changeset
1107 }
Ritor1
parents:
diff changeset
1108
Ritor1
parents:
diff changeset
1109 //----- (004910D3) --------------------------------------------------------
Ritor1
parents:
diff changeset
1110 bool Player::CanIdentify( ItemGen *pItem )
Ritor1
parents:
diff changeset
1111 {
Ritor1
parents:
diff changeset
1112 unsigned __int16 v2; // ax@1
Ritor1
parents:
diff changeset
1113 int v5; // edi@7
Ritor1
parents:
diff changeset
1114 if (CheckHiredNPCSpeciality(Scholar))
Ritor1
parents:
diff changeset
1115 return true;
Ritor1
parents:
diff changeset
1116
Ritor1
parents:
diff changeset
1117 v2 = GetActualSkillLevel(PLAYER_SKILL_ITEM_ID);
Ritor1
parents:
diff changeset
1118 if ( (signed int)SkillToMastery(v2) >= 4 )
Ritor1
parents:
diff changeset
1119 return true;
Ritor1
parents:
diff changeset
1120
Ritor1
parents:
diff changeset
1121 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
1122 v5 = multiplier * (v2 & 0x3F);
Ritor1
parents:
diff changeset
1123 return v5 >= pItemsTable->pItems[pItem->uItemID].uItemID_Rep_St;
Ritor1
parents:
diff changeset
1124 }
Ritor1
parents:
diff changeset
1125
Ritor1
parents:
diff changeset
1126 //----- (00491151) --------------------------------------------------------
Ritor1
parents:
diff changeset
1127 bool Player::CanRepair( ItemGen *pItem )
Ritor1
parents:
diff changeset
1128 {
Ritor1
parents:
diff changeset
1129 unsigned __int16 v2; // ax@1
Ritor1
parents:
diff changeset
1130 int v5; // edi@7
Ritor1
parents:
diff changeset
1131
Ritor1
parents:
diff changeset
1132 ITEM_EQUIP_TYPE equipType = pItem->GetItemEquipType();
Ritor1
parents:
diff changeset
1133 if (CheckHiredNPCSpeciality(Smith) && equipType <= 2 ||
Ritor1
parents:
diff changeset
1134 CheckHiredNPCSpeciality(Armorer) && equipType >= 3 && equipType <= 9 ||
Ritor1
parents:
diff changeset
1135 CheckHiredNPCSpeciality(Alchemist) && equipType >= 9 )
Ritor1
parents:
diff changeset
1136 return true;
Ritor1
parents:
diff changeset
1137
Ritor1
parents:
diff changeset
1138 v2 = GetActualSkillLevel(PLAYER_SKILL_REPAIR);
Ritor1
parents:
diff changeset
1139 if ( (signed int)SkillToMastery(v2) >= 4 )
Ritor1
parents:
diff changeset
1140 return true;
Ritor1
parents:
diff changeset
1141
Ritor1
parents:
diff changeset
1142 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
1143 v5 = multiplier * (v2 & 0x3F);
Ritor1
parents:
diff changeset
1144 return v5 >= pItemsTable->pItems[pItem->uItemID].uItemID_Rep_St;
Ritor1
parents:
diff changeset
1145 }
Ritor1
parents:
diff changeset
1146
Ritor1
parents:
diff changeset
1147 //----- (004911F3) --------------------------------------------------------
Ritor1
parents:
diff changeset
1148 int Player::GetMerchant()
Ritor1
parents:
diff changeset
1149 {
Ritor1
parents:
diff changeset
1150 unsigned __int16 v2; // ax@1
Ritor1
parents:
diff changeset
1151 int v5; // edi@1
Ritor1
parents:
diff changeset
1152 int v7; // eax@3
Ritor1
parents:
diff changeset
1153
Ritor1
parents:
diff changeset
1154 v2 = GetActualSkillLevel(PLAYER_SKILL_MERCHANT);
Ritor1
parents:
diff changeset
1155 if ( SkillToMastery(v2) >= 4 )
Ritor1
parents:
diff changeset
1156 return 10000;
Ritor1
parents:
diff changeset
1157
Ritor1
parents:
diff changeset
1158 v7 = pParty->GetPartyReputation();
Ritor1
parents:
diff changeset
1159 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
1160 v5 = multiplier * (v2 & 0x3F);
Ritor1
parents:
diff changeset
1161 if (v5 == 0)
Ritor1
parents:
diff changeset
1162 {
Ritor1
parents:
diff changeset
1163 return -v7;
Ritor1
parents:
diff changeset
1164 }
Ritor1
parents:
diff changeset
1165 return v5 - v7 + 7;
Ritor1
parents:
diff changeset
1166 }
Ritor1
parents:
diff changeset
1167
Ritor1
parents:
diff changeset
1168 //----- (0049125A) --------------------------------------------------------
Ritor1
parents:
diff changeset
1169 int Player::GetPerception()
Ritor1
parents:
diff changeset
1170 {
Ritor1
parents:
diff changeset
1171 unsigned __int16 v2; // ax@1
Ritor1
parents:
diff changeset
1172 int v5; // edi@1
Ritor1
parents:
diff changeset
1173
Ritor1
parents:
diff changeset
1174 v2 = GetActualSkillLevel(PLAYER_SKILL_PERCEPTION);
Ritor1
parents:
diff changeset
1175 if ( SkillToMastery(v2) >= 4 )
Ritor1
parents:
diff changeset
1176 return 10000;
Ritor1
parents:
diff changeset
1177
Ritor1
parents:
diff changeset
1178 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
1179 v5 = multiplier * (v2 & 0x3F);
Ritor1
parents:
diff changeset
1180 return v5;
Ritor1
parents:
diff changeset
1181 }
Ritor1
parents:
diff changeset
1182
Ritor1
parents:
diff changeset
1183 //----- (004912B0) --------------------------------------------------------
Ritor1
parents:
diff changeset
1184 int Player::GetDisarmTrap()
Ritor1
parents:
diff changeset
1185 {
Ritor1
parents:
diff changeset
1186 unsigned __int16 v2; // ax@1
Ritor1
parents:
diff changeset
1187 int v5; // edi@1
Ritor1
parents:
diff changeset
1188
Ritor1
parents:
diff changeset
1189 v2 = GetActualSkillLevel(PLAYER_SKILL_TRAP_DISARM);
Ritor1
parents:
diff changeset
1190 if ( (signed int)SkillToMastery(v2) >= 4 )
Ritor1
parents:
diff changeset
1191 return 10000;
Ritor1
parents:
diff changeset
1192
Ritor1
parents:
diff changeset
1193 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
1194 if ( HasEnchantedItemEquipped(35) ) //only the real skill level is supposed to be added again, not the multiplied value
Ritor1
parents:
diff changeset
1195 multiplier++;
Ritor1
parents:
diff changeset
1196 v5 = multiplier * (v2 & 0x3F);
Ritor1
parents:
diff changeset
1197 return v5;
Ritor1
parents:
diff changeset
1198 }
Ritor1
parents:
diff changeset
1199
Ritor1
parents:
diff changeset
1200 //----- (00491317) --------------------------------------------------------
Ritor1
parents:
diff changeset
1201 char Player::GetLearningPercent()
Ritor1
parents:
diff changeset
1202 {
Ritor1
parents:
diff changeset
1203 int v2; // eax@1
Ritor1
parents:
diff changeset
1204
Ritor1
parents:
diff changeset
1205 v2 = GetActualSkillLevel(PLAYER_SKILL_LEARNING);
Ritor1
parents:
diff changeset
1206 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
1207 return multiplier * v2 + 9;
Ritor1
parents:
diff changeset
1208 }
Ritor1
parents:
diff changeset
1209
Ritor1
parents:
diff changeset
1210 //----- (0048C6AF) --------------------------------------------------------
Ritor1
parents:
diff changeset
1211 Player::Player()
Ritor1
parents:
diff changeset
1212 {
Ritor1
parents:
diff changeset
1213 memset(&pEquipment, 0, sizeof(PlayerEquipment));
Ritor1
parents:
diff changeset
1214 pInventoryMatrix.fill(0);
Ritor1
parents:
diff changeset
1215 for (uint i = 0; i < 126; ++i)
Ritor1
parents:
diff changeset
1216 pInventoryItemList[i].Reset();
Ritor1
parents:
diff changeset
1217 for (uint i = 0; i < 12; ++i)
Ritor1
parents:
diff changeset
1218 pEquippedItems[i].Reset();
Ritor1
parents:
diff changeset
1219
Ritor1
parents:
diff changeset
1220
Ritor1
parents:
diff changeset
1221 for (uint i = 0; i < 24; ++i)
Ritor1
parents:
diff changeset
1222 {
Ritor1
parents:
diff changeset
1223 pPlayerBuffs[i].uSkill = 0;
Ritor1
parents:
diff changeset
1224 pPlayerBuffs[i].uSkill = 0;
Ritor1
parents:
diff changeset
1225 pPlayerBuffs[i].uPower = 0;
Ritor1
parents:
diff changeset
1226 pPlayerBuffs[i].uExpireTime = 0;
Ritor1
parents:
diff changeset
1227 pPlayerBuffs[i].uCaster = 0;
Ritor1
parents:
diff changeset
1228 pPlayerBuffs[i].uFlags = 0;
Ritor1
parents:
diff changeset
1229 }
Ritor1
parents:
diff changeset
1230
Ritor1
parents:
diff changeset
1231 pName[0] = 0;
Ritor1
parents:
diff changeset
1232 uCurrentFace = 0;
Ritor1
parents:
diff changeset
1233 uVoiceID = 0;
Ritor1
parents:
diff changeset
1234 pConditions.fill(0);
Ritor1
parents:
diff changeset
1235
Ritor1
parents:
diff changeset
1236 field_BB = 0;
Ritor1
parents:
diff changeset
1237
Ritor1
parents:
diff changeset
1238 uMight = uMightBonus = 0;
Ritor1
parents:
diff changeset
1239 uIntelligence = uIntelligenceBonus = 0;
Ritor1
parents:
diff changeset
1240 uWillpower = uWillpowerBonus = 0;
Ritor1
parents:
diff changeset
1241 uEndurance = uEnduranceBonus = 0;
Ritor1
parents:
diff changeset
1242 uSpeed = uSpeedBonus = 0;
Ritor1
parents:
diff changeset
1243 uAccuracy = uAccuracyBonus = 0;
Ritor1
parents:
diff changeset
1244 uLuck = uLuckBonus = 0;
Ritor1
parents:
diff changeset
1245 uLevel = sLevelModifier = 0;
Ritor1
parents:
diff changeset
1246 sAgeModifier = 0;
Ritor1
parents:
diff changeset
1247 sACModifier = 0;
Ritor1
parents:
diff changeset
1248
Ritor1
parents:
diff changeset
1249 // memset(field_1F5, 0, 30);
Ritor1
parents:
diff changeset
1250 pure_luck_used=0;
Ritor1
parents:
diff changeset
1251 pure_speed_used=0;
Ritor1
parents:
diff changeset
1252 pure_intellect_used=0;
Ritor1
parents:
diff changeset
1253 pure_endurance_used=0;
Ritor1
parents:
diff changeset
1254 pure_willpower_used=0;
Ritor1
parents:
diff changeset
1255 pure_accuracy_used=0;
Ritor1
parents:
diff changeset
1256 pure_might_used=0;
Ritor1
parents:
diff changeset
1257
Ritor1
parents:
diff changeset
1258 sResFireBase = sResFireBonus = 0;
Ritor1
parents:
diff changeset
1259 sResAirBase = sResAirBonus = 0;
Ritor1
parents:
diff changeset
1260 sResWaterBase = sResWaterBonus = 0;
Ritor1
parents:
diff changeset
1261 sResEarthBase = sResEarthBonus = 0;
Ritor1
parents:
diff changeset
1262 sResMagicBase = sResMagicBonus = 0;
Ritor1
parents:
diff changeset
1263 sResSpiritBase = sResSpiritBonus = 0;
Ritor1
parents:
diff changeset
1264 sResMindBase = sResMindBonus = 0;
Ritor1
parents:
diff changeset
1265 sResBodyBase = sResBodyBonus = 0;
Ritor1
parents:
diff changeset
1266 sResLightBase = sResLightBonus = 0;
Ritor1
parents:
diff changeset
1267 sResDarkBase = sResDarkBonus = 0;
Ritor1
parents:
diff changeset
1268
Ritor1
parents:
diff changeset
1269 uTimeToRecovery = 0;
Ritor1
parents:
diff changeset
1270
Ritor1
parents:
diff changeset
1271 uSkillPoints = 0;
Ritor1
parents:
diff changeset
1272
Ritor1
parents:
diff changeset
1273 sHealth = 0;
Ritor1
parents:
diff changeset
1274 uFullHealthBonus = 0;
Ritor1
parents:
diff changeset
1275 _health_related = 0;
Ritor1
parents:
diff changeset
1276
Ritor1
parents:
diff changeset
1277 sMana = 0;
Ritor1
parents:
diff changeset
1278 uFullManaBonus = 0;
Ritor1
parents:
diff changeset
1279 _mana_related = 0;
Ritor1
parents:
diff changeset
1280
Ritor1
parents:
diff changeset
1281 uQuickSpell = 0;
Ritor1
parents:
diff changeset
1282 memset(pInstalledBeacons.data(), 0, 5 * sizeof(LloydBeacon));
Ritor1
parents:
diff changeset
1283
Ritor1
parents:
diff changeset
1284 _some_attack_bonus = 0;
Ritor1
parents:
diff changeset
1285 field_1A91 = 0;
Ritor1
parents:
diff changeset
1286 _melee_dmg_bonus = 0;
Ritor1
parents:
diff changeset
1287 field_1A93 = 0;
Ritor1
parents:
diff changeset
1288 _ranged_atk_bonus = 0;
Ritor1
parents:
diff changeset
1289 field_1A95 = 0;
Ritor1
parents:
diff changeset
1290 _ranged_dmg_bonus = 0;
Ritor1
parents:
diff changeset
1291 field_1A97 = 0;
Ritor1
parents:
diff changeset
1292
Ritor1
parents:
diff changeset
1293 expression = CHARACTER_EXPRESSION_INVALID;
Ritor1
parents:
diff changeset
1294 uExpressionTimePassed = 0;
Ritor1
parents:
diff changeset
1295 uExpressionTimeLength = 0;
Ritor1
parents:
diff changeset
1296
Ritor1
parents:
diff changeset
1297 uNumDivineInterventionCastsThisDay = 0;
Ritor1
parents:
diff changeset
1298 uNumArmageddonCasts = 0;
Ritor1
parents:
diff changeset
1299 uNumFireSpikeCasts = 0;
Ritor1
parents:
diff changeset
1300
Ritor1
parents:
diff changeset
1301 memset(field_1988, 0, sizeof(field_1988));
Ritor1
parents:
diff changeset
1302 memset(playerEventBits, 0, sizeof(playerEventBits));
Ritor1
parents:
diff changeset
1303
Ritor1
parents:
diff changeset
1304 field_E0 = 0;
Ritor1
parents:
diff changeset
1305 field_E4 = 0;
Ritor1
parents:
diff changeset
1306 field_E8 = 0;
Ritor1
parents:
diff changeset
1307 field_EC = 0;
Ritor1
parents:
diff changeset
1308 field_F0 = 0;
Ritor1
parents:
diff changeset
1309 field_F4 = 0;
Ritor1
parents:
diff changeset
1310 field_F8 = 0;
Ritor1
parents:
diff changeset
1311 field_FC = 0;
Ritor1
parents:
diff changeset
1312 field_100 = 0;
Ritor1
parents:
diff changeset
1313 field_104 = 0;
Ritor1
parents:
diff changeset
1314
Ritor1
parents:
diff changeset
1315 _expression21_animtime = 0;
Ritor1
parents:
diff changeset
1316 _expression21_frameset = 0;
Ritor1
parents:
diff changeset
1317
Ritor1
parents:
diff changeset
1318 lastOpenedSpellbookPage = 0;
Ritor1
parents:
diff changeset
1319 }
Ritor1
parents:
diff changeset
1320
Ritor1
parents:
diff changeset
1321
Ritor1
parents:
diff changeset
1322 //----- (0048C855) --------------------------------------------------------
Ritor1
parents:
diff changeset
1323 int Player::GetBaseStrength()
Ritor1
parents:
diff changeset
1324 {
Ritor1
parents:
diff changeset
1325 return this->uMight + GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH);
Ritor1
parents:
diff changeset
1326 }
Ritor1
parents:
diff changeset
1327
Ritor1
parents:
diff changeset
1328 //----- (0048C86C) --------------------------------------------------------
Ritor1
parents:
diff changeset
1329 int Player::GetBaseIntelligence()
Ritor1
parents:
diff changeset
1330 {
Ritor1
parents:
diff changeset
1331 return this->uIntelligence + GetItemsBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE);
Ritor1
parents:
diff changeset
1332 }
Ritor1
parents:
diff changeset
1333
Ritor1
parents:
diff changeset
1334 //----- (0048C883) --------------------------------------------------------
Ritor1
parents:
diff changeset
1335 int Player::GetBaseWillpower()
Ritor1
parents:
diff changeset
1336 {
Ritor1
parents:
diff changeset
1337 return this->uWillpower + GetItemsBonus(CHARACTER_ATTRIBUTE_WILLPOWER);
Ritor1
parents:
diff changeset
1338 }
Ritor1
parents:
diff changeset
1339
Ritor1
parents:
diff changeset
1340 //----- (0048C89A) --------------------------------------------------------
Ritor1
parents:
diff changeset
1341 int Player::GetBaseEndurance()
Ritor1
parents:
diff changeset
1342 {
Ritor1
parents:
diff changeset
1343 return this->uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE);
Ritor1
parents:
diff changeset
1344 }
Ritor1
parents:
diff changeset
1345
Ritor1
parents:
diff changeset
1346 //----- (0048C8B1) --------------------------------------------------------
Ritor1
parents:
diff changeset
1347 int Player::GetBaseAccuracy()
Ritor1
parents:
diff changeset
1348 {
Ritor1
parents:
diff changeset
1349 return this->uAccuracy + GetItemsBonus(CHARACTER_ATTRIBUTE_ACCURACY);
Ritor1
parents:
diff changeset
1350 }
Ritor1
parents:
diff changeset
1351
Ritor1
parents:
diff changeset
1352 //----- (0048C8C8) --------------------------------------------------------
Ritor1
parents:
diff changeset
1353 int Player::GetBaseSpeed()
Ritor1
parents:
diff changeset
1354 {
Ritor1
parents:
diff changeset
1355 return this->uSpeed + GetItemsBonus(CHARACTER_ATTRIBUTE_SPEED);
Ritor1
parents:
diff changeset
1356 }
Ritor1
parents:
diff changeset
1357
Ritor1
parents:
diff changeset
1358 //----- (0048C8DF) --------------------------------------------------------
Ritor1
parents:
diff changeset
1359 int Player::GetBaseLuck()
Ritor1
parents:
diff changeset
1360 {
Ritor1
parents:
diff changeset
1361 return this->uLuck + GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK);
Ritor1
parents:
diff changeset
1362 }
Ritor1
parents:
diff changeset
1363
Ritor1
parents:
diff changeset
1364 //----- (0048C8F6) --------------------------------------------------------
Ritor1
parents:
diff changeset
1365 int Player::GetBaseLevel()
Ritor1
parents:
diff changeset
1366 {
Ritor1
parents:
diff changeset
1367 return this->uLevel + GetItemsBonus(CHARACTER_ATTRIBUTE_LEVEL);
Ritor1
parents:
diff changeset
1368 }
Ritor1
parents:
diff changeset
1369
Ritor1
parents:
diff changeset
1370 //----- (0048C90D) --------------------------------------------------------
Ritor1
parents:
diff changeset
1371 int Player::GetActualLevel()
Ritor1
parents:
diff changeset
1372 {
Ritor1
parents:
diff changeset
1373 return uLevel + sLevelModifier +
Ritor1
parents:
diff changeset
1374 GetMagicalBonus(CHARACTER_ATTRIBUTE_LEVEL) +
Ritor1
parents:
diff changeset
1375 GetItemsBonus(CHARACTER_ATTRIBUTE_LEVEL);
Ritor1
parents:
diff changeset
1376 }
Ritor1
parents:
diff changeset
1377
Ritor1
parents:
diff changeset
1378 //----- (0048C93C) --------------------------------------------------------
Ritor1
parents:
diff changeset
1379 int Player::GetActualMight()
Ritor1
parents:
diff changeset
1380 {
Ritor1
parents:
diff changeset
1381 return GetActualAttribute(CHARACTER_ATTRIBUTE_STRENGTH, &Player::uMight, &Player::uMightBonus);
Ritor1
parents:
diff changeset
1382 }
Ritor1
parents:
diff changeset
1383
Ritor1
parents:
diff changeset
1384 //----- (0048C9C2) --------------------------------------------------------
Ritor1
parents:
diff changeset
1385 int Player::GetActualIntelligence()
Ritor1
parents:
diff changeset
1386 {
Ritor1
parents:
diff changeset
1387 return GetActualAttribute(CHARACTER_ATTRIBUTE_INTELLIGENCE, &Player::uIntelligence, &Player::uIntelligenceBonus);
Ritor1
parents:
diff changeset
1388 }
Ritor1
parents:
diff changeset
1389
Ritor1
parents:
diff changeset
1390 //----- (0048CA3F) --------------------------------------------------------
Ritor1
parents:
diff changeset
1391 int Player::GetActualWillpower()
Ritor1
parents:
diff changeset
1392 {
Ritor1
parents:
diff changeset
1393 return GetActualAttribute(CHARACTER_ATTRIBUTE_WILLPOWER, &Player::uWillpower, &Player::uWillpowerBonus);
Ritor1
parents:
diff changeset
1394 }
Ritor1
parents:
diff changeset
1395
Ritor1
parents:
diff changeset
1396 //----- (0048CABC) --------------------------------------------------------
Ritor1
parents:
diff changeset
1397 int Player::GetActualEndurance()
Ritor1
parents:
diff changeset
1398 {
Ritor1
parents:
diff changeset
1399 return GetActualAttribute(CHARACTER_ATTRIBUTE_ENDURANCE, &Player::uEndurance, &Player::uEnduranceBonus);
Ritor1
parents:
diff changeset
1400 }
Ritor1
parents:
diff changeset
1401
Ritor1
parents:
diff changeset
1402 //----- (0048CB39) --------------------------------------------------------
Ritor1
parents:
diff changeset
1403 int Player::GetActualAccuracy()
Ritor1
parents:
diff changeset
1404 {
Ritor1
parents:
diff changeset
1405 return GetActualAttribute(CHARACTER_ATTRIBUTE_ACCURACY, &Player::uAccuracy, &Player::uAccuracyBonus);
Ritor1
parents:
diff changeset
1406 }
Ritor1
parents:
diff changeset
1407
Ritor1
parents:
diff changeset
1408 //----- (0048CBB6) --------------------------------------------------------
Ritor1
parents:
diff changeset
1409 int Player::GetActualSpeed()
Ritor1
parents:
diff changeset
1410 {
Ritor1
parents:
diff changeset
1411 return GetActualAttribute(CHARACTER_ATTRIBUTE_SPEED, &Player::uSpeed, &Player::uSpeedBonus);
Ritor1
parents:
diff changeset
1412 }
Ritor1
parents:
diff changeset
1413
Ritor1
parents:
diff changeset
1414 //----- (0048CC33) --------------------------------------------------------
Ritor1
parents:
diff changeset
1415 int Player::GetActualLuck()
Ritor1
parents:
diff changeset
1416 {
Ritor1
parents:
diff changeset
1417 signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1
Ritor1
parents:
diff changeset
1418
Ritor1
parents:
diff changeset
1419 npc_luck_bonus = 0;
Ritor1
parents:
diff changeset
1420 if ( CheckHiredNPCSpeciality(Fool) )
Ritor1
parents:
diff changeset
1421 npc_luck_bonus = 5;
Ritor1
parents:
diff changeset
1422 if ( CheckHiredNPCSpeciality(ChimneySweep) )
Ritor1
parents:
diff changeset
1423 npc_luck_bonus += 20;
Ritor1
parents:
diff changeset
1424 if ( CheckHiredNPCSpeciality(Psychic) )
Ritor1
parents:
diff changeset
1425 npc_luck_bonus += 10;
Ritor1
parents:
diff changeset
1426
Ritor1
parents:
diff changeset
1427 return GetActualAttribute(CHARACTER_ATTRIBUTE_LUCK, &Player::uLuck, &Player::uLuckBonus)
Ritor1
parents:
diff changeset
1428 + npc_luck_bonus;
Ritor1
parents:
diff changeset
1429 }
Ritor1
parents:
diff changeset
1430
Ritor1
parents:
diff changeset
1431 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
1432 int Player::GetActualAttribute( CHARACTER_ATTRIBUTE_TYPE attrId, unsigned short Player::* attrValue, unsigned short Player::* attrBonus )
Ritor1
parents:
diff changeset
1433 {
Ritor1
parents:
diff changeset
1434 uint uActualAge = this->sAgeModifier + GetBaseAge();
Ritor1
parents:
diff changeset
1435 uint uAgeingMultiplier = 100;
Ritor1
parents:
diff changeset
1436 for (uint i = 0; i < 4; ++i)
Ritor1
parents:
diff changeset
1437 {
Ritor1
parents:
diff changeset
1438 if (uActualAge >= pAgeingTable[i])
Ritor1
parents:
diff changeset
1439 uAgeingMultiplier = pAgingAttributeModifier[attrId][i];
Ritor1
parents:
diff changeset
1440 else
Ritor1
parents:
diff changeset
1441 break;
Ritor1
parents:
diff changeset
1442 }
Ritor1
parents:
diff changeset
1443
Ritor1
parents:
diff changeset
1444 uchar uConditionMult = pConditionAttributeModifier[attrId][GetMajorConditionIdx()];
Ritor1
parents:
diff changeset
1445 int magicBonus = GetMagicalBonus(attrId);
Ritor1
parents:
diff changeset
1446 int itemBonus = GetItemsBonus(attrId);
Ritor1
parents:
diff changeset
1447 return uConditionMult * uAgeingMultiplier * this->*attrValue / 100 / 100
Ritor1
parents:
diff changeset
1448 + magicBonus
Ritor1
parents:
diff changeset
1449 + itemBonus
Ritor1
parents:
diff changeset
1450 + this->*attrBonus;
Ritor1
parents:
diff changeset
1451 }
Ritor1
parents:
diff changeset
1452
Ritor1
parents:
diff changeset
1453 //----- (0048CCF5) --------------------------------------------------------
Ritor1
parents:
diff changeset
1454 int Player::GetActualAttack( bool a2 )
Ritor1
parents:
diff changeset
1455 {
Ritor1
parents:
diff changeset
1456 int v3; // eax@1
Ritor1
parents:
diff changeset
1457 int v4; // edi@1
Ritor1
parents:
diff changeset
1458 int v5; // ebx@1
Ritor1
parents:
diff changeset
1459 int v6; // ebp@1
Ritor1
parents:
diff changeset
1460
Ritor1
parents:
diff changeset
1461 v3 = GetActualAccuracy();
Ritor1
parents:
diff changeset
1462 v4 = GetParameterBonus(v3);
Ritor1
parents:
diff changeset
1463 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK);
Ritor1
parents:
diff changeset
1464 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2);
Ritor1
parents:
diff changeset
1465 return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + this->_some_attack_bonus;
Ritor1
parents:
diff changeset
1466 }
Ritor1
parents:
diff changeset
1467
Ritor1
parents:
diff changeset
1468 //----- (0048CD45) --------------------------------------------------------
Ritor1
parents:
diff changeset
1469 int Player::GetMeleeDamageMinimal()
Ritor1
parents:
diff changeset
1470 {
Ritor1
parents:
diff changeset
1471 int v2; // eax@1
Ritor1
parents:
diff changeset
1472 int v3; // esi@1
Ritor1
parents:
diff changeset
1473 int v4; // esi@1
Ritor1
parents:
diff changeset
1474 int v5; // esi@1
Ritor1
parents:
diff changeset
1475 signed int result; // eax@1
Ritor1
parents:
diff changeset
1476
Ritor1
parents:
diff changeset
1477 v2 = GetActualMight();
Ritor1
parents:
diff changeset
1478 v3 = GetParameterBonus(v2);
Ritor1
parents:
diff changeset
1479 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN) + v3;
Ritor1
parents:
diff changeset
1480 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4;
Ritor1
parents:
diff changeset
1481 result = _melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
Ritor1
parents:
diff changeset
1482 if ( result < 1 )
Ritor1
parents:
diff changeset
1483 result = 1;
Ritor1
parents:
diff changeset
1484 return result;
Ritor1
parents:
diff changeset
1485 }
Ritor1
parents:
diff changeset
1486
Ritor1
parents:
diff changeset
1487 //----- (0048CD90) --------------------------------------------------------
Ritor1
parents:
diff changeset
1488 int Player::GetMeleeDamageMaximal()
Ritor1
parents:
diff changeset
1489 {
Ritor1
parents:
diff changeset
1490 int v2; // eax@1
Ritor1
parents:
diff changeset
1491 int v3; // esi@1
Ritor1
parents:
diff changeset
1492 int v4; // esi@1
Ritor1
parents:
diff changeset
1493 int v5; // esi@1
Ritor1
parents:
diff changeset
1494 int v6; // esi@1
Ritor1
parents:
diff changeset
1495 signed int result; // eax@1
Ritor1
parents:
diff changeset
1496
Ritor1
parents:
diff changeset
1497 v2 = GetActualMight();
Ritor1
parents:
diff changeset
1498 v3 = GetParameterBonus(v2);
Ritor1
parents:
diff changeset
1499 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX) + v3;
Ritor1
parents:
diff changeset
1500 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4;
Ritor1
parents:
diff changeset
1501 v6 = this->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
Ritor1
parents:
diff changeset
1502 result = 1;
Ritor1
parents:
diff changeset
1503 if ( v6 >= 1 )
Ritor1
parents:
diff changeset
1504 result = v6;
Ritor1
parents:
diff changeset
1505 return result;
Ritor1
parents:
diff changeset
1506 }
Ritor1
parents:
diff changeset
1507
Ritor1
parents:
diff changeset
1508 //----- (0048CDDB) --------------------------------------------------------
Ritor1
parents:
diff changeset
1509 int Player::CalculateMeleeDamageTo( bool ignoreSkillBonus, bool ignoreOffhand, unsigned int uTargetActorID )
Ritor1
parents:
diff changeset
1510 {
Ritor1
parents:
diff changeset
1511 int dmgSum; // esi@62
Ritor1
parents:
diff changeset
1512 signed int result; // eax@64
Ritor1
parents:
diff changeset
1513 int mainWpnDmg; // [sp+18h] [bp-8h]@1
Ritor1
parents:
diff changeset
1514 int offHndWpnDmg; // [sp+1Ch] [bp-4h]@1
Ritor1
parents:
diff changeset
1515
Ritor1
parents:
diff changeset
1516 offHndWpnDmg = 0;
Ritor1
parents:
diff changeset
1517 mainWpnDmg = 0;
Ritor1
parents:
diff changeset
1518 if ( IsUnarmed() )
Ritor1
parents:
diff changeset
1519 {
Ritor1
parents:
diff changeset
1520 mainWpnDmg = rand() % 3 + 1;
Ritor1
parents:
diff changeset
1521 }
Ritor1
parents:
diff changeset
1522 else
Ritor1
parents:
diff changeset
1523 {
Ritor1
parents:
diff changeset
1524 if ( HasItemEquipped(EQUIP_TWO_HANDED) )
Ritor1
parents:
diff changeset
1525 {
Ritor1
parents:
diff changeset
1526 ItemGen *mainHandItemGen = this->GetMainHandItem();
Ritor1
parents:
diff changeset
1527 int itemId = mainHandItemGen->uItemID;
Ritor1
parents:
diff changeset
1528 bool addOneDice = false;
Ritor1
parents:
diff changeset
1529 if ( pItemsTable->pItems[itemId].uSkillType == PLAYER_SKILL_SPEAR && !this->pEquipment.uShield )
Ritor1
parents:
diff changeset
1530 addOneDice = true;
Ritor1
parents:
diff changeset
1531 mainWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(mainHandItemGen, uTargetActorID, addOneDice);
Ritor1
parents:
diff changeset
1532 }
Ritor1
parents:
diff changeset
1533 if ( !ignoreOffhand )
Ritor1
parents:
diff changeset
1534 {
Ritor1
parents:
diff changeset
1535 if ( this->HasItemEquipped(EQUIP_SINGLE_HANDED) )
Ritor1
parents:
diff changeset
1536 {
Ritor1
parents:
diff changeset
1537 ItemGen *offHandItemGen = (ItemGen *)&this->pInventoryItemList[this->pEquipment.uShield - 1];
Ritor1
parents:
diff changeset
1538 if ( offHandItemGen->GetItemEquipType() != EQUIP_SHIELD )
Ritor1
parents:
diff changeset
1539 {
Ritor1
parents:
diff changeset
1540 offHndWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(offHandItemGen, uTargetActorID, false);
Ritor1
parents:
diff changeset
1541 }
Ritor1
parents:
diff changeset
1542 }
Ritor1
parents:
diff changeset
1543 }
Ritor1
parents:
diff changeset
1544 }
Ritor1
parents:
diff changeset
1545 dmgSum = mainWpnDmg + offHndWpnDmg;
Ritor1
parents:
diff changeset
1546 if ( !ignoreSkillBonus )
Ritor1
parents:
diff changeset
1547 {
Ritor1
parents:
diff changeset
1548 int might = GetActualMight();
Ritor1
parents:
diff changeset
1549 int mightBonus = GetParameterBonus(might);
Ritor1
parents:
diff changeset
1550 int mightAndSkillbonus = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + mightBonus;
Ritor1
parents:
diff changeset
1551 dmgSum += this->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + mightAndSkillbonus;
Ritor1
parents:
diff changeset
1552 }
Ritor1
parents:
diff changeset
1553 result = 1;
Ritor1
parents:
diff changeset
1554 if ( dmgSum >= 1 )
Ritor1
parents:
diff changeset
1555 result = dmgSum;
Ritor1
parents:
diff changeset
1556 return result;
Ritor1
parents:
diff changeset
1557 }
Ritor1
parents:
diff changeset
1558
Ritor1
parents:
diff changeset
1559
Ritor1
parents:
diff changeset
1560 int Player::CalculateMeleeDmgToEnemyWithWeapon( ItemGen * weapon, unsigned int uTargetActorID , bool addOneDice )
Ritor1
parents:
diff changeset
1561 {
Ritor1
parents:
diff changeset
1562 int itemId = weapon->uItemID;
Ritor1
parents:
diff changeset
1563 int diceCount = pItemsTable->pItems[itemId].uDamageDice;
Ritor1
parents:
diff changeset
1564 if (addOneDice)
Ritor1
parents:
diff changeset
1565 {
Ritor1
parents:
diff changeset
1566 diceCount++;
Ritor1
parents:
diff changeset
1567 }
Ritor1
parents:
diff changeset
1568 int diceSides = pItemsTable->pItems[itemId].uDamageRoll;
Ritor1
parents:
diff changeset
1569 int diceResult = 0;
Ritor1
parents:
diff changeset
1570 for (int i = 0; i < diceCount; i++)
Ritor1
parents:
diff changeset
1571 {
Ritor1
parents:
diff changeset
1572 diceResult += rand() % diceSides + 1;
Ritor1
parents:
diff changeset
1573 }
Ritor1
parents:
diff changeset
1574 int totalDmg = pItemsTable->pItems[itemId].uDamageMod + diceResult;
Ritor1
parents:
diff changeset
1575 if ( uTargetActorID > 0)
Ritor1
parents:
diff changeset
1576 {
Ritor1
parents:
diff changeset
1577 int enchType = weapon->uSpecEnchantmentType;
Ritor1
parents:
diff changeset
1578 if ( MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_UNDEAD) && (enchType == 64 || itemId == ITEM_ARTIFACT_GHOULSBANE || itemId == ITEM_ARTIFACT_GIBBET || itemId == ITEM_RELIC_JUSTICE) )
Ritor1
parents:
diff changeset
1579 {
Ritor1
parents:
diff changeset
1580 totalDmg *= 2;
Ritor1
parents:
diff changeset
1581 }
Ritor1
parents:
diff changeset
1582 else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_KREEGAN) && ( enchType == 39 || itemId == ITEM_ARTIFACT_GIBBET))
Ritor1
parents:
diff changeset
1583 {
Ritor1
parents:
diff changeset
1584 totalDmg *= 2;
Ritor1
parents:
diff changeset
1585 }
Ritor1
parents:
diff changeset
1586 else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_DRAGON) && ( enchType == 40 || itemId == ITEM_ARTIFACT_GIBBET))
Ritor1
parents:
diff changeset
1587 {
Ritor1
parents:
diff changeset
1588 totalDmg *= 2;
Ritor1
parents:
diff changeset
1589 }
Ritor1
parents:
diff changeset
1590 else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_ELF) && ( enchType == 63 || itemId == ITEM_RELIC_OLD_NICK))
Ritor1
parents:
diff changeset
1591 {
Ritor1
parents:
diff changeset
1592 totalDmg *= 2;
Ritor1
parents:
diff changeset
1593 }
Ritor1
parents:
diff changeset
1594 else if (MonsterStats::BelongsToSupertype(uTargetActorID, MONSTER_SUPERTYPE_TITAN) && ( enchType == 65 ))
Ritor1
parents:
diff changeset
1595 {
Ritor1
parents:
diff changeset
1596 totalDmg *= 2;
Ritor1
parents:
diff changeset
1597 }
Ritor1
parents:
diff changeset
1598 }
Ritor1
parents:
diff changeset
1599 if ( (signed int)SkillToMastery(this->pActiveSkills[PLAYER_SKILL_DAGGER]) >= 3
Ritor1
parents:
diff changeset
1600 && pItemsTable->pItems[itemId].uSkillType == 2
Ritor1
parents:
diff changeset
1601 && rand() % 100 < 10 )
Ritor1
parents:
diff changeset
1602 totalDmg *= 3;
Ritor1
parents:
diff changeset
1603 return totalDmg;
Ritor1
parents:
diff changeset
1604 }
Ritor1
parents:
diff changeset
1605
Ritor1
parents:
diff changeset
1606
Ritor1
parents:
diff changeset
1607 //----- (0048D0B9) --------------------------------------------------------
Ritor1
parents:
diff changeset
1608 int Player::GetRangedAttack()
Ritor1
parents:
diff changeset
1609 {
Ritor1
parents:
diff changeset
1610 int v3; // edi@3
Ritor1
parents:
diff changeset
1611 //int v4; // eax@4
Ritor1
parents:
diff changeset
1612 //int v5; // edi@4
Ritor1
parents:
diff changeset
1613 int v6; // edi@4
Ritor1
parents:
diff changeset
1614 int v7; // edi@4
Ritor1
parents:
diff changeset
1615
Ritor1
parents:
diff changeset
1616 ItemGen* mainHandItem = GetMainHandItem();
Ritor1
parents:
diff changeset
1617 if ( mainHandItem != nullptr && ( mainHandItem->uItemID < ITEM_BLASTER || mainHandItem->uItemID > ITEM_LASER_RIFLE ))
Ritor1
parents:
diff changeset
1618 {
Ritor1
parents:
diff changeset
1619 //v4 = GetActualAccuracy();
Ritor1
parents:
diff changeset
1620 //v5 = GetParameterBonus(GetActualAccuracy());
Ritor1
parents:
diff changeset
1621 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + GetParameterBonus(GetActualAccuracy());
Ritor1
parents:
diff changeset
1622 v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6;
Ritor1
parents:
diff changeset
1623 v3 = this->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7;
Ritor1
parents:
diff changeset
1624 }
Ritor1
parents:
diff changeset
1625 else
Ritor1
parents:
diff changeset
1626 {
Ritor1
parents:
diff changeset
1627 v3 = GetActualAttack(true);
Ritor1
parents:
diff changeset
1628 }
Ritor1
parents:
diff changeset
1629 return v3;
Ritor1
parents:
diff changeset
1630 }
Ritor1
parents:
diff changeset
1631
Ritor1
parents:
diff changeset
1632 //----- (0048D124) --------------------------------------------------------
Ritor1
parents:
diff changeset
1633 int Player::GetRangedDamageMin()
Ritor1
parents:
diff changeset
1634 {
Ritor1
parents:
diff changeset
1635 int v2; // edi@1
Ritor1
parents:
diff changeset
1636 int v3; // edi@1
Ritor1
parents:
diff changeset
1637 int v4; // edi@1
Ritor1
parents:
diff changeset
1638 int result; // eax@6
Ritor1
parents:
diff changeset
1639
Ritor1
parents:
diff changeset
1640 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MIN);
Ritor1
parents:
diff changeset
1641 v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2;
Ritor1
parents:
diff changeset
1642 v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3;
Ritor1
parents:
diff changeset
1643 if ( v4 >= 1 )
Ritor1
parents:
diff changeset
1644 result = v4;
Ritor1
parents:
diff changeset
1645 else
Ritor1
parents:
diff changeset
1646 result = 0;
Ritor1
parents:
diff changeset
1647 return result;
Ritor1
parents:
diff changeset
1648 }
Ritor1
parents:
diff changeset
1649
Ritor1
parents:
diff changeset
1650 //----- (0048D191) --------------------------------------------------------
Ritor1
parents:
diff changeset
1651 int Player::GetRangedDamageMax()
Ritor1
parents:
diff changeset
1652 {
Ritor1
parents:
diff changeset
1653 int v2; // edi@1
Ritor1
parents:
diff changeset
1654 int v3; // edi@1
Ritor1
parents:
diff changeset
1655 int v4; // edi@1
Ritor1
parents:
diff changeset
1656 int result; // eax@6
Ritor1
parents:
diff changeset
1657
Ritor1
parents:
diff changeset
1658 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MAX);
Ritor1
parents:
diff changeset
1659 v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2;
Ritor1
parents:
diff changeset
1660 v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3;
Ritor1
parents:
diff changeset
1661 if ( v4 >= 1 )
Ritor1
parents:
diff changeset
1662 result = v4;
Ritor1
parents:
diff changeset
1663 else
Ritor1
parents:
diff changeset
1664 result = 0;
Ritor1
parents:
diff changeset
1665 return result;
Ritor1
parents:
diff changeset
1666 }
Ritor1
parents:
diff changeset
1667
Ritor1
parents:
diff changeset
1668 //----- (0048D1FE) --------------------------------------------------------
Ritor1
parents:
diff changeset
1669 int Player::CalculateRangedDamageTo( int a2 )
Ritor1
parents:
diff changeset
1670 {
Ritor1
parents:
diff changeset
1671 ItemGen *v4; // ebx@2
Ritor1
parents:
diff changeset
1672 unsigned int v5; // edi@2
Ritor1
parents:
diff changeset
1673 int v9; // esi@5
Ritor1
parents:
diff changeset
1674 int v10; // ebx@6
Ritor1
parents:
diff changeset
1675 signed int v15; // [sp+8h] [bp-Ch]@2
Ritor1
parents:
diff changeset
1676 int v17; // [sp+10h] [bp-4h]@1
Ritor1
parents:
diff changeset
1677
Ritor1
parents:
diff changeset
1678 v17 = 0;
Ritor1
parents:
diff changeset
1679 if ( !HasItemEquipped(EQUIP_BOW) )
Ritor1
parents:
diff changeset
1680 return 0;
Ritor1
parents:
diff changeset
1681 v4 = (ItemGen *)&this->pInventoryItemList[this->pEquipment.uBow-1];
Ritor1
parents:
diff changeset
1682 v5 = v4->uItemID;
Ritor1
parents:
diff changeset
1683 v15 = pItemsTable->pItems[v5].uDamageRoll;
Ritor1
parents:
diff changeset
1684 for( int i = 0; i < pItemsTable->pItems[v5].uDamageDice; i++ )
Ritor1
parents:
diff changeset
1685 {
Ritor1
parents:
diff changeset
1686 int v7 = rand() % v15;
Ritor1
parents:
diff changeset
1687 v17 += v7 + 1;
Ritor1
parents:
diff changeset
1688 }
Ritor1
parents:
diff changeset
1689 v9 = pItemsTable->pItems[v5].uDamageMod + v17;
Ritor1
parents:
diff changeset
1690 if ( a2 )
Ritor1
parents:
diff changeset
1691 {
Ritor1
parents:
diff changeset
1692 v10 = v4->uSpecEnchantmentType;
Ritor1
parents:
diff changeset
1693 if ( v10 == 64 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_UNDEAD))
Ritor1
parents:
diff changeset
1694 {
Ritor1
parents:
diff changeset
1695 v9 *= 2;
Ritor1
parents:
diff changeset
1696 }
Ritor1
parents:
diff changeset
1697 else if ( v10 == 39 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_KREEGAN))
Ritor1
parents:
diff changeset
1698 {
Ritor1
parents:
diff changeset
1699 v9 *= 2;
Ritor1
parents:
diff changeset
1700 }
Ritor1
parents:
diff changeset
1701 else if ( v10 == 40 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_DRAGON))
Ritor1
parents:
diff changeset
1702 {
Ritor1
parents:
diff changeset
1703 v9 *= 2;
Ritor1
parents:
diff changeset
1704 }
Ritor1
parents:
diff changeset
1705 else if ( v10 == 63 && MonsterStats::BelongsToSupertype(a2, MONSTER_SUPERTYPE_ELF))
Ritor1
parents:
diff changeset
1706 {
Ritor1
parents:
diff changeset
1707 v9 *= 2;
Ritor1
parents:
diff changeset
1708 }
Ritor1
parents:
diff changeset
1709 }
Ritor1
parents:
diff changeset
1710 return v9 + this->GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS);
Ritor1
parents:
diff changeset
1711 }
Ritor1
parents:
diff changeset
1712
Ritor1
parents:
diff changeset
1713 //----- (0048D2EA) --------------------------------------------------------
Ritor1
parents:
diff changeset
1714 char *Player::GetMeleeDamageString()
Ritor1
parents:
diff changeset
1715 {
Ritor1
parents:
diff changeset
1716 int min_damage; // edi@3
Ritor1
parents:
diff changeset
1717 int max_damage; // eax@3
Ritor1
parents:
diff changeset
1718
Ritor1
parents:
diff changeset
1719 static char player__getmeleedamagestring_static_buff[40]; // idb
Ritor1
parents:
diff changeset
1720
Ritor1
parents:
diff changeset
1721 ItemGen* mainHandItem = GetMainHandItem();
Ritor1
parents:
diff changeset
1722
Ritor1
parents:
diff changeset
1723 if (mainHandItem != nullptr && ( mainHandItem->uItemID >= 135 ) && ( mainHandItem->uItemID <= 159 ))
Ritor1
parents:
diff changeset
1724 {
Ritor1
parents:
diff changeset
1725 strcpy(player__getmeleedamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand"
Ritor1
parents:
diff changeset
1726 return player__getmeleedamagestring_static_buff;
Ritor1
parents:
diff changeset
1727 }
Ritor1
parents:
diff changeset
1728 else if (mainHandItem != nullptr && (mainHandItem->uItemID == ITEM_BLASTER || mainHandItem->uItemID == ITEM_LASER_RIFLE))
Ritor1
parents:
diff changeset
1729 {
Ritor1
parents:
diff changeset
1730 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true);
Ritor1
parents:
diff changeset
1731 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true);
Ritor1
parents:
diff changeset
1732 }
Ritor1
parents:
diff changeset
1733 else
Ritor1
parents:
diff changeset
1734 {
Ritor1
parents:
diff changeset
1735 min_damage = GetMeleeDamageMinimal();
Ritor1
parents:
diff changeset
1736 max_damage = GetMeleeDamageMaximal();
Ritor1
parents:
diff changeset
1737 }
Ritor1
parents:
diff changeset
1738 if ( min_damage == max_damage )
Ritor1
parents:
diff changeset
1739 {
Ritor1
parents:
diff changeset
1740 sprintf(player__getmeleedamagestring_static_buff, "%d", min_damage);
Ritor1
parents:
diff changeset
1741 }
Ritor1
parents:
diff changeset
1742 else
Ritor1
parents:
diff changeset
1743 {
Ritor1
parents:
diff changeset
1744 sprintf(player__getmeleedamagestring_static_buff, "%d - %d", min_damage, max_damage);
Ritor1
parents:
diff changeset
1745 }
Ritor1
parents:
diff changeset
1746 return player__getmeleedamagestring_static_buff;
Ritor1
parents:
diff changeset
1747 }
Ritor1
parents:
diff changeset
1748
Ritor1
parents:
diff changeset
1749 //----- (0048D396) --------------------------------------------------------
Ritor1
parents:
diff changeset
1750 char *Player::GetRangedDamageString()
Ritor1
parents:
diff changeset
1751 {
Ritor1
parents:
diff changeset
1752 int min_damage; // edi@3
Ritor1
parents:
diff changeset
1753 int max_damage; // eax@3
Ritor1
parents:
diff changeset
1754
Ritor1
parents:
diff changeset
1755 static char player__getrangeddamagestring_static_buff[40]; // idb
Ritor1
parents:
diff changeset
1756
Ritor1
parents:
diff changeset
1757 ItemGen* mainHandItem = GetMainHandItem();
Ritor1
parents:
diff changeset
1758
Ritor1
parents:
diff changeset
1759 if (mainHandItem != nullptr && ( mainHandItem->uItemID >= 135 ) && ( mainHandItem->uItemID <= 159 ))
Ritor1
parents:
diff changeset
1760 {
Ritor1
parents:
diff changeset
1761 strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand"
Ritor1
parents:
diff changeset
1762 return player__getrangeddamagestring_static_buff;
Ritor1
parents:
diff changeset
1763 }
Ritor1
parents:
diff changeset
1764 else if (mainHandItem != nullptr && (mainHandItem->uItemID == ITEM_BLASTER || mainHandItem->uItemID == ITEM_LASER_RIFLE))
Ritor1
parents:
diff changeset
1765 {
Ritor1
parents:
diff changeset
1766 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true);
Ritor1
parents:
diff changeset
1767 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true);
Ritor1
parents:
diff changeset
1768 }
Ritor1
parents:
diff changeset
1769 else
Ritor1
parents:
diff changeset
1770 {
Ritor1
parents:
diff changeset
1771 min_damage = GetRangedDamageMin();
Ritor1
parents:
diff changeset
1772 max_damage = GetRangedDamageMax();
Ritor1
parents:
diff changeset
1773 }
Ritor1
parents:
diff changeset
1774 if ( max_damage > 0)
Ritor1
parents:
diff changeset
1775 {
Ritor1
parents:
diff changeset
1776 if ( min_damage == max_damage )
Ritor1
parents:
diff changeset
1777 {
Ritor1
parents:
diff changeset
1778 sprintf(player__getrangeddamagestring_static_buff, "%d", min_damage);
Ritor1
parents:
diff changeset
1779 }
Ritor1
parents:
diff changeset
1780 else
Ritor1
parents:
diff changeset
1781 {
Ritor1
parents:
diff changeset
1782 sprintf(player__getrangeddamagestring_static_buff, "%d - %d", min_damage, max_damage);
Ritor1
parents:
diff changeset
1783 }
Ritor1
parents:
diff changeset
1784 }
Ritor1
parents:
diff changeset
1785 else
Ritor1
parents:
diff changeset
1786 {
Ritor1
parents:
diff changeset
1787 strcpy(player__getrangeddamagestring_static_buff, "N/A");
Ritor1
parents:
diff changeset
1788 }
Ritor1
parents:
diff changeset
1789 return player__getrangeddamagestring_static_buff;
Ritor1
parents:
diff changeset
1790 }
Ritor1
parents:
diff changeset
1791
Ritor1
parents:
diff changeset
1792 //----- (0048D45A) --------------------------------------------------------
Ritor1
parents:
diff changeset
1793 bool Player::CanTrainToNextLevel()
Ritor1
parents:
diff changeset
1794 {
Ritor1
parents:
diff changeset
1795 int lvl = this->uLevel + 1;
Ritor1
parents:
diff changeset
1796 int neededExp = ((lvl * (lvl - 1)) / 2 * 1000);
Ritor1
parents:
diff changeset
1797 return this->uExperience >= neededExp;
Ritor1
parents:
diff changeset
1798 }
Ritor1
parents:
diff changeset
1799
Ritor1
parents:
diff changeset
1800 //----- (0048D498) --------------------------------------------------------
Ritor1
parents:
diff changeset
1801 unsigned int Player::GetExperienceDisplayColor()
Ritor1
parents:
diff changeset
1802 {
Ritor1
parents:
diff changeset
1803 if ( CanTrainToNextLevel() )
Ritor1
parents:
diff changeset
1804 return ui_character_bonus_text_color;
Ritor1
parents:
diff changeset
1805 else
Ritor1
parents:
diff changeset
1806 return ui_character_default_text_color;
Ritor1
parents:
diff changeset
1807 }
Ritor1
parents:
diff changeset
1808
Ritor1
parents:
diff changeset
1809 //----- (0048D4B3) --------------------------------------------------------
Ritor1
parents:
diff changeset
1810 int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int dmg )
Ritor1
parents:
diff changeset
1811 {
Ritor1
parents:
diff changeset
1812 int resist_value; // edi@8
Ritor1
parents:
diff changeset
1813 int player_luck; // eax@21
Ritor1
parents:
diff changeset
1814 signed int res_rand_divider; // ebx@2
Ritor1
parents:
diff changeset
1815 int armor_skill; // eax@29
Ritor1
parents:
diff changeset
1816
Ritor1
parents:
diff changeset
1817 if ( classType == PLAYER_CLASS_LICH && (dmg_type == CHARACTER_ATTRIBUTE_RESIST_MIND || dmg_type == CHARACTER_ATTRIBUTE_RESIST_BODY || dmg_type == CHARACTER_ATTRIBUTE_RESIST_SPIRIT )) //TODO: determine if spirit resistance should be handled by body res. modifier
Ritor1
parents:
diff changeset
1818 return 0;
Ritor1
parents:
diff changeset
1819
Ritor1
parents:
diff changeset
1820 resist_value = 0;
Ritor1
parents:
diff changeset
1821 switch(dmg_type)
Ritor1
parents:
diff changeset
1822 {
Ritor1
parents:
diff changeset
1823 case DMGT_FIRE: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE); break;
Ritor1
parents:
diff changeset
1824 case DMGT_ELECTR: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR); break;
Ritor1
parents:
diff changeset
1825 case DMGT_COLD: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER); break;
Ritor1
parents:
diff changeset
1826 case DMGT_EARTH: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); break;
Ritor1
parents:
diff changeset
1827
Ritor1
parents:
diff changeset
1828 case DMGT_SPIRIT: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_SPIRIT);break;
Ritor1
parents:
diff changeset
1829 case DMGT_MIND: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); break;
Ritor1
parents:
diff changeset
1830 case DMGT_BODY: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); break;
Ritor1
parents:
diff changeset
1831 }
Ritor1
parents:
diff changeset
1832
Ritor1
parents:
diff changeset
1833 player_luck = GetActualLuck();
Ritor1
parents:
diff changeset
1834 res_rand_divider = GetParameterBonus(player_luck) + resist_value + 30;
Ritor1
parents:
diff changeset
1835
Ritor1
parents:
diff changeset
1836 if ( GetParameterBonus(player_luck) + resist_value > 0 )
Ritor1
parents:
diff changeset
1837 {
Ritor1
parents:
diff changeset
1838 for (int i = 0; i < 4; i++)
Ritor1
parents:
diff changeset
1839 {
Ritor1
parents:
diff changeset
1840 if ( rand() % res_rand_divider >= 30 )
Ritor1
parents:
diff changeset
1841 dmg >>= 1;
Ritor1
parents:
diff changeset
1842 else
Ritor1
parents:
diff changeset
1843 break;
Ritor1
parents:
diff changeset
1844 }
Ritor1
parents:
diff changeset
1845 }
Ritor1
parents:
diff changeset
1846 ItemGen* equippedArmor = GetArmorItem();
Ritor1
parents:
diff changeset
1847 if (( dmg_type == DMGT_PHISYCAL ) && ( equippedArmor != nullptr ))
Ritor1
parents:
diff changeset
1848 {
Ritor1
parents:
diff changeset
1849 if (!equippedArmor->IsBroken())
Ritor1
parents:
diff changeset
1850 {
Ritor1
parents:
diff changeset
1851 armor_skill = equippedArmor->GetPlayerSkillType();
Ritor1
parents:
diff changeset
1852 if ( armor_skill==PLAYER_SKILL_PLATE )
Ritor1
parents:
diff changeset
1853 {
Ritor1
parents:
diff changeset
1854 if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 )
Ritor1
parents:
diff changeset
1855 return dmg / 2;
Ritor1
parents:
diff changeset
1856 }
Ritor1
parents:
diff changeset
1857 if (armor_skill==PLAYER_SKILL_CHAIN )
Ritor1
parents:
diff changeset
1858 {
Ritor1
parents:
diff changeset
1859 if (SkillToMastery(pActiveSkills[PLAYER_SKILL_CHAIN]) == 4)
Ritor1
parents:
diff changeset
1860 return dmg * 2 / 3;
Ritor1
parents:
diff changeset
1861 }
Ritor1
parents:
diff changeset
1862 }
Ritor1
parents:
diff changeset
1863 }
Ritor1
parents:
diff changeset
1864 return dmg;
Ritor1
parents:
diff changeset
1865 }
Ritor1
parents:
diff changeset
1866
Ritor1
parents:
diff changeset
1867 //----- (0048D62C) --------------------------------------------------------
Ritor1
parents:
diff changeset
1868 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot)
Ritor1
parents:
diff changeset
1869 {
Ritor1
parents:
diff changeset
1870 return GetNthEquippedIndexItem(uEquipSlot)->GetItemEquipType();
Ritor1
parents:
diff changeset
1871 }
Ritor1
parents:
diff changeset
1872
Ritor1
parents:
diff changeset
1873 //----- (0048D651) --------------------------------------------------------
Ritor1
parents:
diff changeset
1874 PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot)
Ritor1
parents:
diff changeset
1875 {
Ritor1
parents:
diff changeset
1876 return (PLAYER_SKILL_TYPE)GetNthEquippedIndexItem(uEquipSlot)->GetPlayerSkillType();
Ritor1
parents:
diff changeset
1877 }
Ritor1
parents:
diff changeset
1878
Ritor1
parents:
diff changeset
1879 //----- (0048D676) --------------------------------------------------------
Ritor1
parents:
diff changeset
1880 bool Player::IsUnarmed()
Ritor1
parents:
diff changeset
1881 {
Ritor1
parents:
diff changeset
1882 return !HasItemEquipped(EQUIP_TWO_HANDED) &&
Ritor1
parents:
diff changeset
1883 (!HasItemEquipped(EQUIP_SINGLE_HANDED) || GetOffHandItem()->GetItemEquipType() == EQUIP_SHIELD);
Ritor1
parents:
diff changeset
1884 }
Ritor1
parents:
diff changeset
1885
Ritor1
parents:
diff changeset
1886 //----- (0048D6AA) --------------------------------------------------------
Ritor1
parents:
diff changeset
1887 bool Player::HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex)
Ritor1
parents:
diff changeset
1888 {
Ritor1
parents:
diff changeset
1889 uint i = pEquipment.pIndices[uEquipIndex];
Ritor1
parents:
diff changeset
1890 if (i)
Ritor1
parents:
diff changeset
1891 return !pOwnItems[i - 1].IsBroken();
Ritor1
parents:
diff changeset
1892 else
Ritor1
parents:
diff changeset
1893 return false;
Ritor1
parents:
diff changeset
1894 }
Ritor1
parents:
diff changeset
1895
Ritor1
parents:
diff changeset
1896 //----- (0048D6D0) --------------------------------------------------------
Ritor1
parents:
diff changeset
1897 bool Player::HasEnchantedItemEquipped(int uEnchantment)
Ritor1
parents:
diff changeset
1898 {
Ritor1
parents:
diff changeset
1899 for (uint i = 0; i < 16; ++i)
Ritor1
parents:
diff changeset
1900 {
Ritor1
parents:
diff changeset
1901 if (HasItemEquipped((ITEM_EQUIP_TYPE)i) &&
Ritor1
parents:
diff changeset
1902 GetNthEquippedIndexItem(i)->uSpecEnchantmentType == uEnchantment)
Ritor1
parents:
diff changeset
1903 return true;
Ritor1
parents:
diff changeset
1904 }
Ritor1
parents:
diff changeset
1905 return false;
Ritor1
parents:
diff changeset
1906 }
Ritor1
parents:
diff changeset
1907
Ritor1
parents:
diff changeset
1908 //----- (0048D709) --------------------------------------------------------
Ritor1
parents:
diff changeset
1909 bool Player::WearsItem( int item_id, ITEM_EQUIP_TYPE equip_type )
Ritor1
parents:
diff changeset
1910 {
Ritor1
parents:
diff changeset
1911 return ( HasItemEquipped(equip_type) && GetNthEquippedIndexItem(equip_type)->uItemID == item_id );
Ritor1
parents:
diff changeset
1912 }
Ritor1
parents:
diff changeset
1913
Ritor1
parents:
diff changeset
1914 bool Player::WearsItemAnyWhere(int item_id)
Ritor1
parents:
diff changeset
1915 {
Ritor1
parents:
diff changeset
1916 for (int i = 0; i < 16; i++)
Ritor1
parents:
diff changeset
1917 {
Ritor1
parents:
diff changeset
1918 if (WearsItem(item_id, (ITEM_EQUIP_TYPE) i))
Ritor1
parents:
diff changeset
1919 {
Ritor1
parents:
diff changeset
1920 return true;
Ritor1
parents:
diff changeset
1921 }
Ritor1
parents:
diff changeset
1922 }
Ritor1
parents:
diff changeset
1923 return false;
Ritor1
parents:
diff changeset
1924 }
Ritor1
parents:
diff changeset
1925
Ritor1
parents:
diff changeset
1926 //----- (0048D76C) --------------------------------------------------------
Ritor1
parents:
diff changeset
1927 int Player::StealFromShop( ItemGen *itemToSteal, int extraStealDifficulty, int reputation, int a5, int *fineIfFailed ) //returns an int, but is the return value is compared to zero, so might change to bool
Ritor1
parents:
diff changeset
1928 {
Ritor1
parents:
diff changeset
1929 unsigned __int16 v6; // cx@8
Ritor1
parents:
diff changeset
1930 int v7; // edi@8
Ritor1
parents:
diff changeset
1931 unsigned int v8; // ebx@8
Ritor1
parents:
diff changeset
1932 unsigned int itemvalue; // esi@8
Ritor1
parents:
diff changeset
1933 int v10; // eax@8
Ritor1
parents:
diff changeset
1934 int currMaxItemValue; // edi@12
Ritor1
parents:
diff changeset
1935
Ritor1
parents:
diff changeset
1936 if ( !itemToSteal
Ritor1
parents:
diff changeset
1937 || this->IsEradicated()
Ritor1
parents:
diff changeset
1938 || this->IsDead()
Ritor1
parents:
diff changeset
1939 || this->IsPertified()
Ritor1
parents:
diff changeset
1940 || this->IsDrunk()
Ritor1
parents:
diff changeset
1941 || this->IsUnconcious()
Ritor1
parents:
diff changeset
1942 || this->IsAsleep() )
Ritor1
parents:
diff changeset
1943 {
Ritor1
parents:
diff changeset
1944 return 0;
Ritor1
parents:
diff changeset
1945 }
Ritor1
parents:
diff changeset
1946 else
Ritor1
parents:
diff changeset
1947 {
Ritor1
parents:
diff changeset
1948 v6 = this->pActiveSkills[PLAYER_SKILL_STEALING];
Ritor1
parents:
diff changeset
1949 v7 = v6 & 0x3F;
Ritor1
parents:
diff changeset
1950 v8 = SkillToMastery(v6);
Ritor1
parents:
diff changeset
1951 itemvalue = itemToSteal->GetValue();
Ritor1
parents:
diff changeset
1952 v10 = itemToSteal->GetItemEquipType();
Ritor1
parents:
diff changeset
1953 if ( v10 == EQUIP_SINGLE_HANDED || v10 == EQUIP_TWO_HANDED || v10 == EQUIP_BOW )
Ritor1
parents:
diff changeset
1954 itemvalue *= 3;
Ritor1
parents:
diff changeset
1955 currMaxItemValue = StealingRandomBonuses[rand() % 5] + v7 * StealingMasteryBonuses[v8];
Ritor1
parents:
diff changeset
1956 *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue;
Ritor1
parents:
diff changeset
1957 if (a5)
Ritor1
parents:
diff changeset
1958 {
Ritor1
parents:
diff changeset
1959 *fineIfFailed += 500;
Ritor1
parents:
diff changeset
1960 }
Ritor1
parents:
diff changeset
1961 if ( rand() % 100 >= 5 )
Ritor1
parents:
diff changeset
1962 {
Ritor1
parents:
diff changeset
1963 if ( *fineIfFailed > currMaxItemValue )
Ritor1
parents:
diff changeset
1964 if (*fineIfFailed - currMaxItemValue < 500)
Ritor1
parents:
diff changeset
1965 {
Ritor1
parents:
diff changeset
1966 return 1;
Ritor1
parents:
diff changeset
1967 }
Ritor1
parents:
diff changeset
1968 else
Ritor1
parents:
diff changeset
1969 {
Ritor1
parents:
diff changeset
1970 return 0;
Ritor1
parents:
diff changeset
1971 }
Ritor1
parents:
diff changeset
1972 else
Ritor1
parents:
diff changeset
1973 return 2;
Ritor1
parents:
diff changeset
1974 }
Ritor1
parents:
diff changeset
1975 else
Ritor1
parents:
diff changeset
1976 {
Ritor1
parents:
diff changeset
1977 return 0;
Ritor1
parents:
diff changeset
1978 }
Ritor1
parents:
diff changeset
1979 }
Ritor1
parents:
diff changeset
1980 }
Ritor1
parents:
diff changeset
1981
Ritor1
parents:
diff changeset
1982 //----- (0048D88B) --------------------------------------------------------
Ritor1
parents:
diff changeset
1983 int Player::StealFromActor(unsigned int uActorID, int _steal_perm, int reputation)
Ritor1
parents:
diff changeset
1984 {
Ritor1
parents:
diff changeset
1985 Actor *actroPtr; // edi@1
Ritor1
parents:
diff changeset
1986 int v7; // ebx@10
Ritor1
parents:
diff changeset
1987 unsigned int stealingMastery; // esi@10
Ritor1
parents:
diff changeset
1988 int fineIfFailed; // esi@10
Ritor1
parents:
diff changeset
1989 int v11; // eax@13
Ritor1
parents:
diff changeset
1990 bool HasFullItemSlots; // ebx@15
Ritor1
parents:
diff changeset
1991 unsigned __int16 carriedItemId; // si@21
Ritor1
parents:
diff changeset
1992 unsigned int enchBonusSum; // esi@31
Ritor1
parents:
diff changeset
1993 int *enchTypePtr; // eax@34
Ritor1
parents:
diff changeset
1994 ItemGen tempItem; // [sp+8h] [bp-34h]@15
Ritor1
parents:
diff changeset
1995 int currMaxItemValue;
Ritor1
parents:
diff changeset
1996
Ritor1
parents:
diff changeset
1997 actroPtr = &pActors[uActorID];
Ritor1
parents:
diff changeset
1998 if ( !actroPtr
Ritor1
parents:
diff changeset
1999 || this->IsEradicated()
Ritor1
parents:
diff changeset
2000 || this->IsDead()
Ritor1
parents:
diff changeset
2001 || this->IsPertified()
Ritor1
parents:
diff changeset
2002 || this->IsDrunk()
Ritor1
parents:
diff changeset
2003 || this->IsUnconcious()
Ritor1
parents:
diff changeset
2004 || this->IsAsleep() )
Ritor1
parents:
diff changeset
2005 {
Ritor1
parents:
diff changeset
2006 return 0;
Ritor1
parents:
diff changeset
2007 }
Ritor1
parents:
diff changeset
2008 if ( !actroPtr->ActorHasItem() )
Ritor1
parents:
diff changeset
2009 actroPtr->SetRandomGoldIfTheresNoItem();
Ritor1
parents:
diff changeset
2010 unsigned __int16 v6 = this->pActiveSkills[PLAYER_SKILL_STEALING];
Ritor1
parents:
diff changeset
2011 v7 = v6 & 0x3F;
Ritor1
parents:
diff changeset
2012 stealingMastery = SkillToMastery(v6);
Ritor1
parents:
diff changeset
2013 int v30 = StealingMasteryBonuses[stealingMastery];
Ritor1
parents:
diff changeset
2014 int v29 = StealingRandomBonuses[rand() % 5];
Ritor1
parents:
diff changeset
2015 fineIfFailed = actroPtr->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation);
Ritor1
parents:
diff changeset
2016 currMaxItemValue = v29 + v7 * v30;
Ritor1
parents:
diff changeset
2017 if ( rand() % 100 < 5 || fineIfFailed > currMaxItemValue || actroPtr->ActorEnemy() )
Ritor1
parents:
diff changeset
2018 {
Ritor1
parents:
diff changeset
2019 Actor::AggroSurroundingPeasants(uActorID, 1);
Ritor1
parents:
diff changeset
2020 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[376], this->pName);//"%s was caught stealing!"
Ritor1
parents:
diff changeset
2021 ShowStatusBarString(pTmpBuf2.data(), 2);
Ritor1
parents:
diff changeset
2022 return 0;
Ritor1
parents:
diff changeset
2023 }
Ritor1
parents:
diff changeset
2024 else
Ritor1
parents:
diff changeset
2025 {
Ritor1
parents:
diff changeset
2026 v11 = rand();
Ritor1
parents:
diff changeset
2027 if ( v11 % 100 >= 70 ) //stealing gold
Ritor1
parents:
diff changeset
2028 {
Ritor1
parents:
diff changeset
2029 enchBonusSum = 0;
Ritor1
parents:
diff changeset
2030 for (int i = 0; i < v7; i++)
Ritor1
parents:
diff changeset
2031 enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1;
Ritor1
parents:
diff changeset
2032 if ( actroPtr->ActorHasItems[3].GetItemEquipType() != EQUIP_GOLD )
Ritor1
parents:
diff changeset
2033 return 2;
Ritor1
parents:
diff changeset
2034 enchTypePtr = &actroPtr->ActorHasItems[3].uSpecEnchantmentType;
Ritor1
parents:
diff changeset
2035 if ( (int)enchBonusSum >= *enchTypePtr )
Ritor1
parents:
diff changeset
2036 {
Ritor1
parents:
diff changeset
2037 actroPtr->ActorHasItems[3].uItemID = 0;
Ritor1
parents:
diff changeset
2038 *enchTypePtr = 0;
Ritor1
parents:
diff changeset
2039 }
Ritor1
parents:
diff changeset
2040 else
Ritor1
parents:
diff changeset
2041 *enchTypePtr -= enchBonusSum;
Ritor1
parents:
diff changeset
2042 if ( enchBonusSum )
Ritor1
parents:
diff changeset
2043 {
Ritor1
parents:
diff changeset
2044 pParty->PartyFindsGold(enchBonusSum, 2);
Ritor1
parents:
diff changeset
2045 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold
Ritor1
parents:
diff changeset
2046 }
Ritor1
parents:
diff changeset
2047 else
Ritor1
parents:
diff changeset
2048 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything
Ritor1
parents:
diff changeset
2049 ShowStatusBarString(pTmpBuf2.data(), 2);
Ritor1
parents:
diff changeset
2050 return 2;
Ritor1
parents:
diff changeset
2051 }
Ritor1
parents:
diff changeset
2052 else if ( v11 % 100 >= 40 ) //stealing an item
Ritor1
parents:
diff changeset
2053 {
Ritor1
parents:
diff changeset
2054 tempItem.Reset();
Ritor1
parents:
diff changeset
2055 HasFullItemSlots = false;
Ritor1
parents:
diff changeset
2056 int i;
Ritor1
parents:
diff changeset
2057 for (i = 0; i < 4; i++)
Ritor1
parents:
diff changeset
2058 {
Ritor1
parents:
diff changeset
2059 if ( actroPtr->ActorHasItems[i].uItemID != 0 && actroPtr->ActorHasItems[i].GetItemEquipType() != EQUIP_GOLD )
Ritor1
parents:
diff changeset
2060 break;
Ritor1
parents:
diff changeset
2061 }
Ritor1
parents:
diff changeset
2062 if (i == 4)
Ritor1
parents:
diff changeset
2063 HasFullItemSlots = true;
Ritor1
parents:
diff changeset
2064 carriedItemId = actroPtr->uCarriedItemID;
Ritor1
parents:
diff changeset
2065 if ( carriedItemId != 0 || HasFullItemSlots )
Ritor1
parents:
diff changeset
2066 {
Ritor1
parents:
diff changeset
2067 tempItem.Reset();
Ritor1
parents:
diff changeset
2068 if ( carriedItemId != 0 )
Ritor1
parents:
diff changeset
2069 {
Ritor1
parents:
diff changeset
2070 actroPtr->uCarriedItemID = 0;
Ritor1
parents:
diff changeset
2071 tempItem.uItemID = carriedItemId;
Ritor1
parents:
diff changeset
2072 if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_WAND )
Ritor1
parents:
diff changeset
2073 tempItem.uNumCharges = rand() % 6 + pItemsTable->pItems[carriedItemId].uDamageMod + 1;
Ritor1
parents:
diff changeset
2074 else if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_POTION && carriedItemId != ITEM_POTION_BOTTLE)
Ritor1
parents:
diff changeset
2075 tempItem.uEnchantmentType = 2 * rand() % 4 + 2;
Ritor1
parents:
diff changeset
2076 }
Ritor1
parents:
diff changeset
2077 else
Ritor1
parents:
diff changeset
2078 {
Ritor1
parents:
diff changeset
2079 ItemGen* itemToSteal = &actroPtr->ActorHasItems[rand() % 4];
Ritor1
parents:
diff changeset
2080 memcpy(&tempItem, itemToSteal, sizeof(tempItem));
Ritor1
parents:
diff changeset
2081 itemToSteal->Reset();
Ritor1
parents:
diff changeset
2082 carriedItemId = tempItem.uItemID;
Ritor1
parents:
diff changeset
2083 }
Ritor1
parents:
diff changeset
2084 if (carriedItemId != 0) // looks odd in current context, but avoids accessing zeroth element of pItemsTable->pItems
Ritor1
parents:
diff changeset
2085 {
Ritor1
parents:
diff changeset
2086 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
Ritor1
parents:
diff changeset
2087 sprintf(
Ritor1
parents:
diff changeset
2088 pTmpBuf2.data(),
Ritor1
parents:
diff changeset
2089 pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message
Ritor1
parents:
diff changeset
2090 this->pName,
Ritor1
parents:
diff changeset
2091 pItemsTable->pItems[carriedItemId].pUnidentifiedName);
Ritor1
parents:
diff changeset
2092 ShowStatusBarString(pTmpBuf2.data(), 2u);
Ritor1
parents:
diff changeset
2093 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
Ritor1
parents:
diff changeset
2094 memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen));
Ritor1
parents:
diff changeset
2095 pMouse->SetCursorBitmapFromItemID(carriedItemId);
Ritor1
parents:
diff changeset
2096 return 2;
Ritor1
parents:
diff changeset
2097 }
Ritor1
parents:
diff changeset
2098 }
Ritor1
parents:
diff changeset
2099 }
Ritor1
parents:
diff changeset
2100 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything
Ritor1
parents:
diff changeset
2101 ShowStatusBarString(pTmpBuf2.data(), 2);
Ritor1
parents:
diff changeset
2102 return 2;
Ritor1
parents:
diff changeset
2103 }
Ritor1
parents:
diff changeset
2104 }
Ritor1
parents:
diff changeset
2105 // 4EDEA0: using guessed type int dword_4EDEA0[];
Ritor1
parents:
diff changeset
2106 // 4EDEB4: using guessed type int dword_4EDEB4[];
Ritor1
parents:
diff changeset
2107 // 4EDEC4: using guessed type int dword_4EDEC4[];
Ritor1
parents:
diff changeset
2108
Ritor1
parents:
diff changeset
2109 //----- (0048DBB9) --------------------------------------------------------
Ritor1
parents:
diff changeset
2110 void Player::Heal(int amount)
Ritor1
parents:
diff changeset
2111 {
Ritor1
parents:
diff changeset
2112 signed int max_health; // eax@3
Ritor1
parents:
diff changeset
2113
Ritor1
parents:
diff changeset
2114 if ( !IsEradicated() && !IsDead() )
Ritor1
parents:
diff changeset
2115 {
Ritor1
parents:
diff changeset
2116 max_health = GetMaxHealth();
Ritor1
parents:
diff changeset
2117 if ( IsZombie() )
Ritor1
parents:
diff changeset
2118 max_health /= 2;
Ritor1
parents:
diff changeset
2119 sHealth += amount;
Ritor1
parents:
diff changeset
2120 if ( sHealth > max_health )
Ritor1
parents:
diff changeset
2121 sHealth = max_health;
Ritor1
parents:
diff changeset
2122 if ( IsUnconcious() )
Ritor1
parents:
diff changeset
2123 {
Ritor1
parents:
diff changeset
2124 if ( sHealth > 0 )
Ritor1
parents:
diff changeset
2125 {
Ritor1
parents:
diff changeset
2126 SetUnconcious(false);
Ritor1
parents:
diff changeset
2127 }
Ritor1
parents:
diff changeset
2128 }
Ritor1
parents:
diff changeset
2129 }
Ritor1
parents:
diff changeset
2130 }
Ritor1
parents:
diff changeset
2131
Ritor1
parents:
diff changeset
2132 //----- (0048DC1E) --------------------------------------------------------
Ritor1
parents:
diff changeset
2133 int Player::ReceiveDamage( signed int amount, DAMAGE_TYPE dmg_type )
Ritor1
parents:
diff changeset
2134 {
Ritor1
parents:
diff changeset
2135 signed int recieved_dmg; // eax@1
Ritor1
parents:
diff changeset
2136 bool broke_armor;
Ritor1
parents:
diff changeset
2137
Ritor1
parents:
diff changeset
2138 SetAsleep(false);
Ritor1
parents:
diff changeset
2139 recieved_dmg = CalculateIncommingDamage(dmg_type, amount);
Ritor1
parents:
diff changeset
2140 sHealth -= recieved_dmg;
Ritor1
parents:
diff changeset
2141 broke_armor = sHealth <= -10;
Ritor1
parents:
diff changeset
2142 if ( sHealth < 1 ) //
Ritor1
parents:
diff changeset
2143 {
Ritor1
parents:
diff changeset
2144 if ( (sHealth + uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1)
Ritor1
parents:
diff changeset
2145 || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 )
Ritor1
parents:
diff changeset
2146 {
Ritor1
parents:
diff changeset
2147 SetCondUnconsciousWithBlockCheck(false);
Ritor1
parents:
diff changeset
2148 }
Ritor1
parents:
diff changeset
2149 else
Ritor1
parents:
diff changeset
2150 {
Ritor1
parents:
diff changeset
2151 SetCondDeadWithBlockCheck(false);
Ritor1
parents:
diff changeset
2152 if ( sHealth > 0 )
Ritor1
parents:
diff changeset
2153 sHealth = 0;
Ritor1
parents:
diff changeset
2154 }
Ritor1
parents:
diff changeset
2155 if (broke_armor )
Ritor1
parents:
diff changeset
2156 {
Ritor1
parents:
diff changeset
2157 ItemGen* equippedArmor = GetArmorItem();
Ritor1
parents:
diff changeset
2158 if ( equippedArmor != nullptr )
Ritor1
parents:
diff changeset
2159 {
Ritor1
parents:
diff changeset
2160 if ( !(equippedArmor->uAttributes & ITEM_HARDENED))
Ritor1
parents:
diff changeset
2161 {
Ritor1
parents:
diff changeset
2162 equippedArmor->SetBroken();
Ritor1
parents:
diff changeset
2163 }
Ritor1
parents:
diff changeset
2164 }
Ritor1
parents:
diff changeset
2165 }
Ritor1
parents:
diff changeset
2166 }
Ritor1
parents:
diff changeset
2167 if ( recieved_dmg && CanAct() )
Ritor1
parents:
diff changeset
2168 PlaySound(SPEECH_24, 0);
Ritor1
parents:
diff changeset
2169 return recieved_dmg;
Ritor1
parents:
diff changeset
2170 }
Ritor1
parents:
diff changeset
2171
Ritor1
parents:
diff changeset
2172 //----- (0048DCF6) --------------------------------------------------------
Ritor1
parents:
diff changeset
2173 int Player::ReceiveSpecialAttackEffect( int attType, struct Actor *pActor )
Ritor1
parents:
diff changeset
2174 {
Ritor1
parents:
diff changeset
2175 SPECIAL_ATTACK_TYPE attTypeCast = (SPECIAL_ATTACK_TYPE) attType;
Ritor1
parents:
diff changeset
2176 signed int v3; // edi@1
Ritor1
parents:
diff changeset
2177 signed int v4; // ebx@1
Ritor1
parents:
diff changeset
2178 int v6; // eax@2
Ritor1
parents:
diff changeset
2179 int v8; // eax@8
Ritor1
parents:
diff changeset
2180 int v10; // eax@8
Ritor1
parents:
diff changeset
2181 int v11; // ebx@8
Ritor1
parents:
diff changeset
2182 ItemGen *v13; // eax@9
Ritor1
parents:
diff changeset
2183 int v22; // eax@49
Ritor1
parents:
diff changeset
2184 signed int v23; // ebx@49
Ritor1
parents:
diff changeset
2185 void *v27; // ecx@76
Ritor1
parents:
diff changeset
2186 char v46[140]; // [sp+Ch] [bp-94h]@13
Ritor1
parents:
diff changeset
2187 unsigned int v47; // [sp+98h] [bp-8h]@1
Ritor1
parents:
diff changeset
2188 ItemGen* v48; // [sp+9Ch] [bp-4h]@1
Ritor1
parents:
diff changeset
2189
Ritor1
parents:
diff changeset
2190 v4 = 0;
Ritor1
parents:
diff changeset
2191 v47 = 0;
Ritor1
parents:
diff changeset
2192 v48 = nullptr;
Ritor1
parents:
diff changeset
2193 switch ( attTypeCast )
Ritor1
parents:
diff changeset
2194 {
Ritor1
parents:
diff changeset
2195 case SPECIAL_ATTACK_CURSE:
Ritor1
parents:
diff changeset
2196 v6 = GetActualWillpower();
Ritor1
parents:
diff changeset
2197 v11 = GetParameterBonus(v6);
Ritor1
parents:
diff changeset
2198 break;
Ritor1
parents:
diff changeset
2199 case SPECIAL_ATTACK_WEAK:
Ritor1
parents:
diff changeset
2200 case SPECIAL_ATTACK_SLEEP:
Ritor1
parents:
diff changeset
2201 case SPECIAL_ATTACK_DRUNK:
Ritor1
parents:
diff changeset
2202 case SPECIAL_ATTACK_DISEASE_WEAK:
Ritor1
parents:
diff changeset
2203 case SPECIAL_ATTACK_DISEASE_MEDIUM:
Ritor1
parents:
diff changeset
2204 case SPECIAL_ATTACK_DISEASE_SEVERE:
Ritor1
parents:
diff changeset
2205 case SPECIAL_ATTACK_UNCONSCIOUS:
Ritor1
parents:
diff changeset
2206 case SPECIAL_ATTACK_AGING:
Ritor1
parents:
diff changeset
2207 v6 = GetActualEndurance();
Ritor1
parents:
diff changeset
2208 v11 = GetParameterBonus(v6);
Ritor1
parents:
diff changeset
2209 break;
Ritor1
parents:
diff changeset
2210 case SPECIAL_ATTACK_INSANE:
Ritor1
parents:
diff changeset
2211 case SPECIAL_ATTACK_PARALYZED:
Ritor1
parents:
diff changeset
2212 case SPECIAL_ATTACK_FEAR:
Ritor1
parents:
diff changeset
2213 v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
Ritor1
parents:
diff changeset
2214 break;
Ritor1
parents:
diff changeset
2215 case SPECIAL_ATTACK_PETRIFIED:
Ritor1
parents:
diff changeset
2216 v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
Ritor1
parents:
diff changeset
2217 break;
Ritor1
parents:
diff changeset
2218 case SPECIAL_ATTACK_POISON_WEAK:
Ritor1
parents:
diff changeset
2219 case SPECIAL_ATTACK_POISON_MEDIUM:
Ritor1
parents:
diff changeset
2220 case SPECIAL_ATTACK_POISON_SEVERE:
Ritor1
parents:
diff changeset
2221 case SPECIAL_ATTACK_DEAD:
Ritor1
parents:
diff changeset
2222 case SPECIAL_ATTACK_ERADICATED:
Ritor1
parents:
diff changeset
2223 v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
Ritor1
parents:
diff changeset
2224 break;
Ritor1
parents:
diff changeset
2225 case SPECIAL_ATTACK_MANA_DRAIN:
Ritor1
parents:
diff changeset
2226 v8 = GetActualWillpower();
Ritor1
parents:
diff changeset
2227 v10 = GetActualIntelligence();
Ritor1
parents:
diff changeset
2228 v11 = (GetParameterBonus(v10) + GetParameterBonus(v8)) / 2;
Ritor1
parents:
diff changeset
2229 break;
Ritor1
parents:
diff changeset
2230 case SPECIAL_ATTACK_BREAK_ANY:
Ritor1
parents:
diff changeset
2231 for (int i = 0; i < 138; i++)
Ritor1
parents:
diff changeset
2232 {
Ritor1
parents:
diff changeset
2233 v13 = &this->pInventoryItemList[i];
Ritor1
parents:
diff changeset
2234 if ( v13->uItemID > 0 && v13->uItemID <= 134 && !v13->IsBroken())
Ritor1
parents:
diff changeset
2235 v46[v4++] = i;
Ritor1
parents:
diff changeset
2236 }
Ritor1
parents:
diff changeset
2237 if ( !v4 )
Ritor1
parents:
diff changeset
2238 return 0;
Ritor1
parents:
diff changeset
2239 v48 = &this->pInventoryItemList[v46[rand() % v4]];
Ritor1
parents:
diff changeset
2240 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod());
Ritor1
parents:
diff changeset
2241 break;
Ritor1
parents:
diff changeset
2242 case SPECIAL_ATTACK_BREAK_ARMOR:
Ritor1
parents:
diff changeset
2243 for (int i = 0; i < 16; i++ )
Ritor1
parents:
diff changeset
2244 {
Ritor1
parents:
diff changeset
2245 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) )
Ritor1
parents:
diff changeset
2246 {
Ritor1
parents:
diff changeset
2247 if ( i == EQUIP_ARMOUR )
Ritor1
parents:
diff changeset
2248 v46[v4++] = this->pEquipment.uArmor - 1;
Ritor1
parents:
diff changeset
2249 if ( (i == EQUIP_SINGLE_HANDED || i == EQUIP_TWO_HANDED) && GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_SHIELD )
Ritor1
parents:
diff changeset
2250 v46[v4++] = this->pEquipment.pIndices[i] - 1;
Ritor1
parents:
diff changeset
2251 }
Ritor1
parents:
diff changeset
2252 }
Ritor1
parents:
diff changeset
2253 if ( !v4 )
Ritor1
parents:
diff changeset
2254 return 0;
Ritor1
parents:
diff changeset
2255 v48 = &this->pInventoryItemList[v46[rand() % v4]];
Ritor1
parents:
diff changeset
2256 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod());
Ritor1
parents:
diff changeset
2257 break;
Ritor1
parents:
diff changeset
2258 case SPECIAL_ATTACK_BREAK_WEAPON:
Ritor1
parents:
diff changeset
2259 for (int i = 0; i < 16; i++ )
Ritor1
parents:
diff changeset
2260 {
Ritor1
parents:
diff changeset
2261 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) )
Ritor1
parents:
diff changeset
2262 {
Ritor1
parents:
diff changeset
2263 if ( i == EQUIP_BOW )
Ritor1
parents:
diff changeset
2264 v46[v4++] = LOBYTE(this->pEquipment.uBow) - 1;
Ritor1
parents:
diff changeset
2265 if ( (i == EQUIP_SINGLE_HANDED || i == EQUIP_TWO_HANDED)
Ritor1
parents:
diff changeset
2266 && (GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_SINGLE_HANDED || GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_TWO_HANDED) )
Ritor1
parents:
diff changeset
2267 v46[v4++] = this->pEquipment.pIndices[i] - 1;
Ritor1
parents:
diff changeset
2268 }
Ritor1
parents:
diff changeset
2269 }
Ritor1
parents:
diff changeset
2270 if ( !v4 )
Ritor1
parents:
diff changeset
2271 return 0;
Ritor1
parents:
diff changeset
2272 v48 = &this->pInventoryItemList[v46[rand() % v4]];
Ritor1
parents:
diff changeset
2273 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod());
Ritor1
parents:
diff changeset
2274 break;
Ritor1
parents:
diff changeset
2275 case SPECIAL_ATTACK_STEAL:
Ritor1
parents:
diff changeset
2276 for ( int i = 0; i < 126; i++ )
Ritor1
parents:
diff changeset
2277 {
Ritor1
parents:
diff changeset
2278 int ItemPosInList = this->pInventoryMatrix[i];
Ritor1
parents:
diff changeset
2279 if (ItemPosInList > 0)
Ritor1
parents:
diff changeset
2280 {
Ritor1
parents:
diff changeset
2281 ItemGen* v21 = &this->pInventoryItemList[ItemPosInList - 1];
Ritor1
parents:
diff changeset
2282 if ( v21->uItemID > 0 && v21->uItemID <= 134 )
Ritor1
parents:
diff changeset
2283 {
Ritor1
parents:
diff changeset
2284 v46[v4++] = i;
Ritor1
parents:
diff changeset
2285 }
Ritor1
parents:
diff changeset
2286 }
Ritor1
parents:
diff changeset
2287 }
Ritor1
parents:
diff changeset
2288 if ( !v4 )
Ritor1
parents:
diff changeset
2289 return 0;
Ritor1
parents:
diff changeset
2290 v47 = v46[rand() % v4];
Ritor1
parents:
diff changeset
2291 v6 = GetActualAccuracy();
Ritor1
parents:
diff changeset
2292 v11 = GetParameterBonus(v6);
Ritor1
parents:
diff changeset
2293 break;
Ritor1
parents:
diff changeset
2294 default:
Ritor1
parents:
diff changeset
2295 v11 = 0;
Ritor1
parents:
diff changeset
2296 break;
Ritor1
parents:
diff changeset
2297 }
Ritor1
parents:
diff changeset
2298 v22 = GetActualLuck();
Ritor1
parents:
diff changeset
2299 v23 = GetParameterBonus(v22) + v11 + 30;
Ritor1
parents:
diff changeset
2300 if ( rand() % v23 >= 30 )
Ritor1
parents:
diff changeset
2301 {
Ritor1
parents:
diff changeset
2302 return 0;
Ritor1
parents:
diff changeset
2303 }
Ritor1
parents:
diff changeset
2304 else
Ritor1
parents:
diff changeset
2305 {
Ritor1
parents:
diff changeset
2306 for ( v3 = 0; v3 < 4; v3++ )
Ritor1
parents:
diff changeset
2307 {
Ritor1
parents:
diff changeset
2308 if ( this == pPlayers[v3 + 1] )
Ritor1
parents:
diff changeset
2309 break;
Ritor1
parents:
diff changeset
2310 }
Ritor1
parents:
diff changeset
2311
Ritor1
parents:
diff changeset
2312 switch ( attTypeCast )
Ritor1
parents:
diff changeset
2313 {
Ritor1
parents:
diff changeset
2314 case SPECIAL_ATTACK_CURSE:
Ritor1
parents:
diff changeset
2315 SetCondition(Condition_Cursed, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2316 pAudioPlayer->PlaySound(SOUND_221, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2317 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2318 return 1;
Ritor1
parents:
diff changeset
2319 break;
Ritor1
parents:
diff changeset
2320 case SPECIAL_ATTACK_WEAK:
Ritor1
parents:
diff changeset
2321 SetCondition(Condition_Weak, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2322 pAudioPlayer->PlaySound(SOUND_221, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2323 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2324 return 1;
Ritor1
parents:
diff changeset
2325 break;
Ritor1
parents:
diff changeset
2326 case SPECIAL_ATTACK_SLEEP:
Ritor1
parents:
diff changeset
2327 SetCondition(Condition_Sleep, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2328 pAudioPlayer->PlaySound(SOUND_221, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2329 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2330 return 1;
Ritor1
parents:
diff changeset
2331 break;
Ritor1
parents:
diff changeset
2332 case SPECIAL_ATTACK_DRUNK:
Ritor1
parents:
diff changeset
2333 SetCondition(Condition_Drunk, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2334 pAudioPlayer->PlaySound(SOUND_221, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2335 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2336 return 1;
Ritor1
parents:
diff changeset
2337 break;
Ritor1
parents:
diff changeset
2338 case SPECIAL_ATTACK_INSANE:
Ritor1
parents:
diff changeset
2339 SetCondition(Condition_Insane, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2340 pAudioPlayer->PlaySound(SOUND_224, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2341 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2342 return 1;
Ritor1
parents:
diff changeset
2343 break;
Ritor1
parents:
diff changeset
2344 case SPECIAL_ATTACK_POISON_WEAK:
Ritor1
parents:
diff changeset
2345 SetCondition(Condition_Poison_Weak, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2346 pAudioPlayer->PlaySound(SOUND_222, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2347 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2348 return 1;
Ritor1
parents:
diff changeset
2349 break;
Ritor1
parents:
diff changeset
2350 case SPECIAL_ATTACK_POISON_MEDIUM:
Ritor1
parents:
diff changeset
2351 SetCondition(Condition_Poison_Medium, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2352 pAudioPlayer->PlaySound(SOUND_222, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2353 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2354 return 1;
Ritor1
parents:
diff changeset
2355 break;
Ritor1
parents:
diff changeset
2356 case SPECIAL_ATTACK_POISON_SEVERE:
Ritor1
parents:
diff changeset
2357 SetCondition(Condition_Poison_Severe, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2358 pAudioPlayer->PlaySound(SOUND_222, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2359 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2360 return 1;
Ritor1
parents:
diff changeset
2361 break;
Ritor1
parents:
diff changeset
2362 case SPECIAL_ATTACK_DISEASE_WEAK:
Ritor1
parents:
diff changeset
2363 SetCondition(Condition_Disease_Weak, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2364 pAudioPlayer->PlaySound(SOUND_222, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2365 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2366 return 1;
Ritor1
parents:
diff changeset
2367 break;
Ritor1
parents:
diff changeset
2368 case SPECIAL_ATTACK_DISEASE_MEDIUM:
Ritor1
parents:
diff changeset
2369 SetCondition(Condition_Disease_Medium, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2370 pAudioPlayer->PlaySound(SOUND_222, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2371 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2372 return 1;
Ritor1
parents:
diff changeset
2373 break;
Ritor1
parents:
diff changeset
2374 case SPECIAL_ATTACK_DISEASE_SEVERE:
Ritor1
parents:
diff changeset
2375 SetCondition(Condition_Disease_Severe, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2376 pAudioPlayer->PlaySound(SOUND_222, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2377 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2378 return 1;
Ritor1
parents:
diff changeset
2379 break;
Ritor1
parents:
diff changeset
2380 case SPECIAL_ATTACK_PARALYZED:
Ritor1
parents:
diff changeset
2381 SetCondition(Condition_Paralyzed, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2382 pAudioPlayer->PlaySound(SOUND_224, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2383 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2384 return 1;
Ritor1
parents:
diff changeset
2385 break;
Ritor1
parents:
diff changeset
2386 case SPECIAL_ATTACK_UNCONSCIOUS:
Ritor1
parents:
diff changeset
2387 SetCondition(Condition_Unconcious, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2388 pAudioPlayer->PlaySound(SOUND_224, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2389 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2390 return 1;
Ritor1
parents:
diff changeset
2391 break;
Ritor1
parents:
diff changeset
2392 case SPECIAL_ATTACK_DEAD:
Ritor1
parents:
diff changeset
2393 SetCondition(Condition_Dead, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2394 pAudioPlayer->PlaySound(SOUND_225, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2395 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2396 return 1;
Ritor1
parents:
diff changeset
2397 break;
Ritor1
parents:
diff changeset
2398 case SPECIAL_ATTACK_PETRIFIED:
Ritor1
parents:
diff changeset
2399 SetCondition(Condition_Pertified, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2400 pAudioPlayer->PlaySound(SOUND_225, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2401 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2402 return 1;
Ritor1
parents:
diff changeset
2403 break;
Ritor1
parents:
diff changeset
2404 case SPECIAL_ATTACK_ERADICATED:
Ritor1
parents:
diff changeset
2405 SetCondition(Condition_Eradicated, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2406 pAudioPlayer->PlaySound(SOUND_225, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2407 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2408 return 1;
Ritor1
parents:
diff changeset
2409 break;
Ritor1
parents:
diff changeset
2410 case SPECIAL_ATTACK_BREAK_ANY:
Ritor1
parents:
diff changeset
2411 case SPECIAL_ATTACK_BREAK_ARMOR:
Ritor1
parents:
diff changeset
2412 case SPECIAL_ATTACK_BREAK_WEAPON:
Ritor1
parents:
diff changeset
2413 if ( !(v48->uAttributes & ITEM_HARDENED) )
Ritor1
parents:
diff changeset
2414 {
Ritor1
parents:
diff changeset
2415 PlaySound(SPEECH_40, 0);
Ritor1
parents:
diff changeset
2416 v48->SetBroken();
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2417 pAudioPlayer->PlaySound(SOUND_47, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2418 }
Ritor1
parents:
diff changeset
2419 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2420 return 1;
Ritor1
parents:
diff changeset
2421 break;
Ritor1
parents:
diff changeset
2422 case SPECIAL_ATTACK_STEAL:
Ritor1
parents:
diff changeset
2423 PlaySound(SPEECH_40, 0);
Ritor1
parents:
diff changeset
2424 v27 = pActor->ActorHasItems;
Ritor1
parents:
diff changeset
2425 if ( pActor->ActorHasItems[0].uItemID )
Ritor1
parents:
diff changeset
2426 {
Ritor1
parents:
diff changeset
2427 v27 = &pActor->ActorHasItems[1];
Ritor1
parents:
diff changeset
2428 if ( pActor->ActorHasItems[1].uItemID )
Ritor1
parents:
diff changeset
2429 {
Ritor1
parents:
diff changeset
2430 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2431 return 1;
Ritor1
parents:
diff changeset
2432 }
Ritor1
parents:
diff changeset
2433 }
Ritor1
parents:
diff changeset
2434 memcpy(v27, &this->pInventoryItemList[this->pInventoryMatrix[v47]-1], 0x24u);
Ritor1
parents:
diff changeset
2435 RemoveItemAtInventoryIndex(v47);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2436 pAudioPlayer->PlaySound(SOUND_47, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2437 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2438 return 1;
Ritor1
parents:
diff changeset
2439 break;
Ritor1
parents:
diff changeset
2440 case SPECIAL_ATTACK_AGING:
Ritor1
parents:
diff changeset
2441 PlaySound(SPEECH_42, 0);
Ritor1
parents:
diff changeset
2442 ++this->sAgeModifier;
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2443 pAudioPlayer->PlaySound(SOUND_226, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2444 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2445 return 1;
Ritor1
parents:
diff changeset
2446 break;
Ritor1
parents:
diff changeset
2447 case SPECIAL_ATTACK_MANA_DRAIN:
Ritor1
parents:
diff changeset
2448 PlaySound(SPEECH_41, 0);
Ritor1
parents:
diff changeset
2449 this->sMana = 0;
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2450 pAudioPlayer->PlaySound(SOUND_226, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2451 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2452 return 1;
Ritor1
parents:
diff changeset
2453 break;
Ritor1
parents:
diff changeset
2454 case SPECIAL_ATTACK_FEAR:
Ritor1
parents:
diff changeset
2455 SetCondition(Condition_Fear, 1);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
2456 pAudioPlayer->PlaySound(SOUND_221, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
2457 pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3);
Ritor1
parents:
diff changeset
2458 return 1;
Ritor1
parents:
diff changeset
2459 break;
Ritor1
parents:
diff changeset
2460 default:
Ritor1
parents:
diff changeset
2461 return 0;
Ritor1
parents:
diff changeset
2462 }
Ritor1
parents:
diff changeset
2463 }
Ritor1
parents:
diff changeset
2464 }
Ritor1
parents:
diff changeset
2465
Ritor1
parents:
diff changeset
2466 // 48DCF6: using guessed type char var_94[140];
Ritor1
parents:
diff changeset
2467
Ritor1
parents:
diff changeset
2468 //----- (0048E1A3) --------------------------------------------------------
Ritor1
parents:
diff changeset
2469 unsigned int Player::GetSpellSchool(unsigned int uSpellID)
Ritor1
parents:
diff changeset
2470 {
Ritor1
parents:
diff changeset
2471 return pSpellStats->pInfos[uSpellID].uSchool;
Ritor1
parents:
diff changeset
2472 }
Ritor1
parents:
diff changeset
2473
Ritor1
parents:
diff changeset
2474 //----- (0048E1B5) --------------------------------------------------------
Ritor1
parents:
diff changeset
2475 int Player::GetAttackRecoveryTime(bool bRangedAttack)
Ritor1
parents:
diff changeset
2476 {
Ritor1
parents:
diff changeset
2477 ItemGen *weapon = nullptr;
Ritor1
parents:
diff changeset
2478 uint weapon_recovery = base_recovery_times_per_weapon_type[0];
Ritor1
parents:
diff changeset
2479 if (bRangedAttack)
Ritor1
parents:
diff changeset
2480 {
Ritor1
parents:
diff changeset
2481 if ( HasItemEquipped(EQUIP_BOW) )
Ritor1
parents:
diff changeset
2482 {
Ritor1
parents:
diff changeset
2483 weapon = GetBowItem();
Ritor1
parents:
diff changeset
2484 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()];
Ritor1
parents:
diff changeset
2485 }
Ritor1
parents:
diff changeset
2486 }
Ritor1
parents:
diff changeset
2487 else if ( IsUnarmed() == 1 && GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
Ritor1
parents:
diff changeset
2488 {
Ritor1
parents:
diff changeset
2489 weapon_recovery = base_recovery_times_per_weapon_type[1];
Ritor1
parents:
diff changeset
2490 }
Ritor1
parents:
diff changeset
2491 else if ( HasItemEquipped(EQUIP_TWO_HANDED) )
Ritor1
parents:
diff changeset
2492 {
Ritor1
parents:
diff changeset
2493 weapon = GetMainHandItem();
Ritor1
parents:
diff changeset
2494 if (weapon->GetItemEquipType() == EQUIP_WAND)
Ritor1
parents:
diff changeset
2495 {
Ritor1
parents:
diff changeset
2496 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
Ritor1
parents:
diff changeset
2497 __debugbreak(); // looks like wands were two-handed weapons once, or supposed to be. should not get here now
Ritor1
parents:
diff changeset
2498 weapon_recovery = pSpellDatas[wand_spell_ids[weapon->uItemID - ITEM_WAND_FIRE]].uExpertLevelRecovery;
Ritor1
parents:
diff changeset
2499 }
Ritor1
parents:
diff changeset
2500 else
Ritor1
parents:
diff changeset
2501 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()];
Ritor1
parents:
diff changeset
2502 }
Ritor1
parents:
diff changeset
2503 if (HasItemEquipped(EQUIP_SINGLE_HANDED) && GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) != EQUIP_SHIELD)
Ritor1
parents:
diff changeset
2504 // ADD: shield check because shield recovery is added later and can be accidentally doubled
Ritor1
parents:
diff changeset
2505 {
Ritor1
parents:
diff changeset
2506 if (base_recovery_times_per_weapon_type[GetOffHandItem()->GetPlayerSkillType()] > weapon_recovery)
Ritor1
parents:
diff changeset
2507 {
Ritor1
parents:
diff changeset
2508 weapon = GetOffHandItem();
Ritor1
parents:
diff changeset
2509 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()];
Ritor1
parents:
diff changeset
2510 }
Ritor1
parents:
diff changeset
2511 }
Ritor1
parents:
diff changeset
2512
Ritor1
parents:
diff changeset
2513 uint armour_recovery = 0;
Ritor1
parents:
diff changeset
2514 if ( HasItemEquipped(EQUIP_ARMOUR) )
Ritor1
parents:
diff changeset
2515 {
Ritor1
parents:
diff changeset
2516 uchar armour_skill_type = GetArmorItem()->GetPlayerSkillType();
Ritor1
parents:
diff changeset
2517 uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type];
Ritor1
parents:
diff changeset
2518 float multiplier;
Ritor1
parents:
diff changeset
2519
Ritor1
parents:
diff changeset
2520 if (armour_skill_type == PLAYER_SKILL_LEATHER)
Ritor1
parents:
diff changeset
2521 {
Ritor1
parents:
diff changeset
2522 multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 0, 0, 0);
Ritor1
parents:
diff changeset
2523 }
Ritor1
parents:
diff changeset
2524 else if (armour_skill_type == PLAYER_SKILL_CHAIN)
Ritor1
parents:
diff changeset
2525 {
Ritor1
parents:
diff changeset
2526 multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 0.5f, 0, 0);
Ritor1
parents:
diff changeset
2527 }
Ritor1
parents:
diff changeset
2528 else if (armour_skill_type == PLAYER_SKILL_PLATE)
Ritor1
parents:
diff changeset
2529 {
Ritor1
parents:
diff changeset
2530 multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 0.5f, 0.5f, 0);
Ritor1
parents:
diff changeset
2531 }
Ritor1
parents:
diff changeset
2532 else
Ritor1
parents:
diff changeset
2533 {
Ritor1
parents:
diff changeset
2534 Error("Unknown armour type"); // what kind of armour is that?
Ritor1
parents:
diff changeset
2535 multiplier = GetArmorRecoveryMultiplierFromSkillLevel(armour_skill_type, 1.0f, 1.0f, 1.0f, 1.0f);
Ritor1
parents:
diff changeset
2536 }
Ritor1
parents:
diff changeset
2537
Ritor1
parents:
diff changeset
2538 armour_recovery = (uint)(base_armour_recovery * multiplier);
Ritor1
parents:
diff changeset
2539 }
Ritor1
parents:
diff changeset
2540
Ritor1
parents:
diff changeset
2541 uint shield_recovery = 0;
Ritor1
parents:
diff changeset
2542 if (HasItemEquipped(EQUIP_SINGLE_HANDED) && GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) == EQUIP_SHIELD)
Ritor1
parents:
diff changeset
2543 {
Ritor1
parents:
diff changeset
2544 uchar skill_type = GetOffHandItem()->GetPlayerSkillType();
Ritor1
parents:
diff changeset
2545
Ritor1
parents:
diff changeset
2546 uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type];
Ritor1
parents:
diff changeset
2547 float multiplier = GetArmorRecoveryMultiplierFromSkillLevel(skill_type, 1.0f, 0, 0, 0);
Ritor1
parents:
diff changeset
2548 shield_recovery = (uint)(shield_base_recovery * multiplier);
Ritor1
parents:
diff changeset
2549 }
Ritor1
parents:
diff changeset
2550
Ritor1
parents:
diff changeset
2551 uint player_speed_recovery_reduction = GetParameterBonus(GetActualSpeed()),
Ritor1
parents:
diff changeset
2552 sword_axe_bow_recovery_reduction = 0;
Ritor1
parents:
diff changeset
2553 bool shooting_laser = false;
Ritor1
parents:
diff changeset
2554 if (weapon != nullptr)
Ritor1
parents:
diff changeset
2555 {
Ritor1
parents:
diff changeset
2556 if (GetActualSkillLevel((PLAYER_SKILL_TYPE)weapon->GetPlayerSkillType()) &&
Ritor1
parents:
diff changeset
2557 (weapon->GetPlayerSkillType() == PLAYER_SKILL_SWORD || weapon->GetPlayerSkillType() == PLAYER_SKILL_AXE || weapon->GetPlayerSkillType() == PLAYER_SKILL_BOW) )
Ritor1
parents:
diff changeset
2558 {
Ritor1
parents:
diff changeset
2559 if (SkillToMastery(pActiveSkills[weapon->GetPlayerSkillType()]) >= 2 ) // Expert Sword, Axe & Bow reduce recovery
Ritor1
parents:
diff changeset
2560 sword_axe_bow_recovery_reduction = pActiveSkills[weapon->GetPlayerSkillType()] & 0x3F;
Ritor1
parents:
diff changeset
2561 }
Ritor1
parents:
diff changeset
2562 if (weapon->GetPlayerSkillType() == PLAYER_SKILL_BLASTER)
Ritor1
parents:
diff changeset
2563 shooting_laser = true;
Ritor1
parents:
diff changeset
2564 }
Ritor1
parents:
diff changeset
2565
Ritor1
parents:
diff changeset
2566 uint armsmaster_recovery_reduction = 0;
Ritor1
parents:
diff changeset
2567 if (!bRangedAttack && !shooting_laser)
Ritor1
parents:
diff changeset
2568 {
Ritor1
parents:
diff changeset
2569 if (uint armsmaster_level = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER))
Ritor1
parents:
diff changeset
2570 {
Ritor1
parents:
diff changeset
2571 armsmaster_recovery_reduction = armsmaster_level & 0x3F;
Ritor1
parents:
diff changeset
2572 if (SkillToMastery(armsmaster_level) >= 4)
Ritor1
parents:
diff changeset
2573 armsmaster_recovery_reduction *= 2;
Ritor1
parents:
diff changeset
2574 }
Ritor1
parents:
diff changeset
2575 }
Ritor1
parents:
diff changeset
2576
Ritor1
parents:
diff changeset
2577 uint hasteRecoveryReduction = 0;
Ritor1
parents:
diff changeset
2578 if (pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime > 0 || pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0 )
Ritor1
parents:
diff changeset
2579 hasteRecoveryReduction = 25;
Ritor1
parents:
diff changeset
2580
Ritor1
parents:
diff changeset
2581 uint weapon_enchantment_recovery_reduction = 0;
Ritor1
parents:
diff changeset
2582 if ( weapon )
Ritor1
parents:
diff changeset
2583 {
Ritor1
parents:
diff changeset
2584 if (weapon->uSpecEnchantmentType == 59 ||
Ritor1
parents:
diff changeset
2585 weapon->uSpecEnchantmentType == 41 ||
Ritor1
parents:
diff changeset
2586 weapon->uSpecEnchantmentType == 500)
Ritor1
parents:
diff changeset
2587 weapon_enchantment_recovery_reduction = 20;
Ritor1
parents:
diff changeset
2588 }
Ritor1
parents:
diff changeset
2589
Ritor1
parents:
diff changeset
2590 int recovery = weapon_recovery +
Ritor1
parents:
diff changeset
2591 armour_recovery +
Ritor1
parents:
diff changeset
2592 shield_recovery
Ritor1
parents:
diff changeset
2593 - armsmaster_recovery_reduction
Ritor1
parents:
diff changeset
2594 - weapon_enchantment_recovery_reduction
Ritor1
parents:
diff changeset
2595 - hasteRecoveryReduction
Ritor1
parents:
diff changeset
2596 - sword_axe_bow_recovery_reduction
Ritor1
parents:
diff changeset
2597 - player_speed_recovery_reduction;
Ritor1
parents:
diff changeset
2598
Ritor1
parents:
diff changeset
2599 if (recovery < 0)
Ritor1
parents:
diff changeset
2600 recovery = 0;
Ritor1
parents:
diff changeset
2601 return recovery;
Ritor1
parents:
diff changeset
2602 }
Ritor1
parents:
diff changeset
2603
Ritor1
parents:
diff changeset
2604
Ritor1
parents:
diff changeset
2605 //----- new --------------------------------------------------------
Ritor1
parents:
diff changeset
2606 float Player::GetArmorRecoveryMultiplierFromSkillLevel( unsigned char armour_skill_type, float mult1, float mult2, float mult3, float mult4 )
Ritor1
parents:
diff changeset
2607 {
Ritor1
parents:
diff changeset
2608 uint skill_mastery = SkillToMastery(pActiveSkills[armour_skill_type]);
Ritor1
parents:
diff changeset
2609 switch (skill_mastery)
Ritor1
parents:
diff changeset
2610 {
Ritor1
parents:
diff changeset
2611 case 1: return mult1; break;
Ritor1
parents:
diff changeset
2612 case 2: return mult2; break;
Ritor1
parents:
diff changeset
2613 case 3: return mult3; break;
Ritor1
parents:
diff changeset
2614 case 4: return mult4; break;
Ritor1
parents:
diff changeset
2615 }
Ritor1
parents:
diff changeset
2616 Error("Unexpected input value: %d", armour_skill_type);
Ritor1
parents:
diff changeset
2617 return 0;
Ritor1
parents:
diff changeset
2618 }
Ritor1
parents:
diff changeset
2619
Ritor1
parents:
diff changeset
2620 //----- (0048E4F8) --------------------------------------------------------
Ritor1
parents:
diff changeset
2621 int Player::GetMaxHealth()
Ritor1
parents:
diff changeset
2622 {
Ritor1
parents:
diff changeset
2623 int v3; // esi@1
Ritor1
parents:
diff changeset
2624 int v4; // esi@1
Ritor1
parents:
diff changeset
2625 int v6; // esi@1
Ritor1
parents:
diff changeset
2626
Ritor1
parents:
diff changeset
2627 v3 = GetParameterBonus(GetActualEndurance());
Ritor1
parents:
diff changeset
2628 v4 = pBaseHealthPerLevelByClass[classType] * (GetActualLevel() + v3);
Ritor1
parents:
diff changeset
2629 v6 = uFullHealthBonus
Ritor1
parents:
diff changeset
2630 + pBaseHealthByClass[classType / 4]
Ritor1
parents:
diff changeset
2631 + GetSkillBonus(CHARACTER_ATTRIBUTE_HEALTH)
Ritor1
parents:
diff changeset
2632 + GetItemsBonus(CHARACTER_ATTRIBUTE_HEALTH) + v4;
Ritor1
parents:
diff changeset
2633 return max(1, v6);
Ritor1
parents:
diff changeset
2634 }
Ritor1
parents:
diff changeset
2635
Ritor1
parents:
diff changeset
2636 //----- (0048E565) --------------------------------------------------------
Ritor1
parents:
diff changeset
2637 int Player::GetMaxMana()
Ritor1
parents:
diff changeset
2638 {
Ritor1
parents:
diff changeset
2639 int v2; // eax@2
Ritor1
parents:
diff changeset
2640 int v3; // esi@4
Ritor1
parents:
diff changeset
2641 int v4; // eax@5
Ritor1
parents:
diff changeset
2642 int v5; // esi@5
Ritor1
parents:
diff changeset
2643 int v6; // eax@5
Ritor1
parents:
diff changeset
2644 int v7; // esi@6
Ritor1
parents:
diff changeset
2645 int v8; // esi@6
Ritor1
parents:
diff changeset
2646 int v9; // esi@6
Ritor1
parents:
diff changeset
2647
Ritor1
parents:
diff changeset
2648 switch (classType)
Ritor1
parents:
diff changeset
2649 {
Ritor1
parents:
diff changeset
2650 case PLAYER_CLASS_ROGUE:
Ritor1
parents:
diff changeset
2651 case PLAYER_CLASS_SPY:
Ritor1
parents:
diff changeset
2652 case PLAYER_CLASS_ASSASSIN:
Ritor1
parents:
diff changeset
2653 case PLAYER_CLASS_ARCHER:
Ritor1
parents:
diff changeset
2654 case PLAYER_CLASS_WARRIOR_MAGE:
Ritor1
parents:
diff changeset
2655 case PLAYER_CLASS_MASTER_ARCHER:
Ritor1
parents:
diff changeset
2656 case PLAYER_CLASS_SNIPER:
Ritor1
parents:
diff changeset
2657 case PLAYER_CLASS_SORCERER:
Ritor1
parents:
diff changeset
2658 case PLAYER_CLASS_WIZARD:
Ritor1
parents:
diff changeset
2659 case PLAYER_CLASS_ARCHMAGE:
Ritor1
parents:
diff changeset
2660 case PLAYER_CLASS_LICH:
Ritor1
parents:
diff changeset
2661 v2 = GetActualIntelligence();
Ritor1
parents:
diff changeset
2662 v3 = GetParameterBonus(v2);
Ritor1
parents:
diff changeset
2663 break;
Ritor1
parents:
diff changeset
2664 case PLAYER_CLASS_INITIATE:
Ritor1
parents:
diff changeset
2665 case PLAYER_CLASS_MASTER:
Ritor1
parents:
diff changeset
2666 case PLAYER_CLASS_NINJA:
Ritor1
parents:
diff changeset
2667 case PLAYER_CLASS_PALADIN:
Ritor1
parents:
diff changeset
2668 case PLAYER_CLASS_CRUSADER:
Ritor1
parents:
diff changeset
2669 case PLAYER_CLASS_HERO:
Ritor1
parents:
diff changeset
2670 case PLAYER_CLASS_VILLIAN:
Ritor1
parents:
diff changeset
2671 case PLAYER_CLASS_CLERIC:
Ritor1
parents:
diff changeset
2672 case PLAYER_CLASS_PRIEST:
Ritor1
parents:
diff changeset
2673 case PLAYER_CLASS_PRIEST_OF_SUN:
Ritor1
parents:
diff changeset
2674 case PLAYER_CLASS_PRIEST_OF_MOON:
Ritor1
parents:
diff changeset
2675 v2 = GetActualWillpower();
Ritor1
parents:
diff changeset
2676 v3 = GetParameterBonus(v2);
Ritor1
parents:
diff changeset
2677 break;
Ritor1
parents:
diff changeset
2678 case PLAYER_CLASS_HUNTER:
Ritor1
parents:
diff changeset
2679 case PLAYER_CLASS_RANGER_LORD:
Ritor1
parents:
diff changeset
2680 case PLAYER_CLASS_BOUNTY_HUNTER:
Ritor1
parents:
diff changeset
2681 case PLAYER_CLASS_DRUID:
Ritor1
parents:
diff changeset
2682 case PLAYER_CLASS_GREAT_DRUID:
Ritor1
parents:
diff changeset
2683 case PLAYER_CLASS_ARCH_DRUID:
Ritor1
parents:
diff changeset
2684 case PLAYER_CLASS_WARLOCK:
Ritor1
parents:
diff changeset
2685 v4 = GetActualWillpower();
Ritor1
parents:
diff changeset
2686 v5 = GetParameterBonus(v4);
Ritor1
parents:
diff changeset
2687 v6 = GetActualIntelligence();
Ritor1
parents:
diff changeset
2688 v3 = GetParameterBonus(v6) + v5;
Ritor1
parents:
diff changeset
2689 break;
Ritor1
parents:
diff changeset
2690 default:
Ritor1
parents:
diff changeset
2691 return 0;
Ritor1
parents:
diff changeset
2692 break;
Ritor1
parents:
diff changeset
2693 }
Ritor1
parents:
diff changeset
2694 v7 = pBaseManaPerLevelByClass[classType] * (GetActualLevel() + v3);
Ritor1
parents:
diff changeset
2695 v8 = GetItemsBonus(CHARACTER_ATTRIBUTE_MANA) + v7;
Ritor1
parents:
diff changeset
2696 v9 = uFullManaBonus
Ritor1
parents:
diff changeset
2697 + pBaseManaByClass[classType / 4]
Ritor1
parents:
diff changeset
2698 + GetSkillBonus(CHARACTER_ATTRIBUTE_MANA)
Ritor1
parents:
diff changeset
2699 + v8;
Ritor1
parents:
diff changeset
2700 return max(0,v9);
Ritor1
parents:
diff changeset
2701 }
Ritor1
parents:
diff changeset
2702
Ritor1
parents:
diff changeset
2703 //----- (0048E656) --------------------------------------------------------
Ritor1
parents:
diff changeset
2704 int Player::GetBaseAC()
Ritor1
parents:
diff changeset
2705 {
Ritor1
parents:
diff changeset
2706 int v2; // eax@1
Ritor1
parents:
diff changeset
2707 int v3; // esi@1
Ritor1
parents:
diff changeset
2708 int v4; // esi@1
Ritor1
parents:
diff changeset
2709 int v5; // esi@1
Ritor1
parents:
diff changeset
2710
Ritor1
parents:
diff changeset
2711 v2 = GetActualSpeed();
Ritor1
parents:
diff changeset
2712 v3 = GetParameterBonus(v2);
Ritor1
parents:
diff changeset
2713 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v3;
Ritor1
parents:
diff changeset
2714 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4;
Ritor1
parents:
diff changeset
2715 return max(0, v5);
Ritor1
parents:
diff changeset
2716 }
Ritor1
parents:
diff changeset
2717
Ritor1
parents:
diff changeset
2718 //----- (0048E68F) --------------------------------------------------------
Ritor1
parents:
diff changeset
2719 int Player::GetActualAC()
Ritor1
parents:
diff changeset
2720 {
Ritor1
parents:
diff changeset
2721 int v2; // eax@1
Ritor1
parents:
diff changeset
2722 int v3; // esi@1
Ritor1
parents:
diff changeset
2723 int v4; // esi@1
Ritor1
parents:
diff changeset
2724 int v5; // esi@1
Ritor1
parents:
diff changeset
2725 int v6; // esi@1
Ritor1
parents:
diff changeset
2726
Ritor1
parents:
diff changeset
2727 v2 = GetActualSpeed();
Ritor1
parents:
diff changeset
2728 v3 = GetParameterBonus(v2);
Ritor1
parents:
diff changeset
2729 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v3;
Ritor1
parents:
diff changeset
2730 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4;
Ritor1
parents:
diff changeset
2731 v6 = this->sACModifier + GetMagicalBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v5;
Ritor1
parents:
diff changeset
2732 return max(0, v6);
Ritor1
parents:
diff changeset
2733 }
Ritor1
parents:
diff changeset
2734
Ritor1
parents:
diff changeset
2735 //----- (0048E6DC) --------------------------------------------------------
Ritor1
parents:
diff changeset
2736 unsigned int Player::GetBaseAge()
Ritor1
parents:
diff changeset
2737 {
Ritor1
parents:
diff changeset
2738 return (unsigned int)(((__int64)(pParty->uTimePlayed * 0.234375) / 60 / 60 / 24) / 7 / 4 / 12 - uBirthYear + game_starting_year);
Ritor1
parents:
diff changeset
2739 }
Ritor1
parents:
diff changeset
2740
Ritor1
parents:
diff changeset
2741 //----- (0048E72C) --------------------------------------------------------
Ritor1
parents:
diff changeset
2742 unsigned int Player::GetActualAge()
Ritor1
parents:
diff changeset
2743 {
Ritor1
parents:
diff changeset
2744 return this->sAgeModifier + GetBaseAge();
Ritor1
parents:
diff changeset
2745 }
Ritor1
parents:
diff changeset
2746
Ritor1
parents:
diff changeset
2747 //----- (0048E73F) --------------------------------------------------------
Ritor1
parents:
diff changeset
2748 int Player::GetBaseResistance(enum CHARACTER_ATTRIBUTE_TYPE a2)
Ritor1
parents:
diff changeset
2749 {
Ritor1
parents:
diff changeset
2750 int v7; // esi@20
Ritor1
parents:
diff changeset
2751 int racialBonus = 0;
Ritor1
parents:
diff changeset
2752 __int16* resStat;
Ritor1
parents:
diff changeset
2753 int result;
Ritor1
parents:
diff changeset
2754
Ritor1
parents:
diff changeset
2755 switch (a2)
Ritor1
parents:
diff changeset
2756 {
Ritor1
parents:
diff changeset
2757 case CHARACTER_ATTRIBUTE_RESIST_FIRE:
Ritor1
parents:
diff changeset
2758 resStat = &sResFireBase;
Ritor1
parents:
diff changeset
2759 if (IsRaceGoblin())
Ritor1
parents:
diff changeset
2760 racialBonus = 5;
Ritor1
parents:
diff changeset
2761 break;
Ritor1
parents:
diff changeset
2762 case CHARACTER_ATTRIBUTE_RESIST_AIR:
Ritor1
parents:
diff changeset
2763 resStat = &sResAirBase;
Ritor1
parents:
diff changeset
2764 if (IsRaceGoblin())
Ritor1
parents:
diff changeset
2765 racialBonus = 5;
Ritor1
parents:
diff changeset
2766 break;
Ritor1
parents:
diff changeset
2767 case CHARACTER_ATTRIBUTE_RESIST_WATER:
Ritor1
parents:
diff changeset
2768 resStat = &sResWaterBase;
Ritor1
parents:
diff changeset
2769 if (IsRaceDwarf())
Ritor1
parents:
diff changeset
2770 racialBonus = 5;
Ritor1
parents:
diff changeset
2771 break;
Ritor1
parents:
diff changeset
2772 case CHARACTER_ATTRIBUTE_RESIST_EARTH:
Ritor1
parents:
diff changeset
2773 resStat = &sResEarthBase;
Ritor1
parents:
diff changeset
2774 if (IsRaceDwarf())
Ritor1
parents:
diff changeset
2775 racialBonus = 5;
Ritor1
parents:
diff changeset
2776 break;
Ritor1
parents:
diff changeset
2777 case CHARACTER_ATTRIBUTE_RESIST_MIND:
Ritor1
parents:
diff changeset
2778 resStat = &sResMindBase;
Ritor1
parents:
diff changeset
2779 if (IsRaceElf())
Ritor1
parents:
diff changeset
2780 racialBonus = 10;
Ritor1
parents:
diff changeset
2781 break;
Ritor1
parents:
diff changeset
2782 case CHARACTER_ATTRIBUTE_RESIST_BODY:
Ritor1
parents:
diff changeset
2783 case CHARACTER_ATTRIBUTE_RESIST_SPIRIT:
Ritor1
parents:
diff changeset
2784 resStat = &sResBodyBase;
Ritor1
parents:
diff changeset
2785 if (IsRaceHuman())
Ritor1
parents:
diff changeset
2786 racialBonus = 5;
Ritor1
parents:
diff changeset
2787 break;
Ritor1
parents:
diff changeset
2788 default:
Ritor1
parents:
diff changeset
2789 Error("Unknown attribute");
Ritor1
parents:
diff changeset
2790 }
Ritor1
parents:
diff changeset
2791 v7 = GetItemsBonus(a2) + racialBonus;
Ritor1
parents:
diff changeset
2792 result = v7 + *resStat;
Ritor1
parents:
diff changeset
2793 if ( classType == PLAYER_CLASS_LICH )
Ritor1
parents:
diff changeset
2794 {
Ritor1
parents:
diff changeset
2795 if ( result > 200 )
Ritor1
parents:
diff changeset
2796 result = 200;
Ritor1
parents:
diff changeset
2797 }
Ritor1
parents:
diff changeset
2798 return result;
Ritor1
parents:
diff changeset
2799 }
Ritor1
parents:
diff changeset
2800
Ritor1
parents:
diff changeset
2801 //----- (0048E7D0) --------------------------------------------------------
Ritor1
parents:
diff changeset
2802 int Player::GetActualResistance(enum CHARACTER_ATTRIBUTE_TYPE a2)
Ritor1
parents:
diff changeset
2803 {
Ritor1
parents:
diff changeset
2804 signed int v10 = 0; // [sp+14h] [bp-4h]@1
Ritor1
parents:
diff changeset
2805 __int16* resStat;
Ritor1
parents:
diff changeset
2806 int result;
Ritor1
parents:
diff changeset
2807 int baseRes;
Ritor1
parents:
diff changeset
2808
Ritor1
parents:
diff changeset
2809 int leatherArmorSkillLevel = GetActualSkillLevel(PLAYER_SKILL_LEATHER);
Ritor1
parents:
diff changeset
2810 if ( CheckHiredNPCSpeciality(Enchanter) )
Ritor1
parents:
diff changeset
2811 v10 = 20;
Ritor1
parents:
diff changeset
2812 if ( (a2 == CHARACTER_ATTRIBUTE_RESIST_FIRE
Ritor1
parents:
diff changeset
2813 || a2 == CHARACTER_ATTRIBUTE_RESIST_AIR
Ritor1
parents:
diff changeset
2814 || a2 == CHARACTER_ATTRIBUTE_RESIST_WATER
Ritor1
parents:
diff changeset
2815 || a2 == CHARACTER_ATTRIBUTE_RESIST_EARTH)
Ritor1
parents:
diff changeset
2816 && SkillToMastery(leatherArmorSkillLevel) == 4
Ritor1
parents:
diff changeset
2817 && HasItemEquipped(EQUIP_ARMOUR)
Ritor1
parents:
diff changeset
2818 && GetEquippedItemSkillType(EQUIP_ARMOUR) == PLAYER_SKILL_LEATHER )
Ritor1
parents:
diff changeset
2819 v10 += leatherArmorSkillLevel & 0x3F;
Ritor1
parents:
diff changeset
2820 switch (a2)
Ritor1
parents:
diff changeset
2821 {
Ritor1
parents:
diff changeset
2822 case CHARACTER_ATTRIBUTE_RESIST_FIRE:
Ritor1
parents:
diff changeset
2823 resStat = &sResFireBonus;
Ritor1
parents:
diff changeset
2824 break;
Ritor1
parents:
diff changeset
2825 case CHARACTER_ATTRIBUTE_RESIST_AIR:
Ritor1
parents:
diff changeset
2826 resStat = &sResAirBonus;
Ritor1
parents:
diff changeset
2827 break;
Ritor1
parents:
diff changeset
2828 case CHARACTER_ATTRIBUTE_RESIST_WATER:
Ritor1
parents:
diff changeset
2829 resStat = &sResWaterBonus;
Ritor1
parents:
diff changeset
2830 break;
Ritor1
parents:
diff changeset
2831 case CHARACTER_ATTRIBUTE_RESIST_EARTH:
Ritor1
parents:
diff changeset
2832 resStat = &sResEarthBonus;
Ritor1
parents:
diff changeset
2833 break;
Ritor1
parents:
diff changeset
2834 case CHARACTER_ATTRIBUTE_RESIST_MIND:
Ritor1
parents:
diff changeset
2835 resStat = &sResMindBonus;
Ritor1
parents:
diff changeset
2836 break;
Ritor1
parents:
diff changeset
2837 case CHARACTER_ATTRIBUTE_RESIST_BODY:
Ritor1
parents:
diff changeset
2838 case CHARACTER_ATTRIBUTE_RESIST_SPIRIT:
Ritor1
parents:
diff changeset
2839 resStat = &sResBodyBonus;
Ritor1
parents:
diff changeset
2840 break;
Ritor1
parents:
diff changeset
2841 default: Error("Unexpected attribute");
Ritor1
parents:
diff changeset
2842 }
Ritor1
parents:
diff changeset
2843 baseRes = GetBaseResistance(a2);
Ritor1
parents:
diff changeset
2844 result = v10 + GetMagicalBonus(a2) + baseRes + *(resStat);
Ritor1
parents:
diff changeset
2845 if ( classType == PLAYER_CLASS_LICH )
Ritor1
parents:
diff changeset
2846 {
Ritor1
parents:
diff changeset
2847 if ( result > 200 )
Ritor1
parents:
diff changeset
2848 result = 200;
Ritor1
parents:
diff changeset
2849 }
Ritor1
parents:
diff changeset
2850 return result;
Ritor1
parents:
diff changeset
2851 }
Ritor1
parents:
diff changeset
2852
Ritor1
parents:
diff changeset
2853 //----- (0048E8F5) --------------------------------------------------------
Ritor1
parents:
diff changeset
2854 bool Player::Recover(int dt)
Ritor1
parents:
diff changeset
2855 {
Ritor1
parents:
diff changeset
2856 int v3; // qax@1
Ritor1
parents:
diff changeset
2857
Ritor1
parents:
diff changeset
2858 v3 = (int)(dt * GetSpecialItemBonus(17) * 0.01 + dt);
Ritor1
parents:
diff changeset
2859
Ritor1
parents:
diff changeset
2860 //Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery);
Ritor1
parents:
diff changeset
2861
Ritor1
parents:
diff changeset
2862 if (uTimeToRecovery > v3)
Ritor1
parents:
diff changeset
2863 {
Ritor1
parents:
diff changeset
2864 uTimeToRecovery -= v3;
Ritor1
parents:
diff changeset
2865 return true;
Ritor1
parents:
diff changeset
2866 }
Ritor1
parents:
diff changeset
2867 else
Ritor1
parents:
diff changeset
2868 {
Ritor1
parents:
diff changeset
2869 uTimeToRecovery = 0;
Ritor1
parents:
diff changeset
2870 viewparams->bRedrawGameUI = true;
Ritor1
parents:
diff changeset
2871 if (!uActiveCharacter)
Ritor1
parents:
diff changeset
2872 uActiveCharacter = pParty->GetNextActiveCharacter();
Ritor1
parents:
diff changeset
2873 return false;
Ritor1
parents:
diff changeset
2874 }
Ritor1
parents:
diff changeset
2875 }
Ritor1
parents:
diff changeset
2876
Ritor1
parents:
diff changeset
2877 //----- (0048E96A) --------------------------------------------------------
Ritor1
parents:
diff changeset
2878 void Player::SetRecoveryTime(signed int rec)
Ritor1
parents:
diff changeset
2879 {
Ritor1
parents:
diff changeset
2880 Assert(rec >= 0);
Ritor1
parents:
diff changeset
2881
Ritor1
parents:
diff changeset
2882 if (rec > uTimeToRecovery)
Ritor1
parents:
diff changeset
2883 uTimeToRecovery = rec;
Ritor1
parents:
diff changeset
2884
Ritor1
parents:
diff changeset
2885 if (uActiveCharacter != 0 && pPlayers[uActiveCharacter] == this && !some_active_character)
Ritor1
parents:
diff changeset
2886 uActiveCharacter = pParty->GetNextActiveCharacter();
Ritor1
parents:
diff changeset
2887
Ritor1
parents:
diff changeset
2888 viewparams->bRedrawGameUI = true;
Ritor1
parents:
diff changeset
2889 }
Ritor1
parents:
diff changeset
2890 // 50C0C4: using guessed type int some_active_character;
Ritor1
parents:
diff changeset
2891
Ritor1
parents:
diff changeset
2892 //----- (0048E9B7) --------------------------------------------------------
Ritor1
parents:
diff changeset
2893 void Player::RandomizeName()
Ritor1
parents:
diff changeset
2894 {
Ritor1
parents:
diff changeset
2895 if (!uExpressionTimePassed)
Ritor1
parents:
diff changeset
2896 strcpy(pName, pNPCStats->pNPCNames[rand() % pNPCStats->uNumNPCNames[uSex]][uSex]);
Ritor1
parents:
diff changeset
2897 }
Ritor1
parents:
diff changeset
2898
Ritor1
parents:
diff changeset
2899 //----- (0048E9F4) --------------------------------------------------------
Ritor1
parents:
diff changeset
2900 unsigned int Player::GetMajorConditionIdx()
Ritor1
parents:
diff changeset
2901 {
Ritor1
parents:
diff changeset
2902 for (uint i = 0; i < 18; ++i)
Ritor1
parents:
diff changeset
2903 if (pConditions[pConditionImportancyTable[i]] != 0)
Ritor1
parents:
diff changeset
2904 return pConditionImportancyTable[i];
Ritor1
parents:
diff changeset
2905
Ritor1
parents:
diff changeset
2906 return 18;
Ritor1
parents:
diff changeset
2907 }
Ritor1
parents:
diff changeset
2908
Ritor1
parents:
diff changeset
2909 //----- (0048EA1B) --------------------------------------------------------
Ritor1
parents:
diff changeset
2910 int Player::GetParameterBonus( int player_parameter )
Ritor1
parents:
diff changeset
2911 {
Ritor1
parents:
diff changeset
2912 int i; // eax@1
Ritor1
parents:
diff changeset
2913 i = 0;
Ritor1
parents:
diff changeset
2914 while (param_to_bonus_table[i])
Ritor1
parents:
diff changeset
2915 {
Ritor1
parents:
diff changeset
2916 if (player_parameter >= param_to_bonus_table[i])
Ritor1
parents:
diff changeset
2917 break;
Ritor1
parents:
diff changeset
2918 ++i;
Ritor1
parents:
diff changeset
2919 }
Ritor1
parents:
diff changeset
2920 return parameter_to_bonus_value[i];
Ritor1
parents:
diff changeset
2921 }
Ritor1
parents:
diff changeset
2922
Ritor1
parents:
diff changeset
2923 //----- (0048EA46) --------------------------------------------------------
Ritor1
parents:
diff changeset
2924 int Player::GetSpecialItemBonus( int enchantmentId )
Ritor1
parents:
diff changeset
2925 {
Ritor1
parents:
diff changeset
2926 for (int i = EQUIP_SINGLE_HANDED; i < EQUIP_BOOK; ++i )
Ritor1
parents:
diff changeset
2927 {
Ritor1
parents:
diff changeset
2928 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) )
Ritor1
parents:
diff changeset
2929 {
Ritor1
parents:
diff changeset
2930 if (enchantmentId == 17)
Ritor1
parents:
diff changeset
2931 {
Ritor1
parents:
diff changeset
2932 if ((GetNthEquippedIndexItem(i)->uSpecEnchantmentType == 17) || (GetNthEquippedIndexItem(i)->uItemID == 533)) //Elven Chainmail+Increases rate of Recovery
Ritor1
parents:
diff changeset
2933 return 50;
Ritor1
parents:
diff changeset
2934 }
Ritor1
parents:
diff changeset
2935 if (enchantmentId == 24)
Ritor1
parents:
diff changeset
2936 {
Ritor1
parents:
diff changeset
2937 if (GetNthEquippedIndexItem(i)->uSpecEnchantmentType == 24) //Increased Knockback.
Ritor1
parents:
diff changeset
2938 return 5;
Ritor1
parents:
diff changeset
2939 }
Ritor1
parents:
diff changeset
2940 }
Ritor1
parents:
diff changeset
2941 }
Ritor1
parents:
diff changeset
2942 return 0;
Ritor1
parents:
diff changeset
2943 }
Ritor1
parents:
diff changeset
2944
Ritor1
parents:
diff changeset
2945 //----- (0048EAAE) --------------------------------------------------------
Ritor1
parents:
diff changeset
2946 int Player::GetItemsBonus( enum CHARACTER_ATTRIBUTE_TYPE attr, bool getOnlyMainHandDmg /*= false*/ )
Ritor1
parents:
diff changeset
2947 {
Ritor1
parents:
diff changeset
2948 int v5; // edi@1
Ritor1
parents:
diff changeset
2949 int v9; // eax@49
Ritor1
parents:
diff changeset
2950 int v14; // ecx@58
Ritor1
parents:
diff changeset
2951 int v15; // eax@58
Ritor1
parents:
diff changeset
2952 int v17; // eax@62
Ritor1
parents:
diff changeset
2953 int v22; // eax@76
Ritor1
parents:
diff changeset
2954 int v25; // ecx@80
Ritor1
parents:
diff changeset
2955 int v26; // edi@80
Ritor1
parents:
diff changeset
2956 int v32; // eax@98
Ritor1
parents:
diff changeset
2957 int v56; // eax@365
Ritor1
parents:
diff changeset
2958 signed int v58; // [sp-4h] [bp-20h]@10
Ritor1
parents:
diff changeset
2959 int v61; // [sp+10h] [bp-Ch]@1
Ritor1
parents:
diff changeset
2960 int v62; // [sp+14h] [bp-8h]@1
Ritor1
parents:
diff changeset
2961 ItemGen *currEquippedItem; // [sp+20h] [bp+4h]@101
Ritor1
parents:
diff changeset
2962 bool no_skills;
Ritor1
parents:
diff changeset
2963
Ritor1
parents:
diff changeset
2964 v5 = 0;
Ritor1
parents:
diff changeset
2965 v62 = 0;
Ritor1
parents:
diff changeset
2966 v61 = 0;
Ritor1
parents:
diff changeset
2967
Ritor1
parents:
diff changeset
2968 no_skills=false;
Ritor1
parents:
diff changeset
2969 switch (attr)
Ritor1
parents:
diff changeset
2970 {
Ritor1
parents:
diff changeset
2971 case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY: v58 = PLAYER_SKILL_ALCHEMY; break;
Ritor1
parents:
diff changeset
2972 case CHARACTER_ATTRIBUTE_SKILL_STEALING: v58 = PLAYER_SKILL_STEALING; break;
Ritor1
parents:
diff changeset
2973 case CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM: v58 = PLAYER_SKILL_TRAP_DISARM; break;
Ritor1
parents:
diff changeset
2974 case CHARACTER_ATTRIBUTE_SKILL_ITEM_ID: v58 = PLAYER_SKILL_ITEM_ID; break;
Ritor1
parents:
diff changeset
2975 case CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID: v58 = PLAYER_SKILL_MONSTER_ID; break;
Ritor1
parents:
diff changeset
2976 case CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER: v58 = PLAYER_SKILL_ARMSMASTER; break;
Ritor1
parents:
diff changeset
2977 case CHARACTER_ATTRIBUTE_SKILL_DODGE: v58 = PLAYER_SKILL_DODGE; break;
Ritor1
parents:
diff changeset
2978 case CHARACTER_ATTRIBUTE_SKILL_UNARMED: v58 = PLAYER_SKILL_UNARMED; break;
Ritor1
parents:
diff changeset
2979 case CHARACTER_ATTRIBUTE_SKILL_FIRE: v58 = PLAYER_SKILL_FIRE; break;
Ritor1
parents:
diff changeset
2980 case CHARACTER_ATTRIBUTE_SKILL_AIR: v58 = PLAYER_SKILL_AIR; break;
Ritor1
parents:
diff changeset
2981 case CHARACTER_ATTRIBUTE_SKILL_WATER: v58 = PLAYER_SKILL_WATER; break;
Ritor1
parents:
diff changeset
2982 case CHARACTER_ATTRIBUTE_SKILL_EARTH: v58 = PLAYER_SKILL_EARTH; break;
Ritor1
parents:
diff changeset
2983 case CHARACTER_ATTRIBUTE_SKILL_SPIRIT: v58 = PLAYER_SKILL_SPIRIT; break;
Ritor1
parents:
diff changeset
2984 case CHARACTER_ATTRIBUTE_SKILL_MIND: v58 = PLAYER_SKILL_MIND; break;
Ritor1
parents:
diff changeset
2985 case CHARACTER_ATTRIBUTE_SKILL_BODY: v58 = PLAYER_SKILL_BODY; break;
Ritor1
parents:
diff changeset
2986 case CHARACTER_ATTRIBUTE_SKILL_LIGHT: v58 = PLAYER_SKILL_LIGHT; break;
Ritor1
parents:
diff changeset
2987 case CHARACTER_ATTRIBUTE_SKILL_DARK: v58 = PLAYER_SKILL_DARK; break;
Ritor1
parents:
diff changeset
2988 case CHARACTER_ATTRIBUTE_SKILL_MEDITATION: v58 = PLAYER_SKILL_MEDITATION; break;
Ritor1
parents:
diff changeset
2989 case CHARACTER_ATTRIBUTE_SKILL_BOW: v58 = PLAYER_SKILL_BOW; break;
Ritor1
parents:
diff changeset
2990 case CHARACTER_ATTRIBUTE_SKILL_SHIELD: v58 = PLAYER_SKILL_SHIELD; break;
Ritor1
parents:
diff changeset
2991 case CHARACTER_ATTRIBUTE_SKILL_LEARNING: v58 = PLAYER_SKILL_LEARNING; break;
Ritor1
parents:
diff changeset
2992 default:
Ritor1
parents:
diff changeset
2993 no_skills=true;
Ritor1
parents:
diff changeset
2994 }
Ritor1
parents:
diff changeset
2995 if (!no_skills)
Ritor1
parents:
diff changeset
2996 {
Ritor1
parents:
diff changeset
2997 if ( !this->pActiveSkills[v58] )
Ritor1
parents:
diff changeset
2998 return 0;
Ritor1
parents:
diff changeset
2999 }
Ritor1
parents:
diff changeset
3000
Ritor1
parents:
diff changeset
3001 switch(attr) //TODO would be nice to move these into separate functions
Ritor1
parents:
diff changeset
3002 {
Ritor1
parents:
diff changeset
3003 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS:
Ritor1
parents:
diff changeset
3004 case CHARACTER_ATTRIBUTE_RANGED_ATTACK:
Ritor1
parents:
diff changeset
3005 if ( HasItemEquipped(EQUIP_BOW) )
Ritor1
parents:
diff changeset
3006 v5 = GetBowItem()->GetDamageMod();
Ritor1
parents:
diff changeset
3007 return v5;
Ritor1
parents:
diff changeset
3008 break;
Ritor1
parents:
diff changeset
3009
Ritor1
parents:
diff changeset
3010 case CHARACTER_ATTRIBUTE_RANGED_DMG_MIN:
Ritor1
parents:
diff changeset
3011 if ( !HasItemEquipped(EQUIP_BOW) )
Ritor1
parents:
diff changeset
3012 return 0;
Ritor1
parents:
diff changeset
3013 v5 = GetBowItem()->GetDamageMod();
Ritor1
parents:
diff changeset
3014 v56 = GetBowItem()->GetDamageDice();
Ritor1
parents:
diff changeset
3015 return v5 + v56;
Ritor1
parents:
diff changeset
3016 break;
Ritor1
parents:
diff changeset
3017
Ritor1
parents:
diff changeset
3018 case CHARACTER_ATTRIBUTE_RANGED_DMG_MAX:
Ritor1
parents:
diff changeset
3019 if ( !HasItemEquipped(EQUIP_BOW) )
Ritor1
parents:
diff changeset
3020 return 0;
Ritor1
parents:
diff changeset
3021 v5 = GetBowItem()->GetDamageDice() * GetBowItem()->GetDamageRoll();
Ritor1
parents:
diff changeset
3022 v56 = GetBowItem()->GetDamageMod();
Ritor1
parents:
diff changeset
3023 return v5 + v56;
Ritor1
parents:
diff changeset
3024
Ritor1
parents:
diff changeset
3025 case CHARACTER_ATTRIBUTE_LEVEL:
Ritor1
parents:
diff changeset
3026 if ( !Player::HasEnchantedItemEquipped(25) )
Ritor1
parents:
diff changeset
3027 return 0;
Ritor1
parents:
diff changeset
3028 return 5;
Ritor1
parents:
diff changeset
3029 break;
Ritor1
parents:
diff changeset
3030
Ritor1
parents:
diff changeset
3031 case CHARACTER_ATTRIBUTE_MELEE_DMG_MAX:
Ritor1
parents:
diff changeset
3032 if ( IsUnarmed() )
Ritor1
parents:
diff changeset
3033 {
Ritor1
parents:
diff changeset
3034 return 3;
Ritor1
parents:
diff changeset
3035 }
Ritor1
parents:
diff changeset
3036 else
Ritor1
parents:
diff changeset
3037 {
Ritor1
parents:
diff changeset
3038 if ( this->HasItemEquipped(EQUIP_TWO_HANDED) )
Ritor1
parents:
diff changeset
3039 {
Ritor1
parents:
diff changeset
3040 v22 = this->GetEquippedItemEquipType(EQUIP_TWO_HANDED);
Ritor1
parents:
diff changeset
3041 if ( v22 >= 0 && v22 <= 2)
Ritor1
parents:
diff changeset
3042 {
Ritor1
parents:
diff changeset
3043 ItemGen* mainHandItem = GetMainHandItem();
Ritor1
parents:
diff changeset
3044 v26 = mainHandItem->GetDamageRoll();
Ritor1
parents:
diff changeset
3045 if ( GetOffHandItem() != nullptr || mainHandItem->GetPlayerSkillType() != 4 )
Ritor1
parents:
diff changeset
3046 {
Ritor1
parents:
diff changeset
3047 v25 = mainHandItem->GetDamageDice();
Ritor1
parents:
diff changeset
3048 }
Ritor1
parents:
diff changeset
3049 else
Ritor1
parents:
diff changeset
3050 {
Ritor1
parents:
diff changeset
3051 v25 = mainHandItem->GetDamageDice() + 1;
Ritor1
parents:
diff changeset
3052 }
Ritor1
parents:
diff changeset
3053 v5 = mainHandItem->GetDamageMod() + v25 * v26;
Ritor1
parents:
diff changeset
3054 }
Ritor1
parents:
diff changeset
3055 }
Ritor1
parents:
diff changeset
3056 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_SINGLE_HANDED) || (GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) < 0 || GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) > 2))
Ritor1
parents:
diff changeset
3057 {
Ritor1
parents:
diff changeset
3058 return v5;
Ritor1
parents:
diff changeset
3059 }
Ritor1
parents:
diff changeset
3060 else
Ritor1
parents:
diff changeset
3061 {
Ritor1
parents:
diff changeset
3062 ItemGen* offHandItem = GetOffHandItem();
Ritor1
parents:
diff changeset
3063 v15 = offHandItem->GetDamageMod();
Ritor1
parents:
diff changeset
3064 v14 = offHandItem->GetDamageDice() * offHandItem->GetDamageRoll();
Ritor1
parents:
diff changeset
3065 return v5 + v15 + v14;
Ritor1
parents:
diff changeset
3066 }
Ritor1
parents:
diff changeset
3067 }
Ritor1
parents:
diff changeset
3068 break;
Ritor1
parents:
diff changeset
3069
Ritor1
parents:
diff changeset
3070 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS:
Ritor1
parents:
diff changeset
3071 case CHARACTER_ATTRIBUTE_ATTACK:
Ritor1
parents:
diff changeset
3072 if ( IsUnarmed() )
Ritor1
parents:
diff changeset
3073 {
Ritor1
parents:
diff changeset
3074 return 0;
Ritor1
parents:
diff changeset
3075 }
Ritor1
parents:
diff changeset
3076 if ( this->HasItemEquipped(EQUIP_TWO_HANDED) )
Ritor1
parents:
diff changeset
3077 {
Ritor1
parents:
diff changeset
3078 v17 = this->GetEquippedItemEquipType(EQUIP_TWO_HANDED);
Ritor1
parents:
diff changeset
3079 if ( v17 >= 0 && v17 <= 2)
Ritor1
parents:
diff changeset
3080 {
Ritor1
parents:
diff changeset
3081 v5 = GetMainHandItem()->GetDamageMod();
Ritor1
parents:
diff changeset
3082 }
Ritor1
parents:
diff changeset
3083 }
Ritor1
parents:
diff changeset
3084 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_SINGLE_HANDED) || (this->GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) < 0) || this->GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) > 2 )
Ritor1
parents:
diff changeset
3085 return v5;
Ritor1
parents:
diff changeset
3086 else
Ritor1
parents:
diff changeset
3087 {
Ritor1
parents:
diff changeset
3088 v56 = GetOffHandItem()->GetDamageMod();
Ritor1
parents:
diff changeset
3089 return v5 + v56;
Ritor1
parents:
diff changeset
3090 }
Ritor1
parents:
diff changeset
3091 break;
Ritor1
parents:
diff changeset
3092
Ritor1
parents:
diff changeset
3093 case CHARACTER_ATTRIBUTE_MELEE_DMG_MIN:
Ritor1
parents:
diff changeset
3094 if ( IsUnarmed() )
Ritor1
parents:
diff changeset
3095 {
Ritor1
parents:
diff changeset
3096 return 1;
Ritor1
parents:
diff changeset
3097 }
Ritor1
parents:
diff changeset
3098 if ( this->HasItemEquipped(EQUIP_TWO_HANDED) )
Ritor1
parents:
diff changeset
3099 {
Ritor1
parents:
diff changeset
3100 v9 = this->GetEquippedItemEquipType(EQUIP_TWO_HANDED);
Ritor1
parents:
diff changeset
3101 if ( v9 >= 0 && v9 <= 2)
Ritor1
parents:
diff changeset
3102 {
Ritor1
parents:
diff changeset
3103 ItemGen* mainHandItem = GetMainHandItem();
Ritor1
parents:
diff changeset
3104 v5 = mainHandItem->GetDamageDice() +
Ritor1
parents:
diff changeset
3105 mainHandItem->GetDamageMod();
Ritor1
parents:
diff changeset
3106 if ( GetOffHandItem() == nullptr && mainHandItem->GetPlayerSkillType() == 4)
Ritor1
parents:
diff changeset
3107 {
Ritor1
parents:
diff changeset
3108 ++v5;
Ritor1
parents:
diff changeset
3109 }
Ritor1
parents:
diff changeset
3110 }
Ritor1
parents:
diff changeset
3111 }
Ritor1
parents:
diff changeset
3112
Ritor1
parents:
diff changeset
3113 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_SINGLE_HANDED) || (this->GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) < 0) || this->GetEquippedItemEquipType(EQUIP_SINGLE_HANDED) > 2 )
Ritor1
parents:
diff changeset
3114 {
Ritor1
parents:
diff changeset
3115 return v5;
Ritor1
parents:
diff changeset
3116 }
Ritor1
parents:
diff changeset
3117 else
Ritor1
parents:
diff changeset
3118 {
Ritor1
parents:
diff changeset
3119 ItemGen* offHandItem = GetOffHandItem();
Ritor1
parents:
diff changeset
3120 v14 = offHandItem->GetDamageMod();
Ritor1
parents:
diff changeset
3121 v15 = offHandItem->GetDamageDice();
Ritor1
parents:
diff changeset
3122 return v5 + v15 + v14;
Ritor1
parents:
diff changeset
3123 }
Ritor1
parents:
diff changeset
3124 break;
Ritor1
parents:
diff changeset
3125
Ritor1
parents:
diff changeset
3126 case CHARACTER_ATTRIBUTE_STRENGTH:
Ritor1
parents:
diff changeset
3127 case CHARACTER_ATTRIBUTE_INTELLIGENCE:
Ritor1
parents:
diff changeset
3128 case CHARACTER_ATTRIBUTE_WILLPOWER:
Ritor1
parents:
diff changeset
3129 case CHARACTER_ATTRIBUTE_ENDURANCE:
Ritor1
parents:
diff changeset
3130 case CHARACTER_ATTRIBUTE_ACCURACY:
Ritor1
parents:
diff changeset
3131 case CHARACTER_ATTRIBUTE_SPEED:
Ritor1
parents:
diff changeset
3132 case CHARACTER_ATTRIBUTE_LUCK:
Ritor1
parents:
diff changeset
3133 case CHARACTER_ATTRIBUTE_HEALTH:
Ritor1
parents:
diff changeset
3134 case CHARACTER_ATTRIBUTE_MANA:
Ritor1
parents:
diff changeset
3135 case CHARACTER_ATTRIBUTE_AC_BONUS:
Ritor1
parents:
diff changeset
3136
Ritor1
parents:
diff changeset
3137 case CHARACTER_ATTRIBUTE_RESIST_FIRE:
Ritor1
parents:
diff changeset
3138 case CHARACTER_ATTRIBUTE_RESIST_AIR:
Ritor1
parents:
diff changeset
3139 case CHARACTER_ATTRIBUTE_RESIST_WATER:
Ritor1
parents:
diff changeset
3140 case CHARACTER_ATTRIBUTE_RESIST_EARTH:
Ritor1
parents:
diff changeset
3141 case CHARACTER_ATTRIBUTE_RESIST_MIND:
Ritor1
parents:
diff changeset
3142 case CHARACTER_ATTRIBUTE_RESIST_BODY:
Ritor1
parents:
diff changeset
3143 case CHARACTER_ATTRIBUTE_RESIST_SPIRIT:
Ritor1
parents:
diff changeset
3144
Ritor1
parents:
diff changeset
3145 case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY:
Ritor1
parents:
diff changeset
3146 case CHARACTER_ATTRIBUTE_SKILL_STEALING:
Ritor1
parents:
diff changeset
3147 case CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM:
Ritor1
parents:
diff changeset
3148 case CHARACTER_ATTRIBUTE_SKILL_ITEM_ID:
Ritor1
parents:
diff changeset
3149 case CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID:
Ritor1
parents:
diff changeset
3150 case CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER:
Ritor1
parents:
diff changeset
3151 case CHARACTER_ATTRIBUTE_SKILL_DODGE:
Ritor1
parents:
diff changeset
3152 case CHARACTER_ATTRIBUTE_SKILL_UNARMED:
Ritor1
parents:
diff changeset
3153
Ritor1
parents:
diff changeset
3154 case CHARACTER_ATTRIBUTE_SKILL_FIRE:
Ritor1
parents:
diff changeset
3155 case CHARACTER_ATTRIBUTE_SKILL_AIR:
Ritor1
parents:
diff changeset
3156 case CHARACTER_ATTRIBUTE_SKILL_WATER:
Ritor1
parents:
diff changeset
3157 case CHARACTER_ATTRIBUTE_SKILL_EARTH:
Ritor1
parents:
diff changeset
3158 case CHARACTER_ATTRIBUTE_SKILL_SPIRIT:
Ritor1
parents:
diff changeset
3159 case CHARACTER_ATTRIBUTE_SKILL_MIND:
Ritor1
parents:
diff changeset
3160 case CHARACTER_ATTRIBUTE_SKILL_BODY:
Ritor1
parents:
diff changeset
3161 case CHARACTER_ATTRIBUTE_SKILL_LIGHT:
Ritor1
parents:
diff changeset
3162 case CHARACTER_ATTRIBUTE_SKILL_DARK:
Ritor1
parents:
diff changeset
3163 case CHARACTER_ATTRIBUTE_SKILL_MEDITATION:
Ritor1
parents:
diff changeset
3164 case CHARACTER_ATTRIBUTE_SKILL_BOW:
Ritor1
parents:
diff changeset
3165 case CHARACTER_ATTRIBUTE_SKILL_SHIELD:
Ritor1
parents:
diff changeset
3166 case CHARACTER_ATTRIBUTE_SKILL_LEARNING:
Ritor1
parents:
diff changeset
3167 for (int i = 0; i < 16; i++)
Ritor1
parents:
diff changeset
3168 {
Ritor1
parents:
diff changeset
3169 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) )
Ritor1
parents:
diff changeset
3170 {
Ritor1
parents:
diff changeset
3171 currEquippedItem = GetNthEquippedIndexItem(i);
Ritor1
parents:
diff changeset
3172 if ( attr == CHARACTER_ATTRIBUTE_AC_BONUS )
Ritor1
parents:
diff changeset
3173 {
Ritor1
parents:
diff changeset
3174 v32 = currEquippedItem->GetItemEquipType();
Ritor1
parents:
diff changeset
3175 if ( v32 >= 3 && v32 <= 11 )
Ritor1
parents:
diff changeset
3176 {
Ritor1
parents:
diff changeset
3177 v5 += currEquippedItem->GetDamageDice() + currEquippedItem->GetDamageMod();
Ritor1
parents:
diff changeset
3178 }
Ritor1
parents:
diff changeset
3179 }
Ritor1
parents:
diff changeset
3180 if ( pItemsTable->IsMaterialNonCommon(currEquippedItem)
Ritor1
parents:
diff changeset
3181 && !pItemsTable->IsMaterialSpecial(currEquippedItem) )
Ritor1
parents:
diff changeset
3182 {
Ritor1
parents:
diff changeset
3183 currEquippedItem->GetItemBonusArtifact(this, attr, &v62);
Ritor1
parents:
diff changeset
3184 }
Ritor1
parents:
diff changeset
3185 else if ( currEquippedItem->uEnchantmentType != 0 )
Ritor1
parents:
diff changeset
3186 {
Ritor1
parents:
diff changeset
3187 if (this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uEnchantmentType - 1 == attr)//if (currEquippedItem->IsRegularEnchanmentForAttribute(attr))
Ritor1
parents:
diff changeset
3188 {
Ritor1
parents:
diff changeset
3189 if ( attr > CHARACTER_ATTRIBUTE_RESIST_BODY && v5 < currEquippedItem->m_enchantmentStrength )//for skills bonuses
Ritor1
parents:
diff changeset
3190 v5 = currEquippedItem->m_enchantmentStrength;
Ritor1
parents:
diff changeset
3191 else // for resists and attributes bonuses
Ritor1
parents:
diff changeset
3192 v5 += currEquippedItem->m_enchantmentStrength;
Ritor1
parents:
diff changeset
3193 }
Ritor1
parents:
diff changeset
3194 }
Ritor1
parents:
diff changeset
3195 else
Ritor1
parents:
diff changeset
3196 {
Ritor1
parents:
diff changeset
3197 currEquippedItem->GetItemBonusSpecialEnchantment(this, attr, &v5, &v61);
Ritor1
parents:
diff changeset
3198 }
Ritor1
parents:
diff changeset
3199 }
Ritor1
parents:
diff changeset
3200 }
Ritor1
parents:
diff changeset
3201 return v5 + v62 + v61;
Ritor1
parents:
diff changeset
3202 break;
Ritor1
parents:
diff changeset
3203 default:
Ritor1
parents:
diff changeset
3204 return 0;
Ritor1
parents:
diff changeset
3205 }
Ritor1
parents:
diff changeset
3206 }
Ritor1
parents:
diff changeset
3207
Ritor1
parents:
diff changeset
3208 //----- (0048F73C) --------------------------------------------------------
Ritor1
parents:
diff changeset
3209 int Player::GetMagicalBonus(enum CHARACTER_ATTRIBUTE_TYPE a2)
Ritor1
parents:
diff changeset
3210 {
Ritor1
parents:
diff changeset
3211 int v3 = 0; // eax@4
Ritor1
parents:
diff changeset
3212 int v4 = 0; // ecx@5
Ritor1
parents:
diff changeset
3213
Ritor1
parents:
diff changeset
3214 switch ( a2 )
Ritor1
parents:
diff changeset
3215 {
Ritor1
parents:
diff changeset
3216 case CHARACTER_ATTRIBUTE_RESIST_FIRE:
Ritor1
parents:
diff changeset
3217 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_FIRE].uPower;
Ritor1
parents:
diff changeset
3218 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].uPower;
Ritor1
parents:
diff changeset
3219 break;
Ritor1
parents:
diff changeset
3220 case CHARACTER_ATTRIBUTE_RESIST_AIR:
Ritor1
parents:
diff changeset
3221 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_AIR].uPower;
Ritor1
parents:
diff changeset
3222 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].uPower;
Ritor1
parents:
diff changeset
3223 break;
Ritor1
parents:
diff changeset
3224 case CHARACTER_ATTRIBUTE_RESIST_BODY:
Ritor1
parents:
diff changeset
3225 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_BODY].uPower;
Ritor1
parents:
diff changeset
3226 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_BODY].uPower;
Ritor1
parents:
diff changeset
3227 break;
Ritor1
parents:
diff changeset
3228 case CHARACTER_ATTRIBUTE_RESIST_WATER:
Ritor1
parents:
diff changeset
3229 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_WATER].uPower;
Ritor1
parents:
diff changeset
3230 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].uPower;
Ritor1
parents:
diff changeset
3231 break;
Ritor1
parents:
diff changeset
3232 case CHARACTER_ATTRIBUTE_RESIST_EARTH:
Ritor1
parents:
diff changeset
3233 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_EARTH].uPower;
Ritor1
parents:
diff changeset
3234 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].uPower;
Ritor1
parents:
diff changeset
3235 break;
Ritor1
parents:
diff changeset
3236 case CHARACTER_ATTRIBUTE_RESIST_MIND:
Ritor1
parents:
diff changeset
3237 v3 = this->pPlayerBuffs[PLAYER_BUFF_RESIST_MIND].uPower;
Ritor1
parents:
diff changeset
3238 v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].uPower;
Ritor1
parents:
diff changeset
3239 break;
Ritor1
parents:
diff changeset
3240 case CHARACTER_ATTRIBUTE_ATTACK:
Ritor1
parents:
diff changeset
3241 case CHARACTER_ATTRIBUTE_RANGED_ATTACK:
Ritor1
parents:
diff changeset
3242 v3 = this->pPlayerBuffs[PLAYER_BUFF_BLESS].uPower; //only player effect spell in both VI and VII
Ritor1
parents:
diff changeset
3243 break;
Ritor1
parents:
diff changeset
3244 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS:
Ritor1
parents:
diff changeset
3245 v3 = this->pPlayerBuffs[PLAYER_BUFF_HEROISM].uPower;
Ritor1
parents:
diff changeset
3246 v4 = pParty->pPartyBuffs[PARTY_BUFF_HEROISM].uPower;
Ritor1
parents:
diff changeset
3247 break;
Ritor1
parents:
diff changeset
3248 case CHARACTER_ATTRIBUTE_STRENGTH:
Ritor1
parents:
diff changeset
3249 v3 = pPlayerBuffs[PLAYER_BUFF_STRENGTH].uPower;
Ritor1
parents:
diff changeset
3250 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower;
Ritor1
parents:
diff changeset
3251 break;
Ritor1
parents:
diff changeset
3252 case CHARACTER_ATTRIBUTE_INTELLIGENCE:
Ritor1
parents:
diff changeset
3253 v3 = pPlayerBuffs[PLAYER_BUFF_INTELLIGENCE].uPower;
Ritor1
parents:
diff changeset
3254 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower;
Ritor1
parents:
diff changeset
3255 break;
Ritor1
parents:
diff changeset
3256 case CHARACTER_ATTRIBUTE_WILLPOWER:
Ritor1
parents:
diff changeset
3257 v3 = pPlayerBuffs[PLAYER_BUFF_WILLPOWER].uPower;
Ritor1
parents:
diff changeset
3258 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower;
Ritor1
parents:
diff changeset
3259 break;
Ritor1
parents:
diff changeset
3260 case CHARACTER_ATTRIBUTE_ENDURANCE:
Ritor1
parents:
diff changeset
3261 v3 = pPlayerBuffs[PLAYER_BUFF_ENDURANCE].uPower;
Ritor1
parents:
diff changeset
3262 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower;
Ritor1
parents:
diff changeset
3263 break;
Ritor1
parents:
diff changeset
3264 case CHARACTER_ATTRIBUTE_ACCURACY:
Ritor1
parents:
diff changeset
3265 v3 = pPlayerBuffs[PLAYER_BUFF_ACCURACY].uPower;
Ritor1
parents:
diff changeset
3266 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower;
Ritor1
parents:
diff changeset
3267 break;
Ritor1
parents:
diff changeset
3268 case CHARACTER_ATTRIBUTE_SPEED:
Ritor1
parents:
diff changeset
3269 v3 = pPlayerBuffs[PLAYER_BUFF_SPEED].uPower;
Ritor1
parents:
diff changeset
3270 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower;
Ritor1
parents:
diff changeset
3271 break;
Ritor1
parents:
diff changeset
3272 case CHARACTER_ATTRIBUTE_LUCK:
Ritor1
parents:
diff changeset
3273 v3 = pPlayerBuffs[PLAYER_BUFF_LUCK].uPower;
Ritor1
parents:
diff changeset
3274 v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower;
Ritor1
parents:
diff changeset
3275 break;
Ritor1
parents:
diff changeset
3276 case CHARACTER_ATTRIBUTE_AC_BONUS:
Ritor1
parents:
diff changeset
3277 v3 = this->pPlayerBuffs[PLAYER_BUFF_STONESKIN].uPower;
Ritor1
parents:
diff changeset
3278 v4 = pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].uPower;
Ritor1
parents:
diff changeset
3279 break;
Ritor1
parents:
diff changeset
3280 }
Ritor1
parents:
diff changeset
3281 return v3 + v4;
Ritor1
parents:
diff changeset
3282 }
Ritor1
parents:
diff changeset
3283
Ritor1
parents:
diff changeset
3284 //----- (0048F882) --------------------------------------------------------
Ritor1
parents:
diff changeset
3285 int Player::GetActualSkillLevel( PLAYER_SKILL_TYPE uSkillType )
Ritor1
parents:
diff changeset
3286 {
Ritor1
parents:
diff changeset
3287 signed int bonus_value; // esi@1
Ritor1
parents:
diff changeset
3288 unsigned __int16 skill_value; // ax@126
Ritor1
parents:
diff changeset
3289 int result; // al@127
Ritor1
parents:
diff changeset
3290
Ritor1
parents:
diff changeset
3291 bonus_value = 0;
Ritor1
parents:
diff changeset
3292 switch (uSkillType)
Ritor1
parents:
diff changeset
3293 {
Ritor1
parents:
diff changeset
3294 case PLAYER_SKILL_MONSTER_ID:
Ritor1
parents:
diff changeset
3295 {
Ritor1
parents:
diff changeset
3296 if ( CheckHiredNPCSpeciality(Hunter) )
Ritor1
parents:
diff changeset
3297 bonus_value = 6;
Ritor1
parents:
diff changeset
3298 if ( CheckHiredNPCSpeciality(Sage) )
Ritor1
parents:
diff changeset
3299 bonus_value += 6;
Ritor1
parents:
diff changeset
3300 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID);
Ritor1
parents:
diff changeset
3301 }
Ritor1
parents:
diff changeset
3302 break;
Ritor1
parents:
diff changeset
3303
Ritor1
parents:
diff changeset
3304 case PLAYER_SKILL_ARMSMASTER:
Ritor1
parents:
diff changeset
3305 {
Ritor1
parents:
diff changeset
3306 if ( CheckHiredNPCSpeciality(Armsmaster) )
Ritor1
parents:
diff changeset
3307 bonus_value = 2;
Ritor1
parents:
diff changeset
3308 if ( CheckHiredNPCSpeciality(Weaponsmaster) )
Ritor1
parents:
diff changeset
3309 bonus_value += 3;
Ritor1
parents:
diff changeset
3310 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER);
Ritor1
parents:
diff changeset
3311 }
Ritor1
parents:
diff changeset
3312 break;
Ritor1
parents:
diff changeset
3313
Ritor1
parents:
diff changeset
3314 case PLAYER_SKILL_STEALING:
Ritor1
parents:
diff changeset
3315 {
Ritor1
parents:
diff changeset
3316 if (CheckHiredNPCSpeciality(Burglar))
Ritor1
parents:
diff changeset
3317 bonus_value = 8;
Ritor1
parents:
diff changeset
3318 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_STEALING);
Ritor1
parents:
diff changeset
3319 }
Ritor1
parents:
diff changeset
3320 break;
Ritor1
parents:
diff changeset
3321
Ritor1
parents:
diff changeset
3322
Ritor1
parents:
diff changeset
3323 case PLAYER_SKILL_ALCHEMY:
Ritor1
parents:
diff changeset
3324 {
Ritor1
parents:
diff changeset
3325 if ( CheckHiredNPCSpeciality(Herbalist) )
Ritor1
parents:
diff changeset
3326 bonus_value = 4;
Ritor1
parents:
diff changeset
3327 if ( CheckHiredNPCSpeciality(Apothecary) )
Ritor1
parents:
diff changeset
3328 bonus_value += 8;
Ritor1
parents:
diff changeset
3329 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY);
Ritor1
parents:
diff changeset
3330 }
Ritor1
parents:
diff changeset
3331 break;
Ritor1
parents:
diff changeset
3332
Ritor1
parents:
diff changeset
3333 case PLAYER_SKILL_LEARNING:
Ritor1
parents:
diff changeset
3334 {
Ritor1
parents:
diff changeset
3335 if ( CheckHiredNPCSpeciality(Teacher) )
Ritor1
parents:
diff changeset
3336 bonus_value = 10;
Ritor1
parents:
diff changeset
3337 if ( CheckHiredNPCSpeciality(Instructor) )
Ritor1
parents:
diff changeset
3338 bonus_value += 15;
Ritor1
parents:
diff changeset
3339 if ( CheckHiredNPCSpeciality(Scholar) )
Ritor1
parents:
diff changeset
3340 bonus_value += 5;
Ritor1
parents:
diff changeset
3341 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LEARNING);
Ritor1
parents:
diff changeset
3342 }
Ritor1
parents:
diff changeset
3343 break;
Ritor1
parents:
diff changeset
3344
Ritor1
parents:
diff changeset
3345 case PLAYER_SKILL_UNARMED:
Ritor1
parents:
diff changeset
3346 {
Ritor1
parents:
diff changeset
3347 if (CheckHiredNPCSpeciality(Monk) )
Ritor1
parents:
diff changeset
3348 bonus_value = 2;
Ritor1
parents:
diff changeset
3349 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_UNARMED);
Ritor1
parents:
diff changeset
3350 }
Ritor1
parents:
diff changeset
3351 break;
Ritor1
parents:
diff changeset
3352
Ritor1
parents:
diff changeset
3353 case PLAYER_SKILL_DODGE:
Ritor1
parents:
diff changeset
3354 {
Ritor1
parents:
diff changeset
3355 if ( CheckHiredNPCSpeciality(Monk) )
Ritor1
parents:
diff changeset
3356 bonus_value = 2;
Ritor1
parents:
diff changeset
3357 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DODGE);
Ritor1
parents:
diff changeset
3358 }
Ritor1
parents:
diff changeset
3359 break;
Ritor1
parents:
diff changeset
3360
Ritor1
parents:
diff changeset
3361 case PLAYER_SKILL_BOW:
Ritor1
parents:
diff changeset
3362 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BOW);
Ritor1
parents:
diff changeset
3363 break;
Ritor1
parents:
diff changeset
3364 case PLAYER_SKILL_SHIELD:
Ritor1
parents:
diff changeset
3365 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SHIELD);
Ritor1
parents:
diff changeset
3366 break;
Ritor1
parents:
diff changeset
3367
Ritor1
parents:
diff changeset
3368 case PLAYER_SKILL_EARTH:
Ritor1
parents:
diff changeset
3369 if ( CheckHiredNPCSpeciality(Apprentice) )
Ritor1
parents:
diff changeset
3370 bonus_value = 2;
Ritor1
parents:
diff changeset
3371 if ( CheckHiredNPCSpeciality(Mystic) )
Ritor1
parents:
diff changeset
3372 bonus_value += 3;
Ritor1
parents:
diff changeset
3373 if ( CheckHiredNPCSpeciality(Spellmaster) )
Ritor1
parents:
diff changeset
3374 bonus_value += 4;
Ritor1
parents:
diff changeset
3375 if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
Ritor1
parents:
diff changeset
3376 bonus_value += 3;
Ritor1
parents:
diff changeset
3377 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_EARTH);
Ritor1
parents:
diff changeset
3378 break;
Ritor1
parents:
diff changeset
3379 case PLAYER_SKILL_FIRE:
Ritor1
parents:
diff changeset
3380 if ( CheckHiredNPCSpeciality(Apprentice) )
Ritor1
parents:
diff changeset
3381 bonus_value = 2;
Ritor1
parents:
diff changeset
3382 if ( CheckHiredNPCSpeciality(Mystic) )
Ritor1
parents:
diff changeset
3383 bonus_value += 3;
Ritor1
parents:
diff changeset
3384 if ( CheckHiredNPCSpeciality(Spellmaster) )
Ritor1
parents:
diff changeset
3385 bonus_value += 4;
Ritor1
parents:
diff changeset
3386 if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
Ritor1
parents:
diff changeset
3387 bonus_value += 3;
Ritor1
parents:
diff changeset
3388 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_FIRE);
Ritor1
parents:
diff changeset
3389 break;
Ritor1
parents:
diff changeset
3390 case PLAYER_SKILL_AIR:
Ritor1
parents:
diff changeset
3391 if ( CheckHiredNPCSpeciality(Apprentice) )
Ritor1
parents:
diff changeset
3392 bonus_value = 2;
Ritor1
parents:
diff changeset
3393 if ( CheckHiredNPCSpeciality(Mystic) )
Ritor1
parents:
diff changeset
3394 bonus_value += 3;
Ritor1
parents:
diff changeset
3395 if ( CheckHiredNPCSpeciality(Spellmaster) )
Ritor1
parents:
diff changeset
3396 bonus_value += 4;
Ritor1
parents:
diff changeset
3397 if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
Ritor1
parents:
diff changeset
3398 bonus_value += 3;
Ritor1
parents:
diff changeset
3399 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_AIR);
Ritor1
parents:
diff changeset
3400 break;
Ritor1
parents:
diff changeset
3401 case PLAYER_SKILL_WATER:
Ritor1
parents:
diff changeset
3402 if ( CheckHiredNPCSpeciality(Apprentice) )
Ritor1
parents:
diff changeset
3403 bonus_value = 2;
Ritor1
parents:
diff changeset
3404 if ( CheckHiredNPCSpeciality(Mystic) )
Ritor1
parents:
diff changeset
3405 bonus_value += 3;
Ritor1
parents:
diff changeset
3406 if ( CheckHiredNPCSpeciality(Spellmaster) )
Ritor1
parents:
diff changeset
3407 bonus_value += 4;
Ritor1
parents:
diff changeset
3408 if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() )
Ritor1
parents:
diff changeset
3409 bonus_value += 3;
Ritor1
parents:
diff changeset
3410 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_WATER);
Ritor1
parents:
diff changeset
3411 break;
Ritor1
parents:
diff changeset
3412 case PLAYER_SKILL_SPIRIT:
Ritor1
parents:
diff changeset
3413 if ( CheckHiredNPCSpeciality(Acolyte2) )
Ritor1
parents:
diff changeset
3414 bonus_value = 2;
Ritor1
parents:
diff changeset
3415 if ( CheckHiredNPCSpeciality(Initiate) )
Ritor1
parents:
diff changeset
3416 bonus_value += 3;
Ritor1
parents:
diff changeset
3417 if ( CheckHiredNPCSpeciality(Prelate) )
Ritor1
parents:
diff changeset
3418 bonus_value += 4;
Ritor1
parents:
diff changeset
3419 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SPIRIT);
Ritor1
parents:
diff changeset
3420 break;
Ritor1
parents:
diff changeset
3421 case PLAYER_SKILL_MIND:
Ritor1
parents:
diff changeset
3422 if ( CheckHiredNPCSpeciality(Acolyte2) )
Ritor1
parents:
diff changeset
3423 bonus_value = 2;
Ritor1
parents:
diff changeset
3424 if ( CheckHiredNPCSpeciality(Initiate) )
Ritor1
parents:
diff changeset
3425 bonus_value += 3;
Ritor1
parents:
diff changeset
3426 if ( CheckHiredNPCSpeciality(Prelate) )
Ritor1
parents:
diff changeset
3427 bonus_value += 4;
Ritor1
parents:
diff changeset
3428 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MIND);
Ritor1
parents:
diff changeset
3429 break;
Ritor1
parents:
diff changeset
3430 case PLAYER_SKILL_BODY:
Ritor1
parents:
diff changeset
3431 if ( CheckHiredNPCSpeciality(Acolyte2) )
Ritor1
parents:
diff changeset
3432 bonus_value = 2;
Ritor1
parents:
diff changeset
3433 if ( CheckHiredNPCSpeciality(Initiate) )
Ritor1
parents:
diff changeset
3434 bonus_value += 3;
Ritor1
parents:
diff changeset
3435 if ( CheckHiredNPCSpeciality(Prelate) )
Ritor1
parents:
diff changeset
3436 bonus_value += 4;
Ritor1
parents:
diff changeset
3437 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BODY);
Ritor1
parents:
diff changeset
3438 break;
Ritor1
parents:
diff changeset
3439 case PLAYER_SKILL_LIGHT:
Ritor1
parents:
diff changeset
3440 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LIGHT);
Ritor1
parents:
diff changeset
3441 break;
Ritor1
parents:
diff changeset
3442 case PLAYER_SKILL_DARK:
Ritor1
parents:
diff changeset
3443 {
Ritor1
parents:
diff changeset
3444 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DARK);
Ritor1
parents:
diff changeset
3445 }
Ritor1
parents:
diff changeset
3446 break;
Ritor1
parents:
diff changeset
3447
Ritor1
parents:
diff changeset
3448 case PLAYER_SKILL_MERCHANT:
Ritor1
parents:
diff changeset
3449 {
Ritor1
parents:
diff changeset
3450 if ( CheckHiredNPCSpeciality(Trader) )
Ritor1
parents:
diff changeset
3451 bonus_value = 4;
Ritor1
parents:
diff changeset
3452 if ( CheckHiredNPCSpeciality(Merchant) )
Ritor1
parents:
diff changeset
3453 bonus_value += 6;
Ritor1
parents:
diff changeset
3454 if ( CheckHiredNPCSpeciality(Gypsy) )
Ritor1
parents:
diff changeset
3455 bonus_value += 3;
Ritor1
parents:
diff changeset
3456 if ( CheckHiredNPCSpeciality(Duper) )
Ritor1
parents:
diff changeset
3457 bonus_value += 8;
Ritor1
parents:
diff changeset
3458 }
Ritor1
parents:
diff changeset
3459 break;
Ritor1
parents:
diff changeset
3460
Ritor1
parents:
diff changeset
3461 case PLAYER_SKILL_PERCEPTION:
Ritor1
parents:
diff changeset
3462 {
Ritor1
parents:
diff changeset
3463 if ( CheckHiredNPCSpeciality(Scout) )
Ritor1
parents:
diff changeset
3464 bonus_value = 6;
Ritor1
parents:
diff changeset
3465 if ( CheckHiredNPCSpeciality(Psychic) )
Ritor1
parents:
diff changeset
3466 bonus_value += 5;
Ritor1
parents:
diff changeset
3467 }
Ritor1
parents:
diff changeset
3468 break;
Ritor1
parents:
diff changeset
3469
Ritor1
parents:
diff changeset
3470 case PLAYER_SKILL_ITEM_ID:
Ritor1
parents:
diff changeset
3471 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID);
Ritor1
parents:
diff changeset
3472 break;
Ritor1
parents:
diff changeset
3473 case PLAYER_SKILL_MEDITATION:
Ritor1
parents:
diff changeset
3474 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MEDITATION);
Ritor1
parents:
diff changeset
3475 break;
Ritor1
parents:
diff changeset
3476 case PLAYER_SKILL_TRAP_DISARM:
Ritor1
parents:
diff changeset
3477 {
Ritor1
parents:
diff changeset
3478 if ( CheckHiredNPCSpeciality(Tinker) )
Ritor1
parents:
diff changeset
3479 bonus_value = 4;
Ritor1
parents:
diff changeset
3480 if ( CheckHiredNPCSpeciality(Locksmith) )
Ritor1
parents:
diff changeset
3481 bonus_value += 6;
Ritor1
parents:
diff changeset
3482 if ( CheckHiredNPCSpeciality(Burglar) )
Ritor1
parents:
diff changeset
3483 bonus_value += 8;
Ritor1
parents:
diff changeset
3484 bonus_value += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM);
Ritor1
parents:
diff changeset
3485 }
Ritor1
parents:
diff changeset
3486 break;
Ritor1
parents:
diff changeset
3487 }
Ritor1
parents:
diff changeset
3488
Ritor1
parents:
diff changeset
3489 skill_value = pActiveSkills[uSkillType];
Ritor1
parents:
diff changeset
3490 if ( bonus_value + (skill_value & 0x3F) < 60 )
Ritor1
parents:
diff changeset
3491 result = bonus_value + skill_value;
Ritor1
parents:
diff changeset
3492 else
Ritor1
parents:
diff changeset
3493 result = skill_value & 0xFFFC | 0x3C; //al
Ritor1
parents:
diff changeset
3494 return result;
Ritor1
parents:
diff changeset
3495 }
Ritor1
parents:
diff changeset
3496
Ritor1
parents:
diff changeset
3497
Ritor1
parents:
diff changeset
3498 //----- (0048FC00) --------------------------------------------------------
Ritor1
parents:
diff changeset
3499 int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE inSkill) //TODO: move the individual implementations to attribute classes once possible
Ritor1
parents:
diff changeset
3500 {
Ritor1
parents:
diff changeset
3501 int armsMasterBonus;
Ritor1
parents:
diff changeset
3502
Ritor1
parents:
diff changeset
3503 armsMasterBonus = 0;
Ritor1
parents:
diff changeset
3504 int armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER);
Ritor1
parents:
diff changeset
3505 if ( armmaster_skill > 0 )
Ritor1
parents:
diff changeset
3506 {
Ritor1
parents:
diff changeset
3507 int multiplier = 0;
Ritor1
parents:
diff changeset
3508 if ( inSkill == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS )
Ritor1
parents:
diff changeset
3509 {
Ritor1
parents:
diff changeset
3510 multiplier = GetMultiplierForSkillLevel(armmaster_skill, 0, 0, 1, 2);
Ritor1
parents:
diff changeset
3511 }
Ritor1
parents:
diff changeset
3512 else if ( inSkill == CHARACTER_ATTRIBUTE_ATTACK )
Ritor1
parents:
diff changeset
3513 {
Ritor1
parents:
diff changeset
3514 multiplier = GetMultiplierForSkillLevel(armmaster_skill, 0, 1, 1, 2);
Ritor1
parents:
diff changeset
3515 }
Ritor1
parents:
diff changeset
3516 armsMasterBonus = multiplier * (armmaster_skill & 0x3F);
Ritor1
parents:
diff changeset
3517 }
Ritor1
parents:
diff changeset
3518
Ritor1
parents:
diff changeset
3519 switch(inSkill)
Ritor1
parents:
diff changeset
3520 {
Ritor1
parents:
diff changeset
3521 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS:
Ritor1
parents:
diff changeset
3522 if (HasItemEquipped(EQUIP_BOW))
Ritor1
parents:
diff changeset
3523 {
Ritor1
parents:
diff changeset
3524 int bowSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE);
Ritor1
parents:
diff changeset
3525 int multiplier = GetMultiplierForSkillLevel(bowSkillLevel, 0, 0, 0, 1);
Ritor1
parents:
diff changeset
3526 return multiplier * (bowSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3527 }
Ritor1
parents:
diff changeset
3528 return 0;
Ritor1
parents:
diff changeset
3529 break;
Ritor1
parents:
diff changeset
3530 case CHARACTER_ATTRIBUTE_HEALTH:
Ritor1
parents:
diff changeset
3531 {
Ritor1
parents:
diff changeset
3532 int base_value = pBaseHealthPerLevelByClass[classType];
Ritor1
parents:
diff changeset
3533 int attrib_modif = GetBodybuilding();
Ritor1
parents:
diff changeset
3534 return base_value * attrib_modif;
Ritor1
parents:
diff changeset
3535 }
Ritor1
parents:
diff changeset
3536 break;
Ritor1
parents:
diff changeset
3537 case CHARACTER_ATTRIBUTE_MANA:
Ritor1
parents:
diff changeset
3538 {
Ritor1
parents:
diff changeset
3539 int base_value = pBaseManaPerLevelByClass[classType];
Ritor1
parents:
diff changeset
3540 int attrib_modif = GetMeditation();
Ritor1
parents:
diff changeset
3541 return base_value * attrib_modif;
Ritor1
parents:
diff changeset
3542 }
Ritor1
parents:
diff changeset
3543 break;
Ritor1
parents:
diff changeset
3544 case CHARACTER_ATTRIBUTE_AC_BONUS:
Ritor1
parents:
diff changeset
3545 {
Ritor1
parents:
diff changeset
3546 bool wearingArmor = false;
Ritor1
parents:
diff changeset
3547 bool wearingLeather = false;
Ritor1
parents:
diff changeset
3548 unsigned int ACSum = 0;
Ritor1
parents:
diff changeset
3549
Ritor1
parents:
diff changeset
3550 for (int j = 0; j < 16; ++j)
Ritor1
parents:
diff changeset
3551 {
Ritor1
parents:
diff changeset
3552 ItemGen* currItem = GetNthEquippedIndexItem(j);
Ritor1
parents:
diff changeset
3553 if (currItem != nullptr && (!currItem->IsBroken()))
Ritor1
parents:
diff changeset
3554 {
Ritor1
parents:
diff changeset
3555 PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)currItem->GetPlayerSkillType();
Ritor1
parents:
diff changeset
3556 int currArmorSkillLevel = 0;
Ritor1
parents:
diff changeset
3557 int multiplier = 0;
Ritor1
parents:
diff changeset
3558 switch (itemSkillType)
Ritor1
parents:
diff changeset
3559 {
Ritor1
parents:
diff changeset
3560 case PLAYER_SKILL_STAFF:
Ritor1
parents:
diff changeset
3561 currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
Ritor1
parents:
diff changeset
3562 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 0, 1, 1, 1);
Ritor1
parents:
diff changeset
3563 break;
Ritor1
parents:
diff changeset
3564 case PLAYER_SKILL_SWORD:
Ritor1
parents:
diff changeset
3565 case PLAYER_SKILL_SPEAR:
Ritor1
parents:
diff changeset
3566 currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
Ritor1
parents:
diff changeset
3567 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 0, 0, 0, 1);
Ritor1
parents:
diff changeset
3568 break;
Ritor1
parents:
diff changeset
3569 case PLAYER_SKILL_SHIELD:
Ritor1
parents:
diff changeset
3570 currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
Ritor1
parents:
diff changeset
3571 wearingArmor = true;
Ritor1
parents:
diff changeset
3572 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 2, 2);
Ritor1
parents:
diff changeset
3573 break;
Ritor1
parents:
diff changeset
3574 case PLAYER_SKILL_LEATHER:
Ritor1
parents:
diff changeset
3575 currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
Ritor1
parents:
diff changeset
3576 wearingLeather = true;
Ritor1
parents:
diff changeset
3577 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 2, 2);
Ritor1
parents:
diff changeset
3578 break;
Ritor1
parents:
diff changeset
3579 case PLAYER_SKILL_CHAIN:
Ritor1
parents:
diff changeset
3580 currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
Ritor1
parents:
diff changeset
3581 wearingArmor = true;
Ritor1
parents:
diff changeset
3582 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 1, 1);
Ritor1
parents:
diff changeset
3583 break;
Ritor1
parents:
diff changeset
3584 case PLAYER_SKILL_PLATE:
Ritor1
parents:
diff changeset
3585 currArmorSkillLevel = GetActualSkillLevel(itemSkillType);
Ritor1
parents:
diff changeset
3586 wearingArmor = true;
Ritor1
parents:
diff changeset
3587 multiplier = GetMultiplierForSkillLevel(currArmorSkillLevel, 1, 1, 1, 1);
Ritor1
parents:
diff changeset
3588 break;
Ritor1
parents:
diff changeset
3589 }
Ritor1
parents:
diff changeset
3590 ACSum += multiplier * (currArmorSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3591 }
Ritor1
parents:
diff changeset
3592 }
Ritor1
parents:
diff changeset
3593
Ritor1
parents:
diff changeset
3594 int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE);
Ritor1
parents:
diff changeset
3595 int dodgeMastery = SkillToMastery(dodgeSkillLevel);
Ritor1
parents:
diff changeset
3596 int multiplier = GetMultiplierForSkillLevel(dodgeSkillLevel, 1, 2, 3, 3);
Ritor1
parents:
diff changeset
3597 if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) )
Ritor1
parents:
diff changeset
3598 {
Ritor1
parents:
diff changeset
3599 ACSum += multiplier * (dodgeSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3600 }
Ritor1
parents:
diff changeset
3601 return ACSum;
Ritor1
parents:
diff changeset
3602 }
Ritor1
parents:
diff changeset
3603 break;
Ritor1
parents:
diff changeset
3604 case CHARACTER_ATTRIBUTE_ATTACK:
Ritor1
parents:
diff changeset
3605 if ( this->IsUnarmed() )
Ritor1
parents:
diff changeset
3606 {
Ritor1
parents:
diff changeset
3607 int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
Ritor1
parents:
diff changeset
3608 if (!unarmedSkill)
Ritor1
parents:
diff changeset
3609 {
Ritor1
parents:
diff changeset
3610 return 0;
Ritor1
parents:
diff changeset
3611 }
Ritor1
parents:
diff changeset
3612 int multiplier = GetMultiplierForSkillLevel(unarmedSkill, 0, 1, 2, 2);
Ritor1
parents:
diff changeset
3613 return armsMasterBonus + multiplier * (unarmedSkill & 0x3F);
Ritor1
parents:
diff changeset
3614 }
Ritor1
parents:
diff changeset
3615 for (int i = 0; i < 16; ++i)
Ritor1
parents:
diff changeset
3616 {
Ritor1
parents:
diff changeset
3617 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
Ritor1
parents:
diff changeset
3618 {
Ritor1
parents:
diff changeset
3619 ItemGen* currItem = GetNthEquippedIndexItem(i);
Ritor1
parents:
diff changeset
3620 if ( currItem->GetItemEquipType() <= EQUIP_TWO_HANDED)
Ritor1
parents:
diff changeset
3621 {
Ritor1
parents:
diff changeset
3622 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItem->GetPlayerSkillType();
Ritor1
parents:
diff changeset
3623 int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType);
Ritor1
parents:
diff changeset
3624 if (currItemSkillType == PLAYER_SKILL_BLASTER)
Ritor1
parents:
diff changeset
3625 {
Ritor1
parents:
diff changeset
3626 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
3627 return multiplier * (currentItemSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3628 }
Ritor1
parents:
diff changeset
3629 else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
Ritor1
parents:
diff changeset
3630 {
Ritor1
parents:
diff changeset
3631 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
Ritor1
parents:
diff changeset
3632 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 2, 2);
Ritor1
parents:
diff changeset
3633 return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3634 }
Ritor1
parents:
diff changeset
3635 else
Ritor1
parents:
diff changeset
3636 {
Ritor1
parents:
diff changeset
3637 return armsMasterBonus + (currentItemSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3638 }
Ritor1
parents:
diff changeset
3639 }
Ritor1
parents:
diff changeset
3640 }
Ritor1
parents:
diff changeset
3641 }
Ritor1
parents:
diff changeset
3642 return 0;
Ritor1
parents:
diff changeset
3643 break;
Ritor1
parents:
diff changeset
3644
Ritor1
parents:
diff changeset
3645 case CHARACTER_ATTRIBUTE_RANGED_ATTACK:
Ritor1
parents:
diff changeset
3646 for (int i = 0; i < 16; i++)
Ritor1
parents:
diff changeset
3647 {
Ritor1
parents:
diff changeset
3648 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
Ritor1
parents:
diff changeset
3649 {
Ritor1
parents:
diff changeset
3650 ItemGen* currItemPtr = GetNthEquippedIndexItem(i);
Ritor1
parents:
diff changeset
3651 if ( currItemPtr->GetItemEquipType() == EQUIP_TWO_HANDED || currItemPtr->GetItemEquipType() == EQUIP_SINGLE_HANDED )
Ritor1
parents:
diff changeset
3652 {
Ritor1
parents:
diff changeset
3653 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)GetNthEquippedIndexItem(i)->GetPlayerSkillType();
Ritor1
parents:
diff changeset
3654 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType);
Ritor1
parents:
diff changeset
3655 if ( currentItemSkillType == PLAYER_SKILL_BOW )
Ritor1
parents:
diff changeset
3656 {
Ritor1
parents:
diff changeset
3657 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 1, 1);
Ritor1
parents:
diff changeset
3658 return multiplier * (currentItemSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3659 }
Ritor1
parents:
diff changeset
3660 else if ( currentItemSkillType == PLAYER_SKILL_BLASTER )
Ritor1
parents:
diff changeset
3661 {
Ritor1
parents:
diff changeset
3662 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5);
Ritor1
parents:
diff changeset
3663 return multiplier * (currentItemSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3664 }
Ritor1
parents:
diff changeset
3665 }
Ritor1
parents:
diff changeset
3666 }
Ritor1
parents:
diff changeset
3667 }
Ritor1
parents:
diff changeset
3668 return 0;
Ritor1
parents:
diff changeset
3669 break;
Ritor1
parents:
diff changeset
3670
Ritor1
parents:
diff changeset
3671 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS:
Ritor1
parents:
diff changeset
3672 if ( this->IsUnarmed() )
Ritor1
parents:
diff changeset
3673 {
Ritor1
parents:
diff changeset
3674 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
Ritor1
parents:
diff changeset
3675 if ( !unarmedSkillLevel )
Ritor1
parents:
diff changeset
3676 {
Ritor1
parents:
diff changeset
3677 return 0;
Ritor1
parents:
diff changeset
3678 }
Ritor1
parents:
diff changeset
3679 int multiplier = GetMultiplierForSkillLevel(unarmedSkillLevel, 0, 1, 2, 2);
Ritor1
parents:
diff changeset
3680 return multiplier * (unarmedSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3681 }
Ritor1
parents:
diff changeset
3682 for (int i = 0; i < 16; i++)
Ritor1
parents:
diff changeset
3683 {
Ritor1
parents:
diff changeset
3684 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) )
Ritor1
parents:
diff changeset
3685 {
Ritor1
parents:
diff changeset
3686 ItemGen* currItemPtr = GetNthEquippedIndexItem(i);
Ritor1
parents:
diff changeset
3687 if ( currItemPtr->GetItemEquipType() == EQUIP_TWO_HANDED || currItemPtr->GetItemEquipType() == EQUIP_SINGLE_HANDED )
Ritor1
parents:
diff changeset
3688 {
Ritor1
parents:
diff changeset
3689 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItemPtr->GetPlayerSkillType();
Ritor1
parents:
diff changeset
3690 int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType);
Ritor1
parents:
diff changeset
3691 int baseSkillBonus;
Ritor1
parents:
diff changeset
3692 int multiplier;
Ritor1
parents:
diff changeset
3693 switch (currItemSkillType)
Ritor1
parents:
diff changeset
3694 {
Ritor1
parents:
diff changeset
3695 case PLAYER_SKILL_STAFF:
Ritor1
parents:
diff changeset
3696 if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0)
Ritor1
parents:
diff changeset
3697 {
Ritor1
parents:
diff changeset
3698 int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
Ritor1
parents:
diff changeset
3699 int multiplier = GetMultiplierForSkillLevel(unarmedSkillLevel, 0, 1, 2, 2);
Ritor1
parents:
diff changeset
3700 return multiplier * (unarmedSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3701 }
Ritor1
parents:
diff changeset
3702 else
Ritor1
parents:
diff changeset
3703 {
Ritor1
parents:
diff changeset
3704 return armsMasterBonus;
Ritor1
parents:
diff changeset
3705 }
Ritor1
parents:
diff changeset
3706 break;
Ritor1
parents:
diff changeset
3707
Ritor1
parents:
diff changeset
3708 case PLAYER_SKILL_DAGGER:
Ritor1
parents:
diff changeset
3709 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 0, 1);
Ritor1
parents:
diff changeset
3710 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3711 return armsMasterBonus + baseSkillBonus;
Ritor1
parents:
diff changeset
3712 break;
Ritor1
parents:
diff changeset
3713 case PLAYER_SKILL_SWORD:
Ritor1
parents:
diff changeset
3714 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
3715 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3716 return armsMasterBonus + baseSkillBonus;
Ritor1
parents:
diff changeset
3717 break;
Ritor1
parents:
diff changeset
3718 case PLAYER_SKILL_MACE:
Ritor1
parents:
diff changeset
3719 case PLAYER_SKILL_SPEAR:
Ritor1
parents:
diff changeset
3720 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 1, 1, 1);
Ritor1
parents:
diff changeset
3721 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3722 return armsMasterBonus + baseSkillBonus;
Ritor1
parents:
diff changeset
3723 break;
Ritor1
parents:
diff changeset
3724 case PLAYER_SKILL_AXE:
Ritor1
parents:
diff changeset
3725 multiplier = GetMultiplierForSkillLevel(currItemSkillLevel, 0, 0, 1, 1);
Ritor1
parents:
diff changeset
3726 baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F);
Ritor1
parents:
diff changeset
3727 return armsMasterBonus + baseSkillBonus;
Ritor1
parents:
diff changeset
3728 break;
Ritor1
parents:
diff changeset
3729 }
Ritor1
parents:
diff changeset
3730 }
Ritor1
parents:
diff changeset
3731 }
Ritor1
parents:
diff changeset
3732 }
Ritor1
parents:
diff changeset
3733 return 0;
Ritor1
parents:
diff changeset
3734 break;
Ritor1
parents:
diff changeset
3735 default:
Ritor1
parents:
diff changeset
3736 return 0;
Ritor1
parents:
diff changeset
3737 }
Ritor1
parents:
diff changeset
3738 }
Ritor1
parents:
diff changeset
3739
Ritor1
parents:
diff changeset
3740 unsigned int Player::GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4)
Ritor1
parents:
diff changeset
3741 {
Ritor1
parents:
diff changeset
3742 int masteryLvl = SkillToMastery(skillValue);
Ritor1
parents:
diff changeset
3743 switch (masteryLvl)
Ritor1
parents:
diff changeset
3744 {
Ritor1
parents:
diff changeset
3745 case 1: return mult1;
Ritor1
parents:
diff changeset
3746 case 2: return mult2;
Ritor1
parents:
diff changeset
3747 case 3: return mult3;
Ritor1
parents:
diff changeset
3748 case 4: return mult4;
Ritor1
parents:
diff changeset
3749 }
Ritor1
parents:
diff changeset
3750 Error("(%u)", masteryLvl);
Ritor1
parents:
diff changeset
3751 return 0;
Ritor1
parents:
diff changeset
3752 }
Ritor1
parents:
diff changeset
3753 //----- (00490109) --------------------------------------------------------
Ritor1
parents:
diff changeset
3754 // faces are: 0 1 2 3 human males
Ritor1
parents:
diff changeset
3755 // 4 5 6 7 human females
Ritor1
parents:
diff changeset
3756 // 8 9 elf males
Ritor1
parents:
diff changeset
3757 // 10 11 elf females
Ritor1
parents:
diff changeset
3758 // 12 13 dwarf males
Ritor1
parents:
diff changeset
3759 // 14 15 dwarf females
Ritor1
parents:
diff changeset
3760 // 16 17 goblin males
Ritor1
parents:
diff changeset
3761 // 18 19 goblin females
Ritor1
parents:
diff changeset
3762 // 20 lich male
Ritor1
parents:
diff changeset
3763 // 21 lich female
Ritor1
parents:
diff changeset
3764 // 22 underwater suits (unused)
Ritor1
parents:
diff changeset
3765 // 23 zombie male
Ritor1
parents:
diff changeset
3766 // 24 zombie female
Ritor1
parents:
diff changeset
3767 enum CHARACTER_RACE Player::GetRace()
Ritor1
parents:
diff changeset
3768 {
Ritor1
parents:
diff changeset
3769 if ( uCurrentFace <= 7 )
Ritor1
parents:
diff changeset
3770 {
Ritor1
parents:
diff changeset
3771 return CHARACTER_RACE_HUMAN;
Ritor1
parents:
diff changeset
3772 }
Ritor1
parents:
diff changeset
3773 else if ( uCurrentFace <= 11 )
Ritor1
parents:
diff changeset
3774 {
Ritor1
parents:
diff changeset
3775 return CHARACTER_RACE_ELF;
Ritor1
parents:
diff changeset
3776 }
Ritor1
parents:
diff changeset
3777 else if ( uCurrentFace <= 15 )
Ritor1
parents:
diff changeset
3778 {
Ritor1
parents:
diff changeset
3779 return CHARACTER_RACE_DWARF;
Ritor1
parents:
diff changeset
3780 }
Ritor1
parents:
diff changeset
3781 else if ( uCurrentFace <= 19 )
Ritor1
parents:
diff changeset
3782 {
Ritor1
parents:
diff changeset
3783 return CHARACTER_RACE_GOBLIN;
Ritor1
parents:
diff changeset
3784 }
Ritor1
parents:
diff changeset
3785 else
Ritor1
parents:
diff changeset
3786 {
Ritor1
parents:
diff changeset
3787 return CHARACTER_RACE_HUMAN;
Ritor1
parents:
diff changeset
3788 }
Ritor1
parents:
diff changeset
3789 }
Ritor1
parents:
diff changeset
3790
Ritor1
parents:
diff changeset
3791 //----- (00490141) --------------------------------------------------------
Ritor1
parents:
diff changeset
3792 PLAYER_SEX Player::GetSexByVoice()
Ritor1
parents:
diff changeset
3793 {
Ritor1
parents:
diff changeset
3794 switch ( this->uVoiceID )
Ritor1
parents:
diff changeset
3795 {
Ritor1
parents:
diff changeset
3796 case 0u:
Ritor1
parents:
diff changeset
3797 case 1u:
Ritor1
parents:
diff changeset
3798 case 2u:
Ritor1
parents:
diff changeset
3799 case 3u:
Ritor1
parents:
diff changeset
3800 case 8u:
Ritor1
parents:
diff changeset
3801 case 9u:
Ritor1
parents:
diff changeset
3802 case 0xCu:
Ritor1
parents:
diff changeset
3803 case 0xDu:
Ritor1
parents:
diff changeset
3804 case 0x10u:
Ritor1
parents:
diff changeset
3805 case 0x11u:
Ritor1
parents:
diff changeset
3806 case 0x14u:
Ritor1
parents:
diff changeset
3807 case 0x17u:
Ritor1
parents:
diff changeset
3808 return SEX_MALE;
Ritor1
parents:
diff changeset
3809
Ritor1
parents:
diff changeset
3810 case 4u:
Ritor1
parents:
diff changeset
3811 case 5u:
Ritor1
parents:
diff changeset
3812 case 6u:
Ritor1
parents:
diff changeset
3813 case 7u:
Ritor1
parents:
diff changeset
3814 case 0xAu:
Ritor1
parents:
diff changeset
3815 case 0xBu:
Ritor1
parents:
diff changeset
3816 case 0xEu:
Ritor1
parents:
diff changeset
3817 case 0xFu:
Ritor1
parents:
diff changeset
3818 case 0x12u:
Ritor1
parents:
diff changeset
3819 case 0x13u:
Ritor1
parents:
diff changeset
3820 case 0x15u:
Ritor1
parents:
diff changeset
3821 case 0x18u:
Ritor1
parents:
diff changeset
3822 return SEX_FEMALE;
Ritor1
parents:
diff changeset
3823 }
Ritor1
parents:
diff changeset
3824 Error("(%u)", this->uVoiceID);
Ritor1
parents:
diff changeset
3825 return SEX_MALE;
Ritor1
parents:
diff changeset
3826 }
Ritor1
parents:
diff changeset
3827
Ritor1
parents:
diff changeset
3828 //----- (00490188) --------------------------------------------------------
Ritor1
parents:
diff changeset
3829 void Player::SetInitialStats()
Ritor1
parents:
diff changeset
3830 {
Ritor1
parents:
diff changeset
3831 CHARACTER_RACE v1 = GetRace();
Ritor1
parents:
diff changeset
3832 uMight = StatTable[v1][0].uBaseValue;
Ritor1
parents:
diff changeset
3833 uIntelligence = StatTable[v1][1].uBaseValue;
Ritor1
parents:
diff changeset
3834 uWillpower = StatTable[v1][2].uBaseValue;
Ritor1
parents:
diff changeset
3835 uEndurance = StatTable[v1][3].uBaseValue;
Ritor1
parents:
diff changeset
3836 uAccuracy = StatTable[v1][4].uBaseValue;
Ritor1
parents:
diff changeset
3837 uSpeed = StatTable[v1][5].uBaseValue;
Ritor1
parents:
diff changeset
3838 uLuck = StatTable[v1][6].uBaseValue;
Ritor1
parents:
diff changeset
3839 }
Ritor1
parents:
diff changeset
3840
Ritor1
parents:
diff changeset
3841 //----- (004901FC) --------------------------------------------------------
Ritor1
parents:
diff changeset
3842 void Player::SetSexByVoice()
Ritor1
parents:
diff changeset
3843 {
Ritor1
parents:
diff changeset
3844 switch ( this->uVoiceID)
Ritor1
parents:
diff changeset
3845 {
Ritor1
parents:
diff changeset
3846 case 0:
Ritor1
parents:
diff changeset
3847 case 1:
Ritor1
parents:
diff changeset
3848 case 2:
Ritor1
parents:
diff changeset
3849 case 3:
Ritor1
parents:
diff changeset
3850 case 8:
Ritor1
parents:
diff changeset
3851 case 9:
Ritor1
parents:
diff changeset
3852 case 0xC:
Ritor1
parents:
diff changeset
3853 case 0xD:
Ritor1
parents:
diff changeset
3854 case 0x10:
Ritor1
parents:
diff changeset
3855 case 0x11:
Ritor1
parents:
diff changeset
3856 case 0x14:
Ritor1
parents:
diff changeset
3857 case 0x17:
Ritor1
parents:
diff changeset
3858 this->uSex = SEX_MALE;
Ritor1
parents:
diff changeset
3859 break;
Ritor1
parents:
diff changeset
3860 case 4:
Ritor1
parents:
diff changeset
3861 case 5:
Ritor1
parents:
diff changeset
3862 case 6:
Ritor1
parents:
diff changeset
3863 case 7:
Ritor1
parents:
diff changeset
3864 case 0xA:
Ritor1
parents:
diff changeset
3865 case 0xB:
Ritor1
parents:
diff changeset
3866 case 0xE:
Ritor1
parents:
diff changeset
3867 case 0xF:
Ritor1
parents:
diff changeset
3868 case 0x12:
Ritor1
parents:
diff changeset
3869 case 0x13:
Ritor1
parents:
diff changeset
3870 case 0x15:
Ritor1
parents:
diff changeset
3871 case 0x18:
Ritor1
parents:
diff changeset
3872 this->uSex = SEX_FEMALE;
Ritor1
parents:
diff changeset
3873 break;
Ritor1
parents:
diff changeset
3874 default:
Ritor1
parents:
diff changeset
3875 Error("(%u)", this->uVoiceID);
Ritor1
parents:
diff changeset
3876 break;
Ritor1
parents:
diff changeset
3877 }
Ritor1
parents:
diff changeset
3878
Ritor1
parents:
diff changeset
3879 }
Ritor1
parents:
diff changeset
3880
Ritor1
parents:
diff changeset
3881 //----- (0049024A) --------------------------------------------------------
Ritor1
parents:
diff changeset
3882 void Player::Reset(PLAYER_CLASS_TYPE cls)
Ritor1
parents:
diff changeset
3883 {
Ritor1
parents:
diff changeset
3884 sLevelModifier = 0;
Ritor1
parents:
diff changeset
3885 sAgeModifier = 0;
Ritor1
parents:
diff changeset
3886
Ritor1
parents:
diff changeset
3887 classType = cls;
Ritor1
parents:
diff changeset
3888 uLuckBonus = 0;
Ritor1
parents:
diff changeset
3889 uSpeedBonus = 0;
Ritor1
parents:
diff changeset
3890 uAccuracyBonus = 0;
Ritor1
parents:
diff changeset
3891 uEnduranceBonus = 0;
Ritor1
parents:
diff changeset
3892 uWillpowerBonus = 0;
Ritor1
parents:
diff changeset
3893 uIntelligenceBonus = 0;
Ritor1
parents:
diff changeset
3894 uMightBonus = 0;
Ritor1
parents:
diff changeset
3895 uLevel = 1;
Ritor1
parents:
diff changeset
3896 uExperience = 251 + rand() % 100;
Ritor1
parents:
diff changeset
3897 uBirthYear = 1147 - rand() % 6;
Ritor1
parents:
diff changeset
3898 pActiveSkills.fill(0);
Ritor1
parents:
diff changeset
3899 memset(_achieved_awards_bits, 0, sizeof(_achieved_awards_bits));
Ritor1
parents:
diff changeset
3900 memset(&spellbook, 0, sizeof(spellbook));
Ritor1
parents:
diff changeset
3901
Ritor1
parents:
diff changeset
3902 for (uint i = 0; i < 37; ++i)
Ritor1
parents:
diff changeset
3903 {
Ritor1
parents:
diff changeset
3904 if (pSkillAvailabilityPerClass[classType / 4][i] != 2)
Ritor1
parents:
diff changeset
3905 continue;
Ritor1
parents:
diff changeset
3906
Ritor1
parents:
diff changeset
3907 pActiveSkills[i] = 1;
Ritor1
parents:
diff changeset
3908
Ritor1
parents:
diff changeset
3909 switch (i)
Ritor1
parents:
diff changeset
3910 {
Ritor1
parents:
diff changeset
3911 case PLAYER_SKILL_FIRE:
Ritor1
parents:
diff changeset
3912 spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;//its temporary, for test spells
Ritor1
parents:
diff changeset
3913
Ritor1
parents:
diff changeset
3914 extern bool all_magic;
Ritor1
parents:
diff changeset
3915 if ( all_magic == true )
Ritor1
parents:
diff changeset
3916 {
Ritor1
parents:
diff changeset
3917 pActiveSkills[PLAYER_SKILL_AIR] = 1;
Ritor1
parents:
diff changeset
3918 pActiveSkills[PLAYER_SKILL_WATER] = 1;
Ritor1
parents:
diff changeset
3919 pActiveSkills[PLAYER_SKILL_EARTH] = 1;
Ritor1
parents:
diff changeset
3920 spellbook.pFireSpellbook.bIsSpellAvailable[1] = true;
Ritor1
parents:
diff changeset
3921 spellbook.pFireSpellbook.bIsSpellAvailable[2] = true;
Ritor1
parents:
diff changeset
3922 spellbook.pFireSpellbook.bIsSpellAvailable[3] = true;
Ritor1
parents:
diff changeset
3923 spellbook.pFireSpellbook.bIsSpellAvailable[4] = true;
Ritor1
parents:
diff changeset
3924 spellbook.pFireSpellbook.bIsSpellAvailable[5] = true;
Ritor1
parents:
diff changeset
3925 spellbook.pFireSpellbook.bIsSpellAvailable[6] = true;
Ritor1
parents:
diff changeset
3926 spellbook.pFireSpellbook.bIsSpellAvailable[7] = true;
Ritor1
parents:
diff changeset
3927 spellbook.pFireSpellbook.bIsSpellAvailable[8] = true;
Ritor1
parents:
diff changeset
3928 spellbook.pFireSpellbook.bIsSpellAvailable[9] = true;
Ritor1
parents:
diff changeset
3929 spellbook.pFireSpellbook.bIsSpellAvailable[10] = true;
Ritor1
parents:
diff changeset
3930 spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3931 spellbook.pAirSpellbook.bIsSpellAvailable[1] = true;
Ritor1
parents:
diff changeset
3932 spellbook.pAirSpellbook.bIsSpellAvailable[2] = true;
Ritor1
parents:
diff changeset
3933 spellbook.pAirSpellbook.bIsSpellAvailable[3] = true;
Ritor1
parents:
diff changeset
3934 spellbook.pAirSpellbook.bIsSpellAvailable[4] = true;
Ritor1
parents:
diff changeset
3935 spellbook.pAirSpellbook.bIsSpellAvailable[5] = true;
Ritor1
parents:
diff changeset
3936 spellbook.pAirSpellbook.bIsSpellAvailable[6] = true;
Ritor1
parents:
diff changeset
3937 spellbook.pAirSpellbook.bIsSpellAvailable[7] = true;
Ritor1
parents:
diff changeset
3938 spellbook.pAirSpellbook.bIsSpellAvailable[8] = true;
Ritor1
parents:
diff changeset
3939 spellbook.pAirSpellbook.bIsSpellAvailable[9] = true;
Ritor1
parents:
diff changeset
3940 spellbook.pAirSpellbook.bIsSpellAvailable[10] = true;
Ritor1
parents:
diff changeset
3941 spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3942 spellbook.pWaterSpellbook.bIsSpellAvailable[1] = true;
Ritor1
parents:
diff changeset
3943 spellbook.pWaterSpellbook.bIsSpellAvailable[2] = true;
Ritor1
parents:
diff changeset
3944 spellbook.pWaterSpellbook.bIsSpellAvailable[3] = true;
Ritor1
parents:
diff changeset
3945 spellbook.pWaterSpellbook.bIsSpellAvailable[4] = true;
Ritor1
parents:
diff changeset
3946 spellbook.pWaterSpellbook.bIsSpellAvailable[5] = true;
Ritor1
parents:
diff changeset
3947 spellbook.pWaterSpellbook.bIsSpellAvailable[6] = true;
Ritor1
parents:
diff changeset
3948 spellbook.pWaterSpellbook.bIsSpellAvailable[7] = true;
Ritor1
parents:
diff changeset
3949 spellbook.pWaterSpellbook.bIsSpellAvailable[8] = true;
Ritor1
parents:
diff changeset
3950 spellbook.pWaterSpellbook.bIsSpellAvailable[9] = true;
Ritor1
parents:
diff changeset
3951 spellbook.pWaterSpellbook.bIsSpellAvailable[10] = true;
Ritor1
parents:
diff changeset
3952 spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3953 spellbook.pEarthSpellbook.bIsSpellAvailable[1] = true;
Ritor1
parents:
diff changeset
3954 spellbook.pEarthSpellbook.bIsSpellAvailable[2] = true;
Ritor1
parents:
diff changeset
3955 spellbook.pEarthSpellbook.bIsSpellAvailable[3] = true;
Ritor1
parents:
diff changeset
3956 spellbook.pEarthSpellbook.bIsSpellAvailable[4] = true;
Ritor1
parents:
diff changeset
3957 spellbook.pEarthSpellbook.bIsSpellAvailable[5] = true;
Ritor1
parents:
diff changeset
3958 spellbook.pEarthSpellbook.bIsSpellAvailable[6] = true;
Ritor1
parents:
diff changeset
3959 spellbook.pEarthSpellbook.bIsSpellAvailable[7] = true;
Ritor1
parents:
diff changeset
3960 spellbook.pEarthSpellbook.bIsSpellAvailable[8] = true;
Ritor1
parents:
diff changeset
3961 spellbook.pEarthSpellbook.bIsSpellAvailable[9] = true;
Ritor1
parents:
diff changeset
3962 spellbook.pEarthSpellbook.bIsSpellAvailable[10] = true;
Ritor1
parents:
diff changeset
3963 }
Ritor1
parents:
diff changeset
3964 break;
Ritor1
parents:
diff changeset
3965 case PLAYER_SKILL_AIR:
Ritor1
parents:
diff changeset
3966 spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3967 break;
Ritor1
parents:
diff changeset
3968 case PLAYER_SKILL_WATER:
Ritor1
parents:
diff changeset
3969 spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3970 break;
Ritor1
parents:
diff changeset
3971 case PLAYER_SKILL_EARTH:
Ritor1
parents:
diff changeset
3972 spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3973 break;
Ritor1
parents:
diff changeset
3974 case PLAYER_SKILL_SPIRIT:
Ritor1
parents:
diff changeset
3975 spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3976 break;
Ritor1
parents:
diff changeset
3977 case PLAYER_SKILL_MIND:
Ritor1
parents:
diff changeset
3978 spellbook.pMindSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3979 break;
Ritor1
parents:
diff changeset
3980 case PLAYER_SKILL_BODY:
Ritor1
parents:
diff changeset
3981 spellbook.pBodySpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3982
Ritor1
parents:
diff changeset
3983 if ( all_magic == true )
Ritor1
parents:
diff changeset
3984 {
Ritor1
parents:
diff changeset
3985 pActiveSkills[PLAYER_SKILL_MIND] = 1;
Ritor1
parents:
diff changeset
3986 pActiveSkills[PLAYER_SKILL_SPIRIT] = 1;
Ritor1
parents:
diff changeset
3987 spellbook.pBodySpellbook.bIsSpellAvailable[1] = true;
Ritor1
parents:
diff changeset
3988 spellbook.pBodySpellbook.bIsSpellAvailable[2] = true;
Ritor1
parents:
diff changeset
3989 spellbook.pBodySpellbook.bIsSpellAvailable[3] = true;
Ritor1
parents:
diff changeset
3990 spellbook.pBodySpellbook.bIsSpellAvailable[4] = true;
Ritor1
parents:
diff changeset
3991 spellbook.pBodySpellbook.bIsSpellAvailable[5] = true;
Ritor1
parents:
diff changeset
3992 spellbook.pBodySpellbook.bIsSpellAvailable[6] = true;
Ritor1
parents:
diff changeset
3993 spellbook.pBodySpellbook.bIsSpellAvailable[7] = true;
Ritor1
parents:
diff changeset
3994 spellbook.pBodySpellbook.bIsSpellAvailable[8] = true;
Ritor1
parents:
diff changeset
3995 spellbook.pBodySpellbook.bIsSpellAvailable[9] = true;
Ritor1
parents:
diff changeset
3996 spellbook.pBodySpellbook.bIsSpellAvailable[10] = true;
Ritor1
parents:
diff changeset
3997 spellbook.pMindSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
3998 spellbook.pMindSpellbook.bIsSpellAvailable[1] = true;
Ritor1
parents:
diff changeset
3999 spellbook.pMindSpellbook.bIsSpellAvailable[2] = true;
Ritor1
parents:
diff changeset
4000 spellbook.pMindSpellbook.bIsSpellAvailable[3] = true;
Ritor1
parents:
diff changeset
4001 spellbook.pMindSpellbook.bIsSpellAvailable[4] = true;
Ritor1
parents:
diff changeset
4002 spellbook.pMindSpellbook.bIsSpellAvailable[5] = true;
Ritor1
parents:
diff changeset
4003 spellbook.pMindSpellbook.bIsSpellAvailable[6] = true;
Ritor1
parents:
diff changeset
4004 spellbook.pMindSpellbook.bIsSpellAvailable[7] = true;
Ritor1
parents:
diff changeset
4005 spellbook.pMindSpellbook.bIsSpellAvailable[8] = true;
Ritor1
parents:
diff changeset
4006 spellbook.pMindSpellbook.bIsSpellAvailable[9] = true;
Ritor1
parents:
diff changeset
4007 spellbook.pMindSpellbook.bIsSpellAvailable[10] = true;
Ritor1
parents:
diff changeset
4008 spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
4009 spellbook.pSpiritSpellbook.bIsSpellAvailable[1] = true;
Ritor1
parents:
diff changeset
4010 spellbook.pSpiritSpellbook.bIsSpellAvailable[2] = true;
Ritor1
parents:
diff changeset
4011 spellbook.pSpiritSpellbook.bIsSpellAvailable[3] = true;
Ritor1
parents:
diff changeset
4012 spellbook.pSpiritSpellbook.bIsSpellAvailable[4] = true;
Ritor1
parents:
diff changeset
4013 spellbook.pSpiritSpellbook.bIsSpellAvailable[5] = true;
Ritor1
parents:
diff changeset
4014 spellbook.pSpiritSpellbook.bIsSpellAvailable[6] = true;
Ritor1
parents:
diff changeset
4015 spellbook.pSpiritSpellbook.bIsSpellAvailable[7] = true;
Ritor1
parents:
diff changeset
4016 spellbook.pSpiritSpellbook.bIsSpellAvailable[8] = true;
Ritor1
parents:
diff changeset
4017 spellbook.pSpiritSpellbook.bIsSpellAvailable[9] = true;
Ritor1
parents:
diff changeset
4018 spellbook.pSpiritSpellbook.bIsSpellAvailable[10] = true;
Ritor1
parents:
diff changeset
4019 }
Ritor1
parents:
diff changeset
4020 break;
Ritor1
parents:
diff changeset
4021 case PLAYER_SKILL_LIGHT:
Ritor1
parents:
diff changeset
4022 spellbook.pLightSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
4023 break;
Ritor1
parents:
diff changeset
4024 case PLAYER_SKILL_DARK:
Ritor1
parents:
diff changeset
4025 spellbook.pDarkSpellbook.bIsSpellAvailable[0] = true;
Ritor1
parents:
diff changeset
4026 break;
Ritor1
parents:
diff changeset
4027 }
Ritor1
parents:
diff changeset
4028 }
Ritor1
parents:
diff changeset
4029
Ritor1
parents:
diff changeset
4030 memset(&pEquipment, 0, sizeof(PlayerEquipment));
Ritor1
parents:
diff changeset
4031 pInventoryMatrix.fill(0);
Ritor1
parents:
diff changeset
4032 for (uint i = 0; i < 126; ++i)
Ritor1
parents:
diff changeset
4033 pInventoryItemList[i].Reset();
Ritor1
parents:
diff changeset
4034 for (uint i = 0; i < 12; ++i)
Ritor1
parents:
diff changeset
4035 pEquippedItems[i].Reset();
Ritor1
parents:
diff changeset
4036
Ritor1
parents:
diff changeset
4037 sHealth = GetMaxHealth();
Ritor1
parents:
diff changeset
4038 sMana = GetMaxMana();
Ritor1
parents:
diff changeset
4039 }
Ritor1
parents:
diff changeset
4040
Ritor1
parents:
diff changeset
4041 //----- (004903C9) --------------------------------------------------------
Ritor1
parents:
diff changeset
4042 PLAYER_SKILL_TYPE Player::GetSkillIdxByOrder(signed int order)
Ritor1
parents:
diff changeset
4043 {
Ritor1
parents:
diff changeset
4044 int counter; // edx@5
Ritor1
parents:
diff changeset
4045 bool canBeInactive;
Ritor1
parents:
diff changeset
4046 unsigned char requiredValue;
Ritor1
parents:
diff changeset
4047 signed int offset;
Ritor1
parents:
diff changeset
4048
Ritor1
parents:
diff changeset
4049 if ( order <= 1 )
Ritor1
parents:
diff changeset
4050 {
Ritor1
parents:
diff changeset
4051 canBeInactive = false;
Ritor1
parents:
diff changeset
4052 requiredValue = 2; // 2 - primary skill
Ritor1
parents:
diff changeset
4053 offset = 0;
Ritor1
parents:
diff changeset
4054 }
Ritor1
parents:
diff changeset
4055 else if ( order <= 3 )
Ritor1
parents:
diff changeset
4056 {
Ritor1
parents:
diff changeset
4057 canBeInactive = false;
Ritor1
parents:
diff changeset
4058 requiredValue = 1; // 1 - available
Ritor1
parents:
diff changeset
4059 offset = 2;
Ritor1
parents:
diff changeset
4060 }
Ritor1
parents:
diff changeset
4061 else if ( order <= 12 )
Ritor1
parents:
diff changeset
4062 {
Ritor1
parents:
diff changeset
4063 canBeInactive = true;
Ritor1
parents:
diff changeset
4064 requiredValue = 1; // 1 - available
Ritor1
parents:
diff changeset
4065 offset = 4;
Ritor1
parents:
diff changeset
4066 }
Ritor1
parents:
diff changeset
4067 else
Ritor1
parents:
diff changeset
4068 {
Ritor1
parents:
diff changeset
4069 return (PLAYER_SKILL_TYPE)37;
Ritor1
parents:
diff changeset
4070 }
Ritor1
parents:
diff changeset
4071 counter = 0;
Ritor1
parents:
diff changeset
4072 for (int i = 0; i < 37; i++)
Ritor1
parents:
diff changeset
4073 {
Ritor1
parents:
diff changeset
4074 if ( (this->pActiveSkills[i] || canBeInactive) && pSkillAvailabilityPerClass[classType / 4][i] == requiredValue )
Ritor1
parents:
diff changeset
4075 {
Ritor1
parents:
diff changeset
4076 if ( counter == order - offset )
Ritor1
parents:
diff changeset
4077 return (PLAYER_SKILL_TYPE)i;
Ritor1
parents:
diff changeset
4078 ++counter;
Ritor1
parents:
diff changeset
4079 }
Ritor1
parents:
diff changeset
4080 }
Ritor1
parents:
diff changeset
4081
Ritor1
parents:
diff changeset
4082 return (PLAYER_SKILL_TYPE)37;
Ritor1
parents:
diff changeset
4083 }
Ritor1
parents:
diff changeset
4084
Ritor1
parents:
diff changeset
4085
Ritor1
parents:
diff changeset
4086
Ritor1
parents:
diff changeset
4087 //----- (0049048D) --------------------------------------------------------
Ritor1
parents:
diff changeset
4088 //unsigned __int16 PartyCreation_BtnMinusClick(Player *_this, int eAttribute)
Ritor1
parents:
diff changeset
4089 void Player::DecreaseAttribute(int eAttribute)
Ritor1
parents:
diff changeset
4090 {
Ritor1
parents:
diff changeset
4091 int pBaseValue; // ecx@1
Ritor1
parents:
diff changeset
4092 int pDroppedStep; // ebx@1
Ritor1
parents:
diff changeset
4093 int pStep; // esi@1
Ritor1
parents:
diff changeset
4094 int uMinValue; // [sp+Ch] [bp-4h]@1
Ritor1
parents:
diff changeset
4095
Ritor1
parents:
diff changeset
4096 int raceId = GetRace();
Ritor1
parents:
diff changeset
4097 pBaseValue = StatTable[raceId][eAttribute].uBaseValue;
Ritor1
parents:
diff changeset
4098 pDroppedStep = StatTable[raceId][eAttribute].uDroppedStep;
Ritor1
parents:
diff changeset
4099 uMinValue = pBaseValue - 2;
Ritor1
parents:
diff changeset
4100 pStep = StatTable[raceId][eAttribute].uBaseStep;
Ritor1
parents:
diff changeset
4101 unsigned short* AttrToChange = nullptr;
Ritor1
parents:
diff changeset
4102 switch ( eAttribute )
Ritor1
parents:
diff changeset
4103 {
Ritor1
parents:
diff changeset
4104 case CHARACTER_ATTRIBUTE_STRENGTH:
Ritor1
parents:
diff changeset
4105 AttrToChange = &this->uMight;
Ritor1
parents:
diff changeset
4106 break;
Ritor1
parents:
diff changeset
4107 case CHARACTER_ATTRIBUTE_INTELLIGENCE:
Ritor1
parents:
diff changeset
4108 AttrToChange = &this->uIntelligence;
Ritor1
parents:
diff changeset
4109 break;
Ritor1
parents:
diff changeset
4110 case CHARACTER_ATTRIBUTE_WILLPOWER:
Ritor1
parents:
diff changeset
4111 AttrToChange = &this->uWillpower;
Ritor1
parents:
diff changeset
4112 break;
Ritor1
parents:
diff changeset
4113 case CHARACTER_ATTRIBUTE_ENDURANCE:
Ritor1
parents:
diff changeset
4114 AttrToChange = &this->uEndurance;
Ritor1
parents:
diff changeset
4115 break;
Ritor1
parents:
diff changeset
4116 case CHARACTER_ATTRIBUTE_ACCURACY:
Ritor1
parents:
diff changeset
4117 AttrToChange = &this->uAccuracy;
Ritor1
parents:
diff changeset
4118 break;
Ritor1
parents:
diff changeset
4119 case CHARACTER_ATTRIBUTE_SPEED:
Ritor1
parents:
diff changeset
4120 AttrToChange = &this->uSpeed;
Ritor1
parents:
diff changeset
4121 break;
Ritor1
parents:
diff changeset
4122 case CHARACTER_ATTRIBUTE_LUCK:
Ritor1
parents:
diff changeset
4123 AttrToChange = &this->uLuck;
Ritor1
parents:
diff changeset
4124 break;
Ritor1
parents:
diff changeset
4125 }
Ritor1
parents:
diff changeset
4126 if ( *AttrToChange <= pBaseValue )
Ritor1
parents:
diff changeset
4127 pStep = pDroppedStep;
Ritor1
parents:
diff changeset
4128 if ( *AttrToChange - pStep >= uMinValue )
Ritor1
parents:
diff changeset
4129 *AttrToChange -= pStep;
Ritor1
parents:
diff changeset
4130 }
Ritor1
parents:
diff changeset
4131
Ritor1
parents:
diff changeset
4132 //----- (004905F5) --------------------------------------------------------
Ritor1
parents:
diff changeset
4133 //signed int PartyCreation_BtnPlusClick(Player *this, int eAttribute)
Ritor1
parents:
diff changeset
4134 void Player::IncreaseAttribute( int eAttribute )
Ritor1
parents:
diff changeset
4135 {
Ritor1
parents:
diff changeset
4136 int raceId; // eax@1
Ritor1
parents:
diff changeset
4137 int maxValue; // ebx@1
Ritor1
parents:
diff changeset
4138 signed int baseStep; // edi@1
Ritor1
parents:
diff changeset
4139 signed int tmp; // eax@17
Ritor1
parents:
diff changeset
4140 signed int result; // eax@18
Ritor1
parents:
diff changeset
4141 int baseValue; // [sp+Ch] [bp-8h]@1
Ritor1
parents:
diff changeset
4142 signed int droppedStep; // [sp+10h] [bp-4h]@1
Ritor1
parents:
diff changeset
4143 unsigned short* statToChange;
Ritor1
parents:
diff changeset
4144
Ritor1
parents:
diff changeset
4145 raceId = GetRace();
Ritor1
parents:
diff changeset
4146 maxValue = StatTable[raceId][eAttribute].uMaxValue;
Ritor1
parents:
diff changeset
4147 baseStep = StatTable[raceId][eAttribute].uBaseStep;
Ritor1
parents:
diff changeset
4148 baseValue = StatTable[raceId][eAttribute].uBaseValue;
Ritor1
parents:
diff changeset
4149 droppedStep = StatTable[raceId][eAttribute].uDroppedStep;
Ritor1
parents:
diff changeset
4150 PlayerCreation_GetUnspentAttributePointCount();
Ritor1
parents:
diff changeset
4151 switch ( eAttribute )
Ritor1
parents:
diff changeset
4152 {
Ritor1
parents:
diff changeset
4153 case 0:
Ritor1
parents:
diff changeset
4154 statToChange = &this->uMight;
Ritor1
parents:
diff changeset
4155 break;
Ritor1
parents:
diff changeset
4156 case 1:
Ritor1
parents:
diff changeset
4157 statToChange = &this->uIntelligence;
Ritor1
parents:
diff changeset
4158 break;
Ritor1
parents:
diff changeset
4159 case 2:
Ritor1
parents:
diff changeset
4160 statToChange = &this->uWillpower;
Ritor1
parents:
diff changeset
4161 break;
Ritor1
parents:
diff changeset
4162 case 3:
Ritor1
parents:
diff changeset
4163 statToChange = &this->uEndurance;
Ritor1
parents:
diff changeset
4164 break;
Ritor1
parents:
diff changeset
4165 case 4:
Ritor1
parents:
diff changeset
4166 statToChange = &this->uAccuracy;
Ritor1
parents:
diff changeset
4167 break;
Ritor1
parents:
diff changeset
4168 case 5:
Ritor1
parents:
diff changeset
4169 statToChange = &this->uSpeed;
Ritor1
parents:
diff changeset
4170 break;
Ritor1
parents:
diff changeset
4171 case 6:
Ritor1
parents:
diff changeset
4172 statToChange = &this->uLuck;
Ritor1
parents:
diff changeset
4173 break;
Ritor1
parents:
diff changeset
4174 default:
Ritor1
parents:
diff changeset
4175 Error("(%u)", eAttribute);
Ritor1
parents:
diff changeset
4176 break;
Ritor1
parents:
diff changeset
4177 }
Ritor1
parents:
diff changeset
4178 if ( *statToChange < baseValue )
Ritor1
parents:
diff changeset
4179 {
Ritor1
parents:
diff changeset
4180 tmp = baseStep;
Ritor1
parents:
diff changeset
4181 baseStep = droppedStep;
Ritor1
parents:
diff changeset
4182 droppedStep = tmp;
Ritor1
parents:
diff changeset
4183 }
Ritor1
parents:
diff changeset
4184 result = PlayerCreation_GetUnspentAttributePointCount();
Ritor1
parents:
diff changeset
4185 if ( result >= droppedStep )
Ritor1
parents:
diff changeset
4186 {
Ritor1
parents:
diff changeset
4187 if ( baseStep + *statToChange <= maxValue )
Ritor1
parents:
diff changeset
4188 *statToChange += baseStep;
Ritor1
parents:
diff changeset
4189 }
Ritor1
parents:
diff changeset
4190 }
Ritor1
parents:
diff changeset
4191
Ritor1
parents:
diff changeset
4192 //----- (0049070F) --------------------------------------------------------
Ritor1
parents:
diff changeset
4193 void Player::Zero()
Ritor1
parents:
diff changeset
4194 {
Ritor1
parents:
diff changeset
4195 this->sLevelModifier = 0;
Ritor1
parents:
diff changeset
4196 this->sACModifier = 0;
Ritor1
parents:
diff changeset
4197 this->uLuckBonus = 0;
Ritor1
parents:
diff changeset
4198 this->uAccuracyBonus = 0;
Ritor1
parents:
diff changeset
4199 this->uSpeedBonus = 0;
Ritor1
parents:
diff changeset
4200 this->uEnduranceBonus = 0;
Ritor1
parents:
diff changeset
4201 this->uWillpowerBonus = 0;
Ritor1
parents:
diff changeset
4202 this->uIntelligenceBonus = 0;
Ritor1
parents:
diff changeset
4203 this->uMightBonus = 0;
Ritor1
parents:
diff changeset
4204 this->field_100 = 0;
Ritor1
parents:
diff changeset
4205 this->field_FC = 0;
Ritor1
parents:
diff changeset
4206 this->field_F8 = 0;
Ritor1
parents:
diff changeset
4207 this->field_F4 = 0;
Ritor1
parents:
diff changeset
4208 this->field_F0 = 0;
Ritor1
parents:
diff changeset
4209 this->field_EC = 0;
Ritor1
parents:
diff changeset
4210 this->field_E8 = 0;
Ritor1
parents:
diff changeset
4211 this->field_E4 = 0;
Ritor1
parents:
diff changeset
4212 this->field_E0 = 0;
Ritor1
parents:
diff changeset
4213 memset(&this->sResFireBonus, 0, 0x16u);
Ritor1
parents:
diff changeset
4214 this->field_1A97 = 0;
Ritor1
parents:
diff changeset
4215 this->_ranged_dmg_bonus = 0;
Ritor1
parents:
diff changeset
4216 this->field_1A95 = 0;
Ritor1
parents:
diff changeset
4217 this->_ranged_atk_bonus = 0;
Ritor1
parents:
diff changeset
4218 this->field_1A93 = 0;
Ritor1
parents:
diff changeset
4219 this->_melee_dmg_bonus = 0;
Ritor1
parents:
diff changeset
4220 this->field_1A91 = 0;
Ritor1
parents:
diff changeset
4221 this->_some_attack_bonus = 0;
Ritor1
parents:
diff changeset
4222 this->_mana_related = 0;
Ritor1
parents:
diff changeset
4223 this->uFullManaBonus = 0;
Ritor1
parents:
diff changeset
4224 this->_health_related = 0;
Ritor1
parents:
diff changeset
4225 this->uFullHealthBonus = 0;
Ritor1
parents:
diff changeset
4226 }
Ritor1
parents:
diff changeset
4227
Ritor1
parents:
diff changeset
4228 //----- (004907E7) --------------------------------------------------------
Ritor1
parents:
diff changeset
4229 unsigned int Player::GetStatColor(int uStat)
Ritor1
parents:
diff changeset
4230 {
Ritor1
parents:
diff changeset
4231 int attribute_value; // edx@1
Ritor1
parents:
diff changeset
4232
Ritor1
parents:
diff changeset
4233 int base_attribute_value = StatTable[GetRace()][uStat].uBaseValue;
Ritor1
parents:
diff changeset
4234 switch (uStat)
Ritor1
parents:
diff changeset
4235 {
Ritor1
parents:
diff changeset
4236 case 0: attribute_value = uMight; break;
Ritor1
parents:
diff changeset
4237 case 1: attribute_value = uIntelligence; break;
Ritor1
parents:
diff changeset
4238 case 2: attribute_value = uWillpower; break;
Ritor1
parents:
diff changeset
4239 case 3: attribute_value = uEndurance; break;
Ritor1
parents:
diff changeset
4240 case 4: attribute_value = uAccuracy; break;
Ritor1
parents:
diff changeset
4241 case 5: attribute_value = uSpeed; break;
Ritor1
parents:
diff changeset
4242 case 6: attribute_value = uLuck; break;
Ritor1
parents:
diff changeset
4243 default: Error("Unexpected attribute");
Ritor1
parents:
diff changeset
4244 };
Ritor1
parents:
diff changeset
4245
Ritor1
parents:
diff changeset
4246 if (attribute_value == base_attribute_value)
Ritor1
parents:
diff changeset
4247 return ui_character_stat_default_color;
Ritor1
parents:
diff changeset
4248 else if (attribute_value > base_attribute_value)
Ritor1
parents:
diff changeset
4249 return ui_character_stat_buffed_color;
Ritor1
parents:
diff changeset
4250 else
Ritor1
parents:
diff changeset
4251 return ui_character_stat_debuffed_color;
Ritor1
parents:
diff changeset
4252 }
Ritor1
parents:
diff changeset
4253
Ritor1
parents:
diff changeset
4254 //----- (004908A8) --------------------------------------------------------
Ritor1
parents:
diff changeset
4255 bool Player::DiscardConditionIfLastsLongerThan(unsigned int uCondition, signed __int64 uTime)
Ritor1
parents:
diff changeset
4256 {
Ritor1
parents:
diff changeset
4257 if ( pConditions[uCondition] && (uTime < (signed long long)pConditions[uCondition]) )
Ritor1
parents:
diff changeset
4258 {
Ritor1
parents:
diff changeset
4259 pConditions[uCondition] = 0i64;
Ritor1
parents:
diff changeset
4260 return true;
Ritor1
parents:
diff changeset
4261 }
Ritor1
parents:
diff changeset
4262 else
Ritor1
parents:
diff changeset
4263 return false;
Ritor1
parents:
diff changeset
4264 }
Ritor1
parents:
diff changeset
4265
Ritor1
parents:
diff changeset
4266 //----- (004680ED) --------------------------------------------------------
Ritor1
parents:
diff changeset
4267 void Player::UseItem_DrinkPotion_etc(signed int player_num, int a3)
Ritor1
parents:
diff changeset
4268 {
Ritor1
parents:
diff changeset
4269 Player *playerAffected; // esi@1
Ritor1
parents:
diff changeset
4270 signed int v5; // eax@17
Ritor1
parents:
diff changeset
4271 int v8; // edx@39
Ritor1
parents:
diff changeset
4272 const char *v13; // eax@45
Ritor1
parents:
diff changeset
4273 signed int v15; // edi@68
Ritor1
parents:
diff changeset
4274 int v16; // edx@73
Ritor1
parents:
diff changeset
4275 unsigned __int16 v17; // edi@73
Ritor1
parents:
diff changeset
4276 unsigned int v18; // eax@73
Ritor1
parents:
diff changeset
4277 const char *v22; // eax@84
Ritor1
parents:
diff changeset
4278 int scroll_id; // esi@96
Ritor1
parents:
diff changeset
4279 int v25; // eax@109
Ritor1
parents:
diff changeset
4280 int v26; // eax@113
Ritor1
parents:
diff changeset
4281 int new_mana_val; // edi@114
Ritor1
parents:
diff changeset
4282 signed __int64 v28; // qax@120
Ritor1
parents:
diff changeset
4283 __int64 v30; // edi@137
Ritor1
parents:
diff changeset
4284 __int64 v32; // ST3C_4@137
Ritor1
parents:
diff changeset
4285 __int64 v34; // ST34_4@137
Ritor1
parents:
diff changeset
4286 unsigned __int16 v50; // [sp-Ch] [bp-38h]@120
Ritor1
parents:
diff changeset
4287 const char *v66; // [sp-4h] [bp-30h]@69
Ritor1
parents:
diff changeset
4288 signed int v67; // [sp-4h] [bp-30h]@77
Ritor1
parents:
diff changeset
4289 const char *v68; // [sp-4h] [bp-30h]@89
Ritor1
parents:
diff changeset
4290 char v72; // [sp+20h] [bp-Ch]@68
Ritor1
parents:
diff changeset
4291 signed int v73; // [sp+24h] [bp-8h]@1
Ritor1
parents:
diff changeset
4292 const char* v74; // [sp+24h] [bp-8h]@23
Ritor1
parents:
diff changeset
4293 //Player *thisb; // [sp+28h] [bp-4h]@1
Ritor1
parents:
diff changeset
4294 unsigned int thisa; // [sp+28h] [bp-4h]@22
Ritor1
parents:
diff changeset
4295
Ritor1
parents:
diff changeset
4296 //thisb = this;
Ritor1
parents:
diff changeset
4297 playerAffected = &pParty->pPlayers[player_num-1];
Ritor1
parents:
diff changeset
4298 v73 = 1;
Ritor1
parents:
diff changeset
4299 if ( pParty->bTurnBasedModeOn == true && (pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_MOVEMENT) )
Ritor1
parents:
diff changeset
4300 return;
Ritor1
parents:
diff changeset
4301 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_REAGENT )
Ritor1
parents:
diff changeset
4302 {
Ritor1
parents:
diff changeset
4303 if ( pParty->pPickedItem.uItemID == 160 )
Ritor1
parents:
diff changeset
4304 {
Ritor1
parents:
diff changeset
4305 playerAffected->SetCondition(Condition_Poison_Weak, 1);
Ritor1
parents:
diff changeset
4306 }
Ritor1
parents:
diff changeset
4307 else if ( pParty->pPickedItem.uItemID == 161 )
Ritor1
parents:
diff changeset
4308 {
Ritor1
parents:
diff changeset
4309 new_mana_val = playerAffected->sMana;
Ritor1
parents:
diff changeset
4310 new_mana_val += 2;
Ritor1
parents:
diff changeset
4311 if ( new_mana_val > playerAffected->GetMaxMana() )
Ritor1
parents:
diff changeset
4312 new_mana_val = playerAffected->GetMaxMana();
Ritor1
parents:
diff changeset
4313 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4314 }
Ritor1
parents:
diff changeset
4315 else if ( pParty->pPickedItem.uItemID == 162 )
Ritor1
parents:
diff changeset
4316 {
Ritor1
parents:
diff changeset
4317 playerAffected->Heal(2);
Ritor1
parents:
diff changeset
4318 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4319 }
Ritor1
parents:
diff changeset
4320 else
Ritor1
parents:
diff changeset
4321 {
Ritor1
parents:
diff changeset
4322 v68 = pParty->pPickedItem.GetDisplayName();
Ritor1
parents:
diff changeset
4323 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way"
Ritor1
parents:
diff changeset
4324 ShowStatusBarString(pTmpBuf.data(), 2);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4325 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4326 return;
Ritor1
parents:
diff changeset
4327 }
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4328 pAudioPlayer->PlaySound(SOUND_EatApple, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4329
Ritor1
parents:
diff changeset
4330 if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
Ritor1
parents:
diff changeset
4331 {
Ritor1
parents:
diff changeset
4332 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
Ritor1
parents:
diff changeset
4333 }
Ritor1
parents:
diff changeset
4334 if ( v73 )
Ritor1
parents:
diff changeset
4335 {
Ritor1
parents:
diff changeset
4336 if ( pParty->bTurnBasedModeOn )
Ritor1
parents:
diff changeset
4337 {
Ritor1
parents:
diff changeset
4338 pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
Ritor1
parents:
diff changeset
4339 this->SetRecoveryTime(100);
Ritor1
parents:
diff changeset
4340 pTurnEngine->ApplyPlayerAction();
Ritor1
parents:
diff changeset
4341 }
Ritor1
parents:
diff changeset
4342 else
Ritor1
parents:
diff changeset
4343 {
Ritor1
parents:
diff changeset
4344 this->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
Ritor1
parents:
diff changeset
4345 }
Ritor1
parents:
diff changeset
4346 }
Ritor1
parents:
diff changeset
4347 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
4348 return;
Ritor1
parents:
diff changeset
4349 }
Ritor1
parents:
diff changeset
4350
Ritor1
parents:
diff changeset
4351 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_POTION )
Ritor1
parents:
diff changeset
4352 {
Ritor1
parents:
diff changeset
4353 switch ( pParty->pPickedItem.uItemID )
Ritor1
parents:
diff changeset
4354 {
Ritor1
parents:
diff changeset
4355 case 221: //Catalyst
Ritor1
parents:
diff changeset
4356 playerAffected->SetCondition(Condition_Poison_Weak, 1);
Ritor1
parents:
diff changeset
4357 break;
Ritor1
parents:
diff changeset
4358 case 222: //Cure Wounds
Ritor1
parents:
diff changeset
4359 v25 = pParty->pPickedItem.uEnchantmentType + 10;
Ritor1
parents:
diff changeset
4360 playerAffected->Heal(v25);
Ritor1
parents:
diff changeset
4361 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4362 break;
Ritor1
parents:
diff changeset
4363 case 223: //Magic Potion
Ritor1
parents:
diff changeset
4364 v26 = pParty->pPickedItem.uEnchantmentType + 10;
Ritor1
parents:
diff changeset
4365 new_mana_val = playerAffected->sMana;
Ritor1
parents:
diff changeset
4366 new_mana_val += v26;
Ritor1
parents:
diff changeset
4367 if ( new_mana_val > playerAffected->GetMaxMana() )
Ritor1
parents:
diff changeset
4368 new_mana_val = playerAffected->GetMaxMana();
Ritor1
parents:
diff changeset
4369 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4370 playerAffected->sMana = new_mana_val;
Ritor1
parents:
diff changeset
4371 break;
Ritor1
parents:
diff changeset
4372 case 224: //Cure Weakness
Ritor1
parents:
diff changeset
4373 playerAffected->pConditions[Condition_Weak] = 0i64;
Ritor1
parents:
diff changeset
4374 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4375 break;
Ritor1
parents:
diff changeset
4376 case 225: //Cure Disease
Ritor1
parents:
diff changeset
4377 playerAffected->pConditions[Condition_Disease_Severe] = 0i64;
Ritor1
parents:
diff changeset
4378 playerAffected->pConditions[Condition_Disease_Medium] = 0i64;
Ritor1
parents:
diff changeset
4379 playerAffected->pConditions[Condition_Disease_Weak] = 0i64;
Ritor1
parents:
diff changeset
4380 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4381 break;
Ritor1
parents:
diff changeset
4382 case 226: //Cure Poison
Ritor1
parents:
diff changeset
4383 playerAffected->pConditions[Condition_Poison_Severe] = 0i64;
Ritor1
parents:
diff changeset
4384 playerAffected->pConditions[Condition_Poison_Medium] = 0i64;
Ritor1
parents:
diff changeset
4385 playerAffected->pConditions[Condition_Poison_Weak] = 0i64;
Ritor1
parents:
diff changeset
4386 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4387 break;
Ritor1
parents:
diff changeset
4388 case 227: //Awaken
Ritor1
parents:
diff changeset
4389 playerAffected->pConditions[Condition_Sleep] = 0i64;
Ritor1
parents:
diff changeset
4390 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4391 break;
Ritor1
parents:
diff changeset
4392 case 228: //Haste
Ritor1
parents:
diff changeset
4393 if ( !playerAffected->pConditions[Condition_Weak] )
Ritor1
parents:
diff changeset
4394 {
Ritor1
parents:
diff changeset
4395 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4396 playerAffected->pPlayerBuffs[PLAYER_BUFF_HASTE].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
Ritor1
parents:
diff changeset
4397 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4398 }
Ritor1
parents:
diff changeset
4399 break;
Ritor1
parents:
diff changeset
4400 case 229: //Heroism
Ritor1
parents:
diff changeset
4401 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4402 playerAffected->pPlayerBuffs[PLAYER_BUFF_HEROISM].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
Ritor1
parents:
diff changeset
4403 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4404 break;
Ritor1
parents:
diff changeset
4405 case 230: //Bless
Ritor1
parents:
diff changeset
4406 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4407 playerAffected->pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
Ritor1
parents:
diff changeset
4408 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4409 break;
Ritor1
parents:
diff changeset
4410 case 231: //Preservation
Ritor1
parents:
diff changeset
4411 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4412 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4413 playerAffected->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4414 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4415 break;
Ritor1
parents:
diff changeset
4416 case 232: //Shield
Ritor1
parents:
diff changeset
4417 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4418 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4419 playerAffected->pPlayerBuffs[PLAYER_BUFF_SHIELD].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4420 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4421 break;
Ritor1
parents:
diff changeset
4422 case 234: //Stoneskin
Ritor1
parents:
diff changeset
4423 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4424 playerAffected->pPlayerBuffs[PLAYER_BUFF_STONESKIN].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
Ritor1
parents:
diff changeset
4425 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4426 break;
Ritor1
parents:
diff changeset
4427 case 235: //Water Breathing
Ritor1
parents:
diff changeset
4428 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335),
Ritor1
parents:
diff changeset
4429 playerAffected->pPlayerBuffs[PLAYER_BUFF_WATER_WALK].Apply(pParty->uTimePlayed +v28, 3, 5, 0, 0);
Ritor1
parents:
diff changeset
4430 break;
Ritor1
parents:
diff changeset
4431 case 237: //Remove Fear
Ritor1
parents:
diff changeset
4432 playerAffected->pConditions[Condition_Fear] = 0i64;
Ritor1
parents:
diff changeset
4433 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4434 break;
Ritor1
parents:
diff changeset
4435 case 238: //Remove Curse
Ritor1
parents:
diff changeset
4436 playerAffected->pConditions[Condition_Cursed] = 0i64;
Ritor1
parents:
diff changeset
4437 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4438 break;
Ritor1
parents:
diff changeset
4439 case 239: //Cure Insanity
Ritor1
parents:
diff changeset
4440 playerAffected->pConditions[Condition_Insane] = 0i64;
Ritor1
parents:
diff changeset
4441 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4442 break;
Ritor1
parents:
diff changeset
4443 case 240: //Might Boost
Ritor1
parents:
diff changeset
4444 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4445 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4446 playerAffected->pPlayerBuffs[PLAYER_BUFF_STRENGTH].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4447 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4448 break;
Ritor1
parents:
diff changeset
4449 case 241: //Intellect Boost
Ritor1
parents:
diff changeset
4450 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4451 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4452 playerAffected->pPlayerBuffs[PLAYER_BUFF_INTELLIGENCE].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4453 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4454 break;
Ritor1
parents:
diff changeset
4455 case 242: //Personality Boost
Ritor1
parents:
diff changeset
4456 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4457 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4458 playerAffected->pPlayerBuffs[PLAYER_BUFF_WILLPOWER].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4459 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4460 break;
Ritor1
parents:
diff changeset
4461 case 243://Endurance Boost
Ritor1
parents:
diff changeset
4462 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4463 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4464 playerAffected->pPlayerBuffs[PLAYER_BUFF_ENDURANCE].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4465 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4466 break;
Ritor1
parents:
diff changeset
4467 case 244: //Speed Boost
Ritor1
parents:
diff changeset
4468 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4469 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4470 playerAffected->pPlayerBuffs[PLAYER_BUFF_SPEED].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4471 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4472 break;
Ritor1
parents:
diff changeset
4473 case 245: //Accuracy Boost
Ritor1
parents:
diff changeset
4474 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4475 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4476 playerAffected->pPlayerBuffs[PLAYER_BUFF_ACCURACY].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4477 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4478 break;
Ritor1
parents:
diff changeset
4479 case 251: //Cure Paralysis
Ritor1
parents:
diff changeset
4480 playerAffected->pConditions[Condition_Paralyzed] = 0i64;
Ritor1
parents:
diff changeset
4481 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4482 break;
Ritor1
parents:
diff changeset
4483 case 252://Divine Restoration
Ritor1
parents:
diff changeset
4484 v30 = playerAffected->pConditions[Condition_Dead];
Ritor1
parents:
diff changeset
4485 v32 = playerAffected->pConditions[Condition_Pertified];
Ritor1
parents:
diff changeset
4486 v34 = playerAffected->pConditions[Condition_Eradicated];
Ritor1
parents:
diff changeset
4487 pConditions.fill(0);
Ritor1
parents:
diff changeset
4488 playerAffected->pConditions[Condition_Dead] = v30;
Ritor1
parents:
diff changeset
4489 playerAffected->pConditions[Condition_Pertified] = v32;
Ritor1
parents:
diff changeset
4490 playerAffected->pConditions[Condition_Eradicated] = v34;
Ritor1
parents:
diff changeset
4491 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4492 break;
Ritor1
parents:
diff changeset
4493 case 253: //Divine Cure
Ritor1
parents:
diff changeset
4494 v25 = 5 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4495 playerAffected->Heal(v25);
Ritor1
parents:
diff changeset
4496 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4497 break;
Ritor1
parents:
diff changeset
4498 case 254: //Divine Power
Ritor1
parents:
diff changeset
4499 v26 = 5 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4500 new_mana_val = playerAffected->sMana;
Ritor1
parents:
diff changeset
4501 new_mana_val += v26;
Ritor1
parents:
diff changeset
4502 if ( new_mana_val > playerAffected->GetMaxMana() )
Ritor1
parents:
diff changeset
4503 new_mana_val = playerAffected->GetMaxMana();
Ritor1
parents:
diff changeset
4504 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4505 break;
Ritor1
parents:
diff changeset
4506 case 255: //Luck Boost
Ritor1
parents:
diff changeset
4507 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4508 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4509 playerAffected->pPlayerBuffs[PLAYER_BUFF_LUCK].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4510 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4511 break;
Ritor1
parents:
diff changeset
4512 case 256: //Fire Resistance
Ritor1
parents:
diff changeset
4513 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4514 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4515 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_FIRE].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4516 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4517 break;
Ritor1
parents:
diff changeset
4518 case 257: //Air Resistance
Ritor1
parents:
diff changeset
4519 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4520 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4521 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_AIR].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4522 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4523 break;
Ritor1
parents:
diff changeset
4524 case 258: //Water Resistance
Ritor1
parents:
diff changeset
4525 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4526 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4527 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_WATER].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4528 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4529 break;
Ritor1
parents:
diff changeset
4530 case 259: //Earth Resistance
Ritor1
parents:
diff changeset
4531 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4532 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4533 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_EARTH].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4534 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4535 break;
Ritor1
parents:
diff changeset
4536 case 260: //Mind Resistance
Ritor1
parents:
diff changeset
4537 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4538 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4539 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_MIND].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4540 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4541 break;
Ritor1
parents:
diff changeset
4542 case 261: //Body Resistance
Ritor1
parents:
diff changeset
4543 v50 = 3 * pParty->pPickedItem.uEnchantmentType;
Ritor1
parents:
diff changeset
4544 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
Ritor1
parents:
diff changeset
4545 playerAffected->pPlayerBuffs[PLAYER_BUFF_RESIST_BODY].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
Ritor1
parents:
diff changeset
4546 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4547 break;
Ritor1
parents:
diff changeset
4548 case 262: //Stone to Flesh
Ritor1
parents:
diff changeset
4549 playerAffected->pConditions[Condition_Pertified] = 0i64;
Ritor1
parents:
diff changeset
4550 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4551 break;
Ritor1
parents:
diff changeset
4552 case 264: //Pure Luck
Ritor1
parents:
diff changeset
4553 if ( !playerAffected->pure_luck_used )
Ritor1
parents:
diff changeset
4554 {
Ritor1
parents:
diff changeset
4555 playerAffected->uLuck += 50;
Ritor1
parents:
diff changeset
4556 playerAffected->pure_luck_used = 1;
Ritor1
parents:
diff changeset
4557 }
Ritor1
parents:
diff changeset
4558 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4559 break;
Ritor1
parents:
diff changeset
4560 case 265: //Pure Speed
Ritor1
parents:
diff changeset
4561 if ( !playerAffected->pure_speed_used )
Ritor1
parents:
diff changeset
4562 {
Ritor1
parents:
diff changeset
4563 playerAffected->uSpeed += 50;
Ritor1
parents:
diff changeset
4564 playerAffected->pure_speed_used = 1;
Ritor1
parents:
diff changeset
4565 }
Ritor1
parents:
diff changeset
4566 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4567 break;
Ritor1
parents:
diff changeset
4568 case 266: //Pure Intellect
Ritor1
parents:
diff changeset
4569 if ( !playerAffected->pure_intellect_used )
Ritor1
parents:
diff changeset
4570 {
Ritor1
parents:
diff changeset
4571 playerAffected->uIntelligence += 50;
Ritor1
parents:
diff changeset
4572 playerAffected->pure_intellect_used = 1;
Ritor1
parents:
diff changeset
4573 }
Ritor1
parents:
diff changeset
4574 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4575 break;
Ritor1
parents:
diff changeset
4576 case 267: //Pure Endurance
Ritor1
parents:
diff changeset
4577 if ( !playerAffected->pure_endurance_used )
Ritor1
parents:
diff changeset
4578 {
Ritor1
parents:
diff changeset
4579 playerAffected->uEndurance += 50;
Ritor1
parents:
diff changeset
4580 playerAffected->pure_endurance_used = 1;
Ritor1
parents:
diff changeset
4581 }
Ritor1
parents:
diff changeset
4582 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4583 break;
Ritor1
parents:
diff changeset
4584 case 268: //Pure Personality
Ritor1
parents:
diff changeset
4585 if ( !playerAffected->pure_willpower_used )
Ritor1
parents:
diff changeset
4586 {
Ritor1
parents:
diff changeset
4587 playerAffected->uWillpower += 50;
Ritor1
parents:
diff changeset
4588 playerAffected->pure_willpower_used = 1;
Ritor1
parents:
diff changeset
4589 }
Ritor1
parents:
diff changeset
4590 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4591 break;
Ritor1
parents:
diff changeset
4592 case 269: //Pure Accuracy
Ritor1
parents:
diff changeset
4593 if ( !playerAffected->pure_accuracy_used )
Ritor1
parents:
diff changeset
4594 {
Ritor1
parents:
diff changeset
4595 playerAffected->uAccuracy += 50;
Ritor1
parents:
diff changeset
4596 playerAffected->pure_accuracy_used = 1;
Ritor1
parents:
diff changeset
4597 }
Ritor1
parents:
diff changeset
4598 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4599 break;
Ritor1
parents:
diff changeset
4600 case 270: //Pure Might
Ritor1
parents:
diff changeset
4601 if ( !playerAffected->pure_might_used )
Ritor1
parents:
diff changeset
4602 {
Ritor1
parents:
diff changeset
4603 playerAffected->uMight += 50;
Ritor1
parents:
diff changeset
4604 playerAffected->pure_might_used = 1;
Ritor1
parents:
diff changeset
4605 }
Ritor1
parents:
diff changeset
4606 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4607 break;
Ritor1
parents:
diff changeset
4608 case 271: //Rejuvenation
Ritor1
parents:
diff changeset
4609 playerAffected->sAgeModifier = 0;
Ritor1
parents:
diff changeset
4610 playerAffected->PlaySound(SPEECH_36, 0);
Ritor1
parents:
diff changeset
4611 break;
Ritor1
parents:
diff changeset
4612
Ritor1
parents:
diff changeset
4613 default:
Ritor1
parents:
diff changeset
4614 v68 = pParty->pPickedItem.GetDisplayName();
Ritor1
parents:
diff changeset
4615 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way"
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4616 ShowStatusBarString(pTmpBuf.data(), 2);
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4617 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4618 return;
Ritor1
parents:
diff changeset
4619 }
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4620 pAudioPlayer->PlaySound(SOUND_210, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4621 if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
Ritor1
parents:
diff changeset
4622 {
Ritor1
parents:
diff changeset
4623 // if ( !v73 ) v73 is always 1 at this point
Ritor1
parents:
diff changeset
4624 // {
Ritor1
parents:
diff changeset
4625 // pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
4626 // return;
Ritor1
parents:
diff changeset
4627 // }
Ritor1
parents:
diff changeset
4628 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
Ritor1
parents:
diff changeset
4629 }
Ritor1
parents:
diff changeset
4630 if ( v73 )
Ritor1
parents:
diff changeset
4631 {
Ritor1
parents:
diff changeset
4632 if ( pParty->bTurnBasedModeOn )
Ritor1
parents:
diff changeset
4633 {
Ritor1
parents:
diff changeset
4634 pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
Ritor1
parents:
diff changeset
4635 this->SetRecoveryTime(100);
Ritor1
parents:
diff changeset
4636 pTurnEngine->ApplyPlayerAction();
Ritor1
parents:
diff changeset
4637 }
Ritor1
parents:
diff changeset
4638 else
Ritor1
parents:
diff changeset
4639 {
Ritor1
parents:
diff changeset
4640 this->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
Ritor1
parents:
diff changeset
4641 }
Ritor1
parents:
diff changeset
4642 }
Ritor1
parents:
diff changeset
4643 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
4644 return;
Ritor1
parents:
diff changeset
4645 }
Ritor1
parents:
diff changeset
4646
Ritor1
parents:
diff changeset
4647
Ritor1
parents:
diff changeset
4648 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_SPELL_SCROLL )
Ritor1
parents:
diff changeset
4649 {
Ritor1
parents:
diff changeset
4650 if ( pCurrentScreen == SCREEN_CASTING )
Ritor1
parents:
diff changeset
4651 return;
Ritor1
parents:
diff changeset
4652 if ( !playerAffected->CanAct() )
Ritor1
parents:
diff changeset
4653 {
Ritor1
parents:
diff changeset
4654
Ritor1
parents:
diff changeset
4655 v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()];
Ritor1
parents:
diff changeset
4656 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4657 ShowStatusBarString(pTmpBuf.data(), 2);
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4658 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4659 return;
Ritor1
parents:
diff changeset
4660 }
Ritor1
parents:
diff changeset
4661 if ( bUnderwater == 1 )
Ritor1
parents:
diff changeset
4662 {
Ritor1
parents:
diff changeset
4663 ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2u);//"You can not do that while you are underwater!"
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4664 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4665 return;
Ritor1
parents:
diff changeset
4666 }
Ritor1
parents:
diff changeset
4667
Ritor1
parents:
diff changeset
4668 scroll_id = pParty->pPickedItem.uItemID - 299;
Ritor1
parents:
diff changeset
4669 if ( scroll_id == 30 || scroll_id == 4 || scroll_id == 91 || scroll_id == 28 ) //Enchant Item scroll, Vampiric Weapon scroll ,Recharge Item ,Fire Aura
Ritor1
parents:
diff changeset
4670 {
Ritor1
parents:
diff changeset
4671 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
4672 pGUIWindow_CurrentMenu->Release();
Ritor1
parents:
diff changeset
4673 pIcons_LOD->RemoveTexturesPackFromTextureList();
Ritor1
parents:
diff changeset
4674 pCurrentScreen = SCREEN_GAME;
Ritor1
parents:
diff changeset
4675 viewparams->bRedrawGameUI = 1;
Ritor1
parents:
diff changeset
4676 _42777D_CastSpell_UseWand_ShootArrow(scroll_id, player_num - 1, 0x85u, 1, 0);
Ritor1
parents:
diff changeset
4677 }
Ritor1
parents:
diff changeset
4678 else
Ritor1
parents:
diff changeset
4679 {
Ritor1
parents:
diff changeset
4680 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
4681 pMessageQueue_50C9E8->AddGUIMessage(UIMSG_SpellScrollUse, scroll_id, player_num - 1);
Ritor1
parents:
diff changeset
4682 if ( pCurrentScreen && pGUIWindow_CurrentMenu
Ritor1
parents:
diff changeset
4683 && (pGUIWindow_CurrentMenu->eWindowType != WINDOW_null))
Ritor1
parents:
diff changeset
4684 {
Ritor1
parents:
diff changeset
4685 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
Ritor1
parents:
diff changeset
4686 }
Ritor1
parents:
diff changeset
4687 }
Ritor1
parents:
diff changeset
4688 return;
Ritor1
parents:
diff changeset
4689 }
Ritor1
parents:
diff changeset
4690
Ritor1
parents:
diff changeset
4691 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_BOOK )
Ritor1
parents:
diff changeset
4692 {
Ritor1
parents:
diff changeset
4693 v15 = pParty->pPickedItem.uItemID - 400;
Ritor1
parents:
diff changeset
4694 v72 = playerAffected->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400];//(char *)&v3->pConditions[0] + pParty->pPickedItem.uItemID + 2;
Ritor1
parents:
diff changeset
4695 if ( v72 )
Ritor1
parents:
diff changeset
4696 {
Ritor1
parents:
diff changeset
4697 v66 = pParty->pPickedItem.GetDisplayName();
Ritor1
parents:
diff changeset
4698 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[380], v66);//"You already know the %s spell"
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4699 ShowStatusBarString(pTmpBuf.data(), 2);
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4700 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4701 return;
Ritor1
parents:
diff changeset
4702 }
Ritor1
parents:
diff changeset
4703 if ( !playerAffected->CanAct() )
Ritor1
parents:
diff changeset
4704 {
Ritor1
parents:
diff changeset
4705 v66 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()];
Ritor1
parents:
diff changeset
4706 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v66);//"That player is %s"
Ritor1
parents:
diff changeset
4707 ShowStatusBarString(pTmpBuf.data(), 2);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4708 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4709 return;
Ritor1
parents:
diff changeset
4710 }
Ritor1
parents:
diff changeset
4711 v16 = v15 % 11 + 1;
Ritor1
parents:
diff changeset
4712 v17 = playerAffected->pActiveSkills[v15 / 11 + 12];
Ritor1
parents:
diff changeset
4713 v18 = SkillToMastery(v17) - 1;
Ritor1
parents:
diff changeset
4714 switch (v18)
Ritor1
parents:
diff changeset
4715 {
Ritor1
parents:
diff changeset
4716 case 0: v67 = 4; break;
Ritor1
parents:
diff changeset
4717 case 1: v67 = 7; break;
Ritor1
parents:
diff changeset
4718 case 2: v67 = 10; break;
Ritor1
parents:
diff changeset
4719 case 3: v67 = 11; break;
Ritor1
parents:
diff changeset
4720 default:
Ritor1
parents:
diff changeset
4721 v67 = player_num;
Ritor1
parents:
diff changeset
4722 }
Ritor1
parents:
diff changeset
4723
Ritor1
parents:
diff changeset
4724 if ( v16 > v67 || !v17 )
Ritor1
parents:
diff changeset
4725 {
Ritor1
parents:
diff changeset
4726 v22 = pParty->pPickedItem.GetDisplayName();
Ritor1
parents:
diff changeset
4727 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[381], v22); //"You don't have the skill to learn %s"
Ritor1
parents:
diff changeset
4728 ShowStatusBarString(pTmpBuf.data(), 2);
Ritor1
parents:
diff changeset
4729 playerAffected->PlaySound((PlayerSpeech)20, 0);
Ritor1
parents:
diff changeset
4730 return;
Ritor1
parents:
diff changeset
4731 }
Ritor1
parents:
diff changeset
4732 playerAffected->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400] = 1;
Ritor1
parents:
diff changeset
4733 playerAffected->PlaySound(SPEECH_21, 0);
Ritor1
parents:
diff changeset
4734 v73 = 0;
Ritor1
parents:
diff changeset
4735
Ritor1
parents:
diff changeset
4736
Ritor1
parents:
diff changeset
4737 if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
Ritor1
parents:
diff changeset
4738 {
Ritor1
parents:
diff changeset
4739 if ( !v73 )
Ritor1
parents:
diff changeset
4740 {
Ritor1
parents:
diff changeset
4741 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
4742 return;
Ritor1
parents:
diff changeset
4743 }
Ritor1
parents:
diff changeset
4744 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
Ritor1
parents:
diff changeset
4745 }
Ritor1
parents:
diff changeset
4746 // if ( v73 ) v73 is always 0 at this point
Ritor1
parents:
diff changeset
4747 // {
Ritor1
parents:
diff changeset
4748 // if ( pParty->bTurnBasedModeOn )
Ritor1
parents:
diff changeset
4749 // {
Ritor1
parents:
diff changeset
4750 // pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
Ritor1
parents:
diff changeset
4751 // thisb->SetRecoveryTime(100);
Ritor1
parents:
diff changeset
4752 // pTurnEngine->ApplyPlayerAction();
Ritor1
parents:
diff changeset
4753 // }
Ritor1
parents:
diff changeset
4754 // else
Ritor1
parents:
diff changeset
4755 // {
Ritor1
parents:
diff changeset
4756 // thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333);
Ritor1
parents:
diff changeset
4757 // }
Ritor1
parents:
diff changeset
4758 // }
Ritor1
parents:
diff changeset
4759 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
4760 return;
Ritor1
parents:
diff changeset
4761 }
Ritor1
parents:
diff changeset
4762
Ritor1
parents:
diff changeset
4763 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_MESSAGE_SCROLL )
Ritor1
parents:
diff changeset
4764 {
Ritor1
parents:
diff changeset
4765 if ( playerAffected->CanAct() )
Ritor1
parents:
diff changeset
4766 {
Ritor1
parents:
diff changeset
4767 CreateMsgScrollWindow(pParty->pPickedItem.uItemID);
Ritor1
parents:
diff changeset
4768 playerAffected->PlaySound(SPEECH_37, 0);
Ritor1
parents:
diff changeset
4769 return;
Ritor1
parents:
diff changeset
4770 }
Ritor1
parents:
diff changeset
4771 v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()];
Ritor1
parents:
diff changeset
4772 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68);//That player is %s
Ritor1
parents:
diff changeset
4773 ShowStatusBarString(pTmpBuf.data(), 2);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4774 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4775 return;
Ritor1
parents:
diff changeset
4776 }
Ritor1
parents:
diff changeset
4777 else
Ritor1
parents:
diff changeset
4778 {
Ritor1
parents:
diff changeset
4779 if (pParty->pPickedItem.uItemID == 616) //Genie Lamp
Ritor1
parents:
diff changeset
4780 {
Ritor1
parents:
diff changeset
4781 thisa = pParty->uCurrentMonthWeek + 1;
Ritor1
parents:
diff changeset
4782 if ( pParty->uCurrentMonth >= 7 )
Ritor1
parents:
diff changeset
4783 v74 = nullptr;
Ritor1
parents:
diff changeset
4784 else
Ritor1
parents:
diff changeset
4785 v74 = aAttributeNames[pParty->uCurrentMonth];
Ritor1
parents:
diff changeset
4786 switch ( pParty->uCurrentMonth )
Ritor1
parents:
diff changeset
4787 {
Ritor1
parents:
diff changeset
4788 case 0:
Ritor1
parents:
diff changeset
4789 playerAffected->uMight += thisa;
Ritor1
parents:
diff changeset
4790 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"
Ritor1
parents:
diff changeset
4791 break;
Ritor1
parents:
diff changeset
4792 case 1:
Ritor1
parents:
diff changeset
4793 playerAffected->uIntelligence += thisa;
Ritor1
parents:
diff changeset
4794 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"
Ritor1
parents:
diff changeset
4795 break;
Ritor1
parents:
diff changeset
4796 case 2:
Ritor1
parents:
diff changeset
4797 playerAffected->uWillpower += thisa;
Ritor1
parents:
diff changeset
4798 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"
Ritor1
parents:
diff changeset
4799 break;
Ritor1
parents:
diff changeset
4800 case 3:
Ritor1
parents:
diff changeset
4801 playerAffected->uEndurance += thisa;
Ritor1
parents:
diff changeset
4802 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"
Ritor1
parents:
diff changeset
4803 break;
Ritor1
parents:
diff changeset
4804 case 4:
Ritor1
parents:
diff changeset
4805 playerAffected->uAccuracy += thisa;
Ritor1
parents:
diff changeset
4806 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"
Ritor1
parents:
diff changeset
4807 break;
Ritor1
parents:
diff changeset
4808 case 5:
Ritor1
parents:
diff changeset
4809 playerAffected->uSpeed += thisa;
Ritor1
parents:
diff changeset
4810 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"
Ritor1
parents:
diff changeset
4811 break;
Ritor1
parents:
diff changeset
4812 case 6:
Ritor1
parents:
diff changeset
4813 playerAffected->uLuck += thisa;
Ritor1
parents:
diff changeset
4814 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"
Ritor1
parents:
diff changeset
4815 break;
Ritor1
parents:
diff changeset
4816 case 7:
Ritor1
parents:
diff changeset
4817 pParty->PartyFindsGold(1000 * thisa, 0);
Ritor1
parents:
diff changeset
4818 sprintf(pTmpBuf.data(), "+%u %s", 1000 * thisa, pGlobalTXT_LocalizationStrings[97]);//"Gold"
Ritor1
parents:
diff changeset
4819 break;
Ritor1
parents:
diff changeset
4820 case 8:
Ritor1
parents:
diff changeset
4821 Party::GiveFood(5 * thisa);
Ritor1
parents:
diff changeset
4822 sprintf(pTmpBuf.data(), "+%u %s",5 * thisa , pGlobalTXT_LocalizationStrings[653]);//"Food"
Ritor1
parents:
diff changeset
4823 break;
Ritor1
parents:
diff changeset
4824 case 9u:
Ritor1
parents:
diff changeset
4825 playerAffected->uSkillPoints += 2 * thisa;
Ritor1
parents:
diff changeset
4826 sprintf(pTmpBuf.data(), "+%u %s", 2 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_SKILL_POINTS]);
Ritor1
parents:
diff changeset
4827 break;
Ritor1
parents:
diff changeset
4828 case 10:
Ritor1
parents:
diff changeset
4829 playerAffected->uExperience += 2500 * thisa;
Ritor1
parents:
diff changeset
4830 sprintf(pTmpBuf.data(), "+%u %s", 2500 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_EXPIRIENCE]);
Ritor1
parents:
diff changeset
4831 break;
Ritor1
parents:
diff changeset
4832 case 11:
Ritor1
parents:
diff changeset
4833 v8 = rand() % 6;
Ritor1
parents:
diff changeset
4834 switch (v8)
Ritor1
parents:
diff changeset
4835 {
Ritor1
parents:
diff changeset
4836 case 0:
Ritor1
parents:
diff changeset
4837 playerAffected->sResFireBase += thisa;
Ritor1
parents:
diff changeset
4838 v13 = pGlobalTXT_LocalizationStrings[87];//Fire
Ritor1
parents:
diff changeset
4839 break;
Ritor1
parents:
diff changeset
4840 case 1:
Ritor1
parents:
diff changeset
4841 playerAffected->sResAirBase += thisa;
Ritor1
parents:
diff changeset
4842 v13 = pGlobalTXT_LocalizationStrings[6];//Air
Ritor1
parents:
diff changeset
4843 break;
Ritor1
parents:
diff changeset
4844 case 2:
Ritor1
parents:
diff changeset
4845 playerAffected->sResWaterBase += thisa;
Ritor1
parents:
diff changeset
4846 v13 = pGlobalTXT_LocalizationStrings[240];//Water
Ritor1
parents:
diff changeset
4847 break;
Ritor1
parents:
diff changeset
4848 case 3:
Ritor1
parents:
diff changeset
4849 playerAffected->sResEarthBase += thisa;
Ritor1
parents:
diff changeset
4850 v13 = pGlobalTXT_LocalizationStrings[70];//Earth
Ritor1
parents:
diff changeset
4851 break;
Ritor1
parents:
diff changeset
4852 case 4:
Ritor1
parents:
diff changeset
4853 playerAffected->sResMindBase += thisa;
Ritor1
parents:
diff changeset
4854 v13 = pGlobalTXT_LocalizationStrings[142];//Mind
Ritor1
parents:
diff changeset
4855 break;
Ritor1
parents:
diff changeset
4856 case 5:
Ritor1
parents:
diff changeset
4857 playerAffected->sResBodyBase += thisa;
Ritor1
parents:
diff changeset
4858 v13 = pGlobalTXT_LocalizationStrings[29];//Body
Ritor1
parents:
diff changeset
4859 break;
Ritor1
parents:
diff changeset
4860 default: ("Unexpected attribute");
Ritor1
parents:
diff changeset
4861 return;
Ritor1
parents:
diff changeset
4862 }
Ritor1
parents:
diff changeset
4863 sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]);//Permanent
Ritor1
parents:
diff changeset
4864 break;
Ritor1
parents:
diff changeset
4865
Ritor1
parents:
diff changeset
4866 }
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4867 ShowStatusBarString(pTmpBuf.data(), 2);
2498
Ritor1
parents:
diff changeset
4868 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
4869 pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1);
Ritor1
parents:
diff changeset
4870 playerAffected->PlaySound(SPEECH_93, 0);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4871 pAudioPlayer->PlaySound(SOUND_219, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4872 if ( pParty->uDaysPlayed == 6 || pParty->uDaysPlayed == 20 )
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4873 {
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4874 playerAffected->SetCondition(Condition_Eradicated, 0);
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4875 pAudioPlayer->PlaySound(SOUND_215, 0, 0, -1, 0, 0, 0, 0);
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4876 }
2498
Ritor1
parents:
diff changeset
4877 else if ( pParty->uDaysPlayed == 12 || pParty->uDaysPlayed == 26 )
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4878 {
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4879 playerAffected->SetCondition(Condition_Dead, 0);
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4880 pAudioPlayer->PlaySound(SOUND_215, 0, 0, -1, 0, 0, 0, 0);
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4881 }
2498
Ritor1
parents:
diff changeset
4882 else if ( pParty->uDaysPlayed == 4 || pParty->uDaysPlayed == 25 )
Ritor1
parents:
diff changeset
4883 {
Ritor1
parents:
diff changeset
4884 playerAffected->SetCondition(Condition_Pertified, 0);
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4885 pAudioPlayer->PlaySound(SOUND_215, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4886 }
Ritor1
parents:
diff changeset
4887 return;
Ritor1
parents:
diff changeset
4888 }
Ritor1
parents:
diff changeset
4889 else if ( pParty->pPickedItem.uItemID == 630 ) //Red Apple
Ritor1
parents:
diff changeset
4890 {
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4891 Party::GiveFood(1);
2498
Ritor1
parents:
diff changeset
4892 pAudioPlayer->PlaySound(SOUND_EatApple, 0, 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
4893 }
Ritor1
parents:
diff changeset
4894 else if ( pParty->pPickedItem.uItemID == 632 ) //Lute
Ritor1
parents:
diff changeset
4895 {
Ritor1
parents:
diff changeset
4896 pAudioPlayer->PlaySound(SOUND_PlayLute, 0, 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
4897 return;
Ritor1
parents:
diff changeset
4898 }
Ritor1
parents:
diff changeset
4899 else if ( pParty->pPickedItem.uItemID == 633 ) //Faerie Pipes
Ritor1
parents:
diff changeset
4900 {
Ritor1
parents:
diff changeset
4901 pAudioPlayer->PlaySound(SOUND_PlayFaeriePipes, 0, 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
4902 return;
Ritor1
parents:
diff changeset
4903 }
Ritor1
parents:
diff changeset
4904 else if ( pParty->pPickedItem.uItemID == 634 ) //Gryphonheart's Trumpet
Ritor1
parents:
diff changeset
4905 {
Ritor1
parents:
diff changeset
4906 pAudioPlayer->PlaySound(SOUND_PlayGryphonheartsTrumpet, 0, 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
4907 return;
Ritor1
parents:
diff changeset
4908 }
Ritor1
parents:
diff changeset
4909 else if ( pParty->pPickedItem.uItemID == 646 ) //Horseshoe
Ritor1
parents:
diff changeset
4910 {
Ritor1
parents:
diff changeset
4911 pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1);
Ritor1
parents:
diff changeset
4912 v5 = PID(OBJECT_Player, player_num + 49);
Ritor1
parents:
diff changeset
4913 pAudioPlayer->PlaySound(SOUND_20001, v5, 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
4914 playerAffected->AddVariable(VAR_NumSkillPoints, 2);
Ritor1
parents:
diff changeset
4915 }
Ritor1
parents:
diff changeset
4916 else if ( pParty->pPickedItem.uItemID == 650 ) //Temple in a Bottle
Ritor1
parents:
diff changeset
4917 {
Ritor1
parents:
diff changeset
4918 TeleportToNWCDungeon();
Ritor1
parents:
diff changeset
4919 return;
Ritor1
parents:
diff changeset
4920 }
Ritor1
parents:
diff changeset
4921 else
Ritor1
parents:
diff changeset
4922 {
Ritor1
parents:
diff changeset
4923 v68 = pParty->pPickedItem.GetDisplayName();
Ritor1
parents:
diff changeset
4924 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36],v68);//"%s can not be used that way"
2506
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4925 ShowStatusBarString(pTmpBuf.data(), 2);
9b96a51011fb for sound
Ritor1
parents: 2502
diff changeset
4926 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
2498
Ritor1
parents:
diff changeset
4927 return;
Ritor1
parents:
diff changeset
4928 }
Ritor1
parents:
diff changeset
4929
Ritor1
parents:
diff changeset
4930 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
4931 return;
Ritor1
parents:
diff changeset
4932 }
Ritor1
parents:
diff changeset
4933 }
Ritor1
parents:
diff changeset
4934
Ritor1
parents:
diff changeset
4935 bool CmpSkillValue(int valToCompare, int skillValue)
Ritor1
parents:
diff changeset
4936 {
Ritor1
parents:
diff changeset
4937 int v4;
Ritor1
parents:
diff changeset
4938 if ( valToCompare <= 63 )
Ritor1
parents:
diff changeset
4939 v4 = skillValue & 0x3F;
Ritor1
parents:
diff changeset
4940 else
Ritor1
parents:
diff changeset
4941 v4 = skillValue & skillValue;
Ritor1
parents:
diff changeset
4942 return v4 >= valToCompare;
Ritor1
parents:
diff changeset
4943 }
Ritor1
parents:
diff changeset
4944
Ritor1
parents:
diff changeset
4945 //----- (00449BB4) --------------------------------------------------------
Ritor1
parents:
diff changeset
4946 bool Player::CompareVariable( enum VariableType VarNum, signed int pValue ) // in some cases this calls only calls v4 >= pValue, which i've changed to return false, since these values are supposed to be positive and v4 was -1 by default
Ritor1
parents:
diff changeset
4947 {
Ritor1
parents:
diff changeset
4948 Assert(pValue >= 0, "Compare variable shouldn't have negative arguments");
Ritor1
parents:
diff changeset
4949
Ritor1
parents:
diff changeset
4950 signed int v4; // edi@1
Ritor1
parents:
diff changeset
4951 unsigned __int8 test_bit_value; // eax@25
Ritor1
parents:
diff changeset
4952 unsigned __int8 byteWithRequestedBit; // cl@25
Ritor1
parents:
diff changeset
4953 DDM_DLV_Header *v19; // eax@122
Ritor1
parents:
diff changeset
4954 DDM_DLV_Header *v21; // eax@126
Ritor1
parents:
diff changeset
4955 int actStat; // ebx@161
Ritor1
parents:
diff changeset
4956 int baseStat; // eax@161
Ritor1
parents:
diff changeset
4957
Ritor1
parents:
diff changeset
4958
Ritor1
parents:
diff changeset
4959 if ( (signed int)VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_74 )
Ritor1
parents:
diff changeset
4960 return (unsigned __int8)stru_5E4C90_MapPersistVars.field_0[VarNum - VAR_MapPersistentVariable_0] > 0; // originally (unsigned __int8)byte_5E4C15[VarNum];
Ritor1
parents:
diff changeset
4961 if ( (signed int)VarNum >= VAR_MapPersistentVariable_75 && VarNum <= VAR_MapPersistentVariable_99 )
Ritor1
parents:
diff changeset
4962 return (unsigned __int8)stru_5E4C90_MapPersistVars._decor_events[VarNum - VAR_MapPersistentVariable_75] > 0; //not really sure whether the number gets up to 99, but can't ignore the possibility
Ritor1
parents:
diff changeset
4963
Ritor1
parents:
diff changeset
4964 switch ( VarNum )
Ritor1
parents:
diff changeset
4965 {
Ritor1
parents:
diff changeset
4966 case VAR_Sex:
Ritor1
parents:
diff changeset
4967 return ( pValue == this->uSex );
Ritor1
parents:
diff changeset
4968 case VAR_Class:
Ritor1
parents:
diff changeset
4969 return ( pValue == this->classType );
Ritor1
parents:
diff changeset
4970 case VAR_Race:
Ritor1
parents:
diff changeset
4971 return pValue == GetRace();
Ritor1
parents:
diff changeset
4972 case VAR_CurrentHP:
Ritor1
parents:
diff changeset
4973 return this->sHealth >= pValue;
Ritor1
parents:
diff changeset
4974 case VAR_MaxHP:
Ritor1
parents:
diff changeset
4975 return (this->sHealth >= GetMaxHealth());
Ritor1
parents:
diff changeset
4976 case VAR_CurrentSP:
Ritor1
parents:
diff changeset
4977 return this->sMana >= pValue;
Ritor1
parents:
diff changeset
4978 case VAR_MaxSP:
Ritor1
parents:
diff changeset
4979 return (this->sMana >= GetMaxMana());
Ritor1
parents:
diff changeset
4980 case VAR_ActualAC:
Ritor1
parents:
diff changeset
4981 return GetActualAC() >= pValue;
Ritor1
parents:
diff changeset
4982 case VAR_ACModifier:
Ritor1
parents:
diff changeset
4983 return this->sACModifier >= pValue;
Ritor1
parents:
diff changeset
4984 case VAR_BaseLevel:
Ritor1
parents:
diff changeset
4985 return this->uLevel >= pValue;
Ritor1
parents:
diff changeset
4986 case VAR_LevelModifier:
Ritor1
parents:
diff changeset
4987 return this->sLevelModifier >= pValue;
Ritor1
parents:
diff changeset
4988 case VAR_Age:
Ritor1
parents:
diff changeset
4989 return GetActualAge() >= (unsigned int)pValue;
Ritor1
parents:
diff changeset
4990 case VAR_Award:
Ritor1
parents:
diff changeset
4991 return _449B57_test_bit(this->_achieved_awards_bits, pValue);
Ritor1
parents:
diff changeset
4992 case VAR_Experience:
Ritor1
parents:
diff changeset
4993 return this->uExperience >= pValue; //TODO change pValue to long long
Ritor1
parents:
diff changeset
4994 case VAR_QBits_QuestsDone:
Ritor1
parents:
diff changeset
4995 return _449B57_test_bit(pParty->_quest_bits, pValue);
Ritor1
parents:
diff changeset
4996 case VAR_PlayerItemInHands:
Ritor1
parents:
diff changeset
4997 //for (int i = 0; i < 138; i++)
Ritor1
parents:
diff changeset
4998 for (int i = 0; i < 126; i++)
Ritor1
parents:
diff changeset
4999 {
Ritor1
parents:
diff changeset
5000 if (pInventoryItemList[i].uItemID == pValue)
Ritor1
parents:
diff changeset
5001 {
Ritor1
parents:
diff changeset
5002 return true;
Ritor1
parents:
diff changeset
5003 }
Ritor1
parents:
diff changeset
5004 }
Ritor1
parents:
diff changeset
5005 return pParty->pPickedItem.uItemID == pValue;
Ritor1
parents:
diff changeset
5006 case VAR_Hour:
Ritor1
parents:
diff changeset
5007 if ( (long long)(pParty->uTimePlayed * 0.234375) / 60 / 60 % 24 == pValue )
Ritor1
parents:
diff changeset
5008 return true;
Ritor1
parents:
diff changeset
5009 return false;
Ritor1
parents:
diff changeset
5010 case VAR_DayOfYear:
Ritor1
parents:
diff changeset
5011 if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 336 + 1 == pValue)
Ritor1
parents:
diff changeset
5012 return true;
Ritor1
parents:
diff changeset
5013 return false;
Ritor1
parents:
diff changeset
5014 case VAR_DayOfWeek:
Ritor1
parents:
diff changeset
5015 if (((long long)(pParty->uTimePlayed * 0.234375) / 60 / 60) / 24 % 7)
Ritor1
parents:
diff changeset
5016 return true;
Ritor1
parents:
diff changeset
5017 return false;
Ritor1
parents:
diff changeset
5018 case VAR_FixedGold:
Ritor1
parents:
diff changeset
5019 return pParty->uNumGold >= (unsigned int)pValue;
Ritor1
parents:
diff changeset
5020 case VAR_FixedFood:
Ritor1
parents:
diff changeset
5021 return pParty->uNumFoodRations >= (unsigned int)pValue;
Ritor1
parents:
diff changeset
5022 case VAR_MightBonus:
Ritor1
parents:
diff changeset
5023 return this->uMightBonus >= pValue;
Ritor1
parents:
diff changeset
5024 case VAR_IntellectBonus:
Ritor1
parents:
diff changeset
5025 return this->uIntelligenceBonus >= pValue;
Ritor1
parents:
diff changeset
5026 case VAR_PersonalityBonus:
Ritor1
parents:
diff changeset
5027 return this->uWillpowerBonus >= pValue;
Ritor1
parents:
diff changeset
5028 case VAR_EnduranceBonus:
Ritor1
parents:
diff changeset
5029 return this->uEnduranceBonus >= pValue;
Ritor1
parents:
diff changeset
5030 case VAR_SpeedBonus:
Ritor1
parents:
diff changeset
5031 return this->uSpeedBonus >= pValue;
Ritor1
parents:
diff changeset
5032 case VAR_AccuracyBonus:
Ritor1
parents:
diff changeset
5033 return this->uAccuracyBonus >= pValue;
Ritor1
parents:
diff changeset
5034 case VAR_LuckBonus:
Ritor1
parents:
diff changeset
5035 return this->uLuckBonus >= pValue;
Ritor1
parents:
diff changeset
5036 case VAR_BaseMight:
Ritor1
parents:
diff changeset
5037 return this->uMight >= pValue;
Ritor1
parents:
diff changeset
5038 case VAR_BaseIntellect:
Ritor1
parents:
diff changeset
5039 return this->uIntelligence >= pValue;
Ritor1
parents:
diff changeset
5040 case VAR_BasePersonality:
Ritor1
parents:
diff changeset
5041 return this->uWillpower >= pValue;
Ritor1
parents:
diff changeset
5042 case VAR_BaseEndurance:
Ritor1
parents:
diff changeset
5043 return this->uEndurance >= pValue;
Ritor1
parents:
diff changeset
5044 case VAR_BaseSpeed:
Ritor1
parents:
diff changeset
5045 return this->uSpeed >= pValue;
Ritor1
parents:
diff changeset
5046 case VAR_BaseAccuracy:
Ritor1
parents:
diff changeset
5047 return this->uAccuracy >= pValue;
Ritor1
parents:
diff changeset
5048 case VAR_BaseLuck:
Ritor1
parents:
diff changeset
5049 return this->uLuck >= pValue;
Ritor1
parents:
diff changeset
5050 case VAR_ActualMight:
Ritor1
parents:
diff changeset
5051 return GetActualMight() >= pValue;
Ritor1
parents:
diff changeset
5052 case VAR_ActualIntellect:
Ritor1
parents:
diff changeset
5053 return GetActualIntelligence() >= pValue;
Ritor1
parents:
diff changeset
5054 case VAR_ActualPersonality:
Ritor1
parents:
diff changeset
5055 return GetActualWillpower() >= pValue;
Ritor1
parents:
diff changeset
5056 case VAR_ActualEndurance:
Ritor1
parents:
diff changeset
5057 return GetActualEndurance() >= pValue;
Ritor1
parents:
diff changeset
5058 case VAR_ActualSpeed:
Ritor1
parents:
diff changeset
5059 return GetActualSpeed() >= pValue;
Ritor1
parents:
diff changeset
5060 case VAR_ActualAccuracy:
Ritor1
parents:
diff changeset
5061 return GetActualAccuracy() >= pValue;
Ritor1
parents:
diff changeset
5062 case VAR_ActualLuck:
Ritor1
parents:
diff changeset
5063 return GetActualLuck() >= pValue;
Ritor1
parents:
diff changeset
5064 case VAR_FireResistance:
Ritor1
parents:
diff changeset
5065 return this->sResFireBase >= pValue;
Ritor1
parents:
diff changeset
5066 case VAR_AirResistance:
Ritor1
parents:
diff changeset
5067 return this->sResAirBase >= pValue;
Ritor1
parents:
diff changeset
5068 case VAR_WaterResistance:
Ritor1
parents:
diff changeset
5069 return this->sResWaterBase >= pValue;
Ritor1
parents:
diff changeset
5070 case VAR_EarthResistance:
Ritor1
parents:
diff changeset
5071 return this->sResEarthBase >= pValue;
Ritor1
parents:
diff changeset
5072 case VAR_SpiritResistance:
Ritor1
parents:
diff changeset
5073 return this->sResSpiritBase >= pValue;
Ritor1
parents:
diff changeset
5074 case VAR_MindResistance:
Ritor1
parents:
diff changeset
5075 return this->sResMindBase >= pValue;
Ritor1
parents:
diff changeset
5076 case VAR_BodyResistance:
Ritor1
parents:
diff changeset
5077 return this->sResBodyBase >= pValue;
Ritor1
parents:
diff changeset
5078 case VAR_LightResistance:
Ritor1
parents:
diff changeset
5079 return this->sResLightBase >= pValue;
Ritor1
parents:
diff changeset
5080 case VAR_DarkResistance:
Ritor1
parents:
diff changeset
5081 return this->sResDarkBase >= pValue;
Ritor1
parents:
diff changeset
5082 case VAR_PhysicalResistance:
Ritor1
parents:
diff changeset
5083 Error("Physical resistance isn't used in events");
Ritor1
parents:
diff changeset
5084 return false;
Ritor1
parents:
diff changeset
5085 case VAR_MagicResistance:
Ritor1
parents:
diff changeset
5086 return this->sResMagicBase >= pValue;
Ritor1
parents:
diff changeset
5087 case VAR_FireResistanceBonus:
Ritor1
parents:
diff changeset
5088 return this->sResFireBonus >= pValue;
Ritor1
parents:
diff changeset
5089 case VAR_AirResistanceBonus:
Ritor1
parents:
diff changeset
5090 return this->sResAirBonus >= pValue;
Ritor1
parents:
diff changeset
5091 case VAR_WaterResistanceBonus:
Ritor1
parents:
diff changeset
5092 return this->sResWaterBonus >= pValue;
Ritor1
parents:
diff changeset
5093 case VAR_EarthResistanceBonus:
Ritor1
parents:
diff changeset
5094 return this->sResEarthBonus >= pValue;
Ritor1
parents:
diff changeset
5095 case VAR_SpiritResistanceBonus:
Ritor1
parents:
diff changeset
5096 return this->sResSpiritBonus >= pValue;
Ritor1
parents:
diff changeset
5097 case VAR_MindResistanceBonus:
Ritor1
parents:
diff changeset
5098 return this->sResMindBonus >= pValue;
Ritor1
parents:
diff changeset
5099 case VAR_BodyResistanceBonus:
Ritor1
parents:
diff changeset
5100 return this->sResBodyBonus >= pValue;
Ritor1
parents:
diff changeset
5101 case VAR_LightResistanceBonus:
Ritor1
parents:
diff changeset
5102 return this->sResLightBonus >= pValue;
Ritor1
parents:
diff changeset
5103 case VAR_DarkResistanceBonus:
Ritor1
parents:
diff changeset
5104 return this->sResDarkBonus >= pValue;
Ritor1
parents:
diff changeset
5105 case VAR_MagicResistanceBonus:
Ritor1
parents:
diff changeset
5106 return this->sResMagicBonus >= pValue;
Ritor1
parents:
diff changeset
5107 case VAR_StaffSkill:
Ritor1
parents:
diff changeset
5108 return CmpSkillValue(pValue, this->skillStaff);
Ritor1
parents:
diff changeset
5109 case VAR_SwordSkill:
Ritor1
parents:
diff changeset
5110 return CmpSkillValue(pValue, this->skillSword);
Ritor1
parents:
diff changeset
5111 case VAR_DaggerSkill:
Ritor1
parents:
diff changeset
5112 return CmpSkillValue(pValue, this->skillDagger);
Ritor1
parents:
diff changeset
5113 case VAR_AxeSkill:
Ritor1
parents:
diff changeset
5114 return CmpSkillValue(pValue, this->skillAxe);
Ritor1
parents:
diff changeset
5115 case VAR_SpearSkill:
Ritor1
parents:
diff changeset
5116 return CmpSkillValue(pValue, this->skillSpear);
Ritor1
parents:
diff changeset
5117 case VAR_BowSkill:
Ritor1
parents:
diff changeset
5118 return CmpSkillValue(pValue, this->skillBow);
Ritor1
parents:
diff changeset
5119 case VAR_MaceSkill:
Ritor1
parents:
diff changeset
5120 return CmpSkillValue(pValue, this->skillMace);
Ritor1
parents:
diff changeset
5121 case VAR_BlasterSkill:
Ritor1
parents:
diff changeset
5122 return CmpSkillValue(pValue, this->skillBlaster);
Ritor1
parents:
diff changeset
5123 case VAR_ShieldSkill:
Ritor1
parents:
diff changeset
5124 return CmpSkillValue(pValue, this->skillShield);
Ritor1
parents:
diff changeset
5125 case VAR_LeatherSkill:
Ritor1
parents:
diff changeset
5126 return CmpSkillValue(pValue, this->skillLeather);
Ritor1
parents:
diff changeset
5127 case VAR_SkillChain:
Ritor1
parents:
diff changeset
5128 return CmpSkillValue(pValue, this->skillChain);
Ritor1
parents:
diff changeset
5129 case VAR_PlateSkill:
Ritor1
parents:
diff changeset
5130 return CmpSkillValue(pValue, this->skillPlate);
Ritor1
parents:
diff changeset
5131 case VAR_FireSkill:
Ritor1
parents:
diff changeset
5132 return CmpSkillValue(pValue, this->skillFire);
Ritor1
parents:
diff changeset
5133 case VAR_AirSkill:
Ritor1
parents:
diff changeset
5134 return CmpSkillValue(pValue, this->skillAir);
Ritor1
parents:
diff changeset
5135 case VAR_WaterSkill:
Ritor1
parents:
diff changeset
5136 return CmpSkillValue(pValue, this->skillWater);
Ritor1
parents:
diff changeset
5137 case VAR_EarthSkill:
Ritor1
parents:
diff changeset
5138 return CmpSkillValue(pValue, this->skillEarth);
Ritor1
parents:
diff changeset
5139 case VAR_SpiritSkill:
Ritor1
parents:
diff changeset
5140 return CmpSkillValue(pValue, this->skillSpirit);
Ritor1
parents:
diff changeset
5141 case VAR_MindSkill:
Ritor1
parents:
diff changeset
5142 return CmpSkillValue(pValue, this->skillMind);
Ritor1
parents:
diff changeset
5143 case VAR_BodySkill:
Ritor1
parents:
diff changeset
5144 return CmpSkillValue(pValue, this->skillBody);
Ritor1
parents:
diff changeset
5145 case VAR_LightSkill:
Ritor1
parents:
diff changeset
5146 return CmpSkillValue(pValue, this->skillLight);
Ritor1
parents:
diff changeset
5147 case VAR_DarkSkill:
Ritor1
parents:
diff changeset
5148 return CmpSkillValue(pValue, this->skillDark);
Ritor1
parents:
diff changeset
5149 case VAR_IdentifyItemSkill:
Ritor1
parents:
diff changeset
5150 return CmpSkillValue(pValue, this->skillItemId);
Ritor1
parents:
diff changeset
5151 case VAR_MerchantSkill:
Ritor1
parents:
diff changeset
5152 return CmpSkillValue(pValue, this->skillMerchant);
Ritor1
parents:
diff changeset
5153 case VAR_RepairSkill:
Ritor1
parents:
diff changeset
5154 return CmpSkillValue(pValue, this->skillRepair);
Ritor1
parents:
diff changeset
5155 case VAR_BodybuildingSkill:
Ritor1
parents:
diff changeset
5156 return CmpSkillValue(pValue, this->skillBodybuilding);
Ritor1
parents:
diff changeset
5157 case VAR_MeditationSkill:
Ritor1
parents:
diff changeset
5158 return CmpSkillValue(pValue, this->skillMeditation);
Ritor1
parents:
diff changeset
5159 case VAR_PerceptionSkill:
Ritor1
parents:
diff changeset
5160 return CmpSkillValue(pValue, this->skillPerception);
Ritor1
parents:
diff changeset
5161 case VAR_DiplomacySkill:
Ritor1
parents:
diff changeset
5162 return CmpSkillValue(pValue, this->skillDiplomacy);
Ritor1
parents:
diff changeset
5163 case VAR_ThieverySkill:
Ritor1
parents:
diff changeset
5164 Error("Thievery isn't used in events");
Ritor1
parents:
diff changeset
5165 return false;
Ritor1
parents:
diff changeset
5166 case VAR_DisarmTrapSkill: //wasn't in the original
Ritor1
parents:
diff changeset
5167 return CmpSkillValue(pValue, this->skillDisarmTrap);
Ritor1
parents:
diff changeset
5168 case VAR_DodgeSkill: //wasn't in the original
Ritor1
parents:
diff changeset
5169 return CmpSkillValue(pValue, this->skillDodge);
Ritor1
parents:
diff changeset
5170 case VAR_UnarmedSkill: //wasn't in the original
Ritor1
parents:
diff changeset
5171 return CmpSkillValue(pValue, this->skillUnarmed);
Ritor1
parents:
diff changeset
5172 case VAR_IdentifyMonsterSkill: //wasn't in the original
Ritor1
parents:
diff changeset
5173 return CmpSkillValue(pValue, this->skillMonsterId);
Ritor1
parents:
diff changeset
5174 case VAR_ArmsmasterSkill: //wasn't in the original
Ritor1
parents:
diff changeset
5175 return CmpSkillValue(pValue, this->skillArmsmaster);
Ritor1
parents:
diff changeset
5176 case VAR_StealingSkill: //wasn't in the original
Ritor1
parents:
diff changeset
5177 return CmpSkillValue(pValue, this->skillStealing);
Ritor1
parents:
diff changeset
5178 case VAR_AlchemySkill: //wasn't in the original
Ritor1
parents:
diff changeset
5179 return CmpSkillValue(pValue, this->skillAlchemy);
Ritor1
parents:
diff changeset
5180 case VAR_LearningSkill:
Ritor1
parents:
diff changeset
5181 return CmpSkillValue(pValue, this->skillLearning);
Ritor1
parents:
diff changeset
5182 case VAR_Cursed:
Ritor1
parents:
diff changeset
5183 return pConditions[Condition_Cursed] > 0;
Ritor1
parents:
diff changeset
5184 case VAR_Weak:
Ritor1
parents:
diff changeset
5185 return pConditions[Condition_Weak] > 0;
Ritor1
parents:
diff changeset
5186 case VAR_Asleep:
Ritor1
parents:
diff changeset
5187 return pConditions[Condition_Sleep] > 0;
Ritor1
parents:
diff changeset
5188 case VAR_Afraid:
Ritor1
parents:
diff changeset
5189 return pConditions[Condition_Fear] > 0;
Ritor1
parents:
diff changeset
5190 case VAR_Drunk:
Ritor1
parents:
diff changeset
5191 return pConditions[Condition_Drunk] > 0;
Ritor1
parents:
diff changeset
5192 case VAR_Insane:
Ritor1
parents:
diff changeset
5193 return pConditions[Condition_Insane] > 0;
Ritor1
parents:
diff changeset
5194 case VAR_PoisonedGreen:
Ritor1
parents:
diff changeset
5195 return pConditions[Condition_Poison_Weak] > 0;
Ritor1
parents:
diff changeset
5196 case VAR_DiseasedGreen:
Ritor1
parents:
diff changeset
5197 return pConditions[Condition_Disease_Weak] > 0;
Ritor1
parents:
diff changeset
5198 case VAR_PoisonedYellow:
Ritor1
parents:
diff changeset
5199 return pConditions[Condition_Poison_Medium] > 0;
Ritor1
parents:
diff changeset
5200 case VAR_DiseasedYellow:
Ritor1
parents:
diff changeset
5201 return pConditions[Condition_Disease_Medium] > 0;
Ritor1
parents:
diff changeset
5202 case VAR_PoisonedRed:
Ritor1
parents:
diff changeset
5203 return pConditions[Condition_Poison_Severe] > 0;
Ritor1
parents:
diff changeset
5204 case VAR_DiseasedRed:
Ritor1
parents:
diff changeset
5205 return pConditions[Condition_Disease_Severe] > 0;
Ritor1
parents:
diff changeset
5206 case VAR_Paralyzed:
Ritor1
parents:
diff changeset
5207 return pConditions[Condition_Paralyzed] > 0;
Ritor1
parents:
diff changeset
5208 case VAR_Unconsious:
Ritor1
parents:
diff changeset
5209 return pConditions[Condition_Unconcious] > 0;
Ritor1
parents:
diff changeset
5210 case VAR_Dead:
Ritor1
parents:
diff changeset
5211 return pConditions[Condition_Dead] > 0;
Ritor1
parents:
diff changeset
5212 case VAR_Stoned:
Ritor1
parents:
diff changeset
5213 return pConditions[Condition_Pertified] > 0;
Ritor1
parents:
diff changeset
5214 case VAR_Eradicated:
Ritor1
parents:
diff changeset
5215 return pConditions[Condition_Eradicated] > 0;
Ritor1
parents:
diff changeset
5216 case VAR_MajorCondition:
Ritor1
parents:
diff changeset
5217 v4 = GetMajorConditionIdx();
Ritor1
parents:
diff changeset
5218 if ( v4 != 18 )
Ritor1
parents:
diff changeset
5219 {
Ritor1
parents:
diff changeset
5220 return v4 >= pValue;
Ritor1
parents:
diff changeset
5221 }
Ritor1
parents:
diff changeset
5222 return true;
Ritor1
parents:
diff changeset
5223 case VAR_AutoNotes : //TODO: find out why the double subtraction. or whether this is even used
Ritor1
parents:
diff changeset
5224 test_bit_value = 0x80u >> (pValue - 2) % 8;
Ritor1
parents:
diff changeset
5225 byteWithRequestedBit = pParty->_autonote_bits[(pValue - 2) /8];
Ritor1
parents:
diff changeset
5226 return (test_bit_value & byteWithRequestedBit) != 0;
Ritor1
parents:
diff changeset
5227 case VAR_IsMightMoreThanBase:
Ritor1
parents:
diff changeset
5228 actStat = GetActualMight();
Ritor1
parents:
diff changeset
5229 baseStat = GetBaseStrength();
Ritor1
parents:
diff changeset
5230 return (actStat >= baseStat);
Ritor1
parents:
diff changeset
5231 case VAR_IsIntellectMoreThanBase:
Ritor1
parents:
diff changeset
5232 actStat = GetActualIntelligence();
Ritor1
parents:
diff changeset
5233 baseStat = GetBaseIntelligence();
Ritor1
parents:
diff changeset
5234 return (actStat >= baseStat);
Ritor1
parents:
diff changeset
5235 case VAR_IsPersonalityMoreThanBase:
Ritor1
parents:
diff changeset
5236 actStat = GetActualWillpower();
Ritor1
parents:
diff changeset
5237 baseStat = GetBaseWillpower();
Ritor1
parents:
diff changeset
5238 return (actStat >= baseStat);
Ritor1
parents:
diff changeset
5239 case VAR_IsEnduranceMoreThanBase:
Ritor1
parents:
diff changeset
5240 actStat = GetActualEndurance();
Ritor1
parents:
diff changeset
5241 baseStat = GetBaseEndurance();
Ritor1
parents:
diff changeset
5242 return (actStat >= baseStat);
Ritor1
parents:
diff changeset
5243 case VAR_IsSpeedMoreThanBase:
Ritor1
parents:
diff changeset
5244 actStat = GetActualSpeed();
Ritor1
parents:
diff changeset
5245 baseStat = GetBaseSpeed();
Ritor1
parents:
diff changeset
5246 return (actStat >= baseStat);
Ritor1
parents:
diff changeset
5247 case VAR_IsAccuracyMoreThanBase:
Ritor1
parents:
diff changeset
5248 actStat = GetActualAccuracy();
Ritor1
parents:
diff changeset
5249 baseStat = GetBaseAccuracy();
Ritor1
parents:
diff changeset
5250 return (actStat >= baseStat);
Ritor1
parents:
diff changeset
5251 case VAR_IsLuckMoreThanBase:
Ritor1
parents:
diff changeset
5252 actStat = GetActualLuck();
Ritor1
parents:
diff changeset
5253 baseStat = GetBaseLuck();
Ritor1
parents:
diff changeset
5254 return (actStat >= baseStat);
Ritor1
parents:
diff changeset
5255 case VAR_PlayerBits:
Ritor1
parents:
diff changeset
5256 test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8;
Ritor1
parents:
diff changeset
5257 byteWithRequestedBit = this->playerEventBits[((signed __int16)pValue - 1)/8];
Ritor1
parents:
diff changeset
5258 return ( test_bit_value & byteWithRequestedBit ) != 0;
Ritor1
parents:
diff changeset
5259 case VAR_NPCs2:
Ritor1
parents:
diff changeset
5260 return pNPCStats->pNewNPCData[pValue].Hired();
Ritor1
parents:
diff changeset
5261 case VAR_IsFlying:
Ritor1
parents:
diff changeset
5262 if ( pParty->bFlying
Ritor1
parents:
diff changeset
5263 && (pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime> 0) )
Ritor1
parents:
diff changeset
5264 return true;
Ritor1
parents:
diff changeset
5265 return false;
Ritor1
parents:
diff changeset
5266 case VAR_HiredNPCHasSpeciality:
Ritor1
parents:
diff changeset
5267 return CheckHiredNPCSpeciality(pValue);
Ritor1
parents:
diff changeset
5268 case VAR_CircusPrises: //isn't used in MM6 since 0x1D6u is a book of regeneration
Ritor1
parents:
diff changeset
5269 v4 = 0;
Ritor1
parents:
diff changeset
5270 for (int playerNum = 0; playerNum < 4; playerNum++)
Ritor1
parents:
diff changeset
5271 {
Ritor1
parents:
diff changeset
5272 for (int invPos = 0; invPos < 138; invPos++)
Ritor1
parents:
diff changeset
5273 {
Ritor1
parents:
diff changeset
5274 int itemId = pParty->pPlayers[playerNum].pInventoryItemList[invPos].uItemID;
Ritor1
parents:
diff changeset
5275 switch ( itemId )
Ritor1
parents:
diff changeset
5276 {
Ritor1
parents:
diff changeset
5277 case 0x1D6u:
Ritor1
parents:
diff changeset
5278 ++v4;
Ritor1
parents:
diff changeset
5279 break;
Ritor1
parents:
diff changeset
5280 case 0x1D7u:
Ritor1
parents:
diff changeset
5281 v4 += 3;
Ritor1
parents:
diff changeset
5282 break;
Ritor1
parents:
diff changeset
5283 case 0x1DDu:
Ritor1
parents:
diff changeset
5284 v4 += 5;
Ritor1
parents:
diff changeset
5285 break;
Ritor1
parents:
diff changeset
5286 }
Ritor1
parents:
diff changeset
5287 }
Ritor1
parents:
diff changeset
5288 }
Ritor1
parents:
diff changeset
5289 return v4 >= pValue;
Ritor1
parents:
diff changeset
5290 case VAR_NumSkillPoints:
Ritor1
parents:
diff changeset
5291 return this->uSkillPoints >= (unsigned int)pValue;
Ritor1
parents:
diff changeset
5292 case VAR_MonthIs:
Ritor1
parents:
diff changeset
5293 return (pParty->uCurrentMonth == (unsigned int)pValue);
Ritor1
parents:
diff changeset
5294 case VAR_Counter1:
Ritor1
parents:
diff changeset
5295 case VAR_Counter2:
Ritor1
parents:
diff changeset
5296 case VAR_Counter3:
Ritor1
parents:
diff changeset
5297 case VAR_Counter4:
Ritor1
parents:
diff changeset
5298 case VAR_Counter5:
Ritor1
parents:
diff changeset
5299 case VAR_Counter6:
Ritor1
parents:
diff changeset
5300 case VAR_Counter7:
Ritor1
parents:
diff changeset
5301 case VAR_Counter8:
Ritor1
parents:
diff changeset
5302 case VAR_Counter9:
Ritor1
parents:
diff changeset
5303 case VAR_Counter10:
Ritor1
parents:
diff changeset
5304 if (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1]) //originally (signed __int64)(__PAIR__(*(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44304], *(int *)&stru_AA1058[3].pSounds[8 * VarNum + 44300])
Ritor1
parents:
diff changeset
5305 {
Ritor1
parents:
diff changeset
5306 return (pParty->PartyTimes.CounterEventValues[VarNum - VAR_Counter1] + 460800 * pValue * 0.033333335) <= pParty->uTimePlayed ;
Ritor1
parents:
diff changeset
5307 }
Ritor1
parents:
diff changeset
5308 case VAR_ReputationInCurrentLocation:
Ritor1
parents:
diff changeset
5309 v19 = &pOutdoor->ddm;
Ritor1
parents:
diff changeset
5310 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
Ritor1
parents:
diff changeset
5311 v19 = &pIndoor->dlv;
Ritor1
parents:
diff changeset
5312 return (v19->uReputation >= pValue);
Ritor1
parents:
diff changeset
5313 case VAR_Unknown1:
Ritor1
parents:
diff changeset
5314 v21 = &pOutdoor->ddm;
Ritor1
parents:
diff changeset
5315 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
Ritor1
parents:
diff changeset
5316 v21 = &pIndoor->dlv;
Ritor1
parents:
diff changeset
5317 return (v21->field_C_alert == pValue); //yes, equality, not >=
Ritor1
parents:
diff changeset
5318 case VAR_GoldInBank:
Ritor1
parents:
diff changeset
5319 return pParty->uNumGoldInBank >= (unsigned int)pValue;
Ritor1
parents:
diff changeset
5320 case VAR_NumDeaths:
Ritor1
parents:
diff changeset
5321 return pParty->uNumDeaths >= (unsigned int)pValue;
Ritor1
parents:
diff changeset
5322 case VAR_NumBounties:
Ritor1
parents:
diff changeset
5323 return pParty->uNumBountiesCollected >= (unsigned int)pValue;
Ritor1
parents:
diff changeset
5324 case VAR_PrisonTerms:
Ritor1
parents:
diff changeset
5325 return pParty->uNumPrisonTerms >= pValue;
Ritor1
parents:
diff changeset
5326 case VAR_ArenaWinsPage:
Ritor1
parents:
diff changeset
5327 return (unsigned __int8)pParty->uNumArenaPageWins >= pValue;
Ritor1
parents:
diff changeset
5328 case VAR_ArenaWinsSquire:
Ritor1
parents:
diff changeset
5329 return (unsigned __int8)pParty->uNumArenaSquireWins >= pValue;
Ritor1
parents:
diff changeset
5330 case VAR_ArenaWinsKnight:
Ritor1
parents:
diff changeset
5331 return (unsigned __int8)pParty->uNumArenaKnightWins >= pValue;
Ritor1
parents:
diff changeset
5332 case VAR_ArenaWinsLord:
Ritor1
parents:
diff changeset
5333 return pParty->uNumArenaLordWins >= pValue;
Ritor1
parents:
diff changeset
5334 case VAR_Invisible:
Ritor1
parents:
diff changeset
5335 return ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 );
Ritor1
parents:
diff changeset
5336 case VAR_ItemEquipped:
Ritor1
parents:
diff changeset
5337 for (int i = 0; i < 16; i++)
Ritor1
parents:
diff changeset
5338 {
Ritor1
parents:
diff changeset
5339 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) && GetNthEquippedIndexItem(i)->uItemID == pValue )
Ritor1
parents:
diff changeset
5340 {
Ritor1
parents:
diff changeset
5341 return true;
Ritor1
parents:
diff changeset
5342 }
Ritor1
parents:
diff changeset
5343 }
Ritor1
parents:
diff changeset
5344 return false;
Ritor1
parents:
diff changeset
5345 }
Ritor1
parents:
diff changeset
5346
Ritor1
parents:
diff changeset
5347 return false;
Ritor1
parents:
diff changeset
5348 }
Ritor1
parents:
diff changeset
5349
Ritor1
parents:
diff changeset
5350
Ritor1
parents:
diff changeset
5351 //----- (0044A5CB) --------------------------------------------------------
Ritor1
parents:
diff changeset
5352 void Player::SetVariable(enum VariableType var_type, signed int var_value)
Ritor1
parents:
diff changeset
5353 {
Ritor1
parents:
diff changeset
5354 unsigned int v6; // esi@13
Ritor1
parents:
diff changeset
5355 unsigned int v7; // esi@14
Ritor1
parents:
diff changeset
5356 signed int v11; // eax@30
Ritor1
parents:
diff changeset
5357 DDM_DLV_Header *v24; // ecx@148
Ritor1
parents:
diff changeset
5358 ItemGen item; // [sp+Ch] [bp-28h]@52
Ritor1
parents:
diff changeset
5359
Ritor1
parents:
diff changeset
5360
Ritor1
parents:
diff changeset
5361 if ( var_type >= VAR_History_0 && var_type <= VAR_History_28)
Ritor1
parents:
diff changeset
5362 {
Ritor1
parents:
diff changeset
5363 if (!pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0])
Ritor1
parents:
diff changeset
5364 {
Ritor1
parents:
diff changeset
5365 pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0] = pParty->uTimePlayed;
Ritor1
parents:
diff changeset
5366 if (pStorylineText->StoreLine[var_type - VAR_History_0].pText)
Ritor1
parents:
diff changeset
5367 {
Ritor1
parents:
diff changeset
5368 bFlashHistoryBook = 1;
Ritor1
parents:
diff changeset
5369 PlayAwardSound();
Ritor1
parents:
diff changeset
5370 }
Ritor1
parents:
diff changeset
5371 }
Ritor1
parents:
diff changeset
5372 return;
Ritor1
parents:
diff changeset
5373 }
Ritor1
parents:
diff changeset
5374
Ritor1
parents:
diff changeset
5375 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 )
Ritor1
parents:
diff changeset
5376 {
Ritor1
parents:
diff changeset
5377 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_74 )
Ritor1
parents:
diff changeset
5378 stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0] = (char)var_value; // originally (unsigned __int8)byte_5E4C15[VarNum];
Ritor1
parents:
diff changeset
5379 if ( var_type >= VAR_MapPersistentVariable_75 && var_type <= VAR_MapPersistentVariable_99 )
Ritor1
parents:
diff changeset
5380 stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75] = (unsigned char)var_value; //not really sure whether the number gets up to 99, but can't ignore the possibility
Ritor1
parents:
diff changeset
5381 return;
Ritor1
parents:
diff changeset
5382 }
Ritor1
parents:
diff changeset
5383
Ritor1
parents:
diff changeset
5384 if ( var_type >= VAR_UnknownTimeEvent0 && var_type <= VAR_UnknownTimeEvent19 )
Ritor1
parents:
diff changeset
5385 {
Ritor1
parents:
diff changeset
5386 pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed; //*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed);, *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed
Ritor1
parents:
diff changeset
5387 PlayAwardSound();
Ritor1
parents:
diff changeset
5388 return;
Ritor1
parents:
diff changeset
5389 }
Ritor1
parents:
diff changeset
5390
Ritor1
parents:
diff changeset
5391 switch ( var_type )
Ritor1
parents:
diff changeset
5392 {
Ritor1
parents:
diff changeset
5393 case VAR_Sex:
Ritor1
parents:
diff changeset
5394 this->uSex = (PLAYER_SEX)var_value;
Ritor1
parents:
diff changeset
5395 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5396 return;
Ritor1
parents:
diff changeset
5397 case VAR_Class:
Ritor1
parents:
diff changeset
5398 this->classType = (PLAYER_CLASS_TYPE)var_value;
Ritor1
parents:
diff changeset
5399 if ( (PLAYER_CLASS_TYPE)var_value == PLAYER_CLASS_LICH )
Ritor1
parents:
diff changeset
5400 {
Ritor1
parents:
diff changeset
5401 for (int i = 0; i < 138; i++)
Ritor1
parents:
diff changeset
5402 {
Ritor1
parents:
diff changeset
5403 if (this->pOwnItems[i].uItemID == ITEM_LICH_JAR_EMPTY)
Ritor1
parents:
diff changeset
5404 {
Ritor1
parents:
diff changeset
5405 this->pOwnItems[i].uItemID = ITEM_LICH_JAR_FULL;
Ritor1
parents:
diff changeset
5406 this->pOwnItems[i].uHolderPlayer = GetPlayerIndex() + 1;
Ritor1
parents:
diff changeset
5407 }
Ritor1
parents:
diff changeset
5408 }
Ritor1
parents:
diff changeset
5409 if ( this->sResFireBase < 20 )
Ritor1
parents:
diff changeset
5410 this->sResFireBase = 20;
Ritor1
parents:
diff changeset
5411 if ( this->sResAirBase < 20 )
Ritor1
parents:
diff changeset
5412 this->sResAirBase = 20;
Ritor1
parents:
diff changeset
5413 if ( this->sResWaterBase < 20 )
Ritor1
parents:
diff changeset
5414 this->sResWaterBase = 20;
Ritor1
parents:
diff changeset
5415 if ( this->sResEarthBase < 20 )
Ritor1
parents:
diff changeset
5416 this->sResEarthBase = 20;
Ritor1
parents:
diff changeset
5417 this->sResMindBase = 200;
Ritor1
parents:
diff changeset
5418 this->sResBodyBase = 200;
Ritor1
parents:
diff changeset
5419 v11 = this->GetSexByVoice();
Ritor1
parents:
diff changeset
5420 this->uPrevVoiceID = this->uVoiceID;
Ritor1
parents:
diff changeset
5421 this->uPrevFace = this->uCurrentFace;
Ritor1
parents:
diff changeset
5422 if ( v11 )
Ritor1
parents:
diff changeset
5423 {
Ritor1
parents:
diff changeset
5424 this->uCurrentFace = 21;
Ritor1
parents:
diff changeset
5425 this->uVoiceID = 21;
Ritor1
parents:
diff changeset
5426 }
Ritor1
parents:
diff changeset
5427 else
Ritor1
parents:
diff changeset
5428 {
Ritor1
parents:
diff changeset
5429 this->uCurrentFace = 20;
Ritor1
parents:
diff changeset
5430 this->uVoiceID = 20;
Ritor1
parents:
diff changeset
5431 }
Ritor1
parents:
diff changeset
5432 ReloadPlayerPortraits(GetPlayerIndex(), this->uCurrentFace);
Ritor1
parents:
diff changeset
5433 }
Ritor1
parents:
diff changeset
5434 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5435 return;
Ritor1
parents:
diff changeset
5436 case VAR_CurrentHP:
Ritor1
parents:
diff changeset
5437 this->sHealth = var_value;
Ritor1
parents:
diff changeset
5438 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5439 return;
Ritor1
parents:
diff changeset
5440 case VAR_MaxHP:
Ritor1
parents:
diff changeset
5441 this->sHealth = GetMaxHealth();
Ritor1
parents:
diff changeset
5442 return;
Ritor1
parents:
diff changeset
5443 case VAR_CurrentSP:
Ritor1
parents:
diff changeset
5444 this->sMana = var_value;
Ritor1
parents:
diff changeset
5445 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5446 return;
Ritor1
parents:
diff changeset
5447 case VAR_MaxSP:
Ritor1
parents:
diff changeset
5448 this->sMana = GetMaxMana();
Ritor1
parents:
diff changeset
5449 return;
Ritor1
parents:
diff changeset
5450 case VAR_ACModifier:
Ritor1
parents:
diff changeset
5451 this->sACModifier = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5452 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5453 return;
Ritor1
parents:
diff changeset
5454 case VAR_BaseLevel:
Ritor1
parents:
diff changeset
5455 this->uLevel = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5456 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5457 return;
Ritor1
parents:
diff changeset
5458 case VAR_LevelModifier:
Ritor1
parents:
diff changeset
5459 this->sLevelModifier = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5460 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5461 return;
Ritor1
parents:
diff changeset
5462 case VAR_Age:
Ritor1
parents:
diff changeset
5463 this->sAgeModifier = var_value;
Ritor1
parents:
diff changeset
5464 return;
Ritor1
parents:
diff changeset
5465 case VAR_Award:
Ritor1
parents:
diff changeset
5466 if ( !_449B57_test_bit(this->_achieved_awards_bits, var_value) && pAwards[var_value].pText )
Ritor1
parents:
diff changeset
5467 {
Ritor1
parents:
diff changeset
5468 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5469 this->PlaySound(SPEECH_96, 0);
Ritor1
parents:
diff changeset
5470 }
Ritor1
parents:
diff changeset
5471 _449B7E_toggle_bit(this->_achieved_awards_bits, var_value, 1u);
Ritor1
parents:
diff changeset
5472 return;
Ritor1
parents:
diff changeset
5473 case VAR_Experience:
Ritor1
parents:
diff changeset
5474 this->uExperience = var_value;
Ritor1
parents:
diff changeset
5475 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5476 return;
Ritor1
parents:
diff changeset
5477 case VAR_QBits_QuestsDone:
Ritor1
parents:
diff changeset
5478 if ( !_449B57_test_bit(pParty->_quest_bits, var_value) && pQuestTable[var_value-1] )
Ritor1
parents:
diff changeset
5479 {
Ritor1
parents:
diff changeset
5480 bFlashQuestBook = 1;
Ritor1
parents:
diff changeset
5481 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, GetPlayerIndex());
Ritor1
parents:
diff changeset
5482 PlayAwardSound();
Ritor1
parents:
diff changeset
5483 this->PlaySound(SPEECH_93, 0);
Ritor1
parents:
diff changeset
5484 }
Ritor1
parents:
diff changeset
5485 _449B7E_toggle_bit(pParty->_quest_bits, var_value, 1u);
Ritor1
parents:
diff changeset
5486 return;
Ritor1
parents:
diff changeset
5487 case VAR_PlayerItemInHands:
Ritor1
parents:
diff changeset
5488 item.Reset();
Ritor1
parents:
diff changeset
5489 item.uItemID = var_value;
Ritor1
parents:
diff changeset
5490 item.uAttributes = 1;
Ritor1
parents:
diff changeset
5491 pParty->SetHoldingItem(&item);
Ritor1
parents:
diff changeset
5492 if ( var_value >= ITEM_ARTIFACT_PUCK && var_value <= ITEM_RELIC_MEKORIGS_HAMMER )
Ritor1
parents:
diff changeset
5493 pParty->pIsArtifactFound[var_value-500] = 1;
Ritor1
parents:
diff changeset
5494 return;
Ritor1
parents:
diff changeset
5495 case VAR_FixedGold:
Ritor1
parents:
diff changeset
5496 Party::SetGold(var_value);
Ritor1
parents:
diff changeset
5497 return;
Ritor1
parents:
diff changeset
5498 case VAR_RandomGold:
Ritor1
parents:
diff changeset
5499 v6 = rand() % var_value + 1;
Ritor1
parents:
diff changeset
5500 Party::SetGold(v6);
Ritor1
parents:
diff changeset
5501 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[500], v6);// You have %lu gold
Ritor1
parents:
diff changeset
5502 ShowStatusBarString(pTmpBuf.data(), 2u);
Ritor1
parents:
diff changeset
5503 GameUI_DrawFoodAndGold();
Ritor1
parents:
diff changeset
5504 return;
Ritor1
parents:
diff changeset
5505 case VAR_FixedFood:
Ritor1
parents:
diff changeset
5506 Party::SetFood(var_value);
Ritor1
parents:
diff changeset
5507 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5508 return;
Ritor1
parents:
diff changeset
5509 case VAR_RandomFood:
Ritor1
parents:
diff changeset
5510 v7 = rand() % var_value + 1;
Ritor1
parents:
diff changeset
5511 Party::SetFood(v7);
Ritor1
parents:
diff changeset
5512 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], v7);// You have %lu food
Ritor1
parents:
diff changeset
5513 ShowStatusBarString(pTmpBuf.data(), 2u);
Ritor1
parents:
diff changeset
5514 GameUI_DrawFoodAndGold();
Ritor1
parents:
diff changeset
5515 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5516 return;
Ritor1
parents:
diff changeset
5517 case VAR_BaseMight:
Ritor1
parents:
diff changeset
5518 this->uMight = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5519 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5520 return;
Ritor1
parents:
diff changeset
5521 case VAR_BaseIntellect:
Ritor1
parents:
diff changeset
5522 this->uIntelligence = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5523 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5524 return;
Ritor1
parents:
diff changeset
5525 case VAR_BasePersonality:
Ritor1
parents:
diff changeset
5526 this->uWillpower = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5527 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5528 return;
Ritor1
parents:
diff changeset
5529 case VAR_BaseEndurance:
Ritor1
parents:
diff changeset
5530 this->uEndurance = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5531 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5532 return;
Ritor1
parents:
diff changeset
5533 case VAR_BaseSpeed:
Ritor1
parents:
diff changeset
5534 this->uSpeed = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5535 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5536 return;
Ritor1
parents:
diff changeset
5537 case VAR_BaseAccuracy:
Ritor1
parents:
diff changeset
5538 this->uAccuracy = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5539 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5540 return;
Ritor1
parents:
diff changeset
5541 case VAR_BaseLuck:
Ritor1
parents:
diff changeset
5542 this->uLuck = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5543 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5544 return;
Ritor1
parents:
diff changeset
5545 case VAR_MightBonus:
Ritor1
parents:
diff changeset
5546 case VAR_ActualMight:
Ritor1
parents:
diff changeset
5547 this->uMightBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5548 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5549 return;
Ritor1
parents:
diff changeset
5550 case VAR_IntellectBonus:
Ritor1
parents:
diff changeset
5551 case VAR_ActualIntellect:
Ritor1
parents:
diff changeset
5552 this->uIntelligenceBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5553 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5554 return;
Ritor1
parents:
diff changeset
5555 case VAR_PersonalityBonus:
Ritor1
parents:
diff changeset
5556 case VAR_ActualPersonality:
Ritor1
parents:
diff changeset
5557 this->uWillpowerBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5558 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5559 return;
Ritor1
parents:
diff changeset
5560 case VAR_EnduranceBonus:
Ritor1
parents:
diff changeset
5561 case VAR_ActualEndurance:
Ritor1
parents:
diff changeset
5562 this->uEnduranceBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5563 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5564 return;
Ritor1
parents:
diff changeset
5565 case VAR_SpeedBonus:
Ritor1
parents:
diff changeset
5566 case VAR_ActualSpeed:
Ritor1
parents:
diff changeset
5567 this->uSpeedBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5568 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5569 return;
Ritor1
parents:
diff changeset
5570 case VAR_AccuracyBonus:
Ritor1
parents:
diff changeset
5571 case VAR_ActualAccuracy:
Ritor1
parents:
diff changeset
5572 this->uAccuracyBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5573 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5574 return;
Ritor1
parents:
diff changeset
5575 case VAR_LuckBonus:
Ritor1
parents:
diff changeset
5576 case VAR_ActualLuck:
Ritor1
parents:
diff changeset
5577 this->uLuckBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5578 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5579 return;
Ritor1
parents:
diff changeset
5580 case VAR_FireResistance:
Ritor1
parents:
diff changeset
5581 this->sResFireBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5582 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5583 return;
Ritor1
parents:
diff changeset
5584 case VAR_AirResistance:
Ritor1
parents:
diff changeset
5585 this->sResAirBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5586 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5587 return;
Ritor1
parents:
diff changeset
5588 case VAR_WaterResistance:
Ritor1
parents:
diff changeset
5589 this->sResWaterBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5590 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5591 return;
Ritor1
parents:
diff changeset
5592 case VAR_EarthResistance:
Ritor1
parents:
diff changeset
5593 this->sResEarthBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5594 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5595 return;
Ritor1
parents:
diff changeset
5596 case VAR_SpiritResistance:
Ritor1
parents:
diff changeset
5597 this->sResSpiritBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5598 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5599 return;
Ritor1
parents:
diff changeset
5600 case VAR_MindResistance:
Ritor1
parents:
diff changeset
5601 this->sResMindBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5602 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5603 return;
Ritor1
parents:
diff changeset
5604 case VAR_BodyResistance:
Ritor1
parents:
diff changeset
5605 this->sResBodyBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5606 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5607 return;
Ritor1
parents:
diff changeset
5608 case VAR_LightResistance:
Ritor1
parents:
diff changeset
5609 this->sResLightBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5610 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5611 return;
Ritor1
parents:
diff changeset
5612 case VAR_DarkResistance:
Ritor1
parents:
diff changeset
5613 this->sResDarkBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5614 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5615 return;
Ritor1
parents:
diff changeset
5616 case VAR_MagicResistance:
Ritor1
parents:
diff changeset
5617 this->sResMagicBase = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5618 PlayAwardSound_Anim_Face(SPEECH_92);
Ritor1
parents:
diff changeset
5619 return;
Ritor1
parents:
diff changeset
5620 case VAR_FireResistanceBonus:
Ritor1
parents:
diff changeset
5621 this->sResFireBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5622 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5623 return;
Ritor1
parents:
diff changeset
5624 case VAR_AirResistanceBonus:
Ritor1
parents:
diff changeset
5625 this->sResAirBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5626 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5627 return;
Ritor1
parents:
diff changeset
5628 case VAR_WaterResistanceBonus:
Ritor1
parents:
diff changeset
5629 this->sResWaterBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5630 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5631 return;
Ritor1
parents:
diff changeset
5632 case VAR_EarthResistanceBonus:
Ritor1
parents:
diff changeset
5633 this->sResEarthBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5634 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5635 return;
Ritor1
parents:
diff changeset
5636 case VAR_SpiritResistanceBonus:
Ritor1
parents:
diff changeset
5637 this->sResSpiritBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5638 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5639 return;
Ritor1
parents:
diff changeset
5640 case VAR_MindResistanceBonus:
Ritor1
parents:
diff changeset
5641 this->sResMindBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5642 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5643 return;
Ritor1
parents:
diff changeset
5644 case VAR_BodyResistanceBonus:
Ritor1
parents:
diff changeset
5645 this->sResBodyBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5646 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5647 return;
Ritor1
parents:
diff changeset
5648 case VAR_LightResistanceBonus:
Ritor1
parents:
diff changeset
5649 this->sResLightBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5650 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5651 return;
Ritor1
parents:
diff changeset
5652 case VAR_DarkResistanceBonus:
Ritor1
parents:
diff changeset
5653 this->sResDarkBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5654 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5655 return;
Ritor1
parents:
diff changeset
5656 case VAR_PhysicalResistanceBonus:
Ritor1
parents:
diff changeset
5657 Error("Physical res. bonus not used");
Ritor1
parents:
diff changeset
5658 return;
Ritor1
parents:
diff changeset
5659 case VAR_MagicResistanceBonus:
Ritor1
parents:
diff changeset
5660 this->sResMagicBonus = (unsigned __int8)var_value;
Ritor1
parents:
diff changeset
5661 PlayAwardSound_Anim_Face(SPEECH_91);
Ritor1
parents:
diff changeset
5662 return;
Ritor1
parents:
diff changeset
5663 case VAR_Cursed:
Ritor1
parents:
diff changeset
5664 this->SetCondition(Condition_Cursed, 1);
Ritor1
parents:
diff changeset
5665 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5666 return;
Ritor1
parents:
diff changeset
5667 case VAR_Weak:
Ritor1
parents:
diff changeset
5668 this->SetCondition(Condition_Weak, 1);
Ritor1
parents:
diff changeset
5669 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5670 return;
Ritor1
parents:
diff changeset
5671 case VAR_Asleep:
Ritor1
parents:
diff changeset
5672 this->SetCondition(Condition_Sleep, 1);
Ritor1
parents:
diff changeset
5673 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5674 return;
Ritor1
parents:
diff changeset
5675 case VAR_Afraid:
Ritor1
parents:
diff changeset
5676 this->SetCondition(Condition_Fear, 1);
Ritor1
parents:
diff changeset
5677 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5678 return;
Ritor1
parents:
diff changeset
5679 case VAR_Drunk:
Ritor1
parents:
diff changeset
5680 this->SetCondition(Condition_Drunk, 1);
Ritor1
parents:
diff changeset
5681 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5682 return;
Ritor1
parents:
diff changeset
5683 case VAR_Insane:
Ritor1
parents:
diff changeset
5684 this->SetCondition(Condition_Insane, 1);
Ritor1
parents:
diff changeset
5685 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5686 return;
Ritor1
parents:
diff changeset
5687 case VAR_PoisonedGreen:
Ritor1
parents:
diff changeset
5688 this->SetCondition(Condition_Poison_Weak, 1);
Ritor1
parents:
diff changeset
5689 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5690 return;
Ritor1
parents:
diff changeset
5691 case VAR_DiseasedGreen:
Ritor1
parents:
diff changeset
5692 this->SetCondition(Condition_Disease_Weak, 1);
Ritor1
parents:
diff changeset
5693 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5694 return;
Ritor1
parents:
diff changeset
5695 case VAR_PoisonedYellow:
Ritor1
parents:
diff changeset
5696 this->SetCondition(Condition_Poison_Medium, 1);
Ritor1
parents:
diff changeset
5697 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5698 return;
Ritor1
parents:
diff changeset
5699 case VAR_DiseasedYellow:
Ritor1
parents:
diff changeset
5700 this->SetCondition(Condition_Disease_Medium, 1);
Ritor1
parents:
diff changeset
5701 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5702 return;
Ritor1
parents:
diff changeset
5703 case VAR_PoisonedRed:
Ritor1
parents:
diff changeset
5704 this->SetCondition(Condition_Poison_Severe, 1);
Ritor1
parents:
diff changeset
5705 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5706 return;
Ritor1
parents:
diff changeset
5707 case VAR_DiseasedRed:
Ritor1
parents:
diff changeset
5708 this->SetCondition(Condition_Disease_Severe, 1);
Ritor1
parents:
diff changeset
5709 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5710 return;
Ritor1
parents:
diff changeset
5711 case VAR_Paralyzed:
Ritor1
parents:
diff changeset
5712 this->SetCondition(Condition_Paralyzed, 1);
Ritor1
parents:
diff changeset
5713 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5714 return;
Ritor1
parents:
diff changeset
5715 case VAR_Unconsious:
Ritor1
parents:
diff changeset
5716 this->SetCondition(Condition_Unconcious, 1);
Ritor1
parents:
diff changeset
5717 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5718 return;
Ritor1
parents:
diff changeset
5719 case VAR_Dead:
Ritor1
parents:
diff changeset
5720 this->SetCondition(Condition_Dead, 1);
Ritor1
parents:
diff changeset
5721 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5722 return;
Ritor1
parents:
diff changeset
5723 case VAR_Stoned:
Ritor1
parents:
diff changeset
5724 this->SetCondition(Condition_Pertified, 1);
Ritor1
parents:
diff changeset
5725 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5726 return;
Ritor1
parents:
diff changeset
5727 case VAR_Eradicated:
Ritor1
parents:
diff changeset
5728 this->SetCondition(Condition_Eradicated, 1);
Ritor1
parents:
diff changeset
5729 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5730 return;
Ritor1
parents:
diff changeset
5731 case VAR_MajorCondition:
Ritor1
parents:
diff changeset
5732 pConditions.fill(0);
Ritor1
parents:
diff changeset
5733 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5734 return;
Ritor1
parents:
diff changeset
5735 case VAR_AutoNotes:
Ritor1
parents:
diff changeset
5736 if ( !_449B57_test_bit(pParty->_autonote_bits, var_value) && pAutonoteTxt[var_value-1].pText )
Ritor1
parents:
diff changeset
5737 {
Ritor1
parents:
diff changeset
5738 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, GetPlayerIndex());
Ritor1
parents:
diff changeset
5739 this->PlaySound(SPEECH_96, 0);
Ritor1
parents:
diff changeset
5740 bFlashAutonotesBook = 1;
Ritor1
parents:
diff changeset
5741 _506568_autonote_type = pAutonoteTxt[var_value-1].eType;// dword_72371C[2 * a3];
Ritor1
parents:
diff changeset
5742 }
Ritor1
parents:
diff changeset
5743 _449B7E_toggle_bit(pParty->_autonote_bits, var_value, 1u);
Ritor1
parents:
diff changeset
5744 PlayAwardSound();
Ritor1
parents:
diff changeset
5745 return;
Ritor1
parents:
diff changeset
5746 case VAR_PlayerBits:
Ritor1
parents:
diff changeset
5747 _449B7E_toggle_bit((unsigned char *)playerEventBits, var_value, 1u);
Ritor1
parents:
diff changeset
5748 return;
Ritor1
parents:
diff changeset
5749 case VAR_NPCs2:
Ritor1
parents:
diff changeset
5750 pParty->hirelingScrollPosition = 0;
Ritor1
parents:
diff changeset
5751 LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u;
Ritor1
parents:
diff changeset
5752 pParty->CountHirelings();
Ritor1
parents:
diff changeset
5753 viewparams->bRedrawGameUI = true;
Ritor1
parents:
diff changeset
5754 return;
Ritor1
parents:
diff changeset
5755 case VAR_NumSkillPoints:
Ritor1
parents:
diff changeset
5756 this->uSkillPoints = var_value;
Ritor1
parents:
diff changeset
5757 return;
Ritor1
parents:
diff changeset
5758 case VAR_Counter1:
Ritor1
parents:
diff changeset
5759 case VAR_Counter2:
Ritor1
parents:
diff changeset
5760 case VAR_Counter3:
Ritor1
parents:
diff changeset
5761 case VAR_Counter4:
Ritor1
parents:
diff changeset
5762 case VAR_Counter5:
Ritor1
parents:
diff changeset
5763 case VAR_Counter6:
Ritor1
parents:
diff changeset
5764 case VAR_Counter7:
Ritor1
parents:
diff changeset
5765 case VAR_Counter8:
Ritor1
parents:
diff changeset
5766 case VAR_Counter9:
Ritor1
parents:
diff changeset
5767 case VAR_Counter10:
Ritor1
parents:
diff changeset
5768 pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed; // *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed);*(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed);
Ritor1
parents:
diff changeset
5769 return;
Ritor1
parents:
diff changeset
5770 case VAR_ReputationInCurrentLocation:
Ritor1
parents:
diff changeset
5771 v24 = &pOutdoor->ddm;
Ritor1
parents:
diff changeset
5772 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
Ritor1
parents:
diff changeset
5773 v24 = &pIndoor->dlv;
Ritor1
parents:
diff changeset
5774 v24->uReputation = var_value;
Ritor1
parents:
diff changeset
5775 if ( var_value > 10000 )
Ritor1
parents:
diff changeset
5776 v24->uReputation = 10000;
Ritor1
parents:
diff changeset
5777 return;
Ritor1
parents:
diff changeset
5778 case VAR_GoldInBank:
Ritor1
parents:
diff changeset
5779 pParty->uNumGoldInBank = var_value;
Ritor1
parents:
diff changeset
5780 return;
Ritor1
parents:
diff changeset
5781 case VAR_NumDeaths:
Ritor1
parents:
diff changeset
5782 pParty->uNumDeaths = var_value;
Ritor1
parents:
diff changeset
5783 return;
Ritor1
parents:
diff changeset
5784 case VAR_NumBounties:
Ritor1
parents:
diff changeset
5785 pParty->uNumBountiesCollected = var_value;
Ritor1
parents:
diff changeset
5786 return;
Ritor1
parents:
diff changeset
5787 case VAR_PrisonTerms:
Ritor1
parents:
diff changeset
5788 pParty->uNumPrisonTerms = var_value;
Ritor1
parents:
diff changeset
5789 return;
Ritor1
parents:
diff changeset
5790 case VAR_ArenaWinsPage:
Ritor1
parents:
diff changeset
5791 pParty->uNumArenaPageWins = var_value;
Ritor1
parents:
diff changeset
5792 return;
Ritor1
parents:
diff changeset
5793 case VAR_ArenaWinsSquire:
Ritor1
parents:
diff changeset
5794 pParty->uNumArenaSquireWins = var_value;
Ritor1
parents:
diff changeset
5795 return;
Ritor1
parents:
diff changeset
5796 case VAR_ArenaWinsKnight:
Ritor1
parents:
diff changeset
5797 pParty->uNumArenaKnightWins = var_value;
Ritor1
parents:
diff changeset
5798 return;
Ritor1
parents:
diff changeset
5799 case VAR_ArenaWinsLord:
Ritor1
parents:
diff changeset
5800 pParty->uNumArenaLordWins = var_value;
Ritor1
parents:
diff changeset
5801 return;
Ritor1
parents:
diff changeset
5802 case VAR_StaffSkill:
Ritor1
parents:
diff changeset
5803 SetSkillByEvent(&Player::skillStaff, var_value);
Ritor1
parents:
diff changeset
5804 return;
Ritor1
parents:
diff changeset
5805 case VAR_SwordSkill:
Ritor1
parents:
diff changeset
5806 SetSkillByEvent(&Player::skillSword, var_value);
Ritor1
parents:
diff changeset
5807 return;
Ritor1
parents:
diff changeset
5808 case VAR_DaggerSkill:
Ritor1
parents:
diff changeset
5809 SetSkillByEvent(&Player::skillDagger, var_value);
Ritor1
parents:
diff changeset
5810 return;
Ritor1
parents:
diff changeset
5811 case VAR_AxeSkill:
Ritor1
parents:
diff changeset
5812 SetSkillByEvent(&Player::skillAxe, var_value);
Ritor1
parents:
diff changeset
5813 return;
Ritor1
parents:
diff changeset
5814 case VAR_SpearSkill:
Ritor1
parents:
diff changeset
5815 SetSkillByEvent(&Player::skillSpear, var_value);
Ritor1
parents:
diff changeset
5816 return;
Ritor1
parents:
diff changeset
5817 case VAR_BowSkill:
Ritor1
parents:
diff changeset
5818 SetSkillByEvent(&Player::skillBow, var_value);
Ritor1
parents:
diff changeset
5819 return;
Ritor1
parents:
diff changeset
5820 case VAR_MaceSkill:
Ritor1
parents:
diff changeset
5821 SetSkillByEvent(&Player::skillMace, var_value);
Ritor1
parents:
diff changeset
5822 return;
Ritor1
parents:
diff changeset
5823 case VAR_BlasterSkill:
Ritor1
parents:
diff changeset
5824 SetSkillByEvent(&Player::skillBlaster, var_value);
Ritor1
parents:
diff changeset
5825 return;
Ritor1
parents:
diff changeset
5826 case VAR_ShieldSkill:
Ritor1
parents:
diff changeset
5827 SetSkillByEvent(&Player::skillShield, var_value);
Ritor1
parents:
diff changeset
5828 return;
Ritor1
parents:
diff changeset
5829 case VAR_LeatherSkill:
Ritor1
parents:
diff changeset
5830 SetSkillByEvent(&Player::skillLeather, var_value);
Ritor1
parents:
diff changeset
5831 return;
Ritor1
parents:
diff changeset
5832 case VAR_SkillChain:
Ritor1
parents:
diff changeset
5833 SetSkillByEvent(&Player::skillChain, var_value);
Ritor1
parents:
diff changeset
5834 return;
Ritor1
parents:
diff changeset
5835 case VAR_PlateSkill:
Ritor1
parents:
diff changeset
5836 SetSkillByEvent(&Player::skillPlate, var_value);
Ritor1
parents:
diff changeset
5837 return;
Ritor1
parents:
diff changeset
5838 case VAR_FireSkill:
Ritor1
parents:
diff changeset
5839 SetSkillByEvent(&Player::skillFire, var_value);
Ritor1
parents:
diff changeset
5840 return;
Ritor1
parents:
diff changeset
5841 case VAR_AirSkill:
Ritor1
parents:
diff changeset
5842 SetSkillByEvent(&Player::skillAir, var_value);
Ritor1
parents:
diff changeset
5843 return;
Ritor1
parents:
diff changeset
5844 case VAR_WaterSkill:
Ritor1
parents:
diff changeset
5845 SetSkillByEvent(&Player::skillWater, var_value);
Ritor1
parents:
diff changeset
5846 return;
Ritor1
parents:
diff changeset
5847 case VAR_EarthSkill:
Ritor1
parents:
diff changeset
5848 SetSkillByEvent(&Player::skillEarth, var_value);
Ritor1
parents:
diff changeset
5849 return;
Ritor1
parents:
diff changeset
5850 case VAR_SpiritSkill:
Ritor1
parents:
diff changeset
5851 SetSkillByEvent(&Player::skillSpirit, var_value);
Ritor1
parents:
diff changeset
5852 return;
Ritor1
parents:
diff changeset
5853 case VAR_MindSkill:
Ritor1
parents:
diff changeset
5854 SetSkillByEvent(&Player::skillMind, var_value);
Ritor1
parents:
diff changeset
5855 return;
Ritor1
parents:
diff changeset
5856 case VAR_BodySkill:
Ritor1
parents:
diff changeset
5857 SetSkillByEvent(&Player::skillBody, var_value);
Ritor1
parents:
diff changeset
5858 return;
Ritor1
parents:
diff changeset
5859 case VAR_LightSkill:
Ritor1
parents:
diff changeset
5860 SetSkillByEvent(&Player::skillLight, var_value);
Ritor1
parents:
diff changeset
5861 return;
Ritor1
parents:
diff changeset
5862 case VAR_DarkSkill:
Ritor1
parents:
diff changeset
5863 SetSkillByEvent(&Player::skillDark, var_value);
Ritor1
parents:
diff changeset
5864 return;
Ritor1
parents:
diff changeset
5865 case VAR_IdentifyItemSkill:
Ritor1
parents:
diff changeset
5866 SetSkillByEvent(&Player::skillItemId, var_value);
Ritor1
parents:
diff changeset
5867 return;
Ritor1
parents:
diff changeset
5868 case VAR_MerchantSkill:
Ritor1
parents:
diff changeset
5869 SetSkillByEvent(&Player::skillMerchant, var_value);
Ritor1
parents:
diff changeset
5870 return;
Ritor1
parents:
diff changeset
5871 case VAR_RepairSkill:
Ritor1
parents:
diff changeset
5872 SetSkillByEvent(&Player::skillRepair, var_value);
Ritor1
parents:
diff changeset
5873 return;
Ritor1
parents:
diff changeset
5874 case VAR_BodybuildingSkill:
Ritor1
parents:
diff changeset
5875 SetSkillByEvent(&Player::skillBodybuilding, var_value);
Ritor1
parents:
diff changeset
5876 return;
Ritor1
parents:
diff changeset
5877 case VAR_MeditationSkill:
Ritor1
parents:
diff changeset
5878 SetSkillByEvent(&Player::skillMeditation, var_value);
Ritor1
parents:
diff changeset
5879 return;
Ritor1
parents:
diff changeset
5880 case VAR_PerceptionSkill:
Ritor1
parents:
diff changeset
5881 SetSkillByEvent(&Player::skillPerception, var_value);
Ritor1
parents:
diff changeset
5882 return;
Ritor1
parents:
diff changeset
5883 case VAR_DiplomacySkill:
Ritor1
parents:
diff changeset
5884 SetSkillByEvent(&Player::skillDiplomacy, var_value);
Ritor1
parents:
diff changeset
5885 return;
Ritor1
parents:
diff changeset
5886 case VAR_ThieverySkill:
Ritor1
parents:
diff changeset
5887 Error ("Thieving unsupported");
Ritor1
parents:
diff changeset
5888 return;
Ritor1
parents:
diff changeset
5889 case VAR_DisarmTrapSkill:
Ritor1
parents:
diff changeset
5890 SetSkillByEvent(&Player::skillDisarmTrap, var_value);
Ritor1
parents:
diff changeset
5891 return;
Ritor1
parents:
diff changeset
5892 case VAR_DodgeSkill:
Ritor1
parents:
diff changeset
5893 SetSkillByEvent(&Player::skillDodge, var_value);
Ritor1
parents:
diff changeset
5894 return;
Ritor1
parents:
diff changeset
5895 case VAR_UnarmedSkill:
Ritor1
parents:
diff changeset
5896 SetSkillByEvent(&Player::skillUnarmed, var_value);
Ritor1
parents:
diff changeset
5897 return;
Ritor1
parents:
diff changeset
5898 case VAR_IdentifyMonsterSkill:
Ritor1
parents:
diff changeset
5899 SetSkillByEvent(&Player::skillMonsterId, var_value);
Ritor1
parents:
diff changeset
5900 return;
Ritor1
parents:
diff changeset
5901 case VAR_ArmsmasterSkill:
Ritor1
parents:
diff changeset
5902 SetSkillByEvent(&Player::skillArmsmaster, var_value);
Ritor1
parents:
diff changeset
5903 return;
Ritor1
parents:
diff changeset
5904 case VAR_StealingSkill:
Ritor1
parents:
diff changeset
5905 SetSkillByEvent(&Player::skillStealing, var_value);
Ritor1
parents:
diff changeset
5906 return;
Ritor1
parents:
diff changeset
5907 case VAR_AlchemySkill:
Ritor1
parents:
diff changeset
5908 SetSkillByEvent(&Player::skillAlchemy, var_value);
Ritor1
parents:
diff changeset
5909 return;
Ritor1
parents:
diff changeset
5910 case VAR_LearningSkill:
Ritor1
parents:
diff changeset
5911 SetSkillByEvent(&Player::skillLearning, var_value);
Ritor1
parents:
diff changeset
5912 return;
Ritor1
parents:
diff changeset
5913 }
Ritor1
parents:
diff changeset
5914 }
Ritor1
parents:
diff changeset
5915
Ritor1
parents:
diff changeset
5916
Ritor1
parents:
diff changeset
5917 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
5918 void Player::PlayAwardSound()
Ritor1
parents:
diff changeset
5919 {
Ritor1
parents:
diff changeset
5920 int playerIndex = GetPlayerIndex();
Ritor1
parents:
diff changeset
5921 signed int v25 = 8 * playerIndex + 400;
Ritor1
parents:
diff changeset
5922 LOBYTE(v25) = PID(OBJECT_Player,playerIndex - 112);
Ritor1
parents:
diff changeset
5923 pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
5924 }
Ritor1
parents:
diff changeset
5925
Ritor1
parents:
diff changeset
5926 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
5927 void Player::PlayAwardSound_Anim()
Ritor1
parents:
diff changeset
5928 {
Ritor1
parents:
diff changeset
5929 int playerIndex = GetPlayerIndex();
Ritor1
parents:
diff changeset
5930 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, playerIndex);
Ritor1
parents:
diff changeset
5931 PlayAwardSound();
Ritor1
parents:
diff changeset
5932 }
Ritor1
parents:
diff changeset
5933
Ritor1
parents:
diff changeset
5934 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
5935 void Player::PlayAwardSound_Anim_Face( PlayerSpeech speech )
Ritor1
parents:
diff changeset
5936 {
Ritor1
parents:
diff changeset
5937 this->PlaySound(speech, 0);
Ritor1
parents:
diff changeset
5938 PlayAwardSound_Anim();
Ritor1
parents:
diff changeset
5939 }
Ritor1
parents:
diff changeset
5940
Ritor1
parents:
diff changeset
5941 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
5942 void Player::SetSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 skillValue )
Ritor1
parents:
diff changeset
5943 {
Ritor1
parents:
diff changeset
5944 unsigned __int16 currSkillValue = this->*skillToSet;
Ritor1
parents:
diff changeset
5945 if ( skillValue > 63 ) //the original had the condition reversed which was probably wrong
Ritor1
parents:
diff changeset
5946 {
Ritor1
parents:
diff changeset
5947 this->*skillToSet = skillValue | currSkillValue & 63;
Ritor1
parents:
diff changeset
5948 }
Ritor1
parents:
diff changeset
5949 else
Ritor1
parents:
diff changeset
5950 {
Ritor1
parents:
diff changeset
5951 this->*skillToSet = skillValue | currSkillValue & 0xC0;
Ritor1
parents:
diff changeset
5952 }
Ritor1
parents:
diff changeset
5953 int playerIndex = GetPlayerIndex();
Ritor1
parents:
diff changeset
5954 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, playerIndex);
Ritor1
parents:
diff changeset
5955 PlayAwardSound();
Ritor1
parents:
diff changeset
5956 }
Ritor1
parents:
diff changeset
5957
Ritor1
parents:
diff changeset
5958 //----- (0044AFFB) --------------------------------------------------------
Ritor1
parents:
diff changeset
5959 void Player::AddVariable(enum VariableType var_type, signed int val)
Ritor1
parents:
diff changeset
5960 {
Ritor1
parents:
diff changeset
5961 int v6; // eax@15
Ritor1
parents:
diff changeset
5962 unsigned int v7; // esi@18
Ritor1
parents:
diff changeset
5963 DDM_DLV_Header *v27; // eax@153
Ritor1
parents:
diff changeset
5964 ItemGen item; // [sp+Ch] [bp-2Ch]@45
Ritor1
parents:
diff changeset
5965
Ritor1
parents:
diff changeset
5966 if ( var_type >= VAR_Counter1 && var_type <= VAR_Counter10)
Ritor1
parents:
diff changeset
5967 {
Ritor1
parents:
diff changeset
5968 pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed;
Ritor1
parents:
diff changeset
5969 return;
Ritor1
parents:
diff changeset
5970 }
Ritor1
parents:
diff changeset
5971
Ritor1
parents:
diff changeset
5972 if ( var_type >= VAR_UnknownTimeEvent0 && var_type <= VAR_UnknownTimeEvent19 )
Ritor1
parents:
diff changeset
5973 {
Ritor1
parents:
diff changeset
5974 pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed;
Ritor1
parents:
diff changeset
5975 PlayAwardSound();
Ritor1
parents:
diff changeset
5976 return;
Ritor1
parents:
diff changeset
5977 }
Ritor1
parents:
diff changeset
5978
Ritor1
parents:
diff changeset
5979 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 )
Ritor1
parents:
diff changeset
5980 {
Ritor1
parents:
diff changeset
5981
Ritor1
parents:
diff changeset
5982 if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_74 )
Ritor1
parents:
diff changeset
5983 {
Ritor1
parents:
diff changeset
5984 if (255 - val > stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0])
Ritor1
parents:
diff changeset
5985 stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0] += val;
Ritor1
parents:
diff changeset
5986 else
Ritor1
parents:
diff changeset
5987 stru_5E4C90_MapPersistVars.field_0[var_type - VAR_MapPersistentVariable_0] = 255;
Ritor1
parents:
diff changeset
5988 }
Ritor1
parents:
diff changeset
5989 if ( (signed int)var_type >= VAR_MapPersistentVariable_75 && var_type <= VAR_MapPersistentVariable_99 )
Ritor1
parents:
diff changeset
5990 {
Ritor1
parents:
diff changeset
5991 if (255 - val > stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75])
Ritor1
parents:
diff changeset
5992 stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75] += val;
Ritor1
parents:
diff changeset
5993 else
Ritor1
parents:
diff changeset
5994 stru_5E4C90_MapPersistVars._decor_events[var_type - VAR_MapPersistentVariable_75] = 255;
Ritor1
parents:
diff changeset
5995 }
Ritor1
parents:
diff changeset
5996 return;
Ritor1
parents:
diff changeset
5997 }
Ritor1
parents:
diff changeset
5998
Ritor1
parents:
diff changeset
5999 if ( var_type >= VAR_History_0 && var_type <= VAR_History_28)
Ritor1
parents:
diff changeset
6000 {
Ritor1
parents:
diff changeset
6001 if (!pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0])
Ritor1
parents:
diff changeset
6002 {
Ritor1
parents:
diff changeset
6003 pParty->PartyTimes.HistoryEventTimes[var_type - VAR_History_0] = pParty->uTimePlayed;
Ritor1
parents:
diff changeset
6004 if (pStorylineText->StoreLine[var_type - VAR_History_0].pText = 0)
Ritor1
parents:
diff changeset
6005 {
Ritor1
parents:
diff changeset
6006 bFlashHistoryBook = 1;
Ritor1
parents:
diff changeset
6007 PlayAwardSound();
Ritor1
parents:
diff changeset
6008 }
Ritor1
parents:
diff changeset
6009 }
Ritor1
parents:
diff changeset
6010 return;
Ritor1
parents:
diff changeset
6011 }
Ritor1
parents:
diff changeset
6012
Ritor1
parents:
diff changeset
6013 switch ( var_type )
Ritor1
parents:
diff changeset
6014 {
Ritor1
parents:
diff changeset
6015 case VAR_RandomGold:
Ritor1
parents:
diff changeset
6016 if ( val == 0 )
Ritor1
parents:
diff changeset
6017 val = 1;
Ritor1
parents:
diff changeset
6018 v6 = rand();
Ritor1
parents:
diff changeset
6019 pParty->PartyFindsGold(v6 % val + 1, 1);
Ritor1
parents:
diff changeset
6020 GameUI_DrawFoodAndGold();
Ritor1
parents:
diff changeset
6021 return;
Ritor1
parents:
diff changeset
6022 case VAR_RandomFood:
Ritor1
parents:
diff changeset
6023 if ( val == 0 )
Ritor1
parents:
diff changeset
6024 val = 1;
Ritor1
parents:
diff changeset
6025 v7 = rand() % val + 1;
Ritor1
parents:
diff changeset
6026 Party::GiveFood(v7);
Ritor1
parents:
diff changeset
6027 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], v7);// You find %lu food
Ritor1
parents:
diff changeset
6028 ShowStatusBarString(pTmpBuf.data(), 2u);
Ritor1
parents:
diff changeset
6029 GameUI_DrawFoodAndGold();
Ritor1
parents:
diff changeset
6030 PlayAwardSound();
Ritor1
parents:
diff changeset
6031 return;
Ritor1
parents:
diff changeset
6032 case VAR_Sex:
Ritor1
parents:
diff changeset
6033 this->uSex = (PLAYER_SEX)val;
Ritor1
parents:
diff changeset
6034 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6035 return;
Ritor1
parents:
diff changeset
6036 case VAR_Class:
Ritor1
parents:
diff changeset
6037 this->classType = (PLAYER_CLASS_TYPE)val;
Ritor1
parents:
diff changeset
6038 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6039 return;
Ritor1
parents:
diff changeset
6040 case VAR_CurrentHP:
Ritor1
parents:
diff changeset
6041 this->sHealth = min(this->sHealth + val, this->GetMaxHealth() );
Ritor1
parents:
diff changeset
6042 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6043 return;
Ritor1
parents:
diff changeset
6044 case VAR_MaxHP:
Ritor1
parents:
diff changeset
6045 this->_health_related = 0;
Ritor1
parents:
diff changeset
6046 this->uFullHealthBonus = 0;
Ritor1
parents:
diff changeset
6047 this->sHealth = this->GetMaxHealth();
Ritor1
parents:
diff changeset
6048 return;
Ritor1
parents:
diff changeset
6049 case VAR_CurrentSP:
Ritor1
parents:
diff changeset
6050 this->sMana = min(this->sMana + val, this->GetMaxMana() );
Ritor1
parents:
diff changeset
6051 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6052 return;
Ritor1
parents:
diff changeset
6053 case VAR_MaxSP:
Ritor1
parents:
diff changeset
6054 this->_mana_related = 0;
Ritor1
parents:
diff changeset
6055 this->uFullManaBonus = 0;
Ritor1
parents:
diff changeset
6056 this->sMana = GetMaxMana();
Ritor1
parents:
diff changeset
6057 return;
Ritor1
parents:
diff changeset
6058 case VAR_ACModifier:
Ritor1
parents:
diff changeset
6059 this->sACModifier = min(this->sACModifier + val, 255);
Ritor1
parents:
diff changeset
6060 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6061 return;
Ritor1
parents:
diff changeset
6062 case VAR_BaseLevel:
Ritor1
parents:
diff changeset
6063 this->uLevel = min(this->uLevel + val, 255);
Ritor1
parents:
diff changeset
6064 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6065 return;
Ritor1
parents:
diff changeset
6066 case VAR_LevelModifier:
Ritor1
parents:
diff changeset
6067 this->sLevelModifier = min(this->sLevelModifier + val, 255);
Ritor1
parents:
diff changeset
6068 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6069 return;
Ritor1
parents:
diff changeset
6070 case VAR_Age:
Ritor1
parents:
diff changeset
6071 this->sAgeModifier += val;
Ritor1
parents:
diff changeset
6072 return;
Ritor1
parents:
diff changeset
6073 case VAR_Award:
Ritor1
parents:
diff changeset
6074 if (_449B57_test_bit(this->_achieved_awards_bits, val) && pAwards[val].pText )
Ritor1
parents:
diff changeset
6075 {
Ritor1
parents:
diff changeset
6076 PlayAwardSound_Anim97_Face(SPEECH_96);
Ritor1
parents:
diff changeset
6077 }
Ritor1
parents:
diff changeset
6078 _449B7E_toggle_bit(this->_achieved_awards_bits, val, 1);
Ritor1
parents:
diff changeset
6079 return;
Ritor1
parents:
diff changeset
6080 case VAR_Experience:
Ritor1
parents:
diff changeset
6081 this->uExperience = min(this->uExperience + val, 4000000000i64);
Ritor1
parents:
diff changeset
6082 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6083 return;
Ritor1
parents:
diff changeset
6084 case VAR_QBits_QuestsDone:
Ritor1
parents:
diff changeset
6085 if ( !_449B57_test_bit(pParty->_quest_bits, val) && pQuestTable[val] )
Ritor1
parents:
diff changeset
6086 {
Ritor1
parents:
diff changeset
6087 bFlashQuestBook = 1;
Ritor1
parents:
diff changeset
6088 PlayAwardSound_Anim97_Face(SPEECH_93);
Ritor1
parents:
diff changeset
6089 }
Ritor1
parents:
diff changeset
6090 _449B7E_toggle_bit(pParty->_quest_bits, val, 1);
Ritor1
parents:
diff changeset
6091 return;
Ritor1
parents:
diff changeset
6092 case VAR_PlayerItemInHands:
Ritor1
parents:
diff changeset
6093 item.Reset();
Ritor1
parents:
diff changeset
6094 item.uAttributes = 1;
Ritor1
parents:
diff changeset
6095 item.uItemID = val;
Ritor1
parents:
diff changeset
6096 if ( val >= ITEM_ARTIFACT_PUCK && val <= ITEM_RELIC_MEKORIGS_HAMMER )
Ritor1
parents:
diff changeset
6097 pParty->pIsArtifactFound[val-500] = 1;
Ritor1
parents:
diff changeset
6098 else if ( val >= ITEM_WAND_FIRE && val <= ITEM_WAND_INCENERATION )
Ritor1
parents:
diff changeset
6099 {
Ritor1
parents:
diff changeset
6100 item.uNumCharges = rand() % 6 + item.GetDamageMod() + 1;
Ritor1
parents:
diff changeset
6101 item.uMaxCharges = LOBYTE(item.uNumCharges);
Ritor1
parents:
diff changeset
6102 }
Ritor1
parents:
diff changeset
6103 pParty->SetHoldingItem(&item);
Ritor1
parents:
diff changeset
6104 return;
Ritor1
parents:
diff changeset
6105 case VAR_FixedGold:
Ritor1
parents:
diff changeset
6106 pParty->PartyFindsGold(val, 1);
Ritor1
parents:
diff changeset
6107 return;
Ritor1
parents:
diff changeset
6108 case VAR_BaseMight:
Ritor1
parents:
diff changeset
6109 this->uMight = min(this->uMight + val, 255);
Ritor1
parents:
diff changeset
6110 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6111 return;
Ritor1
parents:
diff changeset
6112 case VAR_BaseIntellect:
Ritor1
parents:
diff changeset
6113 this->uIntelligence = min(this->uIntelligence + val, 255);
Ritor1
parents:
diff changeset
6114 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6115 return;
Ritor1
parents:
diff changeset
6116 case VAR_BasePersonality:
Ritor1
parents:
diff changeset
6117 this->uWillpower = min(this->uWillpower + val, 255);
Ritor1
parents:
diff changeset
6118 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6119 return;
Ritor1
parents:
diff changeset
6120 case VAR_BaseEndurance:
Ritor1
parents:
diff changeset
6121 this->uEndurance = min(this->uEndurance + val, 255);
Ritor1
parents:
diff changeset
6122 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6123 return;
Ritor1
parents:
diff changeset
6124 case VAR_BaseSpeed:
Ritor1
parents:
diff changeset
6125 this->uSpeed = min(this->uSpeed + val, 255);
Ritor1
parents:
diff changeset
6126 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6127 return;
Ritor1
parents:
diff changeset
6128 case VAR_BaseAccuracy:
Ritor1
parents:
diff changeset
6129 this->uAccuracy = min(this->uAccuracy + val, 255);
Ritor1
parents:
diff changeset
6130 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6131 return;
Ritor1
parents:
diff changeset
6132 case VAR_BaseLuck:
Ritor1
parents:
diff changeset
6133 this->uLuck = min(this->uLuck + val, 255);
Ritor1
parents:
diff changeset
6134 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6135 return;
Ritor1
parents:
diff changeset
6136 case VAR_FixedFood:
Ritor1
parents:
diff changeset
6137 Party::GiveFood(val);
Ritor1
parents:
diff changeset
6138 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], val);
Ritor1
parents:
diff changeset
6139 ShowStatusBarString(pTmpBuf.data(), 2u);
Ritor1
parents:
diff changeset
6140 if ( pParty->uNumFoodRations > 0xFFFF )
Ritor1
parents:
diff changeset
6141 Party::SetFood(0xFFFFu);
Ritor1
parents:
diff changeset
6142 PlayAwardSound();
Ritor1
parents:
diff changeset
6143 return;
Ritor1
parents:
diff changeset
6144 case VAR_MightBonus:
Ritor1
parents:
diff changeset
6145 case VAR_ActualMight:
Ritor1
parents:
diff changeset
6146 this->uMightBonus = min(this->uMightBonus + val, 255);
Ritor1
parents:
diff changeset
6147 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6148 return;
Ritor1
parents:
diff changeset
6149 case VAR_IntellectBonus:
Ritor1
parents:
diff changeset
6150 case VAR_ActualIntellect:
Ritor1
parents:
diff changeset
6151 this->uIntelligenceBonus = min(this->uIntelligenceBonus + val, 255);
Ritor1
parents:
diff changeset
6152 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6153 return;
Ritor1
parents:
diff changeset
6154 case VAR_PersonalityBonus:
Ritor1
parents:
diff changeset
6155 case VAR_ActualPersonality:
Ritor1
parents:
diff changeset
6156 this->uWillpowerBonus = min(this->uWillpowerBonus + val, 255);
Ritor1
parents:
diff changeset
6157 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6158 return;
Ritor1
parents:
diff changeset
6159 case VAR_EnduranceBonus:
Ritor1
parents:
diff changeset
6160 case VAR_ActualEndurance:
Ritor1
parents:
diff changeset
6161 this->uEnduranceBonus = min(this->uEnduranceBonus + val, 255);
Ritor1
parents:
diff changeset
6162 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6163 return;
Ritor1
parents:
diff changeset
6164 case VAR_SpeedBonus:
Ritor1
parents:
diff changeset
6165 case VAR_ActualSpeed:
Ritor1
parents:
diff changeset
6166 this->uSpeedBonus = min(this->uSpeedBonus + val, 255);
Ritor1
parents:
diff changeset
6167 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6168 return;
Ritor1
parents:
diff changeset
6169 case VAR_AccuracyBonus:
Ritor1
parents:
diff changeset
6170 case VAR_ActualAccuracy:
Ritor1
parents:
diff changeset
6171 this->uAccuracyBonus = min(this->uAccuracyBonus + val, 255);
Ritor1
parents:
diff changeset
6172 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6173 return;
Ritor1
parents:
diff changeset
6174 case VAR_LuckBonus:
Ritor1
parents:
diff changeset
6175 case VAR_ActualLuck:
Ritor1
parents:
diff changeset
6176 this->uLuckBonus = min(this->uLuckBonus + val, 255);
Ritor1
parents:
diff changeset
6177 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6178 return;
Ritor1
parents:
diff changeset
6179 case VAR_FireResistance:
Ritor1
parents:
diff changeset
6180 this->sResFireBase = min(this->sResFireBase + val, 255);
Ritor1
parents:
diff changeset
6181 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6182 return;
Ritor1
parents:
diff changeset
6183 case VAR_AirResistance:
Ritor1
parents:
diff changeset
6184 this->sResAirBase = min(this->sResAirBase + val, 255);
Ritor1
parents:
diff changeset
6185 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6186 return;
Ritor1
parents:
diff changeset
6187 case VAR_WaterResistance:
Ritor1
parents:
diff changeset
6188 this->sResWaterBase = min(this->sResWaterBase + val, 255);
Ritor1
parents:
diff changeset
6189 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6190 return;
Ritor1
parents:
diff changeset
6191 case VAR_EarthResistance:
Ritor1
parents:
diff changeset
6192 this->sResEarthBase = min(this->sResEarthBase + val, 255);
Ritor1
parents:
diff changeset
6193 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6194 return;
Ritor1
parents:
diff changeset
6195 case VAR_SpiritResistance:
Ritor1
parents:
diff changeset
6196 this->sResSpiritBase = min(this->sResSpiritBase + val, 255);
Ritor1
parents:
diff changeset
6197 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6198 return;
Ritor1
parents:
diff changeset
6199 case VAR_MindResistance:
Ritor1
parents:
diff changeset
6200 this->sResMindBase = min(this->sResMindBase + val, 255);
Ritor1
parents:
diff changeset
6201 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6202 return;
Ritor1
parents:
diff changeset
6203 case VAR_BodyResistance:
Ritor1
parents:
diff changeset
6204 this->sResBodyBase = min(this->sResBodyBase + val, 255);
Ritor1
parents:
diff changeset
6205 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6206 return;
Ritor1
parents:
diff changeset
6207 case VAR_LightResistance:
Ritor1
parents:
diff changeset
6208 this->sResLightBase = min(this->sResLightBase + val, 255);
Ritor1
parents:
diff changeset
6209 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6210 return;
Ritor1
parents:
diff changeset
6211 case VAR_DarkResistance:
Ritor1
parents:
diff changeset
6212 this->sResDarkBase = min(this->sResDarkBase + val, 255);
Ritor1
parents:
diff changeset
6213 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6214 return;
Ritor1
parents:
diff changeset
6215 case VAR_MagicResistance:
Ritor1
parents:
diff changeset
6216 this->sResMagicBase = min(this->sResMagicBase + val, 255);
Ritor1
parents:
diff changeset
6217 PlayAwardSound_Anim97_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6218 return;
Ritor1
parents:
diff changeset
6219 case VAR_FireResistanceBonus:
Ritor1
parents:
diff changeset
6220 this->sResFireBonus = min(this->sResFireBonus + val, 255);
Ritor1
parents:
diff changeset
6221 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6222 return;
Ritor1
parents:
diff changeset
6223 case VAR_AirResistanceBonus:
Ritor1
parents:
diff changeset
6224 this->sResAirBonus = min(this->sResAirBonus + val, 255);
Ritor1
parents:
diff changeset
6225 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6226 return;
Ritor1
parents:
diff changeset
6227 case VAR_WaterResistanceBonus:
Ritor1
parents:
diff changeset
6228 this->sResWaterBonus = min(this->sResWaterBonus + val, 255);
Ritor1
parents:
diff changeset
6229 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6230 return;
Ritor1
parents:
diff changeset
6231 case VAR_EarthResistanceBonus:
Ritor1
parents:
diff changeset
6232 this->sResEarthBonus = min(this->sResEarthBonus + val, 255);
Ritor1
parents:
diff changeset
6233 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6234 return;
Ritor1
parents:
diff changeset
6235 case VAR_SpiritResistanceBonus:
Ritor1
parents:
diff changeset
6236 this->sResSpiritBonus = min(this->sResSpiritBonus + val, 255);
Ritor1
parents:
diff changeset
6237 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6238 return;
Ritor1
parents:
diff changeset
6239 case VAR_MindResistanceBonus:
Ritor1
parents:
diff changeset
6240 this->sResMindBonus = min(this->sResMindBonus + val, 255);
Ritor1
parents:
diff changeset
6241 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6242 return;
Ritor1
parents:
diff changeset
6243 case VAR_BodyResistanceBonus:
Ritor1
parents:
diff changeset
6244 this->sResBodyBonus = min(this->sResBodyBonus + val, 255);
Ritor1
parents:
diff changeset
6245 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6246 return;
Ritor1
parents:
diff changeset
6247 case VAR_LightResistanceBonus:
Ritor1
parents:
diff changeset
6248 this->sResLightBonus = min(this->sResLightBonus + val, 255);
Ritor1
parents:
diff changeset
6249 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6250 return;
Ritor1
parents:
diff changeset
6251 case VAR_DarkResistanceBonus:
Ritor1
parents:
diff changeset
6252 this->sResDarkBonus = min(this->sResDarkBonus + val, 255);
Ritor1
parents:
diff changeset
6253 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6254 return;
Ritor1
parents:
diff changeset
6255 case VAR_MagicResistanceBonus:
Ritor1
parents:
diff changeset
6256 this->sResMagicBonus = min(this->sResMagicBonus + val, 255);
Ritor1
parents:
diff changeset
6257 PlayAwardSound_Anim97_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6258 return;
Ritor1
parents:
diff changeset
6259 case VAR_Cursed:
Ritor1
parents:
diff changeset
6260 this->SetCondition(Condition_Cursed, 1);
Ritor1
parents:
diff changeset
6261 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6262 return;
Ritor1
parents:
diff changeset
6263 case VAR_Weak:
Ritor1
parents:
diff changeset
6264 this->SetCondition(Condition_Weak, 1);
Ritor1
parents:
diff changeset
6265 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6266 return;
Ritor1
parents:
diff changeset
6267 case VAR_Asleep:
Ritor1
parents:
diff changeset
6268 this->SetCondition(Condition_Sleep, 1);
Ritor1
parents:
diff changeset
6269 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6270 return;
Ritor1
parents:
diff changeset
6271 case VAR_Afraid:
Ritor1
parents:
diff changeset
6272 this->SetCondition(Condition_Fear, 1);
Ritor1
parents:
diff changeset
6273 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6274 return;
Ritor1
parents:
diff changeset
6275 case VAR_Drunk:
Ritor1
parents:
diff changeset
6276 this->SetCondition(Condition_Drunk, 1);
Ritor1
parents:
diff changeset
6277 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6278 return;
Ritor1
parents:
diff changeset
6279 case VAR_Insane:
Ritor1
parents:
diff changeset
6280 this->SetCondition(Condition_Insane, 1);
Ritor1
parents:
diff changeset
6281 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6282 return;
Ritor1
parents:
diff changeset
6283 case VAR_PoisonedGreen:
Ritor1
parents:
diff changeset
6284 this->SetCondition(Condition_Poison_Weak, 1);
Ritor1
parents:
diff changeset
6285 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6286 return;
Ritor1
parents:
diff changeset
6287 case VAR_DiseasedGreen:
Ritor1
parents:
diff changeset
6288 this->SetCondition(Condition_Disease_Weak, 1);
Ritor1
parents:
diff changeset
6289 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6290 return;
Ritor1
parents:
diff changeset
6291 case VAR_PoisonedYellow:
Ritor1
parents:
diff changeset
6292 this->SetCondition(Condition_Poison_Medium, 1);
Ritor1
parents:
diff changeset
6293 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6294 return;
Ritor1
parents:
diff changeset
6295 case VAR_DiseasedYellow:
Ritor1
parents:
diff changeset
6296 this->SetCondition(Condition_Disease_Medium, 1);
Ritor1
parents:
diff changeset
6297 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6298 return;
Ritor1
parents:
diff changeset
6299 case VAR_PoisonedRed:
Ritor1
parents:
diff changeset
6300 this->SetCondition(Condition_Poison_Severe, 1);
Ritor1
parents:
diff changeset
6301 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6302 return;
Ritor1
parents:
diff changeset
6303 case VAR_DiseasedRed:
Ritor1
parents:
diff changeset
6304 this->SetCondition(Condition_Disease_Severe, 1);
Ritor1
parents:
diff changeset
6305 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6306 return;
Ritor1
parents:
diff changeset
6307 case VAR_Paralyzed:
Ritor1
parents:
diff changeset
6308 this->SetCondition(Condition_Paralyzed, 1);
Ritor1
parents:
diff changeset
6309 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6310 return;
Ritor1
parents:
diff changeset
6311 case VAR_Unconsious:
Ritor1
parents:
diff changeset
6312 this->SetCondition(Condition_Unconcious, 1);
Ritor1
parents:
diff changeset
6313 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6314 return;
Ritor1
parents:
diff changeset
6315 case VAR_Dead:
Ritor1
parents:
diff changeset
6316 this->SetCondition(Condition_Dead, 1);
Ritor1
parents:
diff changeset
6317 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6318 return;
Ritor1
parents:
diff changeset
6319 case VAR_Stoned:
Ritor1
parents:
diff changeset
6320 this->SetCondition(Condition_Pertified, 1);
Ritor1
parents:
diff changeset
6321 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6322 return;
Ritor1
parents:
diff changeset
6323 case VAR_Eradicated:
Ritor1
parents:
diff changeset
6324 this->SetCondition(Condition_Eradicated, 1);
Ritor1
parents:
diff changeset
6325 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6326 return;
Ritor1
parents:
diff changeset
6327 case VAR_MajorCondition :
Ritor1
parents:
diff changeset
6328 pConditions.fill(0);
Ritor1
parents:
diff changeset
6329 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6330 return;
Ritor1
parents:
diff changeset
6331 case VAR_AutoNotes:
Ritor1
parents:
diff changeset
6332 if ( !_449B57_test_bit(pParty->_autonote_bits, val) && pAutonoteTxt[val].pText )
Ritor1
parents:
diff changeset
6333 {
Ritor1
parents:
diff changeset
6334 this->PlaySound(SPEECH_96, 0);
Ritor1
parents:
diff changeset
6335 bFlashAutonotesBook = 1;
Ritor1
parents:
diff changeset
6336 _506568_autonote_type = pAutonoteTxt[val].eType;
Ritor1
parents:
diff changeset
6337 pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, GetPlayerIndex());
Ritor1
parents:
diff changeset
6338 }
Ritor1
parents:
diff changeset
6339 _449B7E_toggle_bit(pParty->_autonote_bits, val, 1);
Ritor1
parents:
diff changeset
6340 PlayAwardSound();
Ritor1
parents:
diff changeset
6341 return;
Ritor1
parents:
diff changeset
6342 case VAR_PlayerBits:
Ritor1
parents:
diff changeset
6343 _449B7E_toggle_bit((unsigned char *)this->playerEventBits, val, 1u);
Ritor1
parents:
diff changeset
6344 return;
Ritor1
parents:
diff changeset
6345 case VAR_NPCs2:
Ritor1
parents:
diff changeset
6346 pParty->hirelingScrollPosition = 0;
Ritor1
parents:
diff changeset
6347 LOBYTE(pNPCStats->pNewNPCData[val].uFlags) |= 0x80u;
Ritor1
parents:
diff changeset
6348 pParty->CountHirelings();
Ritor1
parents:
diff changeset
6349 viewparams->bRedrawGameUI = true;
Ritor1
parents:
diff changeset
6350 return;
Ritor1
parents:
diff changeset
6351 case VAR_NumSkillPoints:
Ritor1
parents:
diff changeset
6352 this->uSkillPoints += val;
Ritor1
parents:
diff changeset
6353 return;
Ritor1
parents:
diff changeset
6354 case VAR_ReputationInCurrentLocation:
Ritor1
parents:
diff changeset
6355 v27 = &pOutdoor->ddm;
Ritor1
parents:
diff changeset
6356 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
Ritor1
parents:
diff changeset
6357 v27 = &pIndoor->dlv;
Ritor1
parents:
diff changeset
6358 v27->uReputation += val;
Ritor1
parents:
diff changeset
6359 if ( v27->uReputation > 10000 )
Ritor1
parents:
diff changeset
6360 v27->uReputation = 10000;
Ritor1
parents:
diff changeset
6361 return;
Ritor1
parents:
diff changeset
6362 case VAR_GoldInBank:
Ritor1
parents:
diff changeset
6363 pParty->uNumGoldInBank += val;
Ritor1
parents:
diff changeset
6364 return;
Ritor1
parents:
diff changeset
6365 case VAR_NumDeaths:
Ritor1
parents:
diff changeset
6366 pParty->uNumDeaths += val;
Ritor1
parents:
diff changeset
6367 return;
Ritor1
parents:
diff changeset
6368 case VAR_NumBounties:
Ritor1
parents:
diff changeset
6369 pParty->uNumBountiesCollected += val;
Ritor1
parents:
diff changeset
6370 return;
Ritor1
parents:
diff changeset
6371 case VAR_PrisonTerms:
Ritor1
parents:
diff changeset
6372 pParty->uNumPrisonTerms += val;
Ritor1
parents:
diff changeset
6373 return;
Ritor1
parents:
diff changeset
6374 case VAR_ArenaWinsPage:
Ritor1
parents:
diff changeset
6375 pParty->uNumArenaPageWins += val;
Ritor1
parents:
diff changeset
6376 return;
Ritor1
parents:
diff changeset
6377 case VAR_ArenaWinsSquire:
Ritor1
parents:
diff changeset
6378 pParty->uNumArenaSquireWins += val;
Ritor1
parents:
diff changeset
6379 return;
Ritor1
parents:
diff changeset
6380 case VAR_ArenaWinsKnight:
Ritor1
parents:
diff changeset
6381 pParty->uNumArenaKnightWins += val;
Ritor1
parents:
diff changeset
6382 return;
Ritor1
parents:
diff changeset
6383 case VAR_ArenaWinsLord:
Ritor1
parents:
diff changeset
6384 pParty->uNumArenaLordWins += val;
Ritor1
parents:
diff changeset
6385 return;
Ritor1
parents:
diff changeset
6386 case VAR_StaffSkill:
Ritor1
parents:
diff changeset
6387 AddSkillByEvent(&Player::skillStaff, val);
Ritor1
parents:
diff changeset
6388 return;
Ritor1
parents:
diff changeset
6389 case VAR_SwordSkill:
Ritor1
parents:
diff changeset
6390 AddSkillByEvent(&Player::skillSword, val);
Ritor1
parents:
diff changeset
6391 return;
Ritor1
parents:
diff changeset
6392 case VAR_DaggerSkill:
Ritor1
parents:
diff changeset
6393 AddSkillByEvent(&Player::skillDagger, val);
Ritor1
parents:
diff changeset
6394 return;
Ritor1
parents:
diff changeset
6395 case VAR_AxeSkill:
Ritor1
parents:
diff changeset
6396 AddSkillByEvent(&Player::skillAxe, val);
Ritor1
parents:
diff changeset
6397 return;
Ritor1
parents:
diff changeset
6398 case VAR_SpearSkill:
Ritor1
parents:
diff changeset
6399 AddSkillByEvent(&Player::skillSpear, val);
Ritor1
parents:
diff changeset
6400 return;
Ritor1
parents:
diff changeset
6401 case VAR_BowSkill:
Ritor1
parents:
diff changeset
6402 AddSkillByEvent(&Player::skillBow, val);
Ritor1
parents:
diff changeset
6403 return;
Ritor1
parents:
diff changeset
6404 case VAR_MaceSkill:
Ritor1
parents:
diff changeset
6405 AddSkillByEvent(&Player::skillMace, val);
Ritor1
parents:
diff changeset
6406 return;
Ritor1
parents:
diff changeset
6407 case VAR_BlasterSkill:
Ritor1
parents:
diff changeset
6408 AddSkillByEvent(&Player::skillBlaster, val);
Ritor1
parents:
diff changeset
6409 return;
Ritor1
parents:
diff changeset
6410 case VAR_ShieldSkill:
Ritor1
parents:
diff changeset
6411 AddSkillByEvent(&Player::skillShield, val);
Ritor1
parents:
diff changeset
6412 return;
Ritor1
parents:
diff changeset
6413 case VAR_LeatherSkill:
Ritor1
parents:
diff changeset
6414 AddSkillByEvent(&Player::skillLeather, val);
Ritor1
parents:
diff changeset
6415 return;
Ritor1
parents:
diff changeset
6416 case VAR_SkillChain:
Ritor1
parents:
diff changeset
6417 AddSkillByEvent(&Player::skillChain, val);
Ritor1
parents:
diff changeset
6418 return;
Ritor1
parents:
diff changeset
6419 case VAR_PlateSkill:
Ritor1
parents:
diff changeset
6420 AddSkillByEvent(&Player::skillPlate, val);
Ritor1
parents:
diff changeset
6421 return;
Ritor1
parents:
diff changeset
6422 case VAR_FireSkill:
Ritor1
parents:
diff changeset
6423 AddSkillByEvent(&Player::skillFire, val);
Ritor1
parents:
diff changeset
6424 return;
Ritor1
parents:
diff changeset
6425 case VAR_AirSkill:
Ritor1
parents:
diff changeset
6426 AddSkillByEvent(&Player::skillAir, val);
Ritor1
parents:
diff changeset
6427 return;
Ritor1
parents:
diff changeset
6428 case VAR_WaterSkill:
Ritor1
parents:
diff changeset
6429 AddSkillByEvent(&Player::skillWater, val);
Ritor1
parents:
diff changeset
6430 return;
Ritor1
parents:
diff changeset
6431 case VAR_EarthSkill:
Ritor1
parents:
diff changeset
6432 AddSkillByEvent(&Player::skillEarth, val);
Ritor1
parents:
diff changeset
6433 return;
Ritor1
parents:
diff changeset
6434 case VAR_SpiritSkill:
Ritor1
parents:
diff changeset
6435 AddSkillByEvent(&Player::skillSpirit, val);
Ritor1
parents:
diff changeset
6436 return;
Ritor1
parents:
diff changeset
6437 case VAR_MindSkill:
Ritor1
parents:
diff changeset
6438 AddSkillByEvent(&Player::skillMind, val);
Ritor1
parents:
diff changeset
6439 return;
Ritor1
parents:
diff changeset
6440 case VAR_BodySkill:
Ritor1
parents:
diff changeset
6441 AddSkillByEvent(&Player::skillBody, val);
Ritor1
parents:
diff changeset
6442 return;
Ritor1
parents:
diff changeset
6443 case VAR_LightSkill:
Ritor1
parents:
diff changeset
6444 AddSkillByEvent(&Player::skillLight, val);
Ritor1
parents:
diff changeset
6445 return;
Ritor1
parents:
diff changeset
6446 case VAR_DarkSkill:
Ritor1
parents:
diff changeset
6447 AddSkillByEvent(&Player::skillDark, val);
Ritor1
parents:
diff changeset
6448 return;
Ritor1
parents:
diff changeset
6449 case VAR_IdentifyItemSkill:
Ritor1
parents:
diff changeset
6450 AddSkillByEvent(&Player::skillItemId, val);
Ritor1
parents:
diff changeset
6451 return;
Ritor1
parents:
diff changeset
6452 case VAR_MerchantSkill:
Ritor1
parents:
diff changeset
6453 AddSkillByEvent(&Player::skillMerchant, val);
Ritor1
parents:
diff changeset
6454 return;
Ritor1
parents:
diff changeset
6455 case VAR_RepairSkill:
Ritor1
parents:
diff changeset
6456 AddSkillByEvent(&Player::skillRepair, val);
Ritor1
parents:
diff changeset
6457 return;
Ritor1
parents:
diff changeset
6458 case VAR_BodybuildingSkill:
Ritor1
parents:
diff changeset
6459 AddSkillByEvent(&Player::skillBodybuilding, val);
Ritor1
parents:
diff changeset
6460 return;
Ritor1
parents:
diff changeset
6461 case VAR_MeditationSkill:
Ritor1
parents:
diff changeset
6462 AddSkillByEvent(&Player::skillMeditation, val);
Ritor1
parents:
diff changeset
6463 return;
Ritor1
parents:
diff changeset
6464 case VAR_PerceptionSkill:
Ritor1
parents:
diff changeset
6465 AddSkillByEvent(&Player::skillPerception, val);
Ritor1
parents:
diff changeset
6466 return;
Ritor1
parents:
diff changeset
6467 case VAR_DiplomacySkill:
Ritor1
parents:
diff changeset
6468 AddSkillByEvent(&Player::skillDiplomacy, val);
Ritor1
parents:
diff changeset
6469 return;
Ritor1
parents:
diff changeset
6470 case VAR_ThieverySkill:
Ritor1
parents:
diff changeset
6471 Error ("Thieving unsupported");
Ritor1
parents:
diff changeset
6472 return;
Ritor1
parents:
diff changeset
6473 case VAR_DisarmTrapSkill:
Ritor1
parents:
diff changeset
6474 AddSkillByEvent(&Player::skillDisarmTrap, val);
Ritor1
parents:
diff changeset
6475 return;
Ritor1
parents:
diff changeset
6476 case VAR_DodgeSkill:
Ritor1
parents:
diff changeset
6477 AddSkillByEvent(&Player::skillDodge, val);
Ritor1
parents:
diff changeset
6478 return;
Ritor1
parents:
diff changeset
6479 case VAR_UnarmedSkill:
Ritor1
parents:
diff changeset
6480 AddSkillByEvent(&Player::skillUnarmed, val);
Ritor1
parents:
diff changeset
6481 return;
Ritor1
parents:
diff changeset
6482 case VAR_IdentifyMonsterSkill:
Ritor1
parents:
diff changeset
6483 AddSkillByEvent(&Player::skillMonsterId, val);
Ritor1
parents:
diff changeset
6484 return;
Ritor1
parents:
diff changeset
6485 case VAR_ArmsmasterSkill:
Ritor1
parents:
diff changeset
6486 AddSkillByEvent(&Player::skillArmsmaster, val);
Ritor1
parents:
diff changeset
6487 return;
Ritor1
parents:
diff changeset
6488 case VAR_StealingSkill:
Ritor1
parents:
diff changeset
6489 AddSkillByEvent(&Player::skillStealing, val);
Ritor1
parents:
diff changeset
6490 return;
Ritor1
parents:
diff changeset
6491 case VAR_AlchemySkill:
Ritor1
parents:
diff changeset
6492 AddSkillByEvent(&Player::skillAlchemy, val);
Ritor1
parents:
diff changeset
6493 return;
Ritor1
parents:
diff changeset
6494 case VAR_LearningSkill:
Ritor1
parents:
diff changeset
6495 AddSkillByEvent(&Player::skillLearning, val);
Ritor1
parents:
diff changeset
6496 return;
Ritor1
parents:
diff changeset
6497 default:
Ritor1
parents:
diff changeset
6498 return;
Ritor1
parents:
diff changeset
6499 }
Ritor1
parents:
diff changeset
6500 }
Ritor1
parents:
diff changeset
6501
Ritor1
parents:
diff changeset
6502 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
6503 void Player::PlayAwardSound_Anim97()
Ritor1
parents:
diff changeset
6504 {
Ritor1
parents:
diff changeset
6505 int playerIndex = GetPlayerIndex();
Ritor1
parents:
diff changeset
6506 pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, playerIndex);
Ritor1
parents:
diff changeset
6507 PlayAwardSound();
Ritor1
parents:
diff changeset
6508 }
Ritor1
parents:
diff changeset
6509
Ritor1
parents:
diff changeset
6510 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
6511 void Player::PlayAwardSound_Anim97_Face( PlayerSpeech speech )
Ritor1
parents:
diff changeset
6512 {
Ritor1
parents:
diff changeset
6513 this->PlaySound(speech, 0);
Ritor1
parents:
diff changeset
6514 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6515 }
Ritor1
parents:
diff changeset
6516
Ritor1
parents:
diff changeset
6517 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
6518 void Player::AddSkillByEvent( unsigned __int16 Player::* skillToSet, unsigned __int16 addSkillValue )
Ritor1
parents:
diff changeset
6519 {
Ritor1
parents:
diff changeset
6520 if ( addSkillValue > 63 )
Ritor1
parents:
diff changeset
6521 {
Ritor1
parents:
diff changeset
6522 this->*skillToSet = (unsigned __int8)addSkillValue | this->*skillToSet & 63;
Ritor1
parents:
diff changeset
6523 }
Ritor1
parents:
diff changeset
6524 else
Ritor1
parents:
diff changeset
6525 {
Ritor1
parents:
diff changeset
6526 this->*skillToSet = min(this->*skillToSet + addSkillValue, 60) | this->*skillToSet & 0xC0;
Ritor1
parents:
diff changeset
6527 }
Ritor1
parents:
diff changeset
6528 PlayAwardSound_Anim97();
Ritor1
parents:
diff changeset
6529 return;
Ritor1
parents:
diff changeset
6530 }
Ritor1
parents:
diff changeset
6531
Ritor1
parents:
diff changeset
6532 //----- (0044B9C4) --------------------------------------------------------
Ritor1
parents:
diff changeset
6533 void Player::SubtractVariable( enum VariableType VarNum, signed int pValue )
Ritor1
parents:
diff changeset
6534 {
Ritor1
parents:
diff changeset
6535 DDM_DLV_Header *locationHeader; // eax@90
Ritor1
parents:
diff changeset
6536 int randGold;
Ritor1
parents:
diff changeset
6537 int randFood;
Ritor1
parents:
diff changeset
6538 int npcIndex;
Ritor1
parents:
diff changeset
6539
Ritor1
parents:
diff changeset
6540 if ( VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_99 )
Ritor1
parents:
diff changeset
6541 {
Ritor1
parents:
diff changeset
6542 if ( VarNum >= VAR_MapPersistentVariable_0 && VarNum <= VAR_MapPersistentVariable_74 )
Ritor1
parents:
diff changeset
6543 {
Ritor1
parents:
diff changeset
6544 stru_5E4C90_MapPersistVars.field_0[VarNum - VAR_MapPersistentVariable_0] -= pValue;
Ritor1
parents:
diff changeset
6545 }
Ritor1
parents:
diff changeset
6546 if ( (signed int)VarNum >= VAR_MapPersistentVariable_75 && VarNum <= VAR_MapPersistentVariable_99 )
Ritor1
parents:
diff changeset
6547 {
Ritor1
parents:
diff changeset
6548 stru_5E4C90_MapPersistVars._decor_events[VarNum - VAR_MapPersistentVariable_75] -= pValue;
Ritor1
parents:
diff changeset
6549 }
Ritor1
parents:
diff changeset
6550 return;
Ritor1
parents:
diff changeset
6551 }
Ritor1
parents:
diff changeset
6552
Ritor1
parents:
diff changeset
6553 switch (VarNum)
Ritor1
parents:
diff changeset
6554 {
Ritor1
parents:
diff changeset
6555 case VAR_CurrentHP:
Ritor1
parents:
diff changeset
6556 ReceiveDamage((signed int)pValue, DMGT_PHISYCAL);
Ritor1
parents:
diff changeset
6557 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6558 return;
Ritor1
parents:
diff changeset
6559 case VAR_CurrentSP:
Ritor1
parents:
diff changeset
6560 this->sMana = max(this->sMana - pValue, 0);
Ritor1
parents:
diff changeset
6561 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6562 return;
Ritor1
parents:
diff changeset
6563 case VAR_ACModifier:
Ritor1
parents:
diff changeset
6564 this->sACModifier -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6565 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6566 return;
Ritor1
parents:
diff changeset
6567 case VAR_BaseLevel:
Ritor1
parents:
diff changeset
6568 this->uLevel -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6569 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6570 return;
Ritor1
parents:
diff changeset
6571 case VAR_LevelModifier:
Ritor1
parents:
diff changeset
6572 this->sLevelModifier -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6573 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6574 return;
Ritor1
parents:
diff changeset
6575 case VAR_Age:
Ritor1
parents:
diff changeset
6576 this->sAgeModifier -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6577 return;
Ritor1
parents:
diff changeset
6578 case VAR_Award:
Ritor1
parents:
diff changeset
6579 _449B7E_toggle_bit(this->_achieved_awards_bits, (signed __int16)pValue, 0);
Ritor1
parents:
diff changeset
6580 return;
Ritor1
parents:
diff changeset
6581 case VAR_Experience:
Ritor1
parents:
diff changeset
6582 this->uExperience -= pValue;
Ritor1
parents:
diff changeset
6583 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6584 return;
Ritor1
parents:
diff changeset
6585 case VAR_QBits_QuestsDone:
Ritor1
parents:
diff changeset
6586 _449B7E_toggle_bit(pParty->_quest_bits, (__int16)pValue, 0);
Ritor1
parents:
diff changeset
6587 this->PlaySound(SPEECH_96, 0);
Ritor1
parents:
diff changeset
6588 return;
Ritor1
parents:
diff changeset
6589 case VAR_PlayerItemInHands:
Ritor1
parents:
diff changeset
6590 for ( uint i = 0; i < 16; ++i )
Ritor1
parents:
diff changeset
6591 {
Ritor1
parents:
diff changeset
6592 int id_ = this->pEquipment.pIndices[i];
Ritor1
parents:
diff changeset
6593 if ( id_ > 0 )
Ritor1
parents:
diff changeset
6594 {
Ritor1
parents:
diff changeset
6595 if ( this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID == pValue )
Ritor1
parents:
diff changeset
6596 {
Ritor1
parents:
diff changeset
6597 this->pEquipment.pIndices[i] = 0;
Ritor1
parents:
diff changeset
6598 }
Ritor1
parents:
diff changeset
6599 }
Ritor1
parents:
diff changeset
6600 }
Ritor1
parents:
diff changeset
6601 for (int i = 0; i < 126; i++)
Ritor1
parents:
diff changeset
6602 {
Ritor1
parents:
diff changeset
6603 int id_ = this->pInventoryMatrix[i];
Ritor1
parents:
diff changeset
6604 if ( id_ > 0 )
Ritor1
parents:
diff changeset
6605 {
Ritor1
parents:
diff changeset
6606 if ( this->pInventoryItemList[id_ - 1].uItemID == pValue )
Ritor1
parents:
diff changeset
6607 {
Ritor1
parents:
diff changeset
6608 RemoveItemAtInventoryIndex(i);
Ritor1
parents:
diff changeset
6609 return;
Ritor1
parents:
diff changeset
6610 }
Ritor1
parents:
diff changeset
6611 }
Ritor1
parents:
diff changeset
6612 }
Ritor1
parents:
diff changeset
6613 if ( pParty->pPickedItem.uItemID == pValue )
Ritor1
parents:
diff changeset
6614 {
Ritor1
parents:
diff changeset
6615 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
6616 return;
Ritor1
parents:
diff changeset
6617 }
Ritor1
parents:
diff changeset
6618 return;
Ritor1
parents:
diff changeset
6619 case VAR_FixedGold:
Ritor1
parents:
diff changeset
6620 if ( (unsigned int)pValue > pParty->uNumGold )
Ritor1
parents:
diff changeset
6621 {
Ritor1
parents:
diff changeset
6622 dword_5B65C4_cancelEventProcessing = 1;
Ritor1
parents:
diff changeset
6623 return;
Ritor1
parents:
diff changeset
6624 }
Ritor1
parents:
diff changeset
6625 Party::TakeGold((unsigned int)pValue);
Ritor1
parents:
diff changeset
6626 return;
Ritor1
parents:
diff changeset
6627 case VAR_RandomGold:
Ritor1
parents:
diff changeset
6628 randGold = rand() % (signed int)pValue + 1;
Ritor1
parents:
diff changeset
6629 if ( (unsigned int)randGold > pParty->uNumGold )
Ritor1
parents:
diff changeset
6630 randGold = pParty->uNumGold;
Ritor1
parents:
diff changeset
6631 Party::TakeGold(randGold);
Ritor1
parents:
diff changeset
6632 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[503], randGold);
Ritor1
parents:
diff changeset
6633 ShowStatusBarString(pTmpBuf.data(), 2);
Ritor1
parents:
diff changeset
6634 GameUI_DrawFoodAndGold();
Ritor1
parents:
diff changeset
6635 return;
Ritor1
parents:
diff changeset
6636 case VAR_FixedFood:
Ritor1
parents:
diff changeset
6637 Party::TakeFood((unsigned int)pValue);
Ritor1
parents:
diff changeset
6638 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6639 return;
Ritor1
parents:
diff changeset
6640 case VAR_RandomFood:
Ritor1
parents:
diff changeset
6641 randFood = rand() % (signed int)pValue + 1;
Ritor1
parents:
diff changeset
6642 if ( (unsigned int)randFood > pParty->uNumFoodRations )
Ritor1
parents:
diff changeset
6643 randFood = pParty->uNumFoodRations;
Ritor1
parents:
diff changeset
6644 Party::TakeFood(randFood);
Ritor1
parents:
diff changeset
6645 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[504], randFood);
Ritor1
parents:
diff changeset
6646 ShowStatusBarString(pTmpBuf.data(), 2u);
Ritor1
parents:
diff changeset
6647 GameUI_DrawFoodAndGold();
Ritor1
parents:
diff changeset
6648 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6649 return;
Ritor1
parents:
diff changeset
6650 case VAR_MightBonus:
Ritor1
parents:
diff changeset
6651 case VAR_ActualMight:
Ritor1
parents:
diff changeset
6652 this->uMightBonus -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6653 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6654 return;
Ritor1
parents:
diff changeset
6655 case VAR_IntellectBonus:
Ritor1
parents:
diff changeset
6656 case VAR_ActualIntellect:
Ritor1
parents:
diff changeset
6657 this->uIntelligenceBonus -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6658 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6659 return;
Ritor1
parents:
diff changeset
6660 case VAR_PersonalityBonus:
Ritor1
parents:
diff changeset
6661 case VAR_ActualPersonality:
Ritor1
parents:
diff changeset
6662 this->uWillpowerBonus -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6663 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6664 return;
Ritor1
parents:
diff changeset
6665 case VAR_EnduranceBonus:
Ritor1
parents:
diff changeset
6666 case VAR_ActualEndurance:
Ritor1
parents:
diff changeset
6667 this->uEnduranceBonus -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6668 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6669 return;
Ritor1
parents:
diff changeset
6670 case VAR_SpeedBonus:
Ritor1
parents:
diff changeset
6671 case VAR_ActualSpeed:
Ritor1
parents:
diff changeset
6672 this->uSpeedBonus -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6673 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6674 return;
Ritor1
parents:
diff changeset
6675 case VAR_AccuracyBonus:
Ritor1
parents:
diff changeset
6676 case VAR_ActualAccuracy:
Ritor1
parents:
diff changeset
6677 this->uAccuracyBonus -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6678 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6679 return;
Ritor1
parents:
diff changeset
6680 case VAR_LuckBonus:
Ritor1
parents:
diff changeset
6681 case VAR_ActualLuck:
Ritor1
parents:
diff changeset
6682 this->uLuckBonus -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6683 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6684 return;
Ritor1
parents:
diff changeset
6685 case VAR_BaseMight:
Ritor1
parents:
diff changeset
6686 this->uMight -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6687 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6688 return;
Ritor1
parents:
diff changeset
6689 case VAR_BaseIntellect:
Ritor1
parents:
diff changeset
6690 this->uIntelligence -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6691 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6692 return;
Ritor1
parents:
diff changeset
6693 case VAR_BasePersonality:
Ritor1
parents:
diff changeset
6694 this->uWillpower -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6695 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6696 return;
Ritor1
parents:
diff changeset
6697 case VAR_BaseEndurance:
Ritor1
parents:
diff changeset
6698 this->uEndurance -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6699 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6700 return;
Ritor1
parents:
diff changeset
6701 case VAR_BaseSpeed:
Ritor1
parents:
diff changeset
6702 this->uSpeed -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6703 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6704 return;
Ritor1
parents:
diff changeset
6705 case VAR_BaseAccuracy:
Ritor1
parents:
diff changeset
6706 this->uAccuracy -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6707 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6708 return;
Ritor1
parents:
diff changeset
6709 case VAR_BaseLuck:
Ritor1
parents:
diff changeset
6710 this->uLuck -= (unsigned __int16)pValue;
Ritor1
parents:
diff changeset
6711 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6712 return;
Ritor1
parents:
diff changeset
6713 case VAR_FireResistance:
Ritor1
parents:
diff changeset
6714 this->sResFireBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6715 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6716 return;
Ritor1
parents:
diff changeset
6717 case VAR_AirResistance:
Ritor1
parents:
diff changeset
6718 this->sResAirBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6719 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6720 return;
Ritor1
parents:
diff changeset
6721 case VAR_WaterResistance:
Ritor1
parents:
diff changeset
6722 this->sResWaterBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6723 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6724 return;
Ritor1
parents:
diff changeset
6725 case VAR_EarthResistance:
Ritor1
parents:
diff changeset
6726 this->sResEarthBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6727 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6728 return;
Ritor1
parents:
diff changeset
6729 case VAR_SpiritResistance:
Ritor1
parents:
diff changeset
6730 this->sResSpiritBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6731 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6732 return;
Ritor1
parents:
diff changeset
6733 case VAR_MindResistance:
Ritor1
parents:
diff changeset
6734 this->sResMindBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6735 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6736 return;
Ritor1
parents:
diff changeset
6737 case VAR_BodyResistance:
Ritor1
parents:
diff changeset
6738 this->sResBodyBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6739 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6740 return;
Ritor1
parents:
diff changeset
6741 case VAR_LightResistance:
Ritor1
parents:
diff changeset
6742 this->sResLightBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6743 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6744 return;
Ritor1
parents:
diff changeset
6745 case VAR_DarkResistance:
Ritor1
parents:
diff changeset
6746 this->sResDarkBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6747 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6748 return;
Ritor1
parents:
diff changeset
6749 case VAR_MagicResistance:
Ritor1
parents:
diff changeset
6750 this->sResMagicBase -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6751 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6752 return;
Ritor1
parents:
diff changeset
6753 case VAR_FireResistanceBonus:
Ritor1
parents:
diff changeset
6754 this->sResFireBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6755 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6756 return;
Ritor1
parents:
diff changeset
6757 case VAR_AirResistanceBonus:
Ritor1
parents:
diff changeset
6758 this->sResAirBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6759 this->PlayAwardSound_Anim98_Face(SPEECH_92);
Ritor1
parents:
diff changeset
6760 return;
Ritor1
parents:
diff changeset
6761 case VAR_WaterResistanceBonus:
Ritor1
parents:
diff changeset
6762 this->sResWaterBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6763 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6764 return;
Ritor1
parents:
diff changeset
6765 case VAR_EarthResistanceBonus:
Ritor1
parents:
diff changeset
6766 this->sResEarthBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6767 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6768 return;
Ritor1
parents:
diff changeset
6769 case VAR_SpiritResistanceBonus:
Ritor1
parents:
diff changeset
6770 this->sResSpiritBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6771 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6772 return;
Ritor1
parents:
diff changeset
6773 case VAR_MindResistanceBonus:
Ritor1
parents:
diff changeset
6774 this->sResMindBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6775 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6776 return;
Ritor1
parents:
diff changeset
6777 case VAR_BodyResistanceBonus:
Ritor1
parents:
diff changeset
6778 this->sResBodyBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6779 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6780 return;
Ritor1
parents:
diff changeset
6781 case VAR_LightResistanceBonus:
Ritor1
parents:
diff changeset
6782 this->sResLightBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6783 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6784 return;
Ritor1
parents:
diff changeset
6785 case VAR_DarkResistanceBonus:
Ritor1
parents:
diff changeset
6786 this->sResDarkBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6787 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6788 return;
Ritor1
parents:
diff changeset
6789 case VAR_MagicResistanceBonus:
Ritor1
parents:
diff changeset
6790 this->sResMagicBonus -= (signed __int16)pValue;
Ritor1
parents:
diff changeset
6791 this->PlayAwardSound_Anim98_Face(SPEECH_91);
Ritor1
parents:
diff changeset
6792 return;
Ritor1
parents:
diff changeset
6793 case VAR_StaffSkill:
Ritor1
parents:
diff changeset
6794 this->skillStaff -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6795 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6796 return;
Ritor1
parents:
diff changeset
6797 case VAR_SwordSkill:
Ritor1
parents:
diff changeset
6798 this->skillSword -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6799 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6800 return;
Ritor1
parents:
diff changeset
6801 case VAR_DaggerSkill:
Ritor1
parents:
diff changeset
6802 this->skillDagger -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6803 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6804 return;
Ritor1
parents:
diff changeset
6805 case VAR_AxeSkill:
Ritor1
parents:
diff changeset
6806 this->skillAxe -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6807 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6808 return;
Ritor1
parents:
diff changeset
6809 case VAR_SpearSkill:
Ritor1
parents:
diff changeset
6810 this->skillSpear -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6811 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6812 return;
Ritor1
parents:
diff changeset
6813 case VAR_BowSkill:
Ritor1
parents:
diff changeset
6814 this->skillBow -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6815 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6816 return;
Ritor1
parents:
diff changeset
6817 case VAR_MaceSkill:
Ritor1
parents:
diff changeset
6818 this->skillMace -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6819 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6820 return;
Ritor1
parents:
diff changeset
6821 case VAR_BlasterSkill:
Ritor1
parents:
diff changeset
6822 this->skillBlaster -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6823 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6824 return;
Ritor1
parents:
diff changeset
6825 case VAR_ShieldSkill:
Ritor1
parents:
diff changeset
6826 this->skillShield -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6827 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6828 return;
Ritor1
parents:
diff changeset
6829 case VAR_LeatherSkill:
Ritor1
parents:
diff changeset
6830 this->skillLearning -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6831 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6832 return;
Ritor1
parents:
diff changeset
6833 case VAR_SkillChain:
Ritor1
parents:
diff changeset
6834 this->skillChain -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6835 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6836 return;
Ritor1
parents:
diff changeset
6837 case VAR_PlateSkill:
Ritor1
parents:
diff changeset
6838 this->skillPlate -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6839 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6840 return;
Ritor1
parents:
diff changeset
6841 case VAR_FireSkill:
Ritor1
parents:
diff changeset
6842 this->skillFire -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6843 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6844 return;
Ritor1
parents:
diff changeset
6845 case VAR_AirSkill:
Ritor1
parents:
diff changeset
6846 this->skillAir -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6847 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6848 return;
Ritor1
parents:
diff changeset
6849 case VAR_WaterSkill:
Ritor1
parents:
diff changeset
6850 this->skillWater -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6851 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6852 return;
Ritor1
parents:
diff changeset
6853 case VAR_EarthSkill:
Ritor1
parents:
diff changeset
6854 this->skillEarth -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6855 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6856 return;
Ritor1
parents:
diff changeset
6857 case VAR_SpiritSkill:
Ritor1
parents:
diff changeset
6858 this->skillSpirit -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6859 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6860 return;
Ritor1
parents:
diff changeset
6861 case VAR_MindSkill:
Ritor1
parents:
diff changeset
6862 this->skillMind -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6863 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6864 return;
Ritor1
parents:
diff changeset
6865 case VAR_BodySkill:
Ritor1
parents:
diff changeset
6866 this->skillBody -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6867 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6868 return;
Ritor1
parents:
diff changeset
6869 case VAR_LightSkill:
Ritor1
parents:
diff changeset
6870 this->skillLight -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6871 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6872 return;
Ritor1
parents:
diff changeset
6873 case VAR_DarkSkill:
Ritor1
parents:
diff changeset
6874 this->skillDark -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6875 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6876 return;
Ritor1
parents:
diff changeset
6877 case VAR_IdentifyItemSkill:
Ritor1
parents:
diff changeset
6878 this->skillItemId -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6879 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6880 return;
Ritor1
parents:
diff changeset
6881 case VAR_MerchantSkill:
Ritor1
parents:
diff changeset
6882 this->skillMerchant -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6883 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6884 return;
Ritor1
parents:
diff changeset
6885 case VAR_RepairSkill:
Ritor1
parents:
diff changeset
6886 this->skillRepair -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6887 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6888 return;
Ritor1
parents:
diff changeset
6889 case VAR_BodybuildingSkill:
Ritor1
parents:
diff changeset
6890 this->skillBodybuilding -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6891 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6892 return;
Ritor1
parents:
diff changeset
6893 case VAR_MeditationSkill:
Ritor1
parents:
diff changeset
6894 this->skillMeditation -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6895 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6896 return;
Ritor1
parents:
diff changeset
6897 case VAR_PerceptionSkill:
Ritor1
parents:
diff changeset
6898 this->skillPerception -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6899 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6900 return;
Ritor1
parents:
diff changeset
6901 case VAR_DiplomacySkill:
Ritor1
parents:
diff changeset
6902 this->skillDiplomacy -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6903 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6904 return;
Ritor1
parents:
diff changeset
6905 case VAR_ThieverySkill:
Ritor1
parents:
diff changeset
6906 Error ("Thieving unsupported");
Ritor1
parents:
diff changeset
6907 return;
Ritor1
parents:
diff changeset
6908 case VAR_DisarmTrapSkill:
Ritor1
parents:
diff changeset
6909 this->skillDisarmTrap -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6910 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6911 return;
Ritor1
parents:
diff changeset
6912 case VAR_DodgeSkill:
Ritor1
parents:
diff changeset
6913 this->skillDodge -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6914 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6915 return;
Ritor1
parents:
diff changeset
6916 case VAR_UnarmedSkill:
Ritor1
parents:
diff changeset
6917 this->skillUnarmed -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6918 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6919 return;
Ritor1
parents:
diff changeset
6920 case VAR_IdentifyMonsterSkill:
Ritor1
parents:
diff changeset
6921 this->skillMonsterId -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6922 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6923 return;
Ritor1
parents:
diff changeset
6924 case VAR_ArmsmasterSkill:
Ritor1
parents:
diff changeset
6925 this->skillArmsmaster -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6926 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6927 return;
Ritor1
parents:
diff changeset
6928 case VAR_StealingSkill:
Ritor1
parents:
diff changeset
6929 this->skillStealing -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6930 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6931 return;
Ritor1
parents:
diff changeset
6932 case VAR_AlchemySkill:
Ritor1
parents:
diff changeset
6933 this->skillAlchemy -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6934 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6935 return;
Ritor1
parents:
diff changeset
6936 case VAR_LearningSkill:
Ritor1
parents:
diff changeset
6937 this->skillLearning -= (unsigned __int8)pValue;
Ritor1
parents:
diff changeset
6938 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6939 return;
Ritor1
parents:
diff changeset
6940 case VAR_Cursed:
Ritor1
parents:
diff changeset
6941 this->pConditions[Condition_Cursed] = 0;
Ritor1
parents:
diff changeset
6942 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6943 return;
Ritor1
parents:
diff changeset
6944 case VAR_Weak:
Ritor1
parents:
diff changeset
6945 this->pConditions[Condition_Weak] = 0;
Ritor1
parents:
diff changeset
6946 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6947 return;
Ritor1
parents:
diff changeset
6948 case VAR_Asleep:
Ritor1
parents:
diff changeset
6949 this->pConditions[Condition_Sleep] = 0;
Ritor1
parents:
diff changeset
6950 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6951 return;
Ritor1
parents:
diff changeset
6952 case VAR_Afraid:
Ritor1
parents:
diff changeset
6953 this->pConditions[Condition_Fear] = 0;
Ritor1
parents:
diff changeset
6954 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6955 return;
Ritor1
parents:
diff changeset
6956 case VAR_Drunk:
Ritor1
parents:
diff changeset
6957 this->pConditions[Condition_Drunk] = 0;
Ritor1
parents:
diff changeset
6958 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6959 return;
Ritor1
parents:
diff changeset
6960 case VAR_Insane:
Ritor1
parents:
diff changeset
6961 this->pConditions[Condition_Insane] = 0;
Ritor1
parents:
diff changeset
6962 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6963 return;
Ritor1
parents:
diff changeset
6964 case VAR_PoisonedGreen:
Ritor1
parents:
diff changeset
6965 this->pConditions[Condition_Poison_Weak] = 0;
Ritor1
parents:
diff changeset
6966 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6967 return;
Ritor1
parents:
diff changeset
6968 case VAR_DiseasedGreen:
Ritor1
parents:
diff changeset
6969 this->pConditions[Condition_Disease_Weak] = 0;
Ritor1
parents:
diff changeset
6970 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6971 return;
Ritor1
parents:
diff changeset
6972 case VAR_PoisonedYellow:
Ritor1
parents:
diff changeset
6973 this->pConditions[Condition_Poison_Medium] = 0;
Ritor1
parents:
diff changeset
6974 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6975 return;
Ritor1
parents:
diff changeset
6976 case VAR_DiseasedYellow:
Ritor1
parents:
diff changeset
6977 this->pConditions[Condition_Disease_Medium] = 0;
Ritor1
parents:
diff changeset
6978 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6979 return;
Ritor1
parents:
diff changeset
6980 case VAR_PoisonedRed:
Ritor1
parents:
diff changeset
6981 this->pConditions[Condition_Poison_Severe] = 0;
Ritor1
parents:
diff changeset
6982 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6983 return;
Ritor1
parents:
diff changeset
6984 case VAR_DiseasedRed:
Ritor1
parents:
diff changeset
6985 this->pConditions[Condition_Disease_Severe] = 0;
Ritor1
parents:
diff changeset
6986 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6987 return;
Ritor1
parents:
diff changeset
6988 case VAR_Paralyzed:
Ritor1
parents:
diff changeset
6989 this->pConditions[Condition_Paralyzed] = 0;
Ritor1
parents:
diff changeset
6990 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6991 return;
Ritor1
parents:
diff changeset
6992 case VAR_Unconsious:
Ritor1
parents:
diff changeset
6993 this->pConditions[Condition_Unconcious] = 0;
Ritor1
parents:
diff changeset
6994 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6995 return;
Ritor1
parents:
diff changeset
6996 case VAR_Dead:
Ritor1
parents:
diff changeset
6997 this->pConditions[Condition_Dead] = 0;
Ritor1
parents:
diff changeset
6998 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
6999 return;
Ritor1
parents:
diff changeset
7000 case VAR_Stoned:
Ritor1
parents:
diff changeset
7001 this->pConditions[Condition_Pertified] = 0;
Ritor1
parents:
diff changeset
7002 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
7003 return;
Ritor1
parents:
diff changeset
7004 case VAR_Eradicated:
Ritor1
parents:
diff changeset
7005 this->pConditions[Condition_Eradicated] = 0;
Ritor1
parents:
diff changeset
7006 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
7007 return;
Ritor1
parents:
diff changeset
7008 case VAR_AutoNotes:
Ritor1
parents:
diff changeset
7009 _449B7E_toggle_bit(pParty->_autonote_bits, pValue - 1, 0);
Ritor1
parents:
diff changeset
7010 return;
Ritor1
parents:
diff changeset
7011 case VAR_NPCs2:
Ritor1
parents:
diff changeset
7012 npcIndex = 0;
Ritor1
parents:
diff changeset
7013 GetNewNPCData(sDialogue_SpeakingActorNPC_ID, &npcIndex);
Ritor1
parents:
diff changeset
7014 if ( npcIndex == pValue )
Ritor1
parents:
diff changeset
7015 {
Ritor1
parents:
diff changeset
7016 npcIdToDismissAfterDialogue = pValue;
Ritor1
parents:
diff changeset
7017 }
Ritor1
parents:
diff changeset
7018 else
Ritor1
parents:
diff changeset
7019 {
Ritor1
parents:
diff changeset
7020 npcIdToDismissAfterDialogue = 0;
Ritor1
parents:
diff changeset
7021 pParty->hirelingScrollPosition = 0;
Ritor1
parents:
diff changeset
7022 LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu;
Ritor1
parents:
diff changeset
7023 pParty->CountHirelings();
Ritor1
parents:
diff changeset
7024 viewparams->bRedrawGameUI = true;
Ritor1
parents:
diff changeset
7025 }
Ritor1
parents:
diff changeset
7026 return;
Ritor1
parents:
diff changeset
7027 case VAR_HiredNPCHasSpeciality:
Ritor1
parents:
diff changeset
7028 for (unsigned int i = 0; i < pNPCStats->uNumNewNPCs; i++)
Ritor1
parents:
diff changeset
7029 {
Ritor1
parents:
diff changeset
7030 if (pNPCStats->pNewNPCData[i].uProfession == pValue)
Ritor1
parents:
diff changeset
7031 {
Ritor1
parents:
diff changeset
7032 LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu;
Ritor1
parents:
diff changeset
7033 }
Ritor1
parents:
diff changeset
7034 }
Ritor1
parents:
diff changeset
7035 if ( pParty->pHirelings[0].uProfession == pValue )
Ritor1
parents:
diff changeset
7036 memset(&pParty->pHirelings[0], 0, sizeof(NPCData));
Ritor1
parents:
diff changeset
7037 if ( pParty->pHirelings[1].uProfession == pValue )
Ritor1
parents:
diff changeset
7038 memset(&pParty->pHirelings[1], 0, sizeof(NPCData));
Ritor1
parents:
diff changeset
7039 pParty->hirelingScrollPosition = 0;
Ritor1
parents:
diff changeset
7040 pParty->CountHirelings();
Ritor1
parents:
diff changeset
7041 return;
Ritor1
parents:
diff changeset
7042 case VAR_NumSkillPoints:
Ritor1
parents:
diff changeset
7043 if ((unsigned int)pValue <= this->uSkillPoints)
Ritor1
parents:
diff changeset
7044 {
Ritor1
parents:
diff changeset
7045 this->uSkillPoints -= pValue;
Ritor1
parents:
diff changeset
7046 }
Ritor1
parents:
diff changeset
7047 else
Ritor1
parents:
diff changeset
7048 {
Ritor1
parents:
diff changeset
7049 this->uSkillPoints = 0;
Ritor1
parents:
diff changeset
7050 }
Ritor1
parents:
diff changeset
7051 return;
Ritor1
parents:
diff changeset
7052 case VAR_ReputationInCurrentLocation:
Ritor1
parents:
diff changeset
7053 locationHeader = &pOutdoor->ddm;
Ritor1
parents:
diff changeset
7054 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
Ritor1
parents:
diff changeset
7055 locationHeader = &pIndoor->dlv;
Ritor1
parents:
diff changeset
7056 locationHeader->uReputation -= pValue;
Ritor1
parents:
diff changeset
7057 if (locationHeader->uReputation < -10000)
Ritor1
parents:
diff changeset
7058 locationHeader->uReputation = -10000;
Ritor1
parents:
diff changeset
7059 return;
Ritor1
parents:
diff changeset
7060 case VAR_GoldInBank:
Ritor1
parents:
diff changeset
7061 if ( (unsigned int)pValue <= pParty->uNumGoldInBank )
Ritor1
parents:
diff changeset
7062 {
Ritor1
parents:
diff changeset
7063 pParty->uNumGoldInBank -= (unsigned int)pValue;
Ritor1
parents:
diff changeset
7064 }
Ritor1
parents:
diff changeset
7065 else
Ritor1
parents:
diff changeset
7066 {
Ritor1
parents:
diff changeset
7067 dword_5B65C4_cancelEventProcessing = 1;
Ritor1
parents:
diff changeset
7068 }
Ritor1
parents:
diff changeset
7069 return;
Ritor1
parents:
diff changeset
7070 case VAR_NumDeaths:
Ritor1
parents:
diff changeset
7071 pParty->uNumDeaths -= (unsigned int)pValue;
Ritor1
parents:
diff changeset
7072 return;
Ritor1
parents:
diff changeset
7073 case VAR_NumBounties:
Ritor1
parents:
diff changeset
7074 pParty->uNumBountiesCollected -= (unsigned int)pValue;
Ritor1
parents:
diff changeset
7075 return;
Ritor1
parents:
diff changeset
7076 case VAR_PrisonTerms:
Ritor1
parents:
diff changeset
7077 pParty->uNumPrisonTerms -= (int)pValue;
Ritor1
parents:
diff changeset
7078 return;
Ritor1
parents:
diff changeset
7079 case VAR_ArenaWinsPage:
Ritor1
parents:
diff changeset
7080 pParty->uNumArenaPageWins -= (char)pValue;
Ritor1
parents:
diff changeset
7081 return;
Ritor1
parents:
diff changeset
7082 case VAR_ArenaWinsSquire:
Ritor1
parents:
diff changeset
7083 pParty->uNumArenaSquireWins -= (char)pValue;
Ritor1
parents:
diff changeset
7084 return;
Ritor1
parents:
diff changeset
7085 case VAR_ArenaWinsKnight:
Ritor1
parents:
diff changeset
7086 pParty->uNumArenaKnightWins -= (char)pValue;
Ritor1
parents:
diff changeset
7087 return;
Ritor1
parents:
diff changeset
7088 case VAR_ArenaWinsLord:
Ritor1
parents:
diff changeset
7089 pParty->uNumArenaLordWins -= (char)pValue;
Ritor1
parents:
diff changeset
7090 return;
Ritor1
parents:
diff changeset
7091 }
Ritor1
parents:
diff changeset
7092 }
Ritor1
parents:
diff changeset
7093 // 5B65C4: using guessed type int dword_5B65C4;
Ritor1
parents:
diff changeset
7094 // 5B65CC: using guessed type int dword_5B65CC;
Ritor1
parents:
diff changeset
7095
Ritor1
parents:
diff changeset
7096 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
7097 void Player::PlayAwardSound_Anim98()
Ritor1
parents:
diff changeset
7098 {
Ritor1
parents:
diff changeset
7099 int playerIndex = GetPlayerIndex();
Ritor1
parents:
diff changeset
7100 pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, playerIndex);
Ritor1
parents:
diff changeset
7101 PlayAwardSound();
Ritor1
parents:
diff changeset
7102 }
Ritor1
parents:
diff changeset
7103
Ritor1
parents:
diff changeset
7104 //----- (new function) --------------------------------------------------------
Ritor1
parents:
diff changeset
7105 void Player::PlayAwardSound_Anim98_Face( PlayerSpeech speech )
Ritor1
parents:
diff changeset
7106 {
Ritor1
parents:
diff changeset
7107 this->PlaySound(speech, 0);
Ritor1
parents:
diff changeset
7108 PlayAwardSound_Anim98();
Ritor1
parents:
diff changeset
7109 }
Ritor1
parents:
diff changeset
7110
Ritor1
parents:
diff changeset
7111 //----- (00467E7F) --------------------------------------------------------
Ritor1
parents:
diff changeset
7112 void Player::EquipBody(ITEM_EQUIP_TYPE uEquipType)
Ritor1
parents:
diff changeset
7113 {
Ritor1
parents:
diff changeset
7114 int itemAnchor; // ebx@1
Ritor1
parents:
diff changeset
7115 int itemInvLocation; // edx@1
Ritor1
parents:
diff changeset
7116 int freeSlot; // eax@3
Ritor1
parents:
diff changeset
7117 ItemGen tempPickedItem; // [sp+Ch] [bp-30h]@1
Ritor1
parents:
diff changeset
7118
Ritor1
parents:
diff changeset
7119 tempPickedItem.Reset();
Ritor1
parents:
diff changeset
7120 itemAnchor = pEquipTypeToBodyAnchor[uEquipType];
Ritor1
parents:
diff changeset
7121 itemInvLocation = pPlayers[uActiveCharacter]->pEquipment.pIndices[itemAnchor];
Ritor1
parents:
diff changeset
7122 if ( itemInvLocation )//ïåðåîäåòüñÿ â äðóãóþ âåùü
Ritor1
parents:
diff changeset
7123 {
Ritor1
parents:
diff changeset
7124 memcpy(&tempPickedItem, &pParty->pPickedItem, sizeof(tempPickedItem));
Ritor1
parents:
diff changeset
7125 pPlayers[uActiveCharacter]->pInventoryItemList[itemInvLocation - 1].uBodyAnchor = 0;
Ritor1
parents:
diff changeset
7126 pParty->pPickedItem.Reset();
Ritor1
parents:
diff changeset
7127 pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[itemInvLocation - 1]);
Ritor1
parents:
diff changeset
7128 tempPickedItem.uBodyAnchor = itemAnchor + 1;
Ritor1
parents:
diff changeset
7129 memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[itemInvLocation - 1], &tempPickedItem, sizeof(ItemGen));
Ritor1
parents:
diff changeset
7130 pPlayers[uActiveCharacter]->pEquipment.pIndices[itemAnchor] = itemInvLocation;
Ritor1
parents:
diff changeset
7131 }
Ritor1
parents:
diff changeset
7132 else//îäåòü âåùü
Ritor1
parents:
diff changeset
7133 {
Ritor1
parents:
diff changeset
7134 freeSlot = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot();
Ritor1
parents:
diff changeset
7135 if (freeSlot >= 0)
Ritor1
parents:
diff changeset
7136 {
Ritor1
parents:
diff changeset
7137 pParty->pPickedItem.uBodyAnchor = itemAnchor + 1;
Ritor1
parents:
diff changeset
7138 memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[freeSlot], &pParty->pPickedItem, sizeof(ItemGen));
Ritor1
parents:
diff changeset
7139 pPlayers[uActiveCharacter]->pEquipment.pIndices[itemAnchor] = freeSlot + 1;
Ritor1
parents:
diff changeset
7140 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
7141 }
Ritor1
parents:
diff changeset
7142 }
Ritor1
parents:
diff changeset
7143 }
Ritor1
parents:
diff changeset
7144
Ritor1
parents:
diff changeset
7145 //----- (0049387A) --------------------------------------------------------
Ritor1
parents:
diff changeset
7146 int CycleCharacter(bool backwards)
Ritor1
parents:
diff changeset
7147 {
Ritor1
parents:
diff changeset
7148 const int PARTYSIZE = 4;
Ritor1
parents:
diff changeset
7149 int valToAdd = backwards ? (PARTYSIZE - 2) : 0;
Ritor1
parents:
diff changeset
7150 int mult = backwards ? -1 : 1;
Ritor1
parents:
diff changeset
7151
Ritor1
parents:
diff changeset
7152 for (int i = 0; i < (PARTYSIZE - 1); i++)
Ritor1
parents:
diff changeset
7153 {
Ritor1
parents:
diff changeset
7154 int currCharId = ((uActiveCharacter + mult * i + valToAdd) % PARTYSIZE) + 1;
Ritor1
parents:
diff changeset
7155 if ( pPlayers[currCharId]->uTimeToRecovery == 0 )
Ritor1
parents:
diff changeset
7156 {
Ritor1
parents:
diff changeset
7157 return currCharId;
Ritor1
parents:
diff changeset
7158 }
Ritor1
parents:
diff changeset
7159 }
Ritor1
parents:
diff changeset
7160 return uActiveCharacter;
Ritor1
parents:
diff changeset
7161 }
Ritor1
parents:
diff changeset
7162
Ritor1
parents:
diff changeset
7163 //----- (0043EE77) --------------------------------------------------------
Ritor1
parents:
diff changeset
7164 bool Player::HasUnderwaterSuitEquipped() //the original function took the player number as a parameter. if it was 0, the whole party was checked. calls with the parameter 0 have been changed to calls to this for every player
Ritor1
parents:
diff changeset
7165 {
Ritor1
parents:
diff changeset
7166 if (GetArmorItem() == nullptr || GetArmorItem()->uItemID != 604)
Ritor1
parents:
diff changeset
7167 {
Ritor1
parents:
diff changeset
7168 return false;
Ritor1
parents:
diff changeset
7169 }
Ritor1
parents:
diff changeset
7170 return true;
Ritor1
parents:
diff changeset
7171 }
Ritor1
parents:
diff changeset
7172
Ritor1
parents:
diff changeset
7173 //----- (0043EE15) --------------------------------------------------------
Ritor1
parents:
diff changeset
7174 bool Player::HasItem( unsigned int uItemID, bool checkHeldItem )
Ritor1
parents:
diff changeset
7175 {
Ritor1
parents:
diff changeset
7176 if ( !checkHeldItem || pParty->pPickedItem.uItemID != uItemID )
Ritor1
parents:
diff changeset
7177 {
Ritor1
parents:
diff changeset
7178 for ( uint i = 0; i < 126; ++i )
Ritor1
parents:
diff changeset
7179 {
Ritor1
parents:
diff changeset
7180 if ( this->pInventoryMatrix[i] > 0 )
Ritor1
parents:
diff changeset
7181 {
Ritor1
parents:
diff changeset
7182 if ( (unsigned int)this->pInventoryItemList[this->pInventoryMatrix[i] - 1].uItemID == uItemID )
Ritor1
parents:
diff changeset
7183 return true;
Ritor1
parents:
diff changeset
7184 }
Ritor1
parents:
diff changeset
7185 }
Ritor1
parents:
diff changeset
7186 for ( uint i = 0; i < 16; ++i )
Ritor1
parents:
diff changeset
7187 {
Ritor1
parents:
diff changeset
7188 if ( this->pEquipment.pIndices[i] )
Ritor1
parents:
diff changeset
7189 {
Ritor1
parents:
diff changeset
7190 if ( (unsigned int)this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID == uItemID )
Ritor1
parents:
diff changeset
7191 return true;
Ritor1
parents:
diff changeset
7192 }
Ritor1
parents:
diff changeset
7193 }
Ritor1
parents:
diff changeset
7194 return false;
Ritor1
parents:
diff changeset
7195 }
Ritor1
parents:
diff changeset
7196 else
Ritor1
parents:
diff changeset
7197 {
Ritor1
parents:
diff changeset
7198 return true;
Ritor1
parents:
diff changeset
7199 }
Ritor1
parents:
diff changeset
7200 }
Ritor1
parents:
diff changeset
7201 //----- (0043EDB9) --------------------------------------------------------
Ritor1
parents:
diff changeset
7202 bool ShouldLoadTexturesForRaceAndGender(unsigned int _this)
Ritor1
parents:
diff changeset
7203 {
Ritor1
parents:
diff changeset
7204 CHARACTER_RACE race; // edi@2
Ritor1
parents:
diff changeset
7205 PLAYER_SEX sex; // eax@2
Ritor1
parents:
diff changeset
7206
Ritor1
parents:
diff changeset
7207 for (int i = 1; i <= 4; i++)
Ritor1
parents:
diff changeset
7208 {
Ritor1
parents:
diff changeset
7209 race = pPlayers[i]->GetRace();
Ritor1
parents:
diff changeset
7210 sex = pPlayers[i]->GetSexByVoice();
Ritor1
parents:
diff changeset
7211 switch(_this)
Ritor1
parents:
diff changeset
7212 {
Ritor1
parents:
diff changeset
7213 case 0:
Ritor1
parents:
diff changeset
7214 if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_MALE )
Ritor1
parents:
diff changeset
7215 return true;
Ritor1
parents:
diff changeset
7216 break;
Ritor1
parents:
diff changeset
7217 case 1:
Ritor1
parents:
diff changeset
7218 if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_FEMALE )
Ritor1
parents:
diff changeset
7219 return true;
Ritor1
parents:
diff changeset
7220 break;
Ritor1
parents:
diff changeset
7221 case 2:
Ritor1
parents:
diff changeset
7222 if ( race == CHARACTER_RACE_DWARF && sex == SEX_MALE )
Ritor1
parents:
diff changeset
7223 return true;
Ritor1
parents:
diff changeset
7224 break;
Ritor1
parents:
diff changeset
7225 case 3:
Ritor1
parents:
diff changeset
7226 if ( race == CHARACTER_RACE_DWARF && sex == SEX_FEMALE )
Ritor1
parents:
diff changeset
7227 return true;
Ritor1
parents:
diff changeset
7228 break;
Ritor1
parents:
diff changeset
7229 }
Ritor1
parents:
diff changeset
7230 }
Ritor1
parents:
diff changeset
7231 return false;
Ritor1
parents:
diff changeset
7232 }
Ritor1
parents:
diff changeset
7233
Ritor1
parents:
diff changeset
7234 //----- (0043ED6F) --------------------------------------------------------
Ritor1
parents:
diff changeset
7235 bool IsDwarfPresentInParty(bool a1)
Ritor1
parents:
diff changeset
7236 {
Ritor1
parents:
diff changeset
7237 for (uint i = 0; i < 4; ++i)
Ritor1
parents:
diff changeset
7238 {
Ritor1
parents:
diff changeset
7239 CHARACTER_RACE race = pParty->pPlayers[i].GetRace();
Ritor1
parents:
diff changeset
7240
Ritor1
parents:
diff changeset
7241 if (race == CHARACTER_RACE_DWARF && a1)
Ritor1
parents:
diff changeset
7242 return true;
Ritor1
parents:
diff changeset
7243 else if (race != CHARACTER_RACE_DWARF && !a1)
Ritor1
parents:
diff changeset
7244 return true;
Ritor1
parents:
diff changeset
7245 }
Ritor1
parents:
diff changeset
7246 return false;
Ritor1
parents:
diff changeset
7247 }
Ritor1
parents:
diff changeset
7248
Ritor1
parents:
diff changeset
7249 //----- (00439FCB) --------------------------------------------------------
Ritor1
parents:
diff changeset
7250 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int dmgSource, Vec3_int_ *pPos, signed int a4)
Ritor1
parents:
diff changeset
7251 {
Ritor1
parents:
diff changeset
7252 Player *playerPtr; // ebx@3
Ritor1
parents:
diff changeset
7253 Actor *actorPtr; // esi@3
Ritor1
parents:
diff changeset
7254 int spellId; // eax@38
Ritor1
parents:
diff changeset
7255 signed int recvdMagicDmg; // eax@139
Ritor1
parents:
diff changeset
7256 int v72[4]; // [sp+30h] [bp-24h]@164
Ritor1
parents:
diff changeset
7257 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3
Ritor1
parents:
diff changeset
7258 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1
Ritor1
parents:
diff changeset
7259
Ritor1
parents:
diff changeset
7260 uActorID = PID_ID(uObjID);
Ritor1
parents:
diff changeset
7261 if ( PID_TYPE(uObjID) != 2)
Ritor1
parents:
diff changeset
7262 {
Ritor1
parents:
diff changeset
7263 playerPtr = &pParty->pPlayers[a4];
Ritor1
parents:
diff changeset
7264 actorPtr = &pActors[uActorID];
Ritor1
parents:
diff changeset
7265 healthBeforeRecvdDamage = playerPtr->sHealth;
Ritor1
parents:
diff changeset
7266 if ( PID_TYPE(uObjID) != 3 || !actorPtr->ActorHitOrMiss(playerPtr) )
Ritor1
parents:
diff changeset
7267 return;
Ritor1
parents:
diff changeset
7268 ItemGen* equippedArmor = playerPtr->GetArmorItem();
Ritor1
parents:
diff changeset
7269 SoundID soundToPlay;
Ritor1
parents:
diff changeset
7270 if ( !equippedArmor
Ritor1
parents:
diff changeset
7271 || equippedArmor->IsBroken()
Ritor1
parents:
diff changeset
7272 ||
Ritor1
parents:
diff changeset
7273 (equippedArmor->GetPlayerSkillType() != PLAYER_SKILL_CHAIN
Ritor1
parents:
diff changeset
7274 && equippedArmor->GetPlayerSkillType() != PLAYER_SKILL_PLATE
Ritor1
parents:
diff changeset
7275 )
Ritor1
parents:
diff changeset
7276 )
Ritor1
parents:
diff changeset
7277 {
Ritor1
parents:
diff changeset
7278 int randVal = rand() % 4;
Ritor1
parents:
diff changeset
7279 switch (randVal)
Ritor1
parents:
diff changeset
7280 {
Ritor1
parents:
diff changeset
7281 case 0 : soundToPlay = (SoundID)108; break;
Ritor1
parents:
diff changeset
7282 case 1 : soundToPlay = (SoundID)109; break;
Ritor1
parents:
diff changeset
7283 case 2 : soundToPlay = (SoundID)110; break;
Ritor1
parents:
diff changeset
7284 case 3 : soundToPlay = (SoundID)44; break;
Ritor1
parents:
diff changeset
7285 default: Error("Unexpected sound value");
Ritor1
parents:
diff changeset
7286 }
Ritor1
parents:
diff changeset
7287 }
Ritor1
parents:
diff changeset
7288 else
Ritor1
parents:
diff changeset
7289 {
Ritor1
parents:
diff changeset
7290 int randVal = rand() % 4;
Ritor1
parents:
diff changeset
7291 switch (randVal)
Ritor1
parents:
diff changeset
7292 {
Ritor1
parents:
diff changeset
7293 case 0 : soundToPlay = (SoundID)105; break;
Ritor1
parents:
diff changeset
7294 case 1 : soundToPlay = (SoundID)106; break;
Ritor1
parents:
diff changeset
7295 case 2 : soundToPlay = (SoundID)107; break;
Ritor1
parents:
diff changeset
7296 case 3 : soundToPlay = (SoundID)45; break;
Ritor1
parents:
diff changeset
7297 default: Error("Unexpected sound value");
Ritor1
parents:
diff changeset
7298 }
Ritor1
parents:
diff changeset
7299 }
Ritor1
parents:
diff changeset
7300 pAudioPlayer->PlaySound(soundToPlay, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0);
Ritor1
parents:
diff changeset
7301 int dmgToReceive = actorPtr->_43B3E0_CalcDamage(dmgSource);
Ritor1
parents:
diff changeset
7302 if ( actorPtr->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 )
Ritor1
parents:
diff changeset
7303 {
Ritor1
parents:
diff changeset
7304 __int16 spellPower = actorPtr->pActorBuffs[ACTOR_BUFF_SHRINK].uPower;
Ritor1
parents:
diff changeset
7305 if ( spellPower )
Ritor1
parents:
diff changeset
7306 dmgToReceive /= (signed int)spellPower;
Ritor1
parents:
diff changeset
7307 }
Ritor1
parents:
diff changeset
7308 int damageType;
Ritor1
parents:
diff changeset
7309 switch (dmgSource)
Ritor1
parents:
diff changeset
7310 {
Ritor1
parents:
diff changeset
7311 case 0: damageType = actorPtr->pMonsterInfo.uAttack1Type;
Ritor1
parents:
diff changeset
7312 break;
Ritor1
parents:
diff changeset
7313 case 1: damageType = actorPtr->pMonsterInfo.uAttack2Type;
Ritor1
parents:
diff changeset
7314 break;
Ritor1
parents:
diff changeset
7315 case 2: spellId = actorPtr->pMonsterInfo.uSpell1ID;
Ritor1
parents:
diff changeset
7316 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool);
Ritor1
parents:
diff changeset
7317 break;
Ritor1
parents:
diff changeset
7318 case 3: spellId = actorPtr->pMonsterInfo.uSpell2ID;
Ritor1
parents:
diff changeset
7319 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool);
Ritor1
parents:
diff changeset
7320 break;
Ritor1
parents:
diff changeset
7321 case 4: damageType = actorPtr->pMonsterInfo.field_3C_some_special_attack;
Ritor1
parents:
diff changeset
7322 break;
Ritor1
parents:
diff changeset
7323 default:
Ritor1
parents:
diff changeset
7324 case 5: damageType = 4; //yes, the original just assigned the value 4
Ritor1
parents:
diff changeset
7325 break;
Ritor1
parents:
diff changeset
7326 }
Ritor1
parents:
diff changeset
7327 if ( !(dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DAMAGE) )
Ritor1
parents:
diff changeset
7328 {
Ritor1
parents:
diff changeset
7329 dmgToReceive = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType);
Ritor1
parents:
diff changeset
7330 if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime > 0 )
Ritor1
parents:
diff changeset
7331 {
Ritor1
parents:
diff changeset
7332 int actorState = actorPtr->uAIState;
Ritor1
parents:
diff changeset
7333 if ( actorState != Dying && actorState != Dead)
Ritor1
parents:
diff changeset
7334 {
Ritor1
parents:
diff changeset
7335 int reflectedDamage = actorPtr->CalcMagicalDamageToActor((DAMAGE_TYPE)damageType, dmgToReceive);
Ritor1
parents:
diff changeset
7336 actorPtr->sCurrentHP -= reflectedDamage;
Ritor1
parents:
diff changeset
7337 if ( reflectedDamage >= 0 )
Ritor1
parents:
diff changeset
7338 {
Ritor1
parents:
diff changeset
7339 if ( actorPtr->sCurrentHP >= 1 )
Ritor1
parents:
diff changeset
7340 {
Ritor1
parents:
diff changeset
7341 Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); //todo extract this branch to a function once Actor::functions are changed to nonstatic actor functions
Ritor1
parents:
diff changeset
7342 Actor::AggroSurroundingPeasants(uActorID, 1);
Ritor1
parents:
diff changeset
7343 }
Ritor1
parents:
diff changeset
7344 else
Ritor1
parents:
diff changeset
7345 {
Ritor1
parents:
diff changeset
7346 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS)
Ritor1
parents:
diff changeset
7347 {
Ritor1
parents:
diff changeset
7348 int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius;
Ritor1
parents:
diff changeset
7349 pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0);
Ritor1
parents:
diff changeset
7350 }
Ritor1
parents:
diff changeset
7351 Actor::Die(uActorID);
Ritor1
parents:
diff changeset
7352 Actor::ApplyFineForKillingPeasant(uActorID);
Ritor1
parents:
diff changeset
7353 Actor::AggroSurroundingPeasants(uActorID, 1);
Ritor1
parents:
diff changeset
7354 if ( actorPtr->pMonsterInfo.uExp )
Ritor1
parents:
diff changeset
7355 pParty->GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp);
Ritor1
parents:
diff changeset
7356 int speechToPlay = SPEECH_51;
Ritor1
parents:
diff changeset
7357 if ( rand() % 100 < 20 )
Ritor1
parents:
diff changeset
7358 speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1;
Ritor1
parents:
diff changeset
7359 playerPtr->PlaySound((PlayerSpeech)speechToPlay, 0);
Ritor1
parents:
diff changeset
7360 }
Ritor1
parents:
diff changeset
7361 }
Ritor1
parents:
diff changeset
7362 }
Ritor1
parents:
diff changeset
7363 }
Ritor1
parents:
diff changeset
7364 if ( !(dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DAMAGE)
Ritor1
parents:
diff changeset
7365 && actorPtr->pMonsterInfo.uSpecialAttackType
Ritor1
parents:
diff changeset
7366 && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackLevel )
Ritor1
parents:
diff changeset
7367 {
Ritor1
parents:
diff changeset
7368 playerPtr->ReceiveSpecialAttackEffect(actorPtr->pMonsterInfo.uSpecialAttackType, actorPtr);
Ritor1
parents:
diff changeset
7369 }
Ritor1
parents:
diff changeset
7370 }
Ritor1
parents:
diff changeset
7371 if ( !pParty->bTurnBasedModeOn )
Ritor1
parents:
diff changeset
7372 {
Ritor1
parents:
diff changeset
7373 int actEndurance = playerPtr->GetActualEndurance();
Ritor1
parents:
diff changeset
7374 int recoveryTime = (int)((20 - playerPtr->GetParameterBonus(actEndurance)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333);
Ritor1
parents:
diff changeset
7375 playerPtr->SetRecoveryTime(recoveryTime);
Ritor1
parents:
diff changeset
7376 }
Ritor1
parents:
diff changeset
7377 int yellThreshold = playerPtr->GetMaxHealth() / 4;
Ritor1
parents:
diff changeset
7378 if ( yellThreshold < playerPtr->sHealth && yellThreshold >= healthBeforeRecvdDamage && playerPtr->sHealth > 0 )
Ritor1
parents:
diff changeset
7379 {
Ritor1
parents:
diff changeset
7380 playerPtr->PlaySound(SPEECH_48, 0);
Ritor1
parents:
diff changeset
7381 }
Ritor1
parents:
diff changeset
7382 viewparams->bRedrawGameUI = 1;
Ritor1
parents:
diff changeset
7383 return;
Ritor1
parents:
diff changeset
7384 }
Ritor1
parents:
diff changeset
7385 else
Ritor1
parents:
diff changeset
7386 {
Ritor1
parents:
diff changeset
7387 SpriteObject* v37 = &pSpriteObjects[uActorID];
Ritor1
parents:
diff changeset
7388 int uActorType = PID_TYPE(v37->spell_caster_pid);
Ritor1
parents:
diff changeset
7389 int uActorID = PID_ID(v37->spell_caster_pid);
Ritor1
parents:
diff changeset
7390 if ( uActorType == 2 )
Ritor1
parents:
diff changeset
7391 {
Ritor1
parents:
diff changeset
7392 Player *playerPtr; // eax@81
Ritor1
parents:
diff changeset
7393 if ( a4 != -1 )
Ritor1
parents:
diff changeset
7394 {
Ritor1
parents:
diff changeset
7395 playerPtr = &pParty->pPlayers[a4];
Ritor1
parents:
diff changeset
7396 }
Ritor1
parents:
diff changeset
7397 else
Ritor1
parents:
diff changeset
7398 {
Ritor1
parents:
diff changeset
7399 int activePlayerCounter = 0;
Ritor1
parents:
diff changeset
7400 for (int i = 1; i <= 4; i++)
Ritor1
parents:
diff changeset
7401 {
Ritor1
parents:
diff changeset
7402 if (pPlayers[i]->CanAct())
Ritor1
parents:
diff changeset
7403 {
Ritor1
parents:
diff changeset
7404 v72[activePlayerCounter] = i;
Ritor1
parents:
diff changeset
7405 activePlayerCounter++;
Ritor1
parents:
diff changeset
7406 }
Ritor1
parents:
diff changeset
7407 }
Ritor1
parents:
diff changeset
7408 if ( activePlayerCounter )
Ritor1
parents:
diff changeset
7409 {
Ritor1
parents:
diff changeset
7410 playerPtr = &pParty->pPlayers[v72[rand() % activePlayerCounter] - 1];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552];
Ritor1
parents:
diff changeset
7411 }
Ritor1
parents:
diff changeset
7412 }
Ritor1
parents:
diff changeset
7413 int v68;
Ritor1
parents:
diff changeset
7414 int v69;
Ritor1
parents:
diff changeset
7415 if ( uActorType != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW)
Ritor1
parents:
diff changeset
7416 {
Ritor1
parents:
diff changeset
7417 int playerMaxHp = playerPtr->GetMaxHealth();
Ritor1
parents:
diff changeset
7418 v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, playerMaxHp);
Ritor1
parents:
diff changeset
7419 v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool);
Ritor1
parents:
diff changeset
7420 }
Ritor1
parents:
diff changeset
7421 else
Ritor1
parents:
diff changeset
7422 {
Ritor1
parents:
diff changeset
7423 v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0);
Ritor1
parents:
diff changeset
7424 v69 = 0;
Ritor1
parents:
diff changeset
7425 }
Ritor1
parents:
diff changeset
7426 playerPtr->ReceiveDamage(v68, (DAMAGE_TYPE)v69);
Ritor1
parents:
diff changeset
7427 if ( uActorType == OBJECT_Player && !_A750D8_player_speech_timer )
Ritor1
parents:
diff changeset
7428 {
Ritor1
parents:
diff changeset
7429 _A750D8_player_speech_timer = 256i64;
Ritor1
parents:
diff changeset
7430 PlayerSpeechID = SPEECH_44;
Ritor1
parents:
diff changeset
7431 uSpeakingCharacter = uActorID + 1;
Ritor1
parents:
diff changeset
7432 }
Ritor1
parents:
diff changeset
7433 return;
Ritor1
parents:
diff changeset
7434 }
Ritor1
parents:
diff changeset
7435 else if ( uActorType == 3 )
Ritor1
parents:
diff changeset
7436 {
Ritor1
parents:
diff changeset
7437 Actor *actorPtr = &pActors[uActorID];
Ritor1
parents:
diff changeset
7438 if ( a4 == -1 )
Ritor1
parents:
diff changeset
7439 a4 = stru_50C198.which_player_to_attack(actorPtr);
Ritor1
parents:
diff changeset
7440 Player *playerPtr = &pParty->pPlayers[a4];
Ritor1
parents:
diff changeset
7441 int dmgToReceive = actorPtr->_43B3E0_CalcDamage(dmgSource);
Ritor1
parents:
diff changeset
7442 unsigned __int16 spriteType = v37->uType;
Ritor1
parents:
diff changeset
7443 if ( v37->uType == 545 )
Ritor1
parents:
diff changeset
7444 {
Ritor1
parents:
diff changeset
7445 __int16 skillLevel = playerPtr->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
Ritor1
parents:
diff changeset
7446 if ( SkillToMastery(skillLevel) >= 4 && rand() % 100 < (skillLevel & 0x3F) )
Ritor1
parents:
diff changeset
7447 {
Ritor1
parents:
diff changeset
7448 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[637], playerPtr->pName);
Ritor1
parents:
diff changeset
7449 ShowStatusBarString(pTmpBuf.data(), 2u);
Ritor1
parents:
diff changeset
7450 playerPtr->PlaySound(SPEECH_6, 0);
Ritor1
parents:
diff changeset
7451 return;
Ritor1
parents:
diff changeset
7452 }
Ritor1
parents:
diff changeset
7453 }
Ritor1
parents:
diff changeset
7454 else if ( spriteType == 555
Ritor1
parents:
diff changeset
7455 || spriteType == 510
Ritor1
parents:
diff changeset
7456 || spriteType == 500
Ritor1
parents:
diff changeset
7457 || spriteType == 515
Ritor1
parents:
diff changeset
7458 || spriteType == 505
Ritor1
parents:
diff changeset
7459 || spriteType == 530
Ritor1
parents:
diff changeset
7460 || spriteType == 525
Ritor1
parents:
diff changeset
7461 || spriteType == 520
Ritor1
parents:
diff changeset
7462 || spriteType == 535
Ritor1
parents:
diff changeset
7463 || spriteType == 540 )
Ritor1
parents:
diff changeset
7464 {
Ritor1
parents:
diff changeset
7465 if ( !actorPtr->ActorHitOrMiss(playerPtr) )
Ritor1
parents:
diff changeset
7466 return;
Ritor1
parents:
diff changeset
7467 if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime > 0 )
Ritor1
parents:
diff changeset
7468 dmgToReceive >>= 1;
Ritor1
parents:
diff changeset
7469 if ( playerPtr->HasEnchantedItemEquipped(36) )
Ritor1
parents:
diff changeset
7470 dmgToReceive >>= 1;
Ritor1
parents:
diff changeset
7471 if ( playerPtr->HasEnchantedItemEquipped(69) )
Ritor1
parents:
diff changeset
7472 dmgToReceive >>= 1;
Ritor1
parents:
diff changeset
7473 if ( playerPtr->HasItemEquipped(EQUIP_ARMOUR)
Ritor1
parents:
diff changeset
7474 && playerPtr->GetArmorItem()->uItemID == ITEM_ARTIFACT_GOVERNORS_ARMOR )
Ritor1
parents:
diff changeset
7475 dmgToReceive >>= 1;
Ritor1
parents:
diff changeset
7476 if ( playerPtr->HasItemEquipped(EQUIP_TWO_HANDED))
Ritor1
parents:
diff changeset
7477 {
Ritor1
parents:
diff changeset
7478 ItemGen* mainHandItem = playerPtr->GetMainHandItem();
Ritor1
parents:
diff changeset
7479 if ( mainHandItem->uItemID == ITEM_RELIC_KELEBRIM || mainHandItem->uItemID == ITEM_ARTIFACT_ELFBANE || (mainHandItem->GetItemEquipType() == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4))
Ritor1
parents:
diff changeset
7480 dmgToReceive >>= 1;
Ritor1
parents:
diff changeset
7481 }
Ritor1
parents:
diff changeset
7482 if ( playerPtr->HasItemEquipped(EQUIP_SINGLE_HANDED))
Ritor1
parents:
diff changeset
7483 {
Ritor1
parents:
diff changeset
7484 ItemGen* offHandItem = playerPtr->GetOffHandItem();
Ritor1
parents:
diff changeset
7485 if ( offHandItem->uItemID == ITEM_RELIC_KELEBRIM || offHandItem->uItemID == ITEM_ARTIFACT_ELFBANE || (offHandItem->GetItemEquipType() == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4))
Ritor1
parents:
diff changeset
7486 dmgToReceive >>= 1;
Ritor1
parents:
diff changeset
7487 }
Ritor1
parents:
diff changeset
7488 }
Ritor1
parents:
diff changeset
7489 if ( actorPtr->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 )
Ritor1
parents:
diff changeset
7490 {
Ritor1
parents:
diff changeset
7491 int spellPower = actorPtr->pActorBuffs[ACTOR_BUFF_SHRINK].uPower;
Ritor1
parents:
diff changeset
7492 if ( spellPower )
Ritor1
parents:
diff changeset
7493 dmgToReceive /= (signed int)spellPower;
Ritor1
parents:
diff changeset
7494 }
Ritor1
parents:
diff changeset
7495 int damageType;
Ritor1
parents:
diff changeset
7496 switch(dmgSource)
Ritor1
parents:
diff changeset
7497 {
Ritor1
parents:
diff changeset
7498 case 0:
Ritor1
parents:
diff changeset
7499 damageType = actorPtr->pMonsterInfo.uAttack1Type;
Ritor1
parents:
diff changeset
7500 break;
Ritor1
parents:
diff changeset
7501 case 1:
Ritor1
parents:
diff changeset
7502 damageType = actorPtr->pMonsterInfo.uAttack2Type;
Ritor1
parents:
diff changeset
7503 break;
Ritor1
parents:
diff changeset
7504 case 2:
Ritor1
parents:
diff changeset
7505 spellId = actorPtr->pMonsterInfo.uSpell1ID;
Ritor1
parents:
diff changeset
7506 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool);
Ritor1
parents:
diff changeset
7507 break;
Ritor1
parents:
diff changeset
7508 case 3:
Ritor1
parents:
diff changeset
7509 spellId = actorPtr->pMonsterInfo.uSpell2ID;
Ritor1
parents:
diff changeset
7510 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool);
Ritor1
parents:
diff changeset
7511 break;
Ritor1
parents:
diff changeset
7512 case 4:
Ritor1
parents:
diff changeset
7513 damageType = actorPtr->pMonsterInfo.field_3C_some_special_attack;
Ritor1
parents:
diff changeset
7514 break;
Ritor1
parents:
diff changeset
7515 case 5:
Ritor1
parents:
diff changeset
7516 damageType = 4;
Ritor1
parents:
diff changeset
7517 break;
Ritor1
parents:
diff changeset
7518 }
Ritor1
parents:
diff changeset
7519 if ( !(dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DAMAGE) )
Ritor1
parents:
diff changeset
7520 {
Ritor1
parents:
diff changeset
7521 int reflectedDmg = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType);
Ritor1
parents:
diff changeset
7522 if ( playerPtr->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime > 0 )
Ritor1
parents:
diff changeset
7523 {
Ritor1
parents:
diff changeset
7524 unsigned __int16 actorState = actorPtr->uAIState;
Ritor1
parents:
diff changeset
7525 if ( actorState != Dying && actorState != Dead)
Ritor1
parents:
diff changeset
7526 {
Ritor1
parents:
diff changeset
7527 recvdMagicDmg = actorPtr->CalcMagicalDamageToActor((DAMAGE_TYPE)damageType, reflectedDmg);
Ritor1
parents:
diff changeset
7528 actorPtr->sCurrentHP -= recvdMagicDmg;
Ritor1
parents:
diff changeset
7529 if ( recvdMagicDmg >= 0 )
Ritor1
parents:
diff changeset
7530 {
Ritor1
parents:
diff changeset
7531 if ( actorPtr->sCurrentHP >= 1 )
Ritor1
parents:
diff changeset
7532 {
Ritor1
parents:
diff changeset
7533 Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0);
Ritor1
parents:
diff changeset
7534 Actor::AggroSurroundingPeasants(uActorID, 1);
Ritor1
parents:
diff changeset
7535 }
Ritor1
parents:
diff changeset
7536 else
Ritor1
parents:
diff changeset
7537 {
Ritor1
parents:
diff changeset
7538 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
Ritor1
parents:
diff changeset
7539 {
Ritor1
parents:
diff changeset
7540 int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius;
Ritor1
parents:
diff changeset
7541 pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0);
Ritor1
parents:
diff changeset
7542 }
Ritor1
parents:
diff changeset
7543 Actor::Die(uActorID);
Ritor1
parents:
diff changeset
7544 Actor::ApplyFineForKillingPeasant(uActorID);
Ritor1
parents:
diff changeset
7545 Actor::AggroSurroundingPeasants(uActorID, 1);
Ritor1
parents:
diff changeset
7546 if ( actorPtr->pMonsterInfo.uExp )
Ritor1
parents:
diff changeset
7547 pParty->GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp);
Ritor1
parents:
diff changeset
7548 int speechToPlay = SPEECH_51;
Ritor1
parents:
diff changeset
7549 if ( rand() % 100 < 20 )
Ritor1
parents:
diff changeset
7550 speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1;
Ritor1
parents:
diff changeset
7551 playerPtr->PlaySound((PlayerSpeech)speechToPlay, 0);
Ritor1
parents:
diff changeset
7552 }
Ritor1
parents:
diff changeset
7553 }
Ritor1
parents:
diff changeset
7554 }
Ritor1
parents:
diff changeset
7555 }
Ritor1
parents:
diff changeset
7556 }
Ritor1
parents:
diff changeset
7557 if ( !dmgSource
Ritor1
parents:
diff changeset
7558 && !(dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DAMAGE)
Ritor1
parents:
diff changeset
7559 && actorPtr->pMonsterInfo.uSpecialAttackType
Ritor1
parents:
diff changeset
7560 && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackLevel )
Ritor1
parents:
diff changeset
7561 {
Ritor1
parents:
diff changeset
7562 playerPtr->ReceiveSpecialAttackEffect(actorPtr->pMonsterInfo.uSpecialAttackType, actorPtr);
Ritor1
parents:
diff changeset
7563 }
Ritor1
parents:
diff changeset
7564 if ( !pParty->bTurnBasedModeOn )
Ritor1
parents:
diff changeset
7565 {
Ritor1
parents:
diff changeset
7566 int actEnd = playerPtr->GetActualEndurance();
Ritor1
parents:
diff changeset
7567 int recTime = (int)((20 - playerPtr->GetParameterBonus(actEnd))
Ritor1
parents:
diff changeset
7568 * flt_6BE3A4_debug_recmod1
Ritor1
parents:
diff changeset
7569 * 2.133333333333333);
Ritor1
parents:
diff changeset
7570 playerPtr->SetRecoveryTime(recTime);
Ritor1
parents:
diff changeset
7571 }
Ritor1
parents:
diff changeset
7572 return;
Ritor1
parents:
diff changeset
7573 }
Ritor1
parents:
diff changeset
7574 else
Ritor1
parents:
diff changeset
7575 {
Ritor1
parents:
diff changeset
7576 return;
Ritor1
parents:
diff changeset
7577 }
Ritor1
parents:
diff changeset
7578 }
Ritor1
parents:
diff changeset
7579 }
Ritor1
parents:
diff changeset
7580 //----- (00421EA6) --------------------------------------------------------
Ritor1
parents:
diff changeset
7581 void Player::OnInventoryLeftClick()
Ritor1
parents:
diff changeset
7582 {
Ritor1
parents:
diff changeset
7583 signed int inventoryXCoord; // ecx@2
Ritor1
parents:
diff changeset
7584 int inventoryYCoord; // eax@2
Ritor1
parents:
diff changeset
7585 int invMatrixIndex; // eax@2
Ritor1
parents:
diff changeset
7586 unsigned int enchantedItemPos; // eax@7
Ritor1
parents:
diff changeset
7587 unsigned int pickedItemId; // esi@12
Ritor1
parents:
diff changeset
7588 unsigned int invItemIndex; // eax@12
Ritor1
parents:
diff changeset
7589 unsigned int itemPos; // eax@18
Ritor1
parents:
diff changeset
7590 ItemGen tmpItem; // [sp+Ch] [bp-3Ch]@1
Ritor1
parents:
diff changeset
7591 unsigned int pY; // [sp+3Ch] [bp-Ch]@2
Ritor1
parents:
diff changeset
7592 unsigned int pX; // [sp+40h] [bp-8h]@2
Ritor1
parents:
diff changeset
7593 CastSpellInfo *pSpellInfo;
Ritor1
parents:
diff changeset
7594
Ritor1
parents:
diff changeset
7595 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 )
Ritor1
parents:
diff changeset
7596 {
Ritor1
parents:
diff changeset
7597 pMouse->GetClickPos(&pX, &pY);
Ritor1
parents:
diff changeset
7598 inventoryYCoord = (pY - 17) / 32;
Ritor1
parents:
diff changeset
7599 inventoryXCoord = (pX - 14) / 32;
Ritor1
parents:
diff changeset
7600 invMatrixIndex = inventoryXCoord + (INVETORYSLOTSWIDTH * inventoryYCoord);
Ritor1
parents:
diff changeset
7601 if ( inventoryYCoord >= 0 && inventoryYCoord < INVETORYSLOTSHEIGHT && inventoryXCoord >= 0 && inventoryXCoord < INVETORYSLOTSWIDTH)
Ritor1
parents:
diff changeset
7602 {
Ritor1
parents:
diff changeset
7603 if ( _50C9A0_IsEnchantingInProgress )
Ritor1
parents:
diff changeset
7604 {
Ritor1
parents:
diff changeset
7605 enchantedItemPos = this->GetItemIDAtInventoryIndex(&invMatrixIndex);
Ritor1
parents:
diff changeset
7606 if ( enchantedItemPos )
Ritor1
parents:
diff changeset
7607 {
Ritor1
parents:
diff changeset
7608 /* *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
Ritor1
parents:
diff changeset
7609 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
Ritor1
parents:
diff changeset
7610 *((int *)pGUIWindow_Settings->ptr_1C + 3) = enchantedItemPos - 1;
Ritor1
parents:
diff changeset
7611 *((short *)pGUIWindow_Settings->ptr_1C + 3) = invMatrixIndex;*/
Ritor1
parents:
diff changeset
7612 pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C;
Ritor1
parents:
diff changeset
7613 pSpellInfo->uFlags &= 0x7F;
Ritor1
parents:
diff changeset
7614 pSpellInfo->uPlayerID_2 = uActiveCharacter - 1;
Ritor1
parents:
diff changeset
7615 pSpellInfo->spell_target_pid = enchantedItemPos - 1;
Ritor1
parents:
diff changeset
7616 pSpellInfo->field_6 = invMatrixIndex;
Ritor1
parents:
diff changeset
7617 ptr_50C9A4_ItemToEnchant = &this->pInventoryItemList[enchantedItemPos-1];
Ritor1
parents:
diff changeset
7618 _50C9A0_IsEnchantingInProgress = 0;
Ritor1
parents:
diff changeset
7619 if ( pMessageQueue_50CBD0->uNumMessages )
Ritor1
parents:
diff changeset
7620 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
Ritor1
parents:
diff changeset
7621 pMouse->SetCursorBitmap("MICON1");
Ritor1
parents:
diff changeset
7622 _50C9D0_AfterEnchClickEventId = 113;
Ritor1
parents:
diff changeset
7623 _50C9D4_AfterEnchClickEventSecondParam = 0;
Ritor1
parents:
diff changeset
7624 _50C9D8_AfterEnchClickEventTimeout = 256;
Ritor1
parents:
diff changeset
7625 }
Ritor1
parents:
diff changeset
7626 return;
Ritor1
parents:
diff changeset
7627 }
Ritor1
parents:
diff changeset
7628 if ( ptr_50C9A4_ItemToEnchant )
Ritor1
parents:
diff changeset
7629 return;
Ritor1
parents:
diff changeset
7630 pickedItemId = pParty->pPickedItem.uItemID;
Ritor1
parents:
diff changeset
7631 invItemIndex = this->GetItemIDAtInventoryIndex(&invMatrixIndex);
Ritor1
parents:
diff changeset
7632 if (!pickedItemId)
Ritor1
parents:
diff changeset
7633 {
Ritor1
parents:
diff changeset
7634 if ( !invItemIndex )
Ritor1
parents:
diff changeset
7635 return;
Ritor1
parents:
diff changeset
7636 else
Ritor1
parents:
diff changeset
7637 {
Ritor1
parents:
diff changeset
7638 memcpy(&pParty->pPickedItem, &this->pInventoryItemList[invItemIndex-1], sizeof(pParty->pPickedItem));
Ritor1
parents:
diff changeset
7639 this->RemoveItemAtInventoryIndex(invMatrixIndex);
Ritor1
parents:
diff changeset
7640 pickedItemId = pParty->pPickedItem.uItemID;
Ritor1
parents:
diff changeset
7641 pMouse->SetCursorBitmap(pItemsTable->pItems[pickedItemId].pIconName);
Ritor1
parents:
diff changeset
7642 return;
Ritor1
parents:
diff changeset
7643 }
Ritor1
parents:
diff changeset
7644 }
Ritor1
parents:
diff changeset
7645 else
Ritor1
parents:
diff changeset
7646 {
Ritor1
parents:
diff changeset
7647 if ( invItemIndex )
Ritor1
parents:
diff changeset
7648 {
Ritor1
parents:
diff changeset
7649 ItemGen* invItemPtr = &this->pInventoryItemList[invItemIndex-1];
Ritor1
parents:
diff changeset
7650 memcpy(&tmpItem, invItemPtr, sizeof(tmpItem));
Ritor1
parents:
diff changeset
7651 this->RemoveItemAtInventoryIndex(invMatrixIndex);
Ritor1
parents:
diff changeset
7652 int emptyIndex = this->AddItem2(invMatrixIndex, &pParty->pPickedItem);
Ritor1
parents:
diff changeset
7653 if ( !emptyIndex )
Ritor1
parents:
diff changeset
7654 {
Ritor1
parents:
diff changeset
7655 emptyIndex = this->AddItem2(-1, &pParty->pPickedItem);
Ritor1
parents:
diff changeset
7656 if ( !emptyIndex )
Ritor1
parents:
diff changeset
7657 {
Ritor1
parents:
diff changeset
7658 this->PutItemArInventoryIndex(tmpItem.uItemID, invItemIndex - 1, invMatrixIndex);
Ritor1
parents:
diff changeset
7659 memcpy(invItemPtr, &tmpItem, sizeof(ItemGen));
Ritor1
parents:
diff changeset
7660 return;
Ritor1
parents:
diff changeset
7661 }
Ritor1
parents:
diff changeset
7662 }
Ritor1
parents:
diff changeset
7663 memcpy(&pParty->pPickedItem, &tmpItem, sizeof(ItemGen));
Ritor1
parents:
diff changeset
7664 pMouse->SetCursorBitmap(pParty->pPickedItem.GetIconName());
Ritor1
parents:
diff changeset
7665 return;
Ritor1
parents:
diff changeset
7666 }
Ritor1
parents:
diff changeset
7667 else
Ritor1
parents:
diff changeset
7668 {
Ritor1
parents:
diff changeset
7669 itemPos = this->AddItem(invMatrixIndex, pickedItemId);
Ritor1
parents:
diff changeset
7670 if ( itemPos )
Ritor1
parents:
diff changeset
7671 {
Ritor1
parents:
diff changeset
7672 memcpy(&this->pInventoryItemList[itemPos-1], &pParty->pPickedItem, sizeof(ItemGen));
Ritor1
parents:
diff changeset
7673 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
7674 return;
Ritor1
parents:
diff changeset
7675 }
Ritor1
parents:
diff changeset
7676 itemPos = this->AddItem(-1, pickedItemId);
Ritor1
parents:
diff changeset
7677 if ( itemPos )
Ritor1
parents:
diff changeset
7678 {
Ritor1
parents:
diff changeset
7679 memcpy(&this->pInventoryItemList[itemPos-1], &pParty->pPickedItem, sizeof(ItemGen));
Ritor1
parents:
diff changeset
7680 pMouse->RemoveHoldingItem();
Ritor1
parents:
diff changeset
7681 return;
Ritor1
parents:
diff changeset
7682 }
Ritor1
parents:
diff changeset
7683 }
Ritor1
parents:
diff changeset
7684 }
Ritor1
parents:
diff changeset
7685 }
Ritor1
parents:
diff changeset
7686 }
Ritor1
parents:
diff changeset
7687 }
Ritor1
parents:
diff changeset
7688
Ritor1
parents:
diff changeset
7689
Ritor1
parents:
diff changeset
7690 bool Player::IsWeak()
Ritor1
parents:
diff changeset
7691 {
Ritor1
parents:
diff changeset
7692 return pConditions[Condition_Weak] != 0;
Ritor1
parents:
diff changeset
7693 }
Ritor1
parents:
diff changeset
7694
Ritor1
parents:
diff changeset
7695 bool Player::IsDead()
Ritor1
parents:
diff changeset
7696 {
Ritor1
parents:
diff changeset
7697 return pConditions[Condition_Dead] != 0;
Ritor1
parents:
diff changeset
7698 }
Ritor1
parents:
diff changeset
7699
Ritor1
parents:
diff changeset
7700 bool Player::IsEradicated()
Ritor1
parents:
diff changeset
7701 {
Ritor1
parents:
diff changeset
7702 return pConditions[Condition_Eradicated] != 0;
Ritor1
parents:
diff changeset
7703 }
Ritor1
parents:
diff changeset
7704
Ritor1
parents:
diff changeset
7705 bool Player::IsZombie()
Ritor1
parents:
diff changeset
7706 {
Ritor1
parents:
diff changeset
7707 return pConditions[Condition_Zombie] != 0;
Ritor1
parents:
diff changeset
7708 }
Ritor1
parents:
diff changeset
7709
Ritor1
parents:
diff changeset
7710 bool Player::IsCursed()
Ritor1
parents:
diff changeset
7711 {
Ritor1
parents:
diff changeset
7712 return pConditions[Condition_Cursed] != 0;
Ritor1
parents:
diff changeset
7713 }
Ritor1
parents:
diff changeset
7714
Ritor1
parents:
diff changeset
7715 bool Player::IsPertified()
Ritor1
parents:
diff changeset
7716 {
Ritor1
parents:
diff changeset
7717 return pConditions[Condition_Pertified] != 0;
Ritor1
parents:
diff changeset
7718 }
Ritor1
parents:
diff changeset
7719
Ritor1
parents:
diff changeset
7720 bool Player::IsUnconcious()
Ritor1
parents:
diff changeset
7721 {
Ritor1
parents:
diff changeset
7722 return pConditions[Condition_Unconcious] != 0;
Ritor1
parents:
diff changeset
7723 }
Ritor1
parents:
diff changeset
7724
Ritor1
parents:
diff changeset
7725 bool Player::IsAsleep()
Ritor1
parents:
diff changeset
7726 {
Ritor1
parents:
diff changeset
7727 return pConditions[Condition_Sleep] != 0;
Ritor1
parents:
diff changeset
7728 }
Ritor1
parents:
diff changeset
7729
Ritor1
parents:
diff changeset
7730 bool Player::IsParalyzed()
Ritor1
parents:
diff changeset
7731 {
Ritor1
parents:
diff changeset
7732 return pConditions[Condition_Paralyzed] != 0;
Ritor1
parents:
diff changeset
7733 }
Ritor1
parents:
diff changeset
7734
Ritor1
parents:
diff changeset
7735 bool Player::IsDrunk()
Ritor1
parents:
diff changeset
7736 {
Ritor1
parents:
diff changeset
7737 return pConditions[Condition_Drunk] != 0;
Ritor1
parents:
diff changeset
7738 }
Ritor1
parents:
diff changeset
7739
Ritor1
parents:
diff changeset
7740 void Player::SetCursed( unsigned long long state )
Ritor1
parents:
diff changeset
7741 {
Ritor1
parents:
diff changeset
7742 pConditions[Condition_Cursed] = state;
Ritor1
parents:
diff changeset
7743 }
Ritor1
parents:
diff changeset
7744
Ritor1
parents:
diff changeset
7745 void Player::SetWeak( unsigned long long state )
Ritor1
parents:
diff changeset
7746 {
Ritor1
parents:
diff changeset
7747 pConditions[Condition_Weak] = state;
Ritor1
parents:
diff changeset
7748 }
Ritor1
parents:
diff changeset
7749
Ritor1
parents:
diff changeset
7750 void Player::SetAsleep( unsigned long long state )
Ritor1
parents:
diff changeset
7751 {
Ritor1
parents:
diff changeset
7752 pConditions[Condition_Sleep] = state;
Ritor1
parents:
diff changeset
7753 }
Ritor1
parents:
diff changeset
7754
Ritor1
parents:
diff changeset
7755 void Player::SetAfraid( unsigned long long state )
Ritor1
parents:
diff changeset
7756 {
Ritor1
parents:
diff changeset
7757 pConditions[Condition_Fear] = state;
Ritor1
parents:
diff changeset
7758 }
Ritor1
parents:
diff changeset
7759
Ritor1
parents:
diff changeset
7760 void Player::SetDrunk( unsigned long long state )
Ritor1
parents:
diff changeset
7761 {
Ritor1
parents:
diff changeset
7762 pConditions[Condition_Drunk] = state;
Ritor1
parents:
diff changeset
7763 }
Ritor1
parents:
diff changeset
7764
Ritor1
parents:
diff changeset
7765 void Player::SetInsane( unsigned long long state )
Ritor1
parents:
diff changeset
7766 {
Ritor1
parents:
diff changeset
7767 pConditions[Condition_Insane] = state;
Ritor1
parents:
diff changeset
7768 }
Ritor1
parents:
diff changeset
7769
Ritor1
parents:
diff changeset
7770 void Player::SetPoisonWeak( unsigned long long state )
Ritor1
parents:
diff changeset
7771 {
Ritor1
parents:
diff changeset
7772 pConditions[Condition_Poison_Weak] = state;
Ritor1
parents:
diff changeset
7773 }
Ritor1
parents:
diff changeset
7774
Ritor1
parents:
diff changeset
7775 void Player::SetDiseaseWeak( unsigned long long state )
Ritor1
parents:
diff changeset
7776 {
Ritor1
parents:
diff changeset
7777 pConditions[Condition_Disease_Weak] = state;
Ritor1
parents:
diff changeset
7778 }
Ritor1
parents:
diff changeset
7779
Ritor1
parents:
diff changeset
7780 void Player::SetPoisonMedium( unsigned long long state )
Ritor1
parents:
diff changeset
7781 {
Ritor1
parents:
diff changeset
7782 pConditions[Condition_Poison_Medium] = state;
Ritor1
parents:
diff changeset
7783 }
Ritor1
parents:
diff changeset
7784
Ritor1
parents:
diff changeset
7785 void Player::SetDiseaseMedium( unsigned long long state )
Ritor1
parents:
diff changeset
7786 {
Ritor1
parents:
diff changeset
7787 pConditions[Condition_Disease_Medium] = state;
Ritor1
parents:
diff changeset
7788 }
Ritor1
parents:
diff changeset
7789
Ritor1
parents:
diff changeset
7790 void Player::SetPoisonSevere( unsigned long long state )
Ritor1
parents:
diff changeset
7791 {
Ritor1
parents:
diff changeset
7792 pConditions[Condition_Poison_Severe] = state;
Ritor1
parents:
diff changeset
7793 }
Ritor1
parents:
diff changeset
7794
Ritor1
parents:
diff changeset
7795 void Player::SetDiseaseSevere( unsigned long long state )
Ritor1
parents:
diff changeset
7796 {
Ritor1
parents:
diff changeset
7797 pConditions[Condition_Disease_Severe] = state;
Ritor1
parents:
diff changeset
7798 }
Ritor1
parents:
diff changeset
7799
Ritor1
parents:
diff changeset
7800 void Player::SetParalyzed( unsigned long long state )
Ritor1
parents:
diff changeset
7801 {
Ritor1
parents:
diff changeset
7802 pConditions[Condition_Paralyzed] = state;
Ritor1
parents:
diff changeset
7803 }
Ritor1
parents:
diff changeset
7804
Ritor1
parents:
diff changeset
7805 void Player::SetUnconcious( unsigned long long state )
Ritor1
parents:
diff changeset
7806 {
Ritor1
parents:
diff changeset
7807 pConditions[Condition_Unconcious] = state;
Ritor1
parents:
diff changeset
7808 }
Ritor1
parents:
diff changeset
7809
Ritor1
parents:
diff changeset
7810 void Player::SetDead( unsigned long long state )
Ritor1
parents:
diff changeset
7811 {
Ritor1
parents:
diff changeset
7812 pConditions[Condition_Dead] = state;
Ritor1
parents:
diff changeset
7813 }
Ritor1
parents:
diff changeset
7814
Ritor1
parents:
diff changeset
7815 void Player::SetPertified( unsigned long long state )
Ritor1
parents:
diff changeset
7816 {
Ritor1
parents:
diff changeset
7817 pConditions[Condition_Pertified] = state;
Ritor1
parents:
diff changeset
7818 }
Ritor1
parents:
diff changeset
7819
Ritor1
parents:
diff changeset
7820 void Player::SetEradicated( unsigned long long state )
Ritor1
parents:
diff changeset
7821 {
Ritor1
parents:
diff changeset
7822 pConditions[Condition_Eradicated] = state;
Ritor1
parents:
diff changeset
7823 }
Ritor1
parents:
diff changeset
7824
Ritor1
parents:
diff changeset
7825 void Player::SetZombie( unsigned long long state )
Ritor1
parents:
diff changeset
7826 {
Ritor1
parents:
diff changeset
7827 pConditions[Condition_Zombie] = state;
Ritor1
parents:
diff changeset
7828 }
Ritor1
parents:
diff changeset
7829
Ritor1
parents:
diff changeset
7830 void Player::SetCondWeakWithBlockCheck( int blockable )
Ritor1
parents:
diff changeset
7831 {
Ritor1
parents:
diff changeset
7832 SetCondition(Condition_Weak, blockable);
Ritor1
parents:
diff changeset
7833 }
Ritor1
parents:
diff changeset
7834
Ritor1
parents:
diff changeset
7835 void Player::SetCondInsaneWithBlockCheck( int blockable )
Ritor1
parents:
diff changeset
7836 {
Ritor1
parents:
diff changeset
7837 SetCondition(Condition_Insane, blockable);
Ritor1
parents:
diff changeset
7838 }
Ritor1
parents:
diff changeset
7839
Ritor1
parents:
diff changeset
7840 void Player::SetCondDeadWithBlockCheck( int blockable )
Ritor1
parents:
diff changeset
7841 {
Ritor1
parents:
diff changeset
7842 SetCondition(Condition_Dead, blockable);
Ritor1
parents:
diff changeset
7843 }
Ritor1
parents:
diff changeset
7844
Ritor1
parents:
diff changeset
7845 void Player::SetCondUnconsciousWithBlockCheck( int blockable )
Ritor1
parents:
diff changeset
7846 {
Ritor1
parents:
diff changeset
7847 SetCondition(Condition_Dead, blockable);
Ritor1
parents:
diff changeset
7848 }
Ritor1
parents:
diff changeset
7849
Ritor1
parents:
diff changeset
7850 ItemGen* Player::GetOffHandItem()
Ritor1
parents:
diff changeset
7851 {
Ritor1
parents:
diff changeset
7852 return GetItem(&PlayerEquipment::uShield);
Ritor1
parents:
diff changeset
7853 }
Ritor1
parents:
diff changeset
7854
Ritor1
parents:
diff changeset
7855 ItemGen* Player::GetMainHandItem()
Ritor1
parents:
diff changeset
7856 {
Ritor1
parents:
diff changeset
7857 return GetItem(&PlayerEquipment::uMainHand);
Ritor1
parents:
diff changeset
7858 }
Ritor1
parents:
diff changeset
7859
Ritor1
parents:
diff changeset
7860 ItemGen* Player::GetBowItem()
Ritor1
parents:
diff changeset
7861 {
Ritor1
parents:
diff changeset
7862 return GetItem(&PlayerEquipment::uBow);
Ritor1
parents:
diff changeset
7863 }
Ritor1
parents:
diff changeset
7864
Ritor1
parents:
diff changeset
7865 ItemGen* Player::GetArmorItem()
Ritor1
parents:
diff changeset
7866 {
Ritor1
parents:
diff changeset
7867 return GetItem(&PlayerEquipment::uArmor);
Ritor1
parents:
diff changeset
7868 }
Ritor1
parents:
diff changeset
7869
Ritor1
parents:
diff changeset
7870 ItemGen* Player::GetHelmItem()
Ritor1
parents:
diff changeset
7871 {
Ritor1
parents:
diff changeset
7872 return GetItem(&PlayerEquipment::uHelm);
Ritor1
parents:
diff changeset
7873 }
Ritor1
parents:
diff changeset
7874
Ritor1
parents:
diff changeset
7875 ItemGen* Player::GetBeltItem()
Ritor1
parents:
diff changeset
7876 {
Ritor1
parents:
diff changeset
7877 return GetItem(&PlayerEquipment::uBelt);
Ritor1
parents:
diff changeset
7878 }
Ritor1
parents:
diff changeset
7879
Ritor1
parents:
diff changeset
7880 ItemGen* Player::GetCloakItem()
Ritor1
parents:
diff changeset
7881 {
Ritor1
parents:
diff changeset
7882 return GetItem(&PlayerEquipment::uCloak);
Ritor1
parents:
diff changeset
7883 }
Ritor1
parents:
diff changeset
7884
Ritor1
parents:
diff changeset
7885 ItemGen* Player::GetGloveItem()
Ritor1
parents:
diff changeset
7886 {
Ritor1
parents:
diff changeset
7887 return GetItem(&PlayerEquipment::uGlove);
Ritor1
parents:
diff changeset
7888 }
Ritor1
parents:
diff changeset
7889
Ritor1
parents:
diff changeset
7890 ItemGen* Player::GetBootItem()
Ritor1
parents:
diff changeset
7891 {
Ritor1
parents:
diff changeset
7892 return GetItem(&PlayerEquipment::uBoot);
Ritor1
parents:
diff changeset
7893 }
Ritor1
parents:
diff changeset
7894
Ritor1
parents:
diff changeset
7895 ItemGen* Player::GetAmuletItem()
Ritor1
parents:
diff changeset
7896 {
Ritor1
parents:
diff changeset
7897 return GetItem(&PlayerEquipment::uAmulet);
Ritor1
parents:
diff changeset
7898 }
Ritor1
parents:
diff changeset
7899
Ritor1
parents:
diff changeset
7900 ItemGen* Player::GetNthRingItem(int ringNum)
Ritor1
parents:
diff changeset
7901 {
Ritor1
parents:
diff changeset
7902 return GetNthEquippedIndexItem(ringNum + 10);
Ritor1
parents:
diff changeset
7903 }
Ritor1
parents:
diff changeset
7904
Ritor1
parents:
diff changeset
7905 ItemGen* Player::GetNthEquippedIndexItem(int index)
Ritor1
parents:
diff changeset
7906 {
Ritor1
parents:
diff changeset
7907 if (this->pEquipment.pIndices[index] == 0)
Ritor1
parents:
diff changeset
7908 {
Ritor1
parents:
diff changeset
7909 return nullptr;
Ritor1
parents:
diff changeset
7910 }
Ritor1
parents:
diff changeset
7911 return &this->pInventoryItemList[this->pEquipment.pIndices[index] - 1];
Ritor1
parents:
diff changeset
7912 }
Ritor1
parents:
diff changeset
7913
Ritor1
parents:
diff changeset
7914 ItemGen* Player::GetItem(unsigned int PlayerEquipment::* itemPos)
Ritor1
parents:
diff changeset
7915 {
Ritor1
parents:
diff changeset
7916 if (this->pEquipment.*itemPos == 0)
Ritor1
parents:
diff changeset
7917 {
Ritor1
parents:
diff changeset
7918 return nullptr;
Ritor1
parents:
diff changeset
7919 }
Ritor1
parents:
diff changeset
7920 return &this->pInventoryItemList[this->pEquipment.*itemPos - 1];
Ritor1
parents:
diff changeset
7921 }
Ritor1
parents:
diff changeset
7922
Ritor1
parents:
diff changeset
7923 int Player::GetPlayerIndex()
Ritor1
parents:
diff changeset
7924 {
Ritor1
parents:
diff changeset
7925 int uPlayerIdx = 0;
Ritor1
parents:
diff changeset
7926 if ( this == pPlayers[1] )
Ritor1
parents:
diff changeset
7927 uPlayerIdx = 0;
Ritor1
parents:
diff changeset
7928 else if( this == pPlayers[2] )
Ritor1
parents:
diff changeset
7929 uPlayerIdx = 1;
Ritor1
parents:
diff changeset
7930 else if ( this == pPlayers[3] )
Ritor1
parents:
diff changeset
7931 uPlayerIdx = 2;
Ritor1
parents:
diff changeset
7932 else if ( this == pPlayers[4] )
Ritor1
parents:
diff changeset
7933 uPlayerIdx = 3;
Ritor1
parents:
diff changeset
7934 else
Ritor1
parents:
diff changeset
7935 Error("Unexpected player pointer");
Ritor1
parents:
diff changeset
7936 return uPlayerIdx;
Ritor1
parents:
diff changeset
7937 }
Ritor1
parents:
diff changeset
7938
Ritor1
parents:
diff changeset
7939 //----- (004272F5) --------------------------------------------------------
Ritor1
parents:
diff changeset
7940 bool Player::PlayerHitOrMiss(Actor *pActor, int a3, int a4)
Ritor1
parents:
diff changeset
7941 {
Ritor1
parents:
diff changeset
7942 signed int naturalArmor; // esi@1
Ritor1
parents:
diff changeset
7943 signed int armorBuff; // edi@1
Ritor1
parents:
diff changeset
7944 int effectiveActorArmor; // esi@8
Ritor1
parents:
diff changeset
7945 int attBonus; // eax@9
Ritor1
parents:
diff changeset
7946 int v9; // edx@11
Ritor1
parents:
diff changeset
7947 // unsigned __int8 v12; // sf@13
Ritor1
parents:
diff changeset
7948 // unsigned __int8 v13; // of@13
Ritor1
parents:
diff changeset
7949 int attPositiveMod; // edx@14
Ritor1
parents:
diff changeset
7950 int attNegativeMod; // eax@14
Ritor1
parents:
diff changeset
7951 // signed int result; // eax@17
Ritor1
parents:
diff changeset
7952
Ritor1
parents:
diff changeset
7953 naturalArmor = pActor->pMonsterInfo.uAC;
Ritor1
parents:
diff changeset
7954 armorBuff = 0;
Ritor1
parents:
diff changeset
7955 if ( pActor->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime > 0 )
Ritor1
parents:
diff changeset
7956 naturalArmor /= 2;
Ritor1
parents:
diff changeset
7957 if ( pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 )
Ritor1
parents:
diff changeset
7958 armorBuff = pActor->pActorBuffs[ACTOR_BUFF_SHIELD].uPower;
Ritor1
parents:
diff changeset
7959 if ( pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uExpireTime > 0 && pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower > armorBuff )
Ritor1
parents:
diff changeset
7960 armorBuff = pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower;
Ritor1
parents:
diff changeset
7961 effectiveActorArmor = armorBuff + naturalArmor;
Ritor1
parents:
diff changeset
7962 if ( a3 )
Ritor1
parents:
diff changeset
7963 attBonus = this->GetRangedAttack();
Ritor1
parents:
diff changeset
7964 else
Ritor1
parents:
diff changeset
7965 attBonus = this->GetActualAttack(false);
Ritor1
parents:
diff changeset
7966 v9 = rand() % (effectiveActorArmor + 2 * attBonus + 30);
Ritor1
parents:
diff changeset
7967 attPositiveMod = a4 + v9;
Ritor1
parents:
diff changeset
7968 if ( a3 == 2 )
Ritor1
parents:
diff changeset
7969 {
Ritor1
parents:
diff changeset
7970 attNegativeMod = ((effectiveActorArmor + 15) / 2) + effectiveActorArmor + 15;
Ritor1
parents:
diff changeset
7971 }
Ritor1
parents:
diff changeset
7972 else if ( a3 == 3 )
Ritor1
parents:
diff changeset
7973 {
Ritor1
parents:
diff changeset
7974 attNegativeMod = 2 * effectiveActorArmor + 30;
Ritor1
parents:
diff changeset
7975 }
Ritor1
parents:
diff changeset
7976 else
Ritor1
parents:
diff changeset
7977 {
Ritor1
parents:
diff changeset
7978 attNegativeMod = effectiveActorArmor + 15;
Ritor1
parents:
diff changeset
7979 }
Ritor1
parents:
diff changeset
7980 return (attPositiveMod > attNegativeMod);
Ritor1
parents:
diff changeset
7981 }
Ritor1
parents:
diff changeset
7982
Ritor1
parents:
diff changeset
7983
Ritor1
parents:
diff changeset
7984 //----- (0042ECB5) --------------------------------------------------------
Ritor1
parents:
diff changeset
7985 void Player::_42ECB5_PlayerAttacksActor()
Ritor1
parents:
diff changeset
7986 {
Ritor1
parents:
diff changeset
7987 // char *v5; // eax@8
Ritor1
parents:
diff changeset
7988 // unsigned int v9; // ecx@21
Ritor1
parents:
diff changeset
7989 // char *v11; // eax@26
Ritor1
parents:
diff changeset
7990 // unsigned int v12; // eax@47
Ritor1
parents:
diff changeset
7991 // SoundID v24; // [sp-4h] [bp-40h]@58
Ritor1
parents:
diff changeset
7992
Ritor1
parents:
diff changeset
7993 //result = pParty->pPlayers[uActiveCharacter-1].CanAct();
Ritor1
parents:
diff changeset
7994 Player* player = &pParty->pPlayers[uActiveCharacter - 1];
Ritor1
parents:
diff changeset
7995 if (!player->CanAct())
Ritor1
parents:
diff changeset
7996 return;
Ritor1
parents:
diff changeset
7997
Ritor1
parents:
diff changeset
7998 CastSpellInfoHelpers::_427D48();
Ritor1
parents:
diff changeset
7999 //v3 = 0;
Ritor1
parents:
diff changeset
8000 if (pParty->Invisible())
Ritor1
parents:
diff changeset
8001 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
Ritor1
parents:
diff changeset
8002
Ritor1
parents:
diff changeset
8003 //v31 = player->pEquipment.uBow;
Ritor1
parents:
diff changeset
8004 int bow_idx = player->pEquipment.uBow;
Ritor1
parents:
diff changeset
8005 if (bow_idx && player->pInventoryItemList[bow_idx - 1].IsBroken())
Ritor1
parents:
diff changeset
8006 bow_idx = 0;
Ritor1
parents:
diff changeset
8007
Ritor1
parents:
diff changeset
8008 //v32 = 0;
Ritor1
parents:
diff changeset
8009 int wand_item_id = 0;
Ritor1
parents:
diff changeset
8010 //v33 = 0;
Ritor1
parents:
diff changeset
8011 //v4 = v1->pEquipment.uMainHand;
Ritor1
parents:
diff changeset
8012 int laser_weapon_item_id = 0;
Ritor1
parents:
diff changeset
8013
Ritor1
parents:
diff changeset
8014 int main_hand_idx = player->pEquipment.uMainHand;
Ritor1
parents:
diff changeset
8015 if (main_hand_idx)
Ritor1
parents:
diff changeset
8016 {
Ritor1
parents:
diff changeset
8017 ItemGen* item = &player->pInventoryItemList[main_hand_idx - 1];
Ritor1
parents:
diff changeset
8018 //v5 = (char *)v1 + 36 * v4;
Ritor1
parents:
diff changeset
8019 if (!item->IsBroken())
Ritor1
parents:
diff changeset
8020 {
Ritor1
parents:
diff changeset
8021 //v28b = &v1->pInventoryItems[v4].uItemID;
Ritor1
parents:
diff changeset
8022 //v6 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124);
Ritor1
parents:
diff changeset
8023 if (item->GetItemEquipType() == EQUIP_WAND)
Ritor1
parents:
diff changeset
8024 {
Ritor1
parents:
diff changeset
8025 if (item->uNumCharges <= 0)
Ritor1
parents:
diff changeset
8026 player->pEquipment.uMainHand = 0; // wand discharged - unequip
Ritor1
parents:
diff changeset
8027 else
Ritor1
parents:
diff changeset
8028 wand_item_id = item->uItemID;//*((int *)v5 + 124);
Ritor1
parents:
diff changeset
8029 }
Ritor1
parents:
diff changeset
8030 else if (item->uItemID == ITEM_BLASTER || item->uItemID == ITEM_LASER_RIFLE)
Ritor1
parents:
diff changeset
8031 laser_weapon_item_id = item->uItemID;//*((int *)v5 + 124);
Ritor1
parents:
diff changeset
8032 }
Ritor1
parents:
diff changeset
8033 }
Ritor1
parents:
diff changeset
8034
Ritor1
parents:
diff changeset
8035 //v30 = 0;
Ritor1
parents:
diff changeset
8036 //v29 = 0;
Ritor1
parents:
diff changeset
8037 //v28 = 0;
Ritor1
parents:
diff changeset
8038 //v7 = pMouse->uPointingObjectID;
Ritor1
parents:
diff changeset
8039
Ritor1
parents:
diff changeset
8040 int target_pid = pMouse->uPointingObjectID;
Ritor1
parents:
diff changeset
8041 int target_type = PID_TYPE(target_pid),
Ritor1
parents:
diff changeset
8042 target_id = PID_ID(target_pid);
Ritor1
parents:
diff changeset
8043 if (target_type != OBJECT_Actor || !pActors[target_id].CanAct())
Ritor1
parents:
diff changeset
8044 {
Ritor1
parents:
diff changeset
8045 target_pid = stru_50C198.FindClosestActor(5120, 0, 0);
Ritor1
parents:
diff changeset
8046 target_type = PID_TYPE(target_pid);
Ritor1
parents:
diff changeset
8047 target_id = PID_ID(target_pid);
Ritor1
parents:
diff changeset
8048 }
Ritor1
parents:
diff changeset
8049
Ritor1
parents:
diff changeset
8050 Actor* actor = &pActors[target_id];
Ritor1
parents:
diff changeset
8051 int actor_distance = 0;
Ritor1
parents:
diff changeset
8052 if (target_type == OBJECT_Actor)
Ritor1
parents:
diff changeset
8053 {
Ritor1
parents:
diff changeset
8054 int distance_x = actor->vPosition.x - pParty->vPosition.x,
Ritor1
parents:
diff changeset
8055 distance_y = actor->vPosition.y - pParty->vPosition.y,
Ritor1
parents:
diff changeset
8056 distance_z = actor->vPosition.z - pParty->vPosition.z;
Ritor1
parents:
diff changeset
8057 actor_distance = integer_sqrt(distance_x * distance_x + distance_y * distance_y + distance_z * distance_z) - actor->uActorRadius;
Ritor1
parents:
diff changeset
8058 if (actor_distance < 0)
Ritor1
parents:
diff changeset
8059 actor_distance = 0;
Ritor1
parents:
diff changeset
8060 }
Ritor1
parents:
diff changeset
8061
Ritor1
parents:
diff changeset
8062 bool shooting_bow = false,
Ritor1
parents:
diff changeset
8063 shotting_laser = false,
Ritor1
parents:
diff changeset
8064 shooting_wand = false,
Ritor1
parents:
diff changeset
8065 melee_attack = false;
Ritor1
parents:
diff changeset
8066 if (laser_weapon_item_id)
Ritor1
parents:
diff changeset
8067 {
Ritor1
parents:
diff changeset
8068 shotting_laser = true;
Ritor1
parents:
diff changeset
8069 _42777D_CastSpell_UseWand_ShootArrow(SPELL_LASER_PROJECTILE, uActiveCharacter - 1, 0, 0, uActiveCharacter + 8);
Ritor1
parents:
diff changeset
8070 }
Ritor1
parents:
diff changeset
8071 else if (wand_item_id)
Ritor1
parents:
diff changeset
8072 {
Ritor1
parents:
diff changeset
8073 shooting_wand = true;
Ritor1
parents:
diff changeset
8074
Ritor1
parents:
diff changeset
8075 int main_hand_idx = player->pEquipment.uMainHand;
Ritor1
parents:
diff changeset
8076 _42777D_CastSpell_UseWand_ShootArrow(wand_spell_ids[player->pInventoryItemList[main_hand_idx - 1].uItemID - ITEM_WAND_FIRE], uActiveCharacter - 1, 8, 0, uActiveCharacter + 8);
Ritor1
parents:
diff changeset
8077
Ritor1
parents:
diff changeset
8078 if (!--player->pInventoryItemList[main_hand_idx - 1].uNumCharges)
Ritor1
parents:
diff changeset
8079 player->pEquipment.uMainHand = 0;
Ritor1
parents:
diff changeset
8080 }
Ritor1
parents:
diff changeset
8081 else if (target_type == OBJECT_Actor && actor_distance <= 407.2)
Ritor1
parents:
diff changeset
8082 {
Ritor1
parents:
diff changeset
8083 melee_attack = true;
Ritor1
parents:
diff changeset
8084
Ritor1
parents:
diff changeset
8085 Vec3_int_ a3;
Ritor1
parents:
diff changeset
8086 a3.x = actor->vPosition.x - pParty->vPosition.x;
Ritor1
parents:
diff changeset
8087 a3.y = actor->vPosition.y - pParty->vPosition.y;
Ritor1
parents:
diff changeset
8088 a3.z = actor->vPosition.z - pParty->vPosition.z;
Ritor1
parents:
diff changeset
8089 Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z);
Ritor1
parents:
diff changeset
8090
Ritor1
parents:
diff changeset
8091 Actor::DamageMonsterFromParty(PID(OBJECT_Player, uActiveCharacter - 1), target_id, &a3);
Ritor1
parents:
diff changeset
8092 if (player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_TWO_HANDED) || player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_SINGLE_HANDED))
Ritor1
parents:
diff changeset
8093 _42FA66_do_explosive_impact(actor->vPosition.x, actor->vPosition.y, actor->vPosition.z + actor->uActorHeight / 2, 0, 512, uActiveCharacter);
Ritor1
parents:
diff changeset
8094 }
Ritor1
parents:
diff changeset
8095 else if (bow_idx)
Ritor1
parents:
diff changeset
8096 {
Ritor1
parents:
diff changeset
8097 shooting_bow = true;
Ritor1
parents:
diff changeset
8098 _42777D_CastSpell_UseWand_ShootArrow(SPELL_BOW_ARROW, uActiveCharacter - 1, 0, 0, 0);
Ritor1
parents:
diff changeset
8099 }
Ritor1
parents:
diff changeset
8100 else
Ritor1
parents:
diff changeset
8101 {
Ritor1
parents:
diff changeset
8102 melee_attack = true;
Ritor1
parents:
diff changeset
8103 ; // actor out of range or no actor; no ranged weapon so melee attacking air
Ritor1
parents:
diff changeset
8104 }
Ritor1
parents:
diff changeset
8105
Ritor1
parents:
diff changeset
8106 if (!pParty->bTurnBasedModeOn && melee_attack) // wands, bows & lasers will add recovery while shooting spell effect
Ritor1
parents:
diff changeset
8107 {
Ritor1
parents:
diff changeset
8108 int recovery = player->GetAttackRecoveryTime(false);
Ritor1
parents:
diff changeset
8109 if (recovery < 30 )
Ritor1
parents:
diff changeset
8110 recovery = 30;
Ritor1
parents:
diff changeset
8111 player->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * (double)recovery * 2.133333333333333);
Ritor1
parents:
diff changeset
8112 }
Ritor1
parents:
diff changeset
8113
Ritor1
parents:
diff changeset
8114 int v34 = 0;
Ritor1
parents:
diff changeset
8115 if (shooting_wand)
Ritor1
parents:
diff changeset
8116 return;
Ritor1
parents:
diff changeset
8117 else if (shooting_bow)
Ritor1
parents:
diff changeset
8118 {
Ritor1
parents:
diff changeset
8119 v34 = 5;
Ritor1
parents:
diff changeset
8120 player->PlaySound(SPEECH_50, 0);
Ritor1
parents:
diff changeset
8121 }
Ritor1
parents:
diff changeset
8122 if (shotting_laser)
Ritor1
parents:
diff changeset
8123 v34 = 7;
Ritor1
parents:
diff changeset
8124 else
Ritor1
parents:
diff changeset
8125 {
Ritor1
parents:
diff changeset
8126 int main_hand_idx = player->pEquipment.uMainHand;
Ritor1
parents:
diff changeset
8127 if (player->HasItemEquipped(EQUIP_TWO_HANDED))
Ritor1
parents:
diff changeset
8128 v34 = player->pInventoryItemList[main_hand_idx - 1].GetPlayerSkillType();
Ritor1
parents:
diff changeset
8129 pTurnEngine->ApplyPlayerAction();
Ritor1
parents:
diff changeset
8130 }
Ritor1
parents:
diff changeset
8131
Ritor1
parents:
diff changeset
8132 switch (v34)
Ritor1
parents:
diff changeset
8133 {
Ritor1
parents:
diff changeset
8134 case 0: pAudioPlayer->PlaySound(SOUND_81, 0, 0, -1, 0, 0, 0, 0); break;
Ritor1
parents:
diff changeset
8135 case 1: pAudioPlayer->PlaySound(SOUND_84, 0, 0, -1, 0, 0, 0, 0); break;
Ritor1
parents:
diff changeset
8136 case 2: pAudioPlayer->PlaySound(SOUND_85, 0, 0, -1, 0, 0, 0, 0); break;
Ritor1
parents:
diff changeset
8137 case 3: pAudioPlayer->PlaySound(SOUND_78, 0, 0, -1, 0, 0, 0, 0); break;
Ritor1
parents:
diff changeset
8138 case 4: pAudioPlayer->PlaySound(SOUND_80, 0, 0, -1, 0, 0, 0, 0); break;
Ritor1
parents:
diff changeset
8139 case 5: pAudioPlayer->PlaySound(SOUND_71, 0, 0, -1, 0, 0, 0, 0); break;
Ritor1
parents:
diff changeset
8140 case 6: pAudioPlayer->PlaySound(SOUND_83, 0, 0, -1, 0, 0, 0, 0); break;
Ritor1
parents:
diff changeset
8141 case 7: pAudioPlayer->PlaySound(SOUND_67, 0, 0, -1, 0, 0, 0, 0); break;
Ritor1
parents:
diff changeset
8142 }
Ritor1
parents:
diff changeset
8143 }
Ritor1
parents:
diff changeset
8144
Ritor1
parents:
diff changeset
8145
Ritor1
parents:
diff changeset
8146 //----- (0042FA66) --------------------------------------------------------
Ritor1
parents:
diff changeset
8147 void Player::_42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6)
Ritor1
parents:
diff changeset
8148 {
Ritor1
parents:
diff changeset
8149 unsigned __int16 v9; // ax@5
Ritor1
parents:
diff changeset
8150
Ritor1
parents:
diff changeset
8151 SpriteObject a1a; // [sp+Ch] [bp-74h]@1
Ritor1
parents:
diff changeset
8152 //SpriteObject::SpriteObject(&a1a);
Ritor1
parents:
diff changeset
8153 a1a.uType = 600;
Ritor1
parents:
diff changeset
8154 a1a.stru_24.Reset();
Ritor1
parents:
diff changeset
8155
Ritor1
parents:
diff changeset
8156 a1a.spell_id = SPELL_FIRE_FIREBALL;
Ritor1
parents:
diff changeset
8157 a1a.spell_level = 8;
Ritor1
parents:
diff changeset
8158 a1a.spell_skill = 3;
Ritor1
parents:
diff changeset
8159 v9 = 0;
Ritor1
parents:
diff changeset
8160 for ( uint i = 0; i < pObjectList->uNumObjects; ++i )
Ritor1
parents:
diff changeset
8161 {
Ritor1
parents:
diff changeset
8162 if ( a1a.uType == pObjectList->pObjects[i].uObjectID )
Ritor1
parents:
diff changeset
8163 v9 = i;
Ritor1
parents:
diff changeset
8164 }
Ritor1
parents:
diff changeset
8165 a1a.uObjectDescID = v9;
Ritor1
parents:
diff changeset
8166 a1a.vPosition.x = a1;
Ritor1
parents:
diff changeset
8167 a1a.vPosition.y = a2;
Ritor1
parents:
diff changeset
8168 a1a.vPosition.z = a3;
Ritor1
parents:
diff changeset
8169 a1a.uAttributes = 0;
Ritor1
parents:
diff changeset
8170 a1a.uSectorID = pIndoor->GetSector(a1, a2, a3);
Ritor1
parents:
diff changeset
8171 a1a.uSpriteFrameID = 0;
Ritor1
parents:
diff changeset
8172 a1a.spell_target_pid = 0;
Ritor1
parents:
diff changeset
8173 a1a.field_60_distance_related_prolly_lod = 0;
Ritor1
parents:
diff changeset
8174 a1a.uFacing = 0;
Ritor1
parents:
diff changeset
8175 a1a.uSoundID = 0;
Ritor1
parents:
diff changeset
8176 if ( a6 >= 1 || a6 <= 4 )
Ritor1
parents:
diff changeset
8177 a1a.spell_caster_pid = PID(OBJECT_Player, a6 - 1);
Ritor1
parents:
diff changeset
8178 else
Ritor1
parents:
diff changeset
8179 a1a.spell_caster_pid = 0;
Ritor1
parents:
diff changeset
8180
Ritor1
parents:
diff changeset
8181 int id = a1a.Create(0, 0, 0, 0);
Ritor1
parents:
diff changeset
8182 if (id != -1)
Ritor1
parents:
diff changeset
8183 AttackerInfo.Add(PID(OBJECT_Item, id), a5, SLOWORD(a1a.vPosition.x), SLOWORD(a1a.vPosition.y),
Ritor1
parents:
diff changeset
8184 SLOWORD(a1a.vPosition.z), 0, 0);
Ritor1
parents:
diff changeset
8185 }
Ritor1
parents:
diff changeset
8186
Ritor1
parents:
diff changeset
8187 //----- (00458244) --------------------------------------------------------
Ritor1
parents:
diff changeset
8188 unsigned int SkillToMastery( unsigned int skill_value )
Ritor1
parents:
diff changeset
8189 {
Ritor1
parents:
diff changeset
8190 switch (skill_value & 0x1C0)
Ritor1
parents:
diff changeset
8191 {
Ritor1
parents:
diff changeset
8192 case 0x100: return 4; // Grandmaster
Ritor1
parents:
diff changeset
8193 case 0x80: return 3; // Master
Ritor1
parents:
diff changeset
8194 case 0x40: return 2; // Expert
Ritor1
parents:
diff changeset
8195 case 0x00: return 1; // Normal
Ritor1
parents:
diff changeset
8196 }
Ritor1
parents:
diff changeset
8197 assert(false);
Ritor1
parents:
diff changeset
8198 return 0;
Ritor1
parents:
diff changeset
8199 }