summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-04-08 07:43:05 +0200
committerKenpachi Developer <Kenpachi.Developer@gmx.de>2020-04-08 08:08:46 +0200
commite5d0f388bd40dbadebe1d18a4a6c2805648baa13 (patch)
treeaeeda119ea010573653f60a9aa7efd53b5d526ea
parentd3d1927e5ff037195dce99accd511127a6d4d52b (diff)
downloadhercules-e5d0f388bd40dbadebe1d18a4a6c2805648baa13.tar.gz
hercules-e5d0f388bd40dbadebe1d18a4a6c2805648baa13.tar.bz2
hercules-e5d0f388bd40dbadebe1d18a4a6c2805648baa13.tar.xz
hercules-e5d0f388bd40dbadebe1d18a4a6c2805648baa13.zip
Add pc_hide() function
-rw-r--r--src/map/pc.c31
-rw-r--r--src/map/pc.h1
2 files changed, 32 insertions, 0 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 90282209b..194c2cbb1 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -9288,6 +9288,36 @@ 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);
+}
+
/*==========================================
* Give an option (type) to player (sd) and display it to client
*------------------------------------------*/
@@ -12824,6 +12854,7 @@ void pc_defaults(void)
pc->itemheal = pc_itemheal;
pc->percentheal = pc_percentheal;
pc->jobchange = pc_jobchange;
+ pc->hide = pc_hide;
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..b895c75db 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -1044,6 +1044,7 @@ 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);
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);