コード例 #1
0
ファイル: Level0.cpp プロジェクト: Ballwinkle/Ascent_NG
bool ChatHandler::HandleStartCommand(const char* args, WorldSession *m_session)
{
	Player* m_plyr = TO_PLAYER(getSelectedChar(m_session, false));
	if( m_plyr == NULL)
		return false;

	uint32 raceid = m_plyr->getRace();
	uint32 classid = m_plyr->getClass();
	std::string argument = args;

	//No arguments given, get race from selected player
	if(m_plyr && args && strlen(args) < 2)
	{
		switch (raceid)
		{
			case 1: argument = "human";		break;
			case 2:	argument = "orc";		break;
			case 3:	argument = "dwarf";		break;
			case 4:	argument = "nightelf";	break;
			case 5:	argument = "undead";	break;
			case 6:	argument = "tauren";	break;
			case 7: argument = "gnome";		break;
			case 8:	argument = "troll";		break;
			case 10:argument = "bloodelf";	break;
			case 11:argument = "draenei";	break;
			default:
			{
				RedSystemMessage(m_session, "Could not extract race from slected character.");
				return true;
			}

		}
	}
	//Optional argument
	else if(m_plyr && args && strlen(args) > 2)
	{
		ASCENT_TOLOWER(argument);

		// Teleport to specific race
		if(argument == "human")				raceid = 1;
		else if(argument == "orc")			raceid = 2;
		else if(argument == "dwarf")		raceid = 3;
		else if(argument == "nightelf")		raceid = 4;
		else if(argument == "undead")		raceid = 5;
		else if(argument == "tauren")		raceid = 6;
		else if(argument == "gnome")		raceid = 7;
		else if(argument == "troll")		raceid = 8;
		else if(argument == "bloodelf")		raceid = 10;
		else if(argument == "draenei")		raceid = 11;
		else if(argument == "deathknight")	classid = 6;
		else
		{
			RedSystemMessage(m_session, "Invalid start location! Valid locations are: human, dwarf, gnome, nightelf, draenei, orc, troll, tauren, undead, bloodelf");
			return true;
		}
	}
	else
		return false;

	//GetPlayerCreateInfo
	PlayerCreateInfo *info = NULL;
	info = objmgr.GetPlayerCreateInfo(raceid, classid);
	if(info == NULL)
	{
		RedSystemMessage(m_session, "Internal error: Could not find create info.");
			return true;
	}


	GreenSystemMessage(m_session, "Telporting %s to %s starting location.", m_plyr->GetName(), argument.c_str());

	m_session->GetPlayer()->SafeTeleport(info->mapId, 0, LocationVector(info->positionX, info->positionY, info->positionZ));
	return true;
}
コード例 #2
0
ファイル: Level0.cpp プロジェクト: AwkwardDev/ascent_classic
bool ChatHandler::HandleStartCommand(const char* args, WorldSession *m_session)
{
	std::string race;
	uint32 raceid = 0;

	Player *m_plyr = getSelectedChar(m_session, false);

	if (m_plyr && args && strlen(args) < 2)
	{
		raceid = m_plyr->getRace();
		switch (raceid)
		{
		case 1:
			race = "human";
		break;
		case 2:
			race = "orc";
		break;
		case 3:
			race = "dwarf";
		break;
		case 4:
			race = "nightelf";
		break;
		case 5:
			race = "undead";
		break;
		case 6:
			race = "tauren";
		break;
		case 7:
			race = "gnome";
		break;
		case 8:
			race = "troll";
		break;
		case 10:
			race = "bloodelf";
		break;
		case 11:
			race = "draenei";
		break;
		default:
			return false;
		break;
		}
	}
	else if (m_plyr && args && strlen(args) > 2)
	{
		race = args;
		ASCENT_TOLOWER(race);

		// Teleport to specific race
		if(race == "human")
			raceid = 1;
		else if(race == "orc")
			raceid = 2;
		else if(race == "dwarf")
			raceid = 3;
		else if(race == "nightelf")
			raceid = 4;
		else if(race == "undead")
			raceid = 5;
		else if(race == "tauren")
			raceid = 6;
		else if(race == "gnome")
			raceid = 7;
		else if(race == "troll")
			raceid = 8;
		else if(race == "bloodelf")
			raceid = 10;
		else if(race == "draenei")
			raceid = 11;
		else
		{
			RedSystemMessage(m_session, "Invalid start location! Valid locations are: human, dwarf, gnome, nightelf, draenei, orc, troll, tauren, undead, bloodelf");
			return true;
		}
	}
	else
	{
		return false;
	}

	// Try to find a class that works
	PlayerCreateInfo *info = NULL;
	for(uint32 i=1;i<11;i++)
	{
		 info = objmgr.GetPlayerCreateInfo(raceid, i);
		 if(info != NULL) break;
	}
	
	if(info == NULL)
	{
		RedSystemMessage(m_session, "Internal error: Could not find create info.");
		return false;
	}


	GreenSystemMessage(m_session, "Telporting %s to %s starting location.", m_plyr->GetName(), race.c_str());

	m_session->GetPlayer()->SafeTeleport(info->mapId, 0, LocationVector(info->positionX, info->positionY, info->positionZ));
	return true;
}
コード例 #3
0
ファイル: QuestCommands.cpp プロジェクト: AwkwardDev/Summit
bool ChatHandler::HandleQuestLookupCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	string x = string(args);
	ASCENT_TOLOWER(x);
	if(x.length() < 4)
	{
		RedSystemMessage(m_session, "Your search string must be at least 5 characters long.");
		return true;
	}

	BlueSystemMessage(m_session, "Starting search of quests `%s`...", x.c_str());
	uint32 t = getMSTime();

	StorageContainerIterator<Quest> * itr = QuestStorage.MakeIterator();

	Quest * i;
	uint32 count = 0;
	string y;
	string recout;

	while(!itr->AtEnd())
	{
		i = itr->Get();

		y = string(i->title);
		ASCENT_TOLOWER(y);

		if(FindXinYString(x, y))
		{
			string questid = MyConvertIntToString(i->id);
			const char * questtitle = i->title;
			recout = "|cff00ccff";
			recout += questid.c_str();
			recout += ": ";
			recout += questtitle;
			recout += "\n";
			SendMultilineMessage(m_session, recout.c_str());

			++count;
			if(count == 25)
			{
				RedSystemMessage(m_session, "More than 25 results returned. aborting.");
				break;
			}
		}
		if(!itr->Inc())
			break;
	}
	itr->Destruct();

	if (count == 0)
	{
		recout = "|cff00ccffNo matches found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
	}

	BlueSystemMessage(m_session, "Search completed in %u ms.", getMSTime() - t);

	return true;
}
コード例 #4
0
ファイル: AHBot.cpp プロジェクト: pfchrono/rs-ascent
void AHBot::AHBotConsoleCommands(BaseConsole * pConsole, int argc, string args)
{
	string cmd = "";
	bool ok2ShowHelp = false;

	if((args.length() > 0) && (argc > 0))
	{
		cmd = string(args);
		ASCENT_TOLOWER(cmd);

		if(cmd.find("help") != std::string::npos)
			ok2ShowHelp = true;
	}
	else
		ok2ShowHelp = true;

	if(ok2ShowHelp == true)
	{
		pConsole->Write("\n");
		pConsole->Write("ahbot console commands are:\n");
		pConsole->Write("  auto     - triggers the automatic startup event\n");
		pConsole->Write("  clear    - clears ALL auctions from ALL auction houses\n");
		pConsole->Write("  config   - shows AHBot configuration information\n");
		pConsole->Write("  count    - counts the auctions on all the auction houses\n");
		pConsole->Write("  help     - displays this information\n");
		pConsole->Write("  list     - lists the available auction houses\n");
		pConsole->Write("  load     - loads an auction house <required itemsToAdd> <optional AHId>\n");
		pConsole->Write("  reload   - Re-loads all auction houses from SQL\n");
		pConsole->Write("  loglevel - Change the AHBot log level\n");
		pConsole->Write("  preload  - triggers the pre-loading of the auction houses\n");
		pConsole->Write("  unload   - unloads an auction house <required AHId>\n");
		pConsole->Write("  refresh  - Change the refresh interval\n");
		pConsole->Write("  time     - shows the current UNIXTIME\n");
		pConsole->Write("");

		return;
	}

	size_t pos = 0;

	if(cmd.find("auto") != std::string::npos)
	{
		pos = cmd.find("auto");
		cmd.replace(pos, 4, "");

		sAHBotMgr.AHBotAutoAH(pConsole, NULL);
	}

	if(cmd.find("time") != std::string::npos)
	{
		pos = cmd.find("time");
		cmd.replace(pos, 4, "");

		sAHBotMgr.AHBotTimeAH(pConsole, NULL);
	}

	if(cmd.find("config") != std::string::npos)
	{
		pos = cmd.find("config");
		cmd.replace(pos, 6, "");

		sAHBotMgr.AHBotConfigAH(pConsole, NULL);
	}

	if(cmd.find("refresh") != std::string::npos)
	{
		pos = cmd.find("refresh");
		cmd.replace(pos, 7, "");

		sAHBotMgr.AHBotRefreshMinutesAH(cmd, pConsole, NULL);
	}

	if(cmd.find("clear") != std::string::npos)
	{
		pos = cmd.find("clear");
		cmd.replace(pos, 5, "");

		sAHBotMgr.AHBotClearAH(pConsole, NULL);
	}

	if(cmd.find("count") != std::string::npos)
	{
		pos = cmd.find("count");
		cmd.replace(pos, 5, "");

		sAHBotMgr.AHBotCountAH(pConsole, NULL);
	}

	if(cmd.find("list") != std::string::npos)
	{
		pos = cmd.find("list");
		cmd.replace(pos, 4, "");

		sAHBotMgr.AHBotListAH(pConsole, NULL);
	}

	if(cmd.find("loglevel") != std::string::npos)
	{
		pos = cmd.find("loglevel");
		cmd.replace(pos, 8, "");

		sAHBotMgr.AHBotLogLevelAH(cmd, pConsole, NULL);
	}

	if(cmd.find("preload") != std::string::npos)
	{
		pos = cmd.find("preload");
		cmd.replace(pos, 7, "");

		sAHBotMgr.AHBotPreloadAH(cmd, pConsole, NULL);
	}

	if(cmd.find("reload") != std::string::npos)
	{
		pos = cmd.find("reload");
		cmd.replace(pos, 6, "");

		sAHBotMgr.AHBotReloadAH(pConsole, NULL);
	}

	if(cmd.find("unload") != std::string::npos)
	{
		pos = cmd.find("unload");
		cmd.replace(pos, 6, "");

		sAHBotMgr.AHBotUnLoadAH(cmd, pConsole, NULL);
	}

	if(cmd.find("load") != std::string::npos)
	{
		pos = cmd.find("load");
		cmd.replace(pos, 4, "");

		sAHBotMgr.AHBotLoadAH(cmd, pConsole, NULL);
	}

	return;
}