Skip to content

Commit

Permalink
Item Max Level clif_equipitemack messages
Browse files Browse the repository at this point in the history
* Max level to equip item now works for Pre-Renewal too, since the field is optional. 0 means no max level limit.
* Fixed fail message on clif_equipitemack when item cannot be equipped because level limitation

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
  • Loading branch information
cydh committed Jan 14, 2015
1 parent 3037a1b commit fa75733
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 77 deletions.
2 changes: 1 addition & 1 deletion db/import-tmpl/item_db.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Items Additional Database
//
// Structure of Database:
// ID,Name,Name,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Class,Gender,Loc,wLV,eLV,Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script }
// ID,Name,Name,Type,Price,Sell,Weight,ATK[:MATK],DEF,Range,Slot,Job,Class,Gender,Loc,wLV,eLV[:maxLevel],Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script }
//
// THQ Quest Items
//=============================================================
Expand Down
2 changes: 1 addition & 1 deletion db/pre-re/item_db.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Items Database
//
// Structure of Database:
// ID,AegisName,Name,Type,Buy,Sell,Weight,ATK,DEF,Range,Slots,Job,Class,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[:maxLevel],Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script }
//
// Healing Items
//=============================================================
Expand Down
2 changes: 1 addition & 1 deletion db/re/item_db.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Items Database
//
// Structure of Database:
// ID,AegisName,Name,Type,Buy,Sell,Weight,ATK,DEF,Range,Slots,Job,Class,Gender,Loc,wLV,eLV,Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script }
// ID,AegisName,Name,Type,Buy,Sell,Weight,ATK[:MATK],DEF,Range,Slots,Job,Class,Gender,Loc,wLV,eLV[:maxLevel],Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script }
//
// Healing Items
//=============================================================
Expand Down
4 changes: 4 additions & 0 deletions doc/item_db.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Weight: Item's weight. Each 10 is 1 weight.

ATK: Weapon's attack

MATK: Weapon's magic attack (Renewal only)

---------------------------------------

DEF: Armor's defense
Expand Down Expand Up @@ -154,6 +156,8 @@ wLV: Weapon level.

eLV: Base level required to be able to equip.

maxLevel: Only able to equip if base level is lower than this.

---------------------------------------

Refineable: 1 if the item can be refined, 0 otherwise.
Expand Down
31 changes: 14 additions & 17 deletions src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -3388,39 +3388,36 @@ void clif_statusupack(struct map_session_data *sd,int type,int ok,int val)
/// 0 = failure
/// 1 = success
/// 2 = failure due to low level
void clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok)
void clif_equipitemack(struct map_session_data *sd,int n,int pos,uint8 flag)
{
int fd,header,offs=0,success;
int fd, header, offs = 0;
#if PACKETVER < 20110824
header = 0xaa;
success = (ok==1);
#elif PACKETVER < 20120925
header = 0x8d0;
success = ok ? 0:1;
#else
header = 0x999;
success = ok ? 0:1;
#endif
nullpo_retv(sd);

fd=sd->fd;
fd = sd->fd;
WFIFOHEAD(fd,packet_len(header));
WFIFOW(fd,offs+0)=header;
WFIFOW(fd,offs+2)=n+2;
WFIFOW(fd,offs+0) = header;
WFIFOW(fd,offs+2) = n+2;
#if PACKETVER >= 20120925
WFIFOL(fd,offs+4)=pos;
offs+=2;
WFIFOL(fd,offs+4) = pos;
offs += 2;
#else
WFIFOW(fd,offs+4)=(int)pos;
WFIFOW(fd,offs+4) = (int)pos;
#endif
#if PACKETVER < 20100629
WFIFOB(fd,offs+6)=success;
WFIFOB(fd,offs+6) = flag;
#else
if (ok && sd->inventory_data[n]->equip&EQP_VISIBLE)
WFIFOW(fd,offs+6)=sd->inventory_data[n]->look;
if (flag == ITEM_EQUIP_ACK_OK && sd->inventory_data[n]->equip&EQP_VISIBLE)
WFIFOW(fd,offs+6) = sd->inventory_data[n]->look;
else
WFIFOW(fd,offs+6)=0;
WFIFOB(fd,offs+8)=success;
WFIFOW(fd,offs+6) = 0;
WFIFOB(fd,offs+8) = flag;
#endif
WFIFOSET(fd,packet_len(header));
}
Expand Down Expand Up @@ -10743,7 +10740,7 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd)
return;

if(!sd->status.inventory[index].identify) {
clif_equipitemack(sd,index,0,0); // fail
clif_equipitemack(sd,index,0,ITEM_EQUIP_ACK_FAIL); // fail
return;
}

Expand Down
21 changes: 20 additions & 1 deletion src/map/clif.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,27 @@ enum useskill_fail_cause
};

enum clif_messages {
/* Constant values */
ADDITEM_TO_CART_FAIL_WEIGHT = 0x0,
ADDITEM_TO_CART_FAIL_COUNT = 0x1,

// clif_equipitemack flag
#if PACKETVER < 20110824
ITEM_EQUIP_ACK_OK = 1,
ITEM_EQUIP_ACK_FAIL = 0,
ITEM_EQUIP_ACK_FAILLEVEL = 0,
#elif PACKETVER < 20120925
ITEM_EQUIP_ACK_OK = 0,
ITEM_EQUIP_ACK_FAIL = 1,
ITEM_EQUIP_ACK_FAILLEVEL = 1,
#else
ITEM_EQUIP_ACK_OK = 0,
ITEM_EQUIP_ACK_FAIL = 1,
ITEM_EQUIP_ACK_FAILLEVEL = 2,
#endif
/* -end- */

//! NOTE: These values below need client version validation
ITEM_CANT_OBTAIN_WEIGHT = 0x34, /* You cannot carry more items because you are overweight. */
ITEM_NOUSE_SITTING = 0x297,
MERC_MSG_BASE = 0x4f2,
Expand Down Expand Up @@ -461,7 +480,7 @@ void clif_arrowequip(struct map_session_data *sd,int val); //self
void clif_arrow_fail(struct map_session_data *sd,int type); //self
void clif_arrow_create_list(struct map_session_data *sd); //self
void clif_statusupack(struct map_session_data *sd,int type,int ok,int val); // self
void clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok); // self
void clif_equipitemack(struct map_session_data *sd,int n,int pos,uint8 flag); // self
void clif_unequipitemack(struct map_session_data *sd,int n,int pos,int ok); // self
void clif_misceffect(struct block_list* bl,int type); // area
void clif_changeoption(struct block_list* bl); // area
Expand Down
7 changes: 1 addition & 6 deletions src/map/itemdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,6 @@ static char itemdb_gendercheck(struct item_data *id)
* For backwards compatibility, in Renewal mode, MATK from weapons comes from the atk slot
* We use a ':' delimiter which, if not found, assumes the weapon does not provide any matk.
**/
#ifdef RENEWAL
static void itemdb_re_split_atoi(char *str, int *val1, int *val2) {
int i, val[2];

Expand All @@ -1120,7 +1119,7 @@ static void itemdb_re_split_atoi(char *str, int *val1, int *val2) {
*val2 = val[1];
return;
}
#endif

/**
* Processes one itemdb entry
*/
Expand Down Expand Up @@ -1221,11 +1220,7 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr
}

id->wlv = cap_value(atoi(str[15]), REFINE_TYPE_ARMOR, REFINE_TYPE_MAX);
#ifdef RENEWAL
itemdb_re_split_atoi(str[16],&id->elv,&id->elvmax);
#else
id->elv = atoi(str[16]);
#endif
id->flag.no_refine = atoi(str[17]) ? 0 : 1; //FIXME: verify this
id->look = atoi(str[18]);

Expand Down
2 changes: 1 addition & 1 deletion src/map/itemdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ struct item_data
int slot;
int look;
int elv;
int elvmax; ///< Maximum level for this item
int wlv;
int view_id;
#ifdef RENEWAL
int matk;
int elvmax;/* maximum level for this item */
#endif

int delay;
Expand Down
4 changes: 2 additions & 2 deletions src/map/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1813,8 +1813,8 @@ int map_quit(struct map_session_data *sd) {

for (i = 0; i < EQI_MAX; i++) {
if (sd->equip_index[i] >= 0)
if (!pc_isequip(sd,sd->equip_index[i]))
pc_unequipitem(sd,sd->equip_index[i],2);
if (pc_isequip(sd,sd->equip_index[i]) != ITEM_EQUIP_ACK_OK)
pc_unequipitem(sd,sd->equip_index[i],ITEM_EQUIP_ACK_FAIL);
}

// Return loot to owner
Expand Down

0 comments on commit fa75733

Please sign in to comment.