Mercurial > mm7
annotate Actor.cpp @ 1311:1dee26137a92
added books h file
author | Gloval |
---|---|
date | Tue, 25 Jun 2013 00:05:51 +0400 |
parents | 13b7be8b06a0 |
children | bfde0563ecdc |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1115
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1115
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1115
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1115
diff
changeset
|
4 |
322 | 5 #include <assert.h> |
6 | |
1016 | 7 |
1253 | 8 #include "mm7_data.h" |
1016 | 9 #include "DecalBuilder.h" |
10 | |
11 #include "Sprites.h" | |
12 #include "stru6.h" | |
13 | |
14 | |
0 | 15 #include "Actor.h" |
16 #include "Math.h" | |
17 #include "Outdoor.h" | |
18 #include "AudioPlayer.h" | |
19 #include "Game.h" | |
20 #include "ObjectList.h" | |
21 #include "Overlays.h" | |
22 #include "Events.h" | |
23 #include "IndoorCamera.h" | |
24 #include "FactionTable.h" | |
25 #include "TurnEngine.h" | |
26 #include "MapInfo.h" | |
924 | 27 #include "CastSpellInfo.h" |
0 | 28 #include "Time.h" |
29 #include "LOD.h" | |
30 #include "Party.h" | |
31 #include "GUIWindow.h" | |
32 #include "GUIFont.h" | |
33 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
34 #include "MM7.h" |
1016 | 35 #include "SpriteObject.h" |
1295 | 36 #include "stru298.h" |
1297 | 37 #include "Log.h" |
38 #include "Texts.h" | |
39 #include "Allocator.h" | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
40 |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
41 |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
42 |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
43 |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
44 |
1202 | 45 std::array<Actor, 500> pActors; |
760 | 46 int uNumActors; |
0 | 47 |
48 stru319 stru_50C198; // idb | |
49 | |
994 | 50 |
51 | |
52 | |
53 //----- (0041AF52) -------------------------------------------------------- | |
54 void Actor::DrawHealthBar(Actor *a1, GUIWindow *a2) | |
55 { | |
56 unsigned int v2; // eax@1 | |
57 GUIWindow *v3; // edi@1 | |
58 unsigned int v4; // esi@1 | |
59 signed int v5; // ebx@4 | |
60 double v6; // st7@5 | |
61 unsigned int v7; // eax@6 | |
62 unsigned int v8; // ebx@10 | |
63 unsigned int v9; // [sp+14h] [bp-Ch]@4 | |
64 unsigned int v10; // [sp+1Ch] [bp-4h]@4 | |
65 | |
66 v2 = a1->pMonsterInfo.uHP; | |
67 v3 = a2; | |
68 v4 = 25; | |
69 if ( (signed int)v2 > 25 ) | |
70 { | |
71 v4 = 200; | |
72 if ( (signed int)v2 < 200 ) | |
73 v4 = a1->pMonsterInfo.uHP; | |
74 } | |
75 v5 = a1->sCurrentHP; | |
76 v10 = v4; | |
77 v9 = uTextureID_mhp_grn; | |
78 if ( v5 < (signed int)v2 ) | |
79 { | |
80 v6 = (double)(signed int)v2; | |
81 v10 = (signed __int64)((double)(signed int)v4 / (double)(signed int)v2 * (double)a1->sCurrentHP); | |
82 if ( v5 <= (signed int)(signed __int64)(0.34 * v6) ) | |
83 { | |
84 v7 = uTextureID_mhp_red; | |
85 v9 = v7; | |
86 } | |
87 else if ( v5 <= (signed int)(signed __int64)(v6 * 0.67) ) | |
88 { | |
89 v7 = uTextureID_mhp_yel; | |
90 v9 = v7; | |
91 } | |
92 } | |
93 v8 = a2->uFrameX + (signed int)(a2->uFrameWidth - v4) / 2; | |
94 | |
95 pRenderer->SetTextureClipRect(v8, a2->uFrameY + 32, v8 + v4, a2->uFrameY + 52); | |
96 pRenderer->DrawTextureIndexed(v8, v3->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_bd)); | |
97 pRenderer->SetTextureClipRect(v8, v3->uFrameY + 32, v8 + v10, v3->uFrameY + 52); | |
98 pRenderer->DrawTextureIndexed(v8, v3->uFrameY + 34, pIcons_LOD->GetTexture(v9)); | |
99 | |
100 pRenderer->ResetTextureClipRect(); | |
101 pRenderer->DrawTextureIndexed(v8 - 5, v3->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capl)); | |
102 pRenderer->DrawTextureIndexed(v8 + v4, v3->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capr)); | |
103 } | |
104 | |
781 | 105 //----- (00448A40) -------------------------------------------------------- |
106 void Actor::ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle) | |
107 { | |
108 if ( uActorID >= 0 && uActorID <= (signed int)(uNumActors - 1) ) | |
109 { | |
110 if ( bToggle ) | |
111 { | |
112 pActors[uActorID].uAttributes |= uFlag; | |
113 } | |
114 else | |
115 { | |
116 if ( uFlag == 0x10000 ) | |
117 { | |
118 if (pActors[uActorID].uAIState == Disabled ) | |
119 pActors[uActorID].uAIState = Standing; | |
120 } | |
121 pActors[uActorID].uAttributes &= ~uFlag; | |
122 } | |
123 } | |
124 } | |
0 | 125 |
126 //----- (00448518) -------------------------------------------------------- | |
127 void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3) | |
128 { | |
129 signed int v3; // eax@1 | |
130 int *v4; // edi@2 | |
131 signed int v5; // eax@6 | |
132 char *v6; // ecx@6 | |
133 char *v7; // eax@11 | |
134 ItemGen *v8; // ecx@15 | |
135 | |
136 v3 = 0; | |
137 if ( (signed int)uNumActors > 0 ) | |
138 { | |
602 | 139 v4 = (int *)&pActors[0].sNPC_ID; |
0 | 140 while ( *(short *)v4 != npc ) |
141 { | |
142 ++v3; | |
143 v4 += 209; | |
144 if ( v3 >= (signed int)uNumActors ) | |
145 return; | |
146 } | |
147 v5 = v3; | |
148 v6 = (char *)&pActors[v5].uCarriedItemID; | |
149 if ( a3 ) | |
150 { | |
151 if ( *(short *)v6 ) | |
152 { | |
153 if ( pActors[v5].array_000234[0].uItemID ) | |
154 { | |
155 v7 = (char *)&pActors[v5].array_000234[1]; | |
156 if ( !*(int *)v7 ) | |
157 *(int *)v7 = item; | |
158 } | |
159 else | |
160 { | |
161 pActors[v5].array_000234[0].uItemID = item; | |
162 } | |
163 } | |
164 else | |
165 { | |
166 *(short *)v6 = item; | |
167 } | |
168 } | |
169 else | |
170 { | |
171 if ( *(short *)v6 == item ) | |
172 { | |
173 *(short *)v6 = 0; | |
174 } | |
175 else | |
176 { | |
177 v8 = pActors[v5].array_000234; | |
178 if ( pActors[v5].array_000234[0].uItemID == item | |
179 || (v8 = &pActors[v5].array_000234[1], pActors[v5].array_000234[1].uItemID == item) ) | |
180 v8->Reset(); | |
181 } | |
182 } | |
183 } | |
184 } | |
185 | |
186 //----- (004485A7) -------------------------------------------------------- | |
526 | 187 void Actor::GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive) |
0 | 188 { |
189 unsigned int v3; // eax@3 | |
190 char *v4; // ecx@3 | |
526 | 191 int *v5; // eax@8 |
0 | 192 ItemGen *v6; // ecx@12 |
193 | |
526 | 194 if ( (uActorID >= 0) && (signed int)uActorID <= (signed int)(uNumActors - 1) ) |
0 | 195 { |
196 v3 = uActorID; | |
197 v4 = (char *)&pActors[uActorID].uCarriedItemID; | |
198 if ( bGive ) | |
199 { | |
200 if ( *(short *)v4 ) | |
201 { | |
202 if ( pActors[v3].array_000234[0].uItemID ) | |
203 { | |
204 v5 = &pActors[v3].array_000234[1].uItemID; | |
205 if ( !*v5 ) | |
206 *v5 = uItemID; | |
207 } | |
208 else | |
209 { | |
210 pActors[v3].array_000234[0].uItemID = uItemID; | |
211 } | |
212 } | |
213 else | |
214 { | |
215 *(short *)v4 = uItemID; | |
216 } | |
217 } | |
218 else | |
219 { | |
220 if ( *(short *)v4 == uItemID ) | |
221 { | |
222 *(short *)v4 = 0; | |
223 } | |
224 else | |
225 { | |
226 v6 = pActors[v3].array_000234; | |
227 if ( pActors[v3].array_000234[0].uItemID == uItemID | |
228 || (v6 = &pActors[v3].array_000234[1], pActors[v3].array_000234[1].uItemID == uItemID) ) | |
229 v6->Reset(); | |
230 } | |
231 } | |
232 } | |
233 } | |
234 | |
188 | 235 |
0 | 236 //----- (0040894B) -------------------------------------------------------- |
237 bool Actor::CanAct() | |
238 { | |
1114 | 239 bool isparalyzed; // esi@1 |
240 bool isstoned; // edi@2 | |
0 | 241 unsigned __int16 v3; // ax@6 |
242 | |
1114 | 243 isstoned = (signed __int64)this->pActorBuffs[5].uExpireTime > 0;// stoned |
244 isparalyzed = (signed __int64)this->pActorBuffs[6].uExpireTime > 0;// paralyzed | |
0 | 245 v3 = this->uAIState; |
1114 | 246 return !(isstoned || isparalyzed || v3 == Dying || v3 == Dead || v3 == Removed || v3 == Summoned || v3 == Disabled); |
0 | 247 } |
248 | |
249 //----- (004089C7) -------------------------------------------------------- | |
303 | 250 bool Actor::IsNotAlive() |
0 | 251 { |
1115 | 252 bool isstoned; // esi@1 |
303 | 253 //unsigned __int16 v2; // ax@3 |
0 | 254 |
1115 | 255 isstoned = (signed __int64)this->pActorBuffs[5].uExpireTime > 0;// stoned |
303 | 256 //v2 = this->uAIState; |
1115 | 257 return (isstoned || (uAIState == Dying) || (uAIState == Dead) || (uAIState == Removed) || (uAIState == Summoned) || (uAIState == Disabled)); |
0 | 258 } |
259 | |
260 //----- (004086E9) -------------------------------------------------------- | |
261 void Actor::SetRandomGoldIfTheresNoItem() | |
262 { | |
263 Actor *v1; // esi@1 | |
264 int v2; // edi@1 | |
265 signed int v3; // ebx@2 | |
266 unsigned __int8 v4; // al@7 | |
267 | |
268 v1 = this; | |
269 v2 = 0; | |
270 if ( !this->array_000234[3].uItemID ) | |
271 { | |
272 v3 = 0; | |
273 if ( this->pMonsterInfo.uTreasureDiceRolls ) | |
274 { | |
275 do | |
276 { | |
277 ++v3; | |
278 v2 += rand() % v1->pMonsterInfo.uTreasureDiceSides + 1; | |
279 } | |
280 while ( v3 < v1->pMonsterInfo.uTreasureDiceRolls ); | |
281 if ( v2 ) | |
282 { | |
283 v1->array_000234[3].uItemID = 197; | |
377 | 284 v1->array_000234[3].uSpecEnchantmentType = v2; |
0 | 285 } |
286 } | |
287 } | |
288 if ( rand() % 100 < v1->pMonsterInfo.uTreasureDropChance ) | |
289 { | |
290 v4 = v1->pMonsterInfo.uTreasureLevel; | |
291 if ( v4 ) | |
292 pItemsTable->GenerateItem(v4, v1->pMonsterInfo.uTreasureType, &v1->array_000234[2]); | |
293 } | |
294 v1->uAttributes |= 0x800000; | |
295 } | |
296 | |
297 //----- (00404AC7) -------------------------------------------------------- | |
1060 | 298 void __fastcall Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel) |
0 | 299 { |
300 Actor *v5; // esi@1 | |
301 unsigned int v6; // edi@1 | |
302 unsigned int v7; // eax@1 | |
303 int v8; // edi@16 | |
304 int v9; // edi@17 | |
305 signed int v10; // ecx@22 | |
306 signed int v11; // eax@29 | |
307 __int16 *v12; // edi@30 | |
308 int v13; // ecx@34 | |
309 int v14; // edx@34 | |
310 int v15; // eax@34 | |
311 AIDirection *v16; // esi@34 | |
312 unsigned __int16 v17; // di@34 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
313 //int v18; // eax@34 |
0 | 314 int v19; // edi@34 |
315 int v20; // eax@35 | |
316 int v21; // eax@39 | |
317 SoundID v22; // eax@39 | |
318 signed int v23; // eax@41 | |
319 double v24; // st7@49 | |
320 float v25; // ST5C_4@50 | |
321 int v26; // eax@50 | |
322 double v27; // st7@50 | |
323 double v28; // st6@50 | |
324 float v29; // ST4C_4@51 | |
325 int v30; // esi@50 | |
326 int v31; // ST3C_4@51 | |
327 unsigned int v32; // edi@51 | |
328 char *v33; // eax@54 | |
329 unsigned __int16 v34; // ax@57 | |
330 signed int v35; // ecx@58 | |
331 signed int v36; // eax@67 | |
332 signed int v37; // eax@68 | |
333 signed __int64 v38; // qtt@69 | |
334 int v39; // ecx@75 | |
335 int v40; // eax@79 | |
336 int v41; // ecx@90 | |
337 int v42; // ecx@91 | |
338 int v43; // eax@95 | |
339 int v44; // ecx@100 | |
340 int v45; // ecx@101 | |
341 int v46; // eax@105 | |
342 unsigned int v47; // ebx@106 | |
343 int v48; // ecx@110 | |
344 char v49; // zf@123 | |
345 int v50; // eax@127 | |
346 int v51; // ecx@130 | |
347 int v52; // eax@132 | |
348 int v53; // ecx@137 | |
349 int v54; // ecx@138 | |
350 int v55; // eax@142 | |
351 SpellBuff *v56; // esi@143 | |
352 Player **v57; // esi@145 | |
353 int v58; // eax@146 | |
354 int v59; // edi@146 | |
355 int v60; // eax@146 | |
356 int v61; // edi@146 | |
357 int v62; // eax@146 | |
358 signed int v63; // edi@146 | |
359 signed int v64; // edi@147 | |
360 int v65; // eax@151 | |
361 char *v66; // eax@160 | |
362 int v67; // edi@167 | |
363 int v68; // edi@168 | |
364 int v69; // eax@171 | |
365 signed int v70; // ecx@172 | |
366 signed int v71; // eax@179 | |
367 __int16 *v72; // edi@180 | |
368 int v73; // ecx@184 | |
369 int v74; // edx@184 | |
370 int v75; // eax@184 | |
371 AIDirection *v76; // esi@184 | |
372 unsigned __int16 v77; // di@184 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
373 //int v78; // eax@184 |
0 | 374 int v79; // edx@185 |
375 int v80; // eax@185 | |
376 int v81; // eax@189 | |
377 unsigned __int16 v82; // ax@190 | |
378 int v83; // ecx@192 | |
379 int v84; // edx@192 | |
380 int v85; // eax@192 | |
381 AIDirection *v86; // esi@192 | |
382 unsigned __int16 v87; // di@192 | |
383 __int16 v88; // ax@192 | |
384 signed int v89; // ecx@192 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
385 //int v90; // eax@192 |
0 | 386 signed int v91; // eax@200 |
387 int v92; // eax@201 | |
388 int v93; // ecx@207 | |
389 int v94; // ecx@208 | |
390 int v95; // eax@212 | |
391 int v96; // ecx@217 | |
392 int v97; // eax@221 | |
393 SoundID v98; // [sp-18h] [bp-E8h]@79 | |
394 signed int v99; // [sp-14h] [bp-E4h]@39 | |
395 unsigned int v100; // [sp-10h] [bp-E0h]@39 | |
396 signed int v101; // [sp-Ch] [bp-DCh]@39 | |
397 signed int v102; // [sp-8h] [bp-D8h]@39 | |
398 int v103; // [sp-4h] [bp-D4h]@39 | |
399 unsigned int v104; // [sp+0h] [bp-D0h]@39 | |
400 signed int v105; // [sp+4h] [bp-CCh]@23 | |
401 int v106; // [sp+4h] [bp-CCh]@39 | |
402 signed int v107; // [sp+4h] [bp-CCh]@42 | |
403 signed int v108; // [sp+4h] [bp-CCh]@173 | |
404 int pitch; // [sp+2Ch] [bp-A4h]@51 | |
405 float v110; // [sp+30h] [bp-A0h]@50 | |
406 int v111; // [sp+38h] [bp-98h]@41 | |
407 float v112; // [sp+3Ch] [bp-94h]@49 | |
408 int v113; // [sp+40h] [bp-90h]@41 | |
409 int v114; // [sp+48h] [bp-88h]@41 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
410 SpriteObject a1; // [sp+4Ch] [bp-84h]@1 |
0 | 411 int v116; // [sp+BCh] [bp-14h]@49 |
412 AIDirection *v117; // [sp+C0h] [bp-10h]@1 | |
413 int v118; // [sp+C4h] [bp-Ch]@29 | |
414 float v119; // [sp+C8h] [bp-8h]@48 | |
415 float v120; // [sp+CCh] [bp-4h]@1 | |
416 int spellnuma; // [sp+D8h] [bp+8h]@29 | |
417 int spellnumb; // [sp+D8h] [bp+8h]@48 | |
418 float spellnumc; // [sp+D8h] [bp+8h]@50 | |
419 signed int spellnumd; // [sp+D8h] [bp+8h]@53 | |
420 int spellnume; // [sp+D8h] [bp+8h]@179 | |
421 int a1a; // [sp+E0h] [bp+10h]@34 | |
422 signed int a1b; // [sp+E0h] [bp+10h]@145 | |
423 int a1c; // [sp+E0h] [bp+10h]@184 | |
424 | |
425 LODWORD(v120) = uActorID; | |
426 v5 = &pActors[uActorID]; | |
427 v117 = pDir; | |
428 v6 = uSkillLevel & 0x3F; | |
429 v7 = SkillToMastery(uSkillLevel); | |
430 if ( spellnum <= 47 ) | |
431 { | |
432 if ( spellnum != 47 ) | |
433 { | |
434 if ( spellnum <= 18 ) | |
435 { | |
436 if ( spellnum == 18 || spellnum == 2 ) | |
437 goto LABEL_159; | |
438 if ( spellnum != 5 ) | |
439 { | |
440 if ( spellnum == 6 ) | |
441 goto LABEL_159; | |
442 if ( spellnum != 9 ) | |
443 { | |
444 if ( spellnum != 11 ) | |
445 { | |
446 if ( spellnum != 15 ) | |
447 { | |
448 if ( spellnum != 17 ) | |
449 return; | |
450 if ( (signed int)v7 <= 0 ) | |
451 goto LABEL_20; | |
452 if ( (signed int)v7 <= 2 ) | |
453 { | |
454 v9 = 300 * v6; | |
455 } | |
456 else | |
457 { | |
458 if ( v7 != 3 ) | |
459 { | |
460 if ( v7 == 4 ) | |
461 { | |
462 v8 = 3600 * (v6 + 64); | |
463 LABEL_21: | |
464 v5->pActorBuffs[15].Apply( | |
465 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v8 << 7) * 0.033333335), | |
466 v7, | |
467 0, | |
468 0, | |
469 0); | |
470 return; | |
471 } | |
472 LABEL_20: | |
473 v8 = 0; | |
474 goto LABEL_21; | |
475 } | |
476 v9 = 900 * v6; | |
477 } | |
478 v8 = v9 + 3840; | |
479 goto LABEL_21; | |
480 } | |
481 v10 = 3; | |
482 if ( uSkillLevel & 0x0100 ) | |
483 { | |
484 v105 = 9; | |
485 } | |
486 else | |
487 { | |
488 if ( (uSkillLevel & 0x80u) == 0 ) | |
489 { | |
490 if ( !(uSkillLevel & 0x40) ) | |
491 goto LABEL_29; | |
492 v105 = 5; | |
493 } | |
494 else | |
495 { | |
496 v105 = 7; | |
497 } | |
498 } | |
499 v10 = v105; | |
500 LABEL_29: | |
501 spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; | |
924 | 502 a1.uType = stru_4E3ACC[15].uType; |
0 | 503 v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1); |
504 v11 = 0; | |
505 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
506 { | |
507 LABEL_33: | |
508 LOWORD(v11) = 0; | |
509 } | |
510 else | |
511 { | |
512 v12 = &pObjectList->pObjects->uObjectID; | |
924 | 513 while ( stru_4E3ACC[15].uType != *v12 ) |
0 | 514 { |
515 ++v11; | |
516 v12 += 28; | |
517 if ( v11 >= (signed int)pObjectList->uNumObjects ) | |
518 goto LABEL_33; | |
519 } | |
520 } | |
521 a1.uObjectDescID = v11; | |
522 a1.stru_24.Reset(); | |
822 | 523 a1.spell_id = SPELL_AIR_SPARKS; |
0 | 524 v13 = v5->vPosition.x; |
525 v14 = v5->vPosition.y; | |
822 | 526 a1.spell_level = uSkillLevel; |
0 | 527 a1.vPosition.x = v13; |
528 v15 = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1); | |
529 v16 = v117; | |
530 v17 = LOWORD(v117->uYawAngle); | |
822 | 531 a1.spell_skill = 0; |
0 | 532 a1.vPosition.y = v14; |
533 a1.vPosition.z = v15; | |
534 a1.uFacing = v17; | |
535 a1.uSoundID = 0; | |
536 a1.uAttributes = 0; | |
537 a1.uSectorID = pIndoor->GetSector(v13, v14, v15); | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
538 a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); |
0 | 539 a1.uSpriteFrameID = 0; |
823 | 540 a1.spell_target_pid = 0; |
0 | 541 a1.field_60_distance_related_prolly_lod = 3; |
542 v19 = spellnuma / -2; | |
543 a1a = spellnuma / 2; | |
544 if ( spellnuma / -2 > spellnuma / 2 ) | |
545 { | |
546 v20 = spellnuma / 2; | |
547 } | |
548 else | |
549 { | |
550 do | |
551 { | |
552 a1.uFacing = v19 + LOWORD(v16->uYawAngle); | |
553 v20 = a1.Create( | |
554 (signed __int16)a1.uFacing, | |
555 v16->uPitchAngle, | |
556 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, | |
557 0); | |
558 v19 += v118; | |
559 } | |
560 while ( v19 <= a1a ); | |
561 } | |
562 if ( v20 != -1 ) | |
563 { | |
564 v106 = 0; | |
565 v104 = 0; | |
566 v103 = 0; | |
567 v102 = 0; | |
568 v21 = 8 * v20; | |
569 v101 = -1; | |
570 LOBYTE(v21) = v21 | 2; | |
571 v100 = 0; | |
572 v99 = v21; | |
573 v22 = (SoundID)word_4EE088_sound_ids[15]; | |
574 LABEL_202: | |
575 v98 = v22; | |
576 goto LABEL_222; | |
577 } | |
578 return; | |
579 } | |
580 LABEL_159: | |
924 | 581 a1.uType = stru_4E3ACC[spellnum].uType; |
0 | 582 v119 = 0.0; |
583 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
584 { | |
585 LABEL_191: | |
586 v82 = 0; | |
587 } | |
588 else | |
589 { | |
590 v66 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
591 while ( (short)a1.uType != *(short *)v66 ) |
0 | 592 { |
593 ++LODWORD(v119); | |
594 v66 += 56; | |
595 if ( SLODWORD(v119) >= (signed int)pObjectList->uNumObjects ) | |
596 goto LABEL_191; | |
597 } | |
598 v82 = LOWORD(v119); | |
599 } | |
600 a1.uObjectDescID = v82; | |
601 a1.stru_24.Reset(); | |
822 | 602 a1.spell_id = spellnum; |
0 | 603 v83 = v5->vPosition.x; |
604 v84 = v5->vPosition.y; | |
822 | 605 a1.spell_level = uSkillLevel; |
0 | 606 a1.vPosition.x = v83; |
607 v85 = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1); | |
608 v86 = v117; | |
609 v87 = LOWORD(v117->uYawAngle); | |
822 | 610 a1.spell_skill = 0; |
0 | 611 a1.vPosition.y = v84; |
612 a1.vPosition.z = v85; | |
613 a1.uFacing = v87; | |
614 a1.uSoundID = 0; | |
615 a1.uAttributes = 0; | |
616 v88 = pIndoor->GetSector(v83, v84, v85); | |
617 v89 = v86->uDistance; | |
618 a1.uSectorID = v88; | |
619 LODWORD(v119) = v89; | |
620 a1.uSpriteFrameID = 0; | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
621 a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); |
823 | 622 a1.spell_target_pid = 0; |
0 | 623 a1.field_60_distance_related_prolly_lod = 3; |
624 if ( (double)v89 >= 307.2 ) | |
625 { | |
626 if ( v89 >= 1024 ) | |
627 { | |
628 if ( v89 >= 2560 ) | |
629 { | |
630 if ( v89 < 5120 ) | |
631 a1.field_60_distance_related_prolly_lod = 3; | |
632 } | |
633 else | |
634 { | |
635 a1.field_60_distance_related_prolly_lod = 2; | |
636 } | |
637 } | |
638 else | |
639 { | |
640 a1.field_60_distance_related_prolly_lod = 1; | |
641 } | |
642 } | |
643 else | |
644 { | |
645 a1.field_60_distance_related_prolly_lod = 0; | |
646 } | |
647 a1.field_61 = 2; | |
648 v91 = a1.Create( | |
649 v86->uYawAngle, | |
650 v86->uPitchAngle, | |
651 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, | |
652 0); | |
653 if ( v91 != -1 ) | |
654 { | |
655 v106 = 0; | |
656 v104 = 0; | |
657 v103 = 0; | |
658 v102 = 0; | |
659 v92 = 8 * v91; | |
660 v101 = -1; | |
661 LOBYTE(v92) = v92 | 2; | |
662 v100 = 0; | |
663 v99 = v92; | |
664 v22 = (SoundID)word_4EE088_sound_ids[spellnum]; | |
665 goto LABEL_202; | |
666 } | |
667 return; | |
668 } | |
669 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
670 return; | |
671 v118 = pParty->vPosition.z; | |
672 v111 = pParty->vPosition.x; | |
673 v114 = pParty->vPosition.z + 2500; | |
674 v113 = pParty->vPosition.y; | |
675 v23 = 8; | |
676 if ( uSkillLevel & 0x0100 ) | |
677 { | |
678 v107 = 14; | |
679 } | |
680 else | |
681 { | |
682 if ( (uSkillLevel & 0x80u) == 0 ) | |
683 { | |
684 if ( !(uSkillLevel & 0x40) ) | |
685 goto LABEL_48; | |
686 v107 = 10; | |
687 } | |
688 else | |
689 { | |
690 v107 = 12; | |
691 } | |
692 } | |
693 v23 = v107; | |
694 LABEL_48: | |
695 v119 = 0.0; | |
696 spellnumb = 0; | |
697 if ( v23 > 0 ) | |
698 { | |
699 v24 = (double)v118; | |
700 v118 = v23; | |
701 v112 = v24; | |
862 | 702 v116 = PID(OBJECT_Actor,LODWORD(v120)); |
0 | 703 do |
704 { | |
705 v26 = rand(); | |
706 v27 = (double)spellnumb; | |
707 v110 = v27; | |
708 v28 = (double)SLODWORD(v119); | |
709 v30 = v26 % 1000; | |
710 v25 = (double)v114; | |
711 spellnumc = (double)(v26 % 1000) + v112 - v25; | |
712 v120 = v28 * v28; | |
713 v119 = v27 * v27; | |
714 if ( sqrt(spellnumc * spellnumc + v119 + v120) <= 1.0 ) | |
715 { | |
716 v32 = 0; | |
717 pitch = 0; | |
718 } | |
719 else | |
720 { | |
721 v31 = (signed __int64)sqrt(v119 + v120); | |
722 v29 = v28; | |
723 v32 = stru_5C6E00->Atan2((signed __int64)v110, (signed __int64)v29); | |
724 pitch = stru_5C6E00->Atan2(v31, (signed __int64)spellnumc); | |
725 } | |
726 a1.stru_24.Reset(); | |
924 | 727 a1.uType = stru_4E3ACC[9].uType; |
0 | 728 spellnumd = 0; |
729 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
730 { | |
731 LABEL_57: | |
732 v34 = 0; | |
733 } | |
734 else | |
735 { | |
736 v33 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
737 while ( (short)a1.uType != *(short *)v33 ) |
0 | 738 { |
739 ++spellnumd; | |
740 v33 += 56; | |
741 if ( spellnumd >= (signed int)pObjectList->uNumObjects ) | |
742 goto LABEL_57; | |
743 } | |
744 v34 = spellnumd; | |
745 } | |
746 a1.uObjectDescID = v34; | |
822 | 747 a1.spell_level = uSkillLevel; |
0 | 748 a1.vPosition.x = v111; |
749 a1.vPosition.y = v113; | |
750 a1.vPosition.z = v30 + v114; | |
822 | 751 a1.spell_id = SPELL_FIRE_METEOR_SHOWER; |
752 a1.spell_skill = 0; | |
0 | 753 a1.uAttributes = 0; |
754 a1.uSectorID = 0; | |
755 a1.uSpriteFrameID = 0; | |
822 | 756 a1.spell_caster_pid = v116; |
823 | 757 a1.spell_target_pid = 0; |
0 | 758 a1.field_60_distance_related_prolly_lod = stru_50C198._427546(v30 + 2500); |
759 a1.uFacing = v32; | |
760 a1.uSoundID = 0; | |
761 v35 = v117->uDistance; | |
762 LODWORD(v119) = v117->uDistance; | |
763 if ( (double)SLODWORD(v119) >= 307.2 ) | |
764 { | |
765 if ( v35 >= 1024 ) | |
766 { | |
767 if ( v35 >= 2560 ) | |
768 { | |
769 if ( v35 < 5120 ) | |
770 a1.field_60_distance_related_prolly_lod = 3; | |
771 } | |
772 else | |
773 { | |
774 a1.field_60_distance_related_prolly_lod = 2; | |
775 } | |
776 } | |
777 else | |
778 { | |
779 a1.field_60_distance_related_prolly_lod = 1; | |
780 } | |
781 } | |
782 else | |
783 { | |
784 a1.field_60_distance_related_prolly_lod = 0; | |
785 } | |
786 a1.field_61 = 2; | |
787 v36 = a1.Create( | |
788 v32, | |
789 pitch, | |
790 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, | |
791 0); | |
792 if ( v36 != -1 ) | |
793 { | |
794 v37 = 8 * v36; | |
795 LOBYTE(v37) = v37 | 2; | |
796 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[9], v37, 0, -1, 0, 0, 0, 0); | |
797 } | |
798 spellnumb = rand() % 1024 - 512; | |
799 v38 = rand(); | |
800 v49 = v118-- == 1; | |
801 LODWORD(v119) = (unsigned __int64)(v38 % 1024) - 512; | |
802 } | |
803 while ( !v49 ); | |
804 } | |
805 return; | |
806 } | |
807 if ( (signed int)v7 > 0 ) | |
808 { | |
809 if ( (signed int)v7 <= 2 ) | |
810 { | |
811 v39 = 60 * (v6 + 60); | |
812 goto LABEL_79; | |
813 } | |
814 if ( v7 == 3 ) | |
815 { | |
816 v39 = 180 * (v6 + 20); | |
817 goto LABEL_79; | |
818 } | |
819 if ( v7 == 4 ) | |
820 { | |
821 v39 = 240 * (v6 + 15); | |
822 LABEL_79: | |
823 v5->pActorBuffs[19].Apply( | |
824 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335), | |
825 v7, | |
826 0, | |
827 0, | |
828 0); | |
829 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFF3C1Eu); | |
830 v106 = 0; | |
831 v104 = 0; | |
832 v103 = 0; | |
833 v102 = 0; | |
834 v40 = 8 * LODWORD(v120); | |
835 v101 = -1; | |
862 | 836 LOBYTE(v40) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 837 v100 = 0; |
838 v99 = v40; | |
839 v98 = (SoundID)10040; | |
840 LABEL_222: | |
841 pAudioPlayer->PlaySound(v98, v99, v100, v101, v102, v103, v104, v106); | |
842 return; | |
843 } | |
844 } | |
845 v39 = 0; | |
846 goto LABEL_79; | |
847 } | |
848 if ( spellnum == 26 || spellnum == 29 ) | |
849 goto LABEL_159; | |
850 if ( spellnum != 38 ) | |
851 { | |
852 if ( spellnum == 39 || spellnum == 41 ) | |
853 goto LABEL_159; | |
854 if ( spellnum != 46 ) | |
855 return; | |
856 if ( (signed int)v7 > 0 ) | |
857 { | |
858 if ( (signed int)v7 <= 2 ) | |
859 { | |
860 v41 = 300 * v6; | |
861 goto LABEL_91; | |
862 } | |
863 if ( v7 == 3 ) | |
864 { | |
865 v41 = 900 * v6; | |
866 goto LABEL_91; | |
867 } | |
868 if ( v7 == 4 ) | |
869 { | |
870 v41 = 1200 * v6; | |
871 LABEL_91: | |
872 v42 = v41 + 3840; | |
873 LABEL_95: | |
874 v5->pActorBuffs[17].Apply( | |
875 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335), | |
876 v7, | |
877 v6 + 5, | |
878 0, | |
879 0); | |
1077 | 880 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u); |
0 | 881 v106 = 0; |
882 v104 = 0; | |
883 v103 = 0; | |
884 v102 = 0; | |
885 v43 = 8 * LODWORD(v120); | |
886 v101 = -1; | |
862 | 887 LOBYTE(v43) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 888 v100 = 0; |
889 v99 = v43; | |
890 v98 = (SoundID)14010; | |
891 goto LABEL_222; | |
892 } | |
893 } | |
894 v42 = 0; | |
895 goto LABEL_95; | |
896 } | |
897 if ( (signed int)v7 <= 0 ) | |
898 goto LABEL_104; | |
899 if ( (signed int)v7 <= 2 ) | |
900 { | |
901 v45 = 300 * v6; | |
902 } | |
903 else | |
904 { | |
905 if ( v7 != 3 ) | |
906 { | |
907 if ( v7 == 4 ) | |
908 { | |
909 v44 = 3600 * (v6 + 64); | |
910 LABEL_105: | |
911 v5->pActorBuffs[16].Apply( | |
912 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335), | |
913 v7, | |
914 v6 + 5, | |
915 0, | |
916 0); | |
1077 | 917 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x5C310Eu); |
0 | 918 v106 = 0; |
919 v104 = 0; | |
920 v103 = 0; | |
921 v102 = 0; | |
922 v46 = 8 * LODWORD(v120); | |
923 v101 = -1; | |
862 | 924 LOBYTE(v46) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 925 v100 = 0; |
926 v99 = v46; | |
927 v98 = (SoundID)13040; | |
928 goto LABEL_222; | |
929 } | |
930 LABEL_104: | |
931 v44 = 0; | |
932 goto LABEL_105; | |
933 } | |
934 v45 = 900 * v6; | |
935 } | |
936 v44 = v45 + 3840; | |
937 goto LABEL_105; | |
938 } | |
939 v47 = 0; | |
940 if ( (signed int)v7 > 0 ) | |
941 { | |
942 if ( (signed int)v7 <= 2 ) | |
943 { | |
944 v48 = 2 * v6 + 40; | |
945 goto LABEL_114; | |
946 } | |
947 if ( v7 == 3 ) | |
948 { | |
949 v48 = 3 * v6 + 60; | |
950 goto LABEL_114; | |
951 } | |
952 if ( v7 == 4 ) | |
953 { | |
954 LOWORD(v48) = 2 * (3 * v6 + 60); | |
955 LABEL_114: | |
956 v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, v7, v48, 0, 0); | |
1077 | 957 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u); |
0 | 958 LABEL_127: |
959 v106 = v47; | |
960 v104 = v47; | |
961 v103 = v47; | |
962 v50 = 8 * LODWORD(v120); | |
963 v102 = v47; | |
964 v101 = -1; | |
862 | 965 LOBYTE(v50) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 966 v100 = v47; |
967 v99 = v50; | |
968 v98 = (SoundID)14020; | |
969 goto LABEL_222; | |
970 } | |
971 } | |
972 LOWORD(v48) = 0; | |
973 goto LABEL_114; | |
974 } | |
975 if ( spellnum <= 80 ) | |
976 { | |
977 if ( spellnum == 80 ) | |
978 { | |
979 v56 = pParty->pPartyBuffs; | |
980 do | |
981 { | |
982 v56->Reset(); | |
983 ++v56; | |
984 } | |
985 while ( (signed int)v56 < (signed int)pParty->pPlayers ); | |
986 a1b = 1; | |
987 v57 = &pPlayers[1]; | |
988 do | |
989 { | |
990 v58 = (*v57)->GetActualWillpower(); | |
1036 | 991 v59 = (*v57)->GetParameterBonus(v58); |
0 | 992 v60 = (*v57)->GetActualIntelligence(); |
1036 | 993 v61 = ((*v57)->GetParameterBonus(v60) + v59) >> 1; |
0 | 994 v62 = (*v57)->GetActualLuck(); |
1036 | 995 v63 = v61 + (*v57)->GetParameterBonus(v62) + 30; |
0 | 996 if ( rand() % v63 < 30 ) |
997 { | |
998 v64 = 6048; | |
999 do | |
1000 { | |
1001 ((SpellBuff *)((char *)*v57 + v64))->Reset(); | |
1002 v64 += 16; | |
1003 } | |
1004 while ( v64 < 6432 ); | |
1005 pOtherOverlayList->_4418B1(11210, a1b + 99, 0, 65536); | |
1006 } | |
1007 ++a1b; | |
1008 ++v57; | |
1009 } | |
1010 while ( (signed int)v57 <= (signed int)&pPlayers[4] ); | |
1011 v106 = 0; | |
1012 v104 = 0; | |
1013 v103 = 0; | |
1014 v65 = 8 * LODWORD(v120); | |
1015 v102 = 0; | |
1016 v101 = -1; | |
862 | 1017 LOBYTE(v65) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 1018 v100 = 0; |
1019 v99 = v65; | |
1020 v22 = (SoundID)word_4EE088_sound_ids[80]; | |
1021 goto LABEL_202; | |
1022 } | |
1023 if ( spellnum != 51 ) | |
1024 { | |
1025 if ( spellnum == 57 || spellnum == 65 || spellnum == 70 ) | |
1026 goto LABEL_159; | |
1027 if ( spellnum == 73 ) | |
1028 { | |
1029 if ( (signed int)v7 <= 0 || (signed int)v7 > 4 ) | |
1030 v51 = 0; | |
1031 else | |
1032 v51 = 3600 * v6; | |
1033 v5->pActorBuffs[21].Apply( | |
1034 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v51 << 7) * 0.033333335), | |
1035 v7, | |
1036 v6, | |
1037 0, | |
1038 0); | |
1039 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xA81376u); | |
1040 v106 = 0; | |
1041 v104 = 0; | |
1042 v103 = 0; | |
1043 v102 = 0; | |
1044 v52 = 8 * LODWORD(v120); | |
1045 v101 = -1; | |
862 | 1046 LOBYTE(v52) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 1047 v100 = 0; |
1048 v99 = v52; | |
1049 v98 = (SoundID)16060; | |
1050 goto LABEL_222; | |
1051 } | |
1052 if ( spellnum == 77 ) | |
1053 { | |
1054 v5->sCurrentHP += 5 * v6 + 10; | |
1055 if ( v5->sCurrentHP >= (signed int)v5->pMonsterInfo.uHP ) | |
1056 v5->sCurrentHP = LOWORD(v5->pMonsterInfo.uHP); | |
1057 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xA81376u); | |
1058 v47 = 0; | |
1059 goto LABEL_127; | |
1060 } | |
1061 v49 = spellnum == 78; | |
1062 LABEL_158: | |
1063 if ( !v49 ) | |
1064 return; | |
1065 goto LABEL_159; | |
1066 } | |
1067 if ( (signed int)v7 > 0 ) | |
1068 { | |
1069 if ( (signed int)v7 <= 2 ) | |
1070 { | |
1071 v53 = 300 * v6; | |
1072 goto LABEL_138; | |
1073 } | |
1074 if ( v7 == 3 ) | |
1075 { | |
1076 v53 = 900 * v6; | |
1077 goto LABEL_138; | |
1078 } | |
1079 if ( v7 == 4 ) | |
1080 { | |
1081 v53 = 1200 * v6; | |
1082 LABEL_138: | |
1083 v54 = v53 + 3840; | |
1084 LABEL_142: | |
1085 v5->pActorBuffs[18].Apply( | |
1086 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335), | |
1087 v7, | |
1088 v6 + 5, | |
1089 0, | |
1090 0); | |
1077 | 1091 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u); |
0 | 1092 v106 = 0; |
1093 v104 = 0; | |
1094 v103 = 0; | |
1095 v102 = 0; | |
1096 v55 = 8 * LODWORD(v120); | |
1097 v101 = -1; | |
862 | 1098 LOBYTE(v55) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 1099 v100 = 0; |
1100 v99 = v55; | |
1101 v98 = (SoundID)14060; | |
1102 goto LABEL_222; | |
1103 } | |
1104 } | |
1105 v54 = 0; | |
1106 goto LABEL_142; | |
1107 } | |
1108 if ( spellnum == 85 ) | |
1109 { | |
1110 if ( (signed int)v7 > 0 ) | |
1111 { | |
1112 if ( (signed int)v7 <= 2 ) | |
1113 { | |
1114 v96 = 300 * v6 + 3840; | |
1115 goto LABEL_221; | |
1116 } | |
1117 if ( v7 == 3 ) | |
1118 { | |
1119 LOWORD(v6) = 3 * v6; | |
1120 v96 = 900 * (uSkillLevel & 0x3F) + 3840; | |
1121 goto LABEL_221; | |
1122 } | |
1123 if ( v7 == 4 ) | |
1124 { | |
1125 v96 = 1200 * v6 + 3840; | |
1126 LOWORD(v6) = 4 * v6; | |
1127 LABEL_221: | |
1128 v5->pActorBuffs[13].Apply( | |
1129 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335), | |
1130 v7, | |
1131 v6, | |
1132 0, | |
1133 0); | |
1134 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu); | |
1135 v106 = 0; | |
1136 v104 = 0; | |
1137 v103 = 0; | |
1138 v102 = 0; | |
1139 v97 = 8 * LODWORD(v120); | |
1140 v101 = -1; | |
862 | 1141 LOBYTE(v97) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 1142 v100 = 0; |
1143 v99 = v97; | |
1144 v98 = (SoundID)17070; | |
1145 goto LABEL_222; | |
1146 } | |
1147 } | |
1148 LOWORD(v6) = uSkillLevel; | |
1149 v96 = 0; | |
1150 goto LABEL_221; | |
1151 } | |
1152 if ( spellnum == 86 ) | |
1153 { | |
1154 if ( (signed int)v7 > 0 ) | |
1155 { | |
1156 if ( (signed int)v7 <= 2 ) | |
1157 { | |
1158 v93 = 300 * v6; | |
1159 goto LABEL_208; | |
1160 } | |
1161 if ( v7 == 3 ) | |
1162 { | |
1163 v93 = 900 * v6; | |
1164 goto LABEL_208; | |
1165 } | |
1166 if ( v7 == 4 ) | |
1167 { | |
1168 v93 = 1200 * v6; | |
1169 LABEL_208: | |
1170 v94 = v93 + 3840; | |
1171 LABEL_212: | |
1172 v5->pActorBuffs[14].Apply( | |
1173 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335), | |
1174 v7, | |
1175 v6 + 5, | |
1176 0, | |
1177 0); | |
1178 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu); | |
1179 v106 = 0; | |
1180 v104 = 0; | |
1181 v103 = 0; | |
1182 v102 = 0; | |
1183 v95 = 8 * LODWORD(v120); | |
1184 v101 = -1; | |
862 | 1185 LOBYTE(v95) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 1186 v100 = 0; |
1187 v99 = v95; | |
1188 v98 = (SoundID)17080; | |
1189 goto LABEL_222; | |
1190 } | |
1191 } | |
1192 v94 = 0; | |
1193 goto LABEL_212; | |
1194 } | |
1195 if ( spellnum == 90 ) | |
1196 goto LABEL_159; | |
1197 if ( spellnum != 93 ) | |
1198 { | |
1199 if ( spellnum != 95 ) | |
1200 { | |
1201 v49 = spellnum == 97; | |
1202 goto LABEL_158; | |
1203 } | |
1204 if ( (signed int)v7 > 0 ) | |
1205 { | |
1206 if ( (signed int)v7 <= 3 ) | |
1207 { | |
1208 v67 = 300 * v6; | |
1209 goto LABEL_168; | |
1210 } | |
1211 if ( v7 == 4 ) | |
1212 { | |
1213 v67 = 900 * v6; | |
1214 LABEL_168: | |
1215 v68 = v67 + 3840; | |
1216 LABEL_171: | |
1217 v5->pActorBuffs[20].Apply( | |
1218 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335), | |
1219 v7, | |
1220 0, | |
1221 0, | |
1222 0); | |
1077 | 1223 pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x7E7E7Eu); |
0 | 1224 v106 = 0; |
1225 v104 = 0; | |
1226 v103 = 0; | |
1227 v102 = 0; | |
1228 v69 = 8 * LODWORD(v120); | |
1229 v101 = -1; | |
862 | 1230 LOBYTE(v69) = PID(OBJECT_Actor,LOBYTE(v120)); |
0 | 1231 v100 = 0; |
1232 v99 = v69; | |
1233 v98 = (SoundID)18060; | |
1234 goto LABEL_222; | |
1235 } | |
1236 } | |
1237 v68 = 0; | |
1238 goto LABEL_171; | |
1239 } | |
1240 v70 = 3; | |
1241 if ( uSkillLevel & 0x100 ) | |
1242 { | |
1243 v108 = 9; | |
1244 } | |
1245 else | |
1246 { | |
1247 if ( (uSkillLevel & 0x80u) == 0 ) | |
1248 { | |
1249 if ( !(uSkillLevel & 0x40) ) | |
1250 goto LABEL_179; | |
1251 v108 = 5; | |
1252 } | |
1253 else | |
1254 { | |
1255 v108 = 7; | |
1256 } | |
1257 } | |
1258 v70 = v108; | |
1259 LABEL_179: | |
1260 spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; | |
924 | 1261 a1.uType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType; |
0 | 1262 v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1); |
1263 v71 = 0; | |
1264 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
1265 { | |
1266 LABEL_183: | |
1267 LOWORD(v71) = 0; | |
1268 } | |
1269 else | |
1270 { | |
1271 v72 = &pObjectList->pObjects->uObjectID; | |
924 | 1272 while ( stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType != *v72 ) |
0 | 1273 { |
1274 ++v71; | |
1275 v72 += 28; | |
1276 if ( v71 >= (signed int)pObjectList->uNumObjects ) | |
1277 goto LABEL_183; | |
1278 } | |
1279 } | |
1280 a1.uObjectDescID = v71; | |
1281 a1.stru_24.Reset(); | |
822 | 1282 a1.spell_id = SPELL_DARK_SHARPMETAL; |
0 | 1283 v73 = v5->vPosition.x; |
1284 v74 = v5->vPosition.y; | |
822 | 1285 a1.spell_level = uSkillLevel; |
0 | 1286 a1.vPosition.x = v73; |
1287 v75 = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1); | |
1288 v76 = v117; | |
1289 v77 = LOWORD(v117->uYawAngle); | |
822 | 1290 a1.spell_skill = 0; |
0 | 1291 a1.vPosition.y = v74; |
1292 a1.vPosition.z = v75; | |
1293 a1.uFacing = v77; | |
1294 a1.uSoundID = 0; | |
1295 a1.uAttributes = 0; | |
1296 a1.uSectorID = pIndoor->GetSector(v73, v74, v75); | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
1297 a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); |
0 | 1298 a1.uSpriteFrameID = 0; |
823 | 1299 a1.spell_target_pid = 0; |
0 | 1300 a1.field_60_distance_related_prolly_lod = 3; |
1301 a1c = spellnume / -2; | |
1302 if ( spellnume / -2 > spellnume / 2 ) | |
1303 { | |
1304 v80 = spellnume / -2; | |
1305 } | |
1306 else | |
1307 { | |
1308 do | |
1309 { | |
1310 v79 = v76->uYawAngle; | |
1311 a1.uFacing = a1c + LOWORD(v76->uYawAngle); | |
1312 v80 = a1.Create( | |
1313 v79, | |
1314 v76->uPitchAngle, | |
1315 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, | |
1316 0); | |
1317 a1c += v116; | |
1318 } | |
1319 while ( a1c <= spellnume / 2 ); | |
1320 } | |
1321 if ( v80 != -1 ) | |
1322 { | |
1323 v106 = 0; | |
1324 v104 = 0; | |
1325 v103 = 0; | |
1326 v102 = 0; | |
1327 v81 = 8 * v80; | |
1328 v101 = -1; | |
1329 LOBYTE(v81) = v81 | 2; | |
1330 v100 = 0; | |
1331 v99 = v81; | |
1332 v22 = (SoundID)word_4EE088_sound_ids[93]; | |
1333 goto LABEL_202; | |
1334 } | |
1335 } | |
1336 | |
1337 //----- (0043ABB0) -------------------------------------------------------- | |
322 | 1338 bool Actor::ArePeasantsOfSameFaction(Actor *a1, Actor *a2) |
0 | 1339 { |
1340 unsigned int v2; // esi@1 | |
1341 unsigned int v3; // edi@1 | |
1342 bool result; // eax@9 | |
1343 | |
1344 v2 = a1->uAlly; | |
1345 v3 = a2->uAlly; | |
1346 if ( !v2 ) | |
1347 v2 = (a1->pMonsterInfo.uID - 1) / 3 + 1; | |
1348 if ( !v3 ) | |
1349 v3 = (a2->pMonsterInfo.uID - 1) / 3 + 1; | |
1350 if ( (signed int)v2 >= 39 && (signed int)v2 <= 44 && (signed int)v3 >= 39 && (signed int)v3 <= 44 | |
1351 || (signed int)v2 >= 45 && (signed int)v2 <= 50 && (signed int)v3 >= 45 && (signed int)v3 <= 50 | |
1352 || (signed int)v2 >= 51 && (signed int)v2 <= 62 && (signed int)v3 >= 51 && (signed int)v3 <= 62 | |
1353 || (signed int)v2 >= 78 && (signed int)v2 <= 83 && (signed int)v3 >= 78 && (signed int)v3 <= 83 ) | |
1354 result = 1; | |
1355 else | |
1356 result = v2 == v3; | |
1357 return result; | |
1358 } | |
1359 | |
1360 //----- (0043AC45) -------------------------------------------------------- | |
322 | 1361 void Actor::AggroSurroundingPeasants(unsigned int uActorID, int a2) |
0 | 1362 { |
1363 int v4; // ebx@8 | |
1364 int v5; // ST1C_4@8 | |
1365 int v6; // eax@8 | |
1366 | |
1202 | 1367 auto victim = &pActors[uActorID]; |
0 | 1368 if ( a2 == 1 ) |
322 | 1369 BYTE2(victim->uAttributes) |= 8u; |
1370 | |
1371 for (uint i = 0; i < uNumActors; ++i) | |
0 | 1372 { |
1202 | 1373 auto actor = &pActors[i]; |
322 | 1374 if (!actor->CanAct() || i == uActorID) |
1375 continue; | |
1376 | |
1377 if (Actor::ArePeasantsOfSameFaction(victim, actor)) | |
0 | 1378 { |
322 | 1379 v4 = abs(actor->vPosition.x - victim->vPosition.x); |
1380 v5 = abs(actor->vPosition.y - victim->vPosition.y); | |
1381 v6 = abs(actor->vPosition.z - victim->vPosition.z); | |
1382 if (int_get_vector_length(v4, v5, v6) < 4096) | |
0 | 1383 { |
322 | 1384 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; |
1385 if ( a2 == 1 ) | |
1386 BYTE2(actor->uAttributes) |= 8u; | |
0 | 1387 } |
1388 } | |
1389 } | |
1390 } | |
1391 | |
1392 //----- (00404874) -------------------------------------------------------- | |
1060 | 1393 char __fastcall Actor::AI_RangedAttack(unsigned int uActorID, AIDirection *a2, int a3, char a4) |
0 | 1394 { |
1395 AIDirection *v4; // edi@1 | |
1396 Actor *v5; // esi@1 | |
1397 char result; // al@1 | |
1398 char *v7; // eax@15 | |
1399 unsigned __int16 v8; // ax@18 | |
1400 unsigned __int16 v9; // ax@19 | |
1401 __int16 v10; // ax@19 | |
1402 signed int v11; // ecx@19 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
1403 //int v12; // eax@19 |
0 | 1404 int v13; // edx@28 |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1405 //SpriteObject a1; // [sp+Ch] [bp-74h]@1 |
0 | 1406 unsigned int v15; // [sp+7Ch] [bp-4h]@1 |
1407 signed int v16; // [sp+88h] [bp+8h]@14 | |
1408 signed int v17; // [sp+88h] [bp+8h]@19 | |
1409 | |
1410 v15 = uActorID; | |
1411 v4 = a2; | |
1412 v5 = &pActors[uActorID]; | |
1413 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1414 SpriteObject a1; // [sp+Ch] [bp-74h]@1 |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1415 //SpriteObject::SpriteObject(&a1); |
0 | 1416 |
1417 result = a3 - 1; | |
1418 switch ( a3 ) | |
1419 { | |
1420 case 1: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1421 a1.uType = 545; |
0 | 1422 goto LABEL_14; |
1423 case 2: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1424 a1.uType = 550; |
0 | 1425 goto LABEL_14; |
1426 case 3: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1427 a1.uType = 510; |
0 | 1428 goto LABEL_14; |
1429 case 4: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1430 a1.uType = 500; |
0 | 1431 goto LABEL_14; |
1432 case 5: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1433 a1.uType = 515; |
0 | 1434 goto LABEL_14; |
1435 case 6: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1436 a1.uType = 505; |
0 | 1437 goto LABEL_14; |
1438 case 7: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1439 a1.uType = 530; |
0 | 1440 goto LABEL_14; |
1441 case 8: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1442 a1.uType = 525; |
0 | 1443 goto LABEL_14; |
1444 case 9: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1445 a1.uType = 520; |
0 | 1446 goto LABEL_14; |
1447 case 10: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1448 a1.uType = 535; |
0 | 1449 goto LABEL_14; |
1450 case 11: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1451 a1.uType = 540; |
0 | 1452 goto LABEL_14; |
1453 case 13: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1454 a1.uType = 555; |
0 | 1455 LABEL_14: |
1456 v16 = 0; | |
1457 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
1458 goto LABEL_18; | |
1459 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
1460 break; | |
1461 default: | |
1462 return result; | |
1463 } | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1464 while ( (short)a1.uType != *(short *)v7 ) |
0 | 1465 { |
1466 ++v16; | |
1467 v7 += 56; | |
1468 if ( v16 >= (signed int)pObjectList->uNumObjects ) | |
1469 { | |
1470 LABEL_18: | |
1471 v8 = 0; | |
1472 goto LABEL_19; | |
1473 } | |
1474 } | |
1475 v8 = v16; | |
1476 LABEL_19: | |
1477 a1.uObjectDescID = v8; | |
1478 a1.stru_24.Reset(); | |
1479 a1.vPosition.x = v5->vPosition.x; | |
822 | 1480 a1.spell_id = 0; |
0 | 1481 a1.vPosition.y = v5->vPosition.y; |
822 | 1482 a1.spell_level = 0; |
0 | 1483 v17 = v5->uActorHeight; |
822 | 1484 a1.spell_skill = 0; |
0 | 1485 v9 = LOWORD(v4->uYawAngle); |
1486 a1.vPosition.z = v5->vPosition.z - (unsigned int)(signed __int64)((double)v17 * -0.75); | |
1487 a1.uFacing = v9; | |
1488 a1.uSoundID = 0; | |
1489 a1.uAttributes = 0; | |
1490 v10 = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); | |
1491 v11 = v4->uDistance; | |
1492 a1.uSectorID = v10; | |
1493 a1.uSpriteFrameID = 0; | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
1494 a1.spell_caster_pid = PID(OBJECT_Actor, v15); |
823 | 1495 a1.spell_target_pid = 0; |
0 | 1496 if ( (double)v11 >= 307.2 ) |
1497 { | |
1498 if ( v11 >= 1024 ) | |
1499 { | |
1500 a1.field_60_distance_related_prolly_lod = 2; | |
1501 if ( v11 >= 2560 ) | |
1502 a1.field_60_distance_related_prolly_lod = 3; | |
1503 } | |
1504 else | |
1505 { | |
1506 a1.field_60_distance_related_prolly_lod = 1; | |
1507 } | |
1508 } | |
1509 else | |
1510 { | |
1511 a1.field_60_distance_related_prolly_lod = 0; | |
1512 } | |
1513 a1.field_61 = a4; | |
1514 result = a1.Create( | |
1515 v4->uYawAngle, | |
1516 v4->uPitchAngle, | |
1517 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, | |
1518 0); | |
1519 if ( v5->pMonsterInfo.uSpecialAbilityType == 1 ) | |
1520 { | |
1521 result = v5->pMonsterInfo.uSpecialAbilityDamageDiceBonus; | |
1522 if ( result == 2 ) | |
1523 { | |
1524 a1.vPosition.z += 40; | |
1525 v13 = v4->uYawAngle; | |
1526 } | |
1527 else | |
1528 { | |
1529 if ( result != 3 ) | |
1530 return result; | |
1531 a1.Create( | |
1532 v4->uYawAngle + 30, | |
1533 v4->uPitchAngle, | |
1534 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, | |
1535 0); | |
1536 v13 = v4->uYawAngle - 30; | |
1537 } | |
1538 result = a1.Create( | |
1539 v13, | |
1540 v4->uPitchAngle, | |
1541 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, | |
1542 0); | |
1543 } | |
1544 return result; | |
1545 } | |
1546 | |
1547 //----- (00404736) -------------------------------------------------------- | |
1548 signed int __fastcall Actor::Explode(unsigned int uActorID) | |
1549 { | |
1550 Actor *v1; // esi@1 | |
1551 signed int v2; // edx@1 | |
1552 char *v3; // ecx@2 | |
1553 unsigned __int16 v4; // ax@5 | |
1554 int v5; // ebx@6 | |
1555 int v6; // ecx@6 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
1556 //int v7; // eax@6 |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1557 SpriteObject a1; // [sp+Ch] [bp-78h]@1 |
0 | 1558 unsigned int v10; // [sp+7Ch] [bp-8h]@1 |
1559 int v11; // [sp+80h] [bp-4h]@6 | |
1560 | |
1561 v10 = uActorID; | |
1562 v1 = &pActors[uActorID]; | |
1563 v2 = 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1564 a1.uType = 600; |
0 | 1565 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1566 { | |
1567 LABEL_5: | |
1568 v4 = 0; | |
1569 } | |
1570 else | |
1571 { | |
1572 v3 = (char *)&pObjectList->pObjects->uObjectID; | |
1573 while ( *(short *)v3 != 600 ) | |
1574 { | |
1575 ++v2; | |
1576 v3 += 56; | |
1577 if ( v2 >= (signed int)pObjectList->uNumObjects ) | |
1578 goto LABEL_5; | |
1579 } | |
1580 v4 = v2; | |
1581 } | |
1582 a1.uObjectDescID = v4; | |
1583 a1.stru_24.Reset(); | |
1584 a1.vPosition.y = v1->vPosition.y; | |
822 | 1585 a1.spell_id = 0; |
0 | 1586 v5 = v1->vPosition.x; |
1587 v11 = v1->uActorHeight; | |
822 | 1588 a1.spell_level = 0; |
1589 a1.spell_skill = 0; | |
0 | 1590 a1.vPosition.x = v5; |
1591 v6 = v1->vPosition.z - (unsigned int)(signed __int64)((double)v11 * -0.75); | |
1592 a1.uFacing = 0; | |
1593 a1.vPosition.z = v6; | |
1594 a1.uSoundID = 0; | |
1595 a1.uAttributes = 0; | |
1596 a1.uSectorID = pIndoor->GetSector(v5, a1.vPosition.y, v6); | |
1597 a1.uSpriteFrameID = 0; | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
1598 a1.spell_caster_pid = PID(OBJECT_Actor, v10); |
823 | 1599 a1.spell_target_pid = 0; |
0 | 1600 a1.field_60_distance_related_prolly_lod = 3; |
1601 a1.field_61 = 4; | |
1602 return a1.Create(0, 0, 0, 0); | |
1603 } | |
1604 | |
1605 //----- (004040E9) -------------------------------------------------------- | |
1606 // // Get direction vector from object1 to object2, | |
1607 // // distance from object1 to object2 and Euler angles of the direction vector | |
1608 // // | |
1609 // // | |
1610 // // object1 & object2 format : objectType | (objectID << 3) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
488
diff
changeset
|
1611 // // objectType == 2 - SpriteObject |
0 | 1612 // // objectType == 3 - Actor |
1613 // // objectType == 4 - Party | |
1614 // // objectType == 5 - Decoration | |
1615 // // | |
1616 // // originally this function had following prototype: | |
1617 // // struct DirectionInfo GetDirectionInfo(signed int object1, signed int object2, signed int a4) | |
1618 // // but compiler converts functions returning structures by value in the such way | |
1619 AIDirection *__fastcall Actor::GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, AIDirection *pOut, int a4) | |
1620 { | |
1621 signed int v4; // eax@1 | |
1622 unsigned int v5; // ecx@1 | |
1623 unsigned int v6; // ebx@1 | |
1624 int v7; // ecx@2 | |
1625 int v8; // ecx@3 | |
1626 int v9; // ecx@4 | |
1627 BLVFace *v10; // eax@8 | |
1628 unsigned int v11; // ecx@8 | |
1629 signed int v12; // eax@9 | |
1630 int v13; // ecx@9 | |
1631 int v14; // eax@9 | |
1632 int v15; // eax@11 | |
1633 int v16; // eax@12 | |
1634 int v17; // eax@13 | |
1635 int v18; // edx@15 | |
1636 signed int v19; // eax@25 | |
1637 signed int v20; // eax@28 | |
1638 int v21; // ebx@28 | |
1639 signed int v22; // eax@28 | |
1640 BLVFace *v23; // eax@35 | |
1641 int v24; // edx@35 | |
1642 unsigned int v25; // ecx@35 | |
1643 signed int v26; // eax@36 | |
1644 int v27; // ecx@36 | |
1645 int v28; // eax@36 | |
1646 int v29; // eax@37 | |
1647 signed int v30; // eax@42 | |
1648 double v31; // st7@45 | |
1649 double v32; // st6@45 | |
1650 double v33; // st7@45 | |
1651 AIDirection *result; // eax@48 | |
1652 int v35; // [sp-18h] [bp-64h]@17 | |
1653 int v36; // [sp-14h] [bp-60h]@17 | |
1654 Vec3_int_ v37; // [sp-10h] [bp-5Ch]@15 | |
1655 int *v38; // [sp-4h] [bp-50h]@15 | |
1656 int *v39; // [sp+0h] [bp-4Ch]@15 | |
1657 int *v40; // [sp+4h] [bp-48h]@15 | |
1658 AIDirection v41; // [sp+14h] [bp-38h]@46 | |
1659 float v42; // [sp+30h] [bp-1Ch]@23 | |
1660 float v43; // [sp+34h] [bp-18h]@45 | |
1661 float v44; // [sp+38h] [bp-14h]@33 | |
1662 float v45; // [sp+3Ch] [bp-10h]@33 | |
1663 int outz; // [sp+40h] [bp-Ch]@6 | |
1664 int outy; // [sp+44h] [bp-8h]@6 | |
1665 int outx; // [sp+48h] [bp-4h]@6 | |
1666 float a4a; // [sp+58h] [bp+Ch]@45 | |
1667 | |
848 | 1668 v4 = PID_ID(uObj1ID); |
849 | 1669 v5 = PID_TYPE(uObj1ID); |
0 | 1670 v6 = uObj2ID; |
849 | 1671 switch(v5) |
0 | 1672 { |
849 | 1673 case OBJECT_Item: |
1674 { | |
1675 v19 = v4; | |
1676 outx = pSpriteObjects[v19].vPosition.x; | |
1677 v13 = pSpriteObjects[v19].vPosition.y; | |
1678 v14 = pSpriteObjects[v19].vPosition.z; | |
1679 outy = v13; | |
1680 outz = v14; | |
1681 break; | |
1682 } | |
1683 case OBJECT_Actor: | |
1684 { | |
1685 outx = pActors[v4].vPosition.x; | |
1686 outy = pActors[v4].vPosition.y; | |
1687 LODWORD(v42) = pActors[v4].uActorHeight; | |
1688 v11 = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)SLODWORD(v42) * -0.75); | |
1689 outz = v11; | |
1690 break; | |
1691 } | |
1692 case OBJECT_Player: | |
1693 { | |
1694 if ( !v4 ) | |
1695 { | |
1696 outx = pParty->vPosition.x; | |
1697 outy = pParty->vPosition.y; | |
1698 v14 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
1699 outz = v14; | |
1700 break;; | |
1701 } | |
1702 if ( v4 == 4 ) | |
1703 { | |
1704 v40 = &outz; | |
1705 v39 = &outy; | |
1706 v38 = &outx; | |
1707 v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; | |
1708 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
1709 *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; | |
1710 v36 = 0; | |
1711 v35 = 24; | |
1712 Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); | |
1713 break; | |
1714 } | |
1715 if ( v4 == 3 ) | |
1716 { | |
1717 v40 = &outz; | |
1718 v39 = &outy; | |
1719 v38 = &outx; | |
1720 v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; | |
1721 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
1722 *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; | |
1723 v36 = 0; | |
1724 v35 = 8; | |
1725 Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); | |
1726 break; | |
1727 } | |
1728 if ( v4 == 2 ) | |
1729 { | |
1730 v40 = &outz; | |
1731 v39 = &outy; | |
1732 v38 = &outx; | |
1733 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
1734 v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; | |
1735 *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; | |
1736 v36 = 0; | |
1737 v35 = 8; | |
1738 Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); | |
1739 break; | |
1740 } | |
1741 if ( v4 == 1 ) | |
1742 { | |
1743 v40 = &outz; | |
1744 v39 = &outy; | |
1745 v38 = &outx; | |
1746 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; | |
1747 v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; | |
1748 *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; | |
1749 v36 = 0; | |
1750 v35 = 24; | |
1751 Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); | |
1752 break; | |
1753 } | |
1754 } | |
1755 case OBJECT_Decoration: | |
1756 { | |
1757 v12 = v4; | |
1758 outx = pLevelDecorations[v12].vPosition.x; | |
1759 v13 = pLevelDecorations[v12].vPosition.y; | |
1760 v14 = pLevelDecorations[v12].vPosition.z; | |
1761 outy = v13; | |
1762 outz = v14; | |
1763 break; | |
1764 } | |
1765 default: | |
1766 { | |
1767 outz = 0; | |
1768 outy = 0; | |
1769 outx = 0; | |
1770 break; | |
1771 } | |
1772 case OBJECT_BModel: | |
1773 { | |
1774 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1775 { | |
1776 v10 = &pIndoor->pFaces[v4]; | |
1777 outx = (v10->pBounding.x1 + v10->pBounding.x2) >> 1; | |
1778 outy = (v10->pBounding.y1 + v10->pBounding.y2) >> 1; | |
1779 v11 = (v10->pBounding.z1 + v10->pBounding.z2) >> 1; | |
1780 outz = v11; | |
862 | 1781 } |
1782 break; | |
1783 } | |
1784 } | |
1785 v20 = v6; | |
1786 v21 = PID_TYPE(v6); | |
1787 v22 = PID_ID(v20); | |
1087 | 1788 switch(v21) |
862 | 1789 { |
1790 case OBJECT_Item: | |
1791 { | |
1792 v30 = v22; | |
1793 LODWORD(v45) = pSpriteObjects[v30].vPosition.x; | |
1794 v27 = pSpriteObjects[v30].vPosition.y; | |
1795 v28 = pSpriteObjects[v30].vPosition.z; | |
1796 LODWORD(v44) = v27; | |
1797 a4 = v28; | |
1798 break; | |
1799 } | |
1800 case OBJECT_Actor: | |
1801 { | |
1802 LODWORD(v45) = pActors[v22].vPosition.x; | |
1803 LODWORD(v44) = pActors[v22].vPosition.y; | |
1804 v25 = pActors[v22].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v22].uActorHeight * -0.75); | |
1805 a4 = v25; | |
1806 break; | |
1807 } | |
1808 case OBJECT_Player: | |
1809 { | |
1810 LODWORD(v45) = pParty->vPosition.x; | |
1811 LODWORD(v44) = pParty->vPosition.y; | |
1812 v29 = a4; | |
1813 if ( !a4 ) | |
1814 v29 = pParty->sEyelevel; | |
1815 v28 = pParty->vPosition.z + v29; | |
1816 a4 = v28; | |
863 | 1817 break; |
862 | 1818 } |
1819 case OBJECT_Decoration: | |
1820 { | |
1821 v26 = v22; | |
1822 LODWORD(v45) = pLevelDecorations[v26].vPosition.x; | |
1823 v27 = pLevelDecorations[v26].vPosition.y; | |
1824 v28 = pLevelDecorations[v26].vPosition.z; | |
1825 LODWORD(v44) = v27; | |
1826 a4 = v28; | |
1827 break; | |
1828 } | |
1829 default: | |
1830 { | |
1831 a4 = 0; | |
1832 v44 = 0.0; | |
1833 v45 = 0.0; | |
1834 break; | |
1835 } | |
1836 case OBJECT_BModel: | |
1837 { | |
1838 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1839 { | |
849 | 1840 v23 = &pIndoor->pFaces[v22]; |
1841 v24 = v23->pBounding.y1; | |
1842 LODWORD(v45) = (v23->pBounding.x1 + v23->pBounding.x2) >> 1; | |
1843 LODWORD(v44) = (v24 + v23->pBounding.y2) >> 1; | |
1844 v25 = (v23->pBounding.z1 + v23->pBounding.z2) >> 1; | |
1845 a4 = v25; | |
1846 } | |
1847 break; | |
1848 } | |
0 | 1849 } |
862 | 1850 |
0 | 1851 v31 = (double)SLODWORD(v45) - (double)outx; |
1852 v42 = v31; | |
1853 v32 = (double)SLODWORD(v44) - (double)outy; | |
1854 v43 = v32; | |
1855 a4a = (double)a4 - (double)outz; | |
1856 v45 = v32 * v32; | |
1857 v44 = v31 * v31; | |
1858 v33 = sqrt(a4a * a4a + v44 + v45); | |
1859 if ( v33 <= 1.0 ) | |
1860 { | |
1861 v41.vDirection.x = 65536; | |
1862 v41.vDirection.y = 0; | |
1863 v41.vDirection.z = 0; | |
1864 v41.uDistance = 1; | |
1865 v41.uDistanceXZ = 1; | |
1866 v41.uYawAngle = 0; | |
1867 v41.uPitchAngle = 0; | |
1868 } | |
1869 else | |
1870 { | |
1871 v41.vDirection.x = (signed __int64)(1.0 / v33 * v42 * 65536.0); | |
1872 v41.vDirection.y = (signed __int64)(1.0 / v33 * v43 * 65536.0); | |
1873 v41.vDirection.z = (signed __int64)(1.0 / v33 * a4a * 65536.0); | |
1874 v41.uDistance = (signed __int64)v33; | |
1875 v41.uDistanceXZ = (signed __int64)sqrt(v44 + v45); | |
1876 v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v42, (signed __int64)v43); | |
1877 v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a); | |
1878 } | |
1879 result = pOut; | |
1880 memcpy(pOut, &v41, 0x1Cu); | |
1881 return result; | |
1882 } | |
1883 | |
1884 //----- (00404030) -------------------------------------------------------- | |
1060 | 1885 void Actor::AI_FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4) |
0 | 1886 { |
1887 unsigned int v4; // edi@1 | |
1888 unsigned int v5; // esi@1 | |
322 | 1889 //unsigned int result; // eax@2 |
0 | 1890 AIDirection *v7; // eax@3 |
1891 unsigned int v8; // ecx@3 | |
1892 Actor *v9; // ebx@3 | |
1893 AIDirection *v10; // esi@4 | |
1894 unsigned __int16 v11; // ax@5 | |
1895 AIDirection a3; // [sp+8h] [bp-38h]@4 | |
1896 AIDirection v13; // [sp+24h] [bp-1Ch]@4 | |
1897 | |
1898 v4 = uObjID; | |
1899 v5 = uActorID; | |
1900 if ( rand() % 100 >= 5 ) | |
1901 { | |
1902 v7 = a4; | |
1903 v8 = 0; | |
1904 v9 = &pActors[v5]; | |
1905 if ( !a4 ) | |
1906 { | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
1907 v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v5), v4, &a3, 0); |
0 | 1908 v7 = &v13; |
1909 memcpy(&v13, v10, sizeof(v13)); | |
1910 v8 = 0; | |
1911 } | |
1912 v9->uYawAngle = LOWORD(v7->uYawAngle); | |
1913 v11 = LOWORD(v7->uPitchAngle); | |
1914 v9->uCurrentActionTime = v8; | |
1915 v9->vVelocity.z = v8; | |
1916 v9->vVelocity.y = v8; | |
1917 v9->vVelocity.x = v8; | |
1918 v9->uPitchAngle = v11; | |
1919 v9->uCurrentActionLength = 256; | |
1920 v9->uAIState = Interacting; | |
322 | 1921 v9->UpdateAnimation(); |
0 | 1922 } |
1923 else | |
414 | 1924 Actor::AI_Bored(v5, v4, a4); |
0 | 1925 } |
1926 | |
1927 //----- (00403F58) -------------------------------------------------------- | |
414 | 1928 void Actor::AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) |
0 | 1929 { |
413 | 1930 if (rand() % 2) |
414 | 1931 AI_Bored(uActorID, uObjID, a4); |
413 | 1932 else |
414 | 1933 AI_Stand(uActorID, uObjID, uActionLength, a4); |
0 | 1934 } |
1935 | |
1936 //----- (00403EB6) -------------------------------------------------------- | |
413 | 1937 void Actor::AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, AIDirection *a4) |
0 | 1938 { |
413 | 1939 assert(uActorID < uNumActors); |
1202 | 1940 auto actor = &pActors[uActorID]; |
413 | 1941 |
1942 AIDirection a3; | |
1943 if (!a4) | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
1944 a4 = Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), object_to_face_pid, &a3, 0); |
0 | 1945 |
413 | 1946 actor->uAIState = Standing; |
1947 if (!uActionLength) | |
1948 actor->uCurrentActionLength = rand() % 256 + 256; | |
0 | 1949 else |
413 | 1950 actor->uCurrentActionLength = uActionLength; |
1951 actor->uCurrentActionTime = 0; | |
1952 actor->uYawAngle = a4->uYawAngle; | |
1953 actor->uPitchAngle = a4->uPitchAngle; | |
1954 actor->vVelocity.z = 0; | |
1955 actor->vVelocity.y = 0; | |
1956 actor->vVelocity.x = 0; | |
1957 actor->UpdateAnimation(); | |
0 | 1958 } |
1959 | |
1960 //----- (00403E61) -------------------------------------------------------- | |
1961 void __fastcall Actor::StandAwhile(unsigned int uActorID) | |
1962 { | |
1963 Actor *v1; // esi@1 | |
1964 | |
1965 v1 = &pActors[uActorID]; | |
1966 v1->uCurrentActionLength = rand() % 128 + 128; | |
1967 v1->uCurrentActionTime = 0; | |
1968 v1->uAIState = Standing; | |
1969 v1->vVelocity.z = 0; | |
1970 v1->vVelocity.y = 0; | |
1971 v1->vVelocity.x = 0; | |
1972 v1->UpdateAnimation(); | |
1973 } | |
1974 | |
1975 //----- (00403C6C) -------------------------------------------------------- | |
1060 | 1976 void Actor::AI_MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0) |
0 | 1977 { |
1978 Actor *v3; // ebx@1 | |
1979 char v4; // zf@1 | |
322 | 1980 //unsigned int result; // eax@3 |
0 | 1981 AIDirection *v6; // esi@6 |
1982 AIDirection *v7; // edi@6 | |
1983 signed int v8; // eax@7 | |
1984 double v9; // st7@9 | |
1985 Vec3_int_ v10; // ST04_12@9 | |
322 | 1986 //int v11; // eax@10 |
0 | 1987 AIDirection *v12; // eax@11 |
1988 unsigned int v13; // esi@11 | |
1989 AIDirection *v14; // esi@12 | |
1990 SpriteFrame *v15; // ecx@13 | |
1991 __int16 v16; // ax@13 | |
1992 unsigned int v17; // ecx@13 | |
1993 signed __int64 v18; // qax@13 | |
1994 AIDirection a3; // [sp+Ch] [bp-48h]@12 | |
1995 AIDirection v20; // [sp+28h] [bp-2Ch]@12 | |
1996 unsigned int v21; // [sp+44h] [bp-10h]@9 | |
848 | 1997 //signed int a2; // [sp+48h] [bp-Ch]@1 |
0 | 1998 int v23; // [sp+4Ch] [bp-8h]@6 |
1999 unsigned int v24; // [sp+50h] [bp-4h]@1 | |
2000 unsigned int v25; // [sp+5Ch] [bp+8h]@13 | |
2001 | |
2002 v3 = &pActors[uActorID]; | |
848 | 2003 //a2 = edx0; |
0 | 2004 v4 = v3->pMonsterInfo.uMovementType == 5; |
2005 v24 = uActorID; | |
2006 if ( v4 && v3->pMonsterInfo.uAIType == 1 ) | |
2007 { | |
848 | 2008 Actor::AI_Stand(uActorID, sTargetPid, 0, arg0); |
322 | 2009 return; |
0 | 2010 } |
322 | 2011 |
848 | 2012 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) |
849 | 2013 { |
2014 v8 = PID_ID(sTargetPid); | |
2015 v6 = (AIDirection *)pActors[v8].vPosition.x; | |
2016 v7 = (AIDirection *)pActors[v8].vPosition.y; | |
2017 v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z); | |
2018 } | |
2019 else if ( PID_TYPE(sTargetPid) == OBJECT_Player) | |
2020 { | |
2021 v6 = (AIDirection *)pParty->vPosition.x; | |
2022 v7 = (AIDirection *)pParty->vPosition.y; | |
2023 v23 = pParty->vPosition.z + pParty->sEyelevel; | |
2024 } | |
2025 else | |
2026 { | |
2027 v6 = arg0; | |
2028 v7 = arg0; | |
2029 } | |
2030 v21 = v3->uActorHeight; | |
2031 v9 = (double)(signed int)v21 * 0.75; | |
2032 v21 = v3->vPosition.z; | |
2033 v10.z = (signed __int64)(v9 + (double)(signed int)v21); | |
2034 v10.y = v3->vPosition.y; | |
2035 v10.x = v3->vPosition.x; | |
2036 if ( sub_407A1C((int)v6, (int)v7, v23, v10) ) | |
2037 { | |
2038 v12 = arg0; | |
2039 v13 = 0; | |
2040 if ( !arg0 ) | |
0 | 2041 { |
849 | 2042 v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), sTargetPid, &a3, 0); |
0 | 2043 v12 = &v20; |
2044 memcpy(&v20, v14, sizeof(v20)); | |
2045 v13 = 0; | |
849 | 2046 } |
2047 v15 = pSpriteFrameTable->pSpriteSFrames; | |
2048 v3->uYawAngle = LOWORD(v12->uYawAngle); | |
2049 v16 = v15[v3->pSpriteIDs[ANIM_AtkMelee]].uAnimLength; | |
2050 v17 = v24; | |
2051 v3->uCurrentActionLength = 8 * v16; | |
2052 v3->uCurrentActionTime = v13; | |
2053 v3->uAIState = AttackingMelee; | |
2054 Actor::PlaySound(v17, 0); | |
2055 LODWORD(v18) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2056 v25 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2057 if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v13 | |
2058 && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v13 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v13) ) | |
2059 { | |
2060 LODWORD(v18) = 2 * v18; | |
0 | 2061 v25 = v18; |
849 | 2062 } |
2063 if ( pParty->bTurnBasedModeOn != 1 ) | |
0 | 2064 v18 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)v25 * 2.133333333333333); |
849 | 2065 v3->pMonsterInfo.uRecoveryTime = v18; |
2066 v3->vVelocity.z = v13; | |
2067 v3->vVelocity.y = v13; | |
2068 v3->vVelocity.x = v13; | |
2069 v3->UpdateAnimation(); | |
2070 } | |
2071 else | |
1060 | 2072 Actor::AI_Pursue1(v24, sTargetPid, rand() % 2, 64, arg0); |
0 | 2073 } |
2074 | |
2075 //----- (00438CF3) -------------------------------------------------------- | |
322 | 2076 void Actor::ApplyFineForKillingPeasant(unsigned int uActorID) |
0 | 2077 { |
2078 unsigned int v1; // esi@1 | |
2079 unsigned int v2; // edi@2 | |
2080 char v3; // bl@3 | |
322 | 2081 //char *v4; // ecx@16 |
2082 //signed int v5; // eax@18 | |
0 | 2083 Player **ppPlayers; // esi@20 |
2084 | |
2085 v1 = uLevelMapStatsID; | |
322 | 2086 if ( !uLevelMapStatsID || !pActors[uActorID].IsPeasant()) |
0 | 2087 return; |
322 | 2088 |
2089 v2 = uActorID; | |
0 | 2090 v3 = 1; |
2091 if ( v1 != 5 ) | |
2092 { | |
2093 if ( v1 == 6 || v1 == 7 ) | |
2094 { | |
484 | 2095 _449B57_test_bit(pParty->_quest_bits, 99); |
2096 if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 100) ) | |
0 | 2097 return; |
2098 goto LABEL_12; | |
2099 } | |
2100 if ( v1 != 8 ) | |
2101 goto LABEL_12; | |
2102 } | |
484 | 2103 if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 99) ) |
0 | 2104 v3 = 0; |
484 | 2105 if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 100) ) |
0 | 2106 v3 = 1; |
2107 if ( v3 ) | |
2108 { | |
2109 LABEL_12: | |
322 | 2110 pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[v2].pMonsterInfo.uLevel + GetPartyReputation()); |
0 | 2111 if ( pParty->uFine < 0 ) |
2112 pParty->uFine = 0; | |
2113 if ( pParty->uFine > 4000000 ) | |
2114 pParty->uFine = 4000000; | |
322 | 2115 |
2116 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2117 { | |
2118 if (pOutdoor->ddm.uReputation < 10000) | |
2119 pOutdoor->ddm.uReputation++; | |
2120 } | |
2121 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
2122 { | |
2123 if (pIndoor->dlv.uReputation < 10000) | |
2124 pIndoor->dlv.uReputation++; | |
2125 } | |
2126 else assert(false); | |
2127 | |
0 | 2128 ppPlayers = &pPlayers[1]; |
2129 do | |
2130 { | |
2131 if ( pParty->uFine ) | |
2132 { | |
484 | 2133 if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)(*ppPlayers)->_guilds_member_bits, 1) ) |
2134 _449B7E_toggle_bit((unsigned char *)(*ppPlayers)->_guilds_member_bits, 1, 1u); | |
0 | 2135 } |
2136 ++ppPlayers; | |
2137 } | |
2138 while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] ); | |
2139 } | |
2140 } | |
2141 | |
2142 //----- (0043AE80) -------------------------------------------------------- | |
322 | 2143 void Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3) |
0 | 2144 { |
2145 int result; // eax@1 | |
2146 unsigned int v4; // esi@1 | |
2147 int v5; // [sp-14h] [bp-18h]@3 | |
2148 unsigned int v6; // [sp-10h] [bp-14h]@3 | |
2149 int v7; // [sp-Ch] [bp-10h]@3 | |
2150 int v8; // [sp-8h] [bp-Ch]@3 | |
2151 __int16 v9; // [sp-4h] [bp-8h]@3 | |
2152 | |
2153 result = a2 - 1; | |
862 | 2154 v4 = PID(OBJECT_Actor,uActorID); |
0 | 2155 switch ( a2 ) |
2156 { | |
2157 case 1: | |
2158 if ( a3 ) | |
2159 { | |
2160 v9 = 0; | |
2161 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0); | |
2162 v7 = 0; | |
2163 LOWORD(v6) = v4; | |
2164 v5 = 904; | |
2165 goto LABEL_16; | |
2166 } | |
322 | 2167 return; |
0 | 2168 case 2: |
2169 if ( a3 ) | |
2170 { | |
2171 v9 = 0; | |
2172 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0); | |
2173 v7 = 0; | |
2174 LOWORD(v6) = v4; | |
2175 v5 = 905; | |
2176 goto LABEL_16; | |
2177 } | |
322 | 2178 return; |
0 | 2179 case 3: |
2180 if ( a3 ) | |
2181 { | |
2182 v9 = 0; | |
2183 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0); | |
2184 v7 = 0; | |
2185 LOWORD(v6) = v4; | |
2186 v5 = 906; | |
2187 goto LABEL_16; | |
2188 } | |
322 | 2189 return; |
0 | 2190 case 4: |
2191 if ( a3 ) | |
2192 { | |
2193 v9 = 0; | |
2194 v8 = (signed __int64)(sub_43AE12(a3) * 65536.0); | |
2195 v7 = 0; | |
2196 LOWORD(v6) = v4; | |
2197 v5 = 907; | |
2198 goto LABEL_16; | |
2199 } | |
322 | 2200 return; |
0 | 2201 case 5: |
2202 v9 = 4; | |
2203 v8 = 65536; | |
2204 v7 = 0; | |
862 | 2205 v6 = PID(OBJECT_Actor,uActorID); |
0 | 2206 v5 = 901; |
2207 goto LABEL_16; | |
2208 case 6: | |
2209 v9 = 4; | |
2210 v8 = 65536; | |
2211 v7 = 0; | |
862 | 2212 v6 = PID(OBJECT_Actor,uActorID); |
0 | 2213 v5 = 902; |
2214 goto LABEL_16; | |
2215 case 7: | |
2216 v9 = 4; | |
2217 v8 = 65536; | |
2218 v7 = 0; | |
862 | 2219 v6 = PID(OBJECT_Actor,uActorID); |
0 | 2220 v5 = 903; |
2221 goto LABEL_16; | |
2222 case 8: | |
2223 v9 = 4; | |
2224 v8 = 65536; | |
2225 v7 = 0; | |
862 | 2226 v6 = PID(OBJECT_Actor,uActorID); |
0 | 2227 v5 = 900; |
2228 goto LABEL_16; | |
2229 case 9: | |
2230 v9 = 4; | |
2231 v8 = 65536; | |
2232 v7 = 0; | |
862 | 2233 v6 = PID(OBJECT_Actor,uActorID); |
0 | 2234 v5 = 909; |
2235 goto LABEL_16; | |
2236 case 10: | |
2237 v9 = 4; | |
2238 v8 = 65536; | |
2239 v7 = 0; | |
862 | 2240 v6 = PID(OBJECT_Actor,uActorID); |
0 | 2241 v5 = 908; |
2242 LABEL_16: | |
2243 result = pOtherOverlayList->_4418B6(v5, v6, v7, v8, v9); | |
2244 break; | |
2245 default: | |
322 | 2246 return; |
0 | 2247 } |
322 | 2248 return; |
0 | 2249 } |
2250 | |
2251 //----- (0043B3E0) -------------------------------------------------------- | |
2252 int Actor::_43B3E0_CalcDamage(Actor *a1, signed int a2) | |
2253 { | |
2254 signed int v2; // ebp@1 | |
2255 int v3; // eax@9 | |
2256 signed int v4; // edi@9 | |
2257 int v5; // esi@9 | |
2258 int v6; // ebx@11 | |
2259 unsigned __int16 v8; // si@21 | |
2260 int v9; // edi@21 | |
2261 signed int v10; // eax@23 | |
2262 int v11; // [sp+10h] [bp-4h]@1 | |
2263 | |
2264 v2 = 0; | |
2265 v11 = 0; | |
2266 if ( a2 ) | |
2267 { | |
2268 if ( a2 == 1 ) | |
2269 { | |
2270 v3 = a1->pMonsterInfo.uAttack2DamageDiceRolls; | |
2271 v4 = a1->pMonsterInfo.uAttack2DamageDiceSides; | |
2272 v5 = a1->pMonsterInfo.uAttack2DamageBonus; | |
2273 } | |
2274 else | |
2275 { | |
2276 if ( a2 <= 1 ) | |
2277 return 0; | |
2278 if ( a2 <= 3 ) | |
2279 { | |
2280 if ( a2 == 2 ) | |
2281 { | |
2282 v8 = a1->pMonsterInfo.uSpellSkillAndMastery1; | |
2283 v9 = a1->pMonsterInfo.uSpell1ID; | |
2284 } | |
2285 else | |
2286 { | |
2287 v8 = a1->pMonsterInfo.uSpellSkillAndMastery2; | |
2288 v9 = a1->pMonsterInfo.uSpell2ID; | |
2289 } | |
2290 v10 = SkillToMastery(v8); | |
2291 return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0); | |
2292 } | |
2293 if ( a2 != 4 ) | |
2294 return 0; | |
2295 v3 = a1->pMonsterInfo.uSpecialAbilityDamageDiceRolls; | |
2296 v4 = a1->pMonsterInfo.uSpecialAbilityDamageDiceSides; | |
2297 v5 = a1->pMonsterInfo.uSpecialAbilityDamageDiceBonus; | |
2298 } | |
2299 } | |
2300 else | |
2301 { | |
2302 if ( (signed __int64)a1->pActorBuffs[14].uExpireTime > 0 ) | |
2303 v2 = a1->pActorBuffs[14].uPower; | |
2304 if ( (signed __int64)a1->pActorBuffs[18].uExpireTime > 0 && a1->pActorBuffs[18].uPower > v2 ) | |
2305 v2 = a1->pActorBuffs[18].uPower; | |
2306 if ( (signed __int64)a1->pActorBuffs[21].uExpireTime > 0 ) | |
2307 v2 += a1->pActorBuffs[21].uPower; | |
2308 v3 = a1->pMonsterInfo.uAttack1DamageDiceRolls; | |
2309 v4 = a1->pMonsterInfo.uAttack1DamageDiceSides; | |
2310 v5 = a1->pMonsterInfo.uAttack1DamageBonus; | |
2311 } | |
2312 if ( v3 > 0 ) | |
2313 { | |
2314 v6 = v3; | |
2315 do | |
2316 { | |
2317 --v6; | |
2318 v11 += rand() % v4 + 1; | |
2319 } | |
2320 while ( v6 ); | |
2321 } | |
2322 return v11 + v5 + v2; | |
2323 } | |
2324 | |
2325 //----- (00438B9B) -------------------------------------------------------- | |
322 | 2326 bool Actor::IsPeasant() |
0 | 2327 { |
2328 unsigned int v1; // eax@1 | |
2329 | |
2330 v1 = this->uAlly; | |
2331 if ( !v1 ) | |
2332 v1 = (this->pMonsterInfo.uID - 1) / 3 + 1; | |
2333 return (signed int)v1 >= 39 && (signed int)v1 <= 44 | |
2334 || (signed int)v1 >= 45 && (signed int)v1 <= 50 | |
2335 || (signed int)v1 >= 51 && (signed int)v1 <= 62 | |
2336 || (signed int)v1 >= 78 && (signed int)v1 <= 83; | |
2337 } | |
2338 | |
2339 //----- (0042EBEE) -------------------------------------------------------- | |
2340 bool Actor::StealFrom(unsigned int uActorID) | |
2341 { | |
2342 unsigned int v1; // esi@1 | |
2343 Player *pPlayer; // edi@1 | |
2344 bool result; // eax@1 | |
2345 int v4; // ebx@2 | |
2346 unsigned int v5; // eax@2 | |
2347 DDM_DLV_Header *v6; // esi@4 | |
2348 unsigned int v7; // [sp+8h] [bp-4h]@1 | |
2349 int v8; // [sp+8h] [bp-4h]@6 | |
2350 | |
2351 v1 = uActiveCharacter; | |
2352 v7 = uActorID; | |
243 | 2353 pPlayer = &pParty->pPlayers[uActiveCharacter-1]; |
0 | 2354 result = pPlayer->CanAct(); |
2355 if ( result ) | |
2356 { | |
1202 | 2357 pCastSpellInfo.data()->_427D48(v1); |
0 | 2358 v4 = 0; |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
2359 v5 = pMapStats->GetMapInfo(pCurrentMapName.data()); |
0 | 2360 if ( v5 ) |
2361 v4 = pMapStats->pInfos[v5]._steal_perm; | |
2362 v6 = &pOutdoor->ddm; | |
2363 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) | |
2364 v6 = &pIndoor->dlv; | |
2365 pPlayer->StealFromActor(v7, v4, v6->uReputation++); | |
2366 v8 = pPlayer->GetAttackRecoveryTime(0); | |
2367 if ( v8 < 30 ) | |
2368 v8 = 30; | |
2369 if ( !pParty->bTurnBasedModeOn ) | |
2370 pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v8 * 2.133333333333333)); | |
2371 pTurnEngine->_40471C(); | |
2372 result = 1; | |
2373 } | |
2374 return result; | |
2375 } | |
2376 | |
2377 //----- (00403A60) -------------------------------------------------------- | |
1060 | 2378 void Actor::AI_SpellAttack2(unsigned int uActorID, signed int edx0, AIDirection *pDir) |
0 | 2379 { |
2380 Actor *v3; // ebx@1 | |
2381 AIDirection *v4; // esi@3 | |
2382 AIDirection *v5; // edi@3 | |
2383 signed int v6; // eax@4 | |
2384 Vec3_int_ v7; // ST04_12@6 | |
322 | 2385 //unsigned int result; // eax@7 |
0 | 2386 AIDirection *v9; // eax@8 |
2387 unsigned int v10; // esi@8 | |
2388 AIDirection *v11; // esi@9 | |
2389 SpriteFrame *v12; // ecx@10 | |
2390 __int16 v13; // ax@10 | |
2391 unsigned int v14; // ecx@10 | |
2392 unsigned int v15; // eax@10 | |
2393 signed int v16; // ecx@17 | |
2394 AIDirection a3; // [sp+Ch] [bp-48h]@9 | |
2395 AIDirection v18; // [sp+28h] [bp-2Ch]@9 | |
2396 int v19; // [sp+44h] [bp-10h]@6 | |
2397 signed int a2; // [sp+48h] [bp-Ch]@1 | |
2398 int v21; // [sp+4Ch] [bp-8h]@3 | |
2399 unsigned int v22; // [sp+50h] [bp-4h]@1 | |
2400 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 | |
2401 | |
2402 v22 = uActorID; | |
2403 v3 = &pActors[uActorID]; | |
2404 a2 = edx0; | |
848 | 2405 if ( PID_TYPE(edx0) == OBJECT_Actor) |
0 | 2406 { |
848 | 2407 v6 = PID_ID(edx0); |
0 | 2408 v4 = (AIDirection *)pActors[v6].vPosition.x; |
2409 v5 = (AIDirection *)pActors[v6].vPosition.y; | |
2410 v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); | |
2411 } | |
2412 else | |
2413 { | |
848 | 2414 if ( PID_TYPE(edx0) == OBJECT_Player) |
0 | 2415 { |
2416 v4 = (AIDirection *)pParty->vPosition.x; | |
2417 v5 = (AIDirection *)pParty->vPosition.y; | |
2418 v21 = pParty->vPosition.z + pParty->sEyelevel; | |
2419 } | |
2420 else | |
2421 { | |
2422 v4 = pDir; | |
2423 v5 = pDir; | |
2424 } | |
2425 } | |
2426 v19 = v3->uActorHeight; | |
2427 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); | |
2428 v7.y = v3->vPosition.y; | |
2429 v7.x = v3->vPosition.x; | |
2430 if ( sub_407A1C((int)v4, (int)v5, v21, v7) ) | |
2431 { | |
2432 v9 = pDir; | |
2433 v10 = 0; | |
2434 if ( !pDir ) | |
2435 { | |
862 | 2436 v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v22), a2, &a3, 0); |
0 | 2437 v9 = &v18; |
2438 memcpy(&v18, v11, sizeof(v18)); | |
2439 v10 = 0; | |
2440 } | |
2441 v12 = pSpriteFrameTable->pSpriteSFrames; | |
2442 v3->uYawAngle = LOWORD(v9->uYawAngle); | |
319 | 2443 v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; |
0 | 2444 v14 = v22; |
2445 v3->uCurrentActionLength = 8 * v13; | |
2446 v3->uCurrentActionTime = v10; | |
2447 v3->uAIState = AttackingRanged4; | |
2448 Actor::PlaySound(v14, 0); | |
2449 v15 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2450 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2451 if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v10 | |
2452 && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v10 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v10) ) | |
2453 { | |
2454 v15 *= 2; | |
2455 pDira = v15; | |
2456 } | |
2457 if ( pParty->bTurnBasedModeOn == 1 ) | |
2458 v3->pMonsterInfo.uRecoveryTime = v15; | |
2459 else | |
2460 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength | |
2461 - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2 | |
2462 * (double)(signed int)pDira | |
2463 * -2.133333333333333); | |
2464 v16 = v3->pMonsterInfo.uSpell2ID; | |
2465 v3->vVelocity.z = v10; | |
2466 v3->vVelocity.y = v10; | |
2467 v3->vVelocity.x = v10; | |
2468 if ( sub_42FB5C(v16) ) | |
2469 { | |
2470 v3->uCurrentActionLength = 64; | |
2471 v3->uCurrentActionTime = v10; | |
2472 v3->uAIState = Fidgeting; | |
322 | 2473 v3->UpdateAnimation(); |
0 | 2474 v3->uAIState = AttackingRanged4; |
2475 } | |
2476 else | |
322 | 2477 v3->UpdateAnimation(); |
0 | 2478 } |
2479 else | |
1060 | 2480 Actor::AI_Pursue1(v22, a2, v22, 64, pDir); |
0 | 2481 } |
2482 | |
2483 //----- (00403854) -------------------------------------------------------- | |
1060 | 2484 void Actor::AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) |
0 | 2485 { |
2486 Actor *v3; // ebx@1 | |
2487 AIDirection *v4; // esi@3 | |
2488 AIDirection *v5; // edi@3 | |
2489 signed int v6; // eax@4 | |
2490 Vec3_int_ v7; // ST04_12@6 | |
322 | 2491 //unsigned int result; // eax@7 |
0 | 2492 AIDirection *v9; // eax@8 |
2493 unsigned int v10; // esi@8 | |
2494 AIDirection *v11; // esi@9 | |
2495 SpriteFrame *v12; // ecx@10 | |
2496 __int16 v13; // ax@10 | |
2497 unsigned int v14; // ecx@10 | |
2498 unsigned int v15; // eax@10 | |
2499 signed int v16; // ecx@17 | |
2500 AIDirection a3; // [sp+Ch] [bp-48h]@9 | |
2501 AIDirection v18; // [sp+28h] [bp-2Ch]@9 | |
2502 int v19; // [sp+44h] [bp-10h]@6 | |
848 | 2503 //signed int a2; // [sp+48h] [bp-Ch]@1 |
0 | 2504 int v21; // [sp+4Ch] [bp-8h]@3 |
2505 unsigned int v22; // [sp+50h] [bp-4h]@1 | |
2506 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 | |
2507 | |
2508 v22 = uActorID; | |
2509 v3 = &pActors[uActorID]; | |
848 | 2510 //a2 = edx0; |
2511 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) | |
0 | 2512 { |
848 | 2513 v6 = PID_ID(sTargetPid); |
0 | 2514 v4 = (AIDirection *)pActors[v6].vPosition.x; |
2515 v5 = (AIDirection *)pActors[v6].vPosition.y; | |
2516 v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); | |
2517 } | |
2518 else | |
2519 { | |
848 | 2520 if ( PID_TYPE(sTargetPid) == OBJECT_Player) |
0 | 2521 { |
2522 v4 = (AIDirection *)pParty->vPosition.x; | |
2523 v5 = (AIDirection *)pParty->vPosition.y; | |
2524 v21 = pParty->vPosition.z + pParty->sEyelevel; | |
2525 } | |
2526 else | |
2527 { | |
2528 v4 = pDir; | |
2529 v5 = pDir; | |
2530 } | |
2531 } | |
2532 v19 = v3->uActorHeight; | |
2533 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); | |
2534 v7.y = v3->vPosition.y; | |
2535 v7.x = v3->vPosition.x; | |
2536 if ( sub_407A1C((int)v4, (int)v5, v21, v7) ) | |
2537 { | |
2538 v9 = pDir; | |
2539 v10 = 0; | |
2540 if ( !pDir ) | |
2541 { | |
862 | 2542 v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v22), sTargetPid, &a3, 0); |
0 | 2543 v9 = &v18; |
2544 memcpy(&v18, v11, sizeof(v18)); | |
2545 v10 = 0; | |
2546 } | |
2547 v12 = pSpriteFrameTable->pSpriteSFrames; | |
2548 v3->uYawAngle = LOWORD(v9->uYawAngle); | |
319 | 2549 v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; |
0 | 2550 v14 = v22; |
2551 v3->uCurrentActionLength = 8 * v13; | |
2552 v3->uCurrentActionTime = v10; | |
2553 v3->uAIState = AttackingRanged3; | |
2554 Actor::PlaySound(v14, 0); | |
2555 v15 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2556 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2557 if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v10 | |
2558 && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v10 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v10) ) | |
2559 { | |
2560 v15 *= 2; | |
2561 pDira = v15; | |
2562 } | |
2563 if ( pParty->bTurnBasedModeOn == 1 ) | |
2564 v3->pMonsterInfo.uRecoveryTime = v15; | |
2565 else | |
2566 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength | |
2567 - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2 | |
2568 * (double)(signed int)pDira | |
2569 * -2.133333333333333); | |
2570 v16 = v3->pMonsterInfo.uSpell1ID; | |
2571 v3->vVelocity.z = v10; | |
2572 v3->vVelocity.y = v10; | |
2573 v3->vVelocity.x = v10; | |
2574 if ( sub_42FB5C(v16) ) | |
2575 { | |
2576 v3->uCurrentActionLength = 64; | |
2577 v3->uCurrentActionTime = v10; | |
2578 v3->uAIState = Fidgeting; | |
322 | 2579 v3->UpdateAnimation(); |
0 | 2580 v3->uAIState = AttackingRanged3; |
2581 } | |
2582 else | |
322 | 2583 v3->UpdateAnimation(); |
0 | 2584 } |
2585 else | |
1060 | 2586 Actor::AI_Pursue1(v22, sTargetPid, v22, 64, pDir); |
0 | 2587 } |
2588 | |
2589 //----- (0040368B) -------------------------------------------------------- | |
1060 | 2590 void Actor::AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) |
0 | 2591 { |
2592 Actor *v3; // ebx@1 | |
2593 AIDirection *v4; // esi@3 | |
2594 AIDirection *v5; // edi@3 | |
2595 signed int v6; // eax@4 | |
2596 Vec3_int_ v7; // ST04_12@6 | |
322 | 2597 //unsigned int result; // eax@7 |
0 | 2598 AIDirection *v9; // eax@8 |
2599 unsigned int v10; // esi@8 | |
2600 AIDirection *v11; // esi@9 | |
2601 SpriteFrame *v12; // ecx@10 | |
2602 __int16 v13; // ax@10 | |
2603 unsigned int v14; // ecx@10 | |
2604 signed __int64 v15; // qax@10 | |
2605 AIDirection a3; // [sp+Ch] [bp-48h]@9 | |
2606 AIDirection v17; // [sp+28h] [bp-2Ch]@9 | |
2607 int v18; // [sp+44h] [bp-10h]@6 | |
848 | 2608 //signed int a2; // [sp+48h] [bp-Ch]@1 |
0 | 2609 int v20; // [sp+4Ch] [bp-8h]@3 |
2610 unsigned int v21; // [sp+50h] [bp-4h]@1 | |
2611 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 | |
2612 | |
2613 v21 = uActorID; | |
2614 v3 = &pActors[uActorID]; | |
848 | 2615 //a2 = edx0; |
2616 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) | |
0 | 2617 { |
848 | 2618 v6 = PID_ID(sTargetPid); |
0 | 2619 v4 = (AIDirection *)pActors[v6].vPosition.x; |
2620 v5 = (AIDirection *)pActors[v6].vPosition.y; | |
2621 v20 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); | |
2622 } | |
2623 else | |
2624 { | |
848 | 2625 if ( PID_TYPE(sTargetPid) == OBJECT_Player) |
0 | 2626 { |
2627 v4 = (AIDirection *)pParty->vPosition.x; | |
2628 v5 = (AIDirection *)pParty->vPosition.y; | |
2629 v20 = pParty->vPosition.z + pParty->sEyelevel; | |
2630 } | |
2631 else | |
2632 { | |
2633 v4 = pDir; | |
2634 v5 = pDir; | |
2635 } | |
2636 } | |
2637 v18 = v3->uActorHeight; | |
2638 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v18 * -0.75); | |
2639 v7.y = v3->vPosition.y; | |
2640 v7.x = v3->vPosition.x; | |
2641 if ( sub_407A1C((int)v4, (int)v5, v20, v7) ) | |
2642 { | |
2643 v9 = pDir; | |
2644 v10 = 0; | |
2645 if ( !pDir ) | |
2646 { | |
862 | 2647 v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); |
0 | 2648 v9 = &v17; |
2649 memcpy(&v17, v11, sizeof(v17)); | |
2650 v10 = 0; | |
2651 } | |
2652 v12 = pSpriteFrameTable->pSpriteSFrames; | |
2653 v3->uYawAngle = LOWORD(v9->uYawAngle); | |
319 | 2654 v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; |
0 | 2655 v14 = v21; |
2656 v3->uCurrentActionLength = 8 * v13; | |
2657 v3->uCurrentActionTime = v10; | |
2658 v3->uAIState = AttackingRanged2; | |
2659 Actor::PlaySound(v14, 0); | |
2660 LODWORD(v15) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2661 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2662 if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v10 | |
2663 && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v10 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v10) ) | |
2664 { | |
2665 LODWORD(v15) = 2 * v15; | |
2666 pDira = v15; | |
2667 } | |
2668 if ( pParty->bTurnBasedModeOn != 1 ) | |
2669 v15 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)pDira * 2.133333333333333); | |
2670 v3->pMonsterInfo.uRecoveryTime = v15; | |
2671 v3->vVelocity.z = v10; | |
2672 v3->vVelocity.y = v10; | |
2673 v3->vVelocity.x = v10; | |
322 | 2674 v3->UpdateAnimation(); |
0 | 2675 } |
2676 else | |
1060 | 2677 Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir); |
0 | 2678 } |
2679 | |
2680 //----- (00403476) -------------------------------------------------------- | |
1060 | 2681 void Actor::AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) |
0 | 2682 { |
2683 Actor *v3; // ebx@1 | |
2684 int v4; // esi@3 | |
2685 int v5; // edi@3 | |
2686 signed int v6; // eax@4 | |
2687 Vec3_int_ v7; // ST04_12@6 | |
2688 unsigned char v8[12]; // ST04_12@7 | |
322 | 2689 //unsigned int result; // eax@8 |
0 | 2690 AIDirection *v10; // eax@9 |
2691 unsigned int v11; // esi@9 | |
2692 AIDirection *v12; // esi@10 | |
2693 SpriteFrame *v13; // ecx@11 | |
2694 __int16 v14; // ax@11 | |
2695 unsigned int v15; // ecx@11 | |
2696 unsigned int v16; // eax@11 | |
2697 AIDirection a3; // [sp+Ch] [bp-48h]@10 | |
2698 AIDirection v18; // [sp+28h] [bp-2Ch]@10 | |
2699 int v19; // [sp+44h] [bp-10h]@6 | |
848 | 2700 //signed int a2; // [sp+48h] [bp-Ch]@1 |
0 | 2701 unsigned int v21; // [sp+4Ch] [bp-8h]@1 |
2702 int v22; // [sp+50h] [bp-4h]@3 | |
2703 unsigned int pDira; // [sp+5Ch] [bp+8h]@11 | |
2704 | |
2705 v21 = uActorID; | |
2706 v3 = &pActors[uActorID]; | |
848 | 2707 //a2 = edx0; |
2708 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) | |
0 | 2709 { |
848 | 2710 v6 = PID_ID(sTargetPid); |
0 | 2711 v4 = pActors[v6].vPosition.x; |
2712 v5 = pActors[v6].vPosition.y; | |
2713 v22 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); | |
2714 } | |
2715 else | |
2716 { | |
848 | 2717 if ( PID_TYPE(sTargetPid) == OBJECT_Player) |
0 | 2718 { |
2719 v4 = pParty->vPosition.x; | |
2720 v5 = pParty->vPosition.y; | |
2721 v22 = pParty->vPosition.z + pParty->sEyelevel; | |
2722 } | |
2723 else | |
2724 { | |
2725 v4 = (int)pDir; | |
2726 v5 = (int)pDir; | |
2727 } | |
2728 } | |
2729 v19 = v3->uActorHeight; | |
2730 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); | |
2731 v7.y = v3->vPosition.y; | |
2732 v7.x = v3->vPosition.x; | |
2733 if ( sub_407A1C(v4, v5, v22, v7) | |
2734 || (*(unsigned int *)&v8[8] = v22, | |
2735 v19 = v3->uActorHeight, | |
2736 *(_QWORD *)v8 = __PAIR__(v5, v4), | |
2737 sub_407A1C( | |
2738 v3->vPosition.x, | |
2739 v3->vPosition.y, | |
2740 v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75), | |
2741 *(Vec3_int_ *)v8)) ) | |
2742 { | |
2743 v10 = pDir; | |
2744 v11 = 0; | |
2745 if ( !pDir ) | |
2746 { | |
862 | 2747 v12 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); |
0 | 2748 v10 = &v18; |
2749 memcpy(&v18, v12, sizeof(v18)); | |
2750 v11 = 0; | |
2751 } | |
2752 v13 = pSpriteFrameTable->pSpriteSFrames; | |
2753 v3->uYawAngle = LOWORD(v10->uYawAngle); | |
319 | 2754 v14 = v13[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; |
0 | 2755 v15 = v21; |
2756 v3->uCurrentActionLength = 8 * v14; | |
2757 v3->uCurrentActionTime = v11; | |
2758 v3->uAIState = AttackingRanged1; | |
2759 Actor::PlaySound(v15, 0); | |
2760 v16 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2761 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
2762 if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v11 | |
2763 && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v11 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v11) ) | |
2764 { | |
2765 v16 *= 2; | |
2766 pDira = v16; | |
2767 } | |
2768 if ( pParty->bTurnBasedModeOn == 1 ) | |
2769 v3->pMonsterInfo.uRecoveryTime = v16; | |
2770 else | |
2771 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength | |
2772 - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2 | |
2773 * (double)(signed int)pDira | |
2774 * -2.133333333333333); | |
2775 v3->vVelocity.z = v11; | |
2776 v3->vVelocity.y = v11; | |
2777 v3->vVelocity.x = v11; | |
322 | 2778 v3->UpdateAnimation(); |
0 | 2779 } |
2780 else | |
1060 | 2781 Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir); |
0 | 2782 } |
2783 | |
2784 //----- (004032B2) -------------------------------------------------------- | |
1060 | 2785 void Actor::AI_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength) |
0 | 2786 { |
2787 unsigned int v4; // edi@1 | |
2788 Actor *v5; // esi@1 | |
2789 int v6; // ebx@1 | |
2790 int v7; // ST08_4@1 | |
2791 int v8; // eax@1 | |
2792 unsigned int v9; // ebx@11 | |
2793 int v10; // ebx@13 | |
2794 signed __int16 v11; // cx@17 | |
2795 unsigned int v12; // [sp-8h] [bp-44h]@10 | |
2796 AIDirection *v13; // [sp-4h] [bp-40h]@10 | |
2797 AIDirection v14; // [sp+Ch] [bp-30h]@7 | |
2798 int v15; // [sp+28h] [bp-14h]@11 | |
2799 unsigned int v16; // [sp+2Ch] [bp-10h]@1 | |
2800 int y; // [sp+30h] [bp-Ch]@1 | |
2801 unsigned int uActorID; // [sp+34h] [bp-8h]@1 | |
2802 int v19; // [sp+38h] [bp-4h]@1 | |
2803 | |
414 | 2804 //v14 never filled, maybe it is passed to function but optimized away as local variable |
2805 | |
0 | 2806 uActorID = a1; |
2807 v4 = a1; | |
2808 v5 = &pActors[a1]; | |
2809 v16 = a2; | |
2810 v6 = v5->vInitialPosition.x - v5->vPosition.x; | |
2811 v7 = v5->vInitialPosition.x - v5->vPosition.x; | |
2812 y = v5->vInitialPosition.y - v5->vPosition.y; | |
2813 v19 = abs(v7); | |
2814 v8 = abs(y); | |
2815 if ( v19 <= v8 ) | |
2816 v19 = v8 + (v19 >> 1); | |
2817 else | |
2818 v19 += v8 >> 1; | |
2819 if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
2820 { | |
2821 if ( !uActionLength ) | |
2822 uActionLength = 256; | |
414 | 2823 Actor::AI_StandOrBored(uActorID, OBJECT_Player, uActionLength, &v14); |
0 | 2824 return; |
2825 } | |
2826 if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 ) | |
2827 { | |
2828 v13 = &v14; | |
2829 v12 = 256; | |
413 | 2830 Actor::AI_Stand(uActorID, v16, v12, v13); |
0 | 2831 return; |
2832 } | |
2833 v15 = (rand() & 0xF) << 12; | |
2834 v19 += (unsigned __int64)(v15 * (signed __int64)a3) >> 16; | |
2835 v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(v6, y); | |
2836 if ( rand() % 100 < 25 ) | |
2837 { | |
2838 Actor::StandAwhile(uActorID); | |
2839 return; | |
2840 } | |
2841 v10 = v9 + rand() % 256 - 128; | |
2842 if ( abs(v10 - v5->uYawAngle) > 256 && !(BYTE2(v5->uAttributes) & 0x20) ) | |
2843 { | |
2844 v13 = &v14; | |
2845 v12 = 256; | |
413 | 2846 Actor::AI_Stand(uActorID, v16, v12, v13); |
245 | 2847 return; |
0 | 2848 } |
2849 v11 = v5->uMovementSpeed; | |
2850 v5->uYawAngle = v10; | |
2851 if ( v11 ) | |
2852 v5->uCurrentActionLength = 32 * v19 / v11; | |
2853 else | |
2854 v5->uCurrentActionLength = 0; | |
2855 v5->uCurrentActionTime = 0; | |
2856 v5->uAIState = Tethered; | |
2857 if ( rand() % 100 < 2 ) | |
2858 Actor::PlaySound(uActorID, 3u); | |
2859 v5->UpdateAnimation(); | |
2860 } | |
2861 | |
2862 //----- (004031C1) -------------------------------------------------------- | |
2863 char __fastcall Actor::_4031C1_update_job(unsigned int uActorID, signed int a2, int a3) | |
2864 { | |
2865 unsigned int v3; // edi@1 | |
2866 Actor *v4; // esi@1 | |
2867 ActorJob *v5; // eax@1 | |
2868 signed int v6; // edx@2 | |
2869 ActorJob *v7; // eax@2 | |
2870 signed int v8; // edi@2 | |
82 | 2871 ActorJob *v9; // ecx@2 |
0 | 2872 __int16 v10; // cx@15 |
2873 signed int v12; // [sp+8h] [bp-4h]@1 | |
2874 | |
2875 v3 = uActorID; | |
2876 v12 = a2; | |
2877 v4 = &pActors[uActorID]; | |
2878 v5 = (ActorJob *)pActors[uActorID].CanAct(); | |
2879 if ( v5 ) | |
2880 { | |
2881 v6 = 65535; | |
2882 v7 = &v4->pScheduledJobs[v3]; | |
2883 v8 = 7; | |
82 | 2884 v9 = &v7[7];//(char *)&v7[7].uHour; |
2885 while ( !(v9->uAttributes & 1) || v9->uHour > v12 ) | |
0 | 2886 { |
2887 --v8; | |
82 | 2888 --v9; |
0 | 2889 if ( v8 < 0 ) |
82 | 2890 break; |
0 | 2891 } |
82 | 2892 if( v8 >= 0 ) |
2893 v6 = v8; | |
0 | 2894 if ( !v8 && v6 == 65535 ) |
2895 v6 = 7; | |
2896 v5 = &v7[v6]; | |
2897 if ( v4->vInitialPosition.x != v5->vPos.x | |
2898 || v4->vInitialPosition.y != v5->vPos.y | |
2899 || v4->vInitialPosition.z != v5->vPos.z | |
2900 || v4->pMonsterInfo.uMovementType != v5->uAction ) | |
2901 { | |
2902 v4->vInitialPosition.x = v5->vPos.x; | |
2903 v4->vInitialPosition.y = v5->vPos.y; | |
2904 v10 = v5->vPos.z; | |
2905 v4->vInitialPosition.z = v10; | |
2906 LOBYTE(v5) = v5->uAction; | |
2907 v4->pMonsterInfo.uMovementType = (unsigned __int8)v5; | |
2908 if ( a3 == 1 ) | |
2909 { | |
2910 v4->vPosition.x = v4->vInitialPosition.x; | |
2911 v4->vPosition.y = v4->vInitialPosition.y; | |
2912 LOBYTE(v5) = v10; | |
2913 v4->vPosition.z = v10; | |
2914 } | |
2915 } | |
2916 } | |
2917 return (char)v5; | |
2918 } | |
2919 | |
2920 //----- (004030AD) -------------------------------------------------------- | |
1060 | 2921 void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int arg0) |
0 | 2922 { |
2923 unsigned int v3; // edi@1 | |
2924 Actor *v4; // ebx@1 | |
322 | 2925 //__int16 result; // ax@10 |
0 | 2926 SpriteFrame *v6; // ecx@16 |
2927 __int16 v7; // ax@16 | |
2928 unsigned int v8; // ecx@16 | |
2929 AIDirection a3; // [sp+Ch] [bp-40h]@16 | |
2930 AIDirection v10; // [sp+28h] [bp-24h]@16 | |
2931 unsigned int v11; // [sp+44h] [bp-8h]@1 | |
2932 signed int a2; // [sp+48h] [bp-4h]@1 | |
2933 | |
2934 v3 = uActorID; | |
2935 a2 = edx0; | |
2936 v4 = &pActors[uActorID]; | |
2937 v11 = uActorID; | |
2938 if ( v4->uAIState == 7 ) | |
2939 BYTE2(v4->uAttributes) |= 2u; | |
2940 if ( v4->pMonsterInfo.uHostilityType != 4 ) | |
2941 { | |
2942 v4->uAttributes &= 0xFFFFFFFBu; | |
2943 v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; | |
2944 } | |
2945 if ( (signed __int64)v4->pActorBuffs[1].uExpireTime > 0 ) | |
2946 v4->pActorBuffs[1].Reset(); | |
2947 if ( (signed __int64)v4->pActorBuffs[4].uExpireTime > 0 ) | |
2948 v4->pActorBuffs[4].Reset(); | |
2949 if ( arg0 | |
322 | 2950 || (v4->uAIState != 8 |
2951 && v4->uAIState != 3 | |
2952 && v4->uAIState != 12 | |
2953 && v4->uAIState != 13 | |
2954 && v4->uAIState != 18 | |
2955 && v4->uAIState != 2)) | |
0 | 2956 { |
862 | 2957 memcpy(&v10, Actor::GetDirectionInfo(PID(OBJECT_Actor,v3), a2, &a3, 0), sizeof(v10)); |
0 | 2958 v6 = pSpriteFrameTable->pSpriteSFrames; |
2959 v4->uYawAngle = LOWORD(v10.uYawAngle); | |
319 | 2960 v7 = v6[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength; |
0 | 2961 v8 = v11; |
2962 v4->uCurrentActionTime = 0; | |
2963 v4->uAIState = Stunned; | |
2964 v4->uCurrentActionLength = 8 * v7; | |
2965 Actor::PlaySound(v8, 2u); | |
322 | 2966 v4->UpdateAnimation(); |
0 | 2967 } |
2968 } | |
2969 | |
2970 //----- (00402F87) -------------------------------------------------------- | |
414 | 2971 void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) |
0 | 2972 { |
2973 unsigned int v7; // eax@3 | |
2974 unsigned int v9; // eax@3 | |
1060 | 2975 |
414 | 2976 assert(uActorID < uNumActors); |
1202 | 2977 auto actor = &pActors[uActorID]; |
417 | 2978 |
2979 AIDirection a3; // [sp+Ch] [bp-5Ch]@2 | |
414 | 2980 if (!a4) |
862 | 2981 a4 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), uObjID, &a3, 0); |
414 | 2982 |
2983 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; | |
2984 | |
2985 v7 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, actor->vPosition.y - pIndoorCamera->pos.y); | |
2986 v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; | |
2987 | |
2988 if ( BYTE1(v9) & 7 ) // turned away - just stand | |
2989 Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); | |
2990 else // facing player - play bored anim | |
0 | 2991 { |
414 | 2992 actor->uAIState = Fidgeting; |
2993 actor->uCurrentActionTime = 0; | |
2994 actor->uYawAngle = a4->uYawAngle; | |
2995 actor->vVelocity.z = 0; | |
2996 actor->vVelocity.y = 0; | |
2997 actor->vVelocity.x = 0; | |
0 | 2998 if ( rand() % 100 < 5 ) |
414 | 2999 Actor::PlaySound(uActorID, 3); |
3000 actor->UpdateAnimation(); | |
0 | 3001 } |
3002 } | |
3003 | |
3004 //----- (00402F27) -------------------------------------------------------- | |
322 | 3005 void Actor::Resurrect(unsigned int uActorID) |
0 | 3006 { |
3007 Actor *pActor; // esi@1 | |
3008 SpriteFrame *v2; // edx@1 | |
3009 int v3; // eax@1 | |
3010 | |
3011 pActor = &pActors[uActorID]; | |
3012 v2 = pSpriteFrameTable->pSpriteSFrames; | |
319 | 3013 v3 = pActor->pSpriteIDs[ANIM_Dying]; |
0 | 3014 pActor->uCurrentActionTime = 0; |
3015 pActor->uAIState = Resurrected; | |
3016 pActor->uCurrentActionAnimation = ANIM_Dying; | |
3017 pActor->uCurrentActionLength = 8 * v2[v3].uAnimLength; | |
3018 pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP); | |
3019 Actor::PlaySound(uActorID, 1u); | |
322 | 3020 pActor->UpdateAnimation(); |
0 | 3021 } |
3022 | |
3023 //----- (00402D6E) -------------------------------------------------------- | |
319 | 3024 void Actor::Die(unsigned int uActorID) |
0 | 3025 { |
319 | 3026 auto actor = &pActors[uActorID]; |
0 | 3027 |
319 | 3028 actor->uCurrentActionTime = 0; |
3029 actor->uAIState = Dying; | |
3030 actor->uCurrentActionAnimation = ANIM_Dying; | |
3031 actor->sCurrentHP = 0; | |
3032 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Dying]].uAnimLength; | |
3033 actor->pActorBuffs[6].Reset(); | |
3034 actor->pActorBuffs[5].Reset(); | |
3035 Actor::PlaySound(uActorID, 1); | |
3036 actor->UpdateAnimation(); | |
3037 | |
3038 for (uint i = 0; i < 5; ++i) | |
3039 if (pParty->field_750[i] == actor->pMonsterInfo.uID) | |
3040 pParty->field_75A[i] = true; | |
3041 | |
3042 for (uint i = 0; i < 22; ++i) | |
3043 actor->pActorBuffs[i].Reset(); | |
3044 | |
3045 ItemGen drop; | |
1012 | 3046 drop.Reset(); |
319 | 3047 switch (actor->pMonsterInfo.uID) |
0 | 3048 { |
319 | 3049 case MONSTER_HARPY_1: case MONSTER_HARPY_2: case MONSTER_HARPY_3: |
3050 drop.uItemID = ITEM_HARPY_FEATHER; | |
3051 break; | |
3052 | |
3053 case MONSTER_OOZE_1: case MONSTER_OOZE_2: case MONSTER_OOZE_3: | |
3054 drop.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE; | |
3055 break; | |
3056 | |
3057 case MONSTER_TROLL_1: case MONSTER_TROLL_2: case MONSTER_TROLL_3: | |
3058 drop.uItemID = ITEM_TROLL_BLOOD; | |
3059 break; | |
3060 | |
3061 case MONSTER_DEVIL_1: case MONSTER_DEVIL_2: case MONSTER_DEVIL_3: | |
3062 drop.uItemID = ITEM_DEVIL_ICHOR; | |
3063 break; | |
3064 | |
3065 case MONSTER_DRAGON_1: case MONSTER_DRAGON_2: case MONSTER_DRAGON_3: | |
3066 drop.uItemID = ITEM_DRAGON_EYE; | |
321 | 3067 break; |
0 | 3068 } |
319 | 3069 |
3070 if (rand() % 100 < 20) | |
0 | 3071 { |
319 | 3072 sub_42F7EB_DropItemAt(pItemsTable->pItems[drop.uItemID].uSpriteID, |
3073 actor->vPosition.x, | |
3074 actor->vPosition.y, | |
3075 actor->vPosition.z + 16, | |
3076 rand() % 200 + 200, | |
0 | 3077 1, |
3078 1, | |
3079 0, | |
319 | 3080 &drop); |
0 | 3081 } |
319 | 3082 |
3083 if (actor->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE) | |
3084 Actor::Explode(uActorID); | |
0 | 3085 } |
3086 | |
3087 //----- (00402CED) -------------------------------------------------------- | |
322 | 3088 void Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID) |
0 | 3089 { |
3090 Actor *v2; // eax@1 | |
3091 unsigned __int16 v3; // dx@1 | |
3092 int v4; // eax@3 | |
3093 int v5; // eax@4 | |
3094 unsigned int v6; // eax@6 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
3095 //signed int v7; // eax@12 |
0 | 3096 signed int v8; // [sp-18h] [bp-1Ch]@10 |
3097 signed int v9; // [sp-14h] [bp-18h]@10 | |
3098 int v10; // [sp-10h] [bp-14h]@10 | |
3099 unsigned int v11; // [sp-Ch] [bp-10h]@10 | |
3100 int v12; // [sp-8h] [bp-Ch]@10 | |
3101 | |
3102 v2 = &pActors[uActorID]; | |
3103 v3 = v2->pSoundSampleIDs[uSoundID]; | |
3104 if ( v3 ) | |
3105 { | |
3106 if ( (signed __int64)v2->pActorBuffs[3].uExpireTime <= 0 ) | |
3107 { | |
3108 v12 = 0; | |
1036 | 3109 |
0 | 3110 v8 = -1; |
3111 } | |
3112 else | |
3113 { | |
3114 v4 = v2->pActorBuffs[3].uPower - 2; | |
3115 if ( v4 ) | |
3116 { | |
3117 v5 = v4 - 1; | |
3118 if ( v5 ) | |
3119 { | |
3120 if ( v5 == 1 ) | |
3121 v6 = 55125; | |
3122 else | |
3123 v6 = uActorID; | |
3124 } | |
3125 else | |
3126 { | |
3127 v6 = 44100; | |
3128 } | |
3129 } | |
3130 else | |
3131 { | |
3132 v6 = 33075; | |
3133 } | |
3134 v12 = v6; | |
1036 | 3135 |
0 | 3136 v8 = 0; |
3137 } | |
1036 | 3138 pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, PID(OBJECT_Actor, uActorID), 0, v8, 0, 0, 0, v12); |
0 | 3139 } |
3140 } | |
3141 | |
3142 //----- (00402AD7) -------------------------------------------------------- | |
1060 | 3143 void Actor::AI_Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) |
0 | 3144 { |
3145 unsigned int v5; // edi@1 | |
3146 int v6; // eax@1 | |
3147 Actor *v7; // ebx@1 | |
3148 unsigned int v8; // ecx@1 | |
3149 char v9; // zf@1 | |
3150 AIDirection *v10; // esi@6 | |
1052 | 3151 //int v12; // ecx@19 |
3152 //unsigned int v13; // eax@19 | |
0 | 3153 AIDirection a3; // [sp+Ch] [bp-5Ch]@7 |
1052 | 3154 //AIDirection v15; // [sp+28h] [bp-40h]@7 |
0 | 3155 AIDirection v16; // [sp+44h] [bp-24h]@7 |
1052 | 3156 //unsigned int v17; // [sp+60h] [bp-8h]@1 |
0 | 3157 unsigned int v18; // [sp+64h] [bp-4h]@1 |
1052 | 3158 //int v19; // [sp+70h] [bp+8h]@19 |
0 | 3159 |
3160 v5 = uActorID; | |
3161 v6 = 0; | |
3162 v7 = &pActors[uActorID]; | |
3163 v18 = a2; | |
862 | 3164 v8 = PID(OBJECT_Actor,uActorID); |
0 | 3165 v9 = v7->pMonsterInfo.uFlying == 0; |
3166 if ( !v9 && !pParty->bFlying ) | |
3167 { | |
3168 if ( v7->pMonsterInfo.uMissleAttack1Type ) | |
3169 v6 = v7->uActorRadius + 512; | |
3170 else | |
3171 v6 = pParty->uPartyHeight; | |
3172 } | |
1052 | 3173 |
0 | 3174 v10 = pDir; |
3175 if ( !pDir ) | |
3176 { | |
1052 | 3177 memcpy(&v16, Actor::GetDirectionInfo(v8, a2, &a3, v6), sizeof(v16)); |
0 | 3178 v10 = &v16; |
3179 } | |
3180 if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
3181 { | |
3182 if ( !uActionLength ) | |
3183 uActionLength = 256; | |
414 | 3184 Actor::AI_StandOrBored(v5, 4, uActionLength, v10); |
322 | 3185 return; |
0 | 3186 } |
3187 if ( (double)(signed int)v10->uDistance < 307.2 ) | |
3188 { | |
3189 if ( !uActionLength ) | |
3190 uActionLength = 256; | |
413 | 3191 Actor::AI_Stand(v5, v18, uActionLength, v10); |
322 | 3192 return; |
0 | 3193 } |
3194 if ( !v7->uMovementSpeed ) | |
322 | 3195 { |
413 | 3196 Actor::AI_Stand(v5, v18, uActionLength, v10); |
322 | 3197 return; |
3198 } | |
0 | 3199 v18 = 16; |
3200 if ( arg0 % 2 ) | |
3201 v18 = -16; | |
1052 | 3202 |
0 | 3203 v7->uYawAngle = stru_5C6E00->Atan2( |
1052 | 3204 pParty->vPosition.x + fixpoint_sub0(stru_5C6E00->Cos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.x, |
3205 pParty->vPosition.y + fixpoint_sub0(stru_5C6E00->Sin(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.y); | |
0 | 3206 if ( uActionLength ) |
3207 v7->uCurrentActionLength = uActionLength; | |
3208 else | |
3209 v7->uCurrentActionLength = 128; | |
3210 v7->uPitchAngle = LOWORD(v10->uPitchAngle); | |
3211 v7->uAIState = Pursuing; | |
322 | 3212 v7->UpdateAnimation(); |
0 | 3213 } |
3214 | |
3215 //----- (00402968) -------------------------------------------------------- | |
1060 | 3216 void Actor::AI_Flee(unsigned int uActorID, signed int sTargetPid, int uActionLength, AIDirection *a4) |
0 | 3217 { |
3218 unsigned int v4; // esi@1 | |
3219 Actor *v5; // ebx@1 | |
322 | 3220 //unsigned int result; // eax@1 |
0 | 3221 int v7; // ecx@2 |
3222 signed __int16 v8; // cx@10 | |
3223 unsigned __int16 v9; // ax@15 | |
3224 AIDirection v10; // [sp+8h] [bp-7Ch]@4 | |
3225 AIDirection a3; // [sp+24h] [bp-60h]@3 | |
3226 AIDirection v12; // [sp+40h] [bp-44h]@3 | |
3227 AIDirection v13; // [sp+5Ch] [bp-28h]@4 | |
3228 signed int a1; // [sp+78h] [bp-Ch]@2 | |
3229 unsigned int v15; // [sp+7Ch] [bp-8h]@1 | |
848 | 3230 //signed int a2; // [sp+80h] [bp-4h]@1 |
0 | 3231 |
3232 v4 = uActorID; | |
848 | 3233 //a2 = edx0; |
0 | 3234 v15 = uActorID; |
3235 v5 = &pActors[uActorID]; | |
322 | 3236 //result = pActors[uActorID].CanAct(); |
3237 if ( pActors[uActorID].CanAct() ) | |
0 | 3238 { |
862 | 3239 v7 = PID(OBJECT_Actor,v4); |
3240 a1 = PID(OBJECT_Actor,v4); | |
0 | 3241 if ( !a4 ) |
3242 { | |
3243 a4 = &v12; | |
848 | 3244 memcpy(&v12, Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying), sizeof(v12)); |
0 | 3245 v7 = a1; |
3246 } | |
3247 memcpy(&a3, Actor::GetDirectionInfo(v7, 4u, &v10, 0), sizeof(a3)); | |
3248 memcpy(&v13, &a3, sizeof(v13)); | |
3249 if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) | |
848 | 3250 || PID_TYPE(sTargetPid) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 ) |
0 | 3251 { |
3252 if ( !uActionLength ) | |
3253 uActionLength = 256; | |
414 | 3254 Actor::AI_StandOrBored(v15, 4, uActionLength, &v13); |
0 | 3255 } |
3256 else | |
3257 { | |
3258 v8 = v5->uMovementSpeed; | |
3259 if ( v8 ) | |
3260 v5->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v8; | |
3261 else | |
3262 v5->uCurrentActionLength = 0; | |
3263 if ( v5->uCurrentActionLength > 256 ) | |
3264 v5->uCurrentActionLength = 256; | |
3265 v5->uYawAngle = LOWORD(stru_5C6E00->uIntegerHalfPi) + LOWORD(a4->uYawAngle); | |
3266 v5->uYawAngle = LOWORD(stru_5C6E00->uDoublePiMask) & (v5->uYawAngle + rand() % (signed int)stru_5C6E00->uIntegerPi); | |
3267 v9 = LOWORD(a4->uPitchAngle); | |
3268 v5->uCurrentActionTime = 0; | |
3269 v5->uPitchAngle = v9; | |
3270 v5->uAIState = Fleeing; | |
322 | 3271 v5->UpdateAnimation(); |
0 | 3272 } |
3273 } | |
3274 } | |
3275 | |
3276 //----- (0040281C) -------------------------------------------------------- | |
1060 | 3277 void Actor::AI_Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5) |
0 | 3278 { |
3279 unsigned int v5; // edi@1 | |
3280 int v6; // eax@1 | |
3281 Actor *v7; // ebx@1 | |
3282 unsigned int v8; // ecx@1 | |
3283 char v9; // zf@1 | |
3284 AIDirection *v10; // esi@7 | |
3285 signed int v11; // edx@12 | |
3286 signed __int16 v13; // cx@19 | |
3287 unsigned __int16 v14; // ax@25 | |
3288 int v15; // [sp-8h] [bp-54h]@12 | |
3289 AIDirection *v16; // [sp-4h] [bp-50h]@12 | |
3290 AIDirection a3; // [sp+Ch] [bp-40h]@8 | |
3291 AIDirection v18; // [sp+28h] [bp-24h]@8 | |
3292 unsigned int v19; // [sp+44h] [bp-8h]@1 | |
3293 unsigned int v20; // [sp+48h] [bp-4h]@1 | |
3294 | |
3295 v5 = uActorID; | |
3296 v6 = 0; | |
3297 v7 = &pActors[uActorID]; | |
3298 v19 = a2; | |
862 | 3299 v8 = PID(OBJECT_Actor,uActorID); |
0 | 3300 v9 = v7->pMonsterInfo.uFlying == 0; |
3301 v20 = v5; | |
3302 if ( !v9 && !pParty->bFlying ) | |
3303 { | |
3304 if ( v7->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
3305 v6 = v7->uActorRadius + 512; | |
3306 else | |
3307 v6 = pParty->uPartyHeight; | |
3308 } | |
3309 v10 = pDir; | |
3310 if ( !pDir ) | |
3311 { | |
3312 memcpy(&v18, Actor::GetDirectionInfo(v8, a2, &a3, v6), sizeof(v18)); | |
3313 memcpy(0, &v18, 0x1Cu); | |
3314 v10 = 0; | |
3315 v5 = v20; | |
3316 } | |
3317 if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
3318 { | |
3319 if ( !uActionLength ) | |
3320 uActionLength = 256; | |
3321 v16 = v10; | |
3322 v15 = uActionLength; | |
3323 v11 = 4; | |
414 | 3324 Actor::AI_StandOrBored(v5, v11, v15, v16); |
322 | 3325 return; |
0 | 3326 } |
3327 if ( (signed int)v10->uDistance < a5 ) | |
3328 { | |
3329 if ( !uActionLength ) | |
3330 uActionLength = 256; | |
3331 v11 = v19; | |
3332 v16 = v10; | |
3333 v15 = uActionLength; | |
414 | 3334 Actor::AI_StandOrBored(v5, v11, v15, v16); |
322 | 3335 return; |
0 | 3336 } |
3337 if ( uActionLength ) | |
3338 { | |
3339 v7->uCurrentActionLength = uActionLength; | |
3340 } | |
3341 else | |
3342 { | |
3343 v13 = v7->uMovementSpeed; | |
3344 if ( v13 ) | |
3345 v7->uCurrentActionLength = (signed int)(v10->uDistanceXZ << 7) / v13; | |
3346 else | |
3347 v7->uCurrentActionLength = 0; | |
3348 if ( v7->uCurrentActionLength > 32 ) | |
3349 v7->uCurrentActionLength = 32; | |
3350 } | |
3351 v7->uYawAngle = LOWORD(v10->uYawAngle); | |
3352 v14 = LOWORD(v10->uPitchAngle); | |
3353 v7->uCurrentActionTime = 0; | |
3354 v7->uPitchAngle = v14; | |
3355 v7->uAIState = Pursuing; | |
322 | 3356 v7->UpdateAnimation(); |
0 | 3357 } |
3358 | |
3359 //----- (00402686) -------------------------------------------------------- | |
1060 | 3360 void Actor::AI_Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4) |
0 | 3361 { |
860 | 3362 //unsigned int v4; // edi@1 |
0 | 3363 int v5; // eax@1 |
3364 Actor *v6; // ebx@1 | |
3365 int v7; // ecx@1 | |
3366 char v8; // zf@1 | |
860 | 3367 //AIDirection *v9; // esi@7 |
0 | 3368 signed int v10; // edx@12 |
3369 signed __int16 v12; // cx@19 | |
3370 int v13; // edx@25 | |
3371 __int16 v14; // ax@25 | |
3372 unsigned __int16 v15; // ax@26 | |
3373 unsigned __int16 v16; // ax@28 | |
3374 int v17; // [sp-8h] [bp-54h]@12 | |
860 | 3375 //AIDirection *v18; // [sp-4h] [bp-50h]@12 |
0 | 3376 AIDirection a3; // [sp+Ch] [bp-40h]@8 |
3377 AIDirection v20; // [sp+28h] [bp-24h]@8 | |
3378 int v21; // [sp+44h] [bp-8h]@1 | |
860 | 3379 //unsigned int v22; // [sp+48h] [bp-4h]@1 |
0 | 3380 |
3381 v5 = 0; | |
3382 v6 = &pActors[uActorID]; | |
3383 v21 = a2; | |
862 | 3384 v7 = PID(OBJECT_Actor,uActorID); |
0 | 3385 v8 = v6->pMonsterInfo.uFlying == 0; |
3386 if ( !v8 && !pParty->bFlying ) | |
3387 { | |
3388 if ( v6->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
3389 v5 = v6->uActorRadius + 512; | |
3390 else | |
3391 v5 = pParty->uPartyHeight; | |
3392 } | |
3393 if ( !a4 ) | |
3394 { | |
3395 memcpy(&v20, Actor::GetDirectionInfo(v7, a2, &a3, v5), sizeof(v20)); | |
3396 } | |
3397 if ( MonsterStats::BelongsToSupertype(v6->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
3398 { | |
3399 if ( !uActionLength ) | |
3400 uActionLength = 256; | |
860 | 3401 return Actor::AI_StandOrBored(uActorID, 4, uActionLength, a4); |
0 | 3402 } |
860 | 3403 if ( (double)(signed int)a4->uDistance < 307.2 ) |
0 | 3404 { |
3405 if ( !uActionLength ) | |
3406 uActionLength = 256; | |
860 | 3407 return Actor::AI_StandOrBored(uActorID, v21, uActionLength, a4); |
0 | 3408 } |
3409 if ( uActionLength ) | |
3410 { | |
3411 v6->uCurrentActionLength = uActionLength + rand() % uActionLength; | |
3412 } | |
3413 else | |
3414 { | |
3415 v12 = v6->uMovementSpeed; | |
3416 if ( v12 ) | |
860 | 3417 v6->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v12; |
0 | 3418 else |
3419 v6->uCurrentActionLength = 0; | |
3420 if ( v6->uCurrentActionLength > 128 ) | |
3421 v6->uCurrentActionLength = 128; | |
3422 } | |
3423 v13 = rand() % 2; | |
860 | 3424 v14 = LOWORD(a4->uYawAngle); |
0 | 3425 if ( v13 ) |
3426 v15 = v14 + 256; | |
3427 else | |
3428 v15 = v14 - 256; | |
3429 v6->uYawAngle = v15; | |
860 | 3430 v16 = LOWORD(a4->uPitchAngle); |
0 | 3431 v6->uCurrentActionTime = 0; |
3432 v6->uPitchAngle = v16; | |
3433 v6->uAIState = Pursuing; | |
3434 if ( rand() % 100 < 2 ) | |
860 | 3435 Actor::PlaySound(uActorID, 2u); |
322 | 3436 v6->UpdateAnimation(); |
0 | 3437 } |
3438 | |
417 | 3439 //----- (00SelectTarget) -------------------------------------------------------- |
3440 void Actor::_SelectTarget(unsigned int uActorID, int *a2, bool can_target_party) | |
0 | 3441 { |
417 | 3442 //Actor *v3; // esi@1 |
3443 //unsigned int v4; // ebx@1 | |
0 | 3444 int v5; // ecx@1 |
417 | 3445 //unsigned int v6; // eax@1 |
3446 //Actor *v7; // edi@2 | |
3447 //__int16 v8; // ax@3 | |
0 | 3448 int v9; // eax@10 |
3449 signed int v10; // eax@13 | |
3450 int v11; // ebx@16 | |
3451 int v12; // eax@16 | |
417 | 3452 //int v13; // eax@25 |
0 | 3453 signed int v14; // eax@31 |
3454 int v15; // edi@43 | |
3455 int v16; // ebx@45 | |
3456 int v17; // eax@45 | |
417 | 3457 //int v18; // eax@51 |
0 | 3458 int v19; // [sp+Ch] [bp-24h]@16 |
417 | 3459 //int *v20; // [sp+10h] [bp-20h]@1 |
0 | 3460 signed int v21; // [sp+14h] [bp-1Ch]@1 |
417 | 3461 //unsigned int v22; // [sp+18h] [bp-18h]@1 |
0 | 3462 int v23; // [sp+1Ch] [bp-14h]@16 |
417 | 3463 //unsigned int v24; // [sp+20h] [bp-10h]@1 |
0 | 3464 int v25; // [sp+24h] [bp-Ch]@1 |
417 | 3465 //signed int v26; // [sp+28h] [bp-8h]@1 |
0 | 3466 int v27; // [sp+2Ch] [bp-4h]@16 |
3467 int v28; // [sp+2Ch] [bp-4h]@45 | |
3468 | |
3469 v25 = -1; | |
417 | 3470 //v22 = uActorID; |
3471 //v3 = &pActors[uActorID]; | |
3472 //v4 = 0; | |
0 | 3473 v5 = 0; |
417 | 3474 //v6 = v3->uLastCharacterIDToHit; |
0 | 3475 *a2 = 0; |
417 | 3476 //v20 = a2; |
0 | 3477 v21 = 0; |
417 | 3478 //v24 = v3->uLastCharacterIDToHit; |
3479 //v26 = 0; | |
3480 assert(uActorID < uNumActors); | |
1202 | 3481 auto _this = &pActors[uActorID]; |
417 | 3482 |
3483 for (uint i = 0; i < uNumActors; ++i) | |
0 | 3484 { |
1202 | 3485 auto actor = &pActors[i]; |
417 | 3486 //v7 = pActors; |
3487 //do | |
3488 //{ | |
3489 //v8 = v7->uAIState; | |
3490 if (actor->uAIState == Dead || actor->uAIState == Dying || | |
3491 actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i ) | |
3492 continue; | |
3493 | |
862 | 3494 if (_this->uLastCharacterIDToHit == 0 || (v9 = 8 * v5, LOBYTE(v9) = PID(OBJECT_Actor,v5), _this->uLastCharacterIDToHit != v9) ) |
245 | 3495 { |
417 | 3496 v10 = _this->GetActorsRelation(actor); |
3497 if ( v10 == 0 ) | |
245 | 3498 continue; |
3499 } | |
417 | 3500 else if (_this->IsNotAlive()) |
245 | 3501 { |
417 | 3502 _this->uLastCharacterIDToHit = 0; |
3503 v10 = _this->GetActorsRelation(actor); | |
3504 if ( v10 == 0 ) | |
245 | 3505 continue; |
3506 } | |
3507 else | |
3508 { | |
417 | 3509 //v18 = actor->uGroup; |
3510 if ( (actor->uGroup != 0 || _this->uGroup != 0) && actor->uGroup == _this->uGroup ) | |
245 | 3511 continue; |
3512 v10 = 4; | |
3513 } | |
417 | 3514 if ( _this->pMonsterInfo.uHostilityType ) |
3515 v10 = pMonsterStats->pInfos[_this->pMonsterInfo.uID].uHostilityType; | |
245 | 3516 v11 = dword_4DF380[v10]; |
417 | 3517 v23 = abs(_this->vPosition.x - actor->vPosition.x); |
3518 v27 = abs(_this->vPosition.y - actor->vPosition.y); | |
3519 v12 = abs(_this->vPosition.z - actor->vPosition.z); | |
245 | 3520 v19 = v12; |
3521 if ( v23 <= v11 | |
3522 && v27 <= v11 | |
3523 && v12 <= v11 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
3524 && sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID)) |
245 | 3525 && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) |
3526 { | |
3527 v25 = v23 * v23 + v27 * v27 + v19 * v19; | |
417 | 3528 v21 = i; |
245 | 3529 } |
417 | 3530 //v4 = 0; |
3531 //++v7; | |
3532 //v5 = v26++ + 1; | |
3533 //} | |
3534 //while ( v26 < (signed int)uNumActors ); | |
3535 | |
0 | 3536 } |
417 | 3537 if ( v25 != -1 ) |
3538 { | |
3539 //v13 = 8 * v21; | |
862 | 3540 //LOBYTE(v13) = PID(OBJECT_Actor,v21); |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
823
diff
changeset
|
3541 *a2 = PID(OBJECT_Actor, v21); |
417 | 3542 } |
3543 | |
3544 if (pParty->Invisible()) | |
3545 can_target_party = false; | |
3546 | |
3547 if (can_target_party) | |
0 | 3548 { |
417 | 3549 v14 = _this->GetActorsRelation(0); |
3550 if ( BYTE2(_this->uAttributes) & 8 | |
3551 && SHIDWORD(_this->pActorBuffs[12].uExpireTime) <= (signed int)0 | |
3552 && (SHIDWORD(_this->pActorBuffs[12].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[12].uExpireTime) <= 0) | |
3553 && SHIDWORD(_this->pActorBuffs[1].uExpireTime) <= (signed int)0 | |
3554 && (SHIDWORD(_this->pActorBuffs[1].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[1].uExpireTime) <= 0) | |
3555 && SHIDWORD(_this->pActorBuffs[2].uExpireTime) <= (signed int)0 | |
3556 && (SHIDWORD(_this->pActorBuffs[2].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[2].uExpireTime) <= 0) ) | |
0 | 3557 v14 = 4; |
417 | 3558 if ( v14 != 0 ) |
0 | 3559 { |
848 | 3560 v15 = dword_4DF380[4]; |
417 | 3561 if ( !_this->pMonsterInfo.uHostilityType ) |
0 | 3562 v15 = dword_4DF380[v14]; |
417 | 3563 v16 = abs(_this->vPosition.x - pParty->vPosition.x); |
3564 v28 = abs(_this->vPosition.y - pParty->vPosition.y); | |
3565 v17 = abs(_this->vPosition.z - pParty->vPosition.z); | |
0 | 3566 if ( v16 <= v15 && v28 <= v15 && v17 <= v15 ) |
3567 { | |
3568 if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 ) | |
417 | 3569 *a2 = OBJECT_Player; |
0 | 3570 } |
3571 } | |
3572 } | |
3573 } | |
3574 // 4DF380: using guessed type int dword_4DF380[]; | |
3575 // 4DF390: using guessed type int dword_4DF390; | |
3576 | |
3577 //----- (0040104C) -------------------------------------------------------- | |
3578 signed int Actor::GetActorsRelation(Actor *a2) | |
3579 { | |
3580 Actor *v2; // esi@1 | |
3581 int v3; // ebp@5 | |
3582 int v4; // edi@11 | |
3583 unsigned int v5; // edx@15 | |
3584 unsigned int v6; // eax@16 | |
3585 unsigned int v7; // ebp@19 | |
3586 int v8; // eax@22 | |
3587 unsigned int v9; // edx@25 | |
3588 unsigned int v10; // edx@33 | |
3589 | |
3590 auto a1 = this; | |
3591 v2 = a2; | |
3592 if ( a1 ) | |
3593 { | |
3594 if ( SHIDWORD(a1->pActorBuffs[9].uExpireTime) >= 0 | |
3595 && (SHIDWORD(a1->pActorBuffs[9].uExpireTime) > 0 || LODWORD(a1->pActorBuffs[9].uExpireTime) > 0) ) | |
3596 return 4; | |
3597 v3 = a1->pMonsterInfo.uID; | |
3598 } | |
3599 else | |
3600 { | |
3601 v3 = 0; | |
3602 } | |
3603 if ( a2 ) | |
3604 { | |
3605 if ( SHIDWORD(a2->pActorBuffs[9].uExpireTime) >= 0 | |
3606 && (SHIDWORD(a2->pActorBuffs[9].uExpireTime) > 0 || LODWORD(a2->pActorBuffs[9].uExpireTime) > 0) ) | |
3607 return 4; | |
3608 v4 = a2->pMonsterInfo.uID; | |
3609 } | |
3610 else | |
3611 { | |
3612 v4 = 0; | |
3613 } | |
3614 if ( a2 ) | |
3615 { | |
3616 if ( a1 ) | |
3617 { | |
3618 v5 = a2->uGroup; | |
3619 if ( v5 ) | |
3620 { | |
3621 v6 = a1->uGroup; | |
3622 if ( v6 ) | |
3623 { | |
3624 if ( v5 == v6 ) | |
3625 return 0; | |
3626 } | |
3627 } | |
3628 } | |
3629 } | |
3630 if ( v3 ) | |
3631 v7 = (v3 - 1) / 3 + 1; | |
3632 else | |
3633 v7 = 0; | |
3634 if ( v4 ) | |
3635 v8 = (v4 - 1) / 3 + 1; | |
3636 else | |
3637 v8 = 0; | |
3638 if ( a1 ) | |
3639 { | |
3640 v9 = a1->uAlly; | |
245 | 3641 if ( (signed int)v9 > 0 ) |
0 | 3642 { |
3643 if ( v9 != 9999 ) | |
3644 { | |
3645 v7 = a1->uAlly; | |
3646 } | |
3647 } | |
245 | 3648 if(v9==9999) |
3649 v7 = 0; | |
0 | 3650 if ( (signed __int64)a1->pActorBuffs[12].uExpireTime > 0 ) |
3651 v7 = 0; | |
3652 } | |
245 | 3653 if ( v2 ) |
0 | 3654 { |
245 | 3655 v10 = v2->uAlly; |
3656 if ( (signed int)v10 > 0 ) | |
3657 { | |
3658 if ( v10 != 9999 ) | |
3659 { | |
3660 v8 = v2->uAlly; | |
3661 } | |
3662 } | |
3663 if(v10==9999) | |
3664 v8 = 0; | |
3665 if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 ) | |
3666 v8 = 0; | |
0 | 3667 } |
3668 if ( a1 && (signed __int64)a1->pActorBuffs[1].uExpireTime > 0 && !v8 | |
3669 || v2 && (signed __int64)v2->pActorBuffs[1].uExpireTime > 0 && !v7 ) | |
3670 return 0; | |
3671 if ( a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && a1->uAttributes & 0x80000 && !v8 ) | |
3672 return 4; | |
3673 if ( v2 && a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && v2->uAttributes & 0x80000 ) | |
3674 { | |
3675 if ( v7 ) | |
245 | 3676 { |
3677 if ( (signed int)v7 < 89 ) | |
3678 { | |
3679 if ( v8 < 89 ) | |
3680 return pFactionTable->relations[v7][v8]; | |
3681 return 0; | |
3682 } | |
3683 return 0; | |
3684 } | |
0 | 3685 return 4; |
3686 } | |
3687 if ( !v7 ) | |
3688 { | |
3689 if ( (!v2 || (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 || !(v2->uAttributes & 0x80000)) | |
100 | 3690 && !pFactionTable->relations[v8][0]) |
0 | 3691 { |
3692 if ( v8 < 89 ) | |
100 | 3693 return pFactionTable->relations[v7][v8]; |
0 | 3694 return 0; |
3695 } | |
3696 return 4; | |
3697 } | |
3698 if ( (signed int)v7 < 89 ) | |
245 | 3699 { |
3700 if ( v8 < 89 ) | |
3701 return pFactionTable->relations[v7][v8]; | |
3702 return 0; | |
3703 } | |
0 | 3704 return 0; |
3705 } | |
3706 | |
3707 //----- (0045976D) -------------------------------------------------------- | |
322 | 3708 void Actor::UpdateAnimation() |
0 | 3709 { |
322 | 3710 //AIState state; // edx@1 |
3711 //unsigned int result; // eax@1 | |
0 | 3712 |
322 | 3713 //state = (AIState)this->; |
3714 uAttributes &= 0xFFDFFFFF; | |
3715 //result = this->uAttributes; | |
3716 switch (uAIState) | |
0 | 3717 { |
3718 case Tethered: | |
322 | 3719 uCurrentActionAnimation = ANIM_Walking; |
3720 break; | |
3721 | |
0 | 3722 case AttackingMelee: |
322 | 3723 uCurrentActionAnimation = ANIM_AtkMelee; |
3724 uAttributes |= 0x200000u; | |
3725 break; | |
3726 | |
0 | 3727 case AttackingRanged1: |
3728 case AttackingRanged2: | |
3729 case AttackingRanged3: | |
3730 case AttackingRanged4: | |
322 | 3731 uCurrentActionAnimation = ANIM_AtkRanged; |
3732 uAttributes |= 0x200000u; | |
3733 break; | |
3734 | |
0 | 3735 case Dying: |
3736 case Resurrected: | |
322 | 3737 uCurrentActionAnimation = ANIM_Dying; |
3738 uAttributes |= 0x200000u; | |
3739 break; | |
3740 | |
0 | 3741 case Pursuing: |
3742 case Fleeing: | |
322 | 3743 uCurrentActionAnimation = ANIM_Walking; |
3744 uAttributes |= 0x200000u; | |
3745 break; | |
3746 | |
0 | 3747 case Stunned: |
322 | 3748 uCurrentActionAnimation = ANIM_GotHit; |
3749 uAttributes |= 0x200000u; | |
3750 break; | |
3751 | |
0 | 3752 case Fidgeting: |
322 | 3753 uCurrentActionAnimation = ANIM_Bored; |
3754 uAttributes |= 0x200000u; | |
3755 break; | |
3756 | |
0 | 3757 case Standing: |
3758 case Interacting: | |
3759 case Summoned: | |
322 | 3760 uCurrentActionAnimation = ANIM_Standing; |
3761 uAttributes |= 0x200000u; | |
3762 break; | |
3763 | |
0 | 3764 case Dead: |
322 | 3765 if (pSpriteFrameTable->pSpriteSFrames[pSpriteIDs[ANIM_Dead]].pHwSpriteIDs[0] <= 0) |
3766 uAIState = Removed; | |
0 | 3767 else |
322 | 3768 uCurrentActionAnimation = ANIM_Dead; |
3769 break; | |
3770 | |
551 | 3771 case Removed: |
652 | 3772 case Disabled: |
551 | 3773 return; |
3774 | |
0 | 3775 default: |
322 | 3776 assert(false); |
0 | 3777 } |
3778 } | |
3779 | |
3780 //----- (00459671) -------------------------------------------------------- | |
3781 void Actor::Reset() | |
3782 { | |
3783 this->pActorName[0] = 0; | |
3784 this->word_000086_some_monster_id = 0; | |
602 | 3785 this->sNPC_ID = 0; |
0 | 3786 this->vPosition.z = 0; |
3787 this->vPosition.y = 0; | |
3788 this->vPosition.x = 0; | |
3789 this->vVelocity.z = 0; | |
3790 this->vVelocity.y = 0; | |
3791 this->vVelocity.x = 0; | |
3792 this->uYawAngle = 0; | |
3793 this->uPitchAngle = 0; | |
3794 this->uAttributes = 0; | |
3795 this->uSectorID = 0; | |
3796 this->uCurrentActionTime = 0; | |
3797 this->vInitialPosition.z = 0; | |
3798 this->vInitialPosition.y = 0; | |
3799 this->vInitialPosition.x = 0; | |
3800 this->vGuardingPosition.z = 0; | |
3801 this->vGuardingPosition.y = 0; | |
3802 this->vGuardingPosition.x = 0; | |
3803 this->uTetherDistance = 256; | |
3804 this->uActorRadius = 32; | |
3805 this->uActorHeight = 128; | |
3806 this->uAIState = Standing; | |
305 | 3807 this->uCurrentActionAnimation = ANIM_Standing; |
0 | 3808 this->uMovementSpeed = 200; |
3809 this->uCarriedItemID = 0; | |
3810 this->uGroup = 0; | |
3811 this->uAlly = 0; | |
3812 this->uSummonerID = 0; | |
3813 this->uLastCharacterIDToHit = 0; | |
3814 this->dword_000334_unique_name = 0; | |
3815 memset(this->pSpriteIDs, 0, sizeof(pSpriteIDs)); | |
3816 memset(this->pActorBuffs, 0, 0x160u); | |
3817 } | |
3818 | |
3819 //----- (0045959A) -------------------------------------------------------- | |
3820 void Actor::PrepareSprites(char load_sounds_if_bit1_set) | |
3821 { | |
694 | 3822 |
3823 MonsterDesc *v3; // esi@1 | |
0 | 3824 MonsterInfo *v9; // [sp+84h] [bp-10h]@1 |
694 | 3825 |
0 | 3826 v3 = &pMonsterList->pMonsters[pMonsterInfo.uID - 1]; |
3827 v9 = &pMonsterStats->pInfos[pMonsterInfo.uID - 1 + 1]; | |
3828 //v12 = pSpriteIDs; | |
3829 //Source = (char *)v3->pSpriteNames; | |
3830 //do | |
3831 for (uint i = 0; i < 8; ++i) | |
3832 { | |
3833 //strcpy(pSpriteName, v3->pSpriteNames[i]); | |
3834 pSpriteIDs[i] = pSpriteFrameTable->FastFindSprite(v3->pSpriteNames[i]); | |
3835 pSpriteFrameTable->InitializeSprite(pSpriteIDs[i]); | |
3836 } | |
3837 uActorHeight = v3->uMonsterHeight; | |
3838 uActorRadius = v3->uMonsterRadius; | |
33 | 3839 uMovementSpeed = v9->uBaseSpeed; |
0 | 3840 if ( !(load_sounds_if_bit1_set & 1) ) |
3841 { | |
694 | 3842 for (int i=0;i<4;++i ) |
3843 pSoundSampleIDs[i]=v3->pSoundSampleIDs[i]; | |
0 | 3844 } |
3845 } | |
3846 | |
3847 //----- (00459667) -------------------------------------------------------- | |
3848 void Actor::Remove() | |
3849 { | |
3850 this->uAIState = Removed; | |
3851 } | |
3852 | |
3853 //----- (0044FD29) -------------------------------------------------------- | |
3854 int Actor::_44FD29(int a2) | |
3855 { | |
3856 Actor *v2; // edi@1 | |
3857 unsigned __int8 v3; // al@1 | |
3858 int v4; // esi@1 | |
3859 int v5; // edx@2 | |
3860 int v6; // eax@8 | |
3861 int v7; // edi@10 | |
3862 Actor *v8; // esi@10 | |
3863 MonsterInfo *v9; // ebx@10 | |
3864 MonsterDesc *v10; // edi@10 | |
3865 unsigned __int16 v11; // ax@10 | |
3866 int v12; // eax@10 | |
3867 int v13; // ebx@10 | |
3868 int v14; // eax@10 | |
3869 int v15; // edi@10 | |
3870 int v16; // eax@10 | |
3871 int v17; // ebx@10 | |
3872 Actor *v18; // ecx@10 | |
3873 signed __int64 v19; // qax@10 | |
3874 unsigned int v20; // eax@12 | |
3875 int v21; // eax@13 | |
3876 int result; // eax@13 | |
3877 Actor *v23; // eax@16 | |
3878 int v24; // [sp+Ch] [bp-1Ch]@1 | |
3879 unsigned int uFaceID; // [sp+10h] [bp-18h]@8 | |
3880 int v26; // [sp+14h] [bp-14h]@10 | |
3881 int v27; // [sp+18h] [bp-10h]@10 | |
3882 int v28; // [sp+1Ch] [bp-Ch]@8 | |
3883 int v29; // [sp+20h] [bp-8h]@10 | |
3884 Actor *v30; // [sp+24h] [bp-4h]@1 | |
3885 | |
3886 v2 = this; | |
3887 v24 = a2; | |
3888 v30 = this; | |
3889 v3 = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls; | |
3890 v4 = this->pMonsterInfo.field_3C_some_special_attack; | |
3891 if ( v3 ) | |
3892 { | |
3893 if ( v3 >= 1u && v3 <= 3u ) | |
3894 v4 = v4 + v3 - 1; | |
3895 } | |
3896 else | |
3897 { | |
3898 v5 = rand() % 100; | |
3899 if ( v5 >= 60 ) | |
3900 { | |
3901 ++v4; | |
3902 if ( v5 >= 90 ) | |
3903 ++v4; | |
3904 } | |
3905 } | |
3906 v6 = v2->vPosition.z; | |
3907 v28 = 0; | |
3908 uFaceID = v6; | |
3909 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
3910 v28 = pIndoor->GetSector(v2->vPosition.x, v2->vPosition.y, v6); | |
3911 v7 = v4 - 1; | |
3912 v8 = &pActors[uNumActors]; | |
3913 v27 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; | |
3914 v29 = v7; | |
3915 v9 = &pMonsterStats->pInfos[v7 + 1]; | |
3916 pActors[uNumActors].Reset(); | |
3917 v10 = &pMonsterList->pMonsters[v7]; | |
3918 strcpy(v8->pActorName, v9->pName); | |
3919 v8->sCurrentHP = LOWORD(v9->uHP); | |
3920 memcpy(&v8->pMonsterInfo, v9, 0x58u); | |
3921 v8->word_000086_some_monster_id = v29 + 1; | |
3922 v8->uActorRadius = v10->uMonsterRadius; | |
3923 v8->uActorHeight = v10->uMonsterHeight; | |
3924 v11 = v10->uMovementSpeed; | |
3925 v8->pMonsterInfo.uTreasureDiceRolls = 0; | |
3926 v8->pMonsterInfo.uTreasureType = 0; | |
3927 v8->pMonsterInfo.uExp = 0; | |
3928 v8->uMovementSpeed = v11; | |
3929 v12 = rand(); | |
3930 v13 = v12 % 2048; | |
323 | 3931 v14 = stru_5C6E00->Cos(v12 % 2048); |
0 | 3932 v26 = v14; |
3933 v15 = ((unsigned __int64)(v14 * (signed __int64)v27) >> 16) + v30->vPosition.x; | |
323 | 3934 v16 = stru_5C6E00->Sin(v13); |
0 | 3935 v26 = v16; |
3936 v29 = (unsigned __int64)(v16 * (signed __int64)v27) >> 16; | |
3937 LOWORD(v16) = uFaceID; | |
3938 v17 = v29 + v30->vPosition.y; | |
3939 v8->vInitialPosition.z = uFaceID; | |
3940 v8->vPosition.z = v16; | |
3941 LOWORD(v16) = v28; | |
3942 v8->vInitialPosition.x = v15; | |
3943 v8->vPosition.x = v15; | |
3944 v8->vInitialPosition.y = v17; | |
3945 v8->vPosition.y = v17; | |
3946 v8->uTetherDistance = 256; | |
3947 v8->uSectorID = v16; | |
3948 v8->PrepareSprites(0); | |
3949 v18 = v30; | |
3950 v8->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
3951 LODWORD(v19) = v18->uAlly; | |
3952 if ( !(uint)v19 ) | |
3953 { | |
3954 uFaceID = v18->pMonsterInfo.uID - 1; | |
3955 v19 = (signed __int64)((double)uFaceID * 0.33333334); | |
3956 v18 = v30; | |
3957 } | |
3958 v8->uAlly = v19; | |
3959 v20 = v18->uGroup; | |
3960 v8->uCurrentActionTime = 0; | |
3961 v8->uGroup = v20; | |
3962 v8->uAIState = Summoned; | |
3963 v8->uCurrentActionLength = 256; | |
3964 v8->UpdateAnimation(); | |
3965 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor | |
3966 || (v21 = v30->vPosition.z, | |
3967 v27 = v30->vPosition.z, | |
3968 result = pIndoor->GetSector(v15, v17, v21), | |
3969 result == v28) | |
723 | 3970 && (result = BLV_GetFloorLevel(v15, v17, v27, result, &uFaceID), result != -30000) |
0 | 3971 && (result = abs(result - v27), result <= 1024) ) |
3972 { | |
3973 v23 = v30; | |
3974 ++uNumActors; | |
3975 ++v23->pMonsterInfo.uSpecialAbilityDamageDiceBonus; | |
3976 if ( v23->uAttributes & 0x80000 ) | |
3977 v8->uAttributes |= 0x80000u; | |
3978 result = 8 * v24; | |
862 | 3979 LOBYTE(result) = PID(OBJECT_Actor,v24); |
0 | 3980 v8->uSummonerID = result; |
3981 } | |
3982 return result; | |
781 | 3983 } |
1295 | 3984 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); |
3985 //----- (0046DF1A) -------------------------------------------------------- | |
3986 signed int __fastcall _46DF1A_collide_against_actor(int a1, int a2) | |
3987 { | |
3988 Actor *v2; // edi@1 | |
3989 unsigned __int16 v3; // ax@1 | |
3990 int v4; // esi@6 | |
3991 int v5; // ecx@8 | |
3992 int v6; // eax@10 | |
3993 int v7; // edx@12 | |
3994 int v8; // ecx@14 | |
3995 int v9; // eax@14 | |
3996 int v10; // ebx@14 | |
3997 int v11; // esi@14 | |
3998 int v12; // ebx@15 | |
3999 int v13; // ebx@17 | |
4000 unsigned int v14; // eax@20 | |
4001 signed int result; // eax@21 | |
4002 int v16; // [sp+Ch] [bp-10h]@1 | |
4003 int v17; // [sp+10h] [bp-Ch]@14 | |
4004 int v18; // [sp+14h] [bp-8h]@14 | |
4005 int v19; // [sp+18h] [bp-4h]@14 | |
4006 | |
4007 v16 = a1; | |
4008 v2 = &pActors[a1]; | |
4009 v3 = v2->uAIState; | |
4010 if ( v3 == 11 || v3 == 4 || v3 == 19 || v3 == 5 || v3 == 17 ) | |
4011 goto LABEL_25; | |
4012 v4 = v2->uActorRadius; | |
4013 if ( a2 ) | |
4014 v4 = a2; | |
4015 v5 = v2->vPosition.x; | |
4016 if ( stru_721530.sMaxX > v5 + v4 | |
4017 || stru_721530.sMinX < v5 - v4 | |
4018 || (v6 = v2->vPosition.y, stru_721530.sMaxY > v6 + v4) | |
4019 || stru_721530.sMinY < v6 - v4 | |
4020 || (v7 = v2->vPosition.z, stru_721530.sMaxZ > v7 + v2->uActorHeight) | |
4021 || stru_721530.sMinZ < v7 | |
4022 || (v8 = v5 - stru_721530.normal.x, | |
4023 v9 = v6 - stru_721530.normal.y, | |
4024 v10 = stru_721530.prolly_normal_d + v4, | |
4025 v17 = stru_721530.prolly_normal_d + v4, | |
4026 v11 = (v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16, | |
4027 v18 = v8, | |
4028 v19 = v9, | |
4029 abs((v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16) > v10) | |
4030 || (v12 = (v18 * stru_721530.field_58.x + v19 * stru_721530.field_58.y) >> 16, v12 <= 0) | |
4031 || (signed int)(((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v12) >> 16) + stru_721530.normal.z) < v2->vPosition.z ) | |
4032 { | |
4033 LABEL_25: | |
4034 result = 0; | |
4035 } | |
4036 else | |
4037 { | |
4038 v13 = v12 - integer_sqrt(v17 * v17 - v11 * v11); | |
4039 if ( v13 < 0 ) | |
4040 v13 = 0; | |
4041 if ( v13 < stru_721530.field_7C ) | |
4042 { | |
4043 stru_721530.field_7C = v13; | |
4044 v14 = 8 * v16; | |
4045 LOBYTE(v14) = PID(OBJECT_Actor,v16); | |
4046 stru_721530.uFaceID = v14; | |
4047 } | |
4048 result = 1; | |
4049 } | |
4050 return result; | |
4051 } | |
4052 //----- (00401A91) -------------------------------------------------------- | |
4053 void __cdecl UpdateActorAI() | |
4054 { | |
4055 //unsigned int v0; // esi@4 | |
4056 int v1; // eax@7 | |
4057 //int v2; // ecx@7 | |
4058 //int v3; // eax@7 | |
4059 signed int v4; // edi@10 | |
4060 Actor *v5; // esi@12 | |
4061 signed int sDmg; // eax@14 | |
4062 __int16 v7; // cx@14 | |
4063 //Player **v8; // esi@20 | |
4064 Player *pPlayer; // ecx@21 | |
4065 Actor *pActor; // esi@34 | |
4066 //__int16 v11; // ax@34 | |
4067 //unsigned int v12; // eax@47 | |
4068 //signed int v13; // edi@47 | |
4069 //SpellBuff *v14; // ebx@47 | |
4070 //unsigned int v15; // edi@67 | |
4071 //char *v16; // eax@67 | |
4072 //unsigned int v17; // edx@67 | |
4073 //unsigned int v18; // ecx@67 | |
4074 //unsigned __int16 v19; // ax@72 | |
4075 //int *v20; // esi@80 | |
4076 //Actor *v21; // ebx@80 | |
4077 unsigned __int16 v22; // ax@86 | |
4078 //signed int v23; // eax@94 | |
4079 //unsigned int v24; // eax@102 | |
4080 //signed int v25; // edi@102 | |
4081 //SpellBuff *v26; // esi@102 | |
4082 unsigned int v27; // ecx@123 | |
4083 unsigned int v28; // eax@123 | |
4084 //unsigned int v29; // eax@127 | |
4085 AIDirection *v30; // eax@129 | |
4086 unsigned __int16 v31; // ax@132 | |
4087 //unsigned int v32; // esi@142 | |
4088 int v33; // eax@144 | |
4089 int v34; // eax@147 | |
4090 char v35; // al@150 | |
4091 unsigned int v36; // edi@152 | |
4092 signed int v37; // eax@154 | |
4093 //unsigned __int8 v38; // sf@158 | |
4094 //unsigned __int8 v39; // of@158 | |
4095 //signed int v40; // edx@166 | |
4096 //unsigned int v41; // ecx@166 | |
4097 double v42; // st7@176 | |
4098 double v43; // st6@176 | |
4099 //bool v44; // eax@189 | |
4100 bool v45; // eax@192 | |
4101 unsigned __int8 v46; // cl@197 | |
4102 double v47; // st7@206 | |
4103 //double v48; // st7@207 | |
4104 //char v49; // zf@208 | |
4105 //char v50; // zf@214 | |
4106 //signed int v51; // edx@219 | |
4107 //unsigned int v52; // ecx@219 | |
4108 __int16 v53; // fps@224 | |
4109 //unsigned __int8 v54; // c0@224 | |
4110 //unsigned __int8 v55; // c3@224 | |
4111 //double v56; // st7@226 | |
4112 AIDirection *v57; // eax@246 | |
4113 double v58; // st7@246 | |
4114 //signed int v59; // [sp-18h] [bp-C8h]@213 | |
4115 //int v60; // [sp-14h] [bp-C4h]@144 | |
4116 //int v61; // [sp-14h] [bp-C4h]@168 | |
4117 //AIDirection *v62; // [sp-14h] [bp-C4h]@213 | |
4118 //signed int v63; // [sp-14h] [bp-C4h]@216 | |
4119 unsigned int v64; // [sp-14h] [bp-C4h]@219 | |
4120 unsigned int v65; // [sp-10h] [bp-C0h]@144 | |
4121 char v66; // [sp-10h] [bp-C0h]@147 | |
4122 //AIDirection *v67; // [sp-10h] [bp-C0h]@167 | |
4123 //int v68; // [sp-10h] [bp-C0h]@168 | |
4124 //AIDirection *v69; // [sp-10h] [bp-C0h]@206 | |
4125 int v70; // [sp-10h] [bp-C0h]@213 | |
4126 //AIDirection *v71; // [sp-10h] [bp-C0h]@216 | |
4127 AIDirection v72; // [sp+0h] [bp-B0h]@246 | |
4128 AIDirection a3; // [sp+1Ch] [bp-94h]@129 | |
4129 AIDirection v74; // [sp+38h] [bp-78h]@246 | |
4130 AIDirection v75; // [sp+54h] [bp-5Ch]@129 | |
4131 int target_pid_type; // [sp+70h] [bp-40h]@83 | |
4132 signed int a1; // [sp+74h] [bp-3Ch]@129 | |
4133 int v78; // [sp+78h] [bp-38h]@79 | |
4134 AIDirection pDir; // [sp+7Ch] [bp-34h]@129 | |
4135 float v80; // [sp+98h] [bp-18h]@33 | |
4136 int v81; // [sp+9Ch] [bp-14h]@100 | |
4137 //int v82; // [sp+A0h] [bp-10h]@45 | |
4138 //unsigned int uActorID; // [sp+A4h] [bp-Ch]@32 | |
4139 unsigned int v84; // [sp+A8h] [bp-8h]@11 | |
4140 signed int target_pid; // [sp+ACh] [bp-4h]@83 | |
4141 AIState uAIState; | |
4142 int v38; | |
4143 | |
4144 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
4145 MakeActorAIList_ODM(); | |
4146 else | |
4147 MakeActorAIList_BLV(); | |
4148 | |
4149 //v0 = 0; | |
4150 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) | |
4151 { | |
4152 if ( pParty->armageddon_timer > 417 ) | |
4153 { | |
4154 pParty->armageddon_timer = 0; | |
4155 } | |
4156 else | |
4157 { | |
4158 pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8); | |
4159 pParty->sRotationX = pParty->sRotationX + rand() % 16 - 8; | |
4160 if ( pParty->sRotationX > 128) | |
4161 pParty->sRotationX = 128; | |
4162 else if ( pParty->sRotationX < -128 ) | |
4163 pParty->sRotationX = -128; | |
4164 | |
4165 pParty->uFlags |= 2u; | |
4166 pParty->armageddon_timer -= pMiscTimer->uTimeElapsed; | |
4167 v4 = pParty->field_16140 + 50; | |
4168 if ( pParty->armageddon_timer <= 0 ) | |
4169 { | |
4170 pParty->armageddon_timer = 0; | |
4171 for(int i = 0; i < uNumActors; i++) | |
4172 { | |
4173 pActor=&pActors[i]; | |
4174 if ( pActor->CanAct() ) | |
4175 { | |
4176 sDmg = stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4); | |
4177 pActor->sCurrentHP -= stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4); | |
4178 if ( sDmg ) | |
4179 { | |
4180 if ( pActor->sCurrentHP >= 0 ) | |
4181 { | |
4182 Actor::AI_Stun(i, 4, 0); | |
4183 } | |
4184 else | |
4185 { | |
4186 Actor::Die(i); | |
4187 if ( pActor->pMonsterInfo.uExp ) | |
4188 GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp); | |
4189 } | |
4190 } | |
4191 } | |
4192 } | |
4193 for(int i = 1; i <= 4; i++) | |
4194 { | |
4195 pPlayer = pPlayers[i]; | |
4196 if ( !pPlayer->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] ) | |
4197 pPlayer->ReceiveDamage(v4, DMGT_5); | |
4198 } | |
4199 } | |
4200 if (pTurnEngine->field_1C) | |
4201 --pTurnEngine->field_1C; | |
4202 } | |
4203 } | |
4204 | |
4205 if (pParty->bTurnBasedModeOn) | |
4206 { | |
4207 pTurnEngine->_405E14(); | |
4208 return; | |
4209 } | |
4210 | |
4211 | |
4212 //uActorID = v0; | |
4213 for (uint i = 0; i < uNumActors; ++i) | |
4214 { | |
4215 pActor = &pActors[i]; | |
4216 //LODWORD(v80) = (int)(char *)pActors + 176; // uAIState | |
4217 //do | |
4218 //{ | |
4219 //pActor = (Actor *)(LODWORD(v80) - 176); | |
4220 //v11 = *(unsigned int *)LODWORD(v80); | |
4221 //v49 = *(unsigned int *)LODWORD(v80) == 5; | |
4222 ai_near_actors_targets_pid[i] = OBJECT_Player; | |
4223 if (pActor->uAIState == Dead || pActor->uAIState == Removed || pActor->uAIState == Disabled || pActor->uAttributes & 0x0400) | |
4224 continue; | |
4225 | |
4226 if (!pActor->sCurrentHP && pActor->uAIState != Dying) | |
4227 Actor::Die(i); | |
4228 | |
4229 //v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1; | |
4230 //v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1; | |
4231 //v12 = 0; | |
4232 //v13 = 0; | |
4233 //v14 = (SpellBuff *)(LODWORD(v80) + 36); | |
4234 for (uint j = 0; j < 22; ++j) | |
4235 { | |
4236 if (j != 10) | |
4237 pActor->pActorBuffs[j]._4585CA(pParty->uTimePlayed); | |
4238 } | |
4239 /*do | |
4240 { | |
4241 if ( v13 != 10 ) | |
4242 { | |
4243 v14->_4585CA(pParty->uTimePlayed); | |
4244 v12 = 0; | |
4245 } | |
4246 ++v13; | |
4247 ++v14; | |
4248 } | |
4249 while ( v13 < 22 );*/ | |
4250 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) | |
4251 //&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12 | |
4252 // || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) ) | |
4253 pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight; | |
4254 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) | |
4255 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
4256 // not sure | |
4257 else if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) | |
4258 pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType; | |
4259 | |
4260 if ((signed __int64)pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 | |
4261 || (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0) | |
4262 continue; | |
4263 | |
4264 //v15 = pMiscTimer->uTimeElapsed; | |
4265 //v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime; | |
4266 //v17 = pActor->uCurrentActionTime; | |
4267 //v18 = pActor->pMonsterInfo.uRecoveryTime; | |
4268 if (pActor->pMonsterInfo.uRecoveryTime) | |
4269 { | |
4270 if (pActor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed) | |
4271 pActor->pMonsterInfo.uRecoveryTime = 0; | |
4272 else | |
4273 pActor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed; | |
4274 } | |
4275 | |
4276 pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed; | |
4277 if (pActor->uCurrentActionTime < pActor->uCurrentActionLength) | |
4278 continue; | |
4279 | |
4280 //v19 = actor->uAIState; | |
4281 if (pActor->uAIState == Dying) | |
4282 pActor->uAIState = Dead; | |
4283 else | |
4284 { | |
4285 if (pActor->uAIState != Summoned) | |
4286 { | |
4287 Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr); | |
4288 continue; | |
4289 } | |
4290 pActor->uAIState = Standing; | |
4291 } | |
4292 | |
4293 pActor->uCurrentActionTime = 0; | |
4294 pActor->uCurrentActionLength = 0; | |
4295 pActor->UpdateAnimation(); | |
4296 //LABEL_78: | |
4297 //++uActorID; | |
4298 //LODWORD(v80) += 836; | |
4299 //} | |
4300 //while ( (signed int)uActorID < (signed int)uNumActors ); | |
4301 } | |
4302 | |
4303 | |
4304 v78 = 0; | |
4305 int actor_id = -1; | |
4306 if ( ai_arrays_size > 0 ) | |
4307 { | |
4308 //while ( 1 ) | |
4309 for(v78 = 0; v78 < ai_arrays_size; ++v78) | |
4310 { | |
4311 actor_id = ai_near_actors_ids[v78]; | |
4312 assert(actor_id < uNumActors); | |
4313 | |
4314 //v20 = &ai_near_actors_targets_pid[actor_id]; | |
4315 pActor = &pActors[actor_id]; | |
4316 Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); | |
4317 if (pActor->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) | |
4318 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
4319 target_pid = ai_near_actors_targets_pid[actor_id]; | |
4320 target_pid_type = PID_TYPE(target_pid); | |
4321 if ( target_pid_type == OBJECT_Actor) | |
4322 v80 = 0.5; | |
4323 else | |
4324 v80 = 1.0; | |
4325 v22 = pActor->uAIState; | |
4326 if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned) | |
4327 { | |
4328 continue; | |
4329 } | |
4330 if ( !pActor->sCurrentHP ) | |
4331 Actor::Die(actor_id); | |
4332 for(int i=0;i<22;i++) | |
4333 { | |
4334 if ( i != 10 ) | |
4335 { | |
4336 pActor->pActorBuffs[i]._4585CA(pParty->uTimePlayed); | |
4337 } | |
4338 } | |
4339 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) | |
4340 pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight; | |
4341 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) | |
4342 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
4343 // not sure | |
4344 else if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) | |
4345 pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType; | |
4346 if ( (signed __int64)pActor->pActorBuffs[2].uExpireTime < 0 ) | |
4347 { | |
4348 pActor->uAIState = Removed; | |
4349 continue; | |
4350 } | |
4351 if ( (signed __int64)pActor->pActorBuffs[5].uExpireTime > 0 | |
4352 || (signed __int64)pActor->pActorBuffs[6].uExpireTime > 0) | |
4353 { | |
4354 continue; | |
4355 } | |
4356 v27 = pMiscTimer->uTimeElapsed; | |
4357 v28 = pActor->pMonsterInfo.uRecoveryTime; | |
4358 pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed; | |
4359 if ( (signed int)v28 > 0 ) | |
4360 pActor->pMonsterInfo.uRecoveryTime = v28 - v27; | |
4361 if ( pActor->pMonsterInfo.uRecoveryTime < 0 ) | |
4362 pActor->pMonsterInfo.uRecoveryTime = 0; | |
4363 if ( !(pActor->uAttributes & 0x8000) ) | |
4364 pActor->uAttributes |= 0x8000; | |
4365 a1 = PID(OBJECT_Actor,actor_id); | |
4366 v30 = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0); | |
4367 memcpy(&v75, v30, sizeof(v75)); | |
4368 memcpy(&pDir, &v75, sizeof(pDir)); | |
4369 uAIState = pActor->uAIState; | |
4370 /*if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Friendly | |
4371 && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 | |
4372 && v80 * 307.2 >= (double)(signed int)v75.uDistance | |
4373 && (uAIState == Pursuing || uAIState == Standing || uAIState == Tethered || uAIState == Fidgeting) | |
4374 || ( v21->pMonsterInfo.uMissleAttack1Type && uAIState == Stunned ) ) | |
4375 { | |
4376 v32 = actor_id; | |
4377 } | |
4378 else | |
4379 */ | |
4380 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly | |
4381 || (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 | |
4382 || v80 * 307.2 < (double)(signed int)v75.uDistance | |
4383 || uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting | |
4384 && !pActor->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned ) | |
4385 { | |
4386 if ( (signed int)pActor->uCurrentActionTime < pActor->uCurrentActionLength ) | |
4387 { | |
4388 continue; | |
4389 } | |
4390 else if ( pActor->uAIState == AttackingMelee ) | |
4391 { | |
4392 v35 = stru_50C198.special_ability_use_check(pActor, actor_id); | |
4393 stru_50FE08.Add( | |
4394 a1, | |
4395 5120, | |
4396 pActor->vPosition.x, | |
4397 pActor->vPosition.y, | |
4398 pActor->vPosition.z + ((signed int)pActor->uActorHeight >> 1), | |
4399 v35, | |
4400 1 | |
4401 ); | |
4402 } | |
4403 else if ( pActor->uAIState == AttackingRanged1 ) | |
4404 { | |
4405 v34 = pActor->pMonsterInfo.uMissleAttack1Type; | |
4406 Actor::AI_RangedAttack(actor_id, &pDir, v34, 0); | |
4407 } | |
4408 else if ( pActor->uAIState == AttackingRanged2 ) | |
4409 { | |
4410 v34 = pActor->pMonsterInfo.uMissleAttack2Type; | |
4411 Actor::AI_RangedAttack(actor_id, &pDir, v34, 1); | |
4412 } | |
4413 else if ( pActor->uAIState == AttackingRanged3 ) | |
4414 { | |
4415 v65 = pActor->pMonsterInfo.uSpellSkillAndMastery1; | |
4416 v33 = pActor->pMonsterInfo.uSpell1ID; | |
4417 Actor::AI_SpellAttack(actor_id, &pDir, v33, 2, v65); | |
4418 } | |
4419 else if ( pActor->uAIState == AttackingRanged4 ) | |
4420 { | |
4421 v65 = pActor->pMonsterInfo.uSpellSkillAndMastery2; | |
4422 v33 = pActor->pMonsterInfo.uSpell2ID; | |
4423 Actor::AI_SpellAttack(actor_id, &pDir, v33, 3, v65); | |
4424 } | |
4425 } | |
4426 | |
4427 v36 = v75.uDistance; | |
4428 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly) | |
4429 { | |
4430 if ( target_pid_type == OBJECT_Actor ) | |
4431 { | |
4432 v36 = v75.uDistance; | |
4433 //v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (pActor->pMonsterInfo.uID - 1) / 3] | |
4434 // + (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3); | |
4435 v37 =pFactionTable->relations[(pActor->pMonsterInfo.uID-1) / 3 + 1][(pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3 + 1]; | |
4436 } | |
4437 else | |
4438 { | |
4439 v37 = 4; | |
4440 } | |
4441 v38=0; | |
4442 if ( v37 == 2 ) | |
4443 { | |
4444 //v39 = __OFSUB__(v36, 1024); | |
4445 //v38 = ((v36 - 1024) & 0x80000000u) != 0; | |
4446 v38 = 1024; | |
4447 } | |
4448 else if ( v37 == 3 ) | |
4449 { | |
4450 //v39 = __OFSUB__(v36, 2560); | |
4451 //v38 = ((v36 - 2560) & 0x80000000u) != 0; | |
4452 v38 = 2560; | |
4453 } | |
4454 else if ( v37 == 4 ) | |
4455 { | |
4456 //v39 = __OFSUB__(v36, 5120); | |
4457 //v38 = ((v36 - 5120) & 0x80000000u) != 0; | |
4458 v38 = 5120; | |
4459 } | |
4460 if ( v37 >= 1 && v37 <= 4 && v36 < v38 || v37 == 1 ) | |
4461 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; | |
4462 } | |
4463 | |
4464 if ( (signed __int64)pActor->pActorBuffs[4].uExpireTime > 0 ) | |
4465 { | |
4466 if ( (signed int)v36 >= 10240 ) | |
4467 { | |
4468 Actor::AI_4032B2(actor_id, target_pid, 1024, 0); | |
4469 } | |
4470 else | |
4471 { | |
4472 //peasents after attacked | |
4473 //guard after attacked | |
4474 Actor::AI_Flee(actor_id, target_pid, 0, &pDir); | |
4475 } | |
4476 continue; | |
4477 } | |
4478 | |
4479 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid ) | |
4480 { | |
4481 | |
4482 if ( pActor->pMonsterInfo.uAIType == 1 ) | |
4483 { | |
4484 if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4485 { | |
4486 Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333), &pDir); | |
4487 } | |
4488 else | |
4489 { | |
4490 Actor::AI_Flee(actor_id, target_pid, 0, &pDir); | |
4491 continue; | |
4492 } | |
4493 | |
4494 } | |
4495 if ( !(pActor->uAttributes & 0x020000) ) | |
4496 { | |
4497 if ( pActor->pMonsterInfo.uAIType == 2 || pActor->pMonsterInfo.uAIType == 3) | |
4498 { | |
4499 if ( pActor->pMonsterInfo.uAIType == 2 ) | |
4500 v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.2; | |
4501 if ( pActor->pMonsterInfo.uAIType == 3 ) | |
4502 v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.1; | |
4503 v84 = pActor->sCurrentHP; | |
4504 v42 = (double)(signed int)v84; | |
4505 if ( v43 > v42 && (signed int)v36 < 10240 ) | |
4506 { | |
4507 Actor::AI_Flee(actor_id, target_pid, 0, &pDir); | |
4508 continue; | |
4509 } | |
4510 } | |
4511 } | |
4512 | |
4513 v81 = v36 - pActor->uActorRadius; | |
4514 if ( target_pid_type == OBJECT_Actor ) | |
4515 v81 -= pActors[PID_ID(target_pid)].uActorRadius; | |
4516 if ( v81 < 0 ) | |
4517 v81 = 0; | |
4518 rand(); | |
4519 pActor->uAttributes &= 0xFFFBFFFF; | |
4520 if ( v81 < 5120 ) | |
4521 { | |
4522 v45 = stru_50C198.special_ability_use_check(pActor, actor_id); | |
4523 if ( v45 == 0 ) | |
4524 { | |
4525 if ( pActor->pMonsterInfo.uMissleAttack1Type ) | |
4526 { | |
4527 if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 ) | |
4528 { | |
4529 Actor::AI_MissileAttack1(actor_id, target_pid, &pDir); | |
4530 } | |
4531 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4532 { | |
4533 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4534 v64 = (signed __int64)v47; | |
4535 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4536 } | |
4537 else | |
4538 { | |
4539 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4540 if ( v80 * 307.2 > (double)v81 ) | |
4541 { | |
4542 v64 = (signed __int64)v47; | |
4543 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4544 } | |
4545 else | |
4546 { | |
4547 Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); | |
4548 } | |
4549 } | |
4550 } | |
4551 else | |
4552 { | |
4553 if ( (double)v81 >= v80 * 307.2 ) | |
4554 { | |
4555 if ( v81 >= 1024 ) | |
4556 { | |
4557 if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4558 { | |
4559 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4560 v64 = (signed __int64)v47; | |
4561 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4562 } | |
4563 else | |
4564 { | |
4565 //monsters | |
4566 Actor::AI_Pursue3(actor_id, target_pid, 0, &pDir); | |
4567 } | |
4568 } | |
4569 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4570 { | |
4571 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4572 v64 = (signed __int64)v47; | |
4573 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4574 } | |
4575 else | |
4576 { | |
4577 v70 = (signed __int64)v80 * 307.2; | |
4578 //monsters | |
4579 //guard after player runs away | |
4580 // follow player | |
4581 Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70); | |
4582 } | |
4583 } | |
4584 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
4585 { | |
4586 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4587 v64 = (signed __int64)v47; | |
4588 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4589 } | |
4590 else | |
4591 { | |
4592 //monsters | |
4593 Actor::AI_MeleeAttack(actor_id, target_pid, &pDir); | |
4594 } | |
4595 } | |
4596 continue; | |
4597 } | |
4598 else if ( v45 == 2 || v45 == 3 ) | |
4599 { | |
4600 if ( v45 == 2 ) | |
4601 v46 = pActor->pMonsterInfo.uSpell1ID; | |
4602 else | |
4603 v46 = pActor->pMonsterInfo.uSpell2ID; | |
4604 if ( v46 ) | |
4605 { | |
4606 if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 ) | |
4607 { | |
4608 if ( v45 == 2 ) | |
4609 Actor::AI_SpellAttack1(actor_id, target_pid, &pDir); | |
4610 else | |
4611 Actor::AI_SpellAttack2(actor_id, target_pid, &pDir); | |
4612 } | |
4613 else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 ) | |
4614 { | |
4615 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4616 v64 = (signed __int64)v47; | |
4617 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4618 } | |
4619 else | |
4620 { | |
4621 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4622 Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); | |
4623 } | |
4624 } | |
4625 else | |
4626 { | |
4627 if ( (double)v81 >= v80 * 307.2 ) | |
4628 { | |
4629 if ( v81 >= 1024 ) | |
4630 { | |
4631 if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4632 { | |
4633 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4634 v64 = (signed __int64)v47; | |
4635 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4636 } | |
4637 else | |
4638 { | |
4639 Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir); | |
4640 } | |
4641 } | |
4642 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4643 { | |
4644 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4645 v64 = (signed __int64)v47; | |
4646 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4647 } | |
4648 else | |
4649 { | |
4650 v70 = (signed __int64)v80 * 307.2; | |
4651 Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70); | |
4652 } | |
4653 } | |
4654 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
4655 { | |
4656 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4657 v64 = (signed __int64)v47; | |
4658 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4659 } | |
4660 else | |
4661 { | |
4662 Actor::AI_MeleeAttack(actor_id, target_pid, &pDir); | |
4663 } | |
4664 } | |
4665 continue; | |
4666 } | |
4667 } | |
4668 } | |
4669 | |
4670 if ( pActor->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 ) | |
4671 { | |
4672 if ( !pActor->pMonsterInfo.uMovementType ) | |
4673 { | |
4674 Actor::AI_4032B2(actor_id, 4, 1024, 0); | |
4675 } | |
4676 else if ( pActor->pMonsterInfo.uMovementType == 1 ) | |
4677 { | |
4678 Actor::AI_4032B2(actor_id, 4, 2560, 0); | |
4679 } | |
4680 else if ( pActor->pMonsterInfo.uMovementType == 2 ) | |
4681 { | |
4682 Actor::AI_4032B2(actor_id, 4, 5120, 0); | |
4683 } | |
4684 else if ( pActor->pMonsterInfo.uMovementType == 4 ) | |
4685 { | |
4686 Actor::AI_4032B2(actor_id, 4, 10240, 0); | |
4687 } | |
4688 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4689 { | |
4690 v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0); | |
4691 v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4692 memcpy(&v74, v57, sizeof(v74)); | |
4693 memcpy(&pDir, &v74, sizeof(pDir)); | |
4694 v64 = (signed __int64)v58; | |
4695 Actor::AI_Stand(actor_id, 4, v64, &pDir); | |
4696 } | |
4697 } | |
4698 else if ( !pActor->pMonsterInfo.uMissleAttack2Type ) | |
4699 { | |
4700 if ( (double)v81 >= v80 * 307.2 ) | |
4701 { | |
4702 if ( v81 >= 1024 ) | |
4703 { | |
4704 if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4705 { | |
4706 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4707 v64 = (signed __int64)v47; | |
4708 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4709 } | |
4710 else | |
4711 { | |
4712 Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir); | |
4713 } | |
4714 } | |
4715 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4716 { | |
4717 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4718 v64 = (signed __int64)v47; | |
4719 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4720 } | |
4721 else | |
4722 { | |
4723 v70 = (signed __int64)v80 * 307.2; | |
4724 Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70); | |
4725 } | |
4726 } | |
4727 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
4728 { | |
4729 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4730 v64 = (signed __int64)v47; | |
4731 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4732 } | |
4733 else | |
4734 { | |
4735 Actor::AI_MeleeAttack(actor_id, target_pid, &pDir); | |
4736 } | |
4737 } | |
4738 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
4739 { | |
4740 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4741 if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 ) | |
4742 { | |
4743 v64 = (signed __int64)v47; | |
4744 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4745 } | |
4746 else | |
4747 { | |
4748 Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); | |
4749 } | |
4750 } | |
4751 else | |
4752 { | |
4753 Actor::AI_MissileAttack2(actor_id, target_pid, &pDir); | |
4754 } | |
4755 } | |
4756 } | |
4757 } | |
4758 //----- (0044665D) -------------------------------------------------------- | |
4759 // uType: 0 -> any monster | |
4760 // 1 -> uParam is GroupID | |
4761 // 2 -> uParam is MonsterID | |
4762 // 3 -> uParam is ActorID | |
4763 // uNumAlive: 0 -> all must be alive | |
4764 int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive) | |
4765 { | |
4766 unsigned int uAliveActors; // eax@6 | |
4767 int v5; // ecx@10 | |
4768 unsigned int uTotalActors; // [sp+0h] [bp-4h]@1 | |
4769 | |
4770 uTotalActors = 0; | |
4771 if ( uType ) | |
4772 { | |
4773 if ( uType == 1 ) | |
4774 { | |
4775 uAliveActors = SearchActorByGroup(&uTotalActors, uParam); | |
4776 } | |
4777 else | |
4778 { | |
4779 if ( uType == 2 ) | |
4780 { | |
4781 uAliveActors = SearchActorByMonsterID(&uTotalActors, uParam); | |
4782 } | |
4783 else | |
4784 { | |
4785 if ( uType != 3 ) | |
4786 return 0; | |
4787 uAliveActors = SearchActorByID(&uTotalActors, uParam); | |
4788 } | |
4789 } | |
4790 } | |
4791 else | |
4792 { | |
4793 uAliveActors = SearchAliveActors(&uTotalActors); | |
4794 } | |
4795 v5 = 0; | |
4796 if ( uNumAlive ) | |
4797 LOBYTE(v5) = (signed int)uAliveActors >= (signed int)uNumAlive; | |
4798 else | |
4799 LOBYTE(v5) = uTotalActors == uAliveActors; | |
4800 return v5; | |
1297 | 4801 } |
4802 //----- (00408B54) -------------------------------------------------------- | |
4803 unsigned int __fastcall SearchActorByID(unsigned int *pTotalActors, unsigned int a2) | |
4804 { | |
4805 unsigned int v2; // edi@1 | |
4806 unsigned int *v3; // esi@1 | |
4807 int v4; // eax@1 | |
4808 unsigned int v5; // ebx@1 | |
4809 unsigned int v6; // edx@1 | |
4810 | |
4811 v2 = a2; | |
4812 v3 = pTotalActors; | |
4813 v4 = GetAlertStatus(); | |
4814 v5 = 0; | |
4815 *v3 = 0; | |
4816 v6 = pActors[v2].uAttributes; | |
4817 if ( (v6 & 0x100000) == v4 ) | |
4818 { | |
4819 *v3 = 1; | |
4820 if ( pActors[v2].IsNotAlive() == 1 ) | |
4821 v5 = 1; | |
4822 } | |
4823 return v5; | |
4824 } | |
4825 //----- (00408AE7) -------------------------------------------------------- | |
4826 unsigned int __fastcall SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup) | |
4827 { | |
4828 unsigned int *v2; // esi@1 | |
4829 signed int v3; // ebx@1 | |
4830 Actor *v4; // edi@2 | |
4831 int v5; // eax@3 | |
4832 unsigned int v7; // [sp+8h] [bp-Ch]@1 | |
4833 int v8; // [sp+Ch] [bp-8h]@1 | |
4834 unsigned int v9; // [sp+10h] [bp-4h]@1 | |
4835 | |
4836 v7 = uGroup; | |
4837 v2 = pTotalActors; | |
4838 v3 = 0; | |
4839 v8 = GetAlertStatus(); | |
4840 *v2 = 0; | |
4841 v9 = 0; | |
4842 if ( (signed int)uNumActors > 0 ) | |
4843 { | |
4844 v4 = pActors.data();//[0].uGroup; | |
4845 do | |
4846 { | |
4847 v5 = v4->uAttributes; | |
4848 if ( (v5 & 0x100000) == v8 ) | |
4849 { | |
4850 if ( v4->uGroup == v7 ) | |
4851 { | |
4852 ++*v2; | |
4853 if ( v4->IsNotAlive() == 1 ) | |
4854 ++v9; | |
4855 } | |
4856 } | |
4857 ++v3; | |
4858 ++v4; | |
4859 } | |
4860 while ( v3 < (signed int)uNumActors ); | |
4861 } | |
4862 return v9; | |
4863 } | |
4864 //----- (00408A7E) -------------------------------------------------------- | |
4865 unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID) | |
4866 { | |
4867 unsigned int *v2; // esi@1 | |
4868 signed int v3; // ebx@1 | |
4869 Actor *v4; // edi@2 | |
4870 int v5; // eax@3 | |
4871 int v7; // [sp+8h] [bp-Ch]@1 | |
4872 int v8; // [sp+Ch] [bp-8h]@1 | |
4873 unsigned int v9; // [sp+10h] [bp-4h]@1 | |
4874 | |
4875 v7 = uMonsterID; | |
4876 v2 = pTotalActors; | |
4877 v3 = 0; | |
4878 v8 = GetAlertStatus(); | |
4879 *v2 = 0; | |
4880 v9 = 0; | |
4881 if ( (signed int)uNumActors > 0 ) | |
4882 { | |
4883 v4 = pActors.data();//[0].pMonsterInfo.uID; | |
4884 do | |
4885 { | |
4886 v5 = v4->uAttributes; // actor::attributes | |
4887 if ( (v5 & 0x100000) == v8 ) | |
4888 { | |
4889 if ( v4->pMonsterInfo.field_33 == v7 ) | |
4890 { | |
4891 ++*v2; | |
4892 if ( v4->IsNotAlive() == 1 ) | |
4893 ++v9; | |
4894 } | |
4895 } | |
4896 ++v3; | |
4897 ++v4; | |
4898 } | |
4899 while ( v3 < (signed int)uNumActors ); | |
4900 } | |
4901 return v9; | |
4902 } | |
4903 //----- (00408A27) -------------------------------------------------------- | |
4904 unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors) | |
4905 { | |
4906 unsigned int *v1; // esi@1 | |
4907 int v2; // eax@1 | |
4908 unsigned int v3; // ebp@1 | |
4909 signed int v4; // ebx@1 | |
4910 Actor *v5; // edi@2 | |
4911 unsigned int v6; // eax@3 | |
4912 int v8; // [sp+Ch] [bp-4h]@1 | |
4913 | |
4914 v1 = pTotalActors; | |
4915 v2 = GetAlertStatus(); | |
4916 v3 = 0; | |
4917 v4 = 0; | |
4918 *v1 = 0; | |
4919 v8 = v2; | |
4920 if ( (signed int)uNumActors > 0 ) | |
4921 { | |
4922 v5 = pActors.data(); | |
4923 do | |
4924 { | |
4925 v6 = v5->uAttributes; | |
4926 if ( (v6 & 0x100000) == v8 ) | |
4927 { | |
4928 ++*v1; | |
4929 if ( v5->IsNotAlive() == 1 ) | |
4930 ++v3; | |
4931 } | |
4932 ++v4; | |
4933 ++v5; | |
4934 } | |
4935 while ( v4 < (signed int)uNumActors ); | |
4936 } | |
4937 return v3; | |
4938 } | |
4939 //----- (00408768) -------------------------------------------------------- | |
4940 void InitializeActors() | |
4941 { | |
4942 signed int v5; // [sp+Ch] [bp-10h]@1 | |
4943 signed int v6; // [sp+10h] [bp-Ch]@1 | |
4944 signed int v7; // [sp+14h] [bp-8h]@1 | |
4945 signed int v8; // [sp+18h] [bp-4h]@1 | |
4946 | |
4947 v8 = 0; | |
4948 v6 = 0; | |
4949 v7 = 0; | |
4950 v5 = 0; | |
4951 if ( !_stricmp(pCurrentMapName.data(), "d25.blv") ) | |
4952 v8 = 1; | |
4953 if ( !_stricmp(pCurrentMapName.data(), "d26.blv") ) | |
4954 v6 = 1; | |
4955 if (_449B57_test_bit(pParty->_quest_bits, 99)) | |
4956 v7 = 1; | |
4957 if (_449B57_test_bit(pParty->_quest_bits, 100)) | |
4958 v5 = 1; | |
4959 | |
4960 Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0; original code behaviour is identical | |
4961 for (uint i = 0; i < uNumActors; ++i) | |
4962 { | |
4963 auto actor = &pActors[i]; | |
4964 | |
4965 if (actor->CanAct() || actor->uAIState == Disabled) | |
4966 { | |
4967 actor->vPosition.x = actor->vInitialPosition.x; | |
4968 actor->vPosition.y = actor->vInitialPosition.y; | |
4969 actor->vPosition.z = actor->vInitialPosition.z; | |
4970 actor->sCurrentHP = actor->pMonsterInfo.uHP; | |
4971 if (actor->uAIState != Disabled) | |
4972 { | |
4973 Actor::AI_Stand(i, ai_near_actors_targets_pid[i], actor->pMonsterInfo.uRecoveryTime, 0); | |
4974 } | |
4975 } | |
4976 | |
4977 actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
4978 | |
4979 if (!v8 || v7) | |
4980 if (!v6 || v5) | |
4981 if (actor->IsPeasant()) | |
4982 BYTE2(actor->uAttributes) &= 0xF7u; | |
4983 | |
4984 BYTE2(actor->uAttributes) &= 0x7Fu; | |
4985 if (BYTE2(actor->uAttributes) & 0x40) | |
4986 Actor::_4031C1_update_job(i, pParty->uCurrentHour, 1); | |
4987 } | |
4988 } | |
4989 //----- (00439474) -------------------------------------------------------- | |
4990 void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity) | |
4991 { | |
4992 //signed int v3; // eax@1 | |
4993 SpriteObject *v4; // ebx@1 | |
4994 //int v5; // edx@3 | |
4995 //bool uPlayerID; // eax@3 | |
4996 //Player *pPlayer; // edi@4 | |
4997 Actor *pMonster; // esi@7 | |
4998 //SpriteObject *v9; // ebx@12 | |
4999 int v10; // eax@12 | |
5000 int v11; // ebx@12 | |
5001 unsigned int v12; // ecx@12 | |
5002 int v13; // edx@15 | |
5003 int v14; // edx@17 | |
5004 int v15; // eax@24 | |
5005 unsigned __int16 v16; // cx@25 | |
5006 int v17; // eax@29 | |
5007 int v18; // eax@38 | |
5008 unsigned __int8 v19; // zf@38 | |
5009 unsigned __int8 v20; // sf@38 | |
5010 int v21; // edx@44 | |
5011 int v22; // eax@44 | |
5012 unsigned __int8 v23; // zf@44 | |
5013 unsigned __int8 v24; // sf@44 | |
5014 int v25; // edx@51 | |
5015 int v26; // ecx@51 | |
5016 //signed int v27; // eax@51 | |
5017 //int v28; // eax@53 | |
5018 signed int v29; // eax@76 | |
5019 signed int v30; // eax@84 | |
5020 signed int v31; // eax@92 | |
5021 int v32; // eax@94 | |
5022 int v33; // eax@100 | |
5023 int v34; // eax@104 | |
5024 signed int v35; // eax@104 | |
5025 double v36; // st7@104 | |
5026 float v37; // ST08_4@104 | |
5027 float v38; // ST04_4@104 | |
5028 float v39; // ST00_4@104 | |
5029 int v40; // ebx@107 | |
5030 unsigned int v41; // ebx@109 | |
5031 signed __int64 v42; // qax@125 | |
5032 unsigned __int16 v43; // ax@132 | |
5033 char v44; // bl@132 | |
5034 unsigned __int16 v45; // ax@132 | |
5035 unsigned __int64 v46; // [sp+Ch] [bp-60h]@6 | |
5036 const char *v47; // [sp+14h] [bp-58h]@104 | |
5037 char *pPlayerName; // [sp+18h] [bp-54h]@12 | |
5038 char *pMonsterName; // [sp+1Ch] [bp-50h]@6 | |
5039 int v50; // [sp+20h] [bp-4Ch]@6 | |
5040 //unsigned __int64 *v51; // [sp+30h] [bp-3Ch]@6 | |
5041 int v52; // [sp+34h] [bp-38h]@12 | |
5042 //int v53; // [sp+38h] [bp-34h]@10 | |
5043 //int v54; // [sp+3Ch] [bp-30h]@1 | |
5044 //int v55; // [sp+40h] [bp-2Ch]@12 | |
5045 signed int a4; // [sp+44h] [bp-28h]@1 | |
5046 PlayerEquipment *v57; // [sp+48h] [bp-24h]@10 | |
5047 //int v58; // [sp+4Ch] [bp-20h]@10 | |
5048 int v59; // [sp+50h] [bp-1Ch]@1 | |
5049 unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1 | |
5050 int v61; // [sp+58h] [bp-14h]@1 | |
5051 bool v62; // [sp+5Ch] [bp-10h]@1 | |
5052 int uDamageAmount; // [sp+60h] [bp-Ch]@1 | |
5053 int a2; // [sp+64h] [bp-8h]@27 | |
5054 int a3; // [sp+6Bh] [bp-1h]@6 | |
5055 | |
5056 //v3 = a1; | |
5057 v4 = 0; | |
5058 uActorID_Monster_ = uActorID_Monster; | |
5059 //v54 = a1; | |
5060 uDamageAmount = 0; | |
5061 a4 = 0; | |
5062 v61 = 0; | |
5063 v59 = 0; | |
5064 v62 = 0; | |
5065 if ( PID_TYPE(a1) == OBJECT_Item) | |
5066 { | |
5067 v4 = &pSpriteObjects[PID_ID(a1)]; | |
5068 //uDamageAmount = (int)v4; | |
5069 v61 = v4->field_60_distance_related_prolly_lod; | |
5070 a1 = v4->spell_caster_pid; | |
5071 //v54 = v4->field_58_pid; | |
5072 } | |
5073 //v5 = a1 & 7; | |
5074 //uPlayerID = a1 >> 3; | |
5075 if (PID_TYPE(a1) != OBJECT_Player) | |
5076 return; | |
5077 | |
5078 assert(PID_ID(abs(a1)) < 4); | |
5079 auto player = &pParty->pPlayers[PID_ID(a1)]; | |
5080 pMonster = &pActors[uActorID_Monster_]; | |
5081 //uPlayerID = pMonster->IsAlive(); | |
5082 if (pMonster->IsNotAlive()) | |
5083 return; | |
5084 | |
5085 BYTE1(pMonster->uAttributes) |= 0xC0u; | |
5086 if ( pMonster->uAIState == Fleeing ) | |
5087 pMonster->uAttributes |= 0x20000u; | |
5088 //v57 = 0; | |
5089 //v53 = 0; | |
5090 //v58 = 0; | |
5091 bool hit_will_stun = false, | |
5092 hit_will_paralyze = false; | |
5093 if ( !v4 ) | |
5094 { | |
5095 //v51 = (unsigned __int64 *)player->pEquipment.uMainHand; | |
5096 int main_hand_idx = player->pEquipment.uMainHand; | |
5097 v59 = 1; | |
5098 if ( player->HasItemEquipped(EQUIP_MAIN_HAND) ) | |
5099 { | |
5100 auto main_hand_skill = pItemsTable->pItems[player->pInventoryItems[main_hand_idx - 1].uItemID].uSkillType; | |
5101 //v55 = pItemsTable->pItems[player->pInventoryItems[main_hand_idx - 1].uItemID].uSkillType; | |
5102 //v28 = SkillToMastery(player->pActiveSkills[v55]); | |
5103 auto main_hand_mastery = SkillToMastery(player->pActiveSkills[main_hand_skill]); | |
5104 //uDamageAmount = v28; | |
5105 switch (main_hand_skill) | |
5106 { | |
5107 case PLAYER_SKILL_STAFF: | |
5108 if (main_hand_mastery >= 3) | |
5109 { | |
5110 if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_STAFF) & 0x3F)) // stun chance when mastery >= 3 | |
5111 hit_will_stun = true; | |
5112 } | |
5113 break; | |
5114 | |
5115 case PLAYER_SKILL_MACE: | |
5116 if (main_hand_mastery >= 3) | |
5117 { | |
5118 if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) | |
5119 hit_will_stun = true; | |
5120 } | |
5121 if (main_hand_mastery >= 4) | |
5122 { | |
5123 if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) | |
5124 hit_will_paralyze = true; | |
5125 } | |
5126 break; | |
5127 } | |
5128 } | |
5129 v50 = pMonster->pMonsterInfo.uID; | |
5130 a2 = 4; | |
5131 //v27 = player->CalculateMeleeDamageTo(0, 0, v50); | |
5132 uDamageAmount = player->CalculateMeleeDamageTo(0, 0, v50); | |
5133 //if ( !v57 ) | |
5134 goto LABEL_67; | |
5135 //goto LABEL_69; | |
5136 } | |
5137 | |
5138 | |
5139 v19 = v4->spell_id == SPELL_DARK_SOULDRINKER; | |
5140 v61 = v4->field_60_distance_related_prolly_lod; | |
5141 if ( !v19 ) | |
5142 { | |
5143 //v9 = (SpriteObject *)uDamageAmount; | |
5144 v50 = pParty->vPosition.x - v4->vPosition.x; | |
5145 //v55 = abs(v50); | |
5146 pMonsterName = (char *)(pParty->vPosition.y - v4->vPosition.y); | |
5147 //v51 = (unsigned __int64 *)abs((int)pMonsterName); | |
5148 pPlayerName = (char *)(pParty->vPosition.z - v4->vPosition.z); | |
5149 v52 = abs((int)pPlayerName); | |
5150 v61 = abs(v50); | |
5151 v10 = abs(v50); | |
5152 v11 = (int)abs((int)pMonsterName); | |
5153 v12 = v52; | |
5154 if ( v10 < v11) | |
5155 { | |
5156 v10 = (int)v11; | |
5157 v11 = v10; | |
5158 } | |
5159 if ( v10 < v52 ) | |
5160 { | |
5161 v13 = v10; | |
5162 v10 = v52; | |
5163 v12 = v13; | |
5164 } | |
5165 if ( v11 < (signed int)v12 ) | |
5166 { | |
5167 v14 = v12; | |
5168 v12 = v11; | |
5169 v11 = v14; | |
5170 } | |
5171 //uPlayerID = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10; | |
5172 v61 = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10; | |
5173 if ( v61 >= 2560 ) | |
5174 { | |
5175 if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) ) | |
5176 return; | |
5177 v61 = 2; | |
5178 } | |
5179 else | |
5180 { | |
5181 v61 = 1; | |
5182 } | |
5183 //v4 = (SpriteObject *)uDamageAmount; | |
5184 } | |
5185 | |
5186 v15 = v4->spell_id; | |
5187 if ( v15 == SPELL_LASER_PROJECTILE ) | |
5188 { | |
5189 v16 = player->pActiveSkills[7]; | |
5190 v61 = 1; | |
5191 if ( (signed int)SkillToMastery(v16) >= 3 ) | |
5192 a4 = player->pActiveSkills[7] & 0x3F; | |
5193 a2 = 4; | |
5194 uDamageAmount = player->CalculateMeleeDamageTo(1, 1, 0); | |
5195 goto LABEL_67; | |
5196 } | |
5197 if ( v15 != SPELL_BOW_ARROW ) | |
5198 { | |
5199 if ( v15 == SPELL_101 ) | |
5200 { | |
5201 a2 = 0; | |
5202 v18 = player->CalculateRangedDamageTo(0); | |
5203 v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0; | |
5204 v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0; | |
5205 uDamageAmount = v18; | |
5206 if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) | |
5207 uDamageAmount >>= 1; | |
5208 v59 = 1; | |
5209 goto LABEL_67; | |
5210 } | |
5211 if ( v15 == SPELL_EARTH_BLADES ) | |
5212 { | |
5213 a4 = 5 * v4->spell_level; | |
5214 a2 = player->GetSpellSchool(0x27u); | |
5215 v21 = v4->spell_level; | |
5216 v50 = pMonster->sCurrentHP; | |
5217 pMonsterName = (char *)v4->spell_skill; | |
5218 v22 = _43AFE3_calc_spell_damage(39, v21, v4->spell_skill, v50); | |
5219 v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0; | |
5220 v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0; | |
5221 uDamageAmount = v22; | |
5222 if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) | |
5223 uDamageAmount >>= 1; | |
5224 v59 = 0; | |
5225 LABEL_67: | |
5226 if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) | |
5227 { | |
5228 //LABEL_68: | |
5229 player->PlaySound(SPEECH_52, 0); | |
5230 return; | |
5231 } | |
5232 goto LABEL_69; | |
5233 } | |
5234 if ( v15 == SPELL_EARTH_STUN ) | |
5235 { | |
5236 uDamageAmount = 0; | |
5237 a2 = 4; | |
5238 hit_will_stun = 1; | |
5239 goto LABEL_67; | |
5240 } | |
5241 a2 = player->GetSpellSchool(v4->spell_id); | |
5242 v25 = v4->spell_level; | |
5243 v26 = v4->spell_id; | |
5244 v50 = pMonster->sCurrentHP; | |
5245 pMonsterName = (char *)v4->spell_skill; | |
5246 //v27 = _43AFE3_calc_spell_damage(v26, v25, (signed int)pMonsterName, v50); | |
5247 v59 = 0; | |
5248 //v57 = (PlayerEquipment *)1; | |
5249 //LABEL_65: | |
5250 uDamageAmount = _43AFE3_calc_spell_damage(v26, v25, v4->spell_skill, v50); | |
5251 //if ( !v57 ) | |
5252 // goto LABEL_67; | |
5253 goto LABEL_69; | |
5254 } | |
5255 v50 = pMonster->word_000086_some_monster_id; | |
5256 a2 = 4; | |
5257 v17 = player->CalculateRangedDamageTo(v50); | |
5258 v19 = v4->stru_24.uItemID == 0; | |
5259 uDamageAmount = v17; | |
5260 v57 = 0; | |
5261 if ( !v19 && v4->stru_24.uSpecEnchantmentType == 3 ) | |
5262 { | |
5263 a2 = 0; | |
5264 v57 = (PlayerEquipment *)1; | |
5265 } | |
5266 if ( SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) >= 0 | |
5267 && (SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) > 0 || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) | |
5268 uDamageAmount >>= 1; | |
5269 v59 = 1; | |
5270 //LABEL_66: | |
5271 if ( !v57 ) | |
5272 goto LABEL_67; | |
5273 LABEL_69: | |
5274 if (player->Weak()) | |
5275 uDamageAmount /= 1; | |
5276 if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 ) | |
5277 uDamageAmount = 0; | |
5278 v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, uDamageAmount); | |
5279 if ( !v4 && player->IsUnarmed() && (signed __int64)player->pPlayerBuffs[6].uExpireTime > 0 ) | |
5280 { | |
5281 v50 = player->pPlayerBuffs[6].uPower; | |
5282 v29 = stru_50C198.CalcMagicalDamageToActor(pMonster, 8, v50); | |
5283 v61 += v29; | |
5284 } | |
5285 uDamageAmount = v61; | |
5286 if ( v59 ) | |
5287 { | |
5288 if ( v4 ) | |
5289 { | |
5290 a4 = v4->stru_24._439DF3_get_additional_damage(&a2, &v62); | |
5291 if ( v62 && pMonster->sCurrentHP > 0 ) | |
5292 { | |
5293 player->sHealth += v61 / 5; | |
5294 if ( player->sHealth > player->GetMaxHealth() ) | |
5295 player->sHealth = player->GetMaxHealth(); | |
5296 v62 = 0; | |
5297 } | |
5298 v30 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4); | |
5299 uDamageAmount = v61 + v30; | |
5300 } | |
5301 else | |
5302 { | |
5303 v59 = 0; | |
5304 v57 = &player->pEquipment; | |
5305 do | |
5306 { | |
5307 if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)v59) ) | |
5308 { | |
5309 auto _s = (ItemGen *)&player->pInventoryItems[v57->uShield - 1]; | |
5310 a4 = _s->_439DF3_get_additional_damage(&a2, &v62); | |
5311 if ( v62 && pMonster->sCurrentHP > 0 ) | |
5312 { | |
5313 player->sHealth += v61 / 5; | |
5314 if ( player->sHealth > player->GetMaxHealth() ) | |
5315 player->sHealth = player->GetMaxHealth(); | |
5316 v62 = 0; | |
5317 } | |
5318 v31 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4); | |
5319 uDamageAmount += v31; | |
5320 } | |
5321 ++v59; | |
5322 v57 = (PlayerEquipment *)((char *)v57 + 4); | |
5323 } | |
5324 while ( v59 <= 1 ); | |
5325 } | |
5326 } | |
5327 v32 = uDamageAmount; | |
5328 pMonster->sCurrentHP -= uDamageAmount; | |
5329 if ( !v32 && !hit_will_stun ) | |
5330 { | |
5331 player->PlaySound(SPEECH_52, 0); | |
5332 return; | |
5333 } | |
5334 if ( pMonster->sCurrentHP > 0 ) | |
5335 { | |
5336 Actor::AI_Stun(uActorID_Monster_, a1, 0); | |
5337 Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); | |
5338 if ( bShowDamage ) | |
5339 { | |
5340 v50 = uDamageAmount; | |
5341 pMonsterName = (char *)pMonster; | |
5342 pPlayerName = player->pName; | |
5343 if ( v4 ) | |
5344 v47 = pGlobalTXT_LocalizationStrings[189];// "%s shoots %s for %lu points" | |
5345 else | |
5346 v47 = pGlobalTXT_LocalizationStrings[164];// "%s hits %s for %lu damage" | |
5347 sprintfex(pTmpBuf.data(), v47, pPlayerName, pMonsterName, v50); | |
5348 ShowStatusBarString(pTmpBuf.data(), 2u); | |
5349 } | |
5350 v41 = 0; | |
5351 } | |
5352 else | |
5353 { | |
5354 if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 ) | |
5355 { | |
5356 v33 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius; | |
5357 //v55 = v33; | |
5358 if ( pRenderer->pRenderD3D ) | |
5359 { | |
5360 if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) | |
5361 { | |
5362 v50 = 0; | |
5363 pMonsterName = 0; | |
5364 v34 = pMonster->vPosition.z; | |
5365 *(float *)&pPlayerName = (double)v33; | |
5366 //v51 = (unsigned __int64 *)v34; | |
5367 *(float *)&v47 = 0.0; | |
5368 v35 = pMonster->vPosition.y; | |
5369 *((float *)&v46 + 1) = 0.0; | |
5370 *(float *)&v46 = 1.0; | |
5371 v36 = (double)(signed int)pMonster->vPosition.z; | |
5372 //v51 = (unsigned __int64 *)v35; | |
5373 v37 = v36; | |
5374 //v51 = (unsigned __int64 *)pMonster->vPosition.x; | |
5375 v38 = (double)v35; | |
5376 v39 = (double)(signed int)pMonster->vPosition.x; | |
5377 pDecalBuilder->AddBloodsplat(v39, v38, v37, 1.0, 0.0, 0.0, *(float *)&pPlayerName, 0, 0); | |
5378 } | |
5379 } | |
5380 } | |
5381 Actor::Die(uActorID_Monster_); | |
5382 Actor::ApplyFineForKillingPeasant(uActorID_Monster_); | |
5383 Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); | |
5384 if ( pMonster->pMonsterInfo.uExp ) | |
5385 GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp); | |
5386 v40 = SPEECH_51; | |
5387 if ( rand() % 100 < 20 ) | |
5388 v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1; | |
5389 player->PlaySound((PlayerSpeech)v40, 0); | |
5390 v41 = 0; | |
5391 if ( bShowDamage ) | |
5392 { | |
5393 v50 = (int)pMonster; | |
5394 pMonsterName = (char *)uDamageAmount; | |
5395 pPlayerName = player->pName; // "%s inflicts %lu points killing %s" | |
5396 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[175], player->pName, uDamageAmount, pMonster); | |
5397 ShowStatusBarString(pTmpBuf.data(), 2u); | |
5398 } | |
5399 } | |
5400 if ( SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) >= (signed int)v41 | |
5401 && (SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) > (signed int)v41 | |
5402 || LODWORD(pMonster->pActorBuffs[20].uExpireTime) > v41) | |
5403 && uDamageAmount != v41 ) | |
5404 player->ReceiveDamage(uDamageAmount, (DAMAGE_TYPE)a2); | |
5405 v50 = 24; | |
5406 v59 = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP; | |
5407 if ( (player->_48EA46_calc_special_bonus_by_items(24) || hit_will_stun != v41) | |
5408 && stru_50C198.GetMagicalResistance(pMonster, 3u) ) | |
5409 { | |
5410 LODWORD(v42) = 20; | |
5411 v59 = 10; | |
5412 if ( pParty->bTurnBasedModeOn == v41 ) | |
5413 v42 = (signed __int64)(flt_6BE3A8_debug_recmod2 * 42.66666666666666); | |
5414 pMonster->pMonsterInfo.uRecoveryTime += v42; | |
5415 if ( bShowDamage != v41 ) | |
5416 { | |
5417 v50 = (int)pMonster; | |
5418 pMonsterName = player->pName; // "%s stuns %s" | |
5419 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[635], player->pName, pMonster); | |
5420 ShowStatusBarString(pTmpBuf.data(), 2u); | |
5421 } | |
5422 } | |
5423 if ( hit_will_paralyze != v41 ) | |
5424 { | |
5425 if ( pMonster->CanAct() ) | |
5426 { | |
5427 if ( stru_50C198.GetMagicalResistance(pMonster, 3) ) | |
5428 { | |
5429 LOBYTE(v43) = player->GetActualSkillLevel(PLAYER_SKILL_MACE); | |
5430 v44 = v43; | |
5431 v45 = SkillToMastery(v43); | |
5432 //v51 = (unsigned __int64 *)(7680 * (v44 & 0x3F)); | |
5433 v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(7680 * (v44 & 0x3F)) * 0.033333335); | |
5434 pMonster->pActorBuffs[6].Apply(v46, v45, 0, 0, 0); | |
5435 if ( bShowDamage ) | |
5436 { | |
5437 v50 = (int)pMonster; | |
5438 pMonsterName = player->pName; // "%s paralyzes %s" | |
5439 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[636], player->pName, pMonster); | |
5440 ShowStatusBarString(pTmpBuf.data(), 2u); | |
5441 } | |
5442 } | |
5443 } | |
5444 } | |
5445 if ( v59 > 10 ) | |
5446 v59 = 10; | |
5447 if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) | |
5448 { | |
5449 pVelocity->x = (unsigned __int64)(v59 * (signed __int64)pVelocity->x) >> 16; | |
5450 pVelocity->y = (unsigned __int64)(v59 * (signed __int64)pVelocity->y) >> 16; | |
5451 pVelocity->z = (unsigned __int64)(v59 * (signed __int64)pVelocity->z) >> 16; | |
5452 pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x); | |
5453 pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y); | |
5454 pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z); | |
5455 } | |
5456 Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61); | |
5457 } | |
5458 //----- (004BBF61) -------------------------------------------------------- | |
5459 void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z) | |
5460 { | |
5461 size_t v4; // esi@1 | |
5462 int monster_id; // edi@1 | |
5463 __int16 v6; // ax@4 | |
5464 Actor *v7; // esi@5 | |
5465 int v8; // eax@5 | |
5466 MonsterInfo *v9; // edi@5 | |
5467 MonsterDesc *v10; // ebx@5 | |
5468 unsigned __int16 *v11; // ebx@5 | |
5469 int v12; // ebx@7 | |
5470 int v13; // eax@8 | |
5471 __int16 x_; // [sp+8h] [bp-Ch]@1 | |
5472 __int16 v15; // [sp+Ch] [bp-8h]@1 | |
5473 __int16 v16; // [sp+10h] [bp-4h]@3 | |
5474 signed int ya; // [sp+1Ch] [bp+8h]@5 | |
5475 | |
5476 v4 = uNumActors; | |
5477 monster_id = a1; | |
5478 x_ = x; | |
5479 v15 = a1; | |
5480 if ( (signed int)uNumActors < 500 | |
5481 && ((signed int)pAllocator->uBigBufferSizeAligned >> 10) - ((signed int)pAllocator->uNextFreeOffsetInBigBuffer >> 10) >= 2000 ) | |
5482 { | |
5483 v16 = 0; | |
5484 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
5485 { | |
5486 v6 = pIndoor->GetSector(x, y, z); | |
5487 v4 = uNumActors; | |
5488 v16 = v6; | |
5489 } | |
5490 v7 = &pActors[v4]; | |
5491 v7->Reset(); | |
5492 v8 = monster_id; | |
5493 v9 = &pMonsterStats->pInfos[monster_id]; | |
5494 v10 = &pMonsterList->pMonsters[v8 - 1]; | |
5495 strcpy(v7->pActorName, v9->pName); | |
5496 v7->sCurrentHP = LOWORD(v9->uHP); | |
5497 memcpy(&v7->pMonsterInfo, v9, 0x58u); | |
5498 v7->word_000086_some_monster_id = v15; | |
5499 v7->uActorRadius = v10->uMonsterRadius; | |
5500 v7->uActorHeight = v10->uMonsterHeight; | |
5501 v7->uMovementSpeed = v10->uMovementSpeed; | |
5502 v7->vInitialPosition.x = x_; | |
5503 v7->vPosition.x = x_; | |
5504 BYTE2(v7->uAttributes) |= 8u; | |
5505 v7->pMonsterInfo.uTreasureType = 0; | |
5506 v7->pMonsterInfo.uTreasureLevel = 0; | |
5507 v7->pMonsterInfo.uTreasureDiceSides = 0; | |
5508 v7->pMonsterInfo.uTreasureDiceRolls = 0; | |
5509 v7->pMonsterInfo.uTreasureDropChance = 0; | |
5510 v7->vInitialPosition.y = y; | |
5511 v7->vPosition.y = y; | |
5512 v7->vInitialPosition.z = z; | |
5513 v7->vPosition.z = z; | |
5514 v7->uTetherDistance = 256; | |
5515 v7->uSectorID = v16; | |
5516 v7->uGroup = 1; | |
5517 v7->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; | |
5518 v7->PrepareSprites(0); | |
5519 v11 = v10->pSoundSampleIDs; | |
5520 ya = 4; | |
5521 do | |
5522 { | |
5523 pSoundList->LoadSound((signed __int16)*v11, 0); | |
5524 ++v11; | |
5525 --ya; | |
5526 } | |
5527 while ( ya ); | |
5528 v12 = 0; | |
5529 do | |
5530 LOWORD(v13) = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[v9->uSpell1ID], 1u); | |
5531 while ( v13 ); | |
5532 ++uNumActors; | |
5533 } | |
1295 | 5534 } |