diff options
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 168 |
1 files changed, 126 insertions, 42 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 5fc4e3ddf..1dc032f7c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1320,7 +1320,7 @@ int pc_reg_received(struct map_session_data *sd) clif->pLoadEndAck(sd->fd, sd); } - if( sd->sc.option & OPTION_INVISIBLE ) { + if (pc_isinvisible(sd)) { sd->vd.class_ = INVISIBLE_CLASS; clif->message(sd->fd, msg_txt(11)); // Invisible: On // decrement the number of pvp players on the map @@ -1729,7 +1729,7 @@ int pc_disguise(struct map_session_data *sd, int class_) { if (class_ >= 0 && sd->disguise == class_) return 0; - if(sd->sc.option&OPTION_INVISIBLE) { //Character is invisible. Stealth class-change. [Skotlex] + if (pc_isinvisible(sd)) { //Character is invisible. Stealth class-change. [Skotlex] sd->disguise = class_; //viewdata is set on uncloaking. return 2; } @@ -3102,11 +3102,11 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->skillfixcastrate[i].id == type2) - sd->skillfixcastrate[i].val += val; + sd->skillfixcastrate[i].val -= val; else { sd->skillfixcastrate[i].id = type2; - sd->skillfixcastrate[i].val = val; + sd->skillfixcastrate[i].val -= val; } break; @@ -4474,7 +4474,7 @@ int pc_useitem(struct map_session_data *sd,int n) { } else {// not yet used item (all slots are initially empty) sd->item_delay[i].nameid = nameid; } - if( !(nameid == ITEMID_REINS_OF_MOUNT && sd->sc.option&(OPTION_WUGRIDER|OPTION_RIDING|OPTION_DRAGON|OPTION_MADOGEAR)) ) + if (!(nameid == ITEMID_REINS_OF_MOUNT && pc_hasmount(sd))) sd->item_delay[i].tick = tick + sd->inventory_data[n]->delay; } else {// should not happen ShowError("pc_useitem: Exceeded item delay array capacity! (nameid=%d, char_id=%d)\n", nameid, sd->status.char_id); @@ -4731,7 +4731,7 @@ void pc_bound_clear(struct map_session_data *sd, enum e_item_bound_type type) { ShowError("Helllo! You reached pc_bound_clear for IBT_ACCOUNT, unfortunately no scenario was expected for this!\n"); break; case IBT_GUILD: { - struct guild_storage *gstor = gstorage->id2storage(sd->status.guild_id); + struct guild_storage *gstor = idb_get(gstorage->db,sd->status.guild_id); for( i = 0; i < MAX_INVENTORY; i++ ){ if(sd->status.inventory[i].bound == type) { @@ -7639,6 +7639,10 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp) // Recovery Potion if( sd->sc.data[SC_HEALPLUS] ) hp += (int)(hp * sd->sc.data[SC_HEALPLUS]->val1/100.); + + // 2014 Halloween Event : Pumpkin Bonus + if ( sd->sc.data[SC_MTF_PUMPKIN] && itemid == ITEMID_PUMPKIN ) + hp += (int)(hp * sd->sc.data[SC_MTF_PUMPKIN]->val1/100); } if(sp) { bonus = 100 + (sd->battle_status.int_<<1) @@ -8149,48 +8153,111 @@ int pc_setcart(struct map_session_data *sd,int type) { return 0; } -/*========================================== - * Give player a falcon - *------------------------------------------*/ -int pc_setfalcon(TBL_PC* sd, int flag) +/* FIXME: These setter methods are inconsistent in their class/skill checks. + They should be changed so that they all either do or skip the checks.*/ + +/** + * Gives/removes a falcon. + * + * The target player needs the required skills in order to obtain a falcon. + * + * @param sd Target player. + * @param flag New state. + **/ +void pc_setfalcon(TBL_PC* sd, bool flag) { - if( flag ){ - if( pc->checkskill(sd,HT_FALCON)>0 ) // add falcon if he have the skill + if (flag) { + if (pc->checkskill(sd,HT_FALCON) > 0) // add falcon if he have the skill pc->setoption(sd,sd->sc.option|OPTION_FALCON); - } else if( pc_isfalcon(sd) ){ + } else if (pc_isfalcon(sd)) { pc->setoption(sd,sd->sc.option&~OPTION_FALCON); // remove falcon } - - return 0; } -/*========================================== - * Set player riding - *------------------------------------------*/ -int pc_setriding(TBL_PC* sd, int flag) +/** + * Mounts/dismounts a Peco or Gryphon. + * + * The target player needs the required skills in order to mount a peco. + * + * @param sd Target player. + * @param flag New state. + **/ +void pc_setridingpeco(TBL_PC* sd, bool flag) { - if( flag ){ - if( pc->checkskill(sd,KN_RIDING) > 0 ) // add peco + if (flag) { + if (pc->checkskill(sd, KN_RIDING)) pc->setoption(sd, sd->sc.option|OPTION_RIDING); - } else if( pc_isriding(sd) ){ - pc->setoption(sd, sd->sc.option&~OPTION_RIDING); + } else if (pc_isridingpeco(sd)) { + pc->setoption(sd, sd->sc.option&~OPTION_RIDING); } - - return 0; } /** - * Gives player a mado - * @param flag 1 Set mado + * Gives/removes a Mado Gear. + * + * The target player needs to be the correct class in order to obtain a mado gear. + * + * @param sd Target player. + * @param flag New state. **/ -void pc_setmadogear( struct map_session_data *sd, int flag ) { - if( flag ) { - if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) +void pc_setmadogear(struct map_session_data *sd, bool flag) +{ + if (flag) { + if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) pc->setoption(sd, sd->sc.option|OPTION_MADOGEAR); - } else if( pc_ismadogear(sd) ) + } else if (pc_ismadogear(sd)) { pc->setoption(sd, sd->sc.option&~OPTION_MADOGEAR); + } +} - return; +/** + * Mounts/dismounts a dragon. + * + * The target player needs the required skills in order to mount a dragon. + * + * @param sd Target player. + * @param type New state. This must be a valid OPTION_DRAGON* or 0. + **/ +void pc_setridingdragon(TBL_PC* sd, unsigned int type) +{ + if (type&OPTION_DRAGON) { + // Ensure only one dragon is set at a time. + if (type&OPTION_DRAGON1) + type = OPTION_DRAGON1; + else if (type&OPTION_DRAGON2) + type = OPTION_DRAGON2; + else if (type&OPTION_DRAGON3) + type = OPTION_DRAGON3; + else if (type&OPTION_DRAGON4) + type = OPTION_DRAGON4; + else if (type&OPTION_DRAGON5) + type = OPTION_DRAGON5; + else + type = OPTION_DRAGON1; + + if (pc->checkskill(sd, RK_DRAGONTRAINING)) + pc->setoption(sd, (sd->sc.option&~OPTION_DRAGON)|type); + } else if (pc_isridingdragon(sd)) { + pc->setoption(sd,sd->sc.option&~OPTION_DRAGON); // remove dragon + } +} + +/** + * Mounts/dismounts a wug. + * + * The target player needs the required skills in order to mount a wug. + * + * @param sd Target player. + * @param flag New state. + **/ +void pc_setridingwug(TBL_PC* sd, bool flag) +{ + if (flag) { + if (pc->checkskill(sd, RA_WUGRIDER) > 0) + pc->setoption(sd,sd->sc.option|OPTION_WUGRIDER); + } else if (pc_isridingwug(sd)) { + pc->setoption(sd,sd->sc.option&~OPTION_WUGRIDER); // remove wug + } } /** @@ -9116,8 +9183,15 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { //OnUnEquip script [Skotlex] if (sd->inventory_data[n]) { - if (sd->inventory_data[n]->unequip_script) - script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + 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 ) + script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + } + else + script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + } if(itemdb_isspecial(sd->status.inventory[n].card[0])) ; //No cards else { @@ -9127,8 +9201,16 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { continue; if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { - if( data->unequip_script ) - script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + 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 ) + script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + } + else + script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + } } } @@ -9203,7 +9285,7 @@ int pc_checkitem(struct map_session_data *sd) } if (sd->guild) { - struct guild_storage *guild_storage = gstorage->id2storage2(sd->guild->guild_id); + struct guild_storage *guild_storage = idb_get(gstorage->db,sd->guild->guild_id); if (guild_storage) { for( i = 0; i < MAX_GUILD_STORAGE; i++ ) { id = guild_storage->items[i].nameid; @@ -9284,8 +9366,8 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap) sd1=(struct map_session_data *)bl; sd2=va_arg(ap,struct map_session_data *); - if( sd1->sc.option&OPTION_INVISIBLE || sd2->sc.option&OPTION_INVISIBLE ) - {// cannot register pvp rank for hidden GMs + if (pc_isinvisible(sd1) ||pc_isinvisible(sd2)) { + // cannot register pvp rank for hidden GMs return 0; } @@ -9319,8 +9401,8 @@ int pc_calc_pvprank_timer(int tid, int64 tick, int id, intptr_t data) { return 0; sd->pvp_timer = INVALID_TIMER; - if( sd->sc.option&OPTION_INVISIBLE ) - {// do not calculate the pvp rank for a hidden GM + if (pc_isinvisible(sd)) { + // do not calculate the pvp rank for a hidden GM return 0; } @@ -10958,8 +11040,10 @@ void pc_defaults(void) { pc->setoption = pc_setoption; pc->setcart = pc_setcart; pc->setfalcon = pc_setfalcon; - pc->setriding = pc_setriding; + pc->setridingpeco = pc_setridingpeco; pc->setmadogear = pc_setmadogear; + pc->setridingdragon = pc_setridingdragon; + pc->setridingwug = pc_setridingwug; pc->changelook = pc_changelook; pc->equiplookall = pc_equiplookall; |