예제 #1
0
void CivilianAI::ComputeState(int nStimType)
{
	int nStim = nStimType;

	if(nStimType == -1)
		nStim = ComputeStimuli();

	if(!nStim)
	{
		SetNewState(StateStrToInt(m_szAIState));
	}
	else
	{
		if(m_nState == STATE_Escape_Hide)
		{
			SetNewState(STATE_Escape_Hide);
		}
		else if(m_bScared || (m_fStimuli[HEALTH] < 1.0f))
		{
			m_bScared = DTRUE;
			SetNewState(STATE_Escape_RunAway);
		}
		else
			SetNewState(StateStrToInt(m_szAIState));
	}

	return;
}
예제 #2
0
void UndeadGideon::ComputeState(int nStimType)
{
	int nStim = nStimType;

	if(nStimType == -1)
		nStim = ComputeStimuli();

	DFLOAT fHeight = (DFLOAT)fabs(m_vTargetPos.y - m_MoveObj.GetPos().y);

	if(nStim == 0)
	{
		switch(m_nState)
		{
			case STATE_Idle:				SetNewState(STATE_Idle);			break;
			case STATE_SearchVisualTarget:	SetNewState(STATE_Idle);			break;
			case STATE_SearchSmellTarget:	SetNewState(STATE_Idle);			break;
			default:						SetNewState(STATE_SearchSmellTarget);	break;
		}
	}
	else
	{
		if(nStimType == STIM_SMELL)
			SetNewState(STATE_SearchSmellTarget);
		else if(m_fStimuli[SIGHT] <= 0.85f || fHeight > m_vDims.y)
			SetNewState(STATE_AttackFar);
		else
			SetNewState(STATE_AttackClose);
	}

	return;
}
예제 #3
0
파일: bug.cpp 프로젝트: Arc0re/lithtech
void BugAI::AI_STATE_Idle()
{
	if(ComputeStimuli())
	{
		ComputeState();
		m_pServerDE->SetNextUpdate(m_hObject,0.1f);
		return;
	}
	else
		m_pServerDE->SetNextUpdate(m_hObject,0.2f);

	switch(Metacmd)
	{
		case 1:		char szSound[256];
					_mbscpy((unsigned char*)szSound, (const unsigned char*)SOUND_IDLE);
					m_pAnim_Sound->GetSoundPath(szSound,m_pServerDE->IntRandom(1,NUM_BUG_IDLE));

					PlayAISound(szSound, 1000.0f);					

					Metacmd++;			break;
		case 2:		MC_Idle();						break;
		case 3:		m_fRadsLeft = m_pServerDE->Random(-1.56f,1.56f);	
					Metacmd++;						break;
		case 4:		MC_Turn();						break;
		case 5:		MC_Run();						break;
		case 6:		SetNewState(STATE_Idle);		break;
	}

	return;
}
예제 #4
0
void GremlinAI::AI_STATE_GuardLocation()
{
	int nStimType = ComputeStimuli();

	MC_FaceTarget();
	Metacmd--;

	switch(Metacmd)
	{
		case 1:		if(nStimType != STIM_SMELL && nStimType > 0)
						Metacmd++;

					break;
		case 2:		MC_Taunt_Bold();		break;
		case 3:		if(m_fStimuli[SIGHT] <= m_fSeeingDist || m_nCurMetacmd == MC_FIRE_STAND)
					{
						MC_Fire_Stand();
					}
					else
						Metacmd++;

					break;
		case 4:		if(m_fStimuli[HEALTH] <= 0.50f)
						ComputeState();
					else
						Metacmd = 1;			
					
					break;
	}

	return;
}
예제 #5
0
void GremlinAI::ComputeState(int nStimType)
{
	int nStim = nStimType;

	if(nStimType == -1)
		nStim = ComputeStimuli();

	if(nStim == 0)
	{
		switch(m_nState)
		{
			case STATE_Idle:				SetNewState(STATE_Idle);			break;
			case STATE_SearchVisualTarget:	SetNewState(STATE_Idle);			break;
			case STATE_SearchSmellTarget:	SetNewState(STATE_Idle);			break;
			default:						SetNewState(STATE_SearchSmellTarget);	break;
		}
	}
	else
	{
		if(nStimType == STIM_SMELL)
			SetNewState(STATE_SearchSmellTarget);
		else if(m_fStimuli[SIGHT] <= 0.75f)
			SetNewState(STATE_AttackFar);
		else
			SetNewState(STATE_AttackClose);
	}

	return;
}
예제 #6
0
void CultistAI::ComputeState(int nStimType)
{
	int nStim = nStimType;

	if(nStimType == -1)
		nStim = ComputeStimuli();

	DFLOAT fHeight = (DFLOAT)fabs(m_vTargetPos.y - m_MoveObj.GetPos().y);

	if(!nStim)
	{
		switch(m_nState)
		{
			case STATE_Idle:				SetNewState(STATE_Idle);			break;
			case STATE_SearchVisualTarget:	SetNewState(STATE_Idle);			break;
			case STATE_SearchSmellTarget:	SetNewState(STATE_Idle);			break;
			case STATE_FindAmmo:			SetNewState(m_nLastState);			break;
			case STATE_FindHealth:			SetNewState(m_nLastState);			break;
			case STATE_Escape_RunAway:		SetNewState(STATE_Idle);
			case STATE_AttackFar:			
			case STATE_AttackClose:			
			default:						if(m_nLastState == STATE_GuardLocation)
												SetNewState(STATE_GuardLocation);
											else if(fHeight <= m_vDims.y && m_fStimuli[HEALTH] >= 0.50f)
												SetNewState(STATE_SearchVisualTarget);
											else
												SetNewState(STATE_Idle);

											break;
		}
	}
	else
	{
		if(m_fStimuli[HEALTH] < 0.25f)
		{
			SetNewState(STATE_Escape_RunAway);
			return;
		}
		else if(m_fStimuli[HEALTH] < 0.50f)
		{
			SetNewState(STATE_AttackFar);
			return;
		}
		else
		{
			if(m_fStimuli[SIGHT] <= 0.5f || fHeight > m_vDims.y)
				SetNewState(STATE_AttackFar);
			else
				SetNewState(STATE_AttackClose);
		}
	}

	return;
}
예제 #7
0
void MadScientistAI::ComputeState(int nStimType)
{
	int nStim = nStimType;

	if(nStimType == -1)
		nStim = ComputeStimuli();

	if(nStim == 0)
	{
		SetNewState(StateStrToInt(m_szAIState));
	}
	else
	{
		SetNewState(STATE_Escape_Hide);
	}

	return;
}
예제 #8
0
void MadScientistAI::AI_STATE_Idle()
{
	int nStimType = ComputeStimuli();

	if(nStimType > 0)
	{
		m_pServerDE->SetNextUpdate(m_hObject, 0.001f);
		ComputeState(nStimType);
		return;
	}

	m_pServerDE->SetNextUpdate(m_hObject, 0.1f);

	switch(Metacmd)
	{
		case 1:		MC_Idle();			break;
		case 2:		ComputeState();		break;
	}

	return;
}
예제 #9
0
파일: Naga.cpp 프로젝트: Arc0re/lithtech
void Naga::ComputeState(int nStimType)
{
	int nStim = nStimType;

	if(nStimType == -1)
		nStim = ComputeStimuli();

	if(!nStim)
	{
		switch(m_nState)
		{
			case STATE_Idle:				SetNewState(STATE_Idle);				break;
			case STATE_SearchVisualTarget:	SetNewState(STATE_Idle);				break;
			default:						SetNewState(STATE_SearchVisualTarget);	break;
		}
	}
	else
	{
		if(m_fStimuli[SENSE] > 0.0f && m_fStimuli[SIGHT] <= 0.0f)
		{
			SetNewState(STATE_AttackFar);
			return;
		}

		//if health is low or threat is high, attack close
		if(m_fStimuli[HEALTH] < 0.25f || m_fStimuli[THREAT] > 0.75f)
		{
			SetNewState(STATE_AttackClose);
			return;
		}

		if(m_fStimuli[SIGHT] > 0.85f)
			SetNewState(STATE_AttackClose);
		else
			SetNewState(STATE_AttackFar);
	}

	return;
}
예제 #10
0
void DeathShroud::ComputeState(int nStimType)
{
	int nStim = nStimType;

	if(nStimType == -1)
		nStim = ComputeStimuli();

	if(!nStim)
	{
		switch(m_nState)
		{
			case STATE_Idle:				SetNewState(STATE_Idle);			break;
			case STATE_SearchVisualTarget:	SetNewState(STATE_Idle);			break;
			case STATE_SearchSmellTarget:	SetNewState(STATE_Idle);			break;
			default:						SetNewState(STATE_SearchVisualTarget);	break;
		}
	}
	else
	{
		SetNewState(STATE_AttackFar);				
	}
	return;
}
예제 #11
0
void OpheliaREV::AI_STATE_Escape_RunAway()
{
	if(Metacmd > 1)
	{
		int nStimType = ComputeStimuli();

		if(nStimType > 0)
		{
			ComputeState(nStimType);
			return;
		}
	}

	DFLOAT fDim = (DFLOAT)sqrt((m_vDims.x * m_vDims.x) + (m_vDims.z * m_vDims.z)) + 0.1f;

	switch(Metacmd)
	{
		case 1:		m_hTrackObject = FindObjectInRadius(m_pServerDE->GetClass("ExitHint"), m_fSeeingDist, FIND_VISIBLE | FIND_AVOID_TARGET);

					if(m_hTrackObject)
					{
						m_pServerDE->GetObjectPos(m_hTrackObject,&m_vTrackObjPos);

						MC_FacePos(m_vTrackObjPos);

						if(!m_MoveObj.CalculatePath(m_vTrackObjPos))
							SetNewState(STATE_Idle);
					}
					else
						SetNewState(STATE_AttackFar);
					
					break;
		case 2:	
		{
					DVector* pvPos = m_MoveObj.GetNextPathPoint();
					
					if(pvPos)
						MC_FacePos(*pvPos);	
					else
						SetNewState(STATE_Escape_RunAway);

					break;
		}
		case 3:		
		{
					DVector vPoint = *m_MoveObj.GetNextPathPoint();
					vPoint.y = m_MoveObj.GetPos().y;

					if(VEC_DIST(vPoint, m_MoveObj.GetPos()) <= fDim/2)
					{
						if(!m_MoveObj.MoveToNextPathPoint())
						{
							MC_FacePos(m_vTargetPos);
						}
						else
						{
							Metacmd = 2;
						}
					}
					else
						MC_Run();

					break;
		}
		case 4:		ComputeState();			break;
	}

	return;}