viewing paste Charms | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
Index: src/common/mmo.h
===================================================================
--- src/common/mmo.h    (revision 17121)
+++ src/common/mmo.h    (working copy)
@@ -175,6 +175,7 @@
    IT_UNKNOWN2,//9
    IT_AMMO,    //10
    IT_DELAYCONSUME,//11
+   IT_CHARM,   //12
    IT_CASH = 18,
    IT_MAX
 };
Index: src/map/clif.c
===================================================================
--- src/map/clif.c  (revision 17121)
+++ src/map/clif.c  (working copy)
@@ -65,7 +65,7 @@
 //Converts item type in case of pet eggs.
 static inline int itemtype(int type)
 {
-   return ( type == IT_PETEGG ) ? IT_WEAPON : type;
+   return ( type == IT_PETEGG ) ? IT_WEAPON : ( type == IT_CHARM ) ? IT_ETC : type;
 }
 
 
@@ -14114,7 +14114,7 @@
        return;
    }
 
-   if( (item = itemdb_exists(sd->status.inventory[idx].nameid)) != NULL && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC) )
+   if( (item = itemdb_exists(sd->status.inventory[idx].nameid)) != NULL && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC || item->type == IT_CHARM) )
    { // Consumable or pets are not allowed
        clif_Auction_setitem(sd->fd, idx, true);
        return;
Index: src/map/itemdb.c
===================================================================
--- src/map/itemdb.c    (revision 17121)
+++ src/map/itemdb.c    (working copy)
@@ -198,6 +198,7 @@
        case IT_AMMO:           return "Arrow/Ammunition";
        case IT_DELAYCONSUME:   return "Delay-Consume Usable";
        case IT_CASH:           return "Cash Usable";
+       case IT_CHARM:          return "Charm";
    }
    return "Unknown Type";
 }
@@ -976,7 +977,7 @@
 
    id->type = atoi(str[3]);
 
-   if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_DELAYCONSUME && id->type < IT_CASH ) || id->type >= IT_MAX )
+   if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_CHARM && id->type < IT_CASH ) || id->type >= IT_MAX )
    {// catch invalid item types
        ShowWarning("itemdb_parse_dbrow: Invalid item type %d for item %d. IT_ETC will be used.\n", id->type, nameid);
        id->type = IT_ETC;
Index: src/map/log.c
===================================================================
--- src/map/log.c   (revision 17121)
+++ src/map/log.c   (working copy)
@@ -111,7 +111,7 @@
 
    if( ( filter&LOG_FILTER_ALL ) ||
        ( filter&LOG_FILTER_HEALING && id->type == IT_HEALING ) ||
-       ( filter&LOG_FILTER_ETC_AMMO && ( id->type == IT_ETC || id->type == IT_AMMO ) ) ||
+       ( filter&LOG_FILTER_ETC_AMMO && ( id->type == IT_ETC || id->type == IT_AMMO || id->type == IT_CHARM ) ) ||
        ( filter&LOG_FILTER_USABLE && ( id->type == IT_USABLE || id->type == IT_CASH ) ) ||
        ( filter&LOG_FILTER_WEAPON && id->type == IT_WEAPON ) ||
        ( filter&LOG_FILTER_ARMOR && id->type == IT_ARMOR ) ||
Index: src/map/pc.c
===================================================================
--- src/map/pc.c    (revision 17121)
+++ src/map/pc.c    (working copy)
@@ -3835,6 +3835,8 @@
    //Auto-equip
    if(data->flag.autoequip)
        pc_equipitem(sd, i, data->equip);
+   if(sd->inventory_data[i]->type == IT_CHARM)
+       status_calc_pc(sd,0);
 
    /* rental item check */
    if( item_data->expire_time ) {
@@ -3863,6 +3865,7 @@
  *------------------------------------------*/
 int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type)
 {
+   int mem = 0;
    nullpo_retr(1, sd);
 
    if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
@@ -3875,6 +3878,7 @@
    if( sd->status.inventory[n].amount <= 0 ){
        if(sd->status.inventory[n].equip)
            pc_unequipitem(sd,n,3);
+       mem = sd->inventory_data[n]->type;
        memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0]));
        sd->inventory_data[n] = NULL;
    }
@@ -3882,6 +3886,8 @@
        clif_delitem(sd,n,amount,reason);
    if(!(type&2))
        clif_updatestatus(sd,SP_WEIGHT);
+   if(mem == IT_CHARM)
+       status_calc_pc(sd,0);
 
    return 0;
 }
Index: src/map/status.c
===================================================================
--- src/map/status.c    (revision 17121)
+++ src/map/status.c    (working copy)
@@ -2425,6 +2425,24 @@
    pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),true);
 
    // Parse equipment.
+   for(i=0;i<MAX_INVENTORY;i++)
+   {
+       if(!sd->inventory_data[i])
+           continue;
+       if(sd->inventory_data[i]->type == IT_CHARM)
+       {
+           if(sd->inventory_data[i]->script && sd->inventory_data[i]->elv <= sd->status.base_level)
+           {
+               if((!((1<<(sd->class_&MAPID_BASEMASK)) &(sd->inventory_data[i]->class_base[sd->class_&JOBL_2_1?1:(sd->class_&JOBL_2_2?2:0)])))
+                   || (!((1<<(sd->class_&JOBL_UPPER?1:(sd->class_&JOBL_BABY?2:0))) &sd->inventory_data[i]->class_upper)))
+                       continue;            
+               run_script(sd->inventory_data[i]->script,0,sd->bl.id,0);
+                if (!calculating)
+                    return 1;
+           }
+       }
+   }
+
    for(i=0;i<EQI_MAX-1;i++) {
        current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
        if(index < 0)
Viewed 1130 times, submitted by Lilith.