1 registered members (AndrewAMD),
16,038
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
taking cover
#349644
12/09/10 20:06
12/09/10 20:06
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
So Im trying to make a taking cover code for my enemies; Here is how it looks know; ENTITY* my_target;
action my_enemy() { while (!player) {wait (1);} var idle_percentage = 0; var run_percentage = 0; VECTOR content_right; VECTOR content_left; VECTOR temp; my.health = 100; my.eflags |= FAT | NARROW; my.emask |= ENABLE_SHOOT | ENABLE_SCAN; c_setminmax(my); my.status = idle; while(my.health>0) { if (my.status == idle) { ent_animate(my, "stand", idle_percentage, ANM_CYCLE); idle_percentage += 3 * time_step; if (vec_dist (player.x, my.x) < 5000) { if ((c_scan(my.x, my.pan, vector(120, 60, 4500), IGNORE_ME) > 0) && (you == player)) { my.status = attacking; } } } if (my.status == attacking) { 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); } if (vec_dist (player.x, my.x) > 500) { vec_set(content_right, vector(50, -20, -15)); vec_rotate(content_right, my.pan); vec_add(content_right.x, my.x); if (c_content (content_right.x, 0) != 1) { my.pan += 5 * time_step; } vec_set(content_left, vector(50, 20, -15)); vec_rotate(content_left, my.pan); vec_add(content_left.x, my.x); if (c_content (content_left.x, 0) != 1) { my.pan -= 5 * time_step; } ent_animate(my, "alert", 100, NULL); } else { ent_animate(my, "alert", 100, NULL); } if ((total_frames % 20) == 1) { ak_shoot_handle=snd_play(ak_shoot_wav,70,0); enemy_bullet(50, 7, 10); } if (vec_dist (player.x, my.x) > 6000) { my.status = idle; } c_scan(my.x, my.pan, vector(360, 60, 4500), IGNORE_ME | SCAN_ENTS | SCAN_LIMIT); if (you) { my_target = you; my_target.scale_z = 4; vec_set(temp, my_target.x); vec_sub(temp, my.x); vec_to_angle(my.pan, temp); my.tilt = 0; while (vec_dist (my.x, my_target.x) > 50) { c_move (my, vector(20 * time_step, 0, 0), nullvector, GLIDE); ent_animate(my, "run", run_percentage, ANM_CYCLE); run_percentage += 6 * time_step; } my.skill99 = 0; while (my.skill99 < my_target.skill1) { my.status = attacking; } ent_remove(my_target); } else { my.status = idle; } } wait (1); } my.event = NULL; RagDoll_Spawn(me); }
action target_cover() { set (my, PASSABLE | INVISIBLE); my.emask |= ENABLE_SCAN; } Everything marked red is in the problem zone. But I just can`t find out what the problem is! And just for information; 1. Befor I added my not working cover code, the enemy was fine. 2. There are no warning or errors. The enemy just not moves and when I shoot him the game freezes...  And this is like allways with me, open scoure. So I would never be bad if someone uses this script when its fixed.  But it will get better and better, I`ll promise 
|
|
|
Re: taking cover
[Re: TheShooter]
#349648
12/09/10 20:19
12/09/10 20:19
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
äämmm... No. But I will try it wait a second
|
|
|
Re: taking cover
[Re: Random]
#349650
12/09/10 20:30
12/09/10 20:30
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Any other ideas? Hahaha... Let`s see who is able to solve this first 
|
|
|
Re: taking cover
[Re: Superku]
#349654
12/09/10 21:18
12/09/10 21:18
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Ok now the enemy moves when Im in his scan area, but he walks towards the cover point and doesn`t stop walking in that direktion. Moreover, when I shoot him after he starts to walk, he can`t die. Ans all this without seeing him shooting at my player. So here is how it looks now; ENTITY* my_target;
action my_enemy() { while (!player) {wait (1);} var idle_percentage = 0; var run_percentage = 0; VECTOR content_right; VECTOR content_left; VECTOR temp; my.health = 100; my.eflags |= FAT | NARROW; my.emask |= ENABLE_SHOOT | ENABLE_SCAN; c_setminmax(my); my.status = idle; while(my.health>0) { if (my.status == idle) { ent_animate(my, "stand", idle_percentage, ANM_CYCLE); idle_percentage += 3 * time_step; if (vec_dist (player.x, my.x) < 5000) { if ((c_scan(my.x, my.pan, vector(120, 60, 4500), IGNORE_ME) > 0) && (you == player)) { my.status = attacking; } } } if (my.status == attacking) { 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); } if (vec_dist (player.x, my.x) > 500) { vec_set(content_right, vector(50, -20, -15)); vec_rotate(content_right, my.pan); vec_add(content_right.x, my.x); if (c_content (content_right.x, 0) != 1) { my.pan += 5 * time_step; } vec_set(content_left, vector(50, 20, -15)); vec_rotate(content_left, my.pan); vec_add(content_left.x, my.x); if (c_content (content_left.x, 0) != 1) { my.pan -= 5 * time_step; } ent_animate(my, "alert", 100, NULL); } else { ent_animate(my, "alert", 100, NULL); } if ((total_frames % 20) == 1) { ak_shoot_handle=snd_play(ak_shoot_wav,70,0); enemy_bullet(50, 7, 10); } if (vec_dist (player.x, my.x) > 6000) { my.status = idle; } c_scan(my.x, my.pan, vector(360, 60, 4500), IGNORE_ME | SCAN_ENTS | SCAN_LIMIT); if (you) { my_target = you; my_target.scale_z = 4; vec_set(temp, my_target.x); vec_sub(temp, my.x); vec_to_angle(my.pan, temp); my.tilt = 0; while (vec_dist (my.x, my_target.x) > 50) { c_move (my, vector(20 * time_step, 0, 0), nullvector, GLIDE); ent_animate(my, "run", run_percentage, ANM_CYCLE); run_percentage += 6 * time_step; wait(1); } my.skill99 = 0; while (my.skill99 < my_target.skill1) { my.status = attacking; wait(1); } ent_remove(my_target); } else { my.status = idle; } } wait (1); } my.event = NULL; RagDoll_Spawn(me); }
action target_cover() { set (my, PASSABLE | INVISIBLE); my.emask |= ENABLE_SCAN; }
|
|
|
Re: taking cover
[Re: Random]
#349655
12/09/10 21:21
12/09/10 21:21
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
while (vec_dist (my.x, my_target.x) > 50)
{
c_move (my, vector(20 * time_step, 0, 0), nullvector, GLIDE);
ent_animate(my, "run", run_percentage, ANM_CYCLE);
run_percentage += 6 * time_step;
wait(1);
}
my.skill99 = 0;
while (my.skill99 < my_target.skill1)
{
my.status = attacking;
wait(1);
}
He cannot die because you don't check health > 0 in the loop condition. Do you increase skill99 somewhere? Otherwise the second loop will be infinite.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: taking cover
[Re: Superku]
#349694
12/10/10 14:12
12/10/10 14:12
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Yes, Superku! He dies! But hes still not stoping and shooting...; ENTITY* my_target;
action my_enemy() { while (!player) {wait (1);} var idle_percentage = 0; var run_percentage = 0; VECTOR content_right; VECTOR content_left; VECTOR temp; my.health = 100; my.eflags |= FAT | NARROW; my.emask |= ENABLE_SHOOT | ENABLE_SCAN; c_setminmax(my); my.status = idle; while(my.health>0) { if (my.status == idle) { ent_animate(my, "stand", idle_percentage, ANM_CYCLE); idle_percentage += 3 * time_step; if (vec_dist (player.x, my.x) < 5000) { if ((c_scan(my.x, my.pan, vector(120, 60, 4500), IGNORE_ME) > 0) && (you == player)) { my.status = attacking; } } } if (my.status == attacking) { 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); } if (vec_dist (player.x, my.x) > 500) { vec_set(content_right, vector(50, -20, -15)); vec_rotate(content_right, my.pan); vec_add(content_right.x, my.x); if (c_content (content_right.x, 0) != 1) { my.pan += 5 * time_step; } vec_set(content_left, vector(50, 20, -15)); vec_rotate(content_left, my.pan); vec_add(content_left.x, my.x); if (c_content (content_left.x, 0) != 1) { my.pan -= 5 * time_step; } ent_animate(my, "alert", 100, NULL); } else { ent_animate(my, "alert", 100, NULL); } if ((total_frames % 20) == 1) { ak_shoot_handle=snd_play(ak_shoot_wav,70,0); enemy_bullet(50, 7, 10); } if (vec_dist (player.x, my.x) > 6000) { my.status = idle; } c_scan(my.x, my.pan, vector(360, 60, 4500), IGNORE_ME | SCAN_ENTS | SCAN_LIMIT); if (you) { my_target = you; my_target.scale_z = 4; vec_set(temp, my_target.x); vec_sub(temp, my.x); vec_to_angle(my.pan, temp); my.tilt = 0; while (vec_dist (my.x, my_target.x) > 50) { while(my.health>0) { c_move (my, vector(20 * time_step, 0, 0), nullvector, GLIDE); ent_animate(my, "run", run_percentage, ANM_CYCLE); run_percentage += 6 * time_step; wait(1); } } while (my.skill99 < my_target.skill1) { my.skill99 = 1; my.status = attacking; wait(1); } ent_remove(my_target); } else { my.status = idle; } } wait (1); } my.event = NULL; RagDoll_Spawn(me); }
action target_cover() { set (my, PASSABLE | INVISIBLE); my.emask |= ENABLE_SCAN; } red is the from Superkus addwise changed script.
|
|
|
|