Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (AndrewAMD), 16,038 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
taking cover #349644
12/09/10 20:06
12/09/10 20:06
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline 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;

Click to reveal..
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... frown

And this is like allways with me, open scoure.
So I would never be bad if someone uses this script when its fixed. grin

But it will get better and better, I`ll promise wink



Re: taking cover [Re: Random] #349646
12/09/10 20:09
12/09/10 20:09
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
TheShooter Offline
User
TheShooter  Offline
User

Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
have you defined my_target?
mfG


Staub ist das neue Prime!!

Programming is like sex:
One mistake and you have to support it for the rest of your life.

Aktuelles Projekt: http://thisiswargame.bplaced.net/index.html

A8 Commercial *freu*
Re: taking cover [Re: TheShooter] #349648
12/09/10 20:19
12/09/10 20:19
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
äämmm... grin
No.
But I will try it wait a second



Re: taking cover [Re: Random] #349649
12/09/10 20:28
12/09/10 20:28
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
Didn`t change anything



Re: taking cover [Re: Random] #349650
12/09/10 20:30
12/09/10 20:30
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
Any other ideas?
Hahaha...
Let`s see who is able to solve this first grin



Re: taking cover [Re: Random] #349651
12/09/10 20:43
12/09/10 20:43
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
wait(1) in the while loop would be nice.


"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] #349654
12/09/10 21:18
12/09/10 21:18
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline 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;

Click to reveal..
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 Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Code:
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 Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
Yes, Superku!
He dies!

But hes still not stoping and shooting...;

Click to reveal..
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.



Re: taking cover [Re: Random] #349700
12/10/10 14:27
12/10/10 14:27
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Like I have said before, you do not (!!) increase skill99. What's my_target.skill1?


"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
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1