"use strict"; function enemys() { this.init(); } ////// 初始化 ////// enemys.prototype.init = function () { this.enemys = enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80; this.enemydata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.enemys; if (main.mode=='play') this.enemydata.hasSpecial = function (a, b) {return core.enemys.hasSpecial(a, b)}; } ////// 获得一个或所有怪物数据 ////// enemys.prototype.getEnemys = function (enemyId) { if (!core.isset(enemyId)) { return this.enemys; } return this.enemys[enemyId]; } ////// 判断是否含有某特殊属性 ////// enemys.prototype.hasSpecial = function (special, test) { if (!core.isset(special)) return false; if (special instanceof Array) { return special.indexOf(test)>=0; } if (typeof special == 'number') { return special!=0 && (special%100==test||this.hasSpecial(parseInt(special/100), test)); } if (typeof special == 'string') { return this.hasSpecial(core.material.enemys[special], test); } if (core.isset(special.special)) { return this.hasSpecial(special.special, test); } return false; } enemys.prototype.getSpecials = function () { return this.enemydata.getSpecials(); } enemys.prototype.calContent = function (enemy, content) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; if (typeof content == 'string') return content; if (content instanceof Function) { return content(enemy); } return ""; } ////// 获得所有特殊属性的名称 ////// enemys.prototype.getSpecialText = function (enemy) { // 移动到了脚本编辑 - getSpecials中 if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; if (!core.isset(enemy)) return []; var special = enemy.special; var text = []; var specials=this.getSpecials(); if (core.isset(specials)) { for (var i=0;i=1;t--) { var nextAtk = Math.ceil(mon_hp/t) + mon_def; // 装备提升比例的计算临界 nextAtk = Math.ceil(nextAtk / core.getFlag('equip_atk_buff', 1)); if (nextAtk<=hero_atk) break; if (nextAtk!=pre) { var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, nextAtk, core.status.hero.def, core.status.hero.mdef, x, y, floorId); if (nextInfo==null) break; list.push([nextAtk-hero_atk,Math.floor(info.damage-nextInfo.damage)]); if (nextInfo.damage<=0 && !core.flags.enableNegativeDamage) break; pre = nextAtk; } if (list.length>=number) break; } } else { // 暴力for循环法 pre = info.damage; var per_add = Math.ceil(hero_atk / 5000); if (per_add<0) per_add = 1; for (var atk=hero_atk+per_add;atk<=mon_hp+mon_def;atk+=per_add) { var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId); if (nextInfo==null) break; if (pre>nextInfo.damage) { pre = nextInfo.damage; list.push([atk-hero_atk, Math.floor(info.damage-nextInfo.damage)]); if (nextInfo.damage<=0 && !core.flags.enableNegativeDamage) break; if (list.length>=number) break; } } } if (list.length==0) list.push([0,0]); return list; } ////// N防减伤计算 ////// enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; k = k || 1; var nowDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId); var nextDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def + k, core.status.hero.mdef, x, y, floorId); if (nowDamage == null || nextDamage ==null) return "???"; return nowDamage - nextDamage; } enemys.prototype.getEnemyInfo = function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; return this.enemydata.getEnemyInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) } ////// 获得战斗伤害信息(实际伤害计算函数) ////// enemys.prototype.getDamageInfo = function(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) { // 移动到了脚本编辑 - getDamageInfo中 if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; return this.enemydata.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId); } ////// 获得在某个勇士属性下怪物伤害 ////// enemys.prototype.calDamage = function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) { if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; var info = this.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId); if (info == null) return null; return info.damage; } ////// 更新怪物数据 ////// enemys.prototype.updateEnemys = function () { return this.enemydata.updateEnemys(); } ////// 获得当前楼层的怪物列表 ////// enemys.prototype.getCurrentEnemys = function (floorId) { floorId=floorId||core.status.floorId; var enemys = []; var used = {}; var mapBlocks = core.status.maps[floorId].blocks; for (var b = 0; b < mapBlocks.length; b++) { if (core.isset(mapBlocks[b].event) && !mapBlocks[b].disable && mapBlocks[b].event.cls.indexOf('enemy')==0) { var enemyId = mapBlocks[b].event.id; var enemy = core.material.enemys[enemyId]; if (!core.isset(enemy)) continue; // 检查displayIdInBook var tmpId = enemy.displayIdInBook; if (core.isset(core.material.enemys[tmpId])) { enemyId = tmpId; enemy = core.material.enemys[tmpId]; } if (core.isset(used[enemyId])) continue; var mon_hp = enemy.hp, mon_atk = enemy.atk, mon_def = enemy.def; var hero_atk = core.status.hero.atk, hero_def = core.status.hero.def, hero_mdef = core.status.hero.mdef; hero_atk = Math.floor(core.getFlag('equip_atk_buff',1)*hero_atk); hero_def = Math.floor(core.getFlag('equip_def_buff',1)*hero_def); hero_mdef = Math.floor(core.getFlag('equip_mdef_buff',1)*hero_mdef); var enemyInfo = this.getEnemyInfo(enemy, core.status.hero.hp, hero_atk, hero_def, hero_mdef, null, null, floorId); var specialText = core.enemys.getSpecialText(enemyId); if (specialText.length>=3) specialText = "多属性..."; else specialText = specialText.join(" "); var critical = this.nextCriticals(enemyId); if (critical.length>0) critical=critical[0]; var e = core.clone(enemy); for (var x in enemyInfo) { e[x] = enemyInfo[x]; } e.id = enemyId; e.specialText = specialText; e.damage = this.getDamage(enemyId, null, null, floorId); e.critical = critical[0]; e.criticalDamage = critical[1]; e.defDamage = this.getDefDamage(enemyId,1,null,null,floorId); enemys.push(e); used[enemyId] = true; } } enemys.sort(function (a, b) { if (a.damage == b.damage) { return a.money - b.money; } if (a.damage == null) { return 1; } if (b.damage == null) { return -1; } return a.damage - b.damage; }); return enemys; }