2499
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
|
6 #include <stdlib.h>
|
2541
|
7
|
|
8 #include "Engine/Engine.h"
|
2499
|
9
|
|
10 #include "Spells.h"
|
|
11 #include "Engine/Graphics/Overlays.h"
|
|
12 #include "../LOD.h"
|
|
13 #include "../texts.h"
|
|
14
|
|
15 #include "../Party.h"
|
|
16 #include "../OurMath.h"
|
|
17 #include "Engine/Objects/SpriteObject.h"
|
|
18 #include "Engine/Objects/ObjectList.h"
|
|
19 #include "Engine/Graphics/Indoor.h"
|
2502
|
20 #include "Media/Audio/AudioPlayer.h"
|
2499
|
21 #include "Engine/Objects/Actor.h"
|
|
22 #include "stru6.h"
|
|
23
|
|
24
|
|
25 std::array<TownPortalData, 6> TownPortalList = //4ECBB8
|
|
26 {{
|
|
27 {Vec3_int_(-5121, 2107, 1), 1536, 0, 21, 0},
|
|
28 {Vec3_int_(-15148, -10240, 1473), 0, 0, 4, 0},
|
|
29 {Vec3_int_(-10519, 5375, 753), 512, 0, 3, 0},
|
|
30 {Vec3_int_(3114, -11055, 513), 0, 0, 10, 0},
|
|
31 {Vec3_int_(-158, 7624, 1), 512, 0, 7, 0},
|
|
32 {Vec3_int_(-1837, -4247, 65), 65, 0, 8, 0}
|
|
33 }} ;
|
|
34
|
|
35 struct SpellStats *pSpellStats;
|
|
36
|
|
37
|
|
38 std::array<stru324_spell, 103> stru_4E3ACC =
|
|
39 {{
|
|
40 {10, 0},
|
|
41 {1000, 0}, {1010, 0}, {1020, 0}, {1030, 0}, {1040, 0}, {1050, 0}, {1060, 0}, {1070, 0}, {1080, 0}, {1090, 0}, {1100, 0},
|
|
42 {2000, 0}, {2010, 0}, {2020, 0}, {2030, 0}, {2040, 0}, {2050, 0}, {2060, 0}, {2070, 0}, {2080, 0}, {2090, 0}, {2100, 0},
|
|
43 {3000, 0}, {3010, 0}, {3020, 0}, {3030, 0}, {3040, 0}, {3050, 0}, {3060, 0}, {3070, 0}, {3080, 0}, {3090, 0}, {3100, 0},
|
|
44 {4000, 0}, {4010, 0}, {4020, 0}, {4030, 0}, {4040, 0}, {4050, 0}, {4060, 0}, {4070, 0}, {4080, 0}, {4090, 0}, {4100, 0},
|
|
45 {5000, 0}, {5010, 0}, {5020, 0}, {5030, 0}, {5040, 0}, {5050, 0}, {5060, 0}, {5070, 0}, {5080, 0}, {5090, 0}, {5100, 0},
|
|
46 {6000, 0}, {6010, 0}, {6020, 0}, {6030, 0}, {6040, 0}, {6050, 0}, {6060, 0}, {6070, 0}, {6080, 0}, {6090, 0}, {6100, 0},
|
|
47 {7000, 0}, {7010, 0}, {7020, 0}, {7030, 0}, {7040, 0}, {7050, 0}, {7060, 0}, {7070, 0}, {7080, 0}, {7090, 0}, {7100, 0},
|
|
48 {8000, 0}, {8010, 0}, {8020, 0}, {8030, 0}, {8040, 0}, {8050, 0}, {8060, 0}, {8070, 0}, {8080, 0}, {8090, 0}, {8100, 0},
|
|
49 {9000, 0}, {9010, 0}, {9020, 0}, {9030, 0}, {9040, 0}, {9050, 0}, {9060, 0}, {9070, 0}, {9080, 0}, {9090, 0}, {9100, 0},
|
|
50 {545, 0},
|
|
51 {545, 0},
|
|
52 {555, 0}
|
|
53 }};
|
|
54
|
|
55
|
|
56
|
|
57 SpellData::SpellData( __int16 innormalMana, __int16 inExpertLevelMana, __int16 inMasterLevelMana, __int16 inMagisterLevelMana,
|
|
58 __int16 inNormalLevelRecovery, __int16 inExpertLevelRecovery, __int16 inMasterLevelRecovery, __int16 inMagisterLevelRecovery,
|
|
59 __int8 inbaseDamage, __int8 inbonusSkillDamage, __int16 instats ):
|
|
60 uNormalLevelMana(innormalMana),
|
|
61 uExpertLevelMana(inExpertLevelMana),
|
|
62 uMasterLevelMana(inMasterLevelMana),
|
|
63 uMagisterLevelMana(inMagisterLevelMana),
|
|
64 uNormalLevelRecovery(inNormalLevelRecovery),
|
|
65 uExpertLevelRecovery(inExpertLevelRecovery),
|
|
66 uMasterLevelRecovery(inMasterLevelRecovery),
|
|
67 uMagisterLevelRecovery(inMagisterLevelRecovery),
|
|
68 baseDamage(inbaseDamage),
|
|
69 bonusSkillDamage(inbonusSkillDamage),
|
|
70 stats(instats)
|
|
71 {
|
|
72
|
|
73 }
|
|
74
|
|
75 //9 spellbook pages 11 spells per page 9*11 =99 +1 zero struct at 0. It counted from 1!
|
|
76 std::array<SpellData, 100> pSpellDatas={{
|
|
77 SpellData(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
|
|
78
|
|
79 SpellData(1, 1, 1, 1, 60, 60, 60, 40, 0, 0, 0),//0 fire
|
|
80 SpellData(2, 2, 2, 2, 110, 110, 100, 90, 3, 3, 0),
|
|
81 SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0),
|
|
82 SpellData(4, 4, 4, 4, 120, 120, 120, 120, 0, 0, 0),
|
|
83 SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0),
|
|
84 SpellData(8, 8, 8, 8, 100, 100, 90, 80, 0, 6, 0),
|
|
85 SpellData(10, 10, 10, 10, 150, 150, 150, 150, 0, 6, 0),
|
|
86 SpellData(15, 15, 15, 15, 120, 120, 120, 120, 0, 6, 0),
|
|
87 SpellData(20, 20, 20, 20, 100, 100, 100, 90, 8, 1, 0),
|
|
88 SpellData(25, 25, 25, 25, 100, 100, 100, 90, 12, 1, 0),
|
|
89 SpellData(30, 30, 30, 30, 90, 90, 90, 90, 15, 15, 0),
|
|
90
|
|
91 SpellData(1, 1, 1, 0, 60, 60, 60, 60, 0, 0, 0), //1 air
|
|
92 SpellData(2, 2, 2, 2, 120, 120, 120, 100, 0, 0, 0),
|
|
93 SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0),
|
|
94 SpellData(4, 4, 4, 4, 110, 100, 90, 80, 2, 1, 0),
|
|
95 SpellData(5, 5, 5, 5, 90, 90, 70, 50, 0, 0, 0),
|
|
96 SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0),
|
|
97 SpellData(10, 10, 10, 10, 100, 100, 90, 70, 0, 8, 0),
|
|
98 SpellData(15, 15, 15, 15, 200, 200, 200, 200, 0, 0, 0),
|
|
99 SpellData(20, 20, 20, 20, 100, 100, 100, 90, 10, 10, 0),
|
|
100 SpellData(25, 25, 25, 25, 250, 250, 250, 250, 0, 0, 0),
|
|
101 SpellData(30, 30, 30, 30, 90, 90, 90, 90, 20, 1, 0),
|
|
102
|
|
103 SpellData(1, 1, 1, 1, 60, 60, 60, 20, 0, 0, 0), //2 water
|
|
104 SpellData(2, 2, 2, 2, 110, 100, 90, 70, 2, 2, 0),
|
|
105 SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0),
|
|
106 SpellData(4, 4, 4, 4, 110, 100, 90, 80, 0, 4, 0),
|
|
107 SpellData(5, 5, 5, 5, 150, 150, 150, 150, 0, 0, 0),
|
|
108 SpellData(8, 8, 8, 8, 200, 200, 200, 200, 0, 0, 0),
|
|
109 SpellData(10, 10, 10, 10, 100, 100, 90, 80, 9, 9, 0),
|
|
110 SpellData(15, 15, 15, 15, 140, 140, 140, 140, 0, 0, 0),
|
|
111 SpellData(20, 20, 20, 20, 200, 200, 200, 200, 0, 0, 0),
|
|
112 SpellData(25, 25, 25, 25, 80, 80, 80, 80, 12, 3, 0),
|
|
113 SpellData(30, 30, 30, 30, 250, 250, 250, 250, 0, 0, 0),
|
|
114
|
|
115 SpellData(1, 1, 1, 1, 80, 80, 80, 80, 0, 0, 0), //3 earth
|
|
116 SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0),
|
|
117 SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0),
|
|
118 SpellData(4, 4, 4, 4, 110, 100, 90, 80, 5, 3, 0),
|
|
119 SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0),
|
|
120 SpellData(8, 8, 8, 8, 100, 100, 90, 80, 0, 9, 0),
|
|
121 SpellData(10, 10, 10, 10, 140, 140, 140, 140, 0, 0, 0),
|
|
122 SpellData(15, 15, 15, 15, 90, 90, 90, 80, 0, 8, 0),
|
|
123 SpellData(20, 20, 20, 20, 150, 150, 150, 150, 0, 0, 0),
|
|
124 SpellData(25, 25, 25, 25, 100, 100, 100, 90, 20, 1, 0),
|
|
125 SpellData(30, 30, 30, 30, 90, 90, 90, 90, 25, 0, 0),
|
|
126
|
|
127 SpellData(1, 1, 1, 1, 100, 100, 100, 100, 0, 0, 0), //4 spirit
|
|
128 SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0),
|
|
129 SpellData(3, 3, 3, 3, 90, 90, 90, 90, 0, 0, 0),
|
|
130 SpellData(4, 4, 4, 4, 120, 120, 120, 120, 0, 0, 0),
|
|
131 SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0),
|
|
132 SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0),
|
|
133 SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0),
|
|
134 SpellData(15, 15, 15, 15, 100, 100, 100, 100, 10, 8, 0),
|
|
135 SpellData(20, 20, 20, 20, 240, 240, 240, 240, 0, 0, 0),
|
|
136 SpellData(25, 25, 25, 25, 150, 150, 150, 150, 0, 0, 0),
|
|
137 SpellData(30, 30, 30, 30, 1000, 1000, 1000, 1000, 0, 0, 0),
|
|
138
|
|
139 SpellData(1, 1, 1, 1, 120, 120, 120, 120, 0, 0, 0), //5 mind
|
|
140 SpellData(2, 2, 2, 2, 110, 110, 110, 110, 3, 3, 0),
|
|
141 SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0),
|
|
142 SpellData(4, 4, 4, 4, 110, 100, 90, 80, 0, 0, 0),
|
|
143 SpellData(5, 5, 5, 5, 100, 100, 100, 100, 0, 0, 0),
|
|
144 SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0),
|
|
145 SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0),
|
|
146 SpellData(15, 15, 15, 15, 80, 80, 80, 80, 0, 0, 0),
|
|
147 SpellData(20, 20, 20, 20, 120, 120, 120, 120, 0, 0, 0),
|
|
148 SpellData(25, 25, 25, 25, 110, 110, 110, 100, 12, 12, 0),
|
|
149 SpellData(30, 30, 30, 30, 120, 120, 120, 120, 0, 0, 0),
|
|
150
|
|
151 SpellData(1, 1, 1, 1, 120, 120, 120, 120, 0, 0, 0), //6 body
|
|
152 SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0),
|
|
153 SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0),
|
|
154 SpellData(4, 4, 4, 4, 110, 100, 90, 80, 8, 2, 0),
|
|
155 SpellData(5, 5, 5, 5, 110, 110, 110, 110, 0, 0, 0),
|
|
156 SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0),
|
|
157 SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0),
|
|
158 SpellData(15, 15, 15, 15, 120, 120, 120, 120, 0, 0, 0),
|
|
159 SpellData(20, 20, 20, 20, 120, 120, 120, 120, 0, 0, 0),
|
|
160 SpellData(25, 25, 25, 25, 110, 110, 110, 100, 30, 5, 0),
|
|
161 SpellData(30, 30, 30, 30, 100, 100, 100, 100, 0, 0, 0),
|
|
162
|
|
163 SpellData(5, 5, 5, 5, 110, 100, 90, 80, 0, 4, 0), //7 light
|
|
164 SpellData(10, 10, 10, 10, 120, 110, 100, 90, 16, 16, 0),
|
|
165 SpellData(15, 15, 15, 15, 120, 110, 100, 90, 0, 0, 0),
|
|
166 SpellData(20, 20, 20, 20, 160, 140, 120, 100, 0, 0, 0),
|
|
167 SpellData(25, 25, 25, 25, 140, 140, 140, 140, 0, 0, 0),
|
|
168 SpellData(30, 30, 30, 30, 500, 500, 500, 500, 0, 0, 0),
|
|
169 SpellData(35, 35, 35, 35, 135, 135, 120, 100, 25, 1, 0),
|
|
170 SpellData(40, 40, 40, 40, 500, 500, 500, 500, 0, 0, 0),
|
|
171 SpellData(45, 45, 45, 45, 250, 250, 250, 250, 0, 0, 0),
|
|
172 SpellData(50, 50, 50, 50, 150, 150, 150, 135, 20, 20, 0),
|
|
173 SpellData(55, 55, 55, 55, 300, 300, 300, 300, 0, 0, 0),
|
|
174
|
|
175 SpellData(10, 10, 10, 10, 140, 140, 140, 140, 0, 0, 0), //8 dark
|
|
176 SpellData(15, 15, 15, 15, 120, 110, 100, 90, 25, 10, 0),
|
|
177 SpellData(20, 20, 20, 20, 120, 100, 90, 120, 0, 0, 0),
|
|
178 SpellData(25, 25, 25, 25, 120, 120, 120, 120, 0, 0, 0),
|
|
179 SpellData(30, 30, 30, 30, 90, 90, 80, 70, 6, 6, 0),
|
|
180 SpellData(35, 35, 35, 35, 120, 120, 100, 80, 0, 0, 0),
|
|
181 SpellData(40, 40, 40, 40, 110, 110, 110, 110, 0, 0, 0),
|
|
182 SpellData(45, 45, 45, 45, 200, 200, 200, 150, 0, 0, 0),
|
|
183 SpellData(50, 50, 50, 50, 120, 120, 120, 100, 0, 25, 0),
|
|
184 SpellData(55, 55, 55, 55, 250, 250, 250, 250, 50, 1, 0),
|
|
185 SpellData(60, 60, 60, 60, 300, 300, 300, 300, 25, 8, 0)
|
|
186 }};
|
|
187
|
|
188 std::array<unsigned int, 25> wand_spell_ids =
|
|
189 {
|
|
190 // 135 Wand of Fire 136 Wand of Sparks 137 Wand of Poison 138 Wand of Stunning 139 Wand of Harm
|
|
191 SPELL_FIRE_FIRE_BOLT, SPELL_AIR_SPARKS, SPELL_WATER_POISON_SPRAY, SPELL_EARTH_STUN, SPELL_BODY_HARM,
|
|
192 // 140 Fairy Wand of Light 141 Fairy Wand of Ice 142 Fairy Wand of Lashing 143 Fairy Wand of Mind 144 Fairy Wand of Swarms
|
|
193 SPELL_LIGHT_LIGHT_BOLT, SPELL_WATER_ICE_BOLT, SPELL_SPIRIT_SPIRIT_LASH, SPELL_MIND_MIND_BLAST, SPELL_EARTH_DEADLY_SWARM,
|
|
194 // 145 Alacorn Wand of Fireballs 146 Alacorn Wand of Acid 147 Alacorn Wand of Lightning 148 Alacorn Wand of Blades 149 Alacorn Wand of Charms
|
|
195 SPELL_FIRE_FIREBALL, SPELL_WATER_ACID_BURST, SPELL_AIR_LIGHNING_BOLT, SPELL_EARTH_BLADES, SPELL_MIND_CHARM,
|
|
196 // 150 Arcane Wand of Blasting 151 Arcane Wand of The Fist 152 Arcane Wand of Rocks 153 Arcane Wand of Paralyzing 154 Arcane Wand of Clouds
|
|
197 SPELL_WATER_ICE_BLAST, SPELL_BODY_FLYING_FIST, SPELL_EARTH_ROCK_BLAST, SPELL_LIGHT_PARALYZE, SPELL_DARK_TOXIC_CLOUD,
|
|
198 // 155 Mystic Wand of Implosion 156 Mystic Wand of Distortion 157 Mystic Wand of Sharpmetal 158 Mystic Wand of Shrinking 159 Mystic Wand of Incineration
|
|
199 SPELL_AIR_IMPLOSION, SPELL_EARTH_MASS_DISTORTION, SPELL_DARK_SHARPMETAL, SPELL_DARK_SHRINKING_RAY, SPELL_FIRE_INCINERATE
|
|
200 };
|
|
201
|
|
202
|
|
203 std::array<std::array<struct SpellBookIconPos, 12>, 9> pIconPos={{
|
|
204
|
|
205 { 0, 0, 17, 13, 115, 2, 217, 15,
|
|
206 299, 6, 28, 125, 130, 133, 294, 114,
|
|
207 11, 232, 134, 233, 237, 171, 296, 231},
|
|
208
|
|
209 { 0, 0, 19, 9, 117, 3, 206, 13,
|
|
210 285, 7, 16, 123, 113, 101, 201, 118,
|
|
211 317, 110, 11, 230, 149, 236, 296, 234},
|
|
212
|
|
213 { 0, 0, 17, 9, 140, 0, 210, 34,
|
|
214 293, 5, 15, 98, 78, 121, 175, 136,
|
|
215 301, 115, 15, 226, 154, 225, 272, 220},
|
|
216
|
|
217 { 0, 0, 7, 9, 156, 2, 277, 9,
|
|
218 11, 117, 111, 82, 180, 102, 303, 108,
|
|
219 10, 229, 120, 221, 201, 217, 296, 225},
|
|
220
|
|
221 { 0, 0, 18, 8, 89, 15, 192, 14,
|
|
222 292, 7, 22, 129, 125, 146, 217, 136,
|
|
223 305, 115, 22, 226, 174, 237, 290, 231},
|
|
224
|
|
225 { 0, 0, 18, 12, 148, 9, 292, 7,
|
|
226 17, 122, 121, 99, 220, 87, 293, 112,
|
|
227 13, 236, 128, 213, 220, 223, 315, 223},
|
|
228
|
|
229 { 0, 0, 23, 14, 127, 8, 204, 0,
|
|
230 306, 8, 14, 115, 122, 132, 200, 116,
|
|
231 293, 122, 20, 228, 154, 228, 294, 239},
|
|
232
|
|
233 { 0, 0, 19, 14, 124, 10, 283, 12,
|
|
234 8, 105, 113, 89, 190, 82, 298, 108,
|
|
235 18, 181, 101, 204, 204, 203, 285, 218},
|
|
236
|
|
237 { 0, 0, 18, 17, 110, 16, 201, 15,
|
|
238 307, 15, 18, 148, 125, 166, 201, 123,
|
|
239 275, 120, 28, 235, 217, 222, 324, 216}}};
|
|
240
|
|
241
|
|
242 //----- (0042EB31) --------------------------------------------------------
|
|
243 bool SpellBuff::NotExpired()
|
|
244 {
|
|
245 return (signed __int64)this->uExpireTime > 0 ? true:false;
|
|
246 }
|
|
247
|
|
248
|
|
249 //----- (00458585) --------------------------------------------------------
|
|
250 void SpellBuff::Reset()
|
|
251 {
|
|
252 uSkill = 0;
|
|
253 uPower = 0;
|
|
254 uExpireTime = 0i64;
|
|
255 uCaster = 0;
|
|
256 uFlags = 0;
|
|
257 if (uOverlayID)
|
|
258 {
|
|
259 pOtherOverlayList->pOverlays[uOverlayID - 1].Reset();
|
|
260 pOtherOverlayList->bRedraw = true;
|
|
261 uOverlayID = 0;
|
|
262 }
|
|
263 }
|
|
264
|
|
265 //----- (004585CA) --------------------------------------------------------
|
|
266 bool SpellBuff::IsBuffExpiredToTime( __int64 time_end )
|
|
267 {
|
|
268 if (uExpireTime && (uExpireTime < time_end))
|
|
269 {
|
|
270 uExpireTime = 0;
|
|
271 uPower = 0;
|
|
272 uSkill = 0;
|
|
273 uOverlayID = 0;
|
|
274 return true;
|
|
275 }
|
|
276 return false;
|
|
277 }
|
|
278
|
|
279 //----- (004584E0) --------------------------------------------------------
|
|
280 bool SpellBuff::Apply( signed __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int uOverlayID, unsigned __int8 caster )
|
|
281 {
|
|
282 if (this->uExpireTime && (uExpireTime < this->uExpireTime))
|
|
283 return false;
|
|
284
|
|
285 this->uSkill = uSkillLevel;
|
|
286 this->uPower = uPower;
|
|
287 this->uExpireTime = uExpireTime;
|
|
288 if (this->uOverlayID && this->uOverlayID != uOverlayID)
|
|
289 {
|
|
290 pOtherOverlayList->pOverlays[this->uOverlayID - 1].Reset();
|
|
291 pOtherOverlayList->bRedraw = true;
|
|
292 this->uOverlayID = 0;
|
|
293 }
|
|
294 this->uOverlayID = uOverlayID;
|
|
295 this->uCaster = caster;
|
|
296
|
|
297 return true;
|
|
298 }
|
|
299
|
|
300 //----- (0045384A) --------------------------------------------------------
|
|
301 void SpellStats::Initialize()
|
|
302 {
|
|
303 std::map<std::string, SPELL_SCHOOL, ci_less> spellSchoolMaps;
|
|
304 spellSchoolMaps["fire"] = SPELL_SCHOOL_FIRE;
|
|
305 spellSchoolMaps["air"] = SPELL_SCHOOL_AIR;
|
|
306 spellSchoolMaps["water"] = SPELL_SCHOOL_WATER;
|
|
307 spellSchoolMaps["earth"] = SPELL_SCHOOL_EARTH;
|
|
308 spellSchoolMaps["spirit"] = SPELL_SCHOOL_SPIRIT;
|
|
309 spellSchoolMaps["mind"] = SPELL_SCHOOL_MIND;
|
|
310 spellSchoolMaps["body"] = SPELL_SCHOOL_BODY;
|
|
311 spellSchoolMaps["light"] = SPELL_SCHOOL_LIGHT;
|
|
312 spellSchoolMaps["dark"] = SPELL_SCHOOL_DARK;
|
|
313 spellSchoolMaps["magic"] = SPELL_SCHOOL_MAGIC;
|
|
314
|
|
315 char* test_string;
|
|
316
|
|
317 free(pSpellsTXT_Raw);
|
|
318 pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0);
|
|
319
|
|
320 strtok(pSpellsTXT_Raw, "\r");
|
|
321 for(int i=1; i<100; ++i)
|
|
322 {
|
|
323 if (((i % 11) - 1 )==0)
|
|
324 strtok(NULL, "\r");
|
|
325 test_string=strtok(NULL, "\r")+1;
|
|
326 auto tokens = Tokenize(test_string, '\t');
|
|
327 pInfos[i].pName=RemoveQuotes(tokens[2]);
|
|
328 auto findResult = spellSchoolMaps.find(tokens[3]);
|
|
329 pInfos[i].uSchool = findResult == spellSchoolMaps.end() ? SPELL_SCHOOL_NONE : findResult->second;
|
|
330 pInfos[i].pShortName=RemoveQuotes(tokens[4]);
|
|
331 pInfos[i].pDescription=RemoveQuotes(tokens[5]);
|
|
332 pInfos[i].pBasicSkillDesc=RemoveQuotes(tokens[6]);
|
|
333 pInfos[i].pExpertSkillDesc=RemoveQuotes(tokens[7]);
|
|
334 pInfos[i].pMasterSkillDesc=RemoveQuotes(tokens[8]);
|
|
335 pInfos[i].pGrandmasterSkillDesc=RemoveQuotes(tokens[9]);
|
|
336 pSpellDatas[i].stats |= strchr(tokens[10], 'm') || strchr(tokens[10], 'M') ? 1 : 0;
|
|
337 pSpellDatas[i].stats |= strchr(tokens[10], 'e') || strchr(tokens[10], 'E') ? 2 : 0;
|
|
338 pSpellDatas[i].stats |= strchr(tokens[10], 'c') || strchr(tokens[10], 'C') ? 4 : 0;
|
|
339 pSpellDatas[i].stats |= strchr(tokens[10], 'x') || strchr(tokens[10], 'X') ? 8 : 0;
|
|
340 }
|
|
341 }
|
|
342 //----- (00448DF8) --------------------------------------------------------
|
|
343 void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz)//sub_448DF8
|
|
344 {
|
|
345 int v9; // esi@1
|
|
346 signed __int64 v10; // st7@4
|
|
347 signed __int64 v11; // st6@4
|
|
348 signed __int64 v12; // st5@4
|
|
349 double v13; // st7@6
|
|
350 int v14; // ST44_4@7
|
|
351 uint skillMasteryPlusOne; // ebx@9
|
|
352 uint v16; // edx@15
|
|
353 int i; // esi@42
|
|
354 int j; // esi@60
|
|
355 unsigned __int64 v36; // qax@99
|
|
356 // SpellBuff *v37; // ecx@99
|
|
357 int v38; // esi@103
|
|
358 signed __int64 v39; // qax@105
|
|
359 int v42; // esi@111
|
|
360 int v43; // ebx@111
|
|
361 int v47; // [sp-4h] [bp-B8h]@35
|
|
362 int v49; // [sp+0h] [bp-B4h]@35
|
|
363 int v55; // [sp+28h] [bp-8Ch]@7
|
|
364 unsigned int yaw; // [sp+30h] [bp-84h]@7
|
|
365 int pitch; // [sp+34h] [bp-80h]@7
|
|
366 int v60; // [sp+ACh] [bp-8h]@1
|
|
367 int a6_4; // [sp+C8h] [bp+14h]@117
|
|
368 int a7c; // [sp+CCh] [bp+18h]@29
|
|
369 int a7d; // [sp+CCh] [bp+18h]@55
|
|
370 signed __int64 xSquared; // [sp+D0h] [bp+1Ch]@6
|
|
371 int a8b; // [sp+D0h] [bp+1Ch]@37
|
|
372 int a8c; // [sp+D0h] [bp+1Ch]@55
|
|
373 signed __int64 ySquared; // [sp+D4h] [bp+20h]@6
|
|
374
|
|
375 v9 = 0;
|
|
376 skillMasteryPlusOne = uSkillLevel + 1;
|
|
377 //spellnum_ = uSpellID;
|
|
378 v60 = 0;
|
|
379 if ( tox || toy || toz )
|
|
380 {
|
|
381 v10 = tox - fromx;
|
|
382 v11 = toy - fromy;
|
|
383 v12 = toz - fromz;
|
|
384 }
|
|
385 else
|
|
386 {
|
|
387 v10 = pParty->vPosition.x - fromx;
|
|
388 v11 = pParty->vPosition.y - fromy;
|
|
389 v12 = (pParty->vPosition.z + pParty->sEyelevel) - fromz;
|
|
390 }
|
|
391 v13 = sqrt(long double(v10 * v10 + v11 * v11 + v12 * v12));
|
|
392 if ( v13 <= 1.0 )
|
|
393 {
|
|
394 v55 = 1;
|
|
395 yaw = 0;
|
|
396 pitch = 0;
|
|
397 }
|
|
398 else
|
|
399 {
|
|
400 v55 = (int)v13;
|
|
401 ySquared = v11 * v11;
|
|
402 xSquared = v10 * v10;
|
|
403 v14 = (int)sqrt(long double(xSquared + ySquared));
|
|
404 yaw = stru_5C6E00->Atan2((int)v10, (int)v11);
|
|
405 pitch = stru_5C6E00->Atan2(v14, (int)v12);
|
|
406 }
|
|
407 Assert(skillMasteryPlusOne > 0 && skillMasteryPlusOne <= 4, "Invalid mastery level");
|
|
408
|
|
409 SpriteObject a1; // [sp+38h] [bp-7Ch]@12
|
|
410 //SpriteObject::SpriteObject(&a1);
|
|
411
|
|
412 switch ( uSpellID )
|
|
413 {
|
|
414 case SPELL_FIRE_FIRE_BOLT:
|
|
415 case SPELL_FIRE_FIREBALL:
|
|
416 case SPELL_AIR_LIGHNING_BOLT:
|
|
417 case SPELL_WATER_ICE_BOLT:
|
|
418 case SPELL_WATER_ACID_BURST:
|
|
419 case SPELL_WATER_ICE_BLAST:
|
|
420 case SPELL_EARTH_BLADES:
|
|
421 case SPELL_EARTH_ROCK_BLAST:
|
|
422 case SPELL_WATER_POISON_SPRAY:
|
|
423 case SPELL_AIR_SPARKS:
|
|
424 case SPELL_EARTH_DEATH_BLOSSOM:
|
|
425 a1.uType = stru_4E3ACC[uSpellID].uType;
|
|
426 a1.stru_24.Reset();
|
|
427 a1.spell_id = uSpellID;
|
|
428 a1.spell_level = uSkill;
|
|
429 a1.spell_skill = skillMasteryPlusOne;
|
|
430 v16 = 0;
|
|
431 while (v16 < pObjectList->uNumObjects)
|
|
432 {
|
|
433 if ( a1.uType == pObjectList->pObjects[v16].uObjectID)
|
|
434 {
|
|
435 break;
|
|
436 }
|
|
437 v16++;
|
|
438 }
|
|
439 a1.uObjectDescID = v16;
|
|
440 a1.vPosition.x = fromx;
|
|
441 a1.vPosition.y = fromy;
|
|
442 a1.vPosition.z = fromz;
|
|
443 a1.uAttributes = 16;
|
|
444 a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
|
|
445 a1.field_60_distance_related_prolly_lod = v55;
|
|
446 a1.uSpriteFrameID = 0;
|
|
447 a1.spell_caster_pid = 8000 | OBJECT_Item;
|
|
448 a1.uSoundID = 0;
|
|
449 break;
|
|
450 }
|
|
451
|
|
452 switch ( uSpellID )
|
|
453 {
|
|
454 case SPELL_FIRE_FIRE_BOLT:
|
|
455 case SPELL_FIRE_FIREBALL:
|
|
456 case SPELL_AIR_LIGHNING_BOLT:
|
|
457 case SPELL_WATER_ICE_BOLT:
|
|
458 case SPELL_WATER_ACID_BURST:
|
|
459 case SPELL_WATER_ICE_BLAST:
|
|
460 case SPELL_EARTH_BLADES:
|
|
461 case SPELL_EARTH_ROCK_BLAST:
|
|
462 //v20 = yaw;
|
|
463 a1.spell_target_pid = 0;
|
|
464 a1.uFacing = yaw;
|
|
465 a1.uSoundID = 0;
|
|
466 v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
|
|
467 a1.Create(yaw, pitch, v49, 0);
|
|
468 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
|
|
469 return;
|
|
470 case SPELL_WATER_POISON_SPRAY:
|
|
471 switch ( skillMasteryPlusOne )
|
|
472 {
|
|
473 case 1:
|
|
474 v60 = 1;
|
|
475 break;
|
|
476 case 2:
|
|
477 v60 = 3;
|
|
478 break;
|
|
479 case 3:
|
|
480 v60 = 5;
|
|
481 break;
|
|
482 case 4:
|
|
483 v60 = 7;
|
|
484 break;
|
|
485 }
|
|
486 a1.spell_target_pid = 0;
|
|
487 a1.uFacing = yaw;
|
|
488 if ( v60 == 1 )
|
|
489 {
|
|
490 v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
|
|
491 a1.Create(yaw, pitch, v49, 0);
|
|
492 }
|
|
493 else
|
|
494 {
|
|
495 a7c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
|
|
496 a8b = a7c / (v60 - 1);
|
|
497 for ( i = a7c / -2; i <= a7c / 2; i += a8b )
|
|
498 {
|
|
499 a1.uFacing = i + yaw;
|
|
500 a1.Create((signed __int16)(i + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0);
|
|
501 }
|
|
502 }
|
|
503 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
|
|
504 return;
|
|
505 case SPELL_AIR_SPARKS:
|
|
506 switch ( skillMasteryPlusOne )
|
|
507 {
|
|
508 case 1:
|
|
509 v60 = 3;
|
|
510 break;
|
|
511 case 2:
|
|
512 v60 = 5;
|
|
513 break;
|
|
514 case 3:
|
|
515 v60 = 7;
|
|
516 break;
|
|
517 case 4:
|
|
518 v60 = 9;
|
|
519 break;
|
|
520 }
|
|
521 a7d = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
|
|
522 a8c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v60 - 1);
|
|
523 a1.spell_target_pid = 4;
|
|
524 for ( j = a7d / -2; j <= a7d / 2; j += a8c )
|
|
525 {
|
|
526 a1.uFacing = j + yaw;
|
|
527 a1.Create((signed __int16)(j + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0);
|
|
528 }
|
|
529 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
|
|
530 return;
|
|
531 case SPELL_EARTH_DEATH_BLOSSOM:
|
|
532 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
533 return;
|
|
534 a1.spell_target_pid = 4;
|
|
535 v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
|
|
536 v47 = (signed int)stru_5C6E00->uIntegerHalfPi / 2;
|
|
537 a1.Create(yaw, v47, v49, 0);
|
|
538 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
|
|
539 return;
|
|
540
|
|
541 case SPELL_FIRE_HASTE:
|
|
542 if ( skillMasteryPlusOne > 0 )
|
|
543 {
|
|
544 if ( skillMasteryPlusOne <= 2 )
|
|
545 v9 = 60 * (uSkill + 60);
|
|
546 else if ( skillMasteryPlusOne == 3 )
|
|
547 v9 = 180 * (uSkill + 20);
|
|
548 else if ( skillMasteryPlusOne == 4 )
|
|
549 v9 = 240 * (uSkill + 15);
|
|
550 }
|
|
551 for (uint i = 0; i < 4; ++i)
|
|
552 if (pParty->pPlayers[i].IsWeak())
|
|
553 return;
|
|
554 pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 * 128) * 0.033333335), skillMasteryPlusOne, 0, 0, 0);
|
2541
|
555 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0);
|
|
556 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1);
|
|
557 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2);
|
|
558 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3);
|
2499
|
559 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);//çâóê àëòàðÿ
|
|
560 return;
|
|
561 case SPELL_AIR_SHIELD:
|
|
562 case SPELL_EARTH_STONESKIN:
|
|
563 case SPELL_SPIRIT_HEROISM:
|
|
564 switch ( skillMasteryPlusOne )
|
|
565 {
|
|
566 case 1:
|
|
567 case 2:
|
|
568 v9 = 300 * (uSkill + 12);
|
|
569 break;
|
|
570 case 3:
|
|
571 v9 = 900 * (uSkill + 4);
|
|
572 break;
|
|
573 case 4:
|
|
574 v9 = 3600 * (uSkill + 1);
|
|
575 break;
|
|
576 }
|
|
577 switch ( uSpellID )
|
|
578 {
|
|
579 case SPELL_AIR_SHIELD:
|
|
580 v60 = 0;
|
|
581 uSkill = 14;
|
|
582 break;
|
|
583 case SPELL_EARTH_STONESKIN:
|
|
584 v60 = uSkill + 5;
|
|
585 uSkill = 15;
|
|
586 break;
|
|
587 case SPELL_SPIRIT_HEROISM:
|
|
588 v60 = uSkill + 5;
|
|
589 uSkill = 9;
|
|
590 break;
|
|
591 }
|
2541
|
592 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0);
|
|
593 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1);
|
|
594 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2);
|
|
595 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3);
|
2499
|
596 v36 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 << 7) * 0.033333335);
|
|
597 pParty->pPartyBuffs[uSkill].Apply(v36, skillMasteryPlusOne, v60, 0, 0);
|
|
598 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
|
|
599 return;
|
|
600 case SPELL_FIRE_IMMOLATION:
|
|
601 if (skillMasteryPlusOne == 4)
|
|
602 v38 = 600 * uSkill;
|
|
603 else
|
|
604 v38 = 60 * uSkill;
|
2541
|
605 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0);
|
|
606 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1);
|
|
607 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2);
|
|
608 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3);
|
2499
|
609 v39 = (signed __int64)((double)(v38 << 7) * 0.033333335);
|
|
610 v36 = pParty->uTimePlayed + v39;
|
|
611 pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(v36, skillMasteryPlusOne, uSkill, 0, 0);
|
|
612 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
|
|
613 return;
|
|
614 case SPELL_FIRE_PROTECTION_FROM_FIRE:
|
|
615 case SPELL_AIR_PROTECTION_FROM_AIR:
|
|
616 case SPELL_WATER_PROTECTION_FROM_WATER:
|
|
617 case SPELL_EARTH_PROTECTION_FROM_EARTH:
|
|
618 case SPELL_MIND_PROTECTION_FROM_MIND:
|
|
619 case SPELL_BODY_PROTECTION_FROM_BODY:
|
|
620 a6_4 = 3600 * uSkill;
|
|
621 switch (skillMasteryPlusOne)
|
|
622 {
|
|
623 case 1:
|
|
624 v60 = uSkill;
|
|
625 break;
|
|
626 case 2:
|
|
627 v60 = 2 * uSkill;
|
|
628 break;
|
|
629 case 3:
|
|
630 v60 = 3 * uSkill;
|
|
631 break;
|
|
632 case 4:
|
|
633 v60 = 4 * uSkill;
|
|
634 break;
|
|
635 }
|
|
636 switch ( uSpellID )
|
|
637 {
|
|
638 case SPELL_FIRE_PROTECTION_FROM_FIRE:
|
|
639 uSkill = PARTY_BUFF_RESIST_FIRE;
|
|
640 break;
|
|
641 case SPELL_AIR_PROTECTION_FROM_AIR:
|
|
642 uSkill = PARTY_BUFF_RESIST_AIR;
|
|
643 break;
|
|
644 case SPELL_WATER_PROTECTION_FROM_WATER:
|
|
645 uSkill = PARTY_BUFF_RESIST_WATER;
|
|
646 break;
|
|
647 case SPELL_EARTH_PROTECTION_FROM_EARTH:
|
|
648 uSkill = PARTY_BUFF_RESIST_EARTH;
|
|
649 break;
|
|
650 case SPELL_MIND_PROTECTION_FROM_MIND:
|
|
651 uSkill = PARTY_BUFF_RESIST_MIND;
|
|
652 break;
|
|
653 case SPELL_BODY_PROTECTION_FROM_BODY:
|
|
654 uSkill = PARTY_BUFF_RESIST_BODY;
|
|
655 break;
|
|
656 }
|
2541
|
657 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0);
|
|
658 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1);
|
|
659 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2);
|
|
660 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3);
|
2499
|
661 pParty->pPartyBuffs[uSkill].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)a6_4 * 4.2666669), skillMasteryPlusOne, v60, 0, 0);
|
|
662 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
|
|
663 return;
|
|
664 case SPELL_LIGHT_DAY_OF_THE_GODS :
|
|
665 switch (skillMasteryPlusOne)
|
|
666 {
|
|
667 case 2:
|
|
668 v42 = 10800 * uSkill;
|
|
669 v43 = 3 * uSkill + 10;
|
|
670 break;
|
|
671 case 3:
|
|
672 v42 = 18000 * uSkill;
|
|
673 v43 = 5 * uSkill + 10;
|
|
674 break;
|
|
675 case 4:
|
|
676 v42 = 14400 * uSkill;
|
|
677 v43 = 4 * uSkill + 10;
|
|
678 break;
|
|
679 }
|
2541
|
680 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0);
|
|
681 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1);
|
|
682 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2);
|
|
683 pEngine->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3);
|
2499
|
684 v39 = (signed __int64)((double)(v42 << 7) * 0.033333335);
|
|
685 v36 = pParty->uTimePlayed + v39;
|
|
686 pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(v36, skillMasteryPlusOne, v43, 0, 0);
|
|
687 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
|
|
688 return;
|
|
689 default:
|
|
690 return;
|
|
691 }
|
|
692 }
|
|
693 //----- (00427769) --------------------------------------------------------
|
|
694 bool sub_427769_isSpellQuickCastableOnShiftClick(unsigned int uSpellID)
|
|
695 {
|
|
696 return ( pSpellDatas[uSpellID].stats & 0xC ) != 0;
|
|
697 }
|
|
698 //----- (0043AFE3) --------------------------------------------------------
|
|
699 int _43AFE3_calc_spell_damage(int spellId, int spellLevel, signed int skillMastery, int currentHp)
|
|
700 {
|
|
701 int result; // eax@1
|
|
702 unsigned int v5; // [sp-4h] [bp-8h]@9
|
|
703
|
|
704 result = 0;
|
|
705 if ( spellId == SPELL_FIRE_FIRE_SPIKE )
|
|
706 {
|
|
707 switch (skillMastery)
|
|
708 {
|
|
709 case 1:
|
|
710 case 2:
|
|
711 v5 = 6;
|
|
712 case 3:
|
|
713 v5 = 8;
|
|
714 case 4:
|
|
715 v5 = 10;
|
|
716 default:
|
|
717 return 0;
|
|
718 }
|
|
719 result = GetDiceResult(spellLevel, v5);
|
|
720 }
|
|
721 else if ( spellId == SPELL_EARTH_MASS_DISTORTION )
|
|
722 result = currentHp * (pSpellDatas[SPELL_EARTH_MASS_DISTORTION].baseDamage + 2 * spellLevel) / 100;
|
|
723 else
|
|
724 result = pSpellDatas[spellId].baseDamage
|
|
725 + GetDiceResult(spellLevel, pSpellDatas[spellId].bonusSkillDamage);
|
|
726
|
|
727 return result;
|
|
728 } |