Пример #1
0
void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const char *pMessage)
{
	if (pEntity)
		MESSAGE_BEGIN(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pEntity);
	else
		MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY);

	WRITE_BYTE(29);
	WRITE_BYTE(textparms.channel & 0xFF);
	WRITE_SHORT(FixedSigned16(textparms.x, (1<<13)));
	WRITE_SHORT(FixedSigned16(textparms.y, (1<<13)));
	WRITE_BYTE(textparms.effect);
	WRITE_BYTE(textparms.r1);
	WRITE_BYTE(textparms.g1);
	WRITE_BYTE(textparms.b1);
	WRITE_BYTE(0);
	WRITE_BYTE(255);
	WRITE_BYTE(255);
	WRITE_BYTE(250);
	WRITE_BYTE(0);
	WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8)));
	WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8)));
	WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8)));
	
	if (textparms.effect == 2)
		WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8)));
	
	WRITE_STRING(pMessage);
	MESSAGE_END();
}
Пример #2
0
void META_UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, 
		const char *pMessage)
{
	if ( FNullEnt(pEntity) || pEntity->free )
		return;

	MESSAGE_BEGIN( MSG_ONE, SVC_TEMPENTITY, NULL, pEntity );
		WRITE_BYTE( TE_TEXTMESSAGE );
		WRITE_BYTE( textparms.channel & 0xFF );

		WRITE_SHORT( FixedSigned16( textparms.x, 1<<13 ) );
		WRITE_SHORT( FixedSigned16( textparms.y, 1<<13 ) );
		WRITE_BYTE( textparms.effect );

		WRITE_BYTE( textparms.r1 );
		WRITE_BYTE( textparms.g1 );
		WRITE_BYTE( textparms.b1 );
		WRITE_BYTE( textparms.a1 );

		WRITE_BYTE( textparms.r2 );
		WRITE_BYTE( textparms.g2 );
		WRITE_BYTE( textparms.b2 );
		WRITE_BYTE( textparms.a2 );

		WRITE_SHORT( FixedUnsigned16( textparms.fadeinTime, 1<<8 ) );
		WRITE_SHORT( FixedUnsigned16( textparms.fadeoutTime, 1<<8 ) );
		WRITE_SHORT( FixedUnsigned16( textparms.holdTime, 1<<8 ) );

		if ( textparms.effect == 2 )
			WRITE_SHORT( FixedUnsigned16( textparms.fxTime, 1<<8 ) );
		
		if ( strlen( pMessage ) < 512 )
		{
			WRITE_STRING( pMessage );
		}
		else
		{
			char tmp[512];
			strncpy( tmp, pMessage, 511 );
			tmp[511] = 0;
			WRITE_STRING( tmp );
		}
	MESSAGE_END();
}
Пример #3
0
void NPC::DebugModeMsg(void)
{
	if (FNullEnt(g_hostEntity))
		return;

	if (IsValidPlayer(INDEXENT(g_hostEntity->v.iuser2)))
		return;

	char gamemodName[12];
	switch (GetGameMode())
	{
	case 0:
		sprintf(gamemodName, "Normal");
		break;

	case 1:
		sprintf(gamemodName, "Dm");
		break;

	case 2:
		sprintf(gamemodName, "ZP");
		break;

	case 3:
		sprintf(gamemodName, "VS Npc");
		break;

	case 4:
		sprintf(gamemodName, "ZH");
		break;
	}

	char taskName[33];
	if (m_task & TASK_ENEMY)
		sprintf(taskName, "TASK_ENEMY");
	else if (m_task & TASK_MOVETOTARGET)
		sprintf(taskName, "TASK_MOVETOTARGET");
	else
		sprintf(taskName, "TASK_NORMAL");

	char enemyName[33];
	if (!FNullEnt(m_enemy))
		strcat(enemyName, GetEntityName(m_enemy));
	else if (!FNullEnt(m_moveTargetEntity))
		strcat(enemyName, GetEntityName(m_moveTargetEntity));
	else
		strcpy(enemyName, " (null)");

	// P.45 - Debugs Mode improve
	char npcTeam[33];
	if (m_npcTeam == 0)
		sprintf(npcTeam, "TR");
	else if (m_npcTeam == 1)
		sprintf(npcTeam, "CT");
	else 
		sprintf(npcTeam, "Team-%d", m_npcTeam);

	int navIndex[2] = { -1, -1 };
	PathNode *navid = &m_navNode[0];
	while (navid != null)
	{
		if (navIndex[0] == -1)
			navIndex[0] = navid->index;
		else if (navIndex[1] == -1)
		{
			navIndex[1] = navid->index;
			break;
		}

		navid = navid->next;
	}

	char outputBuffer[512];
	sprintf(outputBuffer, "\n\n\n\n\n\n\n Game Mode: %s"
		"\n [%s] \n Task: %s\n"
		"Enemy: %s  Team: %s\n"
		"CWI: %d  GI: %d\n"
		"Nav: %d  Next Nav :%d\n"
		"Move Speed: %.2f  Speed: %.2f\n"
		"Attack Distance : %.2f"
		"",
		gamemodName,
		GetEntityName(GetEntity()), taskName,
		enemyName, npcTeam, 
		m_currentWaypointIndex, m_goalWaypoint, 
		navIndex[0], navIndex[1], 
		m_moveSpeed, GetDistance2D(pev->velocity), 
		m_attackDistance);

	MESSAGE_BEGIN(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, null, g_hostEntity);
	WRITE_BYTE(TE_TEXTMESSAGE);
	WRITE_BYTE(1);
	WRITE_SHORT(FixedSigned16(-1, 1 << 13));
	WRITE_SHORT(FixedSigned16(0, 1 << 13));
	WRITE_BYTE(0);
	WRITE_BYTE(255);
	WRITE_BYTE(100);
	WRITE_BYTE(255);
	WRITE_BYTE(0);
	WRITE_BYTE(255);
	WRITE_BYTE(255);
	WRITE_BYTE(255);
	WRITE_BYTE(0);
	WRITE_SHORT(FixedUnsigned16(0, 1 << 8));
	WRITE_SHORT(FixedUnsigned16(0, 1 << 8));
	WRITE_SHORT(FixedUnsigned16(1.0, 1 << 8));
	WRITE_STRING(const_cast <const char *> (&outputBuffer[0]));
	MESSAGE_END();
	
	
	if (!FNullEnt (m_enemy))
		DrawLine(g_hostEntity, pev->origin, GetEntityOrigin (m_enemy), Color(255, 0, 0, 200), 10, 0, 5, 1, LINE_SIMPLE);

	if (!FNullEnt (m_moveTargetEntity))
		DrawLine(g_hostEntity, pev->origin, GetEntityOrigin (m_moveTargetEntity), Color(0, 255, 0, 200), 10, 0, 5, 1, LINE_SIMPLE);

	PathNode *node = &m_navNode[0];
	Vector src = nullvec;

	while (node != null)
	{
		int wpIndex = node->index;

		src = g_waypoint->g_waypointPointOrigin[node->index];
		node = node->next;

		if (node != null)
		{
			bool jumpPoint = false;
			for (int j = 0; j < Const_MaxPathIndex; j++)
			{
				if (g_waypoint->g_wpConnectionIndex[wpIndex][j] != node->index)
					continue;

				if (g_waypoint->g_wpConnectionFlags[wpIndex][j] & PATHFLAG_JUMP)
				{
					jumpPoint = true;
					break;
				}
			}

			if (!jumpPoint)
				DrawLine(g_hostEntity, src, g_waypoint->g_waypointPointOrigin[node->index],
					Color(255, 100, 55, 20), 15, 0, 8, 1, LINE_SIMPLE);
			else
				DrawLine(g_hostEntity, src, g_waypoint->g_waypointPointOrigin[node->index],
					Color(255, 0, 0, 20), 15, 0, 8, 1, LINE_SIMPLE);
		}
		else
			DrawLine(g_hostEntity, src, src + Vector(0, 0, 40),
				Color(255, 255, 255, 100), 15, 0, 8, 1, LINE_SIMPLE);
	}

	if (g_waypoint->GetEntityWpIndex(GetEntity()) != -1)
	{
		src = g_waypoint->g_waypointPointOrigin[g_waypoint->GetEntityWpIndex(GetEntity())];
		DrawLine(g_hostEntity, src, src + Vector(0, 0, 40),
			Color(255, 0, 0, 100), 15, 0, 8, 1, LINE_SIMPLE);
	}

	if (m_currentWaypointIndex != -1)
	{
		src = g_waypoint->g_waypointPointOrigin[m_currentWaypointIndex];
		DrawLine(g_hostEntity, src, src + Vector(0, 0, 40),
			Color(0, 255, 0, 100), 15, 0, 8, 1, LINE_SIMPLE);
	}

	if (m_waypointOrigin != nullvec)
	{
		src = m_waypointOrigin;
		DrawLine(g_hostEntity, src, src + Vector(0, 0, 40),
			Color(255, 0, 255, 100), 15, 0, 8, 1, LINE_SIMPLE);
	}

	if (m_goalWaypoint != -1)
	{
		src = g_waypoint->g_waypointPointOrigin[m_goalWaypoint];
		DrawLine(g_hostEntity, src, src + Vector(0, 0, 40),
			Color(0, 0, 255, 100), 15, 0, 8, 1, LINE_SIMPLE);
	}
}