Added item check for third classes (as partial merge from Hercules: 1caae98).

- 1:Normal, 2:Trans/Upper, 4:Baby, 8:Third, 16:Trans.Third, 32:Third Baby (see 'doc/item_db.txt' for detail)
- Changed almost all items class on 'db/re/item_db.txt'
- Updated 'sql-files/item_db_re.sql', also fixed SQL error (bugreport:7998)
Added 'item_unconditional' as group permission, default is 'false' (see 'doc/permissions.txt' for detail).
This commit is contained in:
Cahyadi Ramadhan Togihon 2013-08-21 11:33:34 +07:00
parent ff86b75d26
commit 5f123519f6
10 changed files with 11329 additions and 11144 deletions

View File

@ -275,6 +275,7 @@ groups: (
all_commands: true all_commands: true
channel_admin: true channel_admin: true
can_trade_bounded: true can_trade_bounded: true
item_unconditional: false
} }
} }
) )

View File

@ -1,7 +1,7 @@
// Items Additional Database // Items Additional Database
// //
// Structure of Database: // Structure of Database:
// ID,Name,Name,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Upper,Gender,Loc,wLV,eLV,Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script } // ID,Name,Name,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Class,Gender,Loc,wLV,eLV,Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script }
// //
// THQ Quest Items // THQ Quest Items
//============================================================= //=============================================================

View File

@ -1,7 +1,7 @@
// Items Database // Items Database
// //
// Structure of Database: // Structure of Database:
// ID,AegisName,Name,Type,Buy,Sell,Weight,ATK,DEF,Range,Slots,Job,Upper,Gender,Loc,wLV,eLV,Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script } // ID,AegisName,Name,Type,Buy,Sell,Weight,ATK,DEF,Range,Slots,Job,Class,Gender,Loc,wLV,eLV,Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script }
// //
// Healing Items // Healing Items
//============================================================= //=============================================================

File diff suppressed because it is too large Load Diff

View File

@ -3,18 +3,26 @@
//===== By: ================================================== //===== By: ==================================================
//= rAthena Dev Team //= rAthena Dev Team
//===== Current Version: ===================================== //===== Current Version: =====================================
//= 20120904 //= 20130819
//===== Description: ========================================= //===== Description: =========================================
//= Explanation of the item_db.txt file and structure. //= Explanation of the item_db.txt file and structure.
//============================================================ //============================================================
---------------------------------------
ID: Item id ID: Item id
---------------------------------------
AegisName: Server name to reference the item in scripts and lookups, AegisName: Server name to reference the item in scripts and lookups,
should use no spaces. should use no spaces.
---------------------------------------
Name: Name in English for displaying as output for @ and script commands. Name: Name in English for displaying as output for @ and script commands.
---------------------------------------
Type: Type:
0 Healing item. 0 Healing item.
2 Usable item. 2 Usable item.
@ -30,22 +38,37 @@ Type:
18 Another delayed consume that requires user confirmation before 18 Another delayed consume that requires user confirmation before
using item. using item.
---------------------------------------
Buy: Default buying price. When not specified, becomes double the sell price. Buy: Default buying price. When not specified, becomes double the sell price.
---------------------------------------
Sell: Default selling price. When not specified, becomes half the buy price. Sell: Default selling price. When not specified, becomes half the buy price.
---------------------------------------
Weight: Item's weight. Each 10 is 1 weight. Weight: Item's weight. Each 10 is 1 weight.
---------------------------------------
ATK: Weapon's attack ATK: Weapon's attack
---------------------------------------
DEF: Armor's defense DEF: Armor's defense
---------------------------------------
Range: Weapon's attack range Range: Weapon's attack range
---------------------------------------
Slots: Amount of slots the item possesses. Slots: Amount of slots the item possesses.
Job: Equippable jobs. Uses the following bitmask table: ---------------------------------------
Job: Equippable jobs. Uses the following bitmask table:
(S.) Novice (2^00): 0x00000001 (S.) Novice (2^00): 0x00000001
Swordman (2^01): 0x00000002 Swordman (2^01): 0x00000002
Magician (2^02): 0x00000004 Magician (2^02): 0x00000004
@ -77,15 +100,27 @@ Job: Equippable jobs. Uses the following bitmask table:
Dark Collector (2^28): 0x10000000 Dark Collector (2^28): 0x10000000
Kagerou/Oboro (2^29): 0x20000000 Kagerou/Oboro (2^29): 0x20000000
Upper: Equippable upper-types. Uses the following bitmasks: Novice + Swordman + Magician + Archer = 0x0000000F, why?
1: Normal jobs Because: 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, and 15 = F
2: Upper jobs It's using hexadecimal.
4: Baby jobs
8: Third jobs ---------------------------------------
Class: Equippable upper-types. Uses the following bitmasks:
1: Normal classes (no Baby/Transcendent/Third classes)
2: Transcedent classes (no Transcedent-Third classes)
4: Baby classes (no Third-Baby classes)
8: Third classes (no Transcedent-Third or Third-Baby classes)
16: Transcedent-Third classes
32: Third-Baby classes
---------------------------------------
Gender: Gender restriction. 0 is female, 1 is male, 2 for both. Gender: Gender restriction. 0 is female, 1 is male, 2 for both.
Loc: Equipment's placement. Values are: ---------------------------------------
Loc: Equipment's placement. Values are (hexadecimal):
2^8 256 = Upper Headgear 2^8 256 = Upper Headgear
2^9 512 = Middle Headgear 2^9 512 = Middle Headgear
2^0 001 = Lower Headgear 2^0 001 = Lower Headgear
@ -101,12 +136,20 @@ Loc: Equipment's placement. Values are:
2^12 4096 = Costume Low Headgear 2^12 4096 = Costume Low Headgear
2^13 8192 = Costume Garment/Robe 2^13 8192 = Costume Garment/Robe
---------------------------------------
wLV: Weapon level. wLV: Weapon level.
---------------------------------------
eLV: Base level required to be able to equip. eLV: Base level required to be able to equip.
---------------------------------------
Refineable: 1 if the item can be refined, 0 otherwise. Refineable: 1 if the item can be refined, 0 otherwise.
---------------------------------------
View: For normal items, defines a replacement view-sprite for the item (eg: View: For normal items, defines a replacement view-sprite for the item (eg:
Making apples look like apple juice). The special case are weapons Making apples look like apple juice). The special case are weapons
and ammo where this value indicates the weapon-class of the item. and ammo where this value indicates the weapon-class of the item.
@ -147,10 +190,18 @@ View: For normal items, defines a replacement view-sprite for the item (eg:
8: Cannonballs 8: Cannonballs
9: Throwable Items (Sling Item) 9: Throwable Items (Sling Item)
---------------------------------------
Script: Script to execute when the item is used/equipped. Script: Script to execute when the item is used/equipped.
---------------------------------------
OnEquip_Script: Script to execute when the item is equipped. OnEquip_Script: Script to execute when the item is equipped.
Warning, not all item bonuses will work here as expected. Warning, not all item bonuses will work here as expected.
---------------------------------------
OnUnequip_Script: Script to execute when the item is unequipped. OnUnequip_Script: Script to execute when the item is unequipped.
Warning, not all item bonuses will work here as expected. Warning, not all item bonuses will work here as expected.
---------------------------------------

View File

@ -109,6 +109,14 @@ Prevents player from attacking other players.
Allows player to do normal item actions with bounded items (drop, sell, Allows player to do normal item actions with bounded items (drop, sell,
trade, etc.). trade, etc.).
---------------------------------------
*item_unconditional
Allows player to consume any consumable item regardless the requirements
(bypass noitemconsumption mapflag, item's class, gender, status changes,
item delay, etc).
--------------------------------------- ---------------------------------------
====================== ======================

File diff suppressed because it is too large Load Diff

View File

@ -73,6 +73,15 @@ enum {
NOUSE_SITTING = 0x01, NOUSE_SITTING = 0x01,
} item_nouse_list; } item_nouse_list;
enum e_item_job {
ITEMJ_NORMAL = 0x01,
ITEMJ_UPPER = 0x02,
ITEMJ_BABY = 0x04,
ITEMJ_THIRD = 0x08,
ITEMJ_THIRD_TRANS = 0x10,
ITEMJ_THIRD_BABY = 0x20,
};
//The only item group required by the code to be known. See const.txt for the full list. //The only item group required by the code to be known. See const.txt for the full list.
#define IG_FINDINGORE 6 #define IG_FINDINGORE 6
#define IG_POTION 37 #define IG_POTION 37
@ -118,7 +127,7 @@ struct item_data {
//Lupus: I rearranged order of these fields due to compatibility with ITEMINFO script command //Lupus: I rearranged order of these fields due to compatibility with ITEMINFO script command
// some script commands should be revised as well... // some script commands should be revised as well...
unsigned int class_base[3]; //Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2) unsigned int class_base[3]; //Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2)
unsigned class_upper : 4; //Specifies if the upper-type can equip it (bitfield, 1: normal, 2: upper, 3: baby,4:third) unsigned class_upper : 6; //Specifies if the class-type can equip it (0x01: normal, 0x02: trans, 0x04: baby, 0x08:third, 0x10:trans-third, 0x20-third-baby)
struct { struct {
unsigned short chance; unsigned short chance;
int id; int id;

View File

@ -842,6 +842,53 @@ bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd,
return false; // Job Change Fail return false; // Job Change Fail
} }
/*==========================================
* Check if player can use/equip selected item. Used by pc_isUseitem and pc_isequip
Returns:
false : Cannot use/equip
true : Can use/equip
* Credits:
[Inkfish] for first idea
[Haru] for third-classes extension
[Cydh] finishing :D
*------------------------------------------*/
bool pc_isItemClass (struct map_session_data *sd, struct item_data* item) {
while (1) {
if (item->class_upper&ITEMJ_NORMAL && !(sd->class_&(JOBL_UPPER|JOBL_THIRD|JOBL_BABY))) //normal classes (no upper, no baby, no third)
break;
#ifndef RENEWAL
//allow third classes to use trans. class items
if (item->class_upper&ITEMJ_UPPER && sd->class_&(JOBL_UPPER|JOBL_THIRD)) //trans. classes
break;
//third-baby classes can use same item too
if (item->class_upper&ITEMJ_BABY && sd->class_&JOBL_BABY) //baby classes
break;
//don't need to decide specific rules for third-classes?
//items for third classes can be used for all third classes
if (item->class_upper&(ITEMJ_THIRD|ITEMJ_THIRD_TRANS|ITEMJ_THIRD_BABY) && sd->class_&JOBL_THIRD)
break;
#else
//trans. classes (exl. third-trans.)
if (item->class_upper&ITEMJ_UPPER && sd->class_&JOBL_UPPER && !(sd->class_&JOBL_THIRD))
break;
//baby classes (exl. third-baby)
if (item->class_upper&ITEMJ_BABY && sd->class_&JOBL_BABY && !(sd->class_&JOBL_THIRD))
break;
//third classes (exl. third-trans. and baby-third)
if (item->class_upper&ITEMJ_THIRD && sd->class_&JOBL_THIRD && !(sd->class_&(JOBL_UPPER|JOBL_BABY)))
break;
//trans-third classes
if (item->class_upper&ITEMJ_THIRD_TRANS && sd->class_&JOBL_THIRD && sd->class_&JOBL_UPPER)
break;
//third-baby classes
if (item->class_upper&ITEMJ_THIRD_BABY && sd->class_&JOBL_THIRD && sd->class_&JOBL_BABY)
break;
#endif
return false;
}
return true;
}
/*================================================= /*=================================================
* Checks if the player can equip the item at index n in inventory. * Checks if the player can equip the item at index n in inventory.
@ -903,14 +950,9 @@ int pc_isequip(struct map_session_data *sd,int n)
//Not equipable by class. [Skotlex] //Not equipable by class. [Skotlex]
if (!(1<<(sd->class_&MAPID_BASEMASK)&item->class_base[(sd->class_&JOBL_2_1)?1:((sd->class_&JOBL_2_2)?2:0)])) if (!(1<<(sd->class_&MAPID_BASEMASK)&item->class_base[(sd->class_&JOBL_2_1)?1:((sd->class_&JOBL_2_2)?2:0)]))
return 0; return 0;
//Not usable by upper class. [Inkfish]
while( 1 ) { if (!pc_isItemClass(sd,item))
if( item->class_upper&1 && !(sd->class_&(JOBL_UPPER|JOBL_THIRD|JOBL_BABY)) ) break;
if( item->class_upper&2 && sd->class_&(JOBL_UPPER|JOBL_THIRD) ) break;
if( item->class_upper&4 && sd->class_&JOBL_BABY ) break;
if( item->class_upper&8 && sd->class_&JOBL_THIRD ) break;
return 0; return 0;
}
return 1; return 1;
} }
@ -4139,10 +4181,17 @@ int pc_isUseitem(struct map_session_data *sd,int n)
//Not consumable item //Not consumable item
if( item->type != IT_HEALING && item->type != IT_USABLE && item->type != IT_CASH ) if( item->type != IT_HEALING && item->type != IT_USABLE && item->type != IT_CASH )
return 0; return 0;
else if(map[sd->bl.m].flag.noitemconsumption) //consumable but mapflag prevent it
return 0;
if( !item->script ) //if it has no script, you can't really consume it! if( !item->script ) //if it has no script, you can't really consume it!
return 0; return 0;
if (pc_has_permission(sd,PC_PERM_ITEM_UNCONDITIONAL))
return 1;
if(map[sd->bl.m].flag.noitemconsumption) //consumable but mapflag prevent it
return 0;
//Prevent mass item usage. [Skotlex]
if( DIFF_TICK(sd->canuseitem_tick,gettick()) > 0 ||
(itemdb_iscashfood(nameid) && DIFF_TICK(sd->canusecashfood_tick,gettick()) > 0)
)
return 0;
if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) { if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) {
return 0; // You cannot use this item while sitting. return 0; // You cannot use this item while sitting.
@ -4263,14 +4312,21 @@ int pc_isUseitem(struct map_session_data *sd,int n)
(item->class_base[sd->class_&JOBL_2_1?1:(sd->class_&JOBL_2_2?2:0)]) (item->class_base[sd->class_&JOBL_2_1?1:(sd->class_&JOBL_2_2?2:0)])
)) ))
return 0; return 0;
//Not usable by upper class. [Inkfish]
while( 1 ) { if (sd->sc.count && (
if( item->class_upper&1 && !(sd->class_&(JOBL_UPPER|JOBL_THIRD|JOBL_BABY)) ) break; sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAYNIGHTFEVER] ||
if( item->class_upper&2 && sd->class_&(JOBL_UPPER|JOBL_THIRD) ) break; (sd->sc.data[SC_GRAVITATION] && sd->sc.data[SC_GRAVITATION]->val3 == BCT_SELF) ||
if( item->class_upper&4 && sd->class_&JOBL_BABY ) break; sd->sc.data[SC_TRICKDEAD] ||
if( item->class_upper&8 && sd->class_&JOBL_THIRD ) break; sd->sc.data[SC_HIDING] ||
sd->sc.data[SC__SHADOWFORM] ||
sd->sc.data[SC__MANHOLE] ||
sd->sc.data[SC_KAGEHUMI] ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOITEM)
))
return 0;
if (!pc_isItemClass(sd,item))
return 0; return 0;
}
//Dead Branch & Bloody Branch & Porings Box //Dead Branch & Bloody Branch & Porings Box
// FIXME: outdated, use constants or database // FIXME: outdated, use constants or database
@ -4320,24 +4376,6 @@ int pc_useitem(struct map_session_data *sd,int n)
if (nameid != ITEMID_NAUTHIZ && sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT && sd->sc.opt1 != OPT1_BURNING) if (nameid != ITEMID_NAUTHIZ && sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT && sd->sc.opt1 != OPT1_BURNING)
return 0; return 0;
if (sd->sc.count && (
sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAYNIGHTFEVER] ||
(sd->sc.data[SC_GRAVITATION] && sd->sc.data[SC_GRAVITATION]->val3 == BCT_SELF) ||
sd->sc.data[SC_TRICKDEAD] ||
sd->sc.data[SC_HIDING] ||
sd->sc.data[SC__SHADOWFORM] ||
sd->sc.data[SC__MANHOLE] ||
sd->sc.data[SC_KAGEHUMI] ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOITEM)
))
return 0;
//Prevent mass item usage. [Skotlex]
if( DIFF_TICK(sd->canuseitem_tick, tick) > 0 ||
(itemdb_iscashfood(nameid) && DIFF_TICK(sd->canusecashfood_tick, tick) > 0)
)
return 0;
/* Items with delayed consume are not meant to work while in mounts except reins of mount(12622) */ /* Items with delayed consume are not meant to work while in mounts except reins of mount(12622) */
if( id->flag.delay_consume ) { if( id->flag.delay_consume ) {
if( nameid != ITEMID_REINS_OF_MOUNT && sd->sc.option&OPTION_MOUNTING ) if( nameid != ITEMID_REINS_OF_MOUNT && sd->sc.option&OPTION_MOUNTING )
@ -4352,7 +4390,7 @@ int pc_useitem(struct map_session_data *sd,int n)
if( id->flag.delay_consume && ( sd->ud.skilltimer != INVALID_TIMER /*|| !status_check_skilluse(&sd->bl, &sd->bl, ALL_RESURRECTION, 0)*/ ) ) if( id->flag.delay_consume && ( sd->ud.skilltimer != INVALID_TIMER /*|| !status_check_skilluse(&sd->bl, &sd->bl, ALL_RESURRECTION, 0)*/ ) )
return 0; return 0;
if( id->delay > 0 ) { if( id->delay > 0 && !pc_has_permission(sd,PC_PERM_ITEM_UNCONDITIONAL) ) {
int i; int i;
ARR_FIND(0, MAX_ITEMDELAYS, i, sd->item_delay[i].nameid == nameid ); ARR_FIND(0, MAX_ITEMDELAYS, i, sd->item_delay[i].nameid == nameid );
if( i == MAX_ITEMDELAYS ) /* item not found. try first empty now */ if( i == MAX_ITEMDELAYS ) /* item not found. try first empty now */
@ -4391,13 +4429,13 @@ int pc_useitem(struct map_session_data *sd,int n)
} }
/* on restricted maps the item is consumed but the effect is not used */ /* on restricted maps the item is consumed but the effect is not used */
if ( if (!pc_has_permission(sd,PC_PERM_ITEM_UNCONDITIONAL) && (
(!map_flag_vs(sd->bl.m) && id->flag.no_equip&1) || // Normal (!map_flag_vs(sd->bl.m) && id->flag.no_equip&1) || // Normal
(map[sd->bl.m].flag.pvp && id->flag.no_equip&2) || // PVP (map[sd->bl.m].flag.pvp && id->flag.no_equip&2) || // PVP
(map_flag_gvg(sd->bl.m) && id->flag.no_equip&4) || // GVG (map_flag_gvg(sd->bl.m) && id->flag.no_equip&4) || // GVG
(map[sd->bl.m].flag.battleground && id->flag.no_equip&8) || // Battleground (map[sd->bl.m].flag.battleground && id->flag.no_equip&8) || // Battleground
(map[sd->bl.m].flag.restricted && id->flag.no_equip&(8*map[sd->bl.m].zone)) // Zone restriction (map[sd->bl.m].flag.restricted && id->flag.no_equip&(8*map[sd->bl.m].zone)) // Zone restriction
) { )) {
if( battle_config.item_restricted_consumption_type ) { if( battle_config.item_restricted_consumption_type ) {
clif_useitemack(sd,n,item.amount-1,true); clif_useitemack(sd,n,item.amount-1,true);
pc_delitem(sd,n,1,1,0,LOG_TYPE_CONSUME); pc_delitem(sd,n,1,1,0,LOG_TYPE_CONSUME);

View File

@ -45,6 +45,7 @@ enum e_pc_permission {
PC_PERM_DISABLE_CMD_DEAD = 0x100000, PC_PERM_DISABLE_CMD_DEAD = 0x100000,
PC_PERM_CHANNEL_ADMIN = 0x200000, PC_PERM_CHANNEL_ADMIN = 0x200000,
PC_PERM_TRADE_BOUNDED = 0x400000, PC_PERM_TRADE_BOUNDED = 0x400000,
PC_PERM_ITEM_UNCONDITIONAL = 0x800000,
}; };
static const struct { static const struct {
@ -74,6 +75,7 @@ static const struct {
{ "disable_commands_when_dead", PC_PERM_DISABLE_CMD_DEAD }, { "disable_commands_when_dead", PC_PERM_DISABLE_CMD_DEAD },
{ "channel_admin", PC_PERM_CHANNEL_ADMIN }, { "channel_admin", PC_PERM_CHANNEL_ADMIN },
{ "can_trade_bounded", PC_PERM_TRADE_BOUNDED }, { "can_trade_bounded", PC_PERM_TRADE_BOUNDED },
{ "item_unconditional", PC_PERM_ITEM_UNCONDITIONAL },
}; };
#endif // _PC_GROUPS_H_ #endif // _PC_GROUPS_H_