2498
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
2541
|
6
|
|
7 #include "Engine/Engine.h"
|
|
8
|
2498
|
9 #include "Engine/Graphics/Sprites.h"
|
|
10 #include "Engine/Graphics/BSPModel.h"
|
|
11 #include "SpriteObject.h"
|
2499
|
12 #include "../Party.h"
|
|
13 #include "../TurnEngine/TurnEngine.h"
|
|
14 #include "../OurMath.h"
|
2498
|
15 #include "ObjectList.h"
|
|
16 #include "Engine/Graphics/Outdoor.h"
|
|
17 #include "Engine/Graphics/ParticleEngine.h"
|
2499
|
18 #include "../Timer.h"
|
|
19 #include "../LOD.h"
|
2498
|
20 #include "Actor.h"
|
2499
|
21 #include "../Events.h"
|
2502
|
22 #include "Media/Audio/AudioPlayer.h"
|
2498
|
23 #include "Engine/Graphics/Level/Decoration.h"
|
2499
|
24 #include "../stru298.h"
|
|
25 #include "../Random.h"
|
2498
|
26
|
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33
|
|
34 size_t uNumSpriteObjects;
|
|
35 std::array<SpriteObject, MAX_SPRITE_OBJECTS> pSpriteObjects;
|
|
36
|
|
37 //----- (00404828) --------------------------------------------------------
|
|
38 SpriteObject::SpriteObject()
|
|
39 {
|
|
40 field_22_glow_radius_multiplier = 1;
|
|
41 uSoundID = 0;
|
|
42 uFacing = 0;
|
|
43 vVelocity.z = 0;
|
|
44 vVelocity.y = 0;
|
|
45 vVelocity.x = 0;
|
|
46 uType = 0;
|
|
47 uObjectDescID = 0;
|
|
48 field_61 = 0;
|
|
49 field_60_distance_related_prolly_lod = 0;
|
|
50 field_20 = 0;
|
|
51 uSpriteFrameID = 0;
|
|
52 spell_skill = 0;
|
|
53 spell_level = 0;
|
|
54 spell_id = 0;
|
|
55 field_54 = 0;
|
|
56 }
|
|
57
|
|
58 //----- (0042F5ED) --------------------------------------------------------
|
|
59 int SpriteObject::Create(int yaw, int pitch, int a4, int a5)
|
|
60 {
|
|
61 signed int v6; // ebx@2
|
|
62 int v13; // ST2C_4@20
|
|
63 Vec3_int_ v17; // [sp-20h] [bp-30h]@11
|
|
64 int angle; // [sp+Ch] [bp-4h]@1
|
|
65 int a5a; // [sp+20h] [bp+10h]@20
|
|
66
|
|
67 angle = yaw;
|
|
68 if (!uObjectDescID)
|
|
69 return -1;
|
|
70
|
|
71 v6 = 1000;
|
|
72 for (uint i = 0; i < MAX_SPRITE_OBJECTS; ++i)
|
|
73 if (!pSpriteObjects[i].uObjectDescID)
|
|
74 {
|
|
75 v6 = i;
|
|
76 break;
|
|
77 }
|
|
78
|
|
79 if ( v6 >= 1000 )
|
|
80 return -1;
|
|
81 field_64.x = vPosition.x;
|
|
82 field_64.y = vPosition.y;
|
|
83 field_64.z = vPosition.z;
|
|
84
|
|
85 assert(sizeof(SpriteObject) == 0x70);
|
|
86
|
|
87 switch (a5)
|
|
88 {
|
|
89 case 0:
|
|
90 break; //do nothing
|
|
91 case 1:
|
|
92 Vec3_int_::Rotate(24, stru_5C6E00->uIntegerHalfPi + uFacing, 0, vPosition, &vPosition.x,
|
|
93 &vPosition.y, &vPosition.z);
|
|
94 break;
|
|
95 case 2:
|
|
96 Vec3_int_::Rotate(8, stru_5C6E00->uIntegerHalfPi + uFacing, 0, vPosition, &vPosition.x,
|
|
97 &vPosition.y, &vPosition.z);
|
|
98 break;
|
|
99 case 3:
|
|
100 Vec3_int_::Rotate(8, uFacing - stru_5C6E00->uIntegerHalfPi, 0, vPosition, &vPosition.x,
|
|
101 &vPosition.y, &vPosition.z);
|
|
102 break;
|
|
103 case 4:
|
|
104 Vec3_int_::Rotate(24, uFacing - stru_5C6E00->uIntegerHalfPi, 0, vPosition, &vPosition.x,
|
|
105 &vPosition.y, &vPosition.z);
|
|
106 break;
|
|
107 default:
|
|
108 assert(false);
|
|
109 return 0;
|
|
110 break;
|
|
111 }
|
|
112
|
|
113 if ( a4 )
|
|
114 {
|
|
115 v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch));
|
|
116 a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch));
|
|
117 vVelocity.x = fixpoint_mul(v13, a4);
|
|
118 vVelocity.y = fixpoint_mul(a5a, a4);
|
|
119 vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4);
|
|
120 }
|
|
121 else
|
|
122 {
|
|
123 vVelocity.y = 0;
|
|
124 vVelocity.x = 0;
|
|
125 vVelocity.z = 0;
|
|
126 }
|
|
127
|
|
128 memcpy(&pSpriteObjects[v6], this, sizeof(*this));
|
|
129 if ( v6 >= (signed int)uNumSpriteObjects )
|
|
130 uNumSpriteObjects = v6 + 1;
|
|
131 return v6;
|
|
132 }
|
|
133
|
|
134 //----- (00471C03) --------------------------------------------------------
|
|
135 void SpriteObject::UpdateObject_fn0_ODM(unsigned int uLayingItemID)
|
|
136 {
|
|
137 ObjectDesc *object; // ebx@1
|
|
138 int v6; // eax@1
|
|
139 int v7; // ecx@1
|
|
140 int v8; // edi@1
|
|
141 int v9; // eax@4
|
|
142 // int v17; // ST10_4@25
|
|
143 //signed int v19; // eax@28
|
|
144 //Actor *v20; // edi@31
|
|
145 int v21; // eax@41
|
|
146 // int v22; // ecx@43
|
|
147 // __int16 v23; // bx@45
|
|
148 // char v24; // al@46
|
|
149 signed int i; // edi@50
|
|
150 int v26; // edi@52
|
|
151 int v27; // eax@52
|
|
152 __int16 v28; // cx@55
|
|
153 int v29; // eax@55
|
|
154 //signed int v30; // edi@59
|
|
155 BSPModel *bmodel; // ecx@61
|
|
156 ODMFace *face; // edi@61
|
|
157 // int v33; // eax@62
|
|
158 // int v34; // ecx@62
|
|
159 int v35; // eax@63
|
|
160 int v36; // ecx@67
|
|
161 __int16 v37; // ax@67
|
|
162 int v38; // eax@72
|
|
163 //int v39; // eax@72
|
|
164 // unsigned __int64 v40; // qax@72
|
|
165 // int v41; // eax@72
|
|
166 // unsigned __int8 v42; // sf@74
|
|
167 // unsigned __int8 v43; // of@74
|
|
168 int v44; // eax@77
|
|
169 // __int16 v45; // bx@81
|
|
170 // int v46; // eax@85
|
|
171 // const char *v47; // [sp-8h] [bp-B0h]@83
|
|
172 // enum TEXTURE_TYPE v48; // [sp-4h] [bp-ACh]@46
|
|
173 int v49; // [sp+Ch] [bp-9Ch]@52
|
|
174 int v50; // [sp+10h] [bp-98h]@52
|
|
175 Vec3_int_ v51; // [sp+14h] [bp-94h]@11
|
|
176 Particle_sw Dst; // [sp+20h] [bp-88h]@45
|
|
177 int v54; // [sp+8Ch] [bp-1Ch]@1
|
|
178 int v55; // [sp+90h] [bp-18h]@1
|
|
179 int v56; // [sp+94h] [bp-14h]@11
|
|
180 int v57; // [sp+98h] [bp-10h]@1
|
|
181 int v58; // [sp+9Ch] [bp-Ch]@1
|
|
182 int on_water; // [sp+A0h] [bp-8h]@1
|
|
183 int v60; // [sp+A4h] [bp-4h]@11
|
|
184
|
|
185 v58 = 0;
|
|
186 object = &pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID];
|
|
187 v57 = IsTerrainSlopeTooHigh(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y);
|
|
188 v55 = 0;
|
|
189 v6 = ODM_GetFloorLevel(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uHeight, &on_water, &v55, 0);
|
|
190 v7 = v6;
|
|
191 v54 = v6;
|
|
192 v8 = v6 + 1;
|
|
193 if ( pSpriteObjects[uLayingItemID].vPosition.z <= v6 + 1 )
|
|
194 {
|
|
195 if ( on_water )
|
|
196 {
|
|
197 v9 = v6 + 60;
|
|
198 if ( v55 )
|
|
199 v9 = v6 + 30;
|
|
200 sub_42F960_create_object(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, v9);
|
|
201 SpriteObject::OnInteraction(uLayingItemID);
|
|
202 }
|
|
203 }
|
|
204 else
|
|
205 v58 = 1;
|
|
206 if ( !(object->uFlags & OBJECT_DESC_NO_GRAVITY) )
|
|
207 {
|
|
208 if ( v58 )
|
|
209 {
|
|
210 pSpriteObjects[uLayingItemID].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
|
|
211 goto LABEL_13;
|
|
212 }
|
|
213 if ( v57 )
|
|
214 {
|
|
215 pSpriteObjects[uLayingItemID].vPosition.z = v8;
|
|
216 ODM_GetTerrainNormalAt(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, &v51);
|
|
217 pSpriteObjects[uLayingItemID].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
|
|
218 v56 = abs(v51.y * pSpriteObjects[uLayingItemID].vVelocity.y + v51.z * pSpriteObjects[uLayingItemID].vVelocity.z + v51.x * pSpriteObjects[uLayingItemID].vVelocity.x) >> 16;
|
|
219 //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16);
|
|
220 pSpriteObjects[uLayingItemID].vVelocity.x += fixpoint_mul(v56, v51.x);
|
|
221 //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16);
|
|
222 pSpriteObjects[uLayingItemID].vVelocity.y += fixpoint_mul(v56, v51.y);
|
|
223 //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16);
|
|
224 pSpriteObjects[uLayingItemID].vVelocity.z += fixpoint_mul(v56, v51.z);
|
|
225 v7 = v54;
|
|
226 goto LABEL_13;
|
|
227 }
|
|
228 if ( object->uFlags & OBJECT_DESC_INTERACTABLE )
|
|
229 {
|
|
230 if ( pSpriteObjects[uLayingItemID].vPosition.z < v7 )
|
|
231 pSpriteObjects[uLayingItemID].vPosition.z = v8;
|
|
232 if ( !_46BFFA_check_object_intercept(uLayingItemID, 0) )
|
|
233 return;
|
|
234 }
|
|
235 pSpriteObjects[uLayingItemID].vPosition.z = v8;
|
|
236 if ( !(object->uFlags & OBJECT_DESC_BOUNCE) || (v21 = -pSpriteObjects[uLayingItemID].vVelocity.z >> 1, pSpriteObjects[uLayingItemID].vVelocity.z = v21, (signed __int16)v21 < 10) )
|
|
237 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
238
|
|
239 pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.x);
|
|
240 pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.y);
|
|
241 pSpriteObjects[uLayingItemID].vVelocity.z = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.z);
|
|
242 if ( (pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y
|
|
243 + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x) < 400 )
|
|
244 {
|
|
245 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
246 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
247 memset(&Dst, 0, 0x68u);
|
|
248 Dst.x = (double)pSpriteObjects[uLayingItemID].vPosition.x;
|
|
249 Dst.y = (double)pSpriteObjects[uLayingItemID].vPosition.y;
|
|
250 Dst.z = (double)pSpriteObjects[uLayingItemID].vPosition.z;
|
|
251 Dst.r = 0.0;
|
|
252 Dst.g = 0.0;
|
|
253 Dst.b = 0.0;
|
|
254 if (object->uFlags & OBJECT_DESC_TRIAL_FIRE )
|
|
255 {
|
|
256 Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
|
|
257 Dst.uDiffuse = 0xFF3C1E;
|
|
258 Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
|
|
259 Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
|
|
260 Dst.flt_28 = 1.0;
|
2541
|
261 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
262 }
|
|
263 else if ( object->uFlags & OBJECT_DESC_TRIAL_LINE)
|
|
264 {
|
|
265 Dst.type = ParticleType_Line;
|
|
266 Dst.uDiffuse = rand();
|
|
267 Dst.timeToLive = 64;
|
|
268 Dst.uTextureID = 0;
|
|
269 Dst.flt_28 = 1.0;
|
2541
|
270 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
271 }
|
|
272 else if ( object->uFlags & OBJECT_DESC_TRIAL_PARTICLE )
|
|
273 {
|
|
274 Dst.type = ParticleType_Bitmap | ParticleType_8;
|
|
275 Dst.uDiffuse = rand();
|
|
276 Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
|
|
277 Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
|
|
278 Dst.flt_28 = 1.0;
|
2541
|
279 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
280 }
|
|
281 return;
|
|
282 }
|
|
283 }
|
|
284 LABEL_13:
|
|
285 if ( pSpriteObjects[uLayingItemID].vPosition.x >= -0x8000 && pSpriteObjects[uLayingItemID].vPosition.x <= 0x8000
|
|
286 && pSpriteObjects[uLayingItemID].vPosition.y >= -0x8000 && pSpriteObjects[uLayingItemID].vPosition.y <= 0x8000
|
|
287 && pSpriteObjects[uLayingItemID].vPosition.z > v7 && pSpriteObjects[uLayingItemID].vPosition.z <= 13000
|
|
288 || !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
|
|
289 goto LABEL_92;
|
|
290 if ( pSpriteObjects[uLayingItemID].vPosition.z < v7 )
|
|
291 pSpriteObjects[uLayingItemID].vPosition.z = v8;
|
|
292 if ( _46BFFA_check_object_intercept(uLayingItemID, 0) )
|
|
293 {
|
|
294 LABEL_92:
|
|
295 stru_721530.field_0 = 0;
|
|
296 stru_721530.prolly_normal_d = object->uRadius;
|
|
297 stru_721530.height = object->uHeight;
|
|
298 stru_721530.field_8_radius = 0;
|
|
299 stru_721530.field_70 = 0;
|
|
300 for ( v55 = 0; v55 < 100; ++v55 )
|
|
301 {
|
|
302 stru_721530.position.x = pSpriteObjects[uLayingItemID].vPosition.x;
|
|
303 stru_721530.normal.x = stru_721530.position.x;
|
|
304 stru_721530.uSectorID = 0;
|
|
305 stru_721530.position.y = pSpriteObjects[uLayingItemID].vPosition.y;
|
|
306 stru_721530.normal.y = pSpriteObjects[uLayingItemID].vPosition.y;
|
|
307 stru_721530.position.z = pSpriteObjects[uLayingItemID].vPosition.z + stru_721530.prolly_normal_d + 1;
|
|
308 stru_721530.normal.z = stru_721530.position.z;
|
|
309 stru_721530.velocity.x = pSpriteObjects[uLayingItemID].vVelocity.x;
|
|
310 stru_721530.velocity.y = pSpriteObjects[uLayingItemID].vVelocity.y;
|
|
311 stru_721530.velocity.z = pSpriteObjects[uLayingItemID].vVelocity.z;
|
|
312 if ( stru_721530._47050A(0) )
|
|
313 return;
|
|
314 _46E889_collide_against_bmodels(0);
|
|
315 _46E26D_collide_against_sprites(WorldPosToGridCellX(pSpriteObjects[uLayingItemID].vPosition.x), WorldPosToGridCellZ(pSpriteObjects[uLayingItemID].vPosition.y));
|
|
316 if (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) != OBJECT_Player)
|
|
317 _46EF01_collision_chech_player(0);
|
|
318 if (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Actor)
|
|
319 {
|
|
320 if (( PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) >= 0 )
|
|
321 &&( PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) < (signed int)(uNumActors - 1) ))
|
|
322 {
|
|
323 for (v56 =0; v56 < uNumActors; ++v56)
|
|
324 {
|
|
325 if ( pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].GetActorsRelation(&pActors[v56]) )
|
|
326 Actor::_46DF1A_collide_against_actor(v56, 0);
|
|
327 }
|
|
328 }
|
|
329 }
|
|
330 else
|
|
331 {
|
|
332 for ( i = 0; i < (signed int)uNumActors; ++i )
|
|
333 Actor::_46DF1A_collide_against_actor(i, 0);
|
|
334 }
|
|
335 v26 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
|
|
336 v27 = ODM_GetFloorLevel( stru_721530.normal2.x, stru_721530.normal2.y, stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
|
|
337 object->uHeight, &v49, &v50, 0);
|
|
338 if ( on_water && v26 < v27 + 60 )
|
|
339 {
|
|
340 if ( v50 )
|
|
341 v44 = v27 + 30;
|
|
342 else
|
|
343 v44 = v54 + 60;
|
|
344 sub_42F960_create_object(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, v44);
|
|
345 SpriteObject::OnInteraction(uLayingItemID);
|
|
346 return;
|
|
347 }
|
|
348 if ( stru_721530.field_7C >= stru_721530.field_6C )
|
|
349 {
|
|
350 pSpriteObjects[uLayingItemID].vPosition.x = stru_721530.normal2.x;
|
|
351 pSpriteObjects[uLayingItemID].vPosition.y = stru_721530.normal2.y;
|
|
352 pSpriteObjects[uLayingItemID].vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
|
|
353 pSpriteObjects[uLayingItemID].uSectorID = LOWORD(stru_721530.uSectorID);
|
|
354 memset(&Dst, 0, 0x68u);
|
|
355 Dst.x = (double)pSpriteObjects[uLayingItemID].vPosition.x;
|
|
356 Dst.y = (double)pSpriteObjects[uLayingItemID].vPosition.y;
|
|
357 Dst.z = (double)pSpriteObjects[uLayingItemID].vPosition.z;
|
|
358 Dst.r = 0.0;
|
|
359 Dst.g = 0.0;
|
|
360 Dst.b = 0.0;
|
|
361 if ( object->uFlags & OBJECT_DESC_TRIAL_FIRE )
|
|
362 {
|
|
363 Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
|
|
364 Dst.uDiffuse = 0xFF3C1E;
|
|
365 Dst.timeToLive = (unsigned __int8)( rand() & 0x80) + 128;
|
|
366 Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
|
|
367 Dst.flt_28 = 1.0;
|
2541
|
368 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
369 return;
|
|
370 }
|
|
371 else if ( object->uFlags & OBJECT_DESC_TRIAL_LINE )
|
|
372 {
|
|
373 Dst.type = ParticleType_Line;
|
|
374 Dst.uTextureID = 0;
|
|
375 Dst.uDiffuse = rand();
|
|
376 Dst.timeToLive = 64;
|
|
377 Dst.flt_28 = 1.0;
|
2541
|
378 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
379 return;
|
|
380 }
|
|
381 else if ( object->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
|
|
382 {
|
|
383 Dst.type = ParticleType_Bitmap | ParticleType_8;
|
|
384 Dst.uDiffuse = rand();
|
|
385 Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
|
|
386 Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
|
|
387 Dst.flt_28 = 1.0;
|
2541
|
388 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
389 }
|
|
390 return;
|
|
391 }
|
|
392 //v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16);
|
|
393 pSpriteObjects[uLayingItemID].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
|
|
394 //v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16);
|
|
395 pSpriteObjects[uLayingItemID].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
|
|
396 //v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16);
|
|
397 v28 = LOWORD(stru_721530.uSectorID);
|
|
398 pSpriteObjects[uLayingItemID].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
|
|
399 v29 = pSpriteObjects[uLayingItemID].vPosition.z;
|
|
400 pSpriteObjects[uLayingItemID].uSectorID = v28;
|
|
401 stru_721530.field_70 += stru_721530.field_7C;
|
|
402 if ( object->uFlags & OBJECT_DESC_INTERACTABLE )
|
|
403 {
|
|
404 if ( v29 < v54 )
|
|
405 pSpriteObjects[uLayingItemID].vPosition.z = v54 + 1;
|
|
406 if ( !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
|
|
407 return;
|
|
408 }
|
|
409 if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
|
|
410 break;
|
|
411 if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
|
|
412 {
|
|
413 bmodel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
|
|
414 face = &bmodel->pFaces[PID_ID(stru_721530.uFaceID) & 0x3F];
|
|
415 if ( face->uPolygonType == POLYGON_Floor )
|
|
416 {
|
|
417 pSpriteObjects[uLayingItemID].vPosition.z = bmodel->pVertices.pVertices[face->pVertexIDs[0]].z + 1;
|
|
418 if ( pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x
|
|
419 + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y >= 400 )
|
|
420 {
|
|
421 if ( face->uAttributes & FACE_UNKNOW2 )
|
|
422 EventProcessor(face->sCogTriggeredID, 0, 1);
|
|
423 }
|
|
424 else
|
|
425 {
|
|
426 LOWORD(v35) = 0;
|
|
427 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
428 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
429 pSpriteObjects[uLayingItemID].vVelocity.y = v35;
|
|
430 }
|
|
431 }
|
|
432 else
|
|
433 {
|
|
434 v56 = abs(face->pFacePlane.vNormal.x * pSpriteObjects[uLayingItemID].vVelocity.x
|
|
435 + face->pFacePlane.vNormal.y * pSpriteObjects[uLayingItemID].vVelocity.y
|
|
436 + face->pFacePlane.vNormal.z * pSpriteObjects[uLayingItemID].vVelocity.z) >> 16;
|
|
437 if ( (stru_721530.speed >> 3) > v56 )
|
|
438 v56 = stru_721530.speed >> 3;
|
|
439 //v57 = fixpoint_mul(v56, face->pFacePlane.vNormal.x);
|
|
440 //v58 = fixpoint_mul(v56, face->pFacePlane.vNormal.y);
|
|
441 v60 = fixpoint_mul(v56, face->pFacePlane.vNormal.z);
|
|
442 pSpriteObjects[uLayingItemID].vVelocity.x += 2 * fixpoint_mul(v56, face->pFacePlane.vNormal.x);
|
|
443 pSpriteObjects[uLayingItemID].vVelocity.y += 2 * fixpoint_mul(v56, face->pFacePlane.vNormal.y);
|
|
444 if ( face->pFacePlane.vNormal.z <= 32000 )
|
|
445 v37 = 2 * (short)v60;
|
|
446 else
|
|
447 {
|
|
448 v36 = v60;
|
|
449 pSpriteObjects[uLayingItemID].vVelocity.z += (signed __int16)v60;
|
|
450 v58 = fixpoint_mul(0x7D00, v36);
|
|
451 v37 = fixpoint_mul(32000, v36);
|
|
452 }
|
|
453 pSpriteObjects[uLayingItemID].vVelocity.z += v37;
|
|
454 if ( face->uAttributes & FACE_UNKNOW2 )
|
|
455 EventProcessor(face->sCogTriggeredID, 0, 1);
|
|
456 }
|
|
457 }
|
|
458 LABEL_74:
|
|
459 pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.x);
|
|
460 pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.y);
|
|
461 pSpriteObjects[uLayingItemID].vVelocity.z = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.z);
|
|
462 }
|
|
463 v57 = integer_sqrt(pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x
|
|
464 + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y);
|
|
465 v38 = stru_5C6E00->Atan2(pSpriteObjects[uLayingItemID].vPosition.x - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.x,
|
|
466 pSpriteObjects[uLayingItemID].vPosition.y - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.y);
|
|
467 pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v38), v57);
|
|
468 pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v38 - stru_5C6E00->uIntegerHalfPi), v57);
|
|
469 goto LABEL_74;
|
|
470 }
|
|
471 }
|
|
472
|
|
473 //----- (0047136C) --------------------------------------------------------
|
|
474 void SpriteObject::UpdateObject_fn0_BLV(unsigned int uLayingItemID)
|
|
475 {
|
|
476 SpriteObject *pSpriteObject; // esi@1
|
|
477 ObjectDesc *pObject; // edi@1
|
|
478 // int v9; // ecx@16
|
|
479 // __int16 v10; // di@18
|
|
480 // int v14; // ebx@34
|
|
481 signed int v15; // ebx@46
|
|
482 int v17; // eax@50
|
|
483 // int v18; // eax@52
|
|
484 // int v19; // ecx@52
|
|
485 // Vec3_short_ *v20; // ecx@53
|
|
486 __int16 v22; // ax@57
|
|
487 int v23; // edi@62
|
|
488 // unsigned __int8 v27; // sf@64
|
|
489 // unsigned __int8 v28; // of@64
|
|
490 // __int16 v29; // di@67
|
|
491 // char v30; // al@68
|
|
492 Particle_sw Dst; // [sp+Ch] [bp-84h]@18
|
|
493 unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4
|
|
494 int v39; // [sp+80h] [bp-10h]@33
|
|
495 int v40; // [sp+84h] [bp-Ch]@28
|
|
496 int v42; // [sp+8Ch] [bp-4h]@4
|
|
497
|
|
498 pSpriteObject = &pSpriteObjects[uLayingItemID];
|
|
499 pObject = &pObjectList->pObjects[pSpriteObject->uObjectDescID];
|
|
500 pSpriteObject->uSectorID = pIndoor->GetSector(pSpriteObject->vPosition.x, pSpriteObject->vPosition.y, pSpriteObject->vPosition.z);
|
|
501 v42 = BLV_GetFloorLevel(pSpriteObject->vPosition.x, pSpriteObject->vPosition.y, pSpriteObject->vPosition.z, pSpriteObject->uSectorID, &uFaceID);
|
|
502 if ( abs(pSpriteObject->vPosition.x) > 32767
|
|
503 || abs(pSpriteObject->vPosition.y) > 32767
|
|
504 || abs(pSpriteObject->vPosition.z) > 20000
|
|
505 || v42 <= -30000
|
|
506 && (pSpriteObject->uSectorID == 0))
|
|
507 // || (v42 = _46CEC3_get_floor_level(pSpriteObject->vPosition.x, pSpriteObject->vPosition.y, pSpriteObject->vPosition.z, v4, &uFaceID), v42 == -30000)) )
|
|
508 {
|
|
509 SpriteObject::OnInteraction(uLayingItemID);
|
|
510 return;
|
|
511 }
|
|
512 if ( pObject->uFlags & OBJECT_DESC_NO_GRAVITY )//íå ïàäàþùèå îáúåêòû
|
|
513 {
|
|
514 LABEL_25:
|
|
515 stru_721530.field_0 = 0;
|
|
516 stru_721530.prolly_normal_d = pObject->uRadius;
|
|
517 stru_721530.field_84 = -1;
|
|
518 stru_721530.height = pObject->uHeight;
|
|
519 stru_721530.field_8_radius = 0;
|
|
520 stru_721530.field_70 = 0;
|
|
521 for ( uFaceID = 0; uFaceID < 100; uFaceID++ )
|
|
522 {
|
|
523 stru_721530.position.x = pSpriteObject->vPosition.x;
|
|
524 stru_721530.position.y = pSpriteObject->vPosition.y;
|
|
525 stru_721530.position.z = stru_721530.prolly_normal_d + pSpriteObject->vPosition.z + 1;
|
|
526
|
|
527 stru_721530.normal.x = stru_721530.position.x;
|
|
528 stru_721530.normal.y = stru_721530.position.y;
|
|
529 stru_721530.normal.z = stru_721530.position.z;
|
|
530
|
|
531 stru_721530.velocity.x = pSpriteObject->vVelocity.x;
|
|
532 stru_721530.velocity.y = pSpriteObject->vVelocity.y;
|
|
533 stru_721530.velocity.z = pSpriteObject->vVelocity.z;
|
|
534
|
|
535 stru_721530.uSectorID = pSpriteObject->uSectorID;
|
|
536 if ( stru_721530._47050A(0) )
|
|
537 return;
|
|
538
|
|
539 for ( v40 = 0; v40 < 100; ++v40 )
|
|
540 {
|
|
541 _46E44E_collide_against_faces_and_portals(0);
|
|
542 _46E0B2_collide_against_decorations();
|
|
543 if (PID_TYPE(pSpriteObject->spell_caster_pid) != OBJECT_Player)
|
|
544 _46EF01_collision_chech_player(1);
|
|
545 if (PID_TYPE(pSpriteObject->spell_caster_pid) == OBJECT_Actor)
|
|
546 {
|
|
547 for ( v42 = 0; v42 < (signed int)uNumActors; ++v42 )
|
|
548 {
|
|
549 if( pActors[pSpriteObject->spell_caster_pid >> 3].pMonsterInfo.uID != pActors[v42].pMonsterInfo.uID )
|
|
550 //not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius
|
|
551 Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[pActors[v42].word_000086_some_monster_id-1].uToHitRadius);
|
|
552 }
|
|
553 }
|
|
554 else
|
|
555 {
|
|
556 for ( v42 = 0; v42 < (signed int)uNumActors; v42++ )
|
|
557 Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[pActors[v42].word_000086_some_monster_id-1].uToHitRadius);
|
|
558 }
|
|
559 if ( _46F04E_collide_against_portals() )
|
|
560 break;
|
|
561 }
|
|
562 if ( stru_721530.field_7C >= stru_721530.field_6C )
|
|
563 {
|
|
564 pSpriteObject->vPosition.x = stru_721530.normal2.x;
|
|
565 pSpriteObject->vPosition.y = stru_721530.normal2.y;
|
|
566 pSpriteObject->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
|
|
567 pSpriteObject->uSectorID = LOWORD(stru_721530.uSectorID);
|
|
568 if ( !(HIBYTE(pObject->uFlags) & 1) )
|
|
569 return;
|
|
570 memset(&Dst, 0, 0x68u);
|
|
571 Dst.x = (double)pSpriteObject->vPosition.x;
|
|
572 Dst.y = (double)pSpriteObject->vPosition.y;
|
|
573 Dst.z = (double)pSpriteObject->vPosition.z;
|
|
574 Dst.r = 0.0;
|
|
575 Dst.g = 0.0;
|
|
576 Dst.b = 0.0;
|
|
577 if ( pObject->uFlags & OBJECT_DESC_TRIAL_FIRE )
|
|
578 {
|
|
579 Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
|
|
580 Dst.uDiffuse = 0xFF3C1E;
|
|
581 Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
|
|
582 Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
|
|
583 Dst.flt_28 = 1.0;
|
2541
|
584 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
585 return;
|
|
586 }
|
|
587 else if ( pObject->uFlags & OBJECT_DESC_TRIAL_LINE )
|
|
588 {
|
|
589 Dst.type = ParticleType_Line;
|
|
590 Dst.uDiffuse = rand();
|
|
591 Dst.timeToLive = 64;
|
|
592 Dst.uTextureID = 0;
|
|
593 Dst.flt_28 = 1.0;
|
2541
|
594 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
595 return;
|
|
596 }
|
|
597 else if ( pObject->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
|
|
598 {
|
|
599 Dst.type = ParticleType_Bitmap | ParticleType_8;
|
|
600 Dst.uDiffuse = rand();
|
|
601 Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
|
|
602 Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
|
|
603 Dst.flt_28 = 1.0;
|
2541
|
604 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
605 }
|
|
606 return;
|
|
607 }
|
|
608 //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
|
|
609 pSpriteObject->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
|
|
610 //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16;
|
|
611 pSpriteObject->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
|
|
612 //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16;
|
|
613 pSpriteObject->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
|
|
614 pSpriteObject->uSectorID = stru_721530.uSectorID;
|
|
615 stru_721530.field_70 += stru_721530.field_7C;
|
|
616 if ( pObject->uFlags & OBJECT_DESC_INTERACTABLE && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
|
|
617 return;
|
|
618 v15 = (signed int)stru_721530.uFaceID >> 3;
|
|
619 if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
|
|
620 {
|
|
621 v40 = integer_sqrt(pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y);
|
|
622 v23 = stru_5C6E00->Atan2(pSpriteObject->vPosition.x - pLevelDecorations[v15].vPosition.x,
|
|
623 pSpriteObject->vPosition.y - pLevelDecorations[v15].vPosition.y);
|
|
624 pSpriteObject->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v23), v40);
|
|
625 pSpriteObject->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v23), v40);
|
|
626 }
|
|
627 if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
|
|
628 {
|
|
629 stru_721530.field_84 = (signed int)PID_ID(stru_721530.uFaceID);
|
|
630 if ( pIndoor->pFaces[v15].uPolygonType != POLYGON_Floor )
|
|
631 {
|
|
632 v42 = abs(pIndoor->pFaces[v15].pFacePlane_old.vNormal.x * pSpriteObject->vVelocity.x
|
|
633 + pIndoor->pFaces[v15].pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y
|
|
634 + pIndoor->pFaces[v15].pFacePlane_old.vNormal.z * pSpriteObject->vVelocity.z) >> 16;
|
|
635 if ( (stru_721530.speed >> 3) > v42 )
|
|
636 v42 = stru_721530.speed >> 3;
|
|
637 pSpriteObject->vVelocity.x += 2 * fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.x);
|
|
638 pSpriteObject->vVelocity.y += 2 * fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.y);
|
|
639 v39 = fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.z);
|
|
640 if ( pIndoor->pFaces[v15].pFacePlane_old.vNormal.z <= 32000 )
|
|
641 v22 = 2 * v39;
|
|
642 else
|
|
643 {
|
|
644 pSpriteObject->vVelocity.z += v39;
|
|
645 v22 = fixpoint_mul(32000, v39);
|
|
646 }
|
|
647 pSpriteObject->vVelocity.z += v22;
|
|
648 if ( pIndoor->pFaces[v15].uAttributes & FACE_UNKNOW2 )
|
|
649 EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1);
|
|
650 pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
|
|
651 pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
|
|
652 pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
|
|
653 continue;
|
|
654 }
|
|
655 if ( pObject->uFlags & OBJECT_DESC_BOUNCE )
|
|
656 {
|
|
657 v17 = -pSpriteObject->vVelocity.z / 2;
|
|
658 pSpriteObject->vVelocity.z = v17;
|
|
659 if ( (signed __int16)v17 < 10 )
|
|
660 pSpriteObject->vVelocity.z = 0;
|
|
661 if ( pIndoor->pFaces[v15].uAttributes & FACE_UNKNOW2 )
|
|
662 EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1);
|
|
663 pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
|
|
664 pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
|
|
665 pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
|
|
666 continue;
|
|
667 }
|
|
668 pSpriteObject->vVelocity.z = 0;
|
|
669 if ( pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y >= 400 )
|
|
670 {
|
|
671 if ( pIndoor->pFaces[v15].uAttributes & FACE_UNKNOW2 )
|
|
672 EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1);
|
|
673 pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
|
|
674 pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
|
|
675 pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
|
|
676 continue;
|
|
677 }
|
|
678 pSpriteObject->vVelocity.z = 0;
|
|
679 pSpriteObject->vVelocity.y = 0;
|
|
680 pSpriteObject->vVelocity.x = 0;
|
|
681 pSpriteObject->vPosition.z = pIndoor->pVertices[*pIndoor->pFaces[v15].pVertexIDs].z + 1;
|
|
682 }
|
|
683 pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
|
|
684 pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
|
|
685 pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
|
|
686 }
|
|
687 }
|
|
688 //äëÿ ïàäàþùèõ îáúåêòîâ(äëÿ ïðèìåðà âûáðîñ âåùè èç èíâåíòàðÿ)
|
|
689 if ( v42 <= pSpriteObject->vPosition.z - 3 )
|
|
690 {
|
|
691 pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
|
|
692 goto LABEL_25;
|
|
693 }
|
|
694 if ( !(pObject->uFlags & OBJECT_DESC_INTERACTABLE) || _46BFFA_check_object_intercept(uLayingItemID, 0) )
|
|
695 {
|
|
696 pSpriteObject->vPosition.z = v42 + 1;
|
|
697 if ( pIndoor->pFaces[uFaceID].uPolygonType == POLYGON_Floor )
|
|
698 pSpriteObject->vVelocity.z = 0;
|
|
699 else
|
|
700 {
|
|
701 if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 45000 )
|
|
702 pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
|
|
703 }
|
|
704 pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
|
|
705 pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
|
|
706 pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
|
|
707 if ( pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 )
|
|
708 {
|
|
709 pSpriteObject->vVelocity.x = 0;
|
|
710 pSpriteObject->vVelocity.y = 0;
|
|
711 pSpriteObject->vVelocity.z = 0;
|
|
712 if ( !(pObject->uFlags & OBJECT_DESC_NO_SPRITE) )
|
|
713 return;
|
|
714 memset(&Dst, 0, 0x68u);
|
|
715 Dst.x = (double)pSpriteObject->vPosition.x;
|
|
716 Dst.y = (double)pSpriteObject->vPosition.y;
|
|
717 Dst.z = (double)pSpriteObject->vPosition.z;
|
|
718 Dst.r = 0.0;
|
|
719 Dst.g = 0.0;
|
|
720 Dst.b = 0.0;
|
|
721 if ( pObject->uFlags & OBJECT_DESC_TRIAL_FIRE )
|
|
722 {
|
|
723 Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
|
|
724 Dst.uDiffuse = 0xFF3C1E;
|
|
725 Dst.flt_28 = 1.0;
|
|
726 Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
|
|
727 Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
|
2541
|
728 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
729 return;
|
|
730 }
|
|
731 else if ( pObject->uFlags & OBJECT_DESC_TRIAL_LINE )
|
|
732 {
|
|
733 Dst.type = ParticleType_Line;
|
|
734 Dst.uDiffuse = rand();
|
|
735 Dst.timeToLive = 64;
|
|
736 Dst.uTextureID = 0;
|
|
737 Dst.flt_28 = 1.0;
|
2541
|
738 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
739 return;
|
|
740 }
|
|
741 else if ( pObject->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
|
|
742 {
|
|
743 Dst.type = ParticleType_Bitmap | ParticleType_8;
|
|
744 Dst.uDiffuse = rand();
|
|
745 Dst.flt_28 = 1.0;
|
|
746 Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
|
|
747 Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
|
2541
|
748 pEngine->pParticleEngine->AddParticle(&Dst);
|
2498
|
749 }
|
|
750 return;
|
|
751 }
|
|
752 goto LABEL_25;
|
|
753 }
|
|
754 }
|
|
755 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
|
|
756
|
|
757 //----- (00438E35) --------------------------------------------------------
|
|
758 void SpriteObject::ExplosionTraps()
|
|
759 {
|
|
760 MapInfo *pMapInfo; // esi@1
|
|
761 int dir_x; // ebx@1
|
|
762 int v7; // edx@2
|
|
763 unsigned int v10; // eax@7
|
|
764 signed int v11; // ebx@8
|
|
765 signed int v13; // edi@20
|
|
766 int dir_y; // [sp+Ch] [bp-Ch]@1
|
|
767 int dir_z; // [sp+10h] [bp-8h]@1
|
|
768 DAMAGE_TYPE pDamageType; // [sp+14h] [bp-4h]@14
|
|
769
|
|
770 pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)];
|
|
771 dir_x = abs(pParty->vPosition.x - this->vPosition.x);
|
|
772 dir_y = abs(pParty->vPosition.y - this->vPosition.y);
|
|
773 dir_z = abs(pParty->vPosition.z + pParty->sEyelevel - this->vPosition.z);
|
|
774 if ( dir_x < dir_y )
|
|
775 {
|
|
776 v7 = dir_x;
|
|
777 dir_x = dir_y;
|
|
778 dir_y = v7;
|
|
779 }
|
|
780 if ( dir_x < dir_z )
|
|
781 {
|
|
782 v7 = dir_x;
|
|
783 dir_x = dir_z;
|
|
784 dir_z = v7;
|
|
785 }
|
|
786 if ( dir_y < dir_z )
|
|
787 {
|
|
788 v7 = dir_z;
|
|
789 dir_z = dir_y;
|
|
790 dir_y = v7;
|
|
791 }
|
|
792 v10 = ((unsigned int)(11 * dir_y) >> 5) + (dir_z / 4) + dir_x;
|
|
793 if ( (signed int)v10 <= 768 )
|
|
794 {
|
|
795 v11 = 5;
|
|
796 if ( pMapInfo->Trap_D20 )
|
|
797 {
|
|
798 for ( uint i = 0; i < pMapInfo->Trap_D20; ++i )
|
|
799 v11 += rand() % 20 + 1;
|
|
800 }
|
|
801 switch ( this->uType )
|
|
802 {
|
|
803 case 811:
|
|
804 pDamageType = DMGT_FIRE;
|
|
805 break;
|
|
806 case 812:
|
|
807 pDamageType = DMGT_ELECTR;
|
|
808 break;
|
|
809 case 813:
|
|
810 pDamageType = DMGT_COLD;
|
|
811 break;
|
|
812 case 814:
|
|
813 pDamageType = DMGT_BODY;
|
|
814 break;
|
|
815 default:
|
|
816 return;
|
|
817 }
|
|
818 for ( uint i = 1; i <= 4; ++i )
|
|
819 {
|
|
820 if ( pPlayers[i]->CanAct() && (v13 = pPlayers[i]->GetPerception() + 20, rand() % v13 > 20) )
|
|
821 pPlayers[i]->PlaySound(SPEECH_6, 0);
|
|
822 else
|
|
823 pPlayers[i]->ReceiveDamage(v11, pDamageType);
|
|
824 }
|
|
825 }
|
|
826 }
|
|
827
|
|
828 //----- (0042F933) --------------------------------------------------------
|
|
829 void SpriteObject::OnInteraction(unsigned int uLayingItemID)
|
|
830 {
|
|
831 pSpriteObjects[uLayingItemID].uObjectDescID = 0;
|
|
832 if ( pParty->bTurnBasedModeOn == 1 )
|
|
833 {
|
|
834 if (pSpriteObjects[uLayingItemID].uAttributes & 4 )
|
|
835 {
|
|
836 pSpriteObjects[uLayingItemID].uAttributes &= 0xFFFB;//~0x00000004
|
|
837 --pTurnEngine->pending_actions;
|
|
838 }
|
|
839 }
|
|
840 }
|
|
841
|
|
842
|
|
843 //----- (0042FA22) --------------------------------------------------------
|
|
844 void CompactLayingItemsList()
|
|
845 {
|
|
846 int new_obj_pos = 0;
|
|
847
|
|
848 for ( int i = 0; i < MAX_SPRITE_OBJECTS; ++i )
|
|
849 {
|
|
850 if ( pSpriteObjects[i].uObjectDescID )
|
|
851 {
|
|
852 if ( i != new_obj_pos )//
|
|
853 {
|
|
854 memcpy(&pSpriteObjects[new_obj_pos], &pSpriteObjects[i],sizeof(SpriteObject));
|
|
855 pSpriteObjects[i].uObjectDescID = 0;
|
|
856 }
|
|
857 new_obj_pos++;
|
|
858 }
|
|
859 }
|
|
860 uNumSpriteObjects = new_obj_pos;
|
|
861 }
|
|
862 //----- (00408896) --------------------------------------------------------
|
|
863 void SpriteObject::InitializeSpriteObjects()
|
|
864 {
|
|
865 for (uint i = 0; i < uNumSpriteObjects; ++i)
|
|
866 {
|
|
867 SpriteObject* item = &pSpriteObjects[i];
|
|
868
|
|
869 if (item->uType && (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & OBJECT_DESC_UNPICKABLE))
|
|
870 SpriteObject::OnInteraction(i);
|
|
871 }
|
|
872 }
|
|
873 //----- (0046BEF1) --------------------------------------------------------
|
|
874 void SpriteObject::_46BEF1_apply_spells_aoe()
|
|
875 {
|
|
876 //SpriteObject *v1; // edi@1
|
|
877 //Actor *v2; // esi@2
|
|
878 //__int16 v3; // fps@4
|
|
879 //unsigned __int8 v4; // c0@4
|
|
880 //unsigned __int8 v5; // c3@4
|
|
881 //signed int v6; // [sp+8h] [bp-4h]@1
|
|
882
|
|
883 int v7,v9,v10,v11;
|
|
884 __debugbreak();//Ritor1
|
|
885 if ( (signed int)uNumActors > 0 )
|
|
886 {
|
|
887 for ( uint i = 0; i < uNumActors; ++i )
|
|
888 {
|
|
889 if ( pActors[i].CanAct() )
|
|
890 {
|
|
891 //UNDEF(v3);
|
|
892 //.text:0046BF26 movsx eax, word ptr [esi-2]
|
|
893 //.text:0046BF2A sub eax, [edi+4]
|
|
894 //.text:0046BF31 mov [ebp+var_8], eax
|
|
895 //.text:0046BF37 fild [ebp+var_8]
|
|
896 // v7 pushed to stack
|
|
897 v7 = pActors[i].vPosition.x - this->vPosition.x;
|
|
898
|
|
899 //.text:0046BF2D movsx ecx, word ptr [esi+2]
|
|
900 //v8 = pActors[i].vPosition.z;
|
|
901
|
|
902 //.text:0046BF34 movsx eax, word ptr [esi]
|
|
903 //.text:0046BF3A sub eax, [edi+8]
|
|
904 //.text:0046BF3D mov [ebp+var_8], eax
|
|
905 //.text:0046BF44 fild [ebp+var_8]
|
|
906 // v9 pushed to stack
|
|
907 v9 = pActors[i].vPosition.y - this->vPosition.y;
|
|
908
|
|
909 //.text:0046BF40 movsx eax, word ptr [esi-6]
|
|
910 //.text:0046BF47 sar eax, 1
|
|
911 //.text:0046BF49 add eax, ecx
|
|
912 //.text:0046BF4B sub eax, [edi+0Ch]
|
|
913 //.text:0046BF4E mov [ebp+var_8], eax
|
|
914 //.text:0046BF51 fild [ebp+var_8]
|
|
915 //.text:0046BF58 fld st
|
|
916 // v10 pushed to stack, two times
|
|
917 v10 = pActors[i].uActorHeight / 2 + pActors[i].vPosition.z - this->vVelocity.y;
|
|
918
|
|
919 //.text:0046BF54 movsx eax, word ptr [esi-8]
|
|
920 //.text:0046BF5A add eax, 100h
|
|
921 //.text:0046BF63 mov ecx, eax
|
|
922 //v11 = this->vVelocity.x;
|
|
923
|
|
924 //.text:0046BF5F fmul st, st(1)
|
|
925 // stack: v10*v10, v10, v9, v7
|
|
926 //.text:0046BF61 fld st(2)
|
|
927 // stack: v7, v10*v10, v10, v9, v7
|
|
928
|
|
929
|
|
930 //.text:0046BF65 fmul st, st(3)
|
|
931 // stack: v7*v9, v10*v10, v10, v9, v7
|
|
932
|
|
933 //.text:0046BF67 imul ecx, eax
|
|
934 v11 = this->vVelocity.x * this->vVelocity.x;
|
|
935
|
|
936 //.text:0046BF6A faddp st(1), st
|
|
937 // stack: v10*v10+v7*v9, v10, v9, v7
|
|
938 //.text:0046BF6C fld st(3)
|
|
939 // stack: v7, v10*v10+v7*v9, v10, v9, v7
|
|
940 //.text:0046BF6E fmul st, st(4)
|
|
941 // stack: v7*v7, v10*v10+v7*v9, v10, v9, v7
|
|
942 //.text:0046BF70 faddp st(1), st
|
|
943 // stack: v10*v10+v7*v9+v7*v7, v10, v9, v7
|
|
944
|
|
945 //.text:0046BF72 mov [ebp+var_8], ecx
|
|
946 //.text:0046BF75 fild [ebp+var_8]
|
|
947 // v11 pushed to stack
|
|
948
|
|
949 //.text:0046BF78 fcompp
|
|
950 // if ( v11 > v10*v10+v7*v9+v7*v7 )
|
|
951 // stack: v10, v9, v7
|
|
952
|
|
953 //.text:0046BF7A fstp st
|
|
954 // stack: v9, v7
|
|
955
|
|
956 //.text:0046BF7C fnstsw ax
|
|
957 //.text:0046BF7E fstp st
|
|
958 // stack: v7
|
|
959
|
|
960 //.text:0046BF80 test ah, 41h
|
|
961 //.text:0046BF83 fstp st
|
|
962 //.text:0046BF85 jnz short loc_46BFDD
|
|
963
|
|
964 if ( v11 >= v7 * v7 + v9 * v9 + v10 * v10 )
|
|
965 {
|
|
966 if ( pActors[i].DoesDmgTypeDoDamage((DAMAGE_TYPE)0xAu) )
|
|
967 {
|
|
968 pActors[i].pActorBuffs[this->spell_id].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(this->spell_level << 7) * 0.033333335),
|
|
969 this->spell_skill, 4, 0, 0);
|
|
970 HIWORD(pActors[i].uAttributes) |= 8;
|
|
971 }
|
|
972 }
|
|
973 }
|
|
974 }
|
|
975 }
|
|
976 }
|
|
977
|
|
978
|
|
979 //----- (0042F7EB) --------------------------------------------------------
|
|
980 bool SpriteObject::sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9)
|
|
981 {
|
|
982 unsigned __int16 pObjectDescID; // ax@7
|
|
983 SpriteObject pSpellObject; // [sp+Ch] [bp-78h]@1
|
|
984
|
|
985 pSpellObject.stru_24.Reset();
|
|
986 if ( a9 )
|
|
987 memcpy(&pSpellObject.stru_24, a9, sizeof(pSpellObject.stru_24));
|
|
988 pSpellObject.spell_skill = 0;
|
|
989 pSpellObject.spell_level = 0;
|
|
990 pSpellObject.spell_id = 0;
|
|
991 pSpellObject.field_54 = 0;
|
|
992 pSpellObject.uType = uSpriteID;
|
|
993 pObjectDescID = 0;
|
|
994 for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i )
|
|
995 {
|
|
996 if ( (short)uSpriteID == pObjectList->pObjects[i].uObjectID )
|
|
997 pObjectDescID = i;
|
|
998 }
|
|
999 pSpellObject.uObjectDescID = pObjectDescID;
|
|
1000 pSpellObject.vPosition.x = x;
|
|
1001 pSpellObject.vPosition.y = y;
|
|
1002 pSpellObject.vPosition.z = z;
|
|
1003 pSpellObject.uSoundID = 0;
|
|
1004 pSpellObject.uAttributes = attributes;
|
|
1005 pSpellObject.uSectorID = pIndoor->GetSector(x, y, z);
|
|
1006 pSpellObject.uSpriteFrameID = 0;
|
|
1007 pSpellObject.spell_caster_pid = 0;
|
|
1008 pSpellObject.spell_target_pid = 0;
|
|
1009 if ( !(pSpellObject.uAttributes & 0x10) )
|
|
1010 {
|
|
1011 if ( pItemsTable->uAllItemsCount )
|
|
1012 {
|
|
1013 for ( uint i = 1; i < pItemsTable->uAllItemsCount; ++i )
|
|
1014 {
|
|
1015 if ( pItemsTable->pItems[i].uSpriteID == uSpriteID )
|
|
1016 pSpellObject.stru_24.uItemID = i;
|
|
1017 }
|
|
1018 }
|
|
1019 }
|
|
1020 if ( a7 )
|
|
1021 {
|
|
1022 if ( count > 0 )
|
|
1023 {
|
|
1024 for ( uint i = count; i; --i )
|
|
1025 {
|
|
1026 pSpellObject.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi;
|
|
1027 pSpellObject.Create((signed __int16)pSpellObject.uFacing,
|
|
1028 ((signed int)stru_5C6E00->uIntegerHalfPi / 2) + (rand() % ((signed int)stru_5C6E00->uIntegerHalfPi / 2)), a4, 0);
|
|
1029
|
|
1030 }
|
|
1031 }
|
|
1032 }
|
|
1033 else
|
|
1034 {
|
|
1035 pSpellObject.uFacing = 0;
|
|
1036 if ( count > 0 )
|
|
1037 {
|
|
1038 for ( uint i = count; i; --i )
|
|
1039 {
|
|
1040 pSpellObject.Create((signed __int16)pSpellObject.uFacing, stru_5C6E00->uIntegerHalfPi, a4, 0);
|
|
1041 }
|
|
1042 }
|
|
1043 }
|
|
1044 return true;
|
|
1045 }
|
|
1046
|
|
1047 //----- (0042F960) --------------------------------------------------------
|
|
1048 void SpriteObject::sub_42F960_create_object(int x, int y, int z)
|
|
1049 {
|
|
1050 unsigned __int16 v7; // ax@5
|
|
1051 signed int v8; // eax@6
|
|
1052 signed int v9; // eax@7
|
|
1053
|
|
1054 SpriteObject a1; // [sp+Ch] [bp-70h]@1
|
|
1055 //SpriteObject::SpriteObject(&a1);
|
|
1056 a1.stru_24.Reset();
|
|
1057
|
|
1058 a1.spell_skill = 0;
|
|
1059 a1.spell_level = 0;
|
|
1060 a1.spell_id = 0;
|
|
1061 a1.field_54 = 0;
|
|
1062 a1.uType = 800;
|
|
1063 v7 = 0;
|
|
1064 for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i )
|
|
1065 {
|
|
1066 if ( a1.uType == pObjectList->pObjects[i].uObjectID )
|
|
1067 v7 = i;
|
|
1068 }
|
|
1069 a1.uObjectDescID = v7;
|
|
1070 a1.vPosition.x = x;
|
|
1071 a1.vPosition.y = y;
|
|
1072 a1.vPosition.z = z;
|
|
1073 a1.uSoundID = 0;
|
|
1074 a1.uAttributes = 0;
|
|
1075 a1.uSectorID = pIndoor->GetSector(x, y, z);
|
|
1076 a1.uSpriteFrameID = 0;
|
|
1077 a1.spell_caster_pid = 0;
|
|
1078 a1.spell_target_pid = 0;
|
|
1079 v8 = a1.Create(0, 0, 0, 0);
|
|
1080 if ( v8 != -1 )
|
|
1081 {
|
|
1082 v9 = 8 * v8;
|
|
1083 LOBYTE(v9) = v9 | 2;
|
2534
|
1084 pAudioPlayer->PlaySound((SoundID)SOUND_splash, v9, 0, -1, 0, 0, 0, 0);
|
2498
|
1085 }
|
|
1086 }
|
|
1087
|
|
1088 //----- (0046BFFA) --------------------------------------------------------
|
|
1089 bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2)
|
|
1090 {
|
|
1091 ObjectDesc *object; // ebx@1
|
|
1092 unsigned int v8; // eax@19
|
|
1093 signed int v10; // ebx@19
|
|
1094 char *v11; // edx@20
|
|
1095 unsigned __int16 v12; // ax@23
|
|
1096 int v13; // eax@27
|
|
1097 int v16; // eax@36
|
|
1098 __int16 v18; // di@37
|
|
1099 signed int v19; // edx@37
|
|
1100 unsigned __int16 v22; // ax@41
|
|
1101 signed int v24; // ebx@46
|
|
1102 char *v25; // edx@47
|
|
1103 signed int v34; // edx@65
|
|
1104 unsigned __int16 v36; // ax@69
|
|
1105 int v37; // ST14_4@72
|
|
1106 int v38; // eax@72
|
|
1107 int v39; // ST10_4@72
|
|
1108 int v40; // ST0C_4@72
|
|
1109 unsigned __int8 v44; // zf@79
|
|
1110 int v47; // eax@81
|
|
1111 signed int v52; // ebx@93
|
|
1112 signed int v56; // ebx@98
|
|
1113 unsigned __int16 v58; // ax@102
|
|
1114 unsigned __int16 v59; // ax@107
|
|
1115 signed int v61; // ebx@107
|
|
1116 unsigned __int16 v63; // ax@111
|
|
1117 int v64; // ebx@114
|
|
1118 signed int v65; // eax@114
|
|
1119 signed int v69; // ebx@124
|
|
1120 unsigned __int16 v71; // ax@128
|
|
1121 unsigned int v72; // ebx@131
|
|
1122 int v78; // eax@133
|
|
1123 signed int v81; // edx@140
|
|
1124 unsigned __int16 v83; // ax@144
|
|
1125 signed int v86; // ebx@151
|
|
1126 unsigned __int16 v88; // ax@155
|
|
1127 unsigned int v89; // eax@158
|
|
1128 int v90; // ST34_4@159
|
|
1129 int v91; // eax@159
|
|
1130 unsigned int v92; // eax@163
|
|
1131 unsigned __int16 v95; // ax@181
|
|
1132 unsigned __int16 v96; // ax@184
|
|
1133 int v97; // eax@185
|
|
1134 char v100; // ST18_1@198
|
|
1135 int v102; // eax@198
|
|
1136 signed int v106; // eax@208
|
|
1137 unsigned int v107; // edx@220
|
|
1138 signed int v108; // ebx@225
|
|
1139 signed int v110; // ebx@234
|
|
1140 unsigned __int16 v112; // ax@238
|
|
1141 unsigned __int16 v113; // si@241
|
|
1142 int v114; // eax@242
|
|
1143 int v115; // eax@245
|
|
1144 signed int v119; // ebx@251
|
|
1145 unsigned __int16 v121; // ax@255
|
|
1146 int v124; // eax@267
|
|
1147 int v125; // [sp-20h] [bp-4Ch]@28
|
|
1148 char v132; // [sp-8h] [bp-34h]@131
|
|
1149 char v134; // [sp-4h] [bp-30h]@131
|
|
1150 signed int v135; // [sp-4h] [bp-30h]@217
|
|
1151 int v136; // [sp+Ch] [bp-20h]@208
|
|
1152 int v137; // [sp+10h] [bp-1Ch]@208
|
|
1153 signed int v138; // [sp+14h] [bp-18h]@207
|
|
1154 signed int v139; // [sp+18h] [bp-14h]@208
|
|
1155 signed int v141; // [sp+1Ch] [bp-10h]@117
|
|
1156 unsigned int v142; // [sp+1Ch] [bp-10h]@158
|
|
1157 signed int v143; // [sp+1Ch] [bp-10h]@172
|
|
1158 signed int v146; // [sp+20h] [bp-Ch]@60
|
|
1159 int v147; // [sp+20h] [bp-Ch]@72
|
|
1160 signed int v148; // [sp+20h] [bp-Ch]@158
|
|
1161 unsigned __int16 v150; // [sp+20h] [bp-Ch]@208
|
|
1162 signed int v152; // [sp+24h] [bp-8h]@208
|
|
1163
|
|
1164 object = &pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID];
|
|
1165 //v151 = PID_TYPE(a2);
|
|
1166 if (PID_TYPE(a2) == OBJECT_Actor)
|
|
1167 {
|
|
1168 if (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Actor
|
|
1169 && !pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]))
|
|
1170 return 1;
|
|
1171 }
|
|
1172 else
|
|
1173 {
|
|
1174 if (PID_TYPE(a2) == OBJECT_Player && PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Player)
|
|
1175 return 1;
|
|
1176 }
|
|
1177 if (pParty->bTurnBasedModeOn == 1)
|
|
1178 {
|
|
1179 if (pSpriteObjects[uLayingItemID].uAttributes & 4)
|
|
1180 {
|
|
1181 --pTurnEngine->pending_actions;
|
|
1182 pSpriteObjects[uLayingItemID].uAttributes &= 0xFFFB;//~0x00000004
|
|
1183 }
|
|
1184 }
|
|
1185 if (PID_TYPE(a2) == OBJECT_BModel && PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) != OBJECT_Player)
|
|
1186 {
|
|
1187 if (PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) < 500) //bugfix PID_ID(v2->spell_caster_pid)==1000
|
|
1188 pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].uAttributes |= ACTOR_UNKNOW5;
|
|
1189 }
|
|
1190
|
|
1191 //v6 = v2->uType;
|
|
1192 //v7 = v2->uType;
|
|
1193
|
|
1194 switch (pSpriteObjects[uLayingItemID].uType)
|
|
1195 {
|
|
1196
|
|
1197 case 1060:
|
|
1198 case 2030:
|
|
1199 case 9010:
|
|
1200 {
|
|
1201 //v9 = 0;
|
|
1202 if (PID_TYPE(a2) == 6 || PID_TYPE(a2) == 5 || !PID_TYPE(a2))
|
|
1203 return 1;
|
|
1204 if (PID_TYPE(a2) != 2)
|
|
1205 {
|
|
1206 sub_43A97E(uLayingItemID, a2);
|
|
1207 ++pSpriteObjects[uLayingItemID].uType;
|
|
1208 v95 = 0;
|
|
1209 for (v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52)
|
|
1210 {
|
|
1211 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID)
|
|
1212 v95 = v52;
|
|
1213 }
|
|
1214 pSpriteObjects[uLayingItemID].uObjectDescID = v95;
|
|
1215 if (!v95)
|
|
1216 SpriteObject::OnInteraction(uLayingItemID);
|
|
1217 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1218 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1219 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1220 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1221 if (!pSpriteObjects[uLayingItemID].uSoundID)
|
|
1222 v97 = 0;
|
|
1223 else
|
|
1224 v97 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
|
|
1225 v124 = 8 * uLayingItemID;
|
|
1226 LOBYTE(v124) = v124 | 2;
|
|
1227 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1228 pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
|
|
1229 return 0;
|
|
1230 }
|
|
1231 pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
|
|
1232 v121 = 0;
|
|
1233 for (v119 = 0; v119 < (signed int)pObjectList->uNumObjects; ++v119)
|
|
1234 {
|
|
1235 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v119].uObjectID)
|
|
1236 v121 = v119;
|
|
1237 }
|
|
1238 pSpriteObjects[uLayingItemID].uObjectDescID = v121;
|
|
1239 if (!v121)
|
|
1240 SpriteObject::OnInteraction(uLayingItemID);
|
|
1241 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1242 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1243 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1244 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1245 v13 = 8 * uLayingItemID;
|
|
1246 LOBYTE(v13) = PID(OBJECT_Item, uLayingItemID);
|
2534
|
1247 pAudioPlayer->PlaySound(SOUND_fireBall, v13, 0, -1, 0, 0, 0, 0);
|
2498
|
1248 return 0;
|
|
1249 }
|
|
1250
|
|
1251
|
|
1252 case 500:
|
|
1253 case 505:
|
|
1254 case 510:
|
|
1255 case 515:
|
|
1256 case 520:
|
|
1257 case 525:
|
|
1258 case 530:
|
|
1259 case 535:
|
|
1260 case 540:
|
|
1261 {
|
|
1262 sub_43A97E(uLayingItemID, a2);
|
|
1263 ++pSpriteObjects[uLayingItemID].uType;
|
|
1264 v12 = 0;
|
|
1265 for (v10 = 0; v10 < (signed int)pObjectList->uNumObjects; ++v10)
|
|
1266 {
|
|
1267 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v10].uObjectID)
|
|
1268 v12 = v10;
|
|
1269 }
|
|
1270 pSpriteObjects[uLayingItemID].uObjectDescID = v12;
|
|
1271 if (!v12)
|
|
1272 SpriteObject::OnInteraction(uLayingItemID);
|
|
1273 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1274 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1275 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1276 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1277 if (pSpriteObjects[uLayingItemID].uType == 555)
|
|
1278 {
|
|
1279 v13 = 8 * uLayingItemID;
|
|
1280 LOBYTE(v13) = PID(OBJECT_Item, uLayingItemID);
|
2534
|
1281 pAudioPlayer->PlaySound(SOUND_fireBall, v13, 0, -1, 0, 0, 0, 0);
|
2498
|
1282 }
|
|
1283 return 0;
|
|
1284 }
|
|
1285
|
|
1286 case 545:
|
|
1287 case 550:
|
|
1288 {
|
|
1289 if (pSpriteObjects[uLayingItemID].stru_24.uItemID != 405 && pSpriteObjects[uLayingItemID].stru_24.uSpecEnchantmentType != 3)
|
|
1290 {
|
|
1291 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1292 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1293 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1294 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1295 sub_43A97E(uLayingItemID, a2);
|
|
1296 SpriteObject::OnInteraction(uLayingItemID);
|
|
1297 if (pSpriteObjects[uLayingItemID].uSoundID == 0)
|
|
1298 v16 = 0;
|
|
1299 else
|
|
1300 v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
|
|
1301 v124 = 8 * uLayingItemID;
|
|
1302 LOBYTE(v124) = v124 | 2;
|
|
1303 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1;
|
|
1304 pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0);
|
|
1305 return 0;
|
|
1306 }
|
|
1307 v18 = 0;
|
|
1308 pSpriteObjects[uLayingItemID].uType = 600;
|
|
1309 v22 = 0;
|
|
1310 for (v19 = 0; v19 < (signed int)pObjectList->uNumObjects; ++v19)
|
|
1311 {
|
|
1312 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v19].uObjectID)
|
|
1313 v22 = v19;
|
|
1314 }
|
|
1315 pSpriteObjects[uLayingItemID].uObjectDescID = v22;
|
|
1316 if (!v22)
|
|
1317 SpriteObject::OnInteraction(uLayingItemID);
|
|
1318 pSpriteObjects[uLayingItemID].vVelocity.z = v18;
|
|
1319 pSpriteObjects[uLayingItemID].vVelocity.y = v18;
|
|
1320 pSpriteObjects[uLayingItemID].vVelocity.x = v18;
|
|
1321 pSpriteObjects[uLayingItemID].uSpriteFrameID = v18;
|
|
1322 v12 = 0;
|
|
1323 for (v10; v10 < (signed int)v8; ++v10)
|
|
1324 {
|
|
1325 v11 += 56;
|
|
1326 if (pSpriteObjects[uLayingItemID].uType != *(short *)v11)
|
|
1327 v12 = v10;
|
|
1328 }
|
|
1329 pSpriteObjects[uLayingItemID].uObjectDescID = v12;
|
|
1330 if (!v12)
|
|
1331 SpriteObject::OnInteraction(uLayingItemID);
|
|
1332 v44 = pSpriteObjects[uLayingItemID].uType == 555;
|
|
1333 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1334 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1335 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1336 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1337 if (!v44)
|
|
1338 {
|
|
1339 v13 = 8 * uLayingItemID;
|
|
1340 LOBYTE(v13) = PID(OBJECT_Item, uLayingItemID);
|
2534
|
1341 pAudioPlayer->PlaySound(SOUND_fireBall, v13, 0, -1, 0, 0, 0, 0);
|
2498
|
1342 return 0;
|
|
1343 }
|
|
1344 return 0;
|
|
1345 }
|
|
1346
|
|
1347 case 600:
|
|
1348 {
|
|
1349 pSpriteObjects[uLayingItemID].uType = 601;
|
|
1350 v36 = 0;
|
|
1351 for (v34 = 0; v34 < (signed int)pObjectList->uNumObjects; ++v34)
|
|
1352 {
|
|
1353 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v34].uObjectID)
|
|
1354 v36 = v34;
|
|
1355 }
|
|
1356 pSpriteObjects[uLayingItemID].uObjectDescID = v36;
|
|
1357 if (!v36)
|
|
1358 SpriteObject::OnInteraction(uLayingItemID);
|
|
1359 v37 = pSpriteObjects[uLayingItemID].vPosition.z;
|
|
1360 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1361 v38 = 8 * uLayingItemID;
|
|
1362 v39 = pSpriteObjects[uLayingItemID].vPosition.y;
|
|
1363 LOBYTE(v38) = PID(OBJECT_Item, uLayingItemID);
|
|
1364 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1365 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1366 v40 = pSpriteObjects[uLayingItemID].vPosition.x;
|
|
1367 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1368 v147 = v38;
|
|
1369 AttackerInfo.Add(v38, 512, v40, v39, v37, 0, 0);
|
|
1370 if (object->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
|
|
1371 trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uParticleTrailColor);
|
2534
|
1372 pAudioPlayer->PlaySound(SOUND_fireBall, v147, 0, -1, 0, 0, 0, 0);
|
2498
|
1373 return 0;
|
|
1374 }
|
|
1375
|
|
1376 case 1010:
|
|
1377 case 1100:
|
|
1378 case 2060:
|
|
1379 case 3010:
|
|
1380 case 3030:
|
|
1381 case 3060:
|
|
1382 case 4000:
|
|
1383 case 4030:
|
|
1384 case 4050:
|
|
1385 case 4100:
|
|
1386 case 6010:
|
|
1387 case 6090:
|
|
1388 {
|
|
1389 sub_43A97E(uLayingItemID, a2);
|
|
1390 ++pSpriteObjects[uLayingItemID].uType;
|
|
1391 v95 = 0;
|
|
1392 for (v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52)
|
|
1393 {
|
|
1394 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID)
|
|
1395 v95 = v52;
|
|
1396 }
|
|
1397 pSpriteObjects[uLayingItemID].uObjectDescID = v95;
|
|
1398 if (!v95)
|
|
1399 SpriteObject::OnInteraction(uLayingItemID);
|
|
1400 v96 = pSpriteObjects[uLayingItemID].uSoundID;
|
|
1401 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1402 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1403 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1404 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1405 if (!v96)
|
|
1406 v97 = 0;
|
|
1407 else
|
|
1408 v97 = (signed __int16)v96 + 4;
|
|
1409 v124 = 8 * uLayingItemID;
|
|
1410 LOBYTE(v124) = v124 | 2;
|
|
1411 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1412 pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
|
|
1413 return 0;
|
|
1414 }
|
|
1415
|
|
1416
|
|
1417 case 555:
|
|
1418 {
|
|
1419 sub_43A97E(uLayingItemID, a2);
|
|
1420 ++pSpriteObjects[uLayingItemID].uType;
|
|
1421 v18 = 0;
|
|
1422 v22 = 0;
|
|
1423 v25 = (char *)&pObjectList->pObjects->uObjectID;
|
|
1424 for (v24 = 0; v24 < (signed int)pObjectList->uNumObjects; ++v24)
|
|
1425 {
|
|
1426 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v24].uObjectID)
|
|
1427 v22 = v24;
|
|
1428 }
|
|
1429 pSpriteObjects[uLayingItemID].uObjectDescID = v22;
|
|
1430 if (v22 == v18)
|
|
1431 SpriteObject::OnInteraction(uLayingItemID);
|
|
1432 pSpriteObjects[uLayingItemID].vVelocity.z = v18;
|
|
1433 pSpriteObjects[uLayingItemID].vVelocity.y = v18;
|
|
1434 pSpriteObjects[uLayingItemID].vVelocity.x = v18;
|
|
1435 pSpriteObjects[uLayingItemID].uSpriteFrameID = v18;
|
|
1436 return 0;
|
|
1437 }
|
|
1438
|
|
1439 case 3090:
|
|
1440 {
|
|
1441 //v9 = 0;
|
|
1442 pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 2;
|
|
1443 v63 = 0;
|
|
1444 for (v61 = 0; v61 < (signed int)pObjectList->uNumObjects; ++v61)
|
|
1445 {
|
|
1446 if (v59 == pObjectList->pObjects[v61].uObjectID)
|
|
1447 v63 = v61;
|
|
1448 }
|
|
1449 pSpriteObjects[uLayingItemID].uObjectDescID = v63;
|
|
1450 if (!v63)
|
|
1451 SpriteObject::OnInteraction(uLayingItemID);
|
|
1452 v64 = pSpriteObjects[uLayingItemID].uFacing - stru_5C6E00->uIntegerDoublePi;
|
|
1453 v44 = pSpriteObjects[uLayingItemID].spell_skill == 4;
|
|
1454 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1455 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1456 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1457 v65 = 7;
|
|
1458 if (v44)
|
|
1459 v65 = 9;
|
|
1460 if (v65 > 0)
|
|
1461 {
|
|
1462 v141 = v65;
|
|
1463 do
|
|
1464 {
|
|
1465 v64 += (signed int)stru_5C6E00->uIntegerHalfPi / 2;
|
|
1466 pSpriteObjects[uLayingItemID].Create(v64, 0, 1000, 0);
|
|
1467 --v141;
|
|
1468 } while (v141);
|
|
1469 }
|
|
1470 SpriteObject::OnInteraction(uLayingItemID);
|
|
1471 if (!pSpriteObjects[uLayingItemID].uSoundID)
|
|
1472 v16 = 0;
|
|
1473 else
|
|
1474 v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
|
|
1475 v124 = 8 * uLayingItemID;
|
|
1476 LOBYTE(v124) = v124 | 2;
|
|
1477 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1478 pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0);
|
|
1479 return 0;
|
|
1480 }
|
|
1481
|
|
1482 case 3092:
|
|
1483 {
|
|
1484 pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType - 1;
|
|
1485 v58 = 0;
|
|
1486 for (v56 = 0; v56 < (signed int)pObjectList->uNumObjects; ++v56)
|
|
1487 {
|
|
1488 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v56].uObjectID)
|
|
1489 v58 = v56;
|
|
1490 }
|
|
1491 pSpriteObjects[uLayingItemID].uObjectDescID = v58;
|
|
1492 if (!v58)
|
|
1493 SpriteObject::OnInteraction(uLayingItemID);
|
|
1494 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1495 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1496 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1497 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1498 sub_43A97E(uLayingItemID, a2);
|
|
1499 if (!pSpriteObjects[uLayingItemID].uSoundID)
|
|
1500 v16 = 0;
|
|
1501 else
|
|
1502 v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
|
|
1503 v124 = 8 * uLayingItemID;
|
|
1504 LOBYTE(v124) = v124 | 2;
|
|
1505 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1506 pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0);
|
|
1507 return 0;
|
|
1508 }
|
|
1509
|
|
1510 case 4070:
|
|
1511 {
|
|
1512 if (PID_TYPE(a2) == 6 || PID_TYPE(a2) == 5 || !PID_TYPE(a2))
|
|
1513 return 1;
|
|
1514 pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
|
|
1515 v71 = 0;
|
|
1516 for (v69 = 0; v69 < (signed int)pObjectList->uNumObjects; ++v69)
|
|
1517 {
|
|
1518 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v69].uObjectID)
|
|
1519 v71 = v69;
|
|
1520 }
|
|
1521 pSpriteObjects[uLayingItemID].uObjectDescID = v71;
|
|
1522 if (!v71)
|
|
1523 SpriteObject::OnInteraction(uLayingItemID);
|
|
1524 v134 = 0;
|
|
1525 v72 = uLayingItemID;
|
|
1526 v132 = 0;
|
|
1527 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1528 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1529 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1530 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1531 AttackerInfo.Add(PID(OBJECT_Item, v72), 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v132, v134);
|
|
1532 if (!pSpriteObjects[uLayingItemID].uSoundID)
|
|
1533 v78 = 0;
|
|
1534 else
|
|
1535 v78 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
|
|
1536 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1537 pAudioPlayer->PlaySound((SoundID)v125, pSpriteObjects[uLayingItemID].vPosition.x, 0, -1, 0, v78, 0, 0);
|
|
1538 return 0;
|
|
1539 }
|
|
1540
|
|
1541 case 4090:
|
|
1542 {
|
|
1543 //v9 = 0;
|
|
1544 pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 2;
|
|
1545 v88 = 0;
|
|
1546 for (v86 = 0; v86 < (signed int)pObjectList->uNumObjects; ++v86)
|
|
1547 {
|
|
1548 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v86].uObjectID)
|
|
1549 v88 = v86;
|
|
1550 }
|
|
1551 pSpriteObjects[uLayingItemID].uObjectDescID = v88;
|
|
1552 if (!v88)
|
|
1553 SpriteObject::OnInteraction(uLayingItemID);
|
|
1554 v89 = pSpriteObjects[uLayingItemID].uFacing - stru_5C6E00->uIntegerDoublePi;
|
|
1555 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1556 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1557 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1558 v142 = v89;
|
|
1559 v148 = 7;
|
|
1560 do
|
|
1561 {
|
|
1562 pRnd->SetRange(-128, 128);
|
|
1563 v90 = pRnd->GetInRange();
|
|
1564 pRnd->SetRange(5, 500);
|
|
1565 v91 = pRnd->GetInRange();
|
|
1566 v142 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1;
|
|
1567 pSpriteObjects[uLayingItemID].Create(v90 + v142, 0, v91, 0);
|
|
1568 --v148;
|
|
1569 } while (v148);
|
|
1570 SpriteObject::OnInteraction(uLayingItemID);
|
|
1571 if (!pSpriteObjects[uLayingItemID].uSoundID)
|
|
1572 v16 = 0;
|
|
1573 else
|
|
1574 v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
|
|
1575 v124 = 8 * uLayingItemID;
|
|
1576 LOBYTE(v124) = v124 | 2;
|
|
1577 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1578 pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0);
|
|
1579 return 0;
|
|
1580 }
|
|
1581
|
|
1582 case 4092:
|
|
1583 {
|
|
1584 pSpriteObjects[uLayingItemID].uType = 4091;
|
|
1585 v83 = 0;
|
|
1586 for (v81 = 0; v81 < (signed int)pObjectList->uNumObjects; ++v81)
|
|
1587 {
|
|
1588 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v81].uObjectID)
|
|
1589 v83 = v81;
|
|
1590 }
|
|
1591 pSpriteObjects[uLayingItemID].uObjectDescID = v83;
|
|
1592 if (!v83)
|
|
1593 SpriteObject::OnInteraction(uLayingItemID);
|
|
1594 v134 = 0;
|
|
1595 //v72 = uLayingItemID;
|
|
1596 v132 = pSpriteObjects[uLayingItemID].field_61;
|
|
1597 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1598 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1599 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1600 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1601 AttackerInfo.Add(PID(OBJECT_Item, uLayingItemID), 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v132, v134);
|
|
1602 if (!pSpriteObjects[uLayingItemID].uSoundID)
|
|
1603 v78 = 0;
|
|
1604 else
|
|
1605 v78 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
|
|
1606 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1607 pAudioPlayer->PlaySound((SoundID)v125, pSpriteObjects[uLayingItemID].vPosition.x, 0, -1, 0, v78, 0, 0);
|
|
1608 return 0;
|
|
1609 }
|
|
1610
|
|
1611 case 8010:
|
|
1612 {
|
|
1613 if (PID_TYPE(a2) == 3
|
|
1614 && MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD))
|
|
1615 sub_43A97E(uLayingItemID, a2);
|
|
1616 ++pSpriteObjects[uLayingItemID].uType;
|
|
1617 //v9 = 0;
|
|
1618 v95 = 0;
|
|
1619 for (v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52)
|
|
1620 {
|
|
1621 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID)
|
|
1622 v95 = v52;
|
|
1623 }
|
|
1624 pSpriteObjects[uLayingItemID].uObjectDescID = v95;
|
|
1625 if (!v95)
|
|
1626 SpriteObject::OnInteraction(uLayingItemID);
|
|
1627 v96 = pSpriteObjects[uLayingItemID].uSoundID;
|
|
1628 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1629 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1630 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1631 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1632 if (!v96)
|
|
1633 v97 = 0;
|
|
1634 else
|
|
1635 v97 = (signed __int16)v96 + 4;
|
|
1636 v92 = uLayingItemID;
|
|
1637 v124 = 8 * v92;
|
|
1638 LOBYTE(v124) = v124 | 2;
|
|
1639 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1640 pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
|
|
1641 return 0;
|
|
1642 }
|
|
1643
|
|
1644 case 7030:
|
|
1645 case 7090:
|
|
1646 case 8000:
|
|
1647 case 8090:
|
|
1648 {
|
|
1649 sub_43A97E(uLayingItemID, a2);
|
|
1650 ++pSpriteObjects[uLayingItemID].uType;
|
|
1651 v95 = 0;
|
|
1652 for (v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52)
|
|
1653 {
|
|
1654 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID)
|
|
1655 v95 = v52;
|
|
1656 }
|
|
1657 pSpriteObjects[uLayingItemID].uObjectDescID = v95;
|
|
1658 if (!v95)
|
|
1659 SpriteObject::OnInteraction(uLayingItemID);
|
|
1660 v96 = pSpriteObjects[uLayingItemID].uSoundID;
|
|
1661 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1662 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1663 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1664 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1665 if (!v96)
|
|
1666 v97 = 0;
|
|
1667 else
|
|
1668 v97 = (signed __int16)v96 + 4;
|
|
1669 v124 = 8 * uLayingItemID;
|
|
1670 LOBYTE(v124) = v124 | 2;
|
|
1671 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1672 pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
|
|
1673 return 0;
|
|
1674 }
|
|
1675
|
|
1676 case 6040:
|
|
1677 case 8030:
|
|
1678 case 9030:
|
|
1679 {
|
|
1680 v143 = 17030;
|
|
1681 switch (pSpriteObjects[uLayingItemID].uType)
|
|
1682 {
|
|
1683 case 0x1798u:
|
|
1684 v143 = 15040;
|
|
1685 break;
|
|
1686 case 0xFAAu:
|
|
1687 v143 = 13010;
|
|
1688 break;
|
|
1689 case 0x2346u:
|
|
1690 v143 = 18030;
|
|
1691 break;
|
|
1692 }
|
|
1693 v138 = 1;
|
|
1694 if (PID_TYPE(a2) != OBJECT_Actor)
|
|
1695 {
|
|
1696 if (pSpriteObjects[uLayingItemID].uType != 9030 || pSpriteObjects[uLayingItemID].spell_skill != 4)
|
|
1697 {
|
|
1698 SpriteObject::OnInteraction(uLayingItemID);
|
|
1699 return 0;
|
|
1700 }
|
|
1701 pSpriteObjects[uLayingItemID]._46BEF1_apply_spells_aoe();
|
|
1702 if (!v138)
|
|
1703 {
|
|
1704 ++pSpriteObjects[uLayingItemID].uType;
|
|
1705 v112 = 0;
|
|
1706 for (v110 = 0; v110 < (signed int)pObjectList->uNumObjects; ++v110)
|
|
1707 {
|
|
1708 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v110].uObjectID)
|
|
1709 v112 = v110;
|
|
1710 }
|
|
1711 pSpriteObjects[uLayingItemID].uObjectDescID = v112;
|
|
1712 if (!v112)
|
|
1713 SpriteObject::OnInteraction(uLayingItemID);
|
|
1714 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1715 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1716 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1717 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1718 v113 = pSpriteObjects[uLayingItemID].uSoundID;
|
|
1719 if (v113)
|
|
1720 v114 = (signed __int16)v113 + 4;
|
|
1721 else
|
|
1722 v114 = 0;
|
|
1723 v115 = 8 * uLayingItemID;
|
|
1724 LOBYTE(v115) = PID(OBJECT_Item, uLayingItemID);
|
|
1725 v125 = v143 + 1;
|
|
1726 pAudioPlayer->PlaySound((SoundID)v125, v115, 0, -1, 0, v114, 0, 0);
|
|
1727 }
|
|
1728 else
|
|
1729 SpriteObject::OnInteraction(uLayingItemID);
|
|
1730 return 0;
|
|
1731 }
|
|
1732 v106 = a2;
|
|
1733 v150 = 0;
|
|
1734 v139 = PID_ID(v106);
|
|
1735 v137 = pSpriteObjects[uLayingItemID].spell_level;
|
|
1736 v152 = pSpriteObjects[uLayingItemID].spell_skill;
|
|
1737 v136 = pSpriteObjects[uLayingItemID].spell_id;
|
|
1738 if (pSpriteObjects[uLayingItemID].uType == 9030)
|
|
1739 {
|
|
1740 v150 = 2;
|
|
1741 if (v152 == 2)
|
|
1742 v150 = 3;
|
|
1743 else
|
|
1744 {
|
|
1745 if (v152 >= 3)
|
|
1746 v150 = 4;
|
|
1747 }
|
|
1748 pActors[v139].uAttributes |= ACTOR_AGGRESSOR;
|
|
1749 v107 = v135;
|
|
1750 }
|
|
1751 if (pSpriteObjects[uLayingItemID].uType == 6040)
|
|
1752 {
|
|
1753 v135 = 7;
|
|
1754 v107 = v135;
|
|
1755 }
|
|
1756 else
|
|
1757 {
|
|
1758 if (pSpriteObjects[uLayingItemID].uType == 8030)
|
|
1759 {
|
|
1760 v135 = 9;
|
|
1761 v107 = v135;
|
|
1762 }
|
|
1763 else
|
|
1764 {
|
|
1765 if (pSpriteObjects[uLayingItemID].uType != 9030)
|
|
1766 {
|
|
1767 v107 = v136;
|
|
1768 }
|
|
1769 if (pSpriteObjects[uLayingItemID].uType == 9030)
|
|
1770 {
|
|
1771 v135 = 10;
|
|
1772 v107 = v135;
|
|
1773 }
|
|
1774 }
|
|
1775 }
|
|
1776 if (pSpriteObjects[uLayingItemID].uType != 9030 || v152 != 4)
|
|
1777 {
|
|
1778 v108 = v139;
|
|
1779 if (pActors[v139].DoesDmgTypeDoDamage((DAMAGE_TYPE)v107))
|
|
1780 {
|
|
1781 v138 = 0;
|
|
1782 if (pSpriteObjects[uLayingItemID].uType == 8030)
|
|
1783 {
|
|
1784 pActors[v108].uAIState = Standing;
|
|
1785 pActors[v108].UpdateAnimation();
|
|
1786 }
|
|
1787 pActors[v108].pActorBuffs[v136].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335),
|
|
1788 v152, v150, 0, 0);
|
|
1789 }
|
|
1790 }
|
|
1791 else
|
|
1792 {
|
|
1793 pSpriteObjects[uLayingItemID]._46BEF1_apply_spells_aoe();
|
|
1794 }
|
|
1795 pSpriteObjects[uLayingItemID].spell_level = 0;
|
|
1796 pSpriteObjects[uLayingItemID].spell_skill = 0;
|
|
1797 pSpriteObjects[uLayingItemID].spell_id = 0;
|
|
1798 if (!v138)
|
|
1799 {
|
|
1800 ++pSpriteObjects[uLayingItemID].uType;
|
|
1801 v112 = 0;
|
|
1802 for (v110 = 0; v110 < (signed int)pObjectList->uNumObjects; ++v110)
|
|
1803 {
|
|
1804 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v110].uObjectID)
|
|
1805 v112 = v110;
|
|
1806 }
|
|
1807 pSpriteObjects[uLayingItemID].uObjectDescID = v112;
|
|
1808 if (!v112)
|
|
1809 SpriteObject::OnInteraction(uLayingItemID);
|
|
1810 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1811 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1812 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1813 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1814 v113 = pSpriteObjects[uLayingItemID].uSoundID;
|
|
1815 if (v113)
|
|
1816 v114 = (signed __int16)v113 + 4;
|
|
1817 else
|
|
1818 v114 = 0;
|
|
1819 v115 = 8 * uLayingItemID;
|
|
1820 LOBYTE(v115) = PID(OBJECT_Item, uLayingItemID);
|
|
1821 v125 = v143 + 1;
|
|
1822 pAudioPlayer->PlaySound((SoundID)v125, v115, 0, -1, 0, v114, 0, 0);
|
|
1823 }
|
|
1824 else
|
|
1825 SpriteObject::OnInteraction(uLayingItemID);
|
|
1826 return 0;
|
|
1827 }
|
|
1828
|
|
1829 case 9040:
|
|
1830 {
|
|
1831 sub_43A97E(uLayingItemID, a2);
|
|
1832 ++pSpriteObjects[uLayingItemID].uType;
|
|
1833 v95 = 0;
|
|
1834 for (v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52)
|
|
1835 {
|
|
1836 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID)
|
|
1837 v95 = v52;
|
|
1838 }
|
|
1839 pSpriteObjects[uLayingItemID].uObjectDescID = v95;
|
|
1840 if (!v95)
|
|
1841 SpriteObject::OnInteraction(uLayingItemID);
|
|
1842 v96 = pSpriteObjects[uLayingItemID].uSoundID;
|
|
1843 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1844 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1845 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1846 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1847 if (!v96)
|
|
1848 v97 = 0;
|
|
1849 else
|
|
1850 v97 = (signed __int16)v96 + 4;
|
|
1851 v124 = 8 * uLayingItemID;
|
|
1852 LOBYTE(v124) = v124 | 2;
|
|
1853 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1854 pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
|
|
1855 return 0;
|
|
1856 }
|
|
1857
|
|
1858 /*
|
|
1859 case 1080:
|
|
1860 case 2100:
|
|
1861 {
|
|
1862 if (PID_TYPE(a2) != 3)
|
|
1863 {
|
|
1864 //v32 = 0;
|
|
1865 pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
|
|
1866 v46 = 0;
|
|
1867 for (v146 = 0; v146 < (signed int)pObjectList->uNumObjects; ++v146)
|
|
1868 {
|
|
1869 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v146].uObjectID)
|
|
1870 v46 = v146;
|
|
1871 }
|
|
1872 pSpriteObjects[uLayingItemID].uObjectDescID = v46;
|
|
1873 if (!v46)
|
|
1874 SpriteObject::OnInteraction(uLayingItemID);
|
|
1875 v100 = pSpriteObjects[uLayingItemID].field_61;
|
|
1876 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1877 v102 = 8 * uLayingItemID;
|
|
1878 LOBYTE(v102) = PID(OBJECT_Item, uLayingItemID);
|
|
1879 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1880 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1881 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1882 AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, 0);
|
|
1883 if (object->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
|
|
1884 trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uParticleTrailColor);
|
|
1885 if (!pSpriteObjects[uLayingItemID].uSoundID)
|
|
1886 v47 = 0;
|
|
1887 else
|
|
1888 v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
|
|
1889 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1890 pAudioPlayer->PlaySound((SoundID)v125, v102, 0, -1, 0, v47, 0, 0);
|
|
1891 return 0;
|
|
1892 }
|
|
1893 return 1;
|
|
1894 }*/
|
|
1895
|
|
1896 case 1080:
|
|
1897 case 2100:
|
|
1898 {
|
|
1899 if (PID_TYPE(a2) == 3)
|
|
1900 return 1;
|
|
1901 //else go to next case
|
|
1902 }
|
|
1903
|
|
1904 case 1050:
|
|
1905 case 9080:
|
|
1906 {
|
|
1907 v95 = 0;
|
|
1908 pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
|
|
1909 for (v146 = 0; v146 < (signed int)pObjectList->uNumObjects; ++v146)
|
|
1910 {
|
|
1911 if (pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v146].uObjectID)
|
|
1912 v95 = v146;
|
|
1913 }
|
|
1914 pSpriteObjects[uLayingItemID].uObjectDescID = v95;
|
|
1915 if (!v95)
|
|
1916 SpriteObject::OnInteraction(uLayingItemID);
|
|
1917 v100 = pSpriteObjects[uLayingItemID].field_61;
|
|
1918 pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
|
|
1919 v102 = 8 * uLayingItemID;
|
|
1920 LOBYTE(v102) = PID(OBJECT_Item, uLayingItemID);
|
|
1921 pSpriteObjects[uLayingItemID].vVelocity.x = 0;
|
|
1922 pSpriteObjects[uLayingItemID].vVelocity.y = 0;
|
|
1923 pSpriteObjects[uLayingItemID].vVelocity.z = 0;
|
|
1924 AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, 0);
|
|
1925 if (object->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
|
|
1926 trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uParticleTrailColor);
|
|
1927 if (!pSpriteObjects[uLayingItemID].uSoundID)
|
|
1928 v47 = 0;
|
|
1929 else
|
|
1930 v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
|
|
1931 v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
|
|
1932 pAudioPlayer->PlaySound((SoundID)v125, v102, 0, -1, 0, v47, 0, 0);
|
|
1933 return 0;
|
|
1934 }
|
|
1935
|
|
1936 default:
|
|
1937 return 0;
|
|
1938 }
|
|
1939
|
|
1940 }
|
|
1941
|
|
1942 //----- (0043A97E) --------------------------------------------------------
|
|
1943 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2)
|
|
1944 {
|
|
1945 if (PID_TYPE(a2) == OBJECT_Player)
|
|
1946 {
|
|
1947 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x;
|
|
1948 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y;
|
|
1949 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z;
|
|
1950
|
|
1951 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
|
|
1952 DamagePlayerFromMonster(PID(OBJECT_Item, uLayingItemID), pSpriteObjects[uLayingItemID].field_61, &layingitem_vel_50FDFC, -1);
|
|
1953 }
|
|
1954 else if (PID_TYPE(a2) == OBJECT_Actor)
|
|
1955 {
|
|
1956 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x;
|
|
1957 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y;
|
|
1958 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z;
|
|
1959
|
|
1960 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z);
|
|
1961 switch (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid))
|
|
1962 {
|
|
1963 case OBJECT_Actor:
|
|
1964 Actor::ActorDamageFromMonster(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC, pSpriteObjects[uLayingItemID].field_61);
|
|
1965 break;
|
|
1966 case OBJECT_Player:
|
|
1967 Actor::DamageMonsterFromParty(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC);
|
|
1968 break;
|
|
1969 case OBJECT_Item:
|
|
1970 ItemDamageFromActor(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC);
|
|
1971 break;
|
|
1972 }
|
|
1973 }
|
|
1974 }
|