Advertisement
Guest User

Untitled

a guest
Jan 28th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 22.46 KB | None | 0 0
  1. #include "StdAfx.h"
  2. #include "../effectLib/EffectManager.h"
  3. #include "../milesLib/SoundManager.h"
  4.  
  5. #include "ActorInstance.h"
  6. #include "RaceData.h"
  7.  
  8. void CActorInstance::SetBattleHitEffect(DWORD dwID)
  9. {
  10.     m_dwBattleHitEffectID = dwID;
  11. }
  12.  
  13. void CActorInstance::SetBattleAttachEffect(DWORD dwID)
  14. {
  15.     m_dwBattleAttachEffectID = dwID;
  16. }
  17.  
  18. bool CActorInstance::CanAct()
  19. {
  20.     if (IsDead())
  21.         return false;
  22.  
  23.     if (IsStun())
  24.         return false;
  25.  
  26.     if (IsParalysis())
  27.         return false;
  28.  
  29.     if (IsFaint())
  30.         return false;
  31.  
  32.     if (IsSleep())
  33.         return false;
  34.  
  35.     return true;
  36. }
  37.  
  38. bool CActorInstance::CanUseSkill()
  39. {
  40.     if (!CanAct())
  41.         return false;
  42.  
  43.     DWORD dwCurMotionIndex=__GetCurrentMotionIndex();
  44.    
  45.     // Locked during attack
  46.     switch (dwCurMotionIndex)
  47.     {
  48.         case CRaceMotionData::NAME_FISHING_THROW:
  49.         case CRaceMotionData::NAME_FISHING_WAIT:
  50.         case CRaceMotionData::NAME_FISHING_STOP:
  51.         case CRaceMotionData::NAME_FISHING_REACT:
  52.         case CRaceMotionData::NAME_FISHING_CATCH:
  53.         case CRaceMotionData::NAME_FISHING_FAIL:
  54.             return TRUE;
  55.             break;
  56.     }
  57.  
  58.     // Locked during using skill
  59.     if (IsUsingSkill())
  60.     {
  61.         if (m_pkCurRaceMotionData->IsCancelEnableSkill())
  62.             return TRUE;
  63.  
  64.         return FALSE;
  65.     }  
  66.    
  67.     return true;
  68. }
  69.  
  70. bool CActorInstance::CanMove()
  71. {
  72.     if (!CanAct())
  73.         return false;
  74.  
  75.     if (isLock())
  76.         return false;
  77.  
  78.     return true;
  79. }
  80.  
  81. bool CActorInstance::CanAttack()
  82. {
  83.     if (!CanAct())
  84.         return false;
  85.  
  86.     if (IsUsingSkill())
  87.     {
  88.         if (!CanCancelSkill())
  89.             return false;
  90.     }
  91.  
  92.     return true;
  93. }
  94.  
  95. bool CActorInstance::CanFishing()
  96. {
  97.     if (!CanAct())
  98.         return false;
  99.  
  100.     if (IsUsingSkill())
  101.         return false;
  102.  
  103.     switch (__GetCurrentMotionIndex())
  104.     {
  105.         case CRaceMotionData::NAME_WAIT:
  106.         case CRaceMotionData::NAME_WALK:
  107.         case CRaceMotionData::NAME_RUN:
  108.             break;
  109.         default:
  110.             return false;
  111.             break;
  112.     }
  113.  
  114.     return true;
  115. }
  116.  
  117. BOOL CActorInstance::IsClickableDistanceDestInstance(CActorInstance & rkInstDst, float fDistance)
  118. {
  119.     TPixelPosition kPPosSrc;
  120.     GetPixelPosition(&kPPosSrc);
  121.  
  122.     D3DXVECTOR3 kD3DVct3Src(kPPosSrc);
  123.  
  124.     TCollisionPointInstanceList& rkLstkDefPtInst=rkInstDst.m_DefendingPointInstanceList;
  125.     TCollisionPointInstanceList::iterator i;
  126.  
  127.     for (i=rkLstkDefPtInst.begin(); i!=rkLstkDefPtInst.end(); ++i)
  128.     {
  129.         CDynamicSphereInstanceVector& rkVctkDefSphere = (*i).SphereInstanceVector;
  130.  
  131.         CDynamicSphereInstanceVector::iterator j;
  132.         for (j=rkVctkDefSphere.begin(); j!=rkVctkDefSphere.end(); ++j)
  133.         {
  134.             CDynamicSphereInstance& rkSphere=(*j);
  135.  
  136.             float fMovDistance=D3DXVec3Length(&D3DXVECTOR3(rkSphere.v3Position-kD3DVct3Src));
  137.             float fAtkDistance=rkSphere.fRadius+fDistance;
  138.  
  139.             if (fAtkDistance>fMovDistance)
  140.                 return TRUE;
  141.         }
  142.     }
  143.  
  144.     return FALSE;
  145. }
  146.  
  147. void CActorInstance::InputNormalAttackCommand(float fDirRot)
  148. {
  149.     if (!__CanInputNormalAttackCommand())
  150.         return;
  151.  
  152.     m_fAtkDirRot=fDirRot;
  153.     NormalAttack(m_fAtkDirRot);
  154. }
  155.  
  156. bool CActorInstance::InputComboAttackCommand(float fDirRot)
  157. {
  158.     m_fAtkDirRot=fDirRot;
  159.  
  160.     if (m_isPreInput)
  161.         return false;
  162.  
  163.     /////////////////////////////////////////////////////////////////////////////////
  164.  
  165.     // Process Input
  166.     if (0 == m_dwcurComboIndex)
  167.     {
  168.         __RunNextCombo();
  169.         return true;
  170.     }
  171.     else if (m_pkCurRaceMotionData->IsComboInputTimeData())
  172.     {
  173.         // 동작 경과 시간
  174.         float fElapsedTime = GetAttackingElapsedTime();
  175.  
  176.         // 이미 입력 한계 시간이 지났다면..
  177.         if (fElapsedTime > m_pkCurRaceMotionData->GetComboInputEndTime())
  178.         {
  179.             //Tracen("입력 한계 시간 지남");
  180.             if (IsBowMode())
  181.                 m_isNextPreInput = TRUE;
  182.             return false;
  183.         }
  184.  
  185.         if (fElapsedTime > m_pkCurRaceMotionData->GetNextComboTime()) // 콤보 발동 시간 이 후라면
  186.         {
  187.             //Tracen("다음 콤보 동작");
  188.             // args : BlendingTime
  189.             __RunNextCombo();
  190.             return true;
  191.         }
  192.         else if (fElapsedTime > m_pkCurRaceMotionData->GetComboInputStartTime()) // 선 입력 시간 범위 라면..
  193.         {
  194.             //Tracen("선 입력 설정");
  195.             m_isPreInput = TRUE;
  196.             return false;
  197.         }
  198.     }
  199.     else
  200.     {
  201.         float fElapsedTime = GetAttackingElapsedTime();
  202.         if (fElapsedTime > m_pkCurRaceMotionData->GetMotionDuration()*0.9f) // 콤보 발동 시간 이 후라면
  203.         {
  204.             //Tracen("다음 콤보 동작");
  205.             // args : BlendingTime
  206.             __RunNextCombo();
  207.             return true;
  208.         }
  209.     }
  210.     // Process Input
  211.  
  212.     return false;
  213. }
  214.  
  215. void CActorInstance::ComboProcess()
  216. {
  217.     // If combo is on action
  218.     if (0 != m_dwcurComboIndex)
  219.     {
  220.         if (!m_pkCurRaceMotionData)
  221.         {
  222.             Tracef("Attacking motion data is NULL! : %d\n", m_dwcurComboIndex);
  223.             __ClearCombo();
  224.             return;
  225.         }
  226.  
  227.         float fElapsedTime = GetAttackingElapsedTime();
  228.  
  229.         // Process PreInput
  230.         if (m_isPreInput)
  231.         {
  232.             //Tracenf("선입력 %f 다음콤보시간 %f", fElapsedTime, m_pkCurRaceMotionData->GetNextComboTime());
  233.             if (fElapsedTime > m_pkCurRaceMotionData->GetNextComboTime())
  234.             {
  235.                 __RunNextCombo();
  236.                 m_isPreInput = FALSE;
  237.  
  238.                 return;
  239.             }
  240.         }
  241.     }
  242.     else
  243.     {
  244.         m_isPreInput = FALSE;
  245.  
  246.         if (!IsUsingSkill())    // m_isNextPreInput는 활모드 일때만 사용하는 변수
  247.         if (m_isNextPreInput)   // 활일때만 스킬이 캔슬 되는건 이곳 때문임
  248.         {
  249.             __RunNextCombo();
  250.             m_isNextPreInput = FALSE;
  251.         }
  252.     }
  253. }
  254.  
  255. void CActorInstance::__RunNextCombo()
  256. {
  257.     ++m_dwcurComboIndex;
  258.     ///////////////////////////
  259.  
  260.     WORD wComboIndex = m_dwcurComboIndex;
  261.     WORD wComboType = __GetCurrentComboType();
  262.  
  263.     if (wComboIndex==0)
  264.     {
  265.         TraceError("CActorInstance::__RunNextCombo(wComboType=%d, wComboIndex=%d)", wComboType, wComboIndex);
  266.         return;
  267.     }
  268.  
  269.     DWORD dwComboArrayIndex = wComboIndex - 1;
  270.  
  271.     CRaceData::TComboData * pComboData;
  272.  
  273.     if (!m_pkCurRaceData->GetComboDataPointer(m_wcurMotionMode, wComboType, &pComboData))
  274.     {
  275.         TraceError("CActorInstance::__RunNextCombo(wComboType=%d, wComboIndex=%d) - m_pkCurRaceData->GetComboDataPointer(m_wcurMotionMode=%d, &pComboData) == NULL",
  276.             wComboType, wComboIndex, m_wcurMotionMode);
  277.         return;
  278.     }
  279.  
  280.     if (dwComboArrayIndex >= pComboData->ComboIndexVector.size())
  281.     {
  282.         TraceError("CActorInstance::__RunNextCombo(wComboType=%d, wComboIndex=%d) - (dwComboArrayIndex=%d) >= (pComboData->ComboIndexVector.size()=%d)",
  283.             wComboType, wComboIndex, dwComboArrayIndex, pComboData->ComboIndexVector.size());
  284.         return;
  285.     }
  286.  
  287.     WORD wcurComboMotionIndex = pComboData->ComboIndexVector[dwComboArrayIndex];
  288.     ComboAttack(wcurComboMotionIndex, m_fAtkDirRot, 0.1f);
  289.  
  290.     ////////////////////////////////
  291.     // 콤보가 끝났다면
  292.     if (m_dwcurComboIndex == pComboData->ComboIndexVector.size())
  293.     {
  294.         __OnEndCombo();
  295.     }
  296. }
  297.  
  298. void CActorInstance::__OnEndCombo()
  299. {
  300.     if (__IsMountingHorse())
  301.     {
  302.         m_dwcurComboIndex = 1;
  303.     }
  304.  
  305.     // 여기서 콤보를 초기화 해선 안된다.
  306.     // 콤보가 초기화 되는 곳은 마지막 콤보가 끝나고 Motion 이 자동으로 Wait 으로 돌아가는 시점이다.
  307. }
  308.  
  309. void CActorInstance::__ClearCombo()
  310. {
  311.     m_dwcurComboIndex = 0;
  312.     m_isPreInput = FALSE;
  313.     m_pkCurRaceMotionData = NULL;
  314. }
  315.  
  316. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  317.  
  318. BOOL CActorInstance::isAttacking()
  319. {
  320.     if (isNormalAttacking())
  321.         return TRUE;
  322.  
  323.     if (isComboAttacking())
  324.         return TRUE;
  325.  
  326.     if (IsSplashAttacking())
  327.         return TRUE;
  328.  
  329.     return FALSE;
  330. }
  331.  
  332. BOOL CActorInstance::isValidAttacking()
  333. {
  334.     if (!m_pkCurRaceMotionData)
  335.         return FALSE;
  336.  
  337.     if (!m_pkCurRaceMotionData->isAttackingMotion())
  338.         return FALSE;
  339.  
  340.     const NRaceData::TMotionAttackData * c_pData = m_pkCurRaceMotionData->GetMotionAttackDataPointer();
  341.     float fElapsedTime = GetAttackingElapsedTime();
  342.     NRaceData::THitDataContainer::const_iterator itor = c_pData->HitDataContainer.begin();
  343.     for (; itor != c_pData->HitDataContainer.end(); ++itor)
  344.     {
  345.         const NRaceData::THitData & c_rHitData = *itor;
  346.         if (fElapsedTime > c_rHitData.fAttackStartTime &&
  347.             fElapsedTime < c_rHitData.fAttackEndTime)
  348.             return TRUE;
  349.     }
  350.  
  351.     return TRUE;
  352. }
  353.  
  354. BOOL CActorInstance::CanCheckAttacking()
  355. {
  356.     if (isAttacking())
  357.         return true;
  358.  
  359.     return false;
  360. }
  361.  
  362. bool CActorInstance::__IsInSplashTime()
  363. {
  364.     if (m_kSplashArea.fDisappearingTime>GetLocalTime())
  365.         return true;
  366.  
  367.     return false;
  368. }
  369.  
  370. BOOL CActorInstance::isNormalAttacking()
  371. {
  372.     if (!m_pkCurRaceMotionData)
  373.         return FALSE;
  374.  
  375.     if (!m_pkCurRaceMotionData->isAttackingMotion())
  376.         return FALSE;
  377.  
  378.     const NRaceData::TMotionAttackData * c_pData = m_pkCurRaceMotionData->GetMotionAttackDataPointer();
  379.     if (NRaceData::MOTION_TYPE_NORMAL != c_pData->iMotionType)
  380.         return FALSE;
  381.  
  382.     return TRUE;
  383. }
  384.  
  385. BOOL CActorInstance::isComboAttacking()
  386. {
  387.     if (!m_pkCurRaceMotionData)
  388.         return FALSE;
  389.  
  390.     if (!m_pkCurRaceMotionData->isAttackingMotion())
  391.         return FALSE;
  392.  
  393.     const NRaceData::TMotionAttackData * c_pData = m_pkCurRaceMotionData->GetMotionAttackDataPointer();
  394.     if (NRaceData::MOTION_TYPE_COMBO != c_pData->iMotionType)
  395.         return FALSE;
  396.  
  397.     return TRUE;
  398. }
  399.  
  400. BOOL CActorInstance::IsSplashAttacking()
  401. {
  402.     if (!m_pkCurRaceMotionData)
  403.         return FALSE;
  404.  
  405.     if (m_pkCurRaceMotionData->HasSplashMotionEvent())
  406.         return TRUE;
  407.  
  408.     return FALSE;
  409. }
  410.  
  411. BOOL CActorInstance::__IsMovingSkill(WORD wSkillNumber)
  412. {
  413.     enum
  414.     {
  415.         HORSE_DASH_SKILL_NUMBER = 137,
  416.     };
  417.  
  418.     return HORSE_DASH_SKILL_NUMBER == wSkillNumber;
  419. }
  420.  
  421. BOOL CActorInstance::IsActEmotion()
  422. {
  423.     DWORD dwCurMotionIndex=__GetCurrentMotionIndex();
  424.     switch (dwCurMotionIndex)
  425.     {
  426.         case CRaceMotionData::NAME_FRENCH_KISS_START+0:
  427.         case CRaceMotionData::NAME_FRENCH_KISS_START+1:
  428.         case CRaceMotionData::NAME_FRENCH_KISS_START+2:
  429.         case CRaceMotionData::NAME_FRENCH_KISS_START+3:
  430.         case CRaceMotionData::NAME_KISS_START+0:
  431.         case CRaceMotionData::NAME_KISS_START+1:
  432.         case CRaceMotionData::NAME_KISS_START+2:
  433.         case CRaceMotionData::NAME_KISS_START+3:
  434.             return TRUE;
  435.             break;
  436.     }
  437.  
  438.     return FALSE;
  439. }
  440.  
  441. BOOL CActorInstance::IsUsingMovingSkill()
  442. {
  443.     return __IsMovingSkill(m_kCurMotNode.uSkill);
  444. }
  445.  
  446. DWORD CActorInstance::GetComboIndex()
  447. {
  448.     return m_dwcurComboIndex;
  449. }
  450.  
  451. float CActorInstance::GetAttackingElapsedTime()
  452. {
  453.     return (GetLocalTime() - m_kCurMotNode.fStartTime) * m_kCurMotNode.fSpeedRatio;
  454. //  return (GetLocalTime() - m_kCurMotNode.fStartTime) * __GetAttackSpeed();
  455. }
  456.  
  457. bool CActorInstance::__CanInputNormalAttackCommand()
  458. {
  459.     if (IsWaiting())
  460.         return true;
  461.  
  462.     if (isNormalAttacking())
  463.     {
  464.         float fElapsedTime = GetAttackingElapsedTime();
  465.  
  466.         if (fElapsedTime > m_pkCurRaceMotionData->GetMotionDuration()*0.9f)
  467.             return true;
  468.     }
  469.  
  470.     return false;
  471. }
  472.  
  473. BOOL CActorInstance::NormalAttack(float fDirRot, float fBlendTime)
  474. {
  475.     WORD wMotionIndex;
  476.     if (!m_pkCurRaceData->GetNormalAttackIndex(m_wcurMotionMode, &wMotionIndex))
  477.         return FALSE;
  478.  
  479.     BlendRotation(fDirRot, fBlendTime);
  480.     SetAdvancingRotation(fDirRot);
  481.     InterceptOnceMotion(wMotionIndex, 0.1f, 0, __GetAttackSpeed());
  482.  
  483.     __OnAttack(wMotionIndex);
  484.  
  485.     NEW_SetAtkPixelPosition(NEW_GetCurPixelPositionRef());
  486.  
  487.     return TRUE;
  488. }
  489.  
  490. BOOL CActorInstance::ComboAttack(DWORD dwMotionIndex, float fDirRot, float fBlendTime)
  491. {
  492.     BlendRotation(fDirRot, fBlendTime);
  493.     SetAdvancingRotation(fDirRot);
  494.  
  495.     InterceptOnceMotion(dwMotionIndex, fBlendTime, 0, __GetAttackSpeed());
  496.  
  497.     __OnAttack(dwMotionIndex);
  498.  
  499.     NEW_SetAtkPixelPosition(NEW_GetCurPixelPositionRef());
  500.  
  501.     return TRUE;
  502. }
  503.  
  504. void CActorInstance::__ProcessMotionEventAttackSuccess(DWORD dwMotionKey, BYTE byEventIndex, CActorInstance & rVictim)
  505. {
  506.     CRaceMotionData * pMotionData;
  507.  
  508.     if (!m_pkCurRaceData->GetMotionDataPointer(dwMotionKey, &pMotionData))
  509.         return;
  510.  
  511.     if (byEventIndex >= pMotionData->GetMotionEventDataCount())
  512.         return;
  513.  
  514.     const CRaceMotionData::TMotionAttackingEventData * pMotionEventData;
  515.     if (!pMotionData->GetMotionAttackingEventDataPointer(byEventIndex, &pMotionEventData))
  516.         return;
  517.  
  518.     const D3DXVECTOR3& c_rv3VictimPos=rVictim.GetPositionVectorRef();
  519.     __ProcessDataAttackSuccess(pMotionEventData->AttackData, rVictim, c_rv3VictimPos);
  520. }
  521.  
  522.  
  523. void CActorInstance::__ProcessMotionAttackSuccess(DWORD dwMotionKey, CActorInstance & rVictim)
  524. {
  525.     CRaceMotionData * c_pMotionData;
  526.  
  527.     if (!m_pkCurRaceData->GetMotionDataPointer(dwMotionKey, &c_pMotionData))
  528.         return;
  529.  
  530.     const D3DXVECTOR3& c_rv3VictimPos=rVictim.GetPositionVectorRef();
  531.     __ProcessDataAttackSuccess(c_pMotionData->GetMotionAttackDataReference(), rVictim, c_rv3VictimPos);
  532. }
  533.  
  534.  
  535. DWORD CActorInstance::__GetOwnerVID()
  536. {
  537.     return m_dwOwnerVID;
  538. }
  539.  
  540. float CActorInstance::__GetOwnerTime()
  541. {
  542.     return GetLocalTime()-m_fOwnerBaseTime;
  543. }
  544.  
  545. bool IS_HUGE_RACE(unsigned int vnum)
  546. {
  547.     switch (vnum)
  548.     {
  549.     case 2493:
  550.         return true;
  551.     }
  552.     return false;
  553. }
  554.  
  555. bool CActorInstance::__CanPushDestActor(CActorInstance& rkActorDst)
  556. {
  557.     if (rkActorDst.IsBuilding())
  558.         return false;
  559.  
  560.     if (rkActorDst.IsDoor())
  561.         return false;
  562.  
  563.     if (rkActorDst.IsStone())
  564.         return false;
  565.  
  566.     if (rkActorDst.IsNPC())
  567.         return false;
  568.  
  569.     // 거대 몬스터 밀림 제외
  570.     extern bool IS_HUGE_RACE(unsigned int vnum);
  571.     if (IS_HUGE_RACE(rkActorDst.GetRace()))
  572.         return false;
  573.  
  574.     if (rkActorDst.IsStun())
  575.         return true;
  576.  
  577.     if (rkActorDst.__GetOwnerVID()!=GetVirtualID())
  578.         return false;
  579.  
  580.     if (rkActorDst.__GetOwnerTime()>3.0f)
  581.         return false;
  582.  
  583.     return true;
  584. }
  585.  
  586. bool IS_PARTY_HUNTING_RACE(unsigned int vnum)
  587. {
  588.     return true;
  589.  
  590.     // 모든 몬스터 파티 사냥 적용
  591.     /*
  592.     if (vnum < 8) // 플레이어
  593.         return true;
  594.  
  595.     if (vnum >= 8000 && vnum <= 8112) // 메틴석
  596.         return true;
  597.  
  598.     if (vnum >= 2400 && vnum <  5000) // 천의 동굴 이후 몬스터
  599.         return true;
  600.  
  601.     return false;
  602.     */
  603. }
  604.  
  605. void CActorInstance::__ProcessDataAttackSuccess(const NRaceData::TAttackData & c_rAttackData, CActorInstance & rVictim, const D3DXVECTOR3 & c_rv3Position, UINT uiSkill, BOOL isSendPacket)
  606. {
  607.     if (NRaceData::HIT_TYPE_NONE == c_rAttackData.iHittingType)
  608.         return;
  609.  
  610.     InsertDelay(c_rAttackData.fStiffenTime);
  611.  
  612.     if (__CanPushDestActor(rVictim) && c_rAttackData.fExternalForce > 0.0f)
  613.     {
  614.         __PushCircle(rVictim);
  615.        
  616.         // VICTIM_COLLISION_TEST
  617.         const D3DXVECTOR3& kVictimPos = rVictim.GetPosition();
  618.         rVictim.m_PhysicsObject.IncreaseExternalForce(kVictimPos, c_rAttackData.fExternalForce); //*nForceRatio/100.0f);
  619.  
  620.         // VICTIM_COLLISION_TEST_END
  621.     }
  622.  
  623.     // Invisible Time
  624.     if (IS_PARTY_HUNTING_RACE(rVictim.GetRace()))
  625.     {
  626.         if (uiSkill) // 파티 사냥 몬스터라도 스킬이면 무적시간 적용
  627.             rVictim.m_fInvisibleTime = CTimer::Instance().GetCurrentSecond() + c_rAttackData.fInvisibleTime;
  628.  
  629.         if (m_isMain) // #0000794: [M2KR] 폴리모프 - 밸런싱 문제 타인 공격에 의한 무적 타임은 고려하지 않고 자신 공격에 의한것만 체크한다
  630.             rVictim.m_fInvisibleTime = CTimer::Instance().GetCurrentSecond() + c_rAttackData.fInvisibleTime;
  631.     }
  632.     else // 파티 사냥 몬스터가 아닐 경우만 적용
  633.     {
  634.         rVictim.m_fInvisibleTime = CTimer::Instance().GetCurrentSecond() + c_rAttackData.fInvisibleTime;
  635.     }
  636.  
  637.     // Stiffen Time
  638.     rVictim.InsertDelay(c_rAttackData.fStiffenTime);
  639.  
  640.     // Hit Effect
  641.     D3DXVECTOR3 vec3Effect(rVictim.m_x, rVictim.m_y, rVictim.m_z);
  642.  
  643.     // #0000780: [M2KR] 수룡 타격구 문제
  644.     extern bool IS_HUGE_RACE(unsigned int vnum);
  645.     if (IS_HUGE_RACE(rVictim.GetRace()))
  646.     {
  647.         vec3Effect = c_rv3Position;
  648.     }
  649.  
  650.     const D3DXVECTOR3 & v3Pos = GetPosition();
  651.  
  652.     float fHeight = D3DXToDegree(atan2(-vec3Effect.x + v3Pos.x,+vec3Effect.y - v3Pos.y));
  653.  
  654.     // 2004.08.03.myevan.빌딩이나 문의 경우 타격 효과가 보이지 않는다
  655.     if (rVictim.IsBuilding()||rVictim.IsDoor())
  656.     {
  657.         D3DXVECTOR3 vec3Delta=vec3Effect-v3Pos;
  658.         D3DXVec3Normalize(&vec3Delta, &vec3Delta);
  659.         vec3Delta*=30.0f;
  660.  
  661.         CEffectManager& rkEftMgr=CEffectManager::Instance();
  662.         if (m_dwBattleHitEffectID)
  663.             rkEftMgr.CreateEffect(m_dwBattleHitEffectID, v3Pos+vec3Delta, D3DXVECTOR3(0.0f, 0.0f, 0.0f));
  664.     }
  665.     else
  666.     {
  667.         CEffectManager& rkEftMgr=CEffectManager::Instance();
  668.         if (m_dwBattleHitEffectID)
  669.             rkEftMgr.CreateEffect(m_dwBattleHitEffectID, vec3Effect, D3DXVECTOR3(0.0f, 0.0f, fHeight));
  670.         if (m_dwBattleAttachEffectID)
  671.             rVictim.AttachEffectByID(0, NULL, m_dwBattleAttachEffectID);
  672.     }
  673.  
  674.     if (rVictim.IsBuilding())
  675.     {
  676.         // 2004.08.03.빌딩의 경우 흔들리면 이상하다
  677.     }
  678.     else if (rVictim.IsStone() || rVictim.IsDoor())
  679.     {
  680.         __HitStone(rVictim);
  681.     }
  682.     else
  683.     {
  684.         ///////////
  685.         // Motion
  686.         if (NRaceData::HIT_TYPE_GOOD == c_rAttackData.iHittingType || rVictim.IsResistFallen())
  687.         {
  688.             __HitGood(rVictim);
  689.         }
  690.         else if (NRaceData::HIT_TYPE_GREAT == c_rAttackData.iHittingType)
  691.         {
  692.             __HitGreate(rVictim);
  693.         }
  694.         else
  695.         {
  696.             TraceError("ProcessSucceedingAttacking: Unknown AttackingData.iHittingType %d", c_rAttackData.iHittingType);
  697.         }
  698.     }
  699.  
  700.     __OnHit(uiSkill, rVictim, isSendPacket);
  701. }
  702.  
  703. void CActorInstance::OnShootDamage()
  704. {
  705.     if (IsStun())
  706.     {
  707.         Die();
  708.     }
  709.     else
  710.     {
  711.         __Shake(100);
  712.  
  713.         if (!isLock() && !__IsKnockDownMotion() && !__IsStandUpMotion())
  714.         {
  715.             if (InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE))
  716.                 PushLoopMotion(CRaceMotionData::NAME_WAIT);
  717.         }
  718.     }
  719. }
  720.  
  721. void CActorInstance::__Shake(DWORD dwDuration)
  722. {
  723.     DWORD dwCurTime=ELTimer_GetMSec();
  724.     m_dwShakeTime=dwCurTime+dwDuration;
  725. }
  726.  
  727. void CActorInstance::ShakeProcess()
  728. {
  729.     if (m_dwShakeTime)
  730.     {
  731.         D3DXVECTOR3 v3Pos(0.0f, 0.0f, 0.0f);
  732.  
  733.         DWORD dwCurTime=ELTimer_GetMSec();
  734.  
  735.         if (m_dwShakeTime<dwCurTime)
  736.         {
  737.             m_dwShakeTime=0;
  738.         }
  739.         else
  740.         {
  741.             int nShakeSize=10;
  742.  
  743.             switch (rand()%2)
  744.             {
  745.                 case 0:v3Pos.x+=rand()%nShakeSize;break;
  746.                 case 1:v3Pos.x-=rand()%nShakeSize;break;
  747.             }
  748.  
  749.             switch (rand()%2)
  750.             {
  751.                 case 0:v3Pos.y+=rand()%nShakeSize;break;
  752.                 case 1:v3Pos.y-=rand()%nShakeSize;break;
  753.             }
  754.  
  755.             switch (rand()%2)
  756.             {
  757.                 case 0:v3Pos.z+=rand()%nShakeSize;break;
  758.                 case 1:v3Pos.z-=rand()%nShakeSize;break;
  759.             }
  760.         }
  761.  
  762.         m_worldMatrix._41   += v3Pos.x;
  763.         m_worldMatrix._42   += v3Pos.y;
  764.         m_worldMatrix._43   += v3Pos.z;
  765.     }
  766. }
  767.  
  768. void CActorInstance::__HitStone(CActorInstance& rVictim)
  769. {
  770.     if (rVictim.IsStun())
  771.     {
  772.         rVictim.Die();
  773.     }
  774.     else
  775.     {
  776.         rVictim.__Shake(100);
  777.     }
  778. }
  779.  
  780. void CActorInstance::__HitGood(CActorInstance& rVictim)
  781. {
  782.     if (rVictim.IsKnockDown())
  783.         return;
  784.  
  785.     if (rVictim.IsStun())
  786.     {
  787.         rVictim.Die();
  788.     }
  789.     else
  790.     {
  791.         rVictim.__Shake(100);
  792.  
  793.         if (!rVictim.isLock())
  794.         {
  795.             float fRotRad = D3DXToRadian(GetRotation());
  796.             float fVictimRotRad = D3DXToRadian(rVictim.GetRotation());
  797.  
  798.             D3DXVECTOR2 v2Normal(sin(fRotRad), cos(fRotRad));
  799.             D3DXVECTOR2 v2VictimNormal(sin(fVictimRotRad), cos(fVictimRotRad));
  800.  
  801.             D3DXVec2Normalize(&v2Normal, &v2Normal);
  802.             D3DXVec2Normalize(&v2VictimNormal, &v2VictimNormal);
  803.  
  804.             float fScalar = D3DXVec2Dot(&v2Normal, &v2VictimNormal);
  805.  
  806.             if (fScalar < 0.0f)
  807.             {
  808.                 if (rVictim.InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE))
  809.                     rVictim.PushLoopMotion(CRaceMotionData::NAME_WAIT);
  810.             }
  811.             else
  812.             {
  813.                 if (rVictim.InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE_BACK))
  814.                     rVictim.PushLoopMotion(CRaceMotionData::NAME_WAIT);
  815.                 else if (rVictim.InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE))
  816.                     rVictim.PushLoopMotion(CRaceMotionData::NAME_WAIT);
  817.             }
  818.         }
  819.     }
  820. }
  821.  
  822. void CActorInstance::__HitGreate(CActorInstance& rVictim)
  823. {
  824.     // DISABLE_KNOCKDOWN_ATTACK
  825.     if (rVictim.IsKnockDown())
  826.         return;
  827.     if (rVictim.__IsStandUpMotion())
  828.         return;
  829.     // END_OF_DISABLE_KNOCKDOWN_ATTACK
  830.  
  831.     float fRotRad = D3DXToRadian(GetRotation());
  832.     float fVictimRotRad = D3DXToRadian(rVictim.GetRotation());
  833.  
  834.     D3DXVECTOR2 v2Normal(sin(fRotRad), cos(fRotRad));
  835.     D3DXVECTOR2 v2VictimNormal(sin(fVictimRotRad), cos(fVictimRotRad));
  836.  
  837.     D3DXVec2Normalize(&v2Normal, &v2Normal);
  838.     D3DXVec2Normalize(&v2VictimNormal, &v2VictimNormal);
  839.  
  840.     float fScalar = D3DXVec2Dot(&v2Normal, &v2VictimNormal);
  841.  
  842.     rVictim.__Shake(100);
  843.  
  844.     if (rVictim.IsUsingSkill())
  845.         return;
  846.  
  847.     if (rVictim.IsStun())
  848.     {
  849.         if (fScalar < 0.0f)
  850.             rVictim.InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE_FLYING);
  851.         else
  852.         {
  853.             if (!rVictim.InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE_FLYING_BACK))
  854.                 rVictim.InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE_FLYING);
  855.         }
  856.  
  857.         rVictim.m_isRealDead=true;
  858.     }
  859.     else
  860.     {
  861.         if (fScalar < 0.0f)
  862.         {
  863.             if (rVictim.InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE_FLYING))
  864.             {
  865.                 rVictim.PushOnceMotion(CRaceMotionData::NAME_STAND_UP);
  866.                 rVictim.PushLoopMotion(CRaceMotionData::NAME_WAIT);
  867.             }
  868.         }
  869.         else
  870.         {
  871.             if (!rVictim.InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE_FLYING_BACK))
  872.             {
  873.                 if (rVictim.InterceptOnceMotion(CRaceMotionData::NAME_DAMAGE_FLYING))
  874.                 {
  875.                     rVictim.PushOnceMotion(CRaceMotionData::NAME_STAND_UP);
  876.                     rVictim.PushLoopMotion(CRaceMotionData::NAME_WAIT);
  877.                 }
  878.             }
  879.             else
  880.             {
  881.                 rVictim.PushOnceMotion(CRaceMotionData::NAME_STAND_UP_BACK);
  882.                 rVictim.PushLoopMotion(CRaceMotionData::NAME_WAIT);
  883.             }
  884.         }
  885.     }
  886. }
  887.  
  888. void CActorInstance::SetBlendingPosition(const TPixelPosition & c_rPosition, float fBlendingTime)
  889. {
  890.     //return;
  891.     TPixelPosition Position;
  892.  
  893.     Position.x = c_rPosition.x - m_x;
  894.     Position.y = c_rPosition.y - m_y;
  895.     Position.z = 0;
  896.  
  897.     m_PhysicsObject.SetLastPosition(Position, fBlendingTime);
  898. }
  899.  
  900. void CActorInstance::ResetBlendingPosition()
  901. {
  902.     m_PhysicsObject.Initialize();
  903. }
  904.  
  905. void CActorInstance::GetBlendingPosition(TPixelPosition * pPosition)
  906. {
  907.     if (m_PhysicsObject.isBlending())
  908.     {
  909.         m_PhysicsObject.GetLastPosition(pPosition);
  910.         pPosition->x += m_x;
  911.         pPosition->y += m_y;
  912.         pPosition->z += m_z;
  913.     }
  914.     else
  915.     {
  916.         pPosition->x = m_x;
  917.         pPosition->y = m_y;
  918.         pPosition->z = m_z;
  919.     }
  920. }
  921.  
  922. void CActorInstance::__PushCircle(CActorInstance & rVictim)
  923. {
  924.     const TPixelPosition& c_rkPPosAtk=NEW_GetAtkPixelPositionRef();
  925.  
  926.     D3DXVECTOR3 v3SrcPos(c_rkPPosAtk.x, -c_rkPPosAtk.y, c_rkPPosAtk.z);
  927.  
  928.     const D3DXVECTOR3& c_rv3SrcPos = v3SrcPos;
  929.     const D3DXVECTOR3& c_rv3DstPos = rVictim.GetPosition();
  930.  
  931.     D3DXVECTOR3 v3Direction;
  932.     v3Direction.x = c_rv3DstPos.x - c_rv3SrcPos.x;
  933.     v3Direction.y = c_rv3DstPos.y - c_rv3SrcPos.y;
  934.     v3Direction.z = 0.0f;
  935.     D3DXVec3Normalize(&v3Direction, &v3Direction);
  936.  
  937.     rVictim.__SetFallingDirection(v3Direction.x, v3Direction.y);
  938. }
  939.  
  940. void CActorInstance::__PushDirect(CActorInstance & rVictim)
  941. {
  942.     D3DXVECTOR3 v3Direction;
  943.     v3Direction.x = cosf(D3DXToRadian(m_fcurRotation + 270.0f));
  944.     v3Direction.y = sinf(D3DXToRadian(m_fcurRotation + 270.0f));
  945.     v3Direction.z = 0.0f;
  946.  
  947.     rVictim.__SetFallingDirection(v3Direction.x, v3Direction.y);
  948. }
  949.  
  950. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  951.  
  952. bool CActorInstance::__isInvisible()
  953. {
  954.     if (IsDead())
  955.         return true;
  956.  
  957.     if (CTimer::Instance().GetCurrentSecond() >= m_fInvisibleTime)
  958.         return false;
  959.  
  960.     return true;
  961. }
  962.  
  963. void CActorInstance::__SetFallingDirection(float fx, float fy)
  964. {
  965.     m_PhysicsObject.SetDirection(D3DXVECTOR3(fx, fy, 0.0f));
  966. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement