Jump to content

Quest Starter


Go to solution Solved by Shisui,

Recommended Posts

  • 3 weeks later...
  • Former Staff

* Item module:
    - get_attribute | Return: Table1  | Args: byte AttrIndex[0..4]
    - set_attribute | Return: Boolean | Args: byte AttrIndex[0..4], byte AttrType[1..94], short AttrValue[-32768..32767]
 

questlua_item.cpp

Be carefull, in the code you can find a global config-variable!

"g_iItemStackCount" replace with 200 or 250 or what you want.

 

int item_get_attribute(lua_State* L)
{
LPITEM item = CQuestManager::instance().GetCurrentItem();
 
if (!item) return 0;
 
if (!lua_isnumber(L, 1))
{
sys_err("Wrong argument, need a number from range(0..%d)!", ITEM_ATTRIBUTE_MAX_NUM-2);
lua_pushnumber(L, 0);
return 1;
}
 
int iAttrIndex = (int)lua_tonumber(L, 1);
if (iAttrIndex < 0 || iAttrIndex >= ITEM_ATTRIBUTE_MAX_NUM-2)
{
sys_err("Invalid index %d. Index out of range(0..%d)", iAttrIndex, ITEM_ATTRIBUTE_MAX_NUM-2);
lua_pushnumber(L, 0);
return 1;
}
 
const TPlayerItemAttribute& AttrItem = item->GetAttribute(iAttrIndex);
 
lua_newtable(L);
 
lua_pushnumber(L, AttrItem.bType);
lua_rawseti(L, -2, 1);
 
lua_pushnumber(L, AttrItem.sValue);
lua_rawseti(L, -2, 2);
return 1;
}
 
int item_set_attribute(lua_State* L)
{
LPITEM item = CQuestManager::instance().GetCurrentItem();
 
if (!item) return 0;
if (item->GetType() == ITEM_COSTUME)
{
lua_pushboolean(L, false);
return 1;
}
 
if (!lua_isnumber(L, 1))
{
sys_err("Wrong argument[AttrIdx] #1.");
lua_pushboolean(L, false);
return 1;
}
else if (!lua_isnumber(L, 2))
{
sys_err("Wrong argument[AttrType] #2.");
lua_pushboolean(L, false);
return 1;
}
else if (!lua_isnumber(L, 3))
{
sys_err("Wrong argument[AttrValue] #3.");
lua_pushboolean(L, false);
return 1;
}
 
int bAttrIndex = (int)lua_tonumber(L, 1);
if (bAttrIndex < 0 || bAttrIndex >= ITEM_ATTRIBUTE_MAX_NUM-2)
{
sys_err("Invalid AttrIndex %d. AttrIndex out of range(0..4)", bAttrIndex);
lua_pushboolean(L, false);
return 1;
}
 
int bAttrType = (int)lua_tonumber(L, 2);
if (bAttrType < 1 || bAttrType >= MAX_APPLY_NUM)
{
sys_err("Invalid AttrType %d. AttrType out of range(1..%d)", MAX_APPLY_NUM);
lua_pushboolean(L, false);
return 1;
}
 
if (item->HasAttr(bAttrType) && (item->GetAttribute(bAttrIndex).bType != bAttrType))
{
sys_err("AttrType[%d] multiplicated.", bAttrType);
lua_pushboolean(L, false);
return 1;
}
 
int bAttrValue = (int)lua_tonumber(L, 3);
if (bAttrValue < 1 || bAttrValue >= 32768)
{
sys_err("Invalid AttrValue %d. AttrValue should be between 1 and 32767!", bAttrValue);
lua_pushboolean(L, false);
return 1;
}
 
bool bRet = TRUE;
int bAttrCount = item->GetAttributeCount();
if (bAttrCount <= 4 && bAttrCount >= 0)
{
if (bAttrCount < bAttrIndex)
bAttrIndex = bAttrCount;
 
item->SetForceAttribute(bAttrIndex, bAttrType, bAttrValue);
}
else
bRet = FALSE;
 
lua_pushboolean(L, bRet);
return 1;
}
 
 
{ "get_attribute", item_get_attribute },
{ "set_attribute",                 item_set_attribute },

pc.give_item2_select(VNUMITEM,COUNT)
item.set_attribute(bonus, bonus_id, percentage)
 
For example, give item 17009 with 3000 hp.
 
pc.give_item2_select(17009,1)
item.set_attribute(0, 1, 3000)
  • Scream 1
  • Love 1
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.