comparison Actor.cpp @ 1871:e26d8d15ef30

Actor::AI_MeleeAttack cleaned up
author Grumpy7
date Thu, 17 Oct 2013 03:47:21 +0200
parents 7a193504f18e
children a53bd0511de2
comparison
equal deleted inserted replaced
1870:7a193504f18e 1871:e26d8d15ef30
1218 1218
1219 //----- (00403C6C) -------------------------------------------------------- 1219 //----- (00403C6C) --------------------------------------------------------
1220 void Actor::AI_MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0) 1220 void Actor::AI_MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0)
1221 { 1221 {
1222 Actor *v3; // ebx@1 1222 Actor *v3; // ebx@1
1223 char v4; // zf@1 1223 int16_t v6; // esi@6
1224 //unsigned int result; // eax@3 1224 int16_t v7; // edi@6
1225 AIDirection *v6; // esi@6
1226 AIDirection *v7; // edi@6
1227 signed int v8; // eax@7 1225 signed int v8; // eax@7
1228 double v9; // st7@9
1229 Vec3_int_ v10; // ST04_12@9 1226 Vec3_int_ v10; // ST04_12@9
1230 //int v11; // eax@10
1231 AIDirection *v12; // eax@11 1227 AIDirection *v12; // eax@11
1232 unsigned int v13; // esi@11
1233 AIDirection *v14; // esi@12
1234 SpriteFrame *v15; // ecx@13
1235 __int16 v16; // ax@13
1236 unsigned int v17; // ecx@13
1237 signed __int64 v18; // qax@13
1238 AIDirection a3; // [sp+Ch] [bp-48h]@12 1228 AIDirection a3; // [sp+Ch] [bp-48h]@12
1239 AIDirection v20; // [sp+28h] [bp-2Ch]@12 1229 AIDirection v20; // [sp+28h] [bp-2Ch]@12
1240 unsigned int v21; // [sp+44h] [bp-10h]@9
1241 //signed int a2; // [sp+48h] [bp-Ch]@1
1242 int v23; // [sp+4Ch] [bp-8h]@6 1230 int v23; // [sp+4Ch] [bp-8h]@6
1243 unsigned int v24; // [sp+50h] [bp-4h]@1
1244 unsigned int v25; // [sp+5Ch] [bp+8h]@13 1231 unsigned int v25; // [sp+5Ch] [bp+8h]@13
1245 1232
1246 v3 = &pActors[uActorID]; 1233 v3 = &pActors[uActorID];
1247 //a2 = edx0; 1234 if ( v3->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY && v3->pMonsterInfo.uAIType == 1 )
1248 v4 = v3->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY;
1249 v24 = uActorID;
1250 if ( v4 && v3->pMonsterInfo.uAIType == 1 )
1251 { 1235 {
1252 Actor::AI_Stand(uActorID, sTargetPid, 0, arg0); 1236 Actor::AI_Stand(uActorID, sTargetPid, 0, arg0);
1253 return; 1237 return;
1254 } 1238 }
1255 1239
1256 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) 1240 if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
1257 { 1241 {
1258 v8 = PID_ID(sTargetPid); 1242 v8 = PID_ID(sTargetPid);
1259 v6 = (AIDirection *)pActors[v8].vPosition.x; 1243 v6 = pActors[v8].vPosition.x;
1260 v7 = (AIDirection *)pActors[v8].vPosition.y; 1244 v7 = pActors[v8].vPosition.y;
1261 v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z); 1245 v23 = (int)(pActors[v8].uActorHeight * 0.75 + pActors[v8].vPosition.z);
1262 } 1246 }
1263 else if ( PID_TYPE(sTargetPid) == OBJECT_Player) 1247 else if ( PID_TYPE(sTargetPid) == OBJECT_Player)
1264 { 1248 {
1265 v6 = (AIDirection *)pParty->vPosition.x; 1249 v6 = pParty->vPosition.x;
1266 v7 = (AIDirection *)pParty->vPosition.y; 1250 v7 = pParty->vPosition.y;
1267 v23 = pParty->vPosition.z + pParty->sEyelevel; 1251 v23 = pParty->vPosition.z + pParty->sEyelevel;
1268 } 1252 }
1269 else 1253 else
1270 { 1254 {
1271 v6 = arg0; 1255 Error("Should not get here");
1272 v7 = arg0; 1256 return;
1273 } 1257 }
1274 v21 = v3->uActorHeight; 1258 v10.z = (int32_t)(v3->uActorHeight * 0.75 + v3->vPosition.z);
1275 v9 = (double)(signed int)v21 * 0.75;
1276 v21 = v3->vPosition.z;
1277 v10.z = (signed __int64)(v9 + (double)(signed int)v21);
1278 v10.y = v3->vPosition.y; 1259 v10.y = v3->vPosition.y;
1279 v10.x = v3->vPosition.x; 1260 v10.x = v3->vPosition.x;
1261
1280 if ( sub_407A1C((int)v6, (int)v7, v23, v10) ) 1262 if ( sub_407A1C((int)v6, (int)v7, v23, v10) )
1281 { 1263 {
1282 v12 = arg0; 1264 if (arg0 != nullptr)
1283 v13 = 0; 1265 {
1284 if ( !arg0 ) 1266 v12 = arg0;
1285 { 1267 }
1286 v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), sTargetPid, &a3, 0); 1268 else
1287 v12 = &v20; 1269 {
1288 memcpy(&v20, v14, sizeof(v20)); 1270 v12 = Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), sTargetPid, &a3, 0);
1289 v13 = 0; 1271 }
1290 }
1291 v15 = pSpriteFrameTable->pSpriteSFrames;
1292 v3->uYawAngle = LOWORD(v12->uYawAngle); 1272 v3->uYawAngle = LOWORD(v12->uYawAngle);
1293 v16 = v15[v3->pSpriteIDs[ANIM_AtkMelee]].uAnimLength; 1273 v3->uCurrentActionLength = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkMelee]].uAnimLength * 8;
1294 v17 = v24; 1274 v3->uCurrentActionTime = 0;
1295 v3->uCurrentActionLength = 8 * v16;
1296 v3->uCurrentActionTime = v13;
1297 v3->uAIState = AttackingMelee; 1275 v3->uAIState = AttackingMelee;
1298 Actor::PlaySound(v17, 0); 1276 Actor::PlaySound(uActorID, 0);
1299 LODWORD(v18) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
1300 v25 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; 1277 v25 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
1301 if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v13
1302 && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v13 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v13) )
1303 {
1304 LODWORD(v18) = 2 * v18;
1305 v25 = v18;
1306 }
1307 if ( pParty->bTurnBasedModeOn != 1 ) 1278 if ( pParty->bTurnBasedModeOn != 1 )
1308 v18 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)v25 * 2.133333333333333); 1279 {
1309 v3->pMonsterInfo.uRecoveryTime = v18; 1280 v3->pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * v25 * 2.133333333333333);
1310 v3->vVelocity.z = v13; 1281 }
1311 v3->vVelocity.y = v13; 1282 else if ( v3->pActorBuffs[7].uExpireTime > 0 )
1312 v3->vVelocity.x = v13; 1283 {
1284 v3->pMonsterInfo.uRecoveryTime = v25 * 2;
1285 }
1286 else
1287 {
1288 v3->pMonsterInfo.uRecoveryTime = v25;
1289 }
1290 v3->vVelocity.z = 0;
1291 v3->vVelocity.y = 0;
1292 v3->vVelocity.x = 0;
1313 v3->UpdateAnimation(); 1293 v3->UpdateAnimation();
1314 } 1294 }
1315 else 1295 else
1316 Actor::AI_Pursue1(v24, sTargetPid, rand() % 2, 64, arg0); 1296 Actor::AI_Pursue1(uActorID, sTargetPid, rand() % 2, 64, arg0);
1317 } 1297 }
1318 1298
1319 //----- (00438CF3) -------------------------------------------------------- 1299 //----- (00438CF3) --------------------------------------------------------
1320 void Actor::ApplyFineForKillingPeasant(unsigned int uActorID) 1300 void Actor::ApplyFineForKillingPeasant(unsigned int uActorID)
1321 { 1301 {