Posted By: Blink![](/ubb7/images/groups/mod.gif)
![](/ubb7/images/groups/mod.gif)
A6 enemy attack issue, help please... - 09/04/09 23:25
ok, so i have an enemy that attacks. it comes in close to attack, but after it attacks, it "hops" backward a bit. any idea why? it does it everytime it attacks.
thanks in advance,Blink.
thanks in advance,Blink.
Code:
action abigail { enemy_events(); g3_handle_radar(); var move_dist[3]; var distance; my.enable_entity = on; my.enable_impact = on; my.albedo=0; my.ambient=100; my.unlit=on; my.bright=on; my.enable_scan = on; my.polygon = on; my.enable_block=on; my.transparent = on; my.enable_shoot = on; my.health = 10; my.event = enemy_events; vec_set (temp, my.x); temp.z -= 1; my.skill11 = c_trace(my.x,temp,IGNORE_ME|IGNORE_PASSABLE); my.z = my.skill11+0; c_setminmax(my); wait(1); while(plBiped01_entity == null) { wait(1); } while(my.health > 0) { distance = vec_dist(my.x, plBiped01_entity.x); if(distance < 1000) // 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_ME|IGNORE_PASSABLE|IGNORE_MAPS); ent_animate(my, "walk", my.skill19, ANM_CYCLE); // play run frames animation my.skill19 = cycle(my.skill19+48*time_step,0,101); // "run" animation speed + loop animation ent_playsound (my, ghostwalk, 100); if(distance < 150) // if the player comes closer than 50 quants attack him { my.skill23 = 0; // reset "attack" frames while(my.skill23 < 100) { c_trace (my.x,temp,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS|IGNORE_SPRITES|SCAN_TEXTURE); create_explosions(); ent_animate(my,"attack",my.skill23,ANM_CYCLE); // play attack frames animation my.skill23 += 20 * time_step; // "attack" animation speed you = plBiped01_entity; you._armor__003 -= 1 * time_step; wave_handle = snd_play(wave, 100, 0); snd_stop(wave); wait(1); if(you._armor__003 < 0) { you._health__003 += you._armor__003; you._armor__003 = 0; PlBiped_Damage_Reaction(); // display damage panel } } 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 < 90) { ent_animate(me,"death", my.skill22, ANM_CYCLE); // play death frames animation my.skill22 += 16 * time_step; // "death" animation speed wait(1); } my.passable = on; // the corpse can't be hit by the sword from now on while (my.alpha > 0) { my.alpha -= 0.3 * time_step; wait (1); } ent_playsound (my, die, 100); ent_remove (me); } }