summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt13
-rw-r--r--src/map/atcommand.c64
-rw-r--r--src/map/clif.c2559
-rw-r--r--src/map/clif.h30
-rw-r--r--src/map/map.h35
-rw-r--r--src/map/mob.c111
-rw-r--r--src/map/mob.h21
-rw-r--r--src/map/npc.c34
-rw-r--r--src/map/npc.h7
-rw-r--r--src/map/pc.c82
-rw-r--r--src/map/pc.h8
-rw-r--r--src/map/pet.c11
-rw-r--r--src/map/script.c66
-rw-r--r--src/map/skill.c47
-rw-r--r--src/map/status.c210
-rw-r--r--src/map/status.h2
-rw-r--r--src/map/unit.c127
17 files changed, 1225 insertions, 2202 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 5b56c2643..5865fe80b 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,19 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/04/01
+ * Added structure view_data to handle sprite information for all characters
+ (equipment, weapons, hair, dyes, etc). [Skotlex]
+ * Rewrote several clif functions to adapt to the new view_data class.
+ [Skotlex]
+ * Rewrote the way cloth dye packets are resent to optimize bandwidth usage.
+ [Skotlex]
+ * Fixed the npc_item_flag thing (enable_items/disable_items script command)
+ [Skotlex]
+ * Rewrote the disguise implementation to be bandwidth friendly. [Skotlex]
+ * Modified the hide options to change your class to INVISIBLE_CLASS, since
+ such classes don't even get their view packets sent around. [Skotlex]
+ * Added class 139 to npcdb_checkid which was required by some npcs in the
+ swordman quest. [Skotlex]
* April fool! Improved soundeffectall script command. (No, this is not a lie) [Lance]
2006/03/31
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index e10ec8d99..9ce2c3867 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2178,9 +2178,14 @@ int atcommand_hide(
nullpo_retr(-1, sd);
if (sd->sc.option & OPTION_INVISIBLE) {
sd->sc.option &= ~OPTION_INVISIBLE;
+ if (sd->disguise)
+ status_set_viewdata(&sd->bl, sd->disguise);
+ else
+ status_set_viewdata(&sd->bl, sd->status.class_);
clif_displaymessage(fd, msg_table[10]); // Invisible: Off
} else {
sd->sc.option |= OPTION_INVISIBLE;
+ sd->vd.class_ = INVISIBLE_CLASS;
clif_displaymessage(fd, msg_table[11]); // Invisible: On
}
clif_changeoption(&sd->bl);
@@ -6473,21 +6478,7 @@ int atcommand_disguise(
return -1;
}
- /* The previous way....
- if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
- mob_id = atoi(message);
-
- if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
- (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
- (mob_id >= 813 && mob_id <= 858) || // NPC
- (mob_id > 1000 && mob_id < 1582)) { // monsters
- */
- pc_stop_walking(sd,0);
- clif_clearchar(&sd->bl, 0);
- sd->disguise = id;
- sd->state.disguised = 1; // set to override items with disguise script [Valaris]
- clif_changeoption(&sd->bl);
- clif_spawnpc(sd);
+ pc_disguise(sd, id);
clif_displaymessage(fd, msg_table[122]); // Disguise applied.
return 0;
@@ -6517,14 +6508,8 @@ int atcommand_disguiseall(
if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
pl_allsd = map_getallusers(&users);
for(i=0; i < users; i++) {
- if((pl_sd = pl_allsd[i])) {
- pc_stop_walking(pl_sd,0);
- clif_clearchar(&pl_sd->bl, 0);
- pl_sd->disguise = mob_id;
- pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
- clif_changeoption(&pl_sd->bl);
- clif_spawnpc(pl_sd);
- }
+ if((pl_sd = pl_allsd[i]))
+ pc_disguise(pl_sd, mob_id);
}
clif_displaymessage(fd, msg_table[122]); // Disguise applied.
} else {
@@ -6544,11 +6529,7 @@ int atcommand_undisguise(
{
nullpo_retr(-1, sd);
if (sd->disguise) {
- pc_stop_walking(sd,0);
- clif_clearchar(&sd->bl, 0);
- sd->disguise = 0;
- clif_changeoption(&sd->bl);
- clif_spawnpc(sd);
+ pc_disguise(sd, 0);
clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
} else {
clif_displaymessage(fd, msg_table[125]); // You're not disguised.
@@ -6573,13 +6554,8 @@ int atcommand_undisguiseall(
pl_allsd = map_getallusers(&users);
for(i=0; i < users; i++) {
- if((pl_sd = pl_allsd[i]) && pl_sd->disguise) {
- pc_stop_walking(pl_sd,0);
- clif_clearchar(&pl_sd->bl, 0);
- pl_sd->disguise = 0;
- clif_changeoption(&pl_sd->bl);
- clif_spawnpc(pl_sd);
- }
+ if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
+ pc_disguise(pl_sd, 0);
}
clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
@@ -6701,12 +6677,7 @@ int atcommand_chardisguise(
if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
- pc_stop_walking(pl_sd,0);
- clif_clearchar(&pl_sd->bl, 0);
- pl_sd->disguise = mob_id;
- pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
- clif_changeoption(&pl_sd->bl);
- clif_spawnpc(pl_sd);
+ pc_disguise(pl_sd, mob_id);
clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
} else {
clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
@@ -6740,14 +6711,9 @@ int atcommand_charundisguise(
if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
- if (pl_sd->disguise) {
- pc_stop_walking(pl_sd,0);
- clif_clearchar(&pl_sd->bl, 0);
- pl_sd->disguise = 0;
- clif_changeoption(&pl_sd->bl);
- clif_spawnpc(pl_sd);
- clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
- } else {
+ if (pl_sd->disguise)
+ pc_disguise(pl_sd, 0);
+ else {
clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
return -1;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 9472a07bd..43a8ebb0d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -166,6 +166,8 @@ enum {
// Checks if SD is in a trade/shop (where messing with the inventory can cause problems/exploits)
#define clif_trading(sd) (sd->npc_id || sd->vender_id || sd->trade_partner)
+//To idenfity disguised characters.
+#define disguised(bl) (bl->type==BL_PC && ((TBL_PC*)bl)->disguise)
static char map_ip_str[16];
static in_addr_t map_ip;
static in_addr_t bind_ip = INADDR_ANY;
@@ -234,7 +236,7 @@ int clif_countusers(void)
for(i = 0; i < fd_max; i++) {
if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd->state.auth &&
- !(battle_config.hide_GM_session && pc_isGM(sd)))
+ !(battle_config.hide_GM_session && pc_isGM(sd)))
users++;
}
return users;
@@ -244,7 +246,7 @@ int clif_countusers(void)
* 全てのclientに対してfunc()実行
*------------------------------------------
*/
-
+
int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) //recoded by sasuke, bug when player count gets higher [Kevin]
{
int i;
@@ -257,7 +259,7 @@ int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) //rec
if ( session[i] ) {
sd = (struct map_session_data*)session[i]->session_data;
if ( sd && session[i]->func_parse == clif_parse &&
- sd->state.auth && !sd->state.waitingdisconnect )
+ sd->state.auth && !sd->state.waitingdisconnect )
func(sd, ap);
}
}
@@ -276,14 +278,14 @@ int clif_send_sub(struct block_list *bl, va_list ap)
struct map_session_data *sd;
unsigned char *buf;
int len, type;
-
+
nullpo_retr(0, bl);
nullpo_retr(0, ap);
nullpo_retr(0, sd = (struct map_session_data *)bl);
if (!sd->fd) //Avoid attempting to send to disconnected chars (may prevent buffer overrun errors?) [Skotlex]
return 0;
-
+
buf = va_arg(ap,unsigned char*);
len = va_arg(ap,int);
nullpo_retr(0, src_bl = va_arg(ap,struct block_list*));
@@ -321,18 +323,18 @@ int clif_send_sub(struct block_list *bl, va_list ap)
//given buffer to prevent intravision affecting the packet as
//it's being received by everyone. [Skotlex]
if ((sd->special_state.intravision || sd->sc.data[SC_INTRAVISION].timer != -1 )
- && bl != src_bl && WFIFOW(sd->fd,0) == 0x0196)
- { //New intravision method, just modify the status change/start packet. [Skotlex]
+ && bl != src_bl && WFIFOW(sd->fd,0) == 0x0196)
+ { //New intravision method, just modify the status change/start packet. [Skotlex]
switch (WFIFOW(sd->fd,2)) {
- case SI_HIDING:
- case SI_CLOAKING:
- case SI_CHASEWALK:
- WFIFOW(sd->fd,2) = SI_INTRAVISION;
+ case SI_HIDING:
+ case SI_CLOAKING:
+ case SI_CHASEWALK:
+ WFIFOW(sd->fd,2) = SI_INTRAVISION;
}
}
-
+
/* Previous implementation.
- if ((sd->special_state.intravision || sd->sc.data[SC_INTRAVISION].timer != -1 ) && bl != src_bl) {
+ if ((sd->special_state.intravision || sd->sc.data[SC_INTRAVISION].timer != -1 ) && bl != src_bl) {
struct status_change *sc = status_get_sc(src_bl);
if(sc && (sc->option&(OPTION_HIDE|OPTION_CLOAK)))
@@ -591,7 +593,7 @@ int clif_authok(struct map_session_data *sd) {
return 0;
fd = sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x73]);
+ WFIFOHEAD(fd, packet_len_table[0x73]);
WFIFOW(fd, 0) = 0x73;
WFIFOL(fd, 2) = gettick();
WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y);
@@ -610,7 +612,7 @@ int clif_authfail_fd(int fd, int type) {
if (!fd || !session[fd] || session[fd]->func_parse != clif_parse) //clif_authfail should only be invoked on players!
return 0;
- WFIFOHEAD(fd, packet_len_table[0x81]);
+ WFIFOHEAD(fd, packet_len_table[0x81]);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = type;
WFIFOSET(fd,packet_len_table[0x81]);
@@ -643,7 +645,7 @@ int clif_charselectok(int id) {
return 1;
fd = sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xb3]);
+ WFIFOHEAD(fd, packet_len_table[0xb3]);
WFIFOW(fd,0) = 0xb3;
WFIFOB(fd,2) = 1;
WFIFOSET(fd,packet_len_table[0xb3]);
@@ -709,7 +711,7 @@ int clif_clearflooritem(struct flooritem_data *fitem, int fd) {
if (fd == 0) {
clif_send(buf, packet_len_table[0xa1], &fitem->bl, AREA);
} else {
- WFIFOHEAD(fd,packet_len_table[0xa1]);
+ WFIFOHEAD(fd,packet_len_table[0xa1]);
memcpy(WFIFOP(fd,0), buf, 6);
WFIFOSET(fd,packet_len_table[0xa1]);
}
@@ -729,11 +731,11 @@ int clif_clearchar(struct block_list *bl, int type) {
WBUFW(buf,0) = 0x80;
WBUFL(buf,2) = bl->id;
WBUFB(buf,6) = type;
- clif_send(buf, packet_len_table[0x80], bl, type == 1 ? AREA : AREA_WOS);
- if(bl->type==BL_PC && ((struct map_session_data *)bl)->disguise) {
+ clif_send(buf, packet_len_table[0x80], bl, type == 1 ? AREA : AREA_WOS);
+ if(disguised(bl)) {
WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len_table[0x80], bl, AREA);
+ clif_send(buf, packet_len_table[0x80], bl, SELF);
}
return 0;
@@ -773,949 +775,345 @@ int clif_clearchar_id(int id, int type, int fd) {
return 0;
}
-//Small define to specify the weapon view sprite, makes code easier to read down below... [Skotlex]
-#define clif_weapon_viewid(sd, n) ((sd->equip_index[n] >= 0 && sd->inventory_data[sd->equip_index[n]])?(\
- (sd->inventory_data[sd->equip_index[n]]->view_id > 0)?sd->inventory_data[sd->equip_index[n]]->view_id: \
- sd->status.inventory[sd->equip_index[n]].nameid):0)
-
-#define clif_deadsit(sd) (((sd)->sc.count && (sd)->sc.data[SC_TRICKDEAD].timer != -1)?1:sd->state.dead_sit)
-/*==========================================
- *
- *------------------------------------------
- */
-static int clif_set0078(struct map_session_data *sd, unsigned char *buf) {
- int sdoption;
-
- nullpo_retr(0, sd);
-
- // Disable showing Falcon when player is hide [LuzZza]
- if(sd->disguise)
- sdoption = OPTION_INVISIBLE;
- else {
- sdoption = sd->sc.option;
- if(sdoption&(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE))
- sdoption &= ~OPTION_FALCON;
- }
-#if PACKETVER < 4
- memset(buf,0,packet_len_table[0x78]);
-
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=sd->bl.id;
- WBUFW(buf,6)=sd->speed;
- WBUFW(buf,8)=sd->sc.opt1;
- WBUFW(buf,10)=sd->sc.opt2;
- WBUFW(buf,12)=sdoption;
- WBUFW(buf,14)=sd->view_class;
- WBUFW(buf,16)=sd->status.hair;
- if (sd->view_class != JOB_WEDDING && sd->view_class !=JOB_XMAS)
- WBUFW(buf,18) = sd->status.weapon;
- else
- WBUFW(buf,18)=0;
- WBUFW(buf,20)=sd->status.head_bottom;
- WBUFW(buf,22)=sd->status.shield;
- WBUFW(buf,24)=sd->status.head_top;
- WBUFW(buf,26)=sd->status.head_mid;
- WBUFW(buf,28)=sd->status.hair_color;
- WBUFW(buf,30)=sd->status.clothes_color;
- WBUFW(buf,32)=sd->head_dir;
- WBUFL(buf,34)=sd->status.guild_id;
- WBUFL(buf,38)=sd->guild_emblem_id;
- WBUFW(buf,42)=sd->status.manner;
- WBUFB(buf,44)=sd->status.karma;
- WBUFB(buf,45)=sd->sex;
- WBUFPOS(buf,46,sd->bl.x,sd->bl.y);
- WBUFB(buf,48)|=sd->ud.dir&0x0f;
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=clif_deadsit(sd);
- WBUFW(buf,52)=clif_setlevel(sd->status.base_level);
-
- return packet_len_table[0x78];
-#else
- memset(buf,0,packet_len_table[0x1d8]);
-
- WBUFW(buf,0)=0x1d8;
- WBUFL(buf,2)=sd->bl.id;
- WBUFW(buf,6)=sd->speed;
- WBUFW(buf,8)=sd->sc.opt1;
- WBUFW(buf,10)=sd->sc.opt2;
- WBUFW(buf,12)=sdoption;
- WBUFW(buf,14)=sd->view_class;
- WBUFW(buf,16)=sd->status.hair;
- if (sd->view_class != JOB_WEDDING && sd->view_class !=JOB_XMAS)
- WBUFW(buf,18) = clif_weapon_viewid(sd,9);
- else
- WBUFW(buf,18) = 0;
- if (sd->equip_index[8] != sd->equip_index[9] && sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS)
- WBUFW(buf,20) = clif_weapon_viewid(sd,8);
- else
- WBUFW(buf,20) = 0;
- WBUFW(buf,22)=sd->status.head_bottom;
- WBUFW(buf,24)=sd->status.head_top;
- WBUFW(buf,26)=sd->status.head_mid;
- WBUFW(buf,28)=sd->status.hair_color;
- WBUFW(buf,30)=sd->status.clothes_color;
- WBUFW(buf,32)=sd->head_dir;
- WBUFL(buf,34)=sd->status.guild_id;
- WBUFW(buf,38)=sd->guild_emblem_id;
- WBUFW(buf,40)=sd->status.manner;
- WBUFW(buf,42)=sd->sc.opt3;
- WBUFB(buf,44)=sd->status.karma;
- WBUFB(buf,45)=sd->sex;
- WBUFPOS(buf,46,sd->bl.x,sd->bl.y);
- WBUFB(buf,48)|=sd->ud.dir & 0x0f;
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=clif_deadsit(sd);
- WBUFW(buf,52)=clif_setlevel(sd->status.base_level);
-
- return packet_len_table[0x1d8];
+void clif_get_weapon_view(TBL_PC* sd, short *rhand, short *lhand)
+{
+#if PACKETVER > 3
+ struct item_data *id;
#endif
-}
-
-// non-moving function for disguises [Valaris]
-static int clif_dis0078(struct map_session_data *sd, unsigned char *buf) {
-
- nullpo_retr(0, sd);
-
- memset(buf,0,packet_len_table[0x78]);
-
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=-sd->bl.id;
- WBUFW(buf,6)=sd->speed;
- WBUFW(buf,8)=0;
- WBUFW(buf,10)=0;
- WBUFW(buf,12)=sd->sc.option;
- WBUFW(buf,14)=sd->disguise;
- //WBUFL(buf,34)=sd->status.guild_id;
- //WBUFL(buf,38)=sd->guild_emblem_id;
- WBUFW(buf,42)=0;
- WBUFB(buf,44)=0;
- WBUFPOS(buf,46,sd->bl.x,sd->bl.y);
- WBUFB(buf,48)|=sd->ud.dir&0x0f;
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=clif_deadsit(sd);
- WBUFW(buf,52)=0;
-
- return packet_len_table[0x78];
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static int clif_set007b(struct map_session_data *sd,unsigned char *buf) {
-
- int sdoption;
-
- nullpo_retr(0, sd);
-
- // Disable showing Falcon when player is hide [LuzZza]
- if(sd->disguise)
- sdoption = OPTION_INVISIBLE;
- else {
- sdoption = sd->sc.option;
- if(sdoption&(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE))
- sdoption &= ~OPTION_FALCON;
+ if (sd->vd.class_ == JOB_XMAS || sd->vd.class_ == JOB_WEDDING)
+ {
+ *rhand = *lhand = 0;
+ return;
}
#if PACKETVER < 4
- memset(buf,0,packet_len_table[0x7b]);
-
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=sd->bl.id;
- WBUFW(buf,6)=sd->speed;
- WBUFW(buf,8)=sd->sc.opt1;
- WBUFW(buf,10)=sd->sc.opt2;
- WBUFW(buf,12)=sdoption;
- WBUFW(buf,14)=sd->view_class;
- WBUFW(buf,16)=sd->status.hair;
- if(sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS)
- WBUFW(buf,18)=sd->status.weapon;
- else
- WBUFW(buf,18)=0;
- WBUFW(buf,20)=sd->status.head_bottom;
- WBUFL(buf,22)=gettick();
- WBUFW(buf,26)=sd->status.shield;
- WBUFW(buf,28)=sd->status.head_top;
- WBUFW(buf,30)=sd->status.head_mid;
- WBUFW(buf,32)=sd->status.hair_color;
- WBUFW(buf,34)=sd->status.clothes_color;
- WBUFW(buf,36)=sd->head_dir;
- WBUFL(buf,38)=sd->status.guild_id;
- WBUFL(buf,42)=sd->guild_emblem_id;
- WBUFW(buf,46)=sd->sc.opt3;
- WBUFB(buf,48)=sd->status.karma;
- WBUFB(buf,49)=sd->sex;
- WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(sd->status.base_level);
-
- return packet_len_table[0x7b];
+ *rhand = sd->status.weapon;
+ *lhand = sd->status.shield;
#else
- memset(buf,0,packet_len_table[0x1da]);
-
- WBUFW(buf,0)=0x1da;
- WBUFL(buf,2)=sd->bl.id;
- WBUFW(buf,6)=sd->speed;
- WBUFW(buf,8)=sd->sc.opt1;
- WBUFW(buf,10)=sd->sc.opt2;
- WBUFW(buf,12)=sdoption;
- WBUFW(buf,14)=sd->view_class;
- WBUFW(buf,16)=sd->status.hair;
- if(sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS)
- WBUFW(buf,18)= clif_weapon_viewid(sd, 9);
- else
- WBUFW(buf,18)=0;
- if(sd->equip_index[8] != sd->equip_index[9] && sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS)
- WBUFW(buf,20)= clif_weapon_viewid(sd, 8);
- else
- WBUFW(buf,20)=0;
- WBUFW(buf,22)=sd->status.head_bottom;
- WBUFL(buf,24)=gettick();
- WBUFW(buf,28)=sd->status.head_top;
- WBUFW(buf,30)=sd->status.head_mid;
- WBUFW(buf,32)=sd->status.hair_color;
- WBUFW(buf,34)=sd->status.clothes_color;
- WBUFW(buf,36)=sd->head_dir;
- WBUFL(buf,38)=sd->status.guild_id;
- WBUFW(buf,42)=sd->guild_emblem_id;
- WBUFW(buf,44)=sd->status.manner;
- WBUFW(buf,46)=sd->sc.opt3;
- WBUFB(buf,48)=sd->status.karma;
- WBUFB(buf,49)=sd->sex;
- WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(sd->status.base_level);
+ if (sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]])
+ {
+ id = sd->inventory_data[sd->equip_index[9]];
+ if (id->view_id > 0)
+ *rhand = id->view_id;
+ else
+ *rhand = id->nameid;
+ } else
+ *rhand = 0;
- return packet_len_table[0x1da];
+ if (sd->equip_index[8] >= 0 && sd->equip_index[8] != sd->equip_index[9]
+ && sd->inventory_data[sd->equip_index[8]])
+ {
+ id = sd->inventory_data[sd->equip_index[8]];
+ if (id->view_id > 0)
+ *lhand = id->view_id;
+ else
+ *lhand = id->nameid;
+ } else
+ *lhand = 0;
#endif
-}
+}
-// moving function for disguises [Valaris]
-static int clif_dis007b(struct map_session_data *sd,unsigned char *buf) {
-
- nullpo_retr(0, sd);
-
- memset(buf,0,packet_len_table[0x7b]);
-
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=-sd->bl.id;
- WBUFW(buf,6)=sd->speed;
- WBUFW(buf,8)=0;
- WBUFW(buf,10)=0;
- WBUFW(buf,12)=sd->sc.option;
- WBUFW(buf,14)=sd->disguise;
- WBUFL(buf,22)=gettick();
- //WBUFL(buf,38)=sd->status.guild_id;
- //WBUFL(buf,42)=sd->guild_emblem_id;
- WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=0;
-
- return packet_len_table[0x7b];
-}
-
-/*==========================================
- * クラスチェンジ typeはMobの場合は1で他は0?
- *------------------------------------------
- */
-int clif_class_change(struct block_list *bl,int class_,int type)
+static void clif_get_guild_data(struct block_list *bl, long *guild_id, long *emblem_id)
{
- unsigned char buf[16];
-
- nullpo_retr(0, bl);
-
- if(class_ >= MAX_PC_CLASS) {
- WBUFW(buf,0)=0x1b0;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- WBUFL(buf,7)=class_;
-
- clif_send(buf,packet_len_table[0x1b0],bl,AREA);
+ //TODO: There has to be a way to clean this up.
+ switch (bl->type) {
+ case BL_PC:
+ *guild_id = ((TBL_PC*)bl)->status.guild_id;
+ *emblem_id = ((TBL_PC*)bl)->guild_emblem_id;
+ break;
+ case BL_MOB:
+ if (((TBL_MOB*)bl)->guardian_data) {
+ *guild_id =((TBL_MOB*)bl)->guardian_data->guild_id;
+ *emblem_id =((TBL_MOB*)bl)->guardian_data->emblem_id;
+ }
+ break;
+ case BL_NPC:
+ if (bl->subtype == SCRIPT && ((TBL_NPC*)bl)->u.scr.guild_id > 0) {
+ struct guild *g = guild_search(((TBL_NPC*)bl)->u.scr.guild_id);
+ if (g) {
+ *guild_id =g->guild_id;
+ *emblem_id =g->emblem_id;
+ }
+ }
+ break;
+ default:
+ *guild_id = status_get_guild_id(bl);
}
- return 0;
+ return;
}
/*==========================================
*
*------------------------------------------
*/
-int clif_mob_class_change(struct mob_data *md, int class_) {
- unsigned char buf[16];
- int view = mob_get_viewclass(class_);
-
- nullpo_retr(0, md);
-
- if(view >= MAX_PC_CLASS) {
- WBUFW(buf,0)=0x1b0;
- WBUFL(buf,2)=md->bl.id;
- WBUFB(buf,6)=1;
- WBUFL(buf,7)=view;
-
- clif_send(buf,packet_len_table[0x1b0],&md->bl,AREA);
- }
- return 0;
-}
-// mob equipment [Valaris]
-
-int clif_mob_equip(struct mob_data *md, int nameid) {
- unsigned char buf[16];
-
- nullpo_retr(0, md);
-
- memset(buf,0,packet_len_table[0x1a4]);
-
- WBUFW(buf,0)=0x1a4;
- WBUFB(buf,2)=3;
- WBUFL(buf,3)=md->bl.id;
- WBUFL(buf,7)=nameid;
-
- clif_send(buf,packet_len_table[0x1a4],&md->bl,AREA);
-
- return 0;
-}
-
-/*==========================================
- * MOB表示1
- *------------------------------------------
- */
-static int clif_mob0078(struct mob_data *md, unsigned char *buf)
-{
- int level, view_class;
-
- nullpo_retr(0, md);
+static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned char *buf) {
+ struct status_change *sc;
+ struct map_session_data *sd;
+ long guild_id=0, emblem_id=0, lv;
+ unsigned short dir;
- level=status_get_lv(&md->bl);
- view_class = mob_get_viewclass(md->class_);
- if(pcdb_checkid(view_class)) {
-#if PACKETVER < 4
- memset(buf,0,packet_len_table[0x78]);
+ nullpo_retr(0, bl);
+ BL_CAST(BL_PC, bl, sd);
+ sc = status_get_sc(bl);
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=md->bl.id;
- WBUFW(buf,6)=status_get_speed(&md->bl);
- WBUFW(buf,8)=md->sc.opt1;
- WBUFW(buf,10)=md->sc.opt2;
- WBUFW(buf,12)=md->sc.option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(md->class_);
- WBUFW(buf,18)=mob_get_weapon(md->class_);
- WBUFW(buf,20)=mob_get_head_buttom(md->class_);
- WBUFW(buf,22)=mob_get_shield(md->class_);
- WBUFW(buf,24)=mob_get_head_top(md->class_);
- WBUFW(buf,26)=mob_get_head_mid(md->class_);
- WBUFW(buf,28)=mob_get_hair_color(md->class_);
- WBUFW(buf,30)=mob_get_clothes_color(md->class_);
- WBUFW(buf,32)|=md->ud.dir&0x0f; // head direction
- if (md->guardian_data && md->guardian_data->guild_id) { // Added guardian emblems [Valaris]
- WBUFL(buf,34)=md->guardian_data->guild_id;
- WBUFL(buf,38)=md->guardian_data->emblem_id;
- }
- WBUFW(buf,42)=md->sc.opt3;
- WBUFB(buf,44)=0; // karma
- WBUFB(buf,45)=mob_get_sex(md->class_);
- WBUFPOS(buf,46,md->bl.x,md->bl.y);
- WBUFB(buf,48)|=md->ud.dir&0x0f;
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=0; // dead or sit state
- WBUFW(buf,52)=clif_setlevel(level);
-
- return packet_len_table[0x78];
-#else
- // Use 0x1d8 packet for monsters with player sprites [Valaris]
+ clif_get_guild_data(bl, &guild_id, &emblem_id);
+ dir = unit_getdir(bl);
+ lv = status_get_lv(bl);
+ if(pcdb_checkid(vd->class_)) {
+#if PACKETVER > 3
memset(buf,0,packet_len_table[0x1d8]);
WBUFW(buf,0)=0x1d8;
- WBUFL(buf,2)=md->bl.id;
- WBUFW(buf,6)=status_get_speed(&md->bl);
- WBUFW(buf,8)=md->sc.opt1;
- WBUFW(buf,10)=md->sc.opt2;
- WBUFW(buf,12)=md->sc.option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(md->class_);
- WBUFW(buf,18)=mob_get_weapon(md->class_);
- WBUFW(buf,20)=mob_get_shield(md->class_);
- WBUFW(buf,22)=mob_get_head_buttom(md->class_);
- WBUFW(buf,24)=mob_get_head_top(md->class_);
- WBUFW(buf,26)=mob_get_head_mid(md->class_);
- WBUFW(buf,28)=mob_get_hair_color(md->class_);
- WBUFW(buf,30)=mob_get_clothes_color(md->class_);
- WBUFW(buf,32)|=md->ud.dir&0x0f; // head direction
- WBUFL(buf,34)=0; // guild id
- WBUFW(buf,38)=0; // emblem id
- WBUFW(buf,40)=0; // manner
- WBUFW(buf,42)=md->sc.opt3;
- WBUFB(buf,44)=0; // karma
- WBUFB(buf,45)=mob_get_sex(md->class_);
- WBUFPOS(buf,46,md->bl.x,md->bl.y);
- WBUFB(buf,48)|=md->ud.dir&0x0f;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,42)=sc->opt3;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style;
+ WBUFW(buf,18)=vd->weapon;
+ WBUFW(buf,20)=vd->shield;
+ WBUFW(buf,22)=vd->head_bottom;
+ WBUFW(buf,24)=vd->head_top;
+ WBUFW(buf,26)=vd->head_mid;
+ WBUFW(buf,28)=vd->hair_color;
+ WBUFW(buf,30)=vd->cloth_color;
+ WBUFW(buf,32)=sd?sd->head_dir:dir;
+ WBUFL(buf,34)=guild_id;
+ WBUFL(buf,38)=emblem_id;
+ if (sd) {
+ WBUFW(buf,40)=sd->status.manner;
+ WBUFB(buf,44)=sd->status.karma;
+ }
+ WBUFB(buf,45)=vd->sex;
+ WBUFPOS(buf,46,bl->x,bl->y);
+ WBUFB(buf,48)|=dir & 0x0f;
WBUFB(buf,49)=5;
WBUFB(buf,50)=5;
- WBUFB(buf,51)=0; // dead or sit state
- WBUFW(buf,52)=clif_setlevel(level);
-
+ WBUFB(buf,51)=vd->dead_sit;
+ WBUFW(buf,52)=clif_setlevel(lv);
return packet_len_table[0x1d8];
-#endif
- } else {
- // Use 0x78 packet for monsters sprites [Valaris]
+#else
memset(buf,0,packet_len_table[0x78]);
WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=md->bl.id;
- WBUFW(buf,6)=status_get_speed(&md->bl);
- WBUFW(buf,8)=md->sc.opt1;
- WBUFW(buf,10)=md->sc.opt2;
- WBUFW(buf,12)=md->sc.option;
- WBUFW(buf,14)=view_class;
- if (md->guardian_data && md->guardian_data->guild_id) { // Added guardian emblems [Valaris]
- WBUFL(buf,34)=md->guardian_data->guild_id;
- WBUFL(buf,38)=md->guardian_data->emblem_id;
- } // End addition
- WBUFPOS(buf,46,md->bl.x,md->bl.y);
- WBUFB(buf,48)|=md->ud.dir&0x0f;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style;
+ WBUFW(buf,18)=vd->weapon;
+ WBUFW(buf,20)=vd->head_bottom;
+ WBUFW(buf,22)=vd->shield;
+ WBUFW(buf,24)=vd->head_top;
+ WBUFW(buf,26)=vd->head_mid;
+ WBUFW(buf,28)=vd->hair_color;
+ WBUFW(buf,30)=vd->cloth_color;
+ WBUFW(buf,32)=sd?sd->head_dir:dir;
+ WBUFL(buf,34)=guild_id;
+ WBUFL(buf,38)=emblem_id;
+ if (sd) {
+ WBUFW(buf,42)=sd->status.manner;
+ WBUFB(buf,44)=sd->status.karma;
+ }
+ WBUFB(buf,45)=vd->sex;
+ WBUFPOS(buf,46,bl->x,bl->y);
+ WBUFB(buf,48)|=dir&0x0f;
WBUFB(buf,49)=5;
WBUFB(buf,50)=5;
- WBUFW(buf,52)=clif_setlevel(level);
-
+ WBUFB(buf,51)=vd->dead_sit;
+ WBUFW(buf,52)=clif_setlevel(lv);
return packet_len_table[0x78];
+#endif
}
+ //Non-player sprites need just a few fields filled.
+ memset(buf,0,packet_len_table[0x78]);
+
+ WBUFW(buf,0)=0x78;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style; //Required for pets.
+ WBUFW(buf,22)=vd->shield; //Pet armor
+ if (bl->type == BL_NPC && vd->class_ == 722)
+ { //The hell, why flags work like this?
+ WBUFL(buf,22)=emblem_id;
+ WBUFL(buf,26)=guild_id;
+ }
+ WBUFW(buf,32)=dir;
+ WBUFL(buf,34)=guild_id;
+ WBUFL(buf,38)=emblem_id;
+ WBUFPOS(buf,46,bl->x,bl->y);
+ WBUFB(buf,48)|=dir&0x0f;
+ WBUFB(buf,49)=5;
+ WBUFB(buf,50)=5;
+ WBUFW(buf,52)=clif_setlevel(lv);
+ return packet_len_table[0x78];
}
/*==========================================
- * MOB表示2
+ *
*------------------------------------------
*/
-static int clif_mob007b(struct mob_data *md, unsigned char *buf) {
- int level, view_class;
-
- nullpo_retr(0, md);
+static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit_data *ud, unsigned char *buf) {
+ struct status_change *sc;
+ struct map_session_data *sd;
+ long guild_id=0, emblem_id=0, lv;
- level=status_get_lv(&md->bl);
- view_class = mob_get_viewclass(md->class_);
- if(pcdb_checkid(view_class)) {
-#if PACKETVER < 4
- memset(buf,0,packet_len_table[0x7b]);
+ nullpo_retr(0, bl);
+ BL_CAST(BL_PC, bl, sd);
+ sc = status_get_sc(bl);
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=md->bl.id;
- WBUFW(buf,6)=status_get_speed(&md->bl);
- WBUFW(buf,8)=md->sc.opt1;
- WBUFW(buf,10)=md->sc.opt2;
- WBUFW(buf,12)=md->sc.option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(md->class_);
- WBUFW(buf,18)=mob_get_weapon(md->class_);
- WBUFW(buf,20)=mob_get_head_buttom(md->class_);
- WBUFL(buf,22)=gettick();
- WBUFW(buf,26)=mob_get_shield(md->class_);
- WBUFW(buf,28)=mob_get_head_top(md->class_);
- WBUFW(buf,30)=mob_get_head_mid(md->class_);
- WBUFW(buf,32)=mob_get_hair_color(md->class_);
- WBUFW(buf,34)=mob_get_clothes_color(md->class_);
- WBUFW(buf,36)=md->ud.dir&0x0f; // head direction
- if (md->guardian_data && md->guardian_data->guild_id) { // Added guardian emblems [Valaris]
- WBUFL(buf,38)=md->guardian_data->guild_id;
- WBUFL(buf,42)=md->guardian_data->emblem_id;
- }
- WBUFW(buf,46)=md->sc.opt3;
- WBUFB(buf,48)=0; // karma
- WBUFB(buf,49)=mob_get_sex(md->class_);
- WBUFPOS2(buf,50,md->bl.x,md->bl.y,md->ud.to_x,md->ud.to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(level);
-
- return packet_len_table[0x7b];
-#else
- // Use 0x1da packet for monsters with player sprites [Valaris]
+ clif_get_guild_data(bl, &guild_id, &emblem_id);
+ lv = status_get_lv(bl);
+
+ if(pcdb_checkid(vd->class_)) {
+#if PACKETVER > 3
memset(buf,0,packet_len_table[0x1da]);
WBUFW(buf,0)=0x1da;
- WBUFL(buf,2)=md->bl.id;
- WBUFW(buf,6)=status_get_speed(&md->bl);
- WBUFW(buf,8)=md->sc.opt1;
- WBUFW(buf,10)=md->sc.opt2;
- WBUFW(buf,12)=md->sc.option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(md->class_);
- WBUFW(buf,18)=mob_get_weapon(md->class_);
- WBUFW(buf,20)=mob_get_shield(md->class_);
- WBUFW(buf,22)=mob_get_head_buttom(md->class_);
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,46)=sc->opt3;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style;
+ WBUFW(buf,18)=vd->weapon;
+ WBUFW(buf,20)=vd->shield;
+ WBUFW(buf,22)=vd->head_bottom;
WBUFL(buf,24)=gettick();
- WBUFW(buf,28)=mob_get_head_top(md->class_);
- WBUFW(buf,30)=mob_get_head_mid(md->class_);
- WBUFW(buf,32)=mob_get_hair_color(md->class_);
- WBUFW(buf,34)=mob_get_clothes_color(md->class_);
- WBUFW(buf,36)=md->ud.dir&0x0f; // head direction
- if (md->guardian_data && md->guardian_data->guild_id) { // Added guardian emblems [Valaris]
- WBUFL(buf,38)=md->guardian_data->guild_id;
- WBUFW(buf,42)=md->guardian_data->emblem_id;
+ WBUFW(buf,28)=vd->head_top;
+ WBUFW(buf,30)=vd->head_mid;
+ WBUFW(buf,32)=vd->hair_color;
+ WBUFW(buf,34)=vd->cloth_color;
+ WBUFW(buf,36)=sd?sd->head_dir:unit_getdir(bl);
+ WBUFL(buf,38)=guild_id;
+ WBUFW(buf,42)=emblem_id;
+ if (sd) {
+ WBUFW(buf,44)=sd->status.manner;
+ WBUFB(buf,48)=sd->status.karma;
}
- WBUFW(buf,44)=0; // manner
- WBUFW(buf,46)=md->sc.opt3;
- WBUFB(buf,48)=0; // karma
- WBUFB(buf,49)=mob_get_sex(md->class_);
- WBUFPOS2(buf,50,md->bl.x,md->bl.y,md->ud.to_x,md->ud.to_y);
+ WBUFB(buf,49)=vd->sex;
+ WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
WBUFB(buf,56)=5;
WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(level);
+ WBUFW(buf,58)=clif_setlevel(lv);
return packet_len_table[0x1da];
-#endif
- } else {
- // Use 0x7b packet for monsters sprites [Valaris]
- memset(buf,0,packet_len_table[0x7b]);
-
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=md->bl.id;
- WBUFW(buf,6)=status_get_speed(&md->bl);
- WBUFW(buf,8)=md->sc.opt1;
- WBUFW(buf,10)=md->sc.opt2;
- WBUFW(buf,12)=md->sc.option;
- WBUFW(buf,14)=view_class;
- WBUFL(buf,22)=gettick();
- if (md->guardian_data && md->guardian_data->guild_id) { // Added guardian emblems [Valaris]
- WBUFL(buf,38)=md->guardian_data->guild_id;
- WBUFL(buf,42)=md->guardian_data->emblem_id;
- } // End addition
- WBUFPOS2(buf,50,md->bl.x,md->bl.y,md->ud.to_x,md->ud.to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- level = status_get_lv(&md->bl);
- WBUFW(buf,58)=clif_setlevel(level);
-
- return packet_len_table[0x7b];
- }
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static int clif_npc0078(struct npc_data *nd, unsigned char *buf) {
- struct guild *g=NULL;
- int view_class;
-
- nullpo_retr(0, nd);
-
- memset(buf,0,packet_len_table[0x78]);
-
- if (nd->class_ == 722 && nd->u.scr.guild_id > 0)
- g=guild_search(nd->u.scr.guild_id);
-
- if(mobdb_checkid(nd->class_) &&
- pcdb_checkid((view_class = mob_get_viewclass(nd->class_)))) {
- //Disguised player sprite
-#if PACKETVER < 4
- memset(buf,0,packet_len_table[0x78]);
-
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=nd->bl.id;
- WBUFW(buf,6)=nd->speed;
- WBUFW(buf,8)=nd->sc.opt1;
- WBUFW(buf,10)=nd->sc.opt2;
- WBUFW(buf,12)=nd->sc.option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(nd->class_);
- WBUFW(buf,18)=mob_get_weapon(nd->class_);
- WBUFW(buf,20)=mob_get_head_buttom(nd->class_);
- WBUFW(buf,22)=mob_get_shield(nd->class_);
- WBUFW(buf,24)=mob_get_head_top(nd->class_);
- WBUFW(buf,26)=mob_get_head_mid(nd->class_);
- WBUFW(buf,28)=mob_get_hair_color(nd->class_);
- WBUFW(buf,30)=mob_get_clothes_color(nd->class_);
- WBUFW(buf,32)|=nd->ud.dir&0x0f; // head direction
- if (g) {
- WBUFL(buf,34)=g->guild_id;
- WBUFL(buf,38)=g->emblem_id;
- }
- WBUFW(buf,42)=nd->sc.opt3;
- WBUFB(buf,44)=0; // karma
- WBUFB(buf,45)=mob_get_sex(nd->class_);
- WBUFPOS(buf,46,nd->bl.x,nd->bl.y);
- WBUFB(buf,48)|=nd->ud.dir&0x0f;
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=0; // dead or sit state
- WBUFW(buf,52)=50; // No level info.
-
- return packet_len_table[0x78];
#else
- // Use 0x1d8 packet for monsters with player sprites [Valaris]
- memset(buf,0,packet_len_table[0x1d8]);
-
- WBUFW(buf,0)=0x1d8;
- WBUFL(buf,2)=nd->bl.id;
- WBUFW(buf,6)=nd->speed;
- WBUFW(buf,8)=nd->sc.opt1;
- WBUFW(buf,10)=nd->sc.opt2;
- WBUFW(buf,12)=nd->sc.option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(nd->class_);
- WBUFW(buf,18)=mob_get_weapon(nd->class_);
- WBUFW(buf,20)=mob_get_shield(nd->class_);
- WBUFW(buf,22)=mob_get_head_buttom(nd->class_);
- WBUFW(buf,24)=mob_get_head_top(nd->class_);
- WBUFW(buf,26)=mob_get_head_mid(nd->class_);
- WBUFW(buf,28)=mob_get_hair_color(nd->class_);
- WBUFW(buf,30)=mob_get_clothes_color(nd->class_);
- WBUFW(buf,32)|=nd->ud.dir&0x0f; // head direction
- WBUFL(buf,34)=0; // guild id
- WBUFW(buf,38)=0; // emblem id
- WBUFW(buf,40)=0; // manner
- WBUFW(buf,42)=nd->sc.opt3;
- WBUFB(buf,44)=0; // karma
- WBUFB(buf,45)=mob_get_sex(nd->class_);
- WBUFPOS(buf,46,nd->bl.x,nd->bl.y);
- WBUFB(buf,48)|=nd->ud.dir&0x0f;
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=0; // dead or sit state
- WBUFW(buf,52)=50; //No level data.
-
- return packet_len_table[0x1d8];
-#endif
- }
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=nd->bl.id;
- WBUFW(buf,6)=nd->speed;
- WBUFW(buf,14)=nd->class_;
- if (g) {
- WBUFL(buf,22)=g->emblem_id;
- WBUFL(buf,26)=g->guild_id;
- // pc packet says the actual location of these are, but they are not. Why the discordance? [Skotlex]
- // WBUFL(buf,34)=g->emblem_id;
- // WBUFL(buf,38)=g->guild_id;
- }
- WBUFPOS(buf,46,nd->bl.x,nd->bl.y);
- WBUFB(buf,48)|=nd->ud.dir&0x0f;
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
-
- return packet_len_table[0x78];
-}
-
-// NPC Walking [Valaris]
-static int clif_npc007b(struct npc_data *nd, unsigned char *buf) {
- struct guild *g=NULL;
- int view_class;
-
- nullpo_retr(0, nd);
-
- memset(buf,0,packet_len_table[0x7b]);
-
- if (nd->class_ == 722 && nd->u.scr.guild_id > 0)
- g=guild_search(nd->u.scr.guild_id);
-
- if(mobdb_checkid(nd->class_) &&
- pcdb_checkid((view_class = mob_get_viewclass(nd->class_)))) {
- //Disguised player sprite
-#if PACKETVER < 4
memset(buf,0,packet_len_table[0x7b]);
-
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=nd->bl.id;
- WBUFW(buf,6)=nd->speed;
- WBUFW(buf,8)=nd->sc.opt1;
- WBUFW(buf,10)=nd->sc.opt2;
- WBUFW(buf,12)=nd->sc.option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(nd->class_);
- WBUFW(buf,18)=mob_get_weapon(nd->class_);
- WBUFW(buf,20)=mob_get_head_buttom(nd->class_);
- WBUFL(buf,22)=gettick();
- WBUFW(buf,26)=mob_get_shield(nd->class_);
- WBUFW(buf,28)=mob_get_head_top(nd->class_);
- WBUFW(buf,30)=mob_get_head_mid(nd->class_);
- WBUFW(buf,32)=mob_get_hair_color(nd->class_);
- WBUFW(buf,34)=mob_get_clothes_color(nd->class_);
- WBUFW(buf,36)=nd->ud.dir&0x0f; // head direction
- if (g) {
- WBUFL(buf,38)=g->guild_id;
- WBUFL(buf,42)=g->emblem_id;
- }
- WBUFW(buf,46)=nd->sc.opt3;
- WBUFB(buf,48)=0; // karma
- WBUFB(buf,49)=mob_get_sex(nd->class_);
- WBUFPOS2(buf,50,nd->bl.x,nd->bl.y,nd->ud.to_x,nd->ud.to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=50; //Ehm.. no level data.
-
- return packet_len_table[0x7b];
-#else
- // Use 0x1da packet for monsters with player sprites [Valaris]
- memset(buf,0,packet_len_table[0x1da]);
- WBUFW(buf,0)=0x1da;
- WBUFL(buf,2)=nd->bl.id;
- WBUFW(buf,6)=nd->speed;
- WBUFW(buf,8)=nd->sc.opt1;
- WBUFW(buf,10)=nd->sc.opt2;
- WBUFW(buf,12)=nd->sc.option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(nd->class_);
- WBUFW(buf,18)=mob_get_weapon(nd->class_);
- WBUFW(buf,20)=mob_get_shield(nd->class_);
- WBUFW(buf,22)=mob_get_head_buttom(nd->class_);
- WBUFL(buf,24)=gettick();
- WBUFW(buf,28)=mob_get_head_top(nd->class_);
- WBUFW(buf,30)=mob_get_head_mid(nd->class_);
- WBUFW(buf,32)=mob_get_hair_color(nd->class_);
- WBUFW(buf,34)=mob_get_clothes_color(nd->class_);
- WBUFW(buf,36)=nd->ud.dir&0x0f; // head direction
- if (g) {
- WBUFL(buf,38)=g->guild_id;
- WBUFW(buf,42)=g->emblem_id;
+ WBUFW(buf,0)=0x7b;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,46)=sc->opt3;
}
- WBUFW(buf,44)=0; // manner
- WBUFW(buf,46)=nd->sc.opt3;
- WBUFB(buf,48)=0; // karma
- WBUFB(buf,49)=mob_get_sex(nd->class_);
- WBUFPOS2(buf,50,nd->bl.x,nd->bl.y,nd->ud.to_x,nd->ud.to_y);
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style;
+ WBUFW(buf,18)=vd->weapon;
+ WBUFW(buf,20)=vd->head_bottom;
+ WBUFL(buf,22)=gettick();
+ WBUFW(buf,26)=vd->shield;
+ WBUFW(buf,28)=vd->head_top;
+ WBUFW(buf,30)=vd->head_mid;
+ WBUFW(buf,32)=vd->hair_color;
+ WBUFW(buf,34)=vd->cloth_color;
+ WBUFW(buf,36)=sd?sd->head_dir:unit_getdir(bl);
+ WBUFL(buf,38)=guild_id;
+ WBUFL(buf,42)=emblem_id;
+ if (sd)
+ WBUFB(buf,48)=sd->status.karma;
+ WBUFB(buf,49)=vd->sex;
+ WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
WBUFB(buf,56)=5;
WBUFB(buf,57)=5;
- WBUFW(buf,58)=50; //No level data.
+ WBUFW(buf,58)=clif_setlevel(lv);
- return packet_len_table[0x1da];
+ return packet_len_table[0x7b];
#endif
}
+ //Non-player sprites only require a few fields.
+ memset(buf,0,packet_len_table[0x7b]);
WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=nd->bl.id;
- WBUFW(buf,6)=nd->speed;
- WBUFW(buf,14)=nd->class_;
- if (g) {
- WBUFL(buf,22)=g->emblem_id;
- WBUFL(buf,26)=g->guild_id;
- // pc packet says the actual location of these are, but they are not. Why the discordance? [Skotlex]
- // WBUFL(buf,38)=g->emblem_id;
- // WBUFL(buf,42)=g->guild_id;
- }
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,46)=sc->opt3;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style; //For pets
WBUFL(buf,22)=gettick();
- WBUFPOS2(buf,50,nd->bl.x,nd->bl.y,nd->ud.to_x,nd->ud.to_y);
+ WBUFW(buf,26)=vd->shield; //Pet armor
+ WBUFW(buf,36)=unit_getdir(bl);
+ WBUFL(buf,38)=guild_id;
+ WBUFL(buf,42)=emblem_id;
+ WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
WBUFB(buf,56)=5;
WBUFB(buf,57)=5;
+ WBUFW(buf,58)=clif_setlevel(lv);
return packet_len_table[0x7b];
}
-/*==========================================
- *
- *------------------------------------------
- */
-static int clif_pet0078(struct pet_data *pd, unsigned char *buf) {
- int view_class,level;
-
- nullpo_retr(0, pd);
-
- level = status_get_lv(&pd->bl);
- view_class = mob_get_viewclass(pd->class_);
- if(pcdb_checkid(view_class)) {
-#if PACKETVER < 4
- memset(buf,0,packet_len_table[0x78]);
-
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=pd->bl.id;
- WBUFW(buf,6)=pd->speed;
- WBUFW(buf,8)= 0; //opt1
- WBUFW(buf,10)= 0; //opt2
- WBUFW(buf,12)=pd->db->option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(pd->class_);
- WBUFW(buf,18)=mob_get_weapon(pd->class_);
- WBUFW(buf,20)=mob_get_head_buttom(pd->class_);
- WBUFW(buf,22)=mob_get_shield(pd->class_);
- WBUFW(buf,24)=mob_get_head_top(pd->class_);
- WBUFW(buf,26)=mob_get_head_mid(pd->class_);
- WBUFW(buf,28)=mob_get_hair_color(pd->class_);
- WBUFW(buf,30)=mob_get_clothes_color(pd->class_);
- WBUFW(buf,32)|=pd->ud.dir&0x0f; // head direction
- WBUFL(buf,34)=0; //Guild id
- WBUFL(buf,38)=0; //Guild emblem
- WBUFW(buf,42)=0; //opt3;
- WBUFB(buf,44)=0; // karma
- WBUFB(buf,45)=mob_get_sex(pd->class_);
- WBUFPOS(buf,46,pd->bl.x,pd->bl.y);
- WBUFB(buf,48)|=pd->ud.dir&0x0f;
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=0; // dead or sit state
- WBUFW(buf,52)=clif_setlevel(level);
-
- return packet_len_table[0x78];
-#else
- // Use 0x1d8 packet for pets with player sprites [Valaris]
- memset(buf,0,packet_len_table[0x1d8]);
-
- WBUFW(buf,0)=0x1d8;
- WBUFL(buf,2)=pd->bl.id;
- WBUFW(buf,6)=pd->speed;
- WBUFW(buf,8)=0; // opt1
- WBUFW(buf,10)=0; // opt2
- WBUFW(buf,12)=pd->db->option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(pd->class_);
- WBUFW(buf,18)=mob_get_weapon(pd->class_);
- WBUFW(buf,20)=mob_get_shield(pd->class_);
- WBUFW(buf,22)=mob_get_head_buttom(pd->class_);
- WBUFW(buf,24)=mob_get_head_top(pd->class_);
- WBUFW(buf,26)=mob_get_head_mid(pd->class_);
- WBUFW(buf,28)=mob_get_hair_color(pd->class_);
- WBUFW(buf,30)=mob_get_clothes_color(pd->class_);
- WBUFW(buf,32)|=pd->ud.dir&0x0f; // head direction
- WBUFL(buf,34)=0; // guild id
- WBUFW(buf,38)=0; // emblem id
- WBUFW(buf,40)=0; // manner
- WBUFW(buf,42)=0; // opt3
- WBUFB(buf,44)=0; // karma
- WBUFB(buf,45)=mob_get_sex(pd->class_);
- WBUFPOS(buf,46,pd->bl.x,pd->bl.y);
- WBUFB(buf,48)|=pd->ud.dir&0x0f;
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=0; // dead or sit state
- WBUFW(buf,52)=clif_setlevel(level);
-
- return packet_len_table[0x1d8];
-#endif
+//Modifies the buffer for disguise characters and sends it to self.
+//Flag = 0: change id to negative, buf will have disguise data.
+//Flag = 1: change id to positive, class and option to make your own char invisible.
+//Luckily, the offsets that need to be changed are the same in packets 0x78, 0x7b, 0x1d8 and 0x1da
+static void clif_setdisguise(struct map_session_data *sd, unsigned char *buf,int len, int flag) {
+ if (flag) {
+ WBUFL(buf,2)=sd->bl.id;
+ WBUFW(buf,12)=OPTION_INVISIBLE;
+ WBUFW(buf,14)=sd->status.class_;
} else {
- memset(buf,0,packet_len_table[0x78]);
-
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=pd->bl.id;
- WBUFW(buf,6)=pd->speed;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=battle_config.pet_hair_style;
- if(pd->equip && (view_class = itemdb_viewid(pd->equip)) > 0)
- WBUFW(buf,20)=view_class;
- else
- WBUFW(buf,20)=pd->equip;
- WBUFPOS(buf,46,pd->bl.x,pd->bl.y);
- WBUFB(buf,48)|=pd->ud.dir&0x0f;
- WBUFB(buf,49)=0;
- WBUFB(buf,50)=0;
- WBUFW(buf,52)=clif_setlevel(level);
-
- return packet_len_table[0x78];
+ WBUFL(buf,2)=-sd->bl.id;
}
+ clif_send(buf, len, &sd->bl, SELF);
}
/*==========================================
- *
+ * クラスチェンジ typeはMobの場合は1で他は0?
*------------------------------------------
*/
-static int clif_pet007b(struct pet_data *pd, unsigned char *buf) {
- int view_class,level;
-
- nullpo_retr(0, pd);
-
- level = status_get_lv(&pd->bl);
- view_class = mob_get_viewclass(pd->class_);
- if(pcdb_checkid(view_class)) {
-#if PACKETVER < 4
- memset(buf,0,packet_len_table[0x7b]);
-
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=pd->bl.id;
- WBUFW(buf,6)=pd->speed;
- WBUFW(buf,8)= 0; //opt1;
- WBUFW(buf,10)= 0; //opt2;
- WBUFW(buf,12)=pd->db->option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(pd->class_);
- WBUFW(buf,18)=mob_get_weapon(pd->class_);
- WBUFW(buf,20)=mob_get_head_buttom(pd->class_);
- WBUFL(buf,22)=gettick();
- WBUFW(buf,26)=mob_get_shield(pd->class_);
- WBUFW(buf,28)=mob_get_head_top(pd->class_);
- WBUFW(buf,30)=mob_get_head_mid(pd->class_);
- WBUFW(buf,32)=mob_get_hair_color(pd->class_);
- WBUFW(buf,34)=mob_get_clothes_color(pd->class_);
- WBUFW(buf,36)=pd->ud.dir&0x0f; // head direction
- WBUFL(buf,38)=0; // guild id
- WBUFL(buf,42)=0; // emblem id
- WBUFW(buf,46)=0; // opt3;
- WBUFB(buf,48)=0; // karma
- WBUFB(buf,49)=mob_get_sex(pd->class_);
- WBUFPOS2(buf,50,pd->bl.x,pd->bl.y,pd->ud.to_x,pd->ud.to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=0; //0? These are always five for mobs and pets, /hmm [Skotlex]
- WBUFB(buf,57)=0;
- WBUFW(buf,58)=clif_setlevel(level);
-
- return packet_len_table[0x7b];
-#else
- // Use 0x1da packet for monsters with player sprites [Valaris]
- memset(buf,0,packet_len_table[0x1da]);
-
- WBUFW(buf,0)=0x1da;
- WBUFL(buf,2)=pd->bl.id;
- WBUFW(buf,6)=pd->speed;
- WBUFW(buf,8)=0; // opt1
- WBUFW(buf,10)=0; // opt2
- WBUFW(buf,12)=pd->db->option;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=mob_get_hair(pd->class_);
- WBUFW(buf,18)=mob_get_weapon(pd->class_);
- WBUFW(buf,20)=mob_get_shield(pd->class_);
- WBUFW(buf,22)=mob_get_head_buttom(pd->class_);
- WBUFL(buf,24)=gettick();
- WBUFW(buf,28)=mob_get_head_top(pd->class_);
- WBUFW(buf,30)=mob_get_head_mid(pd->class_);
- WBUFW(buf,32)=mob_get_hair_color(pd->class_);
- WBUFW(buf,34)=mob_get_clothes_color(pd->class_);
- WBUFW(buf,36)=pd->ud.dir&0x0f; // head direction
- WBUFL(buf,38)=0; // guild id
- WBUFW(buf,42)=0; // emblem id
- WBUFW(buf,44)=0; // manner
- WBUFW(buf,46)=0; // opt3
- WBUFB(buf,48)=0; // karma
- WBUFB(buf,49)=mob_get_sex(pd->class_);
- WBUFPOS2(buf,50,pd->bl.x,pd->bl.y,pd->ud.to_x,pd->ud.to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=0;
- WBUFB(buf,57)=0;
- WBUFW(buf,58)=clif_setlevel(level);
-
- return packet_len_table[0x1da];
-#endif
- } else {
- // Use 0x7b packet for pets sprites [Valaris]
- memset(buf,0,packet_len_table[0x7b]);
+int clif_class_change(struct block_list *bl,int class_,int type)
+{
+ unsigned char buf[16];
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=pd->bl.id;
- WBUFW(buf,6)=pd->speed;
- WBUFW(buf,14)=view_class;
- WBUFW(buf,16)=battle_config.pet_hair_style;
- if (pd->equip && (view_class = itemdb_viewid(pd->equip)) > 0)
- WBUFW(buf,20)=view_class;
- else
- WBUFW(buf,20)=pd->equip;
- WBUFL(buf,22)=gettick();
- WBUFPOS2(buf,50,pd->bl.x,pd->bl.y,pd->ud.to_x,pd->ud.to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=0;
- WBUFB(buf,57)=0;
- WBUFW(buf,58)=clif_setlevel(level);
+ nullpo_retr(0, bl);
- return packet_len_table[0x7b];
+ if(!pcdb_checkid(class_)) {
+ WBUFW(buf,0)=0x1b0;
+ WBUFL(buf,2)=bl->id;
+ WBUFB(buf,6)=type;
+ WBUFL(buf,7)=class_;
+ clif_send(buf,packet_len_table[0x1b0],bl,AREA);
}
+ return 0;
}
/*==========================================
@@ -1737,7 +1135,7 @@ static int clif_set01e1(struct map_session_data *sd, unsigned char *buf) {
*------------------------------------------
*/
static int clif_set0192(int fd, int m, int x, int y, int type) {
- WFIFOHEAD(fd, packet_len_table[0x192]);
+ WFIFOHEAD(fd, packet_len_table[0x192]);
WFIFOW(fd,0) = 0x192;
WFIFOW(fd,2) = x;
WFIFOW(fd,4) = y;
@@ -1750,7 +1148,7 @@ static int clif_set0192(int fd, int m, int x, int y, int type) {
// new and improved weather display [Valaris]
int clif_weather_sub(int fd, int type) {
- WFIFOHEAD(fd, packet_len_table[0x1f3]);
+ WFIFOHEAD(fd, packet_len_table[0x1f3]);
WFIFOW(fd,0) = 0x1f3;
WFIFOL(fd,2) = -10;
WFIFOL(fd,6) = type;
@@ -1766,15 +1164,22 @@ int clif_weather(int m) {
for(i = 0; i < fd_max; i++) {
if (session[i] && (sd = session[i]->session_data) != NULL && sd->state.auth && sd->bl.m == m) {
- WFIFOHEAD(sd->fd, packet_len_table[0x80]);
+ WFIFOHEAD(sd->fd, packet_len_table[0x80]);
WFIFOW(sd->fd,0) = 0x80;
WFIFOL(sd->fd,2) = -10;
WFIFOB(sd->fd,6) = 0;
WFIFOSET(sd->fd,packet_len_table[0x80]);
- if (map[sd->bl.m].flag.snow || map[sd->bl.m].flag.clouds || map[sd->bl.m].flag.fog || map[sd->bl.m].flag.fireworks ||
- map[sd->bl.m].flag.sakura || map[sd->bl.m].flag.leaves || map[sd->bl.m].flag.rain || map[sd->bl.m].flag.clouds2) {
- WFIFOHEAD(sd->fd, packet_len_table[0x7c]);
+ if (map[sd->bl.m].flag.snow
+ || map[sd->bl.m].flag.clouds
+ || map[sd->bl.m].flag.fog
+ || map[sd->bl.m].flag.fireworks
+ || map[sd->bl.m].flag.sakura
+ || map[sd->bl.m].flag.leaves
+ || map[sd->bl.m].flag.rain
+ || map[sd->bl.m].flag.clouds2
+ ) {
+ WFIFOHEAD(sd->fd, packet_len_table[0x7c]);
WFIFOW(sd->fd,0)=0x7c;
WFIFOL(sd->fd,2)=-10;
WFIFOW(sd->fd,6)=0;
@@ -1817,51 +1222,27 @@ int clif_weather(int m) {
*------------------------------------------
*/
int clif_spawnpc(struct map_session_data *sd) {
- unsigned char buf[128];
-
- nullpo_retr(0, sd);
-
- // Avoid bots/modified clients to view hidden GMs. [Lance]
- if(!pc_isGM(sd) || !sd->status.option&OPTION_INVISIBLE){
- clif_set0078(sd, buf);
-
-#if PACKETVER < 4
- WBUFW(buf, 0) = 0x79;
- WBUFW(buf,51) = clif_setlevel(sd->status.base_level);
- clif_send(buf, packet_len_table[0x79], &sd->bl, AREA_WOS);
-#else
- WBUFW(buf, 0) = 0x1d9;
- WBUFW(buf,51) = clif_setlevel(sd->status.base_level);
- clif_send(buf, packet_len_table[0x1d9], &sd->bl, AREA_WOS);
-#endif
-
- if(sd->disguise > 0) {
- int len;
- memset(buf,0,packet_len_table[0x7c]);
- WBUFW(buf,0)=0x7c;
- WBUFL(buf,2)=-sd->bl.id;
- WBUFW(buf,6)=sd->speed;
- WBUFW(buf,12)=sd->sc.option;
- WBUFW(buf,20)=sd->disguise;
- WBUFPOS(buf,36,sd->bl.x,sd->bl.y);
- clif_send(buf,packet_len_table[0x7c],&sd->bl,AREA);
-
- len = clif_dis0078(sd,buf);
- clif_send(buf,len,&sd->bl,AREA);
- }
- }
if (sd->spiritball > 0)
clif_spiritball(sd);
-
- if (sd->status.guild_id > 0) { // force display of guild emblem [Valaris]
+
+ //Why most it be forced? Doesn't the client ever requests it?
+ //This sounds like more bandwidth wasted than necessary... [Skotlex]
+ if (sd->status.guild_id > 0)
+ { // force display of guild emblem [Valaris]
struct guild *g = guild_search(sd->status.guild_id);
- if (g)
- clif_guild_emblem(sd,g);
- } // end addition [Valaris]
+ if (g) clif_guild_emblem(sd,g);
+ }
- if (map[sd->bl.m].flag.snow || map[sd->bl.m].flag.clouds || map[sd->bl.m].flag.fog || map[sd->bl.m].flag.fireworks ||
- map[sd->bl.m].flag.sakura || map[sd->bl.m].flag.leaves || map[sd->bl.m].flag.rain || map[sd->bl.m].flag.clouds2) {
+ if (map[sd->bl.m].flag.snow
+ || map[sd->bl.m].flag.clouds
+ || map[sd->bl.m].flag.fog
+ || map[sd->bl.m].flag.fireworks
+ || map[sd->bl.m].flag.sakura
+ || map[sd->bl.m].flag.leaves
+ || map[sd->bl.m].flag.rain
+ || map[sd->bl.m].flag.clouds2)
+ {
WFIFOHEAD(sd->fd, packet_len_table[0x7c]);
WFIFOW(sd->fd,0)=0x7c;
WFIFOL(sd->fd,2)=-10;
@@ -1906,151 +1287,64 @@ int clif_spawnpc(struct map_session_data *sd) {
clif_status_load(&sd->bl, SI_NIGHT, 0);
sd->state.night = 0;
}
-
- if(sd->state.size==2) // tiny/big players [Valaris]
- clif_specialeffect(&sd->bl,423,0);
- else if(sd->state.size==1)
- clif_specialeffect(&sd->bl,421,0);
-
return 0;
}
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_spawnnpc(struct npc_data *nd)
+int clif_spawn(struct block_list *bl)
{
- unsigned char buf[64];
- int len;
-
- nullpo_retr(0, nd);
-
- if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS)
+ unsigned char buf[128];
+ struct view_data *vd;
+ nullpo_retr(0, bl);
+ vd = status_get_viewdata(bl);
+ if (!vd || vd->class_ == INVISIBLE_CLASS)
return 0;
+ clif_set0078(bl, vd, buf);
- if(!mobdb_checkid(nd->class_) ||
- !pcdb_checkid(mob_get_viewclass(nd->class_))) {
- //Normal npcs.
- memset(buf,0,packet_len_table[0x7c]);
-
- WBUFW(buf,0)=0x7c;
- WBUFL(buf,2)=nd->bl.id;
- WBUFW(buf,6)=nd->speed;
- WBUFW(buf,20)=nd->class_;
- WBUFPOS(buf,36,nd->bl.x,nd->bl.y);
-
- clif_send(buf,packet_len_table[0x7c],&nd->bl,AREA);
- }
- len = clif_npc0078(nd,buf);
- clif_send(buf,len,&nd->bl,AREA);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_spawnmob(struct mob_data *md)
-{
- unsigned char buf[64];
- int len;
- int viewclass = mob_get_viewclass(md->class_);
-
- if (!pcdb_checkid(viewclass)) {
- memset(buf,0,packet_len_table[0x7c]);
-
- WBUFW(buf,0)=0x7c;
- WBUFL(buf,2)=md->bl.id;
- WBUFW(buf,6)=md->speed;
- WBUFW(buf,8)=md->sc.opt1;
- WBUFW(buf,10)=md->sc.opt2;
- WBUFW(buf,12)=md->sc.option;
- WBUFW(buf,20)=viewclass;
- WBUFPOS(buf,36,md->bl.x,md->bl.y);
- clif_send(buf,packet_len_table[0x7c],&md->bl,AREA);
+#if PACKETVER > 3
+ if (WBUFW(buf,0)==0x78) {
+ WBUFW(buf, 0) = 0x79;
+ WBUFW(buf,51) = WBUFW(buf,52); //Lv is placed on offset 52
+ clif_send(buf, packet_len_table[0x79], bl, AREA_WOS);
+ if (disguised(bl))
+ clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x79], 0);
+ } else {
+#endif
+ WBUFW(buf, 0) = 0x1d9;
+ WBUFW(buf,51) = WBUFW(buf,52); //Lv is placed on offset 52
+ clif_send(buf, packet_len_table[0x1d9], bl, AREA_WOS);
+ if (disguised(bl))
+ clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x1d9], 0);
+#if PACKETVER > 3
}
+#endif
- len = clif_mob0078(md,buf);
- clif_send(buf,len,&md->bl,AREA);
-
- if(battle_config.save_clothcolor && pcdb_checkid(viewclass) && mob_get_clothes_color(md->class_) > 0) // [Valaris]
- clif_changelook(&md->bl, LOOK_CLOTHES_COLOR, mob_get_clothes_color(md->class_));
-
- if (mob_get_equip(md->class_) > 0) // mob equipment [Valaris]
- clif_mob_equip(md,mob_get_equip(md->class_));
-
- if(md->special_state.size==2) // tiny/big mobs [Valaris]
- clif_specialeffect(&md->bl,423,0);
- else if(md->special_state.size==1)
- clif_specialeffect(&md->bl,421,0);
-
- return 0;
-}
-
-// pet
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_spawnpet(struct pet_data *pd)
-{
- unsigned char buf[64];
- int len;
- int viewclass = mob_get_viewclass(pd->class_);
-
- if (!pcdb_checkid(viewclass)) {
- memset(buf,0,packet_len_table[0x7c]);
-
- WBUFW(buf,0)=0x7c;
- WBUFL(buf,2)=pd->bl.id;
- WBUFW(buf,6)=pd->speed;
- WBUFW(buf,20)=viewclass;
- WBUFPOS(buf,36,pd->bl.x,pd->bl.y);
-
- clif_send(buf,packet_len_table[0x7c],&pd->bl,AREA);
+ if (vd->cloth_color)
+ clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
+
+ switch (bl->type)
+ {
+ case BL_PC:
+ {
+ TBL_PC *sd = ((TBL_PC*)bl);
+ clif_spawnpc(sd);
+ if(sd->state.size==2) // tiny/big players [Valaris]
+ clif_specialeffect(bl,423,0);
+ else if(sd->state.size==1)
+ clif_specialeffect(bl,421,0);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB *md = ((TBL_MOB*)bl);
+ if(md->special_state.size==2) // tiny/big mobs [Valaris]
+ clif_specialeffect(&md->bl,423,0);
+ else if(md->special_state.size==1)
+ clif_specialeffect(&md->bl,421,0);
+ }
+ break;
}
-
- len = clif_pet0078(pd,buf);
- clif_send(buf,len,&pd->bl,AREA);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_movepet(struct pet_data *pd) {
- unsigned char buf[256];
- int len;
-
- nullpo_retr(0, pd);
-
- len = clif_pet007b(pd,buf);
- clif_send(buf,len,&pd->bl,AREA);
-
- return 0;
-}
-
-/*==========================================
- * npc walking [Valaris]
- *------------------------------------------
- */
-int clif_movenpc(struct npc_data *nd) {
- unsigned char buf[256];
- int len;
-
- nullpo_retr(0, nd);
-
- len = clif_npc007b(nd,buf);
- clif_send(buf,len,&nd->bl,AREA);
-
return 0;
}
-
/*==========================================
*
*------------------------------------------
@@ -2062,7 +1356,7 @@ int clif_servertick(struct map_session_data *sd)
nullpo_retr(0, sd);
fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x7f]);
+ WFIFOHEAD(fd, packet_len_table[0x7f]);
WFIFOW(fd,0)=0x7f;
WFIFOL(fd,2)=sd->server_tick;
WFIFOSET(fd,packet_len_table[0x7f]);
@@ -2095,20 +1389,20 @@ int clif_walkok(struct map_session_data *sd)
*
*------------------------------------------
*/
-int clif_movechar(struct map_session_data *sd) {
- int fd;
- int len;
+int clif_movepc(struct map_session_data *sd) {
unsigned char buf[256];
nullpo_retr(0, sd);
- fd = sd->fd;
-
- len = clif_set007b(sd, buf);
- clif_send(buf, len, &sd->bl, AREA_WOS);
-
- if (map[sd->bl.m].flag.snow || map[sd->bl.m].flag.clouds || map[sd->bl.m].flag.fog || map[sd->bl.m].flag.fireworks ||
- map[sd->bl.m].flag.sakura || map[sd->bl.m].flag.leaves || map[sd->bl.m].flag.rain || map[sd->bl.m].flag.clouds2) {
+ if (map[sd->bl.m].flag.snow
+ || map[sd->bl.m].flag.clouds
+ || map[sd->bl.m].flag.fog
+ || map[sd->bl.m].flag.fireworks
+ || map[sd->bl.m].flag.sakura
+ || map[sd->bl.m].flag.leaves
+ || map[sd->bl.m].flag.rain
+ || map[sd->bl.m].flag.clouds2
+ ) {
memset(buf,0,packet_len_table[0x7b]);
WBUFW(buf,0)=0x7b;
WBUFL(buf,2)=-10;
@@ -2121,30 +1415,66 @@ int clif_movechar(struct map_session_data *sd) {
WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
WBUFB(buf,56)=5;
WBUFB(buf,57)=5;
- clif_send(buf, len, &sd->bl, SELF);
- }
-
- if(sd->disguise) {
- memset(buf,0,packet_len_table[0x7b]);
- len = clif_dis007b(sd, buf);
- clif_send(buf, len, &sd->bl, AREA);
- return 0;
+ clif_send(buf, packet_len_table[0x7b], &sd->bl, SELF);
}
- //Stupid client that needs this resent every time someone walks :X
- if(battle_config.save_clothcolor && sd->status.clothes_color > 0 && ((sd->view_class != JOB_WEDDING && sd->view_class !=JOB_XMAS) ||
- (sd->view_class==JOB_WEDDING && !battle_config.wedding_ignorepalette) || (sd->view_class==JOB_XMAS && !battle_config.xmas_ignorepalette)))
- clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+ return 0;
+}
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_move(struct block_list *bl) {
+ struct view_data *vd;
+ struct unit_data *ud;
+ unsigned char buf[256];
+ int len;
- if(sd->state.size==2) // tiny/big players [Valaris]
- clif_specialeffect(&sd->bl,423,0);
- else if(sd->state.size==1)
- clif_specialeffect(&sd->bl,421,0);
+ nullpo_retr(0, bl);
+
+ vd = status_get_viewdata(bl);
+ if (!vd || vd->class_ == INVISIBLE_CLASS)
+ return 0;
+
+ ud = unit_bl2ud(bl);
+ nullpo_retr(0, ud);
+
+ len = clif_set007b(bl,vd,ud,buf);
+ clif_send(buf,len,bl,AREA_WOS);
+ if (disguised(bl))
+ clif_setdisguise((TBL_PC*)bl, buf, len, 0);
+
+ //Stupid client that needs this resent every time someone walks :X
+ if(vd->cloth_color)
+ clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
+ switch(bl->type)
+ {
+ case BL_PC:
+ {
+ TBL_PC *sd = ((TBL_PC*)bl);
+ clif_movepc(sd);
+ if(sd->state.size==2) // tiny/big players [Valaris]
+ clif_specialeffect(&sd->bl,423,0);
+ else if(sd->state.size==1)
+ clif_specialeffect(&sd->bl,421,0);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB *md = ((TBL_MOB*)bl);
+ if(md->special_state.size==2) // tiny/big mobs [Valaris]
+ clif_specialeffect(&md->bl,423,0);
+ else if(md->special_state.size==1)
+ clif_specialeffect(&md->bl,421,0);
+ }
+ break;
+ }
return 0;
}
+
/*==========================================
* Delays the map_quit of a player after they are disconnected. [Skotlex]
*------------------------------------------
@@ -2269,16 +1599,14 @@ int clif_fixpos(struct block_list *bl) {
nullpo_retr(0, bl);
WBUFW(buf,0)=0x88;
-
- if (bl->type ==BL_PC && ((struct map_session_data *)bl)->disguise)
- WBUFL(buf,2)=-bl->id;
- else
- WBUFL(buf,2)=bl->id;
-
+ WBUFL(buf,2)=bl->id;
WBUFW(buf,6)=bl->x;
WBUFW(buf,8)=bl->y;
clif_send(buf, packet_len_table[0x88], bl, AREA);
-
+ if (disguised(bl)) {
+ WBUFL(buf,2)=-bl->id;
+ clif_send(buf, packet_len_table[0x88], bl, SELF);
+ }
return 0;
}
@@ -2312,7 +1640,7 @@ int clif_buylist(struct map_session_data *sd, struct npc_data *nd) {
nullpo_retr(0, nd);
fd=sd->fd;
- WFIFOHEAD(fd, 200 * 11 + 4);
+ WFIFOHEAD(fd, 200 * 11 + 4);
WFIFOW(fd,0)=0xc6;
for(i=0;nd->u.shop_item[i].nameid > 0;i++){
id = itemdb_search(nd->u.shop_item[i].nameid);
@@ -2398,7 +1726,7 @@ int clif_scriptnext(struct map_session_data *sd,int npcid) {
nullpo_retr(0, sd);
fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xb5]);
+ WFIFOHEAD(fd, packet_len_table[0xb5]);
WFIFOW(fd,0)=0xb5;
WFIFOL(fd,2)=npcid;
WFIFOSET(fd,packet_len_table[0xb5]);
@@ -2455,7 +1783,7 @@ int clif_scriptinput(struct map_session_data *sd, int npcid) {
nullpo_retr(0, sd);
fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x142]);
+ WFIFOHEAD(fd, packet_len_table[0x142]);
WFIFOW(fd,0)=0x142;
WFIFOL(fd,2)=npcid;
WFIFOSET(fd,packet_len_table[0x142]);
@@ -2473,7 +1801,7 @@ int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
nullpo_retr(0, sd);
fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x1d4]);
+ WFIFOHEAD(fd, packet_len_table[0x1d4]);
WFIFOW(fd,0)=0x1d4;
WFIFOL(fd,2)=npcid;
WFIFOSET(fd,packet_len_table[0x1d4]);
@@ -2491,7 +1819,7 @@ int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int
nullpo_retr(0, sd);
fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x144]);
+ WFIFOHEAD(fd, packet_len_table[0x144]);
WFIFOW(fd,0)=0x144;
WFIFOL(fd,2)=npc_id;
WFIFOL(fd,6)=type;
@@ -2514,7 +1842,7 @@ int clif_cutin(struct map_session_data *sd, char *image, int type) {
nullpo_retr(0, sd);
fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x1b3]);
+ WFIFOHEAD(fd, packet_len_table[0x1b3]);
WFIFOW(fd,0)=0x1b3;
strncpy((char*)WFIFOP(fd,2),image,64);
WFIFOB(fd,66)=type;
@@ -3025,17 +2353,17 @@ int clif_guild_xy_single(int fd, struct map_session_data *sd)
// Guild XY locators [Valaris]
int clif_guild_xy_remove(struct map_session_data *sd)
{
-unsigned char buf[10];
+ unsigned char buf[10];
-nullpo_retr(0, sd);
+ nullpo_retr(0, sd);
-WBUFW(buf,0)=0x1eb;
-WBUFL(buf,2)=sd->status.account_id;
-WBUFW(buf,6)=-1;
-WBUFW(buf,8)=-1;
-clif_send(buf,packet_len_table[0x1eb],&sd->bl,GUILD_SAMEMAP_WOS);
+ WBUFW(buf,0)=0x1eb;
+ WBUFL(buf,2)=sd->status.account_id;
+ WBUFW(buf,6)=-1;
+ WBUFW(buf,8)=-1;
+ clif_send(buf,packet_len_table[0x1eb],&sd->bl,GUILD_SAMEMAP_WOS);
-return 0;
+ return 0;
}
/*==========================================
@@ -3283,60 +2611,91 @@ int clif_changestatus(struct block_list *bl,int type,int val)
*/
int clif_changelook(struct block_list *bl,int type,int val)
{
-
unsigned char buf[32];
struct map_session_data *sd = NULL;
-
+ struct view_data *vd;
nullpo_retr(0, bl);
-
+ vd = status_get_viewdata(bl);
+ nullpo_retr(0, vd);
+
if(bl->type == BL_PC)
sd = (struct map_session_data *)bl;
+ switch(type) {
+ case LOOK_WEAPON:
+ if (sd) clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
+ else vd->weapon = val;
+ break;
+ case LOOK_SHIELD:
+ if (sd) clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
+ else vd->shield = val;
+ break;
+ case LOOK_BASE:
+ vd->class_ = val;
+ if (vd->class_ == JOB_WEDDING || vd->class_ == JOB_XMAS)
+ vd->weapon = vd->shield = 0;
+ if (
+ (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
+ (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette)
+ )
+ vd->cloth_color = 0;
+ break;
+ case LOOK_HAIR:
+ vd->hair_style = val;
+ break;
+ case LOOK_HEAD_BOTTOM:
+ vd->head_bottom = val;
+ break;
+ case LOOK_HEAD_TOP:
+ vd->head_top = val;
+ break;
+ case LOOK_HEAD_MID:
+ vd->head_mid = val;
+ break;
+ case LOOK_HAIR_COLOR:
+ vd->hair_color = val;
+ break;
+ case LOOK_CLOTHES_COLOR:
+ if (
+ (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
+ (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette)
+ )
+ val = 0;
+ vd->cloth_color = val;
+ break;
+ case LOOK_SHOES:
+#if PACKETVER > 3
+ if (sd) {
+ int n;
+ if((n = sd->equip_index[2]) >= 0 && sd->inventory_data[n]) {
+ if(sd->inventory_data[n]->view_id > 0)
+ val = sd->inventory_data[n]->view_id;
+ else
+ val = sd->status.inventory[n].nameid;
+ }
+ val = 0;
+ }
+#endif
+ //Shoes? No packet uses this....
+ break;
+ }
#if PACKETVER < 4
- if(sd && (type == LOOK_WEAPON || type == LOOK_SHIELD) && (sd->view_class == JOB_WEDDING || sd->view_class == JOB_XMAS))
- val =0;
WBUFW(buf,0)=0xc3;
WBUFL(buf,2)=bl->id;
WBUFB(buf,6)=type;
WBUFB(buf,7)=val;
clif_send(buf,packet_len_table[0xc3],bl,AREA);
#else
- if(sd && (type == LOOK_WEAPON || type == LOOK_SHIELD || type == LOOK_SHOES)) {
+ if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
WBUFW(buf,0)=0x1d7;
WBUFL(buf,2)=bl->id;
- if(type == LOOK_SHOES) {
- WBUFB(buf,6)=9;
- if(sd->equip_index[2] >= 0 && sd->inventory_data[sd->equip_index[2]]) {
- if(sd->inventory_data[sd->equip_index[2]]->view_id > 0)
- WBUFW(buf,7)=sd->inventory_data[sd->equip_index[2]]->view_id;
- else
- WBUFW(buf,7)=sd->status.inventory[sd->equip_index[2]].nameid;
- } else
- WBUFW(buf,7)=0;
- WBUFW(buf,9)=0;
- }
- else {
- WBUFB(buf,6)=2;
- if(sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]] && sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS) {
- if(sd->inventory_data[sd->equip_index[9]]->view_id > 0)
- WBUFW(buf,7)=sd->inventory_data[sd->equip_index[9]]->view_id;
- else
- WBUFW(buf,7)=sd->status.inventory[sd->equip_index[9]].nameid;
- } else
- WBUFW(buf,7)=0;
- if(sd->equip_index[8] >= 0 && sd->equip_index[8] != sd->equip_index[9] && sd->inventory_data[sd->equip_index[8]] &&
- sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS) {
- if(sd->inventory_data[sd->equip_index[8]]->view_id > 0)
- WBUFW(buf,9)=sd->inventory_data[sd->equip_index[8]]->view_id;
- else
- WBUFW(buf,9)=sd->status.inventory[sd->equip_index[8]].nameid;
- } else
- WBUFW(buf,9)=0;
- }
+ WBUFB(buf,6)=LOOK_WEAPON;
+ WBUFW(buf,7)=vd->weapon;
+ WBUFW(buf,9)=vd->shield;
clif_send(buf,packet_len_table[0x1d7],bl,AREA);
}
- else if(sd && (type == LOOK_BASE) && (val > 255))
- {
+ else if(type == LOOK_BASE && val > 255)
+ {
WBUFW(buf,0)=0x1d7;
WBUFL(buf,2)=bl->id;
WBUFB(buf,6)=type;
@@ -3354,6 +2713,37 @@ int clif_changelook(struct block_list *bl,int type,int val)
return 0;
}
+//For the stupid cloth-dye bug. Resends the given view data
+//to the area specified by bl.
+void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area)
+{
+ unsigned char buf[32];
+#if PACKETVER < 4
+ WBUFW(buf,0)=0xc3;
+ WBUFL(buf,2)=id;
+ WBUFB(buf,6)=type;
+ WBUFB(buf,7)=val;
+ clif_send(buf,packet_len_table[0xc3],bl,area);
+#else
+ if(type == LOOK_BASE && val > 255)
+ {
+ WBUFW(buf,0)=0x1d7;
+ WBUFL(buf,2)=id;
+ WBUFB(buf,6)=type;
+ WBUFW(buf,7)=val;
+ WBUFW(buf,9)=0;
+ clif_send(buf,packet_len_table[0x1d7],bl,area);
+ } else {
+ WBUFW(buf,0)=0xc3;
+ WBUFL(buf,2)=id;
+ WBUFB(buf,6)=type;
+ WBUFB(buf,7)=val;
+ clif_send(buf,packet_len_table[0xc3],bl,area);
+ }
+#endif
+ return;
+}
+
/*==========================================
*
*------------------------------------------
@@ -3447,7 +2837,7 @@ int clif_arrow_fail(struct map_session_data *sd,int type)
nullpo_retr(0, sd);
fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x013b]);
+ WFIFOHEAD(fd, packet_len_table[0x013b]);
WFIFOW(fd,0)=0x013b;
WFIFOW(fd,2)=type;
@@ -3504,7 +2894,7 @@ int clif_statusupack(struct map_session_data *sd,int type,int ok,int val)
nullpo_retr(0, sd);
fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xbc]);
+ WFIFOHEAD(fd,packet_len_table[0xbc]);
WFIFOW(fd,0)=0xbc;
WFIFOW(fd,2)=type;
WFIFOB(fd,4)=ok;
@@ -3603,27 +2993,20 @@ int clif_changeoption(struct block_list* bl)
sc = status_get_sc(bl);
WBUFW(buf,0) = 0x119;
- if(bl->type==BL_PC && ((struct map_session_data *)bl)->disguise) {
- WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = 0;
- WBUFW(buf,8) = 0;
- WBUFW(buf,10) = OPTION_INVISIBLE;
- WBUFB(buf,12) = 0;
- clif_send(buf,packet_len_table[0x119],bl,AREA);
+ WBUFL(buf,2) = bl->id;
+ WBUFW(buf,6) = sc?sc->opt1:0;
+ WBUFW(buf,8) = sc?sc->opt2:0;
+ WBUFW(buf,10) = sc?sc->option:0;
+ WBUFB(buf,12) = 0; // ??
+ if(disguised(bl)) {
+ clif_send(buf,packet_len_table[0x119],bl,AREA_WOS);
WBUFL(buf,2) = -bl->id;
- WBUFW(buf,6) = 0;
- WBUFW(buf,8) = 0;
- WBUFW(buf,10) = sc?sc->option:0;
- WBUFB(buf,12) = 0;
- clif_send(buf,packet_len_table[0x119],bl,AREA);
- } else {
+ clif_send(buf,packet_len_table[0x119],bl,SELF);
WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = sc?sc->opt1:0;
- WBUFW(buf,8) = sc?sc->opt2:0;
- WBUFW(buf,10) = sc?sc->option:0;
- WBUFB(buf,12) = 0; // ??
+ WBUFW(buf,10) = OPTION_INVISIBLE;
+ clif_send(buf,packet_len_table[0x119],bl,SELF);
+ } else
clif_send(buf,packet_len_table[0x119],bl,AREA);
- }
return 0;
}
@@ -3638,7 +3021,7 @@ int clif_useitemack(struct map_session_data *sd,int index,int amount,int ok)
if(!ok) {
int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xa8]);
+ WFIFOHEAD(fd,packet_len_table[0xa8]);
WFIFOW(fd,0)=0xa8;
WFIFOW(fd,2)=index+2;
WFIFOW(fd,4)=amount;
@@ -3648,7 +3031,7 @@ int clif_useitemack(struct map_session_data *sd,int index,int amount,int ok)
else {
#if PACKETVER < 3
int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xa8]);
+ WFIFOHEAD(fd,packet_len_table[0xa8]);
WFIFOW(fd,0)=0xa8;
WFIFOW(fd,2)=index+2;
WFIFOW(fd,4)=amount;
@@ -3712,7 +3095,7 @@ int clif_dispchat(struct chat_data *cd,int fd)
WBUFB(buf,16)=cd->pub;
strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
if(fd){
- WFIFOHEAD(fd, WBUFW(buf,2));
+ WFIFOHEAD(fd, WBUFW(buf,2));
memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
WFIFOSET(fd,WBUFW(buf,2));
} else {
@@ -4187,73 +3570,29 @@ int clif_storageclose(struct map_session_data *sd)
void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* dstsd)
{
int len;
-
- nullpo_retv(sd);
- nullpo_retv(dstsd);
-
- // Hidden GMs will not be revealed by bots :) [Lance]
- if(!pc_isGM(dstsd) || !dstsd->status.option&OPTION_INVISIBLE){
- if(dstsd->ud.walktimer != -1){
- #if PACKETVER < 4
- WFIFOHEAD(sd->fd, packet_len_table[0x7b]);
- #else
- WFIFOHEAD(sd->fd, packet_len_table[0x1da]);
- #endif
- len = clif_set007b(dstsd,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- if(dstsd->disguise) {
- WFIFOHEAD(sd->fd,packet_len_table[0x7b]);
- len = clif_dis007b(dstsd,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- }
- } else {
-#if PACKETVER < 4
- WFIFOHEAD(sd->fd,packet_len_table[0x78]);
-#else
- WFIFOHEAD(sd->fd,packet_len_table[0x1d8]);
-#endif
- len = clif_set0078(dstsd,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- if(dstsd->disguise) {
- WFIFOHEAD(sd->fd,packet_len_table[0x7b]);
- len = clif_dis0078(dstsd,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- }
- }
- }
-
if(dstsd->chatID){
struct chat_data *cd;
cd=(struct chat_data*)map_id2bl(dstsd->chatID);
- if(cd->usersd[0]==dstsd)
+ if(cd && cd->usersd[0]==dstsd)
clif_dispchat(cd,sd->fd);
}
- if(dstsd->vender_id){
+ if(dstsd->vender_id)
clif_showvendingboard(&dstsd->bl,dstsd->message,sd->fd);
- }
+
if(dstsd->spiritball > 0) {
- WFIFOHEAD(sd->fd, packet_len_table[0x1e1]);
+ WFIFOHEAD(sd->fd, packet_len_table[0x1e1]);
clif_set01e1(dstsd,WFIFOP(sd->fd,0));
WFIFOSET(sd->fd,packet_len_table[0x1e1]);
}
- if(battle_config.save_clothcolor && dstsd->status.clothes_color > 0 && ((dstsd->view_class != JOB_WEDDING && dstsd->view_class !=JOB_XMAS) ||
- (dstsd->view_class==JOB_WEDDING && !battle_config.wedding_ignorepalette) || (dstsd->view_class==JOB_XMAS && !battle_config.xmas_ignorepalette)))
- clif_changelook(&dstsd->bl, LOOK_CLOTHES_COLOR, dstsd->status.clothes_color);
-
if((sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting.
(battle_config.disp_hpmeter && (len = pc_isGM(sd)) >= battle_config.disp_hpmeter && len >= pc_isGM(dstsd))
)
clif_hpmeter_single(sd->fd, dstsd);
- if(sd->status.manner < 0 && battle_config.manner_system)
- clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
+ if(dstsd->status.manner < 0 && battle_config.manner_system)
+ clif_changestatus(&dstsd->bl,SP_MANNER,dstsd->status.manner);
- if(sd->state.size==2) // tiny/big players [Valaris]
- clif_specialeffect(&sd->bl,423,0);
- else if(sd->state.size==1)
- clif_specialeffect(&sd->bl,421,0);
-
// pvp circle for duel [LuzZza]
/*
if(dstsd->duel_group)
@@ -4261,150 +3600,101 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
*/
}
-
-/*==========================================
- * NPC表示
- *------------------------------------------
- */
-//fixed by Valaris
-void clif_getareachar_npc(struct map_session_data* sd,struct npc_data* nd)
-{
- int len;
- nullpo_retv(sd);
- nullpo_retv(nd);
- if(nd->class_ < 0 || nd->flag&1 || nd->class_ == INVISIBLE_CLASS)
- return;
- if(nd->ud.walktimer != -1){
- WFIFOHEAD(sd->fd, packet_len_table[0x7b]);
- len = clif_npc007b(nd,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- } else {
- WFIFOHEAD(sd->fd, packet_len_table[0x78]);
- len = clif_npc0078(nd,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- }
- if(nd->chat_id){
- clif_dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd);
- }
-}
-
-/*==========================================
- * 移動停止
- *------------------------------------------
- */
-int clif_movemob(struct mob_data *md)
-{
- unsigned char buf[256];
- int len;
-
- nullpo_retr(0, md);
-
- len = clif_mob007b(md,buf);
- clif_send(buf,len,&md->bl,AREA);
-
- if(battle_config.save_clothcolor && pcdb_checkid(mob_get_viewclass(md->class_)) && mob_get_clothes_color(md->class_)) // [Valaris]
- clif_changelook(&md->bl, LOOK_CLOTHES_COLOR, mob_get_clothes_color(md->class_));
-
- if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris]
- clif_mob_equip(md,mob_get_equip(md->class_));
-
- if(md->special_state.size==2) // tiny/big mobs [Valaris]
- clif_specialeffect(&md->bl,423,0);
- else if(md->special_state.size==1)
- clif_specialeffect(&md->bl,421,0);
-
- return 0;
-}
-
-/*==========================================
- * モンスターの位置修正
- *------------------------------------------
- */
-int clif_fixmobpos(struct mob_data *md)
+void clif_getareachar_char(struct map_session_data* sd,struct block_list *bl)
{
- unsigned char buf[256];
+ struct unit_data *ud;
+ struct view_data *vd;
int len;
+
+ vd = status_get_viewdata(bl);
- nullpo_retr(0, md);
+ if (!vd || vd->class_ == INVISIBLE_CLASS)
+ return;
- if(md->ud.walktimer != -1){
- len = clif_mob007b(md,buf);
- clif_send(buf,len,&md->bl,AREA);
+ ud = unit_bl2ud(bl);
+ if (ud && ud->walktimer != -1)
+ {
+#if PACKETVER < 4
+ WFIFOHEAD(sd->fd, packet_len_table[0x7b]);
+#else
+ WFIFOHEAD(sd->fd, packet_len_table[0x1da]);
+#endif
+ len = clif_set007b(bl,vd,ud,WFIFOP(sd->fd,0));
+ WFIFOSET(sd->fd,len);
} else {
- len = clif_mob0078(md,buf);
- clif_send(buf,len,&md->bl,AREA);
+#if PACKETVER < 4
+ WFIFOHEAD(sd->fd,packet_len_table[0x78]);
+#else
+ WFIFOHEAD(sd->fd,packet_len_table[0x1d8]);
+#endif
+ len = clif_set0078(bl,vd,WFIFOP(sd->fd,0));
+ WFIFOSET(sd->fd,len);
}
- return 0;
-}
-
-/*==========================================
- * PCの位置修正
- *------------------------------------------
- */
-int clif_fixpcpos(struct map_session_data *sd)
-{
- unsigned char buf[256];
- int len;
-
- nullpo_retr(0, sd);
-
- if(sd->ud.walktimer != -1){
- len = clif_set007b(sd,buf);
- } else {
- len = clif_set0078(sd,buf);
- }
+ if (vd->cloth_color)
+ clif_refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF);
- // Prevent bots/modified clients to view hidden GMs [Lance]
- if(!pc_isGM(sd) || !sd->status.option&OPTION_INVISIBLE){
- clif_send(buf,len,&sd->bl,AREA);
- } else {
- clif_send(buf,len,&sd->bl,SELF);
+ switch (bl->type)
+ {
+ case BL_PC:
+ {
+ TBL_PC* tsd = (TBL_PC*)bl;
+ clif_getareachar_pc(sd, tsd);
+ if(tsd->state.size==2) // tiny/big players [Valaris]
+ clif_specialeffect(bl,423,0);
+ else if(tsd->state.size==1)
+ clif_specialeffect(bl,421,0);
+ }
+ break;
+ case BL_NPC:
+ {
+ if(((TBL_NPC*)bl)->chat_id)
+ clif_dispchat((struct chat_data*)map_id2bl(((TBL_NPC*)bl)->chat_id),sd->fd);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB* md = (TBL_MOB*)bl;
+ if(md->special_state.size==2) // tiny/big mobs [Valaris]
+ clif_specialeffect(bl,423,0);
+ else if(md->special_state.size==1)
+ clif_specialeffect(bl,421,0);
+ }
+ break;
}
-
- return 0;
}
/*==========================================
- *
+ * Older fix pos packet.
*------------------------------------------
*/
-int clif_fixpetpos(struct pet_data *pd)
+int clif_fixpos2(struct block_list* bl)
{
+ struct unit_data *ud;
+ struct view_data *vd;
unsigned char buf[256];
int len;
- nullpo_retr(0, pd);
-
- if(pd->ud.walktimer != -1){
- len = clif_pet007b(pd,buf);
- clif_send(buf,len,&pd->bl,AREA);
- } else {
- len = clif_pet0078(pd,buf);
- clif_send(buf,len,&pd->bl,AREA);
- }
+ nullpo_retr(0, bl);
+ ud = unit_bl2ud(bl);
+ vd = status_get_viewdata(bl);
+ if (!vd || vd->class_ == INVISIBLE_CLASS)
+ return 0;
+
+ if(ud && ud->walktimer != -1)
+ len = clif_set007b(bl,vd,ud,buf);
+ else
+ len = clif_set0078(bl,vd,buf);
+ if (disguised(bl)) {
+ clif_send(buf,len,bl,AREA_WOS);
+ clif_setdisguise((TBL_PC*)bl, buf, len, 0);
+ clif_setdisguise((TBL_PC*)bl, buf, len, 1);
+ } else
+ clif_send(buf,len,bl,AREA);
return 0;
}
-// npc walking [Valaris]
-int clif_fixnpcpos(struct npc_data *nd)
-{
- unsigned char buf[256];
- int len;
-
- nullpo_retr(0, nd);
-
- if(nd->ud.walktimer != -1){
- len = clif_npc007b(nd,buf);
- clif_send(buf,len,&nd->bl,AREA);
- } else {
- len = clif_npc0078(nd,buf);
- clif_send(buf,len,&nd->bl,AREA);
- }
-
- return 0;
-}
/*==========================================
* Modifies the type of damage according to status changes [Skotlex]
*------------------------------------------
@@ -4445,55 +3735,41 @@ int clif_damage(struct block_list *src,struct block_list *dst,unsigned int tick,
}
WBUFW(buf,0)=0x8a;
- if(src->type==BL_PC && ((struct map_session_data *)src)->disguise)
- WBUFL(buf,2)=-src->id;
- else
- WBUFL(buf,2)=src->id;
- if(dst->type==BL_PC && ((struct map_session_data *)dst)->disguise)
- WBUFL(buf,6)=-dst->id;
- else
- WBUFL(buf,6)=dst->id;
+ WBUFL(buf,2)=src->id;
+ WBUFL(buf,6)=dst->id;
WBUFL(buf,10)=tick;
WBUFL(buf,14)=sdelay;
WBUFL(buf,18)=ddelay;
- WBUFW(buf,22)=(damage > 0x7fff)? 0x7fff:damage;
+ WBUFW(buf,22)=(damage > SHRT_MAX)?SHRT_MAX:damage;
WBUFW(buf,24)=div;
WBUFB(buf,26)=type;
WBUFW(buf,27)=damage2;
clif_send(buf,packet_len_table[0x8a],src,AREA);
- if((src->type==BL_PC && ((struct map_session_data *)src)->disguise) || (dst->type==BL_PC && ((struct map_session_data *)dst)->disguise)) {
- memset(buf,0,packet_len_table[0x8a]);
- WBUFW(buf,0)=0x8a;
- if(src->type==BL_PC && ((struct map_session_data *)src)->disguise)
- WBUFL(buf,2)=src->id;
- else
- WBUFL(buf,2)=-src->id;
- if(dst->type==BL_PC && ((struct map_session_data *)dst)->disguise)
- WBUFL(buf,6)=dst->id;
- else
- WBUFL(buf,2)=-dst->id;
- WBUFL(buf,10)=tick;
- WBUFL(buf,14)=sdelay;
- WBUFL(buf,18)=ddelay;
+ if(disguised(src)) {
+ WBUFL(buf,2)=-src->id;
if(damage > 0)
WBUFW(buf,22)=-1;
- else
- WBUFW(buf,22)=0;
- WBUFW(buf,24)=div;
- WBUFB(buf,26)=type;
- WBUFW(buf,27)=0;
- clif_send(buf,packet_len_table[0x8a],src,AREA);
+ if(damage2 > 0)
+ WBUFW(buf,27)=-1;
+ clif_send(buf,packet_len_table[0x8a],src,SELF);
+ }
+ if (disguised(dst)) {
+ WBUFL(buf,6)=-dst->id;
+ if (disguised(src))
+ WBUFL(buf,2)=src->id;
+ else {
+ if(damage > 0)
+ WBUFW(buf,22)=-1;
+ if(damage2 > 0)
+ WBUFW(buf,27)=-1;
+ }
+ clif_send(buf,packet_len_table[0x8a],dst,SELF);
}
//Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
if (type != 4 && type != 9 && damage+damage2 > 0) //Non-endure/Non-flinch attack, update walk delay.
unit_walkdelay(dst, tick, sdelay, ddelay, div);
- // [Valaris]
- if(battle_config.save_clothcolor && src->type==BL_MOB &&
- pcdb_checkid(mob_get_viewclass(((struct mob_data *)src)->class_)) && mob_get_clothes_color(((struct mob_data *)src)->class_) > 0)
- clif_changelook(src, LOOK_CLOTHES_COLOR, mob_get_clothes_color(((struct mob_data *)src)->class_));
-
return 0;
}
@@ -4501,88 +3777,9 @@ int clif_damage(struct block_list *src,struct block_list *dst,unsigned int tick,
*
*------------------------------------------
*/
-void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md)
-{
- int len;
- nullpo_retv(sd);
- nullpo_retv(md);
-
- if (session[sd->fd] == NULL)
- return;
-
- if(md->ud.walktimer != -1){
-#if PACKETVER < 4
- WFIFOHEAD(sd->fd,packet_len_table[0x78]);
-#else
- WFIFOHEAD(sd->fd,packet_len_table[0x1d8]);
-#endif
- len = clif_mob007b(md,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- } else {
-#if PACKETVER < 4
- WFIFOHEAD(sd->fd,packet_len_table[0x78]);
-#else
- WFIFOHEAD(sd->fd,packet_len_table[0x1d8]);
-#endif
- len = clif_mob0078(md,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- }
-
- if(battle_config.save_clothcolor && pcdb_checkid(mob_get_viewclass(md->class_)) && mob_get_clothes_color(md->class_)) // [Valaris]
- clif_changelook(&md->bl, LOOK_CLOTHES_COLOR, mob_get_clothes_color(md->class_));
-
- if(mob_get_equip(md->class_) > 0) // mob equipment [Valaris]
- clif_mob_equip(md,mob_get_equip(md->class_));
-
- if(md->special_state.size==2) // tiny/big mobs [Valaris]
- clif_specialeffect(&md->bl,423,0);
- else if(md->special_state.size==1)
- clif_specialeffect(&md->bl,421,0);
-
-
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_getareachar_pet(struct map_session_data* sd,struct pet_data* pd)
-{
- int len;
-
- nullpo_retv(sd);
- nullpo_retv(pd);
-
- if(pd->ud.walktimer != -1){
-#if PACKETVER < 4
- WFIFOHEAD(sd->fd,packet_len_table[0x7b]);
-#else
- WFIFOHEAD(sd->fd,packet_len_table[0x1da]);
-#endif
- len = clif_pet007b(pd,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- } else {
-#if PACKETVER < 4
- WFIFOHEAD(sd->fd,packet_len_table[0x7b]);
-#else
- WFIFOHEAD(sd->fd,packet_len_table[0x1da]);
-#endif
- len = clif_pet0078(pd,WFIFOP(sd->fd,0));
- WFIFOSET(sd->fd,len);
- }
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem)
{
int view,fd;
-
- nullpo_retv(sd);
- nullpo_retv(fitem);
-
fd=sd->fd;
//009d <ID>.l <item ID>.w <identify flag>.B <X>.w <Y>.w <amount>.w <subX>.B <subY>.B
WFIFOHEAD(fd,packet_len_table[0x9d]);
@@ -4599,7 +3796,6 @@ void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fi
WFIFOW(fd,13)=fitem->item_data.amount;
WFIFOB(fd,15)=fitem->subx;
WFIFOB(fd,16)=fitem->suby;
-
WFIFOSET(fd,packet_len_table[0x9d]);
}
/*==========================================
@@ -4723,20 +3919,6 @@ int clif_01ac(struct block_list *bl)
return 0;
switch(bl->type){
- case BL_PC:
- if(sd==(struct map_session_data*)bl)
- break;
- clif_getareachar_pc(sd,(struct map_session_data*) bl);
- break;
- case BL_NPC:
- clif_getareachar_npc(sd,(struct npc_data*) bl);
- break;
- case BL_MOB:
- clif_getareachar_mob(sd,(struct mob_data*) bl);
- break;
- case BL_PET:
- clif_getareachar_pet(sd,(struct pet_data*) bl);
- break;
case BL_ITEM:
clif_getareachar_item(sd,(struct flooritem_data*) bl);
break;
@@ -4744,227 +3926,94 @@ int clif_01ac(struct block_list *bl)
clif_getareachar_skillunit(sd,(struct skill_unit *)bl);
break;
default:
- if(battle_config.error_log)
- ShowError("clif_getareachar: Unrecognized type %d.\n",bl->type);
+ if(&sd->bl == bl)
+ break;
+ clif_getareachar_char(sd,bl);
break;
}
return 0;
}
/*==========================================
- *
+ * tbl has gone out of view-size of bl
*------------------------------------------
*/
-int clif_pcoutsight(struct block_list *bl,va_list ap)
+int clif_outsight(struct block_list *bl,va_list ap)
{
- struct map_session_data *sd,*dstsd;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- nullpo_retr(0, sd=va_arg(ap,struct map_session_data*));
-
- switch(bl->type){
- case BL_PC:
- dstsd = (struct map_session_data*) bl;
- if(sd != dstsd) {
- clif_clearchar_id(dstsd->bl.id,0,sd->fd);
- clif_clearchar_id(sd->bl.id,0,dstsd->fd);
- if(dstsd->disguise || sd->disguise) {
- clif_clearchar_id(-dstsd->bl.id,0,sd->fd);
- clif_clearchar_id(-sd->bl.id,0,dstsd->fd);
- }
- if(dstsd->chatID){
+ struct block_list *tbl;
+ TBL_PC *sd, *tsd;
+ tbl=va_arg(ap,struct block_list*);
+ if(bl == tbl) return 0;
+ BL_CAST(BL_PC, bl, sd);
+ BL_CAST(BL_PC, tbl, tsd);
+
+ if (tsd && tsd->fd)
+ { //tsd has lost sight of the bl object.
+ switch(bl->type){
+ case BL_PC:
+ clif_clearchar_id(bl->id,0,tsd->fd);
+ if(sd->chatID){
struct chat_data *cd;
- cd=(struct chat_data*)map_id2bl(dstsd->chatID);
- if(cd->usersd[0]==dstsd)
- clif_dispchat(cd,sd->fd);
+ cd=(struct chat_data*)map_id2bl(sd->chatID);
+ if(cd->usersd[0]==sd)
+ clif_dispchat(cd,tsd->fd);
}
- if(dstsd->vender_id){
- clif_closevendingboard(&dstsd->bl,sd->fd);
- }
- }
- break;
- case BL_NPC:
- if( ((struct npc_data *)bl)->class_ != INVISIBLE_CLASS )
- clif_clearchar_id(bl->id,0,sd->fd);
- break;
- case BL_MOB:
- case BL_PET:
- clif_clearchar_id(bl->id,0,sd->fd);
- break;
- case BL_ITEM:
- clif_clearflooritem((struct flooritem_data*)bl,sd->fd);
- break;
- case BL_SKILL:
- clif_clearchar_skillunit((struct skill_unit *)bl,sd->fd);
- break;
- }
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_pcinsight(struct block_list *bl,va_list ap)
-{
- struct map_session_data *sd,*dstsd;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- nullpo_retr(0, sd=va_arg(ap,struct map_session_data*));
-
- switch(bl->type){
- case BL_PC:
- dstsd = (struct map_session_data *)bl;
- if(sd != dstsd) {
- clif_getareachar_pc(sd,dstsd);
- clif_getareachar_pc(dstsd,sd);
+ if(sd->vender_id)
+ clif_closevendingboard(bl,tsd->fd);
+ break;
+ case BL_ITEM:
+ clif_clearflooritem((struct flooritem_data*)bl,tsd->fd);
+ break;
+ case BL_SKILL:
+ clif_clearchar_skillunit((struct skill_unit *)bl,tsd->fd);
+ break;
+ default:
+ if (status_get_viewdata(bl))
+ clif_clearchar_id(bl->id,0,tsd->fd);
+ break;
}
- break;
- case BL_NPC:
- clif_getareachar_npc(sd,(struct npc_data*)bl);
- break;
- case BL_MOB:
- clif_getareachar_mob(sd,(struct mob_data*)bl);
- break;
- case BL_PET:
- clif_getareachar_pet(sd,(struct pet_data*)bl);
- break;
- case BL_ITEM:
- clif_getareachar_item(sd,(struct flooritem_data*)bl);
- break;
- case BL_SKILL:
- clif_getareachar_skillunit(sd,(struct skill_unit *)bl);
- break;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_moboutsight(struct block_list *bl,va_list ap)
-{
- struct map_session_data *sd;
- struct mob_data *md;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- nullpo_retr(0, md=va_arg(ap,struct mob_data*));
-
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
- && session[sd->fd] != NULL) {
- clif_clearchar_id(md->bl.id,0,sd->fd);
}
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_mobinsight(struct block_list *bl,va_list ap)
-{
- struct map_session_data *sd;
- struct mob_data *md;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
-
- md=va_arg(ap,struct mob_data*);
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
- && session[sd->fd] != NULL) {
- clif_getareachar_mob(sd,md);
+ if (sd && sd->fd)
+ { //sd is watching tbl go out of view.
+ if (status_get_viewdata(tbl))
+ clif_clearchar_id(tbl->id,0,sd->fd);
}
-
return 0;
}
/*==========================================
- *
+ * tbl has come into view of bl
*------------------------------------------
*/
-int clif_petoutsight(struct block_list *bl,va_list ap)
+int clif_insight(struct block_list *bl,va_list ap)
{
- struct map_session_data *sd;
- struct pet_data *pd;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- nullpo_retr(0, pd=va_arg(ap,struct pet_data*));
+ struct block_list *tbl;
+ TBL_PC *sd, *tsd;
+ tbl=va_arg(ap,struct block_list*);
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
- && session[sd->fd] != NULL) {
- clif_clearchar_id(pd->bl.id,0,sd->fd);
+ if (bl == tbl) return 0;
+
+ BL_CAST(BL_PC, bl, sd);
+ BL_CAST(BL_PC, tbl, tsd);
+
+ if (tsd && tsd->fd)
+ { //Tell tsd that bl entered into his view
+ switch(bl->type){
+ case BL_ITEM:
+ clif_getareachar_item(tsd,(struct flooritem_data*)bl);
+ break;
+ case BL_SKILL:
+ clif_getareachar_skillunit(tsd,(struct skill_unit *)bl);
+ break;
+ default:
+ clif_getareachar_char(tsd,bl);
+ break;
+ }
}
-
- return 0;
-}
-
-// npc walking [Valaris]
-int clif_npcoutsight(struct block_list *bl,va_list ap)
-{
- struct map_session_data *sd;
- struct npc_data *nd;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- nullpo_retr(0, nd=va_arg(ap,struct npc_data*));
-
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
- && session[sd->fd] != NULL) {
- clif_clearchar_id(nd->bl.id,0,sd->fd);
+ if (sd && sd->fd)
+ { //Tell sd that tbl walked into his view
+ clif_getareachar_char(sd,tbl);
}
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_petinsight(struct block_list *bl,va_list ap)
-{
- struct map_session_data *sd;
- struct pet_data *pd;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
-
- pd=va_arg(ap,struct pet_data*);
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
- && session[sd->fd] != NULL) {
- clif_getareachar_pet(sd,pd);
- }
-
- return 0;
-}
-
-// npc walking [Valaris]
-int clif_npcinsight(struct block_list *bl,va_list ap)
-{
- struct map_session_data *sd;
- struct npc_data *nd;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
-
- nd=va_arg(ap,struct npc_data*);
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
- && session[sd->fd] != NULL) {
- clif_getareachar_npc(sd,nd);
- }
-
return 0;
}
@@ -5092,6 +4141,11 @@ int clif_skillcasting(struct block_list* bl,
WBUFL(buf,16) = pl<0?0:pl; //Avoid sending negatives as element [Skotlex]
WBUFL(buf,20) = casttime;
clif_send(buf,packet_len_table[0x13e], bl, AREA);
+ if (disguised(bl)) {
+ WBUFL(buf,2) = -src_id;
+ WBUFL(buf,20) = 0;
+ clif_send(buf,packet_len_table[0x13e], bl, SELF);
+ }
return 0;
}
@@ -5168,14 +4222,8 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,
#if PACKETVER < 3
WBUFW(buf,0)=0x114;
WBUFW(buf,2)=skill_id;
- if(src->type==BL_PC && ((struct map_session_data *)src)->disguise)
- WBUFL(buf,4)=-src->id;
- else
- WBUFL(buf,4)=src->id;
- if(dst->type==BL_PC && ((struct map_session_data *)dst)->disguise)
- WBUFL(buf,8)=-dst->id;
- else
- WBUFL(buf,8)=dst->id;
+ WBUFL(buf,4)=src->id;
+ WBUFL(buf,8)=dst->id;
WBUFL(buf,12)=tick;
WBUFL(buf,16)=sdelay;
WBUFL(buf,20)=ddelay;
@@ -5184,17 +4232,25 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,
WBUFW(buf,28)=div;
WBUFB(buf,30)=type;
clif_send(buf,packet_len_table[0x114],src,AREA);
+ if(disguised(src)) {
+ WBUFL(buf,4)=-src->id;
+ if(damage > 0)
+ WBUFW(buf,24)=-1;
+ clif_send(buf,packet_len_table[0x114],src,SELF);
+ }
+ if (disguised(dst)) {
+ WBUFL(buf,8)=-dst->id;
+ if (disguised(src))
+ WBUFL(buf,4)=src->id;
+ else if(damage > 0)
+ WBUFW(buf,24)=-1;
+ clif_send(buf,packet_len_table[0x114],dst,SELF);
+ }
#else
WBUFW(buf,0)=0x1de;
WBUFW(buf,2)=skill_id;
- if(src->type==BL_PC && ((struct map_session_data *)src)->disguise)
- WBUFL(buf,4)=-src->id;
- else
- WBUFL(buf,4)=src->id;
- if(dst->type==BL_PC && ((struct map_session_data *)dst)->disguise)
- WBUFL(buf,8)=-dst->id;
- else
- WBUFL(buf,8)=dst->id;
+ WBUFL(buf,4)=src->id;
+ WBUFL(buf,8)=dst->id;
WBUFL(buf,12)=tick;
WBUFL(buf,16)=sdelay;
WBUFL(buf,20)=ddelay;
@@ -5203,6 +4259,20 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,
WBUFW(buf,30)=div;
WBUFB(buf,32)=type;
clif_send(buf,packet_len_table[0x1de],src,AREA);
+ if(disguised(src)) {
+ WBUFL(buf,4)=-src->id;
+ if(damage > 0)
+ WBUFW(buf,24)=-1;
+ clif_send(buf,packet_len_table[0x1de],src,SELF);
+ }
+ if (disguised(dst)) {
+ WBUFL(buf,8)=-dst->id;
+ if (disguised(src))
+ WBUFL(buf,4)=src->id;
+ else if(damage > 0)
+ WBUFW(buf,24)=-1;
+ clif_send(buf,packet_len_table[0x1de],dst,SELF);
+ }
#endif
//Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
@@ -5246,6 +4316,20 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,
WBUFW(buf,32)=div;
WBUFB(buf,34)=type;
clif_send(buf,packet_len_table[0x115],src,AREA);
+ if(disguised(src)) {
+ WBUFL(buf,4)=-src->id;
+ if(damage > 0)
+ WBUFW(buf,28)=-1;
+ clif_send(buf,packet_len_table[0x115],src,SELF);
+ }
+ if (disguised(dst)) {
+ WBUFL(buf,8)=-dst->id;
+ if (disguised(src))
+ WBUFL(buf,4)=src->id;
+ else if(damage > 0)
+ WBUFW(buf,28)=-1;
+ clif_send(buf,packet_len_table[0x115],dst,SELF);
+ }
//Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
if (type != 4 && type != 9 && damage > 0) //Non-endure/Non-flinch attack, update walk delay.
@@ -5267,12 +4351,23 @@ int clif_skill_nodamage(struct block_list *src,struct block_list *dst,
WBUFW(buf,0)=0x11a;
WBUFW(buf,2)=skill_id;
- WBUFW(buf,4)=(heal > 0x7fff)? 0x7fff:heal;
+ WBUFW(buf,4)=(heal > SHRT_MAX)? SHRT_MAX:heal;
WBUFL(buf,6)=dst->id;
WBUFL(buf,10)=src->id;
WBUFB(buf,14)=fail;
clif_send(buf,packet_len_table[0x11a],src,AREA);
+ if(disguised(src)) {
+ WBUFL(buf,10)=-src->id;
+ clif_send(buf,packet_len_table[0x115],src,SELF);
+ }
+ if (disguised(dst)) {
+ WBUFL(buf,6)=-dst->id;
+ if (disguised(src))
+ WBUFL(buf,10)=src->id;
+ clif_send(buf,packet_len_table[0x115],dst,SELF);
+ }
+
return fail;
}
@@ -5294,6 +4389,10 @@ int clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int y
WBUFW(buf,12)=y;
WBUFL(buf,14)=tick;
clif_send(buf,packet_len_table[0x117],src,AREA);
+ if(disguised(src)) {
+ WBUFL(buf,4)=-src->id;
+ clif_send(buf,packet_len_table[0x117],src,SELF);
+ }
return 0;
}
@@ -5457,7 +4556,7 @@ int clif_skill_estimation(struct map_session_data *sd,struct block_list *dst)
return 0;
WBUFW(buf, 0)=0x18c;
- WBUFW(buf, 2)=mob_get_viewclass(md->class_);
+ WBUFW(buf, 2)=md->vd->class_;
WBUFW(buf, 4)=md->level;
WBUFW(buf, 6)=md->db->size;
WBUFL(buf, 8)=md->hp;
@@ -5718,9 +4817,8 @@ int clif_resurrection(struct block_list *bl,int type)
WBUFW(buf,6)=type;
clif_send(buf,packet_len_table[0x148],bl,type==1 ? AREA : AREA_WOS);
-
- if(bl->type==BL_PC && ((struct map_session_data *)bl)->disguise)
- clif_spawnpc(((struct map_session_data *)bl));
+ if (disguised(bl))
+ clif_spawn(bl);
return 0;
}
@@ -5751,7 +4849,7 @@ int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
return 0;
if(type == 2) {
- WFIFOHEAD(sd->fd,packet_len_table[0x19a]);
+ WFIFOHEAD(sd->fd,packet_len_table[0x19a]);
WFIFOW(sd->fd,0) = 0x19a;
WFIFOL(sd->fd,2) = sd->bl.id;
if(pvprank<=0)
@@ -5805,7 +4903,7 @@ int clif_send0199(int map,int type)
*/
int clif_refine(int fd,struct map_session_data *sd,int fail,int index,int val)
{
- WFIFOHEAD(fd,packet_len_table[0x188]);
+ WFIFOHEAD(fd,packet_len_table[0x188]);
WFIFOW(fd,0)=0x188;
WFIFOW(fd,2)=fail;
WFIFOW(fd,4)=index+2;
@@ -7043,7 +6141,6 @@ int clif_pet_performance(struct block_list *bl,int param)
int clif_pet_equip(struct pet_data *pd,int nameid)
{
unsigned char buf[16];
- int view;
nullpo_retr(0, pd);
@@ -7052,11 +6149,7 @@ int clif_pet_equip(struct pet_data *pd,int nameid)
WBUFW(buf,0)=0x1a4;
WBUFB(buf,2)=3;
WBUFL(buf,3)=pd->bl.id;
- if(nameid && (view = itemdb_viewid(nameid)) > 0)
- WBUFL(buf,7)=view;
- else
- WBUFL(buf,7)=nameid;
-
+ WBUFL(buf,7)=pd->vd.shield;
clif_send(buf,packet_len_table[0x1a4],&pd->bl,AREA);
return 0;
@@ -8149,11 +7242,6 @@ void clif_sitting(struct map_session_data *sd)
WBUFL(buf, 2) = sd->bl.id;
WBUFB(buf,26) = 2;
clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
-
- if(sd->disguise) {
- WBUFL(buf, 2) = -sd->bl.id;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
- }
}
/*==========================================
@@ -8831,7 +7919,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
}
map_addblock(&sd->bl); // ブロック登録
- clif_spawnpc(sd); // spawn
+ clif_spawn(&sd->bl); // spawn
// party
party_send_movemap(sd);
@@ -8878,7 +7966,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
// pet
if(sd->status.pet_id > 0 && sd->pd && sd->pet.intimate > 0) {
map_addblock(&sd->pd->bl);
- clif_spawnpet(sd->pd);
+ clif_spawn(&sd->pd->bl);
clif_send_petdata(sd,0,0);
clif_send_petdata(sd,5,battle_config.pet_hair_style);
clif_send_petstatus(sd);
@@ -8886,8 +7974,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if(sd->state.connect_new) {
sd->state.connect_new = 0;
- if(sd->status.class_ != sd->view_class)
- clif_changelook(&sd->bl,LOOK_BASE,sd->view_class);
+// if(sd->status.class_ != sd->vd.class_)
+// clif_changelook(&sd->bl,LOOK_BASE,sd->vd.class_);
if(sd->status.pet_id > 0 && sd->pd && sd->pet.intimate > 900)
clif_pet_emotion(sd->pd,(sd->pd->class_ - 100)*100 + 50 + pet_hungry_val(sd));
@@ -8907,9 +7995,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
#else
clif_changelook(&sd->bl,LOOK_WEAPON,0);
#endif
- if(battle_config.save_clothcolor && sd->status.clothes_color > 0 && ((sd->view_class != JOB_WEDDING && sd->view_class !=JOB_XMAS) ||
- (sd->view_class==JOB_WEDDING && !battle_config.wedding_ignorepalette) || (sd->view_class==JOB_XMAS && !battle_config.xmas_ignorepalette)))
- clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+
+ if(sd->vd.cloth_color)
+ clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
if(battle_config.muting_players && sd->status.manner < 0 && battle_config.manner_system)
sc_start(&sd->bl,SC_NOCHAT,100,0,0);
@@ -8948,6 +8036,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y);
else
sd->areanpc_id = 0;
+
+ if (pc_isdead(sd)) //In case you warped dead.
+ clif_clearchar_area(&sd->bl, 1);
}
/*==========================================
@@ -9007,9 +8098,6 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
*------------------------------------------
*/
void clif_parse_QuitGame(int fd, struct map_session_data *sd) {
-// unsigned int tick=gettick();
-// struct skill_unit_group* sg;
-
WFIFOHEAD(fd,packet_len_table[0x18b]);
WFIFOW(fd,0) = 0x18b;
@@ -9300,24 +8388,17 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd) {
*/
void clif_changed_dir(struct block_list *bl) {
unsigned char buf[64];
- struct map_session_data *sd = NULL;
-
- if (bl->type == BL_PC)
- nullpo_retv (sd=(struct map_session_data *)bl);
WBUFW(buf,0) = 0x9c;
WBUFL(buf,2) = bl->id;
- if (sd)
- WBUFW(buf,6) = sd->head_dir;
+ WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0;
WBUFB(buf,8) = unit_getdir(bl);
clif_send(buf, packet_len_table[0x9c], bl, AREA_WOS);
-
- if(sd && sd->disguise) {
+ if (disguised(bl)) {
WBUFL(buf,2) = -bl->id;
WBUFW(buf,6) = 0;
- WBUFB(buf,8) = unit_getdir(bl);
- clif_send(buf, packet_len_table[0x9c], bl, AREA);
+ clif_send(buf, packet_len_table[0x9c], bl, SELF);
}
return;
@@ -9419,7 +8500,7 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) {
switch(action_type) {
case 0x00: // once attack
case 0x07: // continuous attack
- if(sd->view_class==JOB_WEDDING || sd->view_class==JOB_XMAS)
+ if(sd->vd.class_ ==JOB_WEDDING || sd->vd.class_==JOB_XMAS)
return;
if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
@@ -9457,7 +8538,7 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) {
clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
if(sd->disguise) {
WBUFL(buf, 2) = -sd->bl.id;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
+ clif_send(buf, packet_len_table[0x8a], &sd->bl, SELF);
}
break;
}
@@ -9747,15 +8828,15 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd) {
return;
}
-
if (sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT)
return;
- if (clif_trading(sd))
- return;
-
//This flag enables you to use items while in an NPC. [Skotlex]
- if (sd->npc_id && sd->npc_id != sd->npc_item_flag)
+ if (sd->npc_id) {
+ if (sd->npc_id != sd->npc_item_flag)
+ return;
+ } else
+ if (clif_trading(sd))
return;
if (sd->sc.count && (
@@ -10168,14 +9249,14 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) {
return;
}
- if (sd->view_class == JOB_WEDDING || sd->view_class == JOB_XMAS)
+ if (sd->vd.class_ == JOB_WEDDING || sd->vd.class_ == JOB_XMAS)
return;
if (sd->invincible_timer != -1)
pc_delinvincibletimer(sd);
if(target_id<0) // for disguises [Valaris]
- target_id-=target_id*2;
+ target_id*=-1;
if (sd->skillitem >= 0 && sd->skillitem == skillnum) {
if (skilllv != sd->skillitemlv)
@@ -10258,7 +9339,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, int skilll
return;
}
- if (sd->view_class == JOB_WEDDING || sd->view_class == JOB_XMAS)
+ if (sd->vd.class_ == JOB_WEDDING || sd->vd.class_ == JOB_XMAS)
return;
if (sd->invincible_timer != -1)
@@ -10322,7 +9403,7 @@ void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
if (clif_cant_act(sd))
return;
- if (sd->view_class==JOB_WEDDING || sd->view_class == JOB_XMAS)
+ if (sd->vd.class_==JOB_WEDDING || sd->vd.class_ == JOB_XMAS)
return;
if(sd->invincible_timer != -1)
@@ -11147,9 +10228,15 @@ void clif_parse_GMHide(int fd, struct map_session_data *sd) { // Modified by [Yo
(pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) {
if (sd->sc.option & OPTION_INVISIBLE) {
sd->sc.option &= ~OPTION_INVISIBLE;
+ if (sd->disguise)
+ status_set_viewdata(&sd->bl, sd->disguise);
+ else
+ status_set_viewdata(&sd->bl, sd->status.class_);
clif_displaymessage(fd, "Invisible: Off.");
} else {
sd->sc.option |= OPTION_INVISIBLE;
+ //Experimental hidden mode, changes your view class to invisible [Skotlex]
+ sd->vd.class_ = INVISIBLE_CLASS;
clif_displaymessage(fd, "Invisible: On.");
}
clif_changeoption(&sd->bl);
diff --git a/src/map/clif.h b/src/map/clif.h
index 016598db6..c30610cfb 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -50,24 +50,15 @@ int clif_clearchar(struct block_list*,int); // area or fd
int clif_clearchar_delay(unsigned int,struct block_list *,int);
#define clif_clearchar_area(bl,type) clif_clearchar(bl,type)
int clif_clearchar_id(int,int,int);
-int clif_spawnpc(struct map_session_data*); //area
-int clif_spawnnpc(struct npc_data*); // area
-int clif_spawnmob(struct mob_data*); // area
-int clif_spawnpet(struct pet_data*); // area
+int clif_spawn(struct block_list*); //area
int clif_walkok(struct map_session_data*); // self
-int clif_movechar(struct map_session_data*); // area
-int clif_movemob(struct mob_data*); //area
-int clif_movepet(struct pet_data *pd); //area
-int clif_movenpc(struct npc_data *nd); // [Valaris]
+int clif_move(struct block_list*); // area
int clif_changemap(struct map_session_data*,short,int,int); //self
int clif_changemapserver(struct map_session_data*,char*,int,int,int,int); //self
int clif_blown(struct block_list *); // area
int clif_slide(struct block_list *,int,int); // area
int clif_fixpos(struct block_list *); // area
-int clif_fixmobpos(struct mob_data *md);
-int clif_fixpcpos(struct map_session_data *sd);
-int clif_fixpetpos(struct pet_data *pd);
-int clif_fixnpcpos(struct npc_data *nd); // [Valaris]
+int clif_fixpos2(struct block_list *); // area
int clif_npcbuysell(struct map_session_data*,int); //self
int clif_buylist(struct map_session_data*,struct npc_data*); //self
int clif_selllist(struct map_session_data*); //self
@@ -86,6 +77,7 @@ int clif_changestatus(struct block_list*,int,int); //area
int clif_damage(struct block_list *,struct block_list *,unsigned int,int,int,int,int,int,int); // area
#define clif_takeitem(src,dst) clif_damage(src,dst,0,0,0,0,0,1,0)
int clif_changelook(struct block_list *,int,int); // area
+void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area); //area specified in 'area'
int clif_arrowequip(struct map_session_data *sd,int val); //self
int clif_arrow_fail(struct map_session_data *sd,int type); //self
int clif_arrow_create_list(struct map_session_data *sd); //self
@@ -145,17 +137,11 @@ int clif_guildstorageequiplist(struct map_session_data *sd,struct guild_storage
int clif_updateguildstorageamount(struct map_session_data *sd,struct guild_storage *stor);
int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage *stor,int index,int amount);
-int clif_pcinsight(struct block_list *,va_list); // map_forallinmovearea callback
-int clif_pcoutsight(struct block_list *,va_list); // map_forallinmovearea callback
-int clif_mobinsight(struct block_list *,va_list); // map_forallinmovearea callback
-int clif_moboutsight(struct block_list *,va_list); // map_forallinmovearea callback
-int clif_petoutsight(struct block_list *bl,va_list ap);
-int clif_petinsight(struct block_list *bl,va_list ap);
-int clif_npcoutsight(struct block_list *bl,va_list ap);
-int clif_npcinsight(struct block_list *bl,va_list ap);
+int clif_insight(struct block_list *,va_list); // map_forallinmovearea callback
+int clif_outsight(struct block_list *,va_list); // map_forallinmovearea callback
int clif_class_change(struct block_list *bl,int class_,int type);
-int clif_mob_class_change(struct mob_data *md,int class_);
+#define clif_mob_class_change(md, class_) clif_class_change(&md->bl, class_, 1)
int clif_mob_equip(struct mob_data *md,int nameid); // [Valaris]
int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range);
@@ -335,6 +321,8 @@ int clif_disp_overhead(struct map_session_data *sd, char* mes);
int do_final_clif(void);
int do_init_clif(void);
+void clif_get_weapon_view(TBL_PC* sd, short *rhand, short *lhand);
+
int clif_party_xy_remove(struct map_session_data *sd); //Fix for minimap [Kevin]
void clif_parse_ReqFeel(int fd, struct map_session_data *sd, int skilllv);
diff --git a/src/map/map.h b/src/map/map.h
index 9a75028ef..716f61c5d 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -347,23 +347,23 @@ struct skill_unit_group_tickset {
struct unit_data {
struct block_list *bl;
- int walktimer;
struct walkpath_data walkpath;
+ struct skill_timerskill skilltimerskill[MAX_SKILLTIMERSKILL];
+ struct skill_unit_group skillunit[MAX_SKILLUNITGROUP];
+ struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET];
+ short attacktarget_lv;
short to_x,to_y;
- unsigned char dir;
short skillx,skilly;
short skillid,skilllv;
int skilltarget;
int skilltimer;
- struct skill_timerskill skilltimerskill[MAX_SKILLTIMERSKILL];
- struct skill_unit_group skillunit[MAX_SKILLUNITGROUP];
- struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET];
- int attacktimer;
int attacktarget;
- short attacktarget_lv;
+ int attacktimer;
+ int walktimer;
unsigned int attackabletime;
unsigned int canact_tick;
unsigned int canmove_tick;
+ unsigned char dir;
struct {
unsigned change_walk_target : 1 ;
unsigned skillcastcancel : 1 ;
@@ -430,6 +430,19 @@ struct weapon_data {
int add_damage_class_count;
};
+struct view_data {
+ short class_;
+ short weapon;
+ short shield; //Or left-hand weapon.
+ short head_top;
+ short head_mid;
+ short head_bottom;
+ short hair_style;
+ short hair_color;
+ short cloth_color;
+ char sex;
+ unsigned dead_sit : 2;
+};
struct npc_data;
struct pet_db;
struct item_data;
@@ -438,6 +451,7 @@ struct square;
struct map_session_data {
struct block_list bl;
struct unit_data ud;
+ struct view_data vd;
struct status_change sc;
//NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
//status_calc_pc, while special_state is recalculated in each call. [Skotlex]
@@ -469,7 +483,6 @@ struct map_session_data {
unsigned showexp :1;
unsigned showzeny :1;
unsigned mainchat :1; //[LuzZza]
- unsigned disguised :1; //[Valaris]
unsigned deal_locked :2;
unsigned party_sent :1;
unsigned guild_sent :1;
@@ -547,7 +560,6 @@ struct map_session_data {
int hp_sub,sp_sub;
int inchealhptick,inchealsptick,inchealspirithptick,inchealspiritsptick;
- short view_class;
short weapontype1,weapontype2;
short disguise; // [Valaris]
@@ -766,6 +778,7 @@ struct npc_item_list {
struct npc_data {
struct block_list bl;
struct unit_data ud; //Because they need to be able to move....
+ struct view_data *vd;
struct status_change sc; //They can't have status changes, but.. they want the visual opt values.
short n;
short class_;
@@ -833,6 +846,7 @@ struct spawn_data {
struct mob_data {
struct block_list bl;
struct unit_data ud;
+ struct view_data *vd;
struct status_change sc;
struct mob_db *db; //For quick data access (saves doing mob_db(md->class_) all the time) [Skotlex]
char name[NAME_LENGTH];
@@ -885,7 +899,8 @@ struct mob_data {
struct pet_data {
struct block_list bl;
- struct unit_data ud;
+ struct unit_data ud;
+ struct view_data vd;
struct mob_db *db;
int target_id;
short n;
diff --git a/src/map/mob.c b/src/map/mob.c
index 30021c345..4e3cf74cf 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -125,6 +125,16 @@ int mobdb_checkid(const int id)
}
/*==========================================
+ * Returns the view data associated to this mob class.
+ *------------------------------------------
+ */
+struct view_data * mob_get_viewdata(class_)
+{
+ if (mob_db(class_) == mob_dummy)
+ return 0;
+ return &mob_db(class_)->vd;
+}
+/*==========================================
* Cleans up mob-spawn data to make it "valid"
*------------------------------------------
*/
@@ -202,7 +212,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data)
md->skillidx = -1;
for (i = 0; i < MAX_STATUSCHANGE; i++)
md->sc.data[i].timer = -1;
-
+ status_set_viewdata(&md->bl, md->class_);
map_addiddb(&md->bl);
return md;
}
@@ -719,22 +729,9 @@ int mob_spawn (struct mob_data *md)
memset(md->lootitem, 0, sizeof(md->lootitem));
md->lootitem_count = 0;
- if(md->db->option){ // Added for carts, falcons and pecos for cloned monsters. [Valaris]
- if(md->db->option & 0x0008)
- md->sc.option |= 0x0008;
- if(md->db->option & 0x0080)
- md->sc.option |= 0x0080;
- if(md->db->option & 0x0100)
- md->sc.option |= 0x0100;
- if(md->db->option & 0x0200)
- md->sc.option |= 0x0200;
- if(md->db->option & 0x0400)
- md->sc.option |= 0x0400;
- if(md->db->option & OPTION_FALCON)
- md->sc.option |= OPTION_FALCON;
- if(md->db->option & OPTION_RIDING)
- md->sc.option |= OPTION_RIDING;
- }
+ if(md->db->option)
+ // Added for carts, falcons and pecos for cloned monsters. [Valaris]
+ md->sc.option = md->db->option;
md->max_hp = md->db->max_hp;
if(md->special_state.size==1) // change for sized monsters [Valaris]
@@ -744,10 +741,8 @@ int mob_spawn (struct mob_data *md)
md->hp = md->max_hp;
map_addblock(&md->bl);
+ clif_spawn(&md->bl);
skill_unit_move(&md->bl,tick,1);
-
- clif_spawnmob(md);
-
mobskill_use(md, tick, MSC_SPAWN);
return 0;
}
@@ -960,6 +955,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
unit_can_move(&md->bl))
{
int i=0,dx,dy;
+ mob_stop_attack(md);
do {
if(i<=5){
dx=bl->x - md->bl.x;
@@ -1664,8 +1660,8 @@ int mob_respawn(int tid, unsigned int tick, int id,int data )
unit_dataset(&md->bl);
map_addblock(&md->bl);
mob_heal(md,data*status_get_max_hp(&md->bl)/100);
+ clif_spawn(&md->bl);
skill_unit_move(&md->bl,tick,1);
- clif_spawnmob(md);
mobskill_use(md, tick, MSC_SPAWN);
return 1;
}
@@ -2374,32 +2370,20 @@ int mob_class_change (struct mob_data *md, int class_)
else if(md->hp < 1) md->hp = 1;
memcpy(md->name,md->db->jname,NAME_LENGTH-1);
- memset(&md->state,0,sizeof(md->state));
- md->attacked_id = 0;
- md->attacked_players = 0;
- md->target_id = 0;
- md->move_fail_count = 0;
-
md->speed = md->db->speed;
md->def_ele = md->db->element;
- md->state.skillstate = MSS_IDLE;
- md->last_thinktime = tick;
- md->next_walktime = tick+rand()%50+5000;
- md->last_linktime = tick;
mob_stop_attack(md);
mob_stop_walking(md, 0);
unit_skillcastcancel(&md->bl, 0);
- unit_dataset(&md->bl);
+ status_set_viewdata(&md->bl, class_);
+
for(i=0,c=tick-1000*3600*10;i<MAX_MOBSKILL;i++)
md->skilldelay[i] = c;
if(md->lootitem == NULL && md->db->mode&MD_LOOTER)
md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item));
- clif_clearchar_area(&md->bl,0);
- clif_spawnmob(md);
-
if (battle_config.show_mob_hp)
clif_charnameack(0, &md->bl);
@@ -2945,7 +2929,6 @@ int mob_clone_spawn(struct map_session_data *sd, char *map, int x, int y, const
return 0;
mob_db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db));
- mob_db_data[class_]->view_class=sd->status.class_;
sprintf(mob_db_data[class_]->name,sd->status.name);
sprintf(mob_db_data[class_]->jname,sd->status.name);
mob_db_data[class_]->lv=status_get_lv(&sd->bl);
@@ -2974,33 +2957,8 @@ int mob_clone_spawn(struct map_session_data *sd, char *map, int x, int y, const
mob_db_data[class_]->adelay=status_get_adelay(&sd->bl);
mob_db_data[class_]->amotion=status_get_amotion(&sd->bl);
mob_db_data[class_]->dmotion=status_get_dmotion(&sd->bl);
- mob_db_data[class_]->sex=sd->status.sex;
- mob_db_data[class_]->hair=sd->status.hair;
- mob_db_data[class_]->hair_color=sd->status.hair_color;
-#if PACKETVER < 4
- mob_db_data[class_]->weapon = sd->status.weapon;
- mob_db_data[class_]->shield = sd->status.shield;
-#else
- if (sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]] && sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS) {
- if (sd->inventory_data[sd->equip_index[9]]->view_id > 0)
- mob_db_data[class_]->weapon=sd->inventory_data[sd->equip_index[9]]->view_id;
- else
- mob_db_data[class_]->weapon=sd->status.inventory[sd->equip_index[9]].nameid;
- } else
- mob_db_data[class_]->shield=0;
- if (sd->equip_index[8] >= 0 && sd->equip_index[8] != sd->equip_index[9] && sd->inventory_data[sd->equip_index[8]] && sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS) {
- if (sd->inventory_data[sd->equip_index[8]]->view_id > 0)
- mob_db_data[class_]->shield=sd->inventory_data[sd->equip_index[8]]->view_id;
- else
- mob_db_data[class_]->shield=sd->status.inventory[sd->equip_index[8]].nameid;
- } else
- mob_db_data[class_]->shield=0;
-#endif
- mob_db_data[class_]->head_top=sd->status.head_top;
- mob_db_data[class_]->head_mid=sd->status.head_mid;
- mob_db_data[class_]->head_buttom=sd->status.head_bottom;
+ memcpy(&mob_db_data[class_]->vd, &sd->vd, sizeof(struct view_data));
mob_db_data[class_]->option=sd->sc.option;
- mob_db_data[class_]->clothes_color=sd->status.clothes_color;
//Skill copy [Skotlex]
ms = &mob_db_data[class_]->skill[0];
@@ -3266,7 +3224,7 @@ static int mob_readdb(void)
if (mob_db_data[class_] == NULL)
mob_db_data[class_] = aCalloc(1, sizeof (struct mob_data));
- mob_db_data[class_]->view_class = class_;
+ mob_db_data[class_]->vd.class_ = class_;
memcpy(mob_db_data[class_]->name, str[1], NAME_LENGTH-1);
memcpy(mob_db_data[class_]->jname, str[2], NAME_LENGTH-1);
mob_db_data[class_]->lv = atoi(str[3]);
@@ -3475,22 +3433,25 @@ static int mob_readdb_mobavail(void)
continue;
if (j >= 12 && k > 23 && k < 69)
k += 3977; // advanced job/baby class
- mob_db_data[class_]->view_class=k;
+
+ memset(&mob_db_data[class_]->vd, 0, sizeof(struct view_data));
+ mob_db_data[class_]->vd.class_=k;
//Player sprites
if(pcdb_checkid(k) && j>=12) {
- mob_db_data[class_]->sex=atoi(str[2]);
- mob_db_data[class_]->hair=atoi(str[3]);
- mob_db_data[class_]->hair_color=atoi(str[4]);
- mob_db_data[class_]->weapon=atoi(str[5]);
- mob_db_data[class_]->shield=atoi(str[6]);
- mob_db_data[class_]->head_top=atoi(str[7]);
- mob_db_data[class_]->head_mid=atoi(str[8]);
- mob_db_data[class_]->head_buttom=atoi(str[9]);
+ mob_db_data[class_]->vd.sex=atoi(str[2]);
+ mob_db_data[class_]->vd.hair_style=atoi(str[3]);
+ mob_db_data[class_]->vd.hair_color=atoi(str[4]);
+ mob_db_data[class_]->vd.weapon=atoi(str[5]);
+ mob_db_data[class_]->vd.shield=atoi(str[6]);
+ mob_db_data[class_]->vd.head_top=atoi(str[7]);
+ mob_db_data[class_]->vd.head_mid=atoi(str[8]);
+ mob_db_data[class_]->vd.head_bottom=atoi(str[9]);
mob_db_data[class_]->option=atoi(str[10])&~0x46;
- mob_db_data[class_]->clothes_color=atoi(str[11]); // Monster player dye option - Valaris
+ mob_db_data[class_]->vd.cloth_color=atoi(str[11]); // Monster player dye option - Valaris
}
- else if(str[2] && atoi(str[2]) > 0) mob_db_data[class_]->equip=atoi(str[2]); // mob equipment [Valaris]
+ else if(str[2] && atoi(str[2]) > 0)
+ mob_db_data[class_]->vd.shield=atoi(str[2]); // mob equipment [Valaris]
ln++;
}
@@ -3889,7 +3850,7 @@ static int mob_read_sqldb(void)
ln++;
- mob_db_data[class_]->view_class = class_;
+ mob_db_data[class_]->vd.class_ = class_;
memcpy(mob_db_data[class_]->name, TO_STR(1), NAME_LENGTH-1);
memcpy(mob_db_data[class_]->jname, TO_STR(2), NAME_LENGTH-1);
mob_db_data[class_]->lv = TO_INT(3);
diff --git a/src/map/mob.h b/src/map/mob.h
index e7e3eb07e..8fb930e1f 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -5,6 +5,7 @@
#define _MOB_H_
#include "unit.h"
+#include "map.h"
#define MAX_RANDOMMONSTER 3
#define MAX_MOB_RACE_DB 6
@@ -47,9 +48,8 @@ struct mob_db {
int mexp,mexpper;
struct { int nameid,p; } dropitem[10]; //8 -> 10 Lupus
struct { int nameid,p; } mvpitem[3];
- int view_class,sex;
- short hair,hair_color,weapon,shield,head_top,head_mid,head_buttom,option,clothes_color; // [Valaris]
- int equip; // [Valaris]
+ struct view_data vd;
+ short option;
int summonper[MAX_RANDOMMONSTER];
int maxskill;
struct mob_skill skill[MAX_MOBSKILL];
@@ -112,6 +112,7 @@ struct mob_db* mob_db(int class_);
int mobdb_searchname(const char *str);
int mobdb_searchname_array(struct mob_db** data, int size, const char *str);
int mobdb_checkid(const int id);
+struct view_data* mob_get_viewdata(int class_);
int mob_once_spawn(struct map_session_data *sd,char *mapname,
int x,int y,const char *mobname,int class_,int amount,const char *event);
int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
@@ -135,27 +136,13 @@ int mob_heal(struct mob_data*,int);
#define mob_stop_walking(md, type) { if (md->ud.walktimer != -1) unit_stop_walking(&md->bl, type); }
#define mob_stop_attack(md) { if (md->ud.attacktimer != -1) unit_stop_attack(&md->bl); }
-//Defines to speed up search.
-#define mob_get_viewclass(class_) mob_db(class_)->view_class
-#define mob_get_sex(class_) mob_db(class_)->sex
-#define mob_get_hair(class_) mob_db(class_)->hair
-#define mob_get_hair_color(class_) mob_db(class_)->hair_color
-#define mob_get_weapon(class_) mob_db(class_)->weapon
-#define mob_get_shield(class_) mob_db(class_)->shield
-#define mob_get_head_top(class_) mob_db(class_)->head_top
-#define mob_get_head_mid(class_) mob_db(class_)->head_mid
-#define mob_get_head_buttom(class_) mob_db(class_)->head_buttom
-#define mob_get_clothes_color(class_) mob_db(class_)->clothes_color
-#define mob_get_equip(class_) mob_db(class_)->equip
int do_init_mob(void);
int do_final_mob(void);
int mob_timer_delete(int tid, unsigned int tick, int id, int data);
-
int mob_deleteslave(struct mob_data *md);
-
int mob_random_class (int *value, size_t count);
int mob_get_random_id(int type, int flag, int lv);
int mob_class_change(struct mob_data *md,int class_);
diff --git a/src/map/npc.c b/src/map/npc.c
index e39d9abb6..d1a35ff61 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -63,6 +63,15 @@ static struct tm ev_tm_b; // 時計イベント用
static struct eri *timer_event_ers; //For the npc timer data. [Skotlex]
+//For holding the view data of npc classes. [Skotlex]
+static struct view_data npc_viewdb[MAX_NPC_CLASS];
+
+struct view_data* npc_get_viewdata(int class_)
+{ //Returns the viewdata for normal npc classes.
+ if (npcdb_checkid(class_) || class_ == WARP_CLASS)
+ return &npc_viewdb[class_];
+ return NULL;
+}
/*==========================================
* NPCの無効化/有効化
* npc_enable
@@ -102,7 +111,7 @@ int npc_enable(const char *name,int flag)
if (flag&1) { // 有効化
nd->flag&=~1;
- clif_spawnnpc(nd);
+ clif_spawn(&nd->bl);
}else if (flag&2){
nd->flag&=~1;
nd->sc.option = 0x0000;
@@ -1341,7 +1350,6 @@ int npc_unload (struct npc_data *nd)
}
}
}
-
aFree(nd);
return 0;
@@ -1487,7 +1495,9 @@ int npc_parse_warp (char *w1,char *w2,char *w3,char *w4)
nd->bl.type = BL_NPC;
nd->bl.subtype = WARP;
map_addblock(&nd->bl);
- clif_spawnnpc(nd);
+ unit_dataset(&nd->bl);
+ status_set_viewdata(&nd->bl, nd->class_);
+ clif_spawn(&nd->bl);
strdb_put(npcname_db, nd->name, nd);
return 0;
@@ -1577,7 +1587,8 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4)
if (m >= 0) {
nd->n = map_addnpc(m,nd);
map_addblock(&nd->bl);
- clif_spawnnpc(nd);
+ status_set_viewdata(&nd->bl, nd->class_);
+ clif_spawn(&nd->bl);
} else
// we skip map_addnpc, but still add it to the list of ID's
map_addiddb(&nd->bl);
@@ -1880,14 +1891,15 @@ static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_lin
if (m >= 0) {
nd->n = map_addnpc(m, nd);
map_addblock(&nd->bl);
-
if (evflag) { // イベント型
struct event_data *ev = (struct event_data *)aCalloc(1, sizeof(struct event_data));
ev->nd = nd;
ev->pos = 0;
strdb_put(ev_db, nd->exname, ev);
- } else
- clif_spawnnpc(nd);
+ } else {
+ status_set_viewdata(&nd->bl, nd->class_);
+ clif_spawn(&nd->bl);
+ }
} else {
// we skip map_addnpc, but still add it to the list of ID's
map_addiddb(&nd->bl);
@@ -2675,6 +2687,7 @@ static void npc_debug_warps_sub(struct npc_data *nd)
);
}
+
static void npc_debug_warps()
{
int m, i;
@@ -2691,9 +2704,14 @@ int do_init_npc(void)
{
struct npc_src_list *nsl;
time_t last_time = time(0);
- int busy = 0;
+ int busy;
char c = '-';
+ //Stock view data for normal npcs.
+ memset(&npc_viewdb, 0, sizeof(npc_viewdb));
+ for (busy = 0; busy < MAX_NPC_CLASS; busy++)
+ npc_viewdb[busy].class_ = busy;
+ busy = 0;
// indoorrswtable.txt and etcinfo.txt [Celest]
if (battle_config.indoors_override_grffile)
npc_read_indoors();
diff --git a/src/map/npc.h b/src/map/npc.h
index 8f659eb46..286fd6050 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -10,14 +10,17 @@
#define WARP_DEBUG_CLASS 722
#define INVISIBLE_CLASS 32767
+#define MAX_NPC_CLASS 1000
//Checks if a given id is a valid npc id. [Skotlex]
//Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001)
-#define npcdb_checkid(id) ((id >= 46 && id <= 125) || (id >= 700 && id <= 1000))
+#define npcdb_checkid(id) ((id >= 46 && id <= 125) || id == 139 || (id >= 700 && id <= MAX_NPC_CLASS))
#ifdef PCRE_SUPPORT
void npc_chat_finalize(struct npc_data *nd);
int mob_chat_sub(struct block_list *bl, va_list ap);
#endif
+
+struct view_data* npc_get_viewdata(int class_);
int npc_chat_sub(struct block_list *bl, va_list ap);
int npc_event_dequeue(struct map_session_data *sd);
int npc_event_timer(int tid,unsigned int tick,int id,int data);
@@ -40,8 +43,6 @@ int npc_enable(const char *name,int flag);
int npc_changename(const char *name, const char *newname, short look); // [Lance]
struct npc_data* npc_name2id(const char *name);
-int npc_changestate(struct npc_data *nd,int state,int type);
-
int npc_get_new_npc_id(void);
void npc_addsrcfile(char *);
diff --git a/src/map/pc.c b/src/map/pc.c
index 815a03391..3528628c8 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -649,7 +649,6 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t
// 基本的な初期化
sd->state.connect_new = 1;
- sd->view_class = sd->status.class_;
sd->speed = DEFAULT_WALK_SPEED;
sd->followtimer = -1; // [MouseJstr]
sd->skillitem = -1;
@@ -679,7 +678,9 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t
// アイテムチェック
pc_setinventorydata(sd);
pc_checkitem(sd);
-
+
+ //Set here because we need the inventory data for weapon sprite parsing.
+ status_set_viewdata(&sd->bl, sd->status.class_);
// pet
sd->pet_hungry_timer = -1;
@@ -1100,6 +1101,26 @@ int pc_checkweighticon(struct map_session_data *sd)
return 0;
}
+int pc_disguise(struct map_session_data *sd, int class_) {
+ if (!class_ && !sd->disguise)
+ return 0;
+ if (class_ && (sd->disguise || pc_isriding(sd)))
+ return 0;
+
+ if (!class_) {
+ sd->disguise = 0;
+ class_ = sd->status.class_;
+ } else
+ sd->disguise=class_;
+
+ pc_stop_walking(sd, 0);
+ clif_clearchar(&sd->bl, 0);
+ status_set_viewdata(&sd->bl, class_);
+ clif_changeoption(&sd->bl);
+ clif_spawn(&sd->bl);
+ return 1;
+}
+
static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short card_id) {
int i;
for (i = 0; i < max && spell[i].id; i++) {
@@ -1531,12 +1552,8 @@ int pc_bonus(struct map_session_data *sd,int type,int val)
}
break;
case SP_DISGUISE: // Disguise script for items [Valaris]
- if(sd->state.lr_flag!=2 && !sd->state.disguised && !pc_isriding(sd)) {
- clif_clearchar(&sd->bl, 0);
- sd->disguise=val;
- clif_changeoption(&sd->bl);
- clif_spawnpc(sd);
- }
+ if(sd->state.lr_flag!=2)
+ pc_disguise(sd, val);
break;
case SP_UNBREAKABLE:
if(sd->state.lr_flag!=2) {
@@ -5440,7 +5457,8 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
pc_setglobalreg (sd, "jobchange_level", sd->change_level);
- sd->status.class_ = sd->view_class = job;
+ sd->status.class_ = job;
+ status_set_viewdata(&sd->bl, job);
fame_flag = pc_istop10fame(sd->status.char_id,sd->class_&MAPID_UPPERMASK);
sd->class_ = (unsigned short)b_class;
sd->status.job_level=1;
@@ -5455,14 +5473,10 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
pc_unequipitem(sd,sd->equip_index[i],2); // ?備外し
}
- clif_changelook(&sd->bl,LOOK_BASE,sd->view_class); // move sprite update to prevent client crashes with incompatible equipment [Valaris]
+ clif_changelook(&sd->bl,LOOK_BASE,sd->vd.class_); // move sprite update to prevent client crashes with incompatible equipment [Valaris]
- if(battle_config.save_clothcolor &&
- sd->status.clothes_color > 0 &&
- ((sd->view_class != JOB_WEDDING && sd->view_class !=JOB_XMAS) ||
- (sd->view_class==JOB_WEDDING && !battle_config.wedding_ignorepalette) ||
- (sd->view_class==JOB_XMAS && !battle_config.xmas_ignorepalette)))
- clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+ if(sd->vd.cloth_color)
+ clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
if(battle_config.muting_players && sd->status.manner < 0 && battle_config.manner_system)
clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
@@ -5577,13 +5591,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val)
case LOOK_SHOES:
break;
}
-
- if((type==LOOK_CLOTHES_COLOR) && ((sd->view_class==JOB_WEDDING && battle_config.wedding_ignorepalette) ||
- (sd->view_class==JOB_XMAS && battle_config.xmas_ignorepalette)))
- return 0;
-
clif_changelook(&sd->bl,type,val);
-
return 0;
}
@@ -5599,22 +5607,22 @@ int pc_setoption(struct map_session_data *sd,int type)
switch (sd->status.class_)
{
case JOB_KNIGHT:
- sd->status.class_ = sd->view_class = JOB_KNIGHT2;
+ sd->status.class_ = sd->vd.class_ = JOB_KNIGHT2;
break;
case JOB_CRUSADER:
- sd->status.class_ = sd->view_class = JOB_CRUSADER2;
+ sd->status.class_ = sd->vd.class_ = JOB_CRUSADER2;
break;
case JOB_LORD_KNIGHT:
- sd->status.class_ = sd->view_class = JOB_LORD_KNIGHT2;
+ sd->status.class_ = sd->vd.class_ = JOB_LORD_KNIGHT2;
break;
case JOB_PALADIN:
- sd->status.class_ = sd->view_class = JOB_PALADIN2;
+ sd->status.class_ = sd->vd.class_ = JOB_PALADIN2;
break;
case JOB_BABY_KNIGHT:
- sd->status.class_ = sd->view_class = JOB_BABY_KNIGHT2;
+ sd->status.class_ = sd->vd.class_ = JOB_BABY_KNIGHT2;
break;
case JOB_BABY_CRUSADER:
- sd->status.class_ = sd->view_class = JOB_BABY_CRUSADER2;
+ sd->status.class_ = sd->vd.class_ = JOB_BABY_CRUSADER2;
break;
}
clif_status_load(&sd->bl,SI_RIDING,1);
@@ -5625,22 +5633,22 @@ int pc_setoption(struct map_session_data *sd,int type)
switch (sd->status.class_)
{
case JOB_KNIGHT2:
- sd->status.class_ = sd->view_class = JOB_KNIGHT;
+ sd->status.class_ = sd->vd.class_ = JOB_KNIGHT;
break;
case JOB_CRUSADER2:
- sd->status.class_ = sd->view_class = JOB_CRUSADER;
+ sd->status.class_ = sd->vd.class_ = JOB_CRUSADER;
break;
case JOB_LORD_KNIGHT2:
- sd->status.class_ = sd->view_class = JOB_LORD_KNIGHT;
+ sd->status.class_ = sd->vd.class_ = JOB_LORD_KNIGHT;
break;
case JOB_PALADIN2:
- sd->status.class_ = sd->view_class = JOB_PALADIN;
+ sd->status.class_ = sd->vd.class_ = JOB_PALADIN;
break;
case JOB_BABY_KNIGHT2:
- sd->status.class_ = sd->view_class = JOB_BABY_KNIGHT;
+ sd->status.class_ = sd->vd.class_ = JOB_BABY_KNIGHT;
break;
case JOB_BABY_CRUSADER2:
- sd->status.class_ = sd->view_class = JOB_BABY_CRUSADER;
+ sd->status.class_ = sd->vd.class_ = JOB_BABY_CRUSADER;
break;
}
clif_status_load(&sd->bl,SI_RIDING,0);
@@ -5654,11 +5662,13 @@ int pc_setoption(struct map_session_data *sd,int type)
//SG flying [Komurka]
if (type&OPTION_FLYING && !(sd->sc.option&OPTION_FLYING)) //Flying ON
{
- if (sd->status.class_==JOB_STAR_GLADIATOR) sd->status.class_ = sd->view_class = JOB_STAR_GLADIATOR2;
+ if (sd->status.class_==JOB_STAR_GLADIATOR)
+ sd->status.class_ = sd->vd.class_ = JOB_STAR_GLADIATOR2;
}
else if (!(type&OPTION_FLYING) && sd->sc.option&OPTION_FLYING) //Flying OFF
{
- if (sd->status.class_==JOB_STAR_GLADIATOR2) sd->status.class_ = sd->view_class = JOB_STAR_GLADIATOR;
+ if (sd->status.class_==JOB_STAR_GLADIATOR2)
+ sd->status.class_ = sd->vd.class_ = JOB_STAR_GLADIATOR;
}
sd->sc.option=type;
diff --git a/src/map/pc.h b/src/map/pc.h
index a6e65a3b5..d6b368d16 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -13,10 +13,10 @@
//Update this max as necessary. 53 is the value needed for Super Baby currently
#define MAX_SKILL_TREE 53
-#define pc_setdead(sd) ((sd)->state.dead_sit = 1)
-#define pc_setsit(sd) ((sd)->state.dead_sit = 2)
+#define pc_setdead(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 1)
+#define pc_setsit(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 2)
#define pc_isdead(sd) ((sd)->state.dead_sit == 1)
-#define pc_issit(sd) ((sd)->state.dead_sit == 2)
+#define pc_issit(sd) ((sd)->vd.dead_sit == 2)
#define pc_setdir(sd,b,h) ((sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
#define pc_setchatid(sd,n) ((sd)->chatID = n)
#define pc_ishiding(sd) ((sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK))
@@ -237,5 +237,5 @@ int map_day_timer(int,unsigned int,int,int); // by [yor]
int map_night_timer(int,unsigned int,int,int); // by [yor]
int pc_read_motd(void); // [Valaris]
-
+int pc_disguise(struct map_session_data *sd, int class_);
#endif
diff --git a/src/map/pet.c b/src/map/pet.c
index 00994c723..4aef4e9b4 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -434,6 +434,7 @@ int pet_data_init(struct map_session_data *sd)
pd->bl.subtype = MONS;
pd->bl.type = BL_PET;
pd->msd = sd;
+ status_set_viewdata(&pd->bl,pd->class_);
unit_dataset(&sd->pd->bl);
pd->ud.dir = sd->ud.dir;
@@ -488,7 +489,7 @@ int pet_birth_process(struct map_session_data *sd)
chrif_save(sd,0); //FIXME: As before, is it REALLY Needed to save the char for hatching a pet? [Skotlex]
map_addblock(&sd->pd->bl);
- clif_spawnpet(sd->pd);
+ clif_spawn(&sd->pd->bl);
clif_send_petdata(sd,0,0);
clif_send_petdata(sd,5,battle_config.pet_hair_style);
clif_pet_equip(sd->pd,sd->pet.equip);
@@ -533,7 +534,7 @@ int pet_recv_petdata(int account_id,struct s_pet *p,int flag)
pet_data_init(sd);
if(sd->pd && sd->bl.prev != NULL) {
map_addblock(&sd->pd->bl);
- clif_spawnpet(sd->pd);
+ clif_spawn(&sd->pd->bl);
clif_send_petdata(sd,0,0);
clif_send_petdata(sd,5,battle_config.pet_hair_style);
// clif_pet_equip(sd->pd,sd->pet.equip);
@@ -736,7 +737,7 @@ int pet_change_name(struct map_session_data *sd,char *name)
memcpy(sd->pd->name, name, NAME_LENGTH-1);
clif_clearchar_area(&sd->pd->bl,0);
- clif_spawnpet(sd->pd);
+ clif_spawn(&sd->pd->bl);
clif_send_petdata(sd,0,0);
clif_send_petdata(sd,5,battle_config.pet_hair_style);
sd->pet.rename_flag = 1;
@@ -971,8 +972,8 @@ static int pet_ai_sub_hard(struct pet_data *pd,unsigned int tick)
}
//Return speed to normal.
- if (pd->speed == 1 || pd->speed == sd->speed>>1);
- pd->speed = status_get_speed(&pd->bl);
+ if (pd->speed != sd->petDB->speed)
+ pd->speed == sd->petDB->speed;
if (pd->target_id) {
target= map_id2bl(pd->target_id);
diff --git a/src/map/script.c b/src/map/script.c
index 8e09ad061..c9dfb3cd8 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -6333,11 +6333,9 @@ int buildin_changebase(struct script_state *st)
return 0;
}
-// if(vclass==22) {
-// pc_unequipitem(sd,sd->equip_index[9],0); // 装備外
-// }
-
- sd->view_class = vclass;
+ //If you are already using a special view (disguises?) prevent overriding it. [Skotlex]
+ if (sd->vd.class_ == sd->status.class_)
+ status_set_viewdata(&sd->bl, vclass);
return 0;
}
@@ -8054,13 +8052,7 @@ int buildin_disguise(struct script_state *st)
return 0;
}
- pc_stop_walking(sd,0);
- clif_clearchar(&sd->bl, 0);
- sd->disguise = id;
- sd->state.disguised = 1; // set to override items with disguise script [Valaris]
- clif_changeoption(&sd->bl);
- clif_spawnpc(sd);
-
+ pc_disguise(sd, id);
push_val(st->stack,C_INT,id);
return 0;
}
@@ -8074,11 +8066,7 @@ int buildin_undisguise(struct script_state *st)
struct map_session_data *sd=script_rid2sd(st);
if (sd->disguise) {
- pc_stop_walking(sd,0);
- clif_clearchar(&sd->bl, 0);
- sd->disguise = 0;
- clif_changeoption(&sd->bl);
- clif_spawnpc(sd);
+ pc_disguise(sd, 0);
push_val(st->stack,C_INT,0);
} else {
push_val(st->stack,C_INT,1);
@@ -10209,17 +10197,17 @@ int buildin_getmobdata(struct script_state *st) {
setd_sub(map_id2sd(st->rid),name,9,(void *)(int)md->mode);
setd_sub(map_id2sd(st->rid),name,10,(void *)(int)md->special_state.ai);
setd_sub(map_id2sd(st->rid),name,11,(void *)(int)md->db->option);
- setd_sub(map_id2sd(st->rid),name,12,(void *)(int)md->db->sex);
- setd_sub(map_id2sd(st->rid),name,13,(void *)(int)md->db->view_class);
- setd_sub(map_id2sd(st->rid),name,14,(void *)(int)md->db->hair);
- setd_sub(map_id2sd(st->rid),name,15,(void *)(int)md->db->hair_color);
- setd_sub(map_id2sd(st->rid),name,16,(void *)(int)md->db->head_buttom);
- setd_sub(map_id2sd(st->rid),name,17,(void *)(int)md->db->head_mid);
- setd_sub(map_id2sd(st->rid),name,18,(void *)(int)md->db->head_top);
- setd_sub(map_id2sd(st->rid),name,19,(void *)(int)md->db->clothes_color);
- setd_sub(map_id2sd(st->rid),name,20,(void *)(int)md->db->equip);
- setd_sub(map_id2sd(st->rid),name,21,(void *)(int)md->db->weapon);
- setd_sub(map_id2sd(st->rid),name,22,(void *)(int)md->db->shield);
+ setd_sub(map_id2sd(st->rid),name,12,(void *)(int)md->vd->sex);
+ setd_sub(map_id2sd(st->rid),name,13,(void *)(int)md->vd->class_);
+ setd_sub(map_id2sd(st->rid),name,14,(void *)(int)md->vd->hair_style);
+ setd_sub(map_id2sd(st->rid),name,15,(void *)(int)md->vd->hair_color);
+ setd_sub(map_id2sd(st->rid),name,16,(void *)(int)md->vd->head_bottom);
+ setd_sub(map_id2sd(st->rid),name,17,(void *)(int)md->vd->head_mid);
+ setd_sub(map_id2sd(st->rid),name,18,(void *)(int)md->vd->head_top);
+ setd_sub(map_id2sd(st->rid),name,19,(void *)(int)md->vd->cloth_color);
+ setd_sub(map_id2sd(st->rid),name,20,(void *)(int)md->vd->shield);
+ setd_sub(map_id2sd(st->rid),name,21,(void *)(int)md->vd->weapon);
+ setd_sub(map_id2sd(st->rid),name,22,(void *)(int)md->vd->shield);
setd_sub(map_id2sd(st->rid),name,23,(void *)(int)md->ud.dir);
}
return 0;
@@ -10271,37 +10259,37 @@ int buildin_setmobdata(struct script_state *st){
md->db->option = (short)value;
break;
case 12:
- md->db->sex = value;
+ md->vd->sex = value;
break;
case 13:
- md->db->view_class = value;
+ md->vd->class_ = value;
break;
case 14:
- md->db->hair = (short)value;
+ md->vd->hair_style = (short)value;
break;
case 15:
- md->db->hair_color = (short)value;
+ md->vd->hair_color = (short)value;
break;
case 16:
- md->db->head_buttom = (short)value;
+ md->vd->head_bottom = (short)value;
break;
case 17:
- md->db->head_mid = (short)value;
+ md->vd->head_mid = (short)value;
break;
case 18:
- md->db->head_top = (short)value;
+ md->vd->head_top = (short)value;
break;
case 19:
- md->db->clothes_color = (short)value;
+ md->vd->cloth_color = (short)value;
break;
case 20:
- md->db->equip = value;
+ md->vd->shield = value;
break;
case 21:
- md->db->weapon = (short)value;
+ md->vd->weapon = (short)value;
break;
case 22:
- md->db->shield = (short)value;
+ md->vd->shield = (short)value;
break;
case 23:
md->ud.dir = (unsigned char)value;
diff --git a/src/map/skill.c b/src/map/skill.c
index d30ae2d26..24054ed46 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -1580,13 +1580,9 @@ int skill_blown( struct block_list *src, struct block_list *target,int count)
int dx=0,dy=0,nx,ny;
int x=target->x,y=target->y;
int dir,ret;
- struct map_session_data *sd=NULL;
- struct mob_data *md=NULL;
- struct pet_data *pd=NULL;
struct skill_unit *su=NULL;
nullpo_retr(0, src);
- nullpo_retr(0, target);
if (src != target && map_flag_gvg(target->m) && target->type != BL_SKILL)
return 0; //No knocking back in WoE, except for skills... because traps CAN be knocked back.
@@ -1594,22 +1590,13 @@ int skill_blown( struct block_list *src, struct block_list *target,int count)
return 0; //Actual knockback distance is 0.
switch (target->type) {
- case BL_PC:
- sd=(struct map_session_data *)target;
- break;
case BL_MOB:
- md=(struct mob_data *)target;
- if (md->class_ == MOBID_EMPERIUM)
+ if (((TBL_MOB*)target)->class_ == MOBID_EMPERIUM)
return 0;
break;
- case BL_PET:
- pd=(struct pet_data *)target;
- break;
case BL_SKILL:
su=(struct skill_unit *)target;
break;
- default:
- return 0;
}
if (count&0xf00000)
@@ -1628,8 +1615,9 @@ int skill_blown( struct block_list *src, struct block_list *target,int count)
ret=path_blownpos(target->m,x,y,dx,dy,count&0xffff);
nx=ret>>16;
ny=ret&0xffff;
-
- unit_stop_walking(target,0);
+
+ if (!su)
+ unit_stop_walking(target,0);
dx = nx - x;
dy = ny - y;
@@ -1637,26 +1625,19 @@ int skill_blown( struct block_list *src, struct block_list *target,int count)
if (!dx && !dy) //Could not knockback.
return 0;
- if(sd) /* ?面外に?oたので?チ去 */
- map_foreachinmovearea(clif_pcoutsight,target->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_ALL,sd);
- else if(md)
- map_foreachinmovearea(clif_moboutsight,target->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,md);
- else if(pd)
- map_foreachinmovearea(clif_petoutsight,target->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,pd);
+ map_foreachinmovearea(clif_outsight,target->m,
+ x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,
+ dx,dy,target->type==BL_PC?BL_ALL:BL_PC,target);
- if(su){
+ if(su)
skill_unit_move_unit_group(su->group,target->m,dx,dy);
- }else{
+ else
map_moveblock(target, nx, ny, gettick());
- }
-
- if(sd) /* ?面?に入ってきたので表示 */
- map_foreachinmovearea(clif_pcinsight,target->m,nx-AREA_SIZE,ny-AREA_SIZE,nx+AREA_SIZE,ny+AREA_SIZE,-dx,-dy,BL_ALL,sd);
- else if(md)
- map_foreachinmovearea(clif_mobinsight,target->m,nx-AREA_SIZE,ny-AREA_SIZE,nx+AREA_SIZE,ny+AREA_SIZE,-dx,-dy,BL_PC,md);
- else if(pd)
- map_foreachinmovearea(clif_petinsight,target->m,nx-AREA_SIZE,ny-AREA_SIZE,nx+AREA_SIZE,ny+AREA_SIZE,-dx,-dy,BL_PC,pd);
+ map_foreachinmovearea(clif_insight,target->m,
+ nx-AREA_SIZE,ny-AREA_SIZE,nx+AREA_SIZE,ny+AREA_SIZE,
+ -dx,-dy,target->type==BL_PC?BL_ALL:BL_PC,target);
+
if(!(count&0x20000))
clif_blown(target);
@@ -8826,7 +8807,7 @@ int skill_frostjoke_scream(struct block_list *bl,va_list ap)
return 0;
if (bl->type == BL_PC) {
struct map_session_data *sd = (struct map_session_data *)bl;
- if (sd && sd->sc.option & OPTION_INVISIBLE && pc_isGM(sd) > 0)
+ if (sd && sd->sc.option&OPTION_INVISIBLE)
return 0;
}
//It has been reported that Scream/Joke works the same regardless of woe-setting. [Skotlex]
diff --git a/src/map/status.c b/src/map/status.c
index 171370b0c..8d1028427 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -12,6 +12,7 @@
#include "pc.h"
#include "map.h"
#include "pet.h"
+#include "npc.h"
#include "mob.h"
#include "clif.h"
#include "guild.h"
@@ -626,8 +627,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
b_matk2 = sd->matk2;
b_mdef = sd->mdef;
b_mdef2 = sd->mdef2;
- b_class = sd->view_class;
- sd->view_class = sd->status.class_;
+ b_class = sd->vd.class_;
b_base_atk = sd->base_atk;
pc_calc_skilltree(sd); // スキルツリ?の計算
@@ -799,14 +799,6 @@ int status_calc_pc(struct map_session_data* sd,int first)
+ sizeof(sd->add_mdmg_count)
);
- if(!sd->state.disguised && sd->disguise) {
- pc_stop_walking(sd,0);
- clif_clearchar(&sd->bl, 0);
- sd->disguise=0;
- clif_changeoption(&sd->bl);
- clif_spawnpc(sd);
- }
-
for(i=0;i<10;i++) {
current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
if(index < 0)
@@ -1601,28 +1593,12 @@ int status_calc_pc(struct map_session_data* sd,int first)
calculating = 0;
return 0;
}
-
-
- if(sd->sc.data[SC_WEDDING].timer != -1 && sd->view_class != JOB_WEDDING)
- sd->view_class=JOB_WEDDING;
- if(sd->sc.data[SC_XMAS].timer != -1 && sd->view_class != JOB_XMAS)
- sd->view_class=JOB_XMAS;
-
- if(b_class != sd->view_class) {
- clif_changelook(&sd->bl,LOOK_BASE,sd->view_class);
-#if PACKETVER < 4
- clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
-#else
- clif_changelook(&sd->bl,LOOK_WEAPON,0);
-#endif
- //Restoring cloth dye color after the view class changes. [Skotlex]
- // Added Xmas Suit [Valaris]
- if(battle_config.save_clothcolor && sd->status.clothes_color > 0 &&
- ((sd->view_class != JOB_WEDDING && sd->view_class !=JOB_XMAS) || (sd->view_class==JOB_WEDDING && !battle_config.wedding_ignorepalette) ||
- (sd->view_class==JOB_XMAS && !battle_config.xmas_ignorepalette)))
- clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+ if(b_class != sd->vd.class_) {
+ clif_changelook(&sd->bl,LOOK_BASE,sd->vd.class_);
+ clif_changelook(&sd->bl,LOOK_WEAPON,sd->vd.weapon);
+ clif_changelook(&sd->bl,LOOK_SHIELD,sd->vd.shield);
+ clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
}
if(memcmp(b_skill,sd->status.skill,sizeof(sd->status.skill)))
@@ -2991,7 +2967,7 @@ int status_get_speed(struct block_list *bl)
speed-=((struct mob_data *)bl)->level - ((struct mob_data *)bl)->db->lv;
}
else if(bl->type==BL_PET)
- speed = ((struct pet_data *)bl)->msd->petDB->speed;
+ speed = ((struct pet_data *)bl)->speed;
else if(bl->type==BL_NPC) //Added BL_NPC (Skotlex)
speed = ((struct npc_data *)bl)->speed;
@@ -3208,6 +3184,8 @@ int status_get_guild_id(struct block_list *bl)
return msd->status.guild_id; //Alchemist's mobs [Skotlex]
return 0; //No guild.
}
+ if (bl->type == BL_NPC && bl->subtype == SCRIPT)
+ return ((TBL_NPC*)bl)->u.scr.guild_id;
if(bl->type==BL_SKILL)
return ((struct skill_unit *)bl)->group->guild_id;
return 0;
@@ -3302,6 +3280,98 @@ int status_isimmune(struct block_list *bl)
return 0;
}
+struct view_data *status_get_viewdata(struct block_list *bl)
+{
+ nullpo_retr(NULL, bl);
+ switch (bl->type)
+ {
+ case BL_PC:
+ return &((TBL_PC*)bl)->vd;
+ case BL_MOB:
+ return ((TBL_MOB*)bl)->vd;
+ case BL_PET:
+ return &((TBL_PET*)bl)->vd;
+ case BL_NPC:
+ return ((TBL_NPC*)bl)->vd;
+ }
+ return NULL;
+}
+
+void status_set_viewdata(struct block_list *bl, int class_)
+{
+ struct view_data* vd;
+ nullpo_retv(bl);
+ if (mobdb_checkid(class_) || mob_is_clone(class_))
+ vd = mob_get_viewdata(class_);
+ else if (npcdb_checkid(class_) || (bl->type == BL_NPC && class_ == WARP_CLASS))
+ vd = npc_get_viewdata(class_);
+ else
+ vd = NULL;
+
+ switch (bl->type) {
+ case BL_PC:
+ {
+ TBL_PC* sd = (TBL_PC*)bl;
+ if (pcdb_checkid(class_)) {
+ sd->vd.class_ = class_;
+ clif_get_weapon_view(sd, &sd->vd.weapon, &sd->vd.shield);
+ sd->vd.head_top = sd->status.head_top;
+ sd->vd.head_mid = sd->status.head_mid;
+ sd->vd.head_bottom = sd->status.head_bottom;
+ sd->vd.hair_style = sd->status.hair;
+ sd->vd.hair_color = sd->status.hair_color;
+ sd->vd.cloth_color = sd->status.clothes_color;
+ sd->vd.sex = sd->status.sex;
+ } else if (vd)
+ memcpy(&sd->vd, vd, sizeof(struct view_data));
+ else if (battle_config.error_log)
+ ShowError("status_set_viewdata (PC): No view data for class %d\n", class_);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB* md = (TBL_MOB*)bl;
+ if (vd)
+ md->vd = vd;
+ else if (battle_config.error_log)
+ ShowError("status_set_viewdata (MOB): No view data for class %d\n", class_);
+ }
+ break;
+ case BL_PET:
+ {
+ TBL_PET* pd = (TBL_PET*)bl;
+ if (vd) {
+ memcpy(&pd->vd, vd, sizeof(struct view_data));
+ if (!pcdb_checkid(vd->class_)) {
+ pd->vd.hair_style = battle_config.pet_hair_style;
+ if(pd->equip) {
+ pd->vd.shield = itemdb_viewid(pd->equip);
+ if (!pd->vd.shield)
+ pd->vd.shield = pd->equip;
+ }
+ }
+ } else if (battle_config.error_log)
+ ShowError("status_set_viewdata (PET): No view data for class %d\n", class_);
+ }
+ break;
+ case BL_NPC:
+ {
+ TBL_NPC* nd = (TBL_NPC*)bl;
+ if (vd)
+ nd->vd = vd;
+ else if (battle_config.error_log)
+ ShowError("status_set_viewdata (NPC): No view data for class %d\n", class_);
+ }
+ break;
+ }
+ vd = status_get_viewdata(bl);
+ if (vd && vd->cloth_color && (
+ (vd->class_==JOB_WEDDING && !battle_config.wedding_ignorepalette)
+ || (vd->class_==JOB_XMAS && !battle_config.xmas_ignorepalette)
+ ))
+ vd->cloth_color = 0;
+}
+
struct status_change *status_get_sc(struct block_list *bl)
{
nullpo_retr(NULL, bl);
@@ -3980,24 +4050,20 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
case SC_XMAS: // Xmas Suit [Valaris]
case SC_WEDDING: //結婚用(結婚衣裳になって?くのが?いとか)
- if (sd)
- { //Change look.
- pc_stop_attack(sd);
- if(type==SC_WEDDING)
- sd->view_class = JOB_WEDDING;
- else if(type==SC_XMAS)
- sd->view_class = JOB_XMAS;
- clif_changelook(&sd->bl,LOOK_BASE,sd->view_class);
-#if PACKETVER < 4
- clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
-#else
- clif_changelook(&sd->bl,LOOK_WEAPON,0);
-#endif
- if(battle_config.save_clothcolor && sd->status.clothes_color > 0 &&
- ((type==SC_WEDDING && !battle_config.wedding_ignorepalette) ||
- (type==SC_XMAS && !battle_config.xmas_ignorepalette)))
- clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+ {
+ struct view_data *vd = status_get_viewdata(bl);
+ if (vd) {
+ //Store previous values as they could be removed.
+ val1 = vd->class_;
+ val2 = vd->weapon;
+ val3 = vd->shield;
+ val4 = vd->cloth_color;
+ unit_stop_attack(bl);
+ clif_changelook(bl,LOOK_BASE,type==SC_WEDDING?JOB_WEDDING:JOB_XMAS);
+ clif_changelook(bl,LOOK_WEAPON,0);
+ clif_changelook(bl,LOOK_SHIELD,0);
+ clif_changelook(bl,LOOK_CLOTHES_COLOR,vd->cloth_color);
+ }
}
break;
case SC_NOCHAT: //チャット禁止?態
@@ -4341,6 +4407,13 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
val4 = gettick(); //Store time at which you started running.
calc_flag = 1;
break;
+
+ case SC_TRICKDEAD: /* 死んだふり */
+ {
+ struct view_data *vd = status_get_viewdata(bl);
+ if (vd) vd->dead_sit = 1;
+ break;
+ }
case SC_BLESSING:
case SC_CONCENTRATION: /* コンセントレ?ション */case SC_ETERNALCHAOS: /* エタ?ナルカオス */
case SC_DRUMBATTLE: /* ?太鼓の響き */
@@ -4428,7 +4501,6 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
case SC_POEMBRAGI: /* ブラギの詩 */
case SC_UGLYDANCE: /* 自分勝手なダンス */
case SC_WEAPONPERFECTION: /* ウェポンパ?フェクション */
- case SC_TRICKDEAD: /* 死んだふり */
case SC_FREEZE: /* 凍結 */
case SC_STUN: /* スタン(val2にミリ秒セット) */
case SC_ENERGYCOAT: /* エナジ?コ?ト */
@@ -4849,18 +4921,23 @@ int status_change_end( struct block_list* bl , int type,int tid )
case SC_XMAS: // Xmas Suit [Valaris]
case SC_WEDDING: //結婚用(結婚衣裳になって?くのが?いとか)
- if (sd) {
- //Restore look
- sd->view_class = sd->status.class_;
- clif_changelook(&sd->bl,LOOK_BASE,sd->view_class);
-#if PACKETVER < 4
- clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
-#else
- clif_changelook(&sd->bl,LOOK_WEAPON,0);
-#endif
- if(battle_config.save_clothcolor && sd->status.clothes_color > 0)
- clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+ {
+ struct view_data *vd = status_get_viewdata(bl);
+ if (vd) {
+ if (sd) {
+ //Load data from sd->status.* as the stored values could have changed.
+ status_set_viewdata(bl, sd->status.class_);
+ } else {
+ vd->class_ = sc->data[type].val1;
+ vd->weapon = sc->data[type].val2;
+ vd->shield = sc->data[type].val3;
+ vd->cloth_color = sc->data[type].val4;
+ }
+ clif_changelook(bl,LOOK_BASE,vd->class_);
+ clif_changelook(bl,LOOK_WEAPON,vd->weapon);
+ clif_changelook(bl,LOOK_SHIELD,vd->shield);
+ clif_changelook(bl,LOOK_CLOTHES_COLOR,vd->cloth_color);
+ }
}
break;
case SC_RUN://駆け足
@@ -5047,6 +5124,13 @@ int status_change_end( struct block_list* bl , int type,int tid )
case SC_MOONLIT: //Clear the unit effect. [Skotlex]
skill_setmapcell(bl,CG_MOONLIT, sc->data[SC_MOONLIT].val1, CELL_CLRMOONLIT);
break;
+ case SC_TRICKDEAD: /* 死んだふり */
+ {
+ struct view_data *vd = status_get_viewdata(bl);
+ if (vd) vd->dead_sit = 0;
+ break;
+ }
+
//gs_something2 [Vicious]
case SC_MADNESSCANCEL:
case SC_ADJUSTMENT:
diff --git a/src/map/status.h b/src/map/status.h
index 896e64735..faf395b2f 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -481,6 +481,8 @@ int status_get_mode(struct block_list *bl);
int status_get_mexp(struct block_list *bl);
int status_get_race2(struct block_list *bl);
+struct view_data *status_get_viewdata(struct block_list *bl);
+void status_set_viewdata(struct block_list *bl, int class_);
struct status_change *status_get_sc(struct block_list *bl);
int status_get_matk1(struct block_list *bl);
diff --git a/src/map/unit.c b/src/map/unit.c
index e441bc693..dd2ee0505 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -57,21 +57,9 @@ int unit_walktoxy_sub(struct block_list *bl)
memcpy(&ud->walkpath,&wpd,sizeof(wpd));
- switch (bl->type) {
- case BL_PC:
+ if (bl->type == BL_PC)
clif_walkok((TBL_PC*)bl);
- clif_movechar((TBL_PC*)bl);
- break;
- case BL_MOB:
- clif_movemob((TBL_MOB*)bl);
- break;
- case BL_PET:
- clif_movepet((TBL_PET*)bl);
- break;
- case BL_NPC:
- clif_movenpc((TBL_NPC*)bl);
- break;
- }
+ clif_move(bl);
ud->state.change_walk_target=0;
@@ -151,22 +139,9 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
// バシリカ判定
- ud->walktimer = 1;
- switch (bl->type) {
- case BL_PC:
- map_foreachinmovearea(clif_pcoutsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_ALL,sd);
- break;
- case BL_MOB:
- map_foreachinmovearea(clif_moboutsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,md);
- break;
- case BL_PET:
- map_foreachinmovearea(clif_petoutsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,(TBL_PET*)bl);
- break;
- case BL_NPC:
- map_foreachinmovearea(clif_npcoutsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,(TBL_NPC*)bl);
- break;
- }
- ud->walktimer = -1;
+ map_foreachinmovearea(clif_outsight,bl->m,
+ x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,
+ dx,dy,sd?BL_ALL:BL_PC,bl);
if(md && md->min_chase > md->db->range2)
md->min_chase--;
@@ -176,20 +151,9 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
map_moveblock(bl, x, y, tick);
ud->walktimer = 1;
- switch (bl->type) {
- case BL_PC:
- map_foreachinmovearea(clif_pcinsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,-dx,-dy,BL_ALL,sd);
- break;
- case BL_MOB:
- map_foreachinmovearea(clif_mobinsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,-dx,-dy,BL_PC,md);
- break;
- case BL_PET:
- map_foreachinmovearea(clif_petinsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,-dx,-dy,BL_PC,(TBL_PET*)bl);
- break;
- case BL_NPC:
- map_foreachinmovearea(clif_npcinsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,-dx,-dy,BL_PC,(TBL_NPC*)bl);
- break;
- }
+ map_foreachinmovearea(clif_insight,bl->m,
+ x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,
+ -dx,-dy,sd?BL_ALL:BL_PC,bl);
ud->walktimer = -1;
if(sd) {
@@ -219,7 +183,6 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
clif_displaymessage(sd->fd,"[Miracle of the Sun, Moon and Stars]");
sc_start(&sd->bl,SC_MIRACLE,100,1,battle_config.sg_miracle_skill_duration);
}
-
}
}
@@ -285,14 +248,11 @@ int unit_movepos(struct block_list *bl,int dst_x,int dst_y, int easy, int checkp
int dx,dy,dir;
struct unit_data *ud = NULL;
struct map_session_data *sd = NULL;
- struct mob_data *md = NULL;
struct walkpath_data wpd;
nullpo_retr(0, bl);
if( BL_CAST( BL_PC, bl, sd ) ) {
ud = &sd->ud;
- } else if( BL_CAST( BL_MOB, bl, md ) ) {
- ud = &md->ud;
} else
ud = unit_bl2ud(bl);
@@ -311,37 +271,16 @@ int unit_movepos(struct block_list *bl,int dst_x,int dst_y, int easy, int checkp
dx = dst_x - bl->x;
dy = dst_y - bl->y;
- switch (bl->type) {
- case BL_PC:
- map_foreachinmovearea(clif_pcoutsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,dx,dy,BL_ALL,sd);
- break;
- case BL_MOB:
- map_foreachinmovearea(clif_moboutsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,dx,dy,BL_PC,md);
- break;
- case BL_PET:
- map_foreachinmovearea(clif_petoutsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,dx,dy,BL_PC,(TBL_PET*)bl);
- break;
- case BL_NPC:
- map_foreachinmovearea(clif_petoutsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,dx,dy,BL_PC,(TBL_NPC*)bl);
- break;
- }
+ map_foreachinmovearea(clif_outsight,bl->m,
+ bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,
+ dx,dy,sd?BL_ALL:BL_PC,bl);
map_moveblock(bl, dst_x, dst_y, gettick());
+
ud->walktimer = 1;
- switch (bl->type) {
- case BL_PC:
- map_foreachinmovearea(clif_pcinsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,-dx,-dy,BL_ALL,sd);
- break;
- case BL_MOB:
- map_foreachinmovearea(clif_mobinsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,-dx,-dy,BL_PC,md);
- break;
- case BL_PET:
- map_foreachinmovearea(clif_petinsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,-dx,-dy,BL_PC,(TBL_PET*)bl);
- break;
- case BL_NPC:
- map_foreachinmovearea(clif_npcinsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,-dx,-dy,BL_PC,(TBL_NPC*)bl);
- break;
- }
+ map_foreachinmovearea(clif_insight,bl->m,
+ bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,
+ -dx,-dy,sd?BL_ALL:BL_PC,bl);
ud->walktimer = -1;
if(sd) {
@@ -454,21 +393,11 @@ int unit_warp(struct block_list *bl,int m,int x,int y,int type)
bl->m=m;
map_addblock(bl);
- switch (bl->type) {
- case BL_PC:
- clif_spawnpc((TBL_PC*)bl);
- break;
- case BL_MOB:
- clif_spawnmob((TBL_MOB*)bl);
- mob_warpslave(bl,AREA_SIZE);
- break;
- case BL_PET:
- clif_spawnpet((TBL_PET*)bl);
- break;
- case BL_NPC:
- clif_spawnnpc((TBL_NPC*)bl);
- break;
- }
+ clif_spawn(bl);
+//This is broken because the mob already was changed from map.
+//Fortunately, the slave ai will make them chase their master automatically
+// if (bl->type == BL_MOB)
+// mob_warpslave(bl,AREA_SIZE);
skill_unit_move(bl,gettick(),1);
return 0;
}
@@ -836,11 +765,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, int skill_num, int
}
if( casttime>0 || temp){ /* 詠唱が必要 */
- if(sd && sd->disguise) { // [Valaris]
- clif_skillcasting(src, src->id, target_id, 0,0, skill_num,0);
- clif_skillcasting(src,-src->id, target_id, 0,0, skill_num,casttime);
- } else
- clif_skillcasting(src, src->id, target_id, 0,0, skill_num,casttime);
+
+ clif_skillcasting(src, src->id, target_id, 0,0, skill_num,casttime);
/* 詠唱反応モンスター */
if (sd && target->type == BL_MOB)
@@ -973,12 +899,7 @@ int unit_skilluse_pos2( struct block_list *src, int skill_x, int skill_y, int sk
if( casttime>0 ) {
/* 詠唱が必要 */
unit_stop_walking( src, 1); // 歩行停止
- if(sd && sd->disguise) { // [Valaris]
- clif_skillcasting(src, src->id, 0, skill_x,skill_y, skill_num,0);
- clif_skillcasting(src,-src->id, 0, skill_x,skill_y, skill_num,casttime);
- }
- else
- clif_skillcasting(src, src->id, 0, skill_x,skill_y, skill_num,casttime);
+ clif_skillcasting(src, src->id, 0, skill_x,skill_y, skill_num,casttime);
}
if( casttime<=0 ) /* 詠唱の無いものはキャンセルされない */
@@ -1502,7 +1423,7 @@ int unit_remove_map(struct block_list *bl, int clrtype) {
delete_timer(md->deletetimer,mob_timer_delete);
md->deletetimer=-1;
md->hp=0;
- if(pcdb_checkid(mob_get_viewclass(md->class_))) //Player mobs are not removed automatically by the client.
+ if(pcdb_checkid(md->vd->class_)) //Player mobs are not removed automatically by the client.
clif_clearchar_delay(gettick()+3000,bl,0);
mob_deleteslave(md);