summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c56
-rw-r--r--src/map/map.c2
-rw-r--r--src/map/map.h2
-rw-r--r--src/map/mob.c2
-rw-r--r--src/map/mob.h8
-rw-r--r--src/map/npc.c26
-rw-r--r--src/map/npc.h3
-rw-r--r--src/map/packets.h74
-rw-r--r--src/map/packets_keys.h14
-rw-r--r--src/map/script.c132
-rw-r--r--src/map/script.h2
-rw-r--r--src/map/status.c12
12 files changed, 264 insertions, 69 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 088c92ea8..4dc36be6d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -293,7 +293,11 @@ unsigned char clif_bl_type(struct block_list *bl)
case BL_NPC:
vd = status->get_viewdata(bl);
nullpo_retr(CLUT_NPC, vd);
+#if PACKETVER >= 20170726
+ return CLUT_EVENT;
+#else
return pc->db_checkid(vd->class) ? CLUT_PC : CLUT_EVENT;
+#endif
case BL_PET:
vd = status->get_viewdata(bl);
nullpo_retr(CLUT_NPC, vd);
@@ -1067,14 +1071,17 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
#endif
#if PACKETVER >= 20120221
if (battle_config.show_monster_hp_bar && bl->type == BL_MOB && status_get_hp(bl) < status_get_max_hp(bl)) {
- const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
p.maxHP = status_get_max_hp(bl);
p.HP = status_get_hp(bl);
- p.isBoss = (md->spawn != NULL && md->spawn->state.boss) ? 1 : 0;
} else {
p.maxHP = -1;
p.HP = -1;
- p.isBoss = 0;
+ }
+ if (bl->type == BL_MOB) {
+ const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
+ p.isBoss = (md->spawn != NULL) ? md->spawn->state.boss : BTYPE_NONE;
+ } else {
+ p.isBoss = BTYPE_NONE;
}
#endif
#if PACKETVER >= 20150513
@@ -1216,14 +1223,17 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
#endif
#if PACKETVER >= 20120221
if (battle_config.show_monster_hp_bar && bl->type == BL_MOB && status_get_hp(bl) < status_get_max_hp(bl)) {
- const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
p.maxHP = status_get_max_hp(bl);
p.HP = status_get_hp(bl);
- p.isBoss = (md->spawn != NULL && md->spawn->state.boss) ? 1 : 0;
} else {
p.maxHP = -1;
p.HP = -1;
- p.isBoss = 0;
+ }
+ if (bl->type == BL_MOB) {
+ const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
+ p.isBoss = (md->spawn != NULL) ? md->spawn->state.boss : BTYPE_NONE;
+ } else {
+ p.isBoss = BTYPE_NONE;
}
#endif
#if PACKETVER >= 20150513
@@ -1315,14 +1325,17 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
#endif
#if PACKETVER >= 20120221
if (battle_config.show_monster_hp_bar && bl->type == BL_MOB && status_get_hp(bl) < status_get_max_hp(bl)) {
- const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
p.maxHP = status_get_max_hp(bl);
p.HP = status_get_hp(bl);
- p.isBoss = (md->spawn != NULL && md->spawn->state.boss) ? 1 : 0;
} else {
p.maxHP = -1;
p.HP = -1;
- p.isBoss = 0;
+ }
+ if (bl->type == BL_MOB) {
+ const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
+ p.isBoss = (md->spawn != NULL) ? md->spawn->state.boss : BTYPE_NONE;
+ } else {
+ p.isBoss = BTYPE_NONE;
}
#endif
#if PACKETVER >= 20150513
@@ -3332,17 +3345,22 @@ void clif_changelook(struct block_list *bl,int type,int val)
#if PACKETVER < 4
clif->sendlook(bl, bl->id, type, val, 0, target);
#else
- if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
- nullpo_retv(vd);
- type = LOOK_WEAPON;
- val = vd->weapon;
- val2 = vd->shield;
- }
- if (clif->isdisguised(bl)) {
- clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS);
- clif->sendlook(bl, -bl->id, type, val, val2, SELF);
+ if (bl->type != BL_NPC) {
+ if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
+ nullpo_retv(vd);
+ type = LOOK_WEAPON;
+ val = vd->weapon;
+ val2 = vd->shield;
+ }
+ if (clif->isdisguised(bl)) {
+ clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS);
+ clif->sendlook(bl, -bl->id, type, val, val2, SELF);
+ } else {
+ clif->sendlook(bl, bl->id, type, val, val2, target);
+ }
} else {
- clif->sendlook(bl, bl->id, type, val, val2, target);
+ struct npc_data *nd = BL_UCAST(BL_NPC, bl);
+ npc->refresh(nd);
}
#endif
}
diff --git a/src/map/map.c b/src/map/map.c
index ff5c2aafd..5a647625f 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1840,7 +1840,7 @@ void map_addiddb(struct block_list *bl)
struct mob_data *md = BL_UCAST(BL_MOB, bl);
idb_put(map->mobid_db,bl->id,bl);
- if( md->state.boss )
+ if (md->state.boss == BTYPE_MVP)
idb_put(map->bossid_db, bl->id, bl);
}
diff --git a/src/map/map.h b/src/map/map.h
index 3221c73cd..5835b5abc 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -519,7 +519,7 @@ struct spawn_data {
//0: Normal mob | 1: Standard summon, attacks mobs
//2: Alchemist Marine Sphere | 3: Alchemist Summon Flora | 4: Summon Zanzou
unsigned int dynamic : 1; ///< Whether this data is indexed by a map's dynamic mob list
- unsigned int boss : 1; ///< 0: Non-boss monster | 1: Boss monster
+ uint8 boss; ///< 0: Non-boss monster | 1: Boss monster | 2: MVP
} state;
char name[NAME_LENGTH], eventname[EVENT_NAME_LENGTH]; //Name/event
};
diff --git a/src/map/mob.c b/src/map/mob.c
index 822b84bf4..208617b5d 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2686,7 +2686,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
return 5; // Note: Actually, it's 4. Oh well...
// MvP tomb [GreenBox]
- if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && map->list[md->bl.m].flag.notomb != 1)
+ if (battle_config.mvp_tomb_enabled && md->spawn->state.boss == BTYPE_MVP && map->list[md->bl.m].flag.notomb != 1)
mob->mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL));
if( !rebirth ) {
diff --git a/src/map/mob.h b/src/map/mob.h
index 7f2accedf..83e022899 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -69,6 +69,12 @@ struct hplugin_data_store;
// Disable this to make monsters not do any path search when looking for a target (old behavior).
#define ACTIVEPATHSEARCH
+enum e_bosstype {
+ BTYPE_NONE = 0,
+ BTYPE_BOSS = 1,
+ BTYPE_MVP = 2,
+};
+
//Mob skill states.
enum MobSkillState {
MSS_ANY = -1,
@@ -181,10 +187,10 @@ struct mob_data {
unsigned int spotted: 1;
unsigned int npc_killmonster: 1; //for new killmonster behavior
unsigned int rebirth: 1; // NPC_Rebirth used
- unsigned int boss : 1;
enum MobSkillState skillstate;
unsigned char steal_flag; //number of steal tries (to prevent steal exploit on mobs with few items) [Lupus]
unsigned char attacked_count; //For rude attacked.
+ uint8 boss;
int provoke_flag; // Celest
} state;
struct guardian_data* guardian_data;
diff --git a/src/map/npc.c b/src/map/npc.c
index ecf7f878f..0702b2525 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -114,6 +114,8 @@ bool npc_db_checkid(int id)
return true;
if (id >= MAX_NPC_CLASS2_START && id < MAX_NPC_CLASS2_END) // Second range
return true;
+ if (pc->db_checkid(id))
+ return true;
// Anything else is invalid
return false;
}
@@ -2706,6 +2708,7 @@ struct npc_data *npc_create_npc(enum npc_subtype subtype, int m, int x, int y, u
nd->area_size = AREA_SIZE + 1;
nd->class_ = class_;
nd->speed = 200;
+ nd->vd.class = 0;
return nd;
}
@@ -3656,6 +3659,18 @@ void npc_setclass(struct npc_data* nd, short class_) {
clif->spawn(&nd->bl);// fade in
}
+void npc_refresh(struct npc_data* nd)
+{
+ nullpo_retv(nd);
+
+ if (map->list[nd->bl.m].users) {
+ // using here CLR_TRICKDEAD because other flags show effects.
+ // probably need use other flag or other way to refresh npc.
+ clif->clearunit_area(&nd->bl, CLR_TRICKDEAD); // fade out
+ clif->spawn(&nd->bl); // fade in
+ }
+}
+
// @commands (script based)
int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const char* message, const char* eventname)
{
@@ -3843,7 +3858,12 @@ const char *npc_parse_mob(const char *w1, const char *w2, const char *w3, const
memset(&mobspawn, 0, sizeof(struct spawn_data));
- mobspawn.state.boss = (strcmp(w2,"boss_monster") == 0 ? 1 : 0);
+ if (strcmp(w2, "boss_monster") == 0)
+ mobspawn.state.boss = BTYPE_MVP;
+ else if (strcmp(w2, "miniboss_monster") == 0)
+ mobspawn.state.boss = BTYPE_BOSS;
+ else
+ mobspawn.state.boss = BTYPE_NONE;
// w1=<map name>,<x>,<y>,<xs>,<ys>
// w3=<mob name>{,<mob level>}
@@ -4662,7 +4682,7 @@ int npc_parsesrcfile(const char* filepath, bool runOnInit) {
{
p = npc->parse_duplicate(w1,w2,w3,w4, p, buffer, filepath, (runOnInit?NPO_ONINIT:NPO_NONE), &success);
}
- else if( (strcmp(w2,"monster") == 0 || strcmp(w2,"boss_monster") == 0) )
+ else if (strcmp(w2,"monster") == 0 || strcmp(w2,"boss_monster") == 0 || strcmp(w2,"miniboss_monster") == 0)
{
p = npc->parse_mob(w1, w2, w3, w4, p, buffer, filepath, &success);
}
@@ -4994,7 +5014,6 @@ int do_init_npc(bool minimal) {
npc_viewdb[i].class = i;
for( i = MAX_NPC_CLASS2_START; i < MAX_NPC_CLASS2_END; i++ )
npc_viewdb2[i - MAX_NPC_CLASS2_START].class = i;
-
npc->ev_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, EVENT_NAME_LENGTH);
npc->ev_label_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, NAME_LENGTH);
npc->name_db = strdb_alloc(DB_OPT_BASE, NAME_LENGTH);
@@ -5189,4 +5208,5 @@ void npc_defaults(void) {
npc->market_delfromsql = npc_market_delfromsql;
npc->market_delfromsql_sub = npc_market_delfromsql_sub;
npc->db_checkid = npc_db_checkid;
+ npc->refresh = npc_refresh;
}
diff --git a/src/map/npc.h b/src/map/npc.h
index 3bd11d536..8bb38f252 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -70,7 +70,7 @@ struct npc_parse;
struct npc_data {
struct block_list bl;
struct unit_data *ud;
- struct view_data *vd;
+ struct view_data vd;
unsigned int option;
struct npc_data *master_nd;
short class_;
@@ -309,6 +309,7 @@ struct npc_interface {
void (*market_delfromsql) (struct npc_data *nd, unsigned short index);
void (*market_delfromsql_sub) (const char *npcname, unsigned short index);
bool (*db_checkid) (const int id);
+ void (*refresh) (struct npc_data* nd);
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
diff --git a/src/map/packets.h b/src/map/packets.h
index e9d895440..3fcf1648a 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -10669,4 +10669,78 @@ packet(0x96e,-1,clif->ackmergeitems);
packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME
#endif
+// 2017-10-25eRagexeRE
+#if PACKETVER == 20171025
+// shuffle packets
+ packet(0x0202,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION
+ packet(0x022d,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER
+ packet(0x023b,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS
+ packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES
+ packet(0x035f,6,clif->pTickSend,2); // CZ_REQUEST_TIME
+ packet(0x0360,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE
+ packet(0x0361,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER
+ packet(0x0362,6,clif->pDropItem,2,4); // CZ_ITEM_THROW
+ packet(0x0363,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD
+ packet(0x0364,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY
+ packet(0x0365,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER
+ packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX
+ packet(0x0368,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID
+ packet(0x0369,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT
+ packet(0x0436,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK
+ packet(0x0437,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE
+ packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND
+ packet(0x07e4,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP
+ packet(0x07ec,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE
+ packet(0x0802,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ
+ packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE
+ packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE
+ packet(0x0817,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE
+ packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO
+ packet(0x0835,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE
+ packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK
+ packet(0x083c,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL
+ packet(0x08a2,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD
+ packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME
+#endif
+
+// 2017-11-01bRagexeRE
+#if PACKETVER == 20171101
+// shuffle packets
+ packet(0x022d,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD
+ packet(0x0368,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER
+ packet(0x0369,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO
+ packet(0x0438,6,clif->pTickSend,2); // CZ_REQUEST_TIME
+ packet(0x0835,6,clif->pDropItem,2,4); // CZ_ITEM_THROW
+ packet(0x085b,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER
+ packet(0x0860,6,clif->pGetCharNameRequest,2); // CZ_REQNAME
+ packet(0x086c,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL
+ packet(0x0872,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS
+ packet(0x0876,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION
+ packet(0x0886,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD
+ packet(0x088e,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE
+ packet(0x0890,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE
+ packet(0x0895,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK
+ packet(0x0899,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ
+ packet(0x089b,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE
+ packet(0x089c,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER
+ packet(0x08a0,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY
+ packet(0x08ab,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES
+ packet(0x08ad,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK
+ packet(0x091b,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE
+ packet(0x0939,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE
+ packet(0x094a,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE
+ packet(0x094d,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID
+ packet(0x0952,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX
+ packet(0x0957,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT
+ packet(0x095a,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE
+ packet(0x0962,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP
+ packet(0x0966,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND
+#endif
+
+// 2017-11-01bRagexeRE
+#if PACKETVER >= 20171101
+// new packets
+ packet(0x0ae1,28);
+#endif
+
#endif /* MAP_PACKETS_H */
diff --git a/src/map/packets_keys.h b/src/map/packets_keys.h
index 85796813a..005c3790b 100644
--- a/src/map/packets_keys.h
+++ b/src/map/packets_keys.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2013-2015 Hercules Dev Team
+ * Copyright (C) 2013-2017 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -2057,7 +2057,7 @@
packetKeys(0x03FA5A97,0x20B802D5,0x339F1977);
#endif
-// 2017-06-07bRagexeRE
+// 2017-06-07bRagexeRE, 2017-06-07cRagexeRE
#if PACKETVER == 20170607
packetKeys(0x50564ACD,0x79CA4E15,0x405F4894);
#endif
@@ -2152,6 +2152,16 @@
packetKeys(0x2CAA109C,0x158C1EC2,0x7A5E58F3);
#endif
+// 2017-10-25bRagexeRE, 2017-10-25cRagexeRE, 2017-10-25dRagexeRE, 2017-10-25eRagexeRE
+#if PACKETVER == 20171025
+ packetKeys(0x165C565C,0x565C565C,0x565C565C);
+#endif
+
+// 2017-11-01bRagexeRE
+#if PACKETVER == 20171101
+ packetKeys(0x7056317F,0x7EEE0589,0x02672373);
+#endif
+
#if defined(OBFUSCATIONKEY1) && defined(OBFUSCATIONKEY2) && defined(OBFUSCATIONKEY3)
packetKeys(OBFUSCATIONKEY1,OBFUSCATIONKEY2,OBFUSCATIONKEY3);
diff --git a/src/map/script.c b/src/map/script.c
index d2101d21f..5773457a7 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -14270,31 +14270,36 @@ BUILDIN(setequipoption)
if (equip_index > 0 && equip_index <= ARRAYLENGTH(script->equip)) {
if ((i = pc->checkequip(sd, script->equip[equip_index - 1])) == -1) {
- ShowError("buildin_setequipoptioninfo: No equipment is equipped in the given index %d.\n", equip_index);
+ ShowError("buildin_setequipoption: No equipment is equipped in the given index %d.\n", equip_index);
script_pushint(st, 0);
return false;
}
} else {
- ShowError("buildin_setequipoptioninfo: Invalid equipment index %d provided.\n", equip_index);
+ ShowError("buildin_setequipoption: Invalid equipment index %d provided.\n", equip_index);
script_pushint(st, 0);
return false;
}
if (sd->status.inventory[i].nameid != 0) {
-
- if ((ito = itemdb->option_exists(opt_index)) == NULL) {
- script_pushint(st, 0);
- ShowError("buildin_setequipotion: Option index %d does not exist!\n", opt_index);
- return false;
- } else if (value < -INT16_MAX || value > INT16_MAX) {
- script_pushint(st, 0);
- ShowError("buildin_setequipotion: Option value %d exceeds maximum limit (%d to %d) for type!\n", value, -INT16_MAX, INT16_MAX);
- return false;
+ if (opt_index == 0) {
+ // Remove the option
+ sd->status.inventory[i].option[slot-1].index = 0;
+ sd->status.inventory[i].option[slot-1].value = 0;
+ } else {
+ if ((ito = itemdb->option_exists(opt_index)) == NULL) {
+ script_pushint(st, 0);
+ ShowError("buildin_setequipotion: Option index %d does not exist!\n", opt_index);
+ return false;
+ } else if (value < -INT16_MAX || value > INT16_MAX) {
+ script_pushint(st, 0);
+ ShowError("buildin_setequipotion: Option value %d exceeds maximum limit (%d to %d) for type!\n", value, -INT16_MAX, INT16_MAX);
+ return false;
+ }
+ /* Add Option Index */
+ sd->status.inventory[i].option[slot-1].index = ito->index;
+ /* Add Option Value */
+ sd->status.inventory[i].option[slot-1].value = value;
}
- /* Add Option Index */
- sd->status.inventory[i].option[slot-1].index = ito->index;
- /* Add Option Value */
- sd->status.inventory[i].option[slot-1].value = value;
/* Unequip and simulate deletion of the item. */
pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE); // status calc will happen in pc->equipitem() below
@@ -15866,11 +15871,12 @@ enum logmes_type {
/*==========================================
* Allows player to write logs (i.e. Bank NPC, etc) [Lupus]
*------------------------------------------*/
-BUILDIN(logmes) {
+BUILDIN(logmes)
+{
const char *str = script_getstr(st, 2);
struct map_session_data *sd = script->rid2sd(st);
enum logmes_type type = LOGMES_NPC;
- nullpo_retr(sd, false);
+ nullpo_retr(false, sd);
if (script_hasdata(st, 3)) {
type = script_getnum(st, 3);
@@ -18211,6 +18217,8 @@ BUILDIN(setunitdata)
case UDT_INTIMACY:
case UDT_LIFETIME:
case UDT_MERC_KILLCOUNT:
+ case UDT_ROBE:
+ case UDT_BODY2:
setunitdata_check_min(4, 0);
break;
case UDT_MASTERAID:
@@ -19149,6 +19157,40 @@ BUILDIN(setunitdata)
case UDT_DMOTION:
nd->status.dmotion = (unsigned short) val;
break;
+ case UDT_SEX:
+ nd->vd.sex = (char)val;
+ npc->refresh(nd);
+ break;
+ case UDT_HAIRSTYLE:
+ clif->changelook(bl, LOOK_HAIR, val);
+ break;
+ case UDT_HAIRCOLOR:
+ clif->changelook(bl, LOOK_HAIR_COLOR, val);
+ break;
+ case UDT_HEADBOTTOM:
+ clif->changelook(bl, LOOK_HEAD_BOTTOM, val);
+ break;
+ case UDT_HEADMIDDLE:
+ clif->changelook(bl, LOOK_HEAD_MID, val);
+ break;
+ case UDT_HEADTOP:
+ clif->changelook(bl, LOOK_HEAD_TOP, val);
+ break;
+ case UDT_CLOTHCOLOR:
+ clif->changelook(bl, LOOK_CLOTHES_COLOR, val);
+ break;
+ case UDT_SHIELD:
+ clif->changelook(bl, LOOK_SHIELD, val);
+ break;
+ case UDT_WEAPON:
+ clif->changelook(bl, LOOK_WEAPON, val);
+ break;
+ case UDT_ROBE:
+ clif->changelook(bl, LOOK_ROBE, val);
+ break;
+ case UDT_BODY2:
+ clif->changelook(bl, LOOK_BODY2, val);
+ break;
default:
ShowWarning("buildin_setunitdata: Invalid data type '%s' for NPC unit.\n", udtype);
script_pushint(st, 0);
@@ -19559,6 +19601,18 @@ BUILDIN(getunitdata)
case UDT_AMOTION: script_pushint(st, nd->status.amotion); break;
case UDT_ADELAY: script_pushint(st, nd->status.adelay); break;
case UDT_DMOTION: script_pushint(st, nd->status.dmotion); break;
+ case UDT_SEX: script_pushint(st, nd->vd.sex); break;
+ case UDT_CLASS: script_pushint(st, nd->vd.class); break;
+ case UDT_HAIRSTYLE: script_pushint(st, nd->vd.hair_style); break;
+ case UDT_HAIRCOLOR: script_pushint(st, nd->vd.hair_color); break;
+ case UDT_HEADBOTTOM: script_pushint(st, nd->vd.head_bottom); break;
+ case UDT_HEADMIDDLE: script_pushint(st, nd->vd.head_mid); break;
+ case UDT_HEADTOP: script_pushint(st, nd->vd.head_top); break;
+ case UDT_CLOTHCOLOR: script_pushint(st, nd->vd.cloth_color); break;
+ case UDT_SHIELD: script_pushint(st, nd->vd.shield); break;
+ case UDT_WEAPON: script_pushint(st, nd->vd.weapon); break;
+ case UDT_ROBE: script_pushint(st, nd->vd.robe); break;
+ case UDT_BODY2: script_pushint(st, nd->vd.body_style); break;
default:
ShowWarning("buildin_getunitdata: Invalid data type '%s' for NPC unit.\n", udtype);
script_pushint(st, 0);
@@ -20446,15 +20500,18 @@ BUILDIN(questinfo)
quest_id = script_getnum(st, 2);
icon = script_getnum(st, 3);
- #if PACKETVER >= 20120410
- if(icon < 0 || (icon > 8 && icon != 9999) || icon == 7)
- icon = 9999; // Default to nothing if icon id is invalid.
- #else
- if(icon < 0 || icon > 7)
- icon = 0;
- else
- icon = icon + 1;
- #endif
+#if PACKETVER >= 20170315
+ if (icon < 0 || (icon > 10 && icon != 9999))
+ icon = 9999;
+#elif PACKETVER >= 20120410
+ if (icon < 0 || (icon > 8 && icon != 9999) || icon == 7)
+ icon = 9999; // Default to nothing if icon id is invalid.
+#else
+ if (icon < 0 || icon > 7)
+ icon = 0;
+ else
+ icon = icon + 1;
+#endif
qi.quest_id = quest_id;
qi.icon = (unsigned char)icon;
@@ -20648,15 +20705,18 @@ BUILDIN(showevent)
}
}
- #if PACKETVER >= 20120410
- if(icon < 0 || (icon > 8 && icon != 9999) || icon == 7)
- icon = 9999; // Default to nothing if icon id is invalid.
- #else
- if(icon < 0 || icon > 7)
- icon = 0;
- else
- icon = icon + 1;
- #endif
+#if PACKETVER >= 20170315
+ if (icon < 0 || (icon > 10 && icon != 9999))
+ icon = 9999;
+#elif PACKETVER >= 20120410
+ if (icon < 0 || (icon > 8 && icon != 9999) || icon == 7)
+ icon = 9999; // Default to nothing if icon id is invalid.
+#else
+ if (icon < 0 || icon > 7)
+ icon = 0;
+ else
+ icon = icon + 1;
+#endif
clif->quest_show_event(sd, &nd->bl, icon, color);
return true;
@@ -23505,7 +23565,7 @@ BUILDIN(dressroom)
clif->dressroom_open(sd, 0);
break;
default:
- ShowWarning("script:dressroom: unknown mode (%i).\n", mode);
+ ShowWarning("script:dressroom: unknown mode (%u).\n", mode);
script_pushint(st, 0);
return false;
}
diff --git a/src/map/script.h b/src/map/script.h
index 283afa496..b2ab7510c 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -423,6 +423,8 @@ enum script_unit_data_types {
UDT_LIFETIME,
UDT_MERC_KILLCOUNT,
UDT_STATPOINT,
+ UDT_ROBE,
+ UDT_BODY2,
UDT_MAX
};
diff --git a/src/map/status.c b/src/map/status.c
index e0893aa36..ccd1e6b11 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -6809,7 +6809,7 @@ struct view_data *status_get_viewdata(struct block_list *bl)
case BL_PC: return &BL_UCAST(BL_PC, bl)->vd;
case BL_MOB: return BL_UCAST(BL_MOB, bl)->vd;
case BL_PET: return &BL_UCAST(BL_PET, bl)->vd;
- case BL_NPC: return BL_UCAST(BL_NPC, bl)->vd;
+ case BL_NPC: return &BL_UCAST(BL_NPC, bl)->vd;
case BL_HOM: return BL_UCAST(BL_HOM, bl)->vd;
case BL_MER: return BL_UCAST(BL_MER, bl)->vd;
case BL_ELEM: return BL_UCAST(BL_ELEM, bl)->vd;
@@ -6927,10 +6927,14 @@ void status_set_viewdata(struct block_list *bl, int class_)
case BL_NPC:
{
struct npc_data *nd = BL_UCAST(BL_NPC, bl);
- if (vd != NULL)
- nd->vd = vd;
- else
+ if (vd != NULL) {
+ memcpy(&nd->vd, vd, sizeof(struct view_data));
+ } else if (pc->db_checkid(class_)) {
+ memset(&nd->vd, 0, sizeof(struct view_data));
+ nd->vd.class = class_;
+ } else {
ShowError("status_set_viewdata (NPC): No view data for class %d (name=%s)\n", class_, nd->name);
+ }
}
break;
case BL_HOM: //[blackhole89]