comparison Actor.cpp @ 1456:5c95f2246c2a

TE mostly working
author Gloval
date Wed, 14 Aug 2013 00:40:23 +0400
parents 8ff3c675a726
children 934074e7fcc1 ff2118028c71
comparison
equal deleted inserted replaced
1450:8ff3c675a726 1456:5c95f2246c2a
1953 unsigned int v24; // [sp+50h] [bp-4h]@1 1953 unsigned int v24; // [sp+50h] [bp-4h]@1
1954 unsigned int v25; // [sp+5Ch] [bp+8h]@13 1954 unsigned int v25; // [sp+5Ch] [bp+8h]@13
1955 1955
1956 v3 = &pActors[uActorID]; 1956 v3 = &pActors[uActorID];
1957 //a2 = edx0; 1957 //a2 = edx0;
1958 v4 = v3->pMonsterInfo.uMovementType == 5; 1958 v4 = v3->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY;
1959 v24 = uActorID; 1959 v24 = uActorID;
1960 if ( v4 && v3->pMonsterInfo.uAIType == 1 ) 1960 if ( v4 && v3->pMonsterInfo.uAIType == 1 )
1961 { 1961 {
1962 Actor::AI_Stand(uActorID, sTargetPid, 0, arg0); 1962 Actor::AI_Stand(uActorID, sTargetPid, 0, arg0);
1963 return; 1963 return;
2734 else 2734 else
2735 Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir); 2735 Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir);
2736 } 2736 }
2737 2737
2738 //----- (004032B2) -------------------------------------------------------- 2738 //----- (004032B2) --------------------------------------------------------
2739 void Actor::AI_4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength) 2739 void Actor::AI_RandomMove( unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength )
2740 { 2740 {
2741 unsigned int v4; // edi@1 2741 unsigned int v4; // edi@1
2742 Actor *v5; // esi@1 2742 Actor *v5; // esi@1
2743 int v6; // ebx@1 2743 int v6; // ebx@1
2744 int v7; // ST08_4@1 2744 int v7; // ST08_4@1
2745 int v8; // eax@1 2745 int v8; // eax@1
2755 unsigned int uActorID; // [sp+34h] [bp-8h]@1 2755 unsigned int uActorID; // [sp+34h] [bp-8h]@1
2756 int v19; // [sp+38h] [bp-4h]@1 2756 int v19; // [sp+38h] [bp-4h]@1
2757 2757
2758 //v14 never filled, maybe it is passed to function but optimized away as local variable 2758 //v14 never filled, maybe it is passed to function but optimized away as local variable
2759 2759
2760 uActorID = a1; 2760 uActorID = uActor_id;
2761 v4 = a1; 2761 v4 = uActor_id;
2762 v5 = &pActors[a1]; 2762 v5 = &pActors[uActor_id];
2763 v16 = a2; 2763 v16 = uTarget_id;
2764 v6 = v5->vInitialPosition.x - v5->vPosition.x; 2764 v6 = v5->vInitialPosition.x - v5->vPosition.x;
2765 v7 = v5->vInitialPosition.x - v5->vPosition.x; 2765 v7 = v5->vInitialPosition.x - v5->vPosition.x;
2766 y = v5->vInitialPosition.y - v5->vPosition.y; 2766 y = v5->vInitialPosition.y - v5->vPosition.y;
2767 v19 = abs(v7); 2767 v19 = abs(v7);
2768 v8 = abs(y); 2768 v8 = abs(y);
2777 Actor::AI_StandOrBored(uActorID, OBJECT_Player, uActionLength, &v14); 2777 Actor::AI_StandOrBored(uActorID, OBJECT_Player, uActionLength, &v14);
2778 return; 2778 return;
2779 } 2779 }
2780 if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 ) 2780 if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 )
2781 { 2781 {
2782 v13 = &v14; 2782 Actor::AI_Stand(uActorID, uTarget_id, 256, &v14);
2783 v12 = 256;
2784 Actor::AI_Stand(uActorID, v16, v12, v13);
2785 return; 2783 return;
2786 } 2784 }
2787 v15 = (rand() & 0xF) << 12; 2785 v15 = (rand() & 0xF) << 12;
2788 v19 += (unsigned __int64)(v15 * (signed __int64)a3) >> 16; 2786 v19 += (unsigned __int64)(v15 * (signed __int64)radius) >> 16;
2789 v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(v6, y); 2787 v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(v6, y);
2790 if ( rand() % 100 < 25 ) 2788 if ( rand() % 100 < 25 )
2791 { 2789 {
2792 Actor::StandAwhile(uActorID); 2790 Actor::StandAwhile(uActorID);
2793 return; 2791 return;
2794 } 2792 }
2795 v10 = v9 + rand() % 256 - 128; 2793 v10 = v9 + rand() % 256 - 128;
2796 if ( abs(v10 - v5->uYawAngle) > 256 && !(BYTE2(v5->uAttributes) & 0x20) ) 2794 if ( abs(v10 - v5->uYawAngle) > 256 && !(v5->uAttributes & 0x200000) )
2797 { 2795 {
2798 v13 = &v14; 2796 Actor::AI_Stand(uActorID, uTarget_id, 256, &v14);
2799 v12 = 256;
2800 Actor::AI_Stand(uActorID, v16, v12, v13);
2801 return; 2797 return;
2802 } 2798 }
2803 v11 = v5->uMovementSpeed;
2804 v5->uYawAngle = v10; 2799 v5->uYawAngle = v10;
2805 if ( v11 ) 2800 if ( v5->uMovementSpeed)
2806 v5->uCurrentActionLength = 32 * v19 / v11; 2801 v5->uCurrentActionLength = 32 * v19 / v5->uMovementSpeed;
2807 else 2802 else
2808 v5->uCurrentActionLength = 0; 2803 v5->uCurrentActionLength = 0;
2809 v5->uCurrentActionTime = 0; 2804 v5->uCurrentActionTime = 0;
2810 v5->uAIState = Tethered; 2805 v5->uAIState = Tethered;
2811 if ( rand() % 100 < 2 ) 2806 if ( rand() % 100 < 2 )
2856 v4->vInitialPosition.x = v5->vPos.x; 2851 v4->vInitialPosition.x = v5->vPos.x;
2857 v4->vInitialPosition.y = v5->vPos.y; 2852 v4->vInitialPosition.y = v5->vPos.y;
2858 v10 = v5->vPos.z; 2853 v10 = v5->vPos.z;
2859 v4->vInitialPosition.z = v10; 2854 v4->vInitialPosition.z = v10;
2860 LOBYTE(v5) = v5->uAction; 2855 LOBYTE(v5) = v5->uAction;
2861 v4->pMonsterInfo.uMovementType = (unsigned __int8)v5; 2856 v4->pMonsterInfo.uMovementType = MONSTER_MOVEMENT_TYPE_STAIONARY;
2862 if ( a3 == 1 ) 2857 if ( a3 == 1 )
2863 { 2858 {
2864 v4->vPosition.x = v4->vInitialPosition.x; 2859 v4->vPosition.x = v4->vInitialPosition.x;
2865 v4->vPosition.y = v4->vInitialPosition.y; 2860 v4->vPosition.y = v4->vInitialPosition.y;
2866 LOBYTE(v5) = v10; 2861 LOBYTE(v5) = v10;
4415 4410
4416 if ( (signed __int64)pActor->pActorBuffs[4].uExpireTime > 0 ) 4411 if ( (signed __int64)pActor->pActorBuffs[4].uExpireTime > 0 )
4417 { 4412 {
4418 if ( (signed int)v36 >= 10240 ) 4413 if ( (signed int)v36 >= 10240 )
4419 { 4414 {
4420 Actor::AI_4032B2(actor_id, target_pid, 1024, 0); 4415 Actor::AI_RandomMove(actor_id, target_pid, 1024, 0);
4421 } 4416 }
4422 else 4417 else
4423 { 4418 {
4424 //peasents after attacked 4419 //peasents after attacked
4425 //guard after attacked 4420 //guard after attacked
4431 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid ) 4426 if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid )
4432 { 4427 {
4433 4428
4434 if ( pActor->pMonsterInfo.uAIType == 1 ) 4429 if ( pActor->pMonsterInfo.uAIType == 1 )
4435 { 4430 {
4436 if ( pActor->pMonsterInfo.uMovementType == 5 ) 4431 if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4437 { 4432 {
4438 Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333), &pDir); 4433 Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333), &pDir);
4439 } 4434 }
4440 else 4435 else
4441 { 4436 {
4478 { 4473 {
4479 if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 ) 4474 if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 )
4480 { 4475 {
4481 Actor::AI_MissileAttack1(actor_id, target_pid, &pDir); 4476 Actor::AI_MissileAttack1(actor_id, target_pid, &pDir);
4482 } 4477 }
4483 else if ( pActor->pMonsterInfo.uMovementType == 5 ) 4478 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4484 { 4479 {
4485 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4480 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4486 v64 = (signed __int64)v47; 4481 v64 = (signed __int64)v47;
4487 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); 4482 Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
4488 } 4483 }
4504 { 4499 {
4505 if ( (double)v81 >= v80 * 307.2 ) 4500 if ( (double)v81 >= v80 * 307.2 )
4506 { 4501 {
4507 if ( v81 >= 1024 ) 4502 if ( v81 >= 1024 )
4508 { 4503 {
4509 if ( pActor->pMonsterInfo.uMovementType == 5 ) 4504 if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4510 { 4505 {
4511 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4506 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4512 v64 = (signed __int64)v47; 4507 v64 = (signed __int64)v47;
4513 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); 4508 Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
4514 } 4509 }
4516 { 4511 {
4517 //monsters 4512 //monsters
4518 Actor::AI_Pursue3(actor_id, target_pid, 0, &pDir); 4513 Actor::AI_Pursue3(actor_id, target_pid, 0, &pDir);
4519 } 4514 }
4520 } 4515 }
4521 else if ( pActor->pMonsterInfo.uMovementType == 5 ) 4516 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4522 { 4517 {
4523 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4518 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4524 v64 = (signed __int64)v47; 4519 v64 = (signed __int64)v47;
4525 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); 4520 Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
4526 } 4521 }
4560 if ( v45 == 2 ) 4555 if ( v45 == 2 )
4561 Actor::AI_SpellAttack1(actor_id, target_pid, &pDir); 4556 Actor::AI_SpellAttack1(actor_id, target_pid, &pDir);
4562 else 4557 else
4563 Actor::AI_SpellAttack2(actor_id, target_pid, &pDir); 4558 Actor::AI_SpellAttack2(actor_id, target_pid, &pDir);
4564 } 4559 }
4565 else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 ) 4560 else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4566 { 4561 {
4567 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4562 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4568 v64 = (signed __int64)v47; 4563 v64 = (signed __int64)v47;
4569 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); 4564 Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
4570 } 4565 }
4578 { 4573 {
4579 if ( (double)v81 >= v80 * 307.2 ) 4574 if ( (double)v81 >= v80 * 307.2 )
4580 { 4575 {
4581 if ( v81 >= 1024 ) 4576 if ( v81 >= 1024 )
4582 { 4577 {
4583 if ( pActor->pMonsterInfo.uMovementType == 5 ) 4578 if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4584 { 4579 {
4585 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4580 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4586 v64 = (signed __int64)v47; 4581 v64 = (signed __int64)v47;
4587 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); 4582 Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
4588 } 4583 }
4589 else 4584 else
4590 { 4585 {
4591 Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir); 4586 Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
4592 } 4587 }
4593 } 4588 }
4594 else if ( pActor->pMonsterInfo.uMovementType == 5 ) 4589 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4595 { 4590 {
4596 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4591 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4597 v64 = (signed __int64)v47; 4592 v64 = (signed __int64)v47;
4598 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); 4593 Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
4599 } 4594 }
4619 } 4614 }
4620 } 4615 }
4621 4616
4622 if ( pActor->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 ) 4617 if ( pActor->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 )
4623 { 4618 {
4624 if ( !pActor->pMonsterInfo.uMovementType ) 4619 if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_SHORT )
4625 { 4620 {
4626 Actor::AI_4032B2(actor_id, 4, 1024, 0); 4621 Actor::AI_RandomMove(actor_id, 4, 1024, 0);
4627 } 4622 }
4628 else if ( pActor->pMonsterInfo.uMovementType == 1 ) 4623 else if ( pActor->pMonsterInfo.uMovementType == 1 )
4629 { 4624 {
4630 Actor::AI_4032B2(actor_id, 4, 2560, 0); 4625 Actor::AI_RandomMove(actor_id, 4, 2560, 0);
4631 } 4626 }
4632 else if ( pActor->pMonsterInfo.uMovementType == 2 ) 4627 else if ( pActor->pMonsterInfo.uMovementType == 2 )
4633 { 4628 {
4634 Actor::AI_4032B2(actor_id, 4, 5120, 0); 4629 Actor::AI_RandomMove(actor_id, 4, 5120, 0);
4635 } 4630 }
4636 else if ( pActor->pMonsterInfo.uMovementType == 4 ) 4631 else if ( pActor->pMonsterInfo.uMovementType == 4 )
4637 { 4632 {
4638 Actor::AI_4032B2(actor_id, 4, 10240, 0); 4633 Actor::AI_RandomMove(actor_id, 4, 10240, 0);
4639 } 4634 }
4640 else if ( pActor->pMonsterInfo.uMovementType == 5 ) 4635 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4641 { 4636 {
4642 v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0); 4637 v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0);
4643 v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4638 v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4644 memcpy(&v74, v57, sizeof(v74)); 4639 memcpy(&v74, v57, sizeof(v74));
4645 memcpy(&pDir, &v74, sizeof(pDir)); 4640 memcpy(&pDir, &v74, sizeof(pDir));
4651 { 4646 {
4652 if ( (double)v81 >= v80 * 307.2 ) 4647 if ( (double)v81 >= v80 * 307.2 )
4653 { 4648 {
4654 if ( v81 >= 1024 ) 4649 if ( v81 >= 1024 )
4655 { 4650 {
4656 if ( pActor->pMonsterInfo.uMovementType == 5 ) 4651 if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4657 { 4652 {
4658 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4653 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4659 v64 = (signed __int64)v47; 4654 v64 = (signed __int64)v47;
4660 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); 4655 Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
4661 } 4656 }
4662 else 4657 else
4663 { 4658 {
4664 Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir); 4659 Actor::AI_Pursue3(actor_id, target_pid, 256, &pDir);
4665 } 4660 }
4666 } 4661 }
4667 else if ( pActor->pMonsterInfo.uMovementType == 5 ) 4662 else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4668 { 4663 {
4669 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4664 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4670 v64 = (signed __int64)v47; 4665 v64 = (signed __int64)v47;
4671 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); 4666 Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
4672 } 4667 }
4688 } 4683 }
4689 } 4684 }
4690 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) 4685 else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
4691 { 4686 {
4692 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333; 4687 v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
4693 if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == 5 ) 4688 if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
4694 { 4689 {
4695 v64 = (signed __int64)v47; 4690 v64 = (signed __int64)v47;
4696 Actor::AI_Stand(actor_id, target_pid, v64, &pDir); 4691 Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
4697 } 4692 }
4698 else 4693 else