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 = player.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;
vec_set (temp, my.x);
temp.z -= 1000;
trace_mode = ignore_me + use_box;
player_distance.z = -trace (my.x, temp);
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
}
else // the player is standing
{
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
}
action
enemy_fight // attached to the enemy
{
enemy = me; // I'm the enemy
enemy.healthpoints = 100; // and I have 100 healthpoints
while (my.healthpoints > 0) // as long as I'm alive
{
if (vec_dist (my.x, player.x) < 200 && player.healthpoints >
0) // the player approaches the enemy
{
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0; // I'm a maniac :)
enemy_distance.x = 5 * time;
enemy_distance.y = 0;
vec_set (temp, my.x);
temp.z -= 1000;
trace_mode = ignore_me + use_box;
enemy_distance.z = -trace (my.x, temp);
ent_move(enemy_distance, nullvector);
ent_cycle("walk", my.skill19); // play walk frames animation
my.skill19 += 5 * time; // "walk" animation speed
if (my.skill19 > 100) {my.skill19 = 0;} // loop animation
if (vec_dist (my.x, player.x) < 50) // if the player comes closer than
50 quants attack him
{
my.skill20 = 0; // reset "attack" frames
while (my.skill20 < 100)
{
ent_vertex(my.sword_tip, 291); // sword tip vertex coords - get the value
in Med
ent_vertex(my.sword_base, 306); // sword base vertex coords - get the value
in Med
trace_mode = ignore_me + ignore_passable;
trace (my.sword_base, my.sword_tip); // trace between these sword positions
if (result != 0) // hit something, could be the player or another enemy
{
effect (particle_blood, 2, target, normal);
if (you != null) {you.healthpoints -= 4 * time;}
ent_playsound (my, sword_snd, 50); // sword sound
}
ent_cycle("attack", my.skill20); // play attack frames animation
my.skill20 += 5 * time; // "attack" animation speed
wait (1);
}
waitt (6); // slows down the enemy and reduces the number of traces per
second
}
}
else // the player is farther than 200 quants away
{
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
}
wait (1);
}
while (my.skill22 < 80) // the enemy is dead
{
ent_cycle("death", my.skill22); // play death frames animation
my.skill22 += 1 * time; // "death" animation speed
wait (1);
}
my.passable = on; // the corpse can't be hit by the sword from now on
}
F:
Wie kann ich die Intensität des Nebels in meinen Levels ändern?
Ich verändere camera.fog, doch alle Werte zwischen 1 und 100 liefern
den gleichen Effekt!
A:
Setzen Sie die Intensität mit den neuen Variablen camera.fog_start
und camera.fog_end. Schauen Sie sich “Fogger” in Aum 25 für ein Beispiel
an.
F:
Kann bitte jemand erklären, wie ich eine Bewegung ähnlich wie
in Counterstrike hinbekomme, also normales Gehen ist eigentlich Rennen
und mit Shift wird die Geschwindigkeit halbiert. Ich verwende die Templates.
A:
Schreiben Sie diese Zeile in die Main Funktion:
shift_sense = 0.5;
und ändern Sie danach die strength Variable in der movement.wdl auf diese Weise:
var
strength[3] = 10,4,75; // default ahead, side, jump strength
F:
Ich versuche einen Block zu programmieren, der eine Tür öffnet,
wenn man darauf tritt, aber ich möchte nicht jede Tür aufs Neue
programmieren; ich möchte einfach jeder Tür die gleiche Funktion
geben und die Blöcke auf die Türen weisen lassen. Ist das möglich?
A:
Sicher. Scannen Sie die Türen mit Hilfe der Blöcke. Schauen Sie
sich den “Intelligent Elevators” Artikel in Aum 18 an, um zu sehen, wie
es gemacht wird.
F:
Ich habe eine Waffe und kann laufen. Wenn ich eine Kugel abschieße,
gehe ich sehr langsam. Ist das normal?
A:
Nein, ist es nicht. Ihre Kugel kollidiert mit der Waffe. Schreiben Sie
diese Zeile vor die ent_move Anweisung für Ihre Kugel:
move_mode
= ignore_you + ignore_passable
F:
Wie kann ich AVIs auf Sprites abspielen?
A:
Schreiben Sie den Code unten an das Ende Ihrer office.wdl; dann geben Sie
Ihrem Sprite die Action movie_on_sprite. Mit der “P” Taste rufen Sie den
Film auf.
action
movie_on_sprite
{
while (key_p == 0) {wait (1);} // press "P" to play the movie
media_play ("skiing.avi",bmap_for_entity (my, 0), 100);
}
F:
Kann mir jemand verraten, wie ich den Sprite des Raketenwerfers durch Partikel
ersetzen kann?
A:
Schreiben Sie den Code an den Anfang der weapons.wdl:
bmap spark_pcx = <spark.pcx>;
function
fade_away()
{
my.alpha -= 3 * time;
if (my.alpha < 0) {my.lifespan = 0;}
}
function
particle_sparks()
{
temp.x = random(2) - 1;
temp.y = random(2) - 1;
temp.z = random(2) - 1;
vec_rotate (temp, my.pan);
vec_normalize (temp, 3);
vec_add (my.vel_x, temp);
my.alpha = 40 + random(30);
my.bmap = spark_pcx;
my.size = random(2) + 5;
my.flare = on;
my.bright = on;
my.move = on;
my.lifespan = 100;
my.function = fade_away;
}
function
_rocket_event2()
{
proc_kill(1); //EXCLUSIVE_ENTITY; // terminate other functions started
by 'my' to stop moving
MY.EVENT = NULL;
MY.SKILL9 = -1; // stop movement
wait(1); // to avoid dangerous instruction in event warning
// Apply damage
range = MY._DAMAGE * 6;
damage = MY._DAMAGE;
temp.PAN = 360;
temp.TILT = 360;
temp.Z = range;
indicator = _EXPLODE; // must always be set before scanning
scan(MY.POS,MY_ANGLE,temp);
// Explode
MY.AMBIENT = 100;
MY.FACING = ON;
MY.NEAR = ON;
MY.FLARE = ON;
MY.PASSABLE = ON;
MY.AMBIENT = 100;
MY.LIGHTRED = light_flash.RED;
MY.LIGHTGREEN = light_flash.GREEN;
MY.LIGHTBLUE = light_flash.BLUE;
MY.LIGHTRANGE = 64;
wait(1);
play_entsound ME,hit_wham,300;
my.skill9 = 10;
vec_set (temp, my.pos);
while (my.skill9 > 0)
{
effect (particle_sparks, 10, temp, normal);
my.skill9 -= 2 * time;
}
remove(ME);
}
und ändern Sie dann zwei Zeilen in der rocket_launch Funktion:
function
rocket_launch()
{
vec_scale(MY.SCALE_X,actor_scale); // use actor_scale
MY.ENABLE_BLOCK = ON; // collision
with map surface
MY.ENABLE_ENTITY = ON; // collision with
entity
MY.ENABLE_STUCK = ON;
MY.ENABLE_IMPACT = ON;
MY.ENABLE_PUSH = ON;
MY.EVENT = _rocket_event2;
MY.AMBIENT = 100; // bright
MY.LIGHTRANGE = 150;
MY.LIGHTRED = 250;
MY.LIGHTGREEN = 50;
MY.LIGHTBLUE = 50;
//- MY.PAN = YOUR.PAN; // the rocket start in the same direction
than this 'emitter'
//- MY.TILT = YOUR.TILT;
//- MY.ROLL = YOUR.ROLL;
vec_to_angle(MY.PAN, shot_speed);
MY.SKILL2 = shot_speed.x;
MY.SKILL3 = shot_speed.y;
MY.SKILL4 = shot_speed.z;
MY._DAMAGE = damage;
MY._FIREMODE = fire_mode;
MY.SKILL9 = 250; // 'burn time' (fuel)
while(MY.SKILL9 > 0)
{
temp.X = MY.SKILL2 * TIME;
temp.Y = MY.SKILL3 * TIME;
temp.Z = MY.SKILL4 * TIME;
vec_scale(temp,movement_scale); // scale distance by movement_scale
//-- move(ME,NULLSKILL,temp);
move_mode = ignore_you + ignore_passable + activate_trigger;
result = ent_move(nullskill,temp);
emit(3,MY.POS,particle_smoke); // emit( smoke
MY.SKILL9 -= TIME; // burn fuel
wait(1); // update position once per tick
}
_rocket_event2(); // explode when out of fuel
}
F:
Gibt es eine Möglichkeit, die patrol_path Action zu ändern, dass
ein 3D Pfad verwendet wird?
A:
Benutzen Sie den “Campath” Artikel auf Aum 6. Der Code bewegt eine Kamera
auf einem 3D Pfad, aber Sie können die Kamera durch jede andere Entity
ersetzen.
F:
Ich habe bei anderen schon atemberaubende Terrains mit LOD, Gras, etc.
gesehen. Ich frage mich, ob vielleicht jemand die Geduld hätte, mir
einen Hinweis zu geben, wie sowas bewerkstelligt werden kann...
A:
Unreal Tournament benutzt ein simples LOD System für das Gras, mit
detaillierten Sprites die angezeigt werden, wenn der Spieler näher
kommt. Serious Sam 2 erzeugt detaillierte Gras Sprites um den Spieler herum
und entfernt die, die weiter weg sind.