Ejemplo n.º 1
0
void AIEnemyGMonster::Attack()
{
/*#ifdef _DEBUG
	char temp[512];
	sprintf(temp, "{AI}[GM] (state:%d)", current_state);
	OutputDebugString(temp);
#endif*/
	
	/*if(aiinput->GetDirection())
	{
		if(GetAIMapCord(xtile, ytile) == BLK_STOPRIGHT ) 
		{
			aioutput->moveStop();
			ChangeAttackState((attackstate++)%2);
		}
	}
	else
	{
		if(GetAIMapCord(xtile, ytile) == BLK_STOPLEFT)
		{
			aioutput->moveStop();
			ChangeAttackState((attackstate++)%2);
		}
	}*/
	
	int	pxt = aio->player_input->GetXTilePos();
	int pyt = aio->player_input->GetYTilePos();
	float pxl = aio->player_input->GetXLoc();
	
	if( (abs(pyt - ytile) <=1) && (fabs(pxl - xpos) >= attack_range) ) 
	{
		aioutput->moveStop();
		ChangeState(AIS_CHASE);
		return;
	}
	if(!aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_DAMAGED)
	{
		switch(attackstate)
		{
		case 0:
			FacePlayer();
			aioutput->SetAttack(0);
			aioutput->moveButton4();
			ChangeAttackState(1);
			break;
		case 1:
			aioutput->SetDirection(!aiinput->GetDirection());
			aioutput->SetAttack(0);
			aioutput->moveButton4();
			ChangeAttackState(0);
			break;
		}
	}

}
Ejemplo n.º 2
0
AIEnemyGMonster::AIEnemyGMonster()
{
	SetAttackRange(4*16);
	SetChaseRange(9);
	//ChangeState(AIS_PATROL);
	current_state = AIS_PATROL;
	ChangeAttackState(0);
	run_time = 4;
	run_timer = 4;
	wait_time = .25;
	wait_timer =.25;
	
}
Ejemplo n.º 3
0
void AIEnemyGMonster::Patrol()
{
	int pyt = aio->player_input->GetYTilePos();
	int pxt = aio->player_input->GetXTilePos();
/*#ifdef _DEBUG
	char temp[512];
	sprintf(temp, "{AI}[GM] (state:%d)", current_state);
	OutputDebugString(temp);
#endif*/
	if(ignore_player)
	{
		if( (abs(pyt - ytile) <=1) && (fabs(aio->player_input->GetXLoc() - xpos) <= attack_range) )
		{
			ignore_player = false;
			aioutput->moveStop();
			ChangeAttackState(0);
			ChangeState(AIS_ATTACK);
			return;
		}
	}
	else
	{
		if( (abs(pyt - ytile) <=1) && (abs(pxt - xtile) <= chase_range) )
		{
			if(!CheckObstruct()) 
			{
				aioutput->moveStop();
				ChangeState(AIS_CHASE);
				return;
			}
			
		}
	}
	
	if(run_timer <=0 ) { wait_timer = wait_time; aioutput->moveStop(); ChangeState(AIS_WAIT);}
	else
	{
		run_timer -= time;
		if(!IsStopBlock())
		{
			if(aiinput->GetDirection()) aioutput->moveRight();
			else aioutput->moveLeft();
		}
		else
		{
			if(aiinput->GetDirection()) aioutput->moveLeft();
			else aioutput->moveRight();
		}
	}
	
}
Ejemplo n.º 4
0
void AIEnemyGMonster::Chase()
{
	int	pxt = aio->player_input->GetXTilePos();
	int pyt = aio->player_input->GetYTilePos();
	float pxl = aio->player_input->GetXLoc();
/*#ifdef _DEBUG
	char temp[512];
	sprintf(temp, "{AI}[GM] (state:%d)(tileheight:%d)", current_state, aiinput->GetTileHeight());
	OutputDebugString(temp);
#endif*/
	if(abs(pxt - xtile) > chase_range ) 
	{
		aioutput->moveStop();
		ChangeState(AIS_PATROL);
	}
	if(IsStopBlock()) 
	{
//		was_stop_block = true;
//		xstoploc = xtile;
		ignore_player = true;
		aioutput->moveStop();
		ChangeState(AIS_PATROL);
	}
	else if( (abs(pyt - ytile) <=1) && (fabs(pxl - xpos) <= attack_range) )
	{
		aioutput->moveStop();
		ChangeAttackState(0);
		aioutput->moveStop();
		ChangeState(AIS_ATTACK);
	}
	else
	{
		FacePlayer();
		if(aiinput->GetDirection()) aioutput->moveRight();
		else aioutput->moveLeft();
	}
}
void AIEnemyAdvancedGeneticMonster2::Attack()
{
/*#ifdef _DEBUG
	char temp[256];
	sprintf(temp, "[AGM] attackstate (xtile:%d)(ytile:%d)(stop:%d)(direction:%d)", xtile, ytile, IsStopBlock(), aiinput->GetDirection());
	OutputDebugString(temp);
#endif*/
	
	int pyt = aio->player_input->GetYTilePos();
	int th = abs(ytile - pyt);

	//if(th > attack_height) ChangeState(AIS_PATROL);

	if(IsStopBlock())
	{
		ignore_player = true;
		ChangeState(AIS_PATROL);
		return;
	}
	
	switch(attackstate)
	{
/*	case AIS_AGM_INTRO:
		if(!aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_DAMAGED)
		{
			FacePlayer();
			aioutput->SetAttack(1);
			aioutput->moveButton4();
			ChangeAttackState(AIS_AGM_SLASH);
		}
		break;*/
	case AIS_AGM_SLASH:	
		if(aiinput->GetStateFlags()->S_ON_GROUND && !aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_DAMAGED)
		{
			if(fabs(aio->player_input->GetXLoc()-xpos) <= attack_range) 
			{
				
				FacePlayer();
				aioutput->SetAttack(0);
				aioutput->moveButton4();
				ChangeAttackState(AIS_AGM_JUMP);

			}
			else ChangeState(AIS_CHASE);
		}
		break;	
	case AIS_AGM_JUMP:
		if(!aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_DAMAGED)
		{
			FacePlayer();
			aioutput->moveButton3();
			ChangeAttackState(AIS_AGM_SLASH2);
		}
		break;
	case AIS_AGM_SLASH2:
		if(aiinput->GetStateFlags()->S_ON_GROUND && !aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_DAMAGED)
		{
			if(fabs(aio->player_input->GetXLoc()-xpos) <= attack_range) 
			{
				
				FacePlayer();
				aioutput->SetAttack(0);
				aioutput->moveButton4();
				ChangeAttackState(AIS_AGM_RUN);

			}
			else ChangeState(AIS_CHASE);
		}
		break;

	/*case AIS_AGM_SPIKE:
		if(aiinput->GetStateFlags()->S_ON_GROUND && !aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_DAMAGED)
		{
			FacePlayer();
			aioutput->SetAttack(2);
			aioutput->moveButton4();
			ChangeAttackState(AIS_AGM_RUN);
			run_direction = aiinput->GetDirection();
		}
		break;*/
	case AIS_AGM_RUN:
		if(!aiinput->GetStateFlags()->S_ATTACK)
		{
			if(!IsStopBlock())
			{
				if(run_direction) aioutput->moveRight();
				else aioutput->moveLeft();
				
			}
			else 
			{
				aioutput->moveStop();
				ChangeAttackState(AIS_AGM_SLASH);
			}
		}
		
	default:
		break;
	}



	
/*	switch(attackstate)
	{
	case AIS_AGM_INTRO:
		if(!aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_DAMAGED)
		{
			FacePlayer();
			aioutput->SetAttack(1);
			aioutput->moveButton4();
			ChangeAttackState(AIS_AGM_SLASH);
		}
		break;
	case AIS_AGM_SLASH:
		if((th < attack_height) && (fabs(aio->player_input->GetXLoc()-xpos) <= attack_range)) 
		{
			if(!aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_JUMP && !aiinput->GetStateFlags()->S_DAMAGED)
			{
				FacePlayer();
				aioutput->SetAttack(0);
				aioutput->moveButton4();
				
			}
			if(damaged)
			{
				damaged = false;
				if(damage_count == 2) 
				{
					ChangeAttackState(AIS_AGM_SPIKE);
				}
				else
				{
					damage_count++;
					ChangeAttackState(AIS_AGM_JUMP);
				}
			}
		}
		else if(th > attack_height) ChangeState(AIS_PATROL);
		else ChangeState(AIS_CHASE);
		
		break;
	case AIS_AGM_JUMP:
		if(!aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_DAMAGED)
		{
			aioutput->moveButton3();
			ChangeAttackState(AIS_AGM_SLASH);
		}
		break;
	case AIS_AGM_SPIKE:
		if(!aiinput->GetStateFlags()->S_ATTACK && !aiinput->GetStateFlags()->S_DAMAGED)
		{
			aioutput->SetAttack(2);
			aioutput->moveButton4();
			ChangeAttackState(AIS_AGM_SLASH);
			damage_count = 0;
		}
		break;
	default:
		break;
	}*/
}