Example #1
0
bool Carcass(uint32 i, Spell* pSpell) // Becoming a Shadoweave Tailor
{
	if(!pSpell->u_caster->IsPlayer())
		return true;

	Player*	pPlayer = TO_PLAYER(pSpell->u_caster);
	QuestLogEntry	*pQuest = pPlayer->GetQuestLogForEntry( 10804 );
	Creature*	NetherDrake = pPlayer->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 21648);
	GameObject* FlayerCarcass = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 185155);

	if ( FlayerCarcass == NULL )
	{
		FlayerCarcass = sEAS.SpawnGameobject(pPlayer, 185155, pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 0, 1, 0, 0, 0, 0);
		FlayerCarcass->Despawn(60000);
	}
	if ( NetherDrake == NULL )
		return true;

	if ( NetherDrake->HasActiveAura(38502) )
		return true;

	if( pQuest!=NULL && pQuest->GetMobCount( 0 ) < pQuest->GetQuest()->required_mobcount[0] )
	{
		NetherDrake->CastSpell(NetherDrake, dbcSpell.LookupEntry( 38502 ), true);
		NetherDrake->GetAIInterface()->m_moveFly = true;
		NetherDrake->GetAIInterface()->MoveTo(pPlayer->GetPositionX(), pPlayer->GetPositionY()+2, pPlayer->GetPositionZ(), 0);
		pQuest->SetMobCount( 0, pQuest->GetMobCount( 0 )+1);
		pQuest->SendUpdateAddKill( 0 );
		pQuest->UpdatePlayerFields();
	}
	return true;
}
// Leading the Ancestors Home
bool CompleteAncestorRitual(uint32 i, Spell * pSpell)
{
    if(pSpell == NULL || pSpell->p_caster == NULL || !pSpell->p_caster->IsInWorld())
        return true;

    Player* pPlayer = pSpell->p_caster;
    QuestLogEntry* pQuest = GetQuest( pPlayer, 11610 );
    if( !pQuest )
        return true;

    GameObject* pElderObj;
    pElderObj = pPlayer->GetMapMgr()->GetMapScript()->FindClosestGameObject( 191088, pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ());
    if(pElderObj != NULL && pPlayer->GetDistance2dSq(pElderObj) < 8.0f)
    {
        KillMobForQuest( pPlayer, 11610, 0);
        return true;
    }

    pElderObj = pPlayer->GetMapMgr()->GetMapScript()->FindClosestGameObject( 191089, pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ());
    if(pElderObj != NULL && pPlayer->GetDistance2dSq(pElderObj) < 8.0f)
    {
        KillMobForQuest( pPlayer, 11610, 1);
        return true;
    }

    pElderObj = pPlayer->GetMapMgr()->GetMapScript()->FindClosestGameObject( 191090, pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ());
    if(pElderObj != NULL && pPlayer->GetDistance2dSq(pElderObj) < 8.0f)
    {
        KillMobForQuest( pPlayer, 11610, 2);
        return true;
    }

    return true;
}
void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recvData*/)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_BATTLEGROUND_PLAYER_POSITIONS Message");

    Battleground* bg = _player->GetBattleground();
    if (!bg)                                                 // can't be received if player not in battleground
        return;

    switch (bg->GetTypeID(true))
    {
        case BATTLEGROUND_WS:
        {
            uint32 count1 = 0;                                  //always constant zero?
            uint32 count2 = 0;                                  //count of next fields

            Player* aplayer = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetFlagPickerGUID(BG_TEAM_ALLIANCE));
            if (aplayer)
                ++count1;

            Player* hplayer = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetFlagPickerGUID(BG_TEAM_HORDE));
            if (hplayer)
                ++count2;

            WorldPacket data(SMSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4+16*count1+16*count2));
            data << count1;                                     // alliance flag holders count
            data << count2;                                     // horde flag holders count
            if (aplayer)
            {
                data << uint64(aplayer->GetGUID());
                data << float(aplayer->GetPositionX());
                data << float(aplayer->GetPositionY());
            }
            if (hplayer)
            {
                data << uint64(hplayer->GetGUID());
                data << float(hplayer->GetPositionX());
                data << float(hplayer->GetPositionY());
            }

            SendPacket(&data);
            break;
        }
        case BATTLEGROUND_EY:
        //TODO : fix me!
        break;
        case BATTLEGROUND_AB:
        case BATTLEGROUND_AV:
        {
            WorldPacket data(SMSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4));
            data << uint32(0);
            data << uint32(0);
            SendPacket(&data);
            break;
        }
    default:
        //maybe it is sent also in arena - do nothing
        break;
    }
}
void WorldSession::HandleBattleGroundPlayerPositionsOpcode(WorldPacket & /*recv_data*/)
{
    // empty opcode
    DEBUG_LOG("WORLD: Received opcode MSG_BATTLEGROUND_PLAYER_POSITIONS");

    BattleGround* bg = _player->GetBattleGround();
    if (!bg)                                                // can't be received if player not in battleground
        { return; }

    switch (bg->GetTypeID())
    {
        case BATTLEGROUND_WS:
        {
            uint32 flagCarrierCount = 0;

            Player* flagCarrierAlliance = sObjectMgr.GetPlayer(((BattleGroundWS*)bg)->GetAllianceFlagCarrierGuid());
            if (flagCarrierAlliance)
                { ++flagCarrierCount; }

            Player* flagCarrierHorde = sObjectMgr.GetPlayer(((BattleGroundWS*)bg)->GetHordeFlagCarrierGuid());
            if (flagCarrierHorde)
                { ++flagCarrierCount; }

            WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * flagCarrierCount); // FIXME wrong format
            data << uint32(0);
            data << uint32(flagCarrierCount);

            if (flagCarrierAlliance)
            {
                data << flagCarrierAlliance->GetObjectGuid();
                data << float(flagCarrierAlliance->GetPositionX());
                data << float(flagCarrierAlliance->GetPositionY());
            }
            if (flagCarrierHorde)
            {
                data << flagCarrierHorde->GetObjectGuid();
                data << float(flagCarrierHorde->GetPositionX());
                data << float(flagCarrierHorde->GetPositionY());
            }

            SendPacket(&data);
            break;
        }
        case BATTLEGROUND_AB:
        case BATTLEGROUND_AV:
        {
            // for other BG types - send default
            WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4);
            data << uint32(0);
            data << uint32(0);
            SendPacket(&data);
            break;
        }
        default:
            // maybe it is sent also in arena - do nothing
            break;
    }
}
void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recv_data*/)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message");

    Battleground* bg = _player->GetBattleground();
    if (!bg)                                                 // can't be received if player not in battleground
        return;

    uint32 count = 0;
    Player* aplr = NULL;
    Player* hplr = NULL;

    if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_ALLIANCE))
    {
        aplr = ObjectAccessor::FindPlayer(guid);
        if (aplr)
            ++count;
    }

    if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_HORDE))
    {
        hplr = ObjectAccessor::FindPlayer(guid);
        if (hplr)
            ++count;
    }

    WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * count);
    data << 0;
    data << count;
    if (aplr)
    {
		if (aplr->SendRealNameQuery())
            data << uint64(aplr->GetGUID() + LIMIT_UINT32);
        else
            data << uint64(aplr->GetGUID());

        data << float(aplr->GetPositionX());
        data << float(aplr->GetPositionY());
    }

    if (hplr)
    {
		if (hplr->SendRealNameQuery())
            data << uint64(hplr->GetGUID() + LIMIT_UINT32);
        else
            data << uint64(hplr->GetGUID());

        data << float(hplr->GetPositionX());
        data << float(hplr->GetPositionY());
    }

    SendPacket(&data);
}
void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recvData*/)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message");

    Battleground* bg = _player->GetBattleground();
    if (!bg)                                                 // can't be received if player not in battleground
        return;

    uint32 flagCarrierCount = 0;
    Player* allianceFlagCarrier = NULL;
    Player* hordeFlagCarrier = NULL;

    if (uint64 guid = bg->GetFlagPickerGUID(TEAM_ALLIANCE))
    {
        allianceFlagCarrier = ObjectAccessor::FindPlayer(guid);
        if (allianceFlagCarrier)
            ++flagCarrierCount;
    }

    if (uint64 guid = bg->GetFlagPickerGUID(TEAM_HORDE))
    {
        hordeFlagCarrier = ObjectAccessor::FindPlayer(guid);
        if (hordeFlagCarrier)
            ++flagCarrierCount;
    }

    WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * flagCarrierCount);
    // Used to send several player positions (found used in AV)
    data << 0;  // CGBattlefieldInfo__m_numPlayerPositions
    /*
    for (CGBattlefieldInfo__m_numPlayerPositions)
        data << guid << posx << posy;
    */
    data << flagCarrierCount;
    if (allianceFlagCarrier)
    {
        data << uint64(allianceFlagCarrier->GetGUID());
        data << float(allianceFlagCarrier->GetPositionX());
        data << float(allianceFlagCarrier->GetPositionY());
    }

    if (hordeFlagCarrier)
    {
        data << uint64(hordeFlagCarrier->GetGUID());
        data << float(hordeFlagCarrier->GetPositionX());
        data << float(hordeFlagCarrier->GetPositionY());
    }

    SendPacket(&data);
}
Example #7
0
        void StartDefense()
        {
            Player* player = GetNearestPlayer();

            if (player == nullptr)
                return;

            //Don't do anything with horde players
            if (player->IsTeamHorde())
                return;

            float player_x = player->GetPositionX();
            float player_y = player->GetPositionY();
            float player_z = player->GetPositionZ();

            //hardcoded values...
            // the guards should cast the spell if someone is behind them...
            if (player_x < 5891.88f && player_x >5858.89f && player_y < 594.99f && player_y >565.51f && player_z > 635.0f)
            {
                _unit->SetTargetGUID(player->GetGUID());
                _unit->EventCastSpell(player, dbcSpell.LookupEntry(54029));
            }
            else
            {
                _unit->SetTargetGUID(0); //Reset target... ugly
            }
        }
Example #8
0
    // add go, temp only
    static bool HandleGameObjectAddTempCommand(ChatHandler* handler, const char* args)
    {
        if (!*args)
            return false;
        char* charID = strtok((char*)args, " ");
        if (!charID)
            return false;

        Player *chr = handler->GetSession()->GetPlayer();

        char* spawntime = strtok(NULL, " ");
        uint32 spawntm = 300;

        if (spawntime)
            spawntm = atoi((char*)spawntime);

        float x = chr->GetPositionX();
        float y = chr->GetPositionY();
        float z = chr->GetPositionZ();
        float ang = chr->GetOrientation();

        float rot2 = sin(ang/2);
        float rot3 = cos(ang/2);

        uint32 id = atoi(charID);

        chr->SummonGameObject(id, x, y, z, ang, 0, 0, rot2, rot3, spawntm);

        return true;
    }
Example #9
0
    // add go, temp only
    static bool HandleGameObjectAddTempCommand(ChatHandler* handler, char const* args)
    {
        if (!*args)
            return false;

        char* id = strtok((char*)args, " ");
        if (!id)
            return false;

        Player* player = handler->GetSession()->GetPlayer();

        char* spawntime = strtok(NULL, " ");
        uint32 spawntm = 300;

        if (spawntime)
            spawntm = atoi((char*)spawntime);

        float x = player->GetPositionX();
        float y = player->GetPositionY();
        float z = player->GetPositionZ();
        float ang = player->GetOrientation();

        float rot2 = std::sin(ang/2);
        float rot3 = std::cos(ang/2);

        uint32 objectId = atoi(id);

        player->SummonGameObject(objectId, x, y, z, ang, 0, 0, rot2, rot3, spawntm);

        return true;
    }
Example #10
0
        void StartDefense()
        {
            Player* player = GetNearestPlayer();

            if (player == nullptr)
                return;

            //Don't do anything with alliance players
            if (player->IsTeamAlliance())
                return;

            float player_x = player->GetPositionX();
            float player_y = player->GetPositionY();
            float player_z = player->GetPositionZ();

            //hardcoded values...
            // the guards should cast the spell if someone is behind them...
            if (player_x < 5761.9f && player_x >5738.68f && player_y < 732.12f && player_y >712.09f && player_z > 635.0f)
            {
                _unit->SetTargetGUID(player->GetGUID());
                _unit->EventCastSpell(player, dbcSpell.LookupEntry(54028));
            }
            else
            {
                _unit->SetTargetGUID(0); //Reset target... ugly
            }
        }
Example #11
0
bool ChatHandler::HandleGonameCommand(const char* args)
{
    WorldPacket data;

    if(!*args)
        return false;

    Player *chr = objmgr.GetPlayer(args);
    if (chr)
    {
        if(chr->IsBeingTeleported()==true)
        {
            PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
            return true;
        }

        PSendSysMessage(LANG_APPEARING_AT, chr->GetName());

        char buf0[256];
        sprintf((char*)buf0,LANG_APPEARING_TO, m_session->GetPlayer()->GetName());
        FillSystemMessageData(&data, m_session, buf0);

        chr->GetSession()->SendPacket(&data);

        m_session->GetPlayer()->TeleportTo(chr->GetMapId(), chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(),0.0f);
    }
    else
        PSendSysMessage(LANG_NO_PLAYER, args);

    return true;
}
bool PlantingSeaforiumDepthCharge(uint32 i, Spell * pSpell)
{
    if(pSpell == NULL || pSpell->p_caster == NULL || !pSpell->p_caster->IsInWorld())
        return true;

    
    Player* pPlayer = pSpell->p_caster;
    QuestLogEntry* pQuest = GetQuest( pPlayer, 11608);
    if( !pQuest )
        return true;

    GameObject* pSinkhole = pPlayer->GetMapMgr()->GetMapScript()->FindClosestGameObject( 300171, pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ());
    if( pSinkhole == NULL )
        return true;

    pPlayer->GetMapMgr()->GetMapScript()->SpawnCreature( 25401, pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), pPlayer->GetOrientation());
    
    float posX = pSinkhole->GetPositionX();
    if(posX == 2657.13f)
        KillMobForQuest( pPlayer, 11608, 0);

    if(posX == 2716.02f)
        KillMobForQuest( pPlayer, 11608, 1);

    if(posX == 2877.96f)
        KillMobForQuest( pPlayer, 11608, 2);

    if(posX == 2962.16f)
        KillMobForQuest( pPlayer, 11608, 3);

    return true;
}
Example #13
0
void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv_data*/ )
{
    // empty opcode
    sLog.outDebug("WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message");

    BattleGround *bg = _player->GetBattleGround();
    if(!bg)                                                 // can't be received if player not in battleground
        return;

    if(bg->GetTypeID() == BATTLEGROUND_WS)
    {
        uint32 count1 = 0;
        uint32 count2 = 0;

        Player *ap = objmgr.GetPlayer(((BattleGroundWS*)bg)->GetAllianceFlagPickerGUID());
        if(ap) ++count2;

        Player *hp = objmgr.GetPlayer(((BattleGroundWS*)bg)->GetHordeFlagPickerGUID());
        if(hp) ++count2;

        WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4+16*count1+16*count2));
        data << count1;                                     // alliance flag holders count
        /*for(uint8 i = 0; i < count1; i++)
        {
            data << uint64(0);                              // guid
            data << (float)0;                               // x
            data << (float)0;                               // y
        }*/
        data << count2;                                     // horde flag holders count
        if(ap)
        {
            data << (uint64)ap->GetGUID();
            data << (float)ap->GetPositionX();
            data << (float)ap->GetPositionY();
        }
        if(hp)
        {
            data << (uint64)hp->GetGUID();
            data << (float)hp->GetPositionX();
            data << (float)hp->GetPositionY();
        }

        SendPacket(&data);
    }
}
Example #14
0
    /**
    * Add a waypoint to a creature.
    *
    * The user can either select an npc or provide its GUID.
    *
    * The user can even select a visual waypoint - then the new waypoint
    * is placed *after* the selected one - this makes insertion of new
    * waypoints possible.
    *
    * eg:
    * .wp add 12345
    * -> adds a waypoint to the npc with the GUID 12345
    *
    * .wp add
    * -> adds a waypoint to the currently selected creature
    *
    *
    * @param args if the user did not provide a GUID, it is NULL
    *
    * @return true - command did succeed, false - something went wrong
    */
    static bool HandleWpAddCommand(ChatHandler* handler, const char* args)
    {
        // optional
        char* path_number = NULL;
        uint32 pathid = 0;

        if (*args)
            path_number = strtok((char*)args, " ");

        uint32 point = 0;
        Creature* target = handler->getSelectedCreature();

        if (!path_number)
        {
            if (target)
                pathid = target->GetWaypointPath();
            else
            {
                QueryResult result = WorldDatabase.Query("SELECT MAX(id) FROM waypoint_data");
                uint32 maxpathid = result->Fetch()->GetInt32();
                pathid = maxpathid+1;
                handler->PSendSysMessage("%s%s|r", "|cff00ff00", "New path started.");
            }
        }
        else
            pathid = atoi(path_number);

        // path_id -> ID of the Path
        // point   -> number of the waypoint (if not 0)

        if (!pathid)
        {
            handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Current creature haven't loaded path.");
            return true;
        }

        QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'", pathid);

        if (result)
            point = (*result)[0].GetUInt32();

        Player* player = handler->GetSession()->GetPlayer();
        //Map* map = player->GetMap();

        PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_DATA);

        stmt->setUInt32(0, pathid);
        stmt->setUInt32(1, point + 1);
        stmt->setFloat(2, player->GetPositionX());
        stmt->setFloat(3, player->GetPositionY());
        stmt->setFloat(4, player->GetPositionZ());

        WorldDatabase.Execute(stmt);

        handler->PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point+1, "|r|cff00ff00 created. ");
        return true;
    }                                                           // HandleWpAddCommand
Example #15
0
    static bool HandleWPGPSCommand(ChatHandler* handler, const char* /*args*/)
    {
        Player* player = handler->GetSession()->GetPlayer();

        sLog->outSQLDev("(@PATH, XX, %.3f, %.3f, %.5f, 0, 0, 0, 100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());

        handler->PSendSysMessage("Waypoint SQL written to SQL Developer log");
        return true;
    }
Example #16
0
    static bool HandleGameObjectNearCommand(ChatHandler* handler, char const* args)
    {
        float distance = (!*args) ? 10.0f : (float)(atof(args));
        uint32 count = 0;

        Player* player = handler->GetSession()->GetPlayer();

        PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAMEOBJECT_NEAREST);
        stmt->setFloat(0, player->GetPositionX());
        stmt->setFloat(1, player->GetPositionY());
        stmt->setFloat(2, player->GetPositionZ());
        stmt->setUInt32(3, player->GetMapId());
        stmt->setFloat(4, player->GetPositionX());
        stmt->setFloat(5, player->GetPositionY());
        stmt->setFloat(6, player->GetPositionZ());
        stmt->setFloat(7, distance * distance);
        PreparedQueryResult result = WorldDatabase.Query(stmt);

        if (result)
        {
            do
            {
                Field* fields = result->Fetch();
                uint32 guid = fields[0].GetUInt32();
                uint32 entry = fields[1].GetUInt32();
                float x = fields[2].GetFloat();
                float y = fields[3].GetFloat();
                float z = fields[4].GetFloat();
                uint16 mapId = fields[5].GetUInt16();

                GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);

                if (!gameObjectInfo)
                    continue;

                handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gameObjectInfo->name.c_str(), x, y, z, mapId);

                ++count;
            } while (result->NextRow());
        }

        handler->PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE, distance, count);
        return true;
    }
bool ChatHandler::HandleWPMoveHereCommand(const char* args, WorldSession *m_session)
{
    uint64 guid = m_session->GetPlayer()->GetSelection();
    if (guid == 0)
    {
        SystemMessage(m_session, "No selection.");
        return true;
    }

    if(GET_TYPE_FROM_GUID(guid) != HIGHGUID_TYPE_WAYPOINT)
    {
        SystemMessage(m_session, "You should select a Waypoint.");
        return true;
    }

    Player* pPlayer = m_session->GetPlayer();
    AIInterface* ai = pPlayer->waypointunit;
    if(!ai || !ai->GetUnit())
    {
        SystemMessage(m_session, "Invalid Creature, please select another one.");
        return true;
    }
    std::stringstream ss;

    uint32 wpid = GUID_LOPART(guid);
    if(wpid)
    {
        WayPoint* wp = ai->getWayPoint(wpid);
        if(wp)
        {
            wp->x = pPlayer->GetPositionX();
            wp->y = pPlayer->GetPositionY();
            wp->z = pPlayer->GetPositionZ();
            wp->orientation = pPlayer->GetOrientation();

            //save wp
            ai->saveWayPoints();
        }
        //Refresh client
        if(ai->WayPointsShowing() == true)
        {
            ai->hideWayPoints(pPlayer);
            ai->showWayPoints(pPlayer,ai->WayPointsShowingBackwards());
        }

        ss << "Waypoint " << wpid << " has been moved.";
        SystemMessage(m_session, ss.str().c_str());
    }
    else
    {
        SystemMessage(m_session, "Invalid Waypoint.");
        return true;
    }
    return true;
}
Example #18
0
    static bool HandleMmapLocCommand(ChatHandler* handler, const char* /*args*/)
    {
        handler->PSendSysMessage("mmap tileloc:");

// grid tile location
        Player* player = handler->GetSession()->GetPlayer();

        int32 gx = 32 - player->GetPositionX() / SIZE_OF_GRIDS;
        int32 gy = 32 - player->GetPositionY() / SIZE_OF_GRIDS;

        handler->PSendSysMessage("%03u%02i%02i.mmtile", player->GetMapId(), gy, gx);
        handler->PSendSysMessage("gridloc [%i,%i]", gx, gy);

// calculate navmesh tile location
        const dtNavMesh* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(player->GetMapId());
        const dtNavMeshQuery* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(player->GetMapId(), player->GetInstanceId());
        if (!navmesh || !navmeshquery)
        {
            handler->PSendSysMessage("NavMesh not loaded for current map.");
            return true;
        }

        const float* min = navmesh->getParams()->orig;

        float x, y, z;
        player->GetPosition(x, y, z);
        float location[VERTEX_SIZE] = {y, z, x};
        float extents[VERTEX_SIZE] = {2.f,4.f,2.f};

        int32 tilex = int32((y - min[0]) / SIZE_OF_GRIDS);
        int32 tiley = int32((x - min[2]) / SIZE_OF_GRIDS);

        handler->PSendSysMessage("Calc [%02i,%02i]", tilex, tiley);

// navmesh poly -> navmesh tile location
        dtQueryFilter filter = dtQueryFilter();
        dtPolyRef polyRef = INVALID_POLYREF;
        navmeshquery->findNearestPoly(location, extents, &filter, &polyRef, NULL);

        if (polyRef == INVALID_POLYREF)
            handler->PSendSysMessage("Dt [??,??] (invalid poly, probably no tile loaded)");
        else
        {
            const dtMeshTile* tile;
            const dtPoly* poly;
            navmesh->getTileAndPolyByRef(polyRef, &tile, &poly);
            if (tile)
                handler->PSendSysMessage("Dt [%02i,%02i]", tile->header->x, tile->header->y);
            else
                handler->PSendSysMessage("Dt [??,??] (no tile loaded)");
        }

        return true;
    }
Example #19
0
bool ChatHandler::HandleNpcComeCommand(const char* args, WorldSession* m_session)
{
	// moves npc to players location
	Player* plr = m_session->GetPlayer();
	Creature* crt = getSelectedCreature(m_session, true);
	if(!crt) return true;

	crt->GetAIInterface()->MoveTo(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetOrientation());
	sGMLog.writefromsession(m_session, "used npc come command on %s, sqlid %u", crt->GetCreatureInfo()->Name, crt->GetSQL_id());
	return true;
}
Example #20
0
void BattlegroundDS::PostUpdateImpl(uint32 diff)
{
        if (GetStartTime() >= 75*IN_MILLISECONDS)
        {
            for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end();itr++)
            {
                Player* player = ObjectAccessor::FindPlayer(itr->first);
                if (player && player->isAlive() && player->GetPositionX() < 1260 && player->GetPositionY() >755 && player->GetPositionY() < 775 && player->GetPositionZ() > 13)
                {
                    KnockBackPlayer(player, 6.15f, 50.00f, 5.00f);
                    player->RemoveAurasDueToSpell(48018);
                }
                if (player && player->isAlive() && player->GetPositionX() > 1330 && player->GetPositionY() >805 && player->GetPositionY() < 825 && player->GetPositionZ() > 13)
                {
                    KnockBackPlayer(player, 3.10f, 50.00f, 5.00f);
                    player->RemoveAurasDueToSpell(48018);
                }
            }
        }

        if (getWaterFallTimer() < diff)
        {
            if (isWaterFallActive())
            {
                setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX));
                for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
                    SpawnBGObject(i, getWaterFallTimer());
                setWaterFallActive(false);
            }
            else
            {
                setWaterFallTimer(BG_DS_WATERFALL_DURATION);
                for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
                    SpawnBGObject(i, RESPAWN_IMMEDIATELY);
                setWaterFallActive(true);
            }
        }
        else
            setWaterFallTimer(getWaterFallTimer() - diff);
}
Example #21
0
    static bool HandleGameObjectNearCommand(ChatHandler* handler, const char* args)
    {
        float distance = (!*args) ? 10.0f : (float)(atof(args));
        uint32 count = 0;

        Player* pl = handler->GetSession()->GetPlayer();
        QueryResult result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, "
            "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ "
            "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_",
            pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),
            pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), distance*distance);

        if (result)
        {
            do
            {
                Field *fields = result->Fetch();
                uint32 guid = fields[0].GetUInt32();
                uint32 entry = fields[1].GetUInt32();
                float x = fields[2].GetFloat();
                float y = fields[3].GetFloat();
                float z = fields[4].GetFloat();
                uint16 mapid = fields[5].GetUInt16();

                GameObjectTemplate const * gInfo = sObjectMgr->GetGameObjectTemplate(entry);

                if (!gInfo)
                    continue;

                handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapid);

                ++count;
            } while (result->NextRow());
        }

        handler->PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE, distance, count);
        return true;
    }
Example #22
0
 void TeleportAllPlayersBack()
 {
     Map::PlayerList const &playerList = me->GetMap()->GetPlayers();
     Position const& homePos = me->GetHomePosition();
     for (Map::PlayerList::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
     {
         Player* player = itr->GetSource();
         if (player->IsInDist(&homePos, 50.0f) && player->GetPositionZ() <= DEMON_REALM_Z + 10.f)
         {
             player->RemoveAura(AURA_SPECTRAL_REALM);
             player->TeleportTo(me->GetMap()->GetId(), player->GetPositionX(),
                 player->GetPositionY(), DRAGON_REALM_Z + 5, player->GetOrientation());
         }
     }
 }
Example #23
0
bool ChatHandler::HandleAddMoveCommand(const char* args)
{
    if(!*args)
        return false;

    char* guid_str = strtok((char*)args, " ");
    char* wait_str = strtok((char*)NULL, " ");

    uint32 lowguid = atoi((char*)guid_str);

    Creature* pCreature = NULL;

    if(lowguid)
        pCreature = ObjectAccessor::Instance().GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT));

    if(!pCreature)
    {
        PSendSysMessage("Creature (GUID: %u) not found", lowguid);
        return true;
    }

    int wait = wait_str ? atoi(wait_str) : 0;

    if(wait < 0)
        wait = 0;

    uint32 point;

    QueryResult *result = sDatabase.PQuery( "SELECT MAX(`point`) FROM `creature_movement` WHERE `id` = '%u'",pCreature->GetGUIDLow());
    if( result )
    {
        point = (*result)[0].GetUInt32()+1;

        delete result;
    }
    else
        point = 0;

    Player* player = m_session->GetPlayer();

    sDatabase.PExecute("INSERT INTO `creature_movement` (`id`,`point`,`position_x`,`position_y`,`position_z`,`waittime`) VALUES ('%u','%u','%f', '%f', '%f','%u')",
                       pCreature->GetGUIDLow(), point, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), wait);

    SendSysMessage(LANG_WAYPOINT_ADDED);

    return true;
}
Example #24
0
bool ChatHandler::HandleAddSpwCommand(const char* args)
{
    char* charID = strtok((char*)args, " ");
    if (!charID)
        return false;

    uint32 id  = atoi(charID);

    //QueryResult *result = sDatabase.PQuery("SELECT `modelid`,`flags`,`faction`,`level`,`name` FROM `creature_template` WHERE `entry` = '%u'", id);

    //if(result)
    //{
    //Field *fields = result->Fetch();

    //WorldPacket data;

    Player *chr = m_session->GetPlayer();
    float x = chr->GetPositionX();
    float y = chr->GetPositionY();
    float z = chr->GetPositionZ();
    float o = chr->GetOrientation();

    Creature* pCreature = new Creature;
    if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), chr->GetMapId(), x, y, z, o, id))
    {
        delete pCreature;
        return false;
    }

    pCreature->AIM_Initialize();
    //pCreature->SetUInt32Value(UNIT_FIELD_HEALTH , 1); // temp set on 1 HP needs to be MAX HP (strange error)

    sLog.outDebug(LANG_ADD_OBJ);

    MapManager::Instance().GetMap(pCreature->GetMapId())->Add(pCreature);
    pCreature->SaveToDB();

    //delete result;
    return true;
    //}
    //else
    //    delete result;
    //return false;
}
    void MindControlGhost()
    {
        /************************************************************************/
        /** NOTE FOR FUTURE DEVELOPER: PROPERLY IMPLEMENT THE GHOST PORTION *****/
        /**  ONLY AFTER MaNGOS FULLY IMPLEMENTS MIND CONTROL ABILITIES      *****/
        /**   THE CURRENT CODE IN THIS FUNCTION IS ONLY THE BEGINNING OF    *****/
        /**    WHAT IS FULLY NECESSARY FOR GOREFIEND TO BE 100% COMPLETE    *****/
        /************************************************************************/

        Player* pGhost = NULL;
        if (m_ghostGuid)
            pGhost = m_creature->GetMap()->GetPlayer(m_ghostGuid);

        if (pGhost && pGhost->isAlive() && pGhost->HasAura(SPELL_SHADOW_OF_DEATH, EFFECT_INDEX_0))
        {
            /*float x,y,z;
            pGhost->GetPosition(x,y,z);
            Creature* control = m_creature->SummonCreature(CREATURE_GHOST, x, y, z, 0, TEMPSUMMON_TIMED_DESAWN, 30000);
            if (control)
            {
                ((Player*)pGhost)->Possess(control);
                pGhost->DealDamage(pGhost, pGhost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL,
            false);
            }*/
            for(uint8 i = 0; i < 4; ++i)
            {
                float fX = CalculateRandomLocation(pGhost->GetPositionX(), 10);
                float fY = CalculateRandomLocation(pGhost->GetPositionY(), 10);

                if (Creature* pConstruct = m_creature->SummonCreature(NPC_SHADOWY_CONSTRUCT, fX, fY, pGhost->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000))
                {
                    pConstruct->CastSpell(pConstruct, SPELL_PASSIVE_SHADOWFORM, true);

                    SetThreatList(pConstruct);               // Use same function as Doom Blossom to set Threat List.
                    if (mob_shadowy_constructAI* pConstructAI = dynamic_cast<mob_shadowy_constructAI*>(pConstruct->AI()))
                        pConstructAI->m_ghostGuid = m_ghostGuid;

                    Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1);
                    pConstruct->GetMotionMaster()->MoveChase(pTarget ? pTarget : m_creature->getVictim());
                }
            }
        }
    }
Example #26
0
 void PullAll()
 {
     float fx, fy, fz;
     m_creature->GetPosition(fx, fy, fz);
     fx += cos(m_creature->GetOrientation())*5;
     fy += sin(m_creature->GetOrientation())*5;
     m_creature->UpdateGroundPositionZ(fx, fy, fz, 20.0f);
     
     Map* pMap = m_creature->GetMap();
     if (!pMap)
         return;
     Player *plr = NULL;
     WorldPacket data(SMSG_MONSTER_MOVE);
     Map::PlayerList const &lPlayers = pMap->GetPlayers();
     for(Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
     {
         if (!itr->getSource()->isAlive() || !itr->getSource()->IsInWorld())
             continue;
         plr = itr->getSource();
         
         float distance = plr->GetDistance(fx, fy, fz);
         uint32 traveltime = uint32(distance/(84.0f*0.001f));
         float velocity = (float((0.05f)*8)/float(pow(traveltime/1000.0f, 2.0f)))*10.0f;
         
         data.Initialize(SMSG_MONSTER_MOVE);
         data << plr->GetPackGUID();
         data << uint8(0);
         data << plr->GetPositionX() << plr->GetPositionY() << plr->GetPositionZ();
         data << uint32(getMSTime());
         data << uint8(SPLINETYPE_NORMAL);
         data << uint32(SPLINEFLAG_TRAJECTORY | SPLINEFLAG_WALKMODE | SPLINEFLAG_KNOCKBACK);
         data << uint32(traveltime);
         data << float(velocity);
         data << uint32(0);
         data << uint32(1);
         data << fx << fy << fz;
         plr->SendMessageToSet(&data, true);
         
         m_creature->CastSpell(plr, SPELL_GRIP, true);
     }
 }
Example #27
0
    static bool HandleNpcBotJumpCommand(ChatHandler* handler, const char* /*args*/)
    {
        Player* player = handler->GetSession()->GetPlayer();
        ObjectGuid sel = player->GetTarget();
        if (!sel)
            return false;

        Creature* bot = ObjectAccessor::GetObjectInWorld(sel, (Creature*)NULL);
        if (!bot/* || (!bot->GetIAmABot() && !bot->GetIAmABotsPet())*/)
            return false;

        float speedZ = 10.0f;
        float dist = bot->GetExactDist2d(player->GetPositionX(), player->GetPositionY());
        float speedXY = dist;

        bot->StopMoving();
        bot->GetMotionMaster()->Clear();
        bot->GetMotionMaster()->MoveJump(*player, speedXY, speedZ);

        return true;
    }
Example #28
0
    static bool HandleTeleAddCommand(ChatHandler* handler, const char* args)
    {
        if (!*args)
            return false;

        Player* player = handler->GetSession()->GetPlayer();
        if (!player)
            return false;

        std::string name = args;

        if (sObjectMgr->GetGameTele(name))
        {
            handler->SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST);
            handler->SetSentErrorMessage(true);
            return false;
        }

        GameTele tele;
        tele.position_x  = player->GetPositionX();
        tele.position_y  = player->GetPositionY();
        tele.position_z  = player->GetPositionZ();
        tele.orientation = player->GetOrientation();
        tele.mapId       = player->GetMapId();
        tele.name        = name;

        if (sObjectMgr->AddGameTele(tele))
        {
            handler->SendSysMessage(LANG_COMMAND_TP_ADDED);
        }
        else
        {
            handler->SendSysMessage(LANG_COMMAND_TP_ADDEDERR);
            handler->SetSentErrorMessage(true);
            return false;
        }

        return true;
    }
Example #29
0
    // add go, temp only
    static bool HandleGameObjectAddTempCommand(ChatHandler* handler, char const* args)
    {
        if (!*args)
            return false;

        char* id = strtok((char*)args, " ");
        if (!id)
            return false;

        Player* player = handler->GetSession()->GetPlayer();

        char* spawntime = strtok(NULL, " ");
        uint32 spawntm = 300;

        if (spawntime)
            spawntm = atoi((char*)spawntime);

        float x = player->GetPositionX();
        float y = player->GetPositionY();
        float z = player->GetPositionZ();
        float ang = player->GetOrientation();

        float rot2 = std::sin(ang/2);
        float rot3 = std::cos(ang/2);

        uint32 objectId = atoi(id);

        if (!sObjectMgr->GetGameObjectTemplate(objectId))
        {
            handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, objectId);
            handler->SetSentErrorMessage(true);
            return false;
        }

        player->SummonGameObject(objectId, x, y, z, ang, 0, 0, rot2, rot3, spawntm);

        return true;
    }
Example #30
0
bool SummonAction::Teleport()
{
    Player* master = GetMaster();
    if (!master->IsBeingTeleported())
    {
        float followAngle = GetFollowAngle();
        for (float angle = followAngle - M_PI; angle <= followAngle + M_PI; angle += M_PI / 4)
        {
            uint32 mapId = master->GetMapId();
            float x = master->GetPositionX() + cos(angle) * sPlayerbotAIConfig.followDistance;
            float y = master->GetPositionY()+ sin(angle) * sPlayerbotAIConfig.followDistance;
            float z = master->GetPositionZ();
            if (master->IsWithinLOS(x, y, z))
            {
                bot->GetMotionMaster()->Clear();
                bot->TeleportTo(mapId, x, y, z, 0);
                return true;
            }
        }
    }

    return true;
}