From a271110b6c53cf268747ab74d1471452909c5272 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sun, 10 May 2020 03:02:56 +0200 Subject: Extend item_enabled_npc battle flag with option for usable items --- conf/map/battle/items.conf | 12 ++++++++---- src/map/battle.c | 2 +- src/map/clif.c | 4 ++-- src/map/pc.c | 3 ++- src/map/pc.h | 7 +++++++ src/map/script.c | 5 +++++ 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/conf/map/battle/items.conf b/conf/map/battle/items.conf index 4788d7b30..ef383e19b 100644 --- a/conf/map/battle/items.conf +++ b/conf/map/battle/items.conf @@ -100,10 +100,14 @@ autospell_stacking: false // Default: true (official) item_restricted_consumption_type: true -// Enable all NPC to allow changing of equipments while interacting? (Note 1) -// Script commands 'enable_items/disable_items' will not be override. (see doc/script_commands.txt) -// Default: true (official) -item_enabled_npc: true +// Which item actions are allowed while interacting with NPC? (Note 3) +// Script commands 'enable_items/disable_items' will not be overridden. (See doc/script_commands.txt.) +// 0x0 (ITEMENABLEDNPC_NONE) - Don't allow any item actions. +// 0x1 (ITEMENABLEDNPC_EQUIP) - Allow changing equipment. +// 0x2 (ITEMENABLEDNPC_CONSUME) - Allow consuming usable items. +// Official RE: 0x1 (Default value.) +// Official Pre-RE: 0x3 +item_enabled_npc: 0x1 // Unequip the equipments that has disabled by map_zone_db.conf ? // 0 : disabled equipments and cards are nullify (official) 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); -- cgit v1.2.3-70-g09d2