Jump to content
×
×
  • Create New...
  • 0

Quest Starter


Shisui

Question

4 answers to this question

Recommended Posts

  • 0

i m interessed in that
can u please be so nice to explain us how can i let login start items to have for exemple

sword +9  with 20% strong against zombie  and 12 dexterity

just for an exemple
i m really interessed on how to do that type of initial starter set bonus

Link to comment
Share on other sites

  • 0
  • 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)
  • Love 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


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.