更新战斗函数
This commit is contained in:
parent
fa63fe18fb
commit
d9a5f79f7a
@ -196,6 +196,11 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
"_data": "百分数,如10为10%法抗,怪物受到勇士的法术伤害减免比例"
|
"_data": "百分数,如10为10%法抗,怪物受到勇士的法术伤害减免比例"
|
||||||
|
|
||||||
},
|
},
|
||||||
|
"spell": {
|
||||||
|
"_leaf": true,
|
||||||
|
"_type": "textarea",
|
||||||
|
"_data": "法强"
|
||||||
|
},
|
||||||
"speed": {
|
"speed": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
|
@ -335,7 +335,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
// 获得金币
|
// 获得金币
|
||||||
var money = guards.reduce(function (curr, g) {
|
var money = guards.reduce(function (curr, g) {
|
||||||
return curr + core.material.enemys[g[2]].money;
|
return curr + core.material.enemys[g[2]].money;
|
||||||
}, core.getEnemyValue(enemy, "money", x, y));
|
}, core.getEnemyInfo(enemy, null, x, y).money);
|
||||||
if (core.hasItem("coin")) money *= 2; // 幸运金币:双倍
|
if (core.hasItem("coin")) money *= 2; // 幸运金币:双倍
|
||||||
if (core.hasFlag("curse")) money = 0; // 诅咒效果
|
if (core.hasFlag("curse")) money = 0; // 诅咒效果
|
||||||
core.status.hero.money += money;
|
core.status.hero.money += money;
|
||||||
@ -344,7 +344,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
// 获得经验
|
// 获得经验
|
||||||
var exp = guards.reduce(function (curr, g) {
|
var exp = guards.reduce(function (curr, g) {
|
||||||
return curr + core.material.enemys[g[2]].exp;
|
return curr + core.material.enemys[g[2]].exp;
|
||||||
}, core.getEnemyValue(enemy, "exp", x, y));
|
}, core.getEnemyInfo(enemy, null, x, y).exp);
|
||||||
if (core.hasFlag("curse")) exp = 0;
|
if (core.hasFlag("curse")) exp = 0;
|
||||||
core.status.hero.exp += exp;
|
core.status.hero.exp += exp;
|
||||||
core.status.hero.statistics.exp += exp;
|
core.status.hero.statistics.exp += exp;
|
||||||
@ -530,9 +530,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
// 第五项为该特殊属性的标记;目前 1 代表是地图类技能(需要进行遍历全图)
|
// 第五项为该特殊属性的标记;目前 1 代表是地图类技能(需要进行遍历全图)
|
||||||
// 名字和描述可以直接写字符串,也可以写个function将怪物传进去
|
// 名字和描述可以直接写字符串,也可以写个function将怪物传进去
|
||||||
return [
|
return [
|
||||||
[1, "先攻", "怪物首先攻击", "#ffcc33"],
|
[1, "先攻", "怪物首先攻击", "#ffcc33"], //√
|
||||||
[2, "魔攻", "怪物无视角色的防御", "#bbb0ff"],
|
//[2, "魔攻", "怪物无视角色的防御", "#bbb0ff"],
|
||||||
[3, "坚固", "怪物防御不小于角色攻击-1", "#c0b088"],
|
[3, "坚固", "怪物防御不小于角色攻击-1", "#c0b088"], //√
|
||||||
[
|
[
|
||||||
6,
|
6,
|
||||||
function (enemy) {
|
function (enemy) {
|
||||||
@ -542,21 +542,21 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
return "怪物每回合攻击" + (enemy.n || 4) + "次";
|
return "怪物每回合攻击" + (enemy.n || 4) + "次";
|
||||||
},
|
},
|
||||||
"#ffee77",
|
"#ffee77",
|
||||||
],
|
], //想改成“以XX%、XX%攻击力各攻击一次”
|
||||||
[
|
[
|
||||||
7,
|
7,
|
||||||
"破甲",
|
"破甲",
|
||||||
function (enemy) {
|
function (enemy) {
|
||||||
return (
|
return (
|
||||||
"战斗前,怪物附加角色防御的" +
|
"怪物无视角色防御的" +
|
||||||
Math.floor(
|
Math.floor(
|
||||||
100 * (enemy.breakArmor || core.values.breakArmor || 0)
|
100 * (enemy.breakArmor || core.values.breakArmor || 0)
|
||||||
) +
|
) +
|
||||||
"%作为伤害"
|
"%"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
"#88c0ff",
|
"#88c0ff",
|
||||||
],
|
], //√
|
||||||
[
|
[
|
||||||
8,
|
8,
|
||||||
"反击",
|
"反击",
|
||||||
@ -761,15 +761,15 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
var mon_hp = core.getEnemyValue(enemy, "hp", x, y, floorId),
|
var mon_hp = core.getEnemyValue(enemy, "hp", x, y, floorId),
|
||||||
mon_atk = core.getEnemyValue(enemy, "atk", x, y, floorId),
|
mon_atk = core.getEnemyValue(enemy, "atk", x, y, floorId),
|
||||||
mon_def = core.getEnemyValue(enemy, "def", x, y, floorId),
|
mon_def = core.getEnemyValue(enemy, "def", x, y, floorId),
|
||||||
mon_mdef = core.getEnemyValue(enemy, "mdef", x, y, floorId),
|
mon_mdef = core.getEnemyValue(enemy, "mdef", x, y, floorId) || 0,
|
||||||
mon_speed = core.getEnemyValue(enemy, "speed", x, y, floorId),
|
mon_spell = core.getEnemyValue(enemy, "spell", x, y, floorId) || 0,
|
||||||
|
mon_speed = core.getEnemyValue(enemy, "speed", x, y, floorId) || 1,
|
||||||
mon_special = core.getEnemyValue(enemy, "special", x, y, floorId);
|
mon_special = core.getEnemyValue(enemy, "special", x, y, floorId);
|
||||||
var mon_money = core.getEnemyValue(enemy, "money", x, y, floorId),
|
var mon_money = core.getEnemyValue(enemy, "money", x, y, floorId),
|
||||||
mon_exp = core.getEnemyValue(enemy, "exp", x, y, floorId),
|
mon_exp = core.getEnemyValue(enemy, "exp", x, y, floorId),
|
||||||
mon_point = core.getEnemyValue(enemy, "point", x, y, floorId);
|
mon_point = core.getEnemyValue(enemy, "point", x, y, floorId);
|
||||||
var mon_barrier = 0,
|
var mon_barrier = 0,
|
||||||
mon_absorb_damage = 0,
|
mon_absorb_damage = 0;
|
||||||
mon_magic = core.getEnemyValue(enemy, "magic", x, y, floorId);
|
|
||||||
// 模仿
|
// 模仿
|
||||||
if (core.hasSpecial(mon_special, 10)) {
|
if (core.hasSpecial(mon_special, 10)) {
|
||||||
mon_atk = hero_atk;
|
mon_atk = hero_atk;
|
||||||
@ -881,6 +881,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
atk: Math.floor(mon_atk),
|
atk: Math.floor(mon_atk),
|
||||||
def: Math.floor(mon_def),
|
def: Math.floor(mon_def),
|
||||||
mdef: Math.floor(mon_mdef),
|
mdef: Math.floor(mon_mdef),
|
||||||
|
spell: Math.floor(mon_spell),
|
||||||
speed: Math.floor(mon_speed),
|
speed: Math.floor(mon_speed),
|
||||||
barrier: Math.floor(mon_barrier),
|
barrier: Math.floor(mon_barrier),
|
||||||
absorb: Math.floor(mon_absorb_damage),
|
absorb: Math.floor(mon_absorb_damage),
|
||||||
@ -888,7 +889,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
exp: Math.floor(mon_exp),
|
exp: Math.floor(mon_exp),
|
||||||
point: Math.floor(mon_point),
|
point: Math.floor(mon_point),
|
||||||
special: mon_special,
|
special: mon_special,
|
||||||
magic: mon_magic,
|
|
||||||
guards: guards, // 返回支援情况
|
guards: guards, // 返回支援情况
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -922,6 +922,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
mon_atk = enemyInfo.atk,
|
mon_atk = enemyInfo.atk,
|
||||||
mon_def = enemyInfo.def,
|
mon_def = enemyInfo.def,
|
||||||
mon_mdef = enemyInfo.mdef,
|
mon_mdef = enemyInfo.mdef,
|
||||||
|
mon_spell = enemyInfo.spell,
|
||||||
mon_speed = enemyInfo.speed,
|
mon_speed = enemyInfo.speed,
|
||||||
mon_special = enemyInfo.special,
|
mon_special = enemyInfo.special,
|
||||||
mon_absorb_damage = enemyInfo.absorb,
|
mon_absorb_damage = enemyInfo.absorb,
|
||||||
@ -934,6 +935,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
// 开启了技能1:二倍斩
|
// 开启了技能1:二倍斩
|
||||||
hero_atk *= 2; // 计算时攻击力翻倍
|
hero_atk *= 2; // 计算时攻击力翻倍
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 破甲
|
||||||
|
if (core.hasSpecial(mon_special, 7))
|
||||||
|
hero_def -= Math.floor(
|
||||||
|
(enemy.breakArmor || core.values.breakArmor) * hero_def
|
||||||
|
);
|
||||||
|
|
||||||
//勇士属性取整
|
//勇士属性取整
|
||||||
hero_atk = Math.max(0, Math.floor(hero_atk));
|
hero_atk = Math.max(0, Math.floor(hero_atk));
|
||||||
hero_def = Math.max(0, Math.floor(hero_def));
|
hero_def = Math.max(0, Math.floor(hero_def));
|
||||||
@ -970,10 +978,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
//——第二部分:变量定义和初始赋值——
|
//——第二部分:变量定义和初始赋值——
|
||||||
// 每回合怪物对勇士造成的战斗伤害
|
// 每回合怪物对勇士造成的战斗伤害
|
||||||
let per_damage = Math.max(mon_atk - hero_def, 0),
|
let per_damage = Math.max(mon_atk - hero_def, 0),
|
||||||
per_mdamage = 0;
|
per_mdamage = Math.floor(mon_spell * (100 - hero_mdef) / 100);
|
||||||
if (core.hasSpecial(mon_special, 2)) {
|
|
||||||
per_mdamage = Math.floor(mon_atk * (100 - hero_mdef) / 100);
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
let hero_per_damage = Math.max(hero_atk - mon_def, 0),
|
let hero_per_damage = Math.max(hero_atk - mon_def, 0),
|
||||||
|
|
||||||
@ -988,41 +993,48 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
let heroDiffPerTurn = [],
|
let heroDiffPerTurn = [],
|
||||||
enemyDiffPerTurn = [];
|
enemyDiffPerTurn = [];
|
||||||
|
|
||||||
for (
|
let now_mon_hp = mon_hp,
|
||||||
let now_mon_hp = mon_hp,
|
last_mon_hp = mon_hp,
|
||||||
last_mon_hp = mon_hp,
|
mon_length = length,
|
||||||
mon_length = length,
|
hero_length = 0,
|
||||||
hero_length = length,
|
mon_time = 0,
|
||||||
mon_time = 0,
|
hero_time = 0;
|
||||||
hero_time = 0; now_mon_hp > 0;
|
//先攻,先攻为怪物和勇士同时出第一刀
|
||||||
|
if (core.hasSpecial(mon_special, 1)) mon_length = 0;
|
||||||
|
while (
|
||||||
|
now_mon_hp > 0
|
||||||
|
|
||||||
) {
|
) {
|
||||||
//勇士和怪物的长度。这里需要把if else改成轮次的if和math.min
|
//勇士和怪物的长度
|
||||||
mon_time = mon_length / mon_speed;
|
mon_time = mon_length / mon_speed;
|
||||||
hero_time = hero_length / hero_speed;
|
hero_time = hero_length / hero_speed;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
mon_time < hero_time ||
|
mon_time == Math.min(mon_time, hero_time)
|
||||||
((mon_time == hero_time) && mon_speed > hero_speed)
|
|
||||||
) {
|
) {
|
||||||
//怪物攻击的回合
|
//怪物攻击的回合
|
||||||
//这里计算怪物攻击时发生的各种变化
|
//这里计算怪物攻击时发生的各种变化
|
||||||
|
|
||||||
//伤害与回合增加
|
//伤害与回合增加
|
||||||
damage += per_damage;
|
|
||||||
|
//N连击,待定,想做成“以x%、y%……攻击力各攻击一次”的形式
|
||||||
if (core.hasSpecial(mon_special, 6)) {
|
if (core.hasSpecial(mon_special, 6)) {
|
||||||
|
damage += per_damage * enemy.n;
|
||||||
mon_turn += enemy.n;
|
mon_turn += enemy.n;
|
||||||
} else {
|
} else {
|
||||||
|
damage += per_damage;
|
||||||
mon_turn += 1;
|
mon_turn += 1;
|
||||||
}
|
}
|
||||||
|
damage += per_mdamage;
|
||||||
//重新为长度赋值
|
//重新为长度赋值
|
||||||
mon_length = length;
|
mon_length = length;
|
||||||
hero_length = hero_length - mon_time * hero_speed;
|
hero_length = hero_length - mon_time * hero_speed;
|
||||||
} else {
|
} else if (hero_time == Math.min(mon_time, hero_time)) {
|
||||||
//勇士攻击的回合
|
//勇士攻击的回合
|
||||||
// 这里计算勇士攻击时发生的各种变化
|
// 这里计算勇士攻击时发生的各种变化
|
||||||
|
|
||||||
// 伤害与回合数增加
|
// 伤害与回合数增加
|
||||||
now_mon_hp -= hero_per_damage;
|
now_mon_hp -= hero_per_damage + hero_per_mdamage;
|
||||||
hero_turn += 1; //勇士回合+1,如果有勇士每回合多次攻击的情况,在这里写判断
|
hero_turn += 1; //勇士回合+1,如果有勇士每回合多次攻击的情况,在这里写判断
|
||||||
// 无法战斗计算
|
// 无法战斗计算
|
||||||
if (hero_turn % 50 == 0) {
|
if (hero_turn % 50 == 0) {
|
||||||
@ -1033,6 +1045,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
hero_length = length;
|
hero_length = length;
|
||||||
mon_length = mon_length - hero_time * mon_speed;
|
mon_length = mon_length - hero_time * mon_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
let hero_diff = {},
|
let hero_diff = {},
|
||||||
mon_diff = {};
|
mon_diff = {};
|
||||||
//这里插入汇总勇士和怪物在此回合结束时的情况变化(hp, atk, def, speed, spell, damage, etc),用以跑条动画读取
|
//这里插入汇总勇士和怪物在此回合结束时的情况变化(hp, atk, def, speed, spell, damage, etc),用以跑条动画读取
|
||||||
@ -1041,8 +1054,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
}
|
}
|
||||||
|
|
||||||
//下面这些还没修改
|
//下面这些还没修改
|
||||||
// 连击
|
|
||||||
if (core.hasSpecial(mon_special, 6)) per_damage *= enemy.n || 2;
|
|
||||||
|
|
||||||
// 每回合的反击伤害;反击是按照勇士的攻击次数来计算回合
|
// 每回合的反击伤害;反击是按照勇士的攻击次数来计算回合
|
||||||
let counterDamage = 0;
|
let counterDamage = 0;
|
||||||
@ -1051,14 +1062,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
(enemy.counterAttack || core.values.counterAttack) * hero_atk
|
(enemy.counterAttack || core.values.counterAttack) * hero_atk
|
||||||
);
|
);
|
||||||
|
|
||||||
// 先攻
|
|
||||||
if (core.hasSpecial(mon_special, 1)) init_damage += per_damage;
|
|
||||||
|
|
||||||
// 破甲
|
|
||||||
if (core.hasSpecial(mon_special, 7))
|
|
||||||
init_damage += Math.floor(
|
|
||||||
(enemy.breakArmor || core.values.breakArmor) * hero_def
|
|
||||||
);
|
|
||||||
|
|
||||||
// 净化
|
// 净化
|
||||||
if (core.hasSpecial(mon_special, 9))
|
if (core.hasSpecial(mon_special, 9))
|
||||||
@ -1117,7 +1121,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
}
|
}
|
||||||
if (core.hasSpecial(mon_special, 22)) {
|
if (core.hasSpecial(mon_special, 22)) {
|
||||||
// 固伤
|
// 固伤
|
||||||
damage += enemy.damage || 0;
|
damage += enemy.damage2 || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user