summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-05-10 03:02:56 +0200
committerKenpachi Developer <Kenpachi.Developer@gmx.de>2020-05-13 04:53:29 +0200
commita271110b6c53cf268747ab74d1471452909c5272 (patch)
treed1023faba69fcb2506989427257ed64a1b7ed87e /src
parent944d8489f1bcca93e6b2ff06a159084f064dce12 (diff)
downloadhercules-a271110b6c53cf268747ab74d1471452909c5272.tar.gz
hercules-a271110b6c53cf268747ab74d1471452909c5272.tar.bz2
hercules-a271110b6c53cf268747ab74d1471452909c5272.tar.xz
hercules-a271110b6c53cf268747ab74d1471452909c5272.zip
Extend item_enabled_npc battle flag with option for usable items
Diffstat (limited to 'src')
-rw-r--r--src/map/battle.c2
-rw-r--r--src/map/clif.c4
-rw-r--r--src/map/pc.c3
-rw-r--r--src/map/pc.h7
-rw-r--r--src/map/script.c5
5 files changed, 17 insertions, 4 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index c8cd71b94..cf51f4fc5 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -7378,7 +7378,7 @@ static const struct battle_data {
{ "item_restricted_consumption_type", &battle_config.item_restricted_consumption_type,1, 0, 1, },
{ "unequip_restricted_equipment", &battle_config.unequip_restricted_equipment, 0, 0, 3, },
{ "max_walk_path", &battle_config.max_walk_path, 17, 1, MAX_WALKPATH, },
- { "item_enabled_npc", &battle_config.item_enabled_npc, 1, 0, 1, },
+ { "item_enabled_npc", &battle_config.item_enabled_npc, 1, 0, INT_MAX, },
{ "gm_ignore_warpable_area", &battle_config.gm_ignore_warpable_area, 0, 2, 100, },
{ "packet_obfuscation", &battle_config.packet_obfuscation, 1, 0, 3, },
{ "client_accept_chatdori", &battle_config.client_accept_chatdori, 0, 0, INT_MAX, },
diff --git a/src/map/clif.c b/src/map/clif.c
index 7be5c6978..5a090301d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -12038,7 +12038,7 @@ static void clif_parse_EquipItem(int fd, struct map_session_data *sd)
return; //Out of bounds check.
if( sd->npc_id ) {
- if ( !sd->npc_item_flag )
+ if ((sd->npc_item_flag & ITEMENABLEDNPC_EQUIP) == 0)
return;
} else if (sd->state.storage_flag != STORAGE_FLAG_CLOSED || sd->sc.opt1)
; //You can equip/unequip stuff while storage is open/under status changes
@@ -12083,7 +12083,7 @@ static void clif_parse_UnequipItem(int fd, struct map_session_data *sd)
}
if( sd->npc_id ) {
- if ( !sd->npc_item_flag )
+ if ((sd->npc_item_flag & ITEMENABLEDNPC_EQUIP) == 0)
return;
} else if (sd->state.storage_flag != STORAGE_FLAG_CLOSED || sd->sc.opt1)
; //You can equip/unequip stuff while storage is open/under status changes
diff --git a/src/map/pc.c b/src/map/pc.c
index 5faadf76a..c6f8ef4f9 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -5162,7 +5162,8 @@ static int pc_useitem(struct map_session_data *sd, int n)
nullpo_ret(sd);
Assert_ret(n >= 0 && n < sd->status.inventorySize);
- if (sd->npc_id || sd->state.workinprogress & 1) {
+ if ((sd->npc_id != 0 && (sd->npc_item_flag & ITEMENABLEDNPC_CONSUME) == 0)
+ || (sd->state.workinprogress & 1) != 0) {
#if PACKETVER >= 20110308
clif->msgtable(sd, MSG_BUSY);
#else
diff --git a/src/map/pc.h b/src/map/pc.h
index e560df549..01fd855b7 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -103,6 +103,13 @@ enum pc_checkitem_types {
PCCHECKITEM_GSTORAGE = 0x8
};
+/** Bit flags for allowed item actions while interacting with NPC. **/
+enum item_enabled_npc_flags {
+ ITEMENABLEDNPC_NONE = 0x0, //!< Don't allow any item actions while interacting with NPC.
+ ITEMENABLEDNPC_EQUIP = 0x1, //!< Allow changing equipment while interacting with NPC.
+ ITEMENABLEDNPC_CONSUME = 0x2, //!< Allow consuming usable items while interacting with NPC.
+};
+
struct weapon_data {
int atkmods[3];
BEGIN_ZEROED_BLOCK; // all the variables within this block get zero'ed in each call of status_calc_pc
diff --git a/src/map/script.c b/src/map/script.c
index 45c954dc0..46b7ef8f5 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -27864,6 +27864,11 @@ static void script_hardcoded_constants(void)
script->set_constant("PCBLOCK_COMMANDS", PCBLOCK_COMMANDS, false, false);
script->set_constant("PCBLOCK_NPC", PCBLOCK_NPC, false, false);
+ script->constdb_comment("NPC item action constants");
+ script->set_constant("ITEMENABLEDNPC_NONE", ITEMENABLEDNPC_NONE, false, false);
+ script->set_constant("ITEMENABLEDNPC_EQUIP", ITEMENABLEDNPC_EQUIP, false, false);
+ script->set_constant("ITEMENABLEDNPC_CONSUME", ITEMENABLEDNPC_CONSUME, false, false);
+
script->constdb_comment("private airship responds");
script->set_constant("P_AIRSHIP_NONE", P_AIRSHIP_NONE, false, false);
script->set_constant("P_AIRSHIP_RETRY", P_AIRSHIP_RETRY, false, false);