Guest User

Untitled

a guest
Jan 22nd, 2017
219
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "StdAfx.h"
  2. #include "InstanceBase.h"
  3. #include "PythonBackground.h"
  4. #include "PythonNonPlayer.h"
  5. #include "PythonPlayer.h"
  6. #include "PythonCharacterManager.h"
  7. #include "AbstractPlayer.h"
  8. #include "AbstractApplication.h"
  9. #include "packet.h"
  10.  
  11. #include "../eterlib/StateManager.h"
  12. #include "../gamelib/ItemManager.h"
  13.  
  14. BOOL HAIR_COLOR_ENABLE=FALSE;
  15. BOOL USE_ARMOR_SPECULAR=FALSE;
  16. BOOL RIDE_HORSE_ENABLE=TRUE;
  17. BOOL UNLIMITED_ARROW=FALSE;
  18. const float c_fDefaultRotationSpeed = 1200.0f;
  19. const float c_fDefaultHorseRotationSpeed = 300.0f;
  20.  
  21.  
  22. bool IsWall(unsigned race)
  23. {
  24. switch (race)
  25. {
  26. case 14201:
  27. case 14202:
  28. case 14203:
  29. case 14204:
  30. return true;
  31. break;
  32. }
  33. return false;
  34. }
  35.  
  36. //////////////////////////////////////////////////////////////////////////////////////
  37.  
  38.  
  39. CInstanceBase::SHORSE::SHORSE()
  40. {
  41. __Initialize();
  42. }
  43.  
  44. CInstanceBase::SHORSE::~SHORSE()
  45. {
  46. assert(m_pkActor==NULL);
  47. }
  48.  
  49. void CInstanceBase::SHORSE::__Initialize()
  50. {
  51. m_isMounting=false;
  52. m_pkActor=NULL;
  53. }
  54.  
  55. void CInstanceBase::SHORSE::SetAttackSpeed(UINT uAtkSpd)
  56. {
  57. if (!IsMounting())
  58. return;
  59.  
  60. CActorInstance& rkActor=GetActorRef();
  61. rkActor.SetAttackSpeed(uAtkSpd/100.0f);
  62. }
  63.  
  64. void CInstanceBase::SHORSE::SetMoveSpeed(UINT uMovSpd)
  65. {
  66. if (!IsMounting())
  67. return;
  68.  
  69. CActorInstance& rkActor=GetActorRef();
  70. rkActor.SetMoveSpeed(uMovSpd/100.0f);
  71. }
  72.  
  73. void CInstanceBase::SHORSE::Create(const TPixelPosition& c_rkPPos, UINT eRace, UINT eHitEffect)
  74. {
  75. assert(NULL==m_pkActor && "CInstanceBase::SHORSE::Create - ALREADY MOUNT");
  76.  
  77. m_pkActor=new CActorInstance;
  78.  
  79. CActorInstance& rkActor=GetActorRef();
  80. rkActor.SetEventHandler(CActorInstance::IEventHandler::GetEmptyPtr());
  81. if (!rkActor.SetRace(eRace))
  82. {
  83. delete m_pkActor;
  84. m_pkActor=NULL;
  85. return;
  86. }
  87.  
  88. rkActor.SetShape(0);
  89. rkActor.SetBattleHitEffect(eHitEffect);
  90. rkActor.SetAlphaValue(0.0f);
  91. rkActor.BlendAlphaValue(1.0f, 0.5f);
  92. rkActor.SetMoveSpeed(1.0f);
  93. rkActor.SetAttackSpeed(1.0f);
  94. rkActor.SetMotionMode(CRaceMotionData::MODE_GENERAL);
  95. rkActor.Stop();
  96. rkActor.RefreshActorInstance();
  97.  
  98. rkActor.SetCurPixelPosition(c_rkPPos);
  99.  
  100. m_isMounting=true;
  101. }
  102.  
  103. void CInstanceBase::SHORSE::Destroy()
  104. {
  105. if (m_pkActor)
  106. {
  107. m_pkActor->Destroy();
  108. delete m_pkActor;
  109. }
  110.  
  111. __Initialize();
  112. }
  113.  
  114. CActorInstance& CInstanceBase::SHORSE::GetActorRef()
  115. {
  116. assert(NULL!=m_pkActor && "CInstanceBase::SHORSE::GetActorRef");
  117. return *m_pkActor;
  118. }
  119.  
  120. CActorInstance* CInstanceBase::SHORSE::GetActorPtr()
  121. {
  122. return m_pkActor;
  123. }
  124.  
  125. UINT CInstanceBase::SHORSE::GetLevel()
  126. {
  127. if (m_pkActor)
  128. {
  129. DWORD mount = m_pkActor->GetRace();
  130. switch (mount)
  131. {
  132. case 20101:
  133. case 20102:
  134. case 20103:
  135. return 1;
  136. case 20104:
  137. case 20105:
  138. case 20106:
  139. return 2;
  140. case 20107:
  141. case 20108:
  142. case 20109:
  143. case 20110: // #0000673: [M2EU] 새로운 탈것 타고 공격 안됨
  144. case 20111: // #0000673: [M2EU] 새로운 탈것 타고 공격 안됨
  145. case 20112: // #0000673: [M2EU] 새로운 탈것 타고 공격 안됨
  146. case 20113: // #0000673: [M2EU] 새로운 탈것 타고 공격 안됨
  147. case 20114:
  148. case 20115:
  149. case 20116:
  150. case 20117:
  151. case 20118:
  152. case 20120:
  153. case 20121:
  154. case 20122:
  155. case 20123:
  156. case 20124:
  157. case 20125:
  158. return 3;
  159. case 20229:
  160. return 2;
  161. }
  162.  
  163. // 마운트 확장 시스템용 특수 처리 (20201 ~ 20212 대역을 사용하고 순서대로 4개씩 나눠서 초급, 중급, 고급임)
  164. // -- 탈것 레벨을 클라에서 측정하고 공격/스킬 사용가능 여부도 클라에서 처리하는 것 자체에 문제가 있는 듯.. [hyo]
  165. {
  166. // 중급 탈것은 레벨2 (공격 가능, 스킬 불가)
  167. if ((20205 <= mount && 20208 >= mount) ||
  168. (20214 == mount) || (20217 == mount) // 난폭한 전갑순순록, 난폭한 전갑암순록
  169. )
  170. return 2;
  171.  
  172. // 고급 탈것은 레벨3 (공격 가능, 스킬 가능)
  173. if ((20209 <= mount && 20212 >= mount) ||
  174. (20215 == mount) || (20218 == mount) || (20119 == mount) || // 용맹한 전갑순순록, 용맹한 전갑암순록
  175. (20219 <= mount && 20222 >= mount) ||
  176. (20225 <= mount && 20227 >= mount) ||
  177. (20230 <= mount && 20235 >= mount))
  178. return 3;
  179. }
  180. }
  181. return 0;
  182. }
  183.  
  184. bool CInstanceBase::SHORSE::IsNewMount()
  185. {
  186. if (!m_pkActor)
  187. return false;
  188. DWORD mount = m_pkActor->GetRace();
  189.  
  190. if ((20205 <= mount && 20208 >= mount) ||
  191. (20214 == mount) || (20217 == mount) // 난폭한 전갑순순록, 난폭한 전갑암순록
  192. )
  193. return true;
  194.  
  195. // 고급 탈것
  196. if ((20209 <= mount && 20212 >= mount) ||
  197. (20215 == mount) || (20218 == mount) || (20119 == mount) || // 용맹한 전갑순순록, 용맹한 전갑암순록
  198. (20219 <= mount && 20222 >= mount) ||
  199. (20225 <= mount && 20227 >= mount) ||
  200. (20230 <= mount && 20235 >= mount))
  201. return true;
  202.  
  203. return false;
  204. }
  205. bool CInstanceBase::SHORSE::CanUseSkill()
  206. {
  207. // 마상스킬은 말의 레벨이 3 이상이어야만 함.
  208. if (IsMounting())
  209. return 2 < GetLevel();
  210.  
  211. return true;
  212. }
  213.  
  214. bool CInstanceBase::SHORSE::CanAttack()
  215. {
  216. if (IsMounting())
  217. if (GetLevel()<=1)
  218. return false;
  219.  
  220. return true;
  221. }
  222.  
  223. bool CInstanceBase::SHORSE::IsMounting()
  224. {
  225. return m_isMounting;
  226. }
  227.  
  228. void CInstanceBase::SHORSE::Deform()
  229. {
  230. if (!IsMounting())
  231. return;
  232.  
  233. CActorInstance& rkActor=GetActorRef();
  234. rkActor.INSTANCEBASE_Deform();
  235. }
  236.  
  237. void CInstanceBase::SHORSE::Render()
  238. {
  239. if (!IsMounting())
  240. return;
  241.  
  242. CActorInstance& rkActor=GetActorRef();
  243. rkActor.Render();
  244. }
  245.  
  246. void CInstanceBase::__AttachHorseSaddle()
  247. {
  248. if (!IsMountingHorse())
  249. return;
  250. m_kHorse.m_pkActor->AttachModelInstance(CRaceData::PART_MAIN, "saddle", m_GraphicThingInstance, CRaceData::PART_MAIN);
  251. }
  252.  
  253. void CInstanceBase::__DetachHorseSaddle()
  254. {
  255. if (!IsMountingHorse())
  256. return;
  257. m_kHorse.m_pkActor->DetachModelInstance(CRaceData::PART_MAIN, m_GraphicThingInstance, CRaceData::PART_MAIN);
  258. }
  259.  
  260. //////////////////////////////////////////////////////////////////////////////////////
  261.  
  262. void CInstanceBase::BlockMovement()
  263. {
  264. m_GraphicThingInstance.BlockMovement();
  265. }
  266.  
  267. bool CInstanceBase::IsBlockObject(const CGraphicObjectInstance& c_rkBGObj)
  268. {
  269. return m_GraphicThingInstance.IsBlockObject(c_rkBGObj);
  270. }
  271.  
  272. bool CInstanceBase::AvoidObject(const CGraphicObjectInstance& c_rkBGObj)
  273. {
  274. return m_GraphicThingInstance.AvoidObject(c_rkBGObj);
  275. }
  276.  
  277. ///////////////////////////////////////////////////////////////////////////////////
  278.  
  279. bool __ArmorVnumToShape(int iVnum, DWORD * pdwShape)
  280. {
  281. *pdwShape = iVnum;
  282.  
  283. /////////////////////////////////////////
  284.  
  285. if (0 == iVnum || 1 == iVnum)
  286. return false;
  287.  
  288. if (!USE_ARMOR_SPECULAR)
  289. return false;
  290.  
  291. CItemData * pItemData;
  292. if (!CItemManager::Instance().GetItemDataPointer(iVnum, &pItemData))
  293. return false;
  294.  
  295. enum
  296. {
  297. SHAPE_VALUE_SLOT_INDEX = 3,
  298. };
  299.  
  300. *pdwShape = pItemData->GetValue(SHAPE_VALUE_SLOT_INDEX);
  301.  
  302. return true;
  303. }
  304.  
  305. // 2004.07.05.myevan.궁신탄영 끼이는 문제
  306. class CActorInstanceBackground : public IBackground
  307. {
  308. public:
  309. CActorInstanceBackground() {}
  310. virtual ~CActorInstanceBackground() {}
  311. bool IsBlock(int x, int y)
  312. {
  313. CPythonBackground& rkBG=CPythonBackground::Instance();
  314. return rkBG.isAttrOn(x, y, CTerrainImpl::ATTRIBUTE_BLOCK);
  315. }
  316. };
  317.  
  318. static CActorInstanceBackground gs_kActorInstBG;
  319.  
  320. bool CInstanceBase::LessRenderOrder(CInstanceBase* pkInst)
  321. {
  322. int nMainAlpha=(__GetAlphaValue() < 1.0f) ? 1 : 0;
  323. int nTestAlpha=(pkInst->__GetAlphaValue() < 1.0f) ? 1 : 0;
  324. if (nMainAlpha < nTestAlpha)
  325. return true;
  326. if (nMainAlpha > nTestAlpha)
  327. return false;
  328.  
  329. if (GetRace()<pkInst->GetRace())
  330. return true;
  331. if (GetRace()>pkInst->GetRace())
  332. return false;
  333.  
  334. if (GetShape()<pkInst->GetShape())
  335. return true;
  336.  
  337. if (GetShape()>pkInst->GetShape())
  338. return false;
  339.  
  340. UINT uLeftLODLevel=__LessRenderOrder_GetLODLevel();
  341. UINT uRightLODLevel=pkInst->__LessRenderOrder_GetLODLevel();
  342. if (uLeftLODLevel<uRightLODLevel)
  343. return true;
  344. if (uLeftLODLevel>uRightLODLevel)
  345. return false;
  346.  
  347. if (m_awPart[CRaceData::PART_WEAPON]<pkInst->m_awPart[CRaceData::PART_WEAPON])
  348. return true;
  349.  
  350. return false;
  351. }
  352.  
  353. UINT CInstanceBase::__LessRenderOrder_GetLODLevel()
  354. {
  355. CGrannyLODController* pLODCtrl=m_GraphicThingInstance.GetLODControllerPointer(0);
  356. if (!pLODCtrl)
  357. return 0;
  358.  
  359. return pLODCtrl->GetLODLevel();
  360. }
  361.  
  362. bool CInstanceBase::__Background_GetWaterHeight(const TPixelPosition& c_rkPPos, float* pfHeight)
  363. {
  364. long lHeight;
  365. if (!CPythonBackground::Instance().GetWaterHeight(int(c_rkPPos.x), int(c_rkPPos.y), &lHeight))
  366. return false;
  367.  
  368. *pfHeight = float(lHeight);
  369.  
  370. return true;
  371. }
  372.  
  373. bool CInstanceBase::__Background_IsWaterPixelPosition(const TPixelPosition& c_rkPPos)
  374. {
  375. return CPythonBackground::Instance().isAttrOn(c_rkPPos.x, c_rkPPos.y, CTerrainImpl::ATTRIBUTE_WATER);
  376. }
  377.  
  378. const float PC_DUST_RANGE = 2000.0f;
  379. const float NPC_DUST_RANGE = 1000.0f;
  380.  
  381. DWORD CInstanceBase::ms_dwUpdateCounter=0;
  382. DWORD CInstanceBase::ms_dwRenderCounter=0;
  383. DWORD CInstanceBase::ms_dwDeformCounter=0;
  384.  
  385. CDynamicPool<CInstanceBase> CInstanceBase::ms_kPool;
  386.  
  387. bool CInstanceBase::__IsInDustRange()
  388. {
  389. if (!__IsExistMainInstance())
  390. return false;
  391.  
  392. CInstanceBase* pkInstMain=__GetMainInstancePtr();
  393.  
  394. float fDistance=NEW_GetDistanceFromDestInstance(*pkInstMain);
  395.  
  396. if (IsPC())
  397. {
  398. if (fDistance<=PC_DUST_RANGE)
  399. return true;
  400. }
  401.  
  402. if (fDistance<=NPC_DUST_RANGE)
  403. return true;
  404.  
  405. return false;
  406. }
  407.  
  408. void CInstanceBase::__EnableSkipCollision()
  409. {
  410. if (__IsMainInstance())
  411. {
  412. TraceError("CInstanceBase::__EnableSkipCollision - 자신은 충돌검사스킵이 되면 안된다!!");
  413. return;
  414. }
  415. m_GraphicThingInstance.EnableSkipCollision();
  416. }
  417.  
  418. void CInstanceBase::__DisableSkipCollision()
  419. {
  420. m_GraphicThingInstance.DisableSkipCollision();
  421. }
  422.  
  423. DWORD CInstanceBase::__GetShadowMapColor(float x, float y)
  424. {
  425. CPythonBackground& rkBG=CPythonBackground::Instance();
  426. return rkBG.GetShadowMapColor(x, y);
  427. }
  428.  
  429. float CInstanceBase::__GetBackgroundHeight(float x, float y)
  430. {
  431. CPythonBackground& rkBG=CPythonBackground::Instance();
  432. return rkBG.GetHeight(x, y);
  433. }
  434.  
  435. #ifdef __MOVIE_MODE__
  436.  
  437. BOOL CInstanceBase::IsMovieMode()
  438. {
  439. if (IsAffect(AFFECT_INVISIBILITY))
  440. return true;
  441.  
  442. return false;
  443. }
  444.  
  445. #endif
  446.  
  447. BOOL CInstanceBase::IsInvisibility()
  448. {
  449. if (IsAffect(AFFECT_INVISIBILITY))
  450. return true;
  451.  
  452. return false;
  453. }
  454.  
  455. BOOL CInstanceBase::IsParalysis()
  456. {
  457. return m_GraphicThingInstance.IsParalysis();
  458. }
  459.  
  460. BOOL CInstanceBase::IsGameMaster()
  461. {
  462. if (m_kAffectFlagContainer.IsSet(AFFECT_YMIR))
  463. return true;
  464. return false;
  465. }
  466.  
  467.  
  468. BOOL CInstanceBase::IsSameEmpire(CInstanceBase& rkInstDst)
  469. {
  470. if (0 == rkInstDst.m_dwEmpireID)
  471. return TRUE;
  472.  
  473. if (IsGameMaster())
  474. return TRUE;
  475.  
  476. if (rkInstDst.IsGameMaster())
  477. return TRUE;
  478.  
  479. if (rkInstDst.m_dwEmpireID==m_dwEmpireID)
  480. return TRUE;
  481.  
  482. return FALSE;
  483. }
  484.  
  485. DWORD CInstanceBase::GetEmpireID()
  486. {
  487. return m_dwEmpireID;
  488. }
  489.  
  490. DWORD CInstanceBase::GetGuildID()
  491. {
  492. return m_dwGuildID;
  493. }
  494.  
  495. int CInstanceBase::GetAlignment()
  496. {
  497. return m_sAlignment;
  498. }
  499.  
  500. UINT CInstanceBase::GetAlignmentGrade()
  501. {
  502. if (m_sAlignment >= 12000)
  503. return 0;
  504. else if (m_sAlignment >= 8000)
  505. return 1;
  506. else if (m_sAlignment >= 4000)
  507. return 2;
  508. else if (m_sAlignment >= 1000)
  509. return 3;
  510. else if (m_sAlignment >= 0)
  511. return 4;
  512. else if (m_sAlignment > -4000)
  513. return 5;
  514. else if (m_sAlignment > -8000)
  515. return 6;
  516. else if (m_sAlignment > -12000)
  517. return 7;
  518.  
  519. return 8;
  520. }
  521.  
  522. int CInstanceBase::GetAlignmentType()
  523. {
  524. switch (GetAlignmentGrade())
  525. {
  526. case 0:
  527. case 1:
  528. case 2:
  529. case 3:
  530. {
  531. return ALIGNMENT_TYPE_WHITE;
  532. break;
  533. }
  534.  
  535. case 5:
  536. case 6:
  537. case 7:
  538. case 8:
  539. {
  540. return ALIGNMENT_TYPE_DARK;
  541. break;
  542. }
  543. }
  544.  
  545. return ALIGNMENT_TYPE_NORMAL;
  546. }
  547.  
  548. BYTE CInstanceBase::GetPKMode()
  549. {
  550. return m_byPKMode;
  551. }
  552.  
  553. bool CInstanceBase::IsKiller()
  554. {
  555. return m_isKiller;
  556. }
  557.  
  558. bool CInstanceBase::IsPartyMember()
  559. {
  560. return m_isPartyMember;
  561. }
  562.  
  563. BOOL CInstanceBase::IsInSafe()
  564. {
  565. const TPixelPosition& c_rkPPosCur=m_GraphicThingInstance.NEW_GetCurPixelPositionRef();
  566. if (CPythonBackground::Instance().isAttrOn(c_rkPPosCur.x, c_rkPPosCur.y, CTerrainImpl::ATTRIBUTE_BANPK))
  567. return TRUE;
  568.  
  569. return FALSE;
  570. }
  571.  
  572. float CInstanceBase::CalculateDistanceSq3d(const TPixelPosition& c_rkPPosDst)
  573. {
  574. const TPixelPosition& c_rkPPosSrc=m_GraphicThingInstance.NEW_GetCurPixelPositionRef();
  575. return SPixelPosition_CalculateDistanceSq3d(c_rkPPosSrc, c_rkPPosDst);
  576. }
  577.  
  578. void CInstanceBase::OnSelected()
  579. {
  580. #ifdef __MOVIE_MODE__
  581. if (!__IsExistMainInstance())
  582. return;
  583. #endif
  584.  
  585. if (IsStoneDoor())
  586. return;
  587.  
  588. if (IsDead())
  589. return;
  590.  
  591. __AttachSelectEffect();
  592. }
  593.  
  594. void CInstanceBase::OnUnselected()
  595. {
  596. __DetachSelectEffect();
  597. }
  598.  
  599. void CInstanceBase::OnTargeted()
  600. {
  601. #ifdef __MOVIE_MODE__
  602. if (!__IsExistMainInstance())
  603. return;
  604. #endif
  605.  
  606. if (IsStoneDoor())
  607. return;
  608.  
  609. if (IsDead())
  610. return;
  611.  
  612. __AttachTargetEffect();
  613. }
  614.  
  615. void CInstanceBase::OnUntargeted()
  616. {
  617. __DetachTargetEffect();
  618. }
  619.  
  620. void CInstanceBase::DestroySystem()
  621. {
  622. ms_kPool.Clear();
  623. }
  624.  
  625. void CInstanceBase::CreateSystem(UINT uCapacity)
  626. {
  627. ms_kPool.Create(uCapacity);
  628.  
  629. memset(ms_adwCRCAffectEffect, 0, sizeof(ms_adwCRCAffectEffect));
  630.  
  631. ms_fDustGap=250.0f;
  632. ms_fHorseDustGap=500.0f;
  633. }
  634.  
  635. CInstanceBase* CInstanceBase::New()
  636. {
  637. return ms_kPool.Alloc();
  638. }
  639.  
  640. void CInstanceBase::Delete(CInstanceBase* pkInst)
  641. {
  642. pkInst->Destroy();
  643. ms_kPool.Free(pkInst);
  644. }
  645.  
  646. void CInstanceBase::SetMainInstance()
  647. {
  648. CPythonCharacterManager& rkChrMgr=CPythonCharacterManager::Instance();
  649.  
  650. DWORD dwVID=GetVirtualID();
  651. rkChrMgr.SetMainInstance(dwVID);
  652.  
  653. m_GraphicThingInstance.SetMainInstance();
  654. }
  655.  
  656. CInstanceBase* CInstanceBase::__GetMainInstancePtr()
  657. {
  658. CPythonCharacterManager& rkChrMgr=CPythonCharacterManager::Instance();
  659. return rkChrMgr.GetMainInstancePtr();
  660. }
  661.  
  662. void CInstanceBase::__ClearMainInstance()
  663. {
  664. CPythonCharacterManager& rkChrMgr=CPythonCharacterManager::Instance();
  665. rkChrMgr.ClearMainInstance();
  666. }
  667.  
  668. /* 실제 플레이어 캐릭터인지 조사.*/
  669. bool CInstanceBase::__IsMainInstance()
  670. {
  671. if (this==__GetMainInstancePtr())
  672. return true;
  673.  
  674. return false;
  675. }
  676.  
  677. bool CInstanceBase::__IsExistMainInstance()
  678. {
  679. if(__GetMainInstancePtr())
  680. return true;
  681. else
  682. return false;
  683. }
  684.  
  685. bool CInstanceBase::__MainCanSeeHiddenThing()
  686. {
  687. return false;
  688. // CInstanceBase * pInstance = __GetMainInstancePtr();
  689. // return pInstance->IsAffect(AFFECT_GAMJI);
  690. }
  691.  
  692. float CInstanceBase::__GetBowRange()
  693. {
  694. float fRange = 2500.0f - 100.0f;
  695.  
  696. if (__IsMainInstance())
  697. {
  698. IAbstractPlayer& rPlayer=IAbstractPlayer::GetSingleton();
  699. fRange += float(rPlayer.GetStatus(POINT_BOW_DISTANCE));
  700. }
  701.  
  702. return fRange;
  703. }
  704.  
  705. CInstanceBase* CInstanceBase::__FindInstancePtr(DWORD dwVID)
  706. {
  707. CPythonCharacterManager& rkChrMgr=CPythonCharacterManager::Instance();
  708. return rkChrMgr.GetInstancePtr(dwVID);
  709. }
  710.  
  711. bool CInstanceBase::__FindRaceType(DWORD dwRace, BYTE* pbType)
  712. {
  713. CPythonNonPlayer& rkNonPlayer=CPythonNonPlayer::Instance();
  714. return rkNonPlayer.GetInstanceType(dwRace, pbType);
  715. }
  716.  
  717. bool CInstanceBase::Create(const SCreateData& c_rkCreateData)
  718. {
  719. IAbstractApplication::GetSingleton().SkipRenderBuffering(300);
  720.  
  721. SetInstanceType(c_rkCreateData.m_bType);
  722.  
  723.  
  724. #ifdef NEW_PET_SYSTEM
  725. if (!SetRace(c_rkCreateData.m_dwRace))
  726. return false;
  727.  
  728. if(c_rkCreateData.m_dwRace == 34041 || c_rkCreateData.m_dwRace == 34045 || c_rkCreateData.m_dwRace == 34049 || c_rkCreateData.m_dwRace == 34053)
  729. {
  730. if(c_rkCreateData.m_dwLevel >= 81)
  731. SetRace(c_rkCreateData.m_dwRace+1);
  732. }
  733. #else
  734. if (!SetRace(c_rkCreateData.m_dwRace))
  735. return false;
  736. #endif
  737.  
  738. SetVirtualID(c_rkCreateData.m_dwVID);
  739.  
  740. if (c_rkCreateData.m_isMain)
  741. SetMainInstance();
  742.  
  743. if (IsGuildWall())
  744. {
  745. unsigned center_x;
  746. unsigned center_y;
  747.  
  748. c_rkCreateData.m_kAffectFlags.ConvertToPosition(&center_x, &center_y);
  749.  
  750. float center_z = __GetBackgroundHeight(center_x, center_y);
  751. NEW_SetPixelPosition(TPixelPosition(float(c_rkCreateData.m_lPosX), float(c_rkCreateData.m_lPosY), center_z));
  752. }
  753. else
  754. {
  755. SCRIPT_SetPixelPosition(float(c_rkCreateData.m_lPosX), float(c_rkCreateData.m_lPosY));
  756. }
  757.  
  758. if (0 != c_rkCreateData.m_dwMountVnum)
  759. MountHorse(c_rkCreateData.m_dwMountVnum);
  760.  
  761. SetArmor(c_rkCreateData.m_dwArmor);
  762.  
  763. if (IsPC())
  764. {
  765. SetHair(c_rkCreateData.m_dwHair);
  766. SetAcce(c_rkCreateData.m_dwAcce);
  767. SetWeapon(c_rkCreateData.m_dwWeapon);
  768. }
  769.  
  770. __Create_SetName(c_rkCreateData);
  771.  
  772. m_dwLevel = c_rkCreateData.m_dwLevel;
  773. m_dwGuildID = c_rkCreateData.m_dwGuildID;
  774. m_dwEmpireID = c_rkCreateData.m_dwEmpireID;
  775.  
  776. SetVirtualNumber(c_rkCreateData.m_dwRace);
  777. SetRotation(c_rkCreateData.m_fRot);
  778.  
  779. SetAlignment(c_rkCreateData.m_sAlignment);
  780. #ifdef NEW_PET_SYSTEM
  781. SetLevelText(c_rkCreateData.m_dwLevel);
  782. #endif
  783. SetPKMode(c_rkCreateData.m_byPKMode);
  784.  
  785. SetMoveSpeed(c_rkCreateData.m_dwMovSpd);
  786. SetAttackSpeed(c_rkCreateData.m_dwAtkSpd);
  787. #ifdef NEW_PET_SYSTEM
  788. if(m_dwRace == 34041 ||m_dwRace == 34045 || m_dwRace == 34049 ||m_dwRace == 34053){
  789. float scale = c_rkCreateData.m_dwLevel * 0.005f + 0.75f;
  790. m_GraphicThingInstance.SetScaleNew(scale, scale, scale);
  791. }
  792. else
  793. m_GraphicThingInstance.SetScaleNew(1.0f,1.0f,1.0f);
  794. #endif
  795.  
  796. // NOTE : Dress 를 입고 있으면 Alpha 를 넣지 않는다.
  797. if (!IsWearingDress())
  798. {
  799. // NOTE : 반드시 Affect 셋팅 윗쪽에 있어야 함
  800. m_GraphicThingInstance.SetAlphaValue(0.0f);
  801. m_GraphicThingInstance.BlendAlphaValue(1.0f, 0.5f);
  802. }
  803.  
  804. if (!IsGuildWall())
  805. {
  806. SetAffectFlagContainer(c_rkCreateData.m_kAffectFlags);
  807. }
  808.  
  809. // NOTE : 반드시 Affect 셋팅 후에 해야 함
  810. AttachTextTail();
  811. RefreshTextTail();
  812.  
  813. if (c_rkCreateData.m_dwStateFlags & ADD_CHARACTER_STATE_SPAWN)
  814. {
  815. if (IsAffect(AFFECT_SPAWN))
  816. __AttachEffect(EFFECT_SPAWN_APPEAR);
  817.  
  818. if (IsPC())
  819. {
  820. Refresh(CRaceMotionData::NAME_WAIT, true);
  821. }
  822. else
  823. {
  824. Refresh(CRaceMotionData::NAME_SPAWN, false);
  825. }
  826. }
  827. else
  828. {
  829. Refresh(CRaceMotionData::NAME_WAIT, true);
  830. }
  831.  
  832. __AttachEmpireEffect(c_rkCreateData.m_dwEmpireID);
  833.  
  834. RegisterBoundingSphere();
  835.  
  836. if (c_rkCreateData.m_dwStateFlags & ADD_CHARACTER_STATE_DEAD)
  837. m_GraphicThingInstance.DieEnd();
  838.  
  839. SetStateFlags(c_rkCreateData.m_dwStateFlags);
  840.  
  841. m_GraphicThingInstance.SetBattleHitEffect(ms_adwCRCAffectEffect[EFFECT_HIT]);
  842.  
  843. if (!IsPC())
  844. {
  845. DWORD dwBodyColor = CPythonNonPlayer::Instance().GetMonsterColor(c_rkCreateData.m_dwRace);
  846. if (0 != dwBodyColor)
  847. {
  848. SetModulateRenderMode();
  849. SetAddColor(dwBodyColor);
  850. }
  851. }
  852.  
  853. __AttachHorseSaddle();
  854.  
  855. // 길드 심볼을 위한 임시 코드, 적정 위치를 찾는 중
  856. const int c_iGuildSymbolRace = 14200;
  857. if (c_iGuildSymbolRace == GetRace())
  858. {
  859. std::string strFileName = GetGuildSymbolFileName(m_dwGuildID);
  860. if (IsFile(strFileName.c_str()))
  861. m_GraphicThingInstance.ChangeMaterial(strFileName.c_str());
  862. }
  863.  
  864. return true;
  865. }
  866.  
  867.  
  868. void CInstanceBase::__Create_SetName(const SCreateData& c_rkCreateData)
  869. {
  870. if (IsGoto())
  871. {
  872. SetNameString("", 0);
  873. return;
  874. }
  875. if (IsWarp())
  876. {
  877. __Create_SetWarpName(c_rkCreateData);
  878. return;
  879. }
  880.  
  881. SetNameString(c_rkCreateData.m_stName.c_str(), c_rkCreateData.m_stName.length());
  882. }
  883.  
  884. void CInstanceBase::__Create_SetWarpName(const SCreateData& c_rkCreateData)
  885. {
  886. const char * c_szName;
  887. if (CPythonNonPlayer::Instance().GetName(c_rkCreateData.m_dwRace, &c_szName))
  888. {
  889. std::string strName = c_szName;
  890. int iFindingPos = strName.find_first_of(" ", 0);
  891. if (iFindingPos > 0)
  892. {
  893. strName.resize(iFindingPos);
  894. }
  895. SetNameString(strName.c_str(), strName.length());
  896. }
  897. else
  898. {
  899. SetNameString(c_rkCreateData.m_stName.c_str(), c_rkCreateData.m_stName.length());
  900. }
  901. }
  902.  
  903. void CInstanceBase::SetNameString(const char* c_szName, int len)
  904. {
  905. m_stName.assign(c_szName, len);
  906. }
  907.  
  908.  
  909. bool CInstanceBase::SetRace(DWORD eRace)
  910. {
  911. m_dwRace = eRace;
  912.  
  913. if (!m_GraphicThingInstance.SetRace(eRace))
  914. return false;
  915.  
  916. if (!__FindRaceType(m_dwRace, &m_eRaceType))
  917. m_eRaceType=CActorInstance::TYPE_PC;
  918.  
  919. return true;
  920. }
  921.  
  922. BOOL CInstanceBase::__IsChangableWeapon(int iWeaponID)
  923. {
  924. // 드레스 입고 있을때는 부케외의 장비는 나오지 않게..
  925. if (IsWearingDress())
  926. {
  927. const int c_iBouquets[] =
  928. {
  929. 50201, // Bouquet for Assassin
  930. 50202, // Bouquet for Shaman
  931. 50203,
  932. 50204,
  933. 0, // #0000545: [M2CN] 웨딩 드레스와 장비 착용 문제
  934. };
  935.  
  936. for (int i = 0; c_iBouquets[i] != 0; ++i)
  937. if (iWeaponID == c_iBouquets[i])
  938. return true;
  939.  
  940. return false;
  941. }
  942. else
  943. return true;
  944. }
  945.  
  946. BOOL CInstanceBase::IsWearingDress()
  947. {
  948. const int c_iWeddingDressShape = 201;
  949. return c_iWeddingDressShape == m_eShape;
  950. }
  951.  
  952. BOOL CInstanceBase::IsHoldingPickAxe()
  953. {
  954. const int c_iPickAxeStart = 29101;
  955. const int c_iPickAxeEnd = 29110;
  956. return m_awPart[CRaceData::PART_WEAPON] >= c_iPickAxeStart && m_awPart[CRaceData::PART_WEAPON] <= c_iPickAxeEnd;
  957. }
  958.  
  959. BOOL CInstanceBase::IsNewMount()
  960. {
  961. return m_kHorse.IsNewMount();
  962. }
  963.  
  964. BOOL CInstanceBase::IsMountingHorse()
  965. {
  966. return m_kHorse.IsMounting();
  967. }
  968.  
  969. void CInstanceBase::MountHorse(UINT eRace)
  970. {
  971. m_kHorse.Destroy();
  972. m_kHorse.Create(m_GraphicThingInstance.NEW_GetCurPixelPositionRef(), eRace, ms_adwCRCAffectEffect[EFFECT_HIT]);
  973.  
  974. SetMotionMode(CRaceMotionData::MODE_HORSE);
  975. SetRotationSpeed(c_fDefaultHorseRotationSpeed);
  976.  
  977. m_GraphicThingInstance.MountHorse(m_kHorse.GetActorPtr());
  978. m_GraphicThingInstance.Stop();
  979. m_GraphicThingInstance.RefreshActorInstance();
  980. }
  981.  
  982. void CInstanceBase::DismountHorse()
  983. {
  984. m_kHorse.Destroy();
  985. }
  986.  
  987. void CInstanceBase::GetInfo(std::string* pstInfo)
  988. {
  989. char szInfo[256];
  990. sprintf(szInfo, "Inst - UC %d, RC %d Pool - %d ",
  991. ms_dwUpdateCounter,
  992. ms_dwRenderCounter,
  993. ms_kPool.GetCapacity()
  994. );
  995.  
  996. pstInfo->append(szInfo);
  997. }
  998.  
  999. void CInstanceBase::ResetPerformanceCounter()
  1000. {
  1001. ms_dwUpdateCounter=0;
  1002. ms_dwRenderCounter=0;
  1003. ms_dwDeformCounter=0;
  1004. }
  1005.  
  1006. bool CInstanceBase::NEW_IsLastPixelPosition()
  1007. {
  1008. return m_GraphicThingInstance.IsPushing();
  1009. }
  1010.  
  1011. const TPixelPosition& CInstanceBase::NEW_GetLastPixelPositionRef()
  1012. {
  1013. return m_GraphicThingInstance.NEW_GetLastPixelPositionRef();
  1014. }
  1015.  
  1016. void CInstanceBase::NEW_SetDstPixelPositionZ(FLOAT z)
  1017. {
  1018. m_GraphicThingInstance.NEW_SetDstPixelPositionZ(z);
  1019. }
  1020.  
  1021. void CInstanceBase::NEW_SetDstPixelPosition(const TPixelPosition& c_rkPPosDst)
  1022. {
  1023. m_GraphicThingInstance.NEW_SetDstPixelPosition(c_rkPPosDst);
  1024. }
  1025.  
  1026. void CInstanceBase::NEW_SetSrcPixelPosition(const TPixelPosition& c_rkPPosSrc)
  1027. {
  1028. m_GraphicThingInstance.NEW_SetSrcPixelPosition(c_rkPPosSrc);
  1029. }
  1030.  
  1031. const TPixelPosition& CInstanceBase::NEW_GetCurPixelPositionRef()
  1032. {
  1033. return m_GraphicThingInstance.NEW_GetCurPixelPositionRef();
  1034. }
  1035.  
  1036. const TPixelPosition& CInstanceBase::NEW_GetDstPixelPositionRef()
  1037. {
  1038. return m_GraphicThingInstance.NEW_GetDstPixelPositionRef();
  1039. }
  1040.  
  1041. const TPixelPosition& CInstanceBase::NEW_GetSrcPixelPositionRef()
  1042. {
  1043. return m_GraphicThingInstance.NEW_GetSrcPixelPositionRef();
  1044. }
  1045.  
  1046. /////////////////////////////////////////////////////////////////////////////////////////////////
  1047. void CInstanceBase::OnSyncing()
  1048. {
  1049. m_GraphicThingInstance.__OnSyncing();
  1050. }
  1051.  
  1052. void CInstanceBase::OnWaiting()
  1053. {
  1054. m_GraphicThingInstance.__OnWaiting();
  1055. }
  1056.  
  1057. void CInstanceBase::OnMoving()
  1058. {
  1059. m_GraphicThingInstance.__OnMoving();
  1060. }
  1061.  
  1062. void CInstanceBase::ChangeGuild(DWORD dwGuildID)
  1063. {
  1064. m_dwGuildID=dwGuildID;
  1065.  
  1066. DetachTextTail();
  1067. AttachTextTail();
  1068. RefreshTextTail();
  1069. }
  1070.  
  1071. DWORD CInstanceBase::GetPart(CRaceData::EParts part)
  1072. {
  1073. assert(part >= 0 && part < CRaceData::PART_MAX_NUM);
  1074. return m_awPart[part];
  1075. }
  1076.  
  1077. DWORD CInstanceBase::GetShape()
  1078. {
  1079. return m_eShape;
  1080. }
  1081.  
  1082. bool CInstanceBase::CanAct()
  1083. {
  1084. return m_GraphicThingInstance.CanAct();
  1085. }
  1086.  
  1087. bool CInstanceBase::CanMove()
  1088. {
  1089. return m_GraphicThingInstance.CanMove();
  1090. }
  1091.  
  1092. bool CInstanceBase::CanUseSkill()
  1093. {
  1094. if (IsPoly())
  1095. return false;
  1096.  
  1097. if (IsWearingDress())
  1098. return false;
  1099.  
  1100. if (IsHoldingPickAxe())
  1101. return false;
  1102.  
  1103. if (!m_kHorse.CanUseSkill())
  1104. return false;
  1105.  
  1106. if (!m_GraphicThingInstance.CanUseSkill())
  1107. return false;
  1108.  
  1109. return true;
  1110. }
  1111.  
  1112. bool CInstanceBase::CanAttack()
  1113. {
  1114. if (!m_kHorse.CanAttack())
  1115. return false;
  1116.  
  1117. if (IsWearingDress())
  1118. return false;
  1119.  
  1120. if (IsHoldingPickAxe())
  1121. return false;
  1122.  
  1123. return m_GraphicThingInstance.CanAttack();
  1124. }
  1125.  
  1126.  
  1127.  
  1128. bool CInstanceBase::CanFishing()
  1129. {
  1130. return m_GraphicThingInstance.CanFishing();
  1131. }
  1132.  
  1133.  
  1134. BOOL CInstanceBase::IsBowMode()
  1135. {
  1136. return m_GraphicThingInstance.IsBowMode();
  1137. }
  1138.  
  1139. BOOL CInstanceBase::IsHandMode()
  1140. {
  1141. return m_GraphicThingInstance.IsHandMode();
  1142. }
  1143.  
  1144. BOOL CInstanceBase::IsFishingMode()
  1145. {
  1146. if (CRaceMotionData::MODE_FISHING == m_GraphicThingInstance.GetMotionMode())
  1147. return true;
  1148.  
  1149. return false;
  1150. }
  1151.  
  1152. BOOL CInstanceBase::IsFishing()
  1153. {
  1154. return m_GraphicThingInstance.IsFishing();
  1155. }
  1156.  
  1157. BOOL CInstanceBase::IsDead()
  1158. {
  1159. return m_GraphicThingInstance.IsDead();
  1160. }
  1161.  
  1162. BOOL CInstanceBase::IsStun()
  1163. {
  1164. return m_GraphicThingInstance.IsStun();
  1165. }
  1166.  
  1167. BOOL CInstanceBase::IsSleep()
  1168. {
  1169. return m_GraphicThingInstance.IsSleep();
  1170. }
  1171.  
  1172.  
  1173. BOOL CInstanceBase::__IsSyncing()
  1174. {
  1175. return m_GraphicThingInstance.__IsSyncing();
  1176. }
  1177.  
  1178.  
  1179.  
  1180. void CInstanceBase::NEW_SetOwner(DWORD dwVIDOwner)
  1181. {
  1182. m_GraphicThingInstance.SetOwner(dwVIDOwner);
  1183. }
  1184.  
  1185. float CInstanceBase::GetLocalTime()
  1186. {
  1187. return m_GraphicThingInstance.GetLocalTime();
  1188. }
  1189.  
  1190.  
  1191. void CInstanceBase::PushUDPState(DWORD dwCmdTime, const TPixelPosition& c_rkPPosDst, float fDstRot, UINT eFunc, UINT uArg)
  1192. {
  1193. }
  1194.  
  1195. DWORD ELTimer_GetServerFrameMSec();
  1196.  
  1197. void CInstanceBase::PushTCPStateExpanded(DWORD dwCmdTime, const TPixelPosition& c_rkPPosDst, float fDstRot, UINT eFunc, UINT uArg, UINT uTargetVID)
  1198. {
  1199. SCommand kCmdNew;
  1200. kCmdNew.m_kPPosDst = c_rkPPosDst;
  1201. kCmdNew.m_dwChkTime = dwCmdTime+100;
  1202. kCmdNew.m_dwCmdTime = dwCmdTime;
  1203. kCmdNew.m_fDstRot = fDstRot;
  1204. kCmdNew.m_eFunc = eFunc;
  1205. kCmdNew.m_uArg = uArg;
  1206. kCmdNew.m_uTargetVID = uTargetVID;
  1207. m_kQue_kCmdNew.push_back(kCmdNew);
  1208. }
  1209.  
  1210. void CInstanceBase::PushTCPState(DWORD dwCmdTime, const TPixelPosition& c_rkPPosDst, float fDstRot, UINT eFunc, UINT uArg)
  1211. {
  1212. if (__IsMainInstance())
  1213. {
  1214. //assert(!"CInstanceBase::PushTCPState 플레이어 자신에게 이동패킷은 오면 안된다!");
  1215. TraceError("CInstanceBase::PushTCPState 플레이어 자신에게 이동패킷은 오면 안된다!");
  1216. return;
  1217. }
  1218.  
  1219. int nNetworkGap=ELTimer_GetServerFrameMSec()-dwCmdTime;
  1220.  
  1221. m_nAverageNetworkGap=(m_nAverageNetworkGap*70+nNetworkGap*30)/100;
  1222.  
  1223. /*
  1224. if (m_dwBaseCmdTime == 0)
  1225. {
  1226. m_dwBaseChkTime = ELTimer_GetFrameMSec()-nNetworkGap;
  1227. m_dwBaseCmdTime = dwCmdTime;
  1228.  
  1229. Tracenf("VID[%d] 네트웍갭 [%d]", GetVirtualID(), nNetworkGap);
  1230. }
  1231. */
  1232.  
  1233. //m_dwBaseChkTime-m_dwBaseCmdTime+ELTimer_GetServerMSec();
  1234.  
  1235. SCommand kCmdNew;
  1236. kCmdNew.m_kPPosDst = c_rkPPosDst;
  1237. kCmdNew.m_dwChkTime = dwCmdTime+m_nAverageNetworkGap;//m_dwBaseChkTime + (dwCmdTime - m_dwBaseCmdTime);// + nNetworkGap;
  1238. kCmdNew.m_dwCmdTime = dwCmdTime;
  1239. kCmdNew.m_fDstRot = fDstRot;
  1240. kCmdNew.m_eFunc = eFunc;
  1241. kCmdNew.m_uArg = uArg;
  1242. m_kQue_kCmdNew.push_back(kCmdNew);
  1243.  
  1244. //int nApplyGap=kCmdNew.m_dwChkTime-ELTimer_GetServerFrameMSec();
  1245.  
  1246. //if (nApplyGap<-500 || nApplyGap>500)
  1247. // Tracenf("VID[%d] NAME[%s] 네트웍갭 [cur:%d ave:%d] 작동시간 (%d)", GetVirtualID(), GetNameString(), nNetworkGap, m_nAverageNetworkGap, nApplyGap);
  1248. }
  1249.  
  1250. /*
  1251. CInstanceBase::TStateQueue::iterator CInstanceBase::FindSameState(TStateQueue& rkQuekStt, DWORD dwCmdTime, UINT eFunc, UINT uArg)
  1252. {
  1253. TStateQueue::iterator i=rkQuekStt.begin();
  1254. while (rkQuekStt.end()!=i)
  1255. {
  1256. SState& rkSttEach=*i;
  1257. if (rkSttEach.m_dwCmdTime==dwCmdTime)
  1258. if (rkSttEach.m_eFunc==eFunc)
  1259. if (rkSttEach.m_uArg==uArg)
  1260. break;
  1261. ++i;
  1262. }
  1263.  
  1264. return i;
  1265. }
  1266. */
  1267.  
  1268. BOOL CInstanceBase::__CanProcessNetworkStatePacket()
  1269. {
  1270. if (m_GraphicThingInstance.IsDead())
  1271. return FALSE;
  1272. if (m_GraphicThingInstance.IsKnockDown())
  1273. return FALSE;
  1274. if (m_GraphicThingInstance.IsUsingSkill())
  1275. if (!m_GraphicThingInstance.CanCancelSkill())
  1276. return FALSE;
  1277.  
  1278. return TRUE;
  1279. }
  1280.  
  1281. BOOL CInstanceBase::__IsEnableTCPProcess(UINT eCurFunc)
  1282. {
  1283. if (m_GraphicThingInstance.IsActEmotion())
  1284. {
  1285. return FALSE;
  1286. }
  1287.  
  1288. if (!m_bEnableTCPState)
  1289. {
  1290. if (FUNC_EMOTION != eCurFunc)
  1291. {
  1292. return FALSE;
  1293. }
  1294. }
  1295.  
  1296. return TRUE;
  1297. }
  1298.  
  1299. void CInstanceBase::StateProcess()
  1300. {
  1301. while (1)
  1302. {
  1303. if (m_kQue_kCmdNew.empty())
  1304. return;
  1305.  
  1306. DWORD dwDstChkTime = m_kQue_kCmdNew.front().m_dwChkTime;
  1307. DWORD dwCurChkTime = ELTimer_GetServerFrameMSec();
  1308.  
  1309. if (dwCurChkTime < dwDstChkTime)
  1310. return;
  1311.  
  1312. SCommand kCmdTop = m_kQue_kCmdNew.front();
  1313. m_kQue_kCmdNew.pop_front();
  1314.  
  1315. TPixelPosition kPPosDst = kCmdTop.m_kPPosDst;
  1316. //DWORD dwCmdTime = kCmdTop.m_dwCmdTime;
  1317. FLOAT fRotDst = kCmdTop.m_fDstRot;
  1318. UINT eFunc = kCmdTop.m_eFunc;
  1319. UINT uArg = kCmdTop.m_uArg;
  1320. UINT uVID = GetVirtualID();
  1321. UINT uTargetVID = kCmdTop.m_uTargetVID;
  1322.  
  1323. TPixelPosition kPPosCur;
  1324. NEW_GetPixelPosition(&kPPosCur);
  1325.  
  1326. /*
  1327. if (IsPC())
  1328. Tracenf("%d cmd: vid=%d[%s] func=%d arg=%d curPos=(%f, %f) dstPos=(%f, %f) rot=%f (time %d)",
  1329. ELTimer_GetMSec(),
  1330. uVID, m_stName.c_str(), eFunc, uArg,
  1331. kPPosCur.x, kPPosCur.y,
  1332. kPPosDst.x, kPPosDst.y, fRotDst, dwCmdTime-m_dwBaseCmdTime);
  1333. */
  1334.  
  1335. TPixelPosition kPPosDir = kPPosDst - kPPosCur;
  1336. float fDirLen = (float)sqrt(kPPosDir.x * kPPosDir.x + kPPosDir.y * kPPosDir.y);
  1337.  
  1338. //Tracenf("거리 %f", fDirLen);
  1339.  
  1340. if (!__CanProcessNetworkStatePacket())
  1341. {
  1342. Lognf(0, "vid=%d 움직일 수 없는 상태라 스킵 IsDead=%d, IsKnockDown=%d", uVID, m_GraphicThingInstance.IsDead(), m_GraphicThingInstance.IsKnockDown());
  1343. return;
  1344. }
  1345.  
  1346. if (!__IsEnableTCPProcess(eFunc))
  1347. {
  1348. return;
  1349. }
  1350.  
  1351. switch (eFunc)
  1352. {
  1353. case FUNC_WAIT:
  1354. {
  1355. //Tracenf("%s (%f, %f) -> (%f, %f) 남은거리 %f", GetNameString(), kPPosCur.x, kPPosCur.y, kPPosDst.x, kPPosDst.y, fDirLen);
  1356. if (fDirLen > 1.0f)
  1357. {
  1358. //NEW_GetSrcPixelPositionRef() = kPPosCur;
  1359. //NEW_GetDstPixelPositionRef() = kPPosDst;
  1360. NEW_SetSrcPixelPosition(kPPosCur);
  1361. NEW_SetDstPixelPosition(kPPosDst);
  1362.  
  1363. __EnableSkipCollision();
  1364.  
  1365. m_fDstRot = fRotDst;
  1366. m_isGoing = TRUE;
  1367.  
  1368. m_kMovAfterFunc.eFunc = FUNC_WAIT;
  1369.  
  1370. if (!IsWalking())
  1371. StartWalking();
  1372.  
  1373. //Tracen("목표정지");
  1374. }
  1375. else
  1376. {
  1377. //Tracen("현재 정지");
  1378.  
  1379. m_isGoing = FALSE;
  1380.  
  1381. if (!IsWaiting())
  1382. EndWalking();
  1383.  
  1384. SCRIPT_SetPixelPosition(kPPosDst.x, kPPosDst.y);
  1385. SetAdvancingRotation(fRotDst);
  1386. SetRotation(fRotDst);
  1387. }
  1388. break;
  1389. }
  1390.  
  1391. case FUNC_MOVE:
  1392. {
  1393. //NEW_GetSrcPixelPositionRef() = kPPosCur;
  1394. //NEW_GetDstPixelPositionRef() = kPPosDst;
  1395. NEW_SetSrcPixelPosition(kPPosCur);
  1396. NEW_SetDstPixelPosition(kPPosDst);
  1397. m_fDstRot = fRotDst;
  1398. m_isGoing = TRUE;
  1399. __EnableSkipCollision();
  1400. //m_isSyncMov = TRUE;
  1401.  
  1402. m_kMovAfterFunc.eFunc = FUNC_MOVE;
  1403.  
  1404. if (!IsWalking())
  1405. {
  1406. //Tracen("걷고 있지 않아 걷기 시작");
  1407. StartWalking();
  1408. }
  1409. else
  1410. {
  1411. //Tracen("이미 걷는중 ");
  1412. }
  1413. break;
  1414. }
  1415.  
  1416. case FUNC_COMBO:
  1417. {
  1418. if (fDirLen >= 50.0f)
  1419. {
  1420. NEW_SetSrcPixelPosition(kPPosCur);
  1421. NEW_SetDstPixelPosition(kPPosDst);
  1422. m_fDstRot=fRotDst;
  1423. m_isGoing = TRUE;
  1424. __EnableSkipCollision();
  1425.  
  1426. m_kMovAfterFunc.eFunc = FUNC_COMBO;
  1427. m_kMovAfterFunc.uArg = uArg;
  1428.  
  1429. if (!IsWalking())
  1430. StartWalking();
  1431. }
  1432. else
  1433. {
  1434. //Tracen("대기 공격 정지");
  1435.  
  1436. m_isGoing = FALSE;
  1437.  
  1438. if (IsWalking())
  1439. EndWalking();
  1440.  
  1441. SCRIPT_SetPixelPosition(kPPosDst.x, kPPosDst.y);
  1442. RunComboAttack(fRotDst, uArg);
  1443. }
  1444. break;
  1445. }
  1446.  
  1447. case FUNC_ATTACK:
  1448. {
  1449. if (fDirLen>=50.0f)
  1450. {
  1451. //NEW_GetSrcPixelPositionRef() = kPPosCur;
  1452. //NEW_GetDstPixelPositionRef() = kPPosDst;
  1453. NEW_SetSrcPixelPosition(kPPosCur);
  1454. NEW_SetDstPixelPosition(kPPosDst);
  1455. m_fDstRot = fRotDst;
  1456. m_isGoing = TRUE;
  1457. __EnableSkipCollision();
  1458. //m_isSyncMov = TRUE;
  1459.  
  1460. m_kMovAfterFunc.eFunc = FUNC_ATTACK;
  1461.  
  1462. if (!IsWalking())
  1463. StartWalking();
  1464.  
  1465. //Tracen("너무 멀어서 이동 후 공격");
  1466. }
  1467. else
  1468. {
  1469. //Tracen("노말 공격 정지");
  1470.  
  1471. m_isGoing = FALSE;
  1472.  
  1473. if (IsWalking())
  1474. EndWalking();
  1475.  
  1476. SCRIPT_SetPixelPosition(kPPosDst.x, kPPosDst.y);
  1477. BlendRotation(fRotDst);
  1478.  
  1479. RunNormalAttack(fRotDst);
  1480.  
  1481. //Tracen("가깝기 때문에 워프 공격");
  1482. }
  1483. break;
  1484. }
  1485.  
  1486. case FUNC_MOB_SKILL:
  1487. {
  1488. if (fDirLen >= 50.0f)
  1489. {
  1490. NEW_SetSrcPixelPosition(kPPosCur);
  1491. NEW_SetDstPixelPosition(kPPosDst);
  1492. m_fDstRot = fRotDst;
  1493. m_isGoing = TRUE;
  1494. __EnableSkipCollision();
  1495.  
  1496. m_kMovAfterFunc.eFunc = FUNC_MOB_SKILL;
  1497. m_kMovAfterFunc.uArg = uArg;
  1498.  
  1499. if (!IsWalking())
  1500. StartWalking();
  1501. }
  1502. else
  1503. {
  1504. m_isGoing = FALSE;
  1505.  
  1506. if (IsWalking())
  1507. EndWalking();
  1508.  
  1509. SCRIPT_SetPixelPosition(kPPosDst.x, kPPosDst.y);
  1510. BlendRotation(fRotDst);
  1511.  
  1512. m_GraphicThingInstance.InterceptOnceMotion(CRaceMotionData::NAME_SPECIAL_1 + uArg);
  1513. }
  1514. break;
  1515. }
  1516.  
  1517. case FUNC_EMOTION:
  1518. {
  1519. if (fDirLen>100.0f)
  1520. {
  1521. NEW_SetSrcPixelPosition(kPPosCur);
  1522. NEW_SetDstPixelPosition(kPPosDst);
  1523. m_fDstRot = fRotDst;
  1524. m_isGoing = TRUE;
  1525.  
  1526. if (__IsMainInstance())
  1527. __EnableSkipCollision();
  1528.  
  1529. m_kMovAfterFunc.eFunc = FUNC_EMOTION;
  1530. m_kMovAfterFunc.uArg = uArg;
  1531. m_kMovAfterFunc.uArgExpanded = uTargetVID;
  1532. m_kMovAfterFunc.kPosDst = kPPosDst;
  1533.  
  1534. if (!IsWalking())
  1535. StartWalking();
  1536. }
  1537. else
  1538. {
  1539. __ProcessFunctionEmotion(uArg, uTargetVID, kPPosDst);
  1540. }
  1541. break;
  1542. }
  1543.  
  1544. default:
  1545. {
  1546. if (eFunc & FUNC_SKILL)
  1547. {
  1548. if (fDirLen >= 50.0f)
  1549. {
  1550. //NEW_GetSrcPixelPositionRef() = kPPosCur;
  1551. //NEW_GetDstPixelPositionRef() = kPPosDst;
  1552. NEW_SetSrcPixelPosition(kPPosCur);
  1553. NEW_SetDstPixelPosition(kPPosDst);
  1554. m_fDstRot = fRotDst;
  1555. m_isGoing = TRUE;
  1556. //m_isSyncMov = TRUE;
  1557. __EnableSkipCollision();
  1558.  
  1559. m_kMovAfterFunc.eFunc = eFunc;
  1560. m_kMovAfterFunc.uArg = uArg;
  1561.  
  1562. if (!IsWalking())
  1563. StartWalking();
  1564.  
  1565. //Tracen("너무 멀어서 이동 후 공격");
  1566. }
  1567. else
  1568. {
  1569. //Tracen("스킬 정지");
  1570.  
  1571. m_isGoing = FALSE;
  1572.  
  1573. if (IsWalking())
  1574. EndWalking();
  1575.  
  1576. SCRIPT_SetPixelPosition(kPPosDst.x, kPPosDst.y);
  1577. SetAdvancingRotation(fRotDst);
  1578. SetRotation(fRotDst);
  1579.  
  1580. NEW_UseSkill(0, eFunc & 0x7f, uArg&0x0f, (uArg>>4) ? true : false);
  1581. //Tracen("가깝기 때문에 워프 공격");
  1582. }
  1583. }
  1584. break;
  1585. }
  1586. }
  1587. }
  1588. }
  1589.  
  1590.  
  1591. void CInstanceBase::MovementProcess()
  1592. {
  1593. TPixelPosition kPPosCur;
  1594. NEW_GetPixelPosition(&kPPosCur);
  1595.  
  1596. // 렌더링 좌표계이므로 y를 -화해서 더한다.
  1597.  
  1598. TPixelPosition kPPosNext;
  1599. {
  1600. const D3DXVECTOR3 & c_rkV3Mov = m_GraphicThingInstance.GetMovementVectorRef();
  1601.  
  1602. kPPosNext.x = kPPosCur.x + (+c_rkV3Mov.x);
  1603. kPPosNext.y = kPPosCur.y + (-c_rkV3Mov.y);
  1604. kPPosNext.z = kPPosCur.z + (+c_rkV3Mov.z);
  1605. }
  1606.  
  1607. TPixelPosition kPPosDeltaSC = kPPosCur - NEW_GetSrcPixelPositionRef();
  1608. TPixelPosition kPPosDeltaSN = kPPosNext - NEW_GetSrcPixelPositionRef();
  1609. TPixelPosition kPPosDeltaSD = NEW_GetDstPixelPositionRef() - NEW_GetSrcPixelPositionRef();
  1610.  
  1611. float fCurLen = sqrtf(kPPosDeltaSC.x * kPPosDeltaSC.x + kPPosDeltaSC.y * kPPosDeltaSC.y);
  1612. float fNextLen = sqrtf(kPPosDeltaSN.x * kPPosDeltaSN.x + kPPosDeltaSN.y * kPPosDeltaSN.y);
  1613. float fTotalLen = sqrtf(kPPosDeltaSD.x * kPPosDeltaSD.x + kPPosDeltaSD.y * kPPosDeltaSD.y);
  1614. float fRestLen = fTotalLen - fCurLen;
  1615.  
  1616. if (__IsMainInstance())
  1617. {
  1618. if (m_isGoing && IsWalking())
  1619. {
  1620. float fDstRot = NEW_GetAdvancingRotationFromPixelPosition(NEW_GetSrcPixelPositionRef(), NEW_GetDstPixelPositionRef());
  1621.  
  1622. SetAdvancingRotation(fDstRot);
  1623.  
  1624. if (fRestLen<=0.0)
  1625. {
  1626. if (IsWalking())
  1627. EndWalking();
  1628.  
  1629. //Tracen("목표 도달 정지");
  1630.  
  1631. m_isGoing = FALSE;
  1632.  
  1633. BlockMovement();
  1634.  
  1635. if (FUNC_EMOTION == m_kMovAfterFunc.eFunc)
  1636. {
  1637. DWORD dwMotionNumber = m_kMovAfterFunc.uArg;
  1638. DWORD dwTargetVID = m_kMovAfterFunc.uArgExpanded;
  1639. __ProcessFunctionEmotion(dwMotionNumber, dwTargetVID, m_kMovAfterFunc.kPosDst);
  1640. m_kMovAfterFunc.eFunc = FUNC_WAIT;
  1641. return;
  1642. }
  1643. }
  1644. }
  1645. }
  1646. else
  1647. {
  1648. if (m_isGoing && IsWalking())
  1649. {
  1650. float fDstRot = NEW_GetAdvancingRotationFromPixelPosition(NEW_GetSrcPixelPositionRef(), NEW_GetDstPixelPositionRef());
  1651.  
  1652. SetAdvancingRotation(fDstRot);
  1653.  
  1654. // 만약 렌턴시가 늦어 너무 많이 이동했다면..
  1655. if (fRestLen < -100.0f)
  1656. {
  1657. NEW_SetSrcPixelPosition(kPPosCur);
  1658.  
  1659. float fDstRot = NEW_GetAdvancingRotationFromPixelPosition(kPPosCur, NEW_GetDstPixelPositionRef());
  1660. SetAdvancingRotation(fDstRot);
  1661. //Tracenf("VID %d 오버 방향설정 (%f, %f) %f rest %f", GetVirtualID(), kPPosCur.x, kPPosCur.y, fDstRot, fRestLen);
  1662.  
  1663. // 이동중이라면 다음번에 멈추게 한다
  1664. if (FUNC_MOVE == m_kMovAfterFunc.eFunc)
  1665. {
  1666. m_kMovAfterFunc.eFunc = FUNC_WAIT;
  1667. }
  1668. }
  1669. // 도착했다면...
  1670. else if (fCurLen <= fTotalLen && fTotalLen <= fNextLen)
  1671. {
  1672. if (m_GraphicThingInstance.IsDead() || m_GraphicThingInstance.IsKnockDown())
  1673. {
  1674. __DisableSkipCollision();
  1675.  
  1676. //Tracen("사망 상태라 동작 스킵");
  1677.  
  1678. m_isGoing = FALSE;
  1679.  
  1680. //Tracen("행동 불능 상태라 이후 동작 스킵");
  1681. }
  1682. else
  1683. {
  1684. switch (m_kMovAfterFunc.eFunc)
  1685. {
  1686. case FUNC_ATTACK:
  1687. {
  1688. if (IsWalking())
  1689. EndWalking();
  1690.  
  1691. __DisableSkipCollision();
  1692. m_isGoing = FALSE;
  1693.  
  1694. BlockMovement();
  1695. SCRIPT_SetPixelPosition(NEW_GetDstPixelPositionRef().x, NEW_GetDstPixelPositionRef().y);
  1696. SetAdvancingRotation(m_fDstRot);
  1697. SetRotation(m_fDstRot);
  1698.  
  1699. RunNormalAttack(m_fDstRot);
  1700. break;
  1701. }
  1702.  
  1703. case FUNC_COMBO:
  1704. {
  1705. if (IsWalking())
  1706. EndWalking();
  1707.  
  1708. __DisableSkipCollision();
  1709. m_isGoing = FALSE;
  1710.  
  1711. BlockMovement();
  1712. SCRIPT_SetPixelPosition(NEW_GetDstPixelPositionRef().x, NEW_GetDstPixelPositionRef().y);
  1713. RunComboAttack(m_fDstRot, m_kMovAfterFunc.uArg);
  1714. break;
  1715. }
  1716.  
  1717. case FUNC_EMOTION:
  1718. {
  1719. m_isGoing = FALSE;
  1720. m_kMovAfterFunc.eFunc = FUNC_WAIT;
  1721. __DisableSkipCollision();
  1722. BlockMovement();
  1723.  
  1724. DWORD dwMotionNumber = m_kMovAfterFunc.uArg;
  1725. DWORD dwTargetVID = m_kMovAfterFunc.uArgExpanded;
  1726. __ProcessFunctionEmotion(dwMotionNumber, dwTargetVID, m_kMovAfterFunc.kPosDst);
  1727. break;
  1728. }
  1729.  
  1730. case FUNC_MOVE:
  1731. {
  1732. break;
  1733. }
  1734.  
  1735. case FUNC_MOB_SKILL:
  1736. {
  1737. if (IsWalking())
  1738. EndWalking();
  1739.  
  1740. __DisableSkipCollision();
  1741. m_isGoing = FALSE;
  1742.  
  1743. BlockMovement();
  1744. SCRIPT_SetPixelPosition(NEW_GetDstPixelPositionRef().x, NEW_GetDstPixelPositionRef().y);
  1745. SetAdvancingRotation(m_fDstRot);
  1746. SetRotation(m_fDstRot);
  1747.  
  1748. m_GraphicThingInstance.InterceptOnceMotion(CRaceMotionData::NAME_SPECIAL_1 + m_kMovAfterFunc.uArg);
  1749. break;
  1750. }
  1751.  
  1752. default:
  1753. {
  1754. if (m_kMovAfterFunc.eFunc & FUNC_SKILL)
  1755. {
  1756. SetAdvancingRotation(m_fDstRot);
  1757. BlendRotation(m_fDstRot);
  1758. NEW_UseSkill(0, m_kMovAfterFunc.eFunc & 0x7f, m_kMovAfterFunc.uArg&0x0f, (m_kMovAfterFunc.uArg>>4) ? true : false);
  1759. }
  1760. else
  1761. {
  1762. //Tracenf("VID %d 스킬 공격 (%f, %f) rot %f", GetVirtualID(), NEW_GetDstPixelPositionRef().x, NEW_GetDstPixelPositionRef().y, m_fDstRot);
  1763.  
  1764. __DisableSkipCollision();
  1765. m_isGoing = FALSE;
  1766.  
  1767. BlockMovement();
  1768. SCRIPT_SetPixelPosition(NEW_GetDstPixelPositionRef().x, NEW_GetDstPixelPositionRef().y);
  1769. SetAdvancingRotation(m_fDstRot);
  1770. BlendRotation(m_fDstRot);
  1771. if (!IsWaiting())
  1772. {
  1773. EndWalking();
  1774. }
  1775.  
  1776. //Tracenf("VID %d 정지 (%f, %f) rot %f IsWalking %d", GetVirtualID(), NEW_GetDstPixelPositionRef().x, NEW_GetDstPixelPositionRef().y, m_fDstRot, IsWalking());
  1777. }
  1778. break;
  1779. }
  1780. }
  1781.  
  1782. }
  1783. }
  1784.  
  1785. }
  1786. }
  1787.  
  1788. if (IsWalking() || m_GraphicThingInstance.IsUsingMovingSkill())
  1789. {
  1790. float fRotation = m_GraphicThingInstance.GetRotation();
  1791. float fAdvancingRotation = m_GraphicThingInstance.GetAdvancingRotation();
  1792. int iDirection = GetRotatingDirection(fRotation, fAdvancingRotation);
  1793.  
  1794. if (DEGREE_DIRECTION_SAME != m_iRotatingDirection)
  1795. {
  1796. if (DEGREE_DIRECTION_LEFT == iDirection)
  1797. {
  1798. fRotation = fmodf(fRotation + m_fRotSpd*m_GraphicThingInstance.GetSecondElapsed(), 360.0f);
  1799. }
  1800. else if (DEGREE_DIRECTION_RIGHT == iDirection)
  1801. {
  1802. fRotation = fmodf(fRotation - m_fRotSpd*m_GraphicThingInstance.GetSecondElapsed() + 360.0f, 360.0f);
  1803. }
  1804.  
  1805. if (m_iRotatingDirection != GetRotatingDirection(fRotation, fAdvancingRotation))
  1806. {
  1807. m_iRotatingDirection = DEGREE_DIRECTION_SAME;
  1808. fRotation = fAdvancingRotation;
  1809. }
  1810.  
  1811. m_GraphicThingInstance.SetRotation(fRotation);
  1812. }
  1813.  
  1814. if (__IsInDustRange())
  1815. {
  1816. float fDustDistance = NEW_GetDistanceFromDestPixelPosition(m_kPPosDust);
  1817. if (IsMountingHorse())
  1818. {
  1819. if (fDustDistance > ms_fHorseDustGap)
  1820. {
  1821. NEW_GetPixelPosition(&m_kPPosDust);
  1822. __AttachEffect(EFFECT_HORSE_DUST);
  1823. }
  1824. }
  1825. else
  1826. {
  1827. if (fDustDistance > ms_fDustGap)
  1828. {
  1829. NEW_GetPixelPosition(&m_kPPosDust);
  1830. __AttachEffect(EFFECT_DUST);
  1831. }
  1832. }
  1833. }
  1834. }
  1835. }
  1836.  
  1837. void CInstanceBase::__ProcessFunctionEmotion(DWORD dwMotionNumber, DWORD dwTargetVID, const TPixelPosition & c_rkPosDst)
  1838. {
  1839. if (IsWalking())
  1840. EndWalkingWithoutBlending();
  1841.  
  1842. __EnableChangingTCPState();
  1843. SCRIPT_SetPixelPosition(c_rkPosDst.x, c_rkPosDst.y);
  1844.  
  1845. CInstanceBase * pTargetInstance = CPythonCharacterManager::Instance().GetInstancePtr(dwTargetVID);
  1846. if (pTargetInstance)
  1847. {
  1848. pTargetInstance->__EnableChangingTCPState();
  1849.  
  1850. if (pTargetInstance->IsWalking())
  1851. pTargetInstance->EndWalkingWithoutBlending();
  1852.  
  1853. WORD wMotionNumber1 = HIWORD(dwMotionNumber);
  1854. WORD wMotionNumber2 = LOWORD(dwMotionNumber);
  1855.  
  1856. int src_job = RaceToJob(GetRace());
  1857. int dst_job = RaceToJob(pTargetInstance->GetRace());
  1858.  
  1859. NEW_LookAtDestInstance(*pTargetInstance);
  1860. m_GraphicThingInstance.InterceptOnceMotion(wMotionNumber1 + dst_job);
  1861. m_GraphicThingInstance.SetRotation(m_GraphicThingInstance.GetTargetRotation());
  1862. m_GraphicThingInstance.SetAdvancingRotation(m_GraphicThingInstance.GetTargetRotation());
  1863.  
  1864. pTargetInstance->NEW_LookAtDestInstance(*this);
  1865. pTargetInstance->m_GraphicThingInstance.InterceptOnceMotion(wMotionNumber2 + src_job);
  1866. pTargetInstance->m_GraphicThingInstance.SetRotation(pTargetInstance->m_GraphicThingInstance.GetTargetRotation());
  1867. pTargetInstance->m_GraphicThingInstance.SetAdvancingRotation(pTargetInstance->m_GraphicThingInstance.GetTargetRotation());
  1868.  
  1869. if (pTargetInstance->__IsMainInstance())
  1870. {
  1871. IAbstractPlayer & rPlayer=IAbstractPlayer::GetSingleton();
  1872. rPlayer.EndEmotionProcess();
  1873. }
  1874. }
  1875.  
  1876. if (__IsMainInstance())
  1877. {
  1878. IAbstractPlayer & rPlayer=IAbstractPlayer::GetSingleton();
  1879. rPlayer.EndEmotionProcess();
  1880. }
  1881. }
  1882.  
  1883. ///////////////////////////////////////////////////////////////////////////////////////////////////
  1884. // Update & Deform & Render
  1885.  
  1886. int g_iAccumulationTime = 0;
  1887.  
  1888. void CInstanceBase::Update()
  1889. {
  1890. ++ms_dwUpdateCounter;
  1891.  
  1892. StateProcess();
  1893. m_GraphicThingInstance.PhysicsProcess();
  1894. m_GraphicThingInstance.RotationProcess();
  1895. m_GraphicThingInstance.ComboProcess();
  1896. m_GraphicThingInstance.AccumulationMovement();
  1897.  
  1898. if (m_GraphicThingInstance.IsMovement())
  1899. {
  1900. TPixelPosition kPPosCur;
  1901. NEW_GetPixelPosition(&kPPosCur);
  1902.  
  1903. DWORD dwCurTime=ELTimer_GetFrameMSec();
  1904. //if (m_dwNextUpdateHeightTime<dwCurTime)
  1905. {
  1906. m_dwNextUpdateHeightTime=dwCurTime;
  1907. kPPosCur.z = __GetBackgroundHeight(kPPosCur.x, kPPosCur.y);
  1908. NEW_SetPixelPosition(kPPosCur);
  1909. }
  1910.  
  1911. // SetMaterialColor
  1912. {
  1913. DWORD dwMtrlColor=__GetShadowMapColor(kPPosCur.x, kPPosCur.y);
  1914. m_GraphicThingInstance.SetMaterialColor(dwMtrlColor);
  1915. }
  1916. }
  1917.  
  1918. m_GraphicThingInstance.UpdateAdvancingPointInstance();
  1919.  
  1920. AttackProcess();
  1921. MovementProcess();
  1922.  
  1923. m_GraphicThingInstance.MotionProcess(IsPC());
  1924. if (IsMountingHorse())
  1925. {
  1926. m_kHorse.m_pkActor->HORSE_MotionProcess(FALSE);
  1927. }
  1928.  
  1929. __ComboProcess();
  1930.  
  1931. ProcessDamage();
  1932.  
  1933. }
  1934.  
  1935. void CInstanceBase::Transform()
  1936. {
  1937. if (__IsSyncing())
  1938. {
  1939. //OnSyncing();
  1940. }
  1941. else
  1942. {
  1943. if (IsWalking() || m_GraphicThingInstance.IsUsingMovingSkill())
  1944. {
  1945. const D3DXVECTOR3& c_rv3Movment=m_GraphicThingInstance.GetMovementVectorRef();
  1946.  
  1947. float len=(c_rv3Movment.x*c_rv3Movment.x)+(c_rv3Movment.y*c_rv3Movment.y);
  1948. if (len>1.0f)
  1949. OnMoving();
  1950. else
  1951. OnWaiting();
  1952. }
  1953. }
  1954.  
  1955. m_GraphicThingInstance.INSTANCEBASE_Transform();
  1956. }
  1957.  
  1958.  
  1959. void CInstanceBase::Deform()
  1960. {
  1961. // 2004.07.17.levites.isShow를 ViewFrustumCheck로 변경
  1962. if (!__CanRender())
  1963. return;
  1964.  
  1965. ++ms_dwDeformCounter;
  1966.  
  1967. m_GraphicThingInstance.INSTANCEBASE_Deform();
  1968.  
  1969. m_kHorse.Deform();
  1970. }
  1971.  
  1972. void CInstanceBase::RenderTrace()
  1973. {
  1974. if (!__CanRender())
  1975. return;
  1976.  
  1977. m_GraphicThingInstance.RenderTrace();
  1978. }
  1979.  
  1980.  
  1981.  
  1982.  
  1983. void CInstanceBase::Render()
  1984. {
  1985. // 2004.07.17.levites.isShow를 ViewFrustumCheck로 변경
  1986. if (!__CanRender())
  1987. return;
  1988.  
  1989. ++ms_dwRenderCounter;
  1990.  
  1991. m_kHorse.Render();
  1992. m_GraphicThingInstance.Render();
  1993.  
  1994. if (CActorInstance::IsDirLine())
  1995. {
  1996. if (NEW_GetDstPixelPositionRef().x != 0.0f)
  1997. {
  1998. static CScreen s_kScreen;
  1999.  
  2000. STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
  2001. STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
  2002. STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
  2003. STATEMANAGER.SaveRenderState(D3DRS_ZENABLE, FALSE);
  2004. STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
  2005. STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);
  2006.  
  2007. TPixelPosition px;
  2008. m_GraphicThingInstance.GetPixelPosition(&px);
  2009. D3DXVECTOR3 kD3DVt3Cur(px.x, px.y, px.z);
  2010. //D3DXVECTOR3 kD3DVt3Cur(NEW_GetSrcPixelPositionRef().x, -NEW_GetSrcPixelPositionRef().y, NEW_GetSrcPixelPositionRef().z);
  2011. D3DXVECTOR3 kD3DVt3Dest(NEW_GetDstPixelPositionRef().x, -NEW_GetDstPixelPositionRef().y, NEW_GetDstPixelPositionRef().z);
  2012.  
  2013. //printf("%s %f\n", GetNameString(), kD3DVt3Cur.y - kD3DVt3Dest.y);
  2014. //float fdx = NEW_GetDstPixelPositionRef().x - NEW_GetSrcPixelPositionRef().x;
  2015. //float fdy = NEW_GetDstPixelPositionRef().y - NEW_GetSrcPixelPositionRef().y;
  2016.  
  2017. s_kScreen.SetDiffuseColor(0.0f, 0.0f, 1.0f);
  2018. s_kScreen.RenderLine3d(kD3DVt3Cur.x, kD3DVt3Cur.y, px.z, kD3DVt3Dest.x, kD3DVt3Dest.y, px.z);
  2019. STATEMANAGER.RestoreRenderState(D3DRS_ZENABLE);
  2020. STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, TRUE);
  2021. STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);
  2022. }
  2023. }
  2024. }
  2025.  
  2026. void CInstanceBase::RenderToShadowMap()
  2027. {
  2028. if (IsDoor())
  2029. return;
  2030.  
  2031. if (IsBuilding())
  2032. return;
  2033.  
  2034. if (!__CanRender())
  2035. return;
  2036.  
  2037. if (!__IsExistMainInstance())
  2038. return;
  2039.  
  2040. CInstanceBase* pkInstMain=__GetMainInstancePtr();
  2041.  
  2042. const float SHADOW_APPLY_DISTANCE = 2500.0f;
  2043.  
  2044. float fDistance=NEW_GetDistanceFromDestInstance(*pkInstMain);
  2045. if (fDistance>=SHADOW_APPLY_DISTANCE)
  2046. return;
  2047.  
  2048. m_GraphicThingInstance.RenderToShadowMap();
  2049. }
  2050.  
  2051. void CInstanceBase::RenderCollision()
  2052. {
  2053. m_GraphicThingInstance.RenderCollisionData();
  2054. }
  2055.  
  2056. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2057. // Setting & Getting Data
  2058.  
  2059. void CInstanceBase::SetVirtualID(DWORD dwVirtualID)
  2060. {
  2061. m_GraphicThingInstance.SetVirtualID(dwVirtualID);
  2062. }
  2063.  
  2064. void CInstanceBase::SetVirtualNumber(DWORD dwVirtualNumber)
  2065. {
  2066. m_dwVirtualNumber = dwVirtualNumber;
  2067. }
  2068.  
  2069. void CInstanceBase::SetInstanceType(int iInstanceType)
  2070. {
  2071. m_GraphicThingInstance.SetActorType(iInstanceType);
  2072. }
  2073.  
  2074. void CInstanceBase::SetAlignment(short sAlignment)
  2075. {
  2076. m_sAlignment = sAlignment;
  2077. RefreshTextTailTitle();
  2078. }
  2079.  
  2080. #ifdef NEW_PET_SYSTEM
  2081. void CInstanceBase::SetLevelText(int sLevel)
  2082. {
  2083. m_dwLevel = sLevel;
  2084. UpdateTextTailLevel(sLevel);
  2085. }
  2086. #endif
  2087.  
  2088. void CInstanceBase::SetPKMode(BYTE byPKMode)
  2089. {
  2090. if (m_byPKMode == byPKMode)
  2091. return;
  2092.  
  2093. m_byPKMode = byPKMode;
  2094.  
  2095. if (__IsMainInstance())
  2096. {
  2097. IAbstractPlayer& rPlayer=IAbstractPlayer::GetSingleton();
  2098. rPlayer.NotifyChangePKMode();
  2099. }
  2100. }
  2101.  
  2102. void CInstanceBase::SetKiller(bool bFlag)
  2103. {
  2104. if (m_isKiller == bFlag)
  2105. return;
  2106.  
  2107. m_isKiller = bFlag;
  2108. RefreshTextTail();
  2109. }
  2110.  
  2111. void CInstanceBase::SetPartyMemberFlag(bool bFlag)
  2112. {
  2113. m_isPartyMember = bFlag;
  2114. }
  2115.  
  2116. void CInstanceBase::SetStateFlags(DWORD dwStateFlags)
  2117. {
  2118. if (dwStateFlags & ADD_CHARACTER_STATE_KILLER)
  2119. SetKiller(TRUE);
  2120. else
  2121. SetKiller(FALSE);
  2122.  
  2123. if (dwStateFlags & ADD_CHARACTER_STATE_PARTY)
  2124. SetPartyMemberFlag(TRUE);
  2125. else
  2126. SetPartyMemberFlag(FALSE);
  2127. }
  2128.  
  2129. void CInstanceBase::SetComboType(UINT uComboType)
  2130. {
  2131. m_GraphicThingInstance.SetComboType(uComboType);
  2132. }
  2133.  
  2134. const char * CInstanceBase::GetNameString()
  2135. {
  2136. return m_stName.c_str();
  2137. }
  2138.  
  2139. DWORD CInstanceBase::GetRace()
  2140. {
  2141. return m_dwRace;
  2142. }
  2143.  
  2144.  
  2145. bool CInstanceBase::IsConflictAlignmentInstance(CInstanceBase& rkInstVictim)
  2146. {
  2147. if (PK_MODE_PROTECT == rkInstVictim.GetPKMode())
  2148. return false;
  2149.  
  2150. switch (GetAlignmentType())
  2151. {
  2152. case ALIGNMENT_TYPE_NORMAL:
  2153. case ALIGNMENT_TYPE_WHITE:
  2154. if (ALIGNMENT_TYPE_DARK == rkInstVictim.GetAlignmentType())
  2155. return true;
  2156. break;
  2157. case ALIGNMENT_TYPE_DARK:
  2158. if (GetAlignmentType() != rkInstVictim.GetAlignmentType())
  2159. return true;
  2160. break;
  2161. }
  2162.  
  2163. return false;
  2164. }
  2165.  
  2166. void CInstanceBase::SetDuelMode(DWORD type)
  2167. {
  2168. m_dwDuelMode = type;
  2169. }
  2170.  
  2171. DWORD CInstanceBase::GetDuelMode()
  2172. {
  2173. return m_dwDuelMode;
  2174. }
  2175.  
  2176. bool CInstanceBase::IsAttackableInstance(CInstanceBase& rkInstVictim)
  2177. {
  2178. if (__IsMainInstance())
  2179. {
  2180. CPythonPlayer& rkPlayer=CPythonPlayer::Instance();
  2181. if(rkPlayer.IsObserverMode())
  2182. return false;
  2183. }
  2184.  
  2185. if (GetVirtualID() == rkInstVictim.GetVirtualID())
  2186. return false;
  2187.  
  2188. if (IsStone())
  2189. {
  2190. if (rkInstVictim.IsPC())
  2191. return true;
  2192. }
  2193. else if (IsPC())
  2194. {
  2195. if (rkInstVictim.IsStone())
  2196. return true;
  2197.  
  2198. if (rkInstVictim.IsPC())
  2199. {
  2200. if (GetDuelMode())
  2201. {
  2202. switch(GetDuelMode())
  2203. {
  2204. case DUEL_CANNOTATTACK:
  2205. return false;
  2206. case DUEL_START:
  2207. if(__FindDUELKey(GetVirtualID(),rkInstVictim.GetVirtualID()))
  2208. return true;
  2209. else
  2210. return false;
  2211. }
  2212. }
  2213. if (PK_MODE_GUILD == GetPKMode())
  2214. if (GetGuildID() == rkInstVictim.GetGuildID())
  2215. return false;
  2216.  
  2217. if (rkInstVictim.IsKiller())
  2218. if (!IAbstractPlayer::GetSingleton().IsSamePartyMember(GetVirtualID(), rkInstVictim.GetVirtualID()))
  2219. return true;
  2220.  
  2221. if (PK_MODE_PROTECT != GetPKMode())
  2222. {
  2223. if (PK_MODE_FREE == GetPKMode())
  2224. {
  2225. if (PK_MODE_PROTECT != rkInstVictim.GetPKMode())
  2226. if (!IAbstractPlayer::GetSingleton().IsSamePartyMember(GetVirtualID(), rkInstVictim.GetVirtualID()))
  2227. return true;
  2228. }
  2229. if (PK_MODE_GUILD == GetPKMode())
  2230. {
  2231. if (PK_MODE_PROTECT != rkInstVictim.GetPKMode())
  2232. if (!IAbstractPlayer::GetSingleton().IsSamePartyMember(GetVirtualID(), rkInstVictim.GetVirtualID()))
  2233. if (GetGuildID() != rkInstVictim.GetGuildID())
  2234. return true;
  2235. }
  2236. }
  2237.  
  2238. if (IsSameEmpire(rkInstVictim))
  2239. {
  2240. if (IsPVPInstance(rkInstVictim))
  2241. return true;
  2242.  
  2243. if (PK_MODE_REVENGE == GetPKMode())
  2244. if (!IAbstractPlayer::GetSingleton().IsSamePartyMember(GetVirtualID(), rkInstVictim.GetVirtualID()))
  2245. if (IsConflictAlignmentInstance(rkInstVictim))
  2246. return true;
  2247. }
  2248. else
  2249. {
  2250. return true;
  2251. }
  2252. }
  2253.  
  2254. if (rkInstVictim.IsEnemy())
  2255. return true;
  2256.  
  2257. if (rkInstVictim.IsWoodenDoor())
  2258. return true;
  2259. }
  2260. else if (IsEnemy())
  2261. {
  2262. if (rkInstVictim.IsPC())
  2263. return true;
  2264.  
  2265. if (rkInstVictim.IsBuilding())
  2266. return true;
  2267.  
  2268. }
  2269. else if (IsPoly())
  2270. {
  2271. if (rkInstVictim.IsPC())
  2272. return true;
  2273.  
  2274. if (rkInstVictim.IsEnemy())
  2275. return true;
  2276. }
  2277. return false;
  2278. }
  2279.  
  2280. bool CInstanceBase::IsTargetableInstance(CInstanceBase& rkInstVictim)
  2281. {
  2282. return rkInstVictim.CanPickInstance();
  2283. }
  2284.  
  2285. // 2004. 07. 07. [levites] - 스킬 사용중 타겟이 바뀌는 문제 해결을 위한 코드
  2286. bool CInstanceBase::CanChangeTarget()
  2287. {
  2288. return m_GraphicThingInstance.CanChangeTarget();
  2289. }
  2290.  
  2291. // 2004.07.17.levites.isShow를 ViewFrustumCheck로 변경
  2292. bool CInstanceBase::CanPickInstance()
  2293. {
  2294. if (!__IsInViewFrustum())
  2295. return false;
  2296.  
  2297. if (IsDoor())
  2298. {
  2299. if (IsDead())
  2300. return false;
  2301. }
  2302.  
  2303. if (IsPC())
  2304. {
  2305. if (IsAffect(AFFECT_EUNHYEONG))
  2306. {
  2307. if (!__MainCanSeeHiddenThing())
  2308. return false;
  2309. }
  2310. if (IsAffect(AFFECT_REVIVE_INVISIBILITY))
  2311. return false;
  2312. if (IsAffect(AFFECT_INVISIBILITY))
  2313. return false;
  2314. }
  2315.  
  2316. if (IsDead())
  2317. return false;
  2318.  
  2319. return true;
  2320. }
  2321.  
  2322. bool CInstanceBase::CanViewTargetHP(CInstanceBase& rkInstVictim)
  2323. {
  2324. if (rkInstVictim.IsStone())
  2325. return true;
  2326. if (rkInstVictim.IsWoodenDoor())
  2327. return true;
  2328. if (rkInstVictim.IsEnemy())
  2329. return true;
  2330.  
  2331. return false;
  2332. }
  2333.  
  2334. BOOL CInstanceBase::IsPoly()
  2335. {
  2336. return m_GraphicThingInstance.IsPoly();
  2337. }
  2338.  
  2339. BOOL CInstanceBase::IsPC()
  2340. {
  2341. return m_GraphicThingInstance.IsPC();
  2342. }
  2343.  
  2344. BOOL CInstanceBase::IsNPC()
  2345. {
  2346. return m_GraphicThingInstance.IsNPC();
  2347. }
  2348.  
  2349. #ifdef NEW_PET_SYSTEM
  2350. BOOL CInstanceBase::IsNewPet()
  2351. {
  2352. return m_GraphicThingInstance.IsNewPet();
  2353. }
  2354. #endif
  2355.  
  2356. BOOL CInstanceBase::IsEnemy()
  2357. {
  2358. return m_GraphicThingInstance.IsEnemy();
  2359. }
  2360.  
  2361. BOOL CInstanceBase::IsStone()
  2362. {
  2363. return m_GraphicThingInstance.IsStone();
  2364. }
  2365.  
  2366.  
  2367. BOOL CInstanceBase::IsGuildWall() //IsBuilding 길드건물전체 IsGuildWall은 담장벽만(문은 제외)
  2368. {
  2369. return IsWall(m_dwRace);
  2370. }
  2371.  
  2372.  
  2373. BOOL CInstanceBase::IsResource()
  2374. {
  2375. switch (m_dwVirtualNumber)
  2376. {
  2377. case 20047:
  2378. case 20048:
  2379. case 20049:
  2380. case 20050:
  2381. case 20051:
  2382. case 20052:
  2383. case 20053:
  2384. case 20054:
  2385. case 20055:
  2386. case 20056:
  2387. case 20057:
  2388. case 20058:
  2389. case 20059:
  2390. case 30301:
  2391. case 30302:
  2392. case 30303:
  2393. case 30304:
  2394. case 30305:
  2395. return TRUE;
  2396. }
  2397.  
  2398. return FALSE;
  2399. }
  2400.  
  2401. BOOL CInstanceBase::IsWarp()
  2402. {
  2403. return m_GraphicThingInstance.IsWarp();
  2404. }
  2405.  
  2406. BOOL CInstanceBase::IsGoto()
  2407. {
  2408. return m_GraphicThingInstance.IsGoto();
  2409. }
  2410.  
  2411. BOOL CInstanceBase::IsObject()
  2412. {
  2413. return m_GraphicThingInstance.IsObject();
  2414. }
  2415.  
  2416. BOOL CInstanceBase::IsBuilding()
  2417. {
  2418. return m_GraphicThingInstance.IsBuilding();
  2419. }
  2420.  
  2421. BOOL CInstanceBase::IsDoor()
  2422. {
  2423. return m_GraphicThingInstance.IsDoor();
  2424. }
  2425.  
  2426. BOOL CInstanceBase::IsWoodenDoor()
  2427. {
  2428. if (m_GraphicThingInstance.IsDoor())
  2429. {
  2430. int vnum = GetVirtualNumber();
  2431. if (vnum == 13000) // 나무문
  2432. return true;
  2433. else if (vnum >= 30111 && vnum <= 30119) // 사귀문
  2434. return true;
  2435. else
  2436. return false;
  2437. }
  2438. else
  2439. {
  2440. return false;
  2441. }
  2442. }
  2443.  
  2444. BOOL CInstanceBase::IsStoneDoor()
  2445. {
  2446. return m_GraphicThingInstance.IsDoor() && 13001 == GetVirtualNumber();
  2447. }
  2448.  
  2449. BOOL CInstanceBase::IsFlag()
  2450. {
  2451. if (GetRace() == 20035)
  2452. return TRUE;
  2453. if (GetRace() == 20036)
  2454. return TRUE;
  2455. if (GetRace() == 20037)
  2456. return TRUE;
  2457.  
  2458. return FALSE;
  2459. }
  2460.  
  2461. BOOL CInstanceBase::IsForceVisible()
  2462. {
  2463. if (IsAffect(AFFECT_SHOW_ALWAYS))
  2464. return TRUE;
  2465.  
  2466. if (IsObject() || IsBuilding() || IsDoor() )
  2467. return TRUE;
  2468.  
  2469. return FALSE;
  2470. }
  2471.  
  2472. int CInstanceBase::GetInstanceType()
  2473. {
  2474. return m_GraphicThingInstance.GetActorType();
  2475. }
  2476.  
  2477. DWORD CInstanceBase::GetVirtualID()
  2478. {
  2479. return m_GraphicThingInstance.GetVirtualID();
  2480. }
  2481.  
  2482. DWORD CInstanceBase::GetVirtualNumber()
  2483. {
  2484. return m_dwVirtualNumber;
  2485. }
  2486.  
  2487. // 2004.07.17.levites.isShow를 ViewFrustumCheck로 변경
  2488. bool CInstanceBase::__IsInViewFrustum()
  2489. {
  2490. return m_GraphicThingInstance.isShow();
  2491. }
  2492.  
  2493. bool CInstanceBase::__CanRender()
  2494. {
  2495. if (!__IsInViewFrustum())
  2496. return false;
  2497. if (IsAffect(AFFECT_INVISIBILITY))
  2498. return false;
  2499.  
  2500. return true;
  2501. }
  2502.  
  2503.  
  2504. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2505. // Graphic Control
  2506.  
  2507. bool CInstanceBase::IntersectBoundingBox()
  2508. {
  2509. float u, v, t;
  2510. return m_GraphicThingInstance.Intersect(&u, &v, &t);
  2511. }
  2512.  
  2513. bool CInstanceBase::IntersectDefendingSphere()
  2514. {
  2515. return m_GraphicThingInstance.IntersectDefendingSphere();
  2516. }
  2517.  
  2518. float CInstanceBase::GetDistance(CInstanceBase * pkTargetInst)
  2519. {
  2520. TPixelPosition TargetPixelPosition;
  2521. pkTargetInst->m_GraphicThingInstance.GetPixelPosition(&TargetPixelPosition);
  2522. return GetDistance(TargetPixelPosition);
  2523. }
  2524.  
  2525. float CInstanceBase::GetDistance(const TPixelPosition & c_rPixelPosition)
  2526. {
  2527. TPixelPosition PixelPosition;
  2528. m_GraphicThingInstance.GetPixelPosition(&PixelPosition);
  2529.  
  2530. float fdx = PixelPosition.x - c_rPixelPosition.x;
  2531. float fdy = PixelPosition.y - c_rPixelPosition.y;
  2532.  
  2533. return sqrtf((fdx*fdx) + (fdy*fdy));
  2534. }
  2535.  
  2536. CActorInstance& CInstanceBase::GetGraphicThingInstanceRef()
  2537. {
  2538. return m_GraphicThingInstance;
  2539. }
  2540.  
  2541. CActorInstance* CInstanceBase::GetGraphicThingInstancePtr()
  2542. {
  2543. return &m_GraphicThingInstance;
  2544. }
  2545.  
  2546. void CInstanceBase::RefreshActorInstance()
  2547. {
  2548. m_GraphicThingInstance.RefreshActorInstance();
  2549. }
  2550.  
  2551. void CInstanceBase::Refresh(DWORD dwMotIndex, bool isLoop)
  2552. {
  2553. RefreshState(dwMotIndex, isLoop);
  2554. }
  2555.  
  2556. void CInstanceBase::RestoreRenderMode()
  2557. {
  2558. m_GraphicThingInstance.RestoreRenderMode();
  2559. }
  2560.  
  2561. void CInstanceBase::SetAddRenderMode()
  2562. {
  2563. m_GraphicThingInstance.SetAddRenderMode();
  2564. }
  2565.  
  2566. void CInstanceBase::SetModulateRenderMode()
  2567. {
  2568. m_GraphicThingInstance.SetModulateRenderMode();
  2569. }
  2570.  
  2571. void CInstanceBase::SetRenderMode(int iRenderMode)
  2572. {
  2573. m_GraphicThingInstance.SetRenderMode(iRenderMode);
  2574. }
  2575.  
  2576. void CInstanceBase::SetAddColor(const D3DXCOLOR & c_rColor)
  2577. {
  2578. m_GraphicThingInstance.SetAddColor(c_rColor);
  2579. }
  2580.  
  2581. void CInstanceBase::__SetBlendRenderingMode()
  2582. {
  2583. m_GraphicThingInstance.SetBlendRenderMode();
  2584. }
  2585.  
  2586. void CInstanceBase::__SetAlphaValue(float fAlpha)
  2587. {
  2588. m_GraphicThingInstance.SetAlphaValue(fAlpha);
  2589. }
  2590.  
  2591. float CInstanceBase::__GetAlphaValue()
  2592. {
  2593. return m_GraphicThingInstance.GetAlphaValue();
  2594. }
  2595.  
  2596. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2597. // Part
  2598.  
  2599. void CInstanceBase::SetHair(DWORD eHair)
  2600. {
  2601. if (!HAIR_COLOR_ENABLE)
  2602. return;
  2603.  
  2604. if (IsPC()==false)
  2605. return;
  2606. m_awPart[CRaceData::PART_HAIR] = eHair;
  2607. m_GraphicThingInstance.SetHair(eHair);
  2608. }
  2609.  
  2610. void CInstanceBase::ChangeHair(DWORD eHair)
  2611. {
  2612. if (!HAIR_COLOR_ENABLE)
  2613. return;
  2614.  
  2615. if (IsPC()==false)
  2616. return;
  2617.  
  2618. if (GetPart(CRaceData::PART_HAIR)==eHair)
  2619. return;
  2620.  
  2621. SetHair(eHair);
  2622.  
  2623. //int type = m_GraphicThingInstance.GetMotionMode();
  2624.  
  2625. RefreshState(CRaceMotionData::NAME_WAIT, true);
  2626. //RefreshState(type, true);
  2627. }
  2628.  
  2629. void CInstanceBase::SetArmor(DWORD dwArmor)
  2630. {
  2631. DWORD dwShape;
  2632. if (__ArmorVnumToShape(dwArmor, &dwShape))
  2633. {
  2634. CItemData * pItemData;
  2635. if (CItemManager::Instance().GetItemDataPointer(dwArmor, &pItemData))
  2636. {
  2637. float fSpecularPower=pItemData->GetSpecularPowerf();
  2638. SetShape(dwShape, fSpecularPower);
  2639. __GetRefinedEffect(pItemData);
  2640. return;
  2641. }
  2642. else
  2643. __ClearArmorRefineEffect();
  2644. }
  2645.  
  2646. SetShape(dwArmor);
  2647. }
  2648.  
  2649. void CInstanceBase::SetAcce(DWORD eAcce)
  2650. {
  2651. if (IsPC() == false)
  2652. return;
  2653.  
  2654. __ClearAcceRefineEffect();
  2655. float fSpecular = 0.0f;
  2656. int iAcce = (eAcce > 100) ? (int)(eAcce - 100) : (int)(eAcce);
  2657. if (eAcce > 100)
  2658. {
  2659. fSpecular = 100.0f;
  2660. m_acceEffect = EFFECT_REFINED+EFFECT_ACCE_SPECIAL;
  2661. __EffectContainer_AttachEffect(m_acceEffect);
  2662. }
  2663.  
  2664. m_awPart[CRaceData::PART_ACCE] = iAcce;
  2665. m_GraphicThingInstance.SetAcce(iAcce, fSpecular);
  2666. }
  2667.  
  2668. void CInstanceBase::ChangeAcce(DWORD eAcce)
  2669. {
  2670. if (IsPC() == false)
  2671. return;
  2672.  
  2673. SetAcce(eAcce);
  2674. }
  2675.  
  2676. void CInstanceBase::SetShape(DWORD eShape, float fSpecular)
  2677. {
  2678. if (IsPoly())
  2679. {
  2680. m_GraphicThingInstance.SetShape(0);
  2681. }
  2682. else
  2683. {
  2684. m_GraphicThingInstance.SetShape(eShape, fSpecular);
  2685. }
  2686.  
  2687. m_eShape = eShape;
  2688. }
  2689.  
  2690.  
  2691.  
  2692. DWORD CInstanceBase::GetWeaponType()
  2693. {
  2694. DWORD dwWeapon = GetPart(CRaceData::PART_WEAPON);
  2695. CItemData * pItemData;
  2696. if (!CItemManager::Instance().GetItemDataPointer(dwWeapon, &pItemData))
  2697. return CItemData::WEAPON_NONE;
  2698.  
  2699. #ifdef ENABLE_COSTUME_WEAPON_SYSTEM
  2700. if (pItemData->GetType() == CItemData::ITEM_TYPE_COSTUME)
  2701. return pItemData->GetValue(3);
  2702. #endif
  2703. return pItemData->GetWeaponType();
  2704. }
  2705.  
  2706. /*
  2707. void CInstanceBase::SetParts(const WORD * c_pParts)
  2708. {
  2709. if (IsPoly())
  2710. return;
  2711.  
  2712. if (__IsShapeAnimalWear())
  2713. return;
  2714.  
  2715. UINT eWeapon=c_pParts[CRaceData::PART_WEAPON];
  2716.  
  2717. if (__IsChangableWeapon(eWeapon) == false)
  2718. eWeapon = 0;
  2719.  
  2720. if (eWeapon != m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
  2721. {
  2722. m_GraphicThingInstance.AttachPart(CRaceData::PART_MAIN, CRaceData::PART_WEAPON, eWeapon);
  2723. m_awPart[CRaceData::PART_WEAPON] = eWeapon;
  2724. }
  2725.  
  2726. __AttachHorseSaddle();
  2727. }
  2728. */
  2729.  
  2730. void CInstanceBase::__ClearWeaponRefineEffect()
  2731. {
  2732. if (m_swordRefineEffectRight)
  2733. {
  2734. __DetachEffect(m_swordRefineEffectRight);
  2735. m_swordRefineEffectRight = 0;
  2736. }
  2737. if (m_swordRefineEffectLeft)
  2738. {
  2739. __DetachEffect(m_swordRefineEffectLeft);
  2740. m_swordRefineEffectLeft = 0;
  2741. }
  2742. }
  2743.  
  2744. void CInstanceBase::__ClearAcceRefineEffect()
  2745. {
  2746. if (m_acceEffect)
  2747. {
  2748. __EffectContainer_DetachEffect(EFFECT_REFINED+EFFECT_ACCE_SPECIAL);
  2749. m_acceEffect = 0;
  2750. }
  2751. }
  2752.  
  2753. void CInstanceBase::__ClearArmorRefineEffect()
  2754. {
  2755. if (m_armorRefineEffect)
  2756. {
  2757. __DetachEffect(m_armorRefineEffect);
  2758. m_armorRefineEffect = 0;
  2759. }
  2760. }
  2761.  
  2762. UINT CInstanceBase::__GetRefinedEffect(CItemData* pItem)
  2763. {
  2764. DWORD refine = max(pItem->GetRefine() + pItem->GetSocketCount(),CItemData::ITEM_SOCKET_MAX_NUM) - CItemData::ITEM_SOCKET_MAX_NUM;
  2765. switch (pItem->GetType())
  2766. {
  2767. case CItemData::ITEM_TYPE_WEAPON:
  2768. __ClearWeaponRefineEffect();
  2769. if (refine < 7) //현재 제련도 7 이상만 이펙트가 있습니다.
  2770. return 0;
  2771. switch(pItem->GetSubType())
  2772. {
  2773. case CItemData::WEAPON_DAGGER:
  2774. m_swordRefineEffectRight = EFFECT_REFINED+EFFECT_SMALLSWORD_REFINED7+refine-7;
  2775. m_swordRefineEffectLeft = EFFECT_REFINED+EFFECT_SMALLSWORD_REFINED7_LEFT+refine-7;
  2776. break;
  2777. case CItemData::WEAPON_CLAW:
  2778. m_swordRefineEffectRight = EFFECT_REFINED+EFFECT_SMALLSWORD_REFINED7+refine-7;
  2779. m_swordRefineEffectLeft = EFFECT_REFINED+EFFECT_SMALLSWORD_REFINED7_LEFT+refine-7;
  2780. break;
  2781. case CItemData::WEAPON_FAN:
  2782. m_swordRefineEffectRight = EFFECT_REFINED+EFFECT_FANBELL_REFINED7+refine-7;
  2783. break;
  2784. case CItemData::WEAPON_ARROW:
  2785. case CItemData::WEAPON_UNLIMITED_ARROW:
  2786. case CItemData::WEAPON_BELL:
  2787. m_swordRefineEffectRight = EFFECT_REFINED+EFFECT_SMALLSWORD_REFINED7+refine-7;
  2788. break;
  2789. case CItemData::WEAPON_BOW:
  2790. m_swordRefineEffectRight = EFFECT_REFINED+EFFECT_BOW_REFINED7+refine-7;
  2791.  
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800.  
  2801. break;
  2802. default:
  2803. m_swordRefineEffectRight = EFFECT_REFINED+EFFECT_SWORD_REFINED7+refine-7;
  2804. }
  2805. if (m_swordRefineEffectRight)
  2806. m_swordRefineEffectRight = __AttachEffect(m_swordRefineEffectRight);
  2807. if (m_swordRefineEffectLeft)
  2808. m_swordRefineEffectLeft = __AttachEffect(m_swordRefineEffectLeft);
  2809. break;
  2810. case CItemData::ITEM_TYPE_ARMOR:
  2811. __ClearArmorRefineEffect();
  2812.  
  2813. // 갑옷 특화 이펙트
  2814. if (pItem->GetSubType() == CItemData::ARMOR_BODY)
  2815. {
  2816. DWORD vnum = pItem->GetIndex();
  2817.  
  2818. if (12010 <= vnum && vnum <= 12049)
  2819. {
  2820. __AttachEffect(EFFECT_REFINED+EFFECT_BODYARMOR_SPECIAL);
  2821. __AttachEffect(EFFECT_REFINED+EFFECT_BODYARMOR_SPECIAL2);
  2822. }
  2823. }
  2824.  
  2825. if (refine < 7) //현재 제련도 7 이상만 이펙트가 있습니다.
  2826. return 0;
  2827.  
  2828. if (pItem->GetSubType() == CItemData::ARMOR_BODY)
  2829. {
  2830. m_armorRefineEffect = EFFECT_REFINED+EFFECT_BODYARMOR_REFINED7+refine-7;
  2831. __AttachEffect(m_armorRefineEffect);
  2832. }
  2833. break;
  2834. }
  2835. return 0;
  2836. }
  2837.  
  2838. bool CInstanceBase::SetWeapon(DWORD eWeapon)
  2839. {
  2840. if (IsPoly())
  2841. return false;
  2842.  
  2843. if (__IsShapeAnimalWear())
  2844. return false;
  2845.  
  2846. if (__IsChangableWeapon(eWeapon) == false)
  2847. eWeapon = 0;
  2848.  
  2849. m_GraphicThingInstance.AttachWeapon(eWeapon);
  2850. m_awPart[CRaceData::PART_WEAPON] = eWeapon;
  2851.  
  2852. //Weapon Effect
  2853. CItemData * pItemData;
  2854. if (CItemManager::Instance().GetItemDataPointer(eWeapon, &pItemData))
  2855. {
  2856. #ifdef ENABLE_COSTUME_WEAPON_SYSTEM
  2857. if (pItemData->GetType() == CItemData::ITEM_TYPE_COSTUME)
  2858. __ClearWeaponRefineEffect();
  2859. #endif
  2860.  
  2861. __GetRefinedEffect(pItemData);
  2862. }
  2863.  
  2864. else
  2865. __ClearWeaponRefineEffect();
  2866.  
  2867. return true;
  2868. }
  2869.  
  2870. void CInstanceBase::ChangeWeapon(DWORD eWeapon)
  2871. {
  2872. CheckArrowType();
  2873. if (eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
  2874. return;
  2875.  
  2876. if (SetWeapon(eWeapon))
  2877. RefreshState(CRaceMotionData::NAME_WAIT, true);
  2878. }
  2879.  
  2880. bool CInstanceBase::ChangeArmor(DWORD dwArmor)
  2881. {
  2882. DWORD eShape;
  2883. __ArmorVnumToShape(dwArmor, &eShape);
  2884.  
  2885. if (GetShape()==eShape)
  2886. return false;
  2887.  
  2888. CAffectFlagContainer kAffectFlagContainer;
  2889. kAffectFlagContainer.CopyInstance(m_kAffectFlagContainer);
  2890.  
  2891. DWORD dwVID = GetVirtualID();
  2892. DWORD dwRace = GetRace();
  2893. DWORD eHair = GetPart(CRaceData::PART_HAIR);
  2894. DWORD eAcce = GetPart(CRaceData::PART_ACCE);
  2895. DWORD eWeapon = GetPart(CRaceData::PART_WEAPON);
  2896. float fRot = GetRotation();
  2897. float fAdvRot = GetAdvancingRotation();
  2898.  
  2899. if (IsWalking())
  2900. EndWalking();
  2901.  
  2902. // 2004.07.25.myevan.이펙트 안 붙는 문제
  2903. //////////////////////////////////////////////////////
  2904. __ClearAffects();
  2905. //////////////////////////////////////////////////////
  2906.  
  2907. if (!SetRace(dwRace))
  2908. {
  2909. TraceError("CPythonCharacterManager::ChangeArmor - SetRace VID[%d] Race[%d] ERROR", dwVID, dwRace);
  2910. return false;
  2911. }
  2912.  
  2913. SetArmor(dwArmor);
  2914. SetHair(eHair);
  2915. SetAcce(eAcce);
  2916. SetWeapon(eWeapon);
  2917.  
  2918. SetRotation(fRot);
  2919. SetAdvancingRotation(fAdvRot);
  2920.  
  2921. __AttachHorseSaddle();
  2922.  
  2923. RefreshState(CRaceMotionData::NAME_WAIT, TRUE);
  2924.  
  2925. // 2004.07.25.myevan.이펙트 안 붙는 문제
  2926. /////////////////////////////////////////////////
  2927. SetAffectFlagContainer(kAffectFlagContainer);
  2928. /////////////////////////////////////////////////
  2929.  
  2930. CActorInstance::IEventHandler& rkEventHandler=GetEventHandlerRef();
  2931. rkEventHandler.OnChangeShape();
  2932.  
  2933. return true;
  2934. }
  2935.  
  2936. void CInstanceBase::CheckArrowType()
  2937. {
  2938. CItemData * pItemData;
  2939. if ((!m_kHorse.IsMounting()) && CItemManager::Instance().GetItemDataPointer(CPythonPlayer::Instance().GetItemIndex(TItemPos(INVENTORY, c_Equipment_Arrow)), &pItemData))
  2940. {
  2941. if (CItemData::ITEM_TYPE_WEAPON == pItemData->GetType() && CItemData::WEAPON_UNLIMITED_ARROW == pItemData->GetSubType())
  2942. {
  2943. UNLIMITED_ARROW=TRUE;
  2944.  
  2945. CItemData * pItemData_1;
  2946. if (CItemManager::Instance().GetItemDataPointer(CPythonPlayer::Instance().GetItemIndex(TItemPos(INVENTORY, c_Equipment_Weapon)), &pItemData_1))
  2947. {
  2948. if (pItemData_1->GetSubType() == CItemData::WEAPON_BOW)
  2949. {
  2950. SetMotionMode(CRaceMotionData::MODE_BOW_SPECIAL);
  2951. }
  2952. }
  2953. }
  2954. else
  2955. {
  2956. UNLIMITED_ARROW=FALSE;
  2957.  
  2958. CItemData * pItemData_2;
  2959. if (CItemManager::Instance().GetItemDataPointer(CPythonPlayer::Instance().GetItemIndex(TItemPos(INVENTORY, c_Equipment_Weapon)), &pItemData_2))
  2960. {
  2961. if (pItemData_2->GetSubType() == CItemData::WEAPON_BOW)
  2962. {
  2963. SetMotionMode(CRaceMotionData::MODE_BOW);
  2964. }
  2965. }
  2966. }
  2967. }
  2968. }
  2969.  
  2970. bool CInstanceBase::__IsShapeAnimalWear()
  2971. {
  2972. if (100 == GetShape() ||
  2973. 101 == GetShape() ||
  2974. 102 == GetShape() ||
  2975. 103 == GetShape())
  2976. return true;
  2977.  
  2978. return false;
  2979. }
  2980.  
  2981. DWORD CInstanceBase::__GetRaceType()
  2982. {
  2983. return m_eRaceType;
  2984. }
  2985.  
  2986.  
  2987. void CInstanceBase::RefreshState(DWORD dwMotIndex, bool isLoop)
  2988. {
  2989. DWORD dwPartItemID = m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON);
  2990.  
  2991. BYTE byItemType = 0xff;
  2992. BYTE bySubType = 0xff;
  2993.  
  2994. CItemManager & rkItemMgr = CItemManager::Instance();
  2995. CItemData * pItemData;
  2996.  
  2997. if (rkItemMgr.GetItemDataPointer(dwPartItemID, &pItemData))
  2998. {
  2999. byItemType = pItemData->GetType();
  3000. bySubType = pItemData->GetWeaponType();
  3001. }
  3002.  
  3003. if (IsPoly())
  3004. {
  3005. SetMotionMode(CRaceMotionData::MODE_GENERAL);
  3006. }
  3007. else if (IsWearingDress())
  3008. {
  3009. SetMotionMode(CRaceMotionData::MODE_WEDDING_DRESS);
  3010. }
  3011. else if (IsHoldingPickAxe())
  3012. {
  3013. if (m_kHorse.IsMounting())
  3014. {
  3015. SetMotionMode(CRaceMotionData::MODE_HORSE);
  3016. }
  3017. else
  3018. {
  3019. SetMotionMode(CRaceMotionData::MODE_GENERAL);
  3020. }
  3021. }
  3022. else if (CItemData::ITEM_TYPE_ROD == byItemType)
  3023. {
  3024. if (m_kHorse.IsMounting())
  3025. {
  3026. SetMotionMode(CRaceMotionData::MODE_HORSE);
  3027. }
  3028. else
  3029. {
  3030. SetMotionMode(CRaceMotionData::MODE_FISHING);
  3031. }
  3032. }
  3033. #ifdef ENABLE_COSTUME_WEAPON_SYSTEM
  3034. else if (byItemType == CItemData::ITEM_TYPE_COSTUME)
  3035. {
  3036. switch (pItemData->GetValue(3))
  3037. {
  3038. case CItemData::WEAPON_SWORD:
  3039. if (m_kHorse.IsMounting())
  3040. SetMotionMode(CRaceMotionData::MODE_HORSE_ONEHAND_SWORD);
  3041. else
  3042. SetMotionMode(CRaceMotionData::MODE_ONEHAND_SWORD);
  3043. break;
  3044. case CItemData::WEAPON_DAGGER:
  3045. if (m_kHorse.IsMounting())
  3046. SetMotionMode(CRaceMotionData::MODE_HORSE_DUALHAND_SWORD);
  3047. else
  3048. SetMotionMode(CRaceMotionData::MODE_DUALHAND_SWORD);
  3049. break;
  3050. case CItemData::WEAPON_BOW:
  3051. if (m_kHorse.IsMounting())
  3052. SetMotionMode(CRaceMotionData::MODE_HORSE_BOW);
  3053. else
  3054. #ifdef ENABLE_NEW_ARROW_SYSTEM
  3055. {
  3056. if (m_awPart[CRaceData::PART_ARROW_TYPE] == CItemData::WEAPON_UNLIMITED_ARROW)
  3057. SetMotionMode(CRaceMotionData::MODE_BOW_SPECIAL);
  3058. else
  3059. SetMotionMode(CRaceMotionData::MODE_BOW);
  3060. }
  3061. #else
  3062. SetMotionMode(CRaceMotionData::MODE_BOW);
  3063. #endif
  3064. break;
  3065. case CItemData::WEAPON_TWO_HANDED:
  3066. if (m_kHorse.IsMounting())
  3067. SetMotionMode(CRaceMotionData::MODE_HORSE_TWOHAND_SWORD);
  3068. else
  3069. SetMotionMode(CRaceMotionData::MODE_TWOHAND_SWORD);
  3070. break;
  3071. case CItemData::WEAPON_BELL:
  3072. if (m_kHorse.IsMounting())
  3073. SetMotionMode(CRaceMotionData::MODE_HORSE_BELL);
  3074. else
  3075. SetMotionMode(CRaceMotionData::MODE_BELL);
  3076. break;
  3077. case CItemData::WEAPON_FAN:
  3078. if (m_kHorse.IsMounting())
  3079. SetMotionMode(CRaceMotionData::MODE_HORSE_FAN);
  3080. else
  3081. SetMotionMode(CRaceMotionData::MODE_FAN);
  3082. break;
  3083. case CItemData::WEAPON_CLAW:
  3084. if (m_kHorse.IsMounting())
  3085. SetMotionMode(CRaceMotionData::MODE_HORSE_CLAW);
  3086. else
  3087. SetMotionMode(CRaceMotionData::MODE_CLAW);
  3088. break;
  3089. default:
  3090. if (m_kHorse.IsMounting())
  3091. SetMotionMode(CRaceMotionData::MODE_HORSE);
  3092. else
  3093. SetMotionMode(CRaceMotionData::MODE_GENERAL);
  3094. break;
  3095. }
  3096. }
  3097. #endif
  3098. else if (m_kHorse.IsMounting())
  3099. {
  3100. switch (bySubType)
  3101. {
  3102. case CItemData::WEAPON_SWORD:
  3103. SetMotionMode(CRaceMotionData::MODE_HORSE_ONEHAND_SWORD);
  3104. break;
  3105.  
  3106. case CItemData::WEAPON_TWO_HANDED:
  3107. SetMotionMode(CRaceMotionData::MODE_HORSE_TWOHAND_SWORD); // Only Warrior
  3108. break;
  3109.  
  3110. case CItemData::WEAPON_DAGGER:
  3111. SetMotionMode(CRaceMotionData::MODE_HORSE_DUALHAND_SWORD); // Only Assassin
  3112. break;
  3113.  
  3114. case CItemData::WEAPON_FAN:
  3115. SetMotionMode(CRaceMotionData::MODE_HORSE_FAN); // Only Shaman
  3116. break;
  3117.  
  3118. case CItemData::WEAPON_BELL:
  3119. SetMotionMode(CRaceMotionData::MODE_HORSE_BELL); // Only Shaman
  3120. break;
  3121.  
  3122. case CItemData::WEAPON_BOW:
  3123. SetMotionMode(CRaceMotionData::MODE_HORSE_BOW); // Only Shaman
  3124. break;
  3125.  
  3126. case CItemData::WEAPON_CLAW:
  3127. SetMotionMode(CRaceMotionData::MODE_HORSE_CLAW); // Only Wolfman
  3128. break;
  3129.  
  3130. default:
  3131. SetMotionMode(CRaceMotionData::MODE_HORSE);
  3132. break;
  3133. }
  3134. }
  3135. else
  3136. {
  3137. switch (bySubType)
  3138. {
  3139. case CItemData::WEAPON_SWORD:
  3140. SetMotionMode(CRaceMotionData::MODE_ONEHAND_SWORD);
  3141. break;
  3142.  
  3143. case CItemData::WEAPON_TWO_HANDED:
  3144. SetMotionMode(CRaceMotionData::MODE_TWOHAND_SWORD); // Only Warrior
  3145. break;
  3146.  
  3147. case CItemData::WEAPON_DAGGER:
  3148. SetMotionMode(CRaceMotionData::MODE_DUALHAND_SWORD); // Only Assassin
  3149. break;
  3150.  
  3151. case CItemData::WEAPON_BOW:
  3152. if (!UNLIMITED_ARROW)
  3153. {
  3154. SetMotionMode(CRaceMotionData::MODE_BOW);
  3155. }
  3156. else
  3157. {
  3158. SetMotionMode(CRaceMotionData::MODE_BOW_SPECIAL);
  3159. }
  3160.  
  3161. CheckArrowType();
  3162. break;
  3163.  
  3164. case CItemData::WEAPON_FAN:
  3165. SetMotionMode(CRaceMotionData::MODE_FAN); // Only Shaman
  3166. break;
  3167.  
  3168. case CItemData::WEAPON_BELL:
  3169. SetMotionMode(CRaceMotionData::MODE_BELL); // Only Shaman
  3170. break;
  3171.  
  3172. case CItemData::WEAPON_CLAW:
  3173. SetMotionMode(CRaceMotionData::MODE_CLAW); // Only Wolfman
  3174. break;
  3175.  
  3176. case CItemData::WEAPON_ARROW:
  3177. case CItemData::WEAPON_UNLIMITED_ARROW:
  3178. default:
  3179. SetMotionMode(CRaceMotionData::MODE_GENERAL);
  3180. break;
  3181. }
  3182. }
  3183.  
  3184. if (isLoop)
  3185. m_GraphicThingInstance.InterceptLoopMotion(dwMotIndex);
  3186. else
  3187. m_GraphicThingInstance.InterceptOnceMotion(dwMotIndex);
  3188.  
  3189. RefreshActorInstance();
  3190. }
  3191.  
  3192. ///////////////////////////////////////////////////////////////////////////////////////////////////
  3193. // Device
  3194.  
  3195. void CInstanceBase::RegisterBoundingSphere()
  3196. {
  3197. // Stone 일 경우 DeforomNoSkin 을 하면
  3198. // 낙하하는 애니메이션 같은 경우 애니메이션이
  3199. // 바운드 박스에 영향을 미쳐 컬링이 제대로 이루어지지 않는다.
  3200. if (!IsStone())
  3201. {
  3202. m_GraphicThingInstance.DeformNoSkin();
  3203. }
  3204.  
  3205. m_GraphicThingInstance.RegisterBoundingSphere();
  3206. }
  3207.  
  3208. bool CInstanceBase::CreateDeviceObjects()
  3209. {
  3210. return m_GraphicThingInstance.CreateDeviceObjects();
  3211. }
  3212.  
  3213. void CInstanceBase::DestroyDeviceObjects()
  3214. {
  3215. m_GraphicThingInstance.DestroyDeviceObjects();
  3216. }
  3217.  
  3218. void CInstanceBase::Destroy()
  3219. {
  3220. DetachTextTail();
  3221.  
  3222. DismountHorse();
  3223.  
  3224. m_kQue_kCmdNew.clear();
  3225.  
  3226. __EffectContainer_Destroy();
  3227. __StoneSmoke_Destroy();
  3228.  
  3229. if (__IsMainInstance())
  3230. __ClearMainInstance();
  3231.  
  3232. m_GraphicThingInstance.Destroy();
  3233.  
  3234. __Initialize();
  3235. }
  3236.  
  3237. void CInstanceBase::__InitializeRotationSpeed()
  3238. {
  3239. SetRotationSpeed(c_fDefaultRotationSpeed);
  3240. }
  3241.  
  3242. void CInstanceBase::__Warrior_Initialize()
  3243. {
  3244. m_kWarrior.m_dwGeomgyeongEffect=0;
  3245. }
  3246.  
  3247. void CInstanceBase::__Initialize()
  3248. {
  3249. __Warrior_Initialize();
  3250. __StoneSmoke_Inialize();
  3251. __EffectContainer_Initialize();
  3252. __InitializeRotationSpeed();
  3253.  
  3254. SetEventHandler(CActorInstance::IEventHandler::GetEmptyPtr());
  3255.  
  3256. m_kAffectFlagContainer.Clear();
  3257.  
  3258. m_dwLevel = 0;
  3259. m_dwGuildID = 0;
  3260. m_dwEmpireID = 0;
  3261.  
  3262. m_eType = 0;
  3263. m_eRaceType = 0;
  3264. m_eShape = 0;
  3265. m_dwRace = 0;
  3266. m_dwVirtualNumber = 0;
  3267.  
  3268. m_dwBaseCmdTime=0;
  3269. m_dwBaseChkTime=0;
  3270. m_dwSkipTime=0;
  3271.  
  3272. m_GraphicThingInstance.Initialize();
  3273.  
  3274. m_dwAdvActorVID=0;
  3275. m_dwLastDmgActorVID=0;
  3276.  
  3277. m_nAverageNetworkGap=0;
  3278. m_dwNextUpdateHeightTime=0;
  3279.  
  3280. // Moving by keyboard
  3281. m_iRotatingDirection = DEGREE_DIRECTION_SAME;
  3282.  
  3283. // Moving by mouse
  3284. m_isTextTail = FALSE;
  3285. m_isGoing = FALSE;
  3286. NEW_SetSrcPixelPosition(TPixelPosition(0, 0, 0));
  3287. NEW_SetDstPixelPosition(TPixelPosition(0, 0, 0));
  3288.  
  3289. m_kPPosDust = TPixelPosition(0, 0, 0);
  3290.  
  3291.  
  3292. m_kQue_kCmdNew.clear();
  3293.  
  3294. m_dwLastComboIndex = 0;
  3295.  
  3296. m_swordRefineEffectRight = 0;
  3297. m_swordRefineEffectLeft = 0;
  3298. m_armorRefineEffect = 0;
  3299. m_acceEffect = 0;
  3300.  
  3301. m_sAlignment = 0;
  3302. m_byPKMode = 0;
  3303. m_isKiller = false;
  3304. m_isPartyMember = false;
  3305.  
  3306. m_bEnableTCPState = TRUE;
  3307.  
  3308. m_stName = "";
  3309.  
  3310. memset(m_awPart, 0, sizeof(m_awPart));
  3311. memset(m_adwCRCAffectEffect, 0, sizeof(m_adwCRCAffectEffect));
  3312. //memset(m_adwCRCEmoticonEffect, 0, sizeof(m_adwCRCEmoticonEffect));
  3313. memset(&m_kMovAfterFunc, 0, sizeof(m_kMovAfterFunc));
  3314.  
  3315. m_bDamageEffectType = false;
  3316. m_dwDuelMode = DUEL_NONE;
  3317. m_dwEmoticonTime = 0;
  3318. }
  3319.  
  3320. CInstanceBase::CInstanceBase()
  3321. {
  3322. __Initialize();
  3323. }
  3324.  
  3325. CInstanceBase::~CInstanceBase()
  3326. {
  3327. Destroy();
  3328. }
  3329.  
  3330.  
  3331. void CInstanceBase::GetBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax)
  3332. {
  3333. m_GraphicThingInstance.GetBoundBox(vtMin, vtMax);
  3334. }
RAW Paste Data