comparison Actor.cpp @ 1879:7efa09ddb8b4

Actor::AI_SpellAttack1 cleaned up
author Grumpy7
date Thu, 17 Oct 2013 10:00:57 +0200
parents 6ffa3228eaf7
children 52e98d25cd64
comparison
equal deleted inserted replaced
1878:6ffa3228eaf7 1879:7efa09ddb8b4
1502 Actor *v3; // ebx@1 1502 Actor *v3; // ebx@1
1503 int16_t v4; // esi@3 1503 int16_t v4; // esi@3
1504 int16_t v5; // edi@3 1504 int16_t v5; // edi@3
1505 signed int v6; // eax@4 1505 signed int v6; // eax@4
1506 Vec3_int_ v7; // ST04_12@6 1506 Vec3_int_ v7; // ST04_12@6
1507 //unsigned int result; // eax@7
1508 AIDirection *v9; // eax@8 1507 AIDirection *v9; // eax@8
1509 __int16 v13; // ax@10 1508 __int16 v13; // ax@10
1510 signed int v16; // ecx@17
1511 AIDirection a3; // [sp+Ch] [bp-48h]@9 1509 AIDirection a3; // [sp+Ch] [bp-48h]@9
1512 AIDirection v18; // [sp+28h] [bp-2Ch]@9 1510 AIDirection v18; // [sp+28h] [bp-2Ch]@9
1513 int v19; // [sp+44h] [bp-10h]@6 1511 int v19; // [sp+44h] [bp-10h]@6
1514 signed int a2; // [sp+48h] [bp-Ch]@1 1512 signed int a2; // [sp+48h] [bp-Ch]@1
1515 int v21; // [sp+4Ch] [bp-8h]@3 1513 int v21; // [sp+4Ch] [bp-8h]@3
1562 } 1560 }
1563 if ( pParty->bTurnBasedModeOn == 1 ) 1561 if ( pParty->bTurnBasedModeOn == 1 )
1564 v3->pMonsterInfo.uRecoveryTime = pDira; 1562 v3->pMonsterInfo.uRecoveryTime = pDira;
1565 else 1563 else
1566 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333); 1564 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333);
1567 v16 = v3->pMonsterInfo.uSpell2ID;
1568 v3->vVelocity.z = 0; 1565 v3->vVelocity.z = 0;
1569 v3->vVelocity.y = 0; 1566 v3->vVelocity.y = 0;
1570 v3->vVelocity.x = 0; 1567 v3->vVelocity.x = 0;
1571 if ( _42FB5C_check_spell(v16) ) 1568 if ( _42FB5C_check_spell(v3->pMonsterInfo.uSpell2ID) )
1572 { 1569 {
1573 v3->uCurrentActionLength = 64; 1570 v3->uCurrentActionLength = 64;
1574 v3->uCurrentActionTime = 0; 1571 v3->uCurrentActionTime = 0;
1575 v3->uAIState = Fidgeting; 1572 v3->uAIState = Fidgeting;
1576 v3->UpdateAnimation(); 1573 v3->UpdateAnimation();
1585 1582
1586 //----- (00403854) -------------------------------------------------------- 1583 //----- (00403854) --------------------------------------------------------
1587 void Actor::AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) 1584 void Actor::AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
1588 { 1585 {
1589 Actor *v3; // ebx@1 1586 Actor *v3; // ebx@1
1590 AIDirection *v4; // esi@3 1587 int16_t v4; // esi@3
1591 AIDirection *v5; // edi@3 1588 int16_t v5; // edi@3
1592 signed int v6; // eax@4 1589 signed int v6; // eax@4
1593 Vec3_int_ v7; // ST04_12@6 1590 Vec3_int_ v7; // ST04_12@6
1594 //unsigned int result; // eax@7
1595 AIDirection *v9; // eax@8 1591 AIDirection *v9; // eax@8
1596 unsigned int v10; // esi@8
1597 AIDirection *v11; // esi@9
1598 SpriteFrame *v12; // ecx@10
1599 __int16 v13; // ax@10 1592 __int16 v13; // ax@10
1600 unsigned int v14; // ecx@10
1601 unsigned int v15; // eax@10
1602 signed int v16; // ecx@17 1593 signed int v16; // ecx@17
1603 AIDirection a3; // [sp+Ch] [bp-48h]@9 1594 AIDirection a3; // [sp+Ch] [bp-48h]@9
1604 AIDirection v18; // [sp+28h] [bp-2Ch]@9 1595 AIDirection v18; // [sp+28h] [bp-2Ch]@9
1605 int v19; // [sp+44h] [bp-10h]@6 1596 int v19; // [sp+44h] [bp-10h]@6
1606 //signed int a2; // [sp+48h] [bp-Ch]@1
1607 int v21; // [sp+4Ch] [bp-8h]@3 1597 int v21; // [sp+4Ch] [bp-8h]@3
1608 unsigned int v22; // [sp+50h] [bp-4h]@1
1609 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 1598 unsigned int pDira; // [sp+5Ch] [bp+8h]@10
1610 1599
1611 v22 = uActorID;
1612 v3 = &pActors[uActorID]; 1600 v3 = &pActors[uActorID];
1613 //a2 = edx0;
1614 if ( PID_TYPE(sTargetPid) == OBJECT_Actor) 1601 if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
1615 { 1602 {
1616 v6 = PID_ID(sTargetPid); 1603 v6 = PID_ID(sTargetPid);
1617 v4 = (AIDirection *)pActors[v6].vPosition.x; 1604 v4 = pActors[v6].vPosition.x;
1618 v5 = (AIDirection *)pActors[v6].vPosition.y; 1605 v5 = pActors[v6].vPosition.y;
1619 v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); 1606 v21 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z);
1607 }
1608 else if ( PID_TYPE(sTargetPid) == OBJECT_Player)
1609 {
1610 v4 = pParty->vPosition.x;
1611 v5 = pParty->vPosition.y;
1612 v21 = pParty->vPosition.z + pParty->sEyelevel;
1620 } 1613 }
1621 else 1614 else
1622 { 1615 {
1623 if ( PID_TYPE(sTargetPid) == OBJECT_Player) 1616 Error("Should not get here");
1624 { 1617 return;
1625 v4 = (AIDirection *)pParty->vPosition.x;
1626 v5 = (AIDirection *)pParty->vPosition.y;
1627 v21 = pParty->vPosition.z + pParty->sEyelevel;
1628 }
1629 else
1630 {
1631 v4 = pDir;
1632 v5 = pDir;
1633 }
1634 } 1618 }
1635 v19 = v3->uActorHeight; 1619 v19 = v3->uActorHeight;
1636 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); 1620 v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75);
1637 v7.y = v3->vPosition.y; 1621 v7.y = v3->vPosition.y;
1638 v7.x = v3->vPosition.x; 1622 v7.x = v3->vPosition.x;
1639 if ( sub_407A1C((int)v4, (int)v5, v21, v7) ) 1623 if ( sub_407A1C(v4, v5, v21, v7) )
1640 { 1624 {
1641 v9 = pDir; 1625 if ( pDir == nullptr )
1642 v10 = 0; 1626 {
1643 if ( !pDir ) 1627 v9 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0);
1644 { 1628 }
1645 v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v22), sTargetPid, &a3, 0); 1629 else
1646 v9 = &v18; 1630 {
1647 memcpy(&v18, v11, sizeof(v18)); 1631 v9 = pDir;
1648 v10 = 0; 1632 }
1649 }
1650 v12 = pSpriteFrameTable->pSpriteSFrames;
1651 v3->uYawAngle = LOWORD(v9->uYawAngle); 1633 v3->uYawAngle = LOWORD(v9->uYawAngle);
1652 v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; 1634 v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
1653 v14 = v22;
1654 v3->uCurrentActionLength = 8 * v13; 1635 v3->uCurrentActionLength = 8 * v13;
1655 v3->uCurrentActionTime = v10; 1636 v3->uCurrentActionTime = 0;
1656 v3->uAIState = AttackingRanged3; 1637 v3->uAIState = AttackingRanged3;
1657 Actor::PlaySound(v14, 0); 1638 Actor::PlaySound(uActorID, 0);
1658 v15 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
1659 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; 1639 pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
1660 if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v10 1640 if (v3->pActorBuffs[7].uExpireTime > 0)
1661 && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v10 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v10) ) 1641 {
1662 { 1642 pDira *= 2;
1663 v15 *= 2;
1664 pDira = v15;
1665 } 1643 }
1666 if ( pParty->bTurnBasedModeOn == 1 ) 1644 if ( pParty->bTurnBasedModeOn == 1 )
1667 v3->pMonsterInfo.uRecoveryTime = v15; 1645 v3->pMonsterInfo.uRecoveryTime = pDira;
1668 else 1646 else
1669 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength 1647 v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333);
1670 - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2
1671 * (double)(signed int)pDira
1672 * -2.133333333333333);
1673 v16 = v3->pMonsterInfo.uSpell1ID; 1648 v16 = v3->pMonsterInfo.uSpell1ID;
1674 v3->vVelocity.z = v10; 1649 v3->vVelocity.z = 0;
1675 v3->vVelocity.y = v10; 1650 v3->vVelocity.y = 0;
1676 v3->vVelocity.x = v10; 1651 v3->vVelocity.x = 0;
1677 if ( _42FB5C_check_spell(v16) ) 1652 if ( _42FB5C_check_spell(v16) )
1678 { 1653 {
1679 v3->uCurrentActionLength = 64; 1654 v3->uCurrentActionLength = 64;
1680 v3->uCurrentActionTime = v10; 1655 v3->uCurrentActionTime = 0;
1681 v3->uAIState = Fidgeting; 1656 v3->uAIState = Fidgeting;
1682 v3->UpdateAnimation(); 1657 v3->UpdateAnimation();
1683 v3->uAIState = AttackingRanged3; 1658 v3->uAIState = AttackingRanged3;
1684 } 1659 }
1685 else 1660 else
1686 v3->UpdateAnimation(); 1661 v3->UpdateAnimation();
1687 } 1662 }
1688 else 1663 else
1689 Actor::AI_Pursue1(v22, sTargetPid, v22, 64, pDir); 1664 Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir);
1690 } 1665 }
1691 1666
1692 //----- (0040368B) -------------------------------------------------------- 1667 //----- (0040368B) --------------------------------------------------------
1693 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)
1694 { 1669 {