comparison SpriteObject.cpp @ 1406:d071e0e9ba75

Explosion Traps fix
author Ritor1
date Tue, 23 Jul 2013 15:41:45 +0600
parents 613c77e51e38
children c9e3b93ec570
comparison
equal deleted inserted replaced
1405:c0b273d33338 1406:d071e0e9ba75
51 } 51 }
52 52
53 //----- (0042F5ED) -------------------------------------------------------- 53 //----- (0042F5ED) --------------------------------------------------------
54 int SpriteObject::Create(int yaw, int pitch, int a4, int a5) 54 int SpriteObject::Create(int yaw, int pitch, int a4, int a5)
55 { 55 {
56 //SpriteObject *v5; // eax@1
57 signed int v6; // ebx@2 56 signed int v6; // ebx@2
58 //char *v7; // ecx@2
59 //signed int result; // eax@6
60 SpriteObject *v9; // ebx@7
61 int v10; // edx@11
62 int v11; // edi@18
63 __int16 v12; // ax@18
64 int v13; // ST2C_4@20 57 int v13; // ST2C_4@20
65 int v14; // eax@20
66 int v15; // [sp-28h] [bp-38h]@14
67 int v16; // [sp-24h] [bp-34h]@11
68 Vec3_int_ v17; // [sp-20h] [bp-30h]@11 58 Vec3_int_ v17; // [sp-20h] [bp-30h]@11
69 int *v18; // [sp-14h] [bp-24h]@11
70 int *v19; // [sp-10h] [bp-20h]@11
71 int *v20; // [sp-Ch] [bp-1Ch]@11
72 //signed int v21; // [sp+8h] [bp-8h]@2
73 int angle; // [sp+Ch] [bp-4h]@1 59 int angle; // [sp+Ch] [bp-4h]@1
74 int a4a; // [sp+1Ch] [bp+Ch]@20
75 int a4b; // [sp+1Ch] [bp+Ch]@20
76 int a5a; // [sp+20h] [bp+10h]@20 60 int a5a; // [sp+20h] [bp+10h]@20
77 61
78 //auto a1 = this;
79 angle = yaw; 62 angle = yaw;
80 //v5 = a1;
81 if (!uObjectDescID) 63 if (!uObjectDescID)
82 return -1; 64 return -1;
83 65
84 v6 = 1000; 66 v6 = 1000;
85 //v7 = (char *)&pSpriteObjects[0].uObjectDescID;
86 /*v21 = 0;
87 do
88 {
89 if ( !*(short *)v7 )
90 break;
91 v7 += 112;
92 ++v6;
93 v21 = v6;
94 }
95 while ( (signed int)v7 < (signed int)((char *)&pObjectList->uNumObjects + 2) );*/
96 for (uint i = 0; i < MAX_SPRITE_OBJECTS; ++i) 67 for (uint i = 0; i < MAX_SPRITE_OBJECTS; ++i)
97 if (!pSpriteObjects[i].uObjectDescID) 68 if (!pSpriteObjects[i].uObjectDescID)
98 { 69 {
99 v6 = i; 70 v6 = i;
100 break; 71 break;
102 73
103 if ( v6 >= 1000 ) 74 if ( v6 >= 1000 )
104 return -1; 75 return -1;
105 field_64.x = vPosition.x; 76 field_64.x = vPosition.x;
106 field_64.y = vPosition.y; 77 field_64.y = vPosition.y;
107 v9 = &pSpriteObjects[v6];
108 field_64.z = vPosition.z; 78 field_64.z = vPosition.z;
109 79
110 assert(sizeof(SpriteObject) == 0x70); 80 assert(sizeof(SpriteObject) == 0x70);
111 memcpy(v9, this, sizeof(*this)); 81 memcpy(&pSpriteObjects[v6], this, sizeof(*this));
82 if ( a5 == 0 )
83 {
84 pSpriteObjects[v6].vVelocity.z = 0;
85 if ( a4 )
86 {
87 v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
88 a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
89 pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
90 pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
91 pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
92 }
93 else
94 {
95 pSpriteObjects[v6].vVelocity.y = 0;
96 pSpriteObjects[v6].vVelocity.x = 0;
97 }
98 if ( v6 >= (signed int)uNumSpriteObjects )
99 uNumSpriteObjects = v6 + 1;
100 return v6;
101 }
112 if ( a5 == 1 ) 102 if ( a5 == 1 )
113 { 103 {
114 v20 = &v9->vPosition.z;
115 v19 = &v9->vPosition.y;
116 v18 = (int *)&v9->vPosition;
117 v17.x = vPosition.x; 104 v17.x = vPosition.x;
118 v17.y = vPosition.y; 105 v17.y = vPosition.y;
119 v17.z = vPosition.z; 106 v17.z = vPosition.z;
120 v16 = 0; 107 Vec3_int_::Rotate(24, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x,
121 v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; 108 &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z);
122 goto LABEL_16; 109 pSpriteObjects[v6].vVelocity.z = 0;
110 if ( a4 )
111 {
112 v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
113 a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
114 pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
115 pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
116 pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
117 }
118 else
119 {
120 pSpriteObjects[v6].vVelocity.y = 0;
121 pSpriteObjects[v6].vVelocity.x = 0;
122 }
123 if ( v6 >= (signed int)uNumSpriteObjects )
124 uNumSpriteObjects = v6 + 1;
125 return v6;
123 } 126 }
124 if ( a5 == 2 ) 127 if ( a5 == 2 )
125 { 128 {
126 v20 = &v9->vPosition.z;
127 v19 = &v9->vPosition.y;
128 v18 = (int *)&v9->vPosition;
129 v17.x = vPosition.x; 129 v17.x = vPosition.x;
130 v17.y = vPosition.y; 130 v17.y = vPosition.y;
131 v17.z = vPosition.z; 131 v17.z = vPosition.z;
132 v16 = 0; 132 Vec3_int_::Rotate(8, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x,
133 v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; 133 &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z);
134 goto LABEL_14; 134 pSpriteObjects[v6].vVelocity.z = 0;
135 if ( a4 )
136 {
137 v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
138 a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
139 pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
140 pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
141 pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
142 }
143 else
144 {
145 pSpriteObjects[v6].vVelocity.y = 0;
146 pSpriteObjects[v6].vVelocity.x = 0;
147 }
148 if ( v6 >= (signed int)uNumSpriteObjects )
149 uNumSpriteObjects = v6 + 1;
150 return v6;
135 } 151 }
136 if ( a5 == 3 ) 152 if ( a5 == 3 )
137 { 153 {
138 v20 = &v9->vPosition.z;
139 v19 = &v9->vPosition.y;
140 v18 = (int *)&v9->vPosition;
141 v17.x = vPosition.x; 154 v17.x = vPosition.x;
142 v17.y = vPosition.y; 155 v17.y = vPosition.y;
143 v17.z = vPosition.z; 156 v17.z = vPosition.z;
144 v16 = 0; 157 Vec3_int_::Rotate(8, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x,
145 v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; 158 &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z);
146 LABEL_14: 159 pSpriteObjects[v6].vVelocity.z = 0;
147 v15 = 8; 160 if ( a4 )
148 LABEL_17: 161 {
149 Vec3_int_::Rotate(v15, v10, v16, v17, v18, v19, v20); 162 v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
150 goto LABEL_18; 163 a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
164 pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
165 pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
166 pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
167 }
168 else
169 {
170 pSpriteObjects[v6].vVelocity.y = 0;
171 pSpriteObjects[v6].vVelocity.x = 0;
172 }
173 if ( v6 >= (signed int)uNumSpriteObjects )
174 uNumSpriteObjects = v6 + 1;
175 return v6;
151 } 176 }
152 if ( a5 == 4 ) 177 if ( a5 == 4 )
153 { 178 {
154 v20 = &v9->vPosition.z;
155 v19 = &v9->vPosition.y;
156 v18 = (int *)&v9->vPosition;
157 v17.x = vPosition.x; 179 v17.x = vPosition.x;
158 v17.y = vPosition.y; 180 v17.y = vPosition.y;
159 v17.z = vPosition.z; 181 v17.z = vPosition.z;
160 v16 = 0; 182 Vec3_int_::Rotate(24, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x,
161 v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; 183 &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z);
162 LABEL_16: 184 pSpriteObjects[v6].vVelocity.z = 0;
163 v15 = 24; 185 if ( a4 )
164 goto LABEL_17; 186 {
165 } 187 v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
166 LABEL_18: 188 a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
167 v11 = a4; 189 pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
168 v12 = 0; 190 pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
169 if ( a4 ) 191 pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
170 { 192 }
171 a4a = stru_5C6E00->Cos(angle); 193 else
172 v13 = (unsigned __int64)(a4a * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; 194 {
173 a4b = stru_5C6E00->Sin(angle); 195 pSpriteObjects[v6].vVelocity.y = 0;
174 a5a = (unsigned __int64)(a4b * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; 196 pSpriteObjects[v6].vVelocity.x = 0;
175 v14 = stru_5C6E00->Sin(pitch); 197 }
176 v9->vVelocity.x = (unsigned int)(v13 * v11) >> 16; 198 if ( v6 >= (signed int)uNumSpriteObjects )
177 v9->vVelocity.y = (unsigned int)(a5a * v11) >> 16; 199 uNumSpriteObjects = v6 + 1;
178 v12 = (unsigned int)(v14 * v11) >> 16; 200 return v6;
179 } 201 }
180 else
181 {
182 v9->vVelocity.y = 0;
183 v9->vVelocity.x = 0;
184 }
185 v9->vVelocity.z = v12;
186
187 if ( v6 >= (signed int)uNumSpriteObjects )
188 uNumSpriteObjects = v6 + 1;
189 return v6;
190 } 202 }
191 203
192 //----- (00471C03) -------------------------------------------------------- 204 //----- (00471C03) --------------------------------------------------------
193 void SpriteObject::UpdateObject_fn0_ODM(unsigned int uLayingItemID) 205 void SpriteObject::UpdateObject_fn0_ODM(unsigned int uLayingItemID)
194 { 206 {
968 } 980 }
969 } 981 }
970 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); 982 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
971 983
972 //----- (00438E35) -------------------------------------------------------- 984 //----- (00438E35) --------------------------------------------------------
973 void SpriteObject::_438E35() 985 void SpriteObject::ExplosionTraps()
974 { 986 {
975 SpriteObject *v1; // edi@1
976 MapInfo *pMapInfo; // esi@1 987 MapInfo *pMapInfo; // esi@1
977 int v3; // ebx@1 988 int dir_x; // ebx@1
978 int v4; // eax@1
979 int v5; // ebx@1
980 unsigned int v6; // ecx@1
981 int v7; // edx@2 989 int v7; // edx@2
982 unsigned int v8; // edx@4
983 unsigned int v9; // edx@6
984 unsigned int v10; // eax@7 990 unsigned int v10; // eax@7
985 signed int v11; // ebx@8 991 signed int v11; // ebx@8
986 Player **v12; // esi@18
987 signed int v13; // edi@20 992 signed int v13; // edi@20
988 int v15; // [sp+Ch] [bp-Ch]@1 993 int dir_y; // [sp+Ch] [bp-Ch]@1
989 int v16; // [sp+10h] [bp-8h]@1 994 int dir_z; // [sp+10h] [bp-8h]@1
990 signed int v17; // [sp+14h] [bp-4h]@8 995 DAMAGE_TYPE pDamageType; // [sp+14h] [bp-4h]@14
991 int v18; // [sp+14h] [bp-4h]@14 996
992
993 v1 = this;
994 pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())]; 997 pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())];
995 v3 = abs(pParty->vPosition.x - v1->vPosition.x); 998 dir_x = abs(pParty->vPosition.x - this->vPosition.x);
996 v15 = abs(pParty->vPosition.y - v1->vPosition.y); 999 dir_y = abs(pParty->vPosition.y - this->vPosition.y);
997 v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z); 1000 dir_z = abs(pParty->vPosition.z + pParty->sEyelevel - this->vPosition.z);
998 v4 = v3; 1001 if ( dir_x < dir_y )
999 v5 = v15; 1002 {
1000 v6 = v16; 1003 v7 = dir_x;
1001 if ( v4 < v15 ) 1004 dir_x = dir_y;
1002 { 1005 dir_y = v7;
1003 v7 = v4; 1006 }
1004 v4 = v15; 1007 if ( dir_x < dir_z )
1005 v5 = v7; 1008 {
1006 } 1009 v7 = dir_x;
1007 if ( v4 < v16 ) 1010 dir_x = dir_z;
1008 { 1011 dir_z = v7;
1009 v8 = v4; 1012 }
1010 v4 = v16; 1013 if ( dir_y < dir_z )
1011 v6 = v8; 1014 {
1012 } 1015 v7 = dir_z;
1013 if ( v5 < (signed int)v6 ) 1016 dir_z = dir_y;
1014 { 1017 dir_y = v7;
1015 v9 = v6; 1018 }
1016 v6 = v5; 1019 v10 = ((unsigned int)(11 * dir_y) >> 5) + (dir_z / 4) + dir_x;
1017 v5 = v9;
1018 }
1019 v10 = ((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4;
1020 if ( (signed int)v10 <= 768 ) 1020 if ( (signed int)v10 <= 768 )
1021 { 1021 {
1022 v17 = 0;
1023 v11 = 5; 1022 v11 = 5;
1024 if ( pMapInfo->Trap_D20 ) 1023 if ( pMapInfo->Trap_D20 )
1025 { 1024 {
1026 do 1025 for ( uint i = 0; i < pMapInfo->Trap_D20; ++i )
1027 {
1028 ++v17;
1029 v11 += rand() % 20 + 1; 1026 v11 += rand() % 20 + 1;
1030 } 1027 }
1031 while ( v17 < pMapInfo->Trap_D20 ); 1028 switch ( this->uType )
1032 } 1029 {
1033 switch ( v1->uType ) 1030 case 811:
1034 { 1031 pDamageType = DMGT_FIRE;
1035 case 0x32Bu:
1036 v18 = 0;
1037 break; 1032 break;
1038 case 0x32Cu: 1033 case 812:
1039 v18 = 1; 1034 pDamageType = DMGT_ELECTR;
1040 break; 1035 break;
1041 case 0x32Du: 1036 case 813:
1042 v18 = 2; 1037 pDamageType = DMGT_COLD;
1038 break;
1039 case 814:
1040 pDamageType = DMGT_BODY;
1043 break; 1041 break;
1044 default: 1042 default:
1045 //LOWORD(v10) = v1->uItemType - 814; 1043 return;
1046 if ( v1->uType != 814 ) 1044 }
1047 return; 1045 for ( uint i = 1; i <= 4; ++i )
1048 v18 = 8; 1046 {
1049 break; 1047 if ( pPlayers[i]->CanAct() && (v13 = pPlayers[i]->GetPerception() + 20, rand() % v13 > 20) )
1050 } 1048 pPlayers[i]->PlaySound(SPEECH_6, 0);
1051 v12 = &pPlayers[1];
1052 do
1053 {
1054 if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) )
1055 (*v12)->PlaySound(SPEECH_6, 0);
1056 else 1049 else
1057 (*v12)->ReceiveDamage(v11, (DAMAGE_TYPE)v18); 1050 pPlayers[i]->ReceiveDamage(v11, pDamageType);
1058 ++v12; 1051 }
1059 }
1060 while ( (signed int)v12 <= (signed int)&pPlayers[4] );
1061 } 1052 }
1062 } 1053 }
1063 1054
1064 //----- (0042F933) -------------------------------------------------------- 1055 //----- (0042F933) --------------------------------------------------------
1065 void SpriteObject::OnInteraction(unsigned int uLayingItemID) 1056 void SpriteObject::OnInteraction(unsigned int uLayingItemID)