Jump to content

Pc.give_item2_select


Recommended Posts

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Premium
int tItem2::get_attr(lua_State* L){
CItem* item = CQuestManager::instance()->GetCurrentItem();
if (!lua::IsNumber(L,1)||!item){
return 0;
}
int attr_index = lua::ToNumber(L,1);
if (attr_index <0 || attr_index > 6){
return 0;
}
TPlayerItemAttribute attr=item->GetAttribute(attr_index);
lua::PushNumber(L,attr.bType);
lua::PushNumber(L,attr.sValue);
return 2;
}
int tItem2::set_attr(lua_State* L){
CItem* item = CQuestManager::instance()->GetCurrentItem();
if (!lua::IsNumber(L,1)||!lua::IsNumber(L,2)||!lua::IsNumber(L,3)||!item){
lua::PushBoolean(L,0);
return 1;
}
int attr_index = lua::ToNumber(L,1);
if (attr_index <0 || attr_index > 6){
lua::PushBoolean(L,0);
return 1;
}
item->SetForceAttribute(attr_index,lua::ToNumber(L,2),lua::ToNumber(L,3));
lua::PushBoolean(L,1);
return 1;
}

Here you go, it's item2.get_attr = set_attr

 

I don't have the other i think

Link to comment
Share on other sites

 

These functions have but to store the guild needed 

Pc.give_item2_select

 

This command already exists in source and imer lib too.

 

Source : questlua_pc.cpp

			{ "give_item2_select",		pc_give_or_drop_item_and_select	},

Imer lib : http://metin2dev.org/board/topic/897-libsource34kimers-libgame/

 

  pc2.give_or_drop_item_and_select

Link to comment
Share on other sites

  • Honorable Member

These functions have but to store the guild needed

Pc.give_item2_select

Where?

pseudo:

int __cdecl quest__pc_give_or_drop_item_and_select(int a1)
{
	int v1; // eax@4
	int v2; // eax@7
	int v3; // ecx@7
	int v4; // ebx@7
	char v5; // al@7
	int v6; // ebx@7
	int v7; // esi@7
	int v8; // edi@7
	int v9; // eax@7
	int result; // eax@11
	long double v11; // fst7@15
	char v12; // ST10_1@17
	char v13; // al@18
	double v14; // ST10_8@20
	int v15; // [sp+18h] [bp-30h]@1
	signed int v16; // [sp+1Ch] [bp-2Ch]@6
	char v17; // [sp+20h] [bp-28h]@6
	int v18; // [sp+34h] [bp-14h]@4
	int v19; // [sp+38h] [bp-10h]@1

	v19 = *(_DWORD *)_stack_chk_guard;
	v15 = *(_DWORD *)(singleton_quest__CQuestManager___ms_singleton + 220);
	if ( !lua_isstring(a1, 1) && !lua_isnumber(a1, 1) )
	{
		quest__CQuestManager__QuestError(
			singleton_quest__CQuestManager___ms_singleton,
			(int)"pc_give_or_drop_item_and_select",
			537,
			"QUEST Make item call error : wrong argument",
			v12);
		goto LABEL_11;
	}
	if ( lua_isnumber(a1, 1) )
	{
		v18 = (signed int)lua_tonumber(a1, 1);
	}
	else
	{
		v1 = lua_tostring(a1, 1);
		if ( !(unsigned __int8)ITEM_MANAGER__GetVnum(singleton_ITEM_MANAGER___ms_singleton, v1, &v18) )
		{
			v13 = lua_tostring(a1, 1);
			quest__CQuestManager__QuestError(
				singleton_quest__CQuestManager___ms_singleton,
				(int)"pc_give_or_drop_item_and_select",
				549,
				"QUEST Make item call error : wrong item name : %s",
				v13);
			goto LABEL_11;
		}
	}
	if ( lua_isnumber(a1, 2) && lua_tonumber(a1, 2) > 0.0 )
	{
		v11 = lua_tonumber(a1, 2);
		v16 = (signed int)rint(v11);
		if ( v16 <= 0 )
		{
			v14 = lua_tonumber(a1, 2);
			quest__CQuestManager__QuestError(
				singleton_quest__CQuestManager___ms_singleton,
				(int)"pc_give_or_drop_item_and_select",
				559,
				"QUEST Make item call error : wrong item count : %g",
				SLOBYTE(v14));
			goto LABEL_11;
		}
		v17 = v16;
	}
	else
	{
		v16 = 1;
		v17 = 1;
	}
	CHARACTER__GetName(v15);
	v5 = lua_tostring(a1, 1);
	sys_log(0, "QUEST [REWARD] item %s to %s", v5);
	v6 = v18;
	v7 = *(_BYTE *)(v15 + 1298);
	v8 = *(_DWORD *)(v15 + 256);
	v9 = quest__PC__GetCurrentQuestName(*(_DWORD *)(singleton_quest__CQuestManager___ms_singleton + 232));
	LogManager__QuestRewardLog(singleton_LogManager___ms_singleton, *(_DWORD *)v9, v8, v7, v6, v16);
	v2 = CHARACTER__AutoGiveItem(v15, v18, v17, -1, 1);
	v4 = v2;
	if ( v2 )
		quest__CQuestManager__SetCurrentItem(singleton_quest__CQuestManager___ms_singleton, v2);
	if ( (unsigned int)(v18 - 80003) <= 4 )
		LogManager__GoldBarLog(
			singleton_LogManager___ms_singleton,
			*(_DWORD *)(v15 + 256),
			*(_DWORD *)(v4 + 88),
			7,
			"quest: give_item2");
LABEL_11:
	result = 0;
	if ( *(_DWORD *)_stack_chk_guard != v19 )
		__stack_chk_fail(v3, *(_DWORD *)_stack_chk_guard ^ v19);
	return result;
}

source:

	int pc_give_or_drop_item_and_select(lua_State* L)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
		if (!ch)
			return 0;

		if (!lua_isstring(L, 1) && !lua_isnumber(L, 1))
		{
			sys_err("QUEST Make item call error : wrong argument");
			return 0;
		}

		DWORD dwVnum;
		if (lua_isnumber(L, 1)) // ąřČŁŔΰćżě ąřČŁ·Î ÁŘ´Ů.
			dwVnum = (int)lua_tonumber(L, 1);
		else if (!ITEM_MANAGER::instance().GetVnum(lua_tostring(L, 1), dwVnum))
		{
			sys_err("QUEST Make item call error : wrong item name : %s", lua_tostring(L, 1));
			return 0;
		}

		int icount = 1;
		if (lua_isnumber(L, 2) && lua_tonumber(L, 2) >  0)
		{
			icount = (int)rint(lua_tonumber(L, 2));
			if (icount <= 0)
			{
				sys_err("QUEST Make item call error : wrong item count : %g", lua_tonumber(L, 2));
				return 0;
			}
		}

		sys_log(0, "QUEST [REWARD] item %s to %s", lua_tostring(L, 1), ch->GetName());

		PC* pPC = CQuestManager::instance().GetCurrentPC();
		LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), dwVnum, icount);

		LPITEM item = ch->AutoGiveItem(dwVnum, icount);
		if (item)
			CQuestManager::Instance().SetCurrentItem(item);

		if (dwVnum >= 80003 && dwVnum <= 80007)
			LogManager::instance().GoldBarLog(ch->GetPlayerID(), item->GetID(), QUEST, "quest: give_item2");

		return 0;
	}

 

Offset what call is:

f5b6e20290.png

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

That's right , this feature is already built but still can't add items to the warehouse guild. Syslog:

Oct  9 18:04:56.721743 :: QUEST ScriptButton pid 29 idx 123
Oct  9 18:04:56.881652 :: QUEST InputString pid 29 msg MOVE_ITEM#INVENTORY#7#59#0
SYSERR: Oct  9 18:04:56.881856 :: RunState: LUA_ERROR: locale/germany/quest/object/state/guildstorage:150: attempt to index field `item' (a nil value)
SYSERR: Oct  9 18:04:56.881869 :: WriteRunningStateToSyserr: LUA_ERROR: quest guildstorage.start click
Oct  9 18:04:57.561662 :: QUEST ScriptButton pid 29 idx 123
Oct  9 18:04:57.721686 :: QUEST InputString pid 29 msg CLOSE#

In quest i edited only

item2.set_attr
to
item.set_attribute
and
item2.get_attr
to
item.get_attribute

because I added myself these features and probably work the same

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



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