Jump to content
  • 0
Sign in to follow this  
KyleZ

How to utilize navigation system for custom NPCs

Question

Hi Hercules!
 
Thanks for all of your input. Please allow me to rephrase this:
 
I could utilize Navi System for custom NPCs, including show them on mini map and search result. Unlike most of you, I'm using a localized client (Chinese). So, editing decompiled LUAs is the easy way out. But that would make our players' experiences half-EN-half-CN, which is unprofessional. Yeah, I could translate them, but that's 2672 NPCs we're talking about...
 
So, I had to download LUBs of localized version and tried to start it there.
Luadisasm made me believe that LUB>LUA is possible with proper function/batch tool, as long as the LUB structure is as simple as navi_npc_krsak.lub.
Correct me if I'm wrong~
 
Time to share what I've learned during the process:
 
There are 4 LUAs (for NPCs ONLY, leave the function lua alone.
1. navi_npc_krsak.lua
2. navi_npcdistance_krsak.lua
3. navi_link_krsak.lua
4. navi_linkdistance_krsak.lua
 
There are comments in the first file
"airplane", --Map
11984, --NPC number
101,--NPC type(known types:101=Normal, 102=sell/buy NPC
86, --SpriteID
"Apple Merchant", --NpcName
"airplane", --Map details, if there's any
50, --x
66 --y
 
Now we know what to do after editing TownInfo.lub, just make sure NPC number isn't conflicted with current ones.
 
After that, you can find your custom NPC in the Navi search. But it won't work properly unless you modify the second file.
 
Say your NPC is in City Hugel, and you want it found when search "Hugel".You have to edit the second file and make sure your input located between the hugel curly blankets.
 
{10046,
{ "airplane", 11976, 135 },
{ "airplane", 11977, 135 },
{ "hu_fild06", 12781, 116 },
{ "hu_in01", 12817, 75 },
{ "hu_in01", 12819, 109 },
{ "hu_in01", 12821, 15 },
{ "hu_in01", 12825, 8 },
{ "hu_in01", 12827, 103 },
{ "hu_in01", 12829, 76 },
{ "hu_in01", 12831, 50 },
{ "hu_in01", 12833, 104 },
{ "hu_in01", 12836, 162 },
{ "hu_in01", 12877, 79 },
{ "hu_in01", 12883, 79 },
{ "hu_in01", 12884, 79 },
{ "hu_in01", 12908, 98 },
{ "odin_tem01", 12872, 138 },
{ "p_track01", 19493, 82 },
{ "p_track02", 19511, 82 },
{ "que_bingo", 12919, 64 },
{ "", 0, 0 }
},
 
You can just put it here with similar structures.
 
{ "airplane", --call it link or reference
11976, --link number.
 135 --distance with the link (the Pythagorean theorem
},
Link data is stored in the 3rd and 4th file.
 
Different towns have difference references, keep in mind. So, to make it perfect, you have to calculate distance with every link..
 
My suggestion is replacing useless officials instead..
 
That's all I guess. At the end, if you can help me with LUB>LUA..Leave me a PM, please. Thank you.
 
========================
Original Post
 
 
I just realized how powerful the native navigation system is the other day. Ever since, I've been trying to utilize it for custom features, npcs, mobs etc.
 
The easy part is to add/delete icons to the mini map in the upper right cornor. Sorry, I don't play English version, I've no idea what you call it natively.
 
Anyway, by editing TownInfo.lub, I successfully added a custom NPC to the mini-map. And the navigation system also worked fine. I mean the system could calculate the route for you once you click corresponding NPC there.
 
Yet I want more. 
Without further modification, you can't find the NPC in the search result. This could be a problem when you have multiple npcs crowed on a smaller place. Adding all of them to the mini-map would be a disaster.
 
I know that it was easy because TownInfo.lub isn't encrypted. Editing other lubs is a whole new story. And I've been told, several times that currently there are no tools for translating lub to lua.
 
In my ' limited' experience, luadisasm can disassemble lub files. disassembled file(navi_npc_krpri.lub) format is as follows:
  1 [   2]: NEWTABLE  R0 75 0      ; R0 := {}  2 [   3]: NEWTABLE  R1 8 0       ; R1 := {}  3 [   4]: LOADK     R2 K1        ; R2 := "airplane"  4 [   4]: LOADK     R3 K2        ; R3 := 11984  5 [   4]: LOADK     R4 K3        ; R4 := 101  6 [   4]: LOADK     R5 K4        ; R5 := 86  7 [   4]: LOADK     R6 K5        ; R6 := "荤苞惑牢"  8 [   4]: LOADK     R7 K1        ; R7 := "airplane"  9 [   4]: LOADK     R8 K6        ; R8 := 50 10 [   4]: LOADK     R9 K7        ; R9 := 66 11 [   4]: SETLIST   R1 8 1       ; R1[1,2,3,4,5,6,7,8] := R2,R3,R4,R5,R6,R7,R8,R9

I am a layman, obviously. Not only on Lua programming, I'm talking basically any programming language. So, can't translate lub to lua = can't restore this format to normal human readable lua?

 
I did some research, and a term caught my eyes: Table serialization/unserialization. Is it the same thing as what we are talking about?
 
I am a layman and I can tell the pattern here.

R1=

"airplane", 11984,101,86,"荤苞惑牢","airplane",50,66

Puting the garbled texts aside, it is exactly the same as in decompiled lua. So, with proper function/ batch tools, we can trans it, can't we?

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0

About that.. Maybe i'm a little greedy here. Like I said, changing TownInfo.lub doesn't include your custom NPCs to the searching database. 

 

See the following screenshot:

attachicon.gifMap.png

 

Say I add 1 NPC in City Hugel, unlike the other official NPCs, I can't find it by keyword searching. As you can see it, my mini map is becoming over-crowded. lol

 

Yes, I can use these decompiled lua files.. haha, the problem is 60% of our players don't speak English..

 

So, we have to decompile native lub, or ask someone to do it for us - -

 

 

Em...... Not sure why you're doing it in such a long way... but for me, I found an already decompiled towninfo.lub (lua) and I just edit the lua everytime and then convert it to lub afterwards. As for the NPCs, I've created my own custom NPCs and I've added them to the towninfo.lua. By doing so, you only add them in the towninfo.lua if you want that specific NPC to have an icon in the map window also known as a minimap icon.

 

As for files to add custom mobs in, check in your /navigation/navi_mob_krsak.lua and for actual custom NPCs its in your /navigation/navi_npc/krsak.lua

Thats what I was referring too. Those two files I stated should help your problem. As for me from my previous experience, I wanted a specific NPC to have its own minimap icon thus I put that NPC inside the towninfo.lua but if I wanted to add my own custom npcs into the navigation, I'll go through the navi_npc/krsak.lua lol.

Share this post


Link to post
Share on other sites
  • 0

Em...... Not sure why you're doing it in such a long way... but for me, I found an already decompiled towninfo.lub (lua) and I just edit the lua everytime and then convert it to lub afterwards. As for the NPCs, I've created my own custom NPCs and I've added them to the towninfo.lua. By doing so, you only add them in the towninfo.lua if you want that specific NPC to have an icon in the map window also known as a minimap icon.

 

As for files to add custom mobs in, check in your /navigation/navi_mob_krsak.lua and for actual custom NPCs its in your /navigation/navi_npc/krsak.lua

Share this post


Link to post
Share on other sites
  • 0

About that.. Maybe i'm a little greedy here. Like I said, changing TownInfo.lub doesn't include your custom NPCs to the searching database. 

 

See the following screenshot:

 

 

Say I add 1 NPC in City Hugel, unlike the other official NPCs, I can't find it by keyword searching. As you can see it, my mini map is becoming over-crowded. lol

 

Yes, I can use these decompiled lua files.. haha, the problem is 60% of our players don't speak English..

 

So, we have to decompile native lub, or ask someone to do it for us - -

Share this post


Link to post
Share on other sites
  • 0

to find it over the Navi search you have too add it here

 

/navigation/navi_npc/krsak.lua

navi_npc_krsak.lua

 

Thanks for the input.

 

I can't use these ready-made decompiled LUAs, because that'll make our players' experiences half-Chinese-half-English...

 

We have to start from localized LUB instead, that's why I made this inquiry.

 

I guess the focus of "how to" just shifted from navigation to LUB>LUA translation.

Share this post


Link to post
Share on other sites
  • 0

 

About that.. Maybe i'm a little greedy here. Like I said, changing TownInfo.lub doesn't include your custom NPCs to the searching database. 

 

See the following screenshot:

attachicon.gifMap.png

 

Say I add 1 NPC in City Hugel, unlike the other official NPCs, I can't find it by keyword searching. As you can see it, my mini map is becoming over-crowded. lol

 

Yes, I can use these decompiled lua files.. haha, the problem is 60% of our players don't speak English..

 

So, we have to decompile native lub, or ask someone to do it for us - -

 

 

>>Em...... Not sure why you're doing it in such a long way... but for me, I found an already decompiled towninfo.lub (lua) and I just edit the lua everytime and then convert it to lub afterwards. As for the NPCs, I've created my own custom NPCs and I've added them to the towninfo.lua. By doing so, you only add them in the towninfo.lua if you want that specific NPC to have an icon in the map window also known as a minimap icon.

 

As for files to add custom mobs in, check in your /navigation/navi_mob_krsak.lua and for actual custom NPCs its in your /navigation/navi_npc/krsak.lua

Thats what I was referring too. Those two files I stated should help your problem. As for me from my previous experience, I wanted a specific NPC to have its own minimap icon thus I put that NPC inside the towninfo.lua but if I wanted to add my own custom npcs into the navigation, I'll go through the navi_npc/krsak.lua lol.

 

 

Hi Mysterious .

 

i try to modify my client and reat towninfo.lua but currenly i have problem on my towninfo.lua i added a custom map and tr to add there but it seem's i can't find those icons on my minimap

 

but on prontera it's work

Edited by Fatalis

Share this post


Link to post
Share on other sites
  • 0

its stupid to think gravity made these files by hand, they probably have some tool that outputs the navigation files based on there own npc folder.

 

i suggest an @command to build the navigation files from a running Hercules, so it can loop every npc and calculate distance tables.

 

if you need the format of any of the lua just ask

Share this post


Link to post
Share on other sites
  • 0

i'm already solve about the icons on minimap but dunno how if i click the icon then there's a arrow will be on the bottom. dunno how to read the lua of navigation
 

 

 Navi_Npc = {	 {		"airplane", --Map		11984, // What is this?		101, // and this?		86, --SpriteID		"Apple Merchant", --NpcName		"airplane",		50, --x		66 --y	},
Edited by Fatalis

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.