Exemplo n.º 1
0
CBotWeapon *CBotWeapons::GetActiveWeapon(const char *szWeaponName, edict_t *pWeaponUpdate, bool bOverrideAmmoTypes)
{
	CBotWeapon *toReturn = NULL;

	if (szWeaponName && *szWeaponName)
	{
		CWeapon *pWeapon = CWeapons::GetWeapon(szWeaponName);

		if (pWeapon)
		{
			register unsigned short int i;

			for (i = 0; i < MAX_WEAPONS; i++)
			{
				CWeapon *p = m_theWeapons[i].GetWeaponInfo();

				if (!p)
					continue;

				if (strcmp(p->GetWeaponName(), szWeaponName) == 0)
				{
					toReturn = &m_theWeapons[i];
					break;
				}
			}

			if (pWeaponUpdate && toReturn)
				toReturn->SetWeaponEntity(pWeaponUpdate, bOverrideAmmoTypes);
		}
	}

	return toReturn;
}
Exemplo n.º 2
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);
	}
}