5504 | | uint32 mapid = unitTarget->GetMapId(); |
| 5504 | uint32 mapid = m_caster->GetMapId(); |
| 5505 | float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); |
| 5506 | |
| 5507 | // src point |
| 5508 | float *fx = new float[11], *fy = new float[11], *fz = new float[11]; |
| 5509 | unitTarget->GetPosition(fx[0], fy[0], fz[0]); |
| 5510 | |
| 5511 | float orientation = unitTarget->GetOrientation(), itr_i, step = dis / 10.0, fx2, fy2, fz2, ground, floor; |
| 5512 | int itr_j = 1, last_valid = 0; |
| 5513 | bool hit = false; |
| 5514 | |
| 5515 | for (itr_i = step; itr_i <= dis; itr_i += step) |
| 5516 | { |
| 5517 | fx[itr_j] = fx[0] + itr_i * cos(orientation); |
| 5518 | fy[itr_j] = fy[0] + itr_i * sin(orientation); |
| 5519 | ground = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], MAX_HEIGHT, true); |
| 5520 | floor = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], fz[last_valid], true); |
| 5521 | fz[itr_j] = fabs(ground - fz[last_valid]) <= fabs(floor - fz[last_valid]) ? ground : floor; |
| 5522 | if (fabs(fz[itr_j] - fz[0]) <= 6.0) |
| 5523 | { |
| 5524 | 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)) |
| 5525 | { |
| 5526 | hit = true; |
| 5527 | fx[itr_j] = fx2 - 0.6 * cos(orientation); |
| 5528 | fy[itr_j] = fy2 - 0.6 * sin(orientation); |
| 5529 | ground = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], MAX_HEIGHT, true); |
| 5530 | floor = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], fz[last_valid], true); |
| 5531 | float tempz = fabs(ground - fz[last_valid]) <= fabs(floor - fz[last_valid]) ? ground : floor; |
| 5532 | fz[itr_j] = fabs(tempz - fz[last_valid]) <= fabs(fz2 - fz[last_valid]) ? tempz : fz2; |
| 5533 | break; |
| 5534 | } |
| 5535 | else |
| 5536 | last_valid = itr_j; |
| 5537 | } |
| 5538 | itr_j++; |
| 5539 | } |
| 5540 | if (hit == false) |
| 5541 | itr_j = last_valid; |
| 5542 | |
| 5543 | |
| 5544 | if (unitTarget->GetTypeId() == TYPEID_PLAYER) |
| 5545 | ((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)); |
| 5546 | else |
| 5547 | MapManager::Instance().GetMap(mapid, unitTarget)->CreatureRelocation((Creature*)unitTarget, fx[itr_j], fy[itr_j], fz[itr_j] + 0.07531, orientation); |
| 5548 | |
| 5549 | delete [] fx; delete [] fy; delete [] fz; |
| 5550 | |
| 5551 | /* uint32 mapid = unitTarget->GetMapId(); |