action
another_entity
{
while (player == null) {wait (1);}
while (1)
{
if (vec_dist(my.x, player.x) < 50 && player._health > 0) { player._health
-= 0.5 * time; }
wait (1);
}
}
F:
Wenn ich versuche, mein Level ausrechnen zu lassen, erhalte ich folgende
Fehlermeldung: “Block outside level boundaries”. Wie kann ich Abhilfe schaffen?
A:
Ihr Level ist größer als 50000 Quants. Klicken Sie auf Build
und tippen Sie in das Feld “Build Options” die Zeile “-bound 100000”. Sie
können Werte bis 250000 eintragen.
F:
Ich möchte in der main eine DLL öffnen und sie schließen,
bevor die Anwendung beendet wird. Jedoch, wenn ich ESC drücke, wird
einfach das Spiel beendet, wie kann ich diese Meldung abfangen, um sicherzugehen,
dass auch die DLL geschlossen wird?
A:
Dieser Code liefert ein Beispiel:
dllfunction ComputeTime(value);
function end_game();
var game_over = 0; // set it to 1 to finish the game
function
main()
{
on_esc = null; // disable
the keys
on_f10 = null; // that
shut down the engine
load_level <sarl.wmb>;
dll_open ("timer.dll");
while (game_over == 0)
{
ComputeTime(25);
wait (1);
}
dll_close(dll_handle);
exit;
}
function
end_game()
{
game_over = 1;
}
on_esc
= end_game; // use the same keys
on_f10
= end_game; // to stop the game
F:
Ich weiß, dass es leicht ist, ich weiß, dass es im Handbuch
steht, aber kann mir jemand mit einem Code helfen, ein Panel auf den Bildschirm
zu bringen?
A:
Hier ist das Beispiel:
bmap mypicture_pcx = <mypicture.pcx>;
panel
mypanel_pan
{
bmap = mypicture_pcx;
pos_x = 10; // position on x
pos_y = 20; // and y
layer = 20;
flags = overlay, refresh, d3d, visible;
}
F:
Wenn ich mein Model speichere, dann kommt es mir vor, als gäbe es
einen Snap, der einige Vertexes verschiebt.
A:
Ältere Model Formate (so wie mdl, md2) speichern ihre Vertex Positionen
in einer Matrix von 256x256 möglichen Koordinaten. Benutzen Sie das
neue mdl-Format zum Speichern: wählen Sie View -> Model properties
und kreuzen Sie “High Precision” an, bevor Sie speichern, um das Problem
zu lösen.
F:
Wie könnte man ein 250x250 Panel, das nur aus einem Bitmap besteht,
zur Laufzeit auf das dreifache seiner Größe skalieren?
A:
Benutzen Sie eine Entity:
entity
my_sprite
{
type = <mysprite.pcx>;
layer = 25;
view = camera;
x = 600;
y = 222;
z = 135;
flags = visible;
}
Diese x y z Werte werden das Sprite als Panel in der oberen linken Ecke erscheinen lassen. Wenn Sie diese Werte ändern, wird es größer erscheinen:
function
increase_size()
{
my_sprite.x = 250; // play with these values
my_sprite.y = 19;
my_sprite.z = -10;
}
F:
Ich habe ein Schwert und wenn der Spieler auf eine gewisse Distanz herangekommen
ist, soll er es mit der Leertaste aufheben können. Geht das?
A:
Kombinieren Sie den Code hier unten mit Ihrem Schwert-Code:
action
pick_up_sword
{
while (player == null) {wait (1);}
while (1)
{
if ((vec_dist (player.x, my.x < 100)) && (key_space == 1))
{
call your sword action / function here
}
wait (1);
}
}
F:
Ich benutze den Schwertkampf-Code aus Aum12. Ist es möglich, nach
vorn zu springen, wenn die Leertaste gedrückt wird? Der Spieler sollte
eine gewisse Distanz springen.
A:
Ersetzen Sie die Action player_fight mit dieser hier:
action
player_fight // attached to the player
{
player = me; // I'm the player
player.healthpoints = 100; // and I have 100 health points
while (player.healthpoints > 0) // as long as I'm alive
{
camera.x = player.x - 200 * cos(player.pan); // 200 = distance between
the player and the camera
camera.y = player.y - 200 * sin(player.pan); // same value here
camera.z = 200; // above the player
camera.pan = player.pan; // looks in the same direction with the player
camera.tilt = -30; // look down at the player
my.pan += 4 * (key_a - key_d) * time - 20 * mouse_force.x * time; // rotates
with the keys A and D or with the mouse
player_distance.x = 10 * (key_w - key_s) * time; // moves forward / backward
with W / S
player_distance.y = 0;
player_distance.z = 0;
if ((key_w == 1) || (key_s == 1)) // the player is walking
{
ent_cycle("walk", my.skill20); // play walk frames animation
my.skill20 += 4 * time; // "walk" animation speed
if (my.skill20 > 100) {my.skill20 = 0;} // loop animation
}
if (key_space == 1) // space to jump
{
ent_cycle("jump", my.skill20);
my.skill20 += 3 * time; // "jump" animation speed
if (my.skill20 < 100)
{
player_distance.z += 0.1 * time;
player_distance.x += 2 * time;
}
}
if (key_any == 0) // the player is standing
{
player_distance.z = 0;
player.skill20 = 0;
ent_cycle("stand", my.skill21); // play stand frames animation
my.skill21 += 2 * time; // "stand" animation speed
if (my.skill21 > 100) {my.skill21 = 0;} // loop animation
}
ent_move(player_distance, nullvector);
if (mouse_left == 1) // if we press the left mouse button
{
my.skill22 = 0; // reset "attack" frames
while (my.skill22 < 100)
{
ent_vertex(my.sword_tip, 315); // sword tip vertex coords - get the value
in Med
ent_vertex(my.sword_base, 293); // sword base vertex coords - get the value
in Med
trace_mode = ignore_me + ignore_passable; // ignore me (the player) and
all the entities that are passable
trace (my.sword_base, my.sword_tip); // trace between these sword positions
if (result != 0) // the player has hit something
{
effect (particle_sparks, 10, target, normal);
if (you != null) {you.healthpoints -= 6 * time;} // if it hasn't hit a
wall, decrease health
ent_playsound (my, sword_snd, 50); // sword sound
}
ent_cycle("attack", my.skill22); // play attack frames animation
my.skill22 += 8 * time; // "attack" animation speed
wait (1);
}
while (mouse_left == 1) {wait (1);} // can't use autofire on a sword :)
}
wait (1);
}
while (my.skill23 < 90) // the player is dead
{
ent_cycle("death", my.skill23); // play death frames animation
my.skill23 += 3 * time; // "death" animation speed
wait (1);
}
my.passable = on; // the corpse can't be hit by the enemy sword from now
on
}
F:
Ich erstelle mein Terrain als Kombination aus Level Blocks und Höhenmaps.
Ich möchte die Kletterfähigkeit meiner Spielcharaktere in den
Höhenmapzonen meines Spiels einschränken, mit Hilfe einer unsichtbaren
Decke, aber der Himmel sollte sichtbar bleiben. Geht das?
A:
Na klar, mit unsichtbaren Level Blocks; fügen Sie einen Block in WED
ein, klicken Sie ihn mit der rechten Maustaste an und wählen Sie invisible
unter seinen Properties an.
F:
Wie kann ich vec_to_mesh oder vec_for_mesh benutzen, um Partikel von sagen
wir drei verschiedenen Vertexes eines Schwertmodels zu emittieren?
A:
Ermitteln Sie die Koordinaten der Vertexes in der Action, die zu dem Schwert
gehört:
var
vertex1;
var
vertex2;
var
vertex3;
action
my_sword
{
while (1)
{
ent_vertex(vertex1, 115); // get this value in Med
ent_vertex(vertex2, 215); // get this value in Med
ent_vertex(vertex3, 315); // get this value in Med
// the rest of your sword action code
..........................
wait (1);
}
}
Die unteren Zeilen gehören in die Action, welche die Partikel erzeugt:
effect
(particle_init, 1, vertex1, normal);
effect
(particle_init, 1, vertex2, normal);
effect
(particle_init, 1, vertex3, normal);
function
particle_init()
{
// the function that creates the particles
}