diff options
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 0aad00a56..78b773550 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -399,7 +399,7 @@ static int pc_banding(struct map_session_data *sd, uint16 skill_lv) for( j = 0; j < i; j++ ) { bsd = map->id2sd(b_sd[j]); if( bsd != NULL ) { - status->set_hp(&bsd->bl,hp,0); // Set hp + status->set_hp(&bsd->bl, hp, STATUS_HEAL_DEFAULT); // Set hp if( (sc = status->get_sc(&bsd->bl)) != NULL && sc->data[SC_BANDING] ) { sc->data[SC_BANDING]->val2 = c; // Set the counter. It doesn't count your self. status_calc_bl(&bsd->bl, status->sc2scb_flag(SC_BANDING)); // Set atk and def. @@ -523,10 +523,9 @@ static int pc_setrestartvalue(struct map_session_data *sd, int type) if (type&1) { //Normal resurrection - st->hp = 1; //Otherwise status->heal may fail if dead. - status->heal(&sd->bl, bst->hp, 0, 1); + status->heal(&sd->bl, bst->hp, 0, STATUS_HEAL_FORCED | STATUS_HEAL_ALLOWREVIVE); if( st->sp < bst->sp ) - status->set_sp(&sd->bl, bst->sp, 1); + status->set_sp(&sd->bl, bst->sp, STATUS_HEAL_FORCED); } else { //Just for saving on the char-server (with values as if respawned) sd->status.hp = bst->hp; sd->status.sp = (st->sp < bst->sp) ? bst->sp : st->sp; @@ -1459,7 +1458,7 @@ static int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_li return 0; //Wrong size } sd->hate_mob[pos] = class_; - pc_setglobalreg(sd,script->add_str(pc->sg_info[pos].hate_var),class_+1); + pc_setglobalreg(sd,script->add_variable(pc->sg_info[pos].hate_var),class_+1); clif->hate_info(sd, pos, class_, 1); return 1; } @@ -1473,27 +1472,28 @@ static int pc_reg_received(struct map_session_data *sd) nullpo_ret(sd); sd->vars_ok = true; - sd->change_level_2nd = pc_readglobalreg(sd,script->add_str("jobchange_level")); - sd->change_level_3rd = pc_readglobalreg(sd,script->add_str("jobchange_level_3rd")); - sd->die_counter = pc_readglobalreg(sd,script->add_str("PC_DIE_COUNTER")); + + sd->change_level_2nd = pc_readglobalreg(sd,script->add_variable("jobchange_level")); + sd->change_level_3rd = pc_readglobalreg(sd,script->add_variable("jobchange_level_3rd")); + sd->die_counter = pc_readglobalreg(sd,script->add_variable("PC_DIE_COUNTER")); // Cash shop - sd->cashPoints = pc_readaccountreg(sd,script->add_str("#CASHPOINTS")); - sd->kafraPoints = pc_readaccountreg(sd,script->add_str("#KAFRAPOINTS")); + sd->cashPoints = pc_readaccountreg(sd,script->add_variable("#CASHPOINTS")); + sd->kafraPoints = pc_readaccountreg(sd,script->add_variable("#KAFRAPOINTS")); // Cooking Exp - sd->cook_mastery = pc_readglobalreg(sd,script->add_str("COOK_MASTERY")); + sd->cook_mastery = pc_readglobalreg(sd,script->add_variable("COOK_MASTERY")); if ((sd->job & MAPID_BASEMASK) == MAPID_TAEKWON) { // Better check for class rather than skill to prevent "skill resets" from unsetting this - sd->mission_mobid = pc_readglobalreg(sd,script->add_str("TK_MISSION_ID")); - sd->mission_count = pc_readglobalreg(sd,script->add_str("TK_MISSION_COUNT")); + sd->mission_mobid = pc_readglobalreg(sd,script->add_variable("TK_MISSION_ID")); + sd->mission_count = pc_readglobalreg(sd,script->add_variable("TK_MISSION_COUNT")); } //SG map and mob read [Komurka] for (i = 0; i < MAX_PC_FEELHATE; i++) { //for now - someone need to make reading from txt/sql - int j = pc_readglobalreg(sd,script->add_str(pc->sg_info[i].feel_var)); + int j = pc_readglobalreg(sd,script->add_variable(pc->sg_info[i].feel_var)); if (j != 0) { sd->feel_map[i].index = j; sd->feel_map[i].m = map->mapindex2mapid(j); @@ -1501,24 +1501,24 @@ static int pc_reg_received(struct map_session_data *sd) sd->feel_map[i].index = 0; sd->feel_map[i].m = -1; } - sd->hate_mob[i] = pc_readglobalreg(sd,script->add_str(pc->sg_info[i].hate_var))-1; + sd->hate_mob[i] = pc_readglobalreg(sd,script->add_variable(pc->sg_info[i].hate_var))-1; } if ((i = pc->checkskill(sd,RG_PLAGIARISM)) > 0) { - sd->cloneskill_id = pc_readglobalreg(sd,script->add_str("CLONE_SKILL")); + sd->cloneskill_id = pc_readglobalreg(sd,script->add_variable("CLONE_SKILL")); if (sd->cloneskill_id > 0 && (idx = skill->get_index(sd->cloneskill_id)) > 0) { sd->status.skill[idx].id = sd->cloneskill_id; - sd->status.skill[idx].lv = pc_readglobalreg(sd,script->add_str("CLONE_SKILL_LV")); + sd->status.skill[idx].lv = pc_readglobalreg(sd,script->add_variable("CLONE_SKILL_LV")); if (sd->status.skill[idx].lv > i) sd->status.skill[idx].lv = i; sd->status.skill[idx].flag = SKILL_FLAG_PLAGIARIZED; } } if ((i = pc->checkskill(sd,SC_REPRODUCE)) > 0) { - sd->reproduceskill_id = pc_readglobalreg(sd,script->add_str("REPRODUCE_SKILL")); + sd->reproduceskill_id = pc_readglobalreg(sd,script->add_variable("REPRODUCE_SKILL")); if( sd->reproduceskill_id > 0 && (idx = skill->get_index(sd->reproduceskill_id)) > 0) { sd->status.skill[idx].id = sd->reproduceskill_id; - sd->status.skill[idx].lv = pc_readglobalreg(sd,script->add_str("REPRODUCE_SKILL_LV")); + sd->status.skill[idx].lv = pc_readglobalreg(sd,script->add_variable("REPRODUCE_SKILL_LV")); if( i < sd->status.skill[idx].lv) sd->status.skill[idx].lv = i; sd->status.skill[idx].flag = SKILL_FLAG_PLAGIARIZED; @@ -1964,7 +1964,7 @@ static int pc_calc_skilltree_normalize_job(struct map_session_data *sd) } - pc_setglobalreg(sd, script->add_str("jobchange_level"), sd->change_level_2nd); + pc_setglobalreg(sd, script->add_variable("jobchange_level"), sd->change_level_2nd); } if (skill_point < novice_skills + (sd->change_level_2nd - 1)) { @@ -1977,7 +1977,7 @@ static int pc_calc_skilltree_normalize_job(struct map_session_data *sd) - (sd->status.job_level - 1) - (sd->change_level_2nd - 1) - novice_skills; - pc_setglobalreg(sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); + pc_setglobalreg(sd, script->add_variable("jobchange_level_3rd"), sd->change_level_3rd); } if (skill_point < novice_skills + (sd->change_level_2nd - 1) + (sd->change_level_3rd - 1)) { @@ -2074,7 +2074,7 @@ static int pc_disguise(struct map_session_data *sd, int class) clif->spawn(&sd->bl); if (class == sd->status.class && pc_iscarton(sd)) { //It seems the cart info is lost on undisguise. - clif->cartlist(sd); + clif->cartList(sd); clif->updatestatus(sd,SP_CARTINFO); } if (sd->chat_id != 0) { @@ -4401,8 +4401,6 @@ static int pc_insert_card(struct map_session_data *sd, int idx_card, int idx_equ static int pc_modifybuyvalue(struct map_session_data *sd, int orig_value) { int skill_lv, rate1 = 0, rate2 = 0; - if (orig_value <= 0) - return 0; if ((skill_lv=pc->checkskill(sd,MC_DISCOUNT)) > 0) // merchant discount rate1 = 5+skill_lv*2-((skill_lv==10)? 1:0); if ((skill_lv=pc->checkskill(sd,RG_COMPULSION)) > 0) // rogue discount @@ -4411,8 +4409,9 @@ static int pc_modifybuyvalue(struct map_session_data *sd, int orig_value) rate1 = rate2; if (rate1 != 0) orig_value = apply_percentrate(orig_value, 100-rate1, 100); - if (orig_value < 1) - orig_value = 1; + + if (orig_value < battle_config.min_item_buy_price) + orig_value = battle_config.min_item_buy_price; return orig_value; } @@ -4422,14 +4421,13 @@ static int pc_modifybuyvalue(struct map_session_data *sd, int orig_value) static int pc_modifysellvalue(struct map_session_data *sd, int orig_value) { int skill_lv, rate = 0; - if (orig_value <= 0) - return 0; if ((skill_lv=pc->checkskill(sd,MC_OVERCHARGE)) > 0) //OverCharge rate = 5+skill_lv*2-((skill_lv==10)? 1:0); if (rate != 0) orig_value = apply_percentrate(orig_value, 100+rate, 100); - if (orig_value < 1) - orig_value = 1; + + if (orig_value < battle_config.min_item_sell_price) + orig_value = battle_config.min_item_sell_price; return orig_value; } @@ -4505,14 +4503,15 @@ static int pc_payzeny(struct map_session_data *sd, int zeny, enum e_log_pick_typ sd->status.zeny -= zeny; clif->updatestatus(sd,SP_ZENY); - achievement->validate_zeny(sd, -zeny); // Achievements [Smokexyz/Hercules] + if (zeny > 0) { + achievement->validate_zeny(sd, -zeny); // Achievements [Smokexyz/Hercules] + logs->zeny(sd, type, tsd ? tsd : sd, -zeny); - if(!tsd) tsd = sd; - logs->zeny(sd, type, tsd, -zeny); - if( zeny > 0 && sd->state.showzeny ) { - char output[255]; - sprintf(output, "Removed %dz.", zeny); - clif_disp_onlyself(sd, output); + if (sd->state.showzeny) { + char output[255]; + sprintf(output, "Removed %dz.", zeny); + clif_disp_onlyself(sd, output); + } } return 0; @@ -4523,7 +4522,7 @@ static int pc_payzeny(struct map_session_data *sd, int zeny, enum e_log_pick_typ * * @param price Price of the item. * @param points Provided kafra points. - * + * * @return points Leftover kafra points. */ //Changed Kafrapoints calculation. [Normynator] @@ -4555,15 +4554,15 @@ static int pc_paycash(struct map_session_data *sd, int price, int points) return -1; } - pc_setaccountreg(sd, script->add_str("#CASHPOINTS"), sd->cashPoints - cash); - pc_setaccountreg(sd, script->add_str("#KAFRAPOINTS"), sd->kafraPoints - mempoints); + pc_setaccountreg(sd, script->add_variable("#CASHPOINTS"), sd->cashPoints - cash); + pc_setaccountreg(sd, script->add_variable("#KAFRAPOINTS"), sd->kafraPoints - mempoints); if (battle_config.cashshop_show_points) { char output[128]; sprintf(output, msg_sd(sd,504), points, cash, sd->kafraPoints, sd->cashPoints); clif_disp_onlyself(sd, output); } - + return points; } @@ -4582,7 +4581,7 @@ static int pc_getcash(struct map_session_data *sd, int cash, int points) cash = MAX_ZENY-sd->cashPoints; } - pc_setaccountreg(sd, script->add_str("#CASHPOINTS"), sd->cashPoints+cash); + pc_setaccountreg(sd, script->add_variable("#CASHPOINTS"), sd->cashPoints+cash); if( battle_config.cashshop_show_points ) { @@ -4605,7 +4604,7 @@ static int pc_getcash(struct map_session_data *sd, int cash, int points) points = MAX_ZENY-sd->kafraPoints; } - pc_setaccountreg(sd, script->add_str("#KAFRAPOINTS"), sd->kafraPoints+points); + pc_setaccountreg(sd, script->add_variable("#KAFRAPOINTS"), sd->kafraPoints+points); if( battle_config.cashshop_show_points ) { @@ -4643,14 +4642,15 @@ static int pc_getzeny(struct map_session_data *sd, int zeny, enum e_log_pick_typ sd->status.zeny += zeny; clif->updatestatus(sd,SP_ZENY); - achievement->validate_zeny(sd, zeny); // Achievements [Smokexyz/Hercules] + if (zeny > 0) { + achievement->validate_zeny(sd, zeny); // Achievements [Smokexyz/Hercules] + logs->zeny(sd, type, tsd ? tsd : sd, zeny); - if(!tsd) tsd = sd; - logs->zeny(sd, type, tsd, zeny); - if( zeny > 0 && sd->state.showzeny ) { - char output[255]; - sprintf(output, "Gained %dz.", zeny); - clif_disp_onlyself(sd, output); + if (sd->state.showzeny) { + char output[255]; + sprintf(output, "Gained %dz.", zeny); + clif_disp_onlyself(sd, output); + } } return 0; @@ -4688,7 +4688,7 @@ static int pc_search_inventory(struct map_session_data *sd, int item_id) * 6 = ? * 7 = stack limitation *------------------------------------------*/ -static int pc_additem(struct map_session_data *sd, struct item *item_data, int amount, e_log_pick_type log_type) +static int pc_additem(struct map_session_data *sd, const struct item *item_data, int amount, e_log_pick_type log_type) { struct item_data *data; int i; @@ -5789,7 +5789,7 @@ static int pc_setpos(struct map_session_data *sd, unsigned short map_index, int for (i = 0; i < VECTOR_LENGTH(sd->script_queues); i++) { struct script_queue *queue = script->queue(VECTOR_INDEX(sd->script_queues, i)); if (queue && queue->event_mapchange[0] != '\0') { - pc->setregstr(sd, script->add_str("@Queue_Destination_Map$"), map->list[m].name); + pc->setregstr(sd, script->add_variable("@Queue_Destination_Map$"), map->list[m].name); npc->event(sd, queue->event_mapchange, 0); } } @@ -7220,7 +7220,7 @@ static uint64 pc_thisjobexp(const struct map_session_data *sd) const struct class_exp_group *exp_group = NULL; nullpo_ret(sd); - + if (sd->status.job_level > pc->maxjoblv(sd) || sd->status.job_level <= 1) return 0; @@ -7696,7 +7696,7 @@ static int pc_resetstate(struct map_session_data *sd) if( sd->mission_mobid ) { //bugreport:2200 sd->mission_mobid = 0; sd->mission_count = 0; - pc_setglobalreg(sd,script->add_str("TK_MISSION_ID"), 0); + pc_setglobalreg(sd,script->add_variable("TK_MISSION_ID"), 0); } status_calc_pc(sd,SCO_NONE); @@ -7856,7 +7856,7 @@ static int pc_resetfeel(struct map_session_data *sd) { sd->feel_map[i].m = -1; sd->feel_map[i].index = 0; - pc_setglobalreg(sd,script->add_str(pc->sg_info[i].feel_var),0); + pc_setglobalreg(sd,script->add_variable(pc->sg_info[i].feel_var),0); } return 0; @@ -7869,7 +7869,7 @@ static int pc_resethate(struct map_session_data *sd) for (i = 0; i < MAX_PC_FEELHATE; i++) { sd->hate_mob[i] = -1; - pc_setglobalreg(sd,script->add_str(pc->sg_info[i].hate_var),0); + pc_setglobalreg(sd,script->add_variable(pc->sg_info[i].hate_var),0); } return 0; } @@ -8059,7 +8059,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) if (sd->npc_id && sd->st && sd->st->state != RUN) npc->event_dequeue(sd); - pc_setglobalreg(sd,script->add_str("PC_DIE_COUNTER"),sd->die_counter+1); + pc_setglobalreg(sd,script->add_variable("PC_DIE_COUNTER"),sd->die_counter+1); pc->setparam(sd, SP_KILLERRID, src?src->id:0); if( sd->bg_id ) {/* TODO: purge when bgqueue is deemed ok */ @@ -8826,7 +8826,7 @@ static int pc_itemheal(struct map_session_data *sd, int itemid, int hp, int sp) } } - return status->heal(&sd->bl, hp, sp, 1); + return status->heal(&sd->bl, hp, sp, STATUS_HEAL_FORCED); } /*========================================== @@ -8920,11 +8920,11 @@ static int pc_jobchange(struct map_session_data *sd, int class, int upper) if ((job & JOBL_2) != 0 && (sd->job & JOBL_2) == 0 && (job & MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) { // changing from 1st to 2nd job sd->change_level_2nd = sd->status.job_level; - pc_setglobalreg(sd, script->add_str("jobchange_level"), sd->change_level_2nd); + pc_setglobalreg(sd, script->add_variable("jobchange_level"), sd->change_level_2nd); } else if((job & JOBL_THIRD) != 0 && (sd->job & JOBL_THIRD) == 0) { // changing from 2nd to 3rd job sd->change_level_3rd = sd->status.job_level; - pc_setglobalreg(sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); + pc_setglobalreg(sd, script->add_variable("jobchange_level_3rd"), sd->change_level_3rd); } if(sd->cloneskill_id) { @@ -8936,8 +8936,8 @@ static int pc_jobchange(struct map_session_data *sd, int class, int upper) clif->deleteskill(sd,sd->cloneskill_id); } sd->cloneskill_id = 0; - pc_setglobalreg(sd, script->add_str("CLONE_SKILL"), 0); - pc_setglobalreg(sd, script->add_str("CLONE_SKILL_LV"), 0); + pc_setglobalreg(sd, script->add_variable("CLONE_SKILL"), 0); + pc_setglobalreg(sd, script->add_variable("CLONE_SKILL_LV"), 0); } if(sd->reproduceskill_id) { @@ -8949,8 +8949,8 @@ static int pc_jobchange(struct map_session_data *sd, int class, int upper) clif->deleteskill(sd,sd->reproduceskill_id); } sd->reproduceskill_id = 0; - pc_setglobalreg(sd, script->add_str("REPRODUCE_SKILL"),0); - pc_setglobalreg(sd, script->add_str("REPRODUCE_SKILL_LV"),0); + pc_setglobalreg(sd, script->add_variable("REPRODUCE_SKILL"),0); + pc_setglobalreg(sd, script->add_variable("REPRODUCE_SKILL_LV"),0); } if ((job & MAPID_UPPERMASK) != (sd->job & MAPID_UPPERMASK)) { //Things to remove when changing class tree. @@ -9197,7 +9197,7 @@ static int pc_setoption(struct map_session_data *sd, int type) #ifndef NEW_CARTS if( type&OPTION_CART && !( p_type&OPTION_CART ) ) { //Cart On - clif->cartlist(sd); + clif->cartList(sd); clif->updatestatus(sd, SP_CARTINFO); if(pc->checkskill(sd, MC_PUSHCART) < 10) status_calc_pc(sd,SCO_NONE); //Apply speed penalty. @@ -9304,7 +9304,7 @@ static int pc_setcart(struct map_session_data *sd, int type) break; default:/* everything else is an allowed ID so we can move on */ if( !sd->sc.data[SC_PUSH_CART] ) /* first time, so fill cart data */ - clif->cartlist(sd); + clif->cartList(sd); clif->updatestatus(sd, SP_CARTINFO); sc_start(NULL,&sd->bl, SC_PUSH_CART, 100, type, 0); clif->sc_load(&sd->bl, sd->bl.id, AREA, SI_ON_PUSH_CART, type, 0, 0); @@ -10877,7 +10877,7 @@ static void pc_regen(struct map_session_data *sd, unsigned int diff_tick) } if (hp > 0 || sp > 0) - status->heal(&sd->bl, hp, sp, 0); + status->heal(&sd->bl, hp, sp, STATUS_HEAL_DEFAULT); return; } |