Hallo Forum,

ich arbeite mich gerade durchs AUM 57.
Nun bin ich beim "Enemycode" der wie folgt aussieht.

Code:
 

action my_enemy // attach this action to your enemies
{
var idle_percentage = 0;
var run_percentage = 0;
var death_percentage = 0;
var content_right; // tracks the content in front of the player
var content_left; // tracks the content in front of the player
my.polygon = on; // use accurate collision detection
my.health = 100;
my.enable_impact = on; // the enemy is sensitive to impact with player's bullets
my.event = got_shot; // and runs this function when it is hit
my.status = idle; // that's the same thing with my.skill1 = 1; (really!)
while (my.status != dead) // this loop will run for as long as my.skill1 isn't equal to 3
{
if (my.status == idle) // hanging around?
{
ent_animate(my, "stand", idle_percentage, anm_cycle); // play the "stand" aka idle animation
idle_percentage += 3 * time; // "3" controls the animation speed
if (vec_dist (player.x, my.x) < 200) // the player has come too close?
{
// scanned in the direction of the pan angle and detected the player?
if ((c_scan(my.x, my.pan, vector(120, 60, 1000), ignore_me) > 0) && (you == player))
{
my.status = attacking; // then attack the player even if it hasn't fired at the enemy yet
}
}
}
if (my.status == attacking) // shooting at the player?
{
// the road is clear? then rotate the enemy towards the player
if (c_content (content_right.x, 0) + c_content (content_left.x, 0) == 2)
{
vec_set(temp, player.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan, temp); // turn the enemy towards the player
}
if (vec_dist (player.x, my.x) > 250)
{
vec_set(content_right, vector(50, -20, -5));
vec_rotate(content_right, my.pan);
vec_add(content_right.x, my.x);
if (c_content (content_right.x, 0) != 1) // this area isn't clear?
{
my.pan += 5 * time; // then rotate the enemy, allowing it to avoid the obstacle
}
vec_set(content_left, vector(50, 20, -5));
vec_rotate(content_left, my.pan);
vec_add(content_left.x, my.x);
if (c_content (content_left.x, 0) != 1) // this area isn't clear?
{
my.pan -= 5 * time; // then rotate the enemy, allowing it to avoid the obstacle
}
c_move (my, vector(10 * time, 0, 0), nullvector, glide);
ent_animate(my, "run", run_percentage, anm_cycle); // play the "run" animation
run_percentage += 6 * time; // "6" controls the animation speed
}
else
{
ent_animate(my, "alert", 100, null); // use the last frame from the "alert" animation here
}
if ((total_frames % 80) == 1) // fire a bullet each second
{
vec_for_vertex (temp, my, 8);
// create the bullet at enemy's position and attach it the "move_enemy_bullets" function
ent_create (bullet_mdl, temp, move_enemy_bullets);
}
if (vec_dist (player.x, my.x) > 250) // the player has moved far away from the enemy?
{
my.status = idle; // then switch to "idle"
}
}
wait (1);
}




Nun soll via c_content geprüft werden ob u.a. ein solider Block im Weg steht.
Ist dies der Fall soll der Block umgangen werden, so steht es im AUM aber hier passiert nichts. Der Feind bleibt stehen und schießt.
Ein weiteres Manko ist das der Feind versucht durch den Block zu schießen, obwohl er keinen Sichtkontakt zum Feind hat (da ein undurchsichtiger Block im Weg steht.) Wo liegt da der Fehler das er den Block nicht umgeht?
Und wie erreiche ich es das er nur schießt bzw. reagiert wenn er visuellen Sichtkontakt hat und nicht wie zur Zeit Sichtkontakt durch Scannen?

Danke für Hilfe

Lg Eike




Last edited by Sticky; 09/11/07 22:37.

A7 Commercial