diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 132 | ||||
-rw-r--r-- | src/map/battle.c | 22 | ||||
-rw-r--r-- | src/map/clif.c | 20 | ||||
-rw-r--r-- | src/map/guild.c | 2 | ||||
-rw-r--r-- | src/map/itemdb.c | 2 | ||||
-rw-r--r-- | src/map/map.c | 7 | ||||
-rw-r--r-- | src/map/mob.c | 791 | ||||
-rw-r--r-- | src/map/mob.h | 183 | ||||
-rw-r--r-- | src/map/npc.c | 94 | ||||
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/map/pet.c | 8 | ||||
-rw-r--r-- | src/map/script.c | 106 | ||||
-rw-r--r-- | src/map/skill.c | 106 | ||||
-rw-r--r-- | src/map/status.c | 26 | ||||
-rw-r--r-- | src/map/unit.c | 26 |
15 files changed, 837 insertions, 690 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index df97740e1..6b62f6325 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1929,8 +1929,8 @@ ACMD(monster) return false; } - if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number) - mob_id = mobdb_checkid(atoi(monster)); + if ((mob_id = mob->db_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number) + mob_id = mob->db_checkid(atoi(monster)); if (mob_id == 0) { clif->message(fd, msg_txt(40)); // Invalid monster ID or name. @@ -1966,7 +1966,7 @@ ACMD(monster) range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { iMap->search_freecell(&sd->bl, 0, &mx, &my, range, range, 0); - k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE); + k = mob->once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE); count += (k != 0) ? 1 : 0; } @@ -2553,7 +2553,7 @@ ACMD(makeegg) if ((item_data = itemdb->search_name(message)) != NULL) // for egg name id = item_data->nameid; else - if ((id = mobdb_searchname(message)) != 0) // for monster name + if ((id = mob->db_searchname(message)) != 0) // for monster name ; else id = atoi(message); @@ -2565,7 +2565,7 @@ ACMD(makeegg) sd->catch_target_class = pet_db[pet_id].class_; intif->create_pet( sd->status.account_id, sd->status.char_id, - (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv, + (short)pet_db[pet_id].class_, (short)mob->db(pet_db[pet_id].class_)->lv, (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } else { @@ -3595,7 +3595,7 @@ ACMD(reloaditemdb) *------------------------------------------*/ ACMD(reloadmobdb) { nullpo_retr(-1, sd); - mob_reload(); + mob->reload(); read_petdb(); homun->reload(); mercenary->read_db(); @@ -3689,7 +3689,7 @@ ACMD(reloadbattleconf) || prev_config.job_exp_rate != battle_config.job_exp_rate ) { // Exp or Drop rates changed. - mob_reload(); //Needed as well so rate changes take effect. + mob->reload(); //Needed as well so rate changes take effect. chrif->ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common); } clif->message(fd, msg_txt(255)); @@ -4744,10 +4744,10 @@ ACMD(disguise) if ((id = atoi(message)) > 0) { //Acquired an ID - if (!mobdb_checkid(id) && !npcdb_checkid(id)) + if (!mob->db_checkid(id) && !npcdb_checkid(id)) id = 0; //Invalid id for either mobs or npcs. } else { //Acquired a Name - if ((id = mobdb_searchname(message)) == 0) + if ((id = mob->db_searchname(message)) == 0) { struct npc_data* nd = npc_name2id(message); if (nd != NULL) @@ -4788,10 +4788,10 @@ ACMD(disguiseall) return false; } - if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number) + if ((mob_id = mob->db_searchname(message)) == 0) // check name first (to avoid possible name begining by a number) mob_id = atoi(message); - if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc... + if (!mob->db_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc... clif->message(fd, msg_txt(123)); // Monster/NPC name/id not found. return false; } @@ -4824,10 +4824,10 @@ ACMD(disguiseguild) } if( (id = atoi(monster)) > 0 ) { - if( !mobdb_checkid(id) && !npcdb_checkid(id) ) + if( !mob->db_checkid(id) && !npcdb_checkid(id) ) id = 0; } else { - if( (id = mobdb_searchname(monster)) == 0 ) { + if( (id = mob->db_searchname(monster)) == 0 ) { struct npc_data* nd = npc_name2id(monster); if( nd != NULL ) id = nd->class_; @@ -6091,14 +6091,14 @@ ACMD(mobsearch) } if ((mob_id = atoi(mob_name)) == 0) - mob_id = mobdb_searchname(mob_name); - if(mob_id > 0 && mobdb_checkid(mob_id) == 0){ + mob_id = mob->db_searchname(mob_name); + if(mob_id > 0 && mob->db_checkid(mob_id) == 0){ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1219),mob_name); // Invalid mob ID %s! clif->message(fd, atcmd_output); return false; } - if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname) - strcpy(mob_name,mob_db(mob_id)->jname); // --ja-- + if(mob_id == atoi(mob_name) && mob->db(mob_id)->jname) + strcpy(mob_name,mob->db(mob_id)->jname); // --ja-- // strcpy(mob_name,mob_db(mob_id)->name); // --en-- snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s @@ -6355,23 +6355,23 @@ ACMD(summon) duration =60; if ((mob_id = atoi(name)) == 0) - mob_id = mobdb_searchname(name); - if(mob_id == 0 || mobdb_checkid(mob_id) == 0) + mob_id = mob->db_searchname(name); + if(mob_id == 0 || mob->db_checkid(mob_id) == 0) { clif->message(fd, msg_txt(40)); // Invalid monster ID or name. return false; } - md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE); + md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE); if(!md) return false; md->master_id=sd->bl.id; md->special_state.ai=1; - md->deletetimer=iTimer->add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0); + md->deletetimer=iTimer->add_timer(tick+(duration*60000),mob->timer_delete,md->bl.id,0); clif->specialeffect(&md->bl,344,AREA); - mob_spawn(md); + mob->spawn(md); sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000); clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick); clif->message(fd, msg_txt(39)); // All monster summoned! @@ -6643,7 +6643,7 @@ ACMD(mobinfo) unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"}; char atcmd_output2[CHAT_SIZE_MAX]; struct item_data *item_data; - struct mob_db *mob, *mob_array[MAX_SEARCH]; + struct mob_db *monster, *mob_array[MAX_SEARCH]; int count; int i, j, k; @@ -6656,11 +6656,11 @@ ACMD(mobinfo) } // If monster identifier/name argument is a name - if ((i = mobdb_checkid(atoi(message)))) { - mob_array[0] = mob_db(i); + if ((i = mob->db_checkid(atoi(message)))) { + mob_array[0] = mob->db(i); count = 1; } else - count = mobdb_searchname_array(mob_array, MAX_SEARCH, message, 0); + count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0); if (!count) { clif->message(fd, msg_txt(40)); // Invalid monster ID or name. @@ -6676,37 +6676,37 @@ ACMD(mobinfo) for (k = 0; k < count; k++) { unsigned int job_exp, base_exp; - mob = mob_array[k]; + monster = mob_array[k]; - job_exp = mob->job_exp; - base_exp = mob->base_exp; + job_exp = monster->job_exp; + base_exp = monster->base_exp; #ifdef RENEWAL_EXP if( battle_config.atcommand_mobinfo_type ) { - base_exp = base_exp * pc->level_penalty_mod(mob->lv - sd->status.base_level, mob->status.race, mob->status.mode, 1) / 100; - job_exp = job_exp * pc->level_penalty_mod(mob->lv - sd->status.base_level, mob->status.race, mob->status.mode, 1) / 100; + base_exp = base_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100; + job_exp = job_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100; } #endif // stats - if (mob->mexp) - sprintf(atcmd_output, msg_txt(1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d) + if (monster->mexp) + sprintf(atcmd_output, msg_txt(1240), monster->name, monster->jname, monster->sprite, monster->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d) else - sprintf(atcmd_output, msg_txt(1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d) + sprintf(atcmd_output, msg_txt(1241), monster->name, monster->jname, monster->sprite, monster->vd.class_); // Monster: '%s'/'%s'/'%s' (%d) clif->message(fd, atcmd_output); - sprintf(atcmd_output, msg_txt(1242), mob->lv, mob->status.max_hp, base_exp, job_exp,MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d + sprintf(atcmd_output, msg_txt(1242), monster->lv, monster->status.max_hp, base_exp, job_exp, MOB_HIT(monster), MOB_FLEE(monster)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d clif->message(fd, atcmd_output); sprintf(atcmd_output, msg_txt(1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d - mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi, - mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk); + monster->status.def, monster->status.mdef, monster->status.str, monster->status.agi, + monster->status.vit, monster->status.int_, monster->status.dex, monster->status.luk); clif->message(fd, atcmd_output); sprintf(atcmd_output, msg_txt(1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d) - mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range, - mob->range2 , mob->range3, msize[mob->status.size], - mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv); + monster->status.rhw.atk, monster->status.rhw.atk2, monster->status.rhw.range, + monster->range2 , monster->range3, msize[monster->status.size], + mrace[monster->status.race], melement[monster->status.def_ele], monster->status.ele_lv); clif->message(fd, atcmd_output); // drops @@ -6716,14 +6716,14 @@ ACMD(mobinfo) for (i = 0; i < MAX_MOB_DROP; i++) { int droprate; - if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb->exists(mob->dropitem[i].nameid)) == NULL) + if (monster->dropitem[i].nameid <= 0 || monster->dropitem[i].p < 1 || (item_data = itemdb->exists(monster->dropitem[i].nameid)) == NULL) continue; - droprate = mob->dropitem[i].p; + droprate = monster->dropitem[i].p; #ifdef RENEWAL_DROP if( battle_config.atcommand_mobinfo_type ) { - droprate = droprate * pc->level_penalty_mod(mob->lv - sd->status.base_level, mob->status.race, mob->status.mode, 2) / 100; + droprate = droprate * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 2) / 100; if (droprate <= 0 && !battle_config.drop_rate0item) droprate = 1; @@ -6748,21 +6748,21 @@ ACMD(mobinfo) else if (j % 3 != 0) clif->message(fd, atcmd_output); // mvp - if (mob->mexp) { - sprintf(atcmd_output, msg_txt(1247), mob->mexp); // MVP Bonus EXP:%u + if (monster->mexp) { + sprintf(atcmd_output, msg_txt(1247), monster->mexp); // MVP Bonus EXP:%u clif->message(fd, atcmd_output); strcpy(atcmd_output, msg_txt(1248)); // MVP Items: j = 0; for (i = 0; i < MAX_MVP_DROP; i++) { - if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb->exists(mob->mvpitem[i].nameid)) == NULL) + if (monster->mvpitem[i].nameid <= 0 || (item_data = itemdb->exists(monster->mvpitem[i].nameid)) == NULL) continue; - if (mob->mvpitem[i].p > 0) { + if (monster->mvpitem[i].p > 0) { j++; if (j == 1) - sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100); + sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)monster->mvpitem[i].p / 100); else - sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100); + sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)monster->mvpitem[i].p / 100); strcat(atcmd_output, atcmd_output2); } } @@ -6792,20 +6792,20 @@ ACMD(showmobs) return false; if((mob_id = atoi(mob_name)) == 0) - mob_id = mobdb_searchname(mob_name); - if(mob_id > 0 && mobdb_checkid(mob_id) == 0){ + mob_id = mob->db_searchname(mob_name); + if(mob_id > 0 && mob->db_checkid(mob_id) == 0){ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1250),mob_name); // Invalid mob id %s! clif->message(fd, atcmd_output); return true; } - if(mob_db(mob_id)->status.mode&MD_BOSS && !pc->has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs. + if(mob->db(mob_id)->status.mode&MD_BOSS && !pc->has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs. clif->message(fd, msg_txt(1251)); // Can't show boss mobs! return true; } - if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname) - strcpy(mob_name,mob_db(mob_id)->jname); // --ja-- + if(mob_id == atoi(mob_name) && mob->db(mob_id)->jname) + strcpy(mob_name,mob->db(mob_id)->jname); // --ja-- //strcpy(mob_name,mob_db(mob_id)->name); // --en-- snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1252), // Mob Search... %s %s @@ -7283,7 +7283,7 @@ ACMD(whodrops) for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++) { - sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.); + sprintf(atcmd_output, "- %s (%02.02f%%)", mob->db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.); clif->message(fd, atcmd_output); } } @@ -7293,7 +7293,7 @@ ACMD(whodrops) ACMD(whereis) { - struct mob_db *mob, *mob_array[MAX_SEARCH]; + struct mob_db *monster, *mob_array[MAX_SEARCH]; int count; int i, j, k; @@ -7303,12 +7303,12 @@ ACMD(whereis) } // If monster identifier/name argument is a name - if ((i = mobdb_checkid(atoi(message)))) + if ((i = mob->db_checkid(atoi(message)))) { - mob_array[0] = mob_db(i); + mob_array[0] = mob->db(i); count = 1; } else - count = mobdb_searchname_array(mob_array, MAX_SEARCH, message, 0); + count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0); if (!count) { clif->message(fd, msg_txt(40)); // Invalid monster ID or name. @@ -7321,15 +7321,15 @@ ACMD(whereis) count = MAX_SEARCH; } for (k = 0; k < count; k++) { - mob = mob_array[k]; - snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), mob->jname); // %s spawns in: + monster = mob_array[k]; + snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), monster->jname); // %s spawns in: clif->message(fd, atcmd_output); - for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++) + for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) { - j = iMap->mapindex2mapid(mob->spawn[i].mapindex); + j = iMap->mapindex2mapid(monster->spawn[i].mapindex); if (j < 0) continue; - snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty); + snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, monster->spawn[i].qty); clif->message(fd, atcmd_output); } if (i == 0) @@ -7979,7 +7979,7 @@ ACMD(clone) } master = sd->bl.id; if (battle_config.atc_slave_clone_limit - && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) { + && mob->countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) { clif->message(fd, msg_txt(127)); // You've reached your slave clones limit. return true; } @@ -7995,7 +7995,7 @@ ACMD(clone) y = sd->bl.y; } - if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) { + if((x = mob->clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) { clif->message(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned. return true; } diff --git a/src/map/battle.c b/src/map/battle.c index f64700f0c..120b23368 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2553,7 +2553,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( !damage ) return 0; - if( battle_config.ksprotection && mob_ksprotected(src, bl) ) + if( battle_config.ksprotection && mob->ksprotected(src, bl) ) return 0; if( iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) && skill->get_type(skill_id) != BF_MISC && skill->get_casttype(skill_id) == CAST_GROUND ) @@ -2834,14 +2834,14 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if (src->type == BL_MOB) { int i; if (sc->data[SC_MANU_DEF]) - for (i=0;ARRAYLENGTH(mob_manuk)>i;i++) - if (mob_manuk[i]==((TBL_MOB*)src)->class_) { + for (i=0;ARRAYLENGTH(mob->manuk)>i;i++) + if (mob->manuk[i]==((TBL_MOB*)src)->class_) { damage -= damage * sc->data[SC_MANU_DEF]->val1 / 100; break; } if (sc->data[SC_SPL_DEF]) - for (i=0;ARRAYLENGTH(mob_splendide)>i;i++) - if (mob_splendide[i]==((TBL_MOB*)src)->class_) { + for (i=0;ARRAYLENGTH(mob->splendide)>i;i++) + if (mob->splendide[i]==((TBL_MOB*)src)->class_) { damage -= damage * sc->data[SC_SPL_DEF]->val1 / 100; break; } @@ -2991,16 +2991,16 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if ( ((sce=sc->data[SC_MANU_ATK]) && (flag&BF_WEAPON)) || ((sce=sc->data[SC_MANU_MATK]) && (flag&BF_MAGIC)) ) - for (i=0;ARRAYLENGTH(mob_manuk)>i;i++) - if (((TBL_MOB*)bl)->class_==mob_manuk[i]) { + for (i=0;ARRAYLENGTH(mob->manuk)>i;i++) + if (((TBL_MOB*)bl)->class_==mob->manuk[i]) { damage += damage * sce->val1 / 100; break; } if ( ((sce=sc->data[SC_SPL_ATK]) && (flag&BF_WEAPON)) || ((sce=sc->data[SC_SPL_MATK]) && (flag&BF_MAGIC)) ) - for (i=0;ARRAYLENGTH(mob_splendide)>i;i++) - if (((TBL_MOB*)bl)->class_==mob_splendide[i]) { + for (i=0;ARRAYLENGTH(mob->splendide)>i;i++) + if (((TBL_MOB*)bl)->class_==mob->splendide[i]) { damage += damage * sce->val1 / 100; break; } @@ -3052,9 +3052,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( bl->type == BL_MOB && !iStatus->isdead(bl) && src != bl) { if (damage > 0 ) - mobskill_event((TBL_MOB*)bl,src,iTimer->gettick(),flag); + mob->skill_event((TBL_MOB*)bl,src,iTimer->gettick(),flag); if (skill_id) - mobskill_event((TBL_MOB*)bl,src,iTimer->gettick(),MSC_SKILLUSED|(skill_id<<16)); + mob->skill_event((TBL_MOB*)bl,src,iTimer->gettick(),MSC_SKILLUSED|(skill_id<<16)); } if( sd ) { if( pc_ismadogear(sd) && rnd()%100 < 50 ) { diff --git a/src/map/clif.c b/src/map/clif.c index 8f82141b2..8c7790a8f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8904,8 +8904,8 @@ void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int cl { if( pcdb_checkid(class_) ) { clif->starskill(sd, pc->job_name(class_), class_, hate_level, type ? 10 : 11); - } else if( mobdb_checkid(class_) ) { - clif->starskill(sd, mob_db(class_)->jname, class_, hate_level, type ? 10 : 11); + } else if( mob->db_checkid(class_) ) { + clif->starskill(sd, mob->db(class_)->jname, class_, hate_level, type ? 10 : 11); } else { ShowWarning("clif_hate_info: Received invalid class %d for this packet (char_id=%d, hate_level=%u, type=%u).\n", class_, sd->status.char_id, (unsigned int)hate_level, (unsigned int)type); } @@ -8916,7 +8916,7 @@ void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int cl *------------------------------------------*/ void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char progress) { - clif->starskill(sd, mob_db(mob_id)->jname, mob_id, progress, 20); + clif->starskill(sd, mob->db(mob_id)->jname, mob_id, progress, 20); } /*========================================== @@ -13416,7 +13416,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) return; } - if( (count=mobdb_searchname_array(mob_array, 10, item_monster_name, 1)) > 0){ + if( (count=mob->db_searchname_array(mob_array, 10, item_monster_name, 1)) > 0){ for(i = 0; i < count; i++){ if( mob_array[i] && strcmp(mob_array[i]->sprite, item_monster_name) == 0 ) // It only accepts sprite name break; @@ -15505,7 +15505,7 @@ void clif_quest_send_mission(struct map_session_data * sd) int fd = sd->fd; int i, j; int len = sd->avail_quests*104+8; - struct mob_db *mob; + struct mob_db *monster; WFIFOHEAD(fd, len); WFIFOW(fd, 0) = 0x2b2; @@ -15522,8 +15522,8 @@ void clif_quest_send_mission(struct map_session_data * sd) { WFIFOL(fd, i*104+22+j*30) = quest_db[sd->quest_index[i]].mob[j]; WFIFOW(fd, i*104+26+j*30) = sd->quest_log[i].count[j]; - mob = mob_db(quest_db[sd->quest_index[i]].mob[j]); - memcpy(WFIFOP(fd, i*104+28+j*30), mob?mob->jname:"NULL", NAME_LENGTH); + monster = mob->db(quest_db[sd->quest_index[i]].mob[j]); + memcpy(WFIFOP(fd, i*104+28+j*30), monster?monster->jname:"NULL", NAME_LENGTH); } } @@ -15537,7 +15537,7 @@ void clif_quest_add(struct map_session_data * sd, struct quest * qd, int index) { int fd = sd->fd; int i; - struct mob_db *mob; + struct mob_db *monster; WFIFOHEAD(fd, packet_len(0x2b3)); WFIFOW(fd, 0) = 0x2b3; @@ -15550,8 +15550,8 @@ void clif_quest_add(struct map_session_data * sd, struct quest * qd, int index) for( i = 0; i < quest_db[index].num_objectives; i++ ) { WFIFOL(fd, i*30+17) = quest_db[index].mob[i]; WFIFOW(fd, i*30+21) = qd->count[i]; - mob = mob_db(quest_db[index].mob[i]); - memcpy(WFIFOP(fd, i*30+23), mob?mob->jname:"NULL", NAME_LENGTH); + monster = mob->db(quest_db[index].mob[i]); + memcpy(WFIFOP(fd, i*30+23), monster?monster->jname:"NULL", NAME_LENGTH); } WFIFOSET(fd, packet_len(0x2b3)); diff --git a/src/map/guild.c b/src/map/guild.c index 601d88387..995c090ec 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1960,7 +1960,7 @@ int guild_castledatasave(int castle_id, int index, int value) gc->guild_id = value; for (i = 0; i < MAX_GUARDIANS; i++) if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL) - mob_guardian_guildchange(gd); + mob->guardian_guildchange(gd); break; } case 2: diff --git a/src/map/itemdb.c b/src/map/itemdb.c index fcd4ccbc1..7045bd358 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2069,7 +2069,7 @@ void itemdb_reload(void) { struct mob_db *entry; if( !((i < 1324 || i > 1363) && (i < 1938 || i > 1946)) ) continue; - entry = mob_db(i); + entry = mob->db(i); for(d = 0; d < MAX_MOB_DROP; d++) { struct item_data *id; if( !entry->dropitem[d].nameid ) diff --git a/src/map/map.c b/src/map/map.c index cbef8ca95..90ad63adf 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -4945,7 +4945,7 @@ void do_final(void) party->do_final_party(); pc->do_final_pc(); do_final_pet(); - do_final_mob(); + mob->final(); homun->final(); atcommand->final_msg(); skill->final(); @@ -5168,7 +5168,7 @@ void map_hp_symbols(void) { HPM->share(elemental,"elemental"); HPM->share(intif,"intif"); HPM->share(mercenary,"mercenary"); - + HPM->share(mob,"mob"); /* partial */ HPM->share(mapit,"mapit"); @@ -5214,6 +5214,7 @@ void map_load_defaults(void) { elemental_defaults(); intif_defaults(); mercenary_defaults(); + mob_defaults(); } int do_init(int argc, char *argv[]) { @@ -5402,7 +5403,7 @@ int do_init(int argc, char *argv[]) itemdb->init(); skill->init(); read_map_zone_db();/* read after item and skill initalization */ - do_init_mob(); + mob->init(); pc->do_init_pc(); iStatus->do_init_status(); party->do_init_party(); diff --git a/src/map/mob.c b/src/map/mob.c index b16c57ef8..49120fdaf 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -43,6 +43,8 @@ #include <string.h> #include <math.h> +struct mob_interface mob_s; + #define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode. #define IDLE_SKILL_INTERVAL 10 //Active idle skills should be triggered every 1 second (1000/MIN_MOBTHINKTIME) @@ -54,17 +56,6 @@ #define MOB_MAX_DELAY (24*3600*1000) #define MAX_MINCHASE 30 //Max minimum chase value to use for mobs. #define RUDE_ATTACKED_COUNT 2 //After how many rude-attacks should the skill be used? -#define MAX_MOB_CHAT 250 //Max Skill's messages - -//Dynamic mob database, allows saving of memory when there's big gaps in the mob_db [Skotlex] -struct mob_db *mob_db_data[MAX_MOB_DB+1]; -struct mob_db *mob_dummy = NULL; //Dummy mob to be returned when a non-existant one is requested. - -struct mob_db *mob_db(int index) { if (index < 0 || index > MAX_MOB_DB || mob_db_data[index] == NULL) return mob_dummy; return mob_db_data[index]; } - -//Dynamic mob chat database -struct mob_chat *mob_chat_db[MAX_MOB_CHAT+1]; -struct mob_chat *mob_chat(short id) { if(id<=0 || id>MAX_MOB_CHAT || mob_chat_db[id]==NULL) return (struct mob_chat*)NULL; return mob_chat_db[id]; } //Dynamic item drop ratio database for per-item drop ratio modifiers overriding global drop ratios. #define MAX_ITEMRATIO_MOBS 10 @@ -82,16 +73,16 @@ static struct { int class_[350]; } summon[MAX_RANDOMMONSTER]; -//Defines the Manuk/Splendide mob groups for the status reductions [Epoque] -const int mob_manuk[8] = { 1986, 1987, 1988, 1989, 1990, 1997, 1998, 1999 }; -const int mob_splendide[5] = { 1991, 1992, 1993, 1994, 1995 }; - -/*========================================== - * Local prototype declaration (only required thing) - *------------------------------------------*/ -static int mob_makedummymobdb(int); -static int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data); -int mob_skill_id2skill_idx(int class_,uint16 skill_id); +struct mob_db *mob_db(int index) { + if (index < 0 || index > MAX_MOB_DB || mob->db_data[index] == NULL) + return mob->dummy; + return mob->db_data[index]; +} +struct mob_chat *mob_chat(short id) { + if(id <= 0 || id > MAX_MOB_CHAT || mob->chat_db[id] == NULL) + return NULL; + return mob->chat_db[id]; +} /*========================================== * Mob is searched with a name. @@ -99,35 +90,34 @@ int mob_skill_id2skill_idx(int class_,uint16 skill_id); int mobdb_searchname(const char *str) { int i; - struct mob_db* mob; + struct mob_db* monster; for(i=0;i<=MAX_MOB_DB;i++){ - mob = mob_db(i); - if(mob == mob_dummy) //Skip dummy mobs. + monster = mob->db(i); + if(monster == mob->dummy) //Skip dummy mobs. continue; - if(strcmpi(mob->name,str)==0 || strcmpi(mob->jname,str)==0 || strcmpi(mob->sprite,str)==0) + if(strcmpi(monster->name,str)==0 || strcmpi(monster->jname,str)==0 || strcmpi(monster->sprite,str)==0) return i; } return 0; } -static int mobdb_searchname_array_sub(struct mob_db* mob, const char *str, int flag) -{ - if (mob == mob_dummy) +int mobdb_searchname_array_sub(struct mob_db* monster, const char *str, int flag) { + if (monster == mob->dummy) return 1; - if(!mob->base_exp && !mob->job_exp && mob->spawn[0].qty < 1) + if(!monster->base_exp && !monster->job_exp && monster->spawn[0].qty < 1) return 1; // Monsters with no base/job exp and no spawn point are, by this criteria, considered "slave mobs" and excluded from search results if( !flag ){ - if(stristr(mob->jname,str)) + if(stristr(monster->jname,str)) return 0; - if(stristr(mob->name,str)) + if(stristr(monster->name,str)) return 0; - return strcmpi(mob->jname,str); + return strcmpi(monster->jname,str); } - if(strcmp(mob->jname,str) == 0) + if(strcmp(monster->jname,str) == 0) return 0; - if(strcmp(mob->name,str) == 0) + if(strcmp(monster->name,str) == 0) return 0; - return strcmp(mob->sprite,str); + return strcmp(monster->sprite,str); } /*========================================== @@ -138,7 +128,7 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) struct npc_data *nd; if ( md->tomb_nid ) - mvptomb_destroy(md); + mob->mvptomb_destroy(md); CREATE(nd, struct npc_data, 1); @@ -204,14 +194,14 @@ void mvptomb_destroy(struct mob_data *md) { int mobdb_searchname_array(struct mob_db** data, int size, const char *str, int flag) { int count = 0, i; - struct mob_db* mob; + struct mob_db* monster; for(i=0;i<=MAX_MOB_DB;i++){ - mob = mob_db(i); - if (mob == mob_dummy || mob_is_clone(i) ) //keep clones out (or you leak player stats) + monster = mob->db(i); + if (monster == mob->dummy || mob->is_clone(i) ) //keep clones out (or you leak player stats) continue; - if (!mobdb_searchname_array_sub(mob, str, flag)) { + if (!mob->db_searchname_array_sub(monster, str, flag)) { if (count < size) - data[count] = mob; + data[count] = monster; count++; } } @@ -223,9 +213,9 @@ int mobdb_searchname_array(struct mob_db** data, int size, const char *str, int *------------------------------------------*/ int mobdb_checkid(const int id) { - if (mob_db(id) == mob_dummy) + if (mob->db(id) == mob->dummy) return 0; - if (mob_is_clone(id)) //checkid is used mostly for random ID based code, therefore clone mobs are out of the question. + if (mob->is_clone(id)) //checkid is used mostly for random ID based code, therefore clone mobs are out of the question. return 0; return id; } @@ -235,9 +225,9 @@ int mobdb_checkid(const int id) *------------------------------------------*/ struct view_data * mob_get_viewdata(int class_) { - if (mob_db(class_) == mob_dummy) + if (mob->db(class_) == mob->dummy) return 0; - return &mob_db(class_)->vd; + return &mob->db(class_)->vd; } /*========================================== * Cleans up mob-spawn data to make it "valid" @@ -246,7 +236,7 @@ int mob_parse_dataset(struct spawn_data *data) { size_t len; - if ((!mobdb_checkid(data->class_) && !mob_is_clone(data->class_)) || !data->num) + if ((!mob->db_checkid(data->class_) && !mob->is_clone(data->class_)) || !data->num) return 0; if( ( len = strlen(data->eventname) ) > 0 ) @@ -258,9 +248,9 @@ int mob_parse_dataset(struct spawn_data *data) } if(strcmp(data->name,"--en--")==0) - safestrncpy(data->name, mob_db(data->class_)->name, sizeof(data->name)); + safestrncpy(data->name, mob->db(data->class_)->name, sizeof(data->name)); else if(strcmp(data->name,"--ja--")==0) - safestrncpy(data->name, mob_db(data->class_)->jname, sizeof(data->name)); + safestrncpy(data->name, mob->db(data->class_)->jname, sizeof(data->name)); return 1; } @@ -276,7 +266,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { md->bl.y = data->y; md->class_ = data->class_; md->state.boss = data->state.boss; - md->db = mob_db(md->class_); + md->db = mob->db(md->class_); if (data->level > 0 && data->level <= MAX_LEVEL) md->level = data->level; memcpy(md->name, data->name, NAME_LENGTH); @@ -314,7 +304,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { *------------------------------------------*/ int mob_get_random_id(int type, int flag, int lv) { - struct mob_db *mob; + struct mob_db *monster; int i=0, class_; if(type < 0 || type >= MAX_RANDOMMONSTER) { ShowError("mob_get_random_id: Invalid type (%d) of random monster.\n", type); @@ -325,17 +315,17 @@ int mob_get_random_id(int type, int flag, int lv) class_ = summon[type].class_[rnd()%summon[type].qty]; else //Dead branch class_ = rnd() % MAX_MOB_DB; - mob = mob_db(class_); - } while ((mob == mob_dummy || - mob_is_clone(class_) || - (flag&1 && mob->summonper[type] <= rnd() % 1000000) || - (flag&2 && lv < mob->lv) || - (flag&4 && mob->status.mode&MD_BOSS) || - (flag&8 && mob->spawn[0].qty < 1) + monster = mob->db(class_); + } while ((monster == mob->dummy || + mob->is_clone(class_) || + (flag&1 && monster->summonper[type] <= rnd() % 1000000) || + (flag&2 && lv < monster->lv) || + (flag&4 && monster->status.mode&MD_BOSS) || + (flag&8 && monster->spawn[0].qty < 1) ) && (i++) < MAX_MOB_DB); if(i >= MAX_MOB_DB) // no suitable monster found, use fallback for given list - class_ = mob_db_data[0]->summonper[type]; + class_ = mob->db_data[0]->summonper[type]; return class_; } @@ -458,10 +448,10 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int data.x = x; data.y = y; - if (!mob_parse_dataset(&data)) + if (!mob->parse_dataset(&data)) return NULL; - return mob_spawn_dataset(&data); + return mob->spawn_dataset(&data); } /*========================================== @@ -479,8 +469,8 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const for (count = 0; count < amount; count++) { - int c = (class_ >= 0) ? class_ : mob_get_random_id(-class_ - 1, (battle_config.random_monster_checklv) ? 3 : 1, lv); - md = mob_once_spawn_sub((sd) ? &sd->bl : NULL, m, x, y, mobname, c, event, size, ai); + int c = (class_ >= 0) ? class_ : mob->get_random_id(-class_ - 1, (battle_config.random_monster_checklv) ? 3 : 1, lv); + md = mob->once_spawn_sub((sd) ? &sd->bl : NULL, m, x, y, mobname, c, event, size, ai); if (!md) continue; @@ -501,11 +491,11 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const memcpy(md->guardian_data->guild_name, g->name, NAME_LENGTH); } else if (gc->guild_id) //Guild not yet available, retry in 5. - iTimer->add_timer(iTimer->gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); + iTimer->add_timer(iTimer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); } } // end addition [Valaris] - mob_spawn(md); + mob->spawn(md); if (class_ < 0 && battle_config.dead_branch_active) //Behold Aegis's masterful decisions yet again... @@ -565,7 +555,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 lx = x; ly = y; - id = mob_once_spawn(sd, m, x, y, mobname, class_, 1, event, size, ai); + id = mob->once_spawn(sd, m, x, y, mobname, class_, 1, event, size, ai); } return id; // id of last spawned mob @@ -573,7 +563,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 /*========================================== * Set a Guardian's guild data [Skotlex] *------------------------------------------*/ -static int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data) +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 mob_data* md; @@ -643,7 +633,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam data.m = m; data.num = 1; if(class_<=0) { - class_ = mob_get_random_id(-class_-1, 1, 99); + class_ = mob->get_random_id(-class_-1, 1, 99); if (!class_) return 0; } @@ -668,7 +658,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam data.y = y; safestrncpy(data.name, mobname, sizeof(data.name)); safestrncpy(data.eventname, event, sizeof(data.eventname)); - if (!mob_parse_dataset(&data)) + if (!mob->parse_dataset(&data)) return 0; gc=guild->mapname2gc(map[m].name); @@ -693,7 +683,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam } } - md = mob_spawn_dataset(&data); + md = mob->spawn_dataset(&data); md->guardian_data = (struct guardian_data*)aCalloc(1, sizeof(struct guardian_data)); md->guardian_data->number = guardian; md->guardian_data->guild_id = gc->guild_id; @@ -719,8 +709,8 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam memcpy (md->guardian_data->guild_name, g->name, NAME_LENGTH); md->guardian_data->guardup_lv = guild->checkskill(g,GD_GUARDUP); } else if (md->guardian_data->guild_id) - iTimer->add_timer(iTimer->gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); - mob_spawn(md); + iTimer->add_timer(iTimer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); + mob->spawn(md); return md->bl.id; } @@ -745,7 +735,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int data.num = 1; if( class_ <= 0 ) { - class_ = mob_get_random_id(-class_-1,1,99); + class_ = mob->get_random_id(-class_-1,1,99); if( !class_ ) return 0; } @@ -760,11 +750,11 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int data.y = y; safestrncpy(data.name, mobname, sizeof(data.name)); safestrncpy(data.eventname, event, sizeof(data.eventname)); - if( !mob_parse_dataset(&data) ) + if( !mob->parse_dataset(&data) ) return 0; - md = mob_spawn_dataset(&data); - mob_spawn(md); + md = mob->spawn_dataset(&data); + mob->spawn(md); md->bg_id = bg_id; // BG Team ID return md->bl.id; @@ -816,7 +806,7 @@ int mob_linksearch(struct block_list *bl,va_list ap) && !md->target_id) { md->last_linktime = tick; - if( mob_can_reach(md,target,md->db->range2, MSS_FOLLOW) ){ // Reachability judging + if( mob->can_reach(md,target,md->db->range2, MSS_FOLLOW) ){ // Reachability judging md->target_id = target->id; md->min_chase=md->db->range3; return 1; @@ -842,7 +832,7 @@ int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data) return 0; } md->spawn_timer = INVALID_TIMER; - mob_spawn(md); + mob->spawn(md); } return 0; } @@ -863,7 +853,7 @@ int mob_setdelayspawn(struct mob_data *md) spawntime+= rnd()%md->spawn->delay2; //Apply the spawn delay fix [Skotlex] - db = mob_db(md->spawn->class_); + db = mob->db(md->spawn->class_); mode = db->status.mode; if (mode & MD_BOSS) { //Bosses if (battle_config.boss_spawn_delay != 100) { @@ -883,8 +873,8 @@ int mob_setdelayspawn(struct mob_data *md) spawntime = 5000; if( md->spawn_timer != INVALID_TIMER ) - iTimer->delete_timer(md->spawn_timer, mob_delayspawn); - md->spawn_timer = iTimer->add_timer(iTimer->gettick()+spawntime, mob_delayspawn, md->bl.id, 0); + iTimer->delete_timer(md->spawn_timer, mob->delayspawn); + md->spawn_timer = iTimer->add_timer(iTimer->gettick()+spawntime, mob->delayspawn, md->bl.id, 0); return 0; } @@ -916,7 +906,7 @@ int mob_spawn (struct mob_data *md) { md->class_ = md->spawn->class_; iStatus->set_viewdata(&md->bl, md->class_); - md->db = mob_db(md->class_); + md->db = mob->db(md->class_); memcpy(md->name,md->spawn->name,NAME_LENGTH); } @@ -930,16 +920,16 @@ int mob_spawn (struct mob_data *md) 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->spawn_timer != INVALID_TIMER ) - iTimer->delete_timer(md->spawn_timer, mob_delayspawn); - md->spawn_timer = iTimer->add_timer(tick+5000,mob_delayspawn,md->bl.id,0); + iTimer->delete_timer(md->spawn_timer, mob->delayspawn); + md->spawn_timer = iTimer->add_timer(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) ) + 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) if( md->spawn_timer != INVALID_TIMER ) - iTimer->delete_timer(md->spawn_timer, mob_delayspawn); - md->spawn_timer = iTimer->add_timer(tick+5000,mob_delayspawn,md->bl.id,0); + iTimer->delete_timer(md->spawn_timer, mob->delayspawn); + md->spawn_timer = iTimer->add_timer(tick+5000,mob->delayspawn,md->bl.id,0); return 1; } } @@ -953,7 +943,7 @@ int mob_spawn (struct mob_data *md) md->ud.target_to = 0; if( md->spawn_timer != INVALID_TIMER ) { - iTimer->delete_timer(md->spawn_timer, mob_delayspawn); + iTimer->delete_timer(md->spawn_timer, mob->delayspawn); md->spawn_timer = INVALID_TIMER; } @@ -984,20 +974,20 @@ int mob_spawn (struct mob_data *md) // MvP tomb [GreenBox] if ( md->tomb_nid ) - mvptomb_destroy(md); + mob->mvptomb_destroy(md); iMap->addblock(&md->bl); if( map[md->bl.m].users ) clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); - mobskill_use(md, tick, MSC_SPAWN); + mob->skill_use(md, tick, MSC_SPAWN); return 0; } /*========================================== * Determines if the mob can change target. [Skotlex] *------------------------------------------*/ -static int mob_can_changetarget(struct mob_data* md, struct block_list* target, int mode) +int mob_can_changetarget(struct mob_data* md, struct block_list* target, int mode) { // if the monster was provoked ignore the above rule [celest] if(md->state.provoke_flag) @@ -1035,7 +1025,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) nullpo_ret(bl); // Nothing will be carried out if there is no mind of changing TAGE by TAGE ending. - if(md->target_id && !mob_can_changetarget(md, bl, status_get_mode(&md->bl))) + 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)) @@ -1053,7 +1043,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) /*========================================== * The ?? routine of an active monster *------------------------------------------*/ -static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) +int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) { struct mob_data *md; struct block_list **target; @@ -1115,7 +1105,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) /*========================================== * chase target-change routine. *------------------------------------------*/ -static 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; @@ -1141,7 +1131,7 @@ static int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) /*========================================== * finds nearby bg ally for guardians looking for users to follow. *------------------------------------------*/ -static int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) { +int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) { struct mob_data *md; struct block_list **target; @@ -1158,7 +1148,7 @@ static int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) { /*========================================== * loot monster item search *------------------------------------------*/ -static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) +int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) { struct mob_data* md; struct block_list **target; @@ -1168,7 +1158,7 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) target= va_arg(ap,struct block_list**); dist=distance_bl(&md->bl, bl); - if(mob_can_reach(md,bl,dist+1, MSS_LOOT) && + if(mob->can_reach(md,bl,dist+1, MSS_LOOT) && ((*target) == NULL || !check_distance_bl(&md->bl, *target, dist)) //New target closer than previous one. ) { (*target) = bl; @@ -1178,7 +1168,7 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) return 0; } -static int mob_warpchase_sub(struct block_list *bl,va_list ap) { +int mob_warpchase_sub(struct block_list *bl,va_list ap) { struct block_list *target; struct npc_data **target_nd; struct npc_data *nd; @@ -1209,7 +1199,7 @@ static int mob_warpchase_sub(struct block_list *bl,va_list ap) { /*========================================== * Processing of slave monsters *------------------------------------------*/ -static 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; @@ -1306,12 +1296,12 @@ int mob_unlocktarget(struct mob_data *md, unsigned int tick) case MSS_IDLE: // Idle skill. if ((md->target_id || !(++md->ud.walk_count%IDLE_SKILL_INTERVAL)) && - mobskill_use(md, tick, -1)) + mob->skill_use(md, tick, -1)) break; //Random walk. if (!md->master_id && DIFF_TICK(md->next_walktime, tick) <= 0 && - !mob_randomwalk(md,tick)) + !mob->randomwalk(md,tick)) //Delay next random walk when this one failed. md->next_walktime=tick+rnd()%3000; break; @@ -1364,7 +1354,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) if(md->move_fail_count>1000){ ShowWarning("MOB can't move. random spawn %d, class = %d, at %s (%d,%d)\n",md->bl.id,md->class_,map[md->bl.m].name, md->bl.x, md->bl.y); md->move_fail_count=0; - mob_spawn(md); + mob->spawn(md); } return 0; } @@ -1396,7 +1386,7 @@ int mob_warpchase(struct mob_data *md, struct block_list *target) return 1; //Already walking to a warp. //Search for warps within mob's viewing range. - iMap->foreachinrange (mob_warpchase_sub, &md->bl, + iMap->foreachinrange (mob->warpchase_sub, &md->bl, md->db->range2, BL_NPC, target, &warp, &distance); if (warp && unit_walktobl(&md->bl, &warp->bl, 1, 1)) @@ -1407,7 +1397,7 @@ int mob_warpchase(struct mob_data *md, struct block_list *target) /*========================================== * AI of MOB whose is near a Player *------------------------------------------*/ -static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) +bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) { struct block_list *tbl = NULL, *abl = NULL; int mode; @@ -1453,9 +1443,9 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) ((((TBL_PC*)tbl)->state.gangsterparadise && !(mode&MD_BOSS)) || ((TBL_PC*)tbl)->invincible_timer != INVALID_TIMER) )) { //Unlock current target. - if (mob_warpchase(md, tbl)) + 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. + mob->unlocktarget(md, tick-(battle_config.mob_ai&0x8?3000:0)); //Imediately do random walk. tbl = NULL; } } @@ -1470,10 +1460,10 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) (!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, tbl, md->min_chase, MSS_RUSH) + || !mob->can_reach(md, tbl, md->min_chase, MSS_RUSH) ) && md->state.attacked_count++ >= RUDE_ATTACKED_COUNT - && !mobskill_use(md, tick, MSC_RUDEATTACKED) // If can't rude Attack + && !mob->skill_use(md, tick, MSC_RUDEATTACKED) // If can't rude Attack && can_move && unit_escape(&md->bl, tbl, rnd()%10 +1)) // Attempt escape { //Escaped md->attacked_id = 0; @@ -1481,7 +1471,7 @@ static 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 = iMap->id2bl(md->attacked_id)) && (!tbl || mob->can_changetarget(md, abl, mode)) ) { int dist; if( md->bl.m != abl->m || abl->prev == NULL @@ -1493,12 +1483,12 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) (!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) + || !mob->can_reach(md, abl, dist+md->db->range3, MSS_RUSH) ) ) ) { // Rude attacked if (md->state.attacked_count++ >= RUDE_ATTACKED_COUNT - && !mobskill_use(md, tick, MSC_RUDEATTACKED) && can_move + && !mob->skill_use(md, tick, MSC_RUDEATTACKED) && can_move && !tbl && unit_escape(&md->bl, abl, rnd()%10 +1)) { //Escaped. //TODO: Maybe it shouldn't attempt to run if it has another, valid target? @@ -1533,26 +1523,26 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) } // Processing of slave monster - if (md->master_id > 0 && mob_ai_sub_hard_slavemob(md, tick)) + if (md->master_id > 0 && mob->ai_sub_hard_slavemob(md, 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); + iMap->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); + 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)) { 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); + iMap->foreachinrange (mob->ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl); } if (!tbl) { //No targets available. @@ -1563,7 +1553,7 @@ static 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); + iMap->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. */ @@ -1571,7 +1561,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) } //This handles triggering idle walk/skill. - mob_unlocktarget(md, tick); + mob->unlocktarget(md, tick); return true; } @@ -1583,21 +1573,21 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) return true; //Already locked. if (md->lootitem == NULL) { //Can't loot... - mob_unlocktarget (md, tick); + mob->unlocktarget (md, tick); return true; } if (!check_distance_bl(&md->bl, tbl, 1)) { //Still not within loot range. if (!(mode&MD_CANMOVE)) { //A looter that can't move? Real smart. - mob_unlocktarget(md,tick); + mob->unlocktarget(md,tick); return true; } if (!can_move) //Stuck. Wait before walking. return true; md->state.skillstate = MSS_LOOT; if (!unit_walktobl(&md->bl, tbl, 1, 1)) - mob_unlocktarget(md, tick); //Can't loot... + mob->unlocktarget(md, tick); //Can't loot... return true; } //Within looting range. @@ -1624,7 +1614,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) } //Clear item. iMap->clearflooritem (tbl); - mob_unlocktarget (md,tick); + mob->unlocktarget (md,tick); return true; } //Attempt to attack. @@ -1636,7 +1626,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) { //Target within range, engage if(tbl->type == BL_PC) - mob_log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus) + mob->log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus) unit_attack(&md->bl,tbl->id,1); return true; } @@ -1645,8 +1635,8 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if (!(mode&MD_CANMOVE)) { //Can't chase. Attempt an idle skill before unlocking. md->state.skillstate = MSS_IDLE; - if (!mobskill_use(md, tick, -1)) - mob_unlocktarget(md,tick); + if (!mob->skill_use(md, tick, -1)) + mob->unlocktarget(md,tick); return true; } @@ -1654,7 +1644,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) { //Stuck. Attempt an idle skill md->state.skillstate = MSS_IDLE; if (!(++md->ud.walk_count%IDLE_SKILL_INTERVAL)) - mobskill_use(md, tick, -1); + mob->skill_use(md, tick, -1); return true; } @@ -1666,18 +1656,18 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) return true; //Follow up if possible. - if(!mob_can_reach(md, tbl, md->min_chase, MSS_RUSH) || + if(!mob->can_reach(md, tbl, md->min_chase, MSS_RUSH) || !unit_walktobl(&md->bl, tbl, md->status.rhw.range, 2)) - mob_unlocktarget(md,tick); + mob->unlocktarget(md,tick); return true; } -static int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap) +int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap) { struct mob_data *md = (struct mob_data*)bl; unsigned int tick = va_arg(ap, unsigned int); - if (mob_ai_sub_hard(md, tick)) + if (mob->ai_sub_hard(md, tick)) { //Hard AI triggered. if(!md->state.spotted) md->state.spotted = 1; @@ -1689,11 +1679,11 @@ static int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap) /*========================================== * Serious processing for mob in PC field of view (foreachclient) *------------------------------------------*/ -static 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); + iMap->foreachinrange(mob->ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick); return 0; } @@ -1701,7 +1691,7 @@ static int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) /*========================================== * Negligent mode MOB AI (PC is not in near) *------------------------------------------*/ -static int mob_ai_sub_lazy(struct mob_data *md, va_list args) +int mob_ai_sub_lazy(struct mob_data *md, va_list args) { unsigned int tick; @@ -1713,7 +1703,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args) tick = va_arg(args,unsigned int); if (battle_config.mob_ai&0x20 && map[md->bl.m].users>0) - return (int)mob_ai_sub_hard(md, tick); + return (int)mob->ai_sub_hard(md, tick); if (md->bl.prev==NULL || md->status.hp == 0) return 1; @@ -1724,7 +1714,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args) DIFF_TICK(tick,md->last_thinktime) > MIN_MOBTHINKTIME) { if (DIFF_TICK(tick,md->last_pcneartime) < battle_config.mob_active_time) - return (int)mob_ai_sub_hard(md, tick); + return (int)mob->ai_sub_hard(md, tick); md->last_pcneartime = 0; } @@ -1734,7 +1724,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args) DIFF_TICK(tick,md->last_thinktime) > MIN_MOBTHINKTIME) { if (DIFF_TICK(tick,md->last_pcneartime) < battle_config.boss_active_time) - return (int)mob_ai_sub_hard(md, tick); + return (int)mob->ai_sub_hard(md, tick); md->last_pcneartime = 0; } @@ -1744,7 +1734,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args) md->last_thinktime=tick; if (md->master_id) { - mob_ai_sub_hard_slavemob (md,tick); + mob->ai_sub_hard_slavemob (md,tick); return 0; } @@ -1753,15 +1743,15 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args) if( map[md->bl.m].users > 0 ) { if( rnd()%1000 < MOB_LAZYMOVEPERC(md) ) - mob_randomwalk(md, tick); + mob->randomwalk(md, tick); else if( rnd()%1000 < MOB_LAZYSKILLPERC ) //Chance to do a mob's idle skill. - mobskill_use(md, tick, -1); + mob->skill_use(md, tick, -1); } else { if( rnd()%1000 < MOB_LAZYMOVEPERC(md) ) - mob_randomwalk(md, tick); + mob->randomwalk(md, tick); } } return 0; @@ -1770,22 +1760,22 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args) /*========================================== * Negligent processing for mob outside PC field of view (interval timer function) *------------------------------------------*/ -static int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) +int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) { - iMap->map_foreachmob(mob_ai_sub_lazy,tick); + iMap->map_foreachmob(mob->ai_sub_lazy,tick); return 0; } /*========================================== * Serious processing for mob in PC field of view (interval timer function) *------------------------------------------*/ -static 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); + iMap->map_foreachmob(mob->ai_sub_lazy,tick); else - iMap->map_foreachpc(mob_ai_sub_foreachclient,tick); + iMap->map_foreachpc(mob->ai_sub_foreachclient,tick); return 0; } @@ -1793,7 +1783,7 @@ static int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data) /*========================================== * Initializes the delay drop structure for mob-dropped items. *------------------------------------------*/ -static struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *data) { +struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *data) { struct item_drop *drop = ers_alloc(item_drop_ers, struct item_drop); memset(&drop->item_data, 0, sizeof(struct item)); drop->item_data.nameid = nameid; @@ -1806,7 +1796,7 @@ static struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data * /*========================================== * Initializes the delay drop structure for mob-looted items. *------------------------------------------*/ -static struct item_drop* mob_setlootitem(struct item* item) +struct item_drop* mob_setlootitem(struct item* item) { struct item_drop *drop = ers_alloc(item_drop_ers, struct item_drop); memcpy(&drop->item_data, item, sizeof(struct item)); @@ -1817,7 +1807,7 @@ static struct item_drop* mob_setlootitem(struct item* item) /*========================================== * item drop with delay (timer function) *------------------------------------------*/ -static int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) +int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) { struct item_drop_list *list; struct item_drop *ditem, *ditem_prev; @@ -1841,7 +1831,7 @@ static int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data * rate is the drop-rate of the item, required for autoloot. * flag : Killed only by homunculus? *------------------------------------------*/ -static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct item_drop *ditem, int loot, int drop_rate, unsigned short flag) +void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct item_drop *ditem, int loot, int drop_rate, unsigned short flag) { TBL_PC* sd; @@ -1915,7 +1905,7 @@ int mob_deleteslave(struct mob_data *md) { nullpo_ret(md); - iMap->foreachinmap(mob_deleteslave_sub, md->bl.m, BL_MOB,md->bl.id); + iMap->foreachinmap(mob->deleteslave_sub, md->bl.m, BL_MOB,md->bl.id); return 0; } // Mob respawning through KAIZEL or NPC_REBIRTH [Skotlex] @@ -2060,7 +2050,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { } //Log damage if (src) - mob_log_damage(md, src, damage); + mob->log_damage(md, src, damage); md->dmgtick = iTimer->gettick(); } @@ -2085,7 +2075,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { if( md->special_state.ai == 2 ) {//LOne WOlf explained that ANYONE can trigger the marine countdown skill. [Skotlex] md->state.alchemist = 1; - mobskill_use(md, iTimer->gettick(), MSC_ALCHEMIST); + mob->skill_use(md, iTimer->gettick(), MSC_ALCHEMIST); } } @@ -2123,7 +2113,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if( src ) { // Use Dead skill only if not killed by Script or Command md->state.skillstate = MSS_DEAD; - mobskill_use(md,tick,-1); + mob->skill_use(md,tick,-1); } iMap->freeblock_lock(); @@ -2131,7 +2121,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) memset(pt,0,sizeof(pt)); if(src && src->type == BL_MOB) - mob_unlocktarget((struct mob_data *)src,tick); + mob->unlocktarget((struct mob_data *)src,tick); // filter out entries not eligible for exp distribution memset(tmpsd,0,sizeof(tmpsd)); @@ -2386,7 +2376,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) continue; } - ditem = mob_setdropitem(md->db->dropitem[i].nameid, 1, it); + ditem = mob->setdropitem(md->db->dropitem[i].nameid, 1, it); //A Rare Drop Global Announce by Lupus if( mvp_sd && drop_rate <= battle_config.rare_drop_announce ) { @@ -2397,14 +2387,14 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) } // Announce first, or else ditem will be freed. [Lance] // By popular demand, use base drop rate for autoloot code. [Skotlex] - mob_item_drop(md, dlist, ditem, 0, md->db->dropitem[i].p, homkillonly); + mob->item_drop(md, dlist, ditem, 0, md->db->dropitem[i].p, homkillonly); } // Ore Discovery [Celest] if (sd == mvp_sd && pc->checkskill(sd,BS_FINDINGORE) > 0) { if( (temp = itemdb->chain_item(itemdb->chain_cache[ECC_ORE],&i)) ) { - ditem = mob_setdropitem(temp, 1, NULL); - mob_item_drop(md, dlist, ditem, 0, i, homkillonly); + ditem = mob->setdropitem(temp, 1, NULL); + mob->item_drop(md, dlist, ditem, 0, i, homkillonly); } } @@ -2435,7 +2425,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) continue; itemid = (sd->add_drop[i].id > 0) ? sd->add_drop[i].id : itemdb->chain_item(sd->add_drop[i].group,&drop_rate); if( itemid ) - mob_item_drop(md, dlist, mob_setdropitem(itemid,1,NULL), 0, drop_rate, homkillonly); + mob->item_drop(md, dlist, mob->setdropitem(itemid,1,NULL), 0, drop_rate, homkillonly); } } @@ -2450,10 +2440,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) // process items looted by the mob if(md->lootitem) { for(i = 0; i < md->lootitem_count; i++) - mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000, homkillonly); + mob->item_drop(md, dlist, mob->setlootitem(&md->lootitem[i]), 1, 10000, homkillonly); } if (dlist->item) //There are drop items. - iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr_t)dlist); + iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); else //No drops ers_free(item_drop_list_ers, dlist); } else if (md->lootitem && md->lootitem_count) { //Loot MUST drop! @@ -2466,8 +2456,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) dlist->third_charid = (third_sd ? third_sd->status.char_id : 0); dlist->item = NULL; for(i = 0; i < md->lootitem_count; i++) - mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000, homkillonly); - iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr_t)dlist); + mob->item_drop(md, dlist, mob->setlootitem(&md->lootitem[i]), 1, 10000, homkillonly); + iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); } if(mvp_sd && md->db->mexp > 0 && !md->special_state.ai) { @@ -2569,7 +2559,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if( sd ) { if( sd->mission_mobid == md->class_) { //TK_MISSION [Skotlex] - if( ++sd->mission_count >= 100 && (temp = mob_get_random_id(0, 0xE, sd->status.base_level)) ) { + if( ++sd->mission_count >= 100 && (temp = mob->get_random_id(0, 0xE, sd->status.base_level)) ) { pc->addfame(sd, 1); sd->mission_mobid = temp; pc_setglobalreg(sd,"TK_MISSION_ID", temp); @@ -2584,7 +2574,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) else if( sd->avail_quests ) quest_update_objective(sd, md->class_); - if( sd->md && src && src->type != BL_HOM && mob_db(md->class_)->lv > sd->status.base_level/2 ) + if( sd->md && src && src->type != BL_HOM && mob->db(md->class_)->lv > sd->status.base_level/2 ) mercenary->kills(sd->md); } @@ -2606,14 +2596,14 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) } if(md->deletetimer != INVALID_TIMER) { - iTimer->delete_timer(md->deletetimer,mob_timer_delete); + iTimer->delete_timer(md->deletetimer,mob->timer_delete); md->deletetimer = INVALID_TIMER; } /** * Only loops if necessary (e.g. a poring would never need to loop) **/ if( md->can_summon ) - mob_deleteslave(md); + mob->deleteslave(md); iMap->freeblock_unlock(); @@ -2637,11 +2627,11 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) // MvP tomb [GreenBox] if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && map[md->bl.m].flag.notomb != 1) - mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL)); + mob->mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL)); if( !rebirth ) { iStatus->change_clear(&md->bl,1); - mob_setdelayspawn(md); //Set respawning. + mob->setdelayspawn(md); //Set respawning. } return 3; //Remove from map. } @@ -2660,7 +2650,7 @@ void mob_revive(struct mob_data *md, unsigned int hp) iMap->addblock(&md->bl); clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); - mobskill_use(md, tick, MSC_SPAWN); + mob->skill_use(md, tick, MSC_SPAWN); if (battle_config.show_mob_info&3) clif->charnameack (0, &md->bl); } @@ -2716,16 +2706,16 @@ int mob_random_class (int *value, size_t count) // no count specified, look into the array manually, but take only max 5 elements if (count < 1) { count = 0; - while(count < 5 && mobdb_checkid(value[count])) count++; + while(count < 5 && mob->db_checkid(value[count])) count++; if(count < 1) // nothing found return 0; } else { // check if at least the first value is valid - if(mobdb_checkid(value[0]) == 0) + if(mob->db_checkid(value[0]) == 0) return 0; } //Pick a random value, hoping it exists. [Skotlex] - return mobdb_checkid(value[rnd()%count]); + return mob->db_checkid(value[rnd()%count]); } /*========================================== @@ -2751,7 +2741,7 @@ int mob_class_change (struct mob_data *md, int class_) if( md->special_state.ai > 1 ) return 0; //Marine Spheres and Floras. - if( mob_is_clone(md->class_) ) + if( mob->is_clone(md->class_) ) return 0; //Clones if( md->class_ == class_ ) @@ -2759,7 +2749,7 @@ int mob_class_change (struct mob_data *md, int class_) hp_rate = get_percentage(md->status.hp, md->status.max_hp); md->class_ = class_; - md->db = mob_db(class_); + md->db = mob->db(class_); if (battle_config.override_mob_names==1) memcpy(md->name,md->db->name,NAME_LENGTH); else @@ -2834,7 +2824,7 @@ 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 iMap->foreachinmap(mob->warpslave_sub, bl->m, BL_MOB, bl, range); } /*========================================== @@ -2857,7 +2847,7 @@ int mob_countslave_sub(struct block_list *bl,va_list ap) *------------------------------------------*/ int mob_countslave(struct block_list *bl) { - return iMap->foreachinmap(mob_countslave_sub, bl->m, BL_MOB,bl->id); + return iMap->foreachinmap(mob->countslave_sub, bl->m, BL_MOB,bl->id); } /*========================================== @@ -2880,14 +2870,14 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id) data.state.size = md2->special_state.size; data.state.ai = md2->special_state.ai; - if(mobdb_checkid(value[0]) == 0) + if(mob->db_checkid(value[0]) == 0) return 0; /** * Flags this monster is able to summon; saves a worth amount of memory upon deletion **/ md2->can_summon = 1; - while(count < 5 && mobdb_checkid(value[count])) count++; + while(count < 5 && mob->db_checkid(value[count])) count++; if(count < 1) return 0; if (amount > 0 && amount < count) { //Do not start on 0, pick some random sub subset [Skotlex] k = rnd()%count; @@ -2901,7 +2891,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id) for(;k<amount;k++) { short x,y; data.class_ = value[k%count]; //Summon slaves in round-robin fashion. [Skotlex] - if (mobdb_checkid(data.class_) == 0) + if (mob->db_checkid(data.class_) == 0) continue; if (iMap->search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) { @@ -2918,15 +2908,15 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id) else strcpy(data.name,"--ja--"); - if (!mob_parse_dataset(&data)) + if (!mob->parse_dataset(&data)) continue; - md= mob_spawn_dataset(&data); + md= mob->spawn_dataset(&data); if(skill_id == NPC_SUMMONSLAVE){ md->master_id=md2->bl.id; md->special_state.ai = md2->special_state.ai; } - mob_spawn(md); + mob->spawn(md); if (hp_rate) //Scale HP md->status.hp = md->status.max_hp*hp_rate/100; @@ -2964,8 +2954,8 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id) *------------------------------------------*/ int mob_skill_id2skill_idx(int class_,uint16 skill_id) { - int i, max = mob_db(class_)->maxskill; - struct mob_skill *ms=mob_db(class_)->skill; + int i, max = mob->db(class_)->maxskill; + struct mob_skill *ms=mob->db(class_)->skill; if(ms==NULL) return -1; @@ -3003,7 +2993,7 @@ int mob_getfriendhprate_sub(struct block_list *bl,va_list ap) (*fr) = bl; return 1; } -static 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; @@ -3013,7 +3003,7 @@ static struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,i 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); + iMap->foreachinrange(mob->getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr); return fr; } /*========================================== @@ -3070,7 +3060,7 @@ 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); + iMap->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr); return fr; } @@ -3149,18 +3139,18 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) } flag ^= (ms[i].cond1 == MSC_MYSTATUSOFF); break; case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp% - flag = ((fbl = mob_getfriendhprate(md, 0, ms[i].cond2)) != NULL); break; + flag = ((fbl = mob->getfriendhprate(md, 0, ms[i].cond2)) != NULL); break; case MSC_FRIENDHPINRATE : - flag = ((fbl = mob_getfriendhprate(md, ms[i].cond2, ms[i].val[0])) != NULL); break; + flag = ((fbl = mob->getfriendhprate(md, ms[i].cond2, ms[i].val[0])) != NULL); break; case MSC_FRIENDSTATUSON: // friend status[num] on case MSC_FRIENDSTATUSOFF: // friend status[num] off - flag = ((fmd = mob_getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL); break; + flag = ((fmd = mob->getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL); break; case MSC_SLAVELT: // slave < num - flag = (mob_countslave(&md->bl) < c2 ); break; + flag = (mob->countslave(&md->bl) < c2 ); break; case MSC_ATTACKPCGT: // attack pc > num flag = (unit_counttargeted(&md->bl) > c2); break; case MSC_SLAVELE: // slave <= num - flag = (mob_countslave(&md->bl) <= c2 ); break; + flag = (mob->countslave(&md->bl) <= c2 ); break; case MSC_ATTACKPCGE: // attack pc >= num flag = (unit_counttargeted(&md->bl) >= c2); break; case MSC_AFTERSKILL: @@ -3170,7 +3160,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) if (flag) md->state.attacked_count = 0; //Rude attacked count should be reset after the skill condition is met. Thanks to Komurka [Skotlex] break; case MSC_MASTERHPLTMAXRATE: - flag = ((fbl = mob_getmasterhpltmaxrate(md, ms[i].cond2)) != NULL); break; + 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; case MSC_ALCHEMIST: @@ -3270,7 +3260,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) } //Skill used. Post-setups... if ( ms[ i ].msg_id ){ //Display color message [SnakeDrak] - struct mob_chat *mc = mob_chat(ms[i].msg_id); + struct mob_chat *mc = mob->chat(ms[i].msg_id); char temp[CHAT_SIZE_MAX]; char name[NAME_LENGTH]; snprintf(name, sizeof name,"%s", md->name); @@ -3306,13 +3296,13 @@ int mobskill_event(struct mob_data *md, struct block_list *src, unsigned int tic md->target_id = src->id; if (flag == -1) - res = mobskill_use(md, tick, MSC_CASTTARGETED); + res = mob->skill_use(md, tick, MSC_CASTTARGETED); else if ((flag&0xffff) == MSC_SKILLUSED) - res = mobskill_use(md, tick, flag); + res = mob->skill_use(md, tick, flag); else if (flag&BF_SHORT) - res = mobskill_use(md, tick, MSC_CLOSEDATTACKED); + res = mob->skill_use(md, tick, MSC_CLOSEDATTACKED); else if (flag&BF_LONG && !(flag&BF_MAGIC)) //Long-attacked should not include magic. - res = mobskill_use(md, tick, MSC_LONGRANGEATTACKED); + res = mob->skill_use(md, tick, MSC_LONGRANGEATTACKED); if (!res) //Restore previous target only if skill condition failed to trigger. [Skotlex] @@ -3329,7 +3319,7 @@ int mob_is_clone(int class_) { if(class_ < MOB_CLONE_START || class_ > MOB_CLONE_END) return 0; - if (mob_db(class_) == mob_dummy) + if (mob->db(class_) == mob->dummy) return 0; return class_; } @@ -3353,11 +3343,11 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons if(pc_isdead(sd) && master_id && flag&1) return 0; - ARR_FIND( MOB_CLONE_START, MOB_CLONE_END, class_, mob_db_data[class_] == NULL ); + ARR_FIND( MOB_CLONE_START, MOB_CLONE_END, class_, mob->db_data[class_] == NULL ); if(class_ >= MOB_CLONE_END) return 0; - db = mob_db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db)); + db = mob->db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db)); status = &db->status; strcpy(db->sprite,sd->status.name); strcpy(db->name,sd->status.name); @@ -3519,7 +3509,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons sd->fd = fd; //Finally, spawn it. - md = mob_once_spawn_sub(&sd->bl, m, x, y, "--en--", class_, event, SZ_SMALL, AI_NONE); + md = mob->once_spawn_sub(&sd->bl, m, x, y, "--en--", class_, event, SZ_SMALL, AI_NONE); if (!md) return 0; //Failed? md->special_state.clone = 1; @@ -3532,12 +3522,12 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons if (duration) //Auto Delete after a while. { if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob_timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + duration, mob_timer_delete, md->bl.id, 0); + iTimer->delete_timer(md->deletetimer, mob->timer_delete); + md->deletetimer = iTimer->add_timer (iTimer->gettick() + duration, mob->timer_delete, md->bl.id, 0); } } - mob_spawn(md); + mob->spawn(md); return md->bl.id; } @@ -3546,11 +3536,11 @@ int mob_clone_delete(struct mob_data *md) { const int class_ = md->class_; if (class_ >= MOB_CLONE_START && class_ < MOB_CLONE_END - && mob_db_data[class_]!=NULL) { - aFree(mob_db_data[class_]); - mob_db_data[class_]=NULL; + && mob->db_data[class_]!=NULL) { + aFree(mob->db_data[class_]); + mob->db_data[class_]=NULL; //Clear references to the db - md->db = mob_dummy; + md->db = mob->dummy; md->vd = NULL; return 1; } @@ -3563,50 +3553,50 @@ int mob_clone_delete(struct mob_data *md) /*========================================== * Since un-setting [ mob ] up was used, it is an initial provisional value setup. *------------------------------------------*/ -static int mob_makedummymobdb(int class_) +int mob_makedummymobdb(int class_) { - if (mob_dummy != NULL) + if (mob->dummy != NULL) { - if (mob_db(class_) == mob_dummy) - return 1; //Using the mob_dummy data already. [Skotlex] + if (mob->db(class_) == mob->dummy) + return 1; //Using the mob->dummy data already. [Skotlex] if (class_ > 0 && class_ <= MAX_MOB_DB) { //Remove the mob data so that it uses the dummy data instead. - aFree(mob_db_data[class_]); - mob_db_data[class_] = NULL; + aFree(mob->db_data[class_]); + mob->db_data[class_] = NULL; } return 0; } //Initialize dummy data. - mob_dummy = (struct mob_db*)aCalloc(1, sizeof(struct mob_db)); //Initializing the dummy mob. - sprintf(mob_dummy->sprite,"DUMMY"); - sprintf(mob_dummy->name,"Dummy"); - sprintf(mob_dummy->jname,"Dummy"); - mob_dummy->lv=1; - mob_dummy->status.max_hp=1000; - mob_dummy->status.max_sp=1; - mob_dummy->status.rhw.range=1; - mob_dummy->status.rhw.atk=7; - mob_dummy->status.rhw.atk2=10; - mob_dummy->status.str=1; - mob_dummy->status.agi=1; - mob_dummy->status.vit=1; - mob_dummy->status.int_=1; - mob_dummy->status.dex=6; - mob_dummy->status.luk=2; - mob_dummy->status.speed=300; - mob_dummy->status.adelay=1000; - mob_dummy->status.amotion=500; - mob_dummy->status.dmotion=500; - mob_dummy->base_exp=2; - mob_dummy->job_exp=1; - mob_dummy->range2=10; - mob_dummy->range3=10; + mob->dummy = (struct mob_db*)aCalloc(1, sizeof(struct mob_db)); //Initializing the dummy mob. + sprintf(mob->dummy->sprite,"DUMMY"); + sprintf(mob->dummy->name,"Dummy"); + sprintf(mob->dummy->jname,"Dummy"); + mob->dummy->lv=1; + mob->dummy->status.max_hp=1000; + mob->dummy->status.max_sp=1; + mob->dummy->status.rhw.range=1; + mob->dummy->status.rhw.atk=7; + mob->dummy->status.rhw.atk2=10; + mob->dummy->status.str=1; + mob->dummy->status.agi=1; + mob->dummy->status.vit=1; + mob->dummy->status.int_=1; + mob->dummy->status.dex=6; + mob->dummy->status.luk=2; + mob->dummy->status.speed=300; + mob->dummy->status.adelay=1000; + mob->dummy->status.amotion=500; + mob->dummy->status.dmotion=500; + mob->dummy->base_exp=2; + mob->dummy->job_exp=1; + mob->dummy->range2=10; + mob->dummy->range3=10; return 0; } //Adjusts the drop rate of item according to the criteria given. [Skotlex] -static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned short rate_min, unsigned short rate_max) +unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned short rate_min, unsigned short rate_max) { double rate = baserate; @@ -3628,7 +3618,7 @@ static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned shor * @param mob_id ID of the monster * @param rate_adjust pointer to store ratio if found */ -static void item_dropratio_adjust(int nameid, int mob_id, int *rate_adjust) +void item_dropratio_adjust(int nameid, int mob_id, int *rate_adjust) { if( item_drop_ratio_db[nameid] ) { if( item_drop_ratio_db[nameid]->mob_id[0] ) { // only for listed mobs @@ -3655,7 +3645,7 @@ static inline int mob_parse_dbrow_cap_value(int class_, int min, int max, int va /*========================================== * processes one mobdb entry *------------------------------------------*/ -static bool mob_parse_dbrow(char** str) +bool mob_parse_dbrow(char** str) { struct mob_db *db, entry; struct status_data *status; @@ -3803,8 +3793,8 @@ static bool mob_parse_dbrow(char** str) db->mvpitem[i].p = 0; //No item.... continue; } - item_dropratio_adjust(db->mvpitem[i].nameid, class_, &rate_adjust); - db->mvpitem[i].p = mob_drop_adjust(atoi(str[32+i*2]), rate_adjust, battle_config.item_drop_mvp_min, battle_config.item_drop_mvp_max); + mob->item_dropratio_adjust(db->mvpitem[i].nameid, class_, &rate_adjust); + db->mvpitem[i].p = mob->drop_adjust(atoi(str[32+i*2]), rate_adjust, battle_config.item_drop_mvp_min, battle_config.item_drop_mvp_max); //calculate and store Max available drop chance of the MVP item if (db->mvpitem[i].p) { @@ -3867,8 +3857,8 @@ static bool mob_parse_dbrow(char** str) ratemax = battle_config.item_drop_common_max; break; } - item_dropratio_adjust(id->nameid, class_, &rate_adjust); - db->dropitem[i].p = mob_drop_adjust(rate, rate_adjust, ratemin, ratemax); + mob->item_dropratio_adjust(id->nameid, class_, &rate_adjust); + db->dropitem[i].p = mob->drop_adjust(rate, rate_adjust, ratemin, ratemax); //calculate and store Max available drop chance of the item if( db->dropitem[i].p && (class_ < 1324 || class_ > 1363) && (class_ < 1938 || class_ > 1946) ) @@ -3890,25 +3880,25 @@ static bool mob_parse_dbrow(char** str) } } // Finally insert monster's data into the database. - if (mob_db_data[class_] == NULL) - mob_db_data[class_] = (struct mob_db*)aMalloc(sizeof(struct mob_db)); + if (mob->db_data[class_] == NULL) + mob->db_data[class_] = (struct mob_db*)aMalloc(sizeof(struct mob_db)); else //Copy over spawn data - memcpy(&db->spawn, mob_db_data[class_]->spawn, sizeof(db->spawn)); + memcpy(&db->spawn, mob->db_data[class_]->spawn, sizeof(db->spawn)); - memcpy(mob_db_data[class_], db, sizeof(struct mob_db)); + memcpy(mob->db_data[class_], db, sizeof(struct mob_db)); return true; } /*========================================== * mob_db.txt reading *------------------------------------------*/ -static bool mob_readdb_sub(char* fields[], int columns, int current) +bool mob_readdb_sub(char* fields[], int columns, int current) { - return mob_parse_dbrow(fields); + return mob->parse_dbrow(fields); } -static void mob_readdb(void) +void mob_readdb(void) { const char* filename[] = { DBPATH"mob_db.txt", @@ -3927,14 +3917,14 @@ static void mob_readdb(void) } } - 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(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); } } /*========================================== * mob_db table reading *------------------------------------------*/ -static int mob_read_sqldb(void) +int mob_read_sqldb(void) { const char* mob_db_name[] = { iMap->mob_db_db, iMap->mob_db2_db }; int fi; @@ -3968,7 +3958,7 @@ static int mob_read_sqldb(void) p+= len + 1; } - if (!mob_parse_dbrow(str)) + if (!mob->parse_dbrow(str)) continue; count++; @@ -3985,13 +3975,13 @@ static int mob_read_sqldb(void) /*========================================== * MOB display graphic change data reading *------------------------------------------*/ -static bool mob_readdb_mobavail(char* str[], int columns, int current) +bool mob_readdb_mobavail(char* str[], int columns, int current) { int class_, k; class_=atoi(str[0]); - if(mob_db(class_) == mob_dummy) // invalid class (probably undefined in db) + if(mob->db(class_) == mob->dummy) // invalid class (probably undefined in db) { ShowWarning("mob_readdb_mobavail: Unknown mob id %d.\n", class_); return false; @@ -3999,24 +3989,24 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current) k=atoi(str[1]); - memset(&mob_db_data[class_]->vd, 0, sizeof(struct view_data)); - mob_db_data[class_]->vd.class_=k; + memset(&mob->db_data[class_]->vd, 0, sizeof(struct view_data)); + mob->db_data[class_]->vd.class_=k; //Player sprites if(pcdb_checkid(k) && columns==12) { - mob_db_data[class_]->vd.sex=atoi(str[2]); - mob_db_data[class_]->vd.hair_style=atoi(str[3]); - mob_db_data[class_]->vd.hair_color=atoi(str[4]); - mob_db_data[class_]->vd.weapon=atoi(str[5]); - mob_db_data[class_]->vd.shield=atoi(str[6]); - mob_db_data[class_]->vd.head_top=atoi(str[7]); - mob_db_data[class_]->vd.head_mid=atoi(str[8]); - mob_db_data[class_]->vd.head_bottom=atoi(str[9]); - mob_db_data[class_]->option=atoi(str[10])&~(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE); - mob_db_data[class_]->vd.cloth_color=atoi(str[11]); // Monster player dye option - Valaris + mob->db_data[class_]->vd.sex=atoi(str[2]); + mob->db_data[class_]->vd.hair_style=atoi(str[3]); + mob->db_data[class_]->vd.hair_color=atoi(str[4]); + mob->db_data[class_]->vd.weapon=atoi(str[5]); + mob->db_data[class_]->vd.shield=atoi(str[6]); + mob->db_data[class_]->vd.head_top=atoi(str[7]); + mob->db_data[class_]->vd.head_mid=atoi(str[8]); + mob->db_data[class_]->vd.head_bottom=atoi(str[9]); + mob->db_data[class_]->option=atoi(str[10])&~(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE); + mob->db_data[class_]->vd.cloth_color=atoi(str[11]); // Monster player dye option - Valaris } else if(columns==3) - mob_db_data[class_]->vd.head_bottom=atoi(str[2]); // mob equipment [Valaris] + mob->db_data[class_]->vd.head_bottom=atoi(str[2]); // mob equipment [Valaris] else if( columns != 2 ) return false; @@ -4026,7 +4016,7 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current) /*========================================== * Reading of random monster data *------------------------------------------*/ -static int mob_read_randommonster(void) +int mob_read_randommonster(void) { FILE *fp; char line[1024]; @@ -4043,7 +4033,7 @@ static 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 + 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]); fp=fopen(line,"r"); if(fp==NULL){ @@ -4066,10 +4056,10 @@ static int mob_read_randommonster(void) continue; class_ = atoi(str[0]); - if(mob_db(class_) == mob_dummy) + if(mob->db(class_) == mob->dummy) continue; count++; - mob_db_data[class_]->summonper[i]=atoi(str[2]); + mob->db_data[class_]->summonper[i]=atoi(str[2]); if (i) { if( summon[i].qty < ARRAYLENGTH(summon[i].class_) ) //MvPs summon[i].class_[summon[i].qty++] = class_; @@ -4080,7 +4070,7 @@ static int mob_read_randommonster(void) } } if (i && !summon[i].qty) { //At least have the default here. - summon[i].class_[0] = mob_db_data[0]->summonper[i]; + summon[i].class_[0] = mob->db_data[0]->summonper[i]; summon[i].qty = 1; } fclose(fp); @@ -4093,7 +4083,7 @@ static int mob_read_randommonster(void) * processes one mob_chat_db entry [SnakeDrak] * @param last_msg_id ensures that only one error message per mob id is printed *------------------------------------------*/ -static bool mob_parse_row_chatdb(char** str, const char* source, int line, int* last_msg_id) +bool mob_parse_row_chatdb(char** str, const char* source, int line, int* last_msg_id) { char* msg; struct mob_chat *ms; @@ -4111,10 +4101,10 @@ static bool mob_parse_row_chatdb(char** str, const char* source, int line, int* return false; } - if (mob_chat_db[msg_id] == NULL) - mob_chat_db[msg_id] = (struct mob_chat*)aCalloc(1, sizeof (struct mob_chat)); + if (mob->chat_db[msg_id] == NULL) + mob->chat_db[msg_id] = (struct mob_chat*)aCalloc(1, sizeof (struct mob_chat)); - ms = mob_chat_db[msg_id]; + ms = mob->chat_db[msg_id]; //MSG ID ms->msg_id=msg_id; //Color @@ -4151,7 +4141,7 @@ static bool mob_parse_row_chatdb(char** str, const char* source, int line, int* /*========================================== * mob_chat_db.txt reading [SnakeDrak] *-------------------------------------------------------------------------*/ -static void mob_readchatdb(void) +void mob_readchatdb(void) { char arc[]="mob_chat_db.txt"; uint32 lines=0, count=0; @@ -4195,7 +4185,7 @@ static void mob_readchatdb(void) continue; } - if( !mob_parse_row_chatdb(str, path, lines, &tmp) ) + if( !mob->parse_row_chatdb(str, path, lines, &tmp) ) continue; count++; @@ -4207,7 +4197,7 @@ static void mob_readchatdb(void) /*========================================== * processes one mob_skill_db entry *------------------------------------------*/ -static bool mob_parse_row_mobskilldb(char** str, int columns, int current) +bool mob_parse_row_mobskilldb(char** str, int columns, int current) { static const struct { char str[32]; @@ -4289,7 +4279,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) mob_id = atoi(str[0]); - if (mob_id > 0 && mob_db(mob_id) == mob_dummy) + if (mob_id > 0 && mob->db(mob_id) == mob->dummy) { if (mob_id != last_mob_id) { ShowError("mob_parse_row_mobskilldb: Non existant Mob id %d\n", mob_id); @@ -4300,8 +4290,8 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) if( strcmp(str[1],"clear")==0 ){ if (mob_id < 0) return false; - memset(mob_db_data[mob_id]->skill,0,sizeof(struct mob_skill)); - mob_db_data[mob_id]->maxskill=0; + memset(mob->db_data[mob_id]->skill,0,sizeof(struct mob_skill)); + mob->db_data[mob_id]->maxskill=0; return true; } @@ -4310,11 +4300,11 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) memset(&gms, 0, sizeof (struct mob_skill)); ms = &gms; } else { - ARR_FIND( 0, MAX_MOBSKILL, i, (ms = &mob_db_data[mob_id]->skill[i])->skill_id == 0 ); + ARR_FIND( 0, MAX_MOBSKILL, i, (ms = &mob->db_data[mob_id]->skill[i])->skill_id == 0 ); if( i == MAX_MOBSKILL ) { if (mob_id != last_mob_id) { - ShowError("mob_parse_row_mobskilldb: Too many skills for monster %d[%s]\n", mob_id, mob_db_data[mob_id]->sprite); + ShowError("mob_parse_row_mobskilldb: Too many skills for monster %d[%s]\n", mob_id, mob->db_data[mob_id]->sprite); last_mob_id = mob_id; } return false; @@ -4336,7 +4326,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) if (mob_id < 0) ShowError("mob_parse_row_mobskilldb: Invalid Skill ID (%d) for all mobs\n", j); else - ShowError("mob_parse_row_mobskilldb: Invalid Skill ID (%d) for mob %d (%s)\n", j, mob_id, mob_db_data[mob_id]->sprite); + ShowError("mob_parse_row_mobskilldb: Invalid Skill ID (%d) for mob %d (%s)\n", j, mob_id, mob->db_data[mob_id]->sprite); return false; } ms->skill_id=j; @@ -4378,13 +4368,13 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) 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, - mob_id < 0?"all mobs":mob_db_data[mob_id]->sprite); + 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, - mob_id < 0?"all mobs":mob_db_data[mob_id]->sprite); + mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite); ms->target = MST_TARGET; } @@ -4412,7 +4402,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) ms->val[4]=(int)strtol(str[16],NULL,0); if(ms->skill_id == NPC_EMOTION && mob_id>0 && - ms->val[1] == mob_db(mob_id)->status.mode) + ms->val[1] == mob->db(mob_id)->status.mode) { ms->val[1] = 0; ms->val[4] = 1; //request to return mode to normal. @@ -4431,7 +4421,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) else ms->emotion=-1; - if(str[18]!=NULL && mob_chat_db[atoi(str[18])]!=NULL) + if(str[18]!=NULL && mob->chat_db[atoi(str[18])]!=NULL) ms->msg_id=atoi(str[18]); else ms->msg_id=0; @@ -4441,9 +4431,9 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) mob_id *= -1; for (i = 1; i < MAX_MOB_DB; i++) { - if (mob_db_data[i] == NULL) + if (mob->db_data[i] == NULL) continue; - if (mob_db_data[i]->status.mode&MD_BOSS) + if (mob->db_data[i]->status.mode&MD_BOSS) { if (!(mob_id&2)) //Skill not for bosses continue; @@ -4451,15 +4441,15 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) if (!(mob_id&1)) //Skill not for normal enemies. continue; - ARR_FIND( 0, MAX_MOBSKILL, j, mob_db_data[i]->skill[j].skill_id == 0 ); + ARR_FIND( 0, MAX_MOBSKILL, j, mob->db_data[i]->skill[j].skill_id == 0 ); if(j==MAX_MOBSKILL) continue; - memcpy (&mob_db_data[i]->skill[j], ms, sizeof(struct mob_skill)); - mob_db_data[i]->maxskill=j+1; + memcpy (&mob->db_data[i]->skill[j], ms, sizeof(struct mob_skill)); + mob->db_data[i]->maxskill=j+1; } } else //Skill set on a single mob. - mob_db_data[mob_id]->maxskill=i+1; + mob->db_data[mob_id]->maxskill=i+1; return true; } @@ -4467,7 +4457,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current) /*========================================== * mob_skill_db.txt reading *------------------------------------------*/ -static void mob_readskilldb(void) { +void mob_readskilldb(void) { const char* filename[] = { DBPATH"mob_skill_db.txt", "mob_skill_db2.txt" }; @@ -4491,7 +4481,7 @@ static void mob_readskilldb(void) { } } - sv->readdb(iMap->db_path, filename[fi], ',', 19, 19, -1, &mob_parse_row_mobskilldb); + sv->readdb(iMap->db_path, filename[fi], ',', 19, 19, -1, mob->parse_row_mobskilldb); } } @@ -4500,7 +4490,7 @@ static void mob_readskilldb(void) { * not overly sure if this is all correct * seems to work though... */ -static int mob_read_sqlskilldb(void) +int mob_read_sqlskilldb(void) { const char* mob_skill_db_name[] = { iMap->mob_skill_db_db, iMap->mob_skill_db2_db }; int fi; @@ -4533,7 +4523,7 @@ static int mob_read_sqlskilldb(void) if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } - if (!mob_parse_row_mobskilldb(str, 19, count)) + if (!mob->parse_row_mobskilldb(str, 19, count)) continue; count++; @@ -4550,7 +4540,7 @@ static int mob_read_sqlskilldb(void) /*========================================== * mob_race2_db.txt reading *------------------------------------------*/ -static bool mob_readdb_race2(char* fields[], int columns, int current) +bool mob_readdb_race2(char* fields[], int columns, int current) { int race, mobid, i; @@ -4565,12 +4555,12 @@ static bool mob_readdb_race2(char* fields[], int columns, int current) for(i = 1; i<columns; i++) { mobid = atoi(fields[i]); - if (mob_db(mobid) == mob_dummy) + if (mob->db(mobid) == mob->dummy) { ShowWarning("mob_readdb_race2: Unknown mob id %d for race2 %d.\n", mobid, race); continue; } - mob_db_data[mobid]->race2 = race; + mob->db_data[mobid]->race2 = race; } return true; } @@ -4578,7 +4568,7 @@ static bool mob_readdb_race2(char* fields[], int columns, int current) /** * Read mob_item_ratio.txt */ -static bool mob_readdb_itemratio(char* str[], int columns, int current) +bool mob_readdb_itemratio(char* str[], int columns, int current) { int nameid, ratio, i; nameid = atoi(str[0]); @@ -4604,26 +4594,25 @@ static bool mob_readdb_itemratio(char* str[], int columns, int current) /** * read all mob-related databases */ -static 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 - mob_readchatdb(); +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 + mob->readchatdb(); if (iMap->db_use_sql_mob_db) { - mob_read_sqldb(); + mob->read_sqldb(); } if (iMap->db_use_sql_mob_skill_db) { - mob_read_sqlskilldb(); + mob->read_sqlskilldb(); } else { - mob_readdb(); - mob_readskilldb(); + mob->readdb(); + mob->readskilldb(); } - sv->readdb(iMap->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(iMap->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); } void mob_reload(void) { @@ -4631,9 +4620,9 @@ void mob_reload(void) { //Mob skills need to be cleared before re-reading them. [Skotlex] for (i = 0; i < MAX_MOB_DB; i++) - if (mob_db_data[i] && !mob_is_clone(i)) { - memset(&mob_db_data[i]->skill,0,sizeof(mob_db_data[i]->skill)); - mob_db_data[i]->maxskill=0; + if (mob->db_data[i] && !mob->is_clone(i)) { + memset(&mob->db_data[i]->skill,0,sizeof(mob->db_data[i]->skill)); + mob->db_data[i]->maxskill=0; } // Clear item_drop_ratio_db @@ -4644,15 +4633,15 @@ void mob_reload(void) { } } - mob_load(); + mob->load(); } void mob_clear_spawninfo() { //Clears spawn related information for a script reload. int i; for (i = 0; i < MAX_MOB_DB; i++) - if (mob_db_data[i]) - memset(&mob_db_data[i]->spawn,0,sizeof(mob_db_data[i]->spawn)); + if (mob->db_data[i]) + memset(&mob->db_data[i]->spawn,0,sizeof(mob->db_data[i]->spawn)); } /*========================================== @@ -4660,23 +4649,23 @@ void mob_clear_spawninfo() *------------------------------------------*/ int do_init_mob(void) { //Initialize the mob database - memset(mob_db_data,0,sizeof(mob_db_data)); //Clear the array - mob_db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns - mob_makedummymobdb(0); //The first time this is invoked, it creates the dummy mob + memset(mob->db_data,0,sizeof(mob->db_data)); //Clear the array + mob->db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns + mob->makedummymobdb(0); //The first time this is invoked, it creates the dummy mob item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_NONE); item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.c::item_drop_list_ers",ERS_OPT_NONE); - mob_load(); + mob->load(); - iTimer->add_timer_func_list(mob_delayspawn,"mob_delayspawn"); - iTimer->add_timer_func_list(mob_delay_item_drop,"mob_delay_item_drop"); - iTimer->add_timer_func_list(mob_ai_hard,"mob_ai_hard"); - iTimer->add_timer_func_list(mob_ai_lazy,"mob_ai_lazy"); - iTimer->add_timer_func_list(mob_timer_delete,"mob_timer_delete"); - iTimer->add_timer_func_list(mob_spawn_guardian_sub,"mob_spawn_guardian_sub"); - iTimer->add_timer_func_list(mob_respawn,"mob_respawn"); - iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME,mob_ai_hard,0,0,MIN_MOBTHINKTIME); - iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME*10,mob_ai_lazy,0,0,MIN_MOBTHINKTIME*10); + iTimer->add_timer_func_list(mob->delayspawn,"mob_delayspawn"); + iTimer->add_timer_func_list(mob->delay_item_drop,"mob_delay_item_drop"); + iTimer->add_timer_func_list(mob->ai_hard,"mob_ai_hard"); + iTimer->add_timer_func_list(mob->ai_lazy,"mob_ai_lazy"); + iTimer->add_timer_func_list(mob->timer_delete,"mob_timer_delete"); + iTimer->add_timer_func_list(mob->spawn_guardian_sub,"mob_spawn_guardian_sub"); + iTimer->add_timer_func_list(mob->respawn,"mob_respawn"); + iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME,mob->ai_hard,0,0,MIN_MOBTHINKTIME); + iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME*10,mob->ai_lazy,0,0,MIN_MOBTHINKTIME*10); return 0; } @@ -4687,25 +4676,25 @@ int do_init_mob(void) int do_final_mob(void) { int i; - if (mob_dummy) + if (mob->dummy) { - aFree(mob_dummy); - mob_dummy = NULL; + aFree(mob->dummy); + mob->dummy = NULL; } for (i = 0; i <= MAX_MOB_DB; i++) { - if (mob_db_data[i] != NULL) + if (mob->db_data[i] != NULL) { - aFree(mob_db_data[i]); - mob_db_data[i] = NULL; + aFree(mob->db_data[i]); + mob->db_data[i] = NULL; } } for (i = 0; i <= MAX_MOB_CHAT; i++) { - if (mob_chat_db[i] != NULL) + if (mob->chat_db[i] != NULL) { - aFree(mob_chat_db[i]); - mob_chat_db[i] = NULL; + aFree(mob->chat_db[i]); + mob->chat_db[i] = NULL; } } for (i = 0; i < MAX_ITEMDB; i++) @@ -4720,3 +4709,115 @@ int do_final_mob(void) ers_destroy(item_drop_list_ers); return 0; } + +void mob_defaults(void) { + //Defines the Manuk/Splendide mob groups for the status reductions [Epoque] + const int mob_manuk[8] = { 1986, 1987, 1988, 1989, 1990, 1997, 1998, 1999 }; + const int mob_splendide[5] = { 1991, 1992, 1993, 1994, 1995 }; + + mob = &mob_s; + + memset(mob->db_data, 0, sizeof(mob->db_data)); + mob->dummy = NULL; + memset(mob->chat_db, 0, sizeof(mob->chat_db)); + + memcpy(mob->manuk, mob_manuk, sizeof(mob->manuk)); + memcpy(mob->splendide, mob_splendide, sizeof(mob->splendide)); + /* */ + mob->reload = mob_reload; + mob->init = do_init_mob; + mob->final = do_final_mob; + /* */ + mob->db = mob_db; + mob->chat = mob_chat; + mob->makedummymobdb = mob_makedummymobdb; + mob->spawn_guardian_sub = mob_spawn_guardian_sub; + mob->skill_id2skill_idx = mob_skill_id2skill_idx; + mob->db_searchname = mobdb_searchname; + mob->db_searchname_array_sub = mobdb_searchname_array_sub; + mob->mvptomb_create = mvptomb_create; + mob->mvptomb_destroy = mvptomb_destroy; + mob->db_searchname_array = mobdb_searchname_array; + mob->db_checkid = mobdb_checkid; + mob->get_viewdata = mob_get_viewdata; + mob->parse_dataset = mob_parse_dataset; + mob->spawn_dataset = mob_spawn_dataset; + mob->get_random_id = mob_get_random_id; + mob->ksprotected = mob_ksprotected; + mob->once_spawn_sub = mob_once_spawn_sub; + mob->once_spawn = mob_once_spawn; + mob->once_spawn_area = mob_once_spawn_area; + mob->spawn_guardian = mob_spawn_guardian; + mob->spawn_bg = mob_spawn_bg; + mob->can_reach = mob_can_reach; + mob->linksearch = mob_linksearch; + mob->delayspawn = mob_delayspawn; + mob->setdelayspawn = mob_setdelayspawn; + mob->count_sub = mob_count_sub; + mob->spawn = mob_spawn; + mob->can_changetarget = mob_can_changetarget; + mob->target = mob_target; + mob->ai_sub_hard_activesearch = mob_ai_sub_hard_activesearch; + mob->ai_sub_hard_changechase = mob_ai_sub_hard_changechase; + mob->ai_sub_hard_bg_ally = mob_ai_sub_hard_bg_ally; + mob->ai_sub_hard_lootsearch = mob_ai_sub_hard_lootsearch; + mob->warpchase_sub = mob_warpchase_sub; + mob->ai_sub_hard_slavemob = mob_ai_sub_hard_slavemob; + mob->unlocktarget = mob_unlocktarget; + mob->randomwalk = mob_randomwalk; + mob->warpchase = mob_warpchase; + mob->ai_sub_hard = mob_ai_sub_hard; + mob->ai_sub_hard_timer = mob_ai_sub_hard_timer; + mob->ai_sub_foreachclient = mob_ai_sub_foreachclient; + mob->ai_sub_lazy = mob_ai_sub_lazy; + mob->ai_lazy = mob_ai_lazy; + mob->ai_hard = mob_ai_hard; + mob->setdropitem = mob_setdropitem; + mob->setlootitem = mob_setlootitem; + mob->delay_item_drop = mob_delay_item_drop; + mob->item_drop = mob_item_drop; + mob->timer_delete = mob_timer_delete; + mob->deleteslave_sub = mob_deleteslave_sub; + mob->deleteslave = mob_deleteslave; + mob->respawn = mob_respawn; + mob->log_damage = mob_log_damage; + mob->damage = mob_damage; + mob->dead = mob_dead; + mob->revive = mob_revive; + mob->guardian_guildchange = mob_guardian_guildchange; + mob->random_class = mob_random_class; + mob->class_change = mob_class_change; + mob->heal = mob_heal; + mob->warpslave_sub = mob_warpslave_sub; + mob->warpslave = mob_warpslave; + mob->countslave_sub = mob_countslave_sub; + mob->countslave = mob_countslave; + mob->summonslave = mob_summonslave; + mob->getfriendhprate_sub = mob_getfriendhprate_sub; + mob->getfriendhprate = mob_getfriendhprate; + mob->getmasterhpltmaxrate = mob_getmasterhpltmaxrate; + mob->getfriendstatus_sub = mob_getfriendstatus_sub; + mob->getfriendstatus = mob_getfriendstatus; + mob->skill_use = mobskill_use; + mob->skill_event = mobskill_event; + mob->is_clone = mob_is_clone; + mob->clone_spawn = mob_clone_spawn; + mob->clone_delete = mob_clone_delete; + mob->drop_adjust = mob_drop_adjust; + mob->item_dropratio_adjust = item_dropratio_adjust; + mob->parse_dbrow = mob_parse_dbrow; + mob->readdb_sub = mob_readdb_sub; + mob->readdb = mob_readdb; + mob->read_sqldb = mob_read_sqldb; + mob->readdb_mobavail = mob_readdb_mobavail; + mob->read_randommonster = mob_read_randommonster; + mob->parse_row_chatdb = mob_parse_row_chatdb; + mob->readchatdb = mob_readchatdb; + mob->parse_row_mobskilldb = mob_parse_row_mobskilldb; + mob->readskilldb = mob_readskilldb; + mob->read_sqlskilldb = mob_read_sqlskilldb; + mob->readdb_race2 = mob_readdb_race2; + mob->readdb_itemratio = mob_readdb_itemratio; + mob->load = mob_load; + mob->clear_spawninfo = mob_clear_spawninfo; +} diff --git a/src/map/mob.h b/src/map/mob.h index 137e33ee7..7e9ecbd28 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #ifndef _MOB_H_ #define _MOB_H_ @@ -38,9 +39,7 @@ //Used to determine default enemy type of mobs (for use in eachinrange calls) #define DEFAULT_ENEMY_TYPE(md) (md->special_state.ai?BL_CHAR:BL_MOB|BL_PC|BL_HOM|BL_MER) -//Externals for the status effects. [Epoque] -extern const int mob_manuk[8]; -extern const int mob_splendide[5]; +#define MAX_MOB_CHAT 250 //Max Skill's messages //Mob skill states. enum MobSkillState { @@ -243,41 +242,6 @@ struct item_drop_list { struct item_drop* item; // linked list of drops }; -struct mob_db* mob_db(int class_); -int mobdb_searchname(const char *str); -int mobdb_searchname_array(struct mob_db** data, int size, const char *str, int flag); -int mobdb_checkid(const int id); -struct view_data* mob_get_viewdata(int class_); - -struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, - short x, short y, const char *mobname, int class_, const char *event, unsigned int size, unsigned int ai); - -int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, - const char* mobname, int class_, int amount, const char* event, unsigned int size, unsigned int ai); - -int mob_once_spawn_area(struct map_session_data* sd, int16 m, - int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int class_, int amount, const char* event, unsigned int size, unsigned int ai); - -bool mob_ksprotected (struct block_list *src, struct block_list *target); - -int mob_spawn_guardian(const char* mapname, int16 x, int16 y, const char* mobname, int class_, const char* event, int guardian, bool has_index); // Spawning Guardians [Valaris] -int mob_spawn_bg(const char* mapname, int16 x, int16 y, const char* mobname, int class_, const char* event, unsigned int bg_id); -int mob_guardian_guildchange(struct mob_data *md); //Change Guardian's ownership. [Skotlex] - -int mob_randomwalk(struct mob_data *md,unsigned int tick); -int mob_warpchase(struct mob_data *md, struct block_list *target); -int mob_target(struct mob_data *md,struct block_list *bl,int dist); -int mob_unlocktarget(struct mob_data *md, unsigned int tick); -struct mob_data* mob_spawn_dataset(struct spawn_data *data); -int mob_spawn(struct mob_data *md); -int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data); -int mob_setdelayspawn(struct mob_data *md); -int mob_parse_dataset(struct spawn_data *data); -void mob_log_damage(struct mob_data *md, struct block_list *src, int damage); -void mob_damage(struct mob_data *md, struct block_list *src, int damage); -int mob_dead(struct mob_data *md, struct block_list *src, int type); -void mob_revive(struct mob_data *md, unsigned int hp); -void mob_heal(struct mob_data *md,unsigned int heal); #define mob_stop_walking(md, type) unit_stop_walking(&(md)->bl, type) #define mob_stop_attack(md) unit_stop_attack(&(md)->bl) @@ -285,36 +249,117 @@ void mob_heal(struct mob_data *md,unsigned int heal); #define mob_is_gvg(md) (map[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) #define mob_is_treasure(md) (((md)->class_ >= MOBID_TREAS01 && (md)->class_ <= MOBID_TREAS40) || ((md)->class_ >= MOBID_TREAS41 && (md)->class_ <= MOBID_TREAS49)) -void mob_clear_spawninfo(); -int do_init_mob(void); -int do_final_mob(void); - -int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data); -int mob_deleteslave(struct mob_data *md); - -int mob_random_class (int *value, size_t count); -int mob_get_random_id(int type, int flag, int lv); -int mob_class_change(struct mob_data *md,int class_); -int mob_warpslave(struct block_list *bl, int range); -int mob_linksearch(struct block_list *bl,va_list ap); - -int mobskill_use(struct mob_data *md,unsigned int tick,int event); -int mobskill_event(struct mob_data *md,struct block_list *src,unsigned int tick, int flag); -int mobskill_castend_id( int tid, unsigned int tick, int id,int data ); -int mobskill_castend_pos( int tid, unsigned int tick, int id,int data ); -int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id); -int mob_countslave(struct block_list *bl); -int mob_count_sub(struct block_list *bl, va_list ap); - -int mob_is_clone(int class_); - -int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, int mode, int flag, unsigned int duration); -int mob_clone_delete(struct mob_data *md); +struct mob_interface { + //Dynamic mob database, allows saving of memory when there's big gaps in the mob_db [Skotlex] + struct mob_db *db_data[MAX_MOB_DB+1]; + struct mob_db *dummy; //Dummy mob to be returned when a non-existant one is requested. + //Dynamic mob chat database + struct mob_chat *chat_db[MAX_MOB_CHAT+1]; + //Defines the Manuk/Splendide mob groups for the status reductions [Epoque] + int manuk[8]; + int splendide[5]; + /* */ + int (*init) (void); + int (*final) (void); + void (*reload) (void); + /* */ + struct mob_db* (*db) (int index); + struct mob_chat* (*chat) (short id); + int (*makedummymobdb) (int); + int (*spawn_guardian_sub) (int tid, unsigned int tick, int id, intptr_t data); + int (*skill_id2skill_idx) (int class_, uint16 skill_id); + int (*db_searchname) (const char *str); + int (*db_searchname_array_sub) (struct mob_db *mob, const char *str, int flag); + // MvP Tomb System + void (*mvptomb_create) (struct mob_data *md, char *killer, time_t time); + void (*mvptomb_destroy) (struct mob_data *md); + int (*db_searchname_array) (struct mob_db **data, int size, const char *str, int flag); + int (*db_checkid) (const int id); + struct view_data* (*get_viewdata) (int class_); + int (*parse_dataset) (struct spawn_data *data); + struct mob_data* (*spawn_dataset) (struct spawn_data *data); + int (*get_random_id) (int type, int flag, int lv); + bool (*ksprotected) (struct block_list *src, struct block_list *target); + struct mob_data* (*once_spawn_sub) (struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int class_, const char *event, unsigned int size, unsigned int ai); + int (*once_spawn) (struct map_session_data *sd, int16 m, int16 x, int16 y, const char *mobname, int class_, int amount, const char *event, unsigned int size, unsigned int ai); + int (*once_spawn_area) (struct map_session_data *sd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, const char *mobname, int class_, int amount, const char *event, unsigned int size, unsigned int ai); + int (*spawn_guardian) (const char *mapname, short x, short y, const char *mobname, int class_, const char *event, int guardian, bool has_index); + int (*spawn_bg) (const char *mapname, short x, short y, const char *mobname, int class_, const char *event, unsigned int bg_id); + int (*can_reach) (struct mob_data *md, struct block_list *bl, int range, int state); + int (*linksearch) (struct block_list *bl, va_list ap); + int (*delayspawn) (int tid, unsigned int tick, int id, intptr_t data); + int (*setdelayspawn) (struct mob_data *md); + int (*count_sub) (struct block_list *bl, va_list ap); + int (*spawn) (struct mob_data *md); + int (*can_changetarget) (struct mob_data *md, struct block_list *target, int mode); + int (*target) (struct mob_data *md, struct block_list *bl, int dist); + int (*ai_sub_hard_activesearch) (struct block_list *bl, va_list ap); + int (*ai_sub_hard_changechase) (struct block_list *bl, va_list ap); + int (*ai_sub_hard_bg_ally) (struct block_list *bl, va_list ap); + int (*ai_sub_hard_lootsearch) (struct block_list *bl, va_list ap); + int (*warpchase_sub) (struct block_list *bl, va_list ap); + int (*ai_sub_hard_slavemob) (struct mob_data *md, unsigned int tick); + int (*unlocktarget) (struct mob_data *md, unsigned int tick); + int (*randomwalk) (struct mob_data *md, unsigned int tick); + int (*warpchase) (struct mob_data *md, struct block_list *target); + bool (*ai_sub_hard) (struct mob_data *md, unsigned int tick); + int (*ai_sub_hard_timer) (struct block_list *bl, va_list ap); + int (*ai_sub_foreachclient) (struct map_session_data *sd, va_list ap); + int (*ai_sub_lazy) (struct mob_data *md, va_list args); + int (*ai_lazy) (int tid, unsigned int tick, int id, intptr_t data); + int (*ai_hard) (int tid, unsigned int tick, int id, intptr_t data); + struct item_drop* (*setdropitem) (int nameid, int qty, struct item_data *data); + struct item_drop* (*setlootitem) (struct item *item); + int (*delay_item_drop) (int tid, unsigned int tick, int id, intptr_t data); + void (*item_drop) (struct mob_data *md, struct item_drop_list *dlist, struct item_drop *ditem, int loot, int drop_rate, unsigned short flag); + int (*timer_delete) (int tid, unsigned int tick, int id, intptr_t data); + int (*deleteslave_sub) (struct block_list *bl, va_list ap); + int (*deleteslave) (struct mob_data *md); + int (*respawn) (int tid, unsigned int tick, int id, intptr_t data); + void (*log_damage) (struct mob_data *md, struct block_list *src, int damage); + void (*damage) (struct mob_data *md, struct block_list *src, int damage); + int (*dead) (struct mob_data *md, struct block_list *src, int type); + void (*revive) (struct mob_data *md, unsigned int hp); + int (*guardian_guildchange) (struct mob_data *md); + int (*random_class) (int *value, size_t count); + int (*class_change) (struct mob_data *md, int class_); + void (*heal) (struct mob_data *md, unsigned int heal); + int (*warpslave_sub) (struct block_list *bl, va_list ap); + int (*warpslave) (struct block_list *bl, int range); + int (*countslave_sub) (struct block_list *bl, va_list ap); + int (*countslave) (struct block_list *bl); + int (*summonslave) (struct mob_data *md2, int *value, int amount, uint16 skill_id); + int (*getfriendhprate_sub) (struct block_list *bl, va_list ap); + struct block_list* (*getfriendhprate) (struct mob_data *md, int min_rate, int max_rate); + struct block_list* (*getmasterhpltmaxrate) (struct mob_data *md, int rate); + int (*getfriendstatus_sub) (struct block_list *bl, va_list ap); + struct mob_data* (*getfriendstatus) (struct mob_data *md, int cond1, int cond2); + int (*skill_use) (struct mob_data *md, unsigned int tick, int event); + int (*skill_event) (struct mob_data *md, struct block_list *src, unsigned int tick, int flag); + int (*is_clone) (int class_); + int (*clone_spawn) (struct map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, int mode, int flag, unsigned int duration); + int (*clone_delete) (struct mob_data *md); + unsigned int (*drop_adjust) (int baserate, int rate_adjust, unsigned short rate_min, unsigned short rate_max); + void (*item_dropratio_adjust) (int nameid, int mob_id, int *rate_adjust); + bool (*parse_dbrow) (char **str); + bool (*readdb_sub) (char *fields[], int columns, int current); + void (*readdb) (void); + int (*read_sqldb) (void); + bool (*readdb_mobavail) (char *str[], int columns, int current); + int (*read_randommonster) (void); + bool (*parse_row_chatdb) (char **str, const char *source, int line, int *last_msg_id); + void (*readchatdb) (void); + bool (*parse_row_mobskilldb) (char **str, int columns, int current); + void (*readskilldb) (void); + int (*read_sqlskilldb) (void); + bool (*readdb_race2) (char *fields[], int columns, int current); + bool (*readdb_itemratio) (char *str[], int columns, int current); + void (*load) (void); + void (*clear_spawninfo) (); +}; -void mob_reload(void); +struct mob_interface *mob; -// MvP Tomb System -void mvptomb_create(struct mob_data *md, char *killer, time_t time); -void mvptomb_destroy(struct mob_data *md); +void mob_defaults(void); #endif /* _MOB_H_ */ diff --git a/src/map/npc.c b/src/map/npc.c index 8a2c0f746..c7c537e1f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2938,15 +2938,15 @@ static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, co * Parse Mob 2 - Actually Spawns Mob * [Wizputer] *------------------------------------------*/ -void npc_parse_mob2(struct spawn_data* mob) +void npc_parse_mob2(struct spawn_data* mobspawn) { int i; - for( i = mob->active; i < mob->num; ++i ) { - struct mob_data* md = mob_spawn_dataset(mob); - md->spawn = mob; + for( i = mobspawn->active; i < mobspawn->num; ++i ) { + struct mob_data* md = mob->spawn_dataset(mobspawn); + md->spawn = mobspawn; md->spawn->active++; - mob_spawn(md); + mob->spawn(md); } } @@ -2955,19 +2955,19 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c int num, class_, m,x,y,xs,ys, i,j; int mob_lv = -1, ai = -1, size = -1; char mapname[32], mobname[NAME_LENGTH]; - struct spawn_data mob, *data; + struct spawn_data mobspawn, *data; struct mob_db* db; - memset(&mob, 0, sizeof(struct spawn_data)); + memset(&mobspawn, 0, sizeof(struct spawn_data)); - mob.state.boss = !strcmpi(w2,"boss_monster"); + mobspawn.state.boss = !strcmpi(w2,"boss_monster"); // w1=<map name>,<x>,<y>,<xs>,<ys> // w3=<mob name>{,<mob level>} // w4=<mob id>,<amount>,<delay1>,<delay2>,<event>{,<mob size>,<mob ai>} if( sscanf(w1, "%31[^,],%d,%d,%d,%d", mapname, &x, &y, &xs, &ys) < 3 || sscanf(w3, "%23[^,],%d", mobname, &mob_lv) < 1 - || sscanf(w4, "%d,%d,%u,%u,%127[^,],%d,%d[^\t\r\n]", &class_, &num, &mob.delay1, &mob.delay2, mob.eventname, &size, &ai) < 2 ) + || sscanf(w4, "%d,%d,%u,%u,%127[^,],%d,%d[^\t\r\n]", &class_, &num, &mobspawn.delay1, &mobspawn.delay2, mobspawn.eventname, &size, &ai) < 2 ) { ShowError("npc_parse_mob: Invalid mob definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return strchr(start,'\n');// skip and continue @@ -2980,16 +2980,16 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c m = iMap->mapname2mapid(mapname); if( m < 0 )//Not loaded on this map-server instance. return strchr(start,'\n');// skip and continue - mob.m = (unsigned short)m; + mobspawn.m = (unsigned short)m; - if( x < 0 || x >= map[mob.m].xs || y < 0 || y >= map[mob.m].ys ) + if( x < 0 || x >= map[mobspawn.m].xs || y < 0 || y >= map[mobspawn.m].ys ) { - ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", map[mob.m].name, x, y, (map[mob.m].xs-1), (map[mob.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); + ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", map[mobspawn.m].name, x, y, (map[mobspawn.m].xs-1), (map[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } // check monster ID if exists! - if( mobdb_checkid(class_) == 0 ) + if( mob->db_checkid(class_) == 0 ) { ShowError("npc_parse_mob: Unknown mob ID %d (file '%s', line '%d').\n", class_, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue @@ -3001,15 +3001,15 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c return strchr(start,'\n');// skip and continue } - if( (mob.state.size < 0 || mob.state.size > 2) && size != -1 ) + if( (mobspawn.state.size < 0 || mobspawn.state.size > 2) && size != -1 ) { - ShowError("npc_parse_mob: Invalid size number %d for mob ID %d (file '%s', line '%d').\n", mob.state.size, class_, filepath, strline(buffer, start - buffer)); + ShowError("npc_parse_mob: Invalid size number %d for mob ID %d (file '%s', line '%d').\n", mobspawn.state.size, class_, filepath, strline(buffer, start - buffer)); return strchr(start, '\n'); } - if( (mob.state.ai < 0 || mob.state.ai > 4) && ai != -1 ) + if( (mobspawn.state.ai < 0 || mobspawn.state.ai > 4) && ai != -1 ) { - ShowError("npc_parse_mob: Invalid ai %d for mob ID %d (file '%s', line '%d').\n", mob.state.ai, class_, filepath, strline(buffer, start - buffer)); + ShowError("npc_parse_mob: Invalid ai %d for mob ID %d (file '%s', line '%d').\n", mobspawn.state.ai, class_, filepath, strline(buffer, start - buffer)); return strchr(start, '\n'); } @@ -3019,58 +3019,58 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c return strchr(start, '\n'); } - mob.num = (unsigned short)num; - mob.active = 0; - mob.class_ = (short) class_; - mob.x = (unsigned short)x; - mob.y = (unsigned short)y; - mob.xs = (signed short)xs; - mob.ys = (signed short)ys; + mobspawn.num = (unsigned short)num; + mobspawn.active = 0; + mobspawn.class_ = (short) class_; + mobspawn.x = (unsigned short)x; + mobspawn.y = (unsigned short)y; + mobspawn.xs = (signed short)xs; + mobspawn.ys = (signed short)ys; if (mob_lv > 0 && mob_lv <= MAX_LEVEL) - mob.level = mob_lv; + mobspawn.level = mob_lv; if (size > 0 && size <= 2) - mob.state.size = size; + mobspawn.state.size = size; if (ai > 0 && ai <= 4) - mob.state.ai = ai; + mobspawn.state.ai = ai; - if (mob.num > 1 && battle_config.mob_count_rate != 100) { - if ((mob.num = mob.num * battle_config.mob_count_rate / 100) < 1) - mob.num = 1; + if (mobspawn.num > 1 && battle_config.mob_count_rate != 100) { + if ((mobspawn.num = mobspawn.num * battle_config.mob_count_rate / 100) < 1) + mobspawn.num = 1; } - if (battle_config.force_random_spawn || (mob.x == 0 && mob.y == 0)) + if (battle_config.force_random_spawn || (mobspawn.x == 0 && mobspawn.y == 0)) { //Force a random spawn anywhere on the map. - mob.x = mob.y = 0; - mob.xs = mob.ys = -1; + mobspawn.x = mobspawn.y = 0; + mobspawn.xs = mobspawn.ys = -1; } - if(mob.delay1>0xfffffff || mob.delay2>0xfffffff) { - ShowError("npc_parse_mob: Invalid spawn delays %u %u (file '%s', line '%d').\n", mob.delay1, mob.delay2, filepath, strline(buffer,start-buffer)); + if(mobspawn.delay1>0xfffffff || mobspawn.delay2>0xfffffff) { + ShowError("npc_parse_mob: Invalid spawn delays %u %u (file '%s', line '%d').\n", mobspawn.delay1, mobspawn.delay2, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } //Use db names instead of the spawn file ones. if(battle_config.override_mob_names==1) - strcpy(mob.name,"--en--"); + strcpy(mobspawn.name,"--en--"); else if (battle_config.override_mob_names==2) - strcpy(mob.name,"--ja--"); + strcpy(mobspawn.name,"--ja--"); else - safestrncpy(mob.name, mobname, sizeof(mob.name)); + safestrncpy(mobspawn.name, mobname, sizeof(mobspawn.name)); //Verify dataset. - if( !mob_parse_dataset(&mob) ) + if( !mob->parse_dataset(&mobspawn) ) { ShowError("npc_parse_mob: Invalid dataset for monster ID %d (file '%s', line '%d').\n", class_, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } //Update mob spawn lookup database - db = mob_db(class_); + db = mob->db(class_); for( i = 0; i < ARRAYLENGTH(db->spawn); ++i ) { - if (map[mob.m].index == db->spawn[i].mapindex) + if (map[mobspawn.m].index == db->spawn[i].mapindex) { //Update total - db->spawn[i].qty += mob.num; + db->spawn[i].qty += mobspawn.num; //Re-sort list for( j = i; j > 0 && db->spawn[j-1].qty < db->spawn[i].qty; --j ); if( j != i ) @@ -3083,18 +3083,18 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c } break; } - if (mob.num > db->spawn[i].qty) + if (mobspawn.num > db->spawn[i].qty) { //Insert into list memmove(&db->spawn[i+1], &db->spawn[i], sizeof(db->spawn) -(i+1)*sizeof(db->spawn[0])); - db->spawn[i].mapindex = map[mob.m].index; - db->spawn[i].qty = mob.num; + db->spawn[i].mapindex = map[mobspawn.m].index; + db->spawn[i].qty = mobspawn.num; break; } } //Now that all has been validated. We allocate the actual memory that the re-spawn data will use. data = (struct spawn_data*)aMalloc(sizeof(struct spawn_data)); - memcpy(data, &mob, sizeof(struct spawn_data)); + memcpy(data, &mobspawn, sizeof(struct spawn_data)); // spawn / cache the new mobs if( battle_config.dynamic_mobs && iMap->addmobtolist(data->m, data) >= 0 ) { @@ -3821,7 +3821,7 @@ int npc_reload(void) { } // clear mob spawn lookup index - mob_clear_spawninfo(); + mob->clear_spawninfo(); npc_warp = npc_shop = npc_script = 0; npc_mob = npc_cache_mob = npc_delay_mob = 0; diff --git a/src/map/pc.c b/src/map/pc.c index 421099ce1..ce275a21c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6817,7 +6817,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { { struct mob_data *md=(struct mob_data *)src; if(md->target_id==sd->bl.id) - mob_unlocktarget(md,tick); + 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] diff --git a/src/map/pet.c b/src/map/pet.c index ae8216fc2..796edd0b8 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -80,7 +80,7 @@ int pet_create_egg(struct map_session_data *sd, int item_id) sd->catch_target_class = pet_db[pet_id].class_; intif->create_pet(sd->status.account_id, sd->status.char_id, (short)pet_db[pet_id].class_, - (short)mob_db(pet_db[pet_id].class_)->lv, + (short)mob->db(pet_db[pet_id].class_)->lv, (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); @@ -353,7 +353,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet) pd->msd = sd; pd->petDB = &pet_db[i]; - pd->db = mob_db(pet->class_); + pd->db = mob->db(pet->class_); memcpy(&pd->pet, pet, sizeof(struct s_pet)); iStatus->set_viewdata(&pd->bl, pet->class_); unit_dataset(&pd->bl); @@ -529,7 +529,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) unit_remove_map(&md->bl,CLR_OUTSIGHT); status_kill(&md->bl); clif->pet_roulette(sd,1); - intif->create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class_,mob_db(pet_db[i].class_)->lv, + intif->create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class_,mob->db(pet_db[i].class_)->lv, pet_db[i].EggID,0,pet_db[i].intimate,100,0,1,pet_db[i].jname); } else @@ -1305,7 +1305,7 @@ int read_petdb() if( (nameid = atoi(str[0])) <= 0 ) continue; - if( !mobdb_checkid(nameid) ) + if( !mob->db_checkid(nameid) ) { ShowWarning("pet_db reading: Invalid mob-class %d, pet not read.\n", nameid); continue; diff --git a/src/map/script.c b/src/map/script.c index 9f165f1eb..337f99cf0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8358,7 +8358,7 @@ BUILDIN(makepet) sd->catch_target_class = pet_db[pet_id].class_; intif->create_pet( sd->status.account_id, sd->status.char_id, - (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv, + (short)pet_db[pet_id].class_, (short)mob->db(pet_db[pet_id].class_)->lv, (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname); } @@ -8485,7 +8485,7 @@ BUILDIN(monster) } } - if (class_ >= 0 && !mobdb_checkid(class_)) + if (class_ >= 0 && !mob->db_checkid(class_)) { ShowWarning("buildin_monster: Attempted to spawn non-existing monster class %d\n", class_); return false; @@ -8510,7 +8510,7 @@ BUILDIN(monster) } } - mob_id = mob_once_spawn(sd, m, x, y, str, class_, amount, event, size, ai); + mob_id = mob->once_spawn(sd, m, x, y, str, class_, amount, event, size, ai); script_pushint(st, mob_id); return true; } @@ -8521,25 +8521,25 @@ BUILDIN(getmobdrops) { int class_ = script_getnum(st,2); int i, j = 0; - struct mob_db *mob; + struct mob_db *monster; - if( !mobdb_checkid(class_) ) + if( !mob->db_checkid(class_) ) { script_pushint(st, 0); return true; } - mob = mob_db(class_); + monster = mob->db(class_); for( i = 0; i < MAX_MOB_DROP; i++ ) { - if( mob->dropitem[i].nameid < 1 ) + if( monster->dropitem[i].nameid < 1 ) continue; - if( itemdb->exists(mob->dropitem[i].nameid) == NULL ) + if( itemdb->exists(monster->dropitem[i].nameid) == NULL ) continue; - mapreg_setreg(reference_uid(script->add_str("$@MobDrop_item"), j), mob->dropitem[i].nameid); - mapreg_setreg(reference_uid(script->add_str("$@MobDrop_rate"), j), mob->dropitem[i].p); + mapreg_setreg(reference_uid(script->add_str("$@MobDrop_item"), j), monster->dropitem[i].nameid); + mapreg_setreg(reference_uid(script->add_str("$@MobDrop_rate"), j), monster->dropitem[i].p); j++; } @@ -8608,7 +8608,7 @@ BUILDIN(areamonster) } } - mob_id = mob_once_spawn_area(sd, m, x0, y0, x1, y1, str, class_, amount, event, size, ai); + mob_id = mob->once_spawn_area(sd, m, x0, y0, x1, y1, str, class_, amount, event, size, ai); script_pushint(st, mob_id); return true; @@ -8762,7 +8762,7 @@ BUILDIN(clone) master_id = 0; } if (sd) //Return ID of newly crafted clone. - script_pushint(st,mob_clone_spawn(sd, m, x, y, event, master_id, mode, flag, 1000*duration)); + script_pushint(st,mob->clone_spawn(sd, m, x, y, event, master_id, mode, flag, 1000*duration)); else //Failed to create clone. script_pushint(st,0); @@ -11372,7 +11372,7 @@ BUILDIN(strmobinfo) int num=script_getnum(st,2); int class_=script_getnum(st,3); - if(!mobdb_checkid(class_)) + if(!mob->db_checkid(class_)) { if (num < 3) //requested a string script_pushconststr(st,""); @@ -11382,13 +11382,13 @@ BUILDIN(strmobinfo) } switch (num) { - case 1: script_pushstrcopy(st,mob_db(class_)->name); break; - case 2: script_pushstrcopy(st,mob_db(class_)->jname); break; - case 3: script_pushint(st,mob_db(class_)->lv); break; - case 4: script_pushint(st,mob_db(class_)->status.max_hp); break; - case 5: script_pushint(st,mob_db(class_)->status.max_sp); break; - case 6: script_pushint(st,mob_db(class_)->base_exp); break; - case 7: script_pushint(st,mob_db(class_)->job_exp); break; + case 1: script_pushstrcopy(st,mob->db(class_)->name); break; + case 2: script_pushstrcopy(st,mob->db(class_)->jname); break; + case 3: script_pushint(st,mob->db(class_)->lv); break; + case 4: script_pushint(st,mob->db(class_)->status.max_hp); break; + case 5: script_pushint(st,mob->db(class_)->status.max_sp); break; + case 6: script_pushint(st,mob->db(class_)->base_exp); break; + case 7: script_pushint(st,mob->db(class_)->job_exp); break; default: script_pushint(st,0); break; @@ -11436,7 +11436,7 @@ BUILDIN(guardian) } check_event(st, evt); - script_pushint(st, mob_spawn_guardian(map,x,y,str,class_,evt,guardian,has_index)); + script_pushint(st, mob->spawn_guardian(map,x,y,str,class_,evt,guardian,has_index)); return true; } @@ -11828,7 +11828,7 @@ BUILDIN(disguise) id = script_getnum(st,2); - if (mobdb_checkid(id) || npcdb_checkid(id)) { + if (mob->db_checkid(id) || npcdb_checkid(id)) { pc->disguise(sd, id); script_pushint(st,id); } else @@ -12932,14 +12932,14 @@ BUILDIN(summon) clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,sd->bl.x,sd->bl.y,tick); - md = mob_once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, _class, event, SZ_SMALL, AI_NONE); + md = mob->once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, _class, event, SZ_SMALL, AI_NONE); if (md) { md->master_id=sd->bl.id; md->special_state.ai = AI_ATTACK; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob_timer_delete); - md->deletetimer = iTimer->add_timer(tick+(timeout>0?timeout*1000:60000),mob_timer_delete,md->bl.id,0); - mob_spawn (md); //Now it is ready for spawning. + iTimer->delete_timer(md->deletetimer, mob->timer_delete); + md->deletetimer = iTimer->add_timer(tick+(timeout>0?timeout*1000:60000),mob->timer_delete,md->bl.id,0); + mob->spawn (md); //Now it is ready for spawning. clif->specialeffect(&md->bl,344,AREA); sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000); } @@ -14612,11 +14612,11 @@ BUILDIN(setitemscript) *------------------------------------------*/ BUILDIN(getmonsterinfo) { - struct mob_db *mob; + struct mob_db *monster; int mob_id; mob_id = script_getnum(st,2); - if (!mobdb_checkid(mob_id)) { + if (!mob->db_checkid(mob_id)) { ShowError("buildin_getmonsterinfo: Wrong Monster ID: %i\n", mob_id); if ( !script_getnum(st,3) ) //requested a string script_pushconststr(st,"null"); @@ -14624,31 +14624,31 @@ BUILDIN(getmonsterinfo) script_pushint(st,-1); return -1; } - mob = mob_db(mob_id); + monster = mob->db(mob_id); switch ( script_getnum(st,3) ) { - case 0: script_pushstrcopy(st,mob->jname); break; - case 1: script_pushint(st,mob->lv); break; - case 2: script_pushint(st,mob->status.max_hp); break; - case 3: script_pushint(st,mob->base_exp); break; - case 4: script_pushint(st,mob->job_exp); break; - case 5: script_pushint(st,mob->status.rhw.atk); break; - case 6: script_pushint(st,mob->status.rhw.atk2); break; - case 7: script_pushint(st,mob->status.def); break; - case 8: script_pushint(st,mob->status.mdef); break; - case 9: script_pushint(st,mob->status.str); break; - case 10: script_pushint(st,mob->status.agi); break; - case 11: script_pushint(st,mob->status.vit); break; - case 12: script_pushint(st,mob->status.int_); break; - case 13: script_pushint(st,mob->status.dex); break; - case 14: script_pushint(st,mob->status.luk); break; - case 15: script_pushint(st,mob->status.rhw.range); break; - case 16: script_pushint(st,mob->range2); break; - case 17: script_pushint(st,mob->range3); break; - case 18: script_pushint(st,mob->status.size); break; - case 19: script_pushint(st,mob->status.race); break; - case 20: script_pushint(st,mob->status.def_ele); break; - case 21: script_pushint(st,mob->status.mode); break; - case 22: script_pushint(st,mob->mexp); break; + case 0: script_pushstrcopy(st,monster->jname); break; + case 1: script_pushint(st,monster->lv); break; + case 2: script_pushint(st,monster->status.max_hp); break; + case 3: script_pushint(st,monster->base_exp); break; + case 4: script_pushint(st,monster->job_exp); break; + case 5: script_pushint(st,monster->status.rhw.atk); break; + case 6: script_pushint(st,monster->status.rhw.atk2); break; + case 7: script_pushint(st,monster->status.def); break; + case 8: script_pushint(st,monster->status.mdef); break; + case 9: script_pushint(st,monster->status.str); break; + case 10: script_pushint(st,monster->status.agi); break; + case 11: script_pushint(st,monster->status.vit); break; + case 12: script_pushint(st,monster->status.int_); break; + case 13: script_pushint(st,monster->status.dex); break; + case 14: script_pushint(st,monster->status.luk); break; + case 15: script_pushint(st,monster->status.rhw.range); break; + case 16: script_pushint(st,monster->range2); break; + case 17: script_pushint(st,monster->range3); break; + case 18: script_pushint(st,monster->status.size); break; + case 19: script_pushint(st,monster->status.race); break; + case 20: script_pushint(st,monster->status.def_ele); break; + case 21: script_pushint(st,monster->status.mode); break; + case 22: script_pushint(st,monster->mexp); break; default: script_pushint(st,-1); //wrong Index } return true; @@ -15843,7 +15843,7 @@ BUILDIN(bg_monster) class_ = script_getnum(st,7); if( script_hasdata(st,8) ) evt = script_getstr(st,8); check_event(st, evt); - script_pushint(st, mob_spawn_bg(map,x,y,str,class_,evt,bg_id)); + script_pushint(st, mob->spawn_bg(map,x,y,str,class_,evt,bg_id)); return true; } diff --git a/src/map/skill.c b/src/map/skill.c index d9df0b869..025ed4486 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1594,21 +1594,21 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint dstmd && !(tstatus->mode&MD_BOSS) && (rnd()%10000 < sd->bonus.classchange)) { - struct mob_db *mob; + struct mob_db *monster; int class_; temp = 0; do { do { class_ = rnd() % MAX_MOB_DB; - } while (!mobdb_checkid(class_)); + } while (!mob->db_checkid(class_)); rate = rnd() % 1000000; - mob = mob_db(class_); + monster = mob->db(class_); } while ( - (mob->status.mode&(MD_BOSS|MD_PLANT) || mob->summonper[0] <= rate) && + (monster->status.mode&(MD_BOSS|MD_PLANT) || monster->summonper[0] <= rate) && (temp++) < 2000); if (temp < 2000) - mob_class_change(dstmd,class_); + mob->class_change(dstmd,class_); } return 0; @@ -5272,7 +5272,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case SA_SUMMONMONSTER: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - if (sd) mob_once_spawn(sd, src->m, src->x, src->y," --ja--", -1, 1, "", SZ_SMALL, AI_NONE); + if (sd) mob->once_spawn(sd, src->m, src->x, src->y," --ja--", -1, 1, "", SZ_SMALL, AI_NONE); break; case SA_LEVELUP: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -5296,9 +5296,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - class_ = skill_id==SA_MONOCELL?1002:mob_get_random_id(4, 1, 0); + class_ = skill_id==SA_MONOCELL?1002:mob->get_random_id(4, 1, 0); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - mob_class_change(dstmd,class_); + mob->class_change(dstmd,class_); if( tsc && dstmd->status.mode&MD_BOSS ) { const enum sc_type scs[] = { SC_QUAGMIRE, SC_PROVOKE, SC_ROKISWEIL, SC_GRAVITATION, SC_NJ_SUITON, SC_NOEQUIPWEAPON, SC_NOEQUIPSHIELD, SC_NOEQUIPARMOR, SC_NOEQUIPHELM, SC_BLADESTOP }; @@ -5685,7 +5685,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - id = mob_get_random_id(0,0xF, sd->status.base_level); + id = mob->get_random_id(0,0xF, sd->status.base_level); if (!id) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; @@ -5740,7 +5740,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( dstmd ) { dstmd->state.provoke_flag = src->id; - mob_target(dstmd, src, skill->get_range2(src,skill_id,skill_lv)); + mob->target(dstmd, src, skill->get_range2(src,skill_id,skill_lv)); } break; @@ -5840,7 +5840,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } else if (dstmd && !(tstatus->mode&MD_BOSS) && rnd() % 100 < 20) { // check if target is a monster and not a Boss, for the 20% chance to absorb 2 SP per monster's level [Reddozen] i = 2 * dstmd->level; - mob_target(dstmd,src,0); + mob->target(dstmd,src,0); } if (i) iStatus->heal(src, 0, i, 3); clif->skill_nodamage(src,bl,skill_id,skill_lv,i?1:0); @@ -6152,7 +6152,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if(pc->steal_coin(sd,bl)) { dstmd->state.provoke_flag = src->id; - mob_target(dstmd, src, skill->get_range2(src,skill_id,skill_lv)); + mob->target(dstmd, src, skill->get_range2(src,skill_id,skill_lv)); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } @@ -6238,7 +6238,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); if(dstmd) - mob_unlocktarget(dstmd,tick); + mob->unlocktarget(dstmd,tick); break; // Mercenary Supportive Skills @@ -6872,7 +6872,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NPC_PROVOCATION: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - if (md) mob_unlocktarget(md, tick); + if (md) mob->unlocktarget(md, tick); break; case NPC_KEEPING: @@ -6915,17 +6915,17 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NPC_SUMMONSLAVE: case NPC_SUMMONMONSTER: if(md && md->skill_idx >= 0) - mob_summonslave(md,md->db->skill[md->skill_idx].val,skill_lv,skill_id); + mob->summonslave(md,md->db->skill[md->skill_idx].val,skill_lv,skill_id); break; case NPC_CALLSLAVE: - mob_warpslave(src,MOB_SLAVEDISTANCE); + mob->warpslave(src,MOB_SLAVEDISTANCE); break; case NPC_RANDOMMOVE: if (md) { md->next_walktime = tick - 1; - mob_randomwalk(md,tick); + mob->randomwalk(md,tick); } break; @@ -6948,7 +6948,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui (tbl = battle->get_targeted(mbl)) == NULL) break; md->state.provoke_flag = tbl->id; - mob_target(md, tbl, sstatus->rhw.range); + mob->target(md, tbl, sstatus->rhw.range); } break; @@ -6966,10 +6966,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NPC_TRANSFORMATION: case NPC_METAMORPHOSIS: if(md && md->skill_idx >= 0) { - int class_ = mob_random_class (md->db->skill[md->skill_idx].val,0); + int class_ = mob->random_class (md->db->skill[md->skill_idx].val,0); if (skill_lv > 1) //Multiply the rest of mobs. [Skotlex] - mob_summonslave(md,md->db->skill[md->skill_idx].val,skill_lv-1,skill_id); - if (class_) mob_class_change(md, class_); + mob->summonslave(md,md->db->skill[md->skill_idx].val,skill_lv-1,skill_id); + if (class_) mob->class_change(md, class_); } break; @@ -6988,7 +6988,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui //If mode gets set by NPC_EMOTION then the target should be reset [Playtester] if(skill_id == NPC_EMOTION && md->db->skill[md->skill_idx].val[1]) - mob_unlocktarget(md,tick); + mob->unlocktarget(md,tick); if(md->db->skill[md->skill_idx].val[1] || md->db->skill[md->skill_idx].val[2]) sc_start4(src, type, 100, skill_lv, @@ -7208,7 +7208,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } if(dstmd) - mob_target(dstmd,src,skill->get_range2(src,skill_id,skill_lv)); + mob->target(dstmd,src,skill->get_range2(src,skill_id,skill_lv)); } break; @@ -8560,7 +8560,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( is_boss(bl) ) break; if( sc_start2(bl, type, 100, skill_lv, src->id, skill->get_time(skill_id, skill_lv))) { if( bl->type == BL_MOB ) - mob_unlocktarget((TBL_MOB*)bl,iTimer->gettick()); + mob->unlocktarget((TBL_MOB*)bl,iTimer->gettick()); unit_stop_attack(bl); clif->bladestop(src, bl->id, 1); iMap->freeblock_unlock(); @@ -9147,15 +9147,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if(sd){ struct mob_data *md; - md = mob_once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), 2308, "", SZ_SMALL, AI_NONE); + md = mob->once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), 2308, "", SZ_SMALL, AI_NONE); if( md ) { md->master_id = src->id; md->special_state.ai = AI_ZANZOU; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob_timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0); - mob_spawn( md ); + iTimer->delete_timer(md->deletetimer, mob->timer_delete); + md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + mob->spawn( md ); pc->setinvincibletimer(sd,500);// unlock target lock clif->skill_nodamage(src,bl,skill_id,skill_lv,1); skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit_getdir(bl),0); @@ -9334,13 +9334,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; for(i=0; i<qty[skill_lv - 1]; i++){ //easy way - md = mob_once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK); + md = mob->once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK); if (md) { md->master_id = src->id; if (md->deletetimer != INVALID_TIMER) - iTimer->delete_timer(md->deletetimer, mob_timer_delete); - md->deletetimer = iTimer->add_timer(iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0); - mob_spawn(md); //Now it is ready for spawning. + iTimer->delete_timer(md->deletetimer, mob->timer_delete); + md->deletetimer = iTimer->add_timer(iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + mob->spawn(md); //Now it is ready for spawning. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_CANATTACK|MD_AGGRESSIVE, 0, 60000); } } @@ -9362,8 +9362,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } if (dstmd) { //Mob skill event for no damage skills (damage ones are handled in battle_calc_damage) [Skotlex] - mob_log_damage(dstmd, src, 0); //Log interaction (counts as 'attacker' for the exp bonus) - mobskill_event(dstmd, src, tick, MSC_SKILLUSED|(skill_id<<16)); + mob->log_damage(dstmd, src, 0); //Log interaction (counts as 'attacker' for the exp bonus) + mob->skill_event(dstmd, src, tick, MSC_SKILLUSED|(skill_id<<16)); } if( sd && !(flag&1) ) { // ensure that the skill last-cast tick is recorded @@ -9995,14 +9995,14 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui struct mob_data *md; // Correct info, don't change any of this! [celest] - md = mob_once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE); + md = mob->once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE); if (md) { md->master_id = src->id; md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob_timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id,skill_lv), mob_timer_delete, md->bl.id, 0); - mob_spawn (md); //Now it is ready for spawning. + iTimer->delete_timer(md->deletetimer, mob->timer_delete); + md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id,skill_lv), mob->timer_delete, md->bl.id, 0); + mob->spawn (md); //Now it is ready for spawning. } } break; @@ -10093,16 +10093,16 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if (rnd()%100 < 50) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); } else { - TBL_MOB* md = mob_once_spawn_sub(src, src->m, x, y, "--ja--",(skill_lv < 2 ? 1084+rnd()%2 : 1078+rnd()%6),"", SZ_SMALL, AI_NONE); + TBL_MOB* md = mob->once_spawn_sub(src, src->m, x, y, "--ja--",(skill_lv < 2 ? 1084+rnd()%2 : 1078+rnd()%6),"", SZ_SMALL, AI_NONE); int i; if (!md) break; if ((i = skill->get_time(skill_id, skill_lv)) > 0) { if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob_timer_delete); - md->deletetimer = iTimer->add_timer (tick + i, mob_timer_delete, md->bl.id, 0); + iTimer->delete_timer(md->deletetimer, mob->timer_delete); + md->deletetimer = iTimer->add_timer (tick + i, mob->timer_delete, md->bl.id, 0); } - mob_spawn (md); + mob->spawn (md); } } break; @@ -10228,15 +10228,15 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui int class_ = 2042; struct mob_data *md; - md = mob_once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE); + md = mob->once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE); if( md ) { md->master_id = src->id; md->special_state.ai = AI_FLORA; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob_timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0); - mob_spawn( md ); + iTimer->delete_timer(md->deletetimer, mob->timer_delete); + md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + mob->spawn( md ); } } break; @@ -10490,7 +10490,7 @@ int skill_icewall_block(struct block_list *bl,va_list ap) { return 0; if( !check_distance_bl(bl, target, status_get_range(bl) ) ) { - mob_unlocktarget(md,iTimer->gettick()); + mob->unlocktarget(md,iTimer->gettick()); mob_stop_walking(md,1); } @@ -11917,7 +11917,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns } if (bl->type == BL_MOB && ss != bl) - mobskill_event((TBL_MOB*)bl, ss, tick, MSC_SKILLUSED|(skill_id<<16)); + mob->skill_event((TBL_MOB*)bl, ss, tick, MSC_SKILLUSED|(skill_id<<16)); return skill_id; } @@ -12938,7 +12938,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; case SR_CURSEDCIRCLE: if (map_flag_gvg2(sd->bl.m)) { - if (iMap->foreachinrange(mob_count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB, + if (iMap->foreachinrange(mob->count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB, MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) { char output[128]; sprintf(output, "You're too close to a stone or emperium to do this skill"); @@ -16726,14 +16726,14 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) { class_ = (nameid == 990 || nameid == 991) ? 2043 + nameid - 990 : (nameid == 992) ? 2046 : 2045; - md = mob_once_spawn_sub(&sd->bl, sd->bl.m, x, y, sd->status.name, class_, "", SZ_SMALL, AI_NONE); + md = mob->once_spawn_sub(&sd->bl, sd->bl.m, x, y, sd->status.name, class_, "", SZ_SMALL, AI_NONE); if( md ) { md->master_id = sd->bl.id; md->special_state.ai = AI_FLORA; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob_timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob_timer_delete, md->bl.id, 0); - mob_spawn(md); + iTimer->delete_timer(md->deletetimer, mob->timer_delete); + md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob->timer_delete, md->bl.id, 0); + mob->spawn(md); md->status.matk_min = md->status.matk_max = 250 + (50 * skill_id); } diff --git a/src/map/status.c b/src/map/status.c index c280d80b8..2db38cb15 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1246,7 +1246,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, switch (target->type) { case BL_PC: pc->damage((TBL_PC*)target,src,hp,sp); break; - case BL_MOB: mob_damage((TBL_MOB*)target, src, hp); break; + case BL_MOB: mob->damage((TBL_MOB*)target, src, hp); break; case BL_HOM: homun->damaged((TBL_HOM*)target); break; case BL_MER: mercenary->heal((TBL_MER*)target,hp,sp); break; case BL_ELEM: elemental->heal((TBL_ELEM*)target,hp,sp); break; @@ -1271,7 +1271,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, //&4: Also delete object from memory. switch (target->type) { case BL_PC: flag = pc->dead((TBL_PC*)target,src); break; - case BL_MOB: flag = mob_dead((TBL_MOB*)target, src, flag&4?3:0); break; + case BL_MOB: flag = mob->dead((TBL_MOB*)target, src, flag&4?3:0); break; case BL_HOM: flag = homun->dead((TBL_HOM*)target); break; case BL_MER: flag = mercenary->dead((TBL_MER*)target); break; case BL_ELEM: flag = elemental->dead((TBL_ELEM*)target); break; @@ -1420,7 +1420,7 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) // send hp update to client switch(bl->type) { case BL_PC: pc->heal((TBL_PC*)bl,hp,sp,flag&2?1:0); break; - case BL_MOB: mob_heal((TBL_MOB*)bl,hp); break; + case BL_MOB: mob->heal((TBL_MOB*)bl,hp); break; case BL_HOM: homun->healed((TBL_HOM*)bl); break; case BL_MER: mercenary->heal((TBL_MER*)bl,hp,sp); break; case BL_ELEM: elemental->heal((TBL_ELEM*)bl,hp,sp); break; @@ -1525,7 +1525,7 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per switch (bl->type) { case BL_PC: pc->revive((TBL_PC*)bl, hp, sp); break; - case BL_MOB: mob_revive((TBL_MOB*)bl, hp); break; + case BL_MOB: mob->revive((TBL_MOB*)bl, hp); break; case BL_HOM: homun->revive((TBL_HOM*)bl, hp, sp); break; } @@ -5858,7 +5858,7 @@ struct status_data *status_get_status_data(struct block_list *bl) case BL_HOM: return &((TBL_HOM*)bl)->battle_status; case BL_MER: return &((TBL_MER*)bl)->battle_status; case BL_ELEM: return &((TBL_ELEM*)bl)->battle_status; - case BL_NPC: return ((mobdb_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : &dummy_status); + case BL_NPC: return ((mob->db_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : &dummy_status); default: return &dummy_status; } @@ -5874,7 +5874,7 @@ struct status_data *status_get_base_status(struct block_list *bl) case BL_HOM: return &((TBL_HOM*)bl)->base_status; case BL_MER: return &((TBL_MER*)bl)->base_status; case BL_ELEM: return &((TBL_ELEM*)bl)->base_status; - case BL_NPC: return ((mobdb_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : NULL); + case BL_NPC: return ((mob->db_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : NULL); default: return NULL; } @@ -6071,8 +6071,8 @@ void status_set_viewdata(struct block_list *bl, int class_) { struct view_data* vd; nullpo_retv(bl); - if (mobdb_checkid(class_) || mob_is_clone(class_)) - vd = mob_get_viewdata(class_); + if (mob->db_checkid(class_) || mob->is_clone(class_)) + vd = mob->get_viewdata(class_); else if (npcdb_checkid(class_) || (bl->type == BL_NPC && class_ == WARP_CLASS)) vd = npc_get_viewdata(class_); else if (homdb_checkid(class_)) @@ -7585,7 +7585,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( val2 && bl->type == BL_MOB ) { struct block_list* src = iMap->id2bl(val2); if( src ) - mob_log_damage((TBL_MOB*)bl,src,diff); + mob->log_damage((TBL_MOB*)bl,src,diff); } status_zap(bl, diff, 0); } @@ -7867,7 +7867,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( val3 && bl->type == BL_MOB ) { struct block_list* src = iMap->id2bl(val3); if( src ) - mob_log_damage((TBL_MOB*)bl,src,status->hp - 1); + mob->log_damage((TBL_MOB*)bl,src,status->hp - 1); } status_zap(bl, status->hp-1, val2?0:status->sp); return 1; @@ -8794,7 +8794,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val4 = tick / tick_time; break; case SC_MONSTER_TRANSFORM: - if( !mobdb_checkid(val1) ) + if( !mob->db_checkid(val1) ) val1 = 1002; // default poring val_flag |= 1; break; @@ -10156,7 +10156,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) if( sce->val2 && bl->type == BL_MOB ) { struct block_list* src = iMap->id2bl(sce->val2); if( src ) - mob_log_damage((TBL_MOB*)bl,src,sce->val4); + mob->log_damage((TBL_MOB*)bl,src,sce->val4); } iMap->freeblock_lock(); status_zap(bl, sce->val4, 0); @@ -10192,7 +10192,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) int hp = rnd()%600 + 200; struct block_list* src = iMap->id2bl(sce->val2); if( src && bl && bl->type == BL_MOB ) { - mob_log_damage((TBL_MOB*)bl,src,sd||hp<status->hp?hp:status->hp-1); + mob->log_damage((TBL_MOB*)bl,src,sd||hp<status->hp?hp:status->hp-1); } iMap->freeblock_lock(); status_fix_damage(src, bl, sd||hp<status->hp?hp:status->hp-1, 1); diff --git a/src/map/unit.c b/src/map/unit.c index d3f72421d..228cd75dd 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -234,7 +234,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data //But avoid triggering on stop-walk calls. if(tid != INVALID_TIMER && !(ud->walk_count%WALK_SKILL_INTERVAL) && - mobskill_use(md, tick, -1)) + mob->skill_use(md, tick, -1)) { if (!(ud->skill_id == NPC_SELFDESTRUCTION && ud->skilltimer != INVALID_TIMER)) { //Skill used, abort walking @@ -295,7 +295,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data if (!tbl || !iStatus->check_visibility(bl, tbl)) { //Cancel chase. ud->to_x = bl->x; ud->to_y = bl->y; - if (tbl && bl->type == BL_MOB && mob_warpchase((TBL_MOB*)bl, tbl) ) + if (tbl && bl->type == BL_MOB && mob->warpchase((TBL_MOB*)bl, tbl) ) return 0; ud->target_to = 0; return 0; @@ -1157,7 +1157,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if( !target || src->m != target->m || !src->prev || !target->prev ) return 0; - if( battle_config.ksprotection && sd && mob_ksprotected(src, target) ) + if( battle_config.ksprotection && sd && mob->ksprotected(src, target) ) return 0; //Normally not needed because clif.c checks for it, but the at/char/script commands don't! [Skotlex] @@ -1358,7 +1358,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if (sd && target->type == BL_MOB) { TBL_MOB *md = (TBL_MOB*)target; - mobskill_event(md, src, tick, -1); //Cast targetted skill event. + mob->skill_event(md, src, tick, -1); //Cast targetted skill event. if (tstatus->mode&(MD_CASTSENSOR_IDLE|MD_CASTSENSOR_CHASE) && battle->check_target(target, src, BCT_ENEMY) > 0) { @@ -1609,7 +1609,7 @@ int unit_unattackable(struct block_list *bl) } if(bl->type == BL_MOB) - mob_unlocktarget((struct mob_data*)bl, iTimer->gettick()) ; + mob->unlocktarget((struct mob_data*)bl, iTimer->gettick()) ; else if(bl->type == BL_PET) pet_unlocktarget((struct pet_data*)bl); return 0; @@ -1837,7 +1837,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t if( src->m != target->m ) { - if( src->type == BL_MOB && mob_warpchase((TBL_MOB*)src, target) ) + if( src->type == BL_MOB && mob->warpchase((TBL_MOB*)src, target) ) return 1; // Follow up. return 0; } @@ -1892,12 +1892,12 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t if(ud->walktimer != INVALID_TIMER) unit_stop_walking(src,1); if(md) { - if (mobskill_use(md,tick,-1)) + if (mob->skill_use(md,tick,-1)) return 1; if (sstatus->mode&MD_ASSIST && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME) { // Link monsters nearby [Skotlex] md->last_linktime = tick; - iMap->foreachinrange(mob_linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick); + iMap->foreachinrange(mob->linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick); } } if(src->type == BL_PET && pet_attackskill((TBL_PET*)src, target->id)) @@ -2476,12 +2476,12 @@ int unit_free(struct block_list *bl, clr_type clrtype) struct mob_data *md = (struct mob_data*)bl; if( md->spawn_timer != INVALID_TIMER ) { - iTimer->delete_timer(md->spawn_timer,mob_delayspawn); + iTimer->delete_timer(md->spawn_timer,mob->delayspawn); md->spawn_timer = INVALID_TIMER; } if( md->deletetimer != INVALID_TIMER ) { - iTimer->delete_timer(md->deletetimer,mob_timer_delete); + iTimer->delete_timer(md->deletetimer,mob->timer_delete); md->deletetimer = INVALID_TIMER; } if( md->lootitem ) @@ -2523,10 +2523,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) aFree(md->base_status); md->base_status = NULL; } - if( mob_is_clone(md->class_) ) - mob_clone_delete(md); + if( mob->is_clone(md->class_) ) + mob->clone_delete(md); if( md->tomb_nid ) - mvptomb_destroy(md); + mob->mvptomb_destroy(md); break; } case BL_HOM: |