2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: ent_remove & ent_create
[Re: Logan]
#357216
02/06/11 04:59
02/06/11 04:59
|
Joined: Sep 2010
Posts: 97
carla_mariz
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 97
|
sure.. first, what i want the function to do is to freeze the ghost for 15 sec if froze is set to one. in 15 sec, the player can eat the ghost(or while it is freezing). if the player ate the ghost, the ghost will disappear but if the 15 sec. is done, he will be visible again. now, if the ghost has not been eaten after he freezes (or after 15 sec), he will be able to move again. whats happening is, the ghost freezes and disappears if he was eaten and become visible again after 15 sec. my problem is, if the ghost is in freeze state and is not eaten by the player, he won't move even if 15 sec is done. the lines under the while condition is not terminated. i hope my explanation is clear. thanks!
Last edited by carla_mariz; 02/06/11 05:00.
|
|
|
Re: ent_remove & ent_create
[Re: carla_mariz]
#357219
02/06/11 05:14
02/06/11 05:14
|
Joined: Jan 2011
Posts: 120 United States
Logan
Member
|
Member
Joined: Jan 2011
Posts: 120
United States
|
Ah... I see. Try this:
if(froze == 1)
{
set(my, PASSABLE);
set(my, UNLIT | BRIGHT | PASSABLE);
my.skin = 2;
my.lightrange = 200;
my.ambient = 100;
my.blue = 200;
var counter = total_secs + 15;
while(total_secs < counter)
{
if (vec_dist(player.x, my.x) > 80) // if the player comes close
{
set(my, INVISIBLE);
wait (-15);
break;
}
wait(1);
}
reset(my, INVISIBLE);
froze = 0;
my.skin = 1;
my.lightrange = 0;
my.ambient = 0;
my.state = 0;
}
I haven't tested this but I think it'll work.
|
|
|
Re: ent_remove & ent_create
[Re: carla_mariz]
#357222
02/06/11 05:45
02/06/11 05:45
|
Joined: Jan 2011
Posts: 120 United States
Logan
Member
|
Member
Joined: Jan 2011
Posts: 120
United States
|
Whoops. Look what a simple > can do when you needed a <.
Replace the > in the if() within the while() with <. That should do it!
That is to say, if (vec_dist(player.x, my.x) > 80) should be if (vec_dist(player.x, my.x) < 80).
Last edited by Logan; 02/06/11 05:46.
|
|
|
Re: ent_remove & ent_create
[Re: carla_mariz]
#359511
02/18/11 03:42
02/18/11 03:42
|
Joined: Sep 2010
Posts: 97
carla_mariz
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 97
|
hi there logan.. i just wanted to ask you again regarding this function... it was working the first time i tested it..but when i put another action to the enemy, i decided to put break; to get out of the while() loop. but then, when freeze = 1 the ghost would freeze but some of them disappears even if the player didn't touched them and they would not return. Some of the enemies, even if not eaten, is still showing. This made me confuse and i did everything just to correct it, but still i can't get the right code. here is the script where in i have to put the if froze = 1.
result = path_scan(me, my.x, my.pan, vector(90, 80, 400));
if (result) {movement_enabled = 1;}
path_getnode (my, 1, pos_node, NULL);
vec_to_angle (my.pan, vec_diff (temp_angle, pos_node, my.x));
while(players_health > 0 && players_life > 0)
{
if(my.state == 0)
{
while(1)
{
if(vec_dist(my.x,player.x) < 550 && players_health > 0)
{
my.state = 1;
break;
}
if(froze == 1)
{
break;
}
if(movement_enabled)
{
entity_speed = minv(5, entity_speed + 0.5 * time_step);
ent_animate(my, "frame", my.skill60, ANM_CYCLE);
my.skill60 += 5 * time_step;
my.skill60 %= 100;
c_move(my, vector(entity_speed * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);
vec_to_angle (my.pan, vec_diff (temp_angle, pos_node, my.x));
}
dist_to_node = vec_dist(my.x, pos_node);
if(dist_to_node < 10)
{
current_node = path_nextnode(my, current_node, 1);
if (!current_node) {current_node = 1;}
path_getnode (my, current_node, pos_node, NULL);
}
wait(1);
}
}
if(froze == 1)
{
set(my, PASSABLE);
set(my, UNLIT | BRIGHT | PASSABLE);
my.skin = 2;
my.lightrange = 200;
my.ambient = 100;
my.blue = 200;
var counter = total_secs + 15;
while(total_secs < counter)
{
if (vec_dist(player.x, my.x) < 80) // if the player comes close
{
set(my, INVISIBLE);
my.skin = 1;
my.lightrange = 0;
my.ambient = 0;
total_ghost += 1;
break;
}
wait(1);
}
wait(-15);
reset(my, INVISIBLE);
froze = 0;
my.skin = 1;
my.lightrange = 0;
my.ambient = 0;
my.state = 0;
}
}
Thanks!
|
|
|
Re: ent_remove & ent_create
[Re: Logan]
#359689
02/19/11 06:48
02/19/11 06:48
|
Joined: Sep 2010
Posts: 97
carla_mariz
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 97
|
i defined it globaly: var froze = 0; actually, i really wanted all my enemies to freeze if froze = 1 and go back to normal if freeze=0..yes it is happening, they freeze for 15 sec but after that some of them are Invisible even if the player didn't ate them. how can i make this work???
|
|
|
|