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..^_^