summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c48
-rw-r--r--src/map/clif.h50
-rw-r--r--src/map/pc.c165
-rw-r--r--src/map/script.c254
4 files changed, 346 insertions, 171 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 8ab6e71a4..f1400a5d4 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -4174,7 +4174,7 @@ void clif_storageitemadded(struct map_session_data* sd, struct item* i, int inde
WFIFOB(fd,12+offset) = i->refine; //refine
clif->addcards(WFIFOP(fd,13+offset), i);
#if PACKETVER >= 20150226
- clif->add_item_options(WFIFOP(fd,21+offset), i);
+ clif->add_item_options(WFIFOP(fd, 21 + offset), i);
#endif
WFIFOSET(fd,packet_len(storageaddType));
}
@@ -6248,7 +6248,7 @@ void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail)
WBUFB(buf,12+offset)=sd->status.cart[n].refine;
clif->addcards(WBUFP(buf,13+offset), &sd->status.cart[n]);
#if PACKETVER >= 20150226
- clif->add_item_options(WBUFP(buf,21+offset), &sd->status.cart[n]);
+ clif->add_item_options(WBUFP(buf, 21 + offset), &sd->status.cart[n]);
#endif
WFIFOSET(fd,packet_len(cartaddType));
}
@@ -6376,7 +6376,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven
WFIFOB(fd,offset+13+i*item_length) = vsd->status.cart[index].refine;
clif->addcards(WFIFOP(fd,offset+14+i*item_length), &vsd->status.cart[index]);
#if PACKETVER >= 20150226
- clif->add_item_options(WFIFOP(fd,offset+22+i*item_length), &vsd->status.cart[index]);
+ clif->add_item_options(WFIFOP(fd, offset + 22 + i * item_length), &vsd->status.cart[index]);
#endif
}
WFIFOSET(fd,WFIFOW(fd,2));
@@ -6442,7 +6442,7 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven
WFIFOB(fd,21+i*item_length) = sd->status.cart[index].refine;
clif->addcards(WFIFOP(fd,22+i*item_length), &sd->status.cart[index]);
#if PACKETVER >= 20150226
- clif->add_item_options(WFIFOP(fd,30+22+i*item_length), &sd->status.cart[index]);
+ clif->add_item_options(WFIFOP(fd, 30 + i * item_length), &sd->status.cart[index]);
#endif
}
WFIFOSET(fd,WFIFOW(fd,2));
@@ -10632,9 +10632,11 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
clif->clearunit_area(&sd->bl,CLR_DEAD);
return;
}
- if( sd->npc_id || sd->state.workinprogress&2 ){
-#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 & 2) {
+#if PACKETVER >= 20110309
+ clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS);
+#else
+ clif->messagecolor_self(fd, COLOR_WHITE, msg_fd(fd, 48));
#endif
return;
}
@@ -10647,9 +10649,11 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
clif->pActionRequest_sub(sd, 0x07, bl->id, timer->gettick());
break;
case BL_NPC:
- if( sd->ud.skill_id < RK_ENCHANTBLADE && sd->ud.skilltimer != INVALID_TIMER ) {// TODO: should only work with none 3rd job skills
-#ifdef RENEWAL
+ if (sd->ud.skill_id < RK_ENCHANTBLADE && sd->ud.skilltimer != INVALID_TIMER) { // TODO: should only work with none 3rd job skills
+#if PACKETVER >= 20110309
clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS);
+#else
+ clif->messagecolor_self(fd, COLOR_WHITE, msg_fd(fd, 48));
#endif
break;
}
@@ -11032,12 +11036,14 @@ void clif_parse_ChangeCart(int fd, struct map_session_data *sd)
if (pc->checkskill(sd, MC_CHANGECART) == 0)
return;
-#ifdef RENEWAL
- if (sd->npc_id || sd->state.workinprogress&1) {
+ 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;
}
-#endif
type = RFIFOW(fd, 2);
@@ -11241,9 +11247,11 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
// Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
pc->update_idle_time(sd, BCIDLE_USESKILLTOID);
- if( sd->npc_id || sd->state.workinprogress&1 ){
-#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;
}
@@ -11338,12 +11346,14 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski
return;
}
-#ifdef RENEWAL
- if( sd->state.workinprogress&1 ){
- clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS); // TODO look for the client date that has this message.
+ if (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;
}
-#endif
//Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
pc->update_idle_time(sd, BCIDLE_USESKILLTOPOS);
diff --git a/src/map/clif.h b/src/map/clif.h
index 6b5fb8dca..ccb227267 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -359,30 +359,32 @@ typedef enum useskill_fail_cause { // clif_skill_fail
}useskill_fail_cause;
enum clif_messages {
- MSG_ITEM_CANT_OBTAIN_WEIGHT = 0x034, ///< You cannot carry more items because you are overweight.
- MSG_ITEM_NEED_STANDING = 0x297, ///< You cannot use this item while sitting.
- MSG_MERCENARY_EXPIRED = 0x4f2, ///< The mercenary contract has expired.
- MSG_MERCENARY_DIED = 0x4f3, ///< The mercenary has died.
- MSG_MERCENARY_RELEASED = 0x4f4, ///< You have released the mercenary.
- MSG_MERCENARY_ESCAPED = 0x4f5, ///< The mercenary has run away.
- MSG_SKILL_CANT_USE_AREA = 0x536, ///< This skill cannot be used within this area
- MSG_ITEM_CANT_USE_AREA = 0x537, ///< This item cannot be used within this area.
- MSG_EQUIP_NOT_PUBLIC = 0x54d, ///< This character's equipment information is not open to the public.
- MSG_ITEM_NEED_MADO = 0x59b, ///< Item can only be used when Mado Gear is mounted.
- MSG_ITEM_NEED_CART = 0x5ef, ///< Usable only when cart is put on
- MSG_RUNE_STONE_MAX_AMOUNT = 0x61b, ///< Cannot create Rune stone more than the maximum amount.
- MSG_SKILL_POINTS_LEFT_JOB1 = 0x61e, ///< You must consume all '%d' remaining points in your 1st Job tab.
- MSG_SKILL_POINTS_LEFT_JOB2 = 0x61f, ///< You must consume all '%d' remaining points in your 2nd Job tab. 1st Tab is already done.
- MSG_SKILL_ITEM_NOT_FOUND = 0x623, // FIXME[Haru]: This seems to be 0x622 in the msgstringtable files I found.
- MSG_SKILL_SUCCESS = 0x627, // FIXME[Haru]: This seems to be 0x626 in the msgstringtable files I found.
- MSG_SKILL_FAILURE = 0x628, // FIXME[Haru]: This seems to be 0x627 in the msgstringtable files I found.
- MSG_SKILL_ITEM_NEED_IDENTIFY = 0x62d, ///< Unable to use unchecked items as materials.
- MSG_ITEM_CANT_EQUIP_LVL = 0x6ed, // FIXME[Haru]: This seems to be 0x6ee in the msgstringtable files I found.
- MSG_ITEM_CANT_USE_LVL = 0x6ee, // FIXME[Haru]: This seems to be 0x6ef in the msgstringtable files I found.
- MSG_COOKING_LIST_FAIL = 0x625, // FIXME[Haru]: This might be a wrong message ID. Not sure what it should be.
- MSG_SECONDS_UNTIL_USE = 0x746, ///< %d seconds left until you can use
- MSG_NPC_WORK_IN_PROGRESS = 0x783, // FIXME[Haru]: This seems to be 0x784 in the msgstringtable files I found.
- MSG_REINS_CANT_USE_MOUNTED = 0x78b, // FIXME[Haru]: This seems to be 0x785 in the msgstringtalbe files I found.
+ MSG_ITEM_CANT_OBTAIN_WEIGHT = 0x034, ///< You cannot carry more items because you are overweight.
+ MSG_ITEM_NEED_STANDING = 0x297, ///< You cannot use this item while sitting.
+ MSG_MERCENARY_EXPIRED = 0x4f2, ///< The mercenary contract has expired.
+ MSG_MERCENARY_DIED = 0x4f3, ///< The mercenary has died.
+ MSG_MERCENARY_RELEASED = 0x4f4, ///< You have released the mercenary.
+ MSG_MERCENARY_ESCAPED = 0x4f5, ///< The mercenary has run away.
+ MSG_PARTY_MEMBER_NOT_SUMMONED = 0x4c5, ///< The party member was not summoned because you are not the party leader.
+ MSG_PARTY_NO_MEMBER_IN_MAP = 0x4c6, ///< There is no party member to summon in the current map.
+ MSG_SKILL_CANT_USE_AREA = 0x536, ///< This skill cannot be used within this area
+ MSG_ITEM_CANT_USE_AREA = 0x537, ///< This item cannot be used within this area.
+ MSG_EQUIP_NOT_PUBLIC = 0x54d, ///< This character's equipment information is not open to the public.
+ MSG_ITEM_NEED_MADO = 0x59b, ///< Item can only be used when Mado Gear is mounted.
+ MSG_ITEM_NEED_CART = 0x5ef, ///< Usable only when cart is put on
+ MSG_RUNE_STONE_MAX_AMOUNT = 0x61b, ///< Cannot create Rune stone more than the maximum amount.
+ MSG_SKILL_POINTS_LEFT_JOB1 = 0x61e, ///< You must consume all '%d' remaining points in your 1st Job tab.
+ MSG_SKILL_POINTS_LEFT_JOB2 = 0x61f, ///< You must consume all '%d' remaining points in your 2nd Job tab. 1st Tab is already done.
+ MSG_SKILL_ITEM_NOT_FOUND = 0x623, // FIXME[Haru]: This seems to be 0x622 in the msgstringtable files I found.
+ MSG_SKILL_SUCCESS = 0x627, // FIXME[Haru]: This seems to be 0x626 in the msgstringtable files I found.
+ MSG_SKILL_FAILURE = 0x628, // FIXME[Haru]: This seems to be 0x627 in the msgstringtable files I found.
+ MSG_SKILL_ITEM_NEED_IDENTIFY = 0x62d, ///< Unable to use unchecked items as materials.
+ MSG_ITEM_CANT_EQUIP_LVL = 0x6ed, // FIXME[Haru]: This seems to be 0x6ee in the msgstringtable files I found.
+ MSG_ITEM_CANT_USE_LVL = 0x6ee, // FIXME[Haru]: This seems to be 0x6ef in the msgstringtable files I found.
+ MSG_COOKING_LIST_FAIL = 0x625, // FIXME[Haru]: This might be a wrong message ID. Not sure what it should be.
+ MSG_SECONDS_UNTIL_USE = 0x746, ///< %d seconds left until you can use
+ MSG_NPC_WORK_IN_PROGRESS = 0x783, // FIXME[Haru]: This seems to be 0x784 in the msgstringtable files I found.
+ MSG_REINS_CANT_USE_MOUNTED = 0x78b, // FIXME[Haru]: This seems to be 0x785 in the msgstringtalbe files I found.
};
/**
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;
diff --git a/src/map/script.c b/src/map/script.c
index a6d3ac852..90c4c3b80 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -6690,9 +6690,10 @@ BUILDIN(warpchar) {
return true;
}
/*==========================================
- * Warpparty - [Fredzilla] [Paradox924X]
- * Syntax: warpparty "to_mapname",x,y,Party_ID,{"from_mapname"};
+ * Warpparty - [Fredzilla] [Paradox924X] [Jedzkie] [Dastgir]
+ * Syntax: warpparty("<to_mapname>", <x>, <y>, <party_id>, "<from_mapname>", <include_leader>)
* If 'from_mapname' is specified, only the party members on that map will be warped
+ * If 'include_leader' option is set to false, the leader will be warped too.
*------------------------------------------*/
BUILDIN(warpparty)
{
@@ -6702,78 +6703,84 @@ BUILDIN(warpparty)
int type;
int map_index;
int i;
+ bool include_leader = true;
- const char* str = script_getstr(st,2);
- int x = script_getnum(st,3);
- int y = script_getnum(st,4);
- int p_id = script_getnum(st,5);
+ const char* str = script_getstr(st, 2);
+ int x = script_getnum(st, 3);
+ int y = script_getnum(st, 4);
+ int p_id = script_getnum(st, 5);
const char* str2 = NULL;
- if ( script_hasdata(st,6) )
- str2 = script_getstr(st,6);
+
+ if (script_hasdata(st, 6))
+ str2 = script_getstr(st, 6);
+ if (script_hasdata(st, 7))
+ include_leader = script_getnum(st, 7);
p = party->search(p_id);
- if(!p)
+
+ if (p == NULL)
return true;
- type = ( strcmp(str,"Random")==0 ) ? 0
- : ( strcmp(str,"SavePointAll")==0 ) ? 1
- : ( strcmp(str,"SavePoint")==0 ) ? 2
- : ( strcmp(str,"Leader")==0 ) ? 3
+ type = (strcmp(str, "Random") == 0) ? 0
+ : (strcmp(str, "SavePointAll") == 0) ? 1
+ : (strcmp(str, "SavePoint") == 0) ? 2
+ : (strcmp(str, "Leader") == 0) ? 3
: 4;
- switch (type)
- {
- case 3:
- for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++);
- if (i == MAX_PARTY || !p->data[i].sd) //Leader not found / not online
- return true;
- pl_sd = p->data[i].sd;
- map_index = pl_sd->mapindex;
- x = pl_sd->bl.x;
- y = pl_sd->bl.y;
- break;
- case 4:
- map_index = script->mapindexname2id(st,str);
- break;
- case 2:
- //"SavePoint" uses save point of the currently attached player
- if (( sd = script->rid2sd(st) ) == NULL )
- return true;
- /* Fall through */
- default:
- map_index = 0;
- break;
+ switch (type) {
+ case 3:
+ ARR_FIND(0, MAX_PARTY, i, p->party.member[i].leader);
+ if (i == MAX_PARTY || !p->data[i].sd) // Leader not found / not online
+ return true;
+ pl_sd = p->data[i].sd;
+ map_index = pl_sd->mapindex;
+ x = pl_sd->bl.x;
+ y = pl_sd->bl.y;
+ break;
+ case 4:
+ map_index = script->mapindexname2id(st, str);
+ break;
+ case 2:
+ // "SavePoint" uses save point of the currently attached player
+ if ((sd = script->rid2sd(st)) == NULL)
+ return true;
+ /* Fall through */
+ default:
+ map_index = 0;
+ break;
}
for (i = 0; i < MAX_PARTY; i++) {
- if( !(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id )
+ if (!(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id)
continue;
- if( str2 && strcmp(str2, map->list[pl_sd->bl.m].name) != 0 )
+ if (str2 && strcmp(str2, map->list[pl_sd->bl.m].name) != 0)
continue;
- if( pc_isdead(pl_sd) )
+ if (pc_isdead(pl_sd))
continue;
- switch( type )
- {
- case 0: // Random
- if(!map->list[pl_sd->bl.m].flag.nowarp)
- pc->randomwarp(pl_sd,CLR_TELEPORT);
- break;
- case 1: // SavePointAll
- if(!map->list[pl_sd->bl.m].flag.noreturn)
- pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
- break;
- case 2: // SavePoint
- if(!map->list[pl_sd->bl.m].flag.noreturn)
- pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
- break;
- case 3: // Leader
- case 4: // m,x,y
- if(!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp)
- pc->setpos(pl_sd,map_index,x,y,CLR_TELEPORT);
- break;
+ if (include_leader == false && p->party.member[i].leader)
+ continue;
+
+ switch( type ) {
+ case 0: // Random
+ if (!map->list[pl_sd->bl.m].flag.nowarp)
+ pc->randomwarp(pl_sd, CLR_TELEPORT);
+ break;
+ case 1: // SavePointAll
+ if (!map->list[pl_sd->bl.m].flag.noreturn)
+ pc->setpos(pl_sd, pl_sd->status.save_point.map, pl_sd->status.save_point.x, pl_sd->status.save_point.y, CLR_TELEPORT);
+ break;
+ case 2: // SavePoint
+ if (!map->list[pl_sd->bl.m].flag.noreturn)
+ pc->setpos(pl_sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
+ break;
+ case 3: // Leader
+ case 4: // m,x,y
+ if (!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp)
+ pc->setpos(pl_sd, map_index, x, y, CLR_TELEPORT);
+ break;
}
}
@@ -9950,7 +9957,13 @@ BUILDIN(end) {
BUILDIN(checkoption)
{
int option;
- struct map_session_data *sd = script->rid2sd(st);
+ struct map_session_data *sd;
+
+ if (script_hasdata(st, 3))
+ sd = map->id2sd(script_getnum(st, 3));
+ else
+ sd = script->rid2sd(st);
+
if (sd == NULL)
return true;// no player attached, report source
@@ -9969,7 +9982,13 @@ BUILDIN(checkoption)
BUILDIN(checkoption1)
{
int opt1;
- struct map_session_data *sd = script->rid2sd(st);
+ struct map_session_data *sd;
+
+ if (script_hasdata(st, 3))
+ sd = map->id2sd(script_getnum(st, 3));
+ else
+ sd = script->rid2sd(st);
+
if (sd == NULL)
return true;// no player attached, report source
@@ -9988,7 +10007,13 @@ BUILDIN(checkoption1)
BUILDIN(checkoption2)
{
int opt2;
- struct map_session_data *sd = script->rid2sd(st);
+ struct map_session_data *sd;
+
+ if (script_hasdata(st, 3))
+ sd = map->id2sd(script_getnum(st, 3));
+ else
+ sd = script->rid2sd(st);
+
if (sd == NULL)
return true;// no player attached, report source
@@ -10012,7 +10037,13 @@ BUILDIN(setoption)
{
int option;
int flag = 1;
- struct map_session_data *sd = script->rid2sd(st);
+ struct map_session_data *sd;
+
+ if (script_hasdata(st, 4))
+ sd = map->id2sd(script_getnum(st, 4));
+ else
+ sd = script->rid2sd(st);
+
if (sd == NULL)
return true;// no player attached, report source
@@ -21593,6 +21624,67 @@ BUILDIN(useatcmd)
return true;
}
+BUILDIN(has_permission)
+{
+ struct map_session_data *sd;
+ enum e_pc_permission perm;
+
+ if (script_hasdata(st, 3)) {
+ sd = map->id2sd(script_getnum(st, 3));
+ } else {
+ sd = script->rid2sd(st);
+ }
+
+ if (sd == NULL) {
+ script_pushint(st, 0);
+ return false;
+ }
+
+ if (script_isstringtype(st, 2)) {
+ // to check for plugin permissions
+ int i = 0, j = -1;
+ const char *name = script_getstr(st, 2);
+ for (; i < pcg->permission_count; ++i) {
+ if (strcmp(pcg->permissions[i].name, name) == 0) {
+ j = i;
+ break;
+ }
+ }
+ if (j < 0) {
+ ShowError("script:has_permission: unknown permission: %s\n", name);
+ script_pushint(st, 0);
+ return false;
+ }
+ script_pushint(st, pc_has_permission(sd, pcg->permissions[j].permission));
+ return true;
+ }
+
+ // to ckeck for built-in permission
+ perm = script_getnum(st, 2);
+ script_pushint(st, pc_has_permission(sd, perm));
+ return true;
+}
+
+BUILDIN(can_use_command)
+{
+ struct map_session_data *sd;
+ const char *cmd = script_getstr(st, 2);
+
+ if (script_hasdata(st, 3)) {
+ sd = map->id2sd(script_getnum(st, 3));
+ } else {
+ sd = script->rid2sd(st);
+ }
+
+ if (sd == NULL) {
+ script_pushint(st, 0);
+ return false;
+ }
+
+ script_pushint(st, pc->can_use_command(sd, cmd));
+ return true;
+}
+
/* getrandgroupitem <container_item_id>,<quantity> */
BUILDIN(getrandgroupitem)
{
@@ -23118,7 +23210,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(warp,"sii?"),
BUILDIN_DEF(areawarp,"siiiisii??"),
BUILDIN_DEF(warpchar,"siii"), // [LuzZza]
- BUILDIN_DEF(warpparty,"siii?"), // [Fredzilla] [Paradox924X]
+ BUILDIN_DEF(warpparty,"siii??"), // [Fredzilla] [Paradox924X] [Jedzkie] [Dastgir]
BUILDIN_DEF(warpguild,"siii?"), // [Fredzilla]
BUILDIN_DEF(setlook,"ii"),
BUILDIN_DEF(changelook,"ii"), // Simulates but don't Store it
@@ -23198,8 +23290,8 @@ void script_parse_builtin(void) {
BUILDIN_DEF(setgroupid, "i?"),
BUILDIN_DEF(getgroupid,""),
BUILDIN_DEF(end,""),
- BUILDIN_DEF(checkoption,"i"),
- BUILDIN_DEF(setoption,"i?"),
+ BUILDIN_DEF(checkoption,"i?"),
+ BUILDIN_DEF(setoption,"i??"),
BUILDIN_DEF(setcart,"?"),
BUILDIN_DEF(checkcart,""),
BUILDIN_DEF(setfalcon,"?"),
@@ -23349,8 +23441,8 @@ void script_parse_builtin(void) {
BUILDIN_DEF(setnpcdir,"*"), // [4144]
BUILDIN_DEF(getnpcclass,"?"), // [4144]
BUILDIN_DEF(getmapxy,"rrri?"), //by Lorky [Lupus]
- BUILDIN_DEF(checkoption1,"i"),
- BUILDIN_DEF(checkoption2,"i"),
+ BUILDIN_DEF(checkoption1,"i?"),
+ BUILDIN_DEF(checkoption2,"i?"),
BUILDIN_DEF(guildgetexp,"i"),
BUILDIN_DEF(guildchangegm,"is"),
BUILDIN_DEF(logmes,"s"), //this command actls as MES but rints info into LOG file either SQL/TXT [Lupus]
@@ -23567,6 +23659,8 @@ void script_parse_builtin(void) {
BUILDIN_DEF(bindatcmd, "ss???"),
BUILDIN_DEF(unbindatcmd, "s"),
BUILDIN_DEF(useatcmd, "s"),
+ BUILDIN_DEF(has_permission, "v?"),
+ BUILDIN_DEF(can_use_command, "s?"),
/**
* Item bound [Xantara] [Akinari] [Mhalicot/Hercules]
@@ -23811,6 +23905,34 @@ void script_hardcoded_constants(void)
script->set_constant("BL_CHAR",BL_CHAR,false, false);
script->set_constant("BL_ALL",BL_ALL,false, false);
+ script->constdb_comment("Player permissions");
+ script->set_constant("PERM_TRADE", PC_PERM_TRADE, false, false);
+ script->set_constant("PERM_PARTY", PC_PERM_PARTY, false, false);
+ script->set_constant("PERM_ALL_SKILL", PC_PERM_ALL_SKILL, false, false);
+ script->set_constant("PERM_USE_ALL_EQUIPMENT", PC_PERM_USE_ALL_EQUIPMENT, false, false);
+ script->set_constant("PERM_SKILL_UNCONDITIONAL", PC_PERM_SKILL_UNCONDITIONAL, false, false);
+ script->set_constant("PERM_JOIN_ALL_CHAT", PC_PERM_JOIN_ALL_CHAT, false, false);
+ script->set_constant("PERM_NO_CHAT_KICK", PC_PERM_NO_CHAT_KICK, false, false);
+ script->set_constant("PERM_HIDE_SESSION", PC_PERM_HIDE_SESSION, false, false);
+ script->set_constant("PERM_RECEIVE_HACK_INFO", PC_PERM_RECEIVE_HACK_INFO, false, false);
+ script->set_constant("PERM_WARP_ANYWHERE", PC_PERM_WARP_ANYWHERE, false, false);
+ script->set_constant("PERM_VIEW_HPMETER", PC_PERM_VIEW_HPMETER, false, false);
+ script->set_constant("PERM_VIEW_EQUIPMENT", PC_PERM_VIEW_EQUIPMENT, false, false);
+ script->set_constant("PERM_USE_CHECK", PC_PERM_USE_CHECK, false, false);
+ script->set_constant("PERM_USE_CHANGEMAPTYPE", PC_PERM_USE_CHANGEMAPTYPE, false, false);
+ script->set_constant("PERM_USE_ALL_COMMANDS", PC_PERM_USE_ALL_COMMANDS, false, false);
+ script->set_constant("PERM_RECEIVE_REQUESTS", PC_PERM_RECEIVE_REQUESTS, false, false);
+ script->set_constant("PERM_SHOW_BOSS", PC_PERM_SHOW_BOSS, false, false);
+ script->set_constant("PERM_DISABLE_PVM", PC_PERM_DISABLE_PVM, false, false);
+ script->set_constant("PERM_DISABLE_PVP", PC_PERM_DISABLE_PVP, false, false);
+ script->set_constant("PERM_DISABLE_CMD_DEAD", PC_PERM_DISABLE_CMD_DEAD, false, false);
+ script->set_constant("PERM_HCHSYS_ADMIN", PC_PERM_HCHSYS_ADMIN, false, false);
+ script->set_constant("PERM_TRADE_BOUND", PC_PERM_TRADE_BOUND, false, false);
+ script->set_constant("PERM_DISABLE_PICK_UP", PC_PERM_DISABLE_PICK_UP, false, false);
+ script->set_constant("PERM_DISABLE_STORE", PC_PERM_DISABLE_STORE, false, false);
+ script->set_constant("PERM_DISABLE_EXP", PC_PERM_DISABLE_EXP, false, false);
+ script->set_constant("PERM_DISABLE_SKILL_USAGE", PC_PERM_DISABLE_SKILL_USAGE, false, false);
+
script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);