die move.c und bei der playercation hab ich viel quatsch gemacht, ich weiß, ist voll unsauber
Code:
var raumschiffspeedz;
var raumschiffspeedy;
var raumschiffspeedx;
var key_space_off = 0;
var playerhealth=100;
var move_var;
var drehung;
var distance;
var angriff;
var alarm;
var gesehen;
var killart;
VECTOR to;
VECTOR to_r;
VECTOR to2;
ENTITY* enemy1;
ENTITY* gotonow;
ENTITY* weapon1;
ENTITY* bullets;
SOUND* wurf_snd = "wurf.wav";
SOUND* schlag_snd = "schlag.wav";
SOUND* schwert_snd = "schwert.wav";
var ninjastern;
var gold;
#define speed_x skill50
#define speed_y skill51
#define speed_z skill52
#define foot_height skill53
#define soil_contact skill54
#define soil_height skill55
#define target_pan skill58
#define slope_tilt skill59
FONT* arial_font = "Arial#25b"; 
/////////////
PANEL* gameover_pan = //mein erstes panel
{
	pos_x = 50;
	pos_y = 110;
	layer = 10;
	button (0, 0, "gameover.jpg", "gameover.jpg", "gameover.jpg", gameover, null, null);
	//flags = OVERLAY | SHOW;
}

/////////////////////////////////////////////////////////////////////
PANEL* panhealth =
{
	digits(50, 25, " %0.f", *, 1, playerhealth);
	//	font = arial_font;
	flags = SHOW;
}
PANEL* pangold =
{
	digits(230, 25, " %0.f", *, 1, gold);
	//	font = arial_font;
	flags = SHOW;
}
PANEL* panninjastern =
{
	digits(140, 25, " %0.f", *, 1, ninjastern);
	//	font = arial_font;
	flags = SHOW;
	
}
function attach_weapon1()

{

	weapon1 = my; // I'm the gun

	set(my, PASSABLE );
	set(my, INVISIBLE );
	while (1)
	{while (!player){
			wait(1);
		}
		vec_set (my.x, vector (0, 0, 10)); // set the proper gun offset in relation to the player
		vec_rotate (my.x, player.pan);
		vec_add (my.x, player.x);
		my.pan = player.pan;
		wait (1);
	}
}
function gameover(){
	reset(gameover_pan,SHOW);
	playerhealth=100;
	level_load("ninjacat.wmb");
	
}
function remove_bullets() // this function runs when the bullet collides with something
{snd_play  (schlag_snd,100,0);
	wait (1); // wait a frame to be sure (don't trigger engine warnings)
	ent_remove (my); // and then remove the bullet
}
function move_bullets(){	
	set(my,SHADOW);
	//	snd_play  (pistole_snd,100,0);
	bullets=my;
	VECTOR bullet_speed[3]; // stores the speed of the bullet
	// the bullet is sensitive to impacts with entities and level blocks
	set(my,PASSABLE);
	my.emask = ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_BLOCK; 
	my.event = remove_bullets; // when it collides with something, its event function (remove_bullets) will run
	my.pan = weapon1.pan;
	bullet_speed.x = 25 * time_step; // adjust the speed of the bullet here
	bullet_speed.y = 0; // the bullet doesn't move sideways
	bullet_speed.z = 0; // or up / down on the z axis
	c_move (my, bullet_speed, nullvector, IGNORE_PASSABLE | IGNORE_YOU);
	wait(1);
	c_move (my, bullet_speed, nullvector, IGNORE_PASSABLE | IGNORE_YOU);
	reset(my,PASSABLE); 
	while (my) // this loop will run for as long as the bullet exists (it isn't "NULL")
	{
		// move the bullet ignoring its creator (weapon1)
		my.skill1 += 10*time_step;
		if (my.skill1 > 100) my.skill1 -= 100; 
		ent_animate(me,"dreh",my.skill1,ANM_CYCLE);
		c_move (my, bullet_speed, nullvector, IGNORE_PASSABLE | IGNORE_YOU); 
		wait (1);
	}
}
function fire_bullets() {
	VECTOR bullet_pos[3];
	vec_for_vertex(bullet_pos, weapon1, 1);
	ent_create("stern.mdl", bullet_pos, move_bullets);
	snd_play  (wurf_snd,100,0);
	wait(1); 
}
function adjust_target2(){
	gotonow=my;
	my.z += 10; // play with the target entity here    
	set(my,PASSABLE);
	set(my,INVISIBLE); 
	vec_set(to_r,my.x);  
	vec_sub(to_r, player.x);
	//vec_set(to2,my.x);
	angriff=0;
	vec_to_angle(player.pan,to_r);
	wait(1);
	if(ninjastern!=0){
		fire_bullets();
		ninjastern-=1;
	}
	ent_remove(my);
}



function create_target2()

{
	move_var=2;
	VECTOR pos1, pos2;
	pos1.x = mouse_pos.x;
	pos1.y = mouse_pos.y;
	pos1.z = 0;
	vec_for_screen (pos1, camera);
	pos2.x = mouse_pos.x;
	pos2.y = mouse_pos.y;
	pos2.z = 20000; // use a big value here
	vec_for_screen (pos2, camera);
	c_trace (pos1.x, pos2.x, IGNORE_PASSABLE); // now "target" holds the coordinates of the hit point
	ent_create ("ziel.mdl", target, adjust_target2); // create the entity at the "target" position
}
function bullets_startup(){
	on_mouse_right = create_target2;
}
function pget_shot(){
	my.ambient = 0;
	gesehen=0;
	my.lightrange = 0;
	if(event_type == EVENT_CLICK)
	{
	}
	if(event_type == EVENT_TOUCH)
	{
	}
	if (event_type == EVENT_SCAN)
	{//wait(1);
		gesehen=1;
		alarm=1;
	}
	else{
		alarm=0;
		//gesehen=0;
	}
	
}
action players_code() {
	move_var=1;
	ent_create ("stern.mdl", vector(0,0,0), attach_weapon1);
	c_scan(my.x, my.pan, vector(180, 180, 0), IGNORE_ME| SCAN_LIMIT);
	c_setminmax(my);
	camera.clip_near = 1;  
	VECTOR temp;
	VECTOR boden;
	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 = pget_shot;
	var speed_down = 0; //(Fallgeschwindigkeit)
	var dist_down = 0; //(Höhenunterschied Spieler - Terrain)
	var dist_ahead = 0; //(Entfernungsunterschied vorwärts - rückwärts)
	var distanceenemy;
	player = my; // I'm the player
	camera.x = my.x - 00 * cos(my.pan);
	camera.y = my.y - 00 * sin(my.pan);
	camera.pan = my.pan; // the camera and the player have the same pan angle
	camera.z = my.z + 200; // place the camera above the player, play with this value
	camera.tilt = -1800;
	/////////////
	while (playerhealth>0){

		if(move_var==1){
			camera.arc=100;
			vec_to_angle(my.pan,to);
			my.tilt=0;
			distance = vec_dist(my.x,to2.x); 
			//distanceenemy=vec_dist(my.x,distanceenemy); 
			c_setminmax(my);
			vec_fill(my.min_x,-10);
			vec_fill(my.max_x,10);
			my.min_z=-22;
			my.max_z = 15;
			vec_for_min(temp,my);	
			my.foot_height = temp.z*my.scale_z;
			if(distance>=26){
				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);
			}
			else{
				if (   gesehen==1 && angriff==1 ){
					my.skill1 = 0;
					killart=1;
					c_scan(my.x, my.pan, vector(90, 180, 30), IGNORE_ME| SCAN_LIMIT);
					snd_play  (schwert_snd,100,0);
					while(my.skill1<100){
						my.skill1 += 10*time_step;
						ent_animate(me,"schwert",my.skill1,ANM_CYCLE);
						wait(1);
					}
					angriff=0;
					killart=0;	
					c_scan(my.x, my.pan, vector(180, 180, 0), IGNORE_ME| SCAN_LIMIT);
				}
				else{
					if(angriff==1){
						killart=2;
						c_scan(my.x, my.pan, vector(90, 180, 30), IGNORE_ME| SCAN_LIMIT);
						my.skill1 = 0;
						while(my.skill1<100){
							
							my.skill1 += 10*time_step;
							//if (my.skill1 > 100) my.skill1 -= 100; 
							ent_animate(me,"kopf",my.skill1,ANM_CYCLE);
							wait(1);
						}
						killart=0;
						angriff=0;
						c_scan(my.x, my.pan, vector(180, 180, 0), IGNORE_ME| SCAN_LIMIT);
				}}
				if (angriff==2){
					c_scan(my.x, my.pan, vector(180, 180, 30), IGNORE_ME| SCAN_LIMIT);
					angriff=0;
				}
			}
			my.speed_x += (6-my.speed_x)/(2+(key_w^key_s)*5)*time_step;
			if(HIT_TARGET && abs(normal.z) < 0.1)	{
				if(target.x < my.x) my.speed_x = maxv(my.speed_x,0);
				else my.speed_x = minv(my.speed_x,0);
			}
			// gravity
			if(my.speed_z <= 0)
			{
				vec_set(temp,vector(my.x,my.y,my.z-1500+my.foot_height));
				c_trace(my.x,temp,IGNORE_PASSABLE | IGNORE_ME | USE_BOX);
				if(!trace_hit) vec_set(target,temp);
				my.soil_height = target.z-my.foot_height;
			}
			if(my.z > my.soil_height+(5+20*my.soil_contact)*time_step || my.speed_z > 0) // additional height buffer when ground contact to avoid player floating on slopes
			{
				my.soil_contact = 0;
				my.speed_z = maxv(my.speed_z-9*time_step,-90);
			}
			else
			{
				//c_move(me,nullvector,vector(0,0,my.soil_height-my.z),IGNORE_PASSABLE);
				my.soil_contact = 1;
				my.speed_z = 0;
				
				//jump code
				if(key_e)
				{
					if(key_space_off)
					{
						key_space_off = 0;
						my.speed_z = 80;
						my.speed_x +=200;
						
						//my.anim_jump = 1;
						//my.anim = 0;
					}
				}
				else key_space_off = 1;
				//my.speed_x -=100;
			}
			if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0)
			dist_down = my.z + boden.z - target.z; 
			else 
			dist_down = 0;
			if (dist_down > 0) 
			dist_down = clamp(dist_down,0,accelerate(speed_down,10,0.1));
			else 
			speed_down = 0; 
			//var dist_ahead = 5*(key_w-key_s)*time_step;
			c_move(me,vector(0,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE);
			
			if(my.speed_z){
			} //c_move(me,nullvector,vector(0,0,maxv(my.speed_z*time_step,my.soil_height-my.z)),IGNORE_PASSABLE | GLIDE); // the maxv command makes sure you never move below the desired height
			if(HIT_TARGET && normal.z < -0.5) my.speed_z = minv(my.speed_z,0); // hit the ceiling?
			////////camera
			camera.x = my.x - 200 ;
			camera.y = my.y  ;
			//camera.pan = my.pan; // the camera and the player have the same pan angle
			camera.z = my.z + 150; // place the camera above the player, play with this value
			camera.tilt = -45;
			if(playerhealth<1){
			}
			//set(gameover_pan,SHOW);
		}
		
		wait (1);
}
wait(1);
set(gameover_pan,SHOW);
}