summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-11 16:32:37 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-11 16:32:37 +0000
commit6749d6567aa972b5cc46e1ed85986be21e2ec799 (patch)
tree4d28fd94577ad9183c9341f71fd961931faba416 /src/map/pc.c
parent1e844abc3fa269a504ba6610ac83224d9660ce22 (diff)
downloadhercules-6749d6567aa972b5cc46e1ed85986be21e2ec799.tar.gz
hercules-6749d6567aa972b5cc46e1ed85986be21e2ec799.tar.bz2
hercules-6749d6567aa972b5cc46e1ed85986be21e2ec799.tar.xz
hercules-6749d6567aa972b5cc46e1ed85986be21e2ec799.zip
- Coded @reset.
- Reenabled @changesex - Added function pet_create_egg which handles creating pet eggs correctly (when passed item id is indeed a valid petegg). Applied this on @createitem and getitem. - Cleaned up code of @item - Added define UNKNOWN_ITEM_ID (512 = apple) - Added IT_* enumation item_Types to identify said data from items. - Cleaned up the itemdb_isequip functions. itemdb_isequip will now return if the item is equipable by players, itemdb_isstackable returns if the item can be stacked, and itemdb_isidentified returns if the item should drop identified. - Added defines CARD0_PET/CARD0_FORGE/CARD0_CREATED to identify if a given item has "invalid" cards, added define function itemdb_isspecial to simplify this check. - Removed itemdb.c considering item ids above 20000 as invalid. - Cleaned up script commands getitem and card-counting related ones. - Cleaned up a bit more pc_isequip git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7613 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c74
1 files changed, 33 insertions, 41 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 5ce2a8394..fa7d614ff 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -386,14 +386,18 @@ int pc_equippoint(struct map_session_data *sd,int n)
nullpo_retr(0, sd);
- if(sd->inventory_data[n]) {
- ep = sd->inventory_data[n]->equip;
- if(sd->inventory_data[n]->look == W_DAGGER ||
- sd->inventory_data[n]->look == W_1HSWORD ||
- sd->inventory_data[n]->look == W_1HAXE) {
- if(ep == EQP_HAND_R && (pc_checkskill(sd,AS_LEFT) > 0 || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN))
- return EQP_WEAPON;
- }
+ if(!sd->inventory_data[n])
+ return 0;
+
+ if (!itemdb_isequip2(sd->inventory_data[n]))
+ return 0; //Not equippable by players.
+
+ ep = sd->inventory_data[n]->equip;
+ if(sd->inventory_data[n]->look == W_DAGGER ||
+ sd->inventory_data[n]->look == W_1HSWORD ||
+ sd->inventory_data[n]->look == W_1HAXE) {
+ if(ep == EQP_HAND_R && (pc_checkskill(sd,AS_LEFT) > 0 || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN))
+ return EQP_WEAPON;
}
return ep;
}
@@ -487,11 +491,8 @@ static int pc_isAllowedCardOn(struct map_session_data *sd,int s,int eqindex,int
int i;
struct item *item = &sd->status.inventory[eqindex];
struct item_data *data;
- if ( //Crafted/made/hatched items.
- item->card[0]==0x00ff ||
- item->card[0]==0x00fe ||
- item->card[0]==(short)0xff00
- )
+ //Crafted/made/hatched items.
+ if (itemdb_isspecial(item->card[0]))
return 1;
for (i=0;i<s;i++) {
@@ -2380,26 +2381,23 @@ int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip)
cardid=sd->status.inventory[idx_card].nameid;
ep=sd->inventory_data[idx_card]->equip;
+ //Check validity
if( nameid <= 0 || cardid <= 0 ||
- (sd->inventory_data[idx_equip]->type!=4 && sd->inventory_data[idx_equip]->type!=5)|| // ? 備じゃない
- sd->inventory_data[idx_card]->type!=6 || // Prevent Hack [Ancyker]
- sd->status.inventory[idx_equip].identify==0 || // 未鑑定
- sd->status.inventory[idx_equip].card[0]==0x00ff || // 製造武器
- sd->status.inventory[idx_equip].card[0]==0x00fe ||
- sd->status.inventory[idx_equip].card[0]==(short)0xff00 ||
- !(sd->inventory_data[idx_equip]->equip&ep) || // ? 備個所違い
- (sd->inventory_data[idx_equip]->type==4 && ep==EQP_SHIELD) || // ? 手武器と盾カ?ド
+ (sd->inventory_data[idx_equip]->type!=IT_WEAPON && sd->inventory_data[idx_equip]->type!=IT_WEAPON)||
+ sd->inventory_data[idx_card]->type!=IT_CARD || // Prevent Hack [Ancyker]
+ sd->status.inventory[idx_equip].identify==0 ||
+ itemdb_isspecial(sd->status.inventory[idx_equip].card[0]) ||
+ !(sd->inventory_data[idx_equip]->equip&ep) ||
+ (sd->inventory_data[idx_equip]->type==IT_WEAPON && ep==EQP_SHIELD) || //Card shield attempted to place on left-hand weapon.
sd->status.inventory[idx_equip].equip){
clif_insert_card(sd,idx_equip,idx_card,1);
return 0;
}
for(i=0;i<sd->inventory_data[idx_equip]->slot;i++){
- if( sd->status.inventory[idx_equip].card[i] == 0){
- // 空きスロットが ったので差し?む
+ if( sd->status.inventory[idx_equip].card[i] == 0)
+ { //Free slot found.
sd->status.inventory[idx_equip].card[i]=cardid;
-
- // カ?ドは減らす
clif_insert_card(sd,idx_equip,idx_card,0);
pc_delitem(sd,idx_card,1,1);
return 0;
@@ -2461,7 +2459,7 @@ int pc_checkadditem(struct map_session_data *sd,int nameid,int amount)
nullpo_retr(0, sd);
- if(itemdb_isequip(nameid))
+ if(!itemdb_isstackable(nameid))
return ADDITEM_NEW;
for(i=0;i<MAX_INVENTORY;i++){
@@ -2584,7 +2582,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount)
i = MAX_INVENTORY;
- if (!itemdb_isequip2(data))
+ if (itemdb_isstackable2(data))
{ //Stackable
for (i = 0; i < MAX_INVENTORY; i++)
{
@@ -2883,7 +2881,7 @@ int pc_useitem(struct map_session_data *sd,int n)
//Logs
pc_delitem(sd,n,1,1);
}
- if(sd->status.inventory[n].card[0]==0x00fe &&
+ if(sd->status.inventory[n].card[0]==CARD0_CREATE &&
pc_famerank(MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3]), MAPID_ALCHEMIST))
{
potion_flag = 2; // Famous player's potions have 50% more efficiency
@@ -2924,8 +2922,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
return 1;
i=MAX_CART;
- if(!itemdb_isequip2(data)){
- // 装 備品ではないので、既所有品なら個数のみ変化させる
+ if(itemdb_isstackable2(data)){
for(i=0;i<MAX_CART;i++){
if(sd->status.cart[i].nameid==item_data->nameid &&
sd->status.cart[i].card[0] == item_data->card[0] && sd->status.cart[i].card[1] == item_data->card[1] &&
@@ -2939,7 +2936,6 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
}
}
if(i >= MAX_CART){
- // 装 備品か未所有品だったので空き欄へ追加
for(i=0;i<MAX_CART;i++){
if(sd->status.cart[i].nameid==0){
memcpy(&sd->status.cart[i],item_data,sizeof(sd->status.cart[0]));
@@ -3134,7 +3130,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl)
memset(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = itemid;
tmp_item.amount = 1;
- tmp_item.identify = !itemdb_isequip3(itemid);
+ tmp_item.identify = itemdb_isidentified(itemid);
flag = pc_additem(sd,&tmp_item,1);
if(battle_config.show_steal_in_same_party)
@@ -4486,7 +4482,7 @@ int pc_resetlvl(struct map_session_data* sd,int type)
clif_updatestatus(sd,SP_UDEX);
clif_updatestatus(sd,SP_ULUK); // End Addition
- for(i=0;i<11;i++) { // unequip items that can't be equipped by base 1 [Valaris]
+ for(i=0;i<EQI_MAX;i++) { // unequip items that can't be equipped by base 1 [Valaris]
if(sd->equip_index[i] >= 0)
if(!pc_isequip(sd,sd->equip_index[i]))
pc_unequipitem(sd,sd->equip_index[i],2);
@@ -4820,7 +4816,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=7420; //PVP Skull item ID
item_tmp.identify=1;
- item_tmp.card[0]=0x00fe;
+ item_tmp.card[0]=CARD0_CREATE;
item_tmp.card[1]=0;
item_tmp.card[2]=GetWord(sd->char_id,0); // CharId
item_tmp.card[3]=GetWord(sd->char_id,1);
@@ -5388,7 +5384,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
clif_updatestatus(sd,SP_JOBEXP);
clif_updatestatus(sd,SP_NEXTJOBEXP);
- for(i=0;i<11;i++) {
+ 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); // ?備外し
@@ -6248,9 +6244,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
struct item_data *data;
if (sd->inventory_data[n]->equip_script)
run_script(sd->inventory_data[n]->equip_script,0,sd->bl.id,fake_nd->bl.id);
- if(sd->status.inventory[n].card[0]==0x00ff ||
- sd->status.inventory[n].card[0]==0x00fe ||
- sd->status.inventory[n].card[0]==(short)0xff00)
+ if(itemdb_isspecial(sd->status.inventory[n].card[0]))
; //No cards
else
for(i=0;i<sd->inventory_data[n]->slot; i++)
@@ -6346,9 +6340,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
struct item_data *data;
if (sd->inventory_data[n]->unequip_script)
run_script(sd->inventory_data[n]->unequip_script,0,sd->bl.id,fake_nd->bl.id);
- if(sd->status.inventory[n].card[0]==0x00ff ||
- sd->status.inventory[n].card[0]==0x00fe ||
- sd->status.inventory[n].card[0]==(short)0xff00)
+ if(itemdb_isspecial(sd->status.inventory[n].card[0]))
; //No cards
else
for(i=0;i<sd->inventory_data[n]->slot; i++)