コード例 #1
0
	void AIUpdate()
	{
		PlayerPointer CurrentPlayer = objmgr.GetPlayer( mPlayerGuid );
		if ( CurrentPlayer == NULLPLR )
		{
			RemoveAIUpdateEvent();
			mPlayerGuid = 0;
			return;
		};

		if ( CurrentPlayer->GetMapId() == 530 ) 		// Shattrath
		{
			CurrentPlayer->SafeTeleport( 530, 0, -1742.640869f, 5454.712402f, -7.928009f, 4.606363f );
		}
		else if ( CurrentPlayer->GetMapId() == 0 ) 		// Elwynn Forest
		{
			CurrentPlayer->SafeTeleport( 0, 0, -9569.150391f, -14.753426f, 68.051422f, 4.874008f );
		}
		else if ( CurrentPlayer->GetMapId() == 1 ) 		// Mulgore
		{
			CurrentPlayer->SafeTeleport( 1, 0, -1326.711914f, 86.301125f, 133.093918f, 3.510725f );
		};

		CurrentPlayer->SetMovement( MOVE_UNROOT, 1 );
		CurrentPlayer->CastSpell( CurrentPlayer, 42867, true ); // 24742
		_gameobject->SetUInt32Value(GAMEOBJECT_FLAGS,0);
		mPlayerGuid = 0;
		RemoveAIUpdateEvent();
	};
コード例 #2
0
	void AIUpdate()
	{
		PlayerPointer plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords( _gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ() );
		if( !plr )
			return;

		if( _gameobject->CalcDistance( _gameobject, plr ) <= 1.5f && plr->GetMapId() == 609)
		{
			plr->SafeTeleport( 609, 4298, 2397.57, -5636.03, 377.05, 0.57 );
		}

		else if( _gameobject->CalcDistance( _gameobject, plr ) <= 1.5f && plr->GetMapId() == 0)
		{
			plr->SafeTeleport( 0, plr->GetInstanceID(), 2395.233154f, -5637.875488f, 377.086884f, 0.520721f);
		}
	}
コード例 #3
0
	void AIUpdate()
	{
		PlayerPointer plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords( _gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ() );
		if( !plr )
			return;

		if( _gameobject->CalcDistance( _gameobject, plr ) <= 1.5f && plr->GetMapId() == 609)
		{
			plr->SafeTeleport( 609, 4298, 2390.18, -5640.28, 420.84, 0.57 );
		}

		else if( _gameobject->CalcDistance( _gameobject, plr ) <= 1.5f && plr->GetMapId() == 0)
		{
			plr->SafeTeleport( 0, plr->GetInstanceID(), 2387.468994f, -5642.544922f, 420.809937f, 0.620461f);
		}
	}
コード例 #4
0
bool ChatHandler::HandleRecallAddCommand(const char* args, WorldSession *m_session)
{
	if(!*args)
		return false;
	
	QueryResult *result = WorldDatabase.Query( "SELECT name FROM recall" );
	if(!result)
		return false;
	do
	{
		Field *fields = result->Fetch();
		const char * locname = fields[0].GetString();
		if (strncmp((char*)args,locname,strlen(locname))==0)
		{
			RedSystemMessage(m_session, "Name in use, please use another name for your location.");
			delete result;
			return true;
		}
	}while (result->NextRow());
	delete result;

	PlayerPointer plr = m_session->GetPlayer();
	std::stringstream ss;
	
	string rc_locname = string(args);

	ss << "INSERT INTO recall (name, mapid, positionX, positionY, positionZ) VALUES ('"
	<< WorldDatabase.EscapeString(rc_locname).c_str() << "' , "
	<< plr->GetMapId() << ", "
	<< plr->GetPositionX() << ", " 
	<< plr->GetPositionY() << ", "
	<< plr->GetPositionZ() << ");";
	WorldDatabase.Execute( ss.str( ).c_str( ) );

	char buf[256]; 
	snprintf((char*)buf, 256, "Added location to DB with MapID: %d, X: %f, Y: %f, Z: %f",
		(unsigned int)plr->GetMapId(), plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ());
	GreenSystemMessage(m_session, buf);
	sGMLog.writefromsession(m_session, "used recall add, added \"%s\" location to database.", rc_locname.c_str());

	return true;
}
コード例 #5
0
    void OnActivate(PlayerPointer pPlayer)
    {
       if (pPlayer->getClass() == 6)
       {
			if(pPlayer->GetMapId() == 609){
				pPlayer->SafeTeleport(609, pPlayer->GetInstanceID(), 2354.496826f, -5661.948730f, 389.454865f, 0.365210f);
			}else{
				pPlayer->SafeTeleport(0, pPlayer->GetInstanceID(), 2354.496826f, -5661.948730f, 389.454865f, 0.365210f);
			};
       }
    }
コード例 #6
0
bool ArathiBasin::HookHandleRepop(PlayerPointer plr)
{
	/* our uber leet ab graveyard handler */
	LocationVector dest( NoBaseGYLocations[plr->m_bgTeam][0], NoBaseGYLocations[plr->m_bgTeam][1], NoBaseGYLocations[plr->m_bgTeam][2], 0.0f );
	float current_distance = 999999.0f;
	float dist;

	for(uint32 i = 0; i < AB_NUM_CONTROL_POINTS; ++i)
	{
		if(m_basesOwnedBy[i] == (int32)plr->m_bgTeam)
		{
			dist = plr->GetPositionV()->Distance2DSq(GraveyardLocations[i][0], GraveyardLocations[i][1]);
			if(dist < current_distance)
			{
				current_distance = dist;
				dest.ChangeCoords(GraveyardLocations[i][0], GraveyardLocations[i][1], GraveyardLocations[i][2]);
			}
		}
	}

	// port us there.
	plr->SafeTeleport(plr->GetMapId(),plr->GetInstanceID(),dest);
	return true;
}
コード例 #7
0
bool ChatHandler::HandleGOSpawn(const char *args, WorldSession *m_session)
{
	std::stringstream sstext;

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

	uint32 EntryID  = atoi(pEntryID);
	
	bool Save = false;
	char* pSave = strtok(NULL, " ");
	if (pSave)
		Save = (atoi(pSave)>0?true:false);

	OUT_DEBUG("Spawning GameObject By Entry '%u'", EntryID);
	sstext << "Spawning GameObject By Entry '" << EntryID << "'" << '\0';
	SystemMessage(m_session, sstext.str().c_str());

	GameObjectPointer go = m_session->GetPlayer()->GetMapMgr()->CreateGameObject(EntryID);
	if(go == NULL)
	{
		sstext << "GameObject Info '" << EntryID << "' Not Found" << '\0';
		SystemMessage(m_session, sstext.str().c_str());
		return true;
	}
	
	PlayerPointer chr = m_session->GetPlayer();
	uint32 mapid = chr->GetMapId();
	float x = chr->GetPositionX();
	float y = chr->GetPositionY();
	float z = chr->GetPositionZ();
	float o = chr->GetOrientation();

	go->SetInstanceID(chr->GetInstanceID());
	go->CreateFromProto(EntryID,mapid,x,y,z,o,0.0f,0.0f,0.0f,0.0f);
	
	go->SetRotation(o);
	go->PushToWorld(m_session->GetPlayer()->GetMapMgr());

	// Create sapwn instance
	GOSpawn * gs = new GOSpawn;
	gs->entry = go->GetEntry();
	gs->facing = go->GetOrientation();
	gs->faction = go->GetUInt32Value(GAMEOBJECT_FACTION);
	gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
	gs->id = objmgr.GenerateGameObjectSpawnID();
	gs->orientation1 = go->GetFloatValue(GAMEOBJECT_ROTATION);
	gs->orientation2 = go->GetFloatValue(GAMEOBJECT_ROTATION_01);
	gs->orientation3 = go->GetFloatValue(GAMEOBJECT_ROTATION_02);
	gs->orientation4 = go->GetFloatValue(GAMEOBJECT_ROTATION_03);
	gs->scale = go->GetFloatValue(OBJECT_FIELD_SCALE_X);
	gs->x = go->GetPositionX();
	gs->y = go->GetPositionY();
	gs->z = go->GetPositionZ();
	gs->state = go->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE);
	//gs->stateNpcLink = 0;

	uint32 cx = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX());
	uint32 cy = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY());

	m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cx,cy)->GOSpawns.push_back(gs);
	go->m_spawn = gs;

	//go->AddToWorld();

	if(Save == true)
	{
		// If we're saving, create template and add index
		go->SaveToDB();
	}
	return true;
}
コード例 #8
0
ファイル: TaxiMgr.cpp プロジェクト: Vanj-crew/HearthStone-Emu
void TaxiPath::SendMoveForTime(PlayerPointer riding, PlayerPointer to, uint32 time)
{
	if (!time)
		return;

	float length;
	uint32 mapid = riding->GetMapId();
	if( mapid == m_map1 )
		length = m_length1;
	else
		length = m_length2;

	float traveled_len = (time/(length * TAXI_TRAVEL_SPEED))*length;
	uint32 len = 0;
	float x = 0,y = 0,z = 0;

	if (!m_pathNodes.size())
		return;

	std::map<uint32, TaxiPathNode*>::iterator itr;
	itr = m_pathNodes.begin();

	float nx;
	float ny;
	float nz;
	bool set = false;
	uint32 nodecounter = 1;

	while (itr != m_pathNodes.end())
	{
		if( itr->second->mapid != mapid )
		{
			itr++;
			nodecounter++;
			continue;
		}

		if(!set)
		{
			nx = itr->second->x;
			ny = itr->second->y;
			nz = itr->second->z;
			set = true;
			continue;
		}

		len = (uint32)sqrt((itr->second->x - nx)*(itr->second->x - nx) +
			(itr->second->y - ny)*(itr->second->y - ny) + 
			(itr->second->z - nz)*(itr->second->z - nz));

		if (len >= traveled_len)
		{
			x = (itr->second->x - nx)*(traveled_len/len) + nx;
			y = (itr->second->y - ny)*(traveled_len/len) + ny;
			z = (itr->second->z - nz)*(traveled_len/len) + nz;
			break;
		}
		else
		{
			traveled_len -= len;
		}

		nx = itr->second->x;
		ny = itr->second->y;
		nz = itr->second->z;
		itr++;
	}

	if (itr == m_pathNodes.end())
		return;

	WorldPacket * data = new WorldPacket(SMSG_MONSTER_MOVE, 2000);
	size_t pos;

	*data << riding->GetNewGUID();
	*data << uint8(0);
	*data << riding->GetPositionX( ) << riding->GetPositionY( ) << riding->GetPositionZ( );
	*data << getMSTime();
	*data << uint8( 0 );
	*data << uint32( MONSTER_MOVE_FLAG_FLY );
	*data << uint32( uint32((length * TAXI_TRAVEL_SPEED) - time));
	*data << uint32( nodecounter );
	pos = data->wpos();
	*data << nx << ny << nz;

	while (itr != m_pathNodes.end())
	{
		TaxiPathNode *pn = itr->second;
		if( pn->mapid != mapid )
			break;

		*data << pn->x << pn->y << pn->z;
		++itr;
		++nodecounter;
	}
	
	*(uint32*)&(data->contents()[pos]) = nodecounter;
	to->delayedPackets.add(data);
/*	if (!time)
		return;

	float traveled_len = (time/(getLength() * TAXI_TRAVEL_SPEED))*getLength();;
	uint32 len = 0, count = 0;
	float x = 0,y = 0,z = 0;

	if (!m_pathNodes.size())
		return;

	std::map<uint32, TaxiPathNode*>::iterator itr;
	itr = m_pathNodes.begin();

	float nx = itr->second->x;
	float ny = itr->second->y;
	float nz = itr->second->z; 
	itr++;

	while (itr != m_pathNodes.end())
	{		
		len = (uint32)sqrt((itr->second->x - nx)*(itr->second->x - nx) +
			(itr->second->y - ny)*(itr->second->y - ny) + 
			(itr->second->z - nz)*(itr->second->z - nz));

		if (len > traveled_len)
		{
			x = (itr->second->x - nx)*(traveled_len/len) + nx;
			y = (itr->second->y - ny)*(traveled_len/len) + ny;
			z = (itr->second->z - nz)*(traveled_len/len) + nz;
			break;
		}
		else
		{
			traveled_len -= len;
		}

		nx = itr->second->x;
		ny = itr->second->y;
		nz = itr->second->z;
		itr++;
		count++;
	}

	if (itr == m_pathNodes.end())
		return;

	WorldPacket * data = new WorldPacket(SMSG_MONSTER_MOVE, 2000);

	*data << riding->GetNewGUID();
	*data << riding->GetPositionX( ) << riding->GetPositionY( ) << riding->GetPositionZ( );
	*data << getMSTime();
	*data << uint8( 0 );
	*data << uint32( MONSTER_MOVE_FLAG_FLY );
	*data << uint32( uint32((getLength() * TAXI_TRAVEL_SPEED) - time));
	*data << uint32( GetNodeCount() - count );
	*data << nx << ny << nz;
	while (itr != m_pathNodes.end())
	{
		TaxiPathNode *pn = itr->second;
		*data << pn->x << pn->y << pn->z;
		itr++;
	}
	//to->GetSession()->SendPacket(&data);
	to->delayedPackets.add(data);*/
}
コード例 #9
0
void StatDumper::DumpStats()
{
    if( Filename[0] == NULL )
        return;
    FILE* f = fopen( Filename, "w" );
    if( !f )
        return;

	Log.Debug( "StatDumper", "Writing %s", Filename );

    // Dump Header
    fprintf(f, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    fprintf(f, "<?xml-stylesheet type=\"text/xsl\" href=\"server_stats.xsl\"?>\n");
    fprintf(f, "<serverpage>\n");
    fprintf(f, "  <status>\n");

	uint32 races[RACE_DRAENEI+1];
	uint32 classes[DRUID+1];
	memset(&races[0], 0, sizeof(uint32)*(RACE_DRAENEI+1));
	memset(&classes[0], 0, sizeof(uint32)*(RACE_DRAENEI+1));
    std::deque<PlayerPointer> gms;
    {
        // Dump server information.
#ifdef WIN32
		// fprintf(f, "    <platform>%s r%u/%s-Win-%s </platform>\n", sWorld.GetCoreName(), BUILD_REVISION, CONFIG, ARCH); GetCoreName function is not implemented yet on core
		fprintf(f, "    <platform>%s r%u/%s-Win-%s </platform>\n", "WowEmu", BUILD_REVISION, CONFIG, ARCH);
#else
		// fprintf(f, "    <platform>%s r%u/%s-%s </platform>\n", sWorld.GetCoreName(), BUILD_REVISION, PLATFORM_TEXT, ARCH); GetCoreName function is not implemented yet on core
		fprintf(f, "    <platform>%s r%u/%s-%s </platform>\n", "WowEmu", BUILD_REVISION, PLATFORM_TEXT, ARCH);
#endif

        char uptime[80];
        GenerateUptimeString(uptime);
        float AvgLat;
        uint32 GMCount;
        int gm = 0;
        int count = 0;
        int avg = 0;
        // lock players reader
        objmgr._playerslock.AcquireReadLock();

        HM_NAMESPACE::hash_map<uint32, PlayerPointer>::const_iterator itr;
        for (itr = objmgr._players.begin(); itr != objmgr._players.end(); itr++)
        {
            if(itr->second->GetSession() && itr->second->IsInWorld())
            {
                count++;
                avg += itr->second->GetSession()->GetLatency();
                if(itr->second->GetSession()->GetPermissionCount())
                {
                    gm++;
                    gms.push_back(itr->second);
                }
				classes[itr->second->getClass()]++;
				races[itr->second->getRace()]++;
            }
        }
        objmgr._playerslock.ReleaseReadLock();

        AvgLat = count ? (float)((float)avg / (float)count) : 0;
        GMCount = gm;

        fprintf(f, "    <uptime>%s</uptime>\n", uptime);
        fprintf(f, "    <oplayers>%u</oplayers>\n", (unsigned int)(sWorld.AlliancePlayers + sWorld.HordePlayers));
        fprintf(f, "    <cpu>%2.2f</cpu>\n", GetCPUUsage());
        fprintf(f, "    <qplayers>%u</qplayers>\n", (unsigned int)sWorld.GetQueueCount());
        fprintf(f, "    <ram>%.3f</ram>\n", GetRAMUsage());
        fprintf(f, "    <avglat>%.3f</avglat>\n", AvgLat);
		fprintf(f, "    <threads>%u</threads>\n", (unsigned int)ThreadPool.GetActiveThreadCount());
		fprintf(f, "    <fthreads>%u</fthreads>\n", (unsigned int)ThreadPool.GetFreeThreadCount());
        time_t t = (time_t)UNIXTIME;
        fprintf(f, "    <gmcount>%u</gmcount>\n", (unsigned int)GMCount);
        fprintf(f, "    <lastupdate>%s</lastupdate>\n", asctime(localtime(&t)));
        fprintf(f, "    <alliance>%u</alliance>\n", (unsigned int)sWorld.AlliancePlayers);
        fprintf(f, "    <horde>%u</horde>\n", (unsigned int)sWorld.HordePlayers);
        fprintf(f, "    <acceptedconns>%u</acceptedconns>\n", (unsigned int)sWorld.mAcceptedConnections);
        fprintf(f, "    <peakcount>%u</peakcount>\n", (unsigned int)sWorld.PeakSessionCount);
		fprintf(f, "    <wdbquerysize>%u</wdbquerysize>\n", WorldDatabase.GetQueueSize());
		fprintf(f, "    <cdbquerysize>%u</cdbquerysize>\n", CharacterDatabase.GetQueueSize());
    }
    fprintf(f, "  </status>\n");
	static const char * race_names[RACE_DRAENEI+1] = {
		NULL,
		"human",
		"orc",
		"dwarf",
		"nightelf",
		"undead",
		"tauren",
		"gnome",
		"troll",
		NULL,
		"bloodelf",
		"draenei",
	};

	static const char * class_names[DRUID+1] = {
		NULL,
		"warrior",
		"paladin",
		"hunter",
		"rogue",
		"priest",
		"deathknight",
		"shaman",
		"mage",
		"warlock",
		NULL,
		"druid",
	};

	fprintf(f, "  <statsummary>\n");
	uint32 i;
	for(i = 0; i <= RACE_DRAENEI; ++i)
	{
		if( race_names[i] != NULL )
			fprintf(f, "    <%s>%u</%s>\n", race_names[i], races[i], race_names[i]);
	}

	for(i = 0; i <= DRUID; ++i)
	{
		if( class_names[i] != NULL )
			fprintf(f, "    <%s>%u</%s>\n", class_names[i], classes[i], class_names[i]);
	}
	fprintf(f, "  </statsummary>\n");

    PlayerPointer plr;
    uint32 t = (uint32)time(NULL);
    char otime[100];
    {
        fprintf(f, "  <instances>\n");

        // need a big buffer..
        static char buf[500000];
        memset(buf, 0, 500000);

        // Dump Instance Information
        //sWorldCreator.BuildXMLStats(buf);
		sInstanceMgr.BuildXMLStats(buf);
        fprintf(f, buf);
        fprintf(f, "  </instances>\n");
    }
    {
        // GM Information
        fprintf(f, "  <gms>\n");
        while(!gms.empty())
        {
            plr = gms.front();
            gms.pop_front();
			if(!plr->bGMTagOn)
				continue;
            FillOnlineTime(t - plr->OnlineTime, otime);
            fprintf(f, "    <gmplr>\n");
            fprintf(f, "      <name>%s</name>\n", plr->GetName());
            fprintf(f, "      <race>%u</race>\n", plr->getRace());
            fprintf(f, "      <class>%u</class>\n", (unsigned int)plr->getClass());
            fprintf(f, "      <gender>%u</gender>\n", (unsigned int)plr->getGender());
            fprintf(f, "      <pvprank>%u</pvprank>\n", (unsigned int)plr->GetPVPRank());
            fprintf(f, "      <level>%u</level>\n", (unsigned int)plr->GetUInt32Value(UNIT_FIELD_LEVEL));
            fprintf(f, "      <map>%u</map>\n", (unsigned int)plr->GetMapId());
            fprintf(f, "      <areaid>%u</areaid>\n", (unsigned int)plr->GetAreaID());
            fprintf(f, "      <ontime>%s</ontime>\n", otime);
            fprintf(f, "      <latency>%u</latency>\n", (unsigned int)plr->GetSession()->GetLatency());
            fprintf(f, "      <permissions>%s</permissions>\n", plr->GetSession()->GetPermissions());
            fprintf(f, "    </gmplr>\n");
        }

        fprintf(f, "  </gms>\n");
    }

    {
    fprintf(f, "  <sessions>\n");
        // Dump Player Information
        objmgr._playerslock.AcquireReadLock();
        HM_NAMESPACE::hash_map<uint32, PlayerPointer>::const_iterator itr;

        for (itr = objmgr._players.begin(); itr != objmgr._players.end(); itr++)
        {
            plr = itr->second;
            if(itr->second->GetSession() && itr->second->IsInWorld())
            {
                FillOnlineTime(t - plr->OnlineTime, otime);

                fprintf(f, "    <plr>\n");
                fprintf(f, "      <name>%s</name>\n", plr->GetName());
                fprintf(f, "      <race>%u</race>\n", (unsigned int)plr->getRace());
                fprintf(f, "      <class>%u</class>\n", (unsigned int)plr->getClass());
				fprintf(f, "      <gender>%u</gender>\n", (unsigned int)plr->getGender());
				fprintf(f, "      <pvprank>%u</pvprank>\n", (unsigned int)plr->GetPVPRank());
                fprintf(f, "      <level>%u</level>\n", (unsigned int)plr->GetUInt32Value(UNIT_FIELD_LEVEL));
                fprintf(f, "      <map>%u</map>\n", (unsigned int)plr->GetMapId());
                fprintf(f, "      <areaid>%u</areaid>\n", (unsigned int)plr->GetAreaID());
				//requested by Zdarkside for he's online map. I hope it does not scre up any parser. If so, then make a better one :P
                fprintf(f, "      <xpos>%f</xpos>\n", plr->GetPositionX ());
                fprintf(f, "      <ypos>%f</ypos>\n", plr->GetPositionY());
                fprintf(f, "      <ontime>%s</ontime>\n", otime);
                fprintf(f, "      <latency>%u</latency>\n", (unsigned int)plr->GetSession()->GetLatency());
                fprintf(f, "    </plr>\n");
                if(plr->GetSession()->GetPermissionCount() > 0)
                    gms.push_back(plr);
            }
        }
        objmgr._playerslock.ReleaseReadLock();
        fprintf(f, "  </sessions>\n");


    }

    fprintf(f, "</serverpage>\n");
    fclose(f);
}