F: Ich brauche einen Code für eine Kamera, welche mir erlaubt frei durch das Level zu fliegen, jedoch aber Kollisionserkennung hat.
A: Weisen Sie Ihrem Player die folgende Aktion zu; mit der Maus können Sie sich drehen, drücken und halten eines Mausbuttons bewegt die Kamera.

action free_camera
{
    my.invisible = on;
    mouse_mode = 0;
    while (1)
    {
       camera.x = my.x;
       camera.y = my.y;
       camera.z = my.z;
       camera.pan = my.pan;
       camera.tilt = my.tilt;
       my.pan -= 10 * mouse_force.x * time;
       my.tilt += 10 * mouse_force.y * time;
       if (mouse_left == 1)
       {
           move_mode = ignore_passable + glide;
           result = ent_move (vector (10 * time, 0, 0), nullvector); // 10 = speed
       }
       if (mouse_right == 1)
       {
           move_mode = ignore_passable + glide;
           result = ent_move (vector (-10 * time, 0, 0), nullvector); // -10 = speed
       }
       wait (1);
    }
}

 

F: Könnten Sie mir bitte beschreiben, wie ich meine Models mit „Ressource“ schützen kann?
A: Folgen Sie diesen einfachen Schritten, allerdings benötigen Sie dafür A5 oder A6 Professional Edition:

- Erstellen Sie ein kurzes Script das wie dieses aussieht und nennen Sie es „Ressource.wdl“.

bind <guard.mdl>;
bind <warlock.mdl>; // "bind" as many models as you need

- Starten Sie WED, platzieren Sie einen einfachen Block im Level und fügen Sie dem Level die „ressource.wdl“ hinzu (File -> Map Properties).

- Benutzen Sie File-> Ressource und WED wird ein Ressource File, eine „*wrs“ Datei, im aktuellen Spiel-Ordner erstellen.

- Benutzen Sie auf diesem Weg Ressource Dateien in Ihrem Script.

resource "resources.wrs"; // open the "resources.wdl" file

string guard_mdl = "guard.mdl"; // retrieve the guard model from "resources.wrs"

starter create_guard_resource
{
   sleep (1); // wait until the level is loaded
   ent_create(guard_mdl, vector(100, 50, 200), null); // create the guard.mdl model at x = 100, y = 50, z = 200 quants
}

 

F: Gibt es eine einfach Methode um die FPS in meinem Spiel zu berechnen und anzuzeigen, da ich den Standard Debugpanel nicht verwenden kann?
A: Benutzen Sie den folgenden Code:

var fpsec;
var init_frames;

starter compute_fpsec()
{
   while (1)
   {
      init_frames = total_frames; // store the initial total_frames value
      sleep (1); // wait for a second
      fpsec = total_frames - init_frames; // get the new total_frames value and subtract init_frames from it
   }
}

panel debug_panel
{
   layer = 20;
   pos_x = 50;
   pos_y = 50;
   digits = 10, 10, 3, _a4font, 1, fpsec;
   flags = overlay, refresh, visible;
}

 

F: Ich möchte in der Lage sein, 200 verschiedene Actors in meinem Strategie-Spiel zu kontrollieren, aber ich kann mich mit der Idee von 200 Pointern nicht recht anfreunden… Gibt es eine Lösung?
A: Ja, benutzen Sie stattdessen ein „handle“:

entity* my_actor;

var index = 0;
var actors[200]; // store 200 handles in this array

action my_actors
{
   actors[index] = handle(my); // store the handle inside the array
   index += 1; // move to the next actor
   // put the rest of the code for your actors here
}

function move_actors_upwards(actor_number)
{
   my_actor = ptr_for_handle(actors[actor_number]);
   my_actor.z += 100;
}

function increase_height() // a simple test function
{
   move_actors_upwards(2); // increase the z of the 2nd actor by 100 quants
   move_actors_upwards(32); // increase the z of the 32nd actor by 100 quants
   move_actors_upwards(85); // increase the z of the 85th actor by 100 quants
}

on_i = increase_height;

 

F: Ich muss viele Meiner Bäume an bestimmten Positionen auf meinem Terrain platzieren, aber das setzen per WED dauert zu lange. Gibt es eine Alternative?
A: Plazieren Sie die Bäume nahe bei ihren endgültigen Positionen und fügen sie den folgenden Code ein. Geben Sie Ihren Bäumen die Action „dummy_tree“,
Im Spiel gehen Sie mit der Maus über die einzelnen Bäume und benutzen „A“, „Z“, „S“, „X“, „D“ und „C“ um die Bäume auf ihre korrekte Position zu setzen. Schreiben Sie sich dann die 3 Koordinaten, welche am Bildschirm angezeigt werden, raus und geben Sie dem entsprechenden Baum in WED. Wiederholen Sie diese Schritte bis alle Bäume richtig positioniert sind. Und vergessen Sie nicht F2 (Quicksave) und F3 (Quickload) um die aktuelle Position der Bäume zu speichern, wenn möchten.

bmap arrow_pcx = <arrow.pcx>;

panel entity_pan
{
   pos_x = 0;
   pos_y = 0;
   digits = 50, 10, 5, _a4font, 1, mouse_ent.x;
   digits = 50, 22, 5, _a4font, 1, mouse_ent.y;
   digits = 50, 34, 5, _a4font, 1, mouse_ent.z;
   flags = refresh, visible;
}

starter set_tree_coords()
{
   mouse_mode = 2;
   mouse_map = arrow_pcx;
   while (1)
   {
      mouse_pos.x = pointer.x;
      mouse_pos.y = pointer.y;
      if (mouse_ent != null) // entity detected?
      {
          if (key_a == on) {mouse_ent.x += 1 * time;}
          if (key_z == on) {mouse_ent.x -= 1 * time;}
          if (key_s == on) {mouse_ent.y += 1 * time;}
          if (key_x == on) {mouse_ent.y -= 1 * time;}
          if (key_d == on) {mouse_ent.z += 1 * time;}
          if (key_c == on) {mouse_ent.z -= 1 * time;}
      }
      wait (1);
   }
}

action dummy_tree // attach this action to all the tree models
{
   my.invisible = off; // put something (anything!) here
}


 

F: Ich möchte ein „Warnung!“ Panel in meinem HUD anzeigen, wenn ein Gegner des Player’s gesehen werden kann. Wie kann ich das bewerkstelligen?
A: Fügen Sie folgenden Code in die „while“ Schleife Ihrer Gegner, welche diese bewegt:

bmap alert_pcx = <alert.pcx>;

panel alert_pan
{
   bmap = alert_pcx;
   layer = 10;
   pos_x = 10;
   pos_y = 5;
   flags = overlay, refresh;
}

action my_enemy
{
    my.skill1 = 100; // health = 100
    // other code outside the "while" loop
    .................
    while (my.skill1 > 0) // as long as I'm alive
    {
       if(vec_to_screen(my.x, camera.x)) // if the camera can see me
       {
           alert_pan.visible = on; // show the "Alert!" panel
       }
       else // otherwise
       {
           alert_pan.visible = off; // hide the panel
       }
       // the rest of the code that runs inside the "while" loop goes here
       ...................
       wait (1);
    }
}

 

 

F: Gibt es eine einfach Möglichkeit um einen „heißen“ Boden zu erstellen, welcher dem Player Leben abzieht, ähnlich wie Lava?
A: Fügen Sie den folgenden Code am Ende Ihres Scripts ein:

starter hot_floor()
{
    while (player == null) {wait (1);}
    while (1)
    {
       vec_set (temp, player.x);
       temp.z -= 5000;
       trace_mode = ignore_me + ignore_passable + ignore_sprites + ignore_models + scan_texture;
       trace(player.x, temp);
       if (str_cmpi (tex_name, "lava")) // use a texture named "lava" (without the quotes) for the hot areas in your level
       {
           player._health -= 3 * time; // "3" gives the health decreasing speed
       }
       wait(1);
    }
}

 

F: Wäre es möglich, Lichter, welche nahe dem Player sind, automatisch anzuschalten auch wieder aus, wenn der Player wieder von den Lichtern weg geht?
A: Kopieren Sie den folgenden Code ans Ende ihres Scripts und geben Sie den Lichtern die Action „nice_lights“.

action nice_light
{
    while (player == null) {wait (1);}
    my.lightred = 200;
    my.lightgreen = 220;
    my.lightblue = 100;
    my.light = on;
    while (1)
    { 
       if (vec_dist (player.x, my.x) < 500) // play with 500
       {
            my.lightrange = 300;
            my.ambient = 100;
       }
       else
       {
            my.lightrange = 0;
            my.ambient = -100;
       }
       wait (1);
    }
}

 

F: Wie kann ich einen Feuerring erstellen, welcher dem Player immer folgt?
A: Benutzen Sie den folgenden Code:

bmap effect_tga = <effect.tga>;

function fade_them()
{
   my.alpha -= 5 * time; // play with 5
   if(my.alpha < 0) {my.lifespan = 0;}
}

function particle_init()
{
   temp.x = random(2) - 1;
   temp.y = random(2) - 1;
   temp.z = random(2) - 1;
   vec_set(my.vel_x, temp);
   my.move = on;
   my.bmap = fire_tga;
   my.flare = on;
   my.bright = on;
   my.alpha = 100;
   my.lifespan = 100;
   my.size = 15;
   my.function = fade_them;
}

starter player_ring()
{
   var temp_var = 0;
   var particle_start;
   var ring_diameter = 50;
   while (player == null) {wait (1);}
   while(1)
   {
      particle_start.x = player.x + (ring_diameter * sin(temp_var));
      particle_start.y = player.y + (ring_diameter * cos(temp_var));
      particle_start.z = player.z;
      effect(particle_init, 5, particle_start.x, nullvector);
      temp_var += 50 * time; // play with 50
      wait (1);
   }
}