diff options
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 165 |
1 files changed, 103 insertions, 62 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 9ebdfa62f..ca7387474 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4844,10 +4844,40 @@ int pc_isUseitem(struct map_session_data *sd,int n) if (map_flag_gvg2(sd->bl.m)) return 0; break; + + case ITEMID_GIANT_FLY_WING: { + struct party_data *p; + + if (!sd->status.party_id) { + clif->msgtable(sd, MSG_PARTY_MEMBER_NOT_SUMMONED); + break; + } + + if ((p = party->search(sd->status.party_id)) != NULL) { + int i; + int16 m; + + ARR_FIND(0, MAX_PARTY, i, p->data[i].sd == sd); + + if (i == MAX_PARTY || !p->party.member[i].leader) { + clif->msgtable(sd, MSG_PARTY_MEMBER_NOT_SUMMONED); + break; + } + + m = sd->bl.m; + + ARR_FIND(0, MAX_PARTY, i, p->data[i].sd && p->data[i].sd != sd && p->data[i].sd->bl.m == m); + + if (i == MAX_PARTY || pc_isdead(p->data[i].sd)) { + clif->msgtable(sd, MSG_PARTY_NO_MEMBER_IN_MAP); + break; + } + } + } + FALLTHROUGH case ITEMID_WING_OF_FLY: - case ITEMID_GIANT_FLY_WING: - if( map->list[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) { - clif->skill_mapinfomessage(sd,0); + if (map->list[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m)) { + clif->skill_mapinfomessage(sd, 0); return 0; } /* Fall through */ @@ -5005,10 +5035,11 @@ int pc_useitem(struct map_session_data *sd,int n) { nullpo_ret(sd); Assert_ret(n >= 0 && n < MAX_INVENTORY); - if( sd->npc_id || sd->state.workinprogress&1 ){ - /* TODO: add to clif->messages enum */ -#ifdef RENEWAL - clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS); // TODO look for the client date that has this message. + if (sd->npc_id || sd->state.workinprogress & 1) { +#if PACKETVER >= 20110309 + clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS); +#else + clif->messagecolor_self(fd, COLOR_WHITE, msg_fd(fd, 48)); #endif return 0; } @@ -9992,51 +10023,51 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) *------------------------------------------*/ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { - int i,iflag; - bool status_cacl = false; + int i, iflag; + bool status_calc = false; int pos; + nullpo_ret(sd); - if( n < 0 || n >= MAX_INVENTORY ) { - clif->unequipitemack(sd,0,0,UIA_FAIL); + if (n < 0 || n >= MAX_INVENTORY) { + clif->unequipitemack(sd, 0, 0, UIA_FAIL); return 0; } // if player is berserk then cannot unequip - if (!(flag&PCUNEQUIPITEM_FORCE) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP]) ) - { - clif->unequipitemack(sd,n,0,UIA_FAIL); + if (!(flag & PCUNEQUIPITEM_FORCE) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP])) { + clif->unequipitemack(sd, n, 0, UIA_FAIL); return 0; } - if( !(flag&PCUNEQUIPITEM_FORCE) && sd->sc.count && sd->sc.data[SC_KYOUGAKU] ) - { - clif->unequipitemack(sd,n,0,UIA_FAIL); + if (!(flag & PCUNEQUIPITEM_FORCE) && sd->sc.count && sd->sc.data[SC_KYOUGAKU]) { + clif->unequipitemack(sd, n, 0, UIA_FAIL); return 0; } - if(battle_config.battle_log) + if (battle_config.battle_log) ShowInfo("unequip %d %x:%x\n", n, (unsigned int)(pc->equippoint(sd, n)), sd->status.inventory[n].equip); - if(!sd->status.inventory[n].equip){ //Nothing to unequip - clif->unequipitemack(sd,n,0,UIA_FAIL); + if (sd->status.inventory[n].equip == 0) { //Nothing to unequip + clif->unequipitemack(sd, n, 0, UIA_FAIL); return 0; } - for(i=0;i<EQI_MAX;i++) { - if(sd->status.inventory[n].equip & pc->equip_pos[i]) + + for (i = 0; i < EQI_MAX; i++) { + if (sd->status.inventory[n].equip & pc->equip_pos[i]) sd->equip_index[i] = -1; } pos = sd->status.inventory[n].equip; pc->unequipitem_pos(sd, n, pos); - clif->unequipitemack(sd,n,pos,UIA_SUCCESS); + clif->unequipitemack(sd, n, pos, UIA_SUCCESS); - if((pos & EQP_ARMS) && - sd->weapontype1 == 0 && sd->weapontype2 == 0 && (!sd->sc.data[SC_TK_SEVENWIND] || sd->sc.data[SC_ASPERSIO])) //Check for seven wind (but not level seven!) - skill->enchant_elemental_end(&sd->bl,-1); + if ((pos & EQP_ARMS) && + sd->weapontype1 == 0 && sd->weapontype2 == 0 && (sd->sc.data[SC_TK_SEVENWIND] == 0 || sd->sc.data[SC_ASPERSIO])) //Check for seven wind (but not level seven!) + skill->enchant_elemental_end(&sd->bl, -1); - if(pos & EQP_ARMOR) { + if (pos & EQP_ARMOR) { // On Armor Change... status_change_end(&sd->bl, SC_BENEDICTIO, INVALID_TIMER); status_change_end(&sd->bl, SC_ARMOR_RESIST, INVALID_TIMER); @@ -10050,74 +10081,84 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) if( sd->state.autobonus&pos ) sd->state.autobonus &= ~sd->status.inventory[n].equip; //Check for activated autobonus [Inkfish] - sd->status.inventory[n].equip=0; + sd->status.inventory[n].equip = 0; iflag = sd->npc_item_flag; /* check for combos (MUST be before status_calc_pc) */ - if ( sd->inventory_data[n] ) { - if( sd->inventory_data[n]->combos_count ) { - if( pc->removecombo(sd,sd->inventory_data[n]) ) - status_cacl = true; - } if(itemdb_isspecial(sd->status.inventory[n].card[0])) - ; //No cards - else { - for( i = 0; i < sd->inventory_data[n]->slot; i++ ) { + if (sd->inventory_data[n] != NULL) { + if (sd->inventory_data[n]->combos_count) { + if (pc->removecombo(sd, sd->inventory_data[n])) + status_calc = true; + } + if (itemdb_isspecial(sd->status.inventory[n].card[0]) == false) { + for (i = 0; i < sd->inventory_data[n]->slot; i++) { struct item_data *data; - if (!sd->status.inventory[n].card[i]) + if (sd->status.inventory[n].card[i] == 0) continue; - if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { - if( data->combos_count ) { - if( pc->removecombo(sd,data) ) - status_cacl = true; + if ((data = itemdb->exists(sd->status.inventory[n].card[i])) != NULL) { + if (data->combos_count) { + if (pc->removecombo(sd, data)) + status_calc = true; } } } } + /* Item Options checking */ + for (i = 0; i < MAX_ITEM_OPTIONS; i++) { + struct item_option *ito = NULL; + int16 item_option = sd->status.inventory[n].option[i].index; + + if (item_option <= 0) + continue; + if ((ito = itemdb->option_exists(sd->status.inventory[n].option[i].index)) == NULL) + continue; + + status_calc = true; + } } - if(flag&PCUNEQUIPITEM_RECALC || status_cacl) { + if (flag & PCUNEQUIPITEM_RECALC || status_calc) { pc->checkallowskill(sd); - status_calc_pc(sd,SCO_NONE); + status_calc_pc(sd, SCO_NONE); } - if(sd->sc.data[SC_CRUCIS] && !battle->check_undead(sd->battle_status.race,sd->battle_status.def_ele)) + if (sd->sc.data[SC_CRUCIS] && battle->check_undead(sd->battle_status.race, sd->battle_status.def_ele) == false) status_change_end(&sd->bl, SC_CRUCIS, INVALID_TIMER); //OnUnEquip script [Skotlex] - if (sd->inventory_data[n]) { - if (sd->inventory_data[n]->unequip_script) { - if ( battle_config.unequip_restricted_equipment & 1 ) { - ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, i, map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid); - if ( i == map->list[sd->bl.m].zone->disabled_items_count ) + if (sd->inventory_data[n] != NULL) { + if (sd->inventory_data[n]->unequip_script != NULL) { + if (battle_config.unequip_restricted_equipment & 1) { + ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, i, map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid); + if (i == map->list[sd->bl.m].zone->disabled_items_count) script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); } else script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); } - if(itemdb_isspecial(sd->status.inventory[n].card[0])) - ; //No cards - else { - for( i = 0; i < sd->inventory_data[n]->slot; i++ ) { - struct item_data *data; - if (!sd->status.inventory[n].card[i]) + if (itemdb_isspecial(sd->status.inventory[n].card[0]) == false) { + for (i = 0; i < sd->inventory_data[n]->slot; i++) { + struct item_data *data = NULL; + if (sd->status.inventory[n].card[i] == 0) continue; - if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { - if ( data->unequip_script ) { - if ( battle_config.unequip_restricted_equipment & 2 ) { + if ((data = itemdb->exists(sd->status.inventory[n].card[i])) != NULL) { + if (data->unequip_script) { + if (battle_config.unequip_restricted_equipment & 2) { int j; - ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, j, map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[n].card[i]); - if ( j == map->list[sd->bl.m].zone->disabled_items_count ) + ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, j, map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[n].card[i]); + if (j == map->list[sd->bl.m].zone->disabled_items_count) script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id); - } - else + } else { script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id); + } } } } } } + sd->npc_item_flag = iflag; return 1; |