[Question] 5375 Teleporting Npc

06/05/2011 01:22 killersub#1
I have a question. I want to know if anyone can (maybe) give me a tip/hint/piece of code as in how to make an NPC teleport to random coords. once you click on an option of the npc.

I have no idea as in how to do this since I just came back from a very long trip and I'm exhausted.

I saw that Elite-Co has something VERY similar to this but I have NO idea on how to convert it.

any help would be very much appreciated :handsdown:
06/05/2011 02:52 F i n c h i#2
THIS IS JUST AN EXAMPLE!

Code:
case [COLOR="Red"]YOUR NPC ID[/COLOR]:
                    {
                        switch (npcRequest.OptionID)
                        {
                            case 0:
                                {
                                    dialog.Text("[COLOR="Red"]I can teleport you to TC (might be wrong coords)[/COLOR]");
                                    dialog.Link("[COLOR="#ff0000"]Go ahead.[/COLOR]", 1);
                                    dialog.Link("[COLOR="#ff0000"]No thanks.[/COLOR]", 255);
                                    dialog.Send();
                                    break;
                                }
                            case 1:
                                {
                                    if (client.Entity.[COLOR="#ff0000"]ConquerPoints[/COLOR] >= [COLOR="#ff0000"]1[/COLOR])
                                    {
                                        client.Entity.[COLOR="#ff0000"]ConquerPoints[/COLOR] -= [COLOR="#ff0000"]1[/COLOR];
                                        client.Entity.Teleport([COLOR="#ff0000"]1002[/COLOR], [COLOR="#ff0000"]300[/COLOR], [COLOR="#ff0000"]330[/COLOR]);
                                    }
                                    else
                                    {
                                        dialog.Text("[COLOR="#ff0000"]Not enough cash![/COLOR]");
                                        dialog.Link("[COLOR="#ff0000"]Ok bye.[/COLOR]", 255);
                                        dialog.Avatar(144);
                                        dialog.Send();
                                    }
                                    break;
                                }
                        }
YOUR NPC ID = Put your NPC ID.

1002 = ID of the map.

300 = X coordinate.

330 = Y coordinate.


ConquerPoints, you could change this with Money, so the player will pay silvers instead of cps.

NOTE: CHANGE THE RED WORDS AS YOU LIKE!
06/05/2011 03:30 Mr_PoP#3
Quote:
Originally Posted by alexalx View Post
THIS IS JUST AN EXAMPLE!

Code:
case [COLOR="Red"]YOUR NPC ID[/COLOR]:
                    {
                        switch (npcRequest.OptionID)
                        {
                            case 0:
                                {
                                    dialog.Text("[COLOR="Red"]I can teleport you to TC (might be wrong coords)[/COLOR]");
                                    dialog.Link("[COLOR="#ff0000"]Go ahead.[/COLOR]", 1);
                                    dialog.Link("[COLOR="#ff0000"]No thanks.[/COLOR]", 255);
                                    dialog.Send();
                                    break;
                                }
                            case 1:
                                {
                                    if (client.Entity.[COLOR="#ff0000"]ConquerPoints[/COLOR] >= [COLOR="#ff0000"]1[/COLOR])
                                    {
                                        client.Entity.[COLOR="#ff0000"]ConquerPoints[/COLOR] -= [COLOR="#ff0000"]1[/COLOR];
                                        client.Entity.Teleport([COLOR="#ff0000"]1002[/COLOR], [COLOR="#ff0000"]300[/COLOR], [COLOR="#ff0000"]330[/COLOR]);
                                    }
                                    else
                                    {
                                        dialog.Text("[COLOR="#ff0000"]Not enough cash![/COLOR]");
                                        dialog.Link("[COLOR="#ff0000"]Ok bye.[/COLOR]", 255);
                                        dialog.Avatar(144);
                                        dialog.Send();
                                    }
                                    break;
                                }
                        }
YOUR NPC ID = Put your NPC ID.

1002 = ID of the map.

300 = X coordinate.

330 = Y coordinate.


ConquerPoints, you could change this with Money, so the player will pay silvers instead of cps.

NOTE: CHANGE THE RED WORDS AS YOU LIKE!
if he made it like this , thats mean that the NPC will send him to a Specific place , he wants it something like that ("He define 10 coords(x,y) and the npc choose the coords randomly , so it's kinda like the "AutoInvite" not all the players teleporting to the same coordinates, but they all teleport to the same map. I guess that what he ment though!
06/05/2011 03:36 zTek#4
Random R = new Random();
int Nr = R.Next(1, 2);
if (Nr == 1)
{
Teleport()
}
if (Nr == 2)
{
Teleport()
}
}
06/05/2011 04:28 pro4never#5
I think he wants to have the NPC move, not his char.


It's really not hard at all but the issue with everyone using public sources is that they are completely unaware of how the core systems work such as the map system.

You need to...

1: remove the npc from map (if the map system is good it despawns on .remove else send gendat 135 I think to remove entity from player screens.)

2: pick a random valid coord. This can either be a db or w/e of pre recorded points or you could do a fully random system where it rolls a random number and checks dmap validity (if not valid pull new coords)

3: insert npc at new point on map. Again if a good map system it will send spawn packets to locals else do it yourself.


Boom, npc is now in a new place. I assume you want this for a hunting quest. You could try searching I posted a super old quest for coemu doing this as one of my early coding attempts.
06/05/2011 04:55 zTek#6
Quote:
Originally Posted by pro4never View Post
I think he wants to have the NPC move, not his char.


It's really not hard at all but the issue with everyone using public sources is that they are completely unaware of how the core systems work such as the map system.

You need to...

1: remove the npc from map (if the map system is good it despawns on .remove else send gendat 135 I think to remove entity from player screens.)

2: pick a random valid coord. This can either be a db or w/e of pre recorded points or you could do a fully random system where it rolls a random number and checks dmap validity (if not valid pull new coords)

3: insert npc at new point on map. Again if a good map system it will send spawn packets to locals else do it yourself.


Boom, npc is now in a new place. I assume you want this for a hunting quest. You could try searching I posted a super old quest for coemu doing this as one of my early coding attempts.
Ah, I guess I didn't read it right. Good eyes ;P
06/05/2011 13:33 _DreadNought_#7
Actually i'm faily sure he wants to do Richard.

Simply manually send the despawn code, normally around Screen.cs and also send that despawn to clients that would've been able to see the npc.

So the npc is gone?

Respawn it!

Find some valid coords, What i'd do if I were doing Richard is, Get about 5 Places for him to goto, do a random, if unable to access the spot, +1+1 to X and Y if still not possible try adding one more X, if STILL not accessable then I'd simply make a new random of the spots and repeat untill its found something.

You then need to simply call a function ex NpcEntity.Respawn(); and dont forget to set its new X and Y;
06/05/2011 23:31 killersub#8
thanks everyone I figured out a way to do it in my source (:

I found out a way to do a dynamic teleport of the npc into the new coords given.

#request close