예제 #1
0
void RCFSourceInfo::ParseRelayDestinations(XMLTag* relayTag)
{
	// parse the NAME attribute of the relay tag and store it in the relayname attribute
	char* name = relayTag->GetAttributeValue("NAME");
	if (name != NULL)
	{
		fName = new char[::strlen(name) + 1];
		::strcpy(fName, name);
	}

	UInt32 numTags = relayTag->GetNumEmbeddedTags();
	AllocateOutputArray(numTags);   // not all these are relay tags, but most are

	// Now actually go through and figure out what to put into these OutputInfo structures,
	// based on what's on the relay_destination line
	fNumOutputs = 0;
	for (UInt32 y = 0; y < numTags; y++)
	{
		XMLTag* destTag = relayTag->GetEmbeddedTagByNameAndAttr("OBJECT", "CLASS", "destination", y);
		if (destTag == NULL)
			return;

		char* destType = destTag->GetAttributeValue("TYPE");
		if (destType == NULL)
			return;

		if (!strcmp(destType, "udp_destination"))
			ParseDestination(destTag, y);
		else if (!strcmp(destType, "announced_destination"))
			ParseAnnouncedDestination(destTag, y);

		fNumOutputs++;
	}
}
예제 #2
0
float MQ2NavigationPlugin::GetNavigationPathLength(PCHAR szLine)
{
	float result = -1.f;
	glm::vec3 destination;

	if (ParseDestination(szLine, destination)) {
		result = GetNavigationPathLength(destination);
	}
	return result;
}
예제 #3
0
bool MQ2NavigationPlugin::CanNavigateToPoint(PCHAR szLine)
{
	glm::vec3 destination;
	bool result = false;

	if (ParseDestination(szLine, destination)) {
		NavigationPath path(Get<NavMeshLoader>()->GetNavMesh());
		path.FindPath(destination);
		result = path.GetPathSize() > 0;
	}

	return result;
}
예제 #4
0
void MQ2NavigationPlugin::Command_Navigate(PSPAWNINFO pChar, PCHAR szLine)
{
	CHAR buffer[MAX_STRING] = { 0 };
	int i = 0;

	GetArg(buffer, szLine, 1);

	if (!stricmp(buffer, "ui")) {
		mq2nav::GetSettings().show_ui = !mq2nav::GetSettings().show_ui;
		mq2nav::SaveSettings(false);
		return;
	}
	else if (!stricmp(buffer, "pause")) {
		m_isPaused = !m_isPaused;
		return;
	}

	m_pEndingDoor = nullptr;
	m_pEndingItem = nullptr;

	//DebugSpewAlways("MQ2Nav::NavigateCommand - start with arg: %s", szLine);
	glm::vec3 destination;
	bool haveDestination = ParseDestination(szLine, destination);

	//DebugSpewAlways("MQ2Nav::NavigateCommand - have destination: %d", haveDestination ? 1 : 0);

	if (!haveDestination)
	{
		// reload nav mesh
		if (!strcmp(buffer, "reload")) {
			Get<NavMeshLoader>()->LoadNavMesh();
		}
		else if (!stricmp(buffer, "recordwaypoint") || !stricmp(buffer, "rwp")) {
			GetArg(buffer, szLine, 2);
			if (0 == *buffer) {
				WriteChatf(PLUGIN_MSG "Usage: /navigate recordwaypoint <waypoint name> <waypoint tag>");
			}
			else {
				std::string waypointName(buffer);
				GetArg(buffer, szLine, 3);
				std::string waypointTag(buffer);
				WriteChatf(PLUGIN_MSG "Recording waypoint: '%s' with tag: %s", waypointName.c_str(), waypointTag.c_str());
				if (mq2nav::AddWaypoint(waypointName, waypointTag)) {
					WriteChatf(PLUGIN_MSG "Overwrote previous waypoint: '%s'", waypointName.c_str());
				}
			}
		}
		else if (!stricmp(buffer, "help")) {
			WriteChatf(PLUGIN_MSG "Usage:");
			WriteChatf(PLUGIN_MSG "\ag/navigate [save | load]\ax - save/load settings");
			WriteChatf(PLUGIN_MSG "\ag/navigate reload\ax - reload navmesh");
			WriteChatf(PLUGIN_MSG "\ag/navigate recordwaypoint <waypoint name> <waypoint tag>\ax - create a waypoint");

			WriteChatf(PLUGIN_MSG "\aoNavigation Options:\ax");
			WriteChatf(PLUGIN_MSG "\ag/navigate target\ax - navigate to target");
			WriteChatf(PLUGIN_MSG "\ag/navigate X Y Z\ax - navigate to coordinates");
			WriteChatf(PLUGIN_MSG "\ag/navigate item [click] [once]\ax - navigate to item (and click it)");
			WriteChatf(PLUGIN_MSG "\ag/navigate door [click] [once]\ax - navigate to door/object (and click it)");
			WriteChatf(PLUGIN_MSG "\ag/navigate waypoint <waypoint>\ax - navigate to waypoint");
			WriteChatf(PLUGIN_MSG "\ag/navigate stop\ax - stop navigation");
			WriteChatf(PLUGIN_MSG "\ag/navigate pause\ax - pause navigation");
		}
		else if (!stricmp(buffer, "load")) {
			mq2nav::LoadSettings(true);
		}
		else if (!stricmp(buffer, "save")) {
			mq2nav::SaveSettings(true);
		}
		Stop();
		return;
	}

	// we were given a destination. Check if we should click once at the end.
	GetArg(buffer, szLine, 3);
	m_bSpamClick = strcmp(buffer, "once");

	BeginNavigation(destination);

	if (m_isActive)
		EzCommand("/squelch /stick off");
}