/*-----d͐ݒ--------------------------*/
GSet(global.G,global.Gdir,1,1, 0,0,1,1);

with(objEnemyEdit){ if(Edit_Play) exit; }

/*-----LN^Ƃ̏̎擾---------------*/
playerDistance = point_distance(x,y,objPlayerDoll.x,objPlayerDoll.y);
playerDirection = point_direction(x,y,objPlayerDoll.x,objPlayerDoll.y);

/*-----[V̏--------------------*/
if(RECV_DAMAGE) playEnemySound(SOUND_DAMAGE);

if(!ChangeMotion){
	switch(MotionNum){
		case STAND :
			/* ̕ */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			/* ߂Â */
			if( !air && 100<playerDistance && playerDistance<450){ MotionChange(WALK,0,5); break; }

			/* ꍇɂĂ͌ */
			if( !objPlayerDoll.HALFBINDED && !air && 350>playerDistance && !instance_exists(Bullet) ){ 
				MotionChange(SHOT_NORMAL,0,10+random(50));
				break;
			}
			break;
		case WALK :
			switch(KeyFrmNum){
				case 1 : Move(-0.2*Direction,0); break;
				case 2 : Move(-2.5*Direction,0); break;
				case 3 : Move(-5.5*Direction,0); break;
				case 4 : if(KEYFRAME) playEnemySound(SOUND_STEP);
						 Move(-1.5*Direction,0); break;
			}
			/* ߂Â藣ꂽ肵~܂ */
			if( 100>playerDistance || playerDistance>550){ MotionChange(STAND,0,5); break; }

			/* ꍇɂĂ͌ */
			if( !objPlayerDoll.HALFBINDED && !air && 350>playerDistance && !instance_exists(Bullet) && random(100)<5 ){ 
				MotionChange(SHOT_NORMAL,0,5);
				break;
			}
			break;
		case SHOT_NORMAL :
			switch(KeyFrmNum){
				case 7 : 
					sound_play(sndVore03);
					if(!instance_exists(Bullet)){
						/* e̍쐬 */
						Fluid(x,y,c_white,5,15,10,30,10,0.5);
						Bullet = createBullet(x,y);
						Bullet.vspeed		= -10;
						Bullet.hspeed		= -40*Direction;
						Bullet.Picture		= SPRITE_BULLET;
					}
					break;
			}
			if(MOTIONEND) MotionChange(STAND,0,1);
			break;
		case SHOT_HARD :
			break;
		case DEAD_MOTION :
			switch(KeyFrmNum){
				case 1 : 
					if(KEYFRAME) effect_create_above(ef_smokeup,x,y,0,c_black);
					break;
			}
			if(MOTIONEND){
				instance_create(x,y,objExplosionSmall);
				Flash(c_white,0.1,0.05);

				Quake(5,5);
				sound_play(sndBomb);
				instance_destroy();
			}
			break;
	}
}

/*-----ѓ̏--------------------*/
with(Bullet){
	gravity = 2;
	image_angle = direction;
	image_alpha = 0.4;
	col = checkBlock(x,y);
	if( col ){
		sound_play(sndLotion);
		FluidwithLine(x,y-vspeed,c_white,10,5,10,0,180,0.5,col);
		destroyBullet();
	}
	col = checkPlayer(x,y);
	if( col ){
		with(col){
			if(!INV && !BINDED){
				DamageVoiceRandom_Low();
				sound_play(sndLotion);
				if(BINDED) addDamage(0, -1, -1, -1, -1, -1, -1);
				else{
					if(air){
						hspeed = other.hspeed/2;
						if(Direction){
							if(other.hspeed > 0) addSTDamage(5,20,FLYING_0, 0, 1, FLYING_0, 0, 2);
							else				 addSTDamage(5,20,FLYING_1, 0, 1, FLYING_1, 0, 2);
						}else{
							if(other.hspeed < 0) addSTDamage(5,20,FLYING_0, 0, 1, FLYING_0, 0, 2);
							else				 addSTDamage(5,20,FLYING_1, 0, 1, FLYING_1, 0, 2);
						}
					}else{
						if(!HALFBINDED){
							hspeed = other.hspeed/2;
							if(Direction){
								if(other.hspeed > 0){
									if(random(100)<50) addSTDamage(0,10,BINDED_FLUID_0, 0, 2, DOWN_1, 0, 2);
									else			   addSTDamage(0,10,BINDED_FLUID_1, 0, 2, DOWN_1, 0, 2);
								}else				 addSTDamage(0,10,BINDED_FLUID_2, 0, 2, DOWN_1, 0, 2);
							}else{
								if(other.hspeed < 0){
									if(random(100)<50) addSTDamage(0,10,BINDED_FLUID_0, 0, 2, DOWN_1, 0, 2);
									else			   addSTDamage(0,10,BINDED_FLUID_1, 0, 2, DOWN_1, 0, 2);
								}else				 addSTDamage(0,10,BINDED_FLUID_2, 0, 2, DOWN_1, 0, 2);
							}
						}else addSTDamage(0,10,null, null, null, null, null, null);
						HALFBINDED = true;
					}
				}
				sound_play(sndBulletHit);
				Quake(5,5);
				with(other){
					FluidwithLine(x,y-vspeed,c_white,20,5,10,0,180,0.5,col.Process[round(random(col.PARTS_MAX-1))]);
					destroyBullet();
				}
			}
		}
	}
	if(Time > 150) destroyBullet();
}