void CStateManagerFracture::execute()
{
	u32 state_id = u32(-1);
	const CEntityAlive* enemy	= object->EnemyMan.get_enemy();

	if (enemy) {
		switch (object->EnemyMan.get_danger_type()) {
				case eStrong:	state_id = eStatePanic; break;
				case eWeak:		state_id = eStateAttack; break;
		}
	} else if (object->HitMemory.is_hit()) {
		state_id = eStateHitted;
	} else if (object->hear_interesting_sound || object->hear_dangerous_sound) {
		state_id = eStateHearDangerousSound;
	} else {
		if (can_eat()) state_id = eStateEat;
		else {
			// Rest & Idle states here 
			state_id = eStateRest;
		}
	}

	// установить текущее состояние
	select_state(state_id); 

	// выполнить текущее состояние
	get_state_current()->execute();

	prev_substate = current_substate;
}
Beispiel #2
0
void CStateManagerZombie::execute()
{
	if (object->com_man().ta_is_active()) return;
	
	u32 state_id = u32(-1);
	
	if (!object->is_under_control()) {
	
		const CEntityAlive* enemy	= object->EnemyMan.get_enemy();

		if (enemy) {
			state_id = eStateAttack;
		} else if (check_state(eStateHearHelpSound)) {
			state_id = eStateHearHelpSound;
		} else if (object->hear_interesting_sound || object->hear_dangerous_sound) {
			state_id = eStateHearInterestingSound;
		} else {
			if (can_eat())	state_id = eStateEat;
			else			state_id = eStateRest;
		}
	} else state_id = eStateControlled;

	// установить текущее состояние
	select_state(state_id); 

	// выполнить текущее состояние
	get_state_current()->execute();

	prev_substate = current_substate;
}
Beispiel #3
0
void CStateManagerDog::execute()
{
	u32 state_id = u32(-1);

	if (!object->is_under_control()) {

		const CEntityAlive* enemy	= object->EnemyMan.get_enemy();

		if (enemy) {
			switch (object->EnemyMan.get_danger_type()) {
				case eStrong:	state_id = eStatePanic; break;
				case eWeak:		state_id = eStateAttack; break;
			}
		} else if (object->HitMemory.is_hit()) {
			state_id = eStateHitted;
		} else if (check_state(eStateHearHelpSound)) {
			state_id = eStateHearHelpSound;
		} else if (object->hear_interesting_sound) {
			state_id = eStateHearInterestingSound;
		} else if (object->hear_dangerous_sound) {
			state_id = eStateHearDangerousSound;	
		} else {
			if (can_eat())	state_id = eStateEat;
			else			state_id = eStateRest;
		}
	} else state_id = eStateControlled;

	select_state		(state_id); 

	// выполнить текущее состояние
	get_state_current()->execute();

	prev_substate		= current_substate;
}
void CStateManagerPoltergeist::execute()
{
	u32 state_id = u32(-1);

	if ( object->EnemyMan.get_enemy() && object->detected_enemy() )
	{
		state_id = eStateAttack_AttackHidden;
	}
	else
	{
		state_id = eStateRest;
	}

	//const CEntityAlive* enemy	= object->EnemyMan.get_enemy();

	//if (enemy) {
	//	if (object->is_hidden()) state_id = eStateAttack_AttackHidden;
	//	else {
	//		switch (object->EnemyMan.get_danger_type()) {
	//			case eStrong:	state_id = eStatePanic; break;
	//			case eWeak:		state_id = eStateAttack; break;
	//		}
	//	}
	//} else if (object->HitMemory.is_hit() && !object->is_hidden()) {
	//	state_id = eStateHitted;
	//} else if (object->hear_dangerous_sound) {
	//	if (!object->is_hidden()) state_id = eStateHearDangerousSound;
	//	else state_id = eStateHearInterestingSound;
	//} else if (object->hear_interesting_sound ) {
	//	state_id = eStateHearInterestingSound;
	//} else {
	//	if (can_eat()) state_id = eStateEat;
	//	else state_id = eStateRest;
	//	
	//	if (state_id == eStateEat) {
	//		if (object->CorpseMan.get_corpse()->Position().distance_to(object->Position()) < 5.f) {
	//			if (object->is_hidden()) {
	//				object->CEnergyHolder::deactivate();
	//			}
	//			
	//			object->DisableHide();
	//		}
	//	}

	//}

	////if (state_id == eStateAttack_AttackHidden) polter_attack();

	//if ((prev_substate == eStateEat) && (state_id != eStateEat)) 
	//	object->EnableHide();


	select_state(state_id); 

	// выполнить текущее состояние
	get_state_current()->execute();

	prev_substate = current_substate;
}
void CStateManagerPsyDog::execute()
{
	const CEntityAlive* enemy	= object->EnemyMan.get_enemy();

	if (enemy && dynamic_cast<const CActor*>(enemy) && smart_cast<CPsyDog*>(object)->must_hide()) {
		
		select_state(eStateAttack_Psy); 
	
		// выполнить текущее состояние
		get_state_current()->execute();

		prev_substate = current_substate;
	} else {
		inherited::execute();
	}
}
void CStateManagerBloodsucker::execute ()
{
	u32 state_id = u32(-1);

	const CEntityAlive* enemy = object->EnemyMan.get_enemy();
	
	if ( !object->is_drag_anim_jump() && !object->is_animated() )
	{
		if ( enemy ) 
		{
			 if ( check_state(eStateCustom_Vampire) ) 
			 {
				state_id = eStateCustom_Vampire;
			 } 
			 else 
			 {
				switch ( object->EnemyMan.get_danger_type() )
				{
					case eStrong: state_id = eStatePanic; break;
					case eWeak:	  state_id = eStateAttack; break;
				}
			}
		} 
		else if ( object->HitMemory.is_hit() ) 
		{
			state_id = eStateHitted;
		} 
		else if ( object->hear_interesting_sound )
		{
			state_id = eStateHearInterestingSound;
		} 
		else 
		{
			if ( can_eat() ) state_id = eStateEat;
			else			 state_id = eStateRest;
		}

		///////////////////////////////////////////////////////////////////////////////
		// Additional
		///////////////////////////////////////////////////////////////////////////////

		// check if start interesting sound state
// 		if ( (prev_substate != eStateHearInterestingSound) && (state_id == eStateHearInterestingSound) )
// 		{
// 			object->start_invisible_predator();
// 		} 
// 		else
// 		// check if stop interesting sound state
// 		if ( (prev_substate == eStateHearInterestingSound) && (state_id != eStateHearInterestingSound) ) 
// 		{
// 			object->stop_invisible_predator();
// 		}

		select_state(state_id); 

		// выполнить текущее состояние
		get_state_current()->execute();

		prev_substate = current_substate;
	}
	else
	{
		state_id = eStateCustom; 

		if ( object->is_drag_anim_jump() )
		{
			select_state(state_id); 

			// выполнить текущее состояние
			get_state_current()->execute();

			prev_substate = current_substate;

			drag_object();
		}
	}	
}