Skip to content

Commit

Permalink
Follow up d2bbd91
Browse files Browse the repository at this point in the history
* Clean up `party_exp_share` for Renewal.
* Updated `party_exp_share` source doc.

Signed-off-by: Cydh Ramdh <cydh@pservero.com>
  • Loading branch information
cydh committed Jun 23, 2016
1 parent d2bbd91 commit 6412c82
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
53 changes: 26 additions & 27 deletions src/map/party.c
Expand Up @@ -1020,16 +1020,26 @@ int party_send_xy_clear(struct party_data *p)
return 0;
}

// exp share and added zeny share [Valaris]
int party_exp_share(struct party_data* p, struct block_list* src, unsigned int base_exp, unsigned int job_exp, int zeny)
/** Party EXP and Zeny sharing
* @param p Party data
* @param src EXP source (for renewal level penalty)
* @param base_exp Base EXP gained from killed mob
* @param job_exp Job EXP gained from killed mob
* @param zeny Zeny gained from killed mob
* @author Valaris
**/
void party_exp_share(struct party_data* p, struct block_list* src, unsigned int base_exp, unsigned int job_exp, int zeny)
{
struct map_session_data* sd[MAX_PARTY];
unsigned int i, c;
#ifdef RENEWAL_EXP
uint32 base_exp_bonus, job_exp_bonus;
#ifdef RENEWAL

This comment has been minimized.

Copy link
@secretdataz

secretdataz Jun 23, 2016

Member

Why RENEWAL instead of RENEWAL_EXP?

This comment has been minimized.

Copy link
@cydh

cydh via email Jun 23, 2016

Author Contributor
TBL_MOB *md = BL_CAST(BL_MOB, src);

if (!md)
return;
#endif

nullpo_ret(p);
nullpo_retv(p);

// count the number of players eligible for exp sharing
for (i = c = 0; i < MAX_PARTY; i++) {
Expand All @@ -1038,7 +1048,7 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b
c++;
}
if (c < 1)
return 0;
return;

base_exp/=c;
job_exp/=c;
Expand All @@ -1055,37 +1065,26 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b
zeny = (unsigned int) cap_value(zeny * bonus/100, INT_MIN, INT_MAX);
}

#ifdef RENEWAL_EXP
base_exp_bonus = base_exp;
job_exp_bonus = job_exp;
#endif

for (i = 0; i < c; i++) {
#ifdef RENEWAL_EXP
if( (base_exp_bonus || job_exp_bonus) && !(src && src->type == BL_MOB && ((TBL_MOB*)src)->db->mexp) ) {
TBL_MOB *md = BL_CAST(BL_MOB, src);
int rate = 0;

if (!md)
return 0;

rate = pc_level_penalty_mod(md->db->lv - sd[i]->status.base_level, md->db->status.class_, md->db->status.mode, 1);
uint32 base_gained = base_exp, job_gained = job_exp;
if (base_exp || job_exp) {
int rate = pc_level_penalty_mod(md->level - sd[i]->status.base_level, md->db->status.class_, md->db->status.mode, 1);
if (rate != 100) {
if (base_exp_bonus)
base_exp = (unsigned int)cap_value(base_exp_bonus * rate / 100, 1, UINT_MAX);
if (job_exp_bonus)
job_exp = (unsigned int)cap_value(job_exp_bonus * rate / 100, 1, UINT_MAX);
if (base_exp)
base_gained = (unsigned int)cap_value(apply_rate(base_exp, rate), 1, UINT_MAX);
if (job_exp)
job_gained = (unsigned int)cap_value(apply_rate(job_exp, rate), 1, UINT_MAX);
}
}
#endif

pc_gainexp(sd[i], src, base_gained, job_gained, 0);
#else
pc_gainexp(sd[i], src, base_exp, job_exp, 0);
#endif

if (zeny) // zeny from mobs [Valaris]
pc_getzeny(sd[i],zeny,LOG_TYPE_PICKDROP_MONSTER,NULL);
}

return 0;
}

//Does party loot. first_charid holds the charid of the player who has time priority to take the item.
Expand Down
2 changes: 1 addition & 1 deletion src/map/party.h
Expand Up @@ -83,7 +83,7 @@ int party_send_message(struct map_session_data *sd,const char *mes,int len);
int party_recv_message(int party_id,uint32 account_id,const char *mes,int len);
int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id, uint16 skill_lv);
int party_send_xy_clear(struct party_data *p);
int party_exp_share(struct party_data *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny);
void party_exp_share(struct party_data *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny);
int party_share_loot(struct party_data* p, struct map_session_data* sd, struct item* item, int first_charid);
int party_send_dot_remove(struct map_session_data *sd);
int party_sub_count(struct block_list *bl, va_list ap);
Expand Down

0 comments on commit 6412c82

Please sign in to comment.