comparison Actor.cpp @ 828:0f56abdcce94

Massive refactors of spells + PID (packed id) macros introduced.
author Nomad
date Wed, 27 Mar 2013 00:27:38 +0200
parents c1da83d8223f
children dfd683c4f538
comparison
equal deleted inserted replaced
824:fe4c8b113548 828:0f56abdcce94
18 #include "Time.h" 18 #include "Time.h"
19 #include "LOD.h" 19 #include "LOD.h"
20 #include "Party.h" 20 #include "Party.h"
21 #include "GUIWindow.h" 21 #include "GUIWindow.h"
22 #include "GUIFont.h" 22 #include "GUIFont.h"
23
24 #include "MM7.h"
25
26
27
28
29
30
23 31
24 Actor pActors[500]; 32 Actor pActors[500];
25 int uNumActors; 33 int uNumActors;
26 34
27 stru319 stru_50C198; // idb 35 stru319 stru_50C198; // idb
382 int v13; // ecx@34 390 int v13; // ecx@34
383 int v14; // edx@34 391 int v14; // edx@34
384 int v15; // eax@34 392 int v15; // eax@34
385 AIDirection *v16; // esi@34 393 AIDirection *v16; // esi@34
386 unsigned __int16 v17; // di@34 394 unsigned __int16 v17; // di@34
387 int v18; // eax@34 395 //int v18; // eax@34
388 int v19; // edi@34 396 int v19; // edi@34
389 int v20; // eax@35 397 int v20; // eax@35
390 int v21; // eax@39 398 int v21; // eax@39
391 SoundID v22; // eax@39 399 SoundID v22; // eax@39
392 signed int v23; // eax@41 400 signed int v23; // eax@41
442 int v73; // ecx@184 450 int v73; // ecx@184
443 int v74; // edx@184 451 int v74; // edx@184
444 int v75; // eax@184 452 int v75; // eax@184
445 AIDirection *v76; // esi@184 453 AIDirection *v76; // esi@184
446 unsigned __int16 v77; // di@184 454 unsigned __int16 v77; // di@184
447 int v78; // eax@184 455 //int v78; // eax@184
448 int v79; // edx@185 456 int v79; // edx@185
449 int v80; // eax@185 457 int v80; // eax@185
450 int v81; // eax@189 458 int v81; // eax@189
451 unsigned __int16 v82; // ax@190 459 unsigned __int16 v82; // ax@190
452 int v83; // ecx@192 460 int v83; // ecx@192
454 int v85; // eax@192 462 int v85; // eax@192
455 AIDirection *v86; // esi@192 463 AIDirection *v86; // esi@192
456 unsigned __int16 v87; // di@192 464 unsigned __int16 v87; // di@192
457 __int16 v88; // ax@192 465 __int16 v88; // ax@192
458 signed int v89; // ecx@192 466 signed int v89; // ecx@192
459 int v90; // eax@192 467 //int v90; // eax@192
460 signed int v91; // eax@200 468 signed int v91; // eax@200
461 int v92; // eax@201 469 int v92; // eax@201
462 int v93; // ecx@207 470 int v93; // ecx@207
463 int v94; // ecx@208 471 int v94; // ecx@208
464 int v95; // eax@212 472 int v95; // eax@212
607 a1.vPosition.z = v15; 615 a1.vPosition.z = v15;
608 a1.uFacing = v17; 616 a1.uFacing = v17;
609 a1.uSoundID = 0; 617 a1.uSoundID = 0;
610 a1.uAttributes = 0; 618 a1.uAttributes = 0;
611 a1.uSectorID = pIndoor->GetSector(v13, v14, v15); 619 a1.uSectorID = pIndoor->GetSector(v13, v14, v15);
612 v18 = 8 * LODWORD(v120); 620 a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120));
613 LOBYTE(v18) = 8 * LOBYTE(v120) | AI_OBJECT_ACTOR;
614 a1.spell_caster_pid = v18;
615 a1.uSpriteFrameID = 0; 621 a1.uSpriteFrameID = 0;
616 a1.spell_target_pid = 0; 622 a1.spell_target_pid = 0;
617 a1.field_60_distance_related_prolly_lod = 3; 623 a1.field_60_distance_related_prolly_lod = 3;
618 v19 = spellnuma / -2; 624 v19 = spellnuma / -2;
619 a1a = spellnuma / 2; 625 a1a = spellnuma / 2;
691 a1.uAttributes = 0; 697 a1.uAttributes = 0;
692 v88 = pIndoor->GetSector(v83, v84, v85); 698 v88 = pIndoor->GetSector(v83, v84, v85);
693 v89 = v86->uDistance; 699 v89 = v86->uDistance;
694 a1.uSectorID = v88; 700 a1.uSectorID = v88;
695 LODWORD(v119) = v89; 701 LODWORD(v119) = v89;
696 v90 = 8 * LODWORD(v120);
697 LOBYTE(v90) = 8 * LOBYTE(v120) | OBJECT_Actor;
698 a1.uSpriteFrameID = 0; 702 a1.uSpriteFrameID = 0;
699 a1.spell_caster_pid = v90; 703 a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120));
700 a1.spell_target_pid = 0; 704 a1.spell_target_pid = 0;
701 a1.field_60_distance_related_prolly_lod = 3; 705 a1.field_60_distance_related_prolly_lod = 3;
702 if ( (double)v89 >= 307.2 ) 706 if ( (double)v89 >= 307.2 )
703 { 707 {
704 if ( v89 >= 1024 ) 708 if ( v89 >= 1024 )
1380 a1.vPosition.z = v75; 1384 a1.vPosition.z = v75;
1381 a1.uFacing = v77; 1385 a1.uFacing = v77;
1382 a1.uSoundID = 0; 1386 a1.uSoundID = 0;
1383 a1.uAttributes = 0; 1387 a1.uAttributes = 0;
1384 a1.uSectorID = pIndoor->GetSector(v73, v74, v75); 1388 a1.uSectorID = pIndoor->GetSector(v73, v74, v75);
1385 v78 = 8 * LODWORD(v120); 1389 a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120));
1386 LOBYTE(v78) = 8 * LOBYTE(v120) | OBJECT_Actor;
1387 a1.spell_caster_pid = v78;
1388 a1.uSpriteFrameID = 0; 1390 a1.uSpriteFrameID = 0;
1389 a1.spell_target_pid = 0; 1391 a1.spell_target_pid = 0;
1390 a1.field_60_distance_related_prolly_lod = 3; 1392 a1.field_60_distance_related_prolly_lod = 3;
1391 a1c = spellnume / -2; 1393 a1c = spellnume / -2;
1392 if ( spellnume / -2 > spellnume / 2 ) 1394 if ( spellnume / -2 > spellnume / 2 )
1488 char *v7; // eax@15 1490 char *v7; // eax@15
1489 unsigned __int16 v8; // ax@18 1491 unsigned __int16 v8; // ax@18
1490 unsigned __int16 v9; // ax@19 1492 unsigned __int16 v9; // ax@19
1491 __int16 v10; // ax@19 1493 __int16 v10; // ax@19
1492 signed int v11; // ecx@19 1494 signed int v11; // ecx@19
1493 int v12; // eax@19 1495 //int v12; // eax@19
1494 int v13; // edx@28 1496 int v13; // edx@28
1495 //SpriteObject a1; // [sp+Ch] [bp-74h]@1 1497 //SpriteObject a1; // [sp+Ch] [bp-74h]@1
1496 unsigned int v15; // [sp+7Ch] [bp-4h]@1 1498 unsigned int v15; // [sp+7Ch] [bp-4h]@1
1497 signed int v16; // [sp+88h] [bp+8h]@14 1499 signed int v16; // [sp+88h] [bp+8h]@14
1498 signed int v17; // [sp+88h] [bp+8h]@19 1500 signed int v17; // [sp+88h] [bp+8h]@19
1578 a1.uSoundID = 0; 1580 a1.uSoundID = 0;
1579 a1.uAttributes = 0; 1581 a1.uAttributes = 0;
1580 v10 = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); 1582 v10 = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z);
1581 v11 = v4->uDistance; 1583 v11 = v4->uDistance;
1582 a1.uSectorID = v10; 1584 a1.uSectorID = v10;
1583 v12 = 8 * v15;
1584 LOBYTE(v12) = 8 * v15 | AI_OBJECT_ACTOR;
1585 a1.uSpriteFrameID = 0; 1585 a1.uSpriteFrameID = 0;
1586 a1.spell_caster_pid = v12; 1586 a1.spell_caster_pid = PID(OBJECT_Actor, v15);
1587 a1.spell_target_pid = 0; 1587 a1.spell_target_pid = 0;
1588 if ( (double)v11 >= 307.2 ) 1588 if ( (double)v11 >= 307.2 )
1589 { 1589 {
1590 if ( v11 >= 1024 ) 1590 if ( v11 >= 1024 )
1591 { 1591 {
1643 signed int v2; // edx@1 1643 signed int v2; // edx@1
1644 char *v3; // ecx@2 1644 char *v3; // ecx@2
1645 unsigned __int16 v4; // ax@5 1645 unsigned __int16 v4; // ax@5
1646 int v5; // ebx@6 1646 int v5; // ebx@6
1647 int v6; // ecx@6 1647 int v6; // ecx@6
1648 int v7; // eax@6 1648 //int v7; // eax@6
1649 SpriteObject a1; // [sp+Ch] [bp-78h]@1 1649 SpriteObject a1; // [sp+Ch] [bp-78h]@1
1650 unsigned int v10; // [sp+7Ch] [bp-8h]@1 1650 unsigned int v10; // [sp+7Ch] [bp-8h]@1
1651 int v11; // [sp+80h] [bp-4h]@6 1651 int v11; // [sp+80h] [bp-4h]@6
1652 1652
1653 v10 = uActorID; 1653 v10 = uActorID;
1684 a1.uFacing = 0; 1684 a1.uFacing = 0;
1685 a1.vPosition.z = v6; 1685 a1.vPosition.z = v6;
1686 a1.uSoundID = 0; 1686 a1.uSoundID = 0;
1687 a1.uAttributes = 0; 1687 a1.uAttributes = 0;
1688 a1.uSectorID = pIndoor->GetSector(v5, a1.vPosition.y, v6); 1688 a1.uSectorID = pIndoor->GetSector(v5, a1.vPosition.y, v6);
1689 v7 = 8 * v10;
1690 LOBYTE(v7) = 8 * v10 | OBJECT_Actor;
1691 a1.uSpriteFrameID = 0; 1689 a1.uSpriteFrameID = 0;
1692 a1.spell_caster_pid = v7; 1690 a1.spell_caster_pid = PID(OBJECT_Actor, v10);
1693 a1.spell_target_pid = 0; 1691 a1.spell_target_pid = 0;
1694 a1.field_60_distance_related_prolly_lod = 3; 1692 a1.field_60_distance_related_prolly_lod = 3;
1695 a1.field_61 = 4; 1693 a1.field_61 = 4;
1696 return a1.Create(0, 0, 0, 0); 1694 return a1.Create(0, 0, 0, 0);
1697 } 1695 }
1981 v7 = a4; 1979 v7 = a4;
1982 v8 = 0; 1980 v8 = 0;
1983 v9 = &pActors[v5]; 1981 v9 = &pActors[v5];
1984 if ( !a4 ) 1982 if ( !a4 )
1985 { 1983 {
1986 v10 = Actor::GetDirectionInfo(8 * v5 | AI_OBJECT_ACTOR, v4, &a3, 0); 1984 v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v5), v4, &a3, 0);
1987 v7 = &v13; 1985 v7 = &v13;
1988 memcpy(&v13, v10, sizeof(v13)); 1986 memcpy(&v13, v10, sizeof(v13));
1989 v8 = 0; 1987 v8 = 0;
1990 } 1988 }
1991 v9->uYawAngle = LOWORD(v7->uYawAngle); 1989 v9->uYawAngle = LOWORD(v7->uYawAngle);
2018 assert(uActorID < uNumActors); 2016 assert(uActorID < uNumActors);
2019 auto actor = pActors + uActorID; 2017 auto actor = pActors + uActorID;
2020 2018
2021 AIDirection a3; 2019 AIDirection a3;
2022 if (!a4) 2020 if (!a4)
2023 a4 = Actor::GetDirectionInfo(8 * uActorID | 3, object_to_face_pid, &a3, 0); 2021 a4 = Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), object_to_face_pid, &a3, 0);
2024 2022
2025 actor->uAIState = Standing; 2023 actor->uAIState = Standing;
2026 if (!uActionLength) 2024 if (!uActionLength)
2027 actor->uCurrentActionLength = rand() % 256 + 256; 2025 actor->uCurrentActionLength = rand() % 256 + 256;
2028 else 2026 else
2119 { 2117 {
2120 v12 = arg0; 2118 v12 = arg0;
2121 v13 = 0; 2119 v13 = 0;
2122 if ( !arg0 ) 2120 if ( !arg0 )
2123 { 2121 {
2124 v14 = Actor::GetDirectionInfo(8 * v24 | OBJECT_Actor, a2, &a3, 0); 2122 v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), a2, &a3, 0);
2125 v12 = &v20; 2123 v12 = &v20;
2126 memcpy(&v20, v14, sizeof(v20)); 2124 memcpy(&v20, v14, sizeof(v20));
2127 v13 = 0; 2125 v13 = 0;
2128 } 2126 }
2129 v15 = pSpriteFrameTable->pSpriteSFrames; 2127 v15 = pSpriteFrameTable->pSpriteSFrames;
3171 Actor *v2; // eax@1 3169 Actor *v2; // eax@1
3172 unsigned __int16 v3; // dx@1 3170 unsigned __int16 v3; // dx@1
3173 int v4; // eax@3 3171 int v4; // eax@3
3174 int v5; // eax@4 3172 int v5; // eax@4
3175 unsigned int v6; // eax@6 3173 unsigned int v6; // eax@6
3176 signed int v7; // eax@12 3174 //signed int v7; // eax@12
3177 signed int v8; // [sp-18h] [bp-1Ch]@10 3175 signed int v8; // [sp-18h] [bp-1Ch]@10
3178 signed int v9; // [sp-14h] [bp-18h]@10 3176 signed int v9; // [sp-14h] [bp-18h]@10
3179 int v10; // [sp-10h] [bp-14h]@10 3177 int v10; // [sp-10h] [bp-14h]@10
3180 unsigned int v11; // [sp-Ch] [bp-10h]@10 3178 unsigned int v11; // [sp-Ch] [bp-10h]@10
3181 int v12; // [sp-8h] [bp-Ch]@10 3179 int v12; // [sp-8h] [bp-Ch]@10
3218 v11 = 0; 3216 v11 = 0;
3219 v10 = 0; 3217 v10 = 0;
3220 v9 = 0; 3218 v9 = 0;
3221 v8 = 0; 3219 v8 = 0;
3222 } 3220 }
3223 v7 = 8 * uActorID; 3221 pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, PID(OBJECT_Actor, uActorID), 0, v8, v9, v10, v11, v12);
3224 LOBYTE(v7) = 8 * uActorID | OBJECT_Actor;
3225 pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, v7, 0, v8, v9, v10, v11, v12);
3226 } 3222 }
3227 } 3223 }
3228 3224
3229 //----- (00402AD7) -------------------------------------------------------- 3225 //----- (00402AD7) --------------------------------------------------------
3230 void Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) 3226 void Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir)
3626 v12 = abs(_this->vPosition.z - actor->vPosition.z); 3622 v12 = abs(_this->vPosition.z - actor->vPosition.z);
3627 v19 = v12; 3623 v19 = v12;
3628 if ( v23 <= v11 3624 if ( v23 <= v11
3629 && v27 <= v11 3625 && v27 <= v11
3630 && v12 <= v11 3626 && v12 <= v11
3631 && sub_4070EF_prolly_collide_objects(8 * i | OBJECT_Actor, 8 * uActorID | OBJECT_Actor) 3627 && sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID))
3632 && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) 3628 && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
3633 { 3629 {
3634 v25 = v23 * v23 + v27 * v27 + v19 * v19; 3630 v25 = v23 * v23 + v27 * v27 + v19 * v19;
3635 v21 = i; 3631 v21 = i;
3636 } 3632 }
3643 } 3639 }
3644 if ( v25 != -1 ) 3640 if ( v25 != -1 )
3645 { 3641 {
3646 //v13 = 8 * v21; 3642 //v13 = 8 * v21;
3647 //LOBYTE(v13) = 8 * v21 | OBJECT_Actor; 3643 //LOBYTE(v13) = 8 * v21 | OBJECT_Actor;
3648 *a2 = 8 * v21 | OBJECT_Actor; 3644 *a2 = PID(OBJECT_Actor, v21);
3649 } 3645 }
3650 3646
3651 if (pParty->Invisible()) 3647 if (pParty->Invisible())
3652 can_target_party = false; 3648 can_target_party = false;
3653 3649