bool ChatHandler::HandleRangeCheckCommand( const char *args , WorldSession *m_session ) { WorldPacket data; uint64 guid = m_session->GetPlayer()->GetSelection(); m_session->SystemMessage( "=== RANGE CHECK ===" ); if (guid == 0) { m_session->SystemMessage("No selection imo."); return true; } Unit* unit = m_session->GetPlayer()->GetMapMgr()->GetUnit( guid ); if(!unit) { m_session->SystemMessage("Invalid selection imo."); return true; } float DistSq = unit->GetDistanceSq( TO_OBJECT(m_session->GetPlayer()) ); m_session->SystemMessage( "GetDistanceSq : %u" , FL2UINT( DistSq ) ); LocationVector locvec( m_session->GetPlayer()->GetPositionX() , m_session->GetPlayer()->GetPositionY() , m_session->GetPlayer()->GetPositionZ() ); float DistReal = unit->CalcDistance( locvec ); m_session->SystemMessage( "CalcDistance : %u" , FL2UINT( DistReal ) ); float Dist2DSq = unit->GetDistance2dSq( TO_OBJECT(m_session->GetPlayer()) ); m_session->SystemMessage( "GetDistance2dSq: %u" , FL2UINT( Dist2DSq ) ); return true; }
bool ChatHandler::HandleRangeCheckCommand(const char* /*args*/, WorldSession* m_session) { uint64 guid = m_session->GetPlayer()->GetSelection(); if (!guid) { m_session->SystemMessage("No selection."); return false; } Unit* unit = m_session->GetPlayer()->GetMapMgr()->GetUnit(guid); if (!unit) { m_session->SystemMessage("Invalid selection."); return false; } float DistSq = unit->GetDistanceSq(m_session->GetPlayer()); m_session->SystemMessage("GetDistanceSq : %u", float2int32(DistSq)); LocationVector locvec(m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ()); float DistReal = unit->CalcDistance(locvec); m_session->SystemMessage("CalcDistance : %u", float2int32(DistReal)); float Dist2DSq = unit->GetDistance2dSq(m_session->GetPlayer()); m_session->SystemMessage("GetDistance2dSq: %u", float2int32(Dist2DSq)); return true; }
bool DeathGrip(uint32 i, Spell* s) { Unit* unitTarget = s->GetUnitTarget(); if(!s->u_caster || !s->u_caster->isAlive() || !unitTarget || !unitTarget->isAlive()) return false; // rooted units can't be death gripped if(unitTarget->isRooted()) return false; if(unitTarget->IsPlayer()) { Player* playerTarget = TO< Player* >(unitTarget); if(playerTarget->m_CurrentTransporter) // Blizzard screwed this up, so we won't. return false; s->SpellEffectPlayerPull(i); return false; } else { float posX, posY, posZ; float deltaX, deltaY; if(s->u_caster->GetPositionX() == 0.0f || s->u_caster->GetPositionY() == 0.0f) return false; deltaX = s->u_caster->GetPositionX() - unitTarget->GetPositionX(); deltaY = s->u_caster->GetPositionY() - unitTarget->GetPositionY(); if(deltaX == 0.0f || deltaY == 0.0f) return false; float d = sqrt(deltaX * deltaX + deltaY * deltaY) - s->u_caster->GetBoundingRadius() - unitTarget->GetBoundingRadius(); float alpha = atanf(deltaY / deltaX); if(deltaX < 0) alpha += M_PI_FLOAT; posX = d * cosf(alpha) + unitTarget->GetPositionX(); posY = d * sinf(alpha) + unitTarget->GetPositionY(); posZ = s->u_caster->GetPositionZ(); uint32 time = uint32((unitTarget->CalcDistance(s->m_caster) / ((unitTarget->m_runSpeed * 3.5) * 0.001f)) + 0.5); WorldPacket data(SMSG_MONSTER_MOVE, 60); data << unitTarget->GetNewGUID(); data << uint8(0); //VLack: the usual change in SMSG_MONSTER_MOVE packets, initial idea from Mangos data << unitTarget->GetPositionX(); data << unitTarget->GetPositionY(); data << unitTarget->GetPositionZ(); data << getMSTime(); data << uint8(0x00); data << uint32(0x00001000); data << time; data << uint32(1); data << posX << posY << posZ; if(unitTarget->IsCreature()) unitTarget->GetAIInterface()->StopMovement(2000); unitTarget->SendMessageToSet(&data, true); unitTarget->SetPosition(posX, posY, posZ, alpha, true); unitTarget->addStateFlag(UF_ATTACKING); unitTarget->smsg_AttackStart(unitTarget); unitTarget->setAttackTimer(time, false); unitTarget->setAttackTimer(time, true); unitTarget->GetAIInterface()->taunt(s->u_caster, true); } return true; }