Mercurial > mm7
comparison Actor.cpp @ 1880:52e98d25cd64
Actor::AI_MissileAttack1 and Actor::AI_MissileAttack2 cleaned up
author | Grumpy7 |
---|---|
date | Thu, 17 Oct 2013 10:23:36 +0200 |
parents | 7efa09ddb8b4 |
children | fa3d4b400b8d |
comparison
equal
deleted
inserted
replaced
1879:7efa09ddb8b4 | 1880:52e98d25cd64 |
---|---|
1615 { | 1615 { |
1616 Error("Should not get here"); | 1616 Error("Should not get here"); |
1617 return; | 1617 return; |
1618 } | 1618 } |
1619 v19 = v3->uActorHeight; | 1619 v19 = v3->uActorHeight; |
1620 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); | 1620 v7.z = v3->vPosition.z - (int)(v19 * -0.75); |
1621 v7.y = v3->vPosition.y; | 1621 v7.y = v3->vPosition.y; |
1622 v7.x = v3->vPosition.x; | 1622 v7.x = v3->vPosition.x; |
1623 if ( sub_407A1C(v4, v5, v21, v7) ) | 1623 if ( sub_407A1C(v4, v5, v21, v7) ) |
1624 { | 1624 { |
1625 if ( pDir == nullptr ) | 1625 if ( pDir == nullptr ) |
1666 | 1666 |
1667 //----- (0040368B) -------------------------------------------------------- | 1667 //----- (0040368B) -------------------------------------------------------- |
1668 void Actor::AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) | 1668 void Actor::AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) |
1669 { | 1669 { |
1670 Actor *v3; // ebx@1 | 1670 Actor *v3; // ebx@1 |
1671 AIDirection *v4; // esi@3 | 1671 int16_t v4; // esi@3 |
1672 AIDirection *v5; // edi@3 | 1672 int16_t v5; // edi@3 |
1673 signed int v6; // eax@4 | 1673 signed int v6; // eax@4 |
1674 Vec3_int_ v7; // ST04_12@6 | 1674 Vec3_int_ v7; // ST04_12@6 |
1675 //unsigned int result; // eax@7 | |
1676 AIDirection *v9; // eax@8 | 1675 AIDirection *v9; // eax@8 |
1677 unsigned int v10; // esi@8 | |
1678 AIDirection *v11; // esi@9 | |
1679 SpriteFrame *v12; // ecx@10 | |
1680 __int16 v13; // ax@10 | 1676 __int16 v13; // ax@10 |
1681 unsigned int v14; // ecx@10 | |
1682 signed __int64 v15; // qax@10 | |
1683 AIDirection a3; // [sp+Ch] [bp-48h]@9 | 1677 AIDirection a3; // [sp+Ch] [bp-48h]@9 |
1684 AIDirection v17; // [sp+28h] [bp-2Ch]@9 | 1678 AIDirection v17; // [sp+28h] [bp-2Ch]@9 |
1685 int v18; // [sp+44h] [bp-10h]@6 | 1679 int v18; // [sp+44h] [bp-10h]@6 |
1686 //signed int a2; // [sp+48h] [bp-Ch]@1 | |
1687 int v20; // [sp+4Ch] [bp-8h]@3 | 1680 int v20; // [sp+4Ch] [bp-8h]@3 |
1688 unsigned int v21; // [sp+50h] [bp-4h]@1 | |
1689 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 | 1681 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 |
1690 | 1682 |
1691 v21 = uActorID; | |
1692 v3 = &pActors[uActorID]; | 1683 v3 = &pActors[uActorID]; |
1693 //a2 = edx0; | |
1694 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) | 1684 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) |
1695 { | 1685 { |
1696 v6 = PID_ID(sTargetPid); | 1686 v6 = PID_ID(sTargetPid); |
1697 v4 = (AIDirection *)pActors[v6].vPosition.x; | 1687 v4 = pActors[v6].vPosition.x; |
1698 v5 = (AIDirection *)pActors[v6].vPosition.y; | 1688 v5 = pActors[v6].vPosition.y; |
1699 v20 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); | 1689 v20 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); |
1690 } | |
1691 else if ( PID_TYPE(sTargetPid) == OBJECT_Player) | |
1692 { | |
1693 v4 = pParty->vPosition.x; | |
1694 v5 = pParty->vPosition.y; | |
1695 v20 = pParty->vPosition.z + pParty->sEyelevel; | |
1700 } | 1696 } |
1701 else | 1697 else |
1702 { | 1698 { |
1703 if ( PID_TYPE(sTargetPid) == OBJECT_Player) | 1699 Error("Should not get here"); |
1704 { | 1700 return; |
1705 v4 = (AIDirection *)pParty->vPosition.x; | |
1706 v5 = (AIDirection *)pParty->vPosition.y; | |
1707 v20 = pParty->vPosition.z + pParty->sEyelevel; | |
1708 } | |
1709 else | |
1710 { | |
1711 v4 = pDir; | |
1712 v5 = pDir; | |
1713 } | |
1714 } | 1701 } |
1715 v18 = v3->uActorHeight; | 1702 v18 = v3->uActorHeight; |
1716 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v18 * -0.75); | 1703 v7.z = v3->vPosition.z - (int)(v18 * -0.75); |
1717 v7.y = v3->vPosition.y; | 1704 v7.y = v3->vPosition.y; |
1718 v7.x = v3->vPosition.x; | 1705 v7.x = v3->vPosition.x; |
1719 if ( sub_407A1C((int)v4, (int)v5, v20, v7) ) | 1706 if ( sub_407A1C(v4, v5, v20, v7) ) |
1720 { | 1707 { |
1721 v9 = pDir; | 1708 if ( pDir == nullptr ) |
1722 v10 = 0; | 1709 { |
1723 if ( !pDir ) | 1710 v9 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); |
1724 { | 1711 } |
1725 v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); | 1712 else |
1726 v9 = &v17; | 1713 { |
1727 memcpy(&v17, v11, sizeof(v17)); | 1714 v9 = pDir; |
1728 v10 = 0; | 1715 } |
1729 } | |
1730 v12 = pSpriteFrameTable->pSpriteSFrames; | |
1731 v3->uYawAngle = LOWORD(v9->uYawAngle); | 1716 v3->uYawAngle = LOWORD(v9->uYawAngle); |
1732 v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; | 1717 v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; |
1733 v14 = v21; | |
1734 v3->uCurrentActionLength = 8 * v13; | 1718 v3->uCurrentActionLength = 8 * v13; |
1735 v3->uCurrentActionTime = v10; | 1719 v3->uCurrentActionTime = 0; |
1736 v3->uAIState = AttackingRanged2; | 1720 v3->uAIState = AttackingRanged2; |
1737 Actor::PlaySound(v14, 0); | 1721 Actor::PlaySound(uActorID, 0); |
1738 LODWORD(v15) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
1739 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | 1722 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; |
1740 if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v10 | 1723 if ( v3->pActorBuffs[7].uExpireTime > 0 ) |
1741 && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v10 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v10) ) | 1724 { |
1742 { | 1725 pDira *= 2; |
1743 LODWORD(v15) = 2 * v15; | |
1744 pDira = v15; | |
1745 } | 1726 } |
1746 if ( pParty->bTurnBasedModeOn != 1 ) | 1727 if ( pParty->bTurnBasedModeOn != 1 ) |
1747 v15 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)pDira * 2.133333333333333); | 1728 v3->pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333); |
1748 v3->pMonsterInfo.uRecoveryTime = v15; | 1729 else |
1749 v3->vVelocity.z = v10; | 1730 { |
1750 v3->vVelocity.y = v10; | 1731 v3->pMonsterInfo.uRecoveryTime = pDira; |
1751 v3->vVelocity.x = v10; | 1732 } |
1733 v3->vVelocity.z = 0; | |
1734 v3->vVelocity.y = 0; | |
1735 v3->vVelocity.x = 0; | |
1752 v3->UpdateAnimation(); | 1736 v3->UpdateAnimation(); |
1753 } | 1737 } |
1754 else | 1738 else |
1755 Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir); | 1739 Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); |
1756 } | 1740 } |
1757 | 1741 |
1758 //----- (00403476) -------------------------------------------------------- | 1742 //----- (00403476) -------------------------------------------------------- |
1759 void Actor::AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) | 1743 void Actor::AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) |
1760 { | 1744 { |
1761 Actor *v3; // ebx@1 | 1745 Actor *v3; // ebx@1 |
1762 int v4; // esi@3 | 1746 int v4; // esi@3 |
1763 int v5; // edi@3 | 1747 int v5; // edi@3 |
1764 signed int v6; // eax@4 | 1748 signed int v6; // eax@4 |
1765 Vec3_int_ v7; // ST04_12@6 | 1749 Vec3_int_ v7; // ST04_12@6 |
1766 unsigned char v8[12]; // ST04_12@7 | |
1767 //unsigned int result; // eax@8 | |
1768 AIDirection *v10; // eax@9 | 1750 AIDirection *v10; // eax@9 |
1769 unsigned int v11; // esi@9 | |
1770 AIDirection *v12; // esi@10 | |
1771 SpriteFrame *v13; // ecx@11 | |
1772 __int16 v14; // ax@11 | 1751 __int16 v14; // ax@11 |
1773 unsigned int v15; // ecx@11 | |
1774 unsigned int v16; // eax@11 | |
1775 AIDirection a3; // [sp+Ch] [bp-48h]@10 | 1752 AIDirection a3; // [sp+Ch] [bp-48h]@10 |
1776 AIDirection v18; // [sp+28h] [bp-2Ch]@10 | 1753 AIDirection v18; // [sp+28h] [bp-2Ch]@10 |
1777 int v19; // [sp+44h] [bp-10h]@6 | 1754 int v19; // [sp+44h] [bp-10h]@6 |
1778 //signed int a2; // [sp+48h] [bp-Ch]@1 | 1755 //signed int a2; // [sp+48h] [bp-Ch]@1 |
1779 unsigned int v21; // [sp+4Ch] [bp-8h]@1 | |
1780 int v22; // [sp+50h] [bp-4h]@3 | 1756 int v22; // [sp+50h] [bp-4h]@3 |
1781 unsigned int pDira; // [sp+5Ch] [bp+8h]@11 | 1757 unsigned int pDira; // [sp+5Ch] [bp+8h]@11 |
1782 | 1758 |
1783 v21 = uActorID; | |
1784 v3 = &pActors[uActorID]; | 1759 v3 = &pActors[uActorID]; |
1785 //a2 = edx0; | 1760 //a2 = edx0; |
1786 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) | 1761 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) |
1787 { | 1762 { |
1788 v6 = PID_ID(sTargetPid); | 1763 v6 = PID_ID(sTargetPid); |
1789 v4 = pActors[v6].vPosition.x; | 1764 v4 = pActors[v6].vPosition.x; |
1790 v5 = pActors[v6].vPosition.y; | 1765 v5 = pActors[v6].vPosition.y; |
1791 v22 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); | 1766 v22 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); |
1792 } | 1767 } |
1793 else | 1768 else |
1794 { | 1769 { |
1795 if ( PID_TYPE(sTargetPid) == OBJECT_Player) | 1770 if ( PID_TYPE(sTargetPid) == OBJECT_Player) |
1796 { | 1771 { |
1806 } | 1781 } |
1807 v19 = v3->uActorHeight; | 1782 v19 = v3->uActorHeight; |
1808 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); | 1783 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); |
1809 v7.y = v3->vPosition.y; | 1784 v7.y = v3->vPosition.y; |
1810 v7.x = v3->vPosition.x; | 1785 v7.x = v3->vPosition.x; |
1811 if ( sub_407A1C(v4, v5, v22, v7) | 1786 if ( sub_407A1C(v4, v5, v22, v7) || sub_407A1C(v7.x, v7.y, v7.z, Vec3_int_(v4, v5, v22))) |
1812 || (*(unsigned int *)&v8[8] = v22, | 1787 { |
1813 v19 = v3->uActorHeight, | 1788 if ( pDir == nullptr ) |
1814 *(_QWORD *)v8 = __PAIR__(v5, v4), | 1789 { |
1815 sub_407A1C( | 1790 v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); |
1816 v3->vPosition.x, | 1791 } |
1817 v3->vPosition.y, | 1792 else |
1818 v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75), | 1793 { |
1819 *(Vec3_int_ *)v8)) ) | 1794 v10 = pDir; |
1820 { | 1795 } |
1821 v10 = pDir; | |
1822 v11 = 0; | |
1823 if ( !pDir ) | |
1824 { | |
1825 v12 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); | |
1826 v10 = &v18; | |
1827 memcpy(&v18, v12, sizeof(v18)); | |
1828 v11 = 0; | |
1829 } | |
1830 v13 = pSpriteFrameTable->pSpriteSFrames; | |
1831 v3->uYawAngle = LOWORD(v10->uYawAngle); | 1796 v3->uYawAngle = LOWORD(v10->uYawAngle); |
1832 v14 = v13[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; | 1797 v14 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; |
1833 v15 = v21; | |
1834 v3->uCurrentActionLength = 8 * v14; | 1798 v3->uCurrentActionLength = 8 * v14; |
1835 v3->uCurrentActionTime = v11; | 1799 v3->uCurrentActionTime = 0; |
1836 v3->uAIState = AttackingRanged1; | 1800 v3->uAIState = AttackingRanged1; |
1837 Actor::PlaySound(v15, 0); | 1801 Actor::PlaySound(uActorID, 0); |
1838 v16 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | |
1839 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; | 1802 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; |
1840 if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v11 | 1803 if ( v3->pActorBuffs[7].uExpireTime > 0 ) |
1841 && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v11 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v11) ) | 1804 { |
1842 { | 1805 pDira *= 2; |
1843 v16 *= 2; | |
1844 pDira = v16; | |
1845 } | 1806 } |
1846 if ( pParty->bTurnBasedModeOn == 1 ) | 1807 if ( pParty->bTurnBasedModeOn == 1 ) |
1847 v3->pMonsterInfo.uRecoveryTime = v16; | 1808 v3->pMonsterInfo.uRecoveryTime = pDira; |
1848 else | 1809 else |
1849 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength | 1810 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength - (int)(flt_6BE3A8_debug_recmod2 * pDira * -2.133333333333333); |
1850 - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2 | 1811 v3->vVelocity.z = 0; |
1851 * (double)(signed int)pDira | 1812 v3->vVelocity.y = 0; |
1852 * -2.133333333333333); | 1813 v3->vVelocity.x = 0; |
1853 v3->vVelocity.z = v11; | |
1854 v3->vVelocity.y = v11; | |
1855 v3->vVelocity.x = v11; | |
1856 v3->UpdateAnimation(); | 1814 v3->UpdateAnimation(); |
1857 } | 1815 } |
1858 else | 1816 else |
1859 Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir); | 1817 Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); |
1860 } | 1818 } |
1861 | 1819 |
1862 //----- (004032B2) -------------------------------------------------------- | 1820 //----- (004032B2) -------------------------------------------------------- |
1863 void Actor::AI_RandomMove( unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength ) | 1821 void Actor::AI_RandomMove( unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength ) |
1864 { | 1822 { |