Mercurial > mm7
comparison mm7_2.cpp @ 2207:ff8920a40c21
fixpoint_mul
author | Ritor1 |
---|---|
date | Thu, 06 Feb 2014 17:20:12 +0600 |
parents | 42c8807225a2 |
children | 0b2eea6f80c9 |
comparison
equal
deleted
inserted
replaced
2206:15a327be07e2 | 2207:ff8920a40c21 |
---|---|
1579 } | 1579 } |
1580 | 1580 |
1581 //----- (0045063B) -------------------------------------------------------- | 1581 //----- (0045063B) -------------------------------------------------------- |
1582 int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) | 1582 int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) |
1583 { | 1583 { |
1584 signed int v2; // edi@1 | |
1585 Actor *v3; // esi@2 | |
1586 //signed __int64 v4; // qax@3 | |
1587 int result; // eax@8 | 1584 int result; // eax@8 |
1588 int v6; // edi@11 | 1585 int v6; // edi@11 |
1589 int v7; // ebx@11 | 1586 int v7; // ebx@11 |
1590 int v8; // edi@11 | 1587 int v8; // edi@11 |
1591 int v9; // ebx@12 | 1588 int v9; // ebx@12 |
1597 int v15; // eax@20 | 1594 int v15; // eax@20 |
1598 int v16; // eax@20 | 1595 int v16; // eax@20 |
1599 int v17; // eax@20 | 1596 int v17; // eax@20 |
1600 int v18; // eax@21 | 1597 int v18; // eax@21 |
1601 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 | 1598 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 |
1602 int v20; // [sp+24h] [bp-20h]@11 | |
1603 //MapInfo *v21; // [sp+28h] [bp-1Ch]@1 | |
1604 int v22; // [sp+2Ch] [bp-18h]@3 | 1599 int v22; // [sp+2Ch] [bp-18h]@3 |
1605 int v23; // [sp+30h] [bp-14h]@11 | |
1606 //int v24; // [sp+34h] [bp-10h]@1 | |
1607 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 | 1600 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 |
1608 int v26; // [sp+3Ch] [bp-8h]@11 | 1601 int v26; // [sp+3Ch] [bp-8h]@11 |
1609 int v27; // [sp+40h] [bp-4h]@11 | 1602 int v27; // [sp+40h] [bp-4h]@11 |
1610 | 1603 |
1611 if (!uNumActors) | 1604 if (!uNumActors) |
1612 return 0; | 1605 return 0; |
1613 | 1606 |
1614 //v21 = a1; | 1607 for ( uint mon_id = 0; mon_id < uNumActors; ++mon_id ) |
1615 //v24 = a2; | 1608 { |
1616 v2 = 0; | 1609 if ((pActors[mon_id].pMonsterInfo.uID < 121 || pActors[mon_id].pMonsterInfo.uID > 123) && // Dwarf FemaleC A-C |
1617 v3 = pActors.data(); | 1610 (pActors[mon_id].pMonsterInfo.uID < 124 || pActors[mon_id].pMonsterInfo.uID > 126) && // Dwarf MaleA A-C |
1618 while ( 1 ) | 1611 (pActors[mon_id].pMonsterInfo.uID < 133 || pActors[mon_id].pMonsterInfo.uID > 135) && // Peasant Elf FemaleA A-C |
1619 { | 1612 pActors[mon_id].CanAct()) |
1620 if (v3->pMonsterInfo.uID >= 121 && v3->pMonsterInfo.uID <= 123 || // Dwarf FemaleC A-C | 1613 { |
1621 v3->pMonsterInfo.uID >= 124 && v3->pMonsterInfo.uID <= 126 || // Dwarf MaleA A-C | 1614 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
1622 v3->pMonsterInfo.uID >= 133 && v3->pMonsterInfo.uID <= 135 || // Peasant Elf FemaleA A-C | 1615 { |
1623 !v3->CanAct()) | 1616 v22 = 0; |
1624 { | 1617 uint face_id = 0; |
1625 ++v2; | 1618 for ( face_id; face_id < 100; ++face_id ) |
1626 ++v3; | 1619 { |
1627 | 1620 v6 = rand() % 1024 + 512; |
1628 if (v2 >= uNumActors) | 1621 v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; |
1629 return 0; | 1622 v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v7), v6); |
1630 | 1623 v8 = 0; |
1631 continue; | 1624 v19.uIndex = a2; |
1632 } | 1625 v19.vPosition.y = fixpoint_mul(stru_5C6E00->Sin(v7), v6) + pParty->vPosition.y; |
1633 | 1626 v19.vPosition.z = pParty->vPosition.z; |
1634 break; | 1627 v26 = 0; |
1628 v27 = 0; | |
1629 v19.vPosition.z = ODM_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z, 0, &v26, &v27, 0); | |
1630 for( int i = 0; i < pOutdoor->uNumBModels; i++ ) | |
1631 { | |
1632 v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); | |
1633 v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); | |
1634 if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) | |
1635 { | |
1636 v22 = 1; | |
1637 break; | |
1638 } | |
1639 } | |
1640 if ( v22 ) | |
1641 { | |
1642 v11 = face_id == 100; | |
1643 break; | |
1644 } | |
1645 } | |
1646 v11 = face_id == 100; | |
1647 } | |
1648 else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1649 { | |
1650 v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
1651 for ( uint i = 0; i < 100; ++i ) | |
1652 { | |
1653 v12 = rand() % 512 + 256; | |
1654 v13 = rand(); | |
1655 v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; | |
1656 v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1657 v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(v15, v12); | |
1658 v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1659 v19.vPosition.y = fixpoint_mul(v16, v12) + pParty->vPosition.y; | |
1660 v19.vPosition.z = pParty->vPosition.z; | |
1661 v19.uIndex = a2; | |
1662 v17 = pIndoor->GetSector(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z); | |
1663 if ( v17 == v22 ) | |
1664 { | |
1665 v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); | |
1666 v19.vPosition.z = v18; | |
1667 if ( v18 != -30000 ) | |
1668 { | |
1669 if ( abs(v18 - pParty->vPosition.z) <= 1024 ) | |
1670 break; | |
1671 } | |
1672 } | |
1673 } | |
1674 v11 = v26 == 100; | |
1675 } | |
1676 if ( v11 ) | |
1677 result = 0; | |
1678 else | |
1679 { | |
1680 SpawnEncounter(a1, &v19, 0, 0, 1); | |
1681 result = a2; | |
1682 } | |
1683 } | |
1684 | |
1685 //break; | |
1635 //v22 = v3->pMonsterInfo.uID - 1; | 1686 //v22 = v3->pMonsterInfo.uID - 1; |
1636 //v4 = (signed __int64)((double)v22 * 0.3333333333333333); | 1687 //v4 = (signed __int64)((double)v22 * 0.3333333333333333); |
1637 //if ( (int)v4 != 40 ) | 1688 //if ( (int)v4 != 40 ) |
1638 //{ | 1689 //{ |
1639 // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) | 1690 // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) |
1641 //} | 1692 //} |
1642 //++v2; | 1693 //++v2; |
1643 //++v3; | 1694 //++v3; |
1644 //if ( v2 >= (signed int)uNumActors ) | 1695 //if ( v2 >= (signed int)uNumActors ) |
1645 // goto LABEL_8; | 1696 // goto LABEL_8; |
1646 } | |
1647 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
1648 { | |
1649 v22 = 0; | |
1650 uFaceID = 0; | |
1651 while ( 1 ) | |
1652 { | |
1653 ++uFaceID; | |
1654 v6 = rand() % 1024 + 512; | |
1655 v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; | |
1656 v20 = stru_5C6E00->Cos(v7); | |
1657 v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; | |
1658 v19.vPosition.x = pParty->vPosition.x + v23; | |
1659 v20 = stru_5C6E00->Sin(v7); | |
1660 v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; | |
1661 v8 = 0; | |
1662 v19.uIndex = a2; | |
1663 v19.vPosition.y = v23 + pParty->vPosition.y; | |
1664 v19.vPosition.z = pParty->vPosition.z; | |
1665 v26 = 0; | |
1666 v27 = 0; | |
1667 v19.vPosition.z = ODM_GetFloorLevel( | |
1668 v19.vPosition.x, | |
1669 v23 + pParty->vPosition.y, | |
1670 pParty->vPosition.z, | |
1671 0, | |
1672 &v26, | |
1673 &v27, | |
1674 0); | |
1675 v23 = 0; | |
1676 for( int i = 0; i < pOutdoor->uNumBModels; i++ ) | |
1677 { | |
1678 v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); | |
1679 v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); | |
1680 if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) | |
1681 { | |
1682 v22 = 1; | |
1683 break; | |
1684 } | |
1685 } | |
1686 v11 = uFaceID == 100; | |
1687 if ( uFaceID >= 100 ) | |
1688 break; | |
1689 if ( v22 ) | |
1690 { | |
1691 v11 = uFaceID == 100; | |
1692 break; | |
1693 } | |
1694 } | |
1695 } | |
1696 else | |
1697 { | |
1698 v26 = 0; | |
1699 v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
1700 do | |
1701 { | |
1702 ++v26; | |
1703 v12 = rand() % 512 + 256; | |
1704 v13 = rand(); | |
1705 v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; | |
1706 v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1707 v20 = v15; | |
1708 v23 = (unsigned __int64)(v15 * (signed __int64)v12) >> 16; | |
1709 v19.vPosition.x = pParty->vPosition.x + v23; | |
1710 v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1711 v20 = v16; | |
1712 v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16; | |
1713 v19.vPosition.y = v23 + pParty->vPosition.y; | |
1714 v19.vPosition.z = pParty->vPosition.z; | |
1715 v19.uIndex = a2; | |
1716 v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z); | |
1717 if ( v17 == v22 ) | |
1718 { | |
1719 v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); | |
1720 v19.vPosition.z = v18; | |
1721 if ( v18 != -30000 ) | |
1722 { | |
1723 if ( abs(v18 - pParty->vPosition.z) <= 1024 ) | |
1724 break; | |
1725 } | |
1726 } | |
1727 } | |
1728 while ( v26 < 100 ); | |
1729 v11 = v26 == 100; | |
1730 } | |
1731 if ( v11 ) | |
1732 { | |
1733 result = 0; | |
1734 } | |
1735 else | |
1736 { | |
1737 SpawnEncounter(a1, &v19, 0, 0, 1); | |
1738 result = a2; | |
1739 } | 1697 } |
1740 return result; | 1698 return result; |
1741 } | 1699 } |
1742 | 1700 |
1743 //----- (00450AAA) -------------------------------------------------------- | 1701 //----- (00450AAA) -------------------------------------------------------- |