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
0 registered members (), 18,008 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
enemy's path:HELP! #348039
11/22/10 05:58
11/22/10 05:58
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,

im creating a game in a7, i want my enemy to follow the player wherever it goes. i thought using PATH would do, but it follows its own path. pls help me, i want to have an algorithm that will make the enemy follow the player's direction.

THANK YOU!^_^

Re: enemy's path:HELP! [Re: carla_mariz] #348048
11/22/10 07:38
11/22/10 07:38
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
You can use 'Team Allies' from AUM (76), here you can download the magazine:
AUM 76
And here you can download resources of that magazine:
RESOURCES AUM 76
You can find it in 'Plug and Play'. Good luck.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: enemy's path:HELP! [Re: 3run] #348053
11/22/10 09:20
11/22/10 09:20
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
wow..♥

but still i cannot find the right code. i want the enemy to have its artificial intelligence that will follow the player. ie the pacman game. the ghost follows pacman.

thank you!^_^

Re: enemy's path:HELP! [Re: carla_mariz] #348055
11/22/10 09:35
11/22/10 09:35
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
Yes, that exactly what you can find in that code. Zombie follows the player (as ghost follows pacman).
It will not stuck at walls and will follow right after the player.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: enemy's path:HELP! [Re: 3run] #348059
11/22/10 10:03
11/22/10 10:03
Joined: Sep 2010
Posts: 97
C
carla_mariz Offline OP
Junior Member
carla_mariz  Offline OP
Junior Member
C

Joined: Sep 2010
Posts: 97
alright!! i found it!! wheeew..thank you so much for your help..

i hope you could help me again..thank you so much!^_^

Re: enemy's path:HELP! [Re: carla_mariz] #348065
11/22/10 12:37
11/22/10 12:37
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
You are welcome, ask for help any time, I'll be glad to help just PM me.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: enemy's path:HELP! [Re: 3run] #348230
11/24/10 09:18
11/24/10 09:18
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 again,
i have a little problem with this code, i know that its just in this part. i want to know which is the code for following the player. i'm sorry i couldn't find it, please help me.

here is the code:
Code:
action door_opener() // this character opens the door for the player
{
	VECTOR temp[3];
	// allow the player to pass through the npc character on a narrow hallway, etc
	set (my, PASSABLE); 
	while (!player) {wait (1);} // wait until the player is loaded
	while (!bigdoor) {wait (1);} // wait until the door is loaded
	while (!got_gold) // if the player didn't bring the gold yet
	{
		if (vec_dist (player.x, my.x) < 100) // and it comes closer than 100 quants to the npc
		{
			set (nogold_pan, VISIBLE); // we display nogold_pan
		}	
		else // and we hide it if the player moves away
		{
			reset (nogold_pan, VISIBLE);
		}	
		my.skill22 += 4 * time_step; // 4 gives the "stand" animation speed
		ent_animate(my, "stand", my.skill22, ANM_CYCLE);
		wait (1);
	}
	// the player has got the gold here, but he needs to take it to the warlock
	while (vec_dist (player.x, my.x) > 100) 
	{
		my.skill22 += 4 * time_step; // 4 gives the "stand" animation speed
		ent_animate(my, "stand", my.skill22, ANM_CYCLE);
		wait (1);
	}
	snd_play(gotgold_wav, 50, 0); // the warlock has got the gold here
	reset (treasure_pan, VISIBLE); // hide treasure_pan
	set (thanks_pan, VISIBLE); // display thanks_pan
	wait (-3); // for 3 seconds 
	reset (thanks_pan, VISIBLE); // and then hide thanks_pan as well
	npc_ready = 1; // the npc is ready to follow the player now
	while (1)
	{
		// use small vertical angles here (30 degrees or so); don't allow the npc to detect crumbs at a top floor (or so)
		c_scan(my.x, my.pan, vector(360, 30, 1000), SCAN_ENTS | SCAN_LIMIT); // scan for crumbs that are placed up to 1000 quants
		if (you) // a crumb was detected?
		{
			target_crumb = you; // the closest crumb to the npc is set to "you" by c_scan
			// rotate the npc towards the crumb
			vec_set(temp, target_crumb.x);
			vec_sub(temp, my.x);
			vec_to_angle(my.pan, temp);
			// the npc looks at the target crumb now
			while (vec_dist (my.x, target_crumb.x) > 30) // the npc moves until it comes close to target_crumb
			{
				my.skill22 += 5 * time_step; // 5 gives the "walk" animation speed
				c_move(my, vector(5 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);
				ent_animate(my, "walk", my.skill22, ANM_CYCLE);

				if (vec_dist (my.x, bigdoor.x) < 300) // the npc has come close enough to the big door?
				{
					var rotation_speed = 4; // play with 4
					var my_angle;
					vec_set(temp.x, bigdoor.x);
					vec_sub(temp.x, my.x);
					vec_to_angle(my_angle, temp.x);
					if (ang(my_angle - my.pan) < -3) 
					{
						while (ang(my_angle - my.pan) < -3)
						{					
	               	my.pan -= rotation_speed * time_step;
							wait (1);
						}
                 } 
                 else
                 {
						if (abs(ang(my_angle - my.pan)) > 3) 
						{
				      	while (ang(my_angle - my.pan) > 3)
  	    					{
     	               	my.pan += rotation_speed * time_step;
								wait (1);
							}
						}
       			}
					// the npc is facing the door here
					my.skill22 = 0;
					while (my.skill22 < 100) // play the "open door" animation (in fact, it's the "attack" animation for this model
					{
						my.skill22 += 5 * time_step; // 5 gives the "open door" (attack) animation speed
						ent_animate(my, "attack", my.skill22, NULL);
						wait (1);
					}
					open_door = 1; // now open the door
					wait (-4); // keep the proper scale_z for the model for 4 seconds
					while (my.scale_z > 0.01) // the npc won't do anything from now on, so let's decrease its scale_z
					{
						my.scale_z -= 0.05 * time_step;
						wait (1);
					}
					set (my, INVISIBLE); // we can safely hide the warlock model now
					while (1) wait (1);
				}
				wait (1);
			}
			// the npc has come close to target_crumb here
			ent_remove(target_crumb); // so remove the current target_crumb and prepare for the following crumb
		}
		wait (1);
	}
}



may i ask again, what is the role of target_crumbs here? it was initialized as entity. is it for the model?

thank you..^_^

Re: enemy's path:HELP! [Re: carla_mariz] #348239
11/24/10 11:56
11/24/10 11:56
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
I'll try to explain how the code work(I havent tried it yet)
-The player will leave crumbs as it moves, one at specified time.
-The follower will look for nearest crumb an go for it. This is the target_crumbs
-Once the follower reach the target_crumbs, the urrent crumb/target_crumb will be removed and it will look for another nearest crumbs.

Well, at least that what I though grin

Re: enemy's path:HELP! [Re: bart_the_13th] #348342
11/25/10 09:18
11/25/10 09:18
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 still couldn't understand..:|

how about the code for following the player?

laugh

Re: enemy's path:HELP! [Re: carla_mariz] #348400
11/26/10 03:56
11/26/10 03:56
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
Well, the follower desn't directly follow the player, instead, it looks for and go to any crumb left by player while the player is moving. It just like when you're lost in the wood and look for any foot print you can find and follow it.

I never tried the code but it should be plug and play

Page 1 of 2 1 2

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

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