Exemple #1
0
void CAI_Rat::UpdateCL			()
{

	///////////////////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
	if (monster_squad().get_squad(this)->GetLeader() == this) {

		if (m_walk_on_way && m_path) draw_way();

	}
#endif
	///////////////////////////////////////////////////////////////////////////////////////

	if (!m_pPhysicsShell && !g_Alive())
		CreateSkeleton			();

	if (!Useful()) {
		inherited::UpdateCL		();
		Exec_Look				(Device.fTimeDelta);

		CMonsterSquad *squad	= monster_squad().get_squad(this);

		if (squad && 
			((squad->GetLeader() != this && !squad->GetLeader()->g_Alive()) ||
			squad->get_index(this) == u32(-1))
			) squad->SetLeader(this);

		if (squad &&
			squad->SquadActive() &&
			squad->GetLeader() == this &&
			m_squad_count != squad->squad_alife_count()
			) 
		{
			squad->set_rat_squad_index(squad->GetLeader());
			m_squad_count = squad->squad_alife_count();
		}
	}
	else {
		if (!H_Parent() && m_pPhysicsShell && m_pPhysicsShell->isActive())
			m_pPhysicsShell->InterpolateGlobalTransform(&XFORM());

		CPhysicsShellHolder::UpdateCL	();
		CEatableItem::UpdateCL			();
	}
}
Exemple #2
0
void CAI_Rat::set_dir()
{
	if ((Device.dwTimeGlobal - m_previous_query_time > TIME_TO_GO) || !m_previous_query_time) {
		CMonsterSquad *squad	= monster_squad().get_squad(this);
		Fvector m_enemy_position = memory().enemy().selected()->Position();
		if (squad && squad->SquadActive())
		{
			float m_delta_Angle = angle_normalize((PI * 2) / squad->squad_alife_count());
			float m_heading, m_pitch;
			Fvector m_temp, m_dest_direction;
			m_temp = squad->GetLeader()->Position();
			m_dest_direction.x = (m_temp.x - m_enemy_position.x) / m_temp.distance_to(m_enemy_position);
			m_dest_direction.y = (m_temp.y - m_enemy_position.y) / m_temp.distance_to(m_enemy_position);
			m_dest_direction.z = (m_temp.z - m_enemy_position.z) / m_temp.distance_to(m_enemy_position);
			m_dest_direction.getHP(m_heading, m_pitch);
			m_heading = angle_normalize(m_heading + m_delta_Angle * squad->get_index(this));
			m_dest_direction.setHP(m_heading, m_pitch);
			m_dest_direction.mul(0.5f);
			m_enemy_position.add(m_enemy_position,m_dest_direction);
		}

		m_tGoalDir.set(m_enemy_position);
	}
}