Jump to content
Daxter

MakeItem vs GiveItem & ItemAttr

Recommended Posts

Hi,

 

I have two questions to which need help understanding:

 

  1. What is the difference between MakeItem and GiveItem? Give takes one more parameter, but how relevant is that?
  2. Is there any place I can find all "codes" for item attributes, like 16 is for rightful BD equips, etc?

Share this post


Link to post
Share on other sites

Bump

Can anyone help with (at least) the item quality part? Function name, or list of values. From what I've gathered 4 seems to be the default, but there's also 96? And from 101+ it's used for gem levels

Edited by Daxter

Share this post


Link to post
Share on other sites

Hello @Daxter,

 

MakeItem() as a result returns two variables (a tuple): success flag (boolean) and position of the created item in the character's bag:

r1,r2 = MakeItem(role, <Item ID>, <Amount>, <Quality/Type>)
-- if r1 == 1 then the item <Item ID> x <Amount> of quality <Quality/Type> is successfully added to the inventory/bag.
-- r2 contains the number of the inventory slot in which the created item is placed if r1 == 1

GiveItem() returns just a success flag:

r1 = GiveItem(role, 0, <Item ID>, <Amount>, <Quality/Type>)
-- The second parameter is an NPC descriptor, usually it equals 0.

You can see examples of using both functions in GameServer scripts.

 

On 1/8/2024 at 1:41 AM, Daxter said:

Bump

Can anyone help with (at least) the item quality part? Function name, or list of values. From what I've gathered 4 seems to be the default, but there's also 96? And from 101+ it's used for gem levels

It depends on the type of item (gem, fairy, etc). For regular items, I think you can use value 4.

  • Thanks 1

Share this post


Link to post
Share on other sites
17 hours ago, V3ct0r said:

Hello @Daxter,

 

MakeItem() as a result returns two variables (a tuple): success flag (boolean) and position of the created item in the character's bag:


r1,r2 = MakeItem(role, <Item ID>, <Amount>, <Quality/Type>)
-- if r1 == 1 then the item <Item ID> x <Amount> of quality <Quality/Type> is successfully added to the inventory/bag.
-- r2 contains the number of the inventory slot in which the created item is placed if r1 == 1

GiveItem() returns just a success flag:


r1 = GiveItem(role, 0, <Item ID>, <Amount>, <Quality/Type>)
-- The second parameter is an NPC descriptor, usually it equals 0.

You can see examples of using both functions in GameServer scripts.

Thanks, that's a lot clearer now.

When you mention GameServer scripts, are you referring to the source code? I'm not very knowledgeable in C++, so I admit i haven't looked into it

17 hours ago, V3ct0r said:

It depends on the type of item (gem, fairy, etc). For regular items, I think you can use value 4.

Right, but there's nothing like a list of outcomes to consult? So I'll have to look it up in other scripts?

For instance, the level 40+ Newbie Chest:

function ItemUse_XRBOX7( role, Item )
	local job = GetChaAttr(role, ATTR_JOB)
	local lv = GetChaAttr(role, ATTR_LV) 
        local cha_type = GetChaTypeID ( role )
        local cha_type = GetChaTypeID ( role )
	local Item_CanGet = GetChaFreeBagGridNum ( role )
	if Item_CanGet < 5 then
		SystemNotice(role ,"To open a Newbie Chest requires 5 empty slots")
		UseItemFailed ( role )
		return
	end
	if lv < 40 then
		SystemNotice(role ,"Currently lower than Lv 40. Unable to use item!")
		UseItemFailed ( role )	
	elseif job == 9 then 
		GiveItem ( role , 0 , 450  , 1 , 4 ) 
		GiveItem ( role , 0 , 295  , 1 , 95 )
		GiveItem ( role , 0 , 4  , 1 , 95 ) 
		GiveItem ( role , 0 , 302  , 1 , 95 )
		local r1,r2 =MakeItem ( role , 22  , 1 , 11 )
		local Item1 = GetChaItem ( role , 2 , r2 )

Serpentine Sword (ID 4) comes gemmed from the chest, meaning Item Quality 95 = random basic gem? And if I were to change the possible gems to include when quality = 95, would that be defined in a script or is defined via GameServer?

Edited by Daxter
Accidental early post

Share this post


Link to post
Share on other sites
7 hours ago, Daxter said:

When you mention GameServer scripts, are you referring to the source code? I'm not very knowledgeable in C++, so I admit i haven't looked into it

No, I refer to GameServer lua scripts, which are located in the GameServer/resource/script/ directory. Analysis of the source code of these functions in C++ can, of course, give more understanding of the specifics of their operation.

 

If you just need to give an item to the player, use the GiveItem() function. If you need to create an item, get and set its attributes, then use the MakeItem() function in conjunction with the GetChaItem(), GetItemAttr() and SetItemAttr() functions.

 

7 hours ago, Daxter said:

Right, but there's nothing like a list of outcomes to consult? So I'll have to look it up in other scripts?

Look at function Creat_Item(item, item_type, item_lv, item_event) from \GameServer\resource\script\calculate\AttrCalculate.lua. The item_event parameter is the quality/type of the item being created. This function performs some manipulations with the item, depending on the parameter. For Type = 95 it will be:

elseif item_event == QUEST_AWARD_SCBOX then
	count = CreateItemAttrCount ( item_type , item_lv , item_event , quality , Item_Attr_95 )
  • Thanks 1

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.


×
×
  • Create New...