Jump to content
Sign in to follow this  
Vendetta

Lv4 Gem Combiner NPC

Recommended Posts

Can someone help me to fix the Lv4 Gem Combiner? The problem is that when i have higher level gem or any gem that are level 2+ the NPC is getting it when im using the combiner. It is a hassle for the players to go to bank or drop the gem just to use the combiner. Can someone share their knowledge and help me with this please. I know that other people have a problem with this too. Thanks in advance, cheers! 

Share this post


Link to post
Share on other sites

npc add functions scrips , instead of exchange scrips. and add requriments and so in the functions ones. 

Edited by Andy
  • Like 1

Share this post


Link to post
Share on other sites

 

4 hours ago, Andy said:

npc add functions scrips , instead of exchange scrips. and add requriments and so in the functions ones. 

Can share function here?

Edited by Anthoni

Share this post


Link to post
Share on other sites
function CombineGem(role, gemId, level)
	local chaBag = GetKbCap(role)
	local gemSlot,gemLv;
	local t = {}
	for i = 0, chaBag do
		gemSlot = GetChaItem(role, 2, i)
		if GetItemID(gemSlot) == gemId then
			gemLv = GetItemAttr(gemSlot, ITEMATTR_VAL_BaoshiLV)
			if gemLv == 1 then
				table.insert(t, i)
			end
		end
	end
	local needqty = 2^(level-1)
	local giveLv = 100+level
	if table.getn(t) < needqty then
		SystemNotice(role, "Failed to combine lv"..level.." "..GetItemName(gemId)..". Unable to find x"..needqty.." "..GetItemName(gemId).."!")
	else
		for i = 1, needqty do
			RemoveChaItem(role, gemId, 1, 2, t[i], 2, 0)
		end
		GiveItem(role, 0, gemId, 1, giveLv)
	end
end

NpcSdk.lua:

		elseif item.func == CombineGem then
			return CombineGem(character, item.p1, item.p2)

Usage:

	Text(1, GetItemName(0863), CombineGem, 0863, 4) -- Lv4 Gem of Rage
	Text(1, GetItemName(0860), CombineGem, 0860, 8) -- Lv8 Gem of Wind

The code may not be too optimized, but the logic is what you seek. =P

  • Like 1

kong.png

a2.png

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
Reply to this topic...

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

Sign in to follow this  

×
×
  • Create New...