comparison Actor.cpp @ 1862:a2bdc17ffd2f

Actor::AI_RangedAttack cleaned up
author Grumpy7
date Mon, 14 Oct 2013 07:32:04 +0200
parents a86c60679949
children 97b75e6100ff
comparison
equal deleted inserted replaced
1861:a86c60679949 1862:a2bdc17ffd2f
739 //----- (0043ABB0) -------------------------------------------------------- 739 //----- (0043ABB0) --------------------------------------------------------
740 bool Actor::ArePeasantsOfSameFaction(Actor *a1, Actor *a2) 740 bool Actor::ArePeasantsOfSameFaction(Actor *a1, Actor *a2)
741 { 741 {
742 unsigned int v2; // esi@1 742 unsigned int v2; // esi@1
743 unsigned int v3; // edi@1 743 unsigned int v3; // edi@1
744 bool result; // eax@9
745 744
746 v2 = a1->uAlly; 745 v2 = a1->uAlly;
747 v3 = a2->uAlly; 746 v3 = a2->uAlly;
748 if ( !v2 ) 747 if ( !v2 )
749 v2 = (a1->pMonsterInfo.uID - 1) / 3 + 1; 748 v2 = (a1->pMonsterInfo.uID - 1) / 3 + 1;
794 } 793 }
795 } 794 }
796 } 795 }
797 796
798 //----- (00404874) -------------------------------------------------------- 797 //----- (00404874) --------------------------------------------------------
799 char __fastcall Actor::AI_RangedAttack(unsigned int uActorID, AIDirection *a2, int a3, char a4) 798 void Actor::AI_RangedAttack( unsigned int uActorID, struct AIDirection *pDir, int type, char a4 )
800 { 799 {
801 AIDirection *v4; // edi@1 800 Actor *actPtr; // esi@1
802 Actor *v5; // esi@1 801 char specAb; // al@1
803 char result; // al@1
804 char *v7; // eax@15
805 unsigned __int16 v8; // ax@18
806 unsigned __int16 v9; // ax@19
807 __int16 v10; // ax@19
808 signed int v11; // ecx@19
809 //int v12; // eax@19
810 int v13; // edx@28 802 int v13; // edx@28
811 //SpriteObject a1; // [sp+Ch] [bp-74h]@1 803
812 unsigned int v15; // [sp+7Ch] [bp-4h]@1 804 actPtr = &pActors[uActorID];
813 signed int v16; // [sp+88h] [bp+8h]@14
814 signed int v17; // [sp+88h] [bp+8h]@19
815
816 v15 = uActorID;
817 v4 = a2;
818 v5 = &pActors[uActorID];
819 805
820 SpriteObject a1; // [sp+Ch] [bp-74h]@1 806 SpriteObject a1; // [sp+Ch] [bp-74h]@1
821 //SpriteObject::SpriteObject(&a1); 807
822 808 switch ( type )
823 result = a3 - 1;
824 switch ( a3 )
825 { 809 {
826 case 1: 810 case 1:
827 a1.uType = 545; 811 a1.uType = 545;
828 goto LABEL_14; 812 break;
829 case 2: 813 case 2:
830 a1.uType = 550; 814 a1.uType = 550;
831 goto LABEL_14; 815 break;
832 case 3: 816 case 3:
833 a1.uType = 510; 817 a1.uType = 510;
834 goto LABEL_14; 818 break;
835 case 4: 819 case 4:
836 a1.uType = 500; 820 a1.uType = 500;
837 goto LABEL_14; 821 break;
838 case 5: 822 case 5:
839 a1.uType = 515; 823 a1.uType = 515;
840 goto LABEL_14; 824 break;
841 case 6: 825 case 6:
842 a1.uType = 505; 826 a1.uType = 505;
843 goto LABEL_14; 827 break;
844 case 7: 828 case 7:
845 a1.uType = 530; 829 a1.uType = 530;
846 goto LABEL_14; 830 break;
847 case 8: 831 case 8:
848 a1.uType = 525; 832 a1.uType = 525;
849 goto LABEL_14; 833 break;
850 case 9: 834 case 9:
851 a1.uType = 520; 835 a1.uType = 520;
852 goto LABEL_14; 836 break;
853 case 10: 837 case 10:
854 a1.uType = 535; 838 a1.uType = 535;
855 goto LABEL_14; 839 break;
856 case 11: 840 case 11:
857 a1.uType = 540; 841 a1.uType = 540;
858 goto LABEL_14; 842 break;
859 case 13: 843 case 13:
860 a1.uType = 555; 844 a1.uType = 555;
861 LABEL_14:
862 v16 = 0;
863 if ( (signed int)pObjectList->uNumObjects <= 0 )
864 goto LABEL_18;
865 v7 = (char *)&pObjectList->pObjects->uObjectID;
866 break; 845 break;
867 default: 846 default:
868 return result; 847 return;
869 } 848 }
870 while ( (short)a1.uType != *(short *)v7 ) 849 a1.uObjectDescID = GetObjDescId(a1.uType);
871 {
872 ++v16;
873 v7 += 56;
874 if ( v16 >= (signed int)pObjectList->uNumObjects )
875 {
876 LABEL_18:
877 v8 = 0;
878 goto LABEL_19;
879 }
880 }
881 v8 = v16;
882 LABEL_19:
883 a1.uObjectDescID = v8;
884 a1.stru_24.Reset(); 850 a1.stru_24.Reset();
885 a1.vPosition.x = v5->vPosition.x; 851 a1.vPosition.x = actPtr->vPosition.x;
886 a1.spell_id = 0; 852 a1.spell_id = 0;
887 a1.vPosition.y = v5->vPosition.y; 853 a1.vPosition.y = actPtr->vPosition.y;
888 a1.spell_level = 0; 854 a1.spell_level = 0;
889 v17 = v5->uActorHeight;
890 a1.spell_skill = 0; 855 a1.spell_skill = 0;
891 v9 = LOWORD(v4->uYawAngle); 856 a1.vPosition.z = actPtr->vPosition.z - (unsigned int)(actPtr->uActorHeight * -0.75);
892 a1.vPosition.z = v5->vPosition.z - (unsigned int)(signed __int64)((double)v17 * -0.75); 857 a1.uFacing = pDir->uYawAngle;
893 a1.uFacing = v9;
894 a1.uSoundID = 0; 858 a1.uSoundID = 0;
895 a1.uAttributes = 0; 859 a1.uAttributes = 0;
896 v10 = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); 860 a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z);
897 v11 = v4->uDistance;
898 a1.uSectorID = v10;
899 a1.uSpriteFrameID = 0; 861 a1.uSpriteFrameID = 0;
900 a1.spell_caster_pid = PID(OBJECT_Actor, v15); 862 a1.spell_caster_pid = PID(OBJECT_Actor, uActorID);
901 a1.spell_target_pid = 0; 863 a1.spell_target_pid = 0;
902 if ( (double)v11 >= 307.2 ) 864 if (pDir->uDistance < 307.2 )
903 {
904 if ( v11 >= 1024 )
905 {
906 a1.field_60_distance_related_prolly_lod = 2;
907 if ( v11 >= 2560 )
908 a1.field_60_distance_related_prolly_lod = 3;
909 }
910 else
911 {
912 a1.field_60_distance_related_prolly_lod = 1;
913 }
914 }
915 else
916 {
917 a1.field_60_distance_related_prolly_lod = 0; 865 a1.field_60_distance_related_prolly_lod = 0;
918 } 866 else if ( pDir->uDistance < 1024 )
867 a1.field_60_distance_related_prolly_lod = 1;
868 else if ( pDir->uDistance < 2560 )
869 a1.field_60_distance_related_prolly_lod = 2;
870 else
871 a1.field_60_distance_related_prolly_lod = 3;
872
919 a1.field_61 = a4; 873 a1.field_61 = a4;
920 result = a1.Create( 874 a1.Create(
921 v4->uYawAngle, 875 pDir->uYawAngle,
922 v4->uPitchAngle, 876 pDir->uPitchAngle,
923 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 877 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
924 0); 878 0);
925 if ( v5->pMonsterInfo.uSpecialAbilityType == 1 ) 879 if ( actPtr->pMonsterInfo.uSpecialAbilityType == 1 )
926 { 880 {
927 result = v5->pMonsterInfo.uSpecialAbilityDamageDiceBonus; 881 specAb = actPtr->pMonsterInfo.uSpecialAbilityDamageDiceBonus;
928 if ( result == 2 ) 882 if ( specAb == 2 )
929 { 883 {
930 a1.vPosition.z += 40; 884 a1.vPosition.z += 40;
931 v13 = v4->uYawAngle; 885 v13 = pDir->uYawAngle;
932 } 886 }
933 else 887 else
934 { 888 {
935 if ( result != 3 ) 889 if ( specAb != 3 )
936 return result; 890 return;
937 a1.Create( 891 a1.Create(
938 v4->uYawAngle + 30, 892 pDir->uYawAngle + 30, //TODO find out why the YawAngle change
939 v4->uPitchAngle, 893 pDir->uPitchAngle,
940 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 894 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
941 0); 895 0);
942 v13 = v4->uYawAngle - 30; 896 v13 = pDir->uYawAngle - 30;
943 } 897 }
944 result = a1.Create( 898 a1.Create(
945 v13, 899 v13,
946 v4->uPitchAngle, 900 pDir->uPitchAngle,
947 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 901 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
948 0); 902 0);
949 } 903 }
950 return result; 904 return;
951 } 905 }
952 906
953 //----- (00404736) -------------------------------------------------------- 907 //----- (00404736) --------------------------------------------------------
954 signed int __fastcall Actor::Explode(unsigned int uActorID) 908 signed int __fastcall Actor::Explode(unsigned int uActorID)
955 { 909 {