1 registered members (AbrahamR),
717
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Probleme mit Egoshooter-Player-Skript
#349542
12/08/10 19:42
12/08/10 19:42
|
Joined: Nov 2010
Posts: 8 Berlin, Germany
Deathmaster
OP
Newbie
|
OP
Newbie
Joined: Nov 2010
Posts: 8
Berlin, Germany
|
Hey Leute, ich hab ein kleines Problem...chen mit dem Player-Skript meines ersten Egoshooters. Ich bin noch recht neu und hab mich deshalb teilweise ans Shootertemplate des AUM gehalten, aber auch einiges selbst geschrieben. Wenn ich das Spiel jetzt starte, hängt der Player halb im Boden fest und die Maus reagiert nicht...ich hab schon einiges probiert, aber anscheinend noch nicht das Richtige. Hier ist mal der gesamte Player-Skript(Achtung, er ist recht lang, noch nicht optimiert, aber auf eher niedrigem Niveau): //in (bad) english Hey Guys, i have (a little…) problem with the player skript of my first egoshooter. I used not lite-c for a long time; that´s why I put some parts of shootertemplate (AUM) in my script. If I start my game, the player hangs till his half in the ground and the mouse don’t react. Here is the whole player script (it is very long, not optimized, but on a low standart): //camera var camera_h_speed; var camera_v_speed; var camera_h_accel = 12; var camera_v_accel = 8; var camera_h_frict = 0.95; var camera_v_frict = 0.8; var cam_height = 35; //camera
//basics var mouse_spd = 10;
var my_height; var my_speed; //basics
//players speed var run_spd = 20; var walk_spd = 10; var strafe_spd = 5; var crawl_spd = 5;' var seal_spd = 3;
var force_jump = 20; //players speed
//players health, armor, etc. var player_health = 100; //players health, armor, etc.
//players stats var stand_var = 1; var ducking_var = 0; var lying_var = 0;
var walking_var = 0; var crawling_var = 0; var sealing_var = 0;
var running_var = 0;
var jump_var = 0; //players stats
VECTOR dist; VECTOR absdist; VECTOR force;
STRING* key_forward = "w"; STRING* key_backward = "s"; STRING* key_left = "a"; STRING* key_right = "d"; STRING* key_jump = "space"; STRING* key_run = "shiftl"; STRING* key_ducking = "strg";
function handle_crawl() { if (stand_var + walking_var == 1) { if (key_ctrl) { c_trace(player.x, vector(player.x, player.y, player.z + 35), IGNORE_ME|IGNORE_PASSABLE|USE_BOX|IGNORE_SPRITES); if(trace_hit) { vec_set(my.min_x,vector(-15,-15,-30)); vec_set(my.max_x,vector(15,15,5)); stand_var = 0; walking_var = 0; crawling_var = 0; ducking_var = 1; if (key_w + key_a + key_s + key_d > 0) { ducking_var = 0; crawling_var = 1; } if (key_w + key_a + key_s + key_d == 0) { crawling_var = 0; ducking_var = 1; } } } } if (crawling_var + ducking_var == 1) { if (key_ctrl) { vec_set(my.min_x,vector(-15,-15,-30)); vec_set(my.max_x,vector(15,15,35)); crawling_var = 0; ducking_var = 0; stand_var = 1; } } }
function handle_seal() { if (stand_var + walking_var + crawling_var + ducking_var == 1) { if (key_m) { c_trace(player.x, vector(player.x, player.y, player.z + 35), IGNORE_ME|IGNORE_PASSABLE|USE_BOX|IGNORE_SPRITES); if(trace_hit) { vec_set(my.min_x,vector(-15,-15,-30)); vec_set(my.max_x,vector(15,15,2)); stand_var = 0; walking_var = 0; crawling_var = 0; ducking_var = 1; if (key_w + key_a + key_s + key_d > 0) { ducking_var = 0; crawling_var = 1; } if (key_w + key_a + key_s + key_d == 0) { crawling_var = 0; ducking_var = 1; } } } } if (sealing_var + lying_var == 1) { if (key_m) { vec_set(my.min_x,vector(-15,-15,-30)); vec_set(my.max_x,vector(15,15,5)); lying_var = 0; ducking_var = 1; sealing_var = 0; } } }
function handle_jump() { if (stand_var + walking_var + running_var == 1) { while(1) { if(key_space) { jump_var = 1; stand_var = 0; walking_var = 0; running_var = 0; while(key_space) wait(1); jump_var = 0; stand_var = 1; } wait(1); } } }
function handle_gravity() { my_height = c_trace(my.x,vector(my.x,my.y,my.z - 1000),IGNORE_MODELS|IGNORE_PASSABLE|IGNORE_SPRITES|USE_BOX); if(my_height > 10) { accelerate(absdist.z,-10,1); // 10 is gravity and 1 is acceleration } else { absdist.z = -(my_height/1.2)+4; // play with 4 (used for smooth) absdist.z = clamp(absdist.z,-4,4); // limit absdist } if(key_space) if(my_height < 10 && jump_var == 0) { jump_var = 1; absdist.z = force_jump * time_step*4; // push the player upwards } }
function handle_camera() { my.pan = camera.pan; camera.arc = 80; camera.clip_near = 0; camera.pan -= accelerate (camera_h_speed, camera_h_accel*(mouse_force.x), camera_h_frict); camera.tilt += accelerate (camera_v_speed, camera_v_accel*(mouse_force.y), camera_v_frict); camera.tilt = clamp(camera.tilt,-80,80); vec_set(camera.x,vector(my.x,my.y,camera.z)); vec_lerp(camera.x,camera.x,vector(my.x,my.y,my.z + cam_height),0.2); //handle_crawl(); // crawling }
function handle_movement() { if(key_shift) { running_var = 1; if(crawling_var + ducking_var == 1) { force.x = crawl_spd * (key_w - key_s) * time_step; accelerate(dist.x,force.x,0.5); force.y = crawl_spd * (key_a - key_d) * time_step; accelerate(dist.y,force.y,0.5); } if(walking_var + stand_var == 1) { force.x = run_spd * (key_w - key_s) * time_step; accelerate(dist.x,force.x,0.5); force.y = strafe_spd * (key_a - key_d) * time_step; accelerate(dist.y,force.y,0.5); } if(lying_var + sealing_var == 1) { force.x = seal_spd * (key_w - key_s) * time_step; accelerate(dist.x,force.x,0.5); force.y = seal_spd * (key_a - key_d) * time_step; accelerate(dist.y,force.y,0.5); } } else { if(crawling_var + ducking_var == 1) { force.x = crawl_spd * (key_w - key_s) * time_step; accelerate(dist.x,force.x,0.5); force.y = crawl_spd * (key_a - key_d) * time_step; accelerate(dist.y,force.y,0.5); } if(walking_var + stand_var == 1) { force.x = walk_spd * (key_w - key_s) * time_step; accelerate(dist.x,force.x,0.5); force.y = strafe_spd * (key_a - key_d) * time_step; accelerate(dist.y,force.y,0.5); } if(lying_var + sealing_var == 1) { force.x = seal_spd * (key_w - key_s) * time_step; accelerate(dist.x,force.x,0.5); force.y = seal_spd * (key_a - key_d) * time_step; accelerate(dist.y,force.y,0.5); } } if((walking_var + stand_var == 0) && (key_w + key_a + key_s + key_d > 0)) { walking_var = 1; stand_var = 0; } if((crawling_var + ducking_var == 0) && (key_w + key_a + key_s + key_d > 0)) { crawling_var = 1; ducking_var = 0; } if((sealing_var + lying_var == 0) && (key_w + key_a + key_s + key_d > 0)) { sealing_var = 1; lying_var = 0; } if((walking_var + stand_var == 0) && (key_w + key_a + key_s + key_d + key_space == 0)) { walking_var = 0; stand_var = 1; } if((crawling_var + ducking_var == 0) && (key_w + key_a + key_s + key_d + key_space == 0)) { crawling_var = 0; ducking_var = 1; } if((sealing_var + lying_var == 0) && (key_w + key_a + key_s + key_d + key_space == 0)) { sealing_var = 0; lying_var = 1; } move_friction = 0; move_min_z = -1; vec_set(temp.x, my.x); temp.z -= 10000; current_height = c_trace(my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | GLIDE); // compute the distance between player's origin and the floor below its feet if(current_height < (tshooter_disttoground * 0.97)) // if it is smaller than the default value (64 quants) push the player upwards a bit (resilience) - 0.97 gives the hysteresis { vertical_speed.z = tshooter_resilience * time_step; } else { if(current_height > tshooter_disttoground) // if it is bigger than the default value (64 quants), move the player downwards { vertical_speed.z -= tshooter_fallspeed * time_step; } else // sitting properly on the floor? { vertical_speed.z = 0; // then don't do anything on the z axis } } if((jump_on) && (current_height < tshooter_disttoground)) // jumping while player's feet are placed on the floor? { if (!snd_playing (jump_handle)) // if no jumping sound is playing, play the jumping sound now jump_handle = snd_play(tshooter_jump_wav, 70, 0); vertical_speed.z = tshooter_jump * time_step; // push the player upwards } }
action player_walk() { player = my; player_health = 100; my.eflags |= FAT | NARROW; set(my, FLAG2); my.emask |= ENABLE_IMPACT; set(my,INVISIBLE); while(player_health > 0) { //player_health = my.health; handle_gravity(); handle_movement(); handle_jump (); my_speed = c_move(my,dist,absdist,IGNORE_PASSABLE|GLIDE); handle_camera(); wait(1); } player_health = 0; while (camera.tilt < 90) { camera.tilt += 2 * time_step; camera.roll += 1.5 * time_step; wait (1); } }Entschuldigt bitte das schlechte Englisch(z.B. "ducking") an einigen Stellen, ich war mir bei den Vokabeln nicht ganz sicher und hab dann halt auf "Denglish" geschrieben Danke schon mal im Voraus Deathmaster Please excuse the very bad english also in the skript(f. ex. "ducking") in several places, I wasn´t sure with some vocabularys, that´s why I wrote Germish Thanks in advance Deathmaster
Last edited by Deathmaster; 12/09/10 17:09.
|
|
|
Re: Probleme mit Egoshooter-Player-Skript
[Re: Deathmaster]
#349546
12/08/10 20:28
12/08/10 20:28
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Please, as I see my script here, could you translate your speech in to English? I want to help you And if you changed code yourself, I can tell you that you made it too complicated And even wrong....
|
|
|
Re: Probleme mit Egoshooter-Player-Skript
[Re: 3run]
#349593
12/09/10 14:19
12/09/10 14:19
|
Joined: Nov 2010
Posts: 8 Berlin, Germany
Deathmaster
OP
Newbie
|
OP
Newbie
Joined: Nov 2010
Posts: 8
Berlin, Germany
|
Ohh, sorry I will translate it...ohh you´re right, I didn´t use the AUM skript, but yours movement demo Thanks a lot for it
Last edited by Deathmaster; 12/09/10 14:33.
|
|
|
Re: Probleme mit Egoshooter-Player-Skript
[Re: Deathmaster]
#349597
12/09/10 14:38
12/09/10 14:38
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
I'm happy to see that you found it useful But why wouldn't you just use as it is? Why do you need Shooterscript? I'm a bit busy at the moment, I'll check the script a bit later...
|
|
|
Re: Probleme mit Egoshooter-Player-Skript
[Re: 3run]
#349619
12/09/10 17:09
12/09/10 17:09
|
Joined: Nov 2010
Posts: 8 Berlin, Germany
Deathmaster
OP
Newbie
|
OP
Newbie
Joined: Nov 2010
Posts: 8
Berlin, Germany
|
Yes, i need a shooter script with crawling, sealing, lying and all that stuff. I want that the mode of the character(crawling, sealing, walkin, standing, etc.) influences the accuracy of the (gun) shoots.
Last edited by Deathmaster; 12/09/10 17:11.
|
|
|
Re: Probleme mit Egoshooter-Player-Skript
[Re: 3run]
#349695
12/10/10 14:14
12/10/10 14:14
|
Joined: Nov 2010
Posts: 8 Berlin, Germany
Deathmaster
OP
Newbie
|
OP
Newbie
Joined: Nov 2010
Posts: 8
Berlin, Germany
|
No, the shooter template hasn´t (any) accuracy at all, but I want to make the shoots with c_trace and I want accuracy . I would find it very cool, if you could help me with the script.
Last edited by Deathmaster; 12/10/10 20:59.
|
|
|
|