Posted By: Morph
Simple enemy... - 01/31/08 14:38
A simple enemy code?? put the code only. Thanks
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);
}
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;
enemy_distance.z = 0;
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
{
if (you != null) {you.healthpoints -= 4 * time;}
}
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
}
var player_distance; // moves the player
var enemy_distance; // moves the enemy
var distance;
define sword_base = skill12; // using skill12, 13, 14 to store the sword_base coords
define sword_tip = skill15; // using skill15, 16, 17 to store the sword_tip coords
define healthpoints = skill18; // just another name for skill18
entity* enemy;
action enemy_fight // attached to the enemy
{
distance = vec_dist (my.x, player.x);
enemy = me; // I'm the enemy
enemy.healthpoints = 100; // and I have 100 healthpoints
while(!player) { wait(1); } // wait until the player exists
{
if (distance < 200) // 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;
enemy_distance.z = 0;
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
{
if (you != null) {you.healthpoints -= 4 * time;}
}
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
}
var enemy_distance; // moves the enemy
var distance;
define sword_base = skill12; // using skill12, 13, 14 to store the sword_base coords
define sword_tip = skill15; // using skill15, 16, 17 to store the sword_tip coords
define healthpoints = skill18; // just another name for skill18
entity* enemy;
action enemy_fight // attached to the enemy
{
while(plBiped01_entity==null){wait(1);}
distance = vec_dist (my.x, plBiped01_entity.x);
enemy = me; // I'm the enemy
enemy.healthpoints = 100; // and I have 100 healthpoints
while(!plBiped01_entity) { wait(1); } // wait until the player exists
{
if (distance < 200) // the player approaches the enemy
{
vec_set(temp, plBiped01_entity.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0; // I'm a maniac :)
enemy_distance.x = 5 * time_step;
enemy_distance.y = 0;
enemy_distance.z = 0;
ent_move(enemy_distance, nullvector);
ent_animate("walk", my.skill19); // play walk frames animation
my.skill19 += 5 * time_step; // "walk" animation speed
if (my.skill19 > 100) {my.skill19 = 0;} // loop animation
if (vec_dist (my.x, plBiped01_entity.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
{
if (you != null) {you.healthpoints -= 4 * time_step;
} }
ent_animate("attack", my.skill20); // play attack frames animation
my.skill20 += 5 * time_step; // "attack" animation speed
wait (1);
}
wait (6); // slows down the enemy and reduces the number of traces per second
}
}
else // the player is farther than 200 quants away
{
ent_animate("stand", my.skill21); // play stand frames animation
my.skill21 += 2 * time_step; // "stand" animation speed
if (my.skill21 > 100) {my.skill21 = 0;} // loop animation
}
wait (1);
while (my.skill22 < 80) // the enemy is dead
{
ent_animate("death", my.skill22); // play death frames animation
my.skill22 += 1 * time_step; // "death" animation speed
wait (1);
}
my.passable = on; // the corpse can't be hit by the sword from now on
}
Quote:
ent_animate(ENTITY* entity,STRING* scene,var percent,var mode)
action enemy_fight // attached to the enemy
{
while(plBiped01_entity==null){wait(1);}
distance = vec_dist (my.x, plBiped01_entity.x);
enemy = me; // I'm the enemy
enemy.healthpoints = 100; // and I have 100 healthpoints
while(!plBiped01_entity) { wait(1); } // wait until the player exists
{
while(!plBiped01_entity) { wait(1); } // wait until the player exists
{
while(!plBiped01_entity) { wait(1); } // wait until the player exists
while(my.healthpoints > 0)
{
enemy = me; // I'm the enemy
enemy.healthpoints = 100; // and I have 100 healthpoints
my.healthpoints = 100;
var enemy_distance; // moves the enemy
var distance;
define sword_base = skill12; // using skill12, 13, 14 to store the sword_base coords
define sword_tip = skill15; // using skill15, 16, 17 to store the sword_tip coords
define healthpoints = skill18; // just another name for skill18
entity* enemy;
action enemy_fight // attached to the enemy
{
while(plBiped01_entity==null){wait(1);}
distance = vec_dist (my.x, plBiped01_entity.x);
my.healthpoints = 100;
while(!plBiped01_entity) { wait(1); } // wait until the player exists
while(my.healthpoints > 0)
{
if (distance < 200) // the player approaches the enemy
{
vec_set(temp, plBiped01_entity.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0; // I'm a maniac :)
enemy_distance.x = 5 * time_step;
enemy_distance.y = 0;
enemy_distance.z = 0;
ent_move(enemy_distance, nullvector);
ent_animate(me,"walk", my.skill19, ANM_CYCLE); // play walk frames animation
my.skill19 += 5 * time_step; // "walk" animation speed
if (my.skill19 > 100) {my.skill19 = 0;} // loop animation
if (vec_dist (my.x, plBiped01_entity.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
{
if (you != null) {you.healthpoints -= 4 * time_step;
} }
ent_animate(me,"attack", my.skill20, ANM_CYCLE); // play attack frames animation
my.skill20 += 5 * time_step; // "attack" animation speed
wait (1);
}
wait (6); // slows down the enemy and reduces the number of traces per second
}
}
else // the player is farther than 200 quants away
{
ent_animate(me,"stand", my.skill21, ANM_CYCLE); // play stand frames animation
my.skill21 += 2 * time_step; // "stand" animation speed
if (my.skill21 > 100) {my.skill21 = 0;} // loop animation
}
wait (1);
while (my.skill22 < 80) // the enemy is dead
{
ent_animate(me,"death", my.skill22, ANM_CYCLE); // play death frames animation
my.skill22 += 1 * time_step; // "death" animation speed
wait (1);
}
my.passable = on; // the corpse can't be hit by the sword from now on
}
}
while (my.skill22 < 80) // the enemy is dead
{
ent_animate(me,"death", my.skill22, ANM_CYCLE); // play death frames animation
my.skill22 += 1 * time_step; // "death" animation speed
my.passable = on; // the corpse can't be hit by the sword from now on
wait (1);
}
define sword_base = skill12; // using skill12, 13, 14 to store the sword_base coords
define sword_tip = skill15; // using skill15, 16, 17 to store the sword_tip coords
define healthpoints = skill18; // just another name for skill18
action enemy_fight
{
var move_dist[3];
var distance;
my.healthpoints = 100;
c_setminmax(my);
wait(1);
while(plBiped01_entity == null) { wait(1); }
while(my.healthpoints > 0)
{
distance = vec_dist(my.x, plBiped01_entity.x);
if(distance < 200) // the player approaches the enemy
{
vec_set(temp, plBiped01_entity.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0;
move_dist.x = 5 * time_step;
move_dist.y = 0;
move_dist.z = 0;
c_move(my,move_dist,nullvector,IGNORE_PASSABLE);
ent_animate(my, "walk", my.skill19, ANM_CYCLE); // play walk frames animation
my.skill19 = cycle(my.skill19+5*time_step,0,101); // "walk" animation speed + loop animation
if(distance < 50) // if the player comes closer than 50 quants attack him
{
my.skill20 = 0; // reset "attack" frames
while(my.skill20 < 100)
{
vec_for_vertex(my.sword_base,my,306);
vec_for_vertex(my.sword_tip,my,291);
c_trace(my.sword_base,my.sword_tip,IGNORE_ME|IGNORE_PASSABLE);
if(you)
{
you.healthpoints -= 4 * time_step;
}
ent_animate(my,"attack",my.skill20,ANM_CYCLE); // play attack frames animation
my.skill20 += 5 * time_step; // "attack" animation speed
wait(1);
}
wait(6);
}
}
else // the player is farther than 200 quants away
{
ent_animate(my,"stand",my.skill21,ANM_CYCLE); // play stand frames animation
my.skill21 = cycle(my.skill21+2*time_step,0,101); // "stand" animation speed + loop animation
}
wait(1);
}
// enemy was killed:
while(my.skill22 < 80)
{
ent_animate(me,"death", my.skill22, ANM_CYCLE); // play death frames animation
my.skill22 += 1 * time_step; // "death" animation speed
wait(1);
}
my.passable = on; // the corpse can't be hit by the sword from now on
}
function enemy_events()
{
if(event_type == event_shoot)
{
my.healthpoints -= 10;
}
}
action enemy_fight
{
var move_dist[3];
var distance;
my.enable_shoot = on;
my.event = enemy_events;
my.healthpoints = 100;
//rest of the code