コード例 #1
0
ファイル: weapons.cpp プロジェクト: yixu34/Mastrix
void WeaponPool::selectNext()
{
	//make sure we don't select something if the weapon pool is empty
	if (secondaryWeapons.empty())
		return;

	if((unsigned)selection+1 >= secondaryWeapons.size())
		selectWeapon(0);
	else
		selectWeapon(selection+1);
}
コード例 #2
0
ファイル: weapons.cpp プロジェクト: yixu34/Mastrix
void WeaponPool::selectPrevious()
{
	//again, an error check if the pool is empty
	if (secondaryWeapons.empty())
		return;

	if(selection==0)
		selectWeapon(secondaryWeapons.size()-1);
	else
		selectWeapon(selection-1);
}
コード例 #3
0
void AIHandlerBot::init()
{
	// Get the physics component and disable deactivation on the rigid body
	ComponentPhysics* physComp;
	aiComp->object->sendGetMessage(COMPMSG_GET_PHYSICS_COMPONENT, &physComp);
	aiComp->rigidBody->setActivationState(DISABLE_DEACTIVATION);

	// Initialize class to find neighbours
	neighbours = new AIGetNeighbours(BOT_NEIGHBOUR_RADIUS, aiComp->object, OBJTAG_BULLET);

	// Initialize perception
	perception = new AIPerception(OBJTAG_AGENT, BOT_VIEW_RANGE, Degree(BOT_FIELD_OF_VIEW), BOT_MEMORY_SPAN, aiComp->object);
	perceptionTimer = new JitteredIntervalTimer(1.0f / 3.0f);

	// Get our character controller
	if (!aiComp->object->sendGetMessage(COMPMSG_GET_CHARACTER_CONTROLLER, &myCharacterController))
		LogManager::getSingleton().logMessage("WARNING: no character controller component in an object with AIHandlerBot!");
	
	// Get our inventory
	if (!aiComp->object->sendGetMessage(COMPMSG_GET_INVENTORY, &myInventory))
		LogManager::getSingleton().logMessage("WARNING: no inventory component in an object with AIHandlerBot!");
	
	// Use the best weapon which is currently in our inventory
	selectWeapon();

	time = 0;
	aimDirection = Vector3(1, 0, 0);
	moveDirection = Vector3::ZERO;
}
コード例 #4
0
ファイル: bot_hldm_bot.cpp プロジェクト: Deathreus/AFKBot
void CHLDMBot :: handleWeapons ()
{
	//
	// Handle attacking at this point
	//
	if ( m_pEnemy && !hasSomeConditions(CONDITION_ENEMY_DEAD) && 
		hasSomeConditions(CONDITION_SEE_CUR_ENEMY) && wantToShoot() && 
		isVisible(m_pEnemy) && isEnemy(m_pEnemy) )
	{
		CBotWeapon *pWeapon;

		pWeapon = getBestWeapon(m_pEnemy,true,true,(m_pEnemy==m_NearestBreakable)&&!rcbot_melee_only.GetBool());

		if ( m_bWantToChangeWeapon && (pWeapon != NULL) && (pWeapon != getCurrentWeapon()) && pWeapon->getWeaponIndex() )
		{
			//selectWeaponSlot(pWeapon->getWeaponInfo()->getSlot());
			selectWeapon(pWeapon->getWeaponIndex());
		}

		setLookAtTask((LOOK_ENEMY));

		///battack = true;

		if ( !handleAttack ( pWeapon, m_pEnemy ) )
		{
			m_pEnemy = NULL;
			m_pOldEnemy = NULL;
			wantToShoot(false);
		}
	}
}