Fragen aus dem Forum

Top  Previous  Next

F: Wie kann ich erreichen, dass sich eine Entity langsam zum Spieler ausrichtet wenn dieser näher als 300 Quants ist?

A: Sehen Sie sich den Code hier gut an.

 

action turn_to_player

{

       var rotation_speed = 4; // play with 4

       var my_angle;

       while (1)

       {

               if (vec_dist (my.x, player.x) < 300)

               {

                       vec_set(temp.x, player.x);

                       vec_sub(temp.x, my.x);

                       vec_to_angle(my_angle, temp.x);

                       if (ang(my_angle - my.pan) < -3)

                       {

                               my.pan -= rotation_speed * time;

                       }

                       else

                       {

                               if (abs(ang(my_angle - my.pan)) > 3)

                               {

                                       my.pan += rotation_speed * time;

                               }

                       }

               }

               wait (1);

       }

}

 

 

F: Ich nutze den Kompass aus AUM 45. Ist es möglich, die Nadel etwas zittern zu lassen, wenn sich der Spieler bewegt?

A: Ersetzen Sie die set_compass() Funktion duch die Folgende:

 

starter set_compass()

{

       while (player == null) {wait (1);} // wait until the player is loaded in the level

       var player1_pos;

       var player2_pos;

       while (1)

       {

               needle.roll = -player.pan;

               if (vec_dist (player1_pos.x, player2_pos.x) != 0) // the player is moving?

               {

                       needle.roll += 1 - random (2); // then add a little wiggling to the needle

               }

               vec_set (player1_pos.x, player.x);

               wait (1);

               vec_set (player2_pos.x, player.x);

       }

}

 

 

F: Ich würde gern mit Hilfe einer transparent werdenden Entity einen Tag-Nacht-Wechsel programmieren. Können Sie helfen?

A: Verwenden Sie den folgenden Code.

 

entity fader_ent

{

       type = <fader.mdl>;

       layer = 10;

       alpha = 0;

       pan = 90;

       flags = transparent, visible;

       view = camera;

       x = 250; // 250 quants ahead of the view, play with this value

       y = 0;

       z = 0;

}

 

starter fade_inout()

{

       while (1)

       {

               while (fader_ent.alpha < 100)

               {

                       fader_ent.alpha += 0.3 * time; // play with 0.3 (use a smaller value here)

                       fader_ent.alpha = min (100, fader_ent.alpha);

                       wait (1);

               }

               fader_ent.alpha = 100;

               while (fader_ent.alpha > 0)

               {

                       fader_ent.alpha -= 0.3 * time; // play with 0.3 (use a smaller value here)

                       fader_ent.alpha = max (0, fader_ent.alpha);

                       wait (1);        

               }

               wait (1); // not really needed here

       }

}

 

 

F: Ich verwende Ihr Maniac-Skript aus AUM 3. Können Sie mir helfen, Schwerkraft für die bösen Pflanzen einzubauen?

A: Hier ist der umgeschriebene Pflanzencode.

 

action evil_plant

{

       plant_speed.y = 0;

       plant_speed.z = 0;

       my.y = player.y;

       my.ambient = 100;

       my.push = 10; // the maniac (player) has a default push = 0

       my.skill9 = 1; // set this skill for evil plants too

       my.skill1 *= plant_speed; // guess why?

       while (1)

       {                

               vec_set(temp.x, my.x);

               temp.z -= 10000;

               my.z -= c_trace(my.x, temp, ignore_sprites + ignore_passable + use_box) - 2; // play with 2

               move_mode = ignore_you + ignore_passable;  

                   ent_move (plant_speed, nullvector);  

               my.skill20 += plant_speed.x;

               if (my.skill20 == my.skill1 || my.skill20 == my.skill1 * -1)

               {

                       plant_speed.x *= -1; // change direction

               }

               wait (1);

       }

}

 

 

F: Wie kann ich den Spieler in einem großen Raum einsperren, der mehrere Türen hat, die sich nacheinander shcließen?

A: Plazieren Sie die “door_trigger” Entity im Zentrum des Raums und geben Sie Ihren Türen die Action “doors”.

 

var close_doors = 0;

 

sound closed_wav = <closed.wav>;

 

action door_trigger

{

       while (player == null) {wait (1);}

       while (vec_dist(player.x, my.x) > 100) {wait (1);}

       close_doors = 1;

}

 

action doors // using vertical gates for the doors

{

       while (close_doors == 0) {wait (1);}

       temp = random(3);

       sleep (temp); // wait 0...3 seconds before closing the doors

       my.skill1 = my.z;

       while (my.z > my.skill1 - 100) // the doors will move 100 quants downwards, play with 100

       {

               my.z -= 5 * time;

               wait (1);

       }

       snd_play (closed_wav, 100, 0);

}

 

 

F: Ich brauche eine Kiste, die der Spieler schieben kann. Können Sie helfen?

A: Hier ist ein Beispiel.

 

action pushable_box

{

       while (player == null) {wait (1);}

       var my_angle;

       while (1)

       {

               // play with 50 - it depends on the size of the box

               if (vec_dist (player.x, my.x) < 50)

               {

                       vec_set(temp.x, player.x);

                       vec_sub(temp.x, my.x);

                       vec_to_angle(my_angle.pan, temp.x);

                       temp.x = -10 * cos(my_angle.pan - my.pan) * time;

                       temp.y = -10 * sin(my_angle.pan - my.pan) * time;

                       temp.z = -1 * time;

                       c_move (my, temp.x, nullvector, ignore_you | ignore_passable | glide);

               }

               wait (1);

       }

}

 

 

F: Haben Sie ein Beispiel einer Kamera, die sich hinter dem Spieler langsamer dreht?

A: Hier ist ein Code, der das leistet.

 

action player_action

{

       player = my; // I'm the player

       var walk_percentage;

       var stand_percentage;

       camera.tilt = -15; // initial tilt value

       while (1)

       {

               // move the player using the "W" and "S" keys; "10" = movement speed

               c_move (my, vector(10 * (key_w - key_s) * time, 0, 0), nullvector, glide);

               // rotate the player by moving the mouse or "A" and "D"

               player.pan -= 5 * mouse_force.x * time - 5 * (key_a - key_d) * time;

               if (abs(ang(camera.pan) - ang(player.pan)) > 3) // play with 3

               {

                       camera.pan += (player.pan - camera.pan) * 0.5 * time; // play with 0.5

               }

               else

               {

                       camera.pan += (player.pan - camera.pan) * 0.2 * time; // play with 0.2

               }

               camera.tilt += 3 * mouse_force.y * time;

               camera.x = player.x - 200 * cos(player.pan); // 200 gives the distance between the player and the camera

               camera.y = player.y - 200 * sin(player.pan); // use the same value here

               camera.z = player.z + 120; // place the camera above the player, play with this value

               if ((key_w == off) && (key_s == off)) // the player isn't moving?

               {

                       ent_animate(my, "stand", stand_percentage, anm_cycle); // play the "stand" animation

               }

               else // the player is moving?

               {

                       ent_animate(my, "walk", walk_percentage, anm_cycle); // play the "walk" animation

               }

               walk_percentage += 7 * time;

               walk_percentage %= 100;

               stand_percentage += 4 * time;

               stand_percentage %= 100;

               wait (1);

       }

}

 

 

F: Haben Sie zufällig einen Schreibmaschinencode?

A: Hier ist ein Beispiel.

 

string text_str[500]; // use up to 500 characters for the text

string temp_str[10];

 

sound newrow_wav = <newrow.wav>;

sound key_wav = <key.wav>;

 

text type_txt

{

       layer = 5;

       pos_x = 10;

       pos_y = 10;

       font = _a4font; // use your own font here

       string = text_str;

       flags = visible;

}

 

starter typewriter()

{

       while (1)

       {

               if (key_any)

               {

                       str_for_key(temp_str, key_lastpressed); // convert the scan code to key

                       if (!str_cmpi (temp_str, "enter")) // Enter wasn't pressed?

                       {

                               if (str_cmpi (temp_str, "space")) // Space was pressed?

                               {

                                       str_cpy (temp_str, " "); // replace "space" with " "

                               }

                               str_cat (text_str, temp_str);

                               snd_play (key_wav, 40, 0);

                               while (key_any) {wait (1);}

                       }

                       else // Enter was pressed

                       {

                               snd_play (newrow_wav, 50, 0);

                               while (key_enter == on) {wait (1);}

                               str_cat (text_str, "\n");

                               str_cat (temp_str, "");

                       }

               }

               wait (1);

       }

}

 

 

F: Wie erstelle ich ein Gesundheitsitem, das sowohl vom Spieler als auch von Gegnern genutzt werden kann?

A: Verwenden Sie das folgende Beispiel.

 

// paste the following code at the top of your main script file

// place the following line of code at the beginning of player's and enemies' actions:

// "init_guys();" (without the quotes)

 

sound gothealth_wav = <bumm.wav>;

 

function give_health

{

       if ((event_type == event_scan) && (you.skill48 == 1234)) // got scanned by a health pack?

       {

               my.skill10 += 100; // increase the health (if you have stored the health in skill10)

               you.skill1 = 1; // and then remove the health pack

       }

}

 

function init_guys()

{

       my.enable_scan = on;

       my.event = give_health;

}

 

action health_packs

{

       my.passable = on;

       my.skill1 = 0;

       my.skill48 = 1234; // set a unique id for the health pack

       while (player == null) {wait (1);}

       while (my.skill1 == 0)

       {

               // scan around the health pack on a distance of 100 quants

               c_scan(my.x, my.pan, vector(360, 180, 100), ignore_me);

               my.pan += 3 * time;

               wait (1);

       }

       my.invisible = on;

       snd_play (gothealth_wav, 80, 0);

       sleep (2);

       ent_remove (my);

}

 

 

F: Ist es wahr, dass die Geschwindigkeit von c_scan von der Reichweite abhängt?

A: Sicher. Mit folgendem Code können Sie das selbst testen.

 

var counted_time;

 

panel time_pan

{

       layer = 5;

       digits = 50, 50, 6, _a4font, 1000, counted_time; // counted_time is multiplied by 1000

       flags = visible;

}

 

action scan_counter

{

       while (key_s == off) {wait (1);} // wait until the "S" key is pressed

       while (key_s == on) {wait (1);} // wait until the "S" key is pressed

       timer(); // initializa Acknex's high precission timer

       c_scan(my.x, my.pan, vector(360, 120, 1000), ignore_me); // play with these values

       counted_time = timer(); // get the time that was needed by the c_scan instruction

}