Jump to content
×
×
  • Create New...

[C++] Increasing the number of attributes


Recommended Posts

  • Moon

greetings everyone, we will increase the number of attributes as you can understand from the title

 

Game

Spoiler


Game Source

open constants.cpp:

search
  
  const int aiItemAttributeAddPercent[ITEM_ATTRIBUTE_MAX_NUM] =
  
change the numbers below
  
  100, 100, 100, 100, 100, 100, 100, 100,

open char_item.cpp
  
  search if (item2->GetAttributeCount() < 4) or if (item2->GetAttributeCount() < 5)
  
  change
  
  if (item2->GetAttributeCount() < 6)
 
open item.h
  
  	search
  
 	 void        PutAttributeWithLevel(BYTE bLevel);

	add
     
    public:
        void        AddRareAttribute2(const int * aiAttrPercentTable = NULL);
    protected:
        void        AddRareAttr(BYTE bApply, BYTE bLevel);
        void        PutRareAttribute(const int * aiAttrPercentTable);
        void        PutRareAttributeWithLevel(BYTE bLevel);
    
   
open item_attribute.cpp
  
  search  int CItem::GetRareAttrCount()
    
  change all code block
    
int CItem::GetRareAttrCount()
{
    int ret = 0;

    for (DWORD dwIdx = ITEM_ATTRIBUTE_RARE_START; dwIdx < ITEM_ATTRIBUTE_RARE_END; dwIdx++)
    {
        if (m_aAttr[dwIdx].bType != 0)
            ret++;
    }

    return ret;
}

search
  
 	m_aAttr[i + 5].bType = 0;
	m_aAttr[i + 5].sValue = 0;

change
  
  m_aAttr[i + ITEM_ATTRIBUTE_RARE_START].bType = 0;
  m_aAttr[i + ITEM_ATTRIBUTE_RARE_START].sValue = 0;

search
  
  if (count >= 2)
  
  change
  
  if (count >= ITEM_ATTRIBUTE_RARE_NUM)
  
search
  
  int pos = count + 5;

change
  
  int pos = count + ITEM_ATTRIBUTE_RARE_START;

add at the bottom of the file
  
void CItem::AddRareAttribute2(const int * aiAttrPercentTable)
{
    static const int aiItemAddAttributePercent[ITEM_ATTRIBUTE_MAX_LEVEL] =
    {
        40, 50, 10, 0, 0
    };
    if (aiAttrPercentTable == NULL)
        aiAttrPercentTable = aiItemAddAttributePercent;

    if (GetRareAttrCount() < MAX_RARE_ATTR_NUM)
        PutRareAttribute(aiAttrPercentTable);
}

void CItem::PutRareAttribute(const int * aiAttrPercentTable)
{
    int iAttrLevelPercent = number(1, 100);
    int i;

    for (i = 0; i < ITEM_ATTRIBUTE_MAX_LEVEL; ++i)
    {
        if (iAttrLevelPercent <= aiAttrPercentTable[i])
            break;

        iAttrLevelPercent -= aiAttrPercentTable[i];
    }

    PutRareAttributeWithLevel(i + 1);
}

void CItem::PutRareAttributeWithLevel(BYTE bLevel)
{
    int iAttributeSet = GetAttributeSetIndex();
    if (iAttributeSet < 0)
        return;

    if (bLevel > ITEM_ATTRIBUTE_MAX_LEVEL)
        return;

    std::vector<int> avail;

    int total = 0;

    // ºÙÀÏ ¼ö ÀÖ´Â ¼Ó¼º ¹è¿À» ±¸Ãà
    for (int i = 0; i < MAX_APPLY_NUM; ++i)
    {
        const TItemAttrTable & r = g_map_itemRare[i];

        if (r.bMaxLevelBySet[iAttributeSet] && !HasRareAttr(i))
        {
            avail.push_back(i);
            total += r.dwProb;
        }
    }

    // ±¸ÃàµÈ ¹è¿·Î È®·ü °è»êÀ» ÅëÇØ ºÙÀÏ ¼Ó¼º ¼±Á¤
    unsigned int prob = number(1, total);
    int attr_idx = APPLY_NONE;

    for (DWORD i = 0; i < avail.size(); ++i)
    {
        const TItemAttrTable & r = g_map_itemRare[avail[i]];

        if (prob <= r.dwProb)
        {
            attr_idx = avail[i];
            break;
        }

        prob -= r.dwProb;
    }

    if (!attr_idx)
    {
        sys_err("Cannot put item rare attribute %d %d", iAttributeSet, bLevel);
        return;
    }

    const TItemAttrTable & r = g_map_itemRare[attr_idx];

    // Á¾·ùº° ¼Ó¼º ·¹º§ ÃÖ´ë°ª Á¦ÇÑ
    if (bLevel > r.bMaxLevelBySet[iAttributeSet])
        bLevel = r.bMaxLevelBySet[iAttributeSet];

    AddRareAttr(attr_idx, bLevel);
}

void CItem::AddRareAttr(BYTE bApply, BYTE bLevel)
{
    if (HasRareAttr(bApply))
        return;

    if (bLevel <= 0)
        return;

    int i = ITEM_ATTRIBUTE_RARE_START + GetRareAttrCount();

    if (i == ITEM_ATTRIBUTE_RARE_END)
        sys_err("item rare attribute overflow!");
    else
    {
        const TItemAttrTable & r = g_map_itemRare[bApply];
        long lVal = r.lValues[MIN(4, bLevel - 1)];

        if (lVal)
            SetForceAttribute(i, bApply, lVal);
    }
}

open item_manager.h
  
  search
  
  const static int MAX_NORM_ATTR_NUM = 5;
  const static int MAX_RARE_ATTR_NUM = 2;

  change
    
  const static int MAX_NORM_ATTR_NUM = ITEM_ATTRIBUTE_NORM_NUM;
  const static int MAX_RARE_ATTR_NUM = ITEM_ATTRIBUTE_RARE_NUM;


    

 

 

 

DB

Spoiler


DB Source

open cache.cpp

search

if (isAttr)

change all code block

if (isAttr)
        {
            iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen,
                    ", attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3"
                    ", attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, attrtype7, attrvalue7");

            iValueLen += snprintf(szValues + iValueLen, sizeof(szValues) - iValueLen,
                    ", %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",
                    p->aAttr[0].bType, p->aAttr[0].sValue,
                    p->aAttr[1].bType, p->aAttr[1].sValue,
                    p->aAttr[2].bType, p->aAttr[2].sValue,
                    p->aAttr[3].bType, p->aAttr[3].sValue,
                    p->aAttr[4].bType, p->aAttr[4].sValue,
                    p->aAttr[5].bType, p->aAttr[5].sValue,
                    p->aAttr[6].bType, p->aAttr[6].sValue,
                    p->aAttr[7].bType, p->aAttr[7].sValue);

            iUpdateLen += snprintf(szUpdate + iUpdateLen, sizeof(szUpdate) - iUpdateLen,
                    ", attrtype0=%d, attrvalue0=%d"
                    ", attrtype1=%d, attrvalue1=%d"
                    ", attrtype2=%d, attrvalue2=%d"
                    ", attrtype3=%d, attrvalue3=%d"
                    ", attrtype4=%d, attrvalue4=%d"
                    ", attrtype5=%d, attrvalue5=%d"
                    ", attrtype6=%d, attrvalue6=%d"
                    ", attrtype7=%d, attrvalue7=%d",
                    p->aAttr[0].bType, p->aAttr[0].sValue,
                    p->aAttr[1].bType, p->aAttr[1].sValue,
                    p->aAttr[2].bType, p->aAttr[2].sValue,
                    p->aAttr[3].bType, p->aAttr[3].sValue,
                    p->aAttr[4].bType, p->aAttr[4].sValue,
                    p->aAttr[5].bType, p->aAttr[5].sValue,
                    p->aAttr[6].bType, p->aAttr[6].sValue,
                    p->aAttr[7].bType, p->aAttr[7].sValue);
        }

open clientmanager.cpp

search

"attrtype6, attrvalue6 "

change

"attrtype6, attrvalue6, "
                "attrtype7, attrvalue7 "

search

"attrtype6, attrvalue6) "
            "VALUES(%u, %u, %d, %d, %u, %u, %ld, %ld, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",

change

"attrtype6, attrvalue6, "
            "attrtype7, attrvalue7) "
            "VALUES(%u, %u, %d, %d, %u, %u, %ld, %ld, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",

search

p->aAttr[6].bType, p->aAttr[6].sValue);

change

p->aAttr[6].bType, p->aAttr[6].sValue,
            p->aAttr[7].bType, p->aAttr[7].sValue);

open clientmanagerplayer.cpp

search

attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6 "

change

attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6,attrtype7,attrvalue7 "

search

attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6 "

change

attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6,attrtype7,attrvalue7 "

 

 

 

Common

Spoiler


Common

open item_lenght.h

search

ITEM_ATTRIBUTE_MAX_NUM        = 7,

change

 ITEM_ATTRIBUTE_NORM_NUM        = 6,
    ITEM_ATTRIBUTE_RARE_NUM        = 2,

    ITEM_ATTRIBUTE_NORM_START    = 0,
    ITEM_ATTRIBUTE_NORM_END        = ITEM_ATTRIBUTE_NORM_START + ITEM_ATTRIBUTE_NORM_NUM,

    ITEM_ATTRIBUTE_RARE_START    = ITEM_ATTRIBUTE_NORM_END,
    ITEM_ATTRIBUTE_RARE_END        = ITEM_ATTRIBUTE_RARE_START + ITEM_ATTRIBUTE_RARE_NUM,

    ITEM_ATTRIBUTE_MAX_NUM        = ITEM_ATTRIBUTE_RARE_END, // 8

 

 

 

Client 

Spoiler


UserInterface

open gametype.h

search

ITEM_ATTRIBUTE_SLOT_MAX_NUM

change

ITEM_ATTRIBUTE_SLOT_MAX_NUM = 8,

 

 

 

Navicat

Spoiler


add the item table

 `attrtype7` tinyint(4) NOT NULL DEFAULT 0,
  `attrvalue7` smallint(6) NOT NULL DEFAULT 0,

 

 

evidence

 

spacer.png

Edited by hasanmacit

hasanmacit

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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.