diff options
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 1297 |
1 files changed, 765 insertions, 532 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 241e0fbb3..ef70aad97 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -33,7 +33,7 @@ #include "elemental.h" #include "npc.h" // fake_nd #include "pet.h" // pet_unlocktarget() -#include "party.h" // party_search() +#include "party.h" // party->search() #include "guild.h" // guild->search(), guild_request_info() #include "script.h" // script_config #include "skill.h" @@ -96,7 +96,7 @@ int pc_class2idx(int class_) { return class_; } -inline int pc_get_group_level(struct map_session_data *sd) { +int pc_get_group_level(struct map_session_data *sd) { return sd->group_level; } @@ -104,7 +104,7 @@ static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data { struct map_session_data *sd; - if( (sd=(struct map_session_data *)map_id2sd(id)) == NULL || sd->bl.type!=BL_PC ) + if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; if(sd->invincible_timer != tid){ @@ -123,8 +123,8 @@ void pc_setinvincibletimer(struct map_session_data* sd, int val) { val += map[sd->bl.m].invincible_time_inc; if( sd->invincible_timer != INVALID_TIMER ) - delete_timer(sd->invincible_timer,pc_invincible_timer); - sd->invincible_timer = add_timer(gettick()+val,pc_invincible_timer,sd->bl.id,0); + iTimer->delete_timer(sd->invincible_timer,pc_invincible_timer); + sd->invincible_timer = iTimer->add_timer(iTimer->gettick()+val,pc_invincible_timer,sd->bl.id,0); } void pc_delinvincibletimer(struct map_session_data* sd) @@ -133,9 +133,9 @@ void pc_delinvincibletimer(struct map_session_data* sd) if( sd->invincible_timer != INVALID_TIMER ) { - delete_timer(sd->invincible_timer,pc_invincible_timer); + iTimer->delete_timer(sd->invincible_timer,pc_invincible_timer); sd->invincible_timer = INVALID_TIMER; - skill->unit_move(&sd->bl,gettick(),1); + skill->unit_move(&sd->bl,iTimer->gettick(),1); } } @@ -144,7 +144,7 @@ static int pc_spiritball_timer(int tid, unsigned int tick, int id, intptr_t data struct map_session_data *sd; int i; - if( (sd=(struct map_session_data *)map_id2sd(id)) == NULL || sd->bl.type!=BL_PC ) + if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; if( sd->spiritball <= 0 ) @@ -184,15 +184,15 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) if( sd->spiritball && sd->spiritball >= max ) { if(sd->spirit_timer[0] != INVALID_TIMER) - delete_timer(sd->spirit_timer[0],pc_spiritball_timer); + iTimer->delete_timer(sd->spirit_timer[0],pc_spiritball_timer); sd->spiritball--; if( sd->spiritball != 0 ) memmove(sd->spirit_timer+0, sd->spirit_timer+1, (sd->spiritball)*sizeof(int)); sd->spirit_timer[sd->spiritball] = INVALID_TIMER; } - tid = add_timer(gettick()+interval, pc_spiritball_timer, sd->bl.id, 0); - ARR_FIND(0, sd->spiritball, i, sd->spirit_timer[i] == INVALID_TIMER || DIFF_TICK(get_timer(tid)->tick, get_timer(sd->spirit_timer[i])->tick) < 0); + tid = iTimer->add_timer(iTimer->gettick()+interval, pc_spiritball_timer, sd->bl.id, 0); + ARR_FIND(0, sd->spiritball, i, sd->spirit_timer[i] == INVALID_TIMER || DIFF_TICK(iTimer->get_timer(tid)->tick, iTimer->get_timer(sd->spirit_timer[i])->tick) < 0); if( i != sd->spiritball ) memmove(sd->spirit_timer+i+1, sd->spirit_timer+i, (sd->spiritball-i)*sizeof(int)); sd->spirit_timer[i] = tid; @@ -226,7 +226,7 @@ int pc_delspiritball(struct map_session_data *sd,int count,int type) for(i=0;i<count;i++) { if(sd->spirit_timer[i] != INVALID_TIMER) { - delete_timer(sd->spirit_timer[i],pc_spiritball_timer); + iTimer->delete_timer(sd->spirit_timer[i],pc_spiritball_timer); sd->spirit_timer[i] = INVALID_TIMER; } } @@ -302,7 +302,7 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { // Get total HP of all Royal Guards in party. for( j = 0; j < i; j++ ) { - bsd = map_id2sd(b_sd[j]); + bsd = iMap->id2sd(b_sd[j]); if( bsd != NULL ) hp += status_get_hp(&bsd->bl); } @@ -313,7 +313,7 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { // If a Royal Guard have full HP, give more HP to others that haven't full HP. for( j = 0; j < i; j++ ) { - bsd = map_id2sd(b_sd[j]); + bsd = iMap->id2sd(b_sd[j]); if( bsd != NULL && (tmp_hp = hp - status_get_max_hp(&bsd->bl)) > 0 ) { extra_hp += tmp_hp; @@ -326,7 +326,7 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { for( j = 0; j < i; j++ ) { - bsd = map_id2sd(b_sd[j]); + bsd = iMap->id2sd(b_sd[j]); if( bsd != NULL ) { status_set_hp(&bsd->bl,hp,0); // Set hp @@ -415,7 +415,7 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { *------------------------------------------*/ static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd = map_id2sd(id); + struct map_session_data *sd = iMap->id2sd(id); if( sd == NULL ) return 0; if( tid != sd->rental_timer ) @@ -424,7 +424,7 @@ static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t return 0; } - pc_inventory_rentals(sd); + pc->inventory_rentals(sd); return 1; } @@ -432,7 +432,7 @@ int pc_inventory_rental_clear(struct map_session_data *sd) { if( sd->rental_timer != INVALID_TIMER ) { - delete_timer(sd->rental_timer, pc_inventory_rental_end); + iTimer->delete_timer(sd->rental_timer, pc_inventory_rental_end); sd->rental_timer = INVALID_TIMER; } @@ -457,7 +457,7 @@ void pc_inventory_rentals(struct map_session_data *sd) status_change_end(&sd->bl,SC_ALL_RIDING,INVALID_TIMER); } clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid); - pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER); + pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER); } else { expire_tick = (unsigned int)(sd->status.inventory[i].expire_time - time(NULL)) * 1000; clif->rental_time(sd->fd, sd->status.inventory[i].nameid, (int)(expire_tick / 1000)); @@ -467,7 +467,7 @@ void pc_inventory_rentals(struct map_session_data *sd) } if( c > 0 ) // min(next_tick,3600000) 1 hour each timer to keep announcing to the owner, and to avoid a but with rental time > 15 days - sd->rental_timer = add_timer(gettick() + min(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); + sd->rental_timer = iTimer->add_timer(iTimer->gettick() + min(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); else sd->rental_timer = INVALID_TIMER; } @@ -482,15 +482,15 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds) if( sd->rental_timer != INVALID_TIMER ) { const struct TimerData * td; - td = get_timer(sd->rental_timer); - if( DIFF_TICK(td->tick, gettick()) > tick ) + td = iTimer->get_timer(sd->rental_timer); + if( DIFF_TICK(td->tick, iTimer->gettick()) > tick ) { // Update Timer as this one ends first than the current one - pc_inventory_rental_clear(sd); - sd->rental_timer = add_timer(gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0); + pc->inventory_rental_clear(sd); + sd->rental_timer = iTimer->add_timer(iTimer->gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0); } } else - sd->rental_timer = add_timer(gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); + sd->rental_timer = iTimer->add_timer(iTimer->gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); } /** @@ -520,7 +520,7 @@ int pc_makesavestatus(struct map_session_data *sd) #endif if (sd->sc.data[SC_JAILED]) { //When Jailed, do not move last point. if(pc_isdead(sd)){ - pc_setrestartvalue(sd,0); + pc->setrestartvalue(sd,0); } else { sd->status.hp = sd->battle_status.hp; sd->status.sp = sd->battle_status.sp; @@ -532,7 +532,7 @@ int pc_makesavestatus(struct map_session_data *sd) } if(pc_isdead(sd)){ - pc_setrestartvalue(sd,0); + pc->setrestartvalue(sd,0); memcpy(&sd->status.last_point,&sd->status.save_point,sizeof(sd->status.last_point)); } else { sd->status.hp = sd->battle_status.hp; @@ -581,7 +581,7 @@ int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int lo sd->client_tick = client_tick; sd->state.active = 0; //to be set to 1 after player is fully authed and loaded. sd->bl.type = BL_PC; - sd->canlog_tick = gettick(); + sd->canlog_tick = iTimer->gettick(); //Required to prevent homunculus copuing a base speed of 0. sd->battle_status.speed = sd->base_status.speed = DEFAULT_WALK_SPEED; return 0; @@ -603,7 +603,7 @@ int pc_equippoint(struct map_session_data *sd,int n) 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 || + if(ep == EQP_HAND_R && (pc->checkskill(sd,AS_LEFT) > 0 || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN || (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO))//Kagerou and Oboro can dual wield daggers. [Rytech] return EQP_ARMS; } @@ -768,10 +768,10 @@ bool pc_can_Adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd return false; // Both parents need to be in the same party // Parents need to have their ring equipped - if( !pc_isequipped(p1_sd, WEDDING_RING_M) && !pc_isequipped(p1_sd, WEDDING_RING_F) ) + if( !pc->isequipped(p1_sd, WEDDING_RING_M) && !pc->isequipped(p1_sd, WEDDING_RING_F) ) return false; - if( !pc_isequipped(p2_sd, WEDDING_RING_M) && !pc_isequipped(p2_sd, WEDDING_RING_F) ) + if( !pc->isequipped(p2_sd, WEDDING_RING_M) && !pc->isequipped(p2_sd, WEDDING_RING_F) ) return false; // Already adopted a baby @@ -805,15 +805,15 @@ bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, int job, joblevel; unsigned int jobexp; - if( !pc_can_Adopt(p1_sd, p2_sd, b_sd) ) + if( !pc->can_Adopt(p1_sd, p2_sd, b_sd) ) return false; // Preserve current job levels and progress joblevel = b_sd->status.job_level; jobexp = b_sd->status.job_exp; - job = pc_mapid2jobid(b_sd->class_|JOBL_BABY, b_sd->status.sex); - if( job != -1 && !pc_jobchange(b_sd, job, 0) ) + job = pc->mapid2jobid(b_sd->class_|JOBL_BABY, b_sd->status.sex); + if( job != -1 && !pc->jobchange(b_sd, job, 0) ) { // Success, proceed to configure parents and baby skills p1_sd->status.child = b_sd->status.char_id; p2_sd->status.child = b_sd->status.char_id; @@ -827,12 +827,12 @@ bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, clif->updatestatus(b_sd, SP_JOBEXP); // Baby Skills - pc_skill(b_sd, WE_BABY, 1, 0); - pc_skill(b_sd, WE_CALLPARENT, 1, 0); + pc->skill(b_sd, WE_BABY, 1, 0); + pc->skill(b_sd, WE_CALLPARENT, 1, 0); // Parents Skills - pc_skill(p1_sd, WE_CALLBABY, 1, 0); - pc_skill(p2_sd, WE_CALLBABY, 1, 0); + pc->skill(p1_sd, WE_CALLBABY, 1, 0); + pc->skill(p2_sd, WE_CALLBABY, 1, 0); return true; } @@ -868,20 +868,20 @@ int pc_isequip(struct map_session_data *sd,int n) if (sd->sc.count) { - if(item->equip & EQP_ARMS && item->type == IT_WEAPON && sd->sc.data[SC_STRIPWEAPON]) // Also works with left-hand weapons [DracoRPG] + if(item->equip & EQP_ARMS && item->type == IT_WEAPON && sd->sc.data[SC_NOEQUIPWEAPON]) // Also works with left-hand weapons [DracoRPG] return 0; - if(item->equip & EQP_SHIELD && item->type == IT_ARMOR && sd->sc.data[SC_STRIPSHIELD]) + if(item->equip & EQP_SHIELD && item->type == IT_ARMOR && sd->sc.data[SC_NOEQUIPSHIELD]) return 0; - if(item->equip & EQP_ARMOR && sd->sc.data[SC_STRIPARMOR]) + if(item->equip & EQP_ARMOR && sd->sc.data[SC_NOEQUIPARMOR]) return 0; - if(item->equip & EQP_HEAD_TOP && sd->sc.data[SC_STRIPHELM]) + if(item->equip & EQP_HEAD_TOP && sd->sc.data[SC_NOEQUIPHELM]) return 0; - if(item->equip & EQP_ACC && sd->sc.data[SC__STRIPACCESSORY]) + if(item->equip & EQP_ACC && sd->sc.data[SC__STRIPACCESSARY]) return 0; if(item->equip && sd->sc.data[SC_KYOUGAKU]) return 0; - if (sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_SUPERNOVICE) { + if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SUPERNOVICE) { //Spirit of Super Novice equip bonuses. [Skotlex] if (sd->status.base_level > 90 && item->equip & EQP_HELM) return 1; //Can equip all helms @@ -918,7 +918,7 @@ int pc_isequip(struct map_session_data *sd,int n) *------------------------------------------*/ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) { int i; - unsigned long tick = gettick(); + unsigned long tick = iTimer->gettick(); uint32 ip = session[sd->fd]->client_addr; sd->login_id2 = login_id2; @@ -935,7 +935,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim } //Set the map-server used job id. [Skotlex] - i = pc_jobid2mapid(sd->status.class_); + i = pc->jobid2mapid(sd->status.class_); if (i == -1) { //Invalid class? ShowError("pc_authok: Invalid class %d for player %s (%d:%d). Class was changed to novice.\n", sd->status.class_, sd->status.name, sd->status.account_id, sd->status.char_id); sd->status.class_ = JOB_NOVICE; @@ -1005,10 +1005,10 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim if (!(battle_config.display_skill_fail&2)) sd->state.showdelay = 1; - pc_setinventorydata(sd); + pc->setinventorydata(sd); pc_setequipindex(sd); - if( sd->status.option & OPTION_INVISIBLE && !pc_can_use_command(sd, "@hide") ) + if( sd->status.option & OPTION_INVISIBLE && !pc->can_use_command(sd, "@hide") ) sd->status.option &=~ OPTION_INVISIBLE; status_change_init(&sd->bl); @@ -1035,6 +1035,8 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim sd->queues = NULL; sd->queues_count = 0; + sd->state.dialog = 0; + // Event Timers for( i = 0; i < MAX_EVENTTIMER; i++ ) sd->eventtimer[i] = INVALID_TIMER; @@ -1045,11 +1047,11 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim sd->hate_mob[i] = -1; //warp player - if ((i=pc_setpos(sd,sd->status.last_point.map, sd->status.last_point.x, sd->status.last_point.y, CLR_OUTSIGHT)) != 0) { + if ((i=pc->setpos(sd,sd->status.last_point.map, sd->status.last_point.x, sd->status.last_point.y, CLR_OUTSIGHT)) != 0) { ShowError ("Last_point_map %s - id %d not found (error code %d)\n", mapindex_id2name(sd->status.last_point.map), sd->status.last_point.map, i); // try warping to a default map instead (church graveyard) - if (pc_setpos(sd, mapindex_name2id(MAP_PRONTERA), 273, 354, CLR_OUTSIGHT) != 0) { + if (pc->setpos(sd, mapindex_name2id(MAP_PRONTERA), 273, 354, CLR_OUTSIGHT) != 0) { // if we fail again clif->authfail_fd(sd->fd, 0); return false; @@ -1090,7 +1092,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim if (expiration_time != 0) { // don't display if it's unlimited or unknow value char tmpstr[1024]; strftime(tmpstr, sizeof(tmpstr) - 1, msg_txt(501), localtime(&expiration_time)); // "Your account time limit is: %d-%m-%Y %H:%M:%S." - clif->wis_message(sd->fd, wisp_server_name, tmpstr, strlen(tmpstr)+1); + clif->wis_message(sd->fd, iMap->wisp_server_name, tmpstr, strlen(tmpstr)+1); } /** @@ -1107,7 +1109,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim /** * Check if player have any item cooldowns on **/ - pc_itemcd_do(sd,true); + pc->itemcd_do(sd,true); /* [Ind/Hercules] */ sd->sc_display = NULL; @@ -1181,7 +1183,7 @@ int pc_reg_received(struct map_session_data *sd) for(i=0;i<MAX_PC_FEELHATE;i++) { //for now - someone need to make reading from txt/sql if ((j = pc_readglobalreg(sd,sg_info[i].feel_var))!=0) { sd->feel_map[i].index = j; - sd->feel_map[i].m = map_mapindex2mapid(j); + sd->feel_map[i].m = iMap->mapindex2mapid(j); } else { sd->feel_map[i].index = 0; sd->feel_map[i].m = -1; @@ -1189,7 +1191,7 @@ int pc_reg_received(struct map_session_data *sd) sd->hate_mob[i] = pc_readglobalreg(sd,sg_info[i].hate_var)-1; } - if ((i = pc_checkskill(sd,RG_PLAGIARISM)) > 0) { + if ((i = pc->checkskill(sd,RG_PLAGIARISM)) > 0) { sd->cloneskill_id = pc_readglobalreg(sd,"CLONE_SKILL"); if (sd->cloneskill_id > 0 && (idx = skill->get_index(sd->cloneskill_id))) { sd->status.skill[idx].id = sd->cloneskill_id; @@ -1199,7 +1201,7 @@ int pc_reg_received(struct map_session_data *sd) sd->status.skill[idx].flag = SKILL_FLAG_PLAGIARIZED; } } - if ((i = pc_checkskill(sd,SC_REPRODUCE)) > 0) { + if ((i = pc->checkskill(sd,SC_REPRODUCE)) > 0) { sd->reproduceskill_id = pc_readglobalreg(sd,"REPRODUCE_SKILL"); if( sd->reproduceskill_id > 0 && (idx = skill->get_index(sd->reproduceskill_id))) { sd->status.skill[idx].id = sd->reproduceskill_id; @@ -1215,7 +1217,7 @@ int pc_reg_received(struct map_session_data *sd) sd->state.active = 1; if (sd->status.party_id) - party_member_joined(sd); + party->member_joined(sd); if (sd->status.guild_id) guild->member_joined(sd); @@ -1231,12 +1233,12 @@ int pc_reg_received(struct map_session_data *sd) if( sd->status.ele_id > 0 ) intif_elemental_request(sd->status.ele_id, sd->status.char_id); - map_addiddb(&sd->bl); - map_delnickdb(sd->status.char_id, sd->status.name); + iMap->addiddb(&sd->bl); + iMap->delnickdb(sd->status.char_id, sd->status.name); if (!chrif_auth_finished(sd)) ShowError("pc_reg_received: Failed to properly remove player %d:%d from logging db!\n", sd->status.account_id, sd->status.char_id); - pc_load_combo(sd); + pc->load_combo(sd); status_calc_pc(sd,1); chrif_scdata_request(sd->status.account_id, sd->status.char_id); @@ -1249,7 +1251,7 @@ int pc_reg_received(struct map_session_data *sd) clif->pLoadEndAck(sd->fd, sd); } - pc_inventory_rentals(sd); + pc->inventory_rentals(sd); if( sd->sc.option & OPTION_INVISIBLE ) { sd->vd.class_ = INVISIBLE_CLASS; @@ -1258,7 +1260,7 @@ int pc_reg_received(struct map_session_data *sd) map[sd->bl.m].users_pvp--; if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking - delete_timer( sd->pvp_timer, pc_calc_pvprank_timer ); + iTimer->delete_timer( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } clif->changeoption(&sd->bl); @@ -1277,7 +1279,7 @@ static int pc_calc_skillpoint(struct map_session_data* sd) nullpo_ret(sd); for(i=1;i<MAX_SKILL;i++){ - if( (skill_lv = pc_checkskill2(sd,i)) > 0) { + if( (skill_lv = pc->checkskill2(sd,i)) > 0) { inf2 = skill_db[i].inf2; if((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) && !(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) //Do not count wedding/link skills. [Skotlex] @@ -1303,14 +1305,14 @@ int pc_calc_skilltree(struct map_session_data *sd) int c=0; nullpo_ret(sd); - i = pc_calc_skilltree_normalize_job(sd); - c = pc_mapid2jobid(i, sd->status.sex); + i = pc->calc_skilltree_normalize_job(sd); + c = pc->mapid2jobid(i, sd->status.sex); if( c == -1 ) { //Unable to normalize job?? ShowError("pc_calc_skilltree: Unable to normalize job %d for character %s (%d:%d)\n", i, sd->status.name, sd->status.account_id, sd->status.char_id); return 1; } - c = pc_class2idx(c); + c = pc->class2idx(c); for( i = 0; i < MAX_SKILL; i++ ) { if( sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED && sd->status.skill[i].flag != SKILL_FLAG_PERM_GRANTED ) //Don't touch these @@ -1336,7 +1338,7 @@ int pc_calc_skilltree(struct map_session_data *sd) sd->status.skill[i].flag = SKILL_FLAG_PERMANENT; } - if( sd->sc.count && sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_BARDDANCER && skill_db[i].nameid >= DC_HUMMING && skill_db[i].nameid <= DC_SERVICEFORYOU ) + if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill_db[i].nameid >= DC_HUMMING && skill_db[i].nameid <= DC_SERVICEFORYOU ) { //Enable Bard/Dancer spirit linked skills. if( sd->status.sex ) { //Link dancer skills to bard. @@ -1408,7 +1410,7 @@ int pc_calc_skilltree(struct map_session_data *sd) else if (sd->status.skill[idx2].flag >= SKILL_FLAG_REPLACED_LV_0) //Real lerned level k = sd->status.skill[idx2].flag - SKILL_FLAG_REPLACED_LV_0; else - k = pc_checkskill2(sd,idx2); + k = pc->checkskill2(sd,idx2); if (k < skill_tree[c][i].need[j].lv) { f = 0; break; @@ -1425,7 +1427,7 @@ int pc_calc_skilltree(struct map_session_data *sd) if(!sd->status.skill[idx].lv && ( (inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) || inf2&INF2_WEDDING_SKILL || - (inf2&INF2_SPIRIT_SKILL && !sd->sc.data[SC_SPIRIT]) + (inf2&INF2_SPIRIT_SKILL && !sd->sc.data[SC_SOULLINK]) )) continue; //Cannot be learned via normal means. Note this check DOES allows raising already known skills. @@ -1441,7 +1443,7 @@ int pc_calc_skilltree(struct map_session_data *sd) } while(flag); // - if( c > 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && sd->status.skill_point == 0 && pc_famerank(sd->status.char_id, MAPID_TAEKWON) ) + if( c > 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && sd->status.skill_point == 0 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) ) { /* Taekwon Ranger Bonus Skill Tree ============================================ @@ -1457,7 +1459,7 @@ int pc_calc_skilltree(struct map_session_data *sd) if( sd->status.skill[idx].id == 0 ) { sd->status.skill[idx].id = id; sd->status.skill[idx].flag = SKILL_FLAG_TEMPORARY; // So it is not saved, and tagged as a "bonus" skill. - } else if( id != NV_BASIC) { + } else if( id != NV_BASIC ) { sd->status.skill[idx].flag = SKILL_FLAG_REPLACED_LV_0 + sd->status.skill[idx].lv; // Remember original level } @@ -1477,13 +1479,13 @@ static void pc_check_skilltree(struct map_session_data *sd, int skill_id) if(battle_config.skillfree) return; //Function serves no purpose if this is set - i = pc_calc_skilltree_normalize_job(sd); - c = pc_mapid2jobid(i, sd->status.sex); + i = pc->calc_skilltree_normalize_job(sd); + c = pc->mapid2jobid(i, sd->status.sex); if (c == -1) { //Unable to normalize job?? ShowError("pc_check_skilltree: Unable to normalize job %d for character %s (%d:%d)\n", i, sd->status.name, sd->status.account_id, sd->status.char_id); return; } - c = pc_class2idx(c); + c = pc->class2idx(c); do { flag = 0; for( i = 0; i < MAX_SKILL_TREE && (id=skill_tree[c][i].id)>0; i++ ) { @@ -1500,7 +1502,7 @@ static void pc_check_skilltree(struct map_session_data *sd, int skill_id) else if( sd->status.skill[idx2].flag >= SKILL_FLAG_REPLACED_LV_0) //Real lerned level k = sd->status.skill[idx2].flag - SKILL_FLAG_REPLACED_LV_0; else - k = pc_checkskill2(sd,idx2); + k = pc->checkskill2(sd,idx2); if( k < skill_tree[c][i].need[j].lv ) { f = 0; break; @@ -1516,7 +1518,7 @@ static void pc_check_skilltree(struct map_session_data *sd, int skill_id) if( !sd->status.skill[idx].lv && ( (j&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) || j&INF2_WEDDING_SKILL || - (j&INF2_SPIRIT_SKILL && !sd->sc.data[SC_SPIRIT]) + (j&INF2_SPIRIT_SKILL && !sd->sc.data[SC_SOULLINK]) ) ) continue; //Cannot be learned via normal means. @@ -1555,7 +1557,7 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) skill_point = pc_calc_skillpoint(sd); - novice_skills = max_level[pc_class2idx(JOB_NOVICE)][1] - 1; + novice_skills = max_level[pc->class2idx(JOB_NOVICE)][1] - 1; // limit 1st class and above to novice job levels if(skill_point < novice_skills) @@ -1572,7 +1574,7 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) { // if neither 2nd nor 3rd jobchange levels are known, we have to assume a default for 2nd if (!sd->change_level_3rd) - sd->change_level_2nd = max_level[pc_class2idx(pc_mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex))][1]; + sd->change_level_2nd = max_level[pc->class2idx(pc->mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex))][1]; else sd->change_level_2nd = 1 + skill_point + sd->status.skill_point - (sd->status.job_level - 1) @@ -1618,7 +1620,7 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) *------------------------------------------ * 1: overweight 50% * 2: overweight 90% - * It's assumed that SC_WEIGHT50 and SC_WEIGHT90 are only started/stopped here. + * It's assumed that SC_WEIGHTOVER50 and SC_WEIGHTOVER90 are only started/stopped here. */ int pc_updateweightstatus(struct map_session_data *sd) { @@ -1627,7 +1629,7 @@ int pc_updateweightstatus(struct map_session_data *sd) nullpo_retr(1, sd); - old_overweight = (sd->sc.data[SC_WEIGHT90]) ? 2 : (sd->sc.data[SC_WEIGHT50]) ? 1 : 0; + old_overweight = (sd->sc.data[SC_WEIGHTOVER90]) ? 2 : (sd->sc.data[SC_WEIGHTOVER50]) ? 1 : 0; new_overweight = (pc_is90overweight(sd)) ? 2 : (pc_is50overweight(sd)) ? 1 : 0; if( old_overweight == new_overweight ) @@ -1635,15 +1637,15 @@ int pc_updateweightstatus(struct map_session_data *sd) // stop old status change if( old_overweight == 1 ) - status_change_end(&sd->bl, SC_WEIGHT50, INVALID_TIMER); + status_change_end(&sd->bl, SC_WEIGHTOVER50, INVALID_TIMER); else if( old_overweight == 2 ) - status_change_end(&sd->bl, SC_WEIGHT90, INVALID_TIMER); + status_change_end(&sd->bl, SC_WEIGHTOVER90, INVALID_TIMER); // start new status change if( new_overweight == 1 ) - sc_start(&sd->bl, SC_WEIGHT50, 100, 0, 0); + sc_start(&sd->bl, SC_WEIGHTOVER50, 100, 0, 0); else if( new_overweight == 2 ) - sc_start(&sd->bl, SC_WEIGHT90, 100, 0, 0); + sc_start(&sd->bl, SC_WEIGHTOVER90, 100, 0, 0); // update overweight status sd->regen.state.overweight = new_overweight; @@ -1911,7 +1913,7 @@ int pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,c } else { // Logout / Unequipped an item with an activated bonus - delete_timer(autobonus[i].active,pc_endautobonus); + iTimer->delete_timer(autobonus[i].active,pc->endautobonus); autobonus[i].active = INVALID_TIMER; } } @@ -1939,7 +1941,7 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) script_run_autobonus(autobonus->other_script,sd->bl.id,sd->equip_index[j]); } - autobonus->active = add_timer(gettick()+autobonus->duration, pc_endautobonus, sd->bl.id, (intptr_t)autobonus); + autobonus->active = iTimer->add_timer(iTimer->gettick()+autobonus->duration, pc->endautobonus, sd->bl.id, (intptr_t)autobonus); sd->state.autobonus |= autobonus->pos; status_calc_pc(sd,0); @@ -1948,7 +1950,7 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd = map_id2sd(id); + struct map_session_data *sd = iMap->id2sd(id); struct s_autobonus *autobonus = (struct s_autobonus *)data; nullpo_ret(sd); @@ -2068,12 +2070,13 @@ int pc_bonus(struct map_session_data *sd,int type,int val) break; case SP_BASE_ATK: if(sd->state.lr_flag != 2) { - //#ifdef RENEWAL - // sd->bonus.eatk += val; - //#else +#ifdef RENEWAL + sd->bonus.eatk += val; + clif->updatestatus(sd,SP_ATK2); +#else bonus = status->batk + val; status->batk = cap_value(bonus, 0, USHRT_MAX); - //#endif +#endif } break; case SP_DEF1: @@ -2429,7 +2432,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) case SP_INTRAVISION: // Maya Purple Card effect allowing to see Hiding/Cloaking people [DracoRPG] if(sd->state.lr_flag != 2) { sd->special_state.intravision = 1; - clif->status_change(&sd->bl, SI_INTRAVISION, 1, 0, 0, 0, 0); + clif->status_change(&sd->bl, SI_CLAIRVOYANCE, 1, 0, 0, 0, 0); } break; case SP_NO_KNOCKBACK: @@ -3554,7 +3557,7 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip) // remember the card id to insert nameid = sd->status.inventory[idx_card].nameid; - if( pc_delitem(sd,idx_card,1,1,0,LOG_TYPE_OTHER) == 1 ) + if( pc->delitem(sd,idx_card,1,1,0,LOG_TYPE_OTHER) == 1 ) {// failed clif->insert_card(sd,idx_equip,idx_card,1); } @@ -3579,9 +3582,9 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip) int pc_modifybuyvalue(struct map_session_data *sd,int orig_value) { int skill,val = orig_value,rate1 = 0,rate2 = 0; - if((skill=pc_checkskill(sd,MC_DISCOUNT))>0) // merchant discount + if((skill=pc->checkskill(sd,MC_DISCOUNT))>0) // merchant discount rate1 = 5+skill*2-((skill==10)? 1:0); - if((skill=pc_checkskill(sd,RG_COMPULSION))>0) // rogue discount + if((skill=pc->checkskill(sd,RG_COMPULSION))>0) // rogue discount rate2 = 5+skill*4; if(rate1 < rate2) rate1 = rate2; if(rate1) @@ -3598,7 +3601,7 @@ int pc_modifybuyvalue(struct map_session_data *sd,int orig_value) int pc_modifysellvalue(struct map_session_data *sd,int orig_value) { int skill,val = orig_value,rate = 0; - if((skill=pc_checkskill(sd,MC_OVERCHARGE))>0) //OverCharge + if((skill=pc->checkskill(sd,MC_OVERCHARGE))>0) //OverCharge rate = 5+skill*2-((skill==10)? 1:0); if(rate) val = (int)((double)orig_value*(double)(100+rate)/100.); @@ -3887,7 +3890,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l if( i >= MAX_INVENTORY ) { - i = pc_search_inventory(sd,0); + i = pc->search_inventory(sd,0); if( i < 0 ) return 4; @@ -3910,17 +3913,17 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l clif->updatestatus(sd,SP_WEIGHT); //Auto-equip if(data->flag.autoequip) - pc_equipitem(sd, i, data->equip); + pc->equipitem(sd, i, data->equip); /* rental item check */ if( item_data->expire_time ) { if( time(NULL) > item_data->expire_time ) { clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid); - pc_delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER); + pc->delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER); } else { int seconds = (int)( item_data->expire_time - time(NULL) ); clif->rental_time(sd->fd, sd->status.inventory[i].nameid, seconds); - pc_inventory_rental_add(sd, seconds); + pc->inventory_rental_add(sd, seconds); } } @@ -3950,7 +3953,7 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reas sd->weight -= sd->inventory_data[n]->weight*amount ; if( sd->status.inventory[n].amount <= 0 ){ if(sd->status.inventory[n].equip) - pc_unequipitem(sd,n,3); + pc->unequipitem(sd,n,3); memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0])); sd->inventory_data[n] = NULL; } @@ -3982,7 +3985,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) sd->status.inventory[n].amount <= 0 || sd->status.inventory[n].amount < amount || sd->state.trading || sd->state.vending || - !sd->inventory_data[n] //pc_delitem would fail on this case. + !sd->inventory_data[n] //pc->delitem would fail on this case. ) return 0; @@ -3992,16 +3995,16 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) return 0; //Can't drop items in nodrop mapflag maps. } - if( !pc_candrop(sd,&sd->status.inventory[n]) ) + if( !pc->candrop(sd,&sd->status.inventory[n]) ) { clif->message (sd->fd, msg_txt(263)); return 0; } - if (!map_addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2)) + if (!iMap->addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2)) return 0; - pc_delitem(sd, n, amount, 1, 0, LOG_TYPE_PICKDROP_PLAYER); + pc->delitem(sd, n, amount, 1, 0, LOG_TYPE_PICKDROP_PLAYER); clif->dropitem(sd, n, amount); return 1; } @@ -4015,7 +4018,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) { int flag=0; - unsigned int tick = gettick(); + unsigned int tick = iTimer->gettick(); struct map_session_data *first_sd = NULL,*second_sd = NULL,*third_sd = NULL; struct party_data *p=NULL; @@ -4026,11 +4029,11 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) return 0; // Distance is too far if (sd->status.party_id) - p = party_search(sd->status.party_id); + p = party->search(sd->status.party_id); if(fitem->first_get_charid > 0 && fitem->first_get_charid != sd->status.char_id) { - first_sd = map_charid2sd(fitem->first_get_charid); + first_sd = iMap->charid2sd(fitem->first_get_charid); if(DIFF_TICK(tick,fitem->first_get_tick) < 0) { if (!(p && p->party.item&1 && first_sd && first_sd->status.party_id == sd->status.party_id @@ -4040,7 +4043,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) else if(fitem->second_get_charid > 0 && fitem->second_get_charid != sd->status.char_id) { - second_sd = map_charid2sd(fitem->second_get_charid); + second_sd = iMap->charid2sd(fitem->second_get_charid); if(DIFF_TICK(tick, fitem->second_get_tick) < 0) { if(!(p && p->party.item&1 && ((first_sd && first_sd->status.party_id == sd->status.party_id) || @@ -4051,7 +4054,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) else if(fitem->third_get_charid > 0 && fitem->third_get_charid != sd->status.char_id) { - third_sd = map_charid2sd(fitem->third_get_charid); + third_sd = iMap->charid2sd(fitem->third_get_charid); if(DIFF_TICK(tick,fitem->third_get_tick) < 0) { if(!(p && p->party.item&1 && ((first_sd && first_sd->status.party_id == sd->status.party_id) || @@ -4065,7 +4068,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) } //This function takes care of giving the item to whoever should have it, considering party-share options. - if ((flag = party_share_loot(p,sd,&fitem->item_data, fitem->first_get_charid))) { + if ((flag = party->share_loot(p,sd,&fitem->item_data, fitem->first_get_charid))) { clif->additem(sd,0,0,flag); return 1; } @@ -4073,7 +4076,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) //Display pickup animation. pc_stop_attack(sd); clif->takeitem(&sd->bl,&fitem->bl); - map_clearflooritem(&fitem->bl); + iMap->clearflooritem(&fitem->bl); return 1; } @@ -4101,7 +4104,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) if( !item->script ) //if it has no script, you can't really consume it! return 0; - if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) { + if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc->get_group_level(sd) < item->item_usage.override) ) { clif->msgtable(sd->fd,664); //clif->colormes(sd->fd,COLOR_WHITE,msg_txt(1474)); return 0; // You cannot use this item while sitting. @@ -4120,7 +4123,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) case 12212: // Giant Fly Wing if( map[sd->bl.m].flag.noteleport || map_flag_gvg(sd->bl.m) ) { - clif->skill_teleportmessage(sd,0); + clif->skill_mapinfomessage(sd,0); return 0; } case 602: // ButterFly Wing @@ -4148,7 +4151,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; case 12210: // Bubble Gum case 12264: // Comp Bubble Gum - if( sd->sc.data[SC_ITEMBOOST] ) + if( sd->sc.data[SC_CASH_RECEIVEITEM] ) return 0; break; case 12208: // Battle Manual @@ -4158,11 +4161,11 @@ int pc_isUseitem(struct map_session_data *sd,int n) case 14532: // Battle_Manual25 case 14533: // Battle_Manual100 case 14545: // Battle_Manual300 - if( sd->sc.data[SC_EXPBOOST] ) + if( sd->sc.data[SC_CASH_PLUSEXP] ) return 0; break; case 14592: // JOB_Battle_Manual - if( sd->sc.data[SC_JEXPBOOST] ) + if( sd->sc.data[SC_CASH_PLUSONLYJOBEXP] ) return 0; break; @@ -4175,7 +4178,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) case 12243: // Mercenary's Berserk Potion if( sd->md == NULL || sd->md->db == NULL ) return 0; - if (sd->md->sc.data[SC_BERSERK] || sd->md->sc.data[SC_SATURDAYNIGHTFEVER] || sd->md->sc.data[SC__BLOODYLUST]) + if (sd->md->sc.data[SC_BERSERK] || sd->md->sc.data[SC_SATURDAY_NIGHT_FEVER] || sd->md->sc.data[SC__BLOODYLUST]) return 0; if( nameid == 12242 && sd->md->db->lv < 40 ) return 0; @@ -4246,7 +4249,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) *------------------------------------------*/ int pc_useitem(struct map_session_data *sd,int n) { - unsigned int tick = gettick(); + unsigned int tick = iTimer->gettick(); int amount, nameid, i; struct script_code *script; @@ -4266,7 +4269,7 @@ int pc_useitem(struct map_session_data *sd,int n) if( !pc_isUseitem(sd,n) ) return 0; - // Store information for later use before it is lost (via pc_delitem) [Paradox924X] + // Store information for later use before it is lost (via pc->delitem) [Paradox924X] nameid = sd->inventory_data[n]->nameid; if (nameid != ITEMID_NAUTHIZ && sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT && sd->sc.opt1 != OPT1_BURNING) @@ -4279,7 +4282,8 @@ int pc_useitem(struct map_session_data *sd,int n) sd->sc.data[SC_HIDING] || sd->sc.data[SC__SHADOWFORM] || sd->sc.data[SC__MANHOLE] || - sd->sc.data[SC_KAGEHUMI] || + sd->sc.data[SC_KG_KAGEHUMI] || + sd->sc.data[SC_WHITEIMPRISON] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOITEM) )) return 0; @@ -4313,16 +4317,7 @@ int pc_useitem(struct map_session_data *sd,int n) if( sd->item_delay[i].nameid ) {// found if( DIFF_TICK(sd->item_delay[i].tick, tick) > 0 ) { int e_tick = DIFF_TICK(sd->item_delay[i].tick, tick)/1000; - char e_msg[100]; - if( e_tick > 99 ) - sprintf(e_msg,"Item Failed. [%s] is cooling down. wait %.1f minutes.", - itemdb_jname(sd->status.inventory[n].nameid), - (double)e_tick / 60); - else - sprintf(e_msg,"Item Failed. [%s] is cooling down. wait %d seconds.", - itemdb_jname(sd->status.inventory[n].nameid), - e_tick+1); - clif->colormes(sd->fd,COLOR_RED,e_msg); + clif->msgtable_num(sd->fd, 0x746, e_tick + 1); // [%d] seconds left until you can use return 0; // Delay has not expired yet } } else {// not yet used item (all slots are initially empty) @@ -4346,7 +4341,7 @@ int pc_useitem(struct map_session_data *sd,int n) if( map[sd->bl.m].zone->disabled_items[i] == nameid ) { if( battle_config.item_restricted_consumption_type ) { clif->useitemack(sd,n,sd->status.inventory[n].amount-1,true); - pc_delitem(sd,n,1,1,0,LOG_TYPE_CONSUME); + pc->delitem(sd,n,1,1,0,LOG_TYPE_CONSUME); } return 0; } @@ -4365,15 +4360,15 @@ int pc_useitem(struct map_session_data *sd,int n) else { if( sd->status.inventory[n].expire_time == 0 ) { clif->useitemack(sd,n,amount-1,true); - pc_delitem(sd,n,1,1,0,LOG_TYPE_CONSUME); // Rental Usable Items are not deleted until expiration + pc->delitem(sd,n,1,1,0,LOG_TYPE_CONSUME); // Rental Usable Items are not deleted until expiration } else clif->useitemack(sd,n,0,false); } 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)) + 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 - if (sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_ROGUE) + if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_ROGUE) potion_flag = 3; //Even more effective potions. } @@ -4410,7 +4405,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun return 1; } - if( !itemdb_cancartstore(item_data, pc_get_group_level(sd)) ) + if( !itemdb_cancartstore(item_data, pc->get_group_level(sd)) ) { // Check item trade restrictions [Skotlex] clif->message (sd->fd, msg_txt(264)); return 1; @@ -4505,8 +4500,8 @@ int pc_putitemtocart(struct map_session_data *sd,int idx,int amount) if( item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending ) return 1; - if( pc_cart_additem(sd,item_data,amount,LOG_TYPE_NONE) == 0 ) - return pc_delitem(sd,idx,amount,0,5,LOG_TYPE_NONE); + if( pc->cart_additem(sd,item_data,amount,LOG_TYPE_NONE) == 0 ) + return pc->delitem(sd,idx,amount,0,5,LOG_TYPE_NONE); return 1; } @@ -4533,7 +4528,7 @@ int pc_cartitem_amount(struct map_session_data* sd, int idx, int amount) /*========================================== * Retrieve an item at index idx from cart. * Return: - * 0 = player not found or (FIXME) succes (from pc_cart_delitem) + * 0 = player not found or (FIXME) succes (from pc->cart_delitem) * 1 = failure *------------------------------------------*/ int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount) @@ -4550,8 +4545,8 @@ int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount) if(item_data->nameid==0 || amount < 1 || item_data->amount<amount || sd->state.vending ) return 1; - if((flag = pc_additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0) - return pc_cart_delitem(sd,idx,amount,0,LOG_TYPE_NONE); + if((flag = pc->additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0) + return pc->cart_delitem(sd,idx,amount,0,LOG_TYPE_NONE); clif->additem(sd,0,0,flag); return 1; @@ -4634,7 +4629,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil tmp_item.nameid = itemid; tmp_item.amount = 1; tmp_item.identify = itemdb_isidentified2(data); - flag = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER); + flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER); //TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise? md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more @@ -4681,13 +4676,13 @@ int pc_steal_coin(struct map_session_data *sd,struct block_list *target) return 0; // FIXME: This formula is either custom or outdated. - skill = pc_checkskill(sd,RG_STEALCOIN)*10; + skill = pc->checkskill(sd,RG_STEALCOIN)*10; rate = skill + (sd->status.base_level - md->level)*3 + sd->battle_status.dex*2 + sd->battle_status.luk*2; if(rnd()%1000 < rate) { int amount = md->level*10 + rnd()%100; - pc_getzeny(sd, amount, LOG_TYPE_STEAL, NULL); + pc->getzeny(sd, amount, LOG_TYPE_STEAL, NULL); md->state.steal_coin_flag = 1; return 1; } @@ -4712,10 +4707,10 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } if( pc_isdead(sd) ) { //Revive dead people before warping them - pc_setstand(sd); - pc_setrestartvalue(sd,1); + pc->setstand(sd); + pc->setrestartvalue(sd,1); } - m = map_mapindex2mapid(mapindex); + m = iMap->mapindex2mapid(mapindex); if( map[m].flag.src4instance ) { struct party_data *p; @@ -4734,7 +4729,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y stop = true; } } - if ( !stop && sd->status.party_id && (p = party_search(sd->status.party_id)) && p->instances ) { + if ( !stop && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) { for( i = 0; i < p->instances; i++ ) { ARR_FIND(0, instances[p->instance[i]].num_map, j, map[instances[p->instance[i]].map[j]].instance_src_map == m && !map[instances[p->instance[i]].map[j]].cName); if( j != instances[p->instance[i]].num_map ) @@ -4769,17 +4764,17 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y for( i = 0; i < sd->queues_count; i++ ) { struct hQueue *queue; if( (queue = script->queue(sd->queues[i])) && queue->onMapChange[0] != '\0' ) { - pc_setregstr(sd, add_str("QMapChangeTo"), map[m].name); + pc->setregstr(sd, add_str("QMapChangeTo"), map[m].name); npc_event(sd, queue->onMapChange, 0); } } if( map[m].cell == (struct mapcell *)0xdeadbeaf ) - map_cellfromcache(&map[m]); + iMap->cellfromcache(&map[m]); if (sd->sc.count) { // Cancel some map related stuff. if (sd->sc.data[SC_JAILED]) return 1; //You may not get out! - status_change_end(&sd->bl, SC_BOSSMAPINFO, INVALID_TIMER); + status_change_end(&sd->bl, SC_CASH_BOSS_ALARM, INVALID_TIMER); status_change_end(&sd->bl, SC_WARM, INVALID_TIMER); status_change_end(&sd->bl, SC_SUN_COMFORT, INVALID_TIMER); status_change_end(&sd->bl, SC_MOON_COMFORT, INVALID_TIMER); @@ -4788,8 +4783,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if (sd->sc.data[SC_KNOWLEDGE]) { struct status_change_entry *sce = sd->sc.data[SC_KNOWLEDGE]; if (sce->timer != INVALID_TIMER) - delete_timer(sce->timer, status_change_timer); - sce->timer = add_timer(gettick() + skill->get_time(SG_KNOWLEDGE, sce->val1), status_change_timer, sd->bl.id, SC_KNOWLEDGE); + iTimer->delete_timer(sce->timer, status_change_timer); + sce->timer = iTimer->add_timer(iTimer->gettick() + skill->get_time(SG_KNOWLEDGE, sce->val1), status_change_timer, sd->bl.id, SC_KNOWLEDGE); } status_change_end(&sd->bl, SC_PROPERTYWALK, INVALID_TIMER); status_change_end(&sd->bl, SC_CLOAKING, INVALID_TIMER); @@ -4797,12 +4792,12 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } 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 ] ) ) + pc->unequipitem( sd , sd->equip_index[ i ] , 2 ); } if (battle_config.clear_unit_onwarp&BL_PC) skill->clear_unitgroup(&sd->bl); - party_send_dot_remove(sd); //minimap dot fix [Kevin] + party->send_dot_remove(sd); //minimap dot fix [Kevin] guild->send_dot_remove(sd); bg_send_dot_remove(sd); if (sd->regen.state.gc) @@ -4823,7 +4818,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y uint32 ip; uint16 port; //if can't find any map-servers, just abort setting position. - if(!sd->mapindex || map_mapname2ipport(mapindex,&ip,&port)) + if(!sd->mapindex || iMap->mapname2ipport(mapindex,&ip,&port)) return 2; if (sd->npc_id) @@ -4834,7 +4829,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y sd->mapindex = mapindex; sd->bl.x=x; sd->bl.y=y; - pc_clean_skilltree(sd); + pc->clean_skilltree(sd); chrif_save(sd,2); chrif_changemapserver(sd, ip, (short)port); @@ -4853,10 +4848,10 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y do { x=rnd()%(map[m].xs-2)+1; y=rnd()%(map[m].ys-2)+1; - } while(map_getcell(m,x,y,CELL_CHKNOPASS)); + } while(iMap->getcell(m,x,y,CELL_CHKNOPASS)); } - if (sd->state.vending && map_getcell(m,x,y,CELL_CHKNOVENDING)) { + if (sd->state.vending && iMap->getcell(m,x,y,CELL_CHKNOVENDING)) { clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell." vending->close(sd); } @@ -4907,7 +4902,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y * Warp player sd to random location on current map. * May fail if no walkable cell found (1000 attempts). * Return: - * 0 = fail or FIXME success (from pc_setpos) + * 0 = fail or FIXME success (from pc->setpos) * x(1|2) = fail *------------------------------------------*/ int pc_randomwarp(struct map_session_data *sd, clr_type type) @@ -4925,10 +4920,10 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) do{ x=rnd()%(map[m].xs-2)+1; y=rnd()%(map[m].ys-2)+1; - }while(map_getcell(m,x,y,CELL_CHKNOPASS) && (i++)<1000 ); + }while(iMap->getcell(m,x,y,CELL_CHKNOPASS) && (i++)<1000 ); if (i < 1000) - return pc_setpos(sd,map[sd->bl.m].index,x,y,type); + return pc->setpos(sd,map[sd->bl.m].index,x,y,type); return 0; } @@ -4945,7 +4940,7 @@ int pc_memo(struct map_session_data* sd, int pos) // check mapflags if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { - clif->skill_teleportmessage(sd, 1); // "Saved point cannot be memorized." + clif->skill_mapinfomessage(sd, 1); // "Saved point cannot be memorized." return 0; } @@ -4954,7 +4949,7 @@ int pc_memo(struct map_session_data* sd, int pos) return 0; // invalid input // check required skill level - skill = pc_checkskill(sd, AL_WARP); + skill = pc->checkskill(sd, AL_WARP); if( skill < 1 ) { clif->skill_memomessage(sd,2); // "You haven't learned Warp." return 0; @@ -5036,21 +5031,24 @@ int pc_checkallowskill(struct map_session_data *sd) { const enum sc_type scw_list[] = { SC_TWOHANDQUICKEN, - SC_ONEHAND, + SC_ONEHANDQUICKEN, SC_AURABLADE, SC_PARRYING, SC_SPEARQUICKEN, SC_ADRENALINE, SC_ADRENALINE2, SC_DANCING, - SC_GATLINGFEVER, + SC_GS_GATLINGFEVER, +#ifdef RENEWAL + SC_EDP, +#endif SC_FEARBREEZE }; const enum sc_type scs_list[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, - SC_REFLECTDAMAGE + SC_LG_REFLECTDAMAGE }; int i; nullpo_ret(sd); @@ -5067,9 +5065,9 @@ int pc_checkallowskill(struct map_session_data *sd) status_change_end(&sd->bl, scw_list[i], INVALID_TIMER); } - if(sd->sc.data[SC_SPURT] && sd->status.weapon) + if(sd->sc.data[SC_STRUP] && sd->status.weapon) // Spurt requires bare hands (feet, in fact xD) - status_change_end(&sd->bl, SC_SPURT, INVALID_TIMER); + status_change_end(&sd->bl, SC_STRUP, INVALID_TIMER); if(sd->status.shield <= 0) { // Skills requiring a shield for (i = 0; i < ARRAYLENGTH(scs_list); i++) @@ -5600,7 +5598,7 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) struct map_session_data *sd; struct block_list *tbl; - sd = map_id2sd(id); + sd = iMap->id2sd(id); nullpo_ret(sd); if (sd->followtimer != tid){ @@ -5610,11 +5608,11 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) } sd->followtimer = INVALID_TIMER; - tbl = map_id2bl(sd->followtarget); + tbl = iMap->id2bl(sd->followtarget); if (tbl == NULL || pc_isdead(sd) || status_isdead(tbl)) { - pc_stop_following(sd); + pc->stop_following(sd); return 0; } @@ -5627,9 +5625,9 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) if (!check_distance_bl(&sd->bl, tbl, 5)) unit_walktobl(&sd->bl, tbl, 5, 0); } else - pc_setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT); + pc->setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT); } - sd->followtimer = add_timer( + sd->followtimer = iTimer->add_timer( tick + 1000, // increase time a bit to loosen up map's load pc_follow_timer, sd->bl.id, 0); return 0; @@ -5640,7 +5638,7 @@ int pc_stop_following (struct map_session_data *sd) nullpo_ret(sd); if (sd->followtimer != INVALID_TIMER) { - delete_timer(sd->followtimer,pc_follow_timer); + iTimer->delete_timer(sd->followtimer,pc_follow_timer); sd->followtimer = INVALID_TIMER; } sd->followtarget = -1; @@ -5653,20 +5651,20 @@ int pc_stop_following (struct map_session_data *sd) int pc_follow(struct map_session_data *sd,int target_id) { - struct block_list *bl = map_id2bl(target_id); + struct block_list *bl = iMap->id2bl(target_id); if (bl == NULL /*|| bl->type != BL_PC*/) return 1; if (sd->followtimer != INVALID_TIMER) - pc_stop_following(sd); + pc->stop_following(sd); sd->followtarget = target_id; - pc_follow_timer(INVALID_TIMER, gettick(), sd->bl.id, 0); + pc_follow_timer(INVALID_TIMER, iTimer->gettick(), sd->bl.id, 0); return 0; } int pc_checkbaselevelup(struct map_session_data *sd) { - unsigned int next = pc_nextbaseexp(sd); + unsigned int next = pc->nextbaseexp(sd); if (!next || sd->status.base_exp < next) return 0; @@ -5677,11 +5675,11 @@ int pc_checkbaselevelup(struct map_session_data *sd) { if(!battle_config.multi_level_up && sd->status.base_exp > next-1) sd->status.base_exp = next-1; - next = pc_gets_status_point(sd->status.base_level); + next = pc->gets_status_point(sd->status.base_level); sd->status.base_level ++; sd->status.status_point += next; - } while ((next=pc_nextbaseexp(sd)) > 0 && sd->status.base_exp >= next); + } while ((next=pc->nextbaseexp(sd)) > 0 && sd->status.base_exp >= next); if (battle_config.pet_lv_rate && sd->pd) //<Skotlex> update pet's level status_calc_pet(sd->pd,0); @@ -5709,9 +5707,9 @@ int pc_checkbaselevelup(struct map_session_data *sd) { npc_script_event(sd, NPCE_BASELVUP); //LORDALFA - LVLUPEVENT if(sd->status.party_id) - party_send_levelup(sd); + party->send_levelup(sd); - pc_baselevelchanged(sd); + pc->baselevelchanged(sd); return 1; } @@ -5721,7 +5719,7 @@ void pc_baselevelchanged(struct map_session_data *sd) { for( i = 0; i < EQI_MAX; i++ ) { if( sd->equip_index[i] >= 0 ) { if( sd->inventory_data[ sd->equip_index[i] ]->elvmax && sd->status.base_level > (unsigned int)sd->inventory_data[ sd->equip_index[i] ]->elvmax ) - pc_unequipitem(sd, sd->equip_index[i], 3); + pc->unequipitem(sd, sd->equip_index[i], 3); } } #endif @@ -5729,7 +5727,7 @@ void pc_baselevelchanged(struct map_session_data *sd) { } int pc_checkjoblevelup(struct map_session_data *sd) { - unsigned int next = pc_nextjobexp(sd); + unsigned int next = pc->nextjobexp(sd); nullpo_ret(sd); if(!next || sd->status.job_exp < next) @@ -5744,7 +5742,7 @@ int pc_checkjoblevelup(struct map_session_data *sd) sd->status.job_level ++; sd->status.skill_point ++; - } while ((next=pc_nextjobexp(sd)) > 0 && sd->status.job_exp >= next); + } while ((next=pc->nextjobexp(sd)) > 0 && sd->status.job_exp >= next); clif->updatestatus(sd,SP_JOBLEVEL); clif->updatestatus(sd,SP_JOBEXP); @@ -5752,8 +5750,8 @@ int pc_checkjoblevelup(struct map_session_data *sd) clif->updatestatus(sd,SP_SKILLPOINT); status_calc_pc(sd,0); clif->misceffect(&sd->bl,1); - if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd)) - clif->status_change(&sd->bl,SI_DEVIL, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL. + if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) + clif->status_change(&sd->bl,SI_DEVIL1, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL. npc_script_event(sd, NPCE_JOBLVUP); return 1; @@ -5775,13 +5773,13 @@ static void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsi (int)(status_get_lv(src) - sd->status.base_level) >= 20) bonus += 15; // pk_mode additional exp if monster >20 levels [Valaris] - if (sd->sc.data[SC_EXPBOOST]) - bonus += sd->sc.data[SC_EXPBOOST]->val1; + if (sd->sc.data[SC_CASH_PLUSEXP]) + bonus += sd->sc.data[SC_CASH_PLUSEXP]->val1; *base_exp = (unsigned int) cap_value(*base_exp + (double)*base_exp * bonus/100., 1, UINT_MAX); - if (sd->sc.data[SC_JEXPBOOST]) - bonus += sd->sc.data[SC_JEXPBOOST]->val1; + if (sd->sc.data[SC_CASH_PLUSONLYJOBEXP]) + bonus += sd->sc.data[SC_CASH_PLUSONLYJOBEXP]->val1; *job_exp = (unsigned int) cap_value(*job_exp + (double)*job_exp * bonus/100., 1, UINT_MAX); @@ -5807,8 +5805,8 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int if(src) pc_calcexp(sd, &base_exp, &job_exp, src); - nextb = pc_nextbaseexp(sd); - nextj = pc_nextjobexp(sd); + nextb = pc->nextbaseexp(sd); + nextj = pc->nextjobexp(sd); if(sd->state.showexp || battle_config.max_exp_gain_rate){ if (nextb > 0) @@ -5834,22 +5832,22 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int //Cap exp to the level up requirement of the previous level when you are at max level, otherwise cap at UINT_MAX (this is required for some S. Novice bonuses). [Skotlex] if (base_exp) { - nextb = nextb?UINT_MAX:pc_thisbaseexp(sd); + nextb = nextb?UINT_MAX:pc->thisbaseexp(sd); if(sd->status.base_exp > nextb - base_exp) sd->status.base_exp = nextb; else sd->status.base_exp += base_exp; - pc_checkbaselevelup(sd); + pc->checkbaselevelup(sd); clif->updatestatus(sd,SP_BASEEXP); } if (job_exp) { - nextj = nextj?UINT_MAX:pc_thisjobexp(sd); + nextj = nextj?UINT_MAX:pc->thisjobexp(sd); if(sd->status.job_exp > nextj - job_exp) sd->status.job_exp = nextj; else sd->status.job_exp += job_exp; - pc_checkjoblevelup(sd); + pc->checkjoblevelup(sd); clif->updatestatus(sd,SP_JOBEXP); } @@ -5872,12 +5870,12 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int *------------------------------------------*/ unsigned int pc_maxbaselv(struct map_session_data *sd) { - return max_level[pc_class2idx(sd->status.class_)][0]; + return max_level[pc->class2idx(sd->status.class_)][0]; } unsigned int pc_maxjoblv(struct map_session_data *sd) { - return max_level[pc_class2idx(sd->status.class_)][1]; + return max_level[pc->class2idx(sd->status.class_)][1]; } /*========================================== @@ -5889,19 +5887,19 @@ unsigned int pc_nextbaseexp(struct map_session_data *sd) { nullpo_ret(sd); - if(sd->status.base_level>=pc_maxbaselv(sd) || sd->status.base_level<=0) + if(sd->status.base_level>=pc->maxbaselv(sd) || sd->status.base_level<=0) return 0; - return exp_table[pc_class2idx(sd->status.class_)][0][sd->status.base_level-1]; + return exp_table[pc->class2idx(sd->status.class_)][0][sd->status.base_level-1]; } //Base exp needed for this level. unsigned int pc_thisbaseexp(struct map_session_data *sd) { - if(sd->status.base_level>pc_maxbaselv(sd) || sd->status.base_level<=1) + if(sd->status.base_level>pc->maxbaselv(sd) || sd->status.base_level<=1) return 0; - return exp_table[pc_class2idx(sd->status.class_)][0][sd->status.base_level-2]; + return exp_table[pc->class2idx(sd->status.class_)][0][sd->status.base_level-2]; } @@ -5917,17 +5915,17 @@ unsigned int pc_nextjobexp(struct map_session_data *sd) { nullpo_ret(sd); - if(sd->status.job_level>=pc_maxjoblv(sd) || sd->status.job_level<=0) + if(sd->status.job_level>=pc->maxjoblv(sd) || sd->status.job_level<=0) return 0; - return exp_table[pc_class2idx(sd->status.class_)][1][sd->status.job_level-1]; + return exp_table[pc->class2idx(sd->status.class_)][1][sd->status.job_level-1]; } //Job exp needed for this level. unsigned int pc_thisjobexp(struct map_session_data *sd) { - if(sd->status.job_level>pc_maxjoblv(sd) || sd->status.job_level<=1) + if(sd->status.job_level>pc->maxjoblv(sd) || sd->status.job_level<=1) return 0; - return exp_table[pc_class2idx(sd->status.class_)][1][sd->status.job_level-2]; + return exp_table[pc->class2idx(sd->status.class_)][1][sd->status.job_level-2]; } /// Returns the value of the specified stat. @@ -6018,7 +6016,7 @@ int pc_statusup(struct map_session_data* sd, int type) nullpo_ret(sd); // check conditions - need = pc_need_status_point(sd,type,1); + need = pc->need_status_point(sd,type,1); if( type < SP_STR || type > SP_LUK || need < 0 || need > sd->status.status_point ) { clif->statusupack(sd,type,0,0); @@ -6040,7 +6038,7 @@ int pc_statusup(struct map_session_data* sd, int type) status_calc_pc(sd,0); // update increase cost indicator - if( need != pc_need_status_point(sd,type,1) ) + if( need != pc->need_status_point(sd,type,1) ) clif->updatestatus(sd, SP_USTR + type-SP_STR); // update statpoint count @@ -6071,7 +6069,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val) return 1; } - need = pc_need_status_point(sd,type,1); + need = pc->need_status_point(sd,type,1); // set new value max = pc_maxparameter(sd); @@ -6080,7 +6078,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val) status_calc_pc(sd,0); // update increase cost indicator - if( need != pc_need_status_point(sd,type,1) ) + if( need != pc->need_status_point(sd,type,1) ) clif->updatestatus(sd, SP_USTR + type-SP_STR); // update stat value @@ -6121,8 +6119,8 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { sd->status.skill_point--; if( !skill_db[index].inf ) status_calc_pc(sd,0); // Only recalculate for passive skills. - else if( sd->status.skill_point == 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->status.char_id, MAPID_TAEKWON) ) - pc_calc_skilltree(sd); // Required to grant all TK Ranger skills. + else if( sd->status.skill_point == 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) ) + pc->calc_skilltree(sd); // Required to grant all TK Ranger skills. else pc_check_skilltree(sd, skill_id); // Check if a new skill can Lvlup @@ -6132,6 +6130,19 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { clif->updatestatus(sd,SP_CARTINFO); if (!pc_has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown clif->skillinfoblock(sd); + }else if( battle_config.skillup_limit ){ + int pts = 0, i, id; + for(i = 0; i < MAX_SKILL_TREE && (id=skill_tree[pc_class2idx(sd->status.class_)][i].id) > 0 ; i++){ + int inf2 = skill->get_inf2(id); + if ( inf2&INF2_QUEST_SKILL || (inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) || id == NV_BASIC ) + continue; + if( sd->status.skill[id].id && sd->status.skill[id].flag == SKILL_FLAG_PERMANENT ) + pts += pc_checkskill(sd, id); + } + if( pts < sd->change_level_2nd ) + clif->msg_value(sd, 0x61E, sd->change_level_2nd-pts); + else if( pts < (sd->change_level_3rd + sd->change_level_2nd) ) + clif->msg_value(sd, 0x61F, sd->change_level_3rd - (pts - sd->change_level_2nd)); } return 0; @@ -6171,8 +6182,8 @@ int pc_allskillup(struct map_session_data *sd) } } else { int inf2; - for(i=0;i < MAX_SKILL_TREE && (id=skill_tree[pc_class2idx(sd->status.class_)][i].id)>0;i++){ - int idx = skill_tree[pc_class2idx(sd->status.class_)][i].idx; + for(i=0;i < MAX_SKILL_TREE && (id=skill_tree[pc->class2idx(sd->status.class_)][i].id)>0;i++){ + int idx = skill_tree[pc->class2idx(sd->status.class_)][i].idx; inf2 = skill_db[idx].inf2; if ( (inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) || @@ -6202,7 +6213,7 @@ int pc_resetlvl(struct map_session_data* sd,int type) nullpo_ret(sd); if (type != 3) //Also reset skills - pc_resetskill(sd, 0); + pc->resetskill(sd, 0); if(type == 1){ sd->status.skill_point=0; @@ -6222,8 +6233,8 @@ int pc_resetlvl(struct map_session_data* sd,int type) if(sd->status.class_ == JOB_NOVICE_HIGH) { sd->status.status_point=100; // not 88 [celest] // give platinum skills upon changing - pc_skill(sd,142,1,0); - pc_skill(sd,143,1,0); + pc->skill(sd,142,1,0); + pc->skill(sd,143,1,0); } } @@ -6268,12 +6279,12 @@ int pc_resetlvl(struct map_session_data* sd,int type) 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); + if(!pc->isequip(sd,sd->equip_index[i])) + pc->unequipitem(sd,sd->equip_index[i],2); } if ((type == 1 || type == 2 || type == 3) && sd->status.party_id) - party_send_levelup(sd); + party->send_levelup(sd); status_calc_pc(sd,0); clif->skillinfoblock(sd); @@ -6301,12 +6312,12 @@ int pc_resetstate(struct map_session_data* sd) else { int add=0; - add += pc_need_status_point(sd, SP_STR, 1-pc_getstat(sd, SP_STR)); - add += pc_need_status_point(sd, SP_AGI, 1-pc_getstat(sd, SP_AGI)); - add += pc_need_status_point(sd, SP_VIT, 1-pc_getstat(sd, SP_VIT)); - add += pc_need_status_point(sd, SP_INT, 1-pc_getstat(sd, SP_INT)); - add += pc_need_status_point(sd, SP_DEX, 1-pc_getstat(sd, SP_DEX)); - add += pc_need_status_point(sd, SP_LUK, 1-pc_getstat(sd, SP_LUK)); + add += pc->need_status_point(sd, SP_STR, 1-pc_getstat(sd, SP_STR)); + add += pc->need_status_point(sd, SP_AGI, 1-pc_getstat(sd, SP_AGI)); + add += pc->need_status_point(sd, SP_VIT, 1-pc_getstat(sd, SP_VIT)); + add += pc->need_status_point(sd, SP_INT, 1-pc_getstat(sd, SP_INT)); + add += pc->need_status_point(sd, SP_DEX, 1-pc_getstat(sd, SP_DEX)); + add += pc->need_status_point(sd, SP_LUK, 1-pc_getstat(sd, SP_LUK)); sd->status.status_point+=add; } @@ -6364,35 +6375,35 @@ int pc_resetskill(struct map_session_data* sd, int flag) /** * It has been confirmed on official server that when you reset skills with a ranked tweakwon your skills are not reset (because you have all of them anyway) **/ - if( (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->status.char_id, MAPID_TAEKWON) ) + if( (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) ) return 0; - if( pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd) ) //Remove perma blindness due to skill-reset. [Skotlex] - clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL); + if( pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd) ) //Remove perma blindness due to skill-reset. [Skotlex] + clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL1); i = sd->sc.option; - if( i&OPTION_RIDING && (!pc_checkskill(sd, KN_RIDING) || (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) ) + if( i&OPTION_RIDING && (!pc->checkskill(sd, KN_RIDING) || (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) ) i &= ~OPTION_RIDING; - if( i&OPTION_FALCON && pc_checkskill(sd, HT_FALCON) ) + if( i&OPTION_FALCON && pc->checkskill(sd, HT_FALCON) ) i &= ~OPTION_FALCON; - if( i&OPTION_DRAGON && pc_checkskill(sd, RK_DRAGONTRAINING) ) + if( i&OPTION_DRAGON && pc->checkskill(sd, RK_DRAGONTRAINING) ) i &= ~OPTION_DRAGON; - if( i&OPTION_WUG && pc_checkskill(sd, RA_WUGMASTERY) ) + if( i&OPTION_WUG && pc->checkskill(sd, RA_WUGMASTERY) ) i &= ~OPTION_WUG; - if( i&OPTION_WUGRIDER && pc_checkskill(sd, RA_WUGRIDER) ) + if( i&OPTION_WUGRIDER && pc->checkskill(sd, RA_WUGRIDER) ) i &= ~OPTION_WUGRIDER; if( i&OPTION_MADOGEAR && ( sd->class_&MAPID_THIRDMASK ) == MAPID_MECHANIC ) i &= ~OPTION_MADOGEAR; #ifndef NEW_CARTS - if( i&OPTION_CART && pc_checkskill(sd, MC_PUSHCART) ) + if( i&OPTION_CART && pc->checkskill(sd, MC_PUSHCART) ) i &= ~OPTION_CART; #else if( sd->sc.data[SC_PUSH_CART] ) - pc_setcart(sd, 0); + pc->setcart(sd, 0); #endif if( i != sd->sc.option ) - pc_setoption(sd, i); + pc->setoption(sd, i); - if( homun_alive(sd->hd) && pc_checkskill(sd, AM_CALLHOMUN) ) + if( homun_alive(sd->hd) && pc->checkskill(sd, AM_CALLHOMUN) ) homun->vaporize(sd, 0); } @@ -6542,19 +6553,19 @@ void pc_respawn(struct map_session_data* sd, clr_type clrtype) if( sd->bg_id && bg_member_respawn(sd) ) return; // member revived by battleground - pc_setstand(sd); - pc_setrestartvalue(sd,3); - if( pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, clrtype) ) + pc->setstand(sd); + pc->setrestartvalue(sd,3); + if( pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, clrtype) ) clif->resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet. } static int pc_respawn_timer(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd = map_id2sd(id); + struct map_session_data *sd = iMap->id2sd(id); if( sd != NULL ) { sd->pvp_point=0; - pc_respawn(sd,CLR_OUTSIGHT); + pc->respawn(sd,CLR_OUTSIGHT); } return 0; @@ -6573,7 +6584,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h return; if( pc_issit(sd) ) { - pc_setstand(sd); + pc->setstand(sd); skill->sit(sd,0); } @@ -6586,20 +6597,19 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h if( sd->status.ele_id > 0 ) elemental_set_target(sd,src); - sd->canlog_tick = gettick(); + sd->canlog_tick = iTimer->gettick(); } /*========================================== * Invoked when a player has negative current hp *------------------------------------------*/ -int pc_dead(struct map_session_data *sd,struct block_list *src) -{ +int pc_dead(struct map_session_data *sd,struct block_list *src) { int i=0,j=0,k=0; - unsigned int tick = gettick(); + unsigned int tick = iTimer->gettick(); for(k = 0; k < 5; k++) if (sd->devotion[k]){ - struct map_session_data *devsd = map_id2sd(sd->devotion[k]); + struct map_session_data *devsd = iMap->id2sd(sd->devotion[k]); if (devsd) status_change_end(&devsd->bl, SC_DEVOTION, INVALID_TIMER); sd->devotion[k] = 0; @@ -6636,8 +6646,11 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) duel_reject(sd->duel_invite, sd); } + if (sd->npc_id && sd->st && sd->st->state != RUN) + npc_event_dequeue(sd); + pc_setglobalreg(sd,"PC_DIE_COUNTER",sd->die_counter+1); - pc_setparam(sd, SP_KILLERRID, src?src->id:0); + pc->setparam(sd, SP_KILLERRID, src?src->id:0); if( sd->bg_id ) {/* TODO: purge when bgqueue is deemed ok */ struct battleground_data *bg; @@ -6654,7 +6667,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) npc_script_event(sd,NPCE_DIE); // Clear anything NPC-related when you die and was interacting with one. - if (sd->npc_id) { + if (sd->npc_id || sd->npc_shopid) { if (sd->state.using_fake_npc) { clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd); sd->state.using_fake_npc = 0; @@ -6665,11 +6678,12 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) sd->npc_menu = 0; sd->npc_id = 0; + sd->npc_shopid = 0; if (sd->st && sd->st->state != END) sd->st->state = END; } - /* e.g. not killed thru pc_damage */ + /* e.g. not killed thru pc->damage */ if( pc_issit(sd) ) { clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_SIT); } @@ -6684,50 +6698,50 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) sd->hp_loss.tick = sd->sp_loss.tick = sd->hp_regen.tick = sd->sp_regen.tick = 0; if ( sd && sd->spiritball ) - pc_delspiritball(sd,sd->spiritball,0); + pc->delspiritball(sd,sd->spiritball,0); for(i = 1; i < 5; i++) - pc_del_talisman(sd, sd->talisman[i], i); + pc->del_charm(sd, sd->charm[i], i); - if (src) - switch (src->type) { - case BL_MOB: - { - struct mob_data *md=(struct mob_data *)src; - if(md->target_id==sd->bl.id) - mob_unlocktarget(md,tick); - if(battle_config.mobs_level_up && md->status.hp && - (unsigned int)md->level < pc_maxbaselv(sd) && - !md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex] - ) { // monster level up [Valaris] - clif->misceffect(&md->bl,0); - md->level++; - status_calc_mob(md, 0); - status_percent_heal(src,10,0); - - if( battle_config.show_mob_info&4 ) - {// update name with new level - clif->charnameack(0, &md->bl); + if (src) { + switch (src->type) { + case BL_MOB: + { + struct mob_data *md=(struct mob_data *)src; + if(md->target_id==sd->bl.id) + mob_unlocktarget(md,tick); + if(battle_config.mobs_level_up && md->status.hp && + (unsigned int)md->level < pc->maxbaselv(sd) && + !md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex] + ) { // monster level up [Valaris] + clif->misceffect(&md->bl,0); + md->level++; + status_calc_mob(md, 0); + status_percent_heal(src,10,0); + + if( battle_config.show_mob_info&4 ) + {// update name with new level + clif->charnameack(0, &md->bl); + } + } + src = battle->get_master(src); // Maybe Player Summon } + break; + case BL_PET: //Pass on to master... + src = &((TBL_PET*)src)->msd->bl; + break; + case BL_HOM: + src = &((TBL_HOM*)src)->master->bl; + break; + case BL_MER: + src = &((TBL_MER*)src)->master->bl; + break; } - src = battle->get_master(src); // Maybe Player Summon - } - break; - case BL_PET: //Pass on to master... - src = &((TBL_PET*)src)->msd->bl; - break; - case BL_HOM: - src = &((TBL_HOM*)src)->master->bl; - break; - case BL_MER: - src = &((TBL_MER*)src)->master->bl; - break; } - if (src && src->type == BL_PC) - { + if (src && src->type == BL_PC) { struct map_session_data *ssd = (struct map_session_data *)src; - pc_setparam(ssd, SP_KILLEDRID, sd->bl.id); + pc->setparam(ssd, SP_KILLEDRID, sd->bl.id); npc_script_event(ssd, NPCE_KILLPC); if (battle_config.pk_mode&2) { @@ -6771,24 +6785,24 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) item_tmp.card[1]=0; item_tmp.card[2]=GetWord(sd->status.char_id,0); // CharId item_tmp.card[3]=GetWord(sd->status.char_id,1); - map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } // activate Steel body if a super novice dies at 99+% exp [celest] if ((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && !sd->state.snovice_dead_flag) { - unsigned int next = pc_nextbaseexp(sd); - if( next == 0 ) next = pc_thisbaseexp(sd); + unsigned int next = pc->nextbaseexp(sd); + if( next == 0 ) next = pc->thisbaseexp(sd); if( get_percentage(sd->status.base_exp,next) >= 99 ) { sd->state.snovice_dead_flag = 1; - pc_setstand(sd); + pc->setstand(sd); status_percent_heal(&sd->bl, 100, 100); clif->resurrection(&sd->bl, 1); if(battle_config.pc_invincible_time) - pc_setinvincibletimer(sd, battle_config.pc_invincible_time); + pc->setinvincibletimer(sd, battle_config.pc_invincible_time); sc_start(&sd->bl,status_skill2sc(MO_STEELBODY),100,1,skill->get_time(MO_STEELBODY,1)); if(map_flag_gvg(sd->bl.m)) - pc_respawn_timer(INVALID_TIMER, gettick(), sd->bl.id, 0); + pc_respawn_timer(INVALID_TIMER, iTimer->gettick(), sd->bl.id, 0); return 0; } } @@ -6797,13 +6811,13 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) if(battle_config.death_penalty_type && (sd->class_&MAPID_UPPERMASK) != MAPID_NOVICE // only novices will receive no penalty && !map[sd->bl.m].flag.noexppenalty && !map_flag_gvg(sd->bl.m) - && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_LIFEINSURANCE]) + && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY]) { unsigned int base_penalty =0; if (battle_config.death_penalty_base > 0) { switch (battle_config.death_penalty_type) { case 1: - base_penalty = (unsigned int) ((double)pc_nextbaseexp(sd) * (double)battle_config.death_penalty_base/10000); + base_penalty = (unsigned int) ((double)pc->nextbaseexp(sd) * (double)battle_config.death_penalty_base/10000); break; case 2: base_penalty = (unsigned int) ((double)sd->status.base_exp * (double)battle_config.death_penalty_base/10000); @@ -6821,7 +6835,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) base_penalty = 0; switch (battle_config.death_penalty_type) { case 1: - base_penalty = (unsigned int) ((double)pc_nextjobexp(sd) * (double)battle_config.death_penalty_job/10000); + base_penalty = (unsigned int) ((double)pc->nextjobexp(sd) * (double)battle_config.death_penalty_job/10000); break; case 2: base_penalty = (unsigned int) ((double)sd->status.job_exp * (double)battle_config.death_penalty_job/10000); @@ -6838,7 +6852,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { base_penalty = (unsigned int)((double)sd->status.zeny * (double)battle_config.zeny_penalty / 10000.); if(base_penalty) - pc_payzeny(sd, base_penalty, LOG_TYPE_PICKDROP_PLAYER, NULL); + pc->payzeny(sd, base_penalty, LOG_TYPE_PICKDROP_PLAYER, NULL); } } @@ -6870,8 +6884,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) int n = eq_n[rnd()%eq_num]; if(rnd()%10000 < per){ if(sd->status.inventory[n].equip) - pc_unequipitem(sd,n,3); - pc_dropitem(sd,n,1); + pc->unequipitem(sd,n,3); + pc->dropitem(sd,n,1); } } } @@ -6883,8 +6897,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) || (type == 2 && sd->status.inventory[i].equip) || type == 3) ){ if(sd->status.inventory[i].equip) - pc_unequipitem(sd,i,3); - pc_dropitem(sd,i,1); + pc->unequipitem(sd,i,3); + pc->dropitem(sd,i,1); break; } } @@ -6905,14 +6919,14 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) } if( sd->pvp_point < 0 ) { - add_timer(tick+1000, pc_respawn_timer,sd->bl.id,0); + iTimer->add_timer(tick+1000, pc_respawn_timer,sd->bl.id,0); return 1|8; } } //GvG if( map_flag_gvg(sd->bl.m) ) { - add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0); + iTimer->add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0); return 1|8; } else if( sd->bg_id ) @@ -6920,7 +6934,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) struct battleground_data *bg = bg_team_search(sd->bg_id); if( bg && bg->mapindex > 0 ) { // Respawn by BG - add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0); + iTimer->add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0); return 1|8; } } @@ -6928,7 +6942,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) //Reset "can log out" tick. if( battle_config.prevent_logout ) - sd->canlog_tick = gettick() - battle_config.prevent_logout; + sd->canlog_tick = iTimer->gettick() - battle_config.prevent_logout; return 1; } @@ -6936,9 +6950,9 @@ void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp) { if(hp) clif->updatestatus(sd,SP_HP); if(sp) clif->updatestatus(sd,SP_SP); - pc_setstand(sd); + pc->setstand(sd); if(battle_config.pc_invincible_time > 0) - pc_setinvincibletimer(sd, battle_config.pc_invincible_time); + pc->setinvincibletimer(sd, battle_config.pc_invincible_time); if( sd->state.gmaster_flag ) { guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->state.gmaster_flag,GD_LEADERSHIP)); @@ -6965,16 +6979,16 @@ int pc_readparam(struct map_session_data* sd,int type) case SP_BASELEVEL: val = sd->status.base_level; break; case SP_JOBLEVEL: val = sd->status.job_level; break; case SP_CLASS: val = sd->status.class_; break; - case SP_BASEJOB: val = pc_mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex); break; //Base job, extracting upper type. + case SP_BASEJOB: val = pc->mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex); break; //Base job, extracting upper type. case SP_UPPER: val = sd->class_&JOBL_UPPER?1:(sd->class_&JOBL_BABY?2:0); break; - case SP_BASECLASS: val = pc_mapid2jobid(sd->class_&MAPID_BASEMASK, sd->status.sex); break; //Extract base class tree. [Skotlex] + case SP_BASECLASS: val = pc->mapid2jobid(sd->class_&MAPID_BASEMASK, sd->status.sex); break; //Extract base class tree. [Skotlex] case SP_SEX: val = sd->status.sex; break; case SP_WEIGHT: val = sd->weight; break; case SP_MAXWEIGHT: val = sd->max_weight; break; case SP_BASEEXP: val = sd->status.base_exp; break; case SP_JOBEXP: val = sd->status.job_exp; break; - case SP_NEXTBASEEXP: val = pc_nextbaseexp(sd); break; - case SP_NEXTJOBEXP: val = pc_nextjobexp(sd); break; + case SP_NEXTBASEEXP: val = pc->nextbaseexp(sd); break; + case SP_NEXTJOBEXP: val = pc->nextjobexp(sd); break; case SP_HP: val = sd->battle_status.hp; break; case SP_MAXHP: val = sd->battle_status.max_hp; break; case SP_SP: val = sd->battle_status.sp; break; @@ -7110,12 +7124,12 @@ int pc_setparam(struct map_session_data *sd,int type,int val) switch(type){ case SP_BASELEVEL: - if ((unsigned int)val > pc_maxbaselv(sd)) //Capping to max - val = pc_maxbaselv(sd); + if ((unsigned int)val > pc->maxbaselv(sd)) //Capping to max + val = pc->maxbaselv(sd); if ((unsigned int)val > sd->status.base_level) { int stat=0; for (i = 0; i < (int)((unsigned int)val - sd->status.base_level); i++) - stat += pc_gets_status_point(sd->status.base_level + i); + stat += pc->gets_status_point(sd->status.base_level + i); sd->status.status_point += stat; } sd->status.base_level = (unsigned int)val; @@ -7127,12 +7141,12 @@ int pc_setparam(struct map_session_data *sd,int type,int val) status_calc_pc(sd, 0); if(sd->status.party_id) { - party_send_levelup(sd); + party->send_levelup(sd); } break; case SP_JOBLEVEL: if ((unsigned int)val >= sd->status.job_level) { - if ((unsigned int)val > pc_maxjoblv(sd)) val = pc_maxjoblv(sd); + if ((unsigned int)val > pc->maxjoblv(sd)) val = pc->maxjoblv(sd); sd->status.skill_point += val - sd->status.job_level; clif->updatestatus(sd, SP_SKILLPOINT); } @@ -7156,15 +7170,15 @@ int pc_setparam(struct map_session_data *sd,int type,int val) sd->status.zeny = cap_value(val, 0, MAX_ZENY); break; case SP_BASEEXP: - if(pc_nextbaseexp(sd) > 0) { + if(pc->nextbaseexp(sd) > 0) { sd->status.base_exp = val; - pc_checkbaselevelup(sd); + pc->checkbaselevelup(sd); } break; case SP_JOBEXP: - if(pc_nextjobexp(sd) > 0) { + if(pc->nextjobexp(sd) > 0) { sd->status.job_exp = val; - pc_checkjoblevelup(sd); + pc->checkjoblevelup(sd); } break; case SP_SEX: @@ -7279,8 +7293,8 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp) if(hp) { int i; bonus = 100 + (sd->battle_status.vit<<1) - + pc_checkskill(sd,SM_RECOVERY)*10 - + pc_checkskill(sd,AM_LEARNINGPOTION)*5; + + pc->checkskill(sd,SM_RECOVERY)*10 + + pc->checkskill(sd,AM_LEARNINGPOTION)*5; // A potion produced by an Alchemist in the Fame Top 10 gets +50% effect [DracoRPG] if (potion_flag > 1) bonus += bonus*(potion_flag-1)*50/100; @@ -7300,13 +7314,13 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp) hp = hp * bonus / 100; // Recovery Potion - if( sd->sc.data[SC_INCHEALRATE] ) - hp += (int)(hp * sd->sc.data[SC_INCHEALRATE]->val1/100.); + if( sd->sc.data[SC_HEALPLUS] ) + hp += (int)(hp * sd->sc.data[SC_HEALPLUS]->val1/100.); } if(sp) { bonus = 100 + (sd->battle_status.int_<<1) - + pc_checkskill(sd,MG_SRECOVERY)*10 - + pc_checkskill(sd,AM_LEARNINGPOTION)*5; + + pc->checkskill(sd,MG_SRECOVERY)*10 + + pc->checkskill(sd,AM_LEARNINGPOTION)*5; if (potion_flag > 1) bonus += bonus*(potion_flag-1)*50/100; if(bonus != 100) @@ -7403,7 +7417,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) return 1; //Normalize job. - b_class = pc_jobid2mapid(job); + b_class = pc->jobid2mapid(job); if (b_class == -1) return 1; switch (upper) { @@ -7416,7 +7430,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) } //This will automatically adjust bard/dancer classes to the correct gender //That is, if you try to jobchange into dancer, it will turn you to bard. - job = pc_mapid2jobid(b_class, sd->status.sex); + job = pc->mapid2jobid(b_class, sd->status.sex); if (job == -1) return 1; @@ -7461,7 +7475,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) } if ( (b_class&MAPID_UPPERMASK) != (sd->class_&MAPID_UPPERMASK) ) { //Things to remove when changing class tree. - const int class_ = pc_class2idx(sd->status.class_); + const int class_ = pc->class2idx(sd->status.class_); short id; for(i = 0; i < MAX_SKILL_TREE && (id = skill_tree[class_][i].id) > 0; i++) { //Remove status specific to your current tree skills. @@ -7473,19 +7487,19 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if( (sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && (b_class&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) { /* going off star glad lineage, reset feel to not store no-longer-used vars in the database */ - pc_resetfeel(sd); + pc->resetfeel(sd); } sd->status.class_ = job; - fame_flag = pc_famerank(sd->status.char_id,sd->class_&MAPID_UPPERMASK); + fame_flag = pc->famerank(sd->status.char_id,sd->class_&MAPID_UPPERMASK); sd->class_ = (unsigned short)b_class; sd->status.job_level=1; sd->status.job_exp=0; - if (sd->status.base_level > pc_maxbaselv(sd)) { - sd->status.base_level = pc_maxbaselv(sd); + if (sd->status.base_level > pc->maxbaselv(sd)) { + sd->status.base_level = pc->maxbaselv(sd); sd->status.base_exp=0; - pc_resetstate(sd); + pc->resetstate(sd); clif->updatestatus(sd,SP_STATUSPOINT); clif->updatestatus(sd,SP_BASELEVEL); clif->updatestatus(sd,SP_BASEEXP); @@ -7498,14 +7512,14 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) 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); // unequip invalid item for class + if(!pc->isequip(sd,sd->equip_index[i])) + pc->unequipitem(sd,sd->equip_index[i],2); // unequip invalid item for class } //Change look, if disguised, you need to undisguise //to correctly calculate new job sprite without if (sd->disguise != -1) - pc_disguise(sd, -1); + pc->disguise(sd, -1); status_set_viewdata(&sd->bl, job); clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_); // move sprite update to prevent client crashes with incompatible equipment [Valaris] @@ -7513,7 +7527,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color); //Update skill tree. - pc_calc_skilltree(sd); + pc->calc_skilltree(sd); clif->skillinfoblock(sd); if (sd->ed) @@ -7521,41 +7535,41 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if (sd->state.vending) vending->close(sd); - map_foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id); + iMap->foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id); //Remove peco/cart/falcon i = sd->sc.option; - if( i&OPTION_RIDING && !pc_checkskill(sd, KN_RIDING) ) + if( i&OPTION_RIDING && (!pc->checkskill(sd, KN_RIDING) || (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) ) i&=~OPTION_RIDING; - if( i&OPTION_FALCON && !pc_checkskill(sd, HT_FALCON) ) + if( i&OPTION_FALCON && !pc->checkskill(sd, HT_FALCON) ) i&=~OPTION_FALCON; - if( i&OPTION_DRAGON && !pc_checkskill(sd,RK_DRAGONTRAINING) ) + if( i&OPTION_DRAGON && !pc->checkskill(sd,RK_DRAGONTRAINING) ) i&=~OPTION_DRAGON; - if( i&OPTION_WUGRIDER && !pc_checkskill(sd,RA_WUGMASTERY) ) + if( i&OPTION_WUGRIDER && !pc->checkskill(sd,RA_WUGMASTERY) ) i&=~OPTION_WUGRIDER; - if( i&OPTION_WUG && !pc_checkskill(sd,RA_WUGMASTERY) ) + if( i&OPTION_WUG && !pc->checkskill(sd,RA_WUGMASTERY) ) i&=~OPTION_WUG; if( i&OPTION_MADOGEAR ) //You do not need a skill for this. i&=~OPTION_MADOGEAR; #ifndef NEW_CARTS - if( i&OPTION_CART && !pc_checkskill(sd, MC_PUSHCART) ) + if( i&OPTION_CART && !pc->checkskill(sd, MC_PUSHCART) ) i&=~OPTION_CART; #else - if( sd->sc.data[SC_PUSH_CART] && !pc_checkskill(sd, MC_PUSHCART) ) - pc_setcart(sd, 0); + if( sd->sc.data[SC_PUSH_CART] && !pc->checkskill(sd, MC_PUSHCART) ) + pc->setcart(sd, 0); #endif if(i != sd->sc.option) - pc_setoption(sd, i); + pc->setoption(sd, i); - if(homun_alive(sd->hd) && !pc_checkskill(sd, AM_CALLHOMUN)) + if(homun_alive(sd->hd) && !pc->checkskill(sd, AM_CALLHOMUN)) homun->vaporize(sd, 0); if(sd->status.manner < 0) clif->changestatus(sd,SP_MANNER,sd->status.manner); status_calc_pc(sd,0); - pc_checkallowskill(sd); - pc_equiplookall(sd); + pc->checkallowskill(sd); + pc->equiplookall(sd); //if you were previously famous, not anymore. if (fame_flag) { @@ -7673,7 +7687,7 @@ int pc_setoption(struct map_session_data *sd,int type) sd->sc.option=type; clif->changeoption(&sd->bl); - if( (type&OPTION_RIDING && !(p_type&OPTION_RIDING)) || (type&OPTION_DRAGON && !(p_type&OPTION_DRAGON) && pc_checkskill(sd,RK_DRAGONTRAINING) > 0) ) { + if( (type&OPTION_RIDING && !(p_type&OPTION_RIDING)) || (type&OPTION_DRAGON && !(p_type&OPTION_DRAGON) && pc->checkskill(sd,RK_DRAGONTRAINING) > 0) ) { // Mounting clif->sc_load(&sd->bl,sd->bl.id,AREA,SI_RIDING, 0, 0, 0); status_calc_pc(sd,0); @@ -7687,11 +7701,11 @@ int pc_setoption(struct map_session_data *sd,int type) if( type&OPTION_CART && !( p_type&OPTION_CART ) ) { //Cart On clif->cartlist(sd); clif->updatestatus(sd, SP_CARTINFO); - if(pc_checkskill(sd, MC_PUSHCART) < 10) + if(pc->checkskill(sd, MC_PUSHCART) < 10) status_calc_pc(sd,0); //Apply speed penalty. } else if( !( type&OPTION_CART ) && p_type&OPTION_CART ){ //Cart Off clif->clearcart(sd->fd); - if(pc_checkskill(sd, MC_PUSHCART) < 10) + if(pc->checkskill(sd, MC_PUSHCART) < 10) status_calc_pc(sd,0); //Remove speed penalty. } #endif @@ -7711,22 +7725,23 @@ int pc_setoption(struct map_session_data *sd,int type) } } if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) { - if( type&OPTION_MADOGEAR && !(p_type&OPTION_MADOGEAR) ) { + int i; + if( type&OPTION_MADOGEAR && !(p_type&OPTION_MADOGEAR) ) status_calc_pc(sd, 0); - status_change_end(&sd->bl,SC_MAXIMIZEPOWER,INVALID_TIMER); - status_change_end(&sd->bl,SC_OVERTHRUST,INVALID_TIMER); - status_change_end(&sd->bl,SC_WEAPONPERFECTION,INVALID_TIMER); - status_change_end(&sd->bl,SC_ADRENALINE,INVALID_TIMER); - status_change_end(&sd->bl,SC_CARTBOOST,INVALID_TIMER); - status_change_end(&sd->bl,SC_MELTDOWN,INVALID_TIMER); - status_change_end(&sd->bl,SC_MAXOVERTHRUST,INVALID_TIMER); - } else if( !(type&OPTION_MADOGEAR) && p_type&OPTION_MADOGEAR ) { + else if( !(type&OPTION_MADOGEAR) && p_type&OPTION_MADOGEAR ) status_calc_pc(sd, 0); - status_change_end(&sd->bl,SC_SHAPESHIFT,INVALID_TIMER); - status_change_end(&sd->bl,SC_HOVERING,INVALID_TIMER); - status_change_end(&sd->bl,SC_ACCELERATION,INVALID_TIMER); - status_change_end(&sd->bl,SC_OVERHEAT_LIMITPOINT,INVALID_TIMER); - status_change_end(&sd->bl,SC_OVERHEAT,INVALID_TIMER); + for( i = 0; i < SC_MAX; i++ ){ + if ( !sd->sc.data[i] || !status_get_sc_type(i) ) + continue; + if ( status_get_sc_type(i)&SC_MADO_NO_RESET ) + continue; + switch (i) { + case SC_BERSERK: + case SC_SATURDAY_NIGHT_FEVER: + sd->sc.data[i]->val2 = 0; + break; + } + status_change_end(&sd->bl, (sc_type)i, INVALID_TIMER); } } @@ -7765,7 +7780,7 @@ int pc_setcart(struct map_session_data *sd,int type) { if( type < 0 || type > MAX_CARTS ) return 1;// Never trust the values sent by the client! [Skotlex] - if( pc_checkskill(sd,MC_PUSHCART) <= 0 && type != 0 ) + if( pc->checkskill(sd,MC_PUSHCART) <= 0 && type != 0 ) return 1;// Push cart is required if( type == 0 && pc_iscarton(sd) ) @@ -7792,14 +7807,14 @@ int pc_setcart(struct map_session_data *sd,int type) { break; } - if(pc_checkskill(sd, MC_PUSHCART) < 10) + if(pc->checkskill(sd, MC_PUSHCART) < 10) status_calc_pc(sd,0); //Recalc speed penalty. #else // Update option option = sd->sc.option; option &= ~OPTION_CART;// clear cart bits option |= cart[type]; // set cart - pc_setoption(sd, option); + pc->setoption(sd, option); #endif return 0; @@ -7811,10 +7826,10 @@ int pc_setcart(struct map_session_data *sd,int type) { int pc_setfalcon(TBL_PC* sd, int flag) { if( flag ){ - if( pc_checkskill(sd,HT_FALCON)>0 ) // add falcon if he have the skill - pc_setoption(sd,sd->sc.option|OPTION_FALCON); + 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) ){ - pc_setoption(sd,sd->sc.option&~OPTION_FALCON); // remove falcon + pc->setoption(sd,sd->sc.option&~OPTION_FALCON); // remove falcon } return 0; @@ -7826,10 +7841,10 @@ int pc_setfalcon(TBL_PC* sd, int flag) int pc_setriding(TBL_PC* sd, int flag) { if( flag ){ - if( pc_checkskill(sd,KN_RIDING) > 0 ) // add peco - pc_setoption(sd, sd->sc.option|OPTION_RIDING); + if( pc->checkskill(sd,KN_RIDING) > 0 ) // add peco + pc->setoption(sd, sd->sc.option|OPTION_RIDING); } else if( pc_isriding(sd) ){ - pc_setoption(sd, sd->sc.option&~OPTION_RIDING); + pc->setoption(sd, sd->sc.option&~OPTION_RIDING); } return 0; @@ -7841,10 +7856,10 @@ int pc_setriding(TBL_PC* sd, int flag) int pc_setmadogear(TBL_PC* sd, int flag) { if( flag ){ - if( pc_checkskill(sd,NC_MADOLICENCE) > 0 ) - pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR); + if( pc->checkskill(sd,NC_MADOLICENCE) > 0 ) + pc->setoption(sd, sd->sc.option|OPTION_MADOGEAR); } else if( pc_ismadogear(sd) ){ - pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR); + pc->setoption(sd, sd->sc.option&~OPTION_MADOGEAR); } return 0; @@ -7857,9 +7872,9 @@ int pc_candrop(struct map_session_data *sd, struct item *item) { if( item && item->expire_time ) return 0; - if( !pc_can_give_items(sd) ) //check if this GM level can drop items + if( !pc->can_give_items(sd) ) //check if this GM level can drop items return 0; - return (itemdb_isdropable(item, pc_get_group_level(sd))); + return (itemdb_isdropable(item, pc->get_group_level(sd))); } /*========================================== @@ -8203,7 +8218,7 @@ int pc_setregistry_str(struct map_session_data *sd,const char *reg,const char *v *------------------------------------------*/ static int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd=map_id2sd(id); + struct map_session_data *sd=iMap->id2sd(id); char *p = (char *)data; int i; if(sd==NULL) @@ -8235,7 +8250,7 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) if( i == MAX_EVENTTIMER ) return 0; - sd->eventtimer[i] = add_timer(gettick()+tick, pc_eventtimer, sd->bl.id, (intptr_t)aStrdup(name)); + sd->eventtimer[i] = iTimer->add_timer(iTimer->gettick()+tick, pc_eventtimer, sd->bl.id, (intptr_t)aStrdup(name)); sd->eventcount++; return 1; @@ -8257,13 +8272,13 @@ int pc_deleventtimer(struct map_session_data *sd,const char *name) // find the named event timer ARR_FIND( 0, MAX_EVENTTIMER, i, sd->eventtimer[i] != INVALID_TIMER && - (p = (char *)(get_timer(sd->eventtimer[i])->data)) != NULL && + (p = (char *)(iTimer->get_timer(sd->eventtimer[i])->data)) != NULL && strcmp(p, name) == 0 ); if( i == MAX_EVENTTIMER ) return 0; // not found - delete_timer(sd->eventtimer[i],pc_eventtimer); + iTimer->delete_timer(sd->eventtimer[i],pc_eventtimer); sd->eventtimer[i] = INVALID_TIMER; sd->eventcount--; aFree(p); @@ -8282,8 +8297,8 @@ int pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick) for(i=0;i<MAX_EVENTTIMER;i++) if( sd->eventtimer[i] != INVALID_TIMER && strcmp( - (char *)(get_timer(sd->eventtimer[i])->data), name)==0 ){ - addtick_timer(sd->eventtimer[i],tick); + (char *)(iTimer->get_timer(sd->eventtimer[i])->data), name)==0 ){ + iTimer->addtick_timer(sd->eventtimer[i],tick); break; } @@ -8304,8 +8319,8 @@ int pc_cleareventtimer(struct map_session_data *sd) for(i=0;i<MAX_EVENTTIMER;i++) if( sd->eventtimer[i] != INVALID_TIMER ){ - char *p = (char *)(get_timer(sd->eventtimer[i])->data); - delete_timer(sd->eventtimer[i],pc_eventtimer); + char *p = (char *)(iTimer->get_timer(sd->eventtimer[i])->data); + iTimer->delete_timer(sd->eventtimer[i],pc_eventtimer); sd->eventtimer[i] = INVALID_TIMER; sd->eventcount--; if (p) aFree(p); @@ -8482,24 +8497,24 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) return 0; } - if( DIFF_TICK(sd->canequip_tick,gettick()) > 0 ) + if( DIFF_TICK(sd->canequip_tick,iTimer->gettick()) > 0 ) { clif->equipitemack(sd,n,0,0); return 0; } id = sd->inventory_data[n]; - pos = pc_equippoint(sd,n); //With a few exceptions, item should go in all specified slots. + pos = pc->equippoint(sd,n); //With a few exceptions, item should go in all specified slots. if(battle_config.battle_log) ShowInfo("equip %d(%d) %x:%x\n",sd->status.inventory[n].nameid,n,id?id->equip:0,req_pos); - if(!pc_isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || sd->status.inventory[n].attribute==1 ) { // [Valaris] - // FIXME: pc_isequip: equip level failure uses 2 instead of 0 + if(!pc->isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || sd->status.inventory[n].attribute==1 ) { // [Valaris] + // FIXME: pc->isequip: equip level failure uses 2 instead of 0 clif->equipitemack(sd,n,0,0); // fail return 0; } - if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAYNIGHTFEVER] || sd->sc.data[SC__BLOODYLUST]) + if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAY_NIGHT_FEVER] || sd->sc.data[SC__BLOODYLUST]) { clif->equipitemack(sd,n,0,0); // fail return 0; @@ -8530,7 +8545,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) for(i=0;i<EQI_MAX;i++) { if(pos & equip_pos[i]) { if(sd->equip_index[i] >= 0) //Slot taken, remove item from there. - pc_unequipitem(sd,sd->equip_index[i],2); + pc->unequipitem(sd,sd->equip_index[i],2); sd->equip_index[i] = n; } @@ -8572,21 +8587,21 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) } //Added check to prevent sending the same look on multiple slots -> //causes client to redraw item on top of itself. (suggested by Lupus) - if(pos & EQP_HEAD_LOW && pc_checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) { + if(pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) { if(id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))) sd->status.head_bottom = id->look; else sd->status.head_bottom = 0; clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); } - if(pos & EQP_HEAD_TOP && pc_checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { + if(pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { if(id) sd->status.head_top = id->look; else sd->status.head_top = 0; clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } - if(pos & EQP_HEAD_MID && pc_checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { + if(pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { if(id && !(pos&EQP_HEAD_TOP)) sd->status.head_mid = id->look; else @@ -8617,7 +8632,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) if(pos & EQP_SHOES) clif->changelook(&sd->bl,LOOK_SHOES,0); - if( pos&EQP_GARMENT && pc_checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) { + if( pos&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) { sd->status.robe = id ? id->look : 0; clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe); } @@ -8628,7 +8643,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) } - pc_checkallowskill(sd); //Check if status changes should be halted. + pc->checkallowskill(sd); //Check if status changes should be halted. iflag = sd->npc_item_flag; /* check for combos (MUST be before status_calc_pc) */ @@ -8695,7 +8710,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { } // if player is berserk then cannot unequip - if (!(flag & 2) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAYNIGHTFEVER] || sd->sc.data[SC__BLOODYLUST])) + if (!(flag & 2) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAY_NIGHT_FEVER] || sd->sc.data[SC__BLOODYLUST])) { clif->unequipitemack(sd,n,0,0); return 0; @@ -8708,7 +8723,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { } if(battle_config.battle_log) - ShowInfo("unequip %d %x:%x\n",n,pc_equippoint(sd,n),sd->status.inventory[n].equip); + ShowInfo("unequip %d %x:%x\n",n,pc->equippoint(sd,n),sd->status.inventory[n].equip); if(!sd->status.inventory[n].equip){ //Nothing to unequip clif->unequipitemack(sd,n,0,0); @@ -8732,51 +8747,51 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { pc_calcweapontype(sd); clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); } - if(sd->status.inventory[n].equip & EQP_HEAD_LOW && pc_checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1 ) { + if(sd->status.inventory[n].equip & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1 ) { sd->status.head_bottom = 0; clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); } - if(sd->status.inventory[n].equip & EQP_HEAD_TOP && pc_checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1 ) { + if(sd->status.inventory[n].equip & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1 ) { sd->status.head_top = 0; clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } - if(sd->status.inventory[n].equip & EQP_HEAD_MID && pc_checkequip(sd,EQP_COSTUME_HEAD_MID) == -1 ) { + if(sd->status.inventory[n].equip & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1 ) { sd->status.head_mid = 0; clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } if(sd->status.inventory[n].equip & EQP_COSTUME_HEAD_TOP) { - sd->status.head_top = ( pc_checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc_checkequip(sd,EQP_HEAD_TOP)]->look : 0; + sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->look : 0; clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } if(sd->status.inventory[n].equip & EQP_COSTUME_HEAD_MID) { - sd->status.head_mid = ( pc_checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc_checkequip(sd,EQP_HEAD_MID)]->look : 0; + sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->look : 0; clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } if(sd->status.inventory[n].equip & EQP_COSTUME_HEAD_LOW) { - sd->status.head_bottom = ( pc_checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc_checkequip(sd,EQP_HEAD_LOW)]->look : 0; + sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->look : 0; clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); } if(sd->status.inventory[n].equip & EQP_SHOES) clif->changelook(&sd->bl,LOOK_SHOES,0); - if( sd->status.inventory[n].equip&EQP_GARMENT && pc_checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) { + if( sd->status.inventory[n].equip&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) { sd->status.robe = 0; clif->changelook(&sd->bl, LOOK_ROBE, 0); } if(sd->status.inventory[n].equip & EQP_COSTUME_GARMENT) { - sd->status.robe = ( pc_checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc_checkequip(sd,EQP_GARMENT)]->look : 0; + sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->look : 0; clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); } clif->unequipitemack(sd,n,sd->status.inventory[n].equip,1); if((sd->status.inventory[n].equip & EQP_ARMS) && - sd->weapontype1 == 0 && sd->weapontype2 == 0 && (!sd->sc.data[SC_SEVENWIND] || sd->sc.data[SC_ASPERSIO])) //Check for seven wind (but not level seven!) + 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(sd->status.inventory[n].equip & EQP_ARMOR) { @@ -8814,12 +8829,12 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { } if(flag&1 || status_cacl) { - pc_checkallowskill(sd); + pc->checkallowskill(sd); status_calc_pc(sd,0); } - if(sd->sc.data[SC_SIGNUMCRUCIS] && !battle->check_undead(sd->battle_status.race,sd->battle_status.def_ele)) - status_change_end(&sd->bl, SC_SIGNUMCRUCIS, INVALID_TIMER); + if(sd->sc.data[SC_CRUCIS] && !battle->check_undead(sd->battle_status.race,sd->battle_status.def_ele)) + status_change_end(&sd->bl, SC_CRUCIS, INVALID_TIMER); //OnUnEquip script [Skotlex] if (sd->inventory_data[n]) { @@ -8865,7 +8880,7 @@ int pc_checkitem(struct map_session_data *sd) if( id && !itemdb_available(id) ) { ShowWarning("Removed invalid/disabled item id %d from inventory (amount=%d, char_id=%d).\n", id, sd->status.inventory[i].amount, sd->status.char_id); - pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER); + pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER); } } @@ -8874,7 +8889,7 @@ int pc_checkitem(struct map_session_data *sd) if( id && !itemdb_available(id) ) { ShowWarning("Removed invalid/disabled item id %d from cart (amount=%d, char_id=%d).\n", id, sd->status.cart[i].amount, sd->status.char_id); - pc_cart_delitem(sd, i, sd->status.cart[i].amount, 0, LOG_TYPE_OTHER); + pc->cart_delitem(sd, i, sd->status.cart[i].amount, 0, LOG_TYPE_OTHER); } } } @@ -8887,8 +8902,8 @@ int pc_checkitem(struct map_session_data *sd) if( !sd->status.inventory[i].equip ) continue; - if( sd->status.inventory[i].equip&~pc_equippoint(sd,i) ) { - pc_unequipitem(sd, i, 2); + if( sd->status.inventory[i].equip&~pc->equippoint(sd,i) ) { + pc->unequipitem(sd, i, 2); calc_flag = 1; continue; } @@ -8896,7 +8911,7 @@ int pc_checkitem(struct map_session_data *sd) } if( calc_flag && sd->state.active ) { - pc_checkallowskill(sd); + pc->checkallowskill(sd); status_calc_pc(sd,0); } @@ -8923,7 +8938,7 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap) return 0; } /*========================================== - * Calculate new rank beetween all present players (map_foreachinarea) + * Calculate new rank beetween all present players (iMap->foreachinarea) * and display result *------------------------------------------*/ int pc_calc_pvprank(struct map_session_data *sd) @@ -8933,7 +8948,7 @@ int pc_calc_pvprank(struct map_session_data *sd) m=&map[sd->bl.m]; old=sd->pvp_rank; sd->pvp_rank=1; - map_foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd); + iMap->foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd); if(old!=sd->pvp_rank || sd->pvp_lastusers!=m->users_pvp) clif->pvpset(sd,sd->pvp_rank,sd->pvp_lastusers=m->users_pvp,0); return sd->pvp_rank; @@ -8945,7 +8960,7 @@ int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; - sd=map_id2sd(id); + sd=iMap->id2sd(id); if(sd==NULL) return 0; sd->pvp_timer = INVALID_TIMER; @@ -8955,8 +8970,8 @@ int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } - if( pc_calc_pvprank(sd) > 0 ) - sd->pvp_timer = add_timer(gettick()+PVP_CALCRANK_INTERVAL,pc_calc_pvprank_timer,id,data); + if( pc->calc_pvprank(sd) > 0 ) + sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+PVP_CALCRANK_INTERVAL,pc->calc_pvprank_timer,id,data); return 0; } @@ -9003,13 +9018,13 @@ int pc_divorce(struct map_session_data *sd) struct map_session_data *p_sd; int i; - if( sd == NULL || !pc_ismarried(sd) ) + if( sd == NULL || !pc->ismarried(sd) ) return -1; if( !sd->status.partner_id ) return -1; // Char is not married - if( (p_sd = map_charid2sd(sd->status.partner_id)) == NULL ) + if( (p_sd = iMap->charid2sd(sd->status.partner_id)) == NULL ) { // Lets char server do the divorce if( chrif_divorce(sd->status.char_id, sd->status.partner_id) ) return -1; // No char server connected @@ -9023,9 +9038,9 @@ int pc_divorce(struct map_session_data *sd) for( i = 0; i < MAX_INVENTORY; i++ ) { if( sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F ) - pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER); + pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER); if( p_sd->status.inventory[i].nameid == WEDDING_RING_M || p_sd->status.inventory[i].nameid == WEDDING_RING_F ) - pc_delitem(p_sd, i, 1, 0, 0, LOG_TYPE_OTHER); + pc->delitem(p_sd, i, 1, 0, 0, LOG_TYPE_OTHER); } clif->divorced(sd, p_sd->status.name); @@ -9039,9 +9054,9 @@ int pc_divorce(struct map_session_data *sd) *------------------------------------------*/ struct map_session_data *pc_get_partner(struct map_session_data *sd) { - if (sd && pc_ismarried(sd)) + if (sd && pc->ismarried(sd)) // charid2sd returns NULL if not found - return map_charid2sd(sd->status.partner_id); + return iMap->charid2sd(sd->status.partner_id); return NULL; } @@ -9053,7 +9068,7 @@ struct map_session_data *pc_get_father (struct map_session_data *sd) { if (sd && sd->class_&JOBL_BABY && sd->status.father > 0) // charid2sd returns NULL if not found - return map_charid2sd(sd->status.father); + return iMap->charid2sd(sd->status.father); return NULL; } @@ -9065,7 +9080,7 @@ struct map_session_data *pc_get_mother (struct map_session_data *sd) { if (sd && sd->class_&JOBL_BABY && sd->status.mother > 0) // charid2sd returns NULL if not found - return map_charid2sd(sd->status.mother); + return iMap->charid2sd(sd->status.mother); return NULL; } @@ -9075,9 +9090,9 @@ struct map_session_data *pc_get_mother (struct map_session_data *sd) *------------------------------------------*/ struct map_session_data *pc_get_child (struct map_session_data *sd) { - if (sd && pc_ismarried(sd) && sd->status.child > 0) + if (sd && pc->ismarried(sd) && sd->status.child > 0) // charid2sd returns NULL if not found - return map_charid2sd(sd->status.child); + return iMap->charid2sd(sd->status.child); return NULL; } @@ -9194,19 +9209,19 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) } mapit->free(iter); - interval = autosave_interval/(map_usercount()+1); - if(interval < minsave_interval) - interval = minsave_interval; - add_timer(gettick()+interval,pc_autosave,0,0); + interval = iMap->autosave_interval/(iMap->usercount()+1); + if(interval < iMap->minsave_interval) + interval = iMap->minsave_interval; + iTimer->add_timer(iTimer->gettick()+interval,pc_autosave,0,0); return 0; } static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { - if (sd->state.night != night_flag && map[sd->bl.m].flag.nightenabled) { //Night/day state does not match. - clif->status_change(&sd->bl, SI_NIGHT, night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex] - sd->state.night = night_flag; + if (sd->state.night != iMap->night_flag && map[sd->bl.m].flag.nightenabled) { //Night/day state does not match. + clif->status_change(&sd->bl, SI_SKE, iMap->night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex] + sd->state.night = iMap->night_flag; return 1; } return 0; @@ -9222,11 +9237,11 @@ int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) if (data == 0 && battle_config.day_duration <= 0) // if we want a day return 0; - if (!night_flag) + if (!iMap->night_flag) return 0; //Already day. - night_flag = 0; // 0=day, 1=night [Yor] - map_foreachpc(pc_daynight_timer_sub); + iMap->night_flag = 0; // 0=day, 1=night [Yor] + iMap->map_foreachpc(pc_daynight_timer_sub); strcpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60)); // The day has arrived! intif_broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0); return 0; @@ -9243,11 +9258,11 @@ int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) if (data == 0 && battle_config.night_duration <= 0) // if we want a night return 0; - if (night_flag) + if (iMap->night_flag) return 0; //Already nigth. - night_flag = 1; // 0=day, 1=night [Yor] - map_foreachpc(pc_daynight_timer_sub); + iMap->night_flag = 1; // 0=day, 1=night [Yor] + iMap->map_foreachpc(pc_daynight_timer_sub); strcpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59)); // The night has fallen... intif_broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0); return 0; @@ -9273,7 +9288,7 @@ void pc_overheat(struct map_session_data *sd, int val) { if( !pc_ismadogear(sd) || sd->sc.data[SC_OVERHEAT] ) return; // already burning - skill = cap_value(pc_checkskill(sd,NC_MAINFRAME),0,4); + skill = cap_value(pc->checkskill(sd,NC_MAINFRAME),0,4); if( sd->sc.data[SC_OVERHEAT_LIMITPOINT] ) { heat += sd->sc.data[SC_OVERHEAT_LIMITPOINT]->val1; status_change_end(&sd->bl,SC_OVERHEAT_LIMITPOINT,INVALID_TIMER); @@ -9309,41 +9324,41 @@ bool pc_can_use_command(struct map_session_data *sd, const char *command) { return atcommand->can_use(sd,command); } -static int pc_talisman_timer(int tid, unsigned int tick, int id, intptr_t data) +static int pc_charm_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; int i, type; - if( (sd=(struct map_session_data *)map_id2sd(id)) == NULL || sd->bl.type!=BL_PC ) + if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; - ARR_FIND(1, 5, type, sd->talisman[type] > 0); + ARR_FIND(1, 5, type, sd->charm[type] > 0); - if( sd->talisman[type] <= 0 ) + if( sd->charm[type] <= 0 ) { - ShowError("pc_talisman_timer: %d talisman's available. (aid=%d cid=%d tid=%d)\n", sd->talisman[type], sd->status.account_id, sd->status.char_id, tid); - sd->talisman[type] = 0; + ShowError("pc_charm_timer: %d charm's available. (aid=%d cid=%d tid=%d)\n", sd->charm[type], sd->status.account_id, sd->status.char_id, tid); + sd->charm[type] = 0; return 0; } - ARR_FIND(0, sd->talisman[type], i, sd->talisman_timer[type][i] == tid); - if( i == sd->talisman[type] ) + ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == tid); + if( i == sd->charm[type] ) { - ShowError("pc_talisman_timer: timer not found (aid=%d cid=%d tid=%d)\n", sd->status.account_id, sd->status.char_id, tid); + ShowError("pc_charm_timer: timer not found (aid=%d cid=%d tid=%d)\n", sd->status.account_id, sd->status.char_id, tid); return 0; } - sd->talisman[type]--; - if( i != sd->talisman[type] ) - memmove(sd->talisman_timer[type]+i, sd->talisman_timer[type]+i+1, (sd->talisman[type]-i)*sizeof(int)); - sd->talisman_timer[type][sd->talisman[type]] = INVALID_TIMER; + sd->charm[type]--; + if( i != sd->charm[type] ) + memmove(sd->charm_timer[type]+i, sd->charm_timer[type]+i+1, (sd->charm[type]-i)*sizeof(int)); + sd->charm_timer[type][sd->charm[type]] = INVALID_TIMER; - clif->talisman(sd, type); + clif->charm(sd, type); return 0; } -int pc_add_talisman(struct map_session_data *sd,int interval,int max,int type) +int pc_add_charm(struct map_session_data *sd,int interval,int max,int type) { int tid, i; @@ -9351,61 +9366,61 @@ int pc_add_talisman(struct map_session_data *sd,int interval,int max,int type) if(max > 10) max = 10; - if(sd->talisman[type] < 0) - sd->talisman[type] = 0; + if(sd->charm[type] < 0) + sd->charm[type] = 0; - if( sd->talisman[type] && sd->talisman[type] >= max ) + if( sd->charm[type] && sd->charm[type] >= max ) { - if(sd->talisman_timer[type][0] != INVALID_TIMER) - delete_timer(sd->talisman_timer[type][0],pc_talisman_timer); - sd->talisman[type]--; - if( sd->talisman[type] != 0 ) - memmove(sd->talisman_timer[type]+0, sd->talisman_timer[type]+1, (sd->talisman[type])*sizeof(int)); - sd->talisman_timer[type][sd->talisman[type]] = INVALID_TIMER; - } - - tid = add_timer(gettick()+interval, pc_talisman_timer, sd->bl.id, 0); - ARR_FIND(0, sd->talisman[type], i, sd->talisman_timer[type][i] == INVALID_TIMER || DIFF_TICK(get_timer(tid)->tick, get_timer(sd->talisman_timer[type][i])->tick) < 0); - if( i != sd->talisman[type] ) - memmove(sd->talisman_timer[type]+i+1, sd->talisman_timer[type]+i, (sd->talisman[type]-i)*sizeof(int)); - sd->talisman_timer[type][i] = tid; - sd->talisman[type]++; - - clif->talisman(sd, type); + if(sd->charm_timer[type][0] != INVALID_TIMER) + iTimer->delete_timer(sd->charm_timer[type][0],pc_charm_timer); + sd->charm[type]--; + if( sd->charm[type] != 0 ) + memmove(sd->charm_timer[type]+0, sd->charm_timer[type]+1, (sd->charm[type])*sizeof(int)); + sd->charm_timer[type][sd->charm[type]] = INVALID_TIMER; + } + + tid = iTimer->add_timer(iTimer->gettick()+interval, pc_charm_timer, sd->bl.id, 0); + ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == INVALID_TIMER || DIFF_TICK(iTimer->get_timer(tid)->tick, iTimer->get_timer(sd->charm_timer[type][i])->tick) < 0); + if( i != sd->charm[type] ) + memmove(sd->charm_timer[type]+i+1, sd->charm_timer[type]+i, (sd->charm[type]-i)*sizeof(int)); + sd->charm_timer[type][i] = tid; + sd->charm[type]++; + + clif->charm(sd, type); return 0; } -int pc_del_talisman(struct map_session_data *sd,int count,int type) +int pc_del_charm(struct map_session_data *sd,int count,int type) { int i; nullpo_ret(sd); - if( sd->talisman[type] <= 0 ) { - sd->talisman[type] = 0; + if( sd->charm[type] <= 0 ) { + sd->charm[type] = 0; return 0; } if( count <= 0 ) return 0; - if( count > sd->talisman[type] ) - count = sd->talisman[type]; - sd->talisman[type] -= count; + if( count > sd->charm[type] ) + count = sd->charm[type]; + sd->charm[type] -= count; if( count > 10 ) count = 10; for(i = 0; i < count; i++) { - if(sd->talisman_timer[type][i] != INVALID_TIMER) { - delete_timer(sd->talisman_timer[type][i],pc_talisman_timer); - sd->talisman_timer[type][i] = INVALID_TIMER; + if(sd->charm_timer[type][i] != INVALID_TIMER) { + iTimer->delete_timer(sd->charm_timer[type][i],pc_charm_timer); + sd->charm_timer[type][i] = INVALID_TIMER; } } for(i = count; i < 10; i++) { - sd->talisman_timer[type][i-count] = sd->talisman_timer[type][i]; - sd->talisman_timer[type][i] = INVALID_TIMER; + sd->charm_timer[type][i-count] = sd->charm_timer[type][i]; + sd->charm_timer[type][i] = INVALID_TIMER; } - clif->talisman(sd, type); + clif->charm(sd, type); return 0; } #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) @@ -9527,7 +9542,7 @@ static bool pc_readdb_skilltree(char* fields[], int columns, int current) ShowWarning("pc_readdb_skilltree: Invalid job class %d specified.\n", class_); return false; } - idx = pc_class2idx(class_); + idx = pc->class2idx(class_); //This is to avoid adding two lines for the same skill. [Skotlex] ARR_FIND( 0, MAX_SKILL_TREE, skill_idx, skill_tree[idx][skill_idx].id == 0 || skill_tree[idx][skill_idx].id == skill_id ); @@ -9597,7 +9612,7 @@ int pc_readdb(void) memset(exp_table,0,sizeof(exp_table)); memset(max_level,0,sizeof(max_level)); - sprintf(line, "%s/"DBPATH"exp.txt", db_path); + sprintf(line, "%s/"DBPATH"exp.txt", iMap->db_path); fp=fopen(line, "r"); if(fp==NULL){ @@ -9634,7 +9649,7 @@ int pc_readdb(void) maxlv = MAX_LEVEL; } count++; - job = jobs[0] = pc_class2idx(job_id); + job = jobs[0] = pc->class2idx(job_id); //We send one less and then one more because the last entry in the exp array should hold 0. max_level[job][type] = pc_split_atoui(split[3], exp_table[job][type],',',maxlv-1)+1; //Reverse check in case the array has a bunch of trailing zeros... [Skotlex] @@ -9659,7 +9674,7 @@ int pc_readdb(void) ShowError("pc_readdb: Invalid job ID %d.\n", job_id); continue; } - job = pc_class2idx(job_id); + job = pc->class2idx(job_id); memcpy(exp_table[job][type], exp_table[jobs[0]][type], sizeof(exp_table[0][0])); max_level[job][type] = maxlv; // ShowDebug("%s - Class %d: %u\n", type?"Job":"Base", job_id, max_level[job][type]); @@ -9670,20 +9685,20 @@ int pc_readdb(void) if (!pcdb_checkid(i)) continue; if (i == JOB_WEDDING || i == JOB_XMAS || i == JOB_SUMMER) continue; //Classes that do not need exp tables. - j = pc_class2idx(i); + j = pc->class2idx(i); if (!max_level[j][0]) - ShowWarning("Class %s (%d) does not has a base exp table.\n", job_name(i), i); + ShowWarning("Class %s (%d) does not has a base exp table.\n", pc->job_name(i), i); if (!max_level[j][1]) - ShowWarning("Class %s (%d) does not has a job exp table.\n", job_name(i), i); + ShowWarning("Class %s (%d) does not has a job exp table.\n", pc->job_name(i), i); } - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"exp.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"exp.txt"); count = 0; // Reset and read skilltree memset(skill_tree,0,sizeof(skill_tree)); - sv->readdb(db_path, DBPATH"skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree); + sv->readdb(iMap->db_path, DBPATH"skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree); #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) - sv->readdb(db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty); + sv->readdb(iMap->db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty); for( k=1; k < 3; k++ ){ // fill in the blanks for( j = 0; j < RC_MAX; j++ ){ int tmp = 0; @@ -9705,7 +9720,7 @@ int pc_readdb(void) for(k=0;k<ELE_MAX;k++) attr_fix_table[i][j][k]=100; - sprintf(line, "%s/"DBPATH"attr_fix.txt", db_path); + sprintf(line, "%s/"DBPATH"attr_fix.txt", iMap->db_path); fp=fopen(line,"r"); if(fp==NULL){ @@ -9749,13 +9764,13 @@ int pc_readdb(void) } } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"attr_fix.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"attr_fix.txt"); count = 0; // reset then read statspoint memset(statp,0,sizeof(statp)); i=1; - sprintf(line, "%s/"DBPATH"statpoint.txt", db_path); + sprintf(line, "%s/"DBPATH"statpoint.txt", iMap->db_path); fp=fopen(line,"r"); if(fp == NULL){ ShowWarning("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line); @@ -9776,14 +9791,14 @@ int pc_readdb(void) } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"statpoint.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"statpoint.txt"); } // generate the remaining parts of the db if necessary k = battle_config.use_statpoint_table; //save setting - battle_config.use_statpoint_table = 0; //temporarily disable to force pc_gets_status_point use default values + battle_config.use_statpoint_table = 0; //temporarily disable to force pc->gets_status_point use default values statp[0] = 45; // seed value for (; i <= MAX_LEVEL; i++) - statp[i] = statp[i-1] + pc_gets_status_point(i-1); + statp[i] = statp[i-1] + pc->gets_status_point(i-1); battle_config.use_statpoint_table = k; //restore setting return 0; @@ -9799,7 +9814,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { return; } for(i = 0; i < MAX_ITEMDELAYS; i++) { - if( cd->nameid[i] && DIFF_TICK(gettick(),cd->tick[i]) < 0 ) { + if( cd->nameid[i] && DIFF_TICK(iTimer->gettick(),cd->tick[i]) < 0 ) { sd->item_delay[cursor].tick = cd->tick[i]; sd->item_delay[cursor].nameid = cd->nameid[i]; cursor++; @@ -9813,7 +9828,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { idb_put( itemcd_db, sd->status.char_id, cd ); } for(i = 0; i < MAX_ITEMDELAYS; i++) { - if( sd->item_delay[i].nameid && DIFF_TICK(gettick(),sd->item_delay[i].tick) < 0 ) { + if( sd->item_delay[i].nameid && DIFF_TICK(iTimer->gettick(),sd->item_delay[i].tick) < 0 ) { cd->tick[cursor] = sd->item_delay[i].tick; cd->nameid[cursor] = sd->item_delay[i].nameid; cursor++; @@ -9822,6 +9837,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { } return; } + /*========================================== * pc Init/Terminate *------------------------------------------*/ @@ -9839,32 +9855,32 @@ int do_init_pc(void) { itemcd_db = idb_alloc(DB_OPT_RELEASE_DATA); - pc_readdb(); + pc->readdb(); - add_timer_func_list(pc_invincible_timer, "pc_invincible_timer"); - add_timer_func_list(pc_eventtimer, "pc_eventtimer"); - add_timer_func_list(pc_inventory_rental_end, "pc_inventory_rental_end"); - add_timer_func_list(pc_calc_pvprank_timer, "pc_calc_pvprank_timer"); - add_timer_func_list(pc_autosave, "pc_autosave"); - add_timer_func_list(pc_spiritball_timer, "pc_spiritball_timer"); - add_timer_func_list(pc_follow_timer, "pc_follow_timer"); - add_timer_func_list(pc_endautobonus, "pc_endautobonus"); - add_timer_func_list(pc_talisman_timer, "pc_talisman_timer"); + iTimer->add_timer_func_list(pc_invincible_timer, "pc_invincible_timer"); + iTimer->add_timer_func_list(pc_eventtimer, "pc_eventtimer"); + iTimer->add_timer_func_list(pc_inventory_rental_end, "pc_inventory_rental_end"); + iTimer->add_timer_func_list(pc->calc_pvprank_timer, "pc->calc_pvprank_timer"); + iTimer->add_timer_func_list(pc_autosave, "pc_autosave"); + iTimer->add_timer_func_list(pc_spiritball_timer, "pc_spiritball_timer"); + iTimer->add_timer_func_list(pc_follow_timer, "pc_follow_timer"); + iTimer->add_timer_func_list(pc->endautobonus, "pc->endautobonus"); + iTimer->add_timer_func_list(pc_charm_timer, "pc_charm_timer"); - add_timer(gettick() + autosave_interval, pc_autosave, 0, 0); + iTimer->add_timer(iTimer->gettick() + iMap->autosave_interval, pc_autosave, 0, 0); // 0=day, 1=night [Yor] - night_flag = battle_config.night_at_start ? 1 : 0; + iMap->night_flag = battle_config.night_at_start ? 1 : 0; if (battle_config.day_duration > 0 && battle_config.night_duration > 0) { int day_duration = battle_config.day_duration; int night_duration = battle_config.night_duration; // add night/day timer [Yor] - add_timer_func_list(map_day_timer, "map_day_timer"); - add_timer_func_list(map_night_timer, "map_night_timer"); + iTimer->add_timer_func_list(pc->map_day_timer, "pc->map_day_timer"); + iTimer->add_timer_func_list(pc->map_night_timer, "pc->map_night_timer"); - day_timer_tid = add_timer_interval(gettick() + (night_flag ? 0 : day_duration) + night_duration, map_day_timer, 0, 0, day_duration + night_duration); - night_timer_tid = add_timer_interval(gettick() + day_duration + (night_flag ? night_duration : 0), map_night_timer, 0, 0, day_duration + night_duration); + pc->day_timer_tid = iTimer->add_timer_interval(iTimer->gettick() + (iMap->night_flag ? 0 : day_duration) + night_duration, pc->map_day_timer, 0, 0, day_duration + night_duration); + pc->night_timer_tid = iTimer->add_timer_interval(iTimer->gettick() + day_duration + (iMap->night_flag ? night_duration : 0), pc->map_night_timer, 0, 0, day_duration + night_duration); } do_init_pc_groups(); @@ -9873,3 +9889,220 @@ int do_init_pc(void) { return 0; } + +/*===================================== +* Default Functions : pc.h +* Generated by HerculesInterfaceMaker +* created by Susu +*-------------------------------------*/ +void pc_defaults(void) { + pc = &pc_s; + + /* vars */ + // timer for night.day + pc->day_timer_tid = day_timer_tid; + pc->night_timer_tid = night_timer_tid; + + /* funcs */ + + pc->class2idx = pc_class2idx; + pc->get_group_level = pc_get_group_level; + pc->can_give_items = pc_can_give_items; + + pc->can_use_command = pc_can_use_command; + + pc->setrestartvalue = pc_setrestartvalue; + pc->makesavestatus = pc_makesavestatus; + pc->respawn = pc_respawn; + pc->setnewpc = pc_setnewpc; + pc->authok = pc_authok; + pc->authfail = pc_authfail; + pc->reg_received = pc_reg_received; + + pc->isequip = pc_isequip; + pc->equippoint = pc_equippoint; + pc->setinventorydata = pc_setinventorydata; + + pc->checkskill = pc_checkskill; + pc->checkskill2 = pc_checkskill2; + pc->checkallowskill = pc_checkallowskill; + pc->checkequip = pc_checkequip; + + pc->calc_skilltree = pc_calc_skilltree; + pc->calc_skilltree_normalize_job = pc_calc_skilltree_normalize_job; + pc->clean_skilltree = pc_clean_skilltree; + + pc->setpos = pc_setpos; + pc->setsavepoint = pc_setsavepoint; + pc->randomwarp = pc_randomwarp; + pc->memo = pc_memo; + + pc->checkadditem = pc_checkadditem; + pc->inventoryblank = pc_inventoryblank; + pc->search_inventory = pc_search_inventory; + pc->payzeny = pc_payzeny; + pc->additem = pc_additem; + pc->getzeny = pc_getzeny; + pc->delitem = pc_delitem; + // Special Shop System + pc->paycash = pc_paycash; + pc->getcash = pc_getcash; + + pc->cart_additem = pc_cart_additem; + pc->cart_delitem = pc_cart_delitem; + pc->putitemtocart = pc_putitemtocart; + pc->getitemfromcart = pc_getitemfromcart; + pc->cartitem_amount = pc_cartitem_amount; + + pc->takeitem = pc_takeitem; + pc->dropitem = pc_dropitem; + + pc->isequipped = pc_isequipped; + pc->can_Adopt = pc_can_Adopt; + pc->adoption = pc_adoption; + + pc->updateweightstatus = pc_updateweightstatus; + + pc->addautobonus = pc_addautobonus; + pc->exeautobonus = pc_exeautobonus; + pc->endautobonus = pc_endautobonus; + pc->delautobonus = pc_delautobonus; + + pc->bonus = pc_bonus; + pc->bonus2 = pc_bonus2; + pc->bonus3 = pc_bonus3; + pc->bonus4 = pc_bonus4; + pc->bonus5 = pc_bonus5; + pc->skill = pc_skill; + + pc->insert_card = pc_insert_card; + + pc->steal_item = pc_steal_item; + pc->steal_coin = pc_steal_coin; + + pc->modifybuyvalue = pc_modifybuyvalue; + pc->modifysellvalue = pc_modifysellvalue; + + pc->follow = pc_follow; // [MouseJstr] + pc->stop_following = pc_stop_following; + + pc->maxbaselv = pc_maxbaselv; + pc->maxjoblv = pc_maxjoblv; + pc->checkbaselevelup = pc_checkbaselevelup; + pc->checkjoblevelup = pc_checkjoblevelup; + pc->gainexp = pc_gainexp; + pc->nextbaseexp = pc_nextbaseexp; + pc->thisbaseexp = pc_thisbaseexp; + pc->nextjobexp = pc_nextjobexp; + pc->thisjobexp = pc_thisjobexp; + pc->gets_status_point = pc_gets_status_point; + pc->need_status_point = pc_need_status_point; + pc->statusup = pc_statusup; + pc->statusup2 = pc_statusup2; + pc->skillup = pc_skillup; + pc->allskillup = pc_allskillup; + pc->resetlvl = pc_resetlvl; + pc->resetstate = pc_resetstate; + pc->resetskill = pc_resetskill; + pc->resetfeel = pc_resetfeel; + pc->resethate = pc_resethate; + pc->equipitem = pc_equipitem; + pc->unequipitem = pc_unequipitem; + pc->checkitem = pc_checkitem; + pc->useitem = pc_useitem; + + pc->skillatk_bonus = pc_skillatk_bonus; + pc->skillheal_bonus = pc_skillheal_bonus; + pc->skillheal2_bonus = pc_skillheal2_bonus; + + pc->damage = pc_damage; + pc->dead = pc_dead; + pc->revive = pc_revive; + pc->heal = pc_heal; + pc->itemheal = pc_itemheal; + pc->percentheal = pc_percentheal; + pc->jobchange = pc_jobchange; + pc->setoption = pc_setoption; + pc->setcart = pc_setcart; + pc->setfalcon = pc_setfalcon; + pc->setriding = pc_setriding; + pc->setmadogear = pc_setmadogear; + pc->changelook = pc_changelook; + pc->equiplookall = pc_equiplookall; + + pc->readparam = pc_readparam; + pc->setparam = pc_setparam; + pc->readreg = pc_readreg; + pc->setreg = pc_setreg; + pc->readregstr = pc_readregstr; + pc->setregstr = pc_setregstr; + pc->readregistry = pc_readregistry; + pc->setregistry = pc_setregistry; + pc->readregistry_str = pc_readregistry_str; + pc->setregistry_str = pc_setregistry_str; + + pc->addeventtimer = pc_addeventtimer; + pc->deleventtimer = pc_deleventtimer; + pc->cleareventtimer = pc_cleareventtimer; + pc->addeventtimercount = pc_addeventtimercount; + + pc->calc_pvprank = pc_calc_pvprank; + pc->calc_pvprank_timer = pc_calc_pvprank_timer; + + pc->ismarried = pc_ismarried; + pc->marriage = pc_marriage; + pc->divorce = pc_divorce; + pc->get_partner = pc_get_partner; + pc->get_father = pc_get_father; + pc->get_mother = pc_get_mother; + pc->get_child = pc_get_child; + + pc->bleeding = pc_bleeding; + pc->regen = pc_regen; + + pc->setstand = pc_setstand; + pc->candrop = pc_candrop; + + pc->jobid2mapid = pc_jobid2mapid; // Skotlex + pc->mapid2jobid = pc_mapid2jobid; // Skotlex + + pc->job_name = job_name; + + pc->setinvincibletimer = pc_setinvincibletimer; + pc->delinvincibletimer = pc_delinvincibletimer; + + pc->addspiritball = pc_addspiritball; + pc->delspiritball = pc_delspiritball; + pc->addfame = pc_addfame; + pc->famerank = pc_famerank; + pc->set_hate_mob = pc_set_hate_mob; + + pc->readdb = pc_readdb; + pc->do_init_pc = do_init_pc; + pc->do_final_pc = do_final_pc; + pc->map_day_timer = map_day_timer; // by [yor] + pc->map_night_timer = map_night_timer; // by [yor] + // Rental System + pc->inventory_rentals = pc_inventory_rentals; + pc->inventory_rental_clear = pc_inventory_rental_clear; + pc->inventory_rental_add = pc_inventory_rental_add; + + pc->disguise = pc_disguise; + pc->isautolooting = pc_isautolooting; + + pc->overheat = pc_overheat; + + pc->banding = pc_banding; + + pc->itemcd_do = pc_itemcd_do; + + pc->load_combo = pc_load_combo; + + pc->add_charm = pc_add_charm; + pc->del_charm = pc_del_charm; + + pc->baselevelchanged = pc_baselevelchanged; +#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) + pc->level_penalty_mod = pc_level_penalty_mod; +#endif +} |