Skip to content

Commit

Permalink
item_noequip overhaul / Fixed Bug #7048
Browse files Browse the repository at this point in the history
Items are no longer unequipped when disabled by item_noequip.txt, instead their effects are nullified -- however cards in them, unless also disabled, wont have its effect nullified.
Consumables will be consumed even while disabled, unless you modify the new config item_restricted_consumption_type
http://hercules.ws/board/tracker/issue-7048-requestreport-regarding-to-item-noequiptxt/

Signed-off-by: shennetsind <ind@henn.et>
  • Loading branch information
shennetsind committed Feb 3, 2013
1 parent 453d6ce commit cc8e005
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 39 deletions.
5 changes: 5 additions & 0 deletions conf/battle/items.conf
Expand Up @@ -75,3 +75,8 @@ gtb_sc_immunity: 50
// NOTE: Different cards that grant the same skill will both
// always work independently of each other regardless of setting.
autospell_stacking: no

// Will disabled consumables (disabled by item_noequip.txt) be consumed when trying to use them?
// 1 (official): yes
// 0: no
item_restricted_consumption_type:1
1 change: 1 addition & 0 deletions src/map/battle.c
Expand Up @@ -5867,6 +5867,7 @@ static const struct _battle_data {
* Hercules
**/
{ "skill_trap_type", &battle_config.skill_trap_type, 0, 0, 1, },
{ "item_restricted_consumption_type", &battle_config.item_restricted_consumption_type,1, 0, 1, },
};
#ifndef STATS_OPT_OUT
/**
Expand Down
1 change: 1 addition & 0 deletions src/map/battle.h
Expand Up @@ -484,6 +484,7 @@ extern struct Battle_Config

int mob_size_influence; // Enable modifications on earned experience, drop rates and monster status depending on monster size. [mkbu95]
int skill_trap_type;
int item_restricted_consumption_type;
} battle_config;

void do_init_battle(void);
Expand Down
55 changes: 16 additions & 39 deletions src/map/pc.c
Expand Up @@ -861,20 +861,6 @@ int pc_isequip(struct map_session_data *sd,int n)
#endif
if(item->sex != 2 && sd->status.sex != item->sex)
return 0;
if(!map_flag_vs(sd->bl.m) && ((item->flag.no_equip&1)))
return 0;
if(map[sd->bl.m].flag.pvp && ((item->flag.no_equip&2)))
return 0;
if(map_flag_gvg(sd->bl.m) && ((item->flag.no_equip&4)))
return 0;
if(map[sd->bl.m].flag.battleground && ((item->flag.no_equip&8)))
return 0;
if(map[sd->bl.m].flag.restricted)
{
int flag =8*map[sd->bl.m].zone;
if (item->flag.no_equip&flag)
return 0;
}

if (sd->sc.count) {

Expand Down Expand Up @@ -4134,16 +4120,6 @@ int pc_isUseitem(struct map_session_data *sd,int n)
else if( itemdb_is_poison(nameid) && (sd->class_&MAPID_THIRDMASK) != MAPID_GUILLOTINE_CROSS )
return 0;

//added item_noequip.txt items check by Maya&[Lupus]
if (
(!map_flag_vs(sd->bl.m) && item->flag.no_equip&1) || // Normal
(map[sd->bl.m].flag.pvp && item->flag.no_equip&2) || // PVP
(map_flag_gvg(sd->bl.m) && item->flag.no_equip&4) || // GVG
(map[sd->bl.m].flag.battleground && item->flag.no_equip&8) || // Battleground
(map[sd->bl.m].flag.restricted && item->flag.no_equip&(8*map[sd->bl.m].zone)) // Zone restriction
)
return 0;

//Gender check
if(item->sex != 2 && sd->status.sex != item->sex)
return 0;
Expand Down Expand Up @@ -4222,7 +4198,7 @@ int pc_useitem(struct map_session_data *sd,int n)
(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) */
if( sd->inventory_data[n]->flag.delay_consume ) {
if( nameid != ITEMID_REINS_OF_MOUNT && sd->sc.option&OPTION_MOUNTING )
Expand Down Expand Up @@ -4273,6 +4249,21 @@ int pc_useitem(struct map_session_data *sd,int n)
}
}

/* on restricted maps the item is consumed but the effect is not used */
if (
(!map_flag_vs(sd->bl.m) && sd->inventory_data[n]->flag.no_equip&1) || // Normal
(map[sd->bl.m].flag.pvp && sd->inventory_data[n]->flag.no_equip&2) || // PVP
(map_flag_gvg(sd->bl.m) && sd->inventory_data[n]->flag.no_equip&4) || // GVG
(map[sd->bl.m].flag.battleground && sd->inventory_data[n]->flag.no_equip&8) || // Battleground
(map[sd->bl.m].flag.restricted && sd->inventory_data[n]->flag.no_equip&(8*map[sd->bl.m].zone)) // Zone restriction
) {
if( battle_config.item_restricted_consumption_type ) {
clif_useitemack(sd,n,sd->status.inventory[n].amount-1,true);
pc_delitem(sd,n,1,1,0,LOG_TYPE_CONSUME);
}
return 0;/* regardless, effect is not run */
}

sd->itemid = sd->status.inventory[n].nameid;
sd->itemindex = n;
if(sd->catch_target_class != -1) //Abort pet catching.
Expand Down Expand Up @@ -8612,7 +8603,6 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
int pc_checkitem(struct map_session_data *sd)
{
int i,id,calc_flag = 0;
struct item_data *it=NULL;

nullpo_ret(sd);

Expand Down Expand Up @@ -8640,7 +8630,6 @@ int pc_checkitem(struct map_session_data *sd)
}

for( i = 0; i < MAX_INVENTORY; i++) {
it = sd->inventory_data[i];

if( sd->status.inventory[i].nameid == 0 )
continue;
Expand All @@ -8654,18 +8643,6 @@ int pc_checkitem(struct map_session_data *sd)
continue;
}

if( it ) { // check for forbiden items.
int flag =
(map[sd->bl.m].flag.restricted?(8*map[sd->bl.m].zone):0)
| (!map_flag_vs(sd->bl.m)?1:0)
| (map[sd->bl.m].flag.pvp?2:0)
| (map_flag_gvg(sd->bl.m)?4:0)
| (map[sd->bl.m].flag.battleground?8:0);
if( flag && (it->flag.no_equip&flag) ) {
pc_unequipitem(sd, i, 2);
calc_flag = 1;
}
}
}

if( calc_flag && sd->state.active ) {
Expand Down
14 changes: 14 additions & 0 deletions src/map/status.c
Expand Up @@ -2443,6 +2443,20 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
if(!sd->inventory_data[index])
continue;

if(sd->inventory_data[index]->flag.no_equip) { // Items may be equipped, their effects however are nullified.
if(map[sd->bl.m].flag.restricted && sd->inventory_data[index]->flag.no_equip&(8*map[sd->bl.m].zone))
continue;
if(!map_flag_vs(sd->bl.m) && sd->inventory_data[index]->flag.no_equip&1)
continue;
if(map[sd->bl.m].flag.pvp && sd->inventory_data[index]->flag.no_equip&2)
continue;
if(map_flag_gvg(sd->bl.m) && sd->inventory_data[index]->flag.no_equip&4)
continue;
if(map[sd->bl.m].flag.battleground && sd->inventory_data[index]->flag.no_equip&8)
continue;
}


status->def += sd->inventory_data[index]->def;

if(first && sd->inventory_data[index]->equip_script)
Expand Down

0 comments on commit cc8e005

Please sign in to comment.