当前位置: 首页>>代码示例>>C++>>正文


C++ SetCondition函数代码示例

本文整理汇总了C++中SetCondition函数的典型用法代码示例。如果您正苦于以下问题:C++ SetCondition函数的具体用法?C++ SetCondition怎么用?C++ SetCondition使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetCondition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ClearConditions

//---------------------------------------------------------
//---------------------------------------------------------
void CZombie::GatherConditions( void )
{
	BaseClass::GatherConditions();

	static int conditionsToClear[] = 
	{
		COND_BLOCKED_BY_DOOR,
		COND_DOOR_OPENED,
		COND_ZOMBIE_CHARGE_TARGET_MOVED,
	};

	ClearConditions( conditionsToClear, ARRAYSIZE( conditionsToClear ) );

	if ( m_hBlockingDoor == NULL || 
		 ( m_hBlockingDoor->m_toggle_state == TS_AT_TOP || 
		   m_hBlockingDoor->m_toggle_state == TS_GOING_UP )  )
	{
		ClearCondition( COND_BLOCKED_BY_DOOR );
		if ( m_hBlockingDoor != NULL )
		{
			SetCondition( COND_DOOR_OPENED );
			m_hBlockingDoor = NULL;
		}
	}
	else
		SetCondition( COND_BLOCKED_BY_DOOR );

	if ( ConditionInterruptsCurSchedule( COND_ZOMBIE_CHARGE_TARGET_MOVED ) )
	{
		if ( GetNavigator()->IsGoalActive() )
		{
			const float CHARGE_RESET_TOLERANCE = 60.0;
			if ( !GetEnemy() ||
				 ( m_vPositionCharged - GetEnemyLKP()  ).Length() > CHARGE_RESET_TOLERANCE )
			{
				SetCondition( COND_ZOMBIE_CHARGE_TARGET_MOVED );
			}
				 
		}
	}
}
开发者ID:RaraFolf,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:43,代码来源:npc_zombie.cpp

示例2: SetCondition

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CAI_OperatorBehavior::GatherConditionsNotActive()
{
    if( m_hPositionEnt )
    {
        // If we're not currently the active behavior, we have a position ent, and the
        // NPC can see it, coax the AI out of IDLE/ALERT schedules with this condition.
        if( CanSeePositionEntity() )
        {
            SetCondition( COND_IDLE_INTERRUPT );
        }
    }
}
开发者ID:Black-Stormy,项目名称:DoubleAction,代码行数:14,代码来源:ai_behavior_operator.cpp

示例3: Log

void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
	std::map<uint16, SpawnCondition>::iterator condi;
	condi = spawn_conditions.find(event.condition_id);
	if(condi == spawn_conditions.end()) {
		Log(Logs::Detail, Logs::Spawns, "Event %d: Unable to find condition %d to execute on.", event.id, event.condition_id);
		return;	//unable to find the spawn condition to operate on
	}

	TimeOfDay_Struct tod;
	zone->zone_time.GetCurrentEQTimeOfDay(&tod);
	if(event.strict && (event.next.hour != tod.hour || event.next.day != tod.day || event.next.month != tod.month || event.next.year != tod.year))
	{
		Log(Logs::Detail, Logs::Spawns, "Event %d: Unable to execute. Condition is strict, and event time has already passed.", event.id);
		return;
	}

	SpawnCondition &cond = condi->second;

	int16 new_value = cond.value;

	//we have our event and our condition, do our stuff.
	switch(event.action) {
	case SpawnEvent::ActionSet:
		new_value = event.argument;
		Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Setting condition %d to %d.", event.id, event.condition_id, event.argument);
		break;
	case SpawnEvent::ActionAdd:
		new_value += event.argument;
		Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Adding %d to condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value);
		break;
	case SpawnEvent::ActionSubtract:
		new_value -= event.argument;
		Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Subtracting %d from condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value);
		break;
	case SpawnEvent::ActionMultiply:
		new_value *= event.argument;
		Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Multiplying condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value);
		break;
	case SpawnEvent::ActionDivide:
		new_value /= event.argument;
		Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Dividing condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value);
		break;
	default:
		Log(Logs::Detail, Logs::Spawns, "Event %d: Invalid event action type %d", event.id, event.action);
		return;
	}

	//now set the condition to the new value
	if(send_update)	//full blown update
		SetCondition(zone->GetShortName(), zone->GetInstanceID(), cond.condition_id, new_value);
	else	//minor update done while loading
		cond.value = new_value;
}
开发者ID:N0ctrnl,项目名称:VAServer,代码行数:53,代码来源:spawn2.cpp

示例4: switch

void CNPC_Cremator::RunTask( const Task_t *pTask )
{
	switch ( pTask->iTask )
	{
	case TASK_CREMATOR_RANGE_ATTACK1:
		{
			SetActivity( ACT_RANGE_ATTACK1 );

			Vector flEnemyLKP = GetEnemyLKP();
			GetMotor()->SetIdealYawToTargetAndUpdate( flEnemyLKP );

			if( m_iAmmo < 1 && IsActivityFinished() )
			{
				SetCondition( COND_CREMATOR_OUT_OF_AMMO );
								
				DevMsg( "NO PRIMARY AMMO\n" );

				StopParticleEffects(this);
				StopSound( "Weapon_Immolator.Single" );
				EmitSound( "Weapon_Immolator.Stop" );
				
				TaskComplete();
				SetNextThink( gpGlobals->curtime + 0.1f );
			}

			// THIS fixes the combat issue with the Cremator continuing to fire at a target that moved out of his reach
			if( GetEnemyLKP().DistTo( GetAbsOrigin()) > CREMATOR_MAX_RANGE )
			{
				// Cremator stops firing and attempts to close the distance.
				SetActivity( ACT_CREMATOR_DISARM );
				TaskComplete();
				Msg( "Enemy is too far\n" );

				SetNextThink( gpGlobals->curtime + 0.1f );
				return;
			}
	/*		// This is bugged and shouldn't be used. Necessary checks are made below, in OnChangeActivity( ).	
			if( IsActivityMovementPhased( ACT_WALK ) || IsActivityMovementPhased( ACT_RUN ) )
			{
				TaskFail( NULL );
				SetActivity( ACT_CREMATOR_DISARM );
				
				DevMsg( "ACT_CREMATOR_DISARM\n" );
				return;
			}
	*/
			break;
		}
		default:
		BaseClass::RunTask( pTask );
		break;
	}
}
开发者ID:RaraFolf,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:53,代码来源:npc_cremator.cpp

示例5: FfbOnUsbData

// Handle incoming data from USB 
void FfbOnUsbData(uint8_t* data, uint16_t len)
{

	uint8_t effectId = data[1]; // effectBlockIndex is always the second byte.

	switch (data[0])    // reportID
	{
	case 1:
		FfbHandle_SetEffect((USB_FFBReport_SetEffect_Output_Data_t*)data);
		break;
	case 2:
		SetEnvelope((USB_FFBReport_SetEnvelope_Output_Data_t*)data, &gEffectStates[effectId]);
		break;
	case 3:
		SetCondition((USB_FFBReport_SetCondition_Output_Data_t*)data, &gEffectStates[effectId]);
		break;
	case 4:
		SetPeriodic((USB_FFBReport_SetPeriodic_Output_Data_t*)data, &gEffectStates[effectId]);
		break;
	case 5:
		SetConstantForce((USB_FFBReport_SetConstantForce_Output_Data_t*)data, &gEffectStates[effectId]);
		break;
	case 6:
		SetRampForce((USB_FFBReport_SetRampForce_Output_Data_t*)data, &gEffectStates[effectId]);
		break;
	case 7:
		FfbHandle_SetCustomForceData((USB_FFBReport_SetCustomForceData_Output_Data_t*)data);
		break;
	case 8:
		FfbHandle_SetDownloadForceSample((USB_FFBReport_SetDownloadForceSample_Output_Data_t*)data);
		break;
	case 9:
		break;
	case 10:
		FfbHandle_EffectOperation((USB_FFBReport_EffectOperation_Output_Data_t*)data);
		break;
	case 11:
		FfbHandle_BlockFree((USB_FFBReport_BlockFree_Output_Data_t*)data);
		break;
	case 12:
		FfbHandle_DeviceControl((USB_FFBReport_DeviceControl_Output_Data_t*)data);
		break;
	case 13:
		FfbHandle_DeviceGain((USB_FFBReport_DeviceGain_Output_Data_t*)data);
		break;
	case 14:
		FfbHandle_SetCustomForce((USB_FFBReport_SetCustomForce_Output_Data_t*)data);
		break;
	default:
		break;
	};

}
开发者ID:nervTeh,项目名称:ForceFeedback-core-library,代码行数:54,代码来源:ffb.c

示例6: SetCondition

//-----------------------------------------------------------------------------
// Purpose: Move the zombie to the vehicle
//-----------------------------------------------------------------------------
int CAI_PassengerBehaviorZombie::SelectSchedule( void )
{
	// See if our enemy got out
	if ( GetOuter()->GetEnemy() != NULL && EnemyInVehicle() == false  )
	{
		if ( GetPassengerState() == PASSENGER_STATE_INSIDE )
		{
			// Exit the vehicle
			SetCondition( COND_PASSENGER_EXITING );
		}
		else if ( GetPassengerState() == PASSENGER_STATE_OUTSIDE )
		{
			// Our target has left the vehicle and we're outside as well, so give up
			Disable();
			return BaseClass::SelectSchedule();
		}
	}

	// Entering schedule
	if ( HasCondition( COND_PASSENGER_ENTERING ) )
	{
		ClearCondition( COND_PASSENGER_ENTERING );
		return SCHED_PASSENGER_ZOMBIE_ENTER_VEHICLE;
	}

	// Exiting schedule
	if ( HasCondition( COND_PASSENGER_EXITING ) )
	{
		ClearCondition( COND_PASSENGER_EXITING );
		return SCHED_PASSENGER_ZOMBIE_EXIT_VEHICLE;
	}

	// Select different schedules based on our state
	PassengerState_e nState = GetPassengerState();
	int nNewSchedule = SCHED_NONE;

	if ( nState == PASSENGER_STATE_INSIDE )
	{
		nNewSchedule = SelectInsideSchedule();
		if ( nNewSchedule != SCHED_NONE )
			return nNewSchedule;
	}
	else if ( nState == PASSENGER_STATE_OUTSIDE )
	{
		nNewSchedule = SelectOutsideSchedule();
		if ( nNewSchedule != SCHED_NONE )
			return nNewSchedule;
	}

	// Worst case he just stands here
	Assert(0);
	return SCHED_IDLE_STAND;
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:56,代码来源:ai_behavior_passenger_zombie.cpp

示例7: LaserStartPosition

//-----------------------------------------------------------------------------
// Purpose: Override so can handle LOS to m_pScriptedTarget
// Input  :
// Output :
//-----------------------------------------------------------------------------
bool CNPC_Stalker::InnateWeaponLOSCondition( const Vector &ownerPos, const Vector &targetPos, bool bSetConditions )
{
	// --------------------
	// Check for occlusion
	// --------------------
	// Base class version assumes innate weapon position is at eye level
	Vector barrelPos = LaserStartPosition(ownerPos);
	trace_t tr;
	AI_TraceLine( barrelPos, targetPos, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr);

	if ( tr.fraction == 1.0 )
	{
		return true;
	}

	CBaseEntity *pBE = tr.m_pEnt;
	CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pBE );
	if ( pBE == GetEnemy() )
	{
		return true;
	}
	else if (pBCC) 
	{
		if (IRelationType( pBCC ) == D_HT)
		{
			return true;
		}
		else if (bSetConditions)
		{
			SetCondition(COND_WEAPON_BLOCKED_BY_FRIEND);
		}
	}
	else if (bSetConditions)
	{
		SetCondition(COND_WEAPON_SIGHT_OCCLUDED);
		SetEnemyOccluder(pBE);
	}

	return false;
}
开发者ID:Muini,项目名称:Nag-asw,代码行数:45,代码来源:npc_stalker.cpp

示例8: SetCondition

//-----------------------------------------------------------------------------
// Purpose: 
// Input  :
// Output : 
//-----------------------------------------------------------------------------
void CBaseHelicopter::GatherEnemyConditions( CBaseEntity *pEnemy )
{
	// -------------------
	// If enemy is dead
	// -------------------
	if ( !pEnemy->IsAlive() )
	{
		SetCondition( COND_ENEMY_DEAD );
		ClearCondition( COND_SEE_ENEMY );
		ClearCondition( COND_ENEMY_OCCLUDED );
		return;
	}
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:18,代码来源:cbasehelicopter.cpp

示例9: SetCondition

//-----------------------------------------------------------------------------
// Purpose:  This is a generic function (to be implemented by sub-classes) to
//			 handle specific interactions between different types of characters
//			 (For example the barnacle grabbing an NPC)
// Input  :  Constant for the type of interaction
// Output :	 true  - if sub-class has a response for the interaction
//			 false - if sub-class has no response
//-----------------------------------------------------------------------------
bool CNPC_Houndeye::HandleInteraction(int interactionType, void *data, CBaseCombatCharacter* sourceEnt)
{
	if (interactionType == g_interactionHoundeyeGroupAttack)
	{
		SetCondition(COND_HOUND_GROUP_ATTACK);
		return true;
	}
	else if (interactionType == g_interactionHoundeyeGroupRetreat)
	{
		SetCondition(COND_HOUND_GROUP_RETREAT);
		return true;
	}
	else if (interactionType == g_interactionHoundeyeGroupRalley)
	{
		SetCondition(COND_HOUND_GROUP_RALLEY);
		SetTarget(sourceEnt);
		m_bLoopClockwise = false;
		return true;
	}

	return false;
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:30,代码来源:npc_houndeye.cpp

示例10: SetCondition

//------------------------------------------------------------------------------
// Purpose: sets / clears conditions for when the behavior is not active.  this is 
//			mainly to have a smaller set of conditions to wake up the behavior.
//------------------------------------------------------------------------------
void CAI_ASW_FlickBehavior::GatherConditionsNotActive( )
{
	BaseClass::GatherConditionsNotActive();

	if ( m_flNextFlickCheck < gpGlobals->curtime )
	{
		if ( GetFlickActivity() != NULL )
		{
			SetCondition( COND_SHIELD_CAN_FLICK );
		}

		m_flNextFlickCheck = gpGlobals->curtime + 1.0f;
	}
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:18,代码来源:asw_ai_behavior_flick.cpp

示例11: ClearCondition

//------------------------------------------------------------------------------
// Purpose: sets / clears conditions for when the behavior is active.  this is
//			generally a larger set of conditions to interrupt any tasks.
//------------------------------------------------------------------------------
void CAI_ASW_HealOtherBehavior::GatherConditions( )
{
	BaseClass::GatherConditions();

	ClearCondition( COND_HEAL_OTHER_HAS_FULL_HEALTH );		// needed?

	if ( GetTarget() != NULL )
	{
		if ( GetTarget()->m_iHealth == GetTarget()->m_iMaxHealth )
		{
			SetCondition( COND_HEAL_OTHER_HAS_FULL_HEALTH );
		}
	}
}
开发者ID:jtanx,项目名称:ch1ckenscoop,代码行数:18,代码来源:asw_ai_behavior_heal_other.cpp

示例12: SetCondition

//-----------------------------------------------------------------------------
// Purpose: Force the driver to pickup a specific entity
// Input  : &inputdata - 
//-----------------------------------------------------------------------------
void CNPC_CraneDriver::InputForcePickup( inputdata_t &inputdata )
{
	string_t iszPickupName = inputdata.value.StringID();
	if ( iszPickupName != NULL_STRING )
	{
		// Turn the magnet off now to drop anything we might have already on the magnet
		m_hCrane->TurnMagnetOff();
		m_hPickupTarget = gEntList.FindEntityByName( NULL, iszPickupName, NULL );
		m_bForcedPickup = true;
		m_bForcedDropoff = false;
		SetCondition( COND_PROVOKED );
		CLEARBITS( m_spawnflags, SF_VEHICLEDRIVER_INACTIVE );
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:18,代码来源:npc_cranedriver.cpp

示例13: HasCondition

//-----------------------------------------------------------------------------
// Purpose: Soldiers use CAN_RANGE_ATTACK2 to indicate whether they can throw
//			a grenade. Because they check only every half-second or so, this
//			condition must persist until it is updated again by the code
//			that determines whether a grenade can be thrown, so prevent the 
//			base class from clearing it out. (sjb)
//-----------------------------------------------------------------------------
void CNPC_CombineShot::ClearAttackConditions()
{
	bool fCanRangeAttack2 = HasCondition( COND_CAN_RANGE_ATTACK2 );

	// Call the base class.
	BaseClass::ClearAttackConditions();

	if( fCanRangeAttack2 )
	{
		// We don't allow the base class to clear this condition because we
		// don't sense for it every frame.
		SetCondition( COND_CAN_RANGE_ATTACK2 );
	}
}
开发者ID:Spasior,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:21,代码来源:npc_combineshot.cpp

示例14: Disable

//-----------------------------------------------------------------------------
// Purpose: 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CAI_AssaultBehavior::CanSelectSchedule()
{
	if ( !GetOuter()->IsInterruptable() )
		return false;

	if ( GetOuter()->HasCondition( COND_RECEIVED_ORDERS ) )
		return false;

	// We're letting other AI run for a little while because the assault AI failed recently.
	if ( m_flTimeDeferScheduleSelection > gpGlobals->curtime )
		return false;

	// No schedule selection if no assault is being conducted.
	if( m_AssaultCue == CUE_NO_ASSAULT )
		return false;

	if ( !m_hAssaultPoint || !m_hRallyPoint )
	{
		Disable();
		return false;
	}

	// Remember when we last saw an enemy
	if ( GetEnemy() )
	{
		m_flLastSawAnEnemyAt = gpGlobals->curtime;
	}

	// If we've seen an enemy in the last few seconds, and we're allowed to divert,
	// let the base AI decide what I should do.
	if ( IsAllowedToDivert() )
	{
		// Return true, but remember that we're actually allowing them to divert
		// This is done because we don't want the assault behaviour to think it's finished with the assault.
		m_bDiverting = true;
	}
	else if ( m_bDiverting )
	{
		// If we were diverting, provoke us to make a new schedule selection
		SetCondition( COND_PROVOKED );

		m_bDiverting = false;
	}

	// If we're diverting, let the base AI decide everything
	if ( m_bDiverting )
		return false;

	return true;
}
开发者ID:paralin,项目名称:hl2sdk,代码行数:54,代码来源:ai_behavior_assault.cpp

示例15: GetAttachment

void CNPC_Dog::CleanCatchAndThrow( bool bClearTimers )
{
	if ( m_hPhysicsEnt )
	{
		if ( m_bHasObject == true )
		{
			IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject();

			m_hPhysicsEnt->SetParent( NULL );
			m_hPhysicsEnt->SetOwnerEntity( NULL );

			Vector vGunPos;
			QAngle angGunAngles;
			GetAttachment( m_iPhysGunAttachment, vGunPos, angGunAngles );

			if ( pPhysObj )
			{
				pPhysObj->Wake();
				pPhysObj->RemoveShadowController();
				pPhysObj->SetPosition( vGunPos, angGunAngles, true );
			}
			else
			{
				Warning( "CleanCatchAndThrow:   m_hPhysicsEnt->VPhysicsGetObject == NULL!\n" );
			}

			m_hPhysicsEnt->SetMoveType( (MoveType_t)m_iContainerMoveType );

			if ( pPhysObj )
			{
				pPhysObj->RecheckCollisionFilter();
			}
	
			ClearBeams();
		}
		
		m_hPhysicsEnt = NULL;
	}

	if ( bClearTimers == true )
	{
		 m_bDoCatchThrowBehavior = false;
		 m_bDoWaitforObjectBehavior = false;
		 m_flTimeToCatch = 0.0f;
		 m_flNextSwat = 0.0f;

		 SetCondition( COND_DOG_LOST_PHYSICS_ENTITY );
	}
}
开发者ID:WorldGamers,项目名称:Mobile-Forces-Source,代码行数:49,代码来源:npc_dog.cpp


注:本文中的SetCondition函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。