Mercurial > mm7
comparison SpriteObject.cpp @ 515:cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Some object-related subs moved to SpriteObject.cpp
author | Nomad |
---|---|
date | Fri, 01 Mar 2013 21:13:12 +0200 |
parents | |
children | 574cc56e05e9 |
comparison
equal
deleted
inserted
replaced
514:0bbc39457b25 | 515:cb0ad52d6a26 |
---|---|
1 #include <assert.h> | |
2 | |
3 #include "SpriteObject.h" | |
4 #include "Party.h" | |
5 #include "TurnEngine.h" | |
6 #include "MapInfo.h" | |
7 #include "Math.h" | |
8 #include "ObjectList.h" | |
9 #include "Indoor.h" | |
10 #include "Outdoor.h" | |
11 #include "ParticleEngine.h" | |
12 #include "Time.h" | |
13 #include "Game.h" | |
14 #include "LOD.h" | |
15 #include "Actor.h" | |
16 #include "Events.h" | |
17 | |
18 #include "mm7_data.h" | |
19 | |
20 | |
21 | |
22 | |
23 size_t uNumSpriteObjects; | |
24 SpriteObject pSpriteObjects[1000]; | |
25 | |
26 | |
27 | |
28 | |
29 //----- (0042F5ED) -------------------------------------------------------- | |
30 int SpriteObject::Create(int yaw, int pitch, int a4, int a5) | |
31 { | |
32 //SpriteObject *v5; // eax@1 | |
33 signed int v6; // ebx@2 | |
34 //char *v7; // ecx@2 | |
35 //signed int result; // eax@6 | |
36 SpriteObject *v9; // ebx@7 | |
37 int v10; // edx@11 | |
38 int v11; // edi@18 | |
39 __int16 v12; // ax@18 | |
40 int v13; // ST2C_4@20 | |
41 int v14; // eax@20 | |
42 int v15; // [sp-28h] [bp-38h]@14 | |
43 int v16; // [sp-24h] [bp-34h]@11 | |
44 Vec3_int_ v17; // [sp-20h] [bp-30h]@11 | |
45 int *v18; // [sp-14h] [bp-24h]@11 | |
46 int *v19; // [sp-10h] [bp-20h]@11 | |
47 int *v20; // [sp-Ch] [bp-1Ch]@11 | |
48 //signed int v21; // [sp+8h] [bp-8h]@2 | |
49 int angle; // [sp+Ch] [bp-4h]@1 | |
50 int a4a; // [sp+1Ch] [bp+Ch]@20 | |
51 int a4b; // [sp+1Ch] [bp+Ch]@20 | |
52 int a5a; // [sp+20h] [bp+10h]@20 | |
53 | |
54 //auto a1 = this; | |
55 angle = yaw; | |
56 //v5 = a1; | |
57 if (!uObjectDescID) | |
58 return -1; | |
59 | |
60 v6 = 1000; | |
61 //v7 = (char *)&pSpriteObjects[0].uObjectDescID; | |
62 /*v21 = 0; | |
63 do | |
64 { | |
65 if ( !*(short *)v7 ) | |
66 break; | |
67 v7 += 112; | |
68 ++v6; | |
69 v21 = v6; | |
70 } | |
71 while ( (signed int)v7 < (signed int)((char *)&pObjectList->uNumObjects + 2) );*/ | |
72 for (uint i = 0; i < 1000; ++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 v9 = &pSpriteObjects[v6]; | |
84 field_64.z = vPosition.z; | |
85 | |
86 assert(sizeof(SpriteObject) == 0x70); | |
87 memcpy(v9, this, sizeof(*this)); | |
88 if ( a5 == 1 ) | |
89 { | |
90 v20 = &v9->vPosition.z; | |
91 v19 = &v9->vPosition.y; | |
92 v18 = (int *)&v9->vPosition; | |
93 v17.x = vPosition.x; | |
94 v17.y = vPosition.y; | |
95 v17.z = vPosition.z; | |
96 v16 = 0; | |
97 v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; | |
98 goto LABEL_16; | |
99 } | |
100 if ( a5 == 2 ) | |
101 { | |
102 v20 = &v9->vPosition.z; | |
103 v19 = &v9->vPosition.y; | |
104 v18 = (int *)&v9->vPosition; | |
105 v17.x = vPosition.x; | |
106 v17.y = vPosition.y; | |
107 v17.z = vPosition.z; | |
108 v16 = 0; | |
109 v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; | |
110 goto LABEL_14; | |
111 } | |
112 if ( a5 == 3 ) | |
113 { | |
114 v20 = &v9->vPosition.z; | |
115 v19 = &v9->vPosition.y; | |
116 v18 = (int *)&v9->vPosition; | |
117 v17.x = vPosition.x; | |
118 v17.y = vPosition.y; | |
119 v17.z = vPosition.z; | |
120 v16 = 0; | |
121 v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; | |
122 LABEL_14: | |
123 v15 = 8; | |
124 LABEL_17: | |
125 Vec3_int_::Rotate(v15, v10, v16, v17, v18, v19, v20); | |
126 goto LABEL_18; | |
127 } | |
128 if ( a5 == 4 ) | |
129 { | |
130 v20 = &v9->vPosition.z; | |
131 v19 = &v9->vPosition.y; | |
132 v18 = (int *)&v9->vPosition; | |
133 v17.x = vPosition.x; | |
134 v17.y = vPosition.y; | |
135 v17.z = vPosition.z; | |
136 v16 = 0; | |
137 v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; | |
138 LABEL_16: | |
139 v15 = 24; | |
140 goto LABEL_17; | |
141 } | |
142 LABEL_18: | |
143 v11 = a4; | |
144 v12 = 0; | |
145 if ( a4 ) | |
146 { | |
147 a4a = stru_5C6E00->Cos(angle); | |
148 v13 = (unsigned __int64)(a4a * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; | |
149 a4b = stru_5C6E00->Sin(angle); | |
150 a5a = (unsigned __int64)(a4b * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; | |
151 v14 = stru_5C6E00->Sin(pitch); | |
152 v9->vVelocity.x = (unsigned int)(v13 * v11) >> 16; | |
153 v9->vVelocity.y = (unsigned int)(a5a * v11) >> 16; | |
154 v12 = (unsigned int)(v14 * v11) >> 16; | |
155 } | |
156 else | |
157 { | |
158 v9->vVelocity.y = 0; | |
159 v9->vVelocity.x = 0; | |
160 } | |
161 v9->vVelocity.z = v12; | |
162 | |
163 if ( v6 >= (signed int)uNumSpriteObjects ) | |
164 uNumSpriteObjects = v6 + 1; | |
165 return v6; | |
166 } | |
167 | |
168 | |
169 | |
170 //----- (00471C03) -------------------------------------------------------- | |
171 void SpriteObject::UpdateObject_fn0_ODM(unsigned int uLayingItemID) | |
172 { | |
173 SpriteObject *v1; // esi@1 | |
174 ObjectDesc *v2; // ebx@1 | |
175 signed int v3; // edx@1 | |
176 int v4; // ecx@1 | |
177 int v5; // ST04_4@1 | |
178 int v6; // eax@1 | |
179 int v7; // ecx@1 | |
180 int v8; // edi@1 | |
181 int v9; // eax@4 | |
182 __int16 v10; // ax@7 | |
183 int v11; // edx@11 | |
184 int v12; // ecx@11 | |
185 signed int v13; // edx@14 | |
186 signed int v14; // edx@16 | |
187 int v15; // eax@24 | |
188 int v16; // eax@25 | |
189 int v17; // ST10_4@25 | |
190 signed int v18; // eax@25 | |
191 signed int v19; // eax@28 | |
192 Actor *v20; // edi@31 | |
193 int v21; // eax@41 | |
194 int v22; // ecx@43 | |
195 __int16 v23; // bx@45 | |
196 char v24; // al@46 | |
197 signed int i; // edi@50 | |
198 int v26; // edi@52 | |
199 int v27; // eax@52 | |
200 __int16 v28; // cx@55 | |
201 int v29; // eax@55 | |
202 signed int v30; // edi@59 | |
203 BSPModel *v31; // ecx@61 | |
204 ODMFace *v32; // edi@61 | |
205 int v33; // eax@62 | |
206 int v34; // ecx@62 | |
207 int v35; // eax@63 | |
208 Actor *v36; // ecx@67 | |
209 __int16 v37; // ax@67 | |
210 int v38; // eax@72 | |
211 int v39; // eax@72 | |
212 unsigned __int64 v40; // qax@72 | |
213 int v41; // eax@72 | |
214 unsigned __int8 v42; // sf@74 | |
215 unsigned __int8 v43; // of@74 | |
216 int v44; // eax@77 | |
217 __int16 v45; // bx@81 | |
218 int v46; // eax@85 | |
219 const char *v47; // [sp-8h] [bp-B0h]@83 | |
220 enum TEXTURE_TYPE v48; // [sp-4h] [bp-ACh]@46 | |
221 int v49; // [sp+Ch] [bp-9Ch]@52 | |
222 int v50; // [sp+10h] [bp-98h]@52 | |
223 Vec3_int_ v51; // [sp+14h] [bp-94h]@11 | |
224 Particle_ Dst; // [sp+20h] [bp-88h]@45 | |
225 unsigned int uLayingItemID_; // [sp+88h] [bp-20h]@1 | |
226 int v54; // [sp+8Ch] [bp-1Ch]@1 | |
227 int v55; // [sp+90h] [bp-18h]@1 | |
228 int v56; // [sp+94h] [bp-14h]@11 | |
229 int v57; // [sp+98h] [bp-10h]@1 | |
230 int v58; // [sp+9Ch] [bp-Ch]@1 | |
231 int v59; // [sp+A0h] [bp-8h]@1 | |
232 Actor *v60; // [sp+A4h] [bp-4h]@11 | |
233 | |
234 uLayingItemID_ = uLayingItemID; | |
235 v1 = &pSpriteObjects[uLayingItemID]; | |
236 v58 = 0; | |
237 v2 = &pObjectList->pObjects[v1->uObjectDescID]; | |
238 v57 = IsTerrainSlopeTooHigh(v1->vPosition.x, v1->vPosition.y); | |
239 v3 = v1->vPosition.y; | |
240 v4 = v1->vPosition.x; | |
241 v5 = v2->uHeight; | |
242 v55 = 0; | |
243 v6 = sub_46D49E_prolly_get_world_y_under_party(v4, v3, v1->vPosition.z, v5, &v59, &v55, 0); | |
244 v7 = v6; | |
245 v54 = v6; | |
246 v8 = v6 + 1; | |
247 if ( v1->vPosition.z <= v6 + 1 ) | |
248 { | |
249 if ( v59 ) | |
250 { | |
251 v9 = v6 + 60; | |
252 if ( v55 ) | |
253 v9 = v7 + 30; | |
254 sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v9); | |
255 SpriteObject::OnInteraction(uLayingItemID_); | |
256 v7 = v54; | |
257 } | |
258 } | |
259 else | |
260 { | |
261 v58 = 1; | |
262 } | |
263 v10 = v2->uFlags; | |
264 if ( !(v10 & 0x20) ) | |
265 { | |
266 if ( v58 ) | |
267 { | |
268 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
269 goto LABEL_13; | |
270 } | |
271 if ( v57 ) | |
272 { | |
273 v11 = v1->vPosition.y; | |
274 v12 = v1->vPosition.x; | |
275 v1->vPosition.z = v8; | |
276 ODM_GetTerrainNormalAt(v12, v11, &v51); | |
277 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
278 v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16; | |
279 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16); | |
280 v1->vVelocity.x += (unsigned int)(v56 * v51.x) >> 16; | |
281 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16); | |
282 v1->vVelocity.y += (unsigned int)(v56 * v51.y) >> 16; | |
283 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16); | |
284 v1->vVelocity.z += (unsigned int)(v56 * v51.z) >> 16; | |
285 LABEL_12: | |
286 v7 = v54; | |
287 goto LABEL_13; | |
288 } | |
289 if ( v10 & 0x40 ) | |
290 { | |
291 if ( v1->vPosition.z < v7 ) | |
292 v1->vPosition.z = v8; | |
293 if ( !_46BFFA_check_object_intercept(uLayingItemID_, 0) ) | |
294 return; | |
295 } | |
296 v1->vPosition.z = v8; | |
297 if ( !(v2->uFlags & 0x80) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) ) | |
298 v1->vVelocity.z = 0; | |
299 v60 = (Actor *)v1->vVelocity.x; | |
300 v55 = 58500; | |
301 v60 = (Actor *)((unsigned __int64)(58500i64 * (signed int)v60) >> 16); | |
302 v1->vVelocity.x = (signed __int16)v60; | |
303 v60 = (Actor *)v1->vVelocity.y; | |
304 v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16); | |
305 v55 = 58500; | |
306 v1->vVelocity.y = (signed __int16)v60; | |
307 v60 = (Actor *)v1->vVelocity.z; | |
308 v60 = (Actor *)((unsigned __int64)(v55 * (signed __int64)(signed int)v60) >> 16); | |
309 v22 = v1->vVelocity.x; | |
310 v1->vVelocity.z = (signed __int16)v60; | |
311 if ( v1->vVelocity.y * v1->vVelocity.y + v22 * v22 >= 400 ) | |
312 goto LABEL_12; | |
313 v1->vVelocity.y = 0; | |
314 v1->vVelocity.x = 0; | |
315 if ( !(HIBYTE(v2->uFlags) & 1) ) | |
316 return; | |
317 memset(&Dst, 0, 0x68u); | |
318 v23 = v2->uFlags; | |
319 Dst.x = (double)v1->vPosition.x; | |
320 Dst.y = (double)v1->vPosition.y; | |
321 Dst.z = (double)v1->vPosition.z; | |
322 Dst.flt_10 = 0.0; | |
323 Dst.flt_14 = 0.0; | |
324 Dst.flt_18 = 0.0; | |
325 if ( HIBYTE(v23) & 2 ) | |
326 { | |
327 Dst.bFree = 1036; | |
328 Dst.uDiffuse = 16727070; | |
329 v24 = rand(); | |
330 v48 = (TEXTURE_TYPE)0; | |
331 LABEL_83: | |
332 v47 = "effpar01"; | |
333 } | |
334 else | |
335 { | |
336 if ( HIBYTE(v23) & 4 ) | |
337 { | |
338 Dst.bFree = 512; | |
339 Dst.uDiffuse = rand(); | |
340 Dst.timeToLive = 64; | |
341 Dst.uTextureID = 0; | |
342 LABEL_89: | |
343 Dst.flt_28 = 1.0; | |
344 pGame->pParticleEngine->AddParticle(&Dst); | |
345 return; | |
346 } | |
347 Dst.bFree = 1032; | |
348 Dst.uDiffuse = rand(); | |
349 v24 = rand(); | |
350 v48 = (TEXTURE_TYPE)0; | |
351 LABEL_87: | |
352 v47 = "effpar03"; | |
353 } | |
354 Dst.timeToLive = (unsigned __int8)(v24 & 0x80) + 128; | |
355 Dst.uTextureID = pBitmaps_LOD->LoadTexture(v47, v48); | |
356 goto LABEL_89; | |
357 } | |
358 LABEL_13: | |
359 if ( v1->vPosition.z > v7 | |
360 && (v13 = v1->vPosition.x, v13 >= -32768) | |
361 && v13 <= 32768 | |
362 && (v14 = v1->vPosition.y, v14 >= -32768) | |
363 && v14 <= 32768 | |
364 && v1->vPosition.z <= 13000 | |
365 || !(v2->uFlags & 0x40) ) | |
366 goto LABEL_92; | |
367 if ( v1->vPosition.z < v7 ) | |
368 v1->vPosition.z = v8; | |
369 if ( _46BFFA_check_object_intercept(uLayingItemID_, 0) ) | |
370 { | |
371 LABEL_92: | |
372 stru_721530.field_0 = 0; | |
373 v55 = 0; | |
374 stru_721530.prolly_normal_d = v2->uRadius; | |
375 stru_721530.field_C = v2->uHeight; | |
376 stru_721530.field_8 = 0; | |
377 stru_721530.field_70 = 0; | |
378 while ( 1 ) | |
379 { | |
380 stru_721530.field_34.x = v1->vPosition.x; | |
381 stru_721530.normal.x = stru_721530.field_34.x; | |
382 v15 = v1->vPosition.y; | |
383 stru_721530.uSectorID = 0; | |
384 stru_721530.field_34.y = v15; | |
385 stru_721530.normal.y = v15; | |
386 stru_721530.field_34.z = v1->vPosition.z + stru_721530.prolly_normal_d + 1; | |
387 stru_721530.normal.z = stru_721530.field_34.z; | |
388 stru_721530.field_1C = v1->vVelocity.x; | |
389 stru_721530.field_20 = v1->vVelocity.y; | |
390 stru_721530.field_24 = v1->vVelocity.z; | |
391 if ( stru_721530._47050A(0) ) | |
392 return; | |
393 _46E889_collide_against_bmodels(0); | |
394 v16 = WorldPosToGridCellZ(v1->vPosition.y); | |
395 v17 = v1->vPosition.x; | |
396 v58 = v16; | |
397 v18 = WorldPosToGridCellX(v17); | |
398 _46E26D_collide_against_sprites(v18, v58); | |
399 if ( (v1->field_58_pid & 7) != OBJECT_Player) | |
400 _46EF01_collision_chech_player(0); | |
401 if ( (v1->field_58_pid & 7) == OBJECT_Actor) | |
402 { | |
403 v19 = v1->field_58_pid >> 3; | |
404 if ( v19 >= 0 ) | |
405 { | |
406 if ( v19 < (signed int)(uNumActors - 1) ) | |
407 { | |
408 v56 = 0; | |
409 if ( (signed int)uNumActors > 0 ) | |
410 { | |
411 v60 = pActors; | |
412 v20 = &pActors[v19]; | |
413 do | |
414 { | |
415 if ( v20->GetActorsRelation(v60) ) | |
416 _46DF1A_collide_against_actor(v56, 0); | |
417 ++v56; | |
418 ++v60; | |
419 } | |
420 while ( v56 < (signed int)uNumActors ); | |
421 } | |
422 } | |
423 } | |
424 } | |
425 else | |
426 { | |
427 for ( i = 0; i < (signed int)uNumActors; ++i ) | |
428 _46DF1A_collide_against_actor(i, 0); | |
429 } | |
430 v26 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
431 v27 = sub_46D49E_prolly_get_world_y_under_party( | |
432 stru_721530.normal2.x, | |
433 stru_721530.normal2.y, | |
434 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1, | |
435 v2->uHeight, | |
436 &v49, | |
437 &v50, | |
438 0); | |
439 if ( v59 && v26 < v27 + 60 ) | |
440 { | |
441 if ( v50 ) | |
442 v44 = v27 + 30; | |
443 else | |
444 v44 = v54 + 60; | |
445 sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v44); | |
446 SpriteObject::OnInteraction(uLayingItemID_); | |
447 return; | |
448 } | |
449 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
450 { | |
451 v1->vPosition.x = stru_721530.normal2.x; | |
452 v1->vPosition.y = stru_721530.normal2.y; | |
453 v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
454 v1->uSectorID = LOWORD(stru_721530.uSectorID); | |
455 if ( !(HIBYTE(v2->uFlags) & 1) ) | |
456 return; | |
457 memset(&Dst, 0, 0x68u); | |
458 v45 = v2->uFlags; | |
459 Dst.x = (double)v1->vPosition.x; | |
460 Dst.y = (double)v1->vPosition.y; | |
461 Dst.z = (double)v1->vPosition.z; | |
462 Dst.flt_10 = 0.0; | |
463 Dst.flt_14 = 0.0; | |
464 Dst.flt_18 = 0.0; | |
465 if ( HIBYTE(v45) & 2 ) | |
466 { | |
467 Dst.bFree = 1036; | |
468 Dst.uDiffuse = 16727070; | |
469 v24 = rand(); | |
470 v48 = (TEXTURE_TYPE)0; | |
471 goto LABEL_83; | |
472 } | |
473 if ( HIBYTE(v45) & 4 ) | |
474 { | |
475 Dst.bFree = 512; | |
476 v46 = rand(); | |
477 Dst.uTextureID = 0; | |
478 Dst.uDiffuse = v46; | |
479 Dst.timeToLive = 64; | |
480 goto LABEL_89; | |
481 } | |
482 Dst.bFree = 1032; | |
483 Dst.uDiffuse = rand(); | |
484 v24 = rand(); | |
485 v48 = (TEXTURE_TYPE)0; | |
486 goto LABEL_87; | |
487 } | |
488 v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16); | |
489 v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
490 v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16); | |
491 v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
492 v60 = (Actor *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16); | |
493 v28 = LOWORD(stru_721530.uSectorID); | |
494 v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
495 v29 = v1->vPosition.z; | |
496 v1->uSectorID = v28; | |
497 stru_721530.field_70 += stru_721530.field_7C; | |
498 if ( v2->uFlags & 0x40 ) | |
499 { | |
500 if ( v29 < v54 ) | |
501 v1->vPosition.z = v54 + 1; | |
502 if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) | |
503 return; | |
504 } | |
505 v30 = (signed int)stru_721530.uFaceID >> 3; | |
506 if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) | |
507 break; | |
508 if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) | |
509 { | |
510 v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; | |
511 v32 = &v31->pFaces[v30 & 0x3F]; | |
512 if ( v32->uPolygonType != 3 ) | |
513 { | |
514 v56 = abs(v32->pFacePlane.vNormal.z * v1->vVelocity.z + v32->pFacePlane.vNormal.y * v1->vVelocity.y | |
515 + v32->pFacePlane.vNormal.x * v1->vVelocity.x) >> 16; | |
516 if ( stru_721530.field_64 >> 3 > v56 ) | |
517 v56 = stru_721530.field_64 >> 3; | |
518 v57 = v32->pFacePlane.vNormal.x; | |
519 v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16; | |
520 v58 = v32->pFacePlane.vNormal.y; | |
521 v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16; | |
522 v60 = (Actor *)v32->pFacePlane.vNormal.z; | |
523 v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)(signed int)v60) >> 16); | |
524 v1->vVelocity.x += 2 * v57; | |
525 v1->vVelocity.y += 2 * v58; | |
526 if ( v32->pFacePlane.vNormal.z <= 32000 ) | |
527 { | |
528 v37 = 2 * (short)v60; | |
529 } | |
530 else | |
531 { | |
532 v36 = v60; | |
533 v57 = 32000; | |
534 v1->vVelocity.z += (signed __int16)v60; | |
535 v58 = (unsigned __int64)(v57 * (signed __int64)(signed int)v36) >> 16; | |
536 v37 = (unsigned int)(v57 * (int)v36) >> 16; | |
537 } | |
538 v1->vVelocity.z += v37; | |
539 LABEL_70: | |
540 if ( BYTE3(v32->uAttributes) & 0x10 ) | |
541 EventProcessor(v32->sCogTriggeredID, 0, 1); | |
542 goto LABEL_74; | |
543 } | |
544 v33 = v31->pVertices.pVertices[v32->pVertexIDs[0]].z; | |
545 v34 = v1->vVelocity.x; | |
546 v1->vPosition.z = v33 + 1; | |
547 if ( v1->vVelocity.y * v1->vVelocity.y + v34 * v34 >= 400 ) | |
548 goto LABEL_70; | |
549 LOWORD(v35) = 0; | |
550 v1->vVelocity.z = 0; | |
551 v1->vVelocity.x = 0; | |
552 goto LABEL_73; | |
553 } | |
554 LABEL_74: | |
555 v58 = v1->vVelocity.x; | |
556 v57 = 58500; | |
557 v58 = (unsigned __int64)(58500i64 * v58) >> 16; | |
558 v1->vVelocity.x = v58; | |
559 v58 = v1->vVelocity.y; | |
560 v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16; | |
561 v57 = 58500; | |
562 v1->vVelocity.y = v58; | |
563 v58 = v1->vVelocity.z; | |
564 v58 = (unsigned __int64)(v57 * (signed __int64)v58) >> 16; | |
565 ++v55; | |
566 v43 = __OFSUB__(v55, 100); | |
567 v42 = v55 - 100 < 0; | |
568 v1->vVelocity.z = v58; | |
569 if ( !(v42 ^ v43) ) | |
570 return; | |
571 } | |
572 v57 = integer_sqrt(v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x); | |
573 v38 = stru_5C6E00->Atan2( | |
574 v1->vPosition.x - pLevelDecorations[v30].vPosition.x, | |
575 v1->vPosition.y - pLevelDecorations[v30].vPosition.y); | |
576 v56 = v38; | |
577 v39 = stru_5C6E00->Cos(v38); | |
578 v60 = (Actor *)v39; | |
579 v40 = v39 * (signed __int64)v57; | |
580 v58 = v40 >> 16; | |
581 v1->vVelocity.x = WORD1(v40); | |
582 v41 = stru_5C6E00->Sin(v56 - stru_5C6E00->uIntegerHalfPi); | |
583 v60 = (Actor *)v41; | |
584 v35 = (unsigned __int64)(v41 * (signed __int64)v57) >> 16; | |
585 v58 = v35; | |
586 LABEL_73: | |
587 v1->vVelocity.y = v35; | |
588 goto LABEL_74; | |
589 } | |
590 } | |
591 | |
592 | |
593 | |
594 //----- (0047136C) -------------------------------------------------------- | |
595 void SpriteObject::UpdateObject_fn0_BLV(unsigned int uLayingItemID) | |
596 { | |
597 SpriteObject *v1; // esi@1 | |
598 ObjectDesc *v2; // edi@1 | |
599 int v3; // ST08_4@1 | |
600 __int16 v4; // ax@5 | |
601 __int16 v5; // ax@7 | |
602 BLVFace *v6; // ecx@11 | |
603 BLVFace *v7; // eax@11 | |
604 signed int v8; // ebx@12 | |
605 int v9; // ecx@16 | |
606 __int16 v10; // di@18 | |
607 char v11; // al@19 | |
608 int v12; // eax@25 | |
609 int v13; // eax@31 | |
610 int v14; // ebx@34 | |
611 signed int v15; // ebx@46 | |
612 BLVFace *v16; // edi@48 | |
613 int v17; // eax@50 | |
614 int v18; // eax@52 | |
615 int v19; // ecx@52 | |
616 Vec3_short_ *v20; // ecx@53 | |
617 int v21; // ecx@57 | |
618 __int16 v22; // ax@57 | |
619 int v23; // edi@62 | |
620 int v24; // edi@62 | |
621 int v25; // eax@62 | |
622 unsigned __int64 v26; // qax@62 | |
623 unsigned __int8 v27; // sf@64 | |
624 unsigned __int8 v28; // of@64 | |
625 __int16 v29; // di@67 | |
626 char v30; // al@68 | |
627 const char *v31; // [sp-8h] [bp-98h]@19 | |
628 const char *v32; // [sp-8h] [bp-98h]@68 | |
629 enum TEXTURE_TYPE v33; // [sp-4h] [bp-94h]@19 | |
630 enum TEXTURE_TYPE v34; // [sp-4h] [bp-94h]@68 | |
631 Particle_ Dst; // [sp+Ch] [bp-84h]@18 | |
632 unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1 | |
633 ObjectDesc *v37; // [sp+78h] [bp-18h]@1 | |
634 unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4 | |
635 int v39; // [sp+80h] [bp-10h]@33 | |
636 Actor *v39b; | |
637 int v40; // [sp+84h] [bp-Ch]@28 | |
638 int v41; // [sp+88h] [bp-8h]@34 | |
639 int v42; // [sp+8Ch] [bp-4h]@4 | |
640 | |
641 uLayingItemID_ = uLayingItemID; | |
642 v1 = &pSpriteObjects[uLayingItemID]; | |
643 v2 = &pObjectList->pObjects[v1->uObjectDescID]; | |
644 v3 = v1->vPosition.x; | |
645 v37 = &pObjectList->pObjects[v1->uObjectDescID]; | |
646 if ( abs(v3) > 32767 | |
647 || abs(v1->vPosition.y) > 32767 | |
648 || abs(v1->vPosition.z) > 20000 | |
649 || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v1->uSectorID, &uFaceID), | |
650 v42 <= -30000) | |
651 && ((v4 = pIndoor->GetSector(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z), | |
652 (v1->uSectorID = v4) == 0) | |
653 || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v4, &uFaceID), v42 == -30000)) ) | |
654 { | |
655 SpriteObject::OnInteraction(uLayingItemID_); | |
656 return; | |
657 } | |
658 v5 = v2->uFlags; | |
659 if ( v5 & 0x20 ) | |
660 { | |
661 LABEL_24: | |
662 v8 = 0; | |
663 LABEL_25: | |
664 stru_721530.field_0 = v8; | |
665 uFaceID = v8; | |
666 stru_721530.prolly_normal_d = v2->uRadius; | |
667 v12 = v2->uHeight; | |
668 stru_721530.field_84 = -1; | |
669 stru_721530.field_C = v12; | |
670 stru_721530.field_8 = v8; | |
671 stru_721530.field_70 = v8; | |
672 while ( 1 ) | |
673 { | |
674 stru_721530.field_34.x = v1->vPosition.x; | |
675 stru_721530.normal.x = stru_721530.field_34.x; | |
676 stru_721530.field_34.y = v1->vPosition.y; | |
677 stru_721530.normal.y = stru_721530.field_34.y; | |
678 stru_721530.field_34.z = stru_721530.prolly_normal_d + v1->vPosition.z + 1; | |
679 stru_721530.normal.z = stru_721530.field_34.z; | |
680 stru_721530.field_1C = v1->vVelocity.x; | |
681 stru_721530.field_20 = v1->vVelocity.y; | |
682 stru_721530.field_24 = v1->vVelocity.z; | |
683 stru_721530.uSectorID = v1->uSectorID; | |
684 if ( stru_721530._47050A(v8) ) | |
685 return; | |
686 v40 = v8; | |
687 do | |
688 { | |
689 _46E44E_collide_against_faces_and_portals(0); | |
690 _46E0B2_collide_against_decorations(); | |
691 if ( (v1->field_58_pid & 7) != OBJECT_Player) | |
692 _46EF01_collision_chech_player(1); | |
693 v13 = v1->field_58_pid; | |
694 v42 = v8; | |
695 if ( (v13 & 7) == OBJECT_Actor) | |
696 { | |
697 if ( (signed int)uNumActors > v8 ) | |
698 { | |
699 v39b = pActors;//[0].word_000086_some_monster_id; | |
700 do | |
701 { | |
702 //v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1; | |
703 //v14 = (signed __int64)((double)v41 * 0.3333333333333333); | |
704 //v41 = *(short *)(v39 - 38) - 1; | |
705 //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) ) | |
706 if( pActors[v1->field_58_pid >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID ) | |
707 //not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius | |
708 _46DF1A_collide_against_actor(v42, *((short *)&pMonsterList->pMonsters[v39b->word_000086_some_monster_id] - 73)); | |
709 ++v42; | |
710 ++v39b;// += 836; | |
711 } | |
712 while ( v42 < (signed int)uNumActors ); | |
713 v8 = 0; | |
714 } | |
715 } | |
716 else | |
717 { | |
718 if ( (signed int)uNumActors > v8 ) | |
719 { | |
720 v39b = pActors;//[0].word_000086_some_monster_id; | |
721 do | |
722 { | |
723 _46DF1A_collide_against_actor(v42++, *((short *)&pMonsterList->pMonsters[*(short *)v39b] - 73)); | |
724 ++v39b; | |
725 } | |
726 while ( v42 < (signed int)uNumActors ); | |
727 } | |
728 } | |
729 if ( _46F04E_collide_against_portals() ) | |
730 break; | |
731 ++v40; | |
732 } | |
733 while ( v40 < 100 ); | |
734 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
735 { | |
736 v1->vPosition.x = stru_721530.normal2.x; | |
737 v1->vPosition.y = stru_721530.normal2.y; | |
738 v1->vPosition.z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
739 v1->uSectorID = LOWORD(stru_721530.uSectorID); | |
740 if ( !(HIBYTE(v2->uFlags) & 1) ) | |
741 return; | |
742 memset(&Dst, v8, 0x68u); | |
743 v29 = v2->uFlags; | |
744 Dst.x = (double)v1->vPosition.x; | |
745 Dst.y = (double)v1->vPosition.y; | |
746 Dst.z = (double)v1->vPosition.z; | |
747 Dst.flt_10 = 0.0; | |
748 Dst.flt_14 = 0.0; | |
749 Dst.flt_18 = 0.0; | |
750 if ( v29 & 0x200 ) | |
751 { | |
752 Dst.bFree = 1036; | |
753 Dst.uDiffuse = 0xFF3C1Eu; | |
754 v30 = rand(); | |
755 v34 = (TEXTURE_TYPE)v8; | |
756 v32 = "effpar01"; | |
757 } | |
758 else | |
759 { | |
760 if ( v29 & 0x400 ) | |
761 goto LABEL_70; | |
762 Dst.bFree = 1032; | |
763 Dst.uDiffuse = rand(); | |
764 v30 = rand(); | |
765 v34 = (TEXTURE_TYPE)v8; | |
766 v32 = "effpar03"; | |
767 } | |
768 Dst.timeToLive = (unsigned __int8)(v30 & 0x80) + 128; | |
769 Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34); | |
770 goto LABEL_71; | |
771 } | |
772 v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
773 v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
774 v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
775 v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
776 v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
777 v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
778 v1->uSectorID = LOWORD(stru_721530.uSectorID); | |
779 stru_721530.field_70 += stru_721530.field_7C; | |
780 if ( v2->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) | |
781 return; | |
782 v15 = (signed int)stru_721530.uFaceID >> 3; | |
783 if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) | |
784 { | |
785 v40 = integer_sqrt(v1->vVelocity.x * v1->vVelocity.x + v1->vVelocity.y * v1->vVelocity.y); | |
786 v23 = stru_5C6E00->Atan2( | |
787 v1->vPosition.x - pLevelDecorations[v15].vPosition.x, | |
788 v1->vPosition.y - pLevelDecorations[v15].vPosition.y); | |
789 v42 = stru_5C6E00->Cos(v23); | |
790 v41 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16; | |
791 v24 = v23; | |
792 v1->vVelocity.x = (unsigned int)(v42 * v40) >> 16; | |
793 v25 = stru_5C6E00->Sin(v23); | |
794 v42 = v25; | |
795 v26 = v25 * (signed __int64)v40; | |
796 v41 = v26 >> 16; | |
797 v1->vVelocity.y = WORD1(v26); | |
798 } | |
799 else | |
800 { | |
801 if ( (stru_721530.uFaceID & 7) != OBJECT_BModel) | |
802 goto LABEL_64; | |
803 stru_721530.field_84 = (signed int)stru_721530.uFaceID >> 3; | |
804 v16 = &pIndoor->pFaces[v15]; | |
805 if ( v16->uPolygonType != 3 ) | |
806 { | |
807 v42 = abs(v16->pFacePlane_old.vNormal.x * v1->vVelocity.x + v16->pFacePlane_old.vNormal.z * v1->vVelocity.z | |
808 + v16->pFacePlane_old.vNormal.y * v1->vVelocity.y) >> 16; | |
809 if ( stru_721530.field_64 >> 3 > v42 ) | |
810 v42 = stru_721530.field_64 >> 3; | |
811 v40 = v16->pFacePlane_old.vNormal.x; | |
812 v40 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16; | |
813 v41 = v16->pFacePlane_old.vNormal.y; | |
814 v41 = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
815 v39 = v16->pFacePlane_old.vNormal.z; | |
816 v39 = (unsigned __int64)(v42 * (signed __int64)v39) >> 16; | |
817 v1->vVelocity.x += 2 * v40; | |
818 v1->vVelocity.y += 2 * v41; | |
819 if ( v16->pFacePlane_old.vNormal.z <= 32000 ) | |
820 { | |
821 v22 = 2 * v39; | |
822 } | |
823 else | |
824 { | |
825 v21 = v39; | |
826 v40 = 32000; | |
827 v1->vVelocity.z += v39; | |
828 v41 = (unsigned __int64)(v40 * (signed __int64)v21) >> 16; | |
829 v22 = (unsigned int)(v40 * v21) >> 16; | |
830 } | |
831 v1->vVelocity.z += v22; | |
832 goto LABEL_60; | |
833 } | |
834 if ( v37->uFlags & 0x80 ) | |
835 { | |
836 v17 = -v1->vVelocity.z >> 1; | |
837 v1->vVelocity.z = v17; | |
838 if ( (signed __int16)v17 < 10 ) | |
839 v1->vVelocity.z = 0; | |
840 LABEL_60: | |
841 if ( BYTE3(v16->uAttributes) & 0x10 ) | |
842 EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1); | |
843 goto LABEL_63; | |
844 } | |
845 v18 = v1->vVelocity.y; | |
846 v19 = v1->vVelocity.x; | |
847 v1->vVelocity.z = 0; | |
848 if ( v19 * v19 + v18 * v18 >= 400 ) | |
849 goto LABEL_60; | |
850 v20 = pIndoor->pVertices; | |
851 v1->vVelocity.z = 0; | |
852 v1->vVelocity.y = 0; | |
853 v1->vVelocity.x = 0; | |
854 v1->vPosition.z = v20[*v16->pVertexIDs].z + 1; | |
855 } | |
856 LABEL_63: | |
857 v2 = v37; | |
858 LABEL_64: | |
859 v41 = v1->vVelocity.x; | |
860 v40 = 58500; | |
861 v41 = (unsigned __int64)(58500i64 * v41) >> 16; | |
862 v1->vVelocity.x = v41; | |
863 v41 = v1->vVelocity.y; | |
864 v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16; | |
865 v40 = 58500; | |
866 v1->vVelocity.y = v41; | |
867 v41 = v1->vVelocity.z; | |
868 v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16; | |
869 ++uFaceID; | |
870 v28 = __OFSUB__(uFaceID, 100); | |
871 v27 = uFaceID - 100 < 0; | |
872 v1->vVelocity.z = v41; | |
873 if ( !(v27 ^ v28) ) | |
874 return; | |
875 v8 = 0; | |
876 } | |
877 } | |
878 if ( v42 <= v1->vPosition.z - 3 ) | |
879 { | |
880 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
881 goto LABEL_24; | |
882 } | |
883 if ( !(v5 & 0x40) || _46BFFA_check_object_intercept(uLayingItemID_, 0) ) | |
884 { | |
885 v6 = pIndoor->pFaces; | |
886 v1->vPosition.z = v42 + 1; | |
887 v7 = &v6[uFaceID]; | |
888 if ( v7->uPolygonType == 3 ) | |
889 { | |
890 v8 = 0; | |
891 v1->vVelocity.z = 0; | |
892 } | |
893 else | |
894 { | |
895 if ( v7->pFacePlane_old.vNormal.z < 45000 ) | |
896 v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
897 v8 = 0; | |
898 } | |
899 v42 = v1->vVelocity.x; | |
900 uFaceID = 58500; | |
901 v42 = (unsigned __int64)(58500i64 * v42) >> 16; | |
902 v1->vVelocity.x = v42; | |
903 v42 = v1->vVelocity.y; | |
904 v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16; | |
905 uFaceID = 58500; | |
906 v1->vVelocity.y = v42; | |
907 v42 = v1->vVelocity.z; | |
908 v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16; | |
909 v9 = v1->vVelocity.x; | |
910 v1->vVelocity.z = v42; | |
911 if ( v9 * v9 + v1->vVelocity.y * v1->vVelocity.y < 400 ) | |
912 { | |
913 v1->vVelocity.z = v8; | |
914 v1->vVelocity.y = v8; | |
915 v1->vVelocity.x = v8; | |
916 if ( !(HIBYTE(v2->uFlags) & 1) ) | |
917 return; | |
918 memset(&Dst, v8, 0x68u); | |
919 v10 = v2->uFlags; | |
920 Dst.x = (double)v1->vPosition.x; | |
921 Dst.y = (double)v1->vPosition.y; | |
922 Dst.z = (double)v1->vPosition.z; | |
923 Dst.flt_10 = 0.0; | |
924 Dst.flt_14 = 0.0; | |
925 Dst.flt_18 = 0.0; | |
926 if ( v10 & 0x200 ) | |
927 { | |
928 Dst.bFree = 1036; | |
929 Dst.uDiffuse = 0xFF3C1Eu; | |
930 Dst.flt_28 = 1.0; | |
931 v11 = rand(); | |
932 v33 = (TEXTURE_TYPE)v8; | |
933 v31 = "effpar01"; | |
934 } | |
935 else | |
936 { | |
937 if ( v10 & 0x400 ) | |
938 { | |
939 LABEL_70: | |
940 Dst.bFree = 512; | |
941 Dst.uDiffuse = rand(); | |
942 Dst.timeToLive = 64; | |
943 Dst.uTextureID = v8; | |
944 LABEL_71: | |
945 Dst.flt_28 = 1.0; | |
946 goto LABEL_72; | |
947 } | |
948 Dst.bFree = 1032; | |
949 Dst.uDiffuse = rand(); | |
950 Dst.flt_28 = 1.0; | |
951 v11 = rand(); | |
952 v33 = (TEXTURE_TYPE)v8; | |
953 v31 = "effpar03"; | |
954 } | |
955 Dst.timeToLive = (unsigned __int8)(v11 & 0x80) + 128; | |
956 Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33); | |
957 LABEL_72: | |
958 pGame->pParticleEngine->AddParticle(&Dst); | |
959 return; | |
960 } | |
961 goto LABEL_25; | |
962 } | |
963 } | |
964 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); | |
965 | |
966 | |
967 | |
968 | |
969 //----- (00438E35) -------------------------------------------------------- | |
970 void SpriteObject::_438E35() | |
971 { | |
972 SpriteObject *v1; // edi@1 | |
973 MapInfo *pMapInfo; // esi@1 | |
974 int v3; // ebx@1 | |
975 int v4; // eax@1 | |
976 int v5; // ebx@1 | |
977 unsigned int v6; // ecx@1 | |
978 int v7; // edx@2 | |
979 unsigned int v8; // edx@4 | |
980 unsigned int v9; // edx@6 | |
981 unsigned int v10; // eax@7 | |
982 signed int v11; // ebx@8 | |
983 Player **v12; // esi@18 | |
984 signed int v13; // edi@20 | |
985 int v15; // [sp+Ch] [bp-Ch]@1 | |
986 int v16; // [sp+10h] [bp-8h]@1 | |
987 signed int v17; // [sp+14h] [bp-4h]@8 | |
988 int v18; // [sp+14h] [bp-4h]@14 | |
989 | |
990 v1 = this; | |
991 pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]; | |
992 v3 = abs(pParty->vPosition.x - v1->vPosition.x); | |
993 v15 = abs(pParty->vPosition.y - v1->vPosition.y); | |
994 v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z); | |
995 v4 = v3; | |
996 v5 = v15; | |
997 v6 = v16; | |
998 if ( v4 < v15 ) | |
999 { | |
1000 v7 = v4; | |
1001 v4 = v15; | |
1002 v5 = v7; | |
1003 } | |
1004 if ( v4 < v16 ) | |
1005 { | |
1006 v8 = v4; | |
1007 v4 = v16; | |
1008 v6 = v8; | |
1009 } | |
1010 if ( v5 < (signed int)v6 ) | |
1011 { | |
1012 v9 = v6; | |
1013 v6 = v5; | |
1014 v5 = v9; | |
1015 } | |
1016 v10 = ((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4; | |
1017 if ( (signed int)v10 <= 768 ) | |
1018 { | |
1019 v17 = 0; | |
1020 v11 = 5; | |
1021 if ( pMapInfo->Trap_D20 ) | |
1022 { | |
1023 do | |
1024 { | |
1025 ++v17; | |
1026 v11 += rand() % 20 + 1; | |
1027 } | |
1028 while ( v17 < pMapInfo->Trap_D20 ); | |
1029 } | |
1030 switch ( v1->uType ) | |
1031 { | |
1032 case 0x32Bu: | |
1033 v18 = 0; | |
1034 break; | |
1035 case 0x32Cu: | |
1036 v18 = 1; | |
1037 break; | |
1038 case 0x32Du: | |
1039 v18 = 2; | |
1040 break; | |
1041 default: | |
1042 //LOWORD(v10) = v1->uItemType - 814; | |
1043 if ( v1->uType != 814 ) | |
1044 return; | |
1045 v18 = 8; | |
1046 break; | |
1047 } | |
1048 v12 = &pPlayers[1]; | |
1049 do | |
1050 { | |
1051 if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) ) | |
1052 (*v12)->PlaySound(SPEECH_6, 0); | |
1053 else | |
1054 (*v12)->ReceiveDamage(v11, v18); | |
1055 ++v12; | |
1056 } | |
1057 while ( (signed int)v12 <= (signed int)&pPlayers[4] ); | |
1058 } | |
1059 } | |
1060 | |
1061 | |
1062 | |
1063 //----- (0042F933) -------------------------------------------------------- | |
1064 void SpriteObject::OnInteraction(unsigned int uLayingItemID) | |
1065 { | |
1066 unsigned int v1; // ecx@1 | |
1067 unsigned __int16 *pAttributes; // ecx@2 | |
1068 unsigned __int16 v3; // ax@2 | |
1069 | |
1070 //__debugbreak(); // find out what's going on | |
1071 | |
1072 v1 = uLayingItemID; | |
1073 pSpriteObjects[v1].uObjectDescID = 0; | |
1074 if ( pParty->bTurnBasedModeOn == 1 ) | |
1075 { | |
1076 pAttributes = &pSpriteObjects[v1].uAttributes; | |
1077 v3 = *pAttributes; | |
1078 if ( *pAttributes & 4 ) | |
1079 { | |
1080 v3 = v3 & 0xFB; | |
1081 --pTurnEngine->field_1C; | |
1082 *pAttributes = v3; | |
1083 } | |
1084 } | |
1085 } |