Exemple #1
0
void CTF2BuiltObjectEvent::Execute(IBotEventInterface *pEvent)
{
	eEngiBuild type = (eEngiBuild)pEvent->GetInt("object");
	int index = pEvent->GetInt("index");
	edict_t *pBuilding = INDEXENT(index);
	CBot *pBot = CBots::GetBotPointer(m_pActivator);

	CClient *pClient = CClients::Get(m_pActivator);

	if (type == ENGI_TELE)
	{
		CTeamFortress2Mod::TeleporterBuilt(m_pActivator, type, pBuilding);

		if (pClient && pClient->AutoWaypointOn())
		{
			if (CTeamFortress2Mod::IsTeleporterEntrance(pBuilding, CTeamFortress2Mod::GetTeam(m_pActivator)))
				pClient->AutoEventWaypoint(CWaypointTypes::W_FL_TELE_ENTRANCE, 400.0f);
			else
				pClient->AutoEventWaypoint(CWaypointTypes::W_FL_TELE_EXIT, 400.0f);
		}
	}

	if (type == ENGI_SENTRY)
	{
		CTeamFortress2Mod::SentryBuilt(m_pActivator, type, pBuilding);

		if (pClient && pClient->AutoWaypointOn())
		{
			pClient->AutoEventWaypoint(CWaypointTypes::W_FL_SENTRY, 400.0f);
		}
	}

	if (type == ENGI_DISP)
	{
		CTeamFortress2Mod::DispenserBuilt(m_pActivator, type, pBuilding);
	}

	if (pBot && pBot->IsTF())
	{
		((CBotFortress*)pBot)->EngiBuildSuccess((eEngiBuild)pEvent->GetInt("object"), pEvent->GetInt("index"));
	}
}
Exemple #2
0
void CFlagEvent::Execute(IBotEventInterface *pEvent)
{
	// dropped / picked up ID
	int type = pEvent->GetInt("eventtype");
	// player id
	int player = pEvent->GetInt("player");

	edict_t *pPlayer = NULL;
	CBot *pBot = NULL;

	// Crash fix
	if (player)
	{
		pPlayer = INDEXENT(player);
		pBot = CBots::GetBotPointer(pPlayer);
	}

	switch (type)
	{
	case FLAG_PICKUP: // pickup
		if (pBot && pBot->IsTF())
		{
			((CBotTF2*)pBot)->PickedUpFlag();
		}

		if (pPlayer)
		{
			int iTeam = CTeamFortress2Mod::GetTeam(pPlayer);

			if (CTeamFortress2Mod::IsFlagAtDefaultState())
			{
				CClient *pClient;

				pClient = CClients::Get(pPlayer);

				if (pClient && pClient->AutoWaypointOn())
					pClient->AutoEventWaypoint(CWaypointTypes::W_FL_FLAG, 200.0f, false);
			}

			CTeamFortress2Mod::FlagPickedUp(iTeam, pPlayer);

		}


		break;
	case FLAG_CAPTURED: // captured
	{
		IPlayerInfo *p = NULL;

		if (pPlayer)
		{
			p = playerinfomanager->GetPlayerInfo(pPlayer);

			if (p)
			{
				CBroadcastFlagCaptured captured = CBroadcastFlagCaptured(p->GetTeamIndex());
				CBots::BotFunction(&captured);
			}
		}

		if (pBot && pBot->IsTF())
		{
			((CBotTF2*)pBot)->CapturedFlag();
			((CBotTF2*)pBot)->DroppedFlag();
		}

		if (pPlayer)
		{
			int iTeam = CTeamFortress2Mod::GetTeam(pPlayer);
			CTeamFortress2Mod::FlagDropped(iTeam, Vector(0, 0, 0));

			CClient *pClient;

			pClient = CClients::Get(pPlayer);

			if (pClient && pClient->AutoWaypointOn())
				pClient->AutoEventWaypoint(CWaypointTypes::W_FL_CAPPOINT, 200.0f, false);
		}

		CTeamFortress2Mod::ResetFlagStateToDefault();

	}
	break;
	case FLAG_DROPPED: // drop
	{
		IPlayerInfo *p = playerinfomanager->GetPlayerInfo(pPlayer);
		Vector vLoc;

		if (p)
		{
			vLoc = CBotGlobals::EntityOrigin(pPlayer);
			CBroadcastFlagDropped dropped = CBroadcastFlagDropped(p->GetTeamIndex(), vLoc);
			CBots::BotFunction(&dropped);
		}

		if (pBot && pBot->IsTF())
			((CBotTF2*)pBot)->DroppedFlag();


		if (pPlayer)
			CTeamFortress2Mod::FlagDropped(CTeamFortress2Mod::GetTeam(pPlayer), vLoc);
	}
	break;
	case FLAG_RETURN:
	{
		if (CTeamFortress2Mod::IsMapType(TF_MAP_SD))
		{
			CBroadcastFlagReturned returned = CBroadcastFlagReturned(CTeamFortress2Mod::GetFlagCarrierTeam());
			CBots::BotFunction(&returned);
		}
		CTeamFortress2Mod::ResetFlagStateToDefault();

		CTeamFortress2Mod::FlagReturned(0); // for special delivery
		//p->GetTeamIndex(),CBotGlobals::EntityOrigin(pPlayer));
	}
	break;
	default:
		break;
	}

}
Exemple #3
0
void CPlayerDeathEvent::Execute(IBotEventInterface *pEvent)
{
	CBot *pBot = CBots::GetBotPointer(m_pActivator);
	const char *weapon = pEvent->GetString("weapon", NULL);
	CBotSquad *pPrevSquadLeadersSquad = NULL;
	int iAttacker = pEvent->GetInt("attacker", 0);

	edict_t *pAttacker = (iAttacker > 0) ? CBotGlobals::PlayerByUserId(iAttacker) : NULL;

	if (pAttacker && ((CBotGlobals::EntityOrigin(pAttacker) - CBotGlobals::EntityOrigin(m_pActivator)).Length() > 512.0f))
	{
		// killer
		CClient *pClient = CClients::Get(pAttacker);

		if (pClient && pClient->AutoWaypointOn())
		{
			CWeapon *pWeapon = CWeapons::GetWeaponByShortName(weapon);

			if (pWeapon != NULL)
			{
				if (pWeapon->IsScoped())
				{
					pClient->AutoEventWaypoint(CWaypointTypes::W_FL_SNIPER, 100.0f);
				}
				else if (pWeapon->IsDeployable())
				{
					// non OO hack here
					if (CBotGlobals::IsCurrentMod(MOD_DOD))
					{
						edict_t *pentWeapon = CWeapons::FindWeapon(pAttacker, pWeapon->GetWeaponName());

						if (CClassInterface::IsMachineGunDeployed(pentWeapon))
						{
							bool bIsProne;
							float flStamina;

							CClassInterface::GetPlayerInfoDOD(pAttacker, &bIsProne, &flStamina);

							if (!bIsProne)
							{
								pClient->AutoEventWaypoint(CWaypointTypes::W_FL_MACHINEGUN, 100.0f);
							}
						}
					}
					//CClassInterface::IsMachineGunDeployed(pWeapon->Get)
					//pWeapon->IsDeployed()
				}
			}
		}

		// victim
		pClient = CClients::Get(m_pActivator);

		if (CBotGlobals::IsPlayer(pAttacker) && pClient && pClient->AutoWaypointOn())
		{
			CWeapon *pWeapon = CWeapons::GetWeaponByShortName(weapon);

			if (pWeapon != NULL)
			{
				if (pWeapon->IsScoped())
				{
					pClient->AutoEventWaypoint(CWaypointTypes::W_FL_SNIPER, 200.0f, true, CClassInterface::GetTeam(pAttacker), CBotGlobals::EntityOrigin(pAttacker) + Vector(0, 0, 32.0f));
				}
			}
		}

	}

	if (pBot)
		pBot->Died(pAttacker, weapon);

	pBot = CBots::GetBotPointer(pAttacker);

	if (pBot)
	{
		pBot->Killed(m_pActivator, (char*)weapon);

		pBot->EnemyDown(m_pActivator);
	}

	if (m_pActivator && pAttacker) // not worldspawn
	{
		CBotSeeFriendlyDie func1(m_pActivator, pAttacker, weapon);
		CBotSeeFriendlyKill func2(pAttacker, m_pActivator, weapon);

		CBots::BotFunction(&func1);
		CBots::BotFunction(&func2);
	}

	if ((pPrevSquadLeadersSquad = CBotSquads::FindSquadByLeader(m_pActivator)) != NULL)
	{
		CBotSquads::ChangeLeader(pPrevSquadLeadersSquad);
	}
}