diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 37 | ||||
-rw-r--r-- | src/map/map.c | 8 | ||||
-rw-r--r-- | src/map/mob.c | 9 | ||||
-rw-r--r-- | src/map/pc.c | 80 | ||||
-rw-r--r-- | src/map/pc.h | 2 | ||||
-rw-r--r-- | src/map/pet.c | 20 | ||||
-rw-r--r-- | src/map/skill.c | 4 | ||||
-rw-r--r-- | src/map/status.c | 4 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.Defs.inc | 4 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 8 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 2 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 52 |
12 files changed, 179 insertions, 51 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 91ddc3ef9..00073e544 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -962,39 +962,10 @@ ACMD(option) *------------------------------------------*/ ACMD(hide) { - if (pc_isinvisible(sd)) { - sd->sc.option &= ~OPTION_INVISIBLE; - if (sd->disguise != -1 ) - status->set_viewdata(&sd->bl, sd->disguise); - else - status->set_viewdata(&sd->bl, sd->status.class); - clif->message(fd, msg_fd(fd,10)); // Invisible: Off - - // increment the number of pvp players on the map - map->list[sd->bl.m].users_pvp++; - - if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank ) { - // register the player for ranking calculations - sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 ); - } - //bugreport:2266 - map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); - } else { - clif->clearunit_area(&sd->bl, CLR_OUTSIGHT); - sd->sc.option |= OPTION_INVISIBLE; - sd->vd.class = INVISIBLE_CLASS; - clif->message(fd, msg_fd(fd,11)); // Invisible: On - - // decrement the number of pvp players on the map - map->list[sd->bl.m].users_pvp--; - - if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) { - // unregister the player for ranking - timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); - sd->pvp_timer = INVALID_TIMER; - } - } - clif->changeoption(&sd->bl); + if (pc_isinvisible(sd)) + pc->unhide(sd, true); + else + pc->hide(sd, true); return true; } diff --git a/src/map/map.c b/src/map/map.c index b2c9c77c3..40e66e4df 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1713,9 +1713,9 @@ static bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, tx = *x + dx; ty = *y + dy; if (unit_is_dir_or_opposite(dir, UNIT_DIR_SOUTHWEST)) - tx *= costrange / MOVE_COST; + tx = tx * costrange / MOVE_COST; if (unit_is_dir_or_opposite(dir, UNIT_DIR_NORTHWEST)) - ty *= costrange / MOVE_COST; + ty = ty * costrange / MOVE_COST; if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) { *x = tx; *y = ty; @@ -1724,9 +1724,9 @@ static bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, tx = *x + dx; ty = *y + dy; if (unit_is_dir_or_opposite(dir, UNIT_DIR_NORTHWEST)) - tx *= costrange / MOVE_COST; + tx = tx * costrange / MOVE_COST; if (unit_is_dir_or_opposite(dir, UNIT_DIR_SOUTHWEST)) - ty *= costrange / MOVE_COST; + ty = ty * costrange / MOVE_COST; if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) { *x = tx; *y = ty; diff --git a/src/map/mob.c b/src/map/mob.c index 347c42439..dcbdccedd 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -447,6 +447,9 @@ static bool mob_ksprotected(struct block_list *src, struct block_list *target) if( !battle_config.ksprotection ) return false; // KS Protection Disabled + if (status->isdead(target) != 0) + return false; // Target is dead. + if( !(md = BL_CAST(BL_MOB,target)) ) return false; // Target is not MOB @@ -3980,8 +3983,8 @@ static int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 } } - mob_skills[i].permillage *= battle_config.mob_skill_rate / 100; - mob_skills[i].delay *= battle_config.mob_skill_delay / 100; + mob_skills[i].permillage = mob_skills[i].permillage * battle_config.mob_skill_rate / 100; + mob_skills[i].delay = mob_skills[i].delay * battle_config.mob_skill_delay / 100; db->maxskill = ++i; } @@ -5085,12 +5088,10 @@ static int mob_read_db_sub(struct config_setting_t *mobt, int n, const char *sou md.status.def_ele = i32; md.status.ele_lv = value; } else if (!inherit) { - ShowWarning("mob_read_db_sub: Missing element for monster ID %d.\n", md.mob_id); md.status.def_ele = ELE_NEUTRAL; md.status.ele_lv = 1; } } else if (!inherit) { - ShowWarning("mob_read_db_sub: Missing element for monster ID %d.\n", md.mob_id); md.status.def_ele = ELE_NEUTRAL; md.status.ele_lv = 1; } diff --git a/src/map/pc.c b/src/map/pc.c index 90282209b..a8ed4430e 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8325,7 +8325,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) base_penalty *= 2; if (sd->status.mod_death != 100) - base_penalty *= sd->status.mod_death / 100; + base_penalty = base_penalty * sd->status.mod_death / 100; sd->status.base_exp -= min(sd->status.base_exp, base_penalty); clif->updatestatus(sd, SP_BASEEXP); @@ -8350,7 +8350,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) job_penalty *= 2; if (sd->status.mod_death != 100) - job_penalty *= sd->status.mod_death / 100; + job_penalty = job_penalty * sd->status.mod_death / 100; sd->status.job_exp -= min(sd->status.job_exp, job_penalty); clif->updatestatus(sd, SP_JOBEXP); @@ -9288,6 +9288,72 @@ static int pc_changelook(struct map_session_data *sd, int type, int val) return 0; } +/** + * Hides a character. + * + * @param sd The character to hide. + * @param show_msg Whether to show message to the character or not. + * + **/ +static void pc_hide(struct map_session_data *sd, bool show_msg) +{ + nullpo_retv(sd); + + clif->clearunit_area(&sd->bl, CLR_OUTSIGHT); + sd->sc.option |= OPTION_INVISIBLE; + sd->vd.class = INVISIBLE_CLASS; + + if (show_msg) + clif->message(sd->fd, atcommand->msgsd(sd, 11)); // Invisible: On + + // Decrement the number of pvp players on the map. + map->list[sd->bl.m].users_pvp--; + + if (map->list[sd->bl.m].flag.pvp != 0 && map->list[sd->bl.m].flag.pvp_nocalcrank == 0 + && sd->pvp_timer != INVALID_TIMER) { // Unregister the player for ranking. + timer->delete(sd->pvp_timer, pc->calc_pvprank_timer); + sd->pvp_timer = INVALID_TIMER; + } + + clif->changeoption(&sd->bl); +} + +/** + * Unhides a character. + * + * @param sd The character to unhide. + * @param show_msg Whether to show message to the character or not. + * + **/ +static void pc_unhide(struct map_session_data *sd, bool show_msg) +{ + nullpo_retv(sd); + + sd->sc.option &= ~OPTION_INVISIBLE; + + if (sd->disguise != -1) + status->set_viewdata(&sd->bl, sd->disguise); + else + status->set_viewdata(&sd->bl, sd->status.class); + + if (show_msg) + clif->message(sd->fd, atcommand->msgsd(sd, 10)); // Invisible: Off + + // Increment the number of pvp players on the map. + map->list[sd->bl.m].users_pvp++; + + if (map->list[sd->bl.m].flag.pvp != 0 && map->list[sd->bl.m].flag.pvp_nocalcrank == 0) // Register the player for ranking. + sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); + + // bugreport:2266 + map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); + + if (sd->disguise != -1) + clif->spawn_unit(&sd->bl, AREA_WOS); + + clif->changeoption(&sd->bl); +} + /*========================================== * Give an option (type) to player (sd) and display it to client *------------------------------------------*/ @@ -9299,7 +9365,13 @@ static int pc_setoption(struct map_session_data *sd, int type) //Option has to be changed client-side before the class sprite or it won't always work (eg: Wedding sprite) [Skotlex] sd->sc.option=type; - clif->changeoption(&sd->bl); + + if ((p_type & OPTION_INVISIBLE) != 0 && (type & OPTION_INVISIBLE) == 0) // Unhide character. + pc->unhide(sd, false); + else if ((p_type & OPTION_INVISIBLE) == 0 && (type & OPTION_INVISIBLE) != 0) // Hide character. + pc->hide(sd, false); + else + clif->changeoption(&sd->bl); if( (type&OPTION_RIDING && !(p_type&OPTION_RIDING)) || (type&OPTION_DRAGON && !(p_type&OPTION_DRAGON) && pc->checkskill(sd,RK_DRAGONTRAINING) > 0) ) { // Mounting @@ -12824,6 +12896,8 @@ void pc_defaults(void) pc->itemheal = pc_itemheal; pc->percentheal = pc_percentheal; pc->jobchange = pc_jobchange; + pc->hide = pc_hide; + pc->unhide = pc_unhide; pc->setoption = pc_setoption; pc->setcart = pc_setcart; pc->setfalcon = pc_setfalcon; diff --git a/src/map/pc.h b/src/map/pc.h index 2699b7882..6b2b44e2a 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1044,6 +1044,8 @@ END_ZEROED_BLOCK; /* End */ int (*itemheal) (struct map_session_data *sd,int itemid, int hp,int sp); int (*percentheal) (struct map_session_data *sd,int hp,int sp); int (*jobchange) (struct map_session_data *sd, int class, int upper); + void (*hide) (struct map_session_data *sd, bool show_msg); + void (*unhide) (struct map_session_data *sd, bool show_msg); int (*setoption) (struct map_session_data *sd,int type); int (*setcart) (struct map_session_data* sd, int type); void (*setfalcon) (struct map_session_data *sd, bool flag); diff --git a/src/map/pet.c b/src/map/pet.c index 620779765..299de42c7 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -323,7 +323,7 @@ static int pet_hungry(int tid, int64 tick, int id, intptr_t data) } clif->send_petdata(sd, pd, 2, pd->pet.hungry); - interval *= battle_config.pet_hungry_delay_rate / 100; + interval = interval * battle_config.pet_hungry_delay_rate / 100; pd->pet_hungry_timer = timer->add(tick + max(interval, 1), pet->hungry, sd->bl.id, 0); return 0; @@ -944,7 +944,7 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd) else intimacy += pd->petDB->r_hungry / 2; // Increase intimacy by 50% of FeedIncrement. - intimacy *= battle_config.pet_friendly_rate / 100; + intimacy = intimacy * battle_config.pet_friendly_rate / 100; pet->set_intimate(pd, pd->pet.intimate + intimacy); if (pd->pet.intimate == PET_INTIMACY_NONE) { @@ -1128,12 +1128,22 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int return 0; } +/** + * Calls pet_ai_sub_hard() for a character's pet if conditions are fulfilled. + * + * @param sd The character. + * @param ap Additional arguments. In this case only the time stamp of pet AI timer execution. + * @return Always 0. + * + **/ static int pet_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) { - int64 tick = va_arg(ap,int64); nullpo_ret(sd); - if(sd->status.pet_id && sd->pd) - pet->ai_sub_hard(sd->pd,sd,tick); + + int64 tick = va_arg(ap, int64); + + if (sd->bl.prev != NULL && sd->status.pet_id != 0 && sd->pd != NULL && sd->pd->bl.prev != NULL) + pet->ai_sub_hard(sd->pd, sd, tick); return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index 3dccf7a9e..1222cf940 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -7383,7 +7383,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * int rate = 100 * (100 - (tstatus->int_ / 2 + tstatus->vit / 3 + tstatus->luk / 10)); int duration = skill->get_time2(skill_id, skill_lv); - duration *= (100 - (tstatus->int_ + tstatus->vit) / 2) / 100; + duration = duration * (100 - (tstatus->int_ + tstatus->vit) / 2) / 100; status->change_start(src, bl, SC_BLIND, rate, 1, 0, 0, 0, duration, SCFLAG_NONE); } @@ -11296,7 +11296,7 @@ static int skill_castend_pos2(struct block_list *src, int x, int y, uint16 skill FALLTHROUGH case GS_GROUNDDRIFT: //Ammo should be deleted right away. if ( skill_id == WM_SEVERE_RAINSTORM ) - sc_start(src,src,SC_NO_SWITCH_EQUIP,100,0,skill->get_time(skill_id,skill_lv)); + sc_start(src, src, type, 100, 0, skill->get_time(skill_id, skill_lv)); skill->unitsetting(src,skill_id,skill_lv,x,y,0); break; case WZ_ICEWALL: diff --git a/src/map/status.c b/src/map/status.c index d3e85e5be..d2d65ce37 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -696,6 +696,7 @@ static void initChangeTables(void) status->set_sc( WM_BEYOND_OF_WARCRY , SC_BEYOND_OF_WARCRY , SCB_STR|SCB_CRI|SCB_MAXHP ); status->set_sc( WM_UNLIMITED_HUMMING_VOICE, SC_UNLIMITED_HUMMING_VOICE, SCB_NONE ); status->set_sc( WM_FRIGG_SONG , SC_FRIGG_SONG , SCB_MAXHP ); + status->set_sc( WM_SEVERE_RAINSTORM , SC_NO_SWITCH_EQUIP , SCB_NONE ); /** * Sorcerer @@ -7808,6 +7809,9 @@ static int status_change_start_sub(struct block_list *src, struct block_list *bl calc_flag = status->dbs->ChangeFlagTable[type]; if(!(flag&SCFLAG_LOADED)) { // Do not parse val settings when loading SCs switch(type) { + case SC_AUTOTRADE: + case SC_KSPROTECTED: + break; // Prevent calling status_change_start_unknown_sc(). case SC_ADORAMUS: sc_start(src,bl,SC_BLIND,100,val1,skill->get_time(status->sc2skill(type),val1)); // Fall through to SC_INC_AGI diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 3bd0b7fe6..dfe5ba4a6 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -6210,6 +6210,10 @@ typedef int (*HPMHOOK_pre_pc_percentheal) (struct map_session_data **sd, int *hp typedef int (*HPMHOOK_post_pc_percentheal) (int retVal___, struct map_session_data *sd, int hp, int sp); typedef int (*HPMHOOK_pre_pc_jobchange) (struct map_session_data **sd, int *class, int *upper); typedef int (*HPMHOOK_post_pc_jobchange) (int retVal___, struct map_session_data *sd, int class, int upper); +typedef void (*HPMHOOK_pre_pc_hide) (struct map_session_data **sd, bool *show_msg); +typedef void (*HPMHOOK_post_pc_hide) (struct map_session_data *sd, bool show_msg); +typedef void (*HPMHOOK_pre_pc_unhide) (struct map_session_data **sd, bool *show_msg); +typedef void (*HPMHOOK_post_pc_unhide) (struct map_session_data *sd, bool show_msg); typedef int (*HPMHOOK_pre_pc_setoption) (struct map_session_data **sd, int *type); typedef int (*HPMHOOK_post_pc_setoption) (int retVal___, struct map_session_data *sd, int type); typedef int (*HPMHOOK_pre_pc_setcart) (struct map_session_data **sd, int *type); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index 109c30885..13633807c 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -4790,6 +4790,10 @@ struct { struct HPMHookPoint *HP_pc_percentheal_post; struct HPMHookPoint *HP_pc_jobchange_pre; struct HPMHookPoint *HP_pc_jobchange_post; + struct HPMHookPoint *HP_pc_hide_pre; + struct HPMHookPoint *HP_pc_hide_post; + struct HPMHookPoint *HP_pc_unhide_pre; + struct HPMHookPoint *HP_pc_unhide_post; struct HPMHookPoint *HP_pc_setoption_pre; struct HPMHookPoint *HP_pc_setoption_post; struct HPMHookPoint *HP_pc_setcart_pre; @@ -11671,6 +11675,10 @@ struct { int HP_pc_percentheal_post; int HP_pc_jobchange_pre; int HP_pc_jobchange_post; + int HP_pc_hide_pre; + int HP_pc_hide_post; + int HP_pc_unhide_pre; + int HP_pc_unhide_post; int HP_pc_setoption_pre; int HP_pc_setoption_post; int HP_pc_setcart_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index ac30b97d4..673dcc67a 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -2453,6 +2453,8 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pc->itemheal, HP_pc_itemheal) }, { HP_POP(pc->percentheal, HP_pc_percentheal) }, { HP_POP(pc->jobchange, HP_pc_jobchange) }, + { HP_POP(pc->hide, HP_pc_hide) }, + { HP_POP(pc->unhide, HP_pc_unhide) }, { HP_POP(pc->setoption, HP_pc_setoption) }, { HP_POP(pc->setcart, HP_pc_setcart) }, { HP_POP(pc->setfalcon, HP_pc_setfalcon) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 57351b808..34bcf3f8f 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -63705,6 +63705,58 @@ int HP_pc_jobchange(struct map_session_data *sd, int class, int upper) { } return retVal___; } +void HP_pc_hide(struct map_session_data *sd, bool show_msg) { + int hIndex = 0; + if (HPMHooks.count.HP_pc_hide_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, bool *show_msg); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_hide_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_pc_hide_pre[hIndex].func; + preHookFunc(&sd, &show_msg); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.pc.hide(sd, show_msg); + } + if (HPMHooks.count.HP_pc_hide_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, bool show_msg); + for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_hide_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_pc_hide_post[hIndex].func; + postHookFunc(sd, show_msg); + } + } + return; +} +void HP_pc_unhide(struct map_session_data *sd, bool show_msg) { + int hIndex = 0; + if (HPMHooks.count.HP_pc_unhide_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, bool *show_msg); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_unhide_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_pc_unhide_pre[hIndex].func; + preHookFunc(&sd, &show_msg); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.pc.unhide(sd, show_msg); + } + if (HPMHooks.count.HP_pc_unhide_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, bool show_msg); + for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_unhide_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_pc_unhide_post[hIndex].func; + postHookFunc(sd, show_msg); + } + } + return; +} int HP_pc_setoption(struct map_session_data *sd, int type) { int hIndex = 0; int retVal___ = 0; |