Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. void Spell::EffectMomentMove(uint32 i)
  2. {
  3. if(unitTarget->isInFlight())
  4. return;
  5.  
  6. if(!m_targets.HasDst())
  7. return;
  8.  
  9. uint32 mapid = m_caster->GetMapId();
  10. float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
  11.  
  12. // src point
  13. float *fx = new float[11], *fy = new float[11], *fz = new float[11];
  14. unitTarget->GetPosition(fx[0], fy[0], fz[0]);
  15.  
  16. float orientation = unitTarget->GetOrientation(), itr_i, step = dis / 10.0, fx2, fy2, fz2, ground, floor;
  17. int itr_j = 1, last_valid = 0;
  18. bool hit = false;
  19.  
  20. for (itr_i = step; itr_i <= dis; itr_i += step)
  21. {
  22. fx[itr_j] = fx[0] + itr_i * cos(orientation);
  23. fy[itr_j] = fy[0] + itr_i * sin(orientation);
  24. ground = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], MAX_HEIGHT, true);
  25. floor = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], fz[last_valid], true);
  26. fz[itr_j] = fabs(ground - fz[last_valid]) <= fabs(floor - fz[last_valid]) ? ground : floor;
  27. if (fabs(fz[itr_j] - fz[0]) <= 6.0)
  28. {
  29. if (VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(mapid, fx[last_valid], fy[last_valid], fz[last_valid] + 0.5, fx[itr_j], fy[itr_j], fz[itr_j] + 0.5, fx2, fy2, fz2, -0.5))
  30. {
  31. hit = true;
  32. fx[itr_j] = fx2 - 0.6 * cos(orientation);
  33. fy[itr_j] = fy2 - 0.6 * sin(orientation);
  34. ground = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], MAX_HEIGHT, true);
  35. floor = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], fz[last_valid], true);
  36. float tempz = fabs(ground - fz[last_valid]) <= fabs(floor - fz[last_valid]) ? ground : floor;
  37. fz[itr_j] = fabs(tempz - fz[last_valid]) <= fabs(fz2 - fz[last_valid]) ? tempz : fz2;
  38. break;
  39. }
  40. else
  41. last_valid = itr_j;
  42. }
  43. itr_j++;
  44. }
  45. if (hit == false)
  46. itr_j = last_valid;
  47.  
  48.  
  49. if (unitTarget->GetTypeId() == TYPEID_PLAYER)
  50. ((Player*)unitTarget)->TeleportTo(mapid, fx[itr_j], fy[itr_j], fz[itr_j] + 0.07531, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget == m_caster ? TELE_TO_SPELL : 0));
  51. else
  52. MapManager::Instance().GetMap(mapid, unitTarget)->CreatureRelocation((Creature*)unitTarget, fx[itr_j], fy[itr_j], fz[itr_j] + 0.07531, orientation);
  53.  
  54. delete [] fx; delete [] fy; delete [] fz;
  55.  
  56. /* uint32 mapid = unitTarget->GetMapId();
  57. float ox,oy,oz;
  58. unitTarget->GetPosition(ox,oy,oz);
  59.  
  60. float fx,fy,fz; // getObjectHitPos overwrite last args in any result case
  61. if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(mapid, ox,oy,oz+0.5, m_targets.m_destX,m_targets.m_destY,oz+0.5,fx,fy,fz, -0.5))
  62. unitTarget->UpdateGroundPositionZ(fx,fy,fz);
  63.  
  64. if(unitTarget->GetTypeId() == TYPEID_PLAYER)
  65. ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, unitTarget->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
  66. else
  67. MapManager::Instance().GetMap(mapid, unitTarget)->CreatureRelocation((Creature*)unitTarget, fx, fy, fz, unitTarget->GetOrientation());*/
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement