From 78a007d2371dc0a46f5e66b776fdf57f04658447 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 21 Aug 2017 22:46:05 +0200 Subject: Add support for bitmask arrays in the item_db Loc field Signed-off-by: Haru --- db/item_db2.conf | 2 +- db/pre-re/item_db.conf | 2 +- db/re/item_db.conf | 2 +- doc/item_db.txt | 52 ++++++++++++++++++++++++++++---------------------- src/map/itemdb.c | 2 +- src/map/script.c | 9 +++++++++ 6 files changed, 42 insertions(+), 27 deletions(-) diff --git a/db/item_db2.conf b/db/item_db2.conf index 8abe34a38..b6c68d069 100644 --- a/db/item_db2.conf +++ b/db/item_db2.conf @@ -81,7 +81,7 @@ item_db: ( Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (int, defaults to both = 2) - Loc: Equip location (int, required value for equipment) + Loc: Equip location (bitmask array, string or int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) diff --git a/db/pre-re/item_db.conf b/db/pre-re/item_db.conf index bea31f2a3..8b7fdf806 100644 --- a/db/pre-re/item_db.conf +++ b/db/pre-re/item_db.conf @@ -81,7 +81,7 @@ item_db: ( Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") - Loc: Equip location (int, required value for equipment) + Loc: Equip location (bitmask array, string or int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) diff --git a/db/re/item_db.conf b/db/re/item_db.conf index 26baa0868..e9c195c92 100644 --- a/db/re/item_db.conf +++ b/db/re/item_db.conf @@ -81,7 +81,7 @@ item_db: ( Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") - Loc: Equip location (int, required value for equipment) + Loc: Equip location (bitmask array, string or int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) diff --git a/doc/item_db.txt b/doc/item_db.txt index d9ec96fc1..913ab80e0 100644 --- a/doc/item_db.txt +++ b/doc/item_db.txt @@ -60,7 +60,7 @@ item_db: ( Job: Job mask (alternate synxtax, int, defaults to all jobs = 0xFFFFFFFF) Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") - Loc: Equip location (int, required value for equipment) + Loc: Equip location (bitmask array, string or int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) @@ -208,28 +208,34 @@ Gender: Gender restriction. When not specified, becomes "SEX_ANY". Loc: Equipment's placement. A value needs to be specified if the item is an - equipment piece. Values are: - - 2^0 001 = Lower Headgear - 2^1 002 = Weapon - 2^2 004 = Garment - 2^3 008 = Accessory 1 - 2^4 016 = Armor - 2^5 032 = Shield - 2^6 064 = Footgear - 2^7 128 = Accessory 2 - 2^8 256 = Upper Headgear - 2^9 512 = Middle Headgear - 2^10 1024 = Costume Top Headgear - 2^11 2048 = Costume Mid Headgear - 2^12 4096 = Costume Low Headgear - 2^13 8192 = Costume Garment/Robe - 2^16 65536 = Shadow Armor - 2^17 131072 = Shadow Weapon - 2^18 262144 = Shadow Shield - 2^18 524288 = Shadow Shoes - 2^20 1048576 = Shadow Accessory 2 - 2^21 2097152 = Shadow Accessory 1 + equipment piece. Values are (bitmask arrays are supported): + + Lower Headgear: EQP_HEAD_LOW (2^00 = 0x000001) + Weapon: EQP_HAND_R or EQP_WEAPON (2^01 = 0x000002) + Garment: EQP_GARMENT (2^02 = 0x000004) + Accessory 1: EQP_ACC_L (2^03 = 0x000008) + Armor: EQP_ARMOR (2^04 = 0x000010) + Shield: EQP_HAND_L or EQP_SHIELD (2^05 = 0x000020) + (Both Hands): EQP_ARMS (EQP_HAND_L | EQP_HAND_R = 0x000022) + Footgear: EQP_SHOES (2^06 = 0x000040) + Accessory 2: EQP_ACC_R (2^07 = 0x000080) + (Both Accessories): EQP_ACC (EQP_ACC_R | EQP_ACC_L = 0x000088) + Upper Headgear: EQP_HEAD_TOP (2^08 = 0x000100) + Middle Headgear: EQP_HEAD_MID (2^09 = 0x000200) + (T+M+B Headgear): EQP_HELM (EQP_HEAD_LOW | EQP_HEAD_MID | EQP_HEAD_TOP = 0x000301) + Costume Top Headgear: EQP_COSTUME_HEAD_TOP (2^10 = 0x000400) + Costume Mid Headgear: EQP_COSTUME_HEAD_MID (2^11 = 0x000800) + Costume Low Headgear: EQP_COSTUME_HEAD_LOW (2^12 = 0x001000) + Costume Garment/Robe: EQP_COSTUME_GARMENT (2^13 = 0x002000) + Ammunition: EQP_AMMO (2^15 = 0x008000) + Shadow Armor: EQP_SHADOW_ARMOR (2^16 = 0x010000) + Shadow Weapon: EQP_SHADOW_WEAPON (2^17 = 0x020000) + Shadow Shield: EQP_SHADOW_SHIELD (2^18 = 0x040000) + (Shadow 2H Weapon): EQP_SHADOW_ARMS (EQP_SHADOW_WEAPON | EQP_SHADOW_SHIELD = 0x060000) + Shadow Shoes: EQP_SHADOW_SHOES (2^19 = 0x080000) + Shadow Accessory 2: EQP_SHADOW_ACC_R (2^20 = 0x100000) + Shadow Accessory 1: EQP_SHADOW_ACC_L (2^21 = 0x200000) + (Shadow Accessories): EQP_SHADOW_ACC (EQP_SHADOW_ACC_R | EQP_SHADOW_ACC_L = 0x300000) WeaponLv: Weapon level. Becomes 0 when not specified. diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 0ace20984..96eced725 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2047,7 +2047,7 @@ int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char * else if( !inherit ) id.sex = 2; - if( itemdb->lookup_const(it, "Loc", &i32) && i32 >= 0 ) + if (itemdb->lookup_const_mask(it, "Loc", &i32) && i32 >= 0) id.equip = i32; if( itemdb->lookup_const(it, "WeaponLv", &i32) && i32 >= 0 ) diff --git a/src/map/script.c b/src/map/script.c index f29ce4104..7dcebd6f6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24459,6 +24459,15 @@ void script_hardcoded_constants(void) script->set_constant("EQP_SHADOW_SHOES", EQP_SHADOW_SHOES, false, false); script->set_constant("EQP_SHADOW_ACC_R", EQP_SHADOW_ACC_R, false, false); script->set_constant("EQP_SHADOW_ACC_L", EQP_SHADOW_ACC_L, false, false); + // Synonyms and combined values + script->set_constant("EQP_WEAPON", EQP_WEAPON, false, false); + script->set_constant("EQP_SHIELD", EQP_SHIELD, false, false); + script->set_constant("EQP_ARMS", EQP_ARMS, false, false); + script->set_constant("EQP_HELM", EQP_HELM, false, false); + script->set_constant("EQP_ACC", EQP_ACC, false, false); + script->set_constant("EQP_COSTUME", EQP_COSTUME, false, false); + script->set_constant("EQP_SHADOW_ACC", EQP_SHADOW_ACC, false, false); + script->set_constant("EQP_SHADOW_ARMS", EQP_SHADOW_ARMS, false, false); script->constdb_comment("Item Option Types"); script->set_constant("IT_OPT_INDEX", IT_OPT_INDEX, false, false); -- cgit v1.2.3-70-g09d2