summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-09-27 05:30:37 +0200
committerHaru <haru@dotalux.com>2013-09-27 05:30:37 +0200
commitb89f58edd8b368e2548ace86f06354bd6ea1c8d2 (patch)
tree2f30953a986a2690c333370d99232a43853a1781 /src/map/mob.c
parent17bc1fab375f8ecc951fbba058a346b1460bf783 (diff)
downloadhercules-b89f58edd8b368e2548ace86f06354bd6ea1c8d2.tar.gz
hercules-b89f58edd8b368e2548ace86f06354bd6ea1c8d2.tar.bz2
hercules-b89f58edd8b368e2548ace86f06354bd6ea1c8d2.tar.xz
hercules-b89f58edd8b368e2548ace86f06354bd6ea1c8d2.zip
Renamed iMap interface to map
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c282
1 files changed, 127 insertions, 155 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index ff949a3ff..b41f7488f 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -154,8 +154,8 @@ 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);
+ map->addnpc(nd->bl.m, nd);
+ map->addblock(&nd->bl);
status->set_viewdata(&nd->bl, nd->class_);
clif->spawn(&nd->bl);
@@ -164,14 +164,14 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
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);
}
@@ -285,7 +285,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) {
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 )
@@ -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 )
@@ -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);
@@ -1188,11 +1185,10 @@ 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 || status->isdead(bl)) {
status_kill(&md->bl);
@@ -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,9 +1243,9 @@ 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;
@@ -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;
}
}
@@ -1372,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;
@@ -1424,7 +1420,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
if (md->target_id) {
//Check validity of current target. [Skotlex]
- tbl = iMap->id2bl(md->target_id);
+ 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))
@@ -1462,8 +1458,7 @@ 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
@@ -1517,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.
@@ -1543,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. */
@@ -1603,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;
}
@@ -1669,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;
}
@@ -1749,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;
}
@@ -1803,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);
@@ -1827,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))
@@ -1851,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 )
@@ -1890,16 +1878,15 @@ 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);
+ struct block_list *bl = map->id2bl(id);
if(!bl) return 0;
status->revive(bl, (uint8)data, 0);
@@ -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
@@ -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 ) {
@@ -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);
@@ -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.
@@ -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);
@@ -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) {