diff options
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 0dbc8c076..551fa9c55 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -792,6 +792,10 @@ int pc_reg_received(struct map_session_data *sd) sd->change_level = pc_readglobalreg(sd,"jobchange_level"); sd->die_counter = pc_readglobalreg(sd,"PC_DIE_COUNTER"); + // Cash shop + sd->cashPoints = pc_readaccountreg(sd,"#CASHPOINTS"); + sd->kafraPoints = pc_readaccountreg(sd,"#KAFRAPOINTS"); + if ((sd->class_&MAPID_BASEMASK)==MAPID_TAEKWON) { //Better check for class rather than skill to prevent "skill resets" from unsetting this sd->mission_mobid = pc_readglobalreg(sd,"TK_MISSION_ID"); @@ -2694,6 +2698,65 @@ int pc_payzeny(struct map_session_data *sd,int zeny) return 0; } +/*========================================== + * Cash Shop + *------------------------------------------*/ + +void pc_paycash(struct map_session_data *sd, int prize, int points) +{ + char output[128]; + int cash = prize - points; + nullpo_retv(sd); + + sd->cashPoints -= cash; + sd->kafraPoints -= points; + + pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints); + pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints); + + if( points ) + { + sprintf(output, "Used %d kafra points. %d points remaining.", points, sd->kafraPoints); + clif_disp_onlyself(sd, output, strlen(output)); + } + + if( cash ) + { + sprintf(output, "Used %d cash points. %d points remaining.", cash, sd->cashPoints); + clif_disp_onlyself(sd, output, strlen(output)); + } +} + +void pc_getcash(struct map_session_data *sd, int cash, int points) +{ + char output[128]; + nullpo_retv(sd); + + if( cash > MAX_ZENY - sd->cashPoints ) + cash = MAX_ZENY - sd->cashPoints; + + sd->cashPoints += cash; + + if( points > MAX_ZENY - sd->kafraPoints ) + points = MAX_ZENY - sd->kafraPoints; + + sd->kafraPoints += points; + + pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints); + pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints); + + if( cash > 0 ) + { + sprintf(output, "Gained %d cash points. Total %d points", points, sd->cashPoints); + clif_disp_onlyself(sd, output, strlen(output)); + } + + if( points > 0 ) + { + sprintf(output, "Gained %d kafra points. Total %d points", points, sd->kafraPoints); + clif_disp_onlyself(sd, output, strlen(output)); + } +} /*========================================== * お金を得る |