diff options
Diffstat (limited to 'src/map/mob.c')
-rw-r--r-- | src/map/mob.c | 402 |
1 files changed, 187 insertions, 215 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index ceb00a6ce..8e956adc1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -134,7 +134,7 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) nd->bl.id = md->tomb_nid = npc->get_new_npc_id(); - nd->dir = md->ud.dir; + nd->dir = md->ud.dir; nd->bl.m = md->bl.m; nd->bl.x = md->bl.x; nd->bl.y = md->bl.y; @@ -154,24 +154,24 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) else nd->u.tomb.killer_name[0] = '\0'; - iMap->addnpc(nd->bl.m, nd); - iMap->addblock(&nd->bl); - iStatus->set_viewdata(&nd->bl, nd->class_); - clif->spawn(&nd->bl); + map->addnpc(nd->bl.m, nd); + map->addblock(&nd->bl); + status->set_viewdata(&nd->bl, nd->class_); + clif->spawn(&nd->bl); } void mvptomb_destroy(struct mob_data *md) { struct npc_data *nd; - if ( (nd = iMap->id2nd(md->tomb_nid)) ) { + if ( (nd = map->id2nd(md->tomb_nid)) ) { int16 m, i; m = nd->bl.m; clif->clearunit_area(&nd->bl,CLR_OUTSIGHT); - iMap->delblock(&nd->bl); + map->delblock(&nd->bl); ARR_FIND( 0, maplist[m].npc_num, i, maplist[m].npc[i] == nd ); if( !(i == maplist[m].npc_num) ) { @@ -180,7 +180,7 @@ void mvptomb_destroy(struct mob_data *md) { maplist[m].npc[maplist[m].npc_num] = NULL; } - iMap->deliddb(&nd->bl); + map->deliddb(&nd->bl); aFree(nd); } @@ -281,11 +281,11 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { md->spawn_timer = INVALID_TIMER; md->deletetimer = INVALID_TIMER; md->skill_idx = -1; - iStatus->set_viewdata(&md->bl, md->class_); - iStatus->change_init(&md->bl); + status->set_viewdata(&md->bl, md->class_); + status->change_init(&md->bl); unit->dataset(&md->bl); - iMap->addiddb(&md->bl); + map->addiddb(&md->bl); return md; } @@ -356,7 +356,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) if( !(sd = BL_CAST(BL_PC,s_bl)) ) return false; // Master is not PC - t_bl = iMap->id2bl(md->target_id); + t_bl = map->id2bl(md->target_id); if( !t_bl || (s_bl = battle->get_master(t_bl)) == NULL ) s_bl = t_bl; @@ -383,7 +383,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) (sce->val2 == 3 && sce->val4 && sce->val4 != t_sd->status.guild_id)) ) break; - if( (pl_sd = iMap->id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m ) + if( (pl_sd = map->id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m ) break; if( !pl_sd->state.noks ) @@ -410,7 +410,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) return true; } while(0); - iStatus->change_start(target, SC_KSPROTECTED, 10000, sd->bl.id, sd->state.noks, sd->status.party_id, sd->status.guild_id, battle_config.ksprotection, 0); + status->change_start(target, SC_KSPROTECTED, 10000, sd->bl.id, sd->state.noks, sd->status.party_id, sd->status.guild_id, battle_config.ksprotection, 0); return false; } @@ -439,11 +439,11 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int // Locate spot next to player. if (bl && (x < 0 || y < 0)) - iMap->search_freecell(bl, m, &x, &y, 1, 1, 0); + map->search_freecell(bl, m, &x, &y, 1, 1, 0); // if none found, pick random position on map - if (x <= 0 || y <= 0 || iMap->getcell(m,x,y,CELL_CHKNOREACH)) - iMap->search_freecell(NULL, m, &x, &y, -1, -1, 1); + if (x <= 0 || y <= 0 || map->getcell(m,x,y,CELL_CHKNOREACH)) + map->search_freecell(NULL, m, &x, &y, -1, -1, 1); data.x = x; data.y = y; @@ -535,7 +535,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 x = rnd()%(x1-x0+1)+x0; y = rnd()%(y1-y0+1)+y0; j++; - } while (iMap->getcell(m,x,y,CELL_CHKNOPASS) && j < max); + } while (map->getcell(m,x,y,CELL_CHKNOPASS) && j < max); if (j == max) {// attempt to find an available cell failed @@ -561,7 +561,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 *------------------------------------------*/ int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data) { //Needed because the guild_data may not be available at guardian spawn time. - struct block_list* bl = iMap->id2bl(id); + struct block_list* bl = map->id2bl(id); struct mob_data* md; struct guild* g; int guardup_lv; @@ -619,7 +619,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam memset(&data, 0, sizeof(struct spawn_data)); data.num = 1; - m=iMap->mapname2mapid(mapname); + m=map->mapname2mapid(mapname); if(m<0) { @@ -642,7 +642,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam return 0; } - if((x<=0 || y<=0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1)) { + if((x<=0 || y<=0) && !map->search_freecell(NULL, m, &x, &y, -1,-1, 1)) { ShowWarning("mob_spawn_guardian: Couldn't locate a spawn cell for guardian class %d (index %d) at castle map %s\n",class_, guardian, maplist[m].name); return 0; } @@ -665,7 +665,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam if( has_index && gc->guardian[guardian].id ) { //Check if guardian already exists, refuse to spawn if so. - struct mob_data *md2 = (TBL_MOB*)iMap->id2bl(gc->guardian[guardian].id); + struct mob_data *md2 = (TBL_MOB*)map->id2bl(gc->guardian[guardian].id); if (md2 && md2->bl.type == BL_MOB && md2->guardian_data && md2->guardian_data->number == guardian @@ -716,8 +716,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int struct spawn_data data; int16 m; - if( (m = iMap->mapname2mapid(mapname)) < 0 ) - { + if( (m = map->mapname2mapid(mapname)) < 0 ) { ShowWarning("mob_spawn_bg: Map [%s] not found.\n", mapname); return 0; } @@ -732,7 +731,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int } data.class_ = class_; - if( (x <= 0 || y <= 0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1) ) { + if( (x <= 0 || y <= 0) && !map->search_freecell(NULL, m, &x, &y, -1,-1, 1) ) { ShowWarning("mob_spawn_bg: Couldn't locate a spawn cell for guardian class %d (bg_id %d) at map %s\n",class_, bg_id, maplist[m].name); return 0; } @@ -810,9 +809,8 @@ int mob_linksearch(struct block_list *bl,va_list ap) /*========================================== * mob spawn with delay (timer function) *------------------------------------------*/ -int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list* bl = iMap->id2bl(id); +int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list* bl = map->id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); if( md ) @@ -894,7 +892,7 @@ int mob_spawn (struct mob_data *md) unit->remove_map(&md->bl,CLR_RESPAWN,ALC_MARK); else if (md->spawn && md->class_ != md->spawn->class_) { md->class_ = md->spawn->class_; - iStatus->set_viewdata(&md->bl, md->class_); + status->set_viewdata(&md->bl, md->class_); md->db = mob->db(md->class_); memcpy(md->name,md->spawn->name,NAME_LENGTH); } @@ -904,18 +902,17 @@ int mob_spawn (struct mob_data *md) md->bl.x = md->spawn->x; md->bl.y = md->spawn->y; - if( (md->bl.x == 0 && md->bl.y == 0) || md->spawn->xs || md->spawn->ys ) - { //Monster can be spawned on an area. - if( !iMap->search_freecell(&md->bl, -1, &md->bl.x, &md->bl.y, md->spawn->xs, md->spawn->ys, battle_config.no_spawn_on_player?4:0) ) - { // retry again later + if( (md->bl.x == 0 && md->bl.y == 0) || md->spawn->xs || md->spawn->ys ) { + //Monster can be spawned on an area. + if( !map->search_freecell(&md->bl, -1, &md->bl.x, &md->bl.y, md->spawn->xs, md->spawn->ys, battle_config.no_spawn_on_player?4:0) ) { + // retry again later if( md->spawn_timer != INVALID_TIMER ) timer->delete(md->spawn_timer, mob->delayspawn); md->spawn_timer = timer->add(tick+5000,mob->delayspawn,md->bl.id,0); return 1; } - } - else if( battle_config.no_spawn_on_player > 99 && iMap->foreachinrange(mob->count_sub, &md->bl, AREA_SIZE, BL_PC) ) - { // retry again later (players on sight) + } else if( battle_config.no_spawn_on_player > 99 && map->foreachinrange(mob->count_sub, &md->bl, AREA_SIZE, BL_PC) ) { + // retry again later (players on sight) if( md->spawn_timer != INVALID_TIMER ) timer->delete(md->spawn_timer, mob->delayspawn); md->spawn_timer = timer->add(tick+5000,mob->delayspawn,md->bl.id,0); @@ -965,7 +962,7 @@ int mob_spawn (struct mob_data *md) if ( md->tomb_nid ) mob->mvptomb_destroy(md); - iMap->addblock(&md->bl); + map->addblock(&md->bl); if( maplist[md->bl.m].users ) clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); @@ -1017,7 +1014,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) if(md->target_id && !mob->can_changetarget(md, bl, status_get_mode(&md->bl))) return 0; - if(!iStatus->check_skilluse(&md->bl, bl, 0, 0)) + if(!status->check_skilluse(&md->bl, bl, 0, 0)) return 0; md->target_id = bl->id; // Since there was no disturbance, it locks on to target. @@ -1045,10 +1042,10 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) mode= va_arg(ap,int); //If can't seek yet, not an enemy, or you can't attack it, skip. - if ((*target) == bl || !iStatus->check_skilluse(&md->bl, bl, 0, 0)) + if ((*target) == bl || !status->check_skilluse(&md->bl, bl, 0, 0)) return 0; - if ((mode&MD_TARGETWEAK) && iStatus->get_lv(bl) >= md->level-5) + if ((mode&MD_TARGETWEAK) && status->get_lv(bl) >= md->level-5) return 0; if(battle->check_target(&md->bl,bl,BCT_ENEMY)<=0) @@ -1094,8 +1091,7 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) /*========================================== * chase target-change routine. *------------------------------------------*/ -int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) -{ +int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) { struct mob_data *md; struct block_list **target; @@ -1104,9 +1100,10 @@ int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) target= va_arg(ap,struct block_list**); //If can't seek yet, not an enemy, or you can't attack it, skip. - if ((*target) == bl || - battle->check_target(&md->bl,bl,BCT_ENEMY)<=0 || - !iStatus->check_skilluse(&md->bl, bl, 0, 0)) + if( *target == bl + || battle->check_target(&md->bl,bl,BCT_ENEMY) <= 0 + || !status->check_skilluse(&md->bl, bl, 0, 0) + ) return 0; if(battle->check_range (&md->bl, bl, md->status.rhw.range)) { @@ -1128,7 +1125,7 @@ int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) { md=va_arg(ap,struct mob_data *); target= va_arg(ap,struct block_list**); - if( iStatus->check_skilluse(&md->bl, bl, 0, 0) && battle->check_target(&md->bl,bl,BCT_ENEMY)<=0 ) { + if( status->check_skilluse(&md->bl, bl, 0, 0) && battle->check_target(&md->bl,bl,BCT_ENEMY)<=0 ) { (*target) = bl; } return 1; @@ -1188,13 +1185,12 @@ int mob_warpchase_sub(struct block_list *bl,va_list ap) { /*========================================== * Processing of slave monsters *------------------------------------------*/ -int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) -{ +int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) { struct block_list *bl; - bl=iMap->id2bl(md->master_id); + bl=map->id2bl(md->master_id); - if (!bl || iStatus->isdead(bl)) { + if (!bl || status->isdead(bl)) { status_kill(&md->bl); return 1; } @@ -1223,12 +1219,12 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) return 0; // Approach master if within view range, chase back to Master's area also if standing on top of the master. - if((md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) && - unit->can_move(&md->bl)) - { + if( (md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) + && unit->can_move(&md->bl) + ) { short x = bl->x, y = bl->y; mob_stop_attack(md); - if(iMap->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1) + if(map->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1) && unit->walktoxy(&md->bl, x, y, 0)) return 1; } @@ -1247,14 +1243,14 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) if (ud) { struct block_list *tbl=NULL; if (ud->target && ud->state.attack_continue) - tbl=iMap->id2bl(ud->target); + tbl=map->id2bl(ud->target); else if (ud->skilltarget) { - tbl = iMap->id2bl(ud->skilltarget); + tbl = map->id2bl(ud->skilltarget); //Required check as skilltarget is not always an enemy. [Skotlex] if (tbl && battle->check_target(&md->bl, tbl, BCT_ENEMY) <= 0) tbl = NULL; } - if (tbl && iStatus->check_skilluse(&md->bl, tbl, 0, 0)) { + if (tbl && status->check_skilluse(&md->bl, tbl, 0, 0)) { md->target_id=tbl->id; md->min_chase=md->db->range3+distance_bl(&md->bl, tbl); if(md->min_chase>MAX_MINCHASE) @@ -1334,7 +1330,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) x+=md->bl.x; y+=md->bl.y; - if((iMap->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){ + if((map->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){ break; } } @@ -1347,8 +1343,9 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) } return 0; } - speed=iStatus->get_speed(&md->bl); - for(i=c=0;i<md->ud.walkpath.path_len;i++){ // The next walk start time is calculated. + speed=status->get_speed(&md->bl); + for(i=c=0;i<md->ud.walkpath.path_len;i++) { + // The next walk start time is calculated. if(md->ud.walkpath.path[i]&1) c+=speed*MOVE_DIAGONAL_COST/MOVE_COST; else @@ -1371,12 +1368,12 @@ int mob_warpchase(struct mob_data *md, struct block_list *target) return 0; //No need to do a warp chase. if (md->ud.walktimer != INVALID_TIMER && - iMap->getcell(md->bl.m,md->ud.to_x,md->ud.to_y,CELL_CHKNPC)) + map->getcell(md->bl.m,md->ud.to_x,md->ud.to_y,CELL_CHKNPC)) return 1; //Already walking to a warp. //Search for warps within mob's viewing range. - iMap->foreachinrange (mob->warpchase_sub, &md->bl, - md->db->range2, BL_NPC, target, &warp, &distance); + map->foreachinrange(mob->warpchase_sub, &md->bl, + md->db->range2, BL_NPC, target, &warp, &distance); if (warp && unit->walktobl(&md->bl, &warp->bl, 1, 1)) return 1; @@ -1421,17 +1418,18 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) can_move = (mode&MD_CANMOVE)&&unit->can_move(&md->bl); - if (md->target_id) - { //Check validity of current target. [Skotlex] - tbl = iMap->id2bl(md->target_id); - if (!tbl || tbl->m != md->bl.m || - (md->ud.attacktimer == INVALID_TIMER && !iStatus->check_skilluse(&md->bl, tbl, 0, 0)) || - (md->ud.walktimer != INVALID_TIMER && !(battle_config.mob_ai&0x1) && !check_distance_bl(&md->bl, tbl, md->min_chase)) || - ( - tbl->type == BL_PC && - ((((TBL_PC*)tbl)->state.gangsterparadise && !(mode&MD_BOSS)) || - ((TBL_PC*)tbl)->invincible_timer != INVALID_TIMER) - )) { //Unlock current target. + if (md->target_id) { + //Check validity of current target. [Skotlex] + tbl = map->id2bl(md->target_id); + if (!tbl || tbl->m != md->bl.m + || (md->ud.attacktimer == INVALID_TIMER && !status->check_skilluse(&md->bl, tbl, 0, 0)) + || (md->ud.walktimer != INVALID_TIMER && !(battle_config.mob_ai&0x1) && !check_distance_bl(&md->bl, tbl, md->min_chase)) + || ( tbl->type == BL_PC + && ((((TBL_PC*)tbl)->state.gangsterparadise && !(mode&MD_BOSS)) + || ((TBL_PC*)tbl)->invincible_timer != INVALID_TIMER) + ) + ) { + //Unlock current target. if (mob->warpchase(md, tbl)) return true; //Chasing this target. mob->unlocktarget(md, tick-(battle_config.mob_ai&0x8?3000:0)); //Imediately do random walk. @@ -1460,22 +1458,22 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) } } else - if( (abl = iMap->id2bl(md->attacked_id)) && (!tbl || mob->can_changetarget(md, abl, mode)) ) - { + if( (abl = map->id2bl(md->attacked_id)) && (!tbl || mob->can_changetarget(md, abl, mode)) ) { int dist; if( md->bl.m != abl->m || abl->prev == NULL - || (dist = distance_bl(&md->bl, abl)) >= MAX_MINCHASE // Attacker longer than visual area - || battle->check_target(&md->bl, abl, BCT_ENEMY) <= 0 // Attacker is not enemy of mob - || (battle_config.mob_ai&0x2 && !iStatus->check_skilluse(&md->bl, abl, 0, 0)) // Cannot normal attack back to Attacker - || (!battle->check_range(&md->bl, abl, md->status.rhw.range) // Not on Melee Range and ... - && ( // Reach check - (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1) - || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP] - || md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target. - || !mob->can_reach(md, abl, dist+md->db->range3, MSS_RUSH) - ) - ) ) - { // Rude attacked + || (dist = distance_bl(&md->bl, abl)) >= MAX_MINCHASE // Attacker longer than visual area + || battle->check_target(&md->bl, abl, BCT_ENEMY) <= 0 // Attacker is not enemy of mob + || (battle_config.mob_ai&0x2 && !status->check_skilluse(&md->bl, abl, 0, 0)) // Cannot normal attack back to Attacker + || (!battle->check_range(&md->bl, abl, md->status.rhw.range) // Not on Melee Range and ... + && ( // Reach check + (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1) + || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP] + || md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target. + || !mob->can_reach(md, abl, dist+md->db->range3, MSS_RUSH) + ) + ) + ) { + // Rude attacked if (md->state.attacked_count++ >= RUDE_ATTACKED_COUNT && !mob->skill_use(md, tick, MSC_RUDEATTACKED) && can_move && !tbl && unit->escape(&md->bl, abl, rnd()%10 +1)) @@ -1486,12 +1484,10 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) } } else - if (!(battle_config.mob_ai&0x2) && !iStatus->check_skilluse(&md->bl, abl, 0, 0)) - { + if (!(battle_config.mob_ai&0x2) && !status->check_skilluse(&md->bl, abl, 0, 0)) { //Can't attack back, but didn't invoke a rude attacked skill... - } - else - { //Attackable + } else { + //Attackable if (!tbl || dist < md->status.rhw.range || !check_distance_bl(&md->bl, tbl, dist) || battle->get_target(tbl) != md->bl.id) { //Change if the new target is closer than the actual one @@ -1516,22 +1512,19 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) return true; // Scan area for targets - if (!tbl && mode&MD_LOOTER && md->lootitem && DIFF_TICK(tick, md->ud.canact_tick) > 0 && - (md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1)) - { // Scan area for items to loot, avoid trying to loot if the mob is full and can't consume the items. - iMap->foreachinrange (mob->ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl); + if (!tbl && mode&MD_LOOTER && md->lootitem && DIFF_TICK(tick, md->ud.canact_tick) > 0 + && (md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1) + ) { + // Scan area for items to loot, avoid trying to loot if the mob is full and can't consume the items. + map->foreachinrange (mob->ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl); } - if ((!tbl && mode&MD_AGGRESSIVE) || md->state.skillstate == MSS_FOLLOW) - { - iMap->foreachinrange (mob->ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode); - } - else - if (mode&MD_CHANGECHASE && (md->state.skillstate == MSS_RUSH || md->state.skillstate == MSS_FOLLOW)) - { + if ((!tbl && mode&MD_AGGRESSIVE) || md->state.skillstate == MSS_FOLLOW) { + map->foreachinrange (mob->ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode); + } else if (mode&MD_CHANGECHASE && (md->state.skillstate == MSS_RUSH || md->state.skillstate == MSS_FOLLOW)) { int search_size; search_size = view_range<md->status.rhw.range ? view_range:md->status.rhw.range; - iMap->foreachinrange (mob->ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl); + map->foreachinrange (mob->ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl); } if (!tbl) { //No targets available. @@ -1542,7 +1535,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if( md->bg_id && mode&MD_CANATTACK ) { if( md->ud.walktimer != INVALID_TIMER ) return true;/* we are already moving */ - iMap->foreachinrange (mob->ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode); + map->foreachinrange (mob->ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode); if( tbl ) { if( distance_blxy(&md->bl, tbl->x, tbl->y) <= 3 || unit->walktobl(&md->bl, tbl, 1, 1) ) return true;/* we're moving or close enough don't unlock the target. */ @@ -1602,7 +1595,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) unit->set_walkdelay(&md->bl, tick, md->status.amotion, 1); } //Clear item. - iMap->clearflooritem (tbl); + map->clearflooritem (tbl); mob->unlocktarget (md,tick); return true; } @@ -1668,11 +1661,10 @@ int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap) /*========================================== * Serious processing for mob in PC field of view (foreachclient) *------------------------------------------*/ -int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) -{ +int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) { unsigned int tick; tick=va_arg(ap,unsigned int); - iMap->foreachinrange(mob->ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick); + map->foreachinrange(mob->ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick); return 0; } @@ -1748,22 +1740,20 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) /*========================================== * Negligent processing for mob outside PC field of view (interval timer function) *------------------------------------------*/ -int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) -{ - iMap->map_foreachmob(mob->ai_sub_lazy,tick); +int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) { + map->map_foreachmob(mob->ai_sub_lazy,tick); return 0; } /*========================================== * Serious processing for mob in PC field of view (interval timer function) *------------------------------------------*/ -int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data) -{ +int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data) { if (battle_config.mob_ai&0x20) - iMap->map_foreachmob(mob->ai_sub_lazy,tick); + map->map_foreachmob(mob->ai_sub_lazy,tick); else - iMap->map_foreachpc(mob->ai_sub_foreachclient,tick); + map->map_foreachpc(mob->ai_sub_foreachclient,tick); return 0; } @@ -1802,9 +1792,9 @@ int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) list=(struct item_drop_list *)data; ditem = list->item; while (ditem) { - iMap->addflooritem(&ditem->item_data,ditem->item_data.amount, - list->m,list->x,list->y, - list->first_charid,list->second_charid,list->third_charid,0); + map->addflooritem(&ditem->item_data,ditem->item_data.amount, + list->m,list->x,list->y, + list->first_charid,list->second_charid,list->third_charid,0); ditem_prev = ditem; ditem = ditem->next; ers_free(item_drop_ers, ditem_prev); @@ -1826,9 +1816,9 @@ void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct ite //Logs items, dropped by mobs [Lupus] logs->pick_mob(md, loot?LOG_TYPE_LOOT:LOG_TYPE_PICKDROP_MONSTER, -ditem->item_data.amount, &ditem->item_data, NULL); - sd = iMap->charid2sd(dlist->first_charid); - if( sd == NULL ) sd = iMap->charid2sd(dlist->second_charid); - if( sd == NULL ) sd = iMap->charid2sd(dlist->third_charid); + sd = map->charid2sd(dlist->first_charid); + if( sd == NULL ) sd = map->charid2sd(dlist->second_charid); + if( sd == NULL ) sd = map->charid2sd(dlist->third_charid); if( sd && (drop_rate <= sd->state.autoloot || pc->isautolooting(sd, ditem->item_data.nameid)) @@ -1850,9 +1840,8 @@ void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct ite dlist->item = ditem; } -int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list* bl = iMap->id2bl(id); +int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list* bl = map->id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); if( md ) @@ -1889,20 +1878,18 @@ int mob_deleteslave_sub(struct block_list *bl,va_list ap) /*========================================== * *------------------------------------------*/ -int mob_deleteslave(struct mob_data *md) -{ +int mob_deleteslave(struct mob_data *md) { nullpo_ret(md); - iMap->foreachinmap(mob->deleteslave_sub, md->bl.m, BL_MOB,md->bl.id); + map->foreachinmap(mob->deleteslave_sub, md->bl.m, BL_MOB,md->bl.id); return 0; } // Mob respawning through KAIZEL or NPC_REBIRTH [Skotlex] -int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list *bl = iMap->id2bl(id); +int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list *bl = map->id2bl(id); if(!bl) return 0; - iStatus->revive(bl, (uint8)data, 0); + status->revive(bl, (uint8)data, 0); return 1; } @@ -1961,9 +1948,8 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage) case BL_MOB: { struct mob_data* md2 = (TBL_MOB*)src; - if( md2->special_state.ai && md2->master_id ) - { - struct map_session_data* msd = iMap->id2sd(md2->master_id); + if( md2->special_state.ai && md2->master_id ) { + struct map_session_data* msd = map->id2sd(md2->master_id); if( msd ) char_id = msd->status.char_id; } @@ -2053,7 +2039,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { int i; for(i = 0; i < DAMAGELOG_SIZE; i++){ // must show hp bar to all char who already hit the mob. if( md->dmglog[i].id ) { - struct map_session_data *sd = iMap->charid2sd(md->dmglog[i].id); + struct map_session_data *sd = map->charid2sd(md->dmglog[i].id); if( sd && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE) ) // check if in range clif->monster_hp_bar(md,sd); } @@ -2103,7 +2089,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { mob->skill_use(md,tick,-1); } - iMap->freeblock_lock(); + map->freeblock_lock(); memset(pt,0,sizeof(pt)); @@ -2112,9 +2098,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { // filter out entries not eligible for exp distribution memset(tmpsd,0,sizeof(tmpsd)); - for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++) - { - struct map_session_data* tsd = iMap->charid2sd(md->dmglog[i].id); + for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++) { + struct map_session_data* tsd = map->charid2sd(md->dmglog[i].id); if(tsd == NULL) continue; // skip empty entries @@ -2168,7 +2153,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if (md->sc.data[SC_RICHMANKIM]) bonus += md->sc.data[SC_RICHMANKIM]->val2; if(sd) { - temp = iStatus->get_class(&md->bl); + temp = status->get_class(&md->bl); if(sd->sc.data[SC_MIRACLE]) i = 2; //All mobs are Star Targets else ARR_FIND(0, MAX_PC_FEELHATE, i, temp == sd->hate_mob[i] && @@ -2516,7 +2501,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if((temp = pc->additem(mvp_sd,&item,1,LOG_TYPE_PICKDROP_PLAYER)) != 0) { clif->additem(mvp_sd,0,0,temp); - iMap->addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1); + map->addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1); } //Logs items, MVP prizes [Lupus] @@ -2557,7 +2542,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } if( sd->status.party_id ) - iMap->foreachinrange(quest->update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_); + map->foreachinrange(quest->update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_); else if( sd->avail_quests ) quest->update_objective(sd, md->class_); @@ -2592,7 +2577,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if( md->can_summon ) mob->deleteslave(md); - iMap->freeblock_unlock(); + map->freeblock_unlock(); if( !rebirth ) { @@ -2609,7 +2594,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } - if(!md->spawn) //Tell iStatus->damage to remove it from memory. + if(!md->spawn) //Tell status->damage to remove it from memory. return 5; // Note: Actually, it's 4. Oh well... // MvP tomb [GreenBox] @@ -2617,7 +2602,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { mob->mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL)); if( !rebirth ) { - iStatus->change_clear(&md->bl,1); + status->change_clear(&md->bl,1); mob->setdelayspawn(md); //Set respawning. } return 3; //Remove from map. @@ -2634,7 +2619,7 @@ void mob_revive(struct mob_data *md, unsigned int hp) memset(md->dmglog, 0, sizeof(md->dmglog)); // Reset the damage done on the rebirthed monster, otherwise will grant full exp + damage done. [Valaris] md->tdmg = 0; if (!md->bl.prev) - iMap->addblock(&md->bl); + map->addblock(&md->bl); clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); mob->skill_use(md, tick, MSC_SPAWN); @@ -2745,7 +2730,7 @@ int mob_class_change (struct mob_data *md, int class_) mob_stop_attack(md); mob_stop_walking(md, 0); unit->skillcastcancel(&md->bl, 0); - iStatus->set_viewdata(&md->bl, class_); + status->set_viewdata(&md->bl, class_); clif->class_change(&md->bl, md->vd->class_, 1); status_calc_mob(md, 1); md->ud.state.speed_changed = 1; //Speed change update. @@ -2785,8 +2770,7 @@ void mob_heal(struct mob_data *md,unsigned int heal) /*========================================== * Added by RoVeRT *------------------------------------------*/ -int mob_warpslave_sub(struct block_list *bl,va_list ap) -{ +int mob_warpslave_sub(struct block_list *bl,va_list ap) { struct mob_data *md=(struct mob_data *)bl; struct block_list *master; short x,y,range=0; @@ -2796,7 +2780,7 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap) if(md->master_id!=master->id) return 0; - iMap->search_freecell(master, 0, &x, &y, range, range, 0); + map->search_freecell(master, 0, &x, &y, range, range, 0); unit->warp(&md->bl, master->m, x, y,CLR_RESPAWN); return 1; } @@ -2806,12 +2790,11 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap) * Warps slaves. Range is the area around the master that they can * appear in randomly. *------------------------------------------*/ -int mob_warpslave(struct block_list *bl, int range) -{ +int mob_warpslave(struct block_list *bl, int range) { if (range < 1) range = 1; //Min range needed to avoid crashes and stuff. [Skotlex] - return iMap->foreachinmap(mob->warpslave_sub, bl->m, BL_MOB, bl, range); + return map->foreachinmap(mob->warpslave_sub, bl->m, BL_MOB, bl, range); } /*========================================== @@ -2832,9 +2815,8 @@ int mob_countslave_sub(struct block_list *bl,va_list ap) /*========================================== * Counts the number of slaves a mob has on the map. *------------------------------------------*/ -int mob_countslave(struct block_list *bl) -{ - return iMap->foreachinmap(mob->countslave_sub, bl->m, BL_MOB,bl->id); +int mob_countslave(struct block_list *bl) { + return map->foreachinmap(mob->countslave_sub, bl->m, BL_MOB,bl->id); } /*========================================== @@ -2881,7 +2863,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id) if (mob->db_checkid(data.class_) == 0) continue; - if (iMap->search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) { + if (map->search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) { data.x = x; data.y = y; } else { @@ -2980,8 +2962,7 @@ int mob_getfriendhprate_sub(struct block_list *bl,va_list ap) (*fr) = bl; return 1; } -struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_rate) -{ +struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_rate) { struct block_list *fr=NULL; int type = BL_MOB; @@ -2990,17 +2971,15 @@ struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_ if (md->special_state.ai) //Summoned creatures. [Skotlex] type = BL_PC; - iMap->foreachinrange(mob->getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr); + map->foreachinrange(mob->getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr); return fr; } /*========================================== * Check hp rate of its master *------------------------------------------*/ -struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int rate) -{ - if( md && md->master_id > 0 ) - { - struct block_list *bl = iMap->id2bl(md->master_id); +struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int rate) { + if( md && md->master_id > 0 ) { + struct block_list *bl = map->id2bl(md->master_id); if( bl && get_percentage(status_get_hp(bl), status_get_max_hp(bl)) < rate ) return bl; } @@ -3042,12 +3021,11 @@ int mob_getfriendstatus_sub(struct block_list *bl,va_list ap) return 0; } -struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2) -{ +struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2) { struct mob_data* fr = NULL; nullpo_ret(md); - iMap->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr); + map->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr); return fr; } @@ -3149,7 +3127,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) case MSC_MASTERHPLTMAXRATE: flag = ((fbl = mob->getmasterhpltmaxrate(md, ms[i].cond2)) != NULL); break; case MSC_MASTERATTACKED: - flag = (md->master_id > 0 && (fbl=iMap->id2bl(md->master_id)) && unit->counttargeted(fbl) > 0); break; + flag = (md->master_id > 0 && (fbl=map->id2bl(md->master_id)) && unit->counttargeted(fbl) > 0); break; case MSC_ALCHEMIST: flag = (md->state.alchemist); break; @@ -3172,12 +3150,12 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) case MST_AROUND6: case MST_AROUND7: case MST_AROUND8: - bl = iMap->id2bl(md->target_id); + bl = map->id2bl(md->target_id); break; case MST_MASTER: bl = &md->bl; if (md->master_id) - bl = iMap->id2bl(md->master_id); + bl = map->id2bl(md->master_id); if (bl) //Otherwise, fall through. break; case MST_FRIEND: @@ -3196,14 +3174,14 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) j = ms[i].target >= MST_AROUND1? (ms[i].target-MST_AROUND1) +1: (ms[i].target-MST_AROUND5) +1; - iMap->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3); + map->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3); } md->skill_idx = i; - iMap->freeblock_lock(); - if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || - !unit->skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) - { - iMap->freeblock_unlock(); + map->freeblock_lock(); + if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) + || !unit->skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) + ) { + map->freeblock_unlock(); continue; } } else { @@ -3214,12 +3192,12 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv)); break; case MST_TARGET: - bl = iMap->id2bl(md->target_id); + bl = map->id2bl(md->target_id); break; case MST_MASTER: bl = &md->bl; if (md->master_id) - bl = iMap->id2bl(md->master_id); + bl = map->id2bl(md->master_id); if (bl) //Otherwise, fall through. break; case MST_FRIEND: @@ -3237,11 +3215,11 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) if (!bl) continue; md->skill_idx = i; - iMap->freeblock_lock(); - if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || - !unit->skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) - { - iMap->freeblock_unlock(); + map->freeblock_lock(); + if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) + || !unit->skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) + ) { + map->freeblock_unlock(); continue; } } @@ -3261,7 +3239,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) md->skilldelay[j]=tick; } else md->skilldelay[i]=tick; - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } //No skill was used. @@ -3338,7 +3316,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons strcpy(db->sprite,sd->status.name); strcpy(db->name,sd->status.name); strcpy(db->jname,sd->status.name); - db->lv=iStatus->get_lv(&sd->bl); + db->lv=status->get_lv(&sd->bl); memcpy(mstatus, &sd->base_status, sizeof(struct status_data)); mstatus->rhw.atk2= mstatus->dex + mstatus->rhw.atk + mstatus->rhw.atk2; //Max ATK mstatus->rhw.atk = mstatus->dex; //Min ATK @@ -3373,7 +3351,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons int idx = skill_tree[pc->class2idx(sd->status.class_)][j].idx; skill_id = skill_tree[pc->class2idx(sd->status.class_)][j].id; if (!skill_id || sd->status.skill[idx].lv < 1 || - (skill_db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL)) + (skill->db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL)) ) continue; for(h = 0; h < maplist[sd->bl.m].zone->disabled_skills_count; h++) { @@ -3406,7 +3384,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons ms[i].casttime = skill->cast_fix(&sd->bl,skill_id, ms[i].skill_lv); ms[i].delay = 5000+skill->delay_fix(&sd->bl,skill_id, ms[i].skill_lv); - inf = skill_db[idx].inf; + inf = skill->db[idx].inf; if (inf&INF_ATTACK_SKILL) { ms[i].target = MST_TARGET; ms[i].cond1 = MSC_ALWAYS; @@ -3747,7 +3725,7 @@ bool mob_parse_dbrow(char** str) { data.bl.type = BL_MOB; data.level = db->lv; memcpy(&data.status, mstatus, sizeof(struct status_data)); - iStatus->calc_misc(&data.bl, mstatus, db->lv); + status->calc_misc(&data.bl, mstatus, db->lv); // MVP EXP Bonus: MEXP // Some new MVP's MEXP multipled by high exp-rate cause overflow. [LuzZza] @@ -3891,22 +3869,21 @@ void mob_readdb(void) { for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { if(fi > 0) { char filepath[256]; - sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + sprintf(filepath, "%s/%s", map->db_path, filename[fi]); if(!exists(filepath)) { continue; } } - sv->readdb(iMap->db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, mob->readdb_sub); + sv->readdb(map->db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, mob->readdb_sub); } } /*========================================== * mob_db table reading *------------------------------------------*/ -int mob_read_sqldb(void) -{ - const char* mob_db_name[] = { iMap->mob_db_db, iMap->mob_db2_db }; +int mob_read_sqldb(void) { + const char* mob_db_name[] = { map->mob_db_db, map->mob_db2_db }; int fi; for( fi = 0; fi < ARRAYLENGTH(mob_db_name); ++fi ) { @@ -4014,7 +3991,7 @@ int mob_read_randommonster(void) for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ ) { unsigned int count = 0; mob->db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one - sprintf(line, "%s/%s", iMap->db_path, mobfile[i]); + sprintf(line, "%s/%s", map->db_path, mobfile[i]); fp=fopen(line,"r"); if(fp==NULL){ ShowError("can't read %s\n",line); @@ -4127,7 +4104,7 @@ void mob_readchatdb(void) { char line[1024], filepath[256]; int i, tmp=0; FILE *fp; - sprintf(filepath, "%s/%s", iMap->db_path, arc); + sprintf(filepath, "%s/%s", map->db_path, arc); fp=fopen(filepath, "r"); if(fp == NULL) { ShowWarning("mob_readchatdb: File not found \"%s\", skipping.\n", filepath); @@ -4344,13 +4321,13 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current) if ( skill->get_casttype2(sidx) == CAST_GROUND) {//Ground skill. if (ms->target > MST_AROUND) { ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target for ground skill %d (%s) for %s.\n", - ms->skill_id, skill_db[sidx].name, + ms->skill_id, skill->db[sidx].name, mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite); ms->target = MST_TARGET; } } else if (ms->target > MST_MASTER) { ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target 'around' for non-ground skill %d (%s) for %s.\n", - ms->skill_id, skill_db[sidx].name, + ms->skill_id, skill->db[sidx].name, mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite); ms->target = MST_TARGET; } @@ -4448,13 +4425,13 @@ void mob_readskilldb(void) { for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { if(fi > 0) { char filepath[256]; - sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + sprintf(filepath, "%s/%s", map->db_path, filename[fi]); if(!exists(filepath)) { continue; } } - sv->readdb(iMap->db_path, filename[fi], ',', 19, 19, -1, mob->parse_row_mobskilldb); + sv->readdb(map->db_path, filename[fi], ',', 19, 19, -1, mob->parse_row_mobskilldb); } } @@ -4463,9 +4440,8 @@ void mob_readskilldb(void) { * not overly sure if this is all correct * seems to work though... */ -int mob_read_sqlskilldb(void) -{ - const char* mob_skill_db_name[] = { iMap->mob_skill_db_db, iMap->mob_skill_db2_db }; +int mob_read_sqlskilldb(void) { + const char* mob_skill_db_name[] = { map->mob_skill_db_db, map->mob_skill_db2_db }; int fi; if( battle_config.mob_skill_rate == 0 ) { @@ -4568,24 +4544,20 @@ bool mob_readdb_itemratio(char* str[], int columns, int current) * read all mob-related databases */ void mob_load(void) { - sv->readdb(iMap->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, mob->readdb_itemratio); // must be read before mobdb + sv->readdb(map->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, mob->readdb_itemratio); // must be read before mobdb mob->readchatdb(); - if (iMap->db_use_sql_mob_db) - { + if (map->db_use_sql_mob_db) { mob->read_sqldb(); } - if (iMap->db_use_sql_mob_skill_db) - { + if (map->db_use_sql_mob_skill_db) { mob->read_sqlskilldb(); - } - else - { + } else { mob->readdb(); mob->readskilldb(); } - sv->readdb(iMap->db_path, "mob_avail.txt", ',', 2, 12, -1, mob->readdb_mobavail); + sv->readdb(map->db_path, "mob_avail.txt", ',', 2, 12, -1, mob->readdb_mobavail); mob->read_randommonster(); - sv->readdb(iMap->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, mob->readdb_race2); + sv->readdb(map->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, mob->readdb_race2); } void mob_reload(void) { |