Exemple #1
0
CBotFollowLastEnemy::CBotFollowLastEnemy(CBot *pBot, edict_t *pEnemy, Vector vLastSee)
{
	Vector vVelocity = Vector(0, 0, 0);
	CClient *pClient = CClients::Get(pEnemy);

	CFindPathTask *pFindPath = new CFindPathTask(vLastSee, LOOK_LAST_ENEMY);

	if (CClassInterface::GetVelocity(pEnemy, &vVelocity))
	{
		if (pClient && (vVelocity == Vector(0, 0, 0)))
			vVelocity = pClient->GetVelocity();
	}
	else if (pClient)
		vVelocity = pClient->GetVelocity();

	pFindPath->SetCompleteInterrupt(CONDITION_SEE_CUR_ENEMY);

	AddTask(pFindPath);

	/*if ( pBot->isTF2() )
	{
	int playerclass = ((CBotTF2*)pBot)->getClass();

	if ( ( playerclass == TF_CLASS_SOLDIER ) || (playerclass == TF_CLASS_DEMOMAN) )
	AddTask(new CBotTF2ShootLastEnemyPosition(vLastSee,pEnemy,vVelocity));
	}*/

	AddTask(new CFindLastEnemy(vLastSee, vVelocity));

	//////////////
	pFindPath->SetNoInterruptions();
}
Exemple #2
0
CBotTF2HealSched::CBotTF2HealSched(edict_t *pHeal)
{
	CFindPathTask *findpath = new CFindPathTask(pHeal);
	findpath->SetCompleteInterrupt(CONDITION_SEE_HEAL);
	AddTask(findpath);
	AddTask(new CBotTF2MedicHeal());
}
Exemple #3
0
CBotRemoveSapperSched::CBotRemoveSapperSched(edict_t *pBuilding, eEngiBuild id)
{
	CFindPathTask *pathtask = new CFindPathTask(pBuilding);
	AddTask(pathtask);
	pathtask->CompleteInRangeFromEdict();
	pathtask->SetRange(150.0f);
	AddTask(new CBotRemoveSapper(pBuilding, id));
}
Exemple #4
0
CBotSpySapBuildingSched::CBotSpySapBuildingSched(edict_t *pBuilding, eEngiBuild id)
{
	CFindPathTask *findpath = new CFindPathTask(pBuilding);

	AddTask(findpath); // first
	AddTask(new CBotTF2SpySap(pBuilding, id)); // second

	findpath->SetDangerPoint(CWaypointLocations::NearestWaypoint(CBotGlobals::EntityOrigin(pBuilding), 200.0f, -1));
}
Exemple #5
0
CBotTFEngiBuild::CBotTFEngiBuild(CBot *pBot, eEngiBuild iObject, CWaypoint *pWaypoint)
{
	CFindPathTask *pathtask = new CFindPathTask(CWaypoints::GetWaypointIndex(pWaypoint));
	AddTask(pathtask); // first

	pathtask->SetInterruptFunction(new CBotTF2EngineerInterrupt(pBot));

	AddTask(new CBotTFEngiBuildTask(iObject, pWaypoint)); // second
}
Exemple #6
0
CBotTF2AttackSentryGun::CBotTF2AttackSentryGun(edict_t *pSentry, CBotWeapon *pWeapon)
{
	CFindPathTask *path = new CFindPathTask(pSentry);

	AddTask(path);
	AddTask(new CBotTF2AttackSentryGunTask(pSentry, pWeapon));

	path->CompleteInRangeFromEdict();
	path->CompleteIfSeeTaskEdict();

	path->SetRange(pWeapon->PrimaryMaxRange() - 100);
}
Exemple #7
0
CBotUseDispSched::CBotUseDispSched(CBot *pBot, edict_t *pDisp)//, bool bNest )
{
	CFindPathTask *pathtask = new CFindPathTask(pDisp);
	CBotTF2WaitHealthTask *gethealth = new CBotTF2WaitHealthTask(CBotGlobals::EntityOrigin(pDisp));
	AddTask(pathtask);
	pathtask->SetInterruptFunction(new CBotTF2EngineerInterrupt(pBot));

	AddTask(gethealth); // second
	gethealth->SetInterruptFunction(new CBotTF2EngineerInterrupt(pBot));

	//if ( bNest )
	//	AddTask(new CBotNest()); // third
}
Exemple #8
0
CGotoHideSpotSched::CGotoHideSpotSched(CBot *pBot, edict_t *pEdict, bool bIsGrenade)
{
	// run at flank while shooting	
	CFindPathTask *pHideGoalPoint = new CFindPathTask(pEdict);

	pBot->SetCoverFrom(pEdict);
	AddTask(new CFindGoodHideSpot(pEdict));
	AddTask(pHideGoalPoint);
	//if ( bIsGrenade )
	//AddTask(new CDODWaitForGrenadeTask(pEdict));

	// don't need to hide if the player we're hiding from died while we're running away
	pHideGoalPoint->FailIfTaskEdictDead();
	pHideGoalPoint->SetLookTask(LOOK_WAYPOINT);
	// no interrupts, should be a quick waypoint path anyway
	pHideGoalPoint->SetNoInterruptions();
	// get vector from good hide spot task
	pHideGoalPoint->GetPassedVector();
	pHideGoalPoint->DontGoToEdict();
	if (bIsGrenade)
	{
		pHideGoalPoint->SetRange(BLAST_RADIUS + 100.0f);
		pHideGoalPoint->CompleteOutOfRangeFromEdict();
	}
}
Exemple #9
0
CGotoHideSpotSched::CGotoHideSpotSched(CBot *pBot, Vector vOrigin, IBotTaskInterrupt *interrupt)
{
	// run at flank while shooting	
	CFindPathTask *pHideGoalPoint = new CFindPathTask();

	pBot->SetCoverFrom(NULL);
	AddTask(new CFindGoodHideSpot(vOrigin));
	AddTask(pHideGoalPoint);

	// no interrupts, should be a quick waypoint path anyway
	pHideGoalPoint->SetNoInterruptions();
	pHideGoalPoint->SetInterruptFunction(interrupt);
	// get vector from good hide spot task
	pHideGoalPoint->GetPassedVector();
}
Exemple #10
0
CBotAttackPointSched::CBotAttackPointSched(Vector vPoint, int iRadius, int iArea, bool bHasRoute, Vector vRoute, bool bNest, edict_t *pLastEnemySentry)
{
	int iDangerWpt = -1;

	if (pLastEnemySentry != NULL)
		iDangerWpt = CWaypointLocations::NearestWaypoint(CBotGlobals::EntityOrigin(pLastEnemySentry), 200.0f, -1, true, true);

	// First find random route 
	if (bHasRoute)
	{
		CFindPathTask *toRoute = new CFindPathTask(vRoute);
		AddTask(toRoute); // first
		toRoute->SetDangerPoint(iDangerWpt);

		if (bNest)
			AddTask(new CBotNest());
	}

	CFindPathTask *toPoint = new CFindPathTask(vPoint);
	AddTask(toPoint); // second / first
	toPoint->SetDangerPoint(iDangerWpt);
	AddTask(new CBotTF2AttackPoint(iArea, vPoint, iRadius)); // third / second 
}
Exemple #11
0
CBotTFEngiUpgrade::CBotTFEngiUpgrade(CBot *pBot, edict_t *pBuilding)
{
	CFindPathTask *pathtask = new CFindPathTask(pBuilding);

	AddTask(pathtask);

	pathtask->CompleteInRangeFromEdict();
	pathtask->FailIfTaskEdictDead();
	pathtask->SetRange(150.0f);

	if (!CTeamFortress2Mod::IsSentryGun(pBuilding))
	{
		pathtask->SetInterruptFunction(new CBotTF2EngineerInterrupt(pBot));

		CBotTF2UpgradeBuilding *upgbuilding = new CBotTF2UpgradeBuilding(pBuilding);
		AddTask(upgbuilding);
		upgbuilding->SetInterruptFunction(new CBotTF2EngineerInterrupt(pBot));

	}
	else
	{
		AddTask(new CBotTF2UpgradeBuilding(pBuilding));
	}
}
Exemple #12
0
// from the bots UTILITIES , execute the given action
bool CHLDMBot :: executeAction ( eBotAction iAction )
{
	switch ( iAction )
	{
	case BOT_UTIL_HL2DM_USE_CRATE:
		// check if it is worth it first
		{
			const char *szModel;
			char type;
			CBotWeapon *pWeapon = NULL;

			/*
			possible models
			0000000000111111111122222222223333
			0123456789012345678901234567890123
			models/items/ammocrate_ar2.mdl
			models/items/ammocrate_grenade.mdl
			models/items/ammocrate_rockets.mdl
			models/items/ammocrate_smg1.mdl
			*/

			szModel = m_pAmmoCrate.get()->GetIServerEntity()->GetModelName().ToCStr();
			type = szModel[23];

			if ( type == 'a' ) // ar2
			{
				pWeapon = m_pWeapons->getWeapon(CWeapons::getWeapon(HL2DM_WEAPON_AR2));
			}
			else if ( type == 'g' ) // grenade
			{
				pWeapon = m_pWeapons->getWeapon(CWeapons::getWeapon(HL2DM_WEAPON_FRAG));
			}
			else if ( type == 'r' ) // rocket
			{
				pWeapon = m_pWeapons->getWeapon(CWeapons::getWeapon(HL2DM_WEAPON_RPG));
			}
			else if ( type == 's' ) // smg
			{
				pWeapon = m_pWeapons->getWeapon(CWeapons::getWeapon(HL2DM_WEAPON_SMG1));
			}

			if ( pWeapon && (pWeapon->getAmmo(this) < 1) )
			{
				CBotSchedule *pSched = new CBotSchedule();
				
				pSched->addTask(new CFindPathTask(m_pAmmoCrate));
				pSched->addTask(new CBotHL2DMUseButton(m_pAmmoCrate));

				m_pSchedules->add(pSched);

				m_fUtilTimes[iAction] = engine->Time() + randomFloat(5.0f,10.0f);
				return true;
			}
		}
		return false;
	case BOT_UTIL_PICKUP_WEAPON:
		m_pSchedules->add(new CBotPickupSched(m_pNearbyWeapon.get()));
		return true;
	case BOT_UTIL_FIND_NEAREST_HEALTH:
		m_pSchedules->add(new CBotPickupSched(m_pHealthKit.get()));
		return true;
	case BOT_UTIL_HL2DM_FIND_ARMOR:
		m_pSchedules->add(new CBotPickupSched(m_pBattery.get()));
		return true;
	case BOT_UTIL_FIND_NEAREST_AMMO:
		m_pSchedules->add(new CBotPickupSched(m_pAmmoKit.get()));
		m_fUtilTimes[iAction] = engine->Time() + randomFloat(5.0f,10.0f);
		return true;
	case BOT_UTIL_HL2DM_USE_HEALTH_CHARGER:
		{
			CBotSchedule *pSched = new CBotSchedule();
			
			pSched->addTask(new CFindPathTask(m_pHealthCharger));
			pSched->addTask(new CBotHL2DMUseCharger(m_pHealthCharger,CHARGER_HEALTH));

			m_pSchedules->add(pSched);

			m_fUtilTimes[BOT_UTIL_HL2DM_USE_HEALTH_CHARGER] = engine->Time() + randomFloat(5.0f,10.0f);
			return true;
		}
	case BOT_UTIL_HL2DM_USE_CHARGER:
		{
			CBotSchedule *pSched = new CBotSchedule();
			
			pSched->addTask(new CFindPathTask(m_pCharger));
			pSched->addTask(new CBotHL2DMUseCharger(m_pCharger,CHARGER_ARMOR));

			m_pSchedules->add(pSched);

			m_fUtilTimes[BOT_UTIL_HL2DM_USE_CHARGER] = engine->Time() + randomFloat(5.0f,10.0f);
			return true;
		}
	case BOT_UTIL_HL2DM_GRAVIGUN_PICKUP:
		{
			CBotSchedule *pSched = new CBotSchedule(new CBotGravGunPickup(m_pCurrentWeapon,m_NearestPhysObj));
			pSched->setID(SCHED_GRAVGUN_PICKUP);
			m_pSchedules->add(pSched);
			return true;
		}
	case BOT_UTIL_FIND_LAST_ENEMY:
		{
			Vector vVelocity = Vector(0,0,0);
			CClient *pClient = CClients::get(m_pLastEnemy);
			CBotSchedule *pSchedule = new CBotSchedule();
			
			CFindPathTask *pFindPath = new CFindPathTask(m_vLastSeeEnemy);	

			pFindPath->setCompleteInterrupt(CONDITION_SEE_CUR_ENEMY);
			
			if ( !CClassInterface::getVelocity(m_pLastEnemy,&vVelocity) )
			{
				if ( pClient )
					vVelocity = pClient->getVelocity();
			}

			pSchedule->addTask(pFindPath);
			pSchedule->addTask(new CFindLastEnemy(m_vLastSeeEnemy,vVelocity));

			//////////////
			pFindPath->setNoInterruptions();

			m_pSchedules->add(pSchedule);

			m_bLookedForEnemyLast = true;

			return true;
		}
	case BOT_UTIL_THROW_GRENADE:
		{
		// find hide waypoint
			CWaypoint *pWaypoint = CWaypoints::getWaypoint(CWaypointLocations::GetCoverWaypoint(getOrigin(),m_vLastSeeEnemy,NULL));

			if ( pWaypoint )
			{
				CBotSchedule *pSched = new CBotSchedule();
				pSched->addTask(new CThrowGrenadeTask(m_pWeapons->getWeapon(CWeapons::getWeapon(HL2DM_WEAPON_FRAG)),getAmmo(CWeapons::getWeapon(HL2DM_WEAPON_FRAG)->getAmmoIndex1()),m_vLastSeeEnemyBlastWaypoint)); // first - throw
				pSched->addTask(new CFindPathTask(pWaypoint->getOrigin())); // 2nd -- hide
				m_pSchedules->add(pSched);
				return true;
			}

		}
	case BOT_UTIL_SNIPE:
		{
			// roam
			CWaypoint *pWaypoint = CWaypoints::randomWaypointGoal(CWaypointTypes::W_FL_SNIPER);

			if ( pWaypoint )
			{
				CBotSchedule *snipe = new CBotSchedule();
				CBotTask *findpath = new CFindPathTask(CWaypoints::getWaypointIndex(pWaypoint));
				CBotTask *snipetask;

				// use DOD task
				snipetask = new CBotHL2DMSnipe(m_pWeapons->getWeapon(CWeapons::getWeapon(HL2DM_WEAPON_CROSSBOW)),pWaypoint->getOrigin(),pWaypoint->getAimYaw(),false,0);

				findpath->setCompleteInterrupt(CONDITION_PUSH);
				snipetask->setCompleteInterrupt(CONDITION_PUSH);

				snipe->setID(SCHED_DEFENDPOINT);
				snipe->addTask(findpath);
				snipe->addTask(snipetask);
				
				m_pSchedules->add(snipe);

				return true;
			}

			break;
		}
	case BOT_UTIL_ROAM:
		// roam
		CWaypoint *pWaypoint = CWaypoints::getWaypoint(CWaypoints::randomFlaggedWaypoint(getTeam()));

		if ( pWaypoint )
		{
			m_pSchedules->add(new CBotGotoOriginSched(pWaypoint->getOrigin()));
			return true;
		}

		break;
	}

	return false;
}