Example #1
0
void BaseEnemy::MoveToXTile(int xtile)
{
		
	//if(IsStopBlock()){aioutput->moveStop(); ChangeState(AIS_WAIT); }

	//FacePlayer();

	if(aiinput->GetXTilePos() < movetoxtile) 
	{
		if(!IsStopBlock()) aioutput->moveRight();
		else 
		{
			aioutput->moveStop();
			ChangeState(AIS_WAIT);
		}
	}
	else if(aiinput->GetXTilePos() > movetoxtile) 
	{
		if(!IsStopBlock()) aioutput->moveLeft();
		else 
		{
			aioutput->moveStop();
			ChangeState(AIS_WAIT);
		}
	}
	else
	{
		aioutput->moveStop();
		ChangeState(AIS_WAIT);
	}

}
void AIEnemyJunkbotTrack::Chase()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs((pyt+aio->player_input->GetTileHeight()) - (ytile + aiinput->GetTileHeight()));
	
    FacePlayer();



	if( (((pyt > ytile) && (th < 1)) || ((pyt <= ytile) && (th <= 2)))  && (abs(aio->player_input->GetXTilePos()-xtile) <= chase_range))
	{
		if(xpos < (aio->player_input->GetXLoc()-attack_range)) 
		{
			if(!IsStopBlock()) aioutput->moveRight();
			else aioutput->moveStop();
		}
		else if(xpos > (aio->player_input->GetXLoc()+attack_range)) 
		{
			if(!IsStopBlock()) aioutput->moveLeft();
			else aioutput->moveStop();
		}
		else
		{
			aioutput->moveStop();
			ChangeState(AIS_ATTACK);
		}
	}
	else ChangeState(AIS_PATROL);
}
void AIEnemyAdvancedGeneticMonster2::Patrol()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs(ytile - pyt);
	
	
/*#ifdef _DEBUG
	char temp[256];
	sprintf(temp, "[AGM] patrolstate (xtile:%d)(ytile:%d)(stop:%d)", xtile, ytile, IsStopBlock());
	OutputDebugString(temp);
#endif*/
	
	
	if(fabs(aio->player_input->GetXLoc() - xpos) <= 8)
	{
		ignore_player = false;
		ChangeState(AIS_ATTACK);
	}
	
	if(th > attack_height || ignore_player) 
	{
		if(!IsStopBlock())
		{
			if(aiinput->GetDirection()) aioutput->moveRight();
			else aioutput->moveLeft();
		}
		else
		{
			if(aiinput->GetDirection()) aioutput->moveLeft();
			else aioutput->moveRight();
		}
	}
	ChangeState(AIS_CHASE);

}
void AIEnemyElitePistolGaurd::Patrol()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs(ytile - pyt);
	
	
	
	if( (th <= tileheight) && (fabs(aio->player_input->GetXLoc()-xpos) <= attack_range))
	{
		aioutput->moveStop();
		ChangeState(AIS_ATTACK);
		fire=0;
	}
	
	else if(IsStopBlock())
	{
		if(aiinput->GetDirection()) aioutput->moveLeft();
		else aioutput->moveRight();
	}

	else
	{
		if(aiinput->GetDirection()) aioutput->moveRight();
		else aioutput->moveLeft();
	}
}
void AIEnemyAdvancedGeneticMonster2::Chase()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs(ytile - pyt);
	int pxt = aio->player_input->GetXTilePos();

/*#ifdef _DEBUG
	char temp[256];
	sprintf(temp, "[AGM] chasestate (xtile:%d)(ytile:%d)(stop:%d)", xtile, ytile, IsStopBlock());
	OutputDebugString(temp);
#endif*/
	if(IsStopBlock())
	{
		ignore_player = true;
		ChangeState(AIS_PATROL);
		return;
	}
	
	if(fabs(aio->player_input->GetXLoc()-xpos) <= attack_range) 
	{
		aioutput->moveStop();
		ChangeState(AIS_ATTACK);
		//ChangeAttackState(AIS_AGM_SLASH);
	
	}
	else if(th <=1)
	{
		if(xtile < pxt ) aioutput->moveRight();
		else aioutput->moveLeft();
	}
	else ChangeState(AIS_PATROL);
	
}
void AIEnemyEliteBatonGaurd::Chase()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs(ytile - pyt);
/*#ifdef _DEBUG
	char temp[256];
	sprintf(temp, "[EBG](xt:%d)(yt:%d)(stop:%d)(state:chase)", xtile, ytile, IsStopBlock()); 
	OutputDebugString(temp);
#endif*/
	
	if(FacePlayer())
	{
		swing_sword=0;
	}
	if(IsStopBlock())
	{
		ignore_player = true;
		aioutput->moveStop();
		ChangeState(AIS_PATROL);
	}
	if((th <= tileheight) && (abs(aio->player_input->GetXTilePos()-xtile) <= chase_range))
	{
		if(xpos < (aio->player_input->GetXLoc()-attack_range)) 
		{
			if(!IsStopBlock()) aioutput->moveRight();
			else aioutput->moveStop();
		}
		else if(xpos > (aio->player_input->GetXLoc()+attack_range)) 
		{
			if(!IsStopBlock()) aioutput->moveLeft();
			else aioutput->moveStop();
		}
		else
		{
			aioutput->moveStop();
			ChangeState(AIS_ATTACK);
		}
	}
	else
	{
		aioutput->moveStop();
		ChangeState(AIS_PATROL);
	}

}
void AIEnemyEliteBatonGaurd::Patrol()
{
		int pyt = aio->player_input->GetYTilePos();
	int th = abs(ytile - pyt);

/*#ifdef _DEBUG
	char temp[256];
	sprintf(temp, "[EBG](xt:%d)(yt:%d)(stop:%d)(state:attack)", xtile, ytile, IsStopBlock()); 
	OutputDebugString(temp);
#endif*/	
	
/*	if( (th <= tileheight) && (fabs(aio->player_input->GetXLoc()-xpos) <= attack_range))
	{
		ChangeState(AIS_ATTACK);
		swing_sword=0;
		throw_star=time_star;
	}*/

	if(ignore_player)
	{
		if((th <= tileheight) && (fabs(aio->player_input->GetXLoc()-xpos) <= attack_range))
		{
			ignore_player = false;
			aioutput->moveStop();
			ChangeState(AIS_ATTACK);
		}
	}
	else
	{
	
		if((th <= tileheight) && (abs(aio->player_input->GetXTilePos()-xtile) <= chase_range))
		{
			aioutput->moveStop();
			ChangeState(AIS_CHASE);
			
		}
	}


	if(IsStopBlock())
	{
		if(aiinput->GetDirection()) aioutput->moveLeft();
		else aioutput->moveRight();
	}

	else
	{
		if(aiinput->GetDirection()) aioutput->moveRight();
		else aioutput->moveLeft();
	}

}
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();
		}
	}
	
}
Example #9
0
void AIEnemyPunk::Patrol()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs((pyt+aio->player_input->GetTileHeight()) - (ytile + aiinput->GetTileHeight()));
	
	
/*	if( (th <= tileheight) && (fabs(aio->player_input->GetXLoc()-xpos) <= attack_range))
	{
		ChangeState(AIS_ATTACK);
		swing_sword=0;
		throw_star=time_star;
	}*/

	
	if(ignore_player)
	{
		if( (((pyt > ytile) && (th < 1)) || ((pyt <= ytile) && (th <= 4)))  && (fabs(aio->player_input->GetXLoc()-xpos) <= attack_range))
		{
			ignore_player = false;
			ChangeState(AIS_ATTACK);
		}
	}
	else
	{
	
		if( (((pyt > ytile) && (th < 1)) || ((pyt <= ytile) && (th <= 4)))  && (abs(aio->player_input->GetXTilePos()-xtile) <= chase_range))
		{
			
			punch=0;
			ChangeState(AIS_CHASE);
			
		}
	}

	

	if(IsStopBlock())
	{
		if(aiinput->GetDirection()) aioutput->moveLeft();
		else aioutput->moveRight();
	}

	else
	{
		if(aiinput->GetDirection()) aioutput->moveRight();
		else aioutput->moveLeft();
	}
	
}
Example #10
0
void AIEnemyPunk::Chase()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs(ytile - pyt);

	
	if(FacePlayer())
	{
		punch=0;
	}
	if(IsStopBlock())
	{
		ignore_player = true;
		aioutput->moveStop();
		ChangeState(AIS_PATROL);
	}
	if((th <= tileheight) && (abs(aio->player_input->GetXTilePos()-xtile) <= chase_range))
	{
		if(xpos < (aio->player_input->GetXLoc()-attack_range)) 
		{
			if(!IsStopBlock()) aioutput->moveRight();
			else aioutput->moveStop();
		}
		else if(xpos > (aio->player_input->GetXLoc()+attack_range)) 
		{
			if(!IsStopBlock()) aioutput->moveLeft();
			else aioutput->moveStop();
		}
		else
		{
			aioutput->moveStop();
			ChangeState(AIS_ATTACK);
		}
	}
	else ChangeState(AIS_PATROL);
}
void AIEnemyGreenNinja::Chase()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs((pyt+aio->player_input->GetTileHeight()) - (ytile + aiinput->GetTileHeight()));
	
	if(FacePlayer())
	{
		swing_sword=0;
	}
	if(IsStopBlock())
	{
		ignore_player = true;
		aioutput->moveStop();
		ChangeState(AIS_PATROL);
	}
	
	if( (((pyt > ytile) && (th < 1)) || ((pyt <= ytile) && (th <= 4)))  && (abs(aio->player_input->GetXTilePos()-xtile) <= chase_range))
	{
		if(xpos < (aio->player_input->GetXLoc()-attack_range)) 
		{
			if(!IsStopBlock()) aioutput->moveRight();
			else aioutput->moveStop();
		}
		else if(xpos > (aio->player_input->GetXLoc()+attack_range)) 
		{
			if(!IsStopBlock()) aioutput->moveLeft();
			else aioutput->moveStop();
		}
		else
		{
			aioutput->moveStop();
			ChangeState(AIS_ATTACK);
		}
	}
	else ChangeState(AIS_PATROL);
}
void AIEnemyFlyingSentryB::Patrol()
{
//	if(abs(aio->player_input->GetXTilePos()-xtile) <= MAX_ENEMY_DIST) ChangeState(AIS_ATTACK);
	
	
/*#ifdef _DEBUG
	char temp[512];
	sprintf(temp, "{AI}[sentryB] (uxb:%d) (lxb:%d) (xt:%d) (yt:%d) (dir:%d)", aiinput->upper_patrol_x, aiinput->lower_patrol_x, xtile, ytile, aiinput->GetDirection());
	OutputDebugString(temp);
#endif*/
	
	if(IsStopBlock())
	{
		
		if(aiinput->GetDirection()) aioutput->moveLeft();
		else aioutput->moveRight();
		

	}
	else
	{
		if(aiinput->GetDirection()) aioutput->moveRight();
		else aioutput->moveLeft();
	}
	
	

	float pxl = aio->player_input->GetXLoc();
	
	if(time_attack <= 0)
	{
		if(!aiinput->GetStateFlags()->S_DAMAGED)
		{
			time_attack = attack_time;
			if( ((pxl > xpos) && aiinput->GetDirection()) || ((pxl < xpos) && !aiinput->GetDirection()) )
			{
				aioutput->moveButton4();
			
			}
		}
	}else time_attack -= time;

}
void AIEnemyElitePistolGaurd::Chase()
{

	if(IsStopBlock()){
		/*face the player and take a final shot for fun :) */
		
		aioutput->moveStop();
		//FacePlayer();
		//aioutput->moveButton4();
	    ChangeState(AIS_PATROL); 
	}

	else if(aio->player_input->GetXLoc() <= (xpos-chase_range*16)) aioutput->moveLeft();
	else if(aio->player_input->GetXLoc() >= (xpos+chase_range*16)) aioutput->moveRight();
	else
	{
		aioutput->moveStop();
		ChangeState(AIS_ATTACK);
	}	
}
Example #14
0
void AIEnemyWolf::Patrol()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs((pyt+aio->player_input->GetTileHeight()) - (ytile + aiinput->GetTileHeight()));
	

	if(IsStopBlock())
	{

		if(aiinput->GetDirection()) aioutput->moveLeft();
		else aioutput->moveRight();
	}

	else
	{
		if(aiinput->GetDirection()) aioutput->moveRight();
		else aioutput->moveLeft();
	}

}
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 AIEnemyFlyingSentryA::Patrol()
{
//	if(abs(aio->player_input->GetXTilePos()-xtile) <= MAX_ENEMY_DIST) ChangeState(AIS_ATTACK);
	
	if(IsStopBlock())
	{
		float dx, dy;
		aiinput->GetVelocityVector(&dx, &dy);

		if(dy >= 0)
		{
			aioutput->moveUp();
			yLocPrev = aiinput->GetYLoc();
		}
		else 
		{
			aioutput->moveDown();
			yLocPrev = aiinput->GetYLoc();
		}
	}
	else 
	{
		float dx, dy;
		aiinput->GetVelocityVector(&dx, &dy);

		if(dy >= 0) 
		{
			aioutput->moveDown();
			yLocPrev = aiinput->GetYLoc();
		}
		else if(dy < 0)
		{
			aioutput->moveUp();
			yLocPrev = aiinput->GetYLoc();
		}
		else
		{
			unsigned int i = rand()%2;

			if(i) aioutput->moveDown();
			else aioutput->moveUp();
		}
	}
//	else /*check for attack */
//		ChangeState(AIS_PATROL);

	time_attack -= time;

	if(time_attack < 0)
	{
		Attack();
		time_attack = attack_time;
	}
//	else
//	{
//		float dx, dy;
//		aiinput->GetVelocityVector(&dx, &dy);

//		if(dy <= 0) aioutput->moveDown();
//		else aioutput->moveUp();
//	}

/*
	if(abs(aio->player_input->GetXTilePos()-xtile) <= MAX_ENEMY_DIST) ChangeState(AIS_ATTACK);
	
	else if(IsStopBlock())
	{
		if(aiinput->GetDirection()) aioutput->moveLeft();
		else aioutput->moveRight();
	}

	else
	{
		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;
	}*/
}