summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/itemdb.c33
-rw-r--r--src/map/itemdb.h2
-rw-r--r--src/map/map.h6
-rw-r--r--src/map/pc.c30
-rw-r--r--src/map/status.c3
5 files changed, 42 insertions, 32 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 728ea0108..f3d462002 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -111,36 +111,25 @@ int itemdb_searchrandomid(int group)
ShowError("itemdb_searchrandomid: No item entries for group id %d\n", group);
return UNKNOWN_ITEM_ID;
}
-
/*==========================================
- * Returns the group this item belongs to.
- * Skips general random item givers (gift/blue/violet box)
+ * Calculates total item-group related bonuses for the given item. [Skotlex]
*------------------------------------------
*/
-int itemdb_group (int nameid)
+int itemdb_group_bonus(struct map_session_data *sd, int itemid)
{
- int i, j;
+ int bonus = 0, i, j;
for (i=0; i < MAX_ITEMGROUP; i++) {
- switch (i) {
- case IG_BLUEBOX:
- case IG_VIOLETBOX:
- case IG_CARDALBUM:
- case IG_GIFTBOX:
- case IG_COOKIEBAG:
- case IG_GIFTBOX_1:
- case IG_GIFTBOX_2:
- case IG_GIFTBOX_3:
- case IG_GIFTBOX_4:
- case IG_GIFTBOXCHINA:
- continue;
- }
-
+ if (!sd->itemgrouphealrate[i])
+ continue;
for (j=0; j < itemgroup_db[i].qty; j++) {
- if (itemgroup_db[i].id[j] == nameid)
- return i;
+ if (itemgroup_db[i].id[j] == itemid)
+ {
+ bonus += sd->itemgrouphealrate[i];
+ continue;
+ }
}
}
- return -1;
+ return bonus;
}
/*==========================================
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index d8255ef5a..fc4f1188b 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -104,7 +104,7 @@ struct item_data* itemdb_exists(int nameid);
#define itemdb_available(n) (itemdb_exists(n) && itemdb_search(n)->flag.available)
#define itemdb_viewid(n) (itemdb_search(n)->view_id)
#define itemdb_autoequip(n) (itemdb_search(n)->flag.autoequip)
-int itemdb_group(int nameid);
+int itemdb_group_bonus(struct map_session_data *sd, int itemid);
int itemdb_searchrandomid(int flags);
diff --git a/src/map/map.h b/src/map/map.h
index a56f14aaa..68fd25d7b 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -629,7 +629,7 @@ struct map_session_data {
int magic_addsize[3];
int critaddrace[RC_MAX];
int expaddrace[RC_MAX];
- int itemhealrate[MAX_ITEMGROUP];
+ int itemgrouphealrate[MAX_ITEMGROUP];
short sp_gain_race[RC_MAX];
// zeroed arrays end here.
// zeroed structures start here
@@ -651,6 +651,10 @@ struct map_session_data {
short id, group;
int race, rate;
} add_drop[MAX_PC_BONUS];
+ struct {
+ int nameid;
+ int rate;
+ } itemhealrate[MAX_PC_BONUS];
// zeroed structures end here
// zeroed vars start here.
int arrow_atk,arrow_ele,arrow_cri,arrow_hit;
diff --git a/src/map/pc.c b/src/map/pc.c
index 2b931ba23..a42911e56 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -2167,10 +2167,18 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
case SP_ADD_ITEM_HEAL_RATE:
if(sd->state.lr_flag == 2)
break;
- if (type2 < MAX_ITEMGROUP)
- sd->itemhealrate[type2] += val;
- else
- ShowWarning("pc_bonus2: AddItemHealRate: Group %d is beyond limit (%d).\n", type2, MAX_ITEMGROUP);
+ if (type2 < MAX_ITEMGROUP) { //Group bonus
+ sd->itemgrouphealrate[type2] += val;
+ break;
+ }
+ //Standard item bonus.
+ for(i=0; i < MAX_PC_BONUS && sd->itemhealrate[i].nameid && sd->itemhealrate[i].nameid != type2; i++);
+ if(i == MAX_PC_BONUS) {
+ ShowWarning("pc_bonus2: Reached max (%d) number of item heal bonuses per character!\n", MAX_PC_BONUS);
+ break;
+ }
+ sd->itemhealrate[i].nameid = type2;
+ sd->itemhealrate[i].rate += val;
break;
case SP_EXP_ADDRACE:
if(sd->state.lr_flag != 2)
@@ -5329,7 +5337,7 @@ void pc_heal(struct map_session_data *sd,unsigned int hp,unsigned int sp, int ty
*/
int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp)
{
- int bonus, type;
+ int i, bonus;
if(hp) {
bonus = 100 + (sd->battle_status.vit<<1)
@@ -5337,8 +5345,16 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp)
+ pc_checkskill(sd,AM_LEARNINGPOTION)*5;
// A potion produced by an Alchemist in the Fame Top 10 gets +50% effect [DracoRPG]
bonus += (potion_flag==2)?50:(potion_flag==3?100:0);
- if ((type = itemdb_group(itemid)) > 0 && type < MAX_ITEMGROUP && sd->itemhealrate[type])
- bonus += bonus * sd->itemhealrate[type] / 100;
+ //Item Group bonuses
+ bonus += bonus*itemdb_group_bonus(sd, itemid)/100;
+ //Individual item bonuses.
+ for(i = 0; i < MAX_PC_BONUS && sd->itemhealrate[i].nameid; i++)
+ {
+ if (sd->itemhealrate[i].nameid == itemid) {
+ bonus += bonus*sd->itemhealrate[i].rate/100;
+ break;
+ }
+ }
if(bonus!=100)
hp = hp * bonus / 100;
}
diff --git a/src/map/status.c b/src/map/status.c
index 8b2942add..5ecb9a93b 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -1539,7 +1539,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
+ sizeof(sd->magic_addsize)
+ sizeof(sd->critaddrace)
+ sizeof(sd->expaddrace)
- + sizeof(sd->itemhealrate)
+ + sizeof(sd->itemgrouphealrate)
+ sizeof(sd->sp_gain_race)
);
@@ -1578,6 +1578,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
+ sizeof(sd->add_dmg)
+ sizeof(sd->add_mdmg)
+ sizeof(sd->add_drop)
+ + sizeof(sd->itemhealrate)
);
// vars zeroing. ints, shorts, chars. in that order.