Mercurial > mm7
comparison Actor.cpp @ 2338:1e865e8690ba
Moving some function declarations from unsorted subs to Actor.h and SpriteObject.h
author | Grumpy7 |
---|---|
date | Sat, 05 Apr 2014 20:27:09 +0200 |
parents | d6887ee81068 |
children | 4100fb5c4913 |
comparison
equal
deleted
inserted
replaced
2337:d04017f3d2fa | 2338:1e865e8690ba |
---|---|
2825 stru_721530.uFaceID = PID(OBJECT_Actor,a1); | 2825 stru_721530.uFaceID = PID(OBJECT_Actor,a1); |
2826 } | 2826 } |
2827 return true; | 2827 return true; |
2828 } | 2828 } |
2829 //----- (00401A91) -------------------------------------------------------- | 2829 //----- (00401A91) -------------------------------------------------------- |
2830 void UpdateActorAI() | 2830 void Actor::UpdateActorAI() |
2831 { | 2831 { |
2832 signed int v4; // edi@10 | 2832 signed int v4; // edi@10 |
2833 signed int sDmg; // eax@14 | 2833 signed int sDmg; // eax@14 |
2834 Player *pPlayer; // ecx@21 | 2834 Player *pPlayer; // ecx@21 |
2835 Actor *pActor; // esi@34 | 2835 Actor *pActor; // esi@34 |
2860 signed int target_pid; // [sp+ACh] [bp-4h]@83 | 2860 signed int target_pid; // [sp+ACh] [bp-4h]@83 |
2861 AIState uAIState; | 2861 AIState uAIState; |
2862 uint v38; | 2862 uint v38; |
2863 | 2863 |
2864 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | 2864 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
2865 MakeActorAIList_ODM(); | 2865 Actor::MakeActorAIList_ODM(); |
2866 else | 2866 else |
2867 MakeActorAIList_BLV(); | 2867 Actor::MakeActorAIList_BLV(); |
2868 | 2868 |
2869 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) | 2869 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) |
2870 { | 2870 { |
2871 if ( pParty->armageddon_timer > 417 ) | 2871 if ( pParty->armageddon_timer > 417 ) |
2872 pParty->armageddon_timer = 0; | 2872 pParty->armageddon_timer = 0; |
3295 | 3295 |
3296 uTotalActors = 0; | 3296 uTotalActors = 0; |
3297 if ( uType ) | 3297 if ( uType ) |
3298 { | 3298 { |
3299 if ( uType == 1 ) | 3299 if ( uType == 1 ) |
3300 uAliveActors = SearchActorByGroup(&uTotalActors, uParam); | 3300 uAliveActors = Actor::SearchActorByGroup(&uTotalActors, uParam); |
3301 else | 3301 else |
3302 { | 3302 { |
3303 if ( uType == 2 ) | 3303 if ( uType == 2 ) |
3304 uAliveActors = SearchActorByMonsterID(&uTotalActors, uParam); | 3304 uAliveActors = Actor::SearchActorByMonsterID(&uTotalActors, uParam); |
3305 else | 3305 else |
3306 { | 3306 { |
3307 if ( uType != 3 ) | 3307 if ( uType != 3 ) |
3308 return 0; | 3308 return 0; |
3309 uAliveActors = SearchActorByID(&uTotalActors, uParam); | 3309 uAliveActors = Actor::SearchActorByID(&uTotalActors, uParam); |
3310 } | 3310 } |
3311 } | 3311 } |
3312 } | 3312 } |
3313 else | 3313 else |
3314 uAliveActors = SearchAliveActors(&uTotalActors); | 3314 uAliveActors = Actor::SearchAliveActors(&uTotalActors); |
3315 | 3315 |
3316 if (uNumAlive) | 3316 if (uNumAlive) |
3317 return uAliveActors >= uNumAlive; | 3317 return uAliveActors >= uNumAlive; |
3318 else | 3318 else |
3319 return uTotalActors == uAliveActors; | 3319 return uTotalActors == uAliveActors; |
3320 } | 3320 } |
3321 //----- (00408B54) -------------------------------------------------------- | 3321 //----- (00408B54) -------------------------------------------------------- |
3322 unsigned int SearchActorByID(unsigned int *pTotalActors, unsigned int a2) | 3322 unsigned int Actor::SearchActorByID(unsigned int *pTotalActors, unsigned int a2) |
3323 { | 3323 { |
3324 int v4; // eax@1 | 3324 int v4; // eax@1 |
3325 unsigned int v5; // ebx@1 | 3325 unsigned int v5; // ebx@1 |
3326 | 3326 |
3327 v4 = GetAlertStatus(); | 3327 v4 = GetAlertStatus(); |
3333 v5 = 1; | 3333 v5 = 1; |
3334 } | 3334 } |
3335 return v5; | 3335 return v5; |
3336 } | 3336 } |
3337 //----- (00408AE7) -------------------------------------------------------- | 3337 //----- (00408AE7) -------------------------------------------------------- |
3338 unsigned int SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup) | 3338 unsigned int Actor::SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup) |
3339 { | 3339 { |
3340 int v8; // [sp+Ch] [bp-8h]@1 | 3340 int v8; // [sp+Ch] [bp-8h]@1 |
3341 unsigned int v9; // [sp+10h] [bp-4h]@1 | 3341 unsigned int v9; // [sp+10h] [bp-4h]@1 |
3342 Actor* v4; | 3342 Actor* v4; |
3343 | 3343 |
3355 } | 3355 } |
3356 } | 3356 } |
3357 return v9; | 3357 return v9; |
3358 } | 3358 } |
3359 //----- (00408A7E) -------------------------------------------------------- | 3359 //----- (00408A7E) -------------------------------------------------------- |
3360 unsigned int SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID) | 3360 unsigned int Actor::SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID) |
3361 { | 3361 { |
3362 Actor *v4; // edi@2 | 3362 Actor *v4; // edi@2 |
3363 int v8; // [sp+Ch] [bp-8h]@1 | 3363 int v8; // [sp+Ch] [bp-8h]@1 |
3364 unsigned int v9; // [sp+10h] [bp-4h]@1 | 3364 unsigned int v9; // [sp+10h] [bp-4h]@1 |
3365 | 3365 |
3377 } | 3377 } |
3378 } | 3378 } |
3379 return v9; | 3379 return v9; |
3380 } | 3380 } |
3381 //----- (00408A27) -------------------------------------------------------- | 3381 //----- (00408A27) -------------------------------------------------------- |
3382 unsigned int SearchAliveActors(unsigned int *pTotalActors) | 3382 unsigned int Actor::SearchAliveActors(unsigned int *pTotalActors) |
3383 { | 3383 { |
3384 int v2; // eax@1 | 3384 int v2; // eax@1 |
3385 unsigned int v3; // ebp@1 | 3385 unsigned int v3; // ebp@1 |
3386 Actor *v5; // edi@2 | 3386 Actor *v5; // edi@2 |
3387 | 3387 |
3399 } | 3399 } |
3400 } | 3400 } |
3401 return v3; | 3401 return v3; |
3402 } | 3402 } |
3403 //----- (00408768) -------------------------------------------------------- | 3403 //----- (00408768) -------------------------------------------------------- |
3404 void InitializeActors() | 3404 void Actor::InitializeActors() |
3405 { | 3405 { |
3406 signed int v5; // [sp+Ch] [bp-10h]@1 | 3406 signed int v5; // [sp+Ch] [bp-10h]@1 |
3407 signed int v6; // [sp+10h] [bp-Ch]@1 | 3407 signed int v6; // [sp+10h] [bp-Ch]@1 |
3408 signed int v7; // [sp+14h] [bp-8h]@1 | 3408 signed int v7; // [sp+14h] [bp-8h]@1 |
3409 signed int v8; // [sp+18h] [bp-4h]@1 | 3409 signed int v8; // [sp+18h] [bp-4h]@1 |
3449 if (actor->uAttributes & 0x400000) | 3449 if (actor->uAttributes & 0x400000) |
3450 Actor::_4031C1_update_job_never_gets_called(i, pParty->uCurrentHour, 1); | 3450 Actor::_4031C1_update_job_never_gets_called(i, pParty->uCurrentHour, 1); |
3451 } | 3451 } |
3452 } | 3452 } |
3453 //----- (00439474) -------------------------------------------------------- | 3453 //----- (00439474) -------------------------------------------------------- |
3454 void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity) | 3454 void Actor::DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity) |
3455 { | 3455 { |
3456 SpriteObject *projectileSprite; // ebx@1 | 3456 SpriteObject *projectileSprite; // ebx@1 |
3457 Actor *pMonster; // esi@7 | 3457 Actor *pMonster; // esi@7 |
3458 unsigned __int16 v16; // cx@25 | 3458 unsigned __int16 v16; // cx@25 |
3459 int v33; // eax@100 | 3459 int v33; // eax@100 |
4415 } | 4415 } |
4416 } | 4416 } |
4417 } | 4417 } |
4418 } | 4418 } |
4419 } | 4419 } |
4420 | |
4421 //----- (004014E6) -------------------------------------------------------- | |
4422 void Actor::MakeActorAIList_ODM() | |
4423 { | |
4424 int v1; // eax@4 | |
4425 // int v2; // ebx@4 | |
4426 // unsigned int v3; // ecx@4 | |
4427 // int v4; // edx@5 | |
4428 // int v5; // edx@7 | |
4429 // unsigned int v6; // edx@9 | |
4430 unsigned int v7; // ST20_4@10 | |
4431 int v9; // edi@10 | |
4432 int v10; // ebx@14 | |
4433 int v21; // [sp+Ch] [bp-14h]@4 | |
4434 int v22; // [sp+10h] [bp-10h]@4 | |
4435 | |
4436 pParty->uFlags &= 0xFFFFFFCFu; | |
4437 | |
4438 ai_arrays_size = 0; | |
4439 for (uint i = 0; i < uNumActors; ++i) | |
4440 { | |
4441 Actor* actor = &pActors[i]; | |
4442 | |
4443 actor->uAttributes &= 0xFFFFFBFF; | |
4444 if (!actor->CanAct()) | |
4445 { | |
4446 actor->uAttributes &= 0xFFFFBFFF; | |
4447 continue; | |
4448 } | |
4449 | |
4450 v22 = abs(pParty->vPosition.z - actor->vPosition.z); | |
4451 v21 = abs(pParty->vPosition.y - actor->vPosition.y); | |
4452 v1 = abs(pParty->vPosition.x - actor->vPosition.x); | |
4453 v7 = int_get_vector_length(v22, v21, v1); | |
4454 //v8 = actor->uActorRadius; | |
4455 v9 = v7 - actor->uActorRadius; | |
4456 //v23 = v7 - v8; | |
4457 if ( v9 < 0 ) | |
4458 { | |
4459 v9 = 0; | |
4460 //v23 = 0; | |
4461 } | |
4462 | |
4463 if (v9 < 5632) | |
4464 { | |
4465 v10 = actor->uAttributes & 0xFEFFFFFF; | |
4466 actor->uAttributes = v10; | |
4467 if ( v10 & 0x80000 || actor->GetActorsRelation(0) ) | |
4468 { | |
4469 //v11 = (pParty->uFlags & 0x10) == 0; | |
4470 actor->uAttributes = v10 | 0x1000000; | |
4471 if (v9 < 5120 ) | |
4472 pParty->SetYellowAlert(); | |
4473 if (v9 < 307) | |
4474 pParty->SetRedAlert(); | |
4475 } | |
4476 actor->uAttributes |= 0x00004000; | |
4477 ai_near_actors_distances[ai_arrays_size] = v9; | |
4478 ai_near_actors_ids[ai_arrays_size++] = i; | |
4479 } | |
4480 else | |
4481 actor->uAttributes &= 0xFFFFBFFF; | |
4482 } | |
4483 | |
4484 /* | |
4485 result = v27; | |
4486 if ( v27 > 0 ) | |
4487 { | |
4488 v14 = 0; | |
4489 v15 = 1; | |
4490 v26 = 1; | |
4491 do | |
4492 { | |
4493 while ( 1 ) | |
4494 { | |
4495 v24 = v15; | |
4496 if ( v15 >= result ) | |
4497 break; | |
4498 v16 = ai_near_actors_distances[v14]; | |
4499 if ( v16 > ai_near_actors_distances[v15] ) | |
4500 { | |
4501 v17 = &ai_near_actors_ids[v15]; | |
4502 v18 = ai_near_actors_ids[v14]; | |
4503 ai_near_actors_ids[v14] = *v17; | |
4504 *v17 = v18; | |
4505 v15 = v24; | |
4506 ai_near_actors_distances[v14] = ai_near_actors_distances[v24]; | |
4507 ai_near_actors_distances[v24] = v16; | |
4508 } | |
4509 result = v27; | |
4510 ++v15; | |
4511 } | |
4512 ++v14; | |
4513 v15 = v26 + 1; | |
4514 v26 = v15; | |
4515 } | |
4516 while ( v15 - 1 < result ); | |
4517 }*/ | |
4518 | |
4519 for (uint i = 0; i < ai_arrays_size; ++i) | |
4520 for (uint j = 0; j < i; ++j) | |
4521 if (ai_near_actors_distances[j] > ai_near_actors_distances[i]) | |
4522 { | |
4523 int tmp = ai_near_actors_distances[j]; | |
4524 ai_near_actors_distances[j] = ai_near_actors_distances[i]; | |
4525 ai_near_actors_distances[i] = tmp; | |
4526 | |
4527 tmp = ai_near_actors_ids[j]; | |
4528 ai_near_actors_ids[j] = ai_near_actors_ids[i]; | |
4529 ai_near_actors_ids[i] = tmp; | |
4530 } | |
4531 | |
4532 | |
4533 if (ai_arrays_size > 30) | |
4534 ai_arrays_size = 30; | |
4535 | |
4536 for (uint i = 0; i < ai_arrays_size; ++i) | |
4537 pActors[ai_near_actors_ids[i]].uAttributes |= 0x0400; | |
4538 } | |
4539 | |
4540 //----- (004016FA) -------------------------------------------------------- | |
4541 int Actor::MakeActorAIList_BLV() | |
4542 { | |
4543 //Actor *v0; // esi@2 | |
4544 int v1; // eax@4 | |
4545 // int v2; // ebx@4 | |
4546 // unsigned int v3; // ecx@4 | |
4547 // int v4; // edx@5 | |
4548 // int v5; // edx@7 | |
4549 // unsigned int v6; // edx@9 | |
4550 unsigned int v7; // ST24_4@10 | |
4551 // int v8; // eax@10 | |
4552 int v9; // edi@10 | |
4553 // int v10; // ebx@14 | |
4554 // char v11; // zf@16 | |
4555 int v12; // eax@22 | |
4556 int v13; // edx@24 | |
4557 // int v14; // ecx@25 | |
4558 int v15; // ebx@26 | |
4559 // unsigned int *v16; // ecx@27 | |
4560 unsigned int v17; // esi@27 | |
4561 int v18; // ecx@31 | |
4562 signed int v19; // edi@31 | |
4563 // Actor *v20; // esi@32 | |
4564 // bool v21; // eax@33 | |
4565 // int v22; // eax@34 | |
4566 // signed int v23; // ebx@36 | |
4567 // Actor *v24; // esi@37 | |
4568 signed int v25; // eax@40 | |
4569 // int v26; // eax@43 | |
4570 int v27; // ebx@45 | |
4571 int j; // edi@45 | |
4572 // unsigned int v29; // eax@46 | |
4573 int v30; // eax@48 | |
4574 // int v31; // ecx@51 | |
4575 // int v32; // eax@51 | |
4576 // signed int v33; // eax@53 | |
4577 // __int64 v34; // qax@55 | |
4578 // char *v35; // ecx@56 | |
4579 int v37; // [sp+Ch] [bp-18h]@1 | |
4580 int v38; // [sp+10h] [bp-14h]@4 | |
4581 int v39; // [sp+14h] [bp-10h]@4 | |
4582 //int v40; // [sp+18h] [bp-Ch]@10 | |
4583 // int v41; // [sp+18h] [bp-Ch]@29 | |
4584 int i; // [sp+18h] [bp-Ch]@31 | |
4585 //signed int v43; // [sp+1Ch] [bp-8h]@1 | |
4586 // signed int v44; // [sp+1Ch] [bp-8h]@25 | |
4587 int v45; // [sp+20h] [bp-4h]@1 | |
4588 | |
4589 // __debugbreak(); // refactor for blv ai | |
4590 pParty->uFlags &= 0xFFFFFFCFu; | |
4591 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
4592 v45 = 0; | |
4593 for ( uint i = 0; i < (signed int)uNumActors; ++i ) | |
4594 { | |
4595 pActors[i].uAttributes &= 0xFB00; | |
4596 if ( !pActors[i].CanAct() ) | |
4597 { | |
4598 pActors[i].uAttributes &= 0xBF00; | |
4599 continue; | |
4600 } | |
4601 v39 = abs(pParty->vPosition.z - pActors[i].vPosition.z); | |
4602 v38 = abs(pParty->vPosition.y - pActors[i].vPosition.y); | |
4603 v1 = abs(pParty->vPosition.x - pActors[i].vPosition.x); | |
4604 v7 = int_get_vector_length(v39, v38, v1); | |
4605 v9 = v7 - pActors[i].uActorRadius; | |
4606 if ( v9 < 0 ) | |
4607 v9 = 0; | |
4608 if ( v9 < 10240 ) | |
4609 { | |
4610 pActors[i].uAttributes &= 0xFEFFFFFF; | |
4611 if ( pActors[i].uAttributes & 0x80000 || pActors[i].GetActorsRelation(0) ) | |
4612 { | |
4613 pActors[i].uAttributes |= 0x1000000; | |
4614 if ( !(pParty->uFlags & 0x10) && (double)v9 < 307.2 ) | |
4615 pParty->uFlags |= 0x10; | |
4616 if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) | |
4617 pParty->uFlags |= 0x20; | |
4618 } | |
4619 v12 = v45++; | |
4620 ai_near_actors_distances[v12] = v9; | |
4621 ai_near_actors_ids[v12] = i; | |
4622 } | |
4623 else | |
4624 pActors[i].uAttributes &= 0xBF00; | |
4625 } | |
4626 v13 = 0; | |
4627 if ( v45 > 0 ) | |
4628 { | |
4629 for ( uint i = 1; i < v45; i++ ) | |
4630 { | |
4631 for ( uint j = 1; j < v45; ++j ) | |
4632 { | |
4633 v15 = ai_near_actors_distances[v13]; | |
4634 if ( ai_near_actors_distances[v13] > ai_near_actors_distances[j] ) | |
4635 { | |
4636 v17 = ai_near_actors_ids[v13]; | |
4637 ai_near_actors_ids[v13] = ai_near_actors_ids[j]; | |
4638 ai_near_actors_ids[j] = v17; | |
4639 ai_near_actors_distances[v13] = ai_near_actors_distances[j]; | |
4640 ai_near_actors_distances[j] = v15; | |
4641 } | |
4642 } | |
4643 ++v13; | |
4644 } | |
4645 } | |
4646 v18 = 0; | |
4647 v19 = 0; | |
4648 for ( i = 0; i < v45; i++ ) | |
4649 { | |
4650 if ( pActors[ai_near_actors_ids[i]].uAttributes & 0x8000 | |
4651 || sub_4070EF_prolly_detect_player(PID(OBJECT_Actor,ai_near_actors_ids[i]), 4) ) | |
4652 { | |
4653 pActors[ai_near_actors_ids[i]].uAttributes |= 0x8000; | |
4654 ai_array_4F6638_actor_ids[v19] = ai_near_actors_ids[i]; | |
4655 ai_array_4F5E68[v19++] = ai_near_actors_distances[i]; | |
4656 if ( v19 >= 30 ) | |
4657 break; | |
4658 } | |
4659 } | |
4660 ai_arrays_size = v19; | |
4661 if ( (signed int)uNumActors > 0 ) | |
4662 { | |
4663 for ( uint i = 0; i < (signed int)uNumActors; ++i ) | |
4664 { | |
4665 if ( pActors[i].CanAct() && pActors[i].uSectorID == v37 ) | |
4666 { | |
4667 v25 = 0; | |
4668 if ( v19 <= 0 ) | |
4669 { | |
4670 pActors[i].uAttributes |= 0x4000; | |
4671 ai_array_4F6638_actor_ids[ai_arrays_size++] = i; | |
4672 } | |
4673 else | |
4674 { | |
4675 while ( ai_array_4F6638_actor_ids[v25] != i ) | |
4676 { | |
4677 ++v25; | |
4678 if ( v25 >= v19 ) | |
4679 { | |
4680 pActors[i].uAttributes |= 0x4000; | |
4681 ai_array_4F6638_actor_ids[ai_arrays_size++] = i; | |
4682 break; | |
4683 } | |
4684 } | |
4685 } | |
4686 } | |
4687 } | |
4688 } | |
4689 v27 = ai_arrays_size; | |
4690 for ( j = 0; j < v45; ++j ) | |
4691 { | |
4692 //v29 = ai_near_actors_ids[j]; | |
4693 if ( pActors[ai_near_actors_ids[j]].uAttributes & 0xC000 && pActors[ai_near_actors_ids[j]].CanAct() ) | |
4694 { | |
4695 v30 = 0; | |
4696 if ( v27 <= 0 ) | |
4697 ai_array_4F6638_actor_ids[ai_arrays_size++] = ai_near_actors_ids[j]; | |
4698 else | |
4699 { | |
4700 while ( ai_array_4F6638_actor_ids[v30] != ai_near_actors_ids[j] ) | |
4701 { | |
4702 ++v30; | |
4703 if ( v30 >= v27 ) | |
4704 { | |
4705 ai_array_4F6638_actor_ids[ai_arrays_size++] = ai_near_actors_ids[j]; | |
4706 break; | |
4707 } | |
4708 } | |
4709 } | |
4710 } | |
4711 } | |
4712 if ( ai_arrays_size > 30 ) | |
4713 ai_arrays_size = 30; | |
4714 memcpy(ai_near_actors_ids.data(), ai_array_4F6638_actor_ids.data(), 4 * ai_arrays_size); | |
4715 memcpy(ai_near_actors_distances.data(), ai_array_4F5E68.data(), 4 * ai_arrays_size); | |
4716 for ( uint i = 0; i < ai_arrays_size; i++ ) | |
4717 pActors[ai_near_actors_ids[i]].uAttributes |= 0x400; | |
4718 return ai_arrays_size; | |
4719 } |