datei Nr3 enemy.c
Code:
var alarm;
var angriff;
var mission;
var kampf_distance;
var playerhealth=100;
#define befinden skill11
#define geld skill10
#define health skill9
#define passantmode skill8
#define xy skill7
ENTITY* enemy1;
ENTITY* fabrik_ent;
ENTITY* laden_ent;
ENTITY* bullets;
STRING* ss01_str = "Welcome to Planet Hope!
Dedanus System";
FONT* quest_font = "CourierNew#25";
PANEL* won_pan = //mein erstes panel
{
	pos_x = 50;
	pos_y = 110;
	layer = 10;
	button (0, 0, "won.jpg", "won.jpg", "won.jpg", gameover, null, null);
	//flags = OVERLAY | SHOW;
}
TEXT* planet_txt =
{font = quest_font;
	pos_x = 400;
	pos_y = 50;
	layer = 3;
	red=255;
	blue=0;
	green=174;	
}
function won()
{
	reset(won_pan,SHOW);
	level_load("ninjacat.wmb");
}
function got_shot(){
	my.ambient = 0;
	my.lightrange = 0;
	if (event_type == EVENT_CLICK) {
		angriff=1;
		set(gotonow,INVISIBLE);
		vec_set(to2,my.x);
	}
	if (event_type == EVENT_TOUCH) 
	{
		my.ambient = 100; // dann lass' ihn heller aussehen
		my.lightrange = 30; 
	}
	if (event_type == EVENT_IMPACT){
		if (you == bullets){
			my.health-=25;
	}}
	if (event_type == EVENT_SCAN){
		if (killart==1){
			wait(-0.5);
			my.health-=25;

		}
		if (killart==2){
			wait(-0.5);
			my.health-=100;
		}
		
		//ent_remove(my);
	}
}
function scan_view(){
	//proc_kill(4); // follow the entity smoothly
	set(my, PASSABLE | TRANSLUCENT);
	my.alpha = 30;
	my.ambient = 100;
	my.z = you.z -5; // move the triangle at the floor level
	my.scale_x=my.scale_x+6.2;
	while (you)
	{
		my.x = you.x;
		my.y = you.y;
		my.z = you.z ; // move the triangle at the floor level
		my.pan = you.pan;
		my.tilt = you.tilt;
		my.scale_y=my.scale_x;
		wait (1);
	}
	ent_remove(my);
}
action enemy(){
	enemy1=my;
	set(my,INVISIBLE);
	set(my,PASSABLE);
	while(mission!=1)
	{wait(1);
	}
	reset(my,INVISIBLE);
	reset(my,PASSABLE);
	my.health=100;
	my.emask = ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_RELEASE | ENABLE_SCAN; // the target is sensitive to impact with player's bullets
	my.emask |= ENABLE_TOUCH;
	my.emask |= ENABLE_CLICK;	
	my.event = got_shot;
	ent_create("dreieck.mdl", nullvector, scan_view);
	while(my.health!=0){
		c_scan(my.x, my.pan, vector(90, 90, 400), IGNORE_ME| SCAN_LIMIT);
		wait(1);
	}
	my.skill1=0;
	while(my.skill1<90){
		
		my.skill1 += 10*time_step;
		ent_animate(me,"tod",my.skill1,ANM_CYCLE);
		wait(1);
	}
	ent_animate(me,"tod",100,ANM_SKIP);
	gold+=10;
	mission+=1;
	wait(-1);
	ent_remove(my);
}
action gegner2(){
	set(my,INVISIBLE);
	set(my,PASSABLE);
	while(mission!=3)
	{wait(1);
	}
	reset(my,INVISIBLE);
	reset(my,PASSABLE);
	VECTOR toe2;
	my.health=100;
	my.emask = ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_RELEASE | ENABLE_SCAN; // the target is sensitive to impact with player's bullets
	my.emask |= ENABLE_TOUCH;
	my.emask |= ENABLE_CLICK;
	my.event = got_shot;
	ent_create("dreieck.mdl", nullvector, scan_view);
	while(my.health>1){
		c_scan(my.x, my.pan, vector(90, 60, 400), IGNORE_ME| SCAN_LIMIT);
		if (alarm==1){
			my.skill1 += 5*time_step;
			if (my.skill1 > 100) my.skill1 -= 100; 
			ent_animate(me,"move",my.skill1,ANM_CYCLE);
			//my.speed_x += (6-my.speed_x)/(2+(key_w^key_s)*5)*time_step;
			//c_move(my,vector(my.speed_x*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE);
			c_scan(my.x, my.pan, vector(90, 60, 400), IGNORE_ME| SCAN_LIMIT);
			vec_set(toe2,player.x);
			vec_sub(toe2, my.x);
			vec_to_angle(my.pan,toe2.x);
			my.tilt=0;
			c_move(my,vector(2*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE);
			kampf_distance = vec_dist(my.x,to2.x);
			if(kampf_distance<50){
				my.skill1=0;
			//	snd_play  (schwert_snd,100,0);
	while(my.skill1<90){
		my.skill1 += 10*time_step;
		ent_animate(me,"schwert",my.skill1,ANM_CYCLE);
		wait(1);
	}
	
				playerhealth-=10;
			}
		}
		
		wait(1);
	}
	my.skill1=0;
	while(my.skill1<90){
		
		my.skill1 += 10*time_step;
		ent_animate(me,"tod",my.skill1,ANM_CYCLE);
		wait(1);
	}
	ent_animate(me,"tod",100,ANM_SKIP);
	gold+=5;
	mission+=1;
	wait(-1);
	ent_remove(my);
}
action gegner3(){
	set(my,INVISIBLE);
	set(my,PASSABLE);
	while(mission!=8)
	{wait(1);
	}
	reset(my,INVISIBLE);
	reset(my,PASSABLE);
	VECTOR toe2;
	my.health=100;
	my.emask = ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_RELEASE | ENABLE_SCAN; // the target is sensitive to impact with player's bullets
	my.emask |= ENABLE_TOUCH;
	my.emask |= ENABLE_CLICK;
	my.event = got_shot;
	ent_create("dreieck.mdl", nullvector, scan_view);
	while(my.health>1){
		c_scan(my.x, my.pan, vector(90, 60, 400), IGNORE_ME| SCAN_LIMIT);
		if (alarm==1){
			my.skill1 += 5*time_step;
			if (my.skill1 > 100) my.skill1 -= 100; 
			ent_animate(me,"move",my.skill1,ANM_CYCLE);
			//my.speed_x += (6-my.speed_x)/(2+(key_w^key_s)*5)*time_step;
			//c_move(my,vector(my.speed_x*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE);
			c_scan(my.x, my.pan, vector(90, 60, 400), IGNORE_ME| SCAN_LIMIT);
			vec_set(toe2,player.x);
			vec_sub(toe2, my.x);
			vec_to_angle(my.pan,toe2.x);
			my.tilt=0;
			c_move(my,vector(2*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE);
			kampf_distance = vec_dist(my.x,to2.x);
			if(kampf_distance<50){
				my.skill1=0;
			//	snd_play  (schwert_snd,100,0);
	while(my.skill1<90){
		my.skill1 += 10*time_step;
		ent_animate(me,"schwert",my.skill1,ANM_CYCLE);
		wait(1);
	}
	
				playerhealth-=10;
			}
		}
		
		wait(1);
	}
	my.skill1=0;
	while(my.skill1<90){
		
		my.skill1 += 10*time_step;
		ent_animate(me,"tod",my.skill1,ANM_CYCLE);
		wait(1);
	}
	ent_animate(me,"tod",100,ANM_SKIP);
	gold+=5;
	mission+=1;
	wait(-1);
	ent_remove(my);
}
action gegner4(){
	set(my,INVISIBLE);
	set(my,PASSABLE);
	while(mission!=15)
	{wait(1);
	}
	reset(my,INVISIBLE);
	reset(my,PASSABLE);
	VECTOR toe2;
	my.health=100;
	my.emask = ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_RELEASE | ENABLE_SCAN; // the target is sensitive to impact with player's bullets
	my.emask |= ENABLE_TOUCH;
	my.emask |= ENABLE_CLICK;
	my.event = got_shot;
	ent_create("dreieck.mdl", nullvector, scan_view);
	while(my.health>1){
		c_scan(my.x, my.pan, vector(90, 60, 400), IGNORE_ME| SCAN_LIMIT);
		if (alarm==1){
			my.skill1 += 5*time_step;
			if (my.skill1 > 100) my.skill1 -= 100; 
			ent_animate(me,"move",my.skill1,ANM_CYCLE);
			//my.speed_x += (6-my.speed_x)/(2+(key_w^key_s)*5)*time_step;
			//c_move(my,vector(my.speed_x*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE);
			c_scan(my.x, my.pan, vector(90, 60, 400), IGNORE_ME| SCAN_LIMIT);
			vec_set(toe2,player.x);
			vec_sub(toe2, my.x);
			vec_to_angle(my.pan,toe2.x);
			my.tilt=0;
			c_move(my,vector(2*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE);
			kampf_distance = vec_dist(my.x,to2.x);
			if(kampf_distance<50){
				my.skill1=0;
			//	snd_play  (schwert_snd,100,0);
	while(my.skill1<90){
		my.skill1 += 10*time_step;
		ent_animate(me,"schwert",my.skill1,ANM_CYCLE);
		wait(1);
	}
	
				playerhealth-=10;
			}
		}
		
		wait(1);
	}
	my.skill1=0;
	while(my.skill1<90){
		
		my.skill1 += 10*time_step;
		ent_animate(me,"tod",my.skill1,ANM_CYCLE);
		wait(1);
	}
	ent_animate(me,"tod",100,ANM_SKIP);
	gold+=5;
	mission+=1;
	wait(-1);
	ent_remove(my);
}
action gegner5(){
	set(my,INVISIBLE);
	set(my,PASSABLE);
	while(mission!=26)
	{wait(1);
	}
	reset(my,INVISIBLE);
	reset(my,PASSABLE);
	VECTOR toe2;
	my.health=100;
	my.emask = ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_RELEASE | ENABLE_SCAN; // the target is sensitive to impact with player's bullets
	my.emask |= ENABLE_TOUCH;
	my.emask |= ENABLE_CLICK;
	my.event = got_shot;
	ent_create("dreieck.mdl", nullvector, scan_view);
	while(my.health>1){
		c_scan(my.x, my.pan, vector(90, 60, 400), IGNORE_ME| SCAN_LIMIT);
		if (alarm==1){
			my.skill1 += 5*time_step;
			if (my.skill1 > 100) my.skill1 -= 100; 
			ent_animate(me,"move",my.skill1,ANM_CYCLE);
			//my.speed_x += (6-my.speed_x)/(2+(key_w^key_s)*5)*time_step;
			//c_move(my,vector(my.speed_x*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE);
			c_scan(my.x, my.pan, vector(90, 60, 400), IGNORE_ME| SCAN_LIMIT);
			vec_set(toe2,player.x);
			vec_sub(toe2, my.x);
			vec_to_angle(my.pan,toe2.x);
			my.tilt=0;
			c_move(my,vector(2*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE);
			kampf_distance = vec_dist(my.x,to2.x);
			if(kampf_distance<50){
				my.skill1=0;
			//	snd_play  (schwert_snd,100,0);
	while(my.skill1<90){
		my.skill1 += 10*time_step;
		ent_animate(me,"schwert",my.skill1,ANM_CYCLE);
		wait(1);
	}
	
				playerhealth-=10;
			}
		}
		
		wait(1);
	}
	my.skill1=0;
	while(my.skill1<90){
		
		my.skill1 += 10*time_step;
		ent_animate(me,"tod",my.skill1,ANM_CYCLE);
		wait(1);
	}
	ent_animate(me,"tod",100,ANM_SKIP);
	gold+=5;
	mission+=1;
	wait(-1);
	ent_remove(my);
}