diff options
author | panikon <panikon@zoho.com> | 2014-07-11 19:16:47 -0300 |
---|---|---|
committer | panikon <panikon@zoho.com> | 2014-07-11 19:16:47 -0300 |
commit | da4f06859fd49393ddd82c07a0586a20cb5ad4f6 (patch) | |
tree | 90c2b0052c5eaa49e5f1ef41b13ad25d555eaae1 | |
parent | 901a8c9cdf891fb65e160094e52346b2aa4e9754 (diff) | |
download | hercules-da4f06859fd49393ddd82c07a0586a20cb5ad4f6.tar.gz hercules-da4f06859fd49393ddd82c07a0586a20cb5ad4f6.tar.bz2 hercules-da4f06859fd49393ddd82c07a0586a20cb5ad4f6.tar.xz hercules-da4f06859fd49393ddd82c07a0586a20cb5ad4f6.zip |
Fixed issue with quest exp and bonuses, issue: 8247 http://hercules.ws/board/index.php?app=tracker&showissue=8247
Corrected *getexp documentation
Documented and changed pc_gainexp type
-rw-r--r-- | doc/script_commands.txt | 10 | ||||
-rw-r--r-- | src/map/pc.c | 27 | ||||
-rw-r--r-- | src/map/pc.h | 2 | ||||
-rw-r--r-- | src/map/script.c | 2 |
4 files changed, 22 insertions, 19 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index f83b6a278..d2a3d80eb 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -4383,14 +4383,14 @@ they will also have their skills reset upon 'changesex'. *getexp <base xp>,<job xp>; This command will give the invoking character a specified number of base -and job experience points. Can be used as a quest reward. Negative values +and job experience points. Should be used as a quest reward. Negative values won't work. +Is subject to EXP bonuses and to the `quest_exp_rate` config option. getexp 10000,5000; -You can also assign directly to the constants defined in 'db/const.txt': +You can also assign directly to the parameters defined in 'db/const.txt': - // These 2 combined has the same effect as the above command BaseExp += 10000; JobExp += 5000; @@ -4398,9 +4398,7 @@ You can also reduce the amount of experience points: BaseExp -= 10000; -Note that 'getexp' is now subject to the 'quest_exp_rate' config option, -which adjusts the gained value. If you want to bypass this, use the 'set' -method. +When setting the parameters directly no bonuses or config options are applied. --------------------------------------- diff --git a/src/map/pc.c b/src/map/pc.c index 1ab9b0e2e..c23e510d6 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5943,9 +5943,9 @@ int pc_checkjoblevelup(struct map_session_data *sd) return 1; } -/*========================================== - * Alters experienced based on self bonuses that do not get even shared to the party. - *------------------------------------------*/ +/** + * Alters EXP based on self bonuses that do not get shared with the party + **/ void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsigned int *job_exp, struct block_list *src) { int bonus = 0; struct status_data *st = status->get_status_data(src); @@ -5976,19 +5976,23 @@ void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsigned in return; } -/*========================================== - * Give x exp at sd player and calculate remaining exp for next lvl - *------------------------------------------*/ -int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int base_exp,unsigned int job_exp,bool is_quest) { + +/** + * Gives a determined EXP amount to sd and calculates remaining EXP for next level + * @param src if is NULL no bonuses are taken into account + * @param is_quest Used to let client know that the EXP was from a quest (clif->displayexp) PACKETVER >= 20091027 + * @retval true success + **/ +bool pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int base_exp,unsigned int job_exp,bool is_quest) { float nextbp=0, nextjp=0; unsigned int nextb=0, nextj=0; nullpo_ret(sd); if(sd->bl.prev == NULL || pc_isdead(sd)) - return 0; + return false; if(!battle_config.pvp_exp && map->list[sd->bl.m].flag.pvp) // [MouseJstr] - return 0; // no exp on pvp maps + return false; // no exp on pvp maps if(sd->status.guild_id>0) base_exp-=guild->payexp(sd,base_exp); @@ -6020,7 +6024,8 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int } } - //Cap exp to the level up requirement of the previous level when you are at max level, otherwise cap at UINT_MAX (this is required for some S. Novice bonuses). [Skotlex] + // Cap exp to the level up requirement of the previous level when you are at max level, + // otherwise cap at UINT_MAX (this is required for some S. Novice bonuses). [Skotlex] if (base_exp) { nextb = nextb?UINT_MAX:pc->thisbaseexp(sd); if(sd->status.base_exp > nextb - base_exp) @@ -6055,7 +6060,7 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int clif_disp_onlyself(sd,output,strlen(output)); } - return 1; + return true; } /*========================================== diff --git a/src/map/pc.h b/src/map/pc.h index fb2d3dbb1..fcd6f39d0 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -858,7 +858,7 @@ struct pc_interface { unsigned int (*maxjoblv) (struct map_session_data *sd); int (*checkbaselevelup) (struct map_session_data *sd); int (*checkjoblevelup) (struct map_session_data *sd); - int (*gainexp) (struct map_session_data *sd, struct block_list *src, unsigned int base_exp, unsigned int job_exp, bool is_quest); + bool (*gainexp) (struct map_session_data *sd, struct block_list *src, unsigned int base_exp, unsigned int job_exp, bool is_quest); unsigned int (*nextbaseexp) (struct map_session_data *sd); unsigned int (*thisbaseexp) (struct map_session_data *sd); unsigned int (*nextjobexp) (struct map_session_data *sd); diff --git a/src/map/script.c b/src/map/script.c index 8fb3975f8..9fe746c8c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8966,7 +8966,7 @@ BUILDIN(getexp) base = (int) cap_value(base * bonus, 0, INT_MAX); job = (int) cap_value(job * bonus, 0, INT_MAX); - pc->gainexp(sd, NULL, base, job, true); + pc->gainexp(sd, &sd->bl, base, job, true); return true; } |