getEnemyInfo & Aura

This commit is contained in:
oc committed 2018-10-11 16:53:39 +08:00
1 parent 3d17624898
commit 41d9c5a298
11 files changed
+186 -87

No files matched your search

+8 -4
View File
@@ -1030,14 +1030,14 @@ actions.prototype.clickViewMaps = function (x,y) {
return;
}
if(x>=2 && x<=10 && y<=4) {
if(y<=4 && (mh==13 || (x>=2 && x<=10))) {
index++;
while (index<core.floorIds.length && index!=now && core.floors[core.floorIds[index]].cannotViewMap)
index++;
if (index<core.floorIds.length)
core.ui.drawMaps(index);
}
else if (x>=2 && x<=10 && y>=8) {
else if (y>=8 && (mh==13 || (x>=2 && x<=10))) {
index--;
while (index>=0 && index!=now && core.floors[core.floorIds[index]].cannotViewMap)
index--;
@@ -2067,6 +2067,10 @@ actions.prototype.clickSyncSave = function (x,y) {
});
break;
case 4:
core.status.event.selection=0;
core.ui.drawReplay();
break;
case 5:
if (core.hasFlag('debug')) {
core.drawText("\t[系统提示]调试模式下无法下载录像");
break;
@@ -2078,11 +2082,11 @@ actions.prototype.clickSyncSave = function (x,y) {
'route': core.encodeRoute(core.status.route)
}));
break;
case 5:
case 6:
core.status.event.selection=0;
core.ui.drawStorageRemove();
break;
case 6:
case 7:
core.status.event.selection=3;
core.ui.drawSettings();
break;
+2 -2
View File
@@ -1280,7 +1280,7 @@ control.prototype.snipe = function (snipes) {
snipe.blockImage = core.material.images[cls];
snipe.height = height;
var damage = core.enemys.getDamage(block.event.id);
var damage = core.enemys.getDamage(block.event.id, x, y);
var color = '#000000';
if (damage == null) {
@@ -1514,7 +1514,7 @@ control.prototype.updateDamage = function () {
var id = mapBlocks[b].event.id;
if (core.flags.displayEnemyDamage) {
var damage = core.enemys.getDamage(id);
var damage = core.enemys.getDamage(id, x, y);
var color = '#000000';
if (damage == null) {
+16 -12
View File
@@ -232,19 +232,23 @@ core.prototype.init = function (coreData, callback) {
core.platform.isQQ = /QQ/i.test(navigator.userAgent);
core.platform.isWeChat = /MicroMessenger/i.test(navigator.userAgent);
core.platform.useLocalForage = core.getLocalStorage('useLocalForage', true);
if (core.platform.isIOS) core.platform.useLocalForage=false;
if (core.platform.useLocalForage) {
try {
core.setLocalForage("__test__", "__test__", function() {
core.setLocalForage("__test__", LZString.compress("__test__"), function() {
try {
core.getLocalForage("__test__", null, function(data) {
if (data!="__test__") {
console.log("localForage unsupported!");
core.platform.useLocalForage=false;
}
else {
console.log("localForage supported!")
core.removeLocalForage("__test__");
try {
if (LZString.decompress(data)!="__test__") {
console.log("localForage unsupported!");
core.platform.useLocalForage=false;
}
else {
console.log("localForage supported!")
core.removeLocalForage("__test__");
}
}
catch (e) {console.log(e); core.platform.useLocalForage=false;}
}, function(e) {console.log(e); core.platform.useLocalForage=false;})
}
catch (e) {console.log(e); core.platform.useLocalForage=false;}
@@ -821,13 +825,13 @@ core.prototype.hasSpecial = function (special, test) {
}
////// 判断能否战斗 //////
core.prototype.canBattle = function(enemyId) {
return core.enemys.canBattle(enemyId);
core.prototype.canBattle = function(enemyId, x, y, floorId) {
return core.enemys.canBattle(enemyId, x, y, floorId);
}
////// 获得伤害数值 //////
core.prototype.getDamage = function(enemy) {
return core.enemys.getDamage(enemy);
core.prototype.getDamage = function(enemy, x, y, floorId) {
return core.enemys.getDamage(enemy, x, y, floorId);
}
////// 获得某个物品的个数 //////
+29 -29
View File
@@ -99,15 +99,15 @@ enemys.prototype.getSpecialHint = function (enemy, special) {
}
////// 能否获胜 //////
enemys.prototype.canBattle = function (enemyId) {
var damage = this.getDamage(enemyId);
enemys.prototype.canBattle = function (enemyId, x, y, floorId) {
var damage = this.getDamage(enemyId, x, y, floorId);
return damage != null && damage < core.status.hero.hp;
}
////// 获得某个怪物的伤害 //////
enemys.prototype.getDamage = function (enemy) {
enemys.prototype.getDamage = function (enemy, x, y, floorId) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
var damage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
var damage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId);
if (damage == null) return null;
return damage + this.getExtraDamage(enemy);
}
@@ -126,7 +126,7 @@ enemys.prototype.getExtraDamage = function (enemy) {
}
////// 接下来N个临界值和临界减伤计算 //////
enemys.prototype.nextCriticals = function (enemy, number) {
enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
var useTurn = !core.flags.useLoop;
@@ -142,7 +142,7 @@ enemys.prototype.nextCriticals = function (enemy, number) {
// 坚固、模仿怪物没有临界!
if (this.hasSpecial(enemy.special, 10)) return [];
var info = this.getDamageInfo(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
var info = this.getDamageInfo(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId);
if (info == null) {
if (core.status.hero.atk<=enemy.def) {
@@ -167,7 +167,7 @@ enemys.prototype.nextCriticals = function (enemy, number) {
}
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);
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,info.damage-nextInfo.damage]);
if (nextInfo.damage<=0 && !core.flags.enableNegativeDamage) break;
@@ -180,7 +180,7 @@ enemys.prototype.nextCriticals = function (enemy, number) {
else { // 暴力for循环法
pre = info.damage;
for (var atk=hero_atk+1;atk<=mon_hp+mon_def;atk++) {
var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, atk, core.status.hero.def, core.status.hero.mdef);
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;
@@ -195,27 +195,32 @@ enemys.prototype.nextCriticals = function (enemy, number) {
}
////// N防减伤计算 //////
enemys.prototype.getDefDamage = function (enemy, k) {
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);
var nextDamage = this.calDamage(enemy, core.status.hero.hp, core.status.hero.atk, core.status.hero.def + k, core.status.hero.mdef);
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) {
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);
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) {
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);
var info = this.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId);
if (info == null) return null;
return info.damage;
}
@@ -246,12 +251,7 @@ enemys.prototype.getCurrentEnemys = function (floorId) {
hero_def = Math.floor(core.getFlag('equip_def_buff',1)*hero_def);
hero_mdef = Math.floor(core.getFlag('equip_mdef_buff',1)*hero_mdef);
}
if (this.hasSpecial(enemy.special, 10)) {
mon_atk=hero_atk;
mon_def=hero_def;
}
if (this.hasSpecial(enemy.special, 3) && mon_def < hero_atk - 1)
mon_def = hero_atk - 1;
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 = "多属性...";
@@ -263,17 +263,17 @@ enemys.prototype.getCurrentEnemys = function (floorId) {
enemys.push({
'id': enemyId,
'name': enemy.name,
'hp': mon_hp,
'atk': mon_atk,
'def': mon_def,
'money': enemy.money,
'experience': enemy.experience,
'point': enemy.point||0, // 加点
'hp': enemyInfo.hp,
'atk': enemyInfo.atk,
'def': enemyInfo.def,
'money': enemyInfo.money||0,
'experience': enemyInfo.experience||0,
'point': enemyInfo.point||0, // 加点
'special': specialText,
'damage': this.getDamage(enemyId),
'damage': this.getDamage(enemyId,null,null,floorId),
'critical': critical[0],
'criticalDamage': critical[1],
'defDamage': this.getDefDamage(enemyId)
'defDamage': this.getDefDamage(enemyId,1,null,null,floorId)
});
used[enemyId] = true;
+1 -1
View File
@@ -1120,7 +1120,7 @@ events.prototype.battle = function (id, x, y, force, callback) {
core.stopAutomaticRoute();
// 非强制战斗
if (!core.enemys.canBattle(id) && !force && !core.isset(core.status.event.id)) {
if (!core.enemys.canBattle(id, x, y) && !force && !core.isset(core.status.event.id)) {
core.drawTip("你打不过此怪物!");
core.clearContinueAutomaticRoute();
return;
+17 -14
View File
@@ -862,8 +862,11 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
var hero_hp = core.getStatus('hp'), hero_atk = core.getStatus('atk'), hero_def = core.getStatus('def'),
hero_mdef = core.getStatus('mdef');
var monster = core.material.enemys[monsterId];
var mon_hp = monster.hp, mon_atk = monster.atk, mon_def = monster.def, mon_money=monster.money, mon_exp = monster.experience, mon_special=monster.special;
hero_hp=Math.max(0, hero_hp);
hero_atk=Math.max(0, hero_atk);
hero_def=Math.max(0, hero_def);
hero_mdef=Math.max(0, hero_mdef);
if (core.flags.equipPercentage) {
hero_atk = Math.floor(core.getFlag('equip_atk_buff',1)*hero_atk);
@@ -871,30 +874,30 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
hero_mdef = Math.floor(core.getFlag('equip_mdef_buff',1)*hero_mdef);
}
var enemy = core.material.enemys[monsterId];
var enemyInfo = core.enemys.getEnemyInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef);
var mon_hp = enemyInfo.hp, mon_atk = enemyInfo.atk, mon_def = enemyInfo.def, mon_money=enemyInfo.money,
mon_exp = enemyInfo.experience, mon_special=enemyInfo.special;
var initDamage = 0; // 战前伤害
// 吸血
if (core.enemys.hasSpecial(mon_special, 11)) {
var vampireDamage = hero_hp * monster.value;
var vampireDamage = hero_hp * enemy.value;
// 如果有神圣盾免疫吸血等可以在这里写
vampireDamage = Math.floor(vampireDamage);
vampireDamage = Math.floor(vampireDamage) || 0;
// 加到自身
if (monster.add) // 如果加到自身
if (enemy.add) // 如果加到自身
mon_hp += vampireDamage;
initDamage += vampireDamage;
}
hero_hp -= core.enemys.getExtraDamage(monster);
hero_hp -= core.enemys.getExtraDamage(enemy);
if (core.enemys.hasSpecial(mon_special, 10)) { // 模仿
mon_atk=hero_atk;
mon_def=hero_def;
}
if (core.enemys.hasSpecial(mon_special, 2)) hero_def=0; // 魔攻
if (core.enemys.hasSpecial(mon_special, 3) && mon_def<hero_atk) mon_def=hero_atk-1; // 坚固
// 实际操作
var turn = 0; // 0为勇士攻击
@@ -904,7 +907,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
var turns = 2;
if (core.enemys.hasSpecial(mon_special, 4)) turns=3;
if (core.enemys.hasSpecial(mon_special, 5)) turns=4;
if (core.enemys.hasSpecial(mon_special, 6)) turns=1+(monster.n||4);
if (core.enemys.hasSpecial(mon_special, 6)) turns=1+(enemy.n||4);
// 初始伤害
if (core.enemys.hasSpecial(mon_special, 7)) initDamage+=Math.floor(core.values.breakArmor * hero_def);
@@ -1158,7 +1161,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
return;
}
}, 500);
}, 400);
}
////// 绘制等待界面 //////
@@ -1192,7 +1195,7 @@ ui.prototype.drawSyncSave = function () {
core.status.event.id = 'syncSave';
this.drawChoices(null, [
"同步存档到服务器", "从服务器加载存档", "存档至本地文件", "从本地文件读档", "下载当前录像", "清空本地存档", "返回主菜单"
"同步存档到服务器", "从服务器加载存档", "存档至本地文件", "从本地文件读档", "回放当前录像", "下载当前录像", "清空本地存档", "返回主菜单"
]);
}