Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: ent_remove & ent_create [Re: carla_mariz] #357214
02/06/11 04:48
02/06/11 04:48
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
I'd like to help--but if you wouldn't mind, could you help me by explaining one more time:

1) What you want to the function to do
2) What is happening instead

Re: ent_remove & ent_create [Re: Logan] #357216
02/06/11 04:59
02/06/11 04:59
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
sure.. grin

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. laugh 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 Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
Ah... I see. Try this:

Code:
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: Logan] #357220
02/06/11 05:24
02/06/11 05:24
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
ok ok, i'll try this right away. thank you very much!!
i'll let you know what happen. laugh

Re: ent_remove & ent_create [Re: carla_mariz] #357221
02/06/11 05:44
02/06/11 05:44
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
hi logan, uhm...what happened is, if the froze is set to one the ghost disappears even if the player hasn't eaten him yet. frown

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 Offline
Member
Logan  Offline
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: Logan] #357223
02/06/11 05:54
02/06/11 05:54
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
yes!!! its now working grin
thanks a lot logan, you didn't stop helping me here.. ahaha laugh
thank you ^_^

Re: ent_remove & ent_create [Re: carla_mariz] #359511
02/18/11 03:42
02/18/11 03:42
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
hi there logan.. laugh
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.
Code:
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! laugh

Re: ent_remove & ent_create [Re: carla_mariz] #359665
02/18/11 22:00
02/18/11 22:00
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
How have you defined "froze"? The way you're using it, it seems to be a global variable, which you don't want, because then when you set it to 1 every enemy across the board is becoming frozen, which still isn't working properly because they are all at different points in their functions.

It needs to be a skill. #define froze skill10, or any other skill you haven't used yet, and then use "my.froze" instead of just "froze". That way each individual entity will keep track of their OWN "froze" state, so some can be frozen and some not-frozen at the same time.

Hope that helps!

Re: ent_remove & ent_create [Re: Logan] #359689
02/19/11 06:48
02/19/11 06:48
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

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. frown

how can i make this work???

Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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