diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 140 | ||||
-rw-r--r-- | src/map/battle.c | 46 | ||||
-rw-r--r-- | src/map/clif.c | 68 | ||||
-rw-r--r-- | src/map/elemental.c | 27 | ||||
-rw-r--r-- | src/map/elemental.h | 14 | ||||
-rw-r--r-- | src/map/guild.c | 4 | ||||
-rw-r--r-- | src/map/homunculus.c | 16 | ||||
-rw-r--r-- | src/map/instance.c | 2 | ||||
-rw-r--r-- | src/map/itemdb.c | 2 | ||||
-rw-r--r-- | src/map/map.c | 27 | ||||
-rw-r--r-- | src/map/mercenary.c | 8 | ||||
-rw-r--r-- | src/map/mob.c | 859 | ||||
-rw-r--r-- | src/map/mob.h | 189 | ||||
-rw-r--r-- | src/map/npc.c | 100 | ||||
-rw-r--r-- | src/map/pc.c | 16 | ||||
-rw-r--r-- | src/map/pc.h | 4 | ||||
-rw-r--r-- | src/map/pet.c | 42 | ||||
-rw-r--r-- | src/map/pet.h | 4 | ||||
-rw-r--r-- | src/map/script.c | 150 | ||||
-rw-r--r-- | src/map/skill.c | 312 | ||||
-rw-r--r-- | src/map/status.c | 106 | ||||
-rw-r--r-- | src/map/unit.c | 382 | ||||
-rw-r--r-- | src/map/unit.h | 124 |
23 files changed, 1409 insertions, 1233 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index df97740e1..6c44f8919 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1453,11 +1453,11 @@ ACMD(help) { // parameter: '0' - everyone, 'id' - only those attacking someone with that id static int atcommand_stopattack(struct block_list *bl,va_list ap) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); int id = va_arg(ap, int); if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target)) { - unit_stop_attack(bl); + unit->stop_attack(bl); return 1; } return 0; @@ -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_; @@ -5429,9 +5429,9 @@ ACMD(useskill) bl = &sd->bl; if (skill->get_inf(skill_id)&INF_GROUND_SKILL) - unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv); + unit->skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv); else - unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv); + unit->skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv); return true; } @@ -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..bc963a7f4 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -50,7 +50,7 @@ int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last s return su->group?su->group->skill_id:0; } - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); return ud?ud->skill_id:0; } @@ -74,7 +74,7 @@ int battle_gettargeted_sub(struct block_list *bl, va_list ap) { if (*c >= 24) return 0; - if ( !(ud = unit_bl2ud(bl)) ) + if ( !(ud = unit->bl2ud(bl)) ) return 0; if (ud->target == target_id || ud->skilltarget == target_id) { @@ -1250,7 +1250,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ if( battle_config.vit_penalty_type && battle_config.vit_penalty_target&target->type ) { unsigned char target_count; //256 max targets should be a sane max - target_count = unit_counttargeted(target); + target_count = unit->counttargeted(target); if(target_count >= battle_config.vit_penalty_count) { if(battle_config.vit_penalty_type == 1) { if( !tsc || !tsc->data[SC_STEELBODY] ) @@ -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 ) @@ -2664,7 +2664,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam delay = 200; else delay = 100; - unit_set_walkdelay(bl, iTimer->gettick(), delay, 1); + unit->set_walkdelay(bl, iTimer->gettick(), delay, 1); if(sc->data[SC_CR_SHRINK] && rnd()%100<5*sce->val1) skill->blown(bl,src,skill->get_blewcount(CR_SHRINK,1),-1,0); @@ -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; } @@ -2931,9 +2931,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam int dx[8]={0,-1,-1,-1,0,1,1,1}; int dy[8]={1,1,0,-1,-1,-1,0,1}; uint8 dir = iMap->calc_dir(bl, src->x, src->y); - if( unit_movepos(bl, src->x-dx[dir], src->y-dy[dir], 1, 1) ) { + if( unit->movepos(bl, src->x-dx[dir], src->y-dy[dir], 1, 1) ) { clif->slide(bl,src->x-dx[dir],src->y-dy[dir]); - unit_setdir(bl, dir); + unit->setdir(bl, dir); } d->dmg_lv = ATK_DEF; status_change_end(bl, SC_LIGHTNINGWALK, INVALID_TIMER); @@ -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 ) { @@ -3837,7 +3837,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) { unsigned char attacker_count; //256 max targets should be a sane max - attacker_count = unit_counttargeted(target); + attacker_count = unit->counttargeted(target); if(attacker_count >= battle_config.agi_penalty_count) { if (battle_config.agi_penalty_type == 1) @@ -4303,7 +4303,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) { unsigned char attacker_count; //256 max targets should be a sane max - attacker_count = unit_counttargeted(target); + attacker_count = unit->counttargeted(target); if(attacker_count >= battle_config.agi_penalty_count) { if (battle_config.agi_penalty_type == 1) flee = (flee * (100 - (attacker_count - (battle_config.agi_penalty_count - 1))*battle_config.agi_penalty_num))/100; @@ -5199,7 +5199,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i int ratio = (status_get_hp(src) / 100) * sc->data[SC_CRESCENTELBOW]->val1 * iStatus->get_lv(bl) / 125; if (ratio > 5000) ratio = 5000; // Maximum of 5000% ATK rdamage = rdamage * ratio / 100 + (*dmg) * (10 + sc->data[SC_CRESCENTELBOW]->val1 * 20 / 10) / 10; - skill->blown(bl, src, skill->get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit_getdir(src), 0); + skill->blown(bl, src, skill->get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit->getdir(src), 0); clif->skill_damage(bl, src, iTimer->gettick(), status_get_amotion(src), 0, rdamage, 1, SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1, 6); // This is how official does clif->damage(src, bl, iTimer->gettick(), status_get_amotion(src)+1000, 0, rdamage/10, 1, 0, 0); @@ -5226,13 +5226,13 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i } if( sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !is_boss(src) ) { uint8 dir = iMap->calc_dir(bl,src->x,src->y), - t_dir = unit_getdir(bl); + t_dir = unit->getdir(bl); if( !iMap->check_dir(dir,t_dir) ) { int64 rd1 = damage * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. trdamage += rdamage = rd1 - (*dmg = rd1 * 30 / 100); // not normalized as intended. clif->skill_damage(src, bl, iTimer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6); - skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit_getdir(src), 0); + skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit->getdir(src), 0); if( skill_id ) status_change_end(bl, SC_DEATHBOUND, INVALID_TIMER); *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); @@ -5417,7 +5417,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if( tsc && tsc->data[SC_AUTOCOUNTER] && iStatus->check_skilluse(target, src, KN_AUTOCOUNTER, 1) ) { uint8 dir = iMap->calc_dir(target,src->x,src->y); - int t_dir = unit_getdir(target); + int t_dir = unit->getdir(target); int dist = distance_bl(src, target); if(dist <= 0 || (!iMap->check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1)) { diff --git a/src/map/clif.c b/src/map/clif.c index 8f82141b2..f8f88c691 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -902,7 +902,7 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; p.sex = vd->sex; - WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl)); + WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl)); p.xSize = p.ySize = (sd) ? 5 : 0; p.state = vd->dead_sit; p.clevel = clif_setlevel(bl); @@ -965,7 +965,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; p.sex = vd->sex; - WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl)); + WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl)); p.xSize = p.ySize = (sd) ? 5 : 0; p.state = vd->dead_sit; p.clevel = clif_setlevel(bl); @@ -1034,7 +1034,7 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) { p.headDir = (sd)? sd->head_dir : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; p.sex = vd->sex; - WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl)); + WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl)); p.xSize = p.ySize = (sd) ? 5 : 0; clif->send(&p,sizeof(p),bl,target); @@ -1092,7 +1092,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; p.sex = vd->sex; - WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl)); + WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl)); p.xSize = p.ySize = (sd) ? 5 : 0; p.clevel = clif_setlevel(bl); #if PACKETVER >= 20080102 @@ -4328,7 +4328,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->option&OPTION_INVISIBLE)) return; - if ( ( ud = unit_bl2ud(bl) ) && ud->walktimer != INVALID_TIMER ) + if ( ( ud = unit->bl2ud(bl) ) && ud->walktimer != INVALID_TIMER ) clif->set_unit_walking(bl,sd,ud,SELF); else clif->set_unit_idle(bl,sd,SELF); @@ -4512,7 +4512,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic } if(src == dst) { - unit_setdir(src,unit_getdir(src)); + unit->setdir(src,unit->getdir(src)); } //Return adjusted can't walk delay for further processing. return clif->calc_walkdelay(dst,ddelay,type,damage+damage2,div); @@ -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); } /*========================================== @@ -9784,7 +9784,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) //Set last idle time... [Skotlex] sd->idletime = last_tick; - unit_walktoxy(&sd->bl, x, y, 4); + unit->walktoxy(&sd->bl, x, y, 4); } @@ -9945,7 +9945,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) pc->disguise(sd,sd->status.class_); if( pc_isdead(sd) ) clif_clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd); - if( unit_is_walking(&sd->bl) ) + if( unit->is_walking(&sd->bl) ) clif->move(&sd->ud); } else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) { const struct TimerData *timer; @@ -10045,7 +10045,7 @@ void clif_changed_dir(struct block_list *bl, enum send_target target) WBUFW(buf,0) = 0x9c; WBUFL(buf,2) = bl->id; WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0; - WBUFB(buf,8) = unit_getdir(bl); + WBUFB(buf,8) = unit->getdir(bl); clif->send(buf, packet_len(0x9c), bl, target); @@ -10169,7 +10169,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, pc->delinvincibletimer(sd); sd->idletime = last_tick; - unit_attack(&sd->bl, target_id, action_type != 0); + unit->attack(&sd->bl, target_id, action_type != 0); break; case 0x02: // sitdown if (battle_config.basic_skill_check && pc->checkskill(sd, NV_BASIC) < 3) { @@ -11248,7 +11248,7 @@ void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_dat if( skill_lv > lv ) skill_lv = lv; if( skill_lv ) - unit_skilluse_id(&hd->bl, target_id, skill_id, skill_lv); + unit->skilluse_id(&hd->bl, target_id, skill_id, skill_lv); } void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) @@ -11269,7 +11269,7 @@ void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_da if( skill_lv > lv ) skill_lv = lv; if( skill_lv ) - unit_skilluse_pos(&hd->bl, x, y, skill_id, skill_lv); + unit->skilluse_pos(&hd->bl, x, y, skill_id, skill_lv); } void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id) @@ -11291,7 +11291,7 @@ void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_ses if( skill_lv > lv ) skill_lv = lv; if( skill_lv ) - unit_skilluse_id(&md->bl, target_id, skill_id, skill_lv); + unit->skilluse_id(&md->bl, target_id, skill_id, skill_lv); } void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) @@ -11314,7 +11314,7 @@ void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_se if( skill_lv > lv ) skill_lv = lv; if( skill_lv ) - unit_skilluse_pos(&md->bl, x, y, skill_id, skill_lv); + unit->skilluse_pos(&md->bl, x, y, skill_id, skill_lv); } @@ -11398,7 +11398,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) skill_lv = sd->skillitemlv; if( !(tmp&INF_SELF_SKILL) ) pc->delinvincibletimer(sd); // Target skills thru items cancel invincibility. [Inkfish] - unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv); + unit->skilluse_id(&sd->bl, target_id, skill_id, skill_lv); return; } @@ -11418,7 +11418,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) pc->delinvincibletimer(sd); if( skill_lv ) - unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv); + unit->skilluse_id(&sd->bl, target_id, skill_id, skill_lv); } /*========================================== @@ -11490,14 +11490,14 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski if( sd->skillitem == skill_id ) { if( skill_lv != sd->skillitemlv ) skill_lv = sd->skillitemlv; - unit_skilluse_pos(&sd->bl, x, y, skill_id, skill_lv); + unit->skilluse_pos(&sd->bl, x, y, skill_id, skill_lv); } else { int lv; sd->skillitem = sd->skillitemlv = 0; if( (lv = pc->checkskill(sd, skill_id)) > 0 ) { if( skill_lv > lv ) skill_lv = lv; - unit_skilluse_pos(&sd->bl, x, y, skill_id,skill_lv); + unit->skilluse_pos(&sd->bl, x, y, skill_id,skill_lv); } } } @@ -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; @@ -14282,9 +14282,9 @@ void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) else return; - unit_calc_pos(bl, sd->bl.x, sd->bl.y, sd->ud.dir); - ud = unit_bl2ud(bl); - unit_walktoxy(bl, ud->to_x, ud->to_y, 4); + unit->calc_pos(bl, sd->bl.x, sd->bl.y, sd->ud.dir); + ud = unit->bl2ud(bl); + unit->walktoxy(bl, ud->to_x, ud->to_y, 4); } @@ -14305,7 +14305,7 @@ void clif_parse_HomMoveTo(int fd, struct map_session_data *sd) else return; - unit_walktoxy(bl, x, y, 4); + unit->walktoxy(bl, x, y, 4); } @@ -14326,8 +14326,8 @@ void clif_parse_HomAttack(int fd,struct map_session_data *sd) bl = &sd->md->bl; else return; - unit_stop_attack(bl); - unit_attack(bl, target_id, action_type != 0); + unit->stop_attack(bl); + unit->attack(bl, target_id, action_type != 0); } @@ -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/elemental.c b/src/map/elemental.c index 1952d93e2..1ef85b3e5 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -205,12 +205,12 @@ int elemental_delete(struct elemental_data *ed, int reply) { elemental->summon_stop(ed); if( !sd ) - return unit_free(&ed->bl, 0); + return unit->free(&ed->bl, 0); sd->ed = NULL; sd->status.ele_id = 0; - return unit_remove_map(&ed->bl, 0); + return unit->remove_map(&ed->bl, 0, ALC_MARK); } void elemental_summon_init(struct elemental_data *ed) { @@ -245,13 +245,13 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { iStatus->set_viewdata(&ed->bl, ed->elemental.class_); ed->vd->head_mid = 10; // Why? iStatus->change_init(&ed->bl); - unit_dataset(&ed->bl); + unit->dataset(&ed->bl); ed->ud.dir = sd->ud.dir; ed->bl.m = sd->bl.m; ed->bl.x = sd->bl.x; ed->bl.y = sd->bl.y; - unit_calc_pos(&ed->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + unit->calc_pos(&ed->bl, sd->bl.x, sd->bl.y, sd->ud.dir); ed->bl.x = ed->ud.to_x; ed->bl.y = ed->ud.to_y; @@ -421,7 +421,7 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned // Not in skill range. if( !battle->check_range(&ed->bl,bl,skill->get_range(skill_id,skill_lv)) ) { // Try to walk to the target. - if( !unit_walktobl(&ed->bl, bl, skill->get_range(skill_id,skill_lv), 2) ) + if( !unit->walktobl(&ed->bl, bl, skill->get_range(skill_id,skill_lv), 2) ) elemental->unlocktarget(ed); else { // Walking, waiting to be in range. Client don't handle it, then we must handle it here. @@ -453,9 +453,9 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned //Otherwise, just cast the skill. if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); + unit->skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); else - unit_skilluse_id(&ed->bl, bl->id, skill_id, skill_lv); + unit->skilluse_id(&ed->bl, bl->id, skill_id, skill_lv); // Reset target. ed->target_id = 0; @@ -497,9 +497,9 @@ int elemental_change_mode_ack(struct elemental_data *ed, int mode) { ed->last_thinktime = iTimer->gettick(); if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); + unit->skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); else - unit_skilluse_id(&ed->bl,bl->id,skill_id,skill_lv); + unit->skilluse_id(&ed->bl,bl->id,skill_id,skill_lv); ed->target_id = 0; // Reset target after casting the skill to avoid continious attack. @@ -692,7 +692,7 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ master_dist = distance_bl(&sd->bl, &ed->bl); if( master_dist > AREA_SIZE ) { // Master out of vision range. elemental->unlocktarget(ed); - unit_warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT); + unit->warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT); clif->elemental_updatestatus(sd,SP_HP); clif->elemental_updatestatus(sd,SP_SP); return 0; @@ -705,7 +705,7 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ if( DIFF_TICK(tick, ed->ud.canmove_tick) < 0 ) return 0; //Can't move yet. if( iMap->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1) - && unit_walktoxy(&ed->bl, x, y, 0) ) + && unit->walktoxy(&ed->bl, x, y, 0) ) return 0; } @@ -731,12 +731,12 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ return 1; if( battle->check_range(&ed->bl, target, ed->base_status.rhw.range) ) {//Target within range, engage - unit_attack(&ed->bl,target->id,1); + unit->attack(&ed->bl,target->id,1); return 1; } //Follow up if possible. - if( !unit_walktobl(&ed->bl, target, ed->base_status.rhw.range, 2) ) + if( !unit->walktobl(&ed->bl, target, ed->base_status.rhw.range, 2) ) elemental->unlocktarget(ed); } @@ -948,6 +948,7 @@ void do_final_elemental(void) { *-------------------------------------*/ void elemental_defaults(void) { elemental = &elemental_s; + /* funcs */ elemental->class = elemental_class; diff --git a/src/map/elemental.h b/src/map/elemental.h index 250cd3b72..ccc3bcb5f 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -46,16 +46,8 @@ struct elemental_data { int target_id, attacked_id; }; - - - - - - - -#define elemental_stop_walking(ed, type) unit_stop_walking(&(ed)->bl, type) -#define elemental_stop_attack(ed) unit_stop_attack(&(ed)->bl) - +#define elemental_stop_walking(ed, type) unit->stop_walking(&(ed)->bl, type) +#define elemental_stop_attack(ed) unit->stop_attack(&(ed)->bl) /*===================================== * Interface : elemental.h @@ -63,8 +55,10 @@ struct elemental_data { * created by Susu *-------------------------------------*/ struct elemental_interface { + /* vars */ struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database + /* funcs */ bool (*class) (int class_); struct view_data * (*get_viewdata) (int class_); diff --git a/src/map/guild.c b/src/map/guild.c index 601d88387..37335f9d0 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1883,7 +1883,7 @@ int guild_break(struct map_session_data *sd,char *name) { } /* regardless of char server allowing it, we clear the guild master's auras */ - if( (ud = unit_bl2ud(&sd->bl)) ) { + if( (ud = unit->bl2ud(&sd->bl)) ) { int count = 0; struct skill_unit_group *groups[4]; for (i=0;i<MAX_SKILLUNITGROUP && ud->skillunit[i];i++) { @@ -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/homunculus.c b/src/map/homunculus.c index 3a6ed074c..e0443f1f6 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -157,7 +157,7 @@ int homunculus_vaporize(struct map_session_data *sd, int flag) { memset(hd->blockskill, 0, sizeof(hd->blockskill)); clif->hominfo(sd, sd->hd, 0); homun->save(hd); - return unit_remove_map(&hd->bl, CLR_OUTSIGHT); + return unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); } //delete a homunculus, completely "killing it". @@ -168,7 +168,7 @@ int homunculus_delete(struct homun_data *hd, int emote) { sd = hd->master; if (!sd) - return unit_free(&hd->bl,CLR_DEAD); + return unit->free(&hd->bl,CLR_DEAD); if (emote >= 0) clif->emotion(&sd->bl, emote); @@ -178,7 +178,7 @@ int homunculus_delete(struct homun_data *hd, int emote) { // Send homunculus_dead to client hd->homunculus.hp = 0; clif->hominfo(sd, hd, 0); - return unit_remove_map(&hd->bl,CLR_OUTSIGHT); + return unit->remove_map(&hd->bl,CLR_OUTSIGHT, ALC_MARK); } int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) { @@ -403,7 +403,7 @@ bool homunculus_evolve(struct homun_data *hd) { hom->luk += 10*rnd_value(min->luk, max->luk); hom->intimacy = 500; - unit_remove_map(&hd->bl, CLR_OUTSIGHT); + unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); iMap->addblock(&hd->bl); clif->spawn(&hd->bl); @@ -447,7 +447,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) { return false; } - unit_remove_map(&hd->bl, CLR_OUTSIGHT); + unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); iMap->addblock(&hd->bl); clif->spawn(&hd->bl); @@ -745,14 +745,14 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { iStatus->set_viewdata(&hd->bl, hd->homunculus.class_); iStatus->change_init(&hd->bl); - unit_dataset(&hd->bl); + unit->dataset(&hd->bl); hd->ud.dir = sd->ud.dir; // Find a random valid pos around the player hd->bl.m = sd->bl.m; hd->bl.x = sd->bl.x; hd->bl.y = sd->bl.y; - unit_calc_pos(&hd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + unit->calc_pos(&hd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); hd->bl.x = hd->ud.to_x; hd->bl.y = hd->ud.to_y; @@ -801,7 +801,7 @@ bool homunculus_call(struct map_session_data *sd) { homun->save(hd); } else //Warp him to master. - unit_warp(&hd->bl,sd->bl.m, sd->bl.x, sd->bl.y,CLR_OUTSIGHT); + unit->warp(&hd->bl,sd->bl.m, sd->bl.x, sd->bl.y,CLR_OUTSIGHT); return true; } diff --git a/src/map/instance.c b/src/map/instance.c index 4e145fb8f..204b7c137 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -344,7 +344,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { npc_unload((struct npc_data *)bl,true); break; case BL_MOB: - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); break; case BL_PET: //There is no need for this, the pet is removed together with the player. [Skotlex] 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..64e765b27 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1307,7 +1307,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 if (iMap->getcell(m,*x,*y,CELL_CHKREACH)) { - if(flag&2 && !unit_can_reach_pos(src, *x, *y, 1)) + if(flag&2 && !unit->can_reach_pos(src, *x, *y, 1)) continue; if(flag&4) { if (spawn >= 100) return 0; //Limit of retries reached. @@ -1595,7 +1595,7 @@ int map_quit(struct map_session_data *sd) { if( sd->ed ) { elemental->clean_effect(sd->ed); - unit_remove_map(&sd->ed->bl,CLR_TELEPORT); + unit->remove_map(&sd->ed->bl,CLR_TELEPORT,ALC_MARK); } if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) { @@ -1604,7 +1604,7 @@ int map_quit(struct map_session_data *sd) { clif->chsys_quit(sd); - unit_remove_map_pc(sd,CLR_TELEPORT); + unit->remove_map_pc(sd,CLR_TELEPORT); if( map[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login int16 m; @@ -1630,7 +1630,7 @@ int map_quit(struct map_session_data *sd) { pc->makesavestatus(sd); pc->clean_skilltree(sd); chrif->save(sd,1); - unit_free_pc(sd); + unit->free_pc(sd); return 0; } @@ -2135,7 +2135,7 @@ int map_removemobs_sub(struct block_list *bl, va_list ap) if( md->db->mexp > 0 ) return 0; - unit_free(&md->bl,CLR_OUTSIGHT); + unit->free(&md->bl,CLR_OUTSIGHT); return 1; } @@ -2244,7 +2244,7 @@ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y) if( dx == 0 && dy == 0 ) { // both are standing on the same spot //dir = 6; // aegis-style, makes knockback default to the left - dir = unit_getdir(src); // athena-style, makes knockback default to behind 'src' + dir = unit->getdir(src); // athena-style, makes knockback default to behind 'src' } else if( dx >= 0 && dy >=0 ) { // upper-right @@ -4872,7 +4872,7 @@ int cleanup_sub(struct block_list *bl, va_list ap) { npc_unload((struct npc_data *)bl,false); break; case BL_MOB: - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); break; case BL_PET: //There is no need for this, the pet is removed together with the player. [Skotlex] @@ -4945,12 +4945,12 @@ 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(); iStatus->do_final_status(); - do_final_unit(); + unit->final(); do_final_battleground(); iDuel->do_final_duel(); elemental->do_final_elemental(); @@ -5168,7 +5168,8 @@ void map_hp_symbols(void) { HPM->share(elemental,"elemental"); HPM->share(intif,"intif"); HPM->share(mercenary,"mercenary"); - + HPM->share(mob,"mob"); + HPM->share(unit,"unit"); /* partial */ HPM->share(mapit,"mapit"); @@ -5214,6 +5215,8 @@ void map_load_defaults(void) { elemental_defaults(); intif_defaults(); mercenary_defaults(); + mob_defaults(); + unit_defaults(); } int do_init(int argc, char *argv[]) { @@ -5402,7 +5405,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(); @@ -5414,7 +5417,7 @@ int do_init(int argc, char *argv[]) elemental->do_init_elemental(); do_init_quest(); do_init_npc(); - do_init_unit(); + unit->init(); do_init_battleground(); iDuel->do_init_duel(); vending->init(); diff --git a/src/map/mercenary.c b/src/map/mercenary.c index bb30bb0d1..8bafcde97 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -247,7 +247,7 @@ int merc_delete(struct mercenary_data *md, int reply) mercenary->contract_stop(md); if( !sd ) - return unit_free(&md->bl, CLR_OUTSIGHT); + return unit->free(&md->bl, CLR_OUTSIGHT); if( md->devotion_flag ) { @@ -262,7 +262,7 @@ int merc_delete(struct mercenary_data *md, int reply) } clif->mercenary_message(sd, reply); - return unit_remove_map(&md->bl, CLR_OUTSIGHT); + return unit->remove_map(&md->bl, CLR_OUTSIGHT, ALC_MARK); } void merc_contract_stop(struct mercenary_data *md) @@ -309,13 +309,13 @@ int merc_data_received(struct s_mercenary *merc, bool flag) memcpy(&md->mercenary, merc, sizeof(struct s_mercenary)); iStatus->set_viewdata(&md->bl, md->mercenary.class_); iStatus->change_init(&md->bl); - unit_dataset(&md->bl); + unit->dataset(&md->bl); md->ud.dir = sd->ud.dir; md->bl.m = sd->bl.m; md->bl.x = sd->bl.x; md->bl.y = sd->bl.y; - unit_calc_pos(&md->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + unit->calc_pos(&md->bl, sd->bl.x, sd->bl.y, sd->ud.dir); md->bl.x = md->ud.to_x; md->bl.y = md->ud.to_y; diff --git a/src/map/mob.c b/src/map/mob.c index b16c57ef8..c566262df 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); @@ -293,7 +283,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { md->skill_idx = -1; iStatus->set_viewdata(&md->bl, md->class_); iStatus->change_init(&md->bl); - unit_dataset(&md->bl); + unit->dataset(&md->bl); iMap->addiddb(&md->bl); return md; @@ -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; @@ -607,7 +597,7 @@ static int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t d } else { if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS && md->guardian_data->castle->guardian[md->guardian_data->number].visible) guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0); - unit_free(&md->bl,CLR_OUTSIGHT); //Remove guardian. + unit->free(&md->bl,CLR_OUTSIGHT); //Remove guardian. } return 0; } @@ -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; @@ -793,7 +783,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range, int state easy = 1; break; } - return unit_can_reach_bl(&md->bl, bl, range, easy, NULL, NULL); + return unit->can_reach_bl(&md->bl, bl, range, easy, NULL, NULL); } /*========================================== @@ -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; } @@ -856,14 +846,14 @@ int mob_setdelayspawn(struct mob_data *md) struct mob_db *db; if (!md->spawn) //Doesn't has respawn data! - return unit_free(&md->bl,CLR_DEAD); + return unit->free(&md->bl,CLR_DEAD); spawntime = md->spawn->delay1; //Base respawn time if (md->spawn->delay2) //random variance 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; } @@ -910,13 +900,11 @@ int mob_spawn (struct mob_data *md) md->last_thinktime = tick; if (md->bl.prev != NULL) - unit_remove_map(&md->bl,CLR_RESPAWN); - else - if (md->spawn && md->class_ != md->spawn->class_) - { + unit->remove_map(&md->bl,CLR_RESPAWN,ALC_MARK); + else if (md->spawn && md->class_ != md->spawn->class_) { md->class_ = md->spawn->class_; iStatus->set_viewdata(&md->bl, md->class_); - md->db = mob_db(md->class_); + md->db = mob->db(md->class_); memcpy(md->name,md->spawn->name,NAME_LENGTH); } @@ -930,16 +918,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 +941,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 +972,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 +1023,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 +1041,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 +1103,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 +1129,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 +1146,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 +1156,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 +1166,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 +1197,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; @@ -1236,7 +1224,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) md->master_dist > MAX_MINCHASE ){ md->master_dist = 0; - unit_warp(&md->bl,bl->m,bl->x,bl->y,CLR_TELEPORT); + unit->warp(&md->bl,bl->m,bl->x,bl->y,CLR_TELEPORT); return 1; } @@ -1245,12 +1233,12 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) // Approach master if within view range, chase back to Master's area also if standing on top of the master. if((md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) && - unit_can_move(&md->bl)) + unit->can_move(&md->bl)) { short x = bl->x, y = bl->y; mob_stop_attack(md); if(iMap->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1) - && unit_walktoxy(&md->bl, x, y, 0)) + && unit->walktoxy(&md->bl, x, y, 0)) return 1; } } else if (bl->m != md->bl.m && map_flag_gvg(md->bl.m)) { @@ -1262,7 +1250,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) //Avoid attempting to lock the master's target too often to avoid unnecessary overload. [Skotlex] if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); md->last_linktime = tick; if (ud) { @@ -1306,12 +1294,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; @@ -1326,7 +1314,7 @@ int mob_unlocktarget(struct mob_data *md, unsigned int tick) if (md->target_id) { md->target_id=0; md->ud.target_to = 0; - unit_set_target(&md->ud, 0); + unit->set_target(&md->ud, 0); } return 0; } @@ -1342,7 +1330,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) nullpo_ret(md); if(DIFF_TICK(md->next_walktime,tick)>0 || - !unit_can_move(&md->bl) || + !unit->can_move(&md->bl) || !(status_get_mode(&md->bl)&MD_CANMOVE)) return 0; @@ -1355,7 +1343,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) x+=md->bl.x; y+=md->bl.y; - if((iMap->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit_walktoxy(&md->bl,x,y,1)){ + if((iMap->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){ break; } } @@ -1364,7 +1352,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,10 +1384,10 @@ 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)) + if (warp && unit->walktobl(&md->bl, &warp->bl, 1, 1)) return 1; return 0; } @@ -1407,7 +1395,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; @@ -1440,7 +1428,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) view_range = md->db->range2; mode = status_get_mode(&md->bl); - can_move = (mode&MD_CANMOVE)&&unit_can_move(&md->bl); + can_move = (mode&MD_CANMOVE)&&unit->can_move(&md->bl); if (md->target_id) { //Check validity of current target. [Skotlex] @@ -1453,9 +1441,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,18 +1458,18 @@ 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 - && can_move && unit_escape(&md->bl, tbl, rnd()%10 +1)) // Attempt escape + && !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; return true; } } 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,13 +1481,13 @@ 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 - && !tbl && unit_escape(&md->bl, abl, rnd()%10 +1)) + && !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? md->attacked_id = 0; @@ -1533,26 +1521,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,15 +1551,15 @@ 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) ) + 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. */ } } //This handles triggering idle walk/skill. - mob_unlocktarget(md, tick); + mob->unlocktarget(md, tick); return true; } @@ -1583,21 +1571,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... + if (!unit->walktobl(&md->bl, tbl, 1, 1)) + mob->unlocktarget(md, tick); //Can't loot... return true; } //Within looting range. @@ -1620,11 +1608,11 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) { //Give them walk act/delay to properly mimic players. [Skotlex] clif->takeitem(&md->bl,tbl); md->ud.canact_tick = tick + md->status.amotion; - unit_set_walkdelay(&md->bl, tick, md->status.amotion, 1); + unit->set_walkdelay(&md->bl, tick, md->status.amotion, 1); } //Clear item. iMap->clearflooritem (tbl); - mob_unlocktarget (md,tick); + mob->unlocktarget (md,tick); return true; } //Attempt to attack. @@ -1636,8 +1624,8 @@ 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) - unit_attack(&md->bl,tbl->id,1); + 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 +1633,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 +1642,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 +1654,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) || - !unit_walktobl(&md->bl, tbl, md->status.rhw.range, 2)) - mob_unlocktarget(md,tick); + 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); 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 +1677,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 +1689,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 +1701,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 +1712,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 +1722,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,24 +1732,24 @@ 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; } - if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit_can_move(&md->bl) ) + if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit->can_move(&md->bl) ) { 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 +1758,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 +1781,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 +1794,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 +1805,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 +1829,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; @@ -1886,7 +1874,7 @@ int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data) } //for Alchemist CANNIBALIZE [Lupus] md->deletetimer = INVALID_TIMER; - unit_free(bl, CLR_TELEPORT); + unit->free(bl, CLR_TELEPORT); } return 0; } @@ -1915,7 +1903,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 +2048,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 +2073,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 +2111,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 +2119,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 +2374,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 +2385,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 +2423,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 +2438,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 +2454,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 +2557,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 +2572,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 +2594,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 +2625,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 +2648,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); } @@ -2683,7 +2671,7 @@ int mob_guardian_guildchange(struct mob_data *md) } else { if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS && md->guardian_data->castle->guardian[md->guardian_data->number].visible) guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number, 0); - unit_free(&md->bl,CLR_OUTSIGHT); //Remove guardian. + unit->free(&md->bl,CLR_OUTSIGHT); //Remove guardian. } return 0; } @@ -2694,7 +2682,7 @@ int mob_guardian_guildchange(struct mob_data *md) ShowError("mob_guardian_guildchange: New Guild (id %d) does not exists!\n", md->guardian_data->guild_id); if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS) guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number, 0); - unit_free(&md->bl,CLR_OUTSIGHT); + unit->free(&md->bl,CLR_OUTSIGHT); return 0; } @@ -2716,16 +2704,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 +2739,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 +2747,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 @@ -2767,7 +2755,7 @@ int mob_class_change (struct mob_data *md, int class_) mob_stop_attack(md); mob_stop_walking(md, 0); - unit_skillcastcancel(&md->bl, 0); + unit->skillcastcancel(&md->bl, 0); iStatus->set_viewdata(&md->bl, class_); clif->class_change(&md->bl, md->vd->class_, 1); status_calc_mob(md, 1); @@ -2820,7 +2808,7 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap) return 0; iMap->search_freecell(master, 0, &x, &y, range, range, 0); - unit_warp(&md->bl, master->m, x, y,CLR_RESPAWN); + unit->warp(&md->bl, master->m, x, y,CLR_RESPAWN); return 1; } @@ -2834,7 +2822,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 +2845,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 +2868,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 +2889,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 +2906,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 +2952,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 +2991,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 +3001,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 +3058,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,20 +3137,20 @@ 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; + 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; + flag = (unit->counttargeted(&md->bl) >= c2); break; case MSC_AFTERSKILL: flag = (md->ud.skill_id == c2); break; case MSC_RUDEATTACKED: @@ -3170,9 +3158,9 @@ 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; + flag = (md->master_id > 0 && (fbl=iMap->id2bl(md->master_id)) && unit->counttargeted(fbl) > 0); break; case MSC_ALCHEMIST: flag = (md->state.alchemist); break; @@ -3224,7 +3212,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) md->skill_idx = i; iMap->freeblock_lock(); if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || - !unit_skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) + !unit->skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) { iMap->freeblock_unlock(); continue; @@ -3262,7 +3250,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) md->skill_idx = i; iMap->freeblock_lock(); if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || - !unit_skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) + !unit->skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) { iMap->freeblock_unlock(); continue; @@ -3270,7 +3258,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 +3294,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 +3317,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 +3341,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 +3507,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 +3520,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 +3534,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 +3551,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 +3616,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 +3643,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 +3791,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 +3855,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 +3878,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 +3915,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 +3956,7 @@ static int mob_read_sqldb(void) p+= len + 1; } - if (!mob_parse_dbrow(str)) + if (!mob->parse_dbrow(str)) continue; count++; @@ -3985,13 +3973,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 +3987,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 +4014,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 +4031,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 +4054,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 +4068,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 +4081,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 +4099,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 +4139,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 +4183,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 +4195,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 +4277,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 +4288,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 +4298,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 +4324,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 +4366,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 +4400,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 +4419,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 +4429,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 +4439,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 +4455,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 +4479,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 +4488,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 +4521,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 +4538,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 +4553,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 +4566,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 +4592,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 +4618,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 +4631,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 +4647,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 +4674,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 +4707,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..4ac8f7bcb 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,78 +242,124 @@ 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) + +#define mob_stop_walking(md, type) unit->stop_walking(&(md)->bl, type) +#define mob_stop_attack(md) unit->stop_attack(&(md)->bl) #define mob_is_battleground(md) ( map[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) #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..c4ef1bcf9 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -971,7 +971,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) if( npc_ontouch_event(sd,map[m].npc[i]) > 0 && npc_ontouch2_event(sd,map[m].npc[i]) > 0 ) { // failed to run OnTouch event, so just click the npc - struct unit_data *ud = unit_bl2ud(&sd->bl); + struct unit_data *ud = unit->bl2ud(&sd->bl); if( ud && ud->walkpath.path_pos < ud->walkpath.path_len ) { // Since walktimer always == INVALID_TIMER at this time, we stop walking manually. [Inkfish] clif->fixpos(&sd->bl); @@ -1021,7 +1021,7 @@ int npc_touch_areanpc2(struct mob_data *md) xs = iMap->mapindex2mapid(map[m].npc[i]->u.warp.mapindex); if( m < 0 ) break; // Cannot Warp between map servers - if( unit_warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) + if( unit->warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) return 1; // Warped break; case SCRIPT: @@ -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 ) { @@ -3796,7 +3796,7 @@ int npc_reload(void) { npc_unload((struct npc_data *)bl, false); break; case BL_MOB: - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); break; } } @@ -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..d502d9a3a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1082,7 +1082,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim //Set here because we need the inventory data for weapon sprite parsing. iStatus->set_viewdata(&sd->bl, sd->status.class_); - unit_dataset(&sd->bl); + unit->dataset(&sd->bl); sd->guild_x = -1; sd->guild_y = -1; @@ -4933,7 +4933,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y npc_event_dequeue(sd); npc_script_event(sd, NPCE_LOGOUT); //remove from map, THEN change x/y coordinates - unit_remove_map_pc(sd,clrtype); + unit->remove_map_pc(sd,clrtype); sd->mapindex = mapindex; sd->bl.x=x; sd->bl.y=y; @@ -4942,7 +4942,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y chrif->changemapserver(sd, ip, (short)port); //Free session data from this map server [Kevin] - unit_free_pc(sd); + unit->free_pc(sd); return 0; } @@ -4965,7 +4965,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } if(sd->bl.prev != NULL){ - unit_remove_map_pc(sd,clrtype); + unit->remove_map_pc(sd,clrtype); clif->changemap(sd,m,x,y); // [MouseJstr] } else if(sd->state.active) //Tag player for rewarping after map-loading is done. [Skotlex] @@ -5730,9 +5730,9 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) if (sd->bl.prev != NULL && tbl->prev != NULL && sd->ud.skilltimer == INVALID_TIMER && sd->ud.attacktimer == INVALID_TIMER && sd->ud.walktimer == INVALID_TIMER) { - if((sd->bl.m == tbl->m) && unit_can_reach_bl(&sd->bl,tbl, AREA_SIZE, 0, NULL, NULL)) { + if((sd->bl.m == tbl->m) && unit->can_reach_bl(&sd->bl,tbl, AREA_SIZE, 0, NULL, NULL)) { if (!check_distance_bl(&sd->bl, tbl, 5)) - unit_walktobl(&sd->bl, tbl, 5, 0); + unit->walktobl(&sd->bl, tbl, 5, 0); } else pc->setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT); } @@ -5753,7 +5753,7 @@ int pc_stop_following (struct map_session_data *sd) sd->followtarget = -1; sd->ud.target_to = 0; - unit_stop_walking(&sd->bl, 1); + unit->stop_walking(&sd->bl, 1); return 0; } @@ -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/pc.h b/src/map/pc.h index 231f369d8..c8e7e17d5 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -645,8 +645,8 @@ enum equip_pos { // Rune Knight Dragon #define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON ) -#define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type) -#define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl) +#define pc_stop_walking(sd, type) unit->stop_walking(&(sd)->bl, type) +#define pc_stop_attack(sd) unit->stop_attack(&(sd)->bl) //Weapon check considering dual wielding. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \ diff --git a/src/map/pet.c b/src/map/pet.c index ae8216fc2..d7f7c29c8 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); @@ -121,9 +121,9 @@ int pet_attackskill(struct pet_data *pd, int target_id) inf = skill->get_inf(pd->a_skill->id); if (inf & INF_GROUND_SKILL) - unit_skilluse_pos(&pd->bl, bl->x, bl->y, pd->a_skill->id, pd->a_skill->lv); + unit->skilluse_pos(&pd->bl, bl->x, bl->y, pd->a_skill->id, pd->a_skill->lv); else //Offensive self skill? Could be stuff like GX. - unit_skilluse_id(&pd->bl,(inf&INF_SELF_SKILL?pd->bl.id:bl->id), pd->a_skill->id, pd->a_skill->lv); + unit->skilluse_id(&pd->bl,(inf&INF_SELF_SKILL?pd->bl.id:bl->id), pd->a_skill->id, pd->a_skill->lv); return 1; //Skill invoked. } return 0; @@ -309,7 +309,7 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } pd->pet.incuvate = 1; - unit_free(&pd->bl,CLR_OUTSIGHT); + unit->free(&pd->bl,CLR_OUTSIGHT); status_calc_pc(sd,0); sd->status.pet_id = 0; @@ -353,16 +353,16 @@ 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); + unit->dataset(&pd->bl); pd->ud.dir = sd->ud.dir; pd->bl.m = sd->bl.m; pd->bl.x = sd->bl.x; pd->bl.y = sd->bl.y; - unit_calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + unit->calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); pd->bl.x = pd->ud.to_x; pd->bl.y = pd->ud.to_y; @@ -526,10 +526,10 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) if(rnd()%10000 < pet_catch_rate) { - unit_remove_map(&md->bl,CLR_OUTSIGHT); + unit->remove_map(&md->bl,CLR_OUTSIGHT,ALC_MARK); 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 @@ -793,7 +793,7 @@ static int pet_randomwalk(struct pet_data *pd,unsigned int tick) Assert((pd->msd == 0) || (pd->msd->pd == pd)); - if(DIFF_TICK(pd->next_walktime,tick) < 0 && unit_can_move(&pd->bl)) { + if(DIFF_TICK(pd->next_walktime,tick) < 0 && unit->can_move(&pd->bl)) { const int retrycount=20; int i,x,y,c,d=12-pd->move_fail_count; if(d<5) d=5; @@ -801,7 +801,7 @@ static int pet_randomwalk(struct pet_data *pd,unsigned int tick) int r=rnd(); x=pd->bl.x+r%(d*2+1)-d; y=pd->bl.y+r/(d*2+1)%(d*2+1)-d; - if(iMap->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit_walktoxy(&pd->bl,x,y,0)){ + if(iMap->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&pd->bl,x,y,0)){ pd->move_fail_count=0; break; } @@ -862,7 +862,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns pd->status.speed = (sd->battle_status.speed>>1); if(pd->status.speed <= 0) pd->status.speed = 1; - if (!unit_walktobl(&pd->bl, &sd->bl, 3, 0)) + if (!unit->walktobl(&pd->bl, &sd->bl, 3, 0)) pet_randomwalk(pd,tick); return 0; } @@ -899,8 +899,8 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns if(pd->ud.walktimer != INVALID_TIMER && check_distance_blxy(&sd->bl, pd->ud.to_x,pd->ud.to_y, 3)) return 0; //Already walking to him - unit_calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); - if(!unit_walktoxy(&pd->bl,pd->ud.to_x,pd->ud.to_y,0)) + unit->calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + if(!unit->walktoxy(&pd->bl,pd->ud.to_x,pd->ud.to_y,0)) pet_randomwalk(pd,tick); return 0; @@ -914,16 +914,16 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns { //enemy targetted if(!battle->check_range(&pd->bl,target,pd->status.rhw.range)) { //Chase - if(!unit_walktobl(&pd->bl, target, pd->status.rhw.range, 2)) + if(!unit->walktobl(&pd->bl, target, pd->status.rhw.range, 2)) pet_unlocktarget(pd); //Unreachable target. return 0; } //Continuous attack. - unit_attack(&pd->bl, pd->target_id, 1); + unit->attack(&pd->bl, pd->target_id, 1); } else { //Item Targeted, attempt loot if (!check_distance_bl(&pd->bl, target, 1)) { //Out of range - if(!unit_walktobl(&pd->bl, target, 1, 1)) //Unreachable target. + if(!unit->walktobl(&pd->bl, target, 1, 1)) //Unreachable target. pet_unlocktarget(pd); return 0; } else{ @@ -971,7 +971,7 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) if(sd_charid && sd_charid != pd->msd->status.char_id) return 0; - if(unit_can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) && + if(unit->can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) && ((*target) == NULL || //New target closer than previous one. !check_distance_bl(&pd->bl, *target, distance_bl(&pd->bl, bl)))) { @@ -1197,9 +1197,9 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) pet_stop_walking(pd,1); pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0); if (skill->get_inf(pd->s_skill->id) & INF_GROUND_SKILL) - unit_skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv); + unit->skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv); else - unit_skilluse_id(&pd->bl, sd->bl.id, pd->s_skill->id, pd->s_skill->lv); + unit->skilluse_id(&pd->bl, sd->bl.id, pd->s_skill->id, pd->s_skill->lv); return 0; } @@ -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/pet.h b/src/map/pet.h index b46f55229..4060b5382 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -126,8 +126,8 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data); // int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris] int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris] -#define pet_stop_walking(pd, type) unit_stop_walking(&(pd)->bl, type) -#define pet_stop_attack(pd) unit_stop_attack(&(pd)->bl) +#define pet_stop_walking(pd, type) unit->stop_walking(&(pd)->bl, type) +#define pet_stop_attack(pd) unit->stop_attack(&(pd)->bl) int read_petdb(void); int do_init_pet(void); diff --git a/src/map/script.c b/src/map/script.c index 9f165f1eb..70c9bd9f1 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 @@ -12635,7 +12635,7 @@ BUILDIN(npcspeed) { nd = (struct npc_data *)iMap->id2bl(st->oid); if( nd ) { - unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit + unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit nd->speed = speed; nd->ud->state.speed_changed = 1; } @@ -12651,13 +12651,13 @@ BUILDIN(npcwalkto) { y=script_getnum(st,3); if( nd ) { - unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit + unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit if (!nd->status.hp) { status_calc_npc(nd, true); } else { status_calc_npc(nd, false); } - unit_walktoxy(&nd->bl,x,y,0); + unit->walktoxy(&nd->bl,x,y,0); } return true; @@ -12667,8 +12667,8 @@ BUILDIN(npcstop) { struct npc_data *nd = (struct npc_data *)iMap->id2bl(st->oid); if( nd ) { - unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit - unit_stop_walking(&nd->bl,1|4); + unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit + unit->stop_walking(&nd->bl,1|4); } return true; @@ -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; @@ -14918,15 +14918,15 @@ BUILDIN(unitwalk) { } if( bl->type == BL_NPC ) { - unit_bl2ud2(bl); // ensure the ((TBL_NPC*)bl)->ud is safe to edit + unit->bl2ud2(bl); // ensure the ((TBL_NPC*)bl)->ud is safe to edit } if( script_hasdata(st,4) ) { int x = script_getnum(st,3); int y = script_getnum(st,4); - script_pushint(st, unit_walktoxy(bl,x,y,0));// We'll use harder calculations. + script_pushint(st, unit->walktoxy(bl,x,y,0));// We'll use harder calculations. } else { int map_id = script_getnum(st,3); - script_pushint(st, unit_walktobl(bl,iMap->id2bl(map_id),65025,1)); + script_pushint(st, unit->walktobl(bl,iMap->id2bl(map_id),65025,1)); } return true; @@ -14972,8 +14972,8 @@ BUILDIN(unitwarp) { map = iMap->mapname2mapid(mapname); if( map >= 0 && bl != NULL ) { - unit_bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit - script_pushint(st, unit_warp(bl,map,x,y,CLR_OUTSIGHT)); + unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit + script_pushint(st, unit->warp(bl,map,x,y,CLR_OUTSIGHT)); } else { script_pushint(st, 0); } @@ -15039,7 +15039,7 @@ BUILDIN(unitattack) script_pushint(st, 0); return false; } - script_pushint(st, unit_walktobl(unit_bl, target_bl, 65025, 2)); + script_pushint(st, unit->walktobl(unit_bl, target_bl, 65025, 2)); return true; } @@ -15055,9 +15055,9 @@ BUILDIN(unitstop) { bl = iMap->id2bl(unit_id); if( bl != NULL ) { - unit_bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit - unit_stop_attack(bl); - unit_stop_walking(bl,4); + unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit + unit->stop_attack(bl); + unit->stop_walking(bl,4); if( bl->type == BL_MOB ) ((TBL_MOB*)bl)->target_id = 0; } @@ -15139,7 +15139,7 @@ BUILDIN(unitskilluseid) status_calc_npc(((TBL_NPC*)bl), false); } } - unit_skilluse_id(bl, target_id, skill_id, skill_lv); + unit->skilluse_id(bl, target_id, skill_id, skill_lv); } return true; @@ -15174,7 +15174,7 @@ BUILDIN(unitskillusepos) status_calc_npc(((TBL_NPC*)bl), false); } } - unit_skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv); + unit->skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv); } 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; } @@ -16373,12 +16373,12 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap) return 0; if( md->ud.skilltimer != INVALID_TIMER ) // Cancel the casting skill. - unit_skillcastcancel(bl,0); + unit->skillcastcancel(bl,0); if( skill->get_casttype(skill_id) == CAST_GROUND ) - unit_skilluse_pos2(&md->bl, tbl->x, tbl->y, skill_id, skill_lv, casttime, cancel); + unit->skilluse_pos2(&md->bl, tbl->x, tbl->y, skill_id, skill_lv, casttime, cancel); else - unit_skilluse_id2(&md->bl, tbl->id, skill_id, skill_lv, casttime, cancel); + unit->skilluse_id2(&md->bl, tbl->id, skill_id, skill_lv, casttime, cancel); clif->emotion(&md->bl, emotion); @@ -16475,7 +16475,7 @@ BUILDIN(pushpc) dx = dirx[dir]; dy = diry[dir]; - unit_blown(&sd->bl, dx, dy, cells, 0); + unit->blown(&sd->bl, dx, dy, cells, 0); return true; } @@ -17140,9 +17140,9 @@ BUILDIN(npcskill) } if (skill->get_inf(skill_id)&INF_GROUND_SKILL) { - unit_skilluse_pos(&nd->bl, sd->bl.x, sd->bl.y, skill_id, skill_level); + unit->skilluse_pos(&nd->bl, sd->bl.x, sd->bl.y, skill_id, skill_level); } else { - unit_skilluse_id(&nd->bl, sd->bl.id, skill_id, skill_level); + unit->skilluse_id(&nd->bl, sd->bl.id, skill_id, skill_level); } return true; diff --git a/src/map/skill.c b/src/map/skill.c index d9df0b869..08da07137 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -863,7 +863,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint break; case WZ_FIREPILLAR: - unit_set_walkdelay(bl, tick, skill->get_time2(skill_id, skill_lv), 1); + unit->set_walkdelay(bl, tick, skill->get_time2(skill_id, skill_lv), 1); break; case MG_FROSTDIVER: @@ -1447,7 +1447,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint } if( sd && sd->ed && sc && !iStatus->isdead(bl) && !skill_id ){ - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); if( sc->data[SC_WILD_STORM_OPTION] ) temp = sc->data[SC_WILD_STORM_OPTION]->val2; @@ -1559,7 +1559,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint } sd->state.autocast = 0; //Set canact delay. [Skotlex] - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); if (ud) { rate = skill->delay_fix(src, temp, skill_lv); if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){ @@ -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; @@ -1900,7 +1900,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * } dstsd->state.autocast = 0; //Set canact delay. [Skotlex] - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (ud) { rate = skill->delay_fix(bl, skill_id, skill_lv); if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){ @@ -2103,7 +2103,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in dy = -diry[dir]; } - return unit_blown(target, dx, dy, count, flag); // send over the proper flag + return unit->blown(target, dx, dy, count, flag); // send over the proper flag } @@ -2338,7 +2338,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds sce->timer = iTimer->add_timer(tick+sce->val4, iStatus->change_timer, src->id, SC_COMBOATTACK); break; } - unit_cancel_combo(src); // Cancel combo wait + unit->cancel_combo(src); // Cancel combo wait break; default: if( src == dsrc ) // Ground skills are exceptions. [Inkfish] @@ -2617,7 +2617,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if (dmg.dmg_lv >= ATK_MISS && (type = skill->get_walkdelay(skill_id, skill_lv)) > 0) { //Skills with can't walk delay also stop normal attacking for that //duration when the attack connects. [Skotlex] - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); if (ud && DIFF_TICK(ud->attackabletime, tick + type) < 0) ud->attackabletime = tick + type; } @@ -2650,7 +2650,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds case SR_KNUCKLEARROW: case GN_WALLOFTHORN: case EL_FIRE_MANTLE: - dir = unit_getdir(bl);// backwards + dir = unit->getdir(bl);// backwards break; // This ensures the storm randomly pushes instead of exactly a cell backwards per official mechanics. case WZ_STORMGUST: @@ -2688,7 +2688,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds } break; case GN_WALLOFTHORN: - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); skill->blown(dsrc,bl,dmg.blewcount,dir, 0x2 ); clif->fixpos(bl); break; @@ -3037,7 +3037,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, if( !type ) switch( state ) { case ST_MOVE_ENABLE: - if( !unit_can_move(bl) ) { + if( !unit->can_move(bl) ) { clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); return 0; } @@ -3086,7 +3086,7 @@ int skill_area_sub_count (struct block_list *src, struct block_list *target, uin *------------------------------------------*/ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *src = iMap->id2bl(id),*target; - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); struct skill_timerskill *skl; int range; @@ -3116,11 +3116,11 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { switch(skl->skill_id) { case RG_INTIMIDATE: - if (unit_warp(src,-1,-1,-1,CLR_TELEPORT) == 0) { + if (unit->warp(src,-1,-1,-1,CLR_TELEPORT) == 0) { short x,y; iMap->search_freecell(src, 0, &x, &y, 1, 1, 0); if (target != src && !iStatus->isdead(target)) - unit_warp(target, -1, x, y, CLR_TELEPORT); + unit->warp(target, -1, x, y, CLR_TELEPORT); } break; case BA_FROSTJOKER: @@ -3193,11 +3193,11 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { break; case SC_FATALMENACE: if( src == target ) // Casters Part - unit_warp(src, -1, skl->x, skl->y, 3); + unit->warp(src, -1, skl->x, skl->y, 3); else { // Target's Part short x = skl->x, y = skl->y; iMap->search_freecell(NULL, target->m, &x, &y, 2, 2, 1); - unit_warp(target,-1,x,y,3); + unit->warp(target,-1,x,y,3); } break; case LG_MOONSLASHER: @@ -3241,7 +3241,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { case SC_ESCAPE: if( skl->type < 4+skl->skill_lv ){ clif->skill_damage(src,src,tick,0,0,-30000,1,skl->skill_id,skl->skill_lv,5); - skill->blown(src,src,1,unit_getdir(src),0); + skill->blown(src,src,1,unit->getdir(src),0); skill->addtimerskill(src,tick+80,src->id,0,0,skl->skill_id,skl->skill_lv,skl->type+1,0); } break; @@ -3300,7 +3300,7 @@ int skill_addtimerskill (struct block_list *src, unsigned int tick, int target, nullpo_retr(1, src); if (src->prev == NULL) return 0; - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); nullpo_retr(1, ud); ARR_FIND( 0, MAX_SKILLTIMERSKILL, i, ud->skilltimerskill[i] == 0 ); @@ -3328,7 +3328,7 @@ int skill_cleartimerskill (struct block_list *src) int i; struct unit_data *ud; nullpo_ret(src); - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); nullpo_ret(ud); for(i=0;i<MAX_SKILLTIMERSKILL;i++) { @@ -3579,7 +3579,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint uint8 dir = iMap->calc_dir(bl, src->x, src->y); // teleport to target (if not on WoE grounds) - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 0, 1) ) + if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) clif->slide(src, bl->x, bl->y); // cause damage and knockback if the path to target was a straight one @@ -3588,7 +3588,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->blown(src, bl, dist, dir, 0); //HACK: since knockback officially defaults to the left, the client also turns to the left... therefore, // make the caster look in the direction of the target - unit_setdir(src, (dir+4)%8); + unit->setdir(src, (dir+4)%8); } } @@ -3626,12 +3626,12 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case RG_BACKSTAP: { - uint8 dir = iMap->calc_dir(src, bl->x, bl->y), t_dir = unit_getdir(bl); + uint8 dir = iMap->calc_dir(src, bl->x, bl->y), t_dir = unit->getdir(bl); if ((!check_distance_bl(src, bl, 0) && !iMap->check_dir(dir, t_dir)) || bl->type == BL_SKILL) { status_change_end(src, SC_HIDING, INVALID_TIMER); skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag); dir = dir < 4 ? dir+4 : dir-4; // change direction [Celest] - unit_setdir(bl,dir); + unit->setdir(bl,dir); } else if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -3691,7 +3691,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint else if( dir == 7 || dir < 2 ) y = i; else y = 0; if( (mbl == src || (!map_flag_gvg2(src->m) && !map[src->m].flag.battleground) ) && // only NJ_ISSEN don't have slide effect in GVG - unit_movepos(src, mbl->x+x, mbl->y+y, 1, 1) ) { + unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1) ) { clif->slide(src, src->x, src->y); clif->fixpos(src); clif->spiritball(src); @@ -3830,7 +3830,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint c = skill->get_blewcount(skill_id,skill_lv); // keep moving target in the direction that src is looking, square by square for(i=0;i<c;i++){ - if (!skill->blown(src,bl,1,(unit_getdir(src)+4)%8,0x1)) + if (!skill->blown(src,bl,1,(unit->getdir(src)+4)%8,0x1)) break; //Can't knockback skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count); if( skill_area_temp[0] > 1 ) break; // collision @@ -4073,17 +4073,17 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint { //You don't move on GVG grounds. short x, y; iMap->search_freecell(bl, 0, &x, &y, 1, 1, 0); - if (unit_movepos(src, x, y, 0, 0)) + if (unit->movepos(src, x, y, 0, 0)) clif->slide(src,src->x,src->y); } status_change_end(src, SC_HIDING, INVALID_TIMER); skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; case RK_PHANTOMTHRUST: - unit_setdir(src,iMap->calc_dir(src, bl->x, bl->y)); + unit->setdir(src,iMap->calc_dir(src, bl->x, bl->y)); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - skill->blown(src,bl,distance_bl(src,bl)-1,unit_getdir(src),0); + skill->blown(src,bl,distance_bl(src,bl)-1,unit->getdir(src),0); if( battle->check_target(src,bl,BCT_ENEMY) > 0 ) skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4100,7 +4100,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint else if( dir == 7 || dir < 2 ) y = -2; else y = 0; - if( unit_movepos(src, bl->x+x, bl->y+y, 1, 1) ) + if( unit->movepos(src, bl->x+x, bl->y+y, 1, 1) ) { clif->slide(src,bl->x+x,bl->y+y); clif->fixpos(src); // the official server send these two packts. @@ -4270,7 +4270,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint short y[8]={1,1,0,-1,-1,-1,0,1}; uint8 dir = iMap->calc_dir(bl, src->x, src->y); - if( unit_movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) ) + if( unit->movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) ) { clif->slide(src, bl->x+x[dir], bl->y+y[dir]); clif->fixpos(src); @@ -4350,7 +4350,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint } break; case LG_PINPOINTATTACK: - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 1, 1) ) + if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) clif->slide(src,bl->x,bl->y); skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4375,7 +4375,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; case SR_KNUCKLEARROW: - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 1, 1) ) { + if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) { clif->slide(src,bl->x,bl->y); clif->fixpos(src); // Aegis send this packet too. } @@ -4523,7 +4523,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag); break; case MH_TINDER_BREAKER: - if (unit_movepos(src, bl->x, bl->y, 1, 1)) { + if (unit->movepos(src, bl->x, bl->y, 1, 1)) { #if PACKETVER >= 20111005 clif->snap(src, bl->x, bl->y); #else @@ -4600,7 +4600,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) return 0;// not found } - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); if( ud == NULL ) { ShowDebug("skill_castend_id: ud == NULL (tid=%d, id=%d)\n", tid, id); @@ -4615,7 +4615,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) return 0; } - if(ud->skill_id != SA_CASTCANCEL && ud->skill_id != SO_SPELLFIST) {// otherwise handled in unit_skillcastcancel() + if(ud->skill_id != SA_CASTCANCEL && ud->skill_id != SO_SPELLFIST) {// otherwise handled in unit->skillcastcancel() if( ud->skilltimer != tid ) { ShowError("skill_castend_id: Timer mismatch %d!=%d!\n", ud->skilltimer, tid); ud->skilltimer = INVALID_TIMER; @@ -4668,7 +4668,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } if(ud->skill_id == RG_BACKSTAP) { - uint8 dir = iMap->calc_dir(src,target->x,target->y),t_dir = unit_getdir(target); + uint8 dir = iMap->calc_dir(src,target->x,target->y),t_dir = unit->getdir(target); if(check_distance_bl(src, target, 0) || iMap->check_dir(dir,t_dir)) { break; } @@ -4782,7 +4782,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } if (ud->walktimer != INVALID_TIMER && ud->skill_id != TK_RUN && ud->skill_id != RA_WUGDASH) - unit_stop_walking(src,1); + unit->stop_walking(src,1); if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) ) ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); //Tests show wings don't overwrite the delay but skill scrolls do. [Inkfish] @@ -4819,7 +4819,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } } if (skill->get_state(ud->skill_id) != ST_MOVE_ENABLE) - unit_set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); + unit->set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); if(battle_config.skill_log && battle_config.skill_log&src->type) ShowInfo("Type %d, ID %d skill castend id [id =%d, lv=%d, target ID %d]\n", @@ -4886,7 +4886,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) if( dir > 2 && dir < 6 ) y = -2; else if( dir == 7 || dir < 2 ) y = 2; else y = 0; - if (unit_movepos(src, src->x+x, src->y+y, 1, 1)) + if (unit->movepos(src, src->x+x, src->y+y, 1, 1)) { //Display movement + animation. clif->slide(src,src->x,src->y); clif->spiritball(src); @@ -5217,14 +5217,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } else {// mob-casted - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); int inf = skill->get_inf(abra_skill_id); if (!ud) break; if (inf&INF_SELF_SKILL || inf&INF_SUPPORT_SKILL) { if (src->type == BL_PET) bl = (struct block_list*)((TBL_PET*)src)->msd; if (!bl) bl = src; - unit_skilluse_id(src, bl->id, abra_skill_id, abra_skill_lv); + unit->skilluse_id(src, bl->id, abra_skill_id, abra_skill_lv); } else { //Assume offensive skills int target_id = 0; if (ud->target) @@ -5238,9 +5238,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (skill->get_casttype(abra_skill_id) == CAST_GROUND) { bl = iMap->id2bl(target_id); if (!bl) bl = src; - unit_skilluse_pos(src, bl->x, bl->y, abra_skill_id, abra_skill_lv); + unit->skilluse_pos(src, bl->x, bl->y, abra_skill_id, abra_skill_lv); } else - unit_skilluse_id(src, target_id, abra_skill_id, abra_skill_lv); + unit->skilluse_id(src, target_id, abra_skill_id, abra_skill_lv); } } } @@ -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 }; @@ -5474,10 +5474,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case TK_JUMPKICK: - /* Check if the target is an enemy; if not, skill should fail so the character doesn't unit_movepos (exploitable) */ + /* Check if the target is an enemy; if not, skill should fail so the character doesn't unit->movepos (exploitable) */ if( battle->check_target(src, bl, BCT_ENEMY) > 0 ) { - if( unit_movepos(src, bl->x, bl->y, 1, 1) ) + if( unit->movepos(src, bl->x, bl->y, 1, 1) ) { skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); clif->slide(src,bl->x,bl->y); @@ -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; @@ -5726,7 +5726,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui iMap->freeblock_unlock(); return 0; } - unit_skillcastcancel(bl, 2); + unit->skillcastcancel(bl, 2); if( tsc && tsc->count ) { @@ -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); @@ -6069,7 +6069,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui iMap->freeblock_unlock(); return 0; } - clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit_getdir(bl),0,0,0)); + clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit->getdir(bl),0,0,0)); if (sd) // If the client receives a skill-use packet inmediately before a walkok packet, it will discard the walk packet! [Skotlex] clif->walkok(sd); // So aegis has to resend the walk ok. break; @@ -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 @@ -6364,12 +6364,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui else clif->skill_warppoint(sd,skill_id,skill_lv, (unsigned short)-1,sd->status.save_point.map,0,0); } else - unit_warp(bl,-1,-1,-1,CLR_TELEPORT); + unit->warp(bl,-1,-1,-1,CLR_TELEPORT); break; case NPC_EXPULSION: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - unit_warp(bl,-1,-1,-1,CLR_TELEPORT); + unit->warp(bl,-1,-1,-1,CLR_TELEPORT); break; case AL_HOLYWATER: @@ -6704,12 +6704,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case TF_BACKSLIDING: //This is the correct implementation as per packet logging information. [Skotlex] 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); + skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit->getdir(bl),0); break; case TK_HIGHJUMP: { - int x,y, dir = unit_getdir(src); + int x,y, dir = unit->getdir(src); //Fails on noteleport maps, except for GvG and BG maps [Skotlex] if( map[src->m].flag.noteleport && @@ -6725,7 +6725,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(src,bl,TK_HIGHJUMP,skill_lv,1); if(!iMap->count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB) && iMap->getcell(src->m,x,y,CELL_CHKREACH)) { clif->slide(src,x,y); - unit_movepos(src, x, y, 1, 0); + unit->movepos(src, x, y, 1, 0); } } break; @@ -6733,7 +6733,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SA_CASTCANCEL: case SO_SPELLFIST: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - unit_skillcastcancel(src,1); + unit->skillcastcancel(src,1); if(sd) { int sp = skill->get_sp(sd->skill_id_old,sd->skill_lv_old); if( skill_id == SO_SPELLFIST ){ @@ -6756,7 +6756,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui iStatus->heal(bl,0,sp,2); status_percent_damage(bl, src, 0, -20, false); //20% max SP damage. } else { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); int bl_skill_id=0,bl_skill_lv=0,hp = 0; if (!ud || ud->skilltimer == INVALID_TIMER) break; //Nothing to cancel. @@ -6773,7 +6773,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui hp = tstatus->max_hp/50; //Recover 2% HP [Skotlex] clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - unit_skillcastcancel(bl,0); + unit->skillcastcancel(bl,0); sp = skill->get_sp(bl_skill_id,bl_skill_lv); status_zap(bl, hp, sp); @@ -6872,14 +6872,14 @@ 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: case NPC_BARRIER: { int skill_time = skill->get_time(skill_id,skill_lv); - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(bl,type,100,skill_lv,skill_time)) && ud) { //Disable attacking/acting/moving for skill's duration. @@ -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,17 +6948,17 @@ 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; case NPC_RUN: { const int mask[8][2] = {{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1}}; - uint8 dir = (bl == src)?unit_getdir(src):iMap->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away. - unit_stop_attack(src); + uint8 dir = (bl == src)?unit->getdir(src):iMap->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away. + unit->stop_attack(src); //Run skillv tiles overriding the can-move check. - if (unit_walktoxy(src, src->x + skill_lv * mask[dir][0], src->y + skill_lv * mask[dir][1], 2) && md) + if (unit->walktoxy(src, src->x + skill_lv * mask[dir][0], src->y + skill_lv * mask[dir][1], 2) && md) md->state.skillstate = MSS_WALK; //Otherwise it isn't updated in the ai. } 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, @@ -7152,7 +7152,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case BD_ENCORE: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); if(sd) - unit_skilluse_id(src,src->id,sd->skill_id_dance,sd->skill_lv_dance); + unit->skilluse_id(src,src->id,sd->skill_id_dance,sd->skill_lv_dance); break; case AS_SPLASHER: @@ -7198,7 +7198,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui return 0; } - unit_skillcastcancel(bl,0); + unit->skillcastcancel(bl,0); if(tsc && tsc->count){ status_change_end(bl, SC_FREEZE, INVALID_TIMER); @@ -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; @@ -7361,7 +7361,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case 5: // 2000HP heal, random teleported iStatus->heal(src, 2000, 0, 0); if( !map_flag_vs(bl->m) ) - unit_warp(bl, -1,-1,-1, CLR_TELEPORT); + unit->warp(bl, -1,-1,-1, CLR_TELEPORT); break; case 6: // random 2 other effects if (count == -1) @@ -7605,10 +7605,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (hd) skill->blockhomun_start(hd, skill_id, skill->get_time2(skill_id,skill_lv)); - if (unit_movepos(src,bl->x,bl->y,0,0)) { + if (unit->movepos(src,bl->x,bl->y,0,0)) { clif->skill_nodamage(src,src,skill_id,skill_lv,1); // Homunc clif->slide(src,bl->x,bl->y) ; - if (unit_movepos(bl,x,y,0,0)) + if (unit->movepos(bl,x,y,0,0)) { clif->skill_nodamage(bl,bl,skill_id,skill_lv,1); // Master clif->slide(bl,x,y) ; @@ -8233,7 +8233,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui return 0; } if( sd && pc_isridingwug(sd) ) { - clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit_getdir(bl),0,0,1)); + clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit->getdir(bl),0,0,1)); clif->walkok(sd); } break; @@ -8249,7 +8249,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NC_F_SIDESLIDE: case NC_B_SIDESLIDE: { - uint8 dir = (skill_id == NC_F_SIDESLIDE) ? (unit_getdir(src)+4)%8 : unit_getdir(src); + uint8 dir = (skill_id == NC_F_SIDESLIDE) ? (unit->getdir(src)+4)%8 : unit->getdir(src); skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),dir,0); clif->slide(src,src->x,src->y); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -8560,8 +8560,8 @@ 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()); - unit_stop_attack(bl); + mob->unlocktarget((TBL_MOB*)bl,iTimer->gettick()); + unit->stop_attack(bl); clif->bladestop(src, bl->id, 1); iMap->freeblock_unlock(); return 1; @@ -8796,14 +8796,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sd->skillitemlv = improv_skill_lv; clif->item_skill(sd, improv_skill_id, improv_skill_lv); } else { - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); int inf = skill->get_inf(improv_skill_id); if (!ud) break; if (inf&INF_SELF_SKILL || inf&INF_SUPPORT_SKILL) { if (src->type == BL_PET) bl = (struct block_list*)((TBL_PET*)src)->msd; if (!bl) bl = src; - unit_skilluse_id(src, bl->id, improv_skill_id, improv_skill_lv); + unit->skilluse_id(src, bl->id, improv_skill_id, improv_skill_lv); } else { int target_id = 0; if (ud->target) @@ -8817,9 +8817,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (skill->get_casttype(improv_skill_id) == CAST_GROUND) { bl = iMap->id2bl(target_id); if (!bl) bl = src; - unit_skilluse_pos(src, bl->x, bl->y, improv_skill_id, improv_skill_lv); + unit->skilluse_pos(src, bl->x, bl->y, improv_skill_id, improv_skill_lv); } else - unit_skilluse_id(src, target_id, improv_skill_id, improv_skill_lv); + unit->skilluse_id(src, target_id, improv_skill_id, improv_skill_lv); } } } @@ -9147,18 +9147,18 @@ 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); + skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit->getdir(bl),0); } } break; @@ -9198,11 +9198,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } - if (unit_movepos(src, bl->x, bl->y, 0, 0)) { + if (unit->movepos(src, bl->x, bl->y, 0, 0)) { clif->skill_nodamage(src, src, skill_id, skill_lv, 1); clif->slide(src, bl->x, bl->y) ; sc_start(src, SC_CONFUSION, 25, skill_lv, skill->get_time(skill_id, skill_lv)); - if ( !is_boss(bl) && unit_stop_walking(&sd->bl, 1) && unit_movepos(bl, x, y, 0, 0) ) + if ( !is_boss(bl) && unit->stop_walking(&sd->bl, 1) && unit->movepos(bl, x, y, 0, 0) ) { if( dstsd && pc_issit(dstsd) ) pc->setstand(dstsd); @@ -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 @@ -9389,7 +9389,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) struct block_list* src = iMap->id2bl(id); int maxcount; struct map_session_data *sd; - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); struct mob_data *md; nullpo_ret(ud); @@ -9485,7 +9485,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) src->type, src->id, ud->skill_id, ud->skill_lv, ud->skillx, ud->skilly); if (ud->walktimer != INVALID_TIMER) - unit_stop_walking(src,1); + unit->stop_walking(src,1); if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) ) ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); @@ -9511,7 +9511,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) // break; // } // } - unit_set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); + unit->set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);// only normal attack and auto cast skills benefit from its bonuses iMap->freeblock_lock(); skill->castend_pos2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv,tick,0); @@ -9969,7 +9969,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui return 0; // not to consume item. case MO_BODYRELOCATION: - if (unit_movepos(src, x, y, 1, 1)) { + if (unit->movepos(src, x, y, 1, 1)) { #if PACKETVER >= 20111005 clif->snap(src, src->x, src->y); #else @@ -9981,7 +9981,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui break; case NJ_SHADOWJUMP: if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground ) { //You don't move on GVG grounds. - unit_movepos(src, x, y, 1, 0); + unit->movepos(src, x, y, 1, 0); clif->slide(src,x,y); } status_change_end(src, SC_HIDING, INVALID_TIMER); @@ -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; @@ -10248,7 +10248,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case SC_FEINTBOMB: skill->unitsetting(src,skill_id,skill_lv,x,y,0); // Set bomb on current Position clif->skill_nodamage(src,src,skill_id,skill_lv,1); - if( skill->blown(src,src,6,unit_getdir(src),0) ) + if( skill->blown(src,src,6,unit->getdir(src),0) ) skill->castend_nodamage_id(src,src,TF_HIDING,1,tick,0x2); break; @@ -10312,7 +10312,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui break; case GN_FIRE_EXPANSION: { int i; - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); if( !ud ) 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); } @@ -11093,7 +11093,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned } else if(bl->type == BL_MOB && battle_config.mob_warp&2) { int16 m = iMap->mapindex2mapid(sg->val3); if (m < 0) break; //Map not available on this map-server. - unit_warp(bl,m,sg->val2>>16,sg->val2&0xffff,CLR_TELEPORT); + unit->warp(bl,m,sg->val2>>16,sg->val2&0xffff,CLR_TELEPORT); } } break; @@ -11182,7 +11182,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned break; if (ss == bl) //Also needed to prevent infinite loop crash. break; - skill->blown(ss,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit_getdir(bl),0); + skill->blown(ss,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit->getdir(bl),0); break; case UNT_WALLOFTHORN: @@ -11399,7 +11399,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_SKIDTRAP: { - skill->blown(&src->bl,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit_getdir(bl),0); + skill->blown(&src->bl,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit->getdir(bl),0); sg->unit_id = UNT_USED_TRAPS; clif->changetraplook(&src->bl, UNT_USED_TRAPS); sg->limit=DIFF_TICK(tick,sg->tick)+1500; @@ -11415,7 +11415,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( td ) sec = DIFF_TICK(td->tick, tick); if( sg->unit_id == UNT_MANHOLE || battle_config.skill_trap_type || !map_flag_gvg2(src->bl.m) ) { - unit_movepos(bl, src->bl.x, src->bl.y, 0, 0); + unit->movepos(bl, src->bl.x, src->bl.y, 0, 0); clif->fixpos(bl); } sg->val2 = bl->id; @@ -11644,7 +11644,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns int i = battle->check_target(&src->bl, bl, BCT_ENEMY); if( i > 0 && !(status_get_mode(bl)&MD_BOSS) ) { // knock-back any enemy except Boss - skill->blown(&src->bl, bl, 2, unit_getdir(bl), 0); + skill->blown(&src->bl, bl, 2, unit->getdir(bl), 0); clif->fixpos(bl); } @@ -11720,7 +11720,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( tsd && !map[bl->m].flag.noteleport ) pc->randomwarp(tsd,3); else if( bl->type == BL_MOB && battle_config.mob_warp&8 ) - unit_warp(bl,-1,-1,-1,3); + unit->warp(bl,-1,-1,-1,3); break; case UNT_REVERBERATION: @@ -11851,21 +11851,21 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns distance_xy(src->bl.x, src->bl.y, bl->x, bl->y) <= range)// don't consider outer bounderies sc_start(bl, type, 100, sg->skill_lv, sec); - if( unit_is_walking(bl) && // wait until target stop walking + if( unit->is_walking(bl) && // wait until target stop walking ( tsc && tsc->data[type] && tsc->data[type]->val4 >= tsc->data[type]->val3-range )) break; if( tsc && ( !tsc->data[type] || (tsc->data[type] && tsc->data[type]->val4 < 1 ) ) ) break; - if( unit_is_walking(bl) && + if( unit->is_walking(bl) && distance_xy(src->bl.x, src->bl.y, bl->x, bl->y) > range )// going outside of boundaries? then force it to stop - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); - if( !unit_is_walking(bl) && + if( !unit->is_walking(bl) && distance_xy(src->bl.x, src->bl.y, bl->x, bl->y) <= range && // only snap if the target is inside the range or src->bl.x != bl->x && src->bl.y != bl->y){// diagonal position parallel to VE's center - unit_movepos(bl, src->bl.x, src->bl.y, 0, 0); + unit->movepos(bl, src->bl.x, src->bl.y, 0, 0); clif->fixpos(bl); } } @@ -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; } @@ -12193,7 +12193,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) { switch(skill_id) { case PR_BENEDICTIO: { uint8 dir = iMap->calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y); - dir = (unit_getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing. + dir = (unit->getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing. if ((tsd->class_&MAPID_BASEMASK) == MAPID_ACOLYTE && (dir == 2 || dir == 6) //Must be standing to the left/right of Priest. && sd->status.sp >= 10) p_sd[(*c)++]=tsd->bl.id; @@ -12217,7 +12217,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) { default: //Warning: Assuming Ensemble Dance/Songs for code speed. [Skotlex] { uint16 skill_lv; - if(pc_issit(tsd) || !unit_can_move(&tsd->bl)) + if(pc_issit(tsd) || !unit->can_move(&tsd->bl)) return 0; if (sd->status.sex != tsd->status.sex && (tsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER && @@ -12546,7 +12546,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; } } - else if( !unit_can_move(&sd->bl) ) + else if( !unit->can_move(&sd->bl) ) { //Placed here as ST_MOVE_ENABLE should not apply if rooted or on a combo. [Skotlex] clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -12590,7 +12590,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; } if(sc->data[SC_COMBOATTACK]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )) { //Cancel combo wait. - unit_cancel_combo(&sd->bl); + unit->cancel_combo(&sd->bl); return 0; } break; //Combo ready. @@ -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"); @@ -13093,7 +13093,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if (sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == skill_id) sd->ud.canmove_tick = iTimer->gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex] - if (!unit_can_move(&sd->bl)) { + if (!unit->can_move(&sd->bl)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -14614,7 +14614,7 @@ int skill_attack_area (struct block_list *bl, va_list ap) *------------------------------------------*/ int skill_clear_group (struct block_list *bl, int flag) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); struct skill_unit_group *group[MAX_SKILLUNITGROUP]; int i, count=0; @@ -14653,7 +14653,7 @@ int skill_clear_group (struct block_list *bl, int flag) * Returns the first element field found [Skotlex] *------------------------------------------*/ struct skill_unit_group *skill_locate_element_field(struct block_list *bl) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); int i; nullpo_ret(bl); if (!ud) return NULL; @@ -14859,7 +14859,7 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) { int skill_chastle_mob_changetarget(struct block_list *bl,va_list ap) { struct mob_data* md; - struct unit_data*ud = unit_bl2ud(bl); + struct unit_data*ud = unit->bl2ud(bl); struct block_list *from_bl; struct block_list *to_bl; md = (struct mob_data*)bl; @@ -15247,7 +15247,7 @@ static int skill_get_new_group_id(void) struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, uint16 skill_id, uint16 skill_lv, int unit_id, int limit, int interval) { - struct unit_data* ud = unit_bl2ud( src ); + struct unit_data* ud = unit->bl2ud( src ); struct skill_unit_group* group; int i; @@ -15318,7 +15318,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin } src=iMap->id2bl(group->src_id); - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); if(!src || !ud) { ShowError("skill_delunitgroup: Group's source not found! (src_id: %d skill_id: %d)\n", group->src_id, group->skill_id); return 0; @@ -15442,7 +15442,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin *------------------------------------------*/ int skill_clear_unitgroup (struct block_list *src) { - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); nullpo_ret(ud); @@ -15464,7 +15464,7 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search (struct block_lis if (group->interval==-1) return NULL; - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (!ud) return NULL; set = ud->skillunittick; @@ -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..6efc0b6ca 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1225,7 +1225,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if(sc->data[SC_KAGEMUSYA] && --(sc->data[SC_KAGEMUSYA]->val3) <= 0) status_change_end(target, SC_KAGEMUSYA, INVALID_TIMER); } - unit_skillcastcancel(target, 2); + unit->skillcastcancel(target, 2); } status->hp-= hp; @@ -1246,20 +1246,20 @@ 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; } if( src && target->type == BL_PC && (((TBL_PC*)target)->disguise) > 0 ) {// stop walking when attacked in disguise to prevent walk-delay bug - unit_stop_walking( target, 1 ); + unit->stop_walking( target, 1 ); } if( status->hp || (flag&8) ) { //Still lives or has been dead before this damage. if (walkdelay) - unit_set_walkdelay(target, iTimer->gettick(), walkdelay, 0); + unit->set_walkdelay(target, iTimer->gettick(), walkdelay, 0); return (int)(hp+sp); } @@ -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; @@ -1339,13 +1339,13 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, iStatus->change_clear(target,0); if(flag&4) //Delete from memory. (also invokes map removal code) - unit_free(target,CLR_DEAD); + unit->free(target,CLR_DEAD); else if(flag&2) //remove from map - unit_remove_map(target,CLR_DEAD); + unit->remove_map(target,CLR_DEAD,ALC_MARK); else { //Some death states that would normally be handled by unit_remove_map - unit_stop_attack(target); - unit_stop_walking(target,1); - unit_skillcastcancel(target,0); + unit->stop_attack(target); + unit->stop_walking(target,1); + unit->skillcastcancel(target,0); clif->clearunit_area(target,CLR_DEAD); skill->unit_move(target,iTimer->gettick(),4); skill->cleartimerskill(target); @@ -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; } @@ -1628,8 +1628,8 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin return 0; if (sc->data[SC_DC_WINKCHARM] && target && !flag) { //Prevents skill usage - if( unit_bl2ud(src) && (unit_bl2ud(src))->walktimer == INVALID_TIMER ) - unit_walktobl(src, iMap->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1); + if( unit->bl2ud(src) && (unit->bl2ud(src))->walktimer == INVALID_TIMER ) + unit->walktobl(src, iMap->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1); clif->emotion(src, E_LV); return 0; } @@ -2088,7 +2088,7 @@ int status_calc_mob_(struct mob_data* md, bool first) if (flag&16 && mbl) { //Max HP setting from Summon Flora/marine Sphere - struct unit_data *ud = unit_bl2ud(mbl); + struct unit_data *ud = unit->bl2ud(mbl); //Remove special AI when this is used by regular mobs. if (mbl->type == BL_MOB && !((TBL_MOB*)mbl)->special_state.ai) md->special_state.ai = 0; @@ -3743,7 +3743,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) } if(flag&SCB_SPEED) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); status->speed = status_calc_speed(bl, sc, b_status->speed); //Re-walk to adjust speed (we do not check if walktimer != INVALID_TIMER @@ -3798,9 +3798,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) status->mode = status_calc_mode(bl, sc, b_status->mode); //Since mode changed, reset their state. if (!(status->mode&MD_CANATTACK)) - unit_stop_attack(bl); + unit->stop_attack(bl); if (!(status->mode&MD_CANMOVE)) - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); } // No status changes alter these yet. @@ -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; } @@ -5883,7 +5883,7 @@ defType status_get_def(struct block_list *bl) { struct unit_data *ud; struct status_data *status = iStatus->get_status_data(bl); int def = status?status->def:0; - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (ud && ud->skilltimer != INVALID_TIMER) def -= def * skill->get_castdef(ud->skill_id)/100; @@ -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_)) @@ -7554,7 +7554,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_HANBOK: if (!vd) return 0; //Store previous values as they could be removed. - unit_stop_attack(bl); + unit->stop_attack(bl); break; case SC_NOCHAT: // [GodLesZ] FIXME: is this correct? a hardcoded interval of 60sec? what about configuration ?_? @@ -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; @@ -7914,11 +7914,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val //val3: When set, this combo time should NOT delay attack/movement //val3: TK: Last used kick //val4: TK: Combo time - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (ud && !val3) { tick += 300 * battle_config.combo_delay_rate/100; ud->attackabletime = iTimer->gettick()+tick; - unit_set_walkdelay(bl, iTimer->gettick(), tick, 1); + unit->set_walkdelay(bl, iTimer->gettick(), tick, 1); } val3 = 0; val4 = tick; @@ -8498,7 +8498,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_UNLIMITED_HUMMING_VOICE: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if( ud == NULL ) return 0; ud->state.skillcastcancel = 0; val3 = 15 - (2 * val2); @@ -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; @@ -8861,9 +8861,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val status_change_end(bl, SC_DANCING, INVALID_TIMER); // Cancel cast when get status [LuzZza] if (battle_config.sc_castcancel&bl->type) - unit_skillcastcancel(bl, 0); + unit->skillcastcancel(bl, 0); case SC_WHITEIMPRISON: - unit_stop_attack(bl); + unit->stop_attack(bl); case SC_STOP: case SC_CONFUSION: case SC_RG_CCONFINE_M: @@ -8882,11 +8882,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_KYOUGAKU: case SC_NEEDLE_OF_PARALYZE: case SC_DEATHBOUND: - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); break; case SC_ANKLESNARE: if( battle_config.skill_trap_type || !map_flag_gvg(bl->m) ) - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); break; case SC_HIDING: case SC_CLOAKING: @@ -8895,11 +8895,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_WEIGHTOVER90: case SC_CAMOUFLAGE: case SC_SIREN: - unit_stop_attack(bl); + unit->stop_attack(bl); break; case SC_SILENCE: if (battle_config.sc_castcancel&bl->type) - unit_skillcastcancel(bl, 0); + unit->skillcastcancel(bl, 0); break; /* */ case SC_ITEMSCRIPT: @@ -9148,9 +9148,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_RUN: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if( ud ) - ud->state.running = unit_run(bl); + ud->state.running = unit->run(bl); } break; case SC_CASH_BOSS_ALARM: @@ -9167,9 +9167,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val **/ case SC_WUGDASH: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if( ud ) - ud->state.running = unit_wugdash(bl, sd); + ud->state.running = unit->wugdash(bl, sd); } break; case SC_COMBOATTACK: @@ -9365,14 +9365,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_RUN: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); bool begin_spurt = true; if (ud) { if(!ud->state.running) begin_spurt = false; ud->state.running = 0; if (ud->walktimer != INVALID_TIMER) - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); } if (begin_spurt && sce->val1 >= 7 && DIFF_TICK(iTimer->gettick(), sce->val4) <= 1000 && @@ -9681,11 +9681,11 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_WUGDASH: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (ud) { ud->state.running = 0; if (ud->walktimer != -1) - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); } } break; @@ -10131,8 +10131,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) case SC_STONE: if(sc->opt1 == OPT1_STONEWAIT && sce->val3) { sce->val4 = 0; - unit_stop_walking(bl,1); - unit_stop_attack(bl); + unit->stop_walking(bl,1); + unit->stop_attack(bl); sc->opt1 = OPT1_STONE; clif->changeoption(bl); sc_timer_next(1000+tick,iStatus->change_timer, bl->id, data ); @@ -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); @@ -10392,7 +10392,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) if( --(sce->val4) > 0 ) { int damage = status->max_hp/100; // {Target VIT x (New Poison Research Skill Level - 3)} + (Target HP/100) damage += status->vit * (sce->val1 - 3); - unit_skillcastcancel(bl,2); + unit->skillcastcancel(bl,2); iMap->freeblock_lock(); iStatus->damage(bl, bl, damage, 0, clif->damage(bl,bl,tick,status_get_amotion(bl),status_get_dmotion(bl)+500,damage,1,0,0), 1); if( sc->data[type] ) { @@ -10420,8 +10420,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) if( !flag ) { // Random Skill Cast if (sd && !pc_issit(sd)) { //can't cast if sit int mushroom_skill_id = 0, i; - unit_stop_attack(bl); - unit_skillcastcancel(bl,1); + unit->stop_attack(bl); + unit->skillcastcancel(bl,1); do { i = rnd() % MAX_SKILL_MAGICMUSHROOM_DB; mushroom_skill_id = skill_magicmushroom_db[i].skill_id; @@ -10618,7 +10618,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) iMap->freeblock_lock(); damage = sce->val3; iStatus->damage(src, bl, damage, 0, clif->damage(bl,bl,tick,status->amotion,status->dmotion+200,damage,1,0,0), 1); - unit_skillcastcancel(bl,1); + unit->skillcastcancel(bl,1); if ( sc->data[type] ) { sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); } @@ -11299,7 +11299,7 @@ static int status_natural_heal(struct block_list* bl, va_list args) if (flag && regen->state.overweight) flag=0; - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (flag&(RGN_HP|RGN_SHP|RGN_SSP) && ud && ud->walktimer != INVALID_TIMER) { diff --git a/src/map/unit.c b/src/map/unit.c index d3f72421d..65eea39c9 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -45,6 +45,8 @@ const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; +struct unit_interface unit_s; + /** * Returns the unit_data for the given block_list. If the object is using * shared unit_data (i.e. in case of BL_NPC), it returns the shared data. @@ -75,13 +77,13 @@ struct unit_data* unit_bl2ud2(struct block_list *bl) { struct npc_data *nd = (struct npc_data *)bl; nd->ud = NULL; CREATE(nd->ud, struct unit_data, 1); - unit_dataset(&nd->bl); + unit->dataset(&nd->bl); } - return unit_bl2ud(bl); + return unit->bl2ud(bl); } -static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data); -static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data); +int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data); +int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data); int unit_walktoxy_sub(struct block_list *bl) { @@ -90,7 +92,7 @@ int unit_walktoxy_sub(struct block_list *bl) struct unit_data *ud = NULL; nullpo_retr(1, bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if(ud == NULL) return 0; if( !path_search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) ) @@ -131,11 +133,11 @@ int unit_walktoxy_sub(struct block_list *bl) else i = iStatus->get_speed(bl); if( i > 0) - ud->walktimer = iTimer->add_timer(iTimer->gettick()+i,unit_walktoxy_timer,bl->id,i); + ud->walktimer = iTimer->add_timer(iTimer->gettick()+i,unit->walktoxy_timer,bl->id,i); return 1; } -static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) +int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { int i; int x,y,dx,dy; @@ -152,7 +154,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data sd = BL_CAST(BL_PC, bl); md = BL_CAST(BL_MOB, bl); mrd = BL_CAST(BL_MER, bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if(ud == NULL) return 0; @@ -178,7 +180,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data dy = diry[(int)dir]; if(iMap->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS)) - return unit_walktoxy_sub(bl); + return unit->walktoxy_sub(bl); //Refresh view for all those we lose sight iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); @@ -216,7 +218,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data else if (DIFF_TICK(iTimer->gettick(), sd->md->masterteleport_timer) > 3000) { sd->md->masterteleport_timer = 0; - unit_warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT ); + unit->warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT ); } } else if( sd->md ) @@ -234,7 +236,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 @@ -257,7 +259,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data else if (DIFF_TICK(iTimer->gettick(), mrd->masterteleport_timer) > 3000) { mrd->masterteleport_timer = 0; - unit_warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT ); + unit->warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT ); } } else @@ -270,7 +272,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data return 0; if(ud->state.change_walk_target) - return unit_walktoxy_sub(bl); + return unit->walktoxy_sub(bl); ud->walkpath.path_pos++; if(ud->walkpath.path_pos>=ud->walkpath.path_len) @@ -281,12 +283,12 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data i = iStatus->get_speed(bl); if(i > 0) { - ud->walktimer = iTimer->add_timer(tick+i,unit_walktoxy_timer,id,i); + ud->walktimer = iTimer->add_timer(tick+i,unit->walktoxy_timer,id,i); if( md && DIFF_TICK(tick,md->dmgtick) < 3000 )//not required not damaged recently clif->move(ud); } else if(ud->state.running) { //Keep trying to run. - if ( !(unit_run(bl) || unit_wugdash(bl,sd)) ) + if ( !(unit->run(bl) || unit->wugdash(bl,sd)) ) ud->state.running = 0; } else if (ud->target_to) { @@ -295,7 +297,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; @@ -307,10 +309,10 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data //only need this one for syncing purposes. [Skotlex] ud->target_to = 0; clif->fixpos(bl); - unit_attack(bl, tbl->id, ud->state.attack_continue); + unit->attack(bl, tbl->id, ud->state.attack_continue); } } else { //Update chase-path - unit_walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue?2:0)); + unit->walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue?2:0)); return 0; } } @@ -321,13 +323,13 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data return 0; } -static int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) +int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl = iMap->id2bl(id); if (!bl || bl->prev == NULL) return 0; - unit_walktoxy(bl, (short)((data>>16)&0xffff), (short)(data&0xffff), 0); + unit->walktoxy(bl, (short)((data>>16)&0xffff), (short)(data&0xffff), 0); return 1; } @@ -343,7 +345,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) nullpo_ret(bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if( ud == NULL) return 0; @@ -362,17 +364,17 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) if (flag&4 && DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0 && DIFF_TICK(ud->canmove_tick, iTimer->gettick()) < 2000) { // Delay walking command. [Skotlex] - iTimer->add_timer(ud->canmove_tick+1, unit_delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); + iTimer->add_timer(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); return 1; } - if(!(flag&2) && (!(status_get_mode(bl)&MD_CANMOVE) || !unit_can_move(bl))) + if(!(flag&2) && (!(status_get_mode(bl)&MD_CANMOVE) || !unit->can_move(bl))) return 0; ud->state.walk_easy = flag&1; ud->to_x = x; ud->to_y = y; - unit_set_target(ud, 0); + unit->set_target(ud, 0); sc = iStatus->get_sc(bl); if (sc && sc->data[SC_CONFUSION]) //Randomize the target position @@ -380,17 +382,17 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) if(ud->walktimer != INVALID_TIMER) { // When you come to the center of the grid because the change of destination while you're walking right now - // Call a function from a timer unit_walktoxy_sub + // Call a function from a timer unit->walktoxy_sub ud->state.change_walk_target = 1; return 1; } if(ud->attacktimer != INVALID_TIMER) { - iTimer->delete_timer( ud->attacktimer, unit_attack_timer ); + iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; } - return unit_walktoxy_sub(bl); + return unit->walktoxy_sub(bl); } //To set Mob's CHASE/FOLLOW states (shouldn't be done if there's no path to reach) @@ -402,18 +404,18 @@ static inline void set_mobstate(struct block_list* bl, int flag) md->state.skillstate = md->state.aggressive ? MSS_FOLLOW : MSS_RUSH; } -static int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) +int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl = iMap->id2bl(id); - struct unit_data *ud = bl?unit_bl2ud(bl):NULL; + struct unit_data *ud = bl?unit->bl2ud(bl):NULL; if (ud && ud->walktimer == INVALID_TIMER && ud->target == data) { if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting? - iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, id, data); - else if (unit_can_move(bl)) + iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, id, data); + else if (unit->can_move(bl)) { - if (unit_walktoxy_sub(bl)) + if (unit->walktoxy_sub(bl)) set_mobstate(bl, ud->state.attack_continue); } } @@ -430,13 +432,13 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int nullpo_ret(bl); nullpo_ret(tbl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if( ud == NULL) return 0; if (!(status_get_mode(bl)&MD_CANMOVE)) return 0; - if (!unit_can_reach_bl(bl, tbl, distance_bl(bl, tbl)+1, flag&1, &ud->to_x, &ud->to_y)) { + if (!unit->can_reach_bl(bl, tbl, distance_bl(bl, tbl)+1, flag&1, &ud->to_x, &ud->to_y)) { ud->to_x = bl->x; ud->to_y = bl->y; ud->target_to = 0; @@ -447,7 +449,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int ud->target_to = tbl->id; ud->chaserange = range; //Note that if flag&2, this SHOULD be attack-range ud->state.attack_continue = flag&2?1:0; //Chase to attack. - unit_set_target(ud, 0); + unit->set_target(ud, 0); sc = iStatus->get_sc(bl); if (sc && sc->data[SC_CONFUSION]) //Randomize the target position @@ -461,19 +463,19 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int if(DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0) { //Can't move, wait a bit before invoking the movement. - iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target); + iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); return 1; } - if(!unit_can_move(bl)) + if(!unit->can_move(bl)) return 0; if(ud->attacktimer != INVALID_TIMER) { - iTimer->delete_timer( ud->attacktimer, unit_attack_timer ); + iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; } - if (unit_walktoxy_sub(bl)) { + if (unit->walktoxy_sub(bl)) { set_mobstate(bl, flag&2); return 1; } @@ -490,7 +492,7 @@ int unit_run(struct block_list *bl) if (!(sc && sc->data[SC_RUN])) return 0; - if (!unit_can_move(bl)) { + if (!unit->can_move(bl)) { status_change_end(bl, SC_RUN, INVALID_TIMER); return 0; } @@ -520,30 +522,30 @@ int unit_run(struct block_list *bl) clif->sc_load(bl,bl->id,AREA,SI_TING,0,0,0); //Set running to 0 beforehand so status_change_end knows not to enable spurt [Kevin] - unit_bl2ud(bl)->state.running = 0; + unit->bl2ud(bl)->state.running = 0; status_change_end(bl, SC_RUN, INVALID_TIMER); - skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit_getdir(bl),0); + skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit->getdir(bl),0); clif->fixpos(bl); //Why is a clif->slide (skill->blown) AND a fixpos needed? Ask Aegis. clif->sc_end(bl,bl->id,AREA,SI_TING); return 0; } - if (unit_walktoxy(bl, to_x, to_y, 1)) + if (unit->walktoxy(bl, to_x, to_y, 1)) return 1; //There must be an obstacle nearby. Attempt walking one cell at a time. do { to_x -= dir_x; to_y -= dir_y; - } while (--i > 0 && !unit_walktoxy(bl, to_x, to_y, 1)); + } while (--i > 0 && !unit->walktoxy(bl, to_x, to_y, 1)); if ( i == 0 ) { // copy-paste from above clif->sc_load(bl,bl->id,AREA,SI_TING,0,0,0); //Set running to 0 beforehand so status_change_end knows not to enable spurt [Kevin] - unit_bl2ud(bl)->state.running = 0; + unit->bl2ud(bl)->state.running = 0; status_change_end(bl, SC_RUN, INVALID_TIMER); - skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit_getdir(bl),0); + skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit->getdir(bl),0); clif->fixpos(bl); clif->sc_end(bl,bl->id,AREA,SI_TING); return 0; @@ -563,7 +565,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { nullpo_ret(sd); nullpo_ret(bl); - if (!unit_can_move(bl)) { + if (!unit->can_move(bl)) { status_change_end(bl,SC_WUGDASH,INVALID_TIMER); return 0; } @@ -588,7 +590,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { if(to_x == bl->x && to_y == bl->y) { - unit_bl2ud(bl)->state.running = 0; + unit->bl2ud(bl)->state.running = 0; status_change_end(bl,SC_WUGDASH,INVALID_TIMER); if( sd ){ @@ -597,15 +599,15 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { } return 0; } - if (unit_walktoxy(bl, to_x, to_y, 1)) + if (unit->walktoxy(bl, to_x, to_y, 1)) return 1; do { to_x -= dir_x; to_y -= dir_y; - } while (--i > 0 && !unit_walktoxy(bl, to_x, to_y, 1)); + } while (--i > 0 && !unit->walktoxy(bl, to_x, to_y, 1)); if (i==0) { - unit_bl2ud(bl)->state.running = 0; + unit->bl2ud(bl)->state.running = 0; status_change_end(bl,SC_WUGDASH,INVALID_TIMER); if( sd ){ @@ -623,7 +625,7 @@ int unit_escape(struct block_list *bl, struct block_list *target, short dist) uint8 dir = iMap->calc_dir(target, bl->x, bl->y); while( dist > 0 && iMap->getcell(bl->m, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], CELL_CHKNOREACH) ) dist--; - return ( dist > 0 && unit_walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) ); + return ( dist > 0 && unit->walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) ); } //Instant warp function. @@ -636,12 +638,12 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool nullpo_ret(bl); sd = BL_CAST(BL_PC, bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if( ud == NULL) return 0; - unit_stop_walking(bl,1); - unit_stop_attack(bl); + unit->stop_walking(bl,1); + unit->stop_attack(bl); if( checkpath && (iMap->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) ) return 0; // unreachable @@ -683,7 +685,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool flag = 2; if( flag ) { - unit_movepos(bl,sd->bl.x,sd->bl.y, 0, 0); + unit->movepos(bl,sd->bl.x,sd->bl.y, 0, 0); clif->slide(bl,bl->x,bl->y); } } @@ -695,7 +697,7 @@ int unit_setdir(struct block_list *bl,unsigned char dir) { struct unit_data *ud; nullpo_ret(bl ); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (!ud) return 0; ud->dir = dir; if (bl->type == BL_PC) @@ -710,7 +712,7 @@ uint8 unit_getdir(struct block_list *bl) { if( bl->type == BL_NPC ) return ((TBL_NPC*)bl)->dir; - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (!ud) return 0; return ud->dir; } @@ -735,7 +737,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) ny = result&0xffff; if(!su) { - unit_stop_walking(bl, 0); + unit->stop_walking(bl, 0); } if( sd ) { @@ -786,7 +788,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) { struct unit_data *ud; nullpo_ret(bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if(bl->prev==NULL || !ud) return 1; @@ -832,7 +834,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) if (bl->type == BL_PC) //Use pc_setpos return pc->setpos((TBL_PC*)bl, map_id2index(m), x, y, type); - if (!unit_remove_map(bl, type)) + if (!unit->remove_map(bl, type, ALC_MARK)) return 3; if (bl->m != m && battle_config.clear_unit_onwarp && @@ -865,14 +867,14 @@ int unit_stop_walking(struct block_list *bl,int type) unsigned int tick; nullpo_ret(bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if(!ud || ud->walktimer == INVALID_TIMER) return 0; //NOTE: We are using timer data after deleting it because we know the //iTimer->delete_timer function does not messes with it. If the function's //behaviour changes in the future, this code could break! td = iTimer->get_timer(ud->walktimer); - iTimer->delete_timer(ud->walktimer, unit_walktoxy_timer); + iTimer->delete_timer(ud->walktimer, unit->walktoxy_timer); ud->walktimer = INVALID_TIMER; ud->state.change_walk_target = 0; tick = iTimer->gettick(); @@ -880,7 +882,7 @@ int unit_stop_walking(struct block_list *bl,int type) || (type&0x04 && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell ) { ud->walkpath.path_len = ud->walkpath.path_pos+1; - unit_walktoxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos); + unit->walktoxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos); } if(type&0x01) @@ -903,7 +905,7 @@ int unit_stop_walking(struct block_list *bl,int type) int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv) { - return unit_skilluse_id2( + return unit->skilluse_id2( src, target_id, skill_id, skill_lv, skill->cast_fix(src, skill_id, skill_lv), skill->get_castcancel(skill_id) @@ -912,7 +914,7 @@ int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uin int unit_is_walking(struct block_list *bl) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); nullpo_ret(bl); if(!ud) return 0; return (ud->walktimer != INVALID_TIMER); @@ -927,7 +929,7 @@ int unit_can_move(struct block_list *bl) { struct status_change *sc; nullpo_ret(bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); sc = iStatus->get_sc(bl); sd = BL_CAST(BL_PC, bl); @@ -1013,10 +1015,10 @@ int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data) if(sd && pc_isridingwug(sd)) clif->skill_nodamage(ud->bl,ud->bl,RA_WUGDASH,ud->skill_lv, - sc_start4(ud->bl,iStatus->skill2sc(RA_WUGDASH),100,ud->skill_lv,unit_getdir(ud->bl),0,0,1)); + sc_start4(ud->bl,iStatus->skill2sc(RA_WUGDASH),100,ud->skill_lv,unit->getdir(ud->bl),0,0,1)); else clif->skill_nodamage(ud->bl,ud->bl,TK_RUN,ud->skill_lv, - sc_start4(ud->bl,iStatus->skill2sc(TK_RUN),100,ud->skill_lv,unit_getdir(ud->bl),0,0,0)); + sc_start4(ud->bl,iStatus->skill2sc(TK_RUN),100,ud->skill_lv,unit->getdir(ud->bl),0,0,0)); if (sd) clif->walkok(sd); @@ -1032,7 +1034,7 @@ int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data) *------------------------------------------*/ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (delay <= 0 || !ud) return 0; /** @@ -1046,7 +1048,7 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int return 0; } else { //Don't set walk delays when already trapped. - if (!unit_can_move(bl)) + if (!unit->can_move(bl)) return 0; } ud->canmove_tick = tick + delay; @@ -1054,18 +1056,18 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int { //Stop walking, if chasing, readjust timers. if (delay == 1) { //Minimal delay (walk-delay) disabled. Just stop walking. - unit_stop_walking(bl,4); + unit->stop_walking(bl,4); } else { //Resume running after can move again [Kevin] if(ud->state.running) { - iTimer->add_timer(ud->canmove_tick, unit_resume_running, bl->id, (intptr_t)ud); + iTimer->add_timer(ud->canmove_tick, unit->resume_running, bl->id, (intptr_t)ud); } else { - unit_stop_walking(bl,2|4); + unit->stop_walking(bl,2|4); if(ud->target) - iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target); + iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); } } } @@ -1087,7 +1089,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui return 0; //Do not continue source is dead sd = BL_CAST(BL_PC, src); - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); if(ud == NULL) return 0; sc = iStatus->get_sc(src); @@ -1157,7 +1159,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] @@ -1234,7 +1236,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui //(these are supposed to always have the same range as your attack) if( src->id != target_id && (!temp || ud->attacktimer == INVALID_TIMER) ) { if( skill->get_state(ud->skill_id) == ST_MOVE_ENABLE ) { - if( !unit_can_reach_bl(src, target, range + 1, 1, NULL, NULL) ) + if( !unit->can_reach_bl(src, target, range + 1, 1, NULL, NULL) ) return 0; // Walk-path check failed. } else if( src->type == BL_MER && skill_id == MA_REMOVETRAP ) { if( !battle->check_range(battle->get_master(src), target, range + 1) ) @@ -1245,7 +1247,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui } if (!temp) //Stop attack on non-combo skills [Skotlex] - unit_stop_attack(src); + unit->stop_attack(src); else if(ud->attacktimer != INVALID_TIMER) //Elsewise, delay current attack sequence ud->attackabletime = tick + status_get_adelay(src); @@ -1349,7 +1351,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui } if(!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026 - unit_stop_walking(src,1);// eventhough this is not how official works but this will do the trick. bugreport:6829 + unit->stop_walking(src,1);// eventhough this is not how official works but this will do the trick. bugreport:6829 // in official this is triggered even if no cast time. clif->skillcasting(src, src->id, target_id, 0,0, skill_id, skill->get_ele(skill_id, skill_lv), casttime); @@ -1358,7 +1360,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) { @@ -1430,7 +1432,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv) { - return unit_skilluse_pos2( + return unit->skilluse_pos2( src, skill_x, skill_y, skill_id, skill_lv, skill->cast_fix(src, skill_id, skill_lv), skill->get_castcancel(skill_id) @@ -1452,7 +1454,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui if(iStatus->isdead(src)) return 0; sd = BL_CAST(BL_PC, src); - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); if(ud == NULL) return 0; if(ud->skilltimer != INVALID_TIMER) //Normally not needed since clif.c checks for it, but at/char/script commands don't! [Skotlex] @@ -1501,12 +1503,12 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui range = skill->get_range2(src, skill_id, skill_lv); // Skill cast distance from database if( skill->get_state(ud->skill_id) == ST_MOVE_ENABLE ) { - if( !unit_can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) ) + if( !unit->can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) ) return 0; //Walk-path check failed. } else if( !battle->check_range(src, &bl, range + 1) ) return 0; //Arrow-path check failed. - unit_stop_attack(src); + unit->stop_attack(src); // moved here to prevent Suffragium from ending if skill fails #ifndef RENEWAL_CAST @@ -1550,7 +1552,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui } } - unit_stop_walking(src,1); + unit->stop_walking(src,1); // in official this is triggered even if no cast time. clif->skillcasting(src, src->id, 0, skill_x, skill_y, skill_id, skill->get_ele(skill_id, skill_lv), casttime); if( casttime > 0 ) { @@ -1575,9 +1577,9 @@ int unit_set_target(struct unit_data* ud, int target_id) nullpo_ret(ud); if( ud->target != target_id ) { - if( ud->target && (target = iMap->id2bl(ud->target)) && (ux = unit_bl2ud(target)) && ux->target_count > 0 ) + if( ud->target && (target = iMap->id2bl(ud->target)) && (ux = unit->bl2ud(target)) && ux->target_count > 0 ) ux->target_count --; - if( target_id && (target = iMap->id2bl(target_id)) && (ux = unit_bl2ud(target)) ) + if( target_id && (target = iMap->id2bl(target_id)) && (ux = unit->bl2ud(target)) ) ux->target_count ++; } @@ -1587,29 +1589,29 @@ int unit_set_target(struct unit_data* ud, int target_id) int unit_stop_attack(struct block_list *bl) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); nullpo_ret(bl); if(!ud || ud->attacktimer == INVALID_TIMER) return 0; - iTimer->delete_timer( ud->attacktimer, unit_attack_timer ); + iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; - unit_set_target(ud, 0); + unit->set_target(ud, 0); return 0; } //Means current target is unattackable. For now only unlocks mobs. int unit_unattackable(struct block_list *bl) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (ud) { ud->state.attack_continue = 0; - unit_set_target(ud, 0); + unit->set_target(ud, 0); } 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; @@ -1624,11 +1626,11 @@ int unit_attack(struct block_list *src,int target_id,int continuous) struct block_list *target; struct unit_data *ud; - nullpo_ret(ud = unit_bl2ud(src)); + nullpo_ret(ud = unit->bl2ud(src)); target = iMap->id2bl(target_id); if( target==NULL || iStatus->isdead(target) ) { - unit_unattackable(src); + unit->unattackable(src); return 1; } @@ -1639,16 +1641,16 @@ int unit_attack(struct block_list *src,int target_id,int continuous) return 0; } if( pc_is90overweight(sd) || pc_isridingwug(sd) ) { // overweight or mounted on warg - stop attacking - unit_stop_attack(src); + unit->stop_attack(src); return 0; } } if( battle->check_target(src,target,BCT_ENEMY) <= 0 || !iStatus->check_skilluse(src, target, 0, 0) ) { - unit_unattackable(src); + unit->unattackable(src); return 1; } ud->state.attack_continue = continuous; - unit_set_target(ud, target_id); + unit->set_target(ud, target_id); if (continuous) //If you're to attack continously, set to auto-case character ud->chaserange = status_get_range(src); @@ -1663,9 +1665,9 @@ int unit_attack(struct block_list *src,int target_id,int continuous) if(DIFF_TICK(ud->attackabletime, iTimer->gettick()) > 0) //Do attack next time it is possible. [Skotlex] - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0); + ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); else //Attack NOW. - unit_attack_timer(INVALID_TIMER, iTimer->gettick(), src->id, 0); + unit->attack_timer(INVALID_TIMER, iTimer->gettick(), src->id, 0); return 0; } @@ -1679,7 +1681,7 @@ int unit_cancel_combo(struct block_list *bl) if (!status_change_end(bl, SC_COMBOATTACK, INVALID_TIMER)) return 0; //Combo wasn't active. - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); nullpo_ret(ud); ud->attackabletime = iTimer->gettick() + status_get_amotion(bl); @@ -1687,8 +1689,8 @@ int unit_cancel_combo(struct block_list *bl) if (ud->attacktimer == INVALID_TIMER) return 1; //Nothing more to do. - iTimer->delete_timer(ud->attacktimer, unit_attack_timer); - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,bl->id,0); + iTimer->delete_timer(ud->attacktimer, unit->attack_timer); + ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,bl->id,0); return 1; } /*========================================== @@ -1747,7 +1749,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) { int dx, dy, x, y, i, k; - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); nullpo_ret(ud); if(dir > 7) @@ -1762,11 +1764,11 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) x = tx + dx; y = ty + dy; - if( !unit_can_reach_pos(bl, x, y, 0) ) + if( !unit->can_reach_pos(bl, x, y, 0) ) { if( dx > 0 ) x--; else if( dx < 0 ) x++; if( dy > 0 ) y--; else if( dy < 0 ) y++; - if( !unit_can_reach_pos(bl, x, y, 0) ) + if( !unit->can_reach_pos(bl, x, y, 0) ) { for( i = 0; i < 12; i++ ) { @@ -1775,20 +1777,20 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) dy = -diry[k] * 2; x = tx + dx; y = ty + dy; - if( unit_can_reach_pos(bl, x, y, 0) ) + if( unit->can_reach_pos(bl, x, y, 0) ) break; else { if( dx > 0 ) x--; else if( dx < 0 ) x++; if( dy > 0 ) y--; else if( dy < 0 ) y++; - if( unit_can_reach_pos(bl, x, y, 0) ) + if( unit->can_reach_pos(bl, x, y, 0) ) break; } } if( i == 12 ) { x = tx; y = tx; // Exactly Master Position - if( !unit_can_reach_pos(bl, x, y, 0) ) + if( !unit->can_reach_pos(bl, x, y, 0) ) return 1; } } @@ -1802,7 +1804,7 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) /*========================================== * Continuous Attack (function timer) *------------------------------------------*/ -static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) +int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) { struct block_list *target; struct unit_data *ud; @@ -1811,7 +1813,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t struct mob_data *md = NULL; int range; - if( (ud=unit_bl2ud(src))==NULL ) + if( (ud=unit->bl2ud(src))==NULL ) return 0; if( ud->attacktimer != tid ) { @@ -1837,7 +1839,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; } @@ -1855,7 +1857,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t if( ud->state.attack_continue ) { if( DIFF_TICK(ud->canact_tick, ud->attackabletime) > 0 ) ud->attackabletime = ud->canact_tick; - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0); + ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); } return 1; } @@ -1863,20 +1865,20 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t sstatus = iStatus->get_status_data(src); range = sstatus->rhw.range + 1; - if( unit_is_walking(target) ) + if( unit->is_walking(target) ) range++; //Extra range when chasing if( !check_distance_bl(src,target,range) ) { //Chase if required. if(sd) clif->movetoattack(sd,target); else if(ud->state.attack_continue) - unit_walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); + unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); return 1; } if( !battle->check_range(src,target,range) ) { //Within range, but no direct line of attack if( ud->state.attack_continue ) { if(ud->chaserange > 2) ud->chaserange-=2; - unit_walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); + unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); } return 1; } @@ -1890,14 +1892,14 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t ud->dir = iMap->calc_dir(src, target->x,target->y ); } if(ud->walktimer != INVALID_TIMER) - unit_stop_walking(src,1); + 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)) @@ -1919,24 +1921,24 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t ud->attackabletime = tick + sstatus->adelay; // You can't move if you can't attack neither. if (src->type&battle_config.attack_walk_delay) - unit_set_walkdelay(src, tick, sstatus->amotion, 1); + unit->set_walkdelay(src, tick, sstatus->amotion, 1); } if(ud->state.attack_continue) { if( src->type == BL_PC ) ((TBL_PC*)src)->idletime = last_tick; - ud->attacktimer = iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0); + ud->attacktimer = iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); } return 1; } -static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data) +int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl; bl = iMap->id2bl(id); - if(bl && unit_attack_timer_sub(bl, tid, tick) == 0) - unit_unattackable(bl); + if(bl && unit->attack_timer_sub(bl, tid, tick) == 0) + unit->unattackable(bl); return 0; } @@ -1948,7 +1950,7 @@ static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data) int unit_skillcastcancel(struct block_list *bl,int type) { struct map_session_data *sd = NULL; - struct unit_data *ud = unit_bl2ud( bl); + struct unit_data *ud = unit->bl2ud( bl); unsigned int tick=iTimer->gettick(); int ret=0, skill_id; @@ -2004,7 +2006,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) // unit_data initialization process void unit_dataset(struct block_list *bl) { struct unit_data *ud; - nullpo_retv(ud = unit_bl2ud(bl)); + nullpo_retv(ud = unit->bl2ud(bl)); memset( ud, 0, sizeof( struct unit_data) ); ud->bl = bl; @@ -2022,7 +2024,7 @@ void unit_dataset(struct block_list *bl) { int unit_counttargeted(struct block_list* bl) { struct unit_data* ud; - if( bl && (ud = unit_bl2ud(bl)) ) + if( bl && (ud = unit->bl2ud(bl)) ) return ud->target_count; return 0; } @@ -2067,9 +2069,9 @@ int unit_changeviewsize(struct block_list *bl,short size) * Otherwise it is assumed bl is being warped. * On-Kill specific stuff is not performed here, look at iStatus->damage for that. *------------------------------------------*/ -int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func) +int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); struct status_change *sc = iStatus->get_sc(bl); nullpo_ret(ud); @@ -2078,14 +2080,14 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, iMap->freeblock_lock(); - unit_set_target(ud, 0); + unit->set_target(ud, 0); if (ud->walktimer != INVALID_TIMER) - unit_stop_walking(bl,0); + unit->stop_walking(bl,0); if (ud->attacktimer != INVALID_TIMER) - unit_stop_attack(bl); + unit->stop_attack(bl); if (ud->skilltimer != INVALID_TIMER) - unit_skillcastcancel(bl,0); + unit->skillcastcancel(bl,0); // Do not reset can-act delay. [Skotlex] ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = iTimer->gettick(); @@ -2233,10 +2235,10 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, case BL_PET: { struct pet_data *pd = (struct pet_data*)bl; if( pd->pet.intimate <= 0 && !(pd->msd && !pd->msd->state.active) ) - { //If logging out, this is deleted on unit_free + { //If logging out, this is deleted on unit->free clif->clearunit_area(bl,clrtype); iMap->delblock(bl); - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); iMap->freeblock_unlock(); return 0; } @@ -2247,11 +2249,11 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, struct homun_data *hd = (struct homun_data *)bl; ud->canact_tick = ud->canmove_tick; //It appears HOM do reset the can-act tick. if( !hd->homunculus.intimacy && !(hd->master && !hd->master->state.active) ) - { //If logging out, this is deleted on unit_free + { //If logging out, this is deleted on unit->free clif->emotion(bl, E_SOB); clif->clearunit_area(bl,clrtype); iMap->delblock(bl); - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); iMap->freeblock_unlock(); return 0; } @@ -2264,7 +2266,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, { clif->clearunit_area(bl,clrtype); iMap->delblock(bl); - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); iMap->freeblock_unlock(); return 0; } @@ -2277,7 +2279,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, { clif->clearunit_area(bl,clrtype); iMap->delblock(bl); - unit_free(bl,0); + unit->free(bl,0); iMap->freeblock_unlock(); return 0; } @@ -2297,27 +2299,27 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype) { - unit_remove_map(&sd->bl,clrtype); + unit->remove_map(&sd->bl,clrtype,ALC_MARK); if (clrtype == CLR_TELEPORT) clrtype = CLR_OUTSIGHT; //CLR_TELEPORT is the warp from logging out, but pets/homunc need to just 'vanish' instead of showing the warping out animation. if(sd->pd) - unit_remove_map(&sd->pd->bl, clrtype); + unit->remove_map(&sd->pd->bl, clrtype, ALC_MARK); if(homun_alive(sd->hd)) - unit_remove_map(&sd->hd->bl, clrtype); + unit->remove_map(&sd->hd->bl, clrtype, ALC_MARK); if(sd->md) - unit_remove_map(&sd->md->bl, clrtype); + unit->remove_map(&sd->md->bl, clrtype, ALC_MARK); if(sd->ed) - unit_remove_map(&sd->ed->bl, clrtype); + unit->remove_map(&sd->ed->bl, clrtype, ALC_MARK); } void unit_free_pc(struct map_session_data *sd) { - if (sd->pd) unit_free(&sd->pd->bl,CLR_OUTSIGHT); - if (sd->hd) unit_free(&sd->hd->bl,CLR_OUTSIGHT); - if (sd->md) unit_free(&sd->md->bl,CLR_OUTSIGHT); - if (sd->ed) unit_free(&sd->ed->bl,CLR_OUTSIGHT); - unit_free(&sd->bl,CLR_TELEPORT); + if (sd->pd) unit->free(&sd->pd->bl,CLR_OUTSIGHT); + if (sd->hd) unit->free(&sd->hd->bl,CLR_OUTSIGHT); + if (sd->md) unit->free(&sd->md->bl,CLR_OUTSIGHT); + if (sd->ed) unit->free(&sd->ed->bl,CLR_OUTSIGHT); + unit->free(&sd->bl,CLR_TELEPORT); } /*========================================== @@ -2326,12 +2328,12 @@ void unit_free_pc(struct map_session_data *sd) *------------------------------------------*/ int unit_free(struct block_list *bl, clr_type clrtype) { - struct unit_data *ud = unit_bl2ud( bl ); + struct unit_data *ud = unit->bl2ud( bl ); nullpo_ret(ud); iMap->freeblock_lock(); if( bl->prev ) //Players are supposed to logout with a "warp" effect. - unit_remove_map(bl, clrtype); + unit->remove_map(bl, clrtype, ALC_MARK); switch( bl->type ) { case BL_PC: @@ -2476,12 +2478,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 +2525,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: @@ -2590,17 +2592,67 @@ int unit_free(struct block_list *bl, clr_type clrtype) return 0; } -int do_init_unit(void) -{ - iTimer->add_timer_func_list(unit_attack_timer, "unit_attack_timer"); - iTimer->add_timer_func_list(unit_walktoxy_timer,"unit_walktoxy_timer"); - iTimer->add_timer_func_list(unit_walktobl_sub, "unit_walktobl_sub"); - iTimer->add_timer_func_list(unit_delay_walktoxy_timer,"unit_delay_walktoxy_timer"); +int do_init_unit(void) { + iTimer->add_timer_func_list(unit->attack_timer, "unit_attack_timer"); + iTimer->add_timer_func_list(unit->walktoxy_timer,"unit_walktoxy_timer"); + iTimer->add_timer_func_list(unit->walktobl_sub, "unit_walktobl_sub"); + iTimer->add_timer_func_list(unit->delay_walktoxy_timer,"unit_delay_walktoxy_timer"); return 0; } -int do_final_unit(void) -{ +int do_final_unit(void) { // nothing to do return 0; } + +void unit_defaults(void) { + unit = &unit_s; + + unit->init = do_init_unit; + unit->final = do_final_unit; + /* */ + unit->bl2ud = unit_bl2ud; + unit->bl2ud2 = unit_bl2ud2; + unit->attack_timer = unit_attack_timer; + unit->walktoxy_timer = unit_walktoxy_timer; + unit->walktoxy_sub = unit_walktoxy_sub; + unit->delay_walktoxy_timer = unit_delay_walktoxy_timer; + unit->walktoxy = unit_walktoxy; + unit->walktobl_sub = unit_walktobl_sub; + unit->walktobl = unit_walktobl; + unit->run = unit_run; + unit->wugdash = unit_wugdash; + unit->escape = unit_escape; + unit->movepos = unit_movepos; + unit->setdir = unit_setdir; + unit->getdir = unit_getdir; + unit->blown = unit_blown; + unit->warp = unit_warp; + unit->stop_walking = unit_stop_walking; + unit->skilluse_id = unit_skilluse_id; + unit->is_walking = unit_is_walking; + unit->can_move = unit_can_move; + unit->resume_running = unit_resume_running; + unit->set_walkdelay = unit_set_walkdelay; + unit->skilluse_id2 = unit_skilluse_id2; + unit->skilluse_pos = unit_skilluse_pos; + unit->skilluse_pos2 = unit_skilluse_pos2; + unit->set_target = unit_set_target; + unit->stop_attack = unit_stop_attack; + unit->unattackable = unit_unattackable; + unit->attack = unit_attack; + unit->cancel_combo = unit_cancel_combo; + unit->can_reach_pos = unit_can_reach_pos; + unit->can_reach_bl = unit_can_reach_bl; + unit->calc_pos = unit_calc_pos; + unit->attack_timer_sub = unit_attack_timer_sub; + unit->skillcastcancel = unit_skillcastcancel; + unit->dataset = unit_dataset; + unit->counttargeted = unit_counttargeted; + unit->fixdamage = unit_fixdamage; + unit->changeviewsize = unit_changeviewsize; + unit->remove_map = unit_remove_map; + unit->remove_map_pc = unit_remove_map_pc; + unit->free_pc = unit_free_pc; + unit->free = unit_free; +} diff --git a/src/map/unit.h b/src/map/unit.h index b743fc8cb..be7b789d9 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -68,79 +68,61 @@ struct view_data { unsigned dead_sit : 2; }; -// PC, MOB, PET に共通する処理を1つにまとめる計画 - -// 歩行開始 -// 戻り値は、0 ( 成功 ), 1 ( 失敗 ) -int unit_walktoxy( struct block_list *bl, short x, short y, int easy); -int unit_walktobl( struct block_list *bl, struct block_list *target, int range, int easy); -int unit_run(struct block_list *bl); -int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir); - -// 歩行停止 -// typeは以下の組み合わせ : -// 1: 位置情報の送信( この関数の後に位置情報を送信する場合は不要 ) -// 2: ダメージディレイ有り -// 4: 不明(MOBのみ?) -int unit_stop_walking(struct block_list *bl,int type); -int unit_can_move(struct block_list *bl); -int unit_is_walking(struct block_list *bl); -int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type); - -int unit_escape(struct block_list *bl, struct block_list *target, short dist); -// 位置の強制移動(吹き飛ばしなど) -int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath); -int unit_warp(struct block_list *bl, short map, short x, short y, clr_type type); -int unit_setdir(struct block_list *bl,unsigned char dir); -uint8 unit_getdir(struct block_list *bl); -int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag); - -// そこまで歩行でたどり着けるかの判定 -bool unit_can_reach_pos(struct block_list *bl,int x,int y,int easy); -bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y); - -// 攻撃関連 -int unit_stop_attack(struct block_list *bl); -int unit_attack(struct block_list *src,int target_id,int continuous); -int unit_cancel_combo(struct block_list *bl); - -// スキル使用 -int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv); -int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv); - -// スキル使用( 補正済みキャスト時間、キャンセル不可設定付き ) -int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); -int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); - -// 詠唱キャンセル -int unit_skillcastcancel(struct block_list *bl,int type); - -int unit_counttargeted(struct block_list *bl); -int unit_set_target(struct unit_data* ud, int target_id); - -// unit_data の初期化処理 -void unit_dataset(struct block_list *bl); +extern const short dirx[8]; +extern const short diry[8]; -int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int tick,int sdelay,int ddelay,int64 damage,int div,int type,int64 damage2); -// その他 -struct unit_data* unit_bl2ud(struct block_list *bl); -struct unit_data* unit_bl2ud2(struct block_list *bl); -void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype); -void unit_free_pc(struct map_session_data *sd); -#define unit_remove_map(bl,clrtype) unit_remove_map_(bl,clrtype,__FILE__,__LINE__,__func__) -int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func); -int unit_free(struct block_list *bl, clr_type clrtype); -int unit_changeviewsize(struct block_list *bl,short size); +struct unit_interface { + int (*init) (void); + int (*final) (void); + /* */ + struct unit_data* (*bl2ud) (struct block_list *bl); + struct unit_data* (*bl2ud2) (struct block_list *bl); + int (*attack_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*walktoxy_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*walktoxy_sub) (struct block_list *bl); + int (*delay_walktoxy_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*walktoxy) (struct block_list *bl, short x, short y, int flag); + int (*walktobl_sub) (int tid, unsigned int tick, int id, intptr_t data); + int (*walktobl) (struct block_list *bl, struct block_list *tbl, int range, int flag); + int (*run) (struct block_list *bl); + int (*wugdash) (struct block_list *bl, struct map_session_data *sd); + int (*escape) (struct block_list *bl, struct block_list *target, short dist); + int (*movepos) (struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath); + int (*setdir) (struct block_list *bl, unsigned char dir); + uint8 (*getdir) (struct block_list *bl); + int (*blown) (struct block_list *bl, int dx, int dy, int count, int flag); + int (*warp) (struct block_list *bl, short m, short x, short y, clr_type type); + int (*stop_walking) (struct block_list *bl, int type); + int (*skilluse_id) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv); + int (*is_walking) (struct block_list *bl); + int (*can_move) (struct block_list *bl); + int (*resume_running) (int tid, unsigned int tick, int id, intptr_t data); + int (*set_walkdelay) (struct block_list *bl, unsigned int tick, int delay, int type); + int (*skilluse_id2) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); + int (*skilluse_pos) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv); + int (*skilluse_pos2) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); + int (*set_target) (struct unit_data *ud, int target_id); + int (*stop_attack) (struct block_list *bl); + int (*unattackable) (struct block_list *bl); + int (*attack) (struct block_list *src, int target_id, int continuous); + int (*cancel_combo) (struct block_list *bl); + bool (*can_reach_pos) (struct block_list *bl, int x, int y, int easy); + bool (*can_reach_bl) (struct block_list *bl, struct block_list *tbl, int range, int easy, short *x, short *y); + int (*calc_pos) (struct block_list *bl, int tx, int ty, uint8 dir); + int (*attack_timer_sub) (struct block_list *src, int tid, unsigned int tick); + int (*skillcastcancel) (struct block_list *bl, int type); + void (*dataset) (struct block_list *bl); + int (*counttargeted) (struct block_list *bl); + int (*fixdamage) (struct block_list *src, struct block_list *target, unsigned int tick, int sdelay, int ddelay, int64 damage, int div, int type, int64 damage2); + int (*changeviewsize) (struct block_list *bl, short size); + int (*remove_map) (struct block_list *bl, clr_type clrtype, const char *file, int line, const char *func); + void (*remove_map_pc) (struct map_session_data *sd, clr_type clrtype); + void (*free_pc) (struct map_session_data *sd); + int (*free) (struct block_list *bl, clr_type clrtype); +}; -// 初期化ルーチン -int do_init_unit(void); -int do_final_unit(void); -/** - * Ranger - **/ -int unit_wugdash(struct block_list *bl, struct map_session_data *sd); +struct unit_interface *unit; -extern const short dirx[8]; -extern const short diry[8]; +void unit_defaults(void); #endif /* _UNIT_H_ */ |