Mercurial > mm7
comparison Actor.cpp @ 1295:86a83e12d795
moving files
author | Ritor1 |
---|---|
date | Mon, 17 Jun 2013 17:34:01 +0600 |
parents | fac7751b2dc9 |
children | 5450af4f57ef |
comparison
equal
deleted
inserted
replaced
1294:6bbd50bda571 | 1295:86a83e12d795 |
---|---|
31 #include "GUIWindow.h" | 31 #include "GUIWindow.h" |
32 #include "GUIFont.h" | 32 #include "GUIFont.h" |
33 | 33 |
34 #include "MM7.h" | 34 #include "MM7.h" |
35 #include "SpriteObject.h" | 35 #include "SpriteObject.h" |
36 | 36 #include "stru298.h" |
37 | 37 |
38 | 38 |
39 | 39 |
40 | 40 |
41 | 41 |
3977 LOBYTE(result) = PID(OBJECT_Actor,v24); | 3977 LOBYTE(result) = PID(OBJECT_Actor,v24); |
3978 v8->uSummonerID = result; | 3978 v8->uSummonerID = result; |
3979 } | 3979 } |
3980 return result; | 3980 return result; |
3981 } | 3981 } |
3982 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); | |
3983 //----- (0046DF1A) -------------------------------------------------------- | |
3984 signed int __fastcall _46DF1A_collide_against_actor(int a1, int a2) | |
3985 { | |
3986 Actor *v2; // edi@1 | |
3987 unsigned __int16 v3; // ax@1 | |
3988 int v4; // esi@6 | |
3989 int v5; // ecx@8 | |
3990 int v6; // eax@10 | |
3991 int v7; // edx@12 | |
3992 int v8; // ecx@14 | |
3993 int v9; // eax@14 | |
3994 int v10; // ebx@14 | |
3995 int v11; // esi@14 | |
3996 int v12; // ebx@15 | |
3997 int v13; // ebx@17 | |
3998 unsigned int v14; // eax@20 | |
3999 signed int result; // eax@21 | |
4000 int v16; // [sp+Ch] [bp-10h]@1 | |
4001 int v17; // [sp+10h] [bp-Ch]@14 | |
4002 int v18; // [sp+14h] [bp-8h]@14 | |
4003 int v19; // [sp+18h] [bp-4h]@14 | |
4004 | |
4005 v16 = a1; | |
4006 v2 = &pActors[a1]; | |
4007 v3 = v2->uAIState; | |
4008 if ( v3 == 11 || v3 == 4 || v3 == 19 || v3 == 5 || v3 == 17 ) | |
4009 goto LABEL_25; | |
4010 v4 = v2->uActorRadius; | |
4011 if ( a2 ) | |
4012 v4 = a2; | |
4013 v5 = v2->vPosition.x; | |
4014 if ( stru_721530.sMaxX > v5 + v4 | |
4015 || stru_721530.sMinX < v5 - v4 | |
4016 || (v6 = v2->vPosition.y, stru_721530.sMaxY > v6 + v4) | |
4017 || stru_721530.sMinY < v6 - v4 | |
4018 || (v7 = v2->vPosition.z, stru_721530.sMaxZ > v7 + v2->uActorHeight) | |
4019 || stru_721530.sMinZ < v7 | |
4020 || (v8 = v5 - stru_721530.normal.x, | |
4021 v9 = v6 - stru_721530.normal.y, | |
4022 v10 = stru_721530.prolly_normal_d + v4, | |
4023 v17 = stru_721530.prolly_normal_d + v4, | |
4024 v11 = (v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16, | |
4025 v18 = v8, | |
4026 v19 = v9, | |
4027 abs((v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16) > v10) | |
4028 || (v12 = (v18 * stru_721530.field_58.x + v19 * stru_721530.field_58.y) >> 16, v12 <= 0) | |
4029 || (signed int)(((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v12) >> 16) + stru_721530.normal.z) < v2->vPosition.z ) | |
4030 { | |
4031 LABEL_25: | |
4032 result = 0; | |
4033 } | |
4034 else | |
4035 { | |
4036 v13 = v12 - integer_sqrt(v17 * v17 - v11 * v11); | |
4037 if ( v13 < 0 ) | |
4038 v13 = 0; | |
4039 if ( v13 < stru_721530.field_7C ) | |
4040 { | |
4041 stru_721530.field_7C = v13; | |
4042 v14 = 8 * v16; | |
4043 LOBYTE(v14) = PID(OBJECT_Actor,v16); | |
4044 stru_721530.uFaceID = v14; | |
4045 } | |
4046 result = 1; | |
4047 } | |
4048 return result; | |
4049 } | |
4050 //----- (00401A91) -------------------------------------------------------- | |
4051 void __cdecl UpdateActorAI() | |
4052 { | |
4053 //unsigned int v0; // esi@4 | |
4054 int v1; // eax@7 | |
4055 //int v2; // ecx@7 | |
4056 //int v3; // eax@7 | |
4057 signed int v4; // edi@10 | |
4058 Actor *v5; // esi@12 | |
4059 signed int sDmg; // eax@14 | |
4060 __int16 v7; // cx@14 | |
4061 //Player **v8; // esi@20 | |
4062 Player *pPlayer; // ecx@21 | |
4063 Actor *pActor; // esi@34 | |
4064 //__int16 v11; // ax@34 | |
4065 //unsigned int v12; // eax@47 | |
4066 //signed int v13; // edi@47 | |
4067 //SpellBuff *v14; // ebx@47 | |
4068 //unsigned int v15; // edi@67 | |
4069 //char *v16; // eax@67 | |
4070 //unsigned int v17; // edx@67 | |
4071 //unsigned int v18; // ecx@67 | |
4072 //unsigned __int16 v19; // ax@72 | |
4073 //int *v20; // esi@80 | |
4074 //Actor *v21; // ebx@80 | |
4075 unsigned __int16 v22; // ax@86 | |
4076 //signed int v23; // eax@94 | |
4077 //unsigned int v24; // eax@102 | |
4078 //signed int v25; // edi@102 | |
4079 //SpellBuff *v26; // esi@102 | |
4080 unsigned int v27; // ecx@123 | |
4081 unsigned int v28; // eax@123 | |
4082 //unsigned int v29; // eax@127 | |
4083 AIDirection *v30; // eax@129 | |
4084 unsigned __int16 v31; // ax@132 | |
4085 //unsigned int v32; // esi@142 | |
4086 int v33; // eax@144 | |
4087 int v34; // eax@147 | |
4088 char v35; // al@150 | |
4089 unsigned int v36; // edi@152 | |
4090 signed int v37; // eax@154 | |
4091 //unsigned __int8 v38; // sf@158 | |
4092 //unsigned __int8 v39; // of@158 | |
4093 //signed int v40; // edx@166 | |
4094 //unsigned int v41; // ecx@166 | |
4095 double v42; // st7@176 | |
4096 double v43; // st6@176 | |
4097 //bool v44; // eax@189 | |
4098 bool v45; // eax@192 | |
4099 unsigned __int8 v46; // cl@197 | |
4100 double v47; // st7@206 | |
4101 //double v48; // st7@207 | |
4102 //char v49; // zf@208 | |
4103 //char v50; // zf@214 | |
4104 //signed int v51; // edx@219 | |
4105 //unsigned int v52; // ecx@219 | |
4106 __int16 v53; // fps@224 | |
4107 //unsigned __int8 v54; // c0@224 | |
4108 //unsigned __int8 v55; // c3@224 | |
4109 //double v56; // st7@226 | |
4110 AIDirection *v57; // eax@246 | |
4111 double v58; // st7@246 | |
4112 //signed int v59; // [sp-18h] [bp-C8h]@213 | |
4113 //int v60; // [sp-14h] [bp-C4h]@144 | |
4114 //int v61; // [sp-14h] [bp-C4h]@168 | |
4115 //AIDirection *v62; // [sp-14h] [bp-C4h]@213 | |
4116 //signed int v63; // [sp-14h] [bp-C4h]@216 | |
4117 unsigned int v64; // [sp-14h] [bp-C4h]@219 | |
4118 unsigned int v65; // [sp-10h] [bp-C0h]@144 | |
4119 char v66; // [sp-10h] [bp-C0h]@147 | |
4120 //AIDirection *v67; // [sp-10h] [bp-C0h]@167 | |
4121 //int v68; // [sp-10h] [bp-C0h]@168 | |
4122 //AIDirection *v69; // [sp-10h] [bp-C0h]@206 | |
4123 int v70; // [sp-10h] [bp-C0h]@213 | |
4124 //AIDirection *v71; // [sp-10h] [bp-C0h]@216 | |
4125 AIDirection v72; // [sp+0h] [bp-B0h]@246 | |
4126 AIDirection a3; // [sp+1Ch] [bp-94h]@129 | |
4127 AIDirection v74; // [sp+38h] [bp-78h]@246 | |
4128 AIDirection v75; // [sp+54h] [bp-5Ch]@129 | |
4129 int target_pid_type; // [sp+70h] [bp-40h]@83 | |
4130 signed int a1; // [sp+74h] [bp-3Ch]@129 | |
4131 int v78; // [sp+78h] [bp-38h]@79 | |
4132 AIDirection pDir; // [sp+7Ch] [bp-34h]@129 | |
4133 float v80; // [sp+98h] [bp-18h]@33 | |
4134 int v81; // [sp+9Ch] [bp-14h]@100 | |
4135 //int v82; // [sp+A0h] [bp-10h]@45 | |
4136 //unsigned int uActorID; // [sp+A4h] [bp-Ch]@32 | |
4137 unsigned int v84; // [sp+A8h] [bp-8h]@11 | |
4138 signed int target_pid; // [sp+ACh] [bp-4h]@83 | |
4139 AIState uAIState; | |
4140 int v38; | |
4141 | |
4142 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
4143 MakeActorAIList_ODM(); | |
4144 else | |
4145 MakeActorAIList_BLV(); | |
4146 | |
4147 //v0 = 0; | |
4148 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) | |
4149 { | |
4150 if ( pParty->armageddon_timer > 417 ) | |
4151 { | |
4152 pParty->armageddon_timer = 0; | |
4153 } | |
4154 else | |
4155 { | |
4156 pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8); | |
4157 pParty->sRotationX = pParty->sRotationX + rand() % 16 - 8; | |
4158 if ( pParty->sRotationX > 128) | |
4159 pParty->sRotationX = 128; | |
4160 else if ( pParty->sRotationX < -128 ) | |
4161 pParty->sRotationX = -128; | |
4162 | |
4163 pParty->uFlags |= 2u; | |
4164 pParty->armageddon_timer -= pMiscTimer->uTimeElapsed; | |
4165 v4 = pParty->field_16140 + 50; | |
4166 if ( pParty->armageddon_timer <= 0 ) | |
4167 { | |
4168 pParty->armageddon_timer = 0; | |
4169 for(int i = 0; i < uNumActors; i++) | |
4170 { | |
4171 pActor=&pActors[i]; | |
4172 if ( pActor->CanAct() ) | |
4173 { | |
4174 sDmg = stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4); | |
4175 pActor->sCurrentHP -= stru_50C198.CalcMagicalDamageToActor(pActor, 5, v4); | |
4176 if ( sDmg ) | |
4177 { | |
4178 if ( pActor->sCurrentHP >= 0 ) | |
4179 { | |
4180 Actor::AI_Stun(i, 4, 0); | |
4181 } | |
4182 else | |
4183 { | |
4184 Actor::Die(i); | |
4185 if ( pActor->pMonsterInfo.uExp ) | |
4186 GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp); | |
4187 } | |
4188 } | |
4189 } | |
4190 } | |
4191 for(int i = 1; i <= 4; i++) | |
4192 { | |
4193 pPlayer = pPlayers[i]; | |
4194 if ( !pPlayer->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] ) | |
4195 pPlayer->ReceiveDamage(v4, DMGT_5); | |
4196 } | |
4197 } | |
4198 if (pTurnEngine->field_1C) | |
4199 --pTurnEngine->field_1C; | |
4200 } | |
4201 } | |
4202 | |
4203 if (pParty->bTurnBasedModeOn) | |
4204 { | |
4205 pTurnEngine->_405E14(); | |
4206 return; | |
4207 } | |
4208 | |
4209 | |
4210 //uActorID = v0; | |
4211 for (uint i = 0; i < uNumActors; ++i) | |
4212 { | |
4213 pActor = &pActors[i]; | |
4214 //LODWORD(v80) = (int)(char *)pActors + 176; // uAIState | |
4215 //do | |
4216 //{ | |
4217 //pActor = (Actor *)(LODWORD(v80) - 176); | |
4218 //v11 = *(unsigned int *)LODWORD(v80); | |
4219 //v49 = *(unsigned int *)LODWORD(v80) == 5; | |
4220 ai_near_actors_targets_pid[i] = OBJECT_Player; | |
4221 if (pActor->uAIState == Dead || pActor->uAIState == Removed || pActor->uAIState == Disabled || pActor->uAttributes & 0x0400) | |
4222 continue; | |
4223 | |
4224 if (!pActor->sCurrentHP && pActor->uAIState != Dying) | |
4225 Actor::Die(i); | |
4226 | |
4227 //v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1; | |
4228 //v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1; | |
4229 //v12 = 0; | |
4230 //v13 = 0; | |
4231 //v14 = (SpellBuff *)(LODWORD(v80) + 36); | |
4232 for (uint j = 0; j < 22; ++j) | |
4233 { | |
4234 if (j != 10) | |
4235 pActor->pActorBuffs[j]._4585CA(pParty->uTimePlayed); | |
4236 } | |
4237 /*do | |
4238 { | |
4239 if ( v13 != 10 ) | |
4240 { | |
4241 v14->_4585CA(pParty->uTimePlayed); | |
4242 v12 = 0; | |
4243 } | |
4244 ++v13; | |
4245 ++v14; | |
4246 } | |
4247 while ( v13 < 22 );*/ | |
4248 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) | |
4249 //&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12 | |
4250 // || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) ) | |
4251 pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight; | |
4252 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) | |
4253 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
4254 // not sure | |
4255 else if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) | |
4256 pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType; | |
4257 | |
4258 if ((signed __int64)pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 | |
4259 || (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0) | |
4260 continue; | |
4261 | |
4262 //v15 = pMiscTimer->uTimeElapsed; | |
4263 //v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime; | |
4264 //v17 = pActor->uCurrentActionTime; | |
4265 //v18 = pActor->pMonsterInfo.uRecoveryTime; | |
4266 if (pActor->pMonsterInfo.uRecoveryTime) | |
4267 { | |
4268 if (pActor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed) | |
4269 pActor->pMonsterInfo.uRecoveryTime = 0; | |
4270 else | |
4271 pActor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed; | |
4272 } | |
4273 | |
4274 pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed; | |
4275 if (pActor->uCurrentActionTime < pActor->uCurrentActionLength) | |
4276 continue; | |
4277 | |
4278 //v19 = actor->uAIState; | |
4279 if (pActor->uAIState == Dying) | |
4280 pActor->uAIState = Dead; | |
4281 else | |
4282 { | |
4283 if (pActor->uAIState != Summoned) | |
4284 { | |
4285 Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr); | |
4286 continue; | |
4287 } | |
4288 pActor->uAIState = Standing; | |
4289 } | |
4290 | |
4291 pActor->uCurrentActionTime = 0; | |
4292 pActor->uCurrentActionLength = 0; | |
4293 pActor->UpdateAnimation(); | |
4294 //LABEL_78: | |
4295 //++uActorID; | |
4296 //LODWORD(v80) += 836; | |
4297 //} | |
4298 //while ( (signed int)uActorID < (signed int)uNumActors ); | |
4299 } | |
4300 | |
4301 | |
4302 v78 = 0; | |
4303 int actor_id = -1; | |
4304 if ( ai_arrays_size > 0 ) | |
4305 { | |
4306 //while ( 1 ) | |
4307 for(v78 = 0; v78 < ai_arrays_size; ++v78) | |
4308 { | |
4309 actor_id = ai_near_actors_ids[v78]; | |
4310 assert(actor_id < uNumActors); | |
4311 | |
4312 //v20 = &ai_near_actors_targets_pid[actor_id]; | |
4313 pActor = &pActors[actor_id]; | |
4314 Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); | |
4315 if (pActor->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) | |
4316 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
4317 target_pid = ai_near_actors_targets_pid[actor_id]; | |
4318 target_pid_type = PID_TYPE(target_pid); | |
4319 if ( target_pid_type == OBJECT_Actor) | |
4320 v80 = 0.5; | |
4321 else | |
4322 v80 = 1.0; | |
4323 v22 = pActor->uAIState; | |
4324 if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned) | |
4325 { | |
4326 continue; | |
4327 } | |
4328 if ( !pActor->sCurrentHP ) | |
4329 Actor::Die(actor_id); | |
4330 for(int i=0;i<22;i++) | |
4331 { | |
4332 if ( i != 10 ) | |
4333 { | |
4334 pActor->pActorBuffs[i]._4585CA(pParty->uTimePlayed); | |
4335 } | |
4336 } | |
4337 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) | |
4338 pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight; | |
4339 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) | |
4340 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
4341 // not sure | |
4342 else if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) | |
4343 pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType; | |
4344 if ( (signed __int64)pActor->pActorBuffs[2].uExpireTime < 0 ) | |
4345 { | |
4346 pActor->uAIState = Removed; | |
4347 continue; | |
4348 } | |
4349 if ( (signed __int64)pActor->pActorBuffs[5].uExpireTime > 0 | |
4350 || (signed __int64)pActor->pActorBuffs[6].uExpireTime > 0) | |
4351 { | |
4352 continue; | |
4353 } | |
4354 v27 = pMiscTimer->uTimeElapsed; | |
4355 v28 = pActor->pMonsterInfo.uRecoveryTime; | |
4356 pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed; | |
4357 if ( (signed int)v28 > 0 ) | |
4358 pActor->pMonsterInfo.uRecoveryTime = v28 - v27; | |
4359 if ( pActor->pMonsterInfo.uRecoveryTime < 0 ) | |
4360 pActor->pMonsterInfo.uRecoveryTime = 0; | |
4361 if ( !(pActor->uAttributes & 0x8000) ) | |
4362 pActor->uAttributes |= 0x8000; | |
4363 a1 = PID(OBJECT_Actor,actor_id); | |
4364 v30 = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0); | |
4365 memcpy(&v75, v30, sizeof(v75)); | |
4366 memcpy(&pDir, &v75, sizeof(pDir)); | |
4367 uAIState = pActor->uAIState; | |
4368 /*if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Friendly | |
4369 && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 | |
4370 && v80 * 307.2 >= (double)(signed int)v75.uDistance | |
4371 && (uAIState == Pursuing || uAIState == Standing || uAIState == Tethered || uAIState == Fidgeting) | |
4372 || ( v21->pMonsterInfo.uMissleAttack1Type && uAIState == Stunned ) ) | |
4373 { | |
4374 v32 = actor_id; | |
4375 } | |
4376 else | |
4377 */ | |
4378 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly | |
4379 || (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 | |
4380 || v80 * 307.2 < (double)(signed int)v75.uDistance | |
4381 || uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting | |
4382 && !pActor->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned ) | |
4383 { | |
4384 if ( (signed int)pActor->uCurrentActionTime < pActor->uCurrentActionLength ) | |
4385 { | |
4386 continue; | |
4387 } | |
4388 else if ( pActor->uAIState == AttackingMelee ) | |
4389 { | |
4390 v35 = stru_50C198.special_ability_use_check(pActor, actor_id); | |
4391 stru_50FE08.Add( | |
4392 a1, | |
4393 5120, | |
4394 pActor->vPosition.x, | |
4395 pActor->vPosition.y, | |
4396 pActor->vPosition.z + ((signed int)pActor->uActorHeight >> 1), | |
4397 v35, | |
4398 1 | |
4399 ); | |
4400 } | |
4401 else if ( pActor->uAIState == AttackingRanged1 ) | |
4402 { | |
4403 v34 = pActor->pMonsterInfo.uMissleAttack1Type; | |
4404 Actor::AI_RangedAttack(actor_id, &pDir, v34, 0); | |
4405 } | |
4406 else if ( pActor->uAIState == AttackingRanged2 ) | |
4407 { | |
4408 v34 = pActor->pMonsterInfo.uMissleAttack2Type; | |
4409 Actor::AI_RangedAttack(actor_id, &pDir, v34, 1); | |
4410 } | |
4411 else if ( pActor->uAIState == AttackingRanged3 ) | |
4412 { | |
4413 v65 = pActor->pMonsterInfo.uSpellSkillAndMastery1; | |
4414 v33 = pActor->pMonsterInfo.uSpell1ID; | |
4415 Actor::AI_SpellAttack(actor_id, &pDir, v33, 2, v65); | |
4416 } | |
4417 else if ( pActor->uAIState == AttackingRanged4 ) | |
4418 { | |
4419 v65 = pActor->pMonsterInfo.uSpellSkillAndMastery2; | |
4420 v33 = pActor->pMonsterInfo.uSpell2ID; | |
4421 Actor::AI_SpellAttack(actor_id, &pDir, v33, 3, v65); | |
4422 } | |
4423 } | |
4424 | |
4425 v36 = v75.uDistance; | |
4426 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly) | |
4427 { | |
4428 if ( target_pid_type == OBJECT_Actor ) | |
4429 { | |
4430 v36 = v75.uDistance; | |
4431 //v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (pActor->pMonsterInfo.uID - 1) / 3] | |
4432 // + (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3); | |
4433 v37 =pFactionTable->relations[(pActor->pMonsterInfo.uID-1) / 3 + 1][(pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3 + 1]; | |
4434 } | |
4435 else | |
4436 { | |
4437 v37 = 4; | |
4438 } | |
4439 v38=0; | |
4440 if ( v37 == 2 ) | |
4441 { | |
4442 //v39 = __OFSUB__(v36, 1024); | |
4443 //v38 = ((v36 - 1024) & 0x80000000u) != 0; | |
4444 v38 = 1024; | |
4445 } | |
4446 else if ( v37 == 3 ) | |
4447 { | |
4448 //v39 = __OFSUB__(v36, 2560); | |
4449 //v38 = ((v36 - 2560) & 0x80000000u) != 0; | |
4450 v38 = 2560; | |
4451 } | |
4452 else if ( v37 == 4 ) | |
4453 { | |
4454 //v39 = __OFSUB__(v36, 5120); | |
4455 //v38 = ((v36 - 5120) & 0x80000000u) != 0; | |
4456 v38 = 5120; | |
4457 } | |
4458 if ( v37 >= 1 && v37 <= 4 && v36 < v38 || v37 == 1 ) | |
4459 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; | |
4460 } | |
4461 | |
4462 if ( (signed __int64)pActor->pActorBuffs[4].uExpireTime > 0 ) | |
4463 { | |
4464 if ( (signed int)v36 >= 10240 ) | |
4465 { | |
4466 Actor::AI_4032B2(actor_id, target_pid, 1024, 0); | |
4467 } | |
4468 else | |
4469 { | |
4470 //peasents after attacked | |
4471 //guard after attacked | |
4472 Actor::AI_Flee(actor_id, target_pid, 0, &pDir); | |
4473 } | |
4474 continue; | |
4475 } | |
4476 | |
4477 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid ) | |
4478 { | |
4479 | |
4480 if ( pActor->pMonsterInfo.uAIType == 1 ) | |
4481 { | |
4482 if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4483 { | |
4484 Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333), &pDir); | |
4485 } | |
4486 else | |
4487 { | |
4488 Actor::AI_Flee(actor_id, target_pid, 0, &pDir); | |
4489 continue; | |
4490 } | |
4491 | |
4492 } | |
4493 if ( !(pActor->uAttributes & 0x020000) ) | |
4494 { | |
4495 if ( pActor->pMonsterInfo.uAIType == 2 || pActor->pMonsterInfo.uAIType == 3) | |
4496 { | |
4497 if ( pActor->pMonsterInfo.uAIType == 2 ) | |
4498 v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.2; | |
4499 if ( pActor->pMonsterInfo.uAIType == 3 ) | |
4500 v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.1; | |
4501 v84 = pActor->sCurrentHP; | |
4502 v42 = (double)(signed int)v84; | |
4503 if ( v43 > v42 && (signed int)v36 < 10240 ) | |
4504 { | |
4505 Actor::AI_Flee(actor_id, target_pid, 0, &pDir); | |
4506 continue; | |
4507 } | |
4508 } | |
4509 } | |
4510 | |
4511 v81 = v36 - pActor->uActorRadius; | |
4512 if ( target_pid_type == OBJECT_Actor ) | |
4513 v81 -= pActors[PID_ID(target_pid)].uActorRadius; | |
4514 if ( v81 < 0 ) | |
4515 v81 = 0; | |
4516 rand(); | |
4517 pActor->uAttributes &= 0xFFFBFFFF; | |
4518 if ( v81 < 5120 ) | |
4519 { | |
4520 v45 = stru_50C198.special_ability_use_check(pActor, actor_id); | |
4521 if ( v45 == 0 ) | |
4522 { | |
4523 if ( pActor->pMonsterInfo.uMissleAttack1Type ) | |
4524 { | |
4525 if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 ) | |
4526 { | |
4527 Actor::AI_MissileAttack1(actor_id, target_pid, &pDir); | |
4528 } | |
4529 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4530 { | |
4531 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4532 v64 = (signed __int64)v47; | |
4533 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4534 } | |
4535 else | |
4536 { | |
4537 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4538 if ( v80 * 307.2 > (double)v81 ) | |
4539 { | |
4540 v64 = (signed __int64)v47; | |
4541 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4542 } | |
4543 else | |
4544 { | |
4545 Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); | |
4546 } | |
4547 } | |
4548 } | |
4549 else | |
4550 { | |
4551 if ( (double)v81 >= v80 * 307.2 ) | |
4552 { | |
4553 if ( v81 >= 1024 ) | |
4554 { | |
4555 if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4556 { | |
4557 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4558 v64 = (signed __int64)v47; | |
4559 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4560 } | |
4561 else | |
4562 { | |
4563 //monsters | |
4564 Actor::AI_Pursue3(actor_id, target_pid, 0, &pDir); | |
4565 } | |
4566 } | |
4567 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4568 { | |
4569 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4570 v64 = (signed __int64)v47; | |
4571 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4572 } | |
4573 else | |
4574 { | |
4575 v70 = (signed __int64)v80 * 307.2; | |
4576 //monsters | |
4577 //guard after player runs away | |
4578 // follow player | |
4579 Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70); | |
4580 } | |
4581 } | |
4582 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
4583 { | |
4584 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4585 v64 = (signed __int64)v47; | |
4586 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4587 } | |
4588 else | |
4589 { | |
4590 //monsters | |
4591 Actor::AI_MeleeAttack(actor_id, target_pid, &pDir); | |
4592 } | |
4593 } | |
4594 continue; | |
4595 } | |
4596 else if ( v45 == 2 || v45 == 3 ) | |
4597 { | |
4598 if ( v45 == 2 ) | |
4599 v46 = pActor->pMonsterInfo.uSpell1ID; | |
4600 else | |
4601 v46 = pActor->pMonsterInfo.uSpell2ID; | |
4602 if ( v46 ) | |
4603 { | |
4604 if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 ) | |
4605 { | |
4606 if ( v45 == 2 ) | |
4607 Actor::AI_SpellAttack1(actor_id, target_pid, &pDir); | |
4608 else | |
4609 Actor::AI_SpellAttack2(actor_id, target_pid, &pDir); | |
4610 } | |
4611 else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 ) | |
4612 { | |
4613 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4614 v64 = (signed __int64)v47; | |
4615 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4616 } | |
4617 else | |
4618 { | |
4619 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4620 Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); | |
4621 } | |
4622 } | |
4623 else | |
4624 { | |
4625 if ( (double)v81 >= v80 * 307.2 ) | |
4626 { | |
4627 if ( v81 >= 1024 ) | |
4628 { | |
4629 if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4630 { | |
4631 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4632 v64 = (signed __int64)v47; | |
4633 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4634 } | |
4635 else | |
4636 { | |
4637 Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir); | |
4638 } | |
4639 } | |
4640 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4641 { | |
4642 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4643 v64 = (signed __int64)v47; | |
4644 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4645 } | |
4646 else | |
4647 { | |
4648 v70 = (signed __int64)v80 * 307.2; | |
4649 Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70); | |
4650 } | |
4651 } | |
4652 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
4653 { | |
4654 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4655 v64 = (signed __int64)v47; | |
4656 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4657 } | |
4658 else | |
4659 { | |
4660 Actor::AI_MeleeAttack(actor_id, target_pid, &pDir); | |
4661 } | |
4662 } | |
4663 continue; | |
4664 } | |
4665 } | |
4666 } | |
4667 | |
4668 if ( pActor->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 ) | |
4669 { | |
4670 if ( !pActor->pMonsterInfo.uMovementType ) | |
4671 { | |
4672 Actor::AI_4032B2(actor_id, 4, 1024, 0); | |
4673 } | |
4674 else if ( pActor->pMonsterInfo.uMovementType == 1 ) | |
4675 { | |
4676 Actor::AI_4032B2(actor_id, 4, 2560, 0); | |
4677 } | |
4678 else if ( pActor->pMonsterInfo.uMovementType == 2 ) | |
4679 { | |
4680 Actor::AI_4032B2(actor_id, 4, 5120, 0); | |
4681 } | |
4682 else if ( pActor->pMonsterInfo.uMovementType == 4 ) | |
4683 { | |
4684 Actor::AI_4032B2(actor_id, 4, 10240, 0); | |
4685 } | |
4686 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4687 { | |
4688 v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0); | |
4689 v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4690 memcpy(&v74, v57, sizeof(v74)); | |
4691 memcpy(&pDir, &v74, sizeof(pDir)); | |
4692 v64 = (signed __int64)v58; | |
4693 Actor::AI_Stand(actor_id, 4, v64, &pDir); | |
4694 } | |
4695 } | |
4696 else if ( !pActor->pMonsterInfo.uMissleAttack2Type ) | |
4697 { | |
4698 if ( (double)v81 >= v80 * 307.2 ) | |
4699 { | |
4700 if ( v81 >= 1024 ) | |
4701 { | |
4702 if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4703 { | |
4704 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4705 v64 = (signed __int64)v47; | |
4706 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4707 } | |
4708 else | |
4709 { | |
4710 Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir); | |
4711 } | |
4712 } | |
4713 else if ( pActor->pMonsterInfo.uMovementType == 5 ) | |
4714 { | |
4715 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4716 v64 = (signed __int64)v47; | |
4717 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4718 } | |
4719 else | |
4720 { | |
4721 v70 = (signed __int64)v80 * 307.2; | |
4722 Actor::AI_Pursue2(actor_id, target_pid, 0, &pDir, v70); | |
4723 } | |
4724 } | |
4725 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
4726 { | |
4727 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4728 v64 = (signed __int64)v47; | |
4729 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4730 } | |
4731 else | |
4732 { | |
4733 Actor::AI_MeleeAttack(actor_id, target_pid, &pDir); | |
4734 } | |
4735 } | |
4736 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) | |
4737 { | |
4738 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; | |
4739 if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 ) | |
4740 { | |
4741 v64 = (signed __int64)v47; | |
4742 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); | |
4743 } | |
4744 else | |
4745 { | |
4746 Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); | |
4747 } | |
4748 } | |
4749 else | |
4750 { | |
4751 Actor::AI_MissileAttack2(actor_id, target_pid, &pDir); | |
4752 } | |
4753 } | |
4754 } | |
4755 } | |
4756 //----- (0044665D) -------------------------------------------------------- | |
4757 // uType: 0 -> any monster | |
4758 // 1 -> uParam is GroupID | |
4759 // 2 -> uParam is MonsterID | |
4760 // 3 -> uParam is ActorID | |
4761 // uNumAlive: 0 -> all must be alive | |
4762 int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive) | |
4763 { | |
4764 unsigned int uAliveActors; // eax@6 | |
4765 int v5; // ecx@10 | |
4766 unsigned int uTotalActors; // [sp+0h] [bp-4h]@1 | |
4767 | |
4768 uTotalActors = 0; | |
4769 if ( uType ) | |
4770 { | |
4771 if ( uType == 1 ) | |
4772 { | |
4773 uAliveActors = SearchActorByGroup(&uTotalActors, uParam); | |
4774 } | |
4775 else | |
4776 { | |
4777 if ( uType == 2 ) | |
4778 { | |
4779 uAliveActors = SearchActorByMonsterID(&uTotalActors, uParam); | |
4780 } | |
4781 else | |
4782 { | |
4783 if ( uType != 3 ) | |
4784 return 0; | |
4785 uAliveActors = SearchActorByID(&uTotalActors, uParam); | |
4786 } | |
4787 } | |
4788 } | |
4789 else | |
4790 { | |
4791 uAliveActors = SearchAliveActors(&uTotalActors); | |
4792 } | |
4793 v5 = 0; | |
4794 if ( uNumAlive ) | |
4795 LOBYTE(v5) = (signed int)uAliveActors >= (signed int)uNumAlive; | |
4796 else | |
4797 LOBYTE(v5) = uTotalActors == uAliveActors; | |
4798 return v5; | |
4799 } |