Jump to content
For maintenance and updates, the community will be offline on 31 December 2022 ×

[Small Function]Get item value by vnum


Karbust

Recommended Posts

  • Web Developer

Sup bois

I needed a way to get the value3 on hair costumes to be used on render target:

But, I needed to get the value3 with the change look system, for which there wasn't a function already.

Open UserInterface -> PythonItemModule.cpp, and after:

PyObject* itemLoadItemTable(PyObject* poSelf, PyObject* poArgs)

Add:

PyObject* itemGetValueByVnum(PyObject* poSelf, PyObject* poArgs) {
	int iValueIndex;
	if (!PyTuple_GetInteger(poArgs, 0, &iValueIndex))
		return Py_BadArgument();

	int iVnum;
	if (!PyTuple_GetInteger(poArgs, 1, &iVnum))
		return Py_BadArgument();

	CItemData* pItemData;
	CItemManager::Instance().GetItemDataPointer(iVnum, &pItemData);
	if (!pItemData)
		return Py_BuildException("Not yet select item data");

	return Py_BuildValue("i", pItemData->GetValue(iValueIndex));
}

Then, after:

{ "LoadItemTable",					itemLoadItemTable,						METH_VARARGS },

Add:

{ "GetValueByVnum",					itemGetValueByVnum,						METH_VARARGS },

How to use it? On uitooltip.py

				elif itemSubType == item.COSTUME_TYPE_HAIR: #Hair 
					if self.__ItemGetRace() == player.GetRace():
						itemVnum_prv = itemVnum
						if app.ENABLE_CHANGE_LOOK_SYSTEM and getChangelookVnum:
							itemVnum_prv = getChangelookVnum
							self.__ModelPreview(item.GetValueByVnum(3, itemVnum_prv), 1, player.GetRace())
						else:
							self.__ModelPreview(item.GetValue(3), 1, player.GetRace())

Result:

244648LIX1bKp.png

  • Metin2 Dev 1
  • Eyes 1
  • Love 2
  • Good 1

QJ0orbR.png

Metin2 Icon Database

Link to comment
Share on other sites

  • Moderator

Hi, thanks for the release, but you don't need any extra function, you just need to select the change look vnum.

item.SelectItem(changelookVnum)
valu3 = item.GetValue(3)

# Set selected item as the old one because it's used later in other conditions
item.SelectItem(oldItemVnum)

 

1 hour ago, Karbust said:
				elif itemSubType == item.COSTUME_TYPE_HAIR: #Hair 
					if self.__ItemGetRace() == player.GetRace():
						itemVnum_prv = itemVnum
						if app.ENABLE_CHANGE_LOOK_SYSTEM and getChangelookVnum:
							itemVnum_prv = getChangelookVnum
							self.__ModelPreview(item.GetValueByVnum(3, itemVnum_prv), 1, player.GetRace())
						else:
							self.__ModelPreview(item.GetValue(3), 1, player.GetRace())

 

So, the code should looks like:

				elif itemSubType == item.COSTUME_TYPE_HAIR:
					if self.__ItemGetRace() == player.GetRace():
						value3 = item.GetValue(3)
						if app.ENABLE_CHANGE_LOOK_SYSTEM and getChangelookVnum:
							item.SelectItem(getChangelookVnum)
							value3 = item.GetValue(3)

						self.__ModelPreview(value3, 1, player.GetRace())
						item.SelectItem(itemVnum)
  • Good 2
Link to comment
Share on other sites

  • Web Developer
3 minutes ago, VegaS™ said:

Hi, thanks for the release, but you don't need any extra function, you just need to select the change look vnum.

item.SelectItem(changelookVnum)
valu3 = item.GetValue(3)

# Set selected item as the old one because it's used later in other conditions
item.SelectItem(oldItemVnum)

 

So, the code should looks like:

				elif itemSubType == item.COSTUME_TYPE_HAIR:
					if self.__ItemGetRace() == player.GetRace():
						value3 = item.GetValue(3)
						if app.ENABLE_CHANGE_LOOK_SYSTEM and getChangelookVnum:
							item.SelectItem(getChangelookVnum)
							value3 = item.GetValue(3)

						self.__ModelPreview(value3, 1, player.GetRace())
						item.SelectItem(itemVnum)

Well, actually didn't try that option, tried others and none worked so, made a new one.

I though the SelectItem only worked with items in the inventory/safebox/etc., based on the code I saw, so I didn't even test it.

Thanks for your input as always 😘

  • Love 1

QJ0orbR.png

Metin2 Icon Database

Link to comment
Share on other sites



×
×
  • 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.