Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Coding Corner
You last visited: Today at 01:20

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



how to parse npc from media.pk2 files

Discussion on how to parse npc from media.pk2 files within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2014
Posts: 20
Received Thanks: 0
how to parse npc from media.pk2 files

Hello
I am working on a nice project but I neee help parsing npc data from the text files

I want to
get npc of each town from text files
get type of npc ... like blacksmith and etc
Get npc shop content


so can anyone help?
fakeheader is offline  
Old 03/03/2015, 10:55   #2
 
elite*gold: 0
Join Date: Feb 2008
Posts: 962
Received Thanks: 650
Check Zbot's source code. It grabs information from text files after being extracted from the media.pk2.
magicanoo is offline  
Old 03/03/2015, 19:55   #3
 
elite*gold: 0
Join Date: Feb 2014
Posts: 20
Received Thanks: 0
i did but its not working i need to make it generic for all servers and because some server has custom npc so i need to find a way to extract the content and the shop type
fakeheader is offline  
Old 03/04/2015, 09:40   #4
dotCom
 
Devsome's Avatar
 
elite*gold: 9842
The Black Market: 107/0/0
Join Date: Mar 2009
Posts: 16,840
Received Thanks: 4,672
Quote:
Originally Posted by fakeheader View Post
i did but its not working i need to make it generic for all servers and because some server has custom npc so i need to find a way to extract the content and the shop type
Then just loop them all with the Method of zBot , otherwise rewrite it du avoid the errors
Devsome is offline  
Old 03/04/2015, 10:02   #5
 
elite*gold: 0
Join Date: Feb 2014
Posts: 20
Received Thanks: 0
well .... zbot has its static values for each town ... and it doesnt have alex npc ... anyway i solved the problem using the the expression ... like npc_wc_ so wc is western china then if the string have _smith then its black smith and thanks to fox564 for this solution, thanks for your time
fakeheader is offline  
Old 03/07/2015, 18:14   #6
 
zeteris's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 575
Received Thanks: 752
Quote:
Originally Posted by fakeheader View Post
well .... zbot has its static values for each town ... and it doesnt have alex npc ... anyway i solved the problem using the the expression ... like npc_wc_ so wc is western china then if the string have _smith then its black smith and thanks to fox564 for this solution, thanks for your time

Just load them from the client textdata it's not that hard.

Hint: don't use CodeName128 to parse anything.
zeteris is offline  
Old 03/08/2015, 17:58   #7
 
elite*gold: 0
Join Date: Feb 2014
Posts: 20
Received Thanks: 0
Thank you for your answer but here is my problem
in zbot there is no alex npc in the parse and also you made other npc static
so what if the client have custom npc names how would I auto buy pots for example
thats why I need to make it generic
fakeheader is offline  
Old 03/08/2015, 20:21   #8
 
Royalblade*'s Avatar
 
elite*gold: 85
Join Date: Feb 2014
Posts: 1,056
Received Thanks: 1,643
Quote:
Originally Posted by fakeheader View Post
Thank you for your answer but here is my problem
in zbot there is no alex npc in the parse and also you made other npc static
so what if the client have custom npc names how would I auto buy pots for example
thats why I need to make it generic
GGWP; You just wasted a lot of time.

1st: Parse SingleSpawn & GroupSpawn
You get, NPCObjectID, XYZ from them.

Then you need to load up a few txt files, get the item locations via this.


Quote:
Originally Posted by Royalblade* View Post
This won't be useful for the general people here. However, when somebody else goes n makes a bot in future, this will save up tons of brainfuck.

However, if you do find a better way to do this, go ahead and post it.

This is strictly speaking only for Type 8 @ 0xB034, since the rest is entirely different.
All those people making alchemy bots etc.. this is highly useful for you

EDIT: For shit like this:

First create this function
PHP Code:
CREATE FUNCTION _getTabIndex(@NPCID INT, @TabCodename VARCHAR(128))
RETURNS INT
AS
BEGIN
    
DECLARE @Index INT;

    
SELECT    @Index tabindex
    FROM    
(
            
SELECT    ROW_NUMBER() OVER (ORDER BY tab.RefTabGroupCodeName ASCtab.ID ASC)-1 tabindextab.CodeName128
            FROM    _RefShopTab tab
            JOIN    _RefMappingShopWithTab maptab ON tab
.RefTabGroupCodeName maptab.RefTabGroupCodeName
            JOIN    _RefShop shop ON maptab
.RefShopCodeName shop.CodeName128
            JOIN    _RefMappingShopGroup mapshop ON shop
.CodeName128 mapshop.RefShopCodeName
            JOIN    _RefShopGroup shopgroup ON mapshop
.RefShopGroupCodeName shopgroup.CodeName128
            JOIN    _Refobjcommon R ON shopgroup
.RefNPCCodeName R.CodeName128
            WHERE    R
.ID = @NPCID
            
q
    WHERE    q
.CodeName128 = @TabCodename
    
RETURN @Index
END 

Then run this and create your npcshoplist. You need to parse NPCs via single/groupspawn beforehand though, otherwise you cant get the NPC ID.

PHP Code:

SELECT    npc
.ID as NPCID,.dbo._getTabIndex(npc.ID,goods.RefTabCodeNameTabIDItem.id as ItemIDgoods.SlotIndex  ,scrap.Data
FROM    _RefShopGoods goods
JOIN    _RefShopTab tab ON goods
.RefTabCodeName tab.CodeName128
JOIN    _RefMappingShopWithTab maptab ON tab
.RefTabGroupCodeName maptab.RefTabGroupCodeName
JOIN    _RefShop shop ON maptab
.RefShopCodeName shop.CodeName128
JOIN    _RefMappingShopGroup mapgroup ON shop
.CodeName128 mapgroup.RefShopCodeName
JOIN    _RefShopGroup shopgroup ON mapgroup
.RefShopGroupCodeName shopgroup.CodeName128
JOIN    _Refobjcommon npc ON shopgroup
.RefNPCCodeName npc.CodeName128
JOIN    _RefPackageItem package ON goods
.RefPackageItemCodeName package.CodeName128
JOIN    _RefScrapOfPackageItem scrap ON package
.CodeName128 scrap.RefPackageItemCodeName
JOIN    _Refobjcommon item ON scrap
.RefItemCodeName item.CodeName128
WHERE npc
.ID 2073
ORDER BY tab
.RefTabGroupCodeName  ASCtab.ID ASC 

THEN it would be properly dynamic. But you don't need anything like XYZ from CharData.txt
Royalblade* is offline  
Thanks
1 User
Old 03/09/2015, 00:08   #9
dotCom
 
Devsome's Avatar
 
elite*gold: 9842
The Black Market: 107/0/0
Join Date: Mar 2009
Posts: 16,840
Received Thanks: 4,672
You can also use like royalblade says ParseSingleSpawn and if type is a NPC then build a function e.g ParseNPC
Old sro-r ParseNPC stuff

Code:
public static int ParseNPC(object opacket, object xresult, bool groupspawn)
{
	Packet packet = (Packet)opacket;
	SpawnData result = (SpawnData)xresult;
	int startpos = (int)packet.data.pointer - 4; 
	//try
	//{
		result.UniqueId = packet.data.ReadDWORD();

		result.xSec = packet.data.ReadBYTE();
		result.ySec = packet.data.ReadBYTE();
		result.X = packet.data.ReadSINGLE();
		result.Z = packet.data.ReadSINGLE();
		result.Y = packet.data.ReadSINGLE();
		packet.data.ReadWORD(); //angle

		result.XCoord = Functions.GetXCoord((int)result.X, result.xSec);
		result.YCoord = Functions.GetYCoord((int)result.Y, result.ySec);

		result.distance = Functions.CalcDistance(result.XCoord, result.YCoord);

		byte haveDest = packet.data.ReadBYTE();
		byte movingType = packet.data.ReadBYTE();
		if (haveDest == 0x01)
		{
			result.DestXSec = packet.data.ReadBYTE();
			result.DestYSec = packet.data.ReadBYTE();

			if (result.DestYSec == 0x80)
			{
				packet.data.ReadSignedDWORD();
				packet.data.ReadSignedDWORD();
				packet.data.ReadSignedDWORD();
			}
			else
			{
				result.DestX = packet.data.ReadSignedWORD();
				result.DestZ = packet.data.ReadSignedWORD();
				result.DestY = packet.data.ReadSignedWORD();
			}
		}
		else
		{
			packet.data.ReadBYTE();
			packet.data.ReadWORD();
		}


		result.DeathFlag = packet.data.ReadBYTE();
		packet.data.ReadBYTE(); //movement flag
		packet.data.ReadBYTE(); //berserk gauge
		packet.data.ReadBYTE(12); //walk speeds

		byte skillcount = packet.data.ReadBYTE();
		for (int s = 0; s < skillcount; s++)
		{
			uint skillid = Functions.ReverseNumber(packet.data.ReadDWORD()); // ID
			packet.data.ReadDWORD(); // SKILL UNIQUE ID

			foreach (SkillData sd in Main.Skills)
			{
				if (sd.ID == skillid)
				{
					if (Functions.extraByte(sd.pk2name) == true)
						packet.data.ReadBYTE();
					break;
				}
			}
		}

		byte action = packet.data.ReadBYTE();

		if (action == 2)
			packet.data.ReadDWORD();
		else if (action != 0x00)
			packet.data.ReadBYTE(packet.data.ReadBYTE());

		Main.UpdateSpawns(result, true);
	//}

	//catch
	//{
	//    string packetasstring = "S->C(" + packet.Opc.ToString("X4") + ") ";
	//    foreach (byte b in packet.ToByteArray())
	//    {
	//        packetasstring += b.ToString("X2");
	//    }


	//    System.IO.File.AppendAllText(System.Environment.CurrentDirectory + "\\err_npc.txt", packetasstring + "\r\n" + "Pos:" + packet.data.pointer.ToString() + " LEN:" + packet.data.len.ToString() + " START POS:" + startpos.ToString() + " MODEL:" + result.model.ToString("X8") + "\r\n");

	//}

	return packet.data.pointer;

}
Update 00:29
You can also parse it with the Media.pk2


Devsome is offline  
Thanks
1 User
Old 03/09/2015, 00:25   #10
 
elite*gold: 0
Join Date: Feb 2014
Posts: 20
Received Thanks: 0
Thanks alot
fakeheader is offline  
Old 03/09/2015, 00:30   #11
dotCom
 
Devsome's Avatar
 
elite*gold: 9842
The Black Market: 107/0/0
Join Date: Mar 2009
Posts: 16,840
Received Thanks: 4,672
Just check my Update.
You're welcome, just don't copy & paste.
Try it on your own
Devsome is offline  
Old 03/09/2015, 16:28   #12
 
elite*gold: 0
Join Date: Feb 2014
Posts: 20
Received Thanks: 0
I have already made my single/group spawn parser functions
I will just try to modify your function and make it more dynamic
thanks again
fakeheader is offline  
Reply

Tags
media.pk2, npc, shop


Similar Threads Similar Threads
[HELP] Opening DDS files from media.pk2
07/25/2013 - Silkroad Online - 1 Replies
Hello Elitepvper's. I have a problem i cannot open dds files in PS CS6 even when i installed The plugin for it from nvidia. PICTURE BELOW View image: DDS error Please help me with teamviewer Thanks in advance PS: If i posted this in the wrong section move it please do NOT delete it please?
[Selling] Old-School media design. #PSD#PRE-SAVED MEDIA FILES#CHEAP
06/04/2013 - Silkroad Online Trading - 12 Replies
WTS my latest Old School's Work.. Fully customized PSD - Ready to import files * Just, give me your server name * What package content: 1. 2x Launchers 2. 2x Mini-loadings 3. Professional - customized - Logo 4. 5x Teleport loadings. 5. Silkroad-Sro_Client-Replacer-SilkroadErrorSenderMX .exe customized logo 128x128 All of em will be avaliable in psd and .dat/ddj for your server. To customize it on the way you do like ...
how to decrypt files from media.pk2
03/12/2012 - SRO Private Server - 2 Replies
this files cant show correctly with hex editor can u help me wth any software to decrpyt it
Need? Media.pk2 and Pk2 files Editor?
03/04/2012 - SRO Private Server - 0 Replies
Hey Everybody, I'm George Albert (One Of Pro PK2 Files) I Would make too many PK2 edits! Music.pk2: 1-Change all safe and danger zones musics to the which music you want! 2-Change CTF,Arena,FortessWar Music to the which one you like too! 3-Full change musics to which musics without happening any lags or bugs (Full Safely Edit) 4-Full Safely and Lag & Bug free! Media.pk2: 1-Launcher: Buttons,Options,Editing Launcher Background image! 2-New Start After-Launcher Loading Background...
[HELP] Parse error: parse error in C:\wamp\www\co\config.php on line 140
03/14/2010 - CO2 Private Server - 5 Replies
Im getting this error when i try to go to my reg page: Parse error: parse error in C:\wamp\www\co\config.php on line 140 It says that ^ Here is the code: <?php // Configurations $myhost='localhost'; // MySQL database address // :33006 $mypass='test'; // MySQL server login



All times are GMT +1. The time now is 01:20.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.