2 registered members (AndrewAMD, TipmyPip),
13,353
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Panzercode aus AUM... Was ist mit der Kanone, wenn ich einen Hang hinauf fahre?
#13103
07/14/03 01:13
07/14/03 01:13
|
Joined: Aug 2002
Posts: 791 NRW, Deutschland
inFusion
OP
User
|
OP
User
Joined: Aug 2002
Posts: 791
NRW, Deutschland
|
Hi! Also, ich hab den anzercode aus AUM und möchte jetzt hinkriegen, dass der GEschützturm sich auch nach dem Panzer"körper" ausrichtet, wenn ich einen Hang hinauf fahre (Ich hab den Code so modifiziert, dass sich der Panzer dem Boden anpasst (indem ich den Code aus den TEmplates genommen habe)). Solange ich die Kanone noch nicht gedreht habe, läuft alles wunderbar, doch wenn ich sie drehe, orientiert sie sich nicht am Panzerkörper! So dass sie teilweise in den Panzer hineinreicht! Das ist mein Bodenanpassungscode vom Panzerkörper: code:
// Adapt the player angle to the floor slope MY_ANGLE.TILT = 0; MY_ANGLE.ROLL = 0; if((my_height < 10) && ((my_floornormal.X != 0) || (my_floornormal.Y != 0) )) { // on a slope? // rotate the floor normal relative to the player MY_ANGLE.PAN = -MY.PAN; vec_rotate(my_floornormal,MY_ANGLE); // calculate the destination tilt and roll angles MY_ANGLE.TILT = -ASIN(my_floornormal.X); MY_ANGLE.ROLL = -ASIN(my_floornormal.Y); } // change the player angles towards the destination angles MY.TILT += 0.2 * ANG(MY_ANGLE.TILT-MY.TILT); MY.ROLL += 0.2 * ANG(MY_ANGLE.ROLL-MY.ROLL);
Das ist der Code für den Panzergeschützturm: code:
function attach_player_turret() { proc_late(); // prevent shaking my.passable = on; my.metal = on; while(you) // as long as the creator exists { vec_set(my.x, you.x); my.pan = you.pan + turret_offset; my.frame = you.frame; my.next_frame = you.next_frame; camera.pan = my.pan; camera.x = my.x - 500 * cos (my.pan); camera.y = my.y - 500 * sin (my.pan); camera.z = my.z + 300; camera.tilt = -20; // the camera looks down wait(1); } ent_remove(my); }
Und ich hab noch eine frage: Wie kann ich verhindern, dass sich der Panzer auch nach den normalen ausrichtet, auf denen die RAkete(die vom Panzer abgeschoßen wurde) aufschlägt?
Hier ist mal mein ganzer Panzercode, ist sehr unübersichtlich, aber vielleicht ist es ja notwendig: code:
function countdown() { if(time_count) { time_count = 0; waitt(16); time_count = 1; wait(1); } }
function attach_player_barrel() { proc_late(); // prevent shaking my.passable = on; my.metal = on; while(you) // as long as the creator exists { vec_set(my.x,you.x); my.pan = you.pan + turret_offset; my.tilt = you.tilt + barrel_offset; my.roll = you.roll; my.frame = you.frame; my.next_frame = you.next_frame; vec_for_vertex(rocket_coords, my, 33); // vertex for player's rocket
if (mouse_left == 1 && time_count && player.shield > 0) { ent_create (tank_rocket, rocket_coords, player_rocket); countdown(); snd_play (tankrocket_snd, 100, 0); }
wait(1); } ent_remove(my); }
function attach_player_turret() { proc_late(); // prevent shaking my.passable = on; my.metal = on; while(you) // as long as the creator exists { vec_set(my.x, you.x); my.pan = you.pan + turret_offset; my.frame = you.frame; my.next_frame = you.next_frame; camera.pan = my.pan; camera.x = my.x - 500 * cos (my.pan); camera.y = my.y - 500 * sin (my.pan); camera.z = my.z + 300; camera.tilt = -20; // the camera looks down wait(1); } ent_remove(my); }
action player_tank { player = me; my.enable_impact = on; my.enable_entity = on; my.fat = ON; my.event = tank_damaged; ent_create(challenger_turret, nullvector, attach_player_turret); ent_create(challenger_barrel, nullvector, attach_player_barrel); my.shield = 250; // 250 shield points for player's tank while (my.shield > 0) // the 10th hit will destroy player's tank {
hoehe_real = result;
if (mouse_force.x != 0) // if we move the mouse on x { turret_offset -= 6 * mouse_force.x * time; if (turret_handle == 0 && turret_offset + my.pan > my.pan -59 && turret_offset + my.pan < my.pan + 59) { turret_handle = snd_play (turret_snd, 70, 0); } } else { turret_handle = 0; }
if (mouse_force.y != 0) // if we move the mouse on y { if(barrel_offset + my.tilt > my.tilt + 40) { barrel_offset = 40; }else{ if(barrel_offset + my.tilt < my.tilt - 0) { barrel_offset = - 0; } } barrel_offset += 4 * mouse_force.y * time; }
/* if (player_speed.x != 0) // if we are moving the tank { my.pan -= 0.1 * (key_d - key_a) * player_speed.x * time; if (engine_handle == 0) // if the engine sound isn't playing { engine_handle = snd_loop (tank_snd, 50, 0); snd_tune (engine_handle, 25, 100, 0); // play the sound at its original frequency (100%) my.skill10 = 100; } } else { my.skill10 -= 5 * time; // decrease the frequency snd_tune (engine_handle, 25, my.skill10, 0); // using snd_tune if (my.skill10 < 20) // if we go below 20% of the original frequency { snd_stop (engine_handle); // stop the engine sound engine_handle = 0; } }
if(normal.z > 0.01) { my_floornormal.X = NORMAL.X; // set my_floornormal to the normal of the surface my_floornormal.Y = NORMAL.Y; my_floornormal.Z = NORMAL.Z; }
vec_set(temp, my.x); temp.z -= 1000; // 100 Quants nach unten trace_mode = IGNORE_ME; result = trace(my.x, temp);
if (RESULT > 5) // in der Luft? { player_speed.X = 0; // keine schiebende Kraft player_speed.Y = 0; player_speed.Z += -1.5; // Schwerkraft } else // auf und nahe dem Boden { player_speed.x = 1.5 * (key_w - key_s) * time + max (1 - time * 0.15, 0) * player_speed.x; player_speed.Y = 0; player_speed.z = (player_speed.z * (-1)) * 0.6; }
sped_real = player_speed.z;
dist.z = (TIME * player_speed.z); dist.x = player_speed.x * time; dist.y = player_speed.y * time;
// Adapt the player angle to the floor slope MY_ANGLE.TILT = 0; MY_ANGLE.ROLL = 0; if((my_height < 10) && ((my_floornormal.X != 0) || (my_floornormal.Y != 0) )) { // on a slope? // rotate the floor normal relative to the player MY_ANGLE.PAN = -MY.PAN; vec_rotate(my_floornormal,MY_ANGLE); // calculate the destination tilt and roll angles MY_ANGLE.TILT = -ASIN(my_floornormal.X); MY_ANGLE.ROLL = -ASIN(my_floornormal.Y); } // change the player angles towards the destination angles MY.TILT += 0.2 * ANG(MY_ANGLE.TILT-MY.TILT); MY.ROLL += 0.2 * ANG(MY_ANGLE.ROLL-MY.ROLL);
move_mode = ignore_you + ignore_passable; ent_move(player_speed, nullvector);
wait (1); } */
player_speed.x = 1.5 * (key_w - key_s) * time + max (1 - time * 0.15, 0) * player_speed.x; player_speed.y = 0;
if (player_speed.x != 0) { my.pan -= 0.5 * (key_d - key_a) * player_speed.x * time; if (engine_handle == 0) { engine_handle = snd_loop (tank_snd, 50, 0); snd_tune (engine_handle, 25, 100, 0); // original frequency (100%) my.skill10 = 100; } } else { my.skill10 -= 5 * time; snd_tune (engine_handle, 25, my.skill10, 0); if (my.skill10 < 20) // below 20% of the original frequency { snd_stop (engine_handle); engine_handle = 0; } }
my_floornormal.X = NORMAL.X; // set my_floornormal to the normal of the surface my_floornormal.Y = NORMAL.Y; my_floornormal.Z = NORMAL.Z;
vec_set(temp.z,MY.x); temp = -4000; trace_mode = IGNORE_SPRITES + IGNORE_PASSENTS + USE_BOX + ACTIVATE_SONAR; result = trace(my.x,temp.z);
if(result > 5) { player_speed.z = 0; }else{ player_speed.z = 5 * result; }
dist.x = player_speed.x; dist.y = player_speed.y; dist.z = TIME * TIME * player_speed.z + max(1-TIME*0.1,0) * player_speed.z;
// Adapt the player angle to the floor slope MY_ANGLE.TILT = 0; MY_ANGLE.ROLL = 0; if((my_height < 10) && ((my_floornormal.X != 0) || (my_floornormal.Y != 0) )) { // on a slope? // rotate the floor normal relative to the player MY_ANGLE.PAN = -MY.PAN; vec_rotate(my_floornormal,MY_ANGLE); // calculate the destination tilt and roll angles MY_ANGLE.TILT = -ASIN(my_floornormal.X); MY_ANGLE.ROLL = -ASIN(my_floornormal.Y); } // change the player angles towards the destination angles MY.TILT += 0.2 * ANG(MY_ANGLE.TILT-MY.TILT); MY.ROLL += 0.2 * ANG(MY_ANGLE.ROLL-MY.ROLL);
move_mode = ignore_you + ignore_passable + use_box + ignore_models;
move(me, dist, nullvector); wait(1); } } function player_rocket() { procket_ptr = me; wait (1); my.skill40 = 1; // it is a rocket my.pan = you.pan; my.tilt = you.tilt; my.enable_impact = on; my.enable_block = on; my.enable_entity = on; my.event = explode_rocket; vec_set(my.skill1,my); my.skill5 = 0; // used for vertical movement my.skill1 = 50; //(x) my.skill2 = 0; //(y) my.skill3 = 0; //(z) procket_speed *= time; while (my != null) { // my.skill5 += time; // if (my.skill5 > 20) // { my.skill3 -= fall_speed * time; // } move_mode = ignore_you + ignore_passable; // ignores the barrel -> can't collide with it ent_move (my.skill1, nullvector); wait (1); } }
function explode_rocket() { wait (1); exclusive_global;
// the following piece of code replaces A5's ent_playsound with a linear function my.skill10 = vec_dist (player.x, my.x); if (my.skill10 < 1000) {my.skill10 = 1000;} // all sounds below 1000 quants will be played with maximal volume my.skill10 = 100000 / my.skill10; // bigger distance -> lower volume; snd_play (tankexplo_snd, my.skill10, 0);
vec_set (temp, my.pos); temp.z += 50; // create the explosion sprite a little higher ent_create(explosion_pcx, temp, animate_explosion); ent_remove (me); }
function animate_explosion() { wait (1); my.passable = on; my.ambient = 100; while (my.frame < 8) { my.frame += 1 * time; wait (1); } ent_remove (me); }
function animate_long_explosion() { wait (1); my.passable = on; my.ambient = 100; while (my.frame < 26) { my.frame += 1 * time; wait (1); } ent_remove (me); }
function tank_damaged() { if (you.skill40 != 1) {return;} // it wasn't hit by a rocket (maybe the 2 tanks collided) wait (1); my.shield -= 25; if (my.shield <= 0) // player's tank was hit 10 times or the enemy tank was hit twice { while (1) { effect (tank_smoke, 5, my.pos, normal); sleep (0.2); } } }
function tank_smoke() { temp.x = random(2) - 1; temp.y = random(2) - 1; temp.z = random(2) + 1; vec_add (my.vel_x, temp); my.alpha = 30 + random(30); my.bmap = tanksmoke_pcx; my.size = 100; my.flare = on; my.move = on; my.lifespan = 100; my.function = fade_smoke; }
function fade_smoke() { my.alpha -= 0.5 * time; if (my.alpha < 0) { my.lifespan = 0; } }
Ich danke schonmal dem, der überhaupt den Mut aufgebracht hat sich das alles hier durchzulesen
MFG HeLioS
|
|
|
Re: Panzercode aus AUM... Was ist mit der Kanone, wenn ich einen Hang hinauf fahre?
#13104
07/20/03 17:01
07/20/03 17:01
|
Anonymous
Unregistered
|
Anonymous
Unregistered
|
Hi, also den großen code hab ich mir jetzt nicht durchgelesen, aber setzt in denen turmcode:
my.roll=you.roll; my.tilt=you.tilt;
mfg Bobba
|
|
|
|