Jump to content

Recommended Posts

Hey, how can i talk to a specific NPC?
 

I know about

vid = player.GetTargetVID()
net.SendOnClickPacket(vid)

but with this, the NPC has to be marked.

 

The problem is, the vid of this specific NPC always changes if i teleport away.

 

Is there a way, how i can scan the vid of a specific NPC nearby and automatic talk to it, if im in x range?

Edited by OnlyGood
Link to comment
https://metin2.dev/topic/25084-how-can-i-talk-to-a-npc-via-python/
Share on other sites

  • Honorable Member

CPythonCharacterManager has functions like CharacterInstanceBegin and CharacterInstanceEnd so you can iterate over the characters nearby like:

TPixelPosition myPos;
CPythonPlayer::instance().NEW_GetMainActorPosition(&myPos);

CPythonCharacterManager& chrMgr = CPythonCharacterManager::instance();
for (auto it = chrMgr.CharacterInstanceBegin(); it != chrMgr.CharacterInstanceEnd(); ++it)
{
	if (CInstanceBase* ch = *it)
	{
		TPixelPosition otherPos;
		ch->NEW_GetPixelPosition(&otherPos);
		if(GetPixelPositionDistance(myPos, otherPos) <= SOME DISTANCE && some other thing to identify your npc)
		{
			CPythonNetworkStream::Instance().SendOnClickPacket(ch->GetVirtualID());
		}
	}
}

 

Edited by Distraught
  • Love 1

992404397646696589.png
Former C++ Developer at Gameloft on DML
Join my Discord: Distraught Labs

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.