Jump to content
  • 0

Runa ignore the amount of available slots


Mahiro

Question


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  65
  • Reputation:   10
  • Joined:  08/02/18
  • Last Seen:  

Could someone give me a little help here?

I manage to make the rune equip in the last slot, and also replace it if there is already a rune there, however when the other common slots are already occupied, it doesn't even open the window to insert a rune, or replace the current one.

 

itemdb.hpp

Quote

#define itemdb_isenchant(i) (i >= 4700 && i <= 4999)

pc.cpp

Quote

int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip)
{
    nullpo_ret(sd);

    if (idx_equip < 0 || idx_equip >= MAX_INVENTORY) {
        return 0;
    }
    if (idx_card < 0 || idx_card >= MAX_INVENTORY) {
        return 0;
    }

    int i;
    t_itemid nameid;
    struct item_data* item_eq = sd->inventory_data[idx_equip];
    struct item_data* item_card = sd->inventory_data[idx_card];

    if(item_eq == nullptr)
        return 0; //Invalid item index.
    if(item_card == nullptr)
        return 0; //Invalid card index.
    if( sd->inventory.u.items_inventory[idx_equip].nameid == 0 || sd->inventory.u.items_inventory[idx_equip].amount < 1 )
        return 0; // target item missing
    if( sd->inventory.u.items_inventory[idx_card].nameid == 0 || sd->inventory.u.items_inventory[idx_card].amount < 1 )
        return 0; // target card missing
    if( item_eq->type != IT_WEAPON && item_eq->type != IT_ARMOR )
        return 0; // only weapons and armor are allowed
    if( item_card->type != IT_CARD )
        return 0; // must be a card
    if( sd->inventory.u.items_inventory[idx_equip].identify == 0 )
        return 0; // target must be identified
    if( itemdb_isspecial(sd->inventory.u.items_inventory[idx_equip].card[0]) )
        return 0; // card slots reserved for other purposes
    if( (item_eq->equip & item_card->equip) == 0 )
        return 0; // card cannot be compounded on this item type
    if( itemdb_isenchant(sd->inventory.u.items_inventory[idx_card].nameid) && item_eq->slots > 3 )
        return 0; // Reserved slot for Enchant is a normal slot
    if( item_eq->type == IT_WEAPON && item_card->equip == EQP_SHIELD )
        return 0; // attempted to place shield card on left-hand weapon.
    if( item_eq->type == IT_ARMOR && (item_card->equip & EQP_ACC) && ((item_card->equip & EQP_ACC) != EQP_ACC) && ((item_eq->equip & EQP_ACC) != (item_card->equip & EQP_ACC)) )
        return 0; // specific accessory-card can only be inserted to specific accessory.
    if( sd->inventory.u.items_inventory[idx_equip].equip != 0 )
        return 0; // item must be unequipped

    // remember the card id to insert
    nameid = sd->inventory.u.items_inventory[idx_card].nameid;

    if( itemdb_isenchant(nameid) ){
        i = 3; // Enchant Slot - Can overwrite current enchant
    }
    else {
        ARR_FIND( 0, item_eq->slots, i, sd->inventory.u.items_inventory[idx_equip].card[i] == 0 );
        if( i == item_eq->slots )
            return 0; // no free slots
    }

    if( pc_delitem(sd,idx_card,1,1,0,LOG_TYPE_OTHER) == 1 )
    {// failed
        clif_insert_card(sd,idx_equip,idx_card,1);
    }
    else
    {// success
        log_pick_pc(sd, LOG_TYPE_OTHER, -1, &sd->inventory.u.items_inventory[idx_equip]);
        sd->inventory.u.items_inventory[idx_equip].card[i] = nameid;
        log_pick_pc(sd, LOG_TYPE_OTHER,  1, &sd->inventory.u.items_inventory[idx_equip]);
        clif_insert_card(sd,idx_equip,idx_card,0);
        if( itemdb_isenchant(nameid) ){
            clif_delitem(sd,idx_equip,1,3);
            clif_additem(sd,idx_equip,1,0);
        }
    }
    
    return 0;
}

 

Edited by Mahiro
bad english
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

perhaps try alter the condition checking here ?

  if( itemdb_isenchant(sd->inventory.u.items_inventory[idx_card].nameid) && item_eq->slots > 3 )
        return 0; // Reserved slot for Enchant is a normal slot

into

  if(!itemdb_isenchant(sd->inventory.u.items_inventory[idx_card].nameid) && idx_card == (item_eq->slots - 1))
        return 0; // Reserved slot for Enchant is a normal slot

or

  if(itemdb_isenchant(sd->inventory.u.items_inventory[idx_card].nameid) && idx_card != (item_eq->slots - 1))
        return 0; // Reserved slot for Enchant is a normal slot

 

Edited by Emistry
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  65
  • Reputation:   10
  • Joined:  08/02/18
  • Last Seen:  

@Emistry Actually I should add in clif.cpp too.
Its working but not 100% Im testing it yet.

Link to comment
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
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

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