0 registered members (),
18,008
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
You can use 'Team Allies' from AUM (76), here you can download the magazine: AUM 76And here you can download resources of that magazine: RESOURCES AUM 76 You can find it in 'Plug and Play'. Good luck.
|
|
|
Re: enemy's path:HELP!
[Re: 3run]
#348230
11/24/10 09:18
11/24/10 09:18
|
Joined: Sep 2010
Posts: 97
carla_mariz
OP
Junior Member
|
OP
Junior Member
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:
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
bart_the_13th
Senior Member
|
Senior Member
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 
|
|
|
|