修改战斗函数
This commit is contained in:
parent
25fb914841
commit
dbb1d76c54
@ -892,171 +892,179 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
"getDamageInfo": function (enemy, hero, x, y, floorId) {
|
"getDamageInfo": function (enemy, hero, x, y, floorId) {
|
||||||
// 获得战斗伤害信息(实际伤害计算函数)
|
// 获得战斗伤害信息(实际伤害计算函数)
|
||||||
//
|
//
|
||||||
// 参数说明:
|
// 参数说明:
|
||||||
// enemy:该怪物信息
|
// enemy:该怪物信息
|
||||||
// hero:勇士的当前数据;如果对应项不存在则会从core.status.hero中取。
|
// hero:勇士的当前数据;如果对应项不存在则会从core.status.hero中取。
|
||||||
// x,y:该怪物的坐标(查看手册和强制战斗时为undefined)
|
// x,y:该怪物的坐标(查看手册和强制战斗时为undefined)
|
||||||
// floorId:该怪物所在的楼层
|
// floorId:该怪物所在的楼层
|
||||||
// 后面三个参数主要是可以在光环等效果上可以适用
|
// 后面三个参数主要是可以在光环等效果上可以适用
|
||||||
floorId = floorId || core.status.floorId;
|
floorId = floorId || core.status.floorId;
|
||||||
|
|
||||||
var hero_hp = core.getRealStatusOrDefault(hero, "hp"),
|
var hero_hp = core.getRealStatusOrDefault(hero, "hp"),
|
||||||
hero_atk = core.getRealStatusOrDefault(hero, "atk"),
|
hero_atk = core.getRealStatusOrDefault(hero, "atk"),
|
||||||
hero_def = core.getRealStatusOrDefault(hero, "def"),
|
hero_def = core.getRealStatusOrDefault(hero, "def"),
|
||||||
hero_mdef = core.getRealStatusOrDefault(hero, "mdef"),
|
hero_matk = core.getRealStatusOrDefault(hero, "matk"),
|
||||||
hero_speed = core.getRealStatusOrDefault(hero, "speed"),
|
hero_mdef = core.getRealStatusOrDefault(hero, "mdef"),
|
||||||
hero_magic = core.getRealStatusOrDefault(hero, "magic"),
|
hero_speed = core.getRealStatusOrDefault(hero, "speed"),
|
||||||
origin_hero_hp = core.getStatusOrDefault(hero, "hp"),
|
hero_spell = core.getRealStatusOrDefault(hero, "spell"),
|
||||||
origin_hero_atk = core.getStatusOrDefault(hero, "atk"),
|
origin_hero_hp = core.getStatusOrDefault(hero, "hp"),
|
||||||
origin_hero_def = core.getStatusOrDefault(hero, "def");
|
origin_hero_atk = core.getStatusOrDefault(hero, "atk"),
|
||||||
|
origin_hero_def = core.getStatusOrDefault(hero, "def");
|
||||||
|
|
||||||
// 怪物的各项数据
|
// 怪物的各项数据
|
||||||
// 对坚固模仿等处理扔到了脚本编辑-getEnemyInfo之中
|
// 对坚固模仿等处理扔到了脚本编辑-getEnemyInfo之中
|
||||||
var enemyInfo = core.enemys.getEnemyInfo(enemy, hero, x, y, floorId);
|
var enemyInfo = core.enemys.getEnemyInfo(enemy, hero, x, y, floorId);
|
||||||
var mon_hp = enemyInfo.hp,
|
var mon_hp = enemyInfo.hp,
|
||||||
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_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,
|
||||||
mon_barrier = enemyInfo.barrier;
|
mon_barrier = enemyInfo.barrier;
|
||||||
|
|
||||||
//---第一部分:静态属性修正---
|
//---第一部分:静态属性修正---
|
||||||
//此处写入静态影响勇士属性的勇士或怪物技能(静态影响怪物属性的技能于getEnemyInfo中写入)
|
//此处写入静态影响勇士属性的勇士或怪物技能(静态影响怪物属性的技能于getEnemyInfo中写入)
|
||||||
// 技能的处理
|
// 技能的处理
|
||||||
if (core.getFlag("skill", 0) == 1) {
|
if (core.getFlag("skill", 0) == 1) {
|
||||||
// 开启了技能1:二倍斩
|
// 开启了技能1:二倍斩
|
||||||
hero_atk *= 2; // 计算时攻击力翻倍
|
hero_atk *= 2; // 计算时攻击力翻倍
|
||||||
}
|
}
|
||||||
//勇士属性取整
|
//勇士属性取整
|
||||||
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));
|
||||||
hero_mdef = Math.max(0, Math.floor(hero_mdef));
|
hero_mdef = Math.max(0, Math.floor(hero_mdef));
|
||||||
hero_speed = Math.max(0, Math.floor(hero_speed));
|
hero_speed = Math.max(0, Math.floor(hero_speed));
|
||||||
|
|
||||||
// 如果是无敌属性,且勇士未持有十字架
|
// 如果是无敌属性,且勇士未持有十字架
|
||||||
if (core.hasSpecial(mon_special, 20) && !core.hasItem("cross"))
|
if (core.hasSpecial(mon_special, 20) && !core.hasItem("cross"))
|
||||||
return null; // 不可战斗
|
return null; // 不可战斗
|
||||||
|
|
||||||
// 战前造成的额外伤害(可被护盾抵消)
|
// 战前造成的额外伤害(可被护盾抵消)
|
||||||
let init_damage = 0;
|
let init_damage = 0;
|
||||||
|
|
||||||
// 吸血
|
// 吸血
|
||||||
if (core.hasSpecial(mon_special, 11)) {
|
if (core.hasSpecial(mon_special, 11)) {
|
||||||
let vampire_damage = hero_hp * enemy.vampire;
|
let vampire_damage = hero_hp * enemy.vampire;
|
||||||
|
|
||||||
// 如果有神圣盾免疫吸血等可以在这里写
|
// 如果有神圣盾免疫吸血等可以在这里写
|
||||||
// 也可以用hasItem和hasEquip来判定装备
|
// 也可以用hasItem和hasEquip来判定装备
|
||||||
// if (core.hasFlag('shield5')) vampire_damage = 0;
|
// if (core.hasFlag('shield5')) vampire_damage = 0;
|
||||||
|
|
||||||
vampire_damage = Math.floor(vampire_damage) || 0;
|
vampire_damage = Math.floor(vampire_damage) || 0;
|
||||||
// 加到自身
|
// 加到自身
|
||||||
if (enemy.add)
|
if (enemy.add)
|
||||||
// 如果加到自身
|
// 如果加到自身
|
||||||
mon_hp += vampire_damage;
|
mon_hp += vampire_damage;
|
||||||
|
|
||||||
init_damage += vampire_damage;
|
init_damage += vampire_damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
//——第二部分:变量定义和初始赋值——
|
//——第二部分:变量定义和初始赋值——
|
||||||
// 每回合怪物对勇士造成的战斗伤害
|
// 每回合怪物对勇士造成的战斗伤害
|
||||||
let per_damage = Math.max(mon_atk - hero_def, 0);
|
let per_damage = Math.max(mon_atk - hero_def, 0);
|
||||||
if (enemyInfo.magic) per_damage = Math.max(mon_atk - hero_mdef, 0);
|
if (enemyInfo.magic) per_damage = Math.max(mon_atk - hero_mdef, 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
let hero_per_damage = Math.max(hero_atk - mon_def, 0);
|
let hero_per_damage = Math.max(hero_atk - mon_def, 0);
|
||||||
if (hero_magic) hero_per_damage = Math.max(hero_atk - mon_mdef, 0);
|
if (hero_magic) hero_per_damage = Math.max(hero_atk - mon_mdef, 0);
|
||||||
|
|
||||||
let damage = 0,
|
let damage = 0,
|
||||||
hero_turn = 0,
|
hero_turn = 0,
|
||||||
mon_turn = 0;
|
mon_turn = 0;
|
||||||
//---第三部分:递归开始---
|
//---第三部分:递归开始---
|
||||||
let length = hero_speed * mon_speed;
|
let length = hero_speed * mon_speed;
|
||||||
|
|
||||||
for (
|
let heroDiffPerTurn = [],
|
||||||
let now_mon_hp = mon_hp,
|
enemyDiffPerTurn = [];
|
||||||
last_mon_hp = mon_hp,
|
|
||||||
mon_length = length,
|
|
||||||
hero_length = length,
|
|
||||||
mon_time = 0,
|
|
||||||
hero_time = 0;
|
|
||||||
now_mon_hp > 0;
|
|
||||||
|
|
||||||
) {
|
for (
|
||||||
//勇士和怪物的长度
|
let now_mon_hp = mon_hp,
|
||||||
mon_time = mon_length / mon_speed;
|
last_mon_hp = mon_hp,
|
||||||
hero_time = hero_length / hero_speed;
|
mon_length = length,
|
||||||
if (
|
hero_length = length,
|
||||||
mon_time < hero_time ||
|
mon_time = 0,
|
||||||
((mon_time = hero_time) && mon_speed > hero_speed)
|
hero_time = 0; now_mon_hp > 0;
|
||||||
) {
|
|
||||||
//怪物攻击的回合
|
|
||||||
//这里计算怪物攻击时发生的各种变化
|
|
||||||
|
|
||||||
//伤害与回合增加
|
) {
|
||||||
damage += per_damage;
|
//勇士和怪物的长度
|
||||||
if (core.hasSpecial(mon_special, 6)) {
|
mon_time = mon_length / mon_speed;
|
||||||
mon_turn += enemy.n;
|
hero_time = hero_length / hero_speed;
|
||||||
} else {
|
if (
|
||||||
mon_turn += 1;
|
mon_time < hero_time ||
|
||||||
}
|
((mon_time == hero_time) && mon_speed > hero_speed)
|
||||||
//重新为长度赋值
|
) {
|
||||||
mon_length = length;
|
//怪物攻击的回合
|
||||||
hero_length = hero_length - mon_time * hero_speed;
|
//这里计算怪物攻击时发生的各种变化
|
||||||
} else {
|
|
||||||
//勇士攻击的回合
|
|
||||||
// 这里计算勇士攻击时发生的各种变化
|
|
||||||
|
|
||||||
// 伤害与回合数增加
|
//伤害与回合增加
|
||||||
now_mon_hp -= hero_per_damage;
|
damage += per_damage;
|
||||||
hero_turn += 1; //勇士回合+1,如果有勇士每回合多次攻击的情况,在这里写判断
|
if (core.hasSpecial(mon_special, 6)) {
|
||||||
// 无法战斗计算
|
mon_turn += enemy.n;
|
||||||
if (hero_turn % 50 == 0) {
|
} else {
|
||||||
if (now_mon_hp >= last_mon_hp) return null;
|
mon_turn += 1;
|
||||||
last_mon_hp = now_mon_hp;
|
}
|
||||||
}
|
//重新为长度赋值
|
||||||
//重新为长度赋值
|
mon_length = length;
|
||||||
hero_length = length;
|
hero_length = hero_length - mon_time * hero_speed;
|
||||||
mon_length = mon_length - hero_time * mon_speed;
|
} else {
|
||||||
}
|
//勇士攻击的回合
|
||||||
}
|
// 这里计算勇士攻击时发生的各种变化
|
||||||
|
|
||||||
//下面这些还没修改
|
// 伤害与回合数增加
|
||||||
// 连击
|
now_mon_hp -= hero_per_damage;
|
||||||
if (core.hasSpecial(mon_special, 6)) per_damage *= enemy.n || 2;
|
hero_turn += 1; //勇士回合+1,如果有勇士每回合多次攻击的情况,在这里写判断
|
||||||
|
// 无法战斗计算
|
||||||
|
if (hero_turn % 50 == 0) {
|
||||||
|
if (now_mon_hp >= last_mon_hp) return null;
|
||||||
|
last_mon_hp = now_mon_hp;
|
||||||
|
}
|
||||||
|
//重新为长度赋值
|
||||||
|
hero_length = length;
|
||||||
|
mon_length = mon_length - hero_time * mon_speed;
|
||||||
|
}
|
||||||
|
let hero_diff = {},
|
||||||
|
mon_diff = {};
|
||||||
|
//这里插入汇总勇士和怪物在此回合结束时的情况数值,用以跑条动画读取
|
||||||
|
heroDiffPerTurn.push(hero_diff);
|
||||||
|
enemyDiffPerTurn.push(mon_diff); //将勇士和怪物此回合结束时的属性变动保存到heroPerInfo和enemyPerInfo中,用以跑条动画读取
|
||||||
|
}
|
||||||
|
|
||||||
// 每回合的反击伤害;反击是按照勇士的攻击次数来计算回合
|
//下面这些还没修改
|
||||||
let counterDamage = 0;
|
// 连击
|
||||||
if (core.hasSpecial(mon_special, 8))
|
if (core.hasSpecial(mon_special, 6)) per_damage *= enemy.n || 2;
|
||||||
counterDamage += Math.floor(
|
|
||||||
(enemy.counterAttack || core.values.counterAttack) * hero_atk
|
|
||||||
);
|
|
||||||
|
|
||||||
// 先攻
|
// 每回合的反击伤害;反击是按照勇士的攻击次数来计算回合
|
||||||
if (core.hasSpecial(mon_special, 1)) init_damage += per_damage;
|
let counterDamage = 0;
|
||||||
|
if (core.hasSpecial(mon_special, 8))
|
||||||
|
counterDamage += Math.floor(
|
||||||
|
(enemy.counterAttack || core.values.counterAttack) * hero_atk
|
||||||
|
);
|
||||||
|
|
||||||
// 破甲
|
// 先攻
|
||||||
if (core.hasSpecial(mon_special, 7))
|
if (core.hasSpecial(mon_special, 1)) init_damage += per_damage;
|
||||||
init_damage += Math.floor(
|
|
||||||
(enemy.breakArmor || core.values.breakArmor) * hero_def
|
|
||||||
);
|
|
||||||
|
|
||||||
// 净化
|
// 破甲
|
||||||
if (core.hasSpecial(mon_special, 9))
|
if (core.hasSpecial(mon_special, 7))
|
||||||
init_damage += Math.floor(
|
init_damage += Math.floor(
|
||||||
(enemy.purify || core.values.purify) * hero_mdef
|
(enemy.breakArmor || core.values.breakArmor) * hero_def
|
||||||
);
|
);
|
||||||
//上面这些还没修改
|
|
||||||
//勇士护盾计算
|
|
||||||
let barrier = hero_mdef;
|
|
||||||
if (enemyInfo.magic) barrier = hero_def;
|
|
||||||
|
|
||||||
// ------ 支援 ----- //
|
// 净化
|
||||||
// 这个递归最好想明白为什么,flag:__extraTurn__是怎么用的
|
if (core.hasSpecial(mon_special, 9))
|
||||||
/*var guards = core.getFlag("__guards__" + x + "_" + y, enemyInfo.guards);
|
init_damage += Math.floor(
|
||||||
|
(enemy.purify || core.values.purify) * hero_mdef
|
||||||
|
);
|
||||||
|
//上面这些还没修改
|
||||||
|
//勇士护盾计算
|
||||||
|
let barrier = hero_mdef;
|
||||||
|
|
||||||
|
|
||||||
|
// ------ 支援 ----- //
|
||||||
|
// 这个递归最好想明白为什么,flag:__extraTurn__是怎么用的
|
||||||
|
/*var guards = core.getFlag("__guards__" + x + "_" + y, enemyInfo.guards);
|
||||||
var guard_before_current_enemy = false; // ------ 支援怪是先打(true)还是后打(false)?
|
var guard_before_current_enemy = false; // ------ 支援怪是先打(true)还是后打(false)?
|
||||||
turn += core.getFlag("__extraTurn__", 0);
|
turn += core.getFlag("__extraTurn__", 0);
|
||||||
if (guards.length > 0) {
|
if (guards.length > 0) {
|
||||||
@ -1084,43 +1092,45 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.removeFlag("__extraTurn__");*/
|
core.removeFlag("__extraTurn__");*/
|
||||||
// ------ 支援END ------ //
|
// ------ 支援END ------ //
|
||||||
|
|
||||||
// 最终伤害:初始伤害 + 怪物对勇士造成的伤害 + 反击伤害
|
// 最终伤害:初始伤害 + 怪物对勇士造成的伤害 + 反击伤害
|
||||||
damage += init_damage + hero_turn * counterDamage;
|
damage += init_damage + hero_turn * counterDamage;
|
||||||
// 再扣去护盾
|
// 再扣去护盾
|
||||||
damage -= barrier;
|
damage -= barrier;
|
||||||
|
|
||||||
// 检查是否允许负伤
|
// 检查是否允许负伤
|
||||||
if (!core.flags.enableNegativeDamage) damage = Math.max(0, damage);
|
if (!core.flags.enableNegativeDamage) damage = Math.max(0, damage);
|
||||||
|
|
||||||
// 最后处理仇恨和固伤(因为这两个不能被护盾减伤)
|
// 最后处理仇恨和固伤(因为这两个不能被护盾减伤)
|
||||||
if (core.hasSpecial(mon_special, 17)) {
|
if (core.hasSpecial(mon_special, 17)) {
|
||||||
// 仇恨
|
// 仇恨
|
||||||
damage += core.getFlag("hatred", 0);
|
damage += core.getFlag("hatred", 0);
|
||||||
}
|
}
|
||||||
if (core.hasSpecial(mon_special, 22)) {
|
if (core.hasSpecial(mon_special, 22)) {
|
||||||
// 固伤
|
// 固伤
|
||||||
damage += enemy.damage || 0;
|
damage += enemy.damage || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mon_hp: Math.floor(mon_hp),
|
mon_hp: Math.floor(mon_hp),
|
||||||
mon_atk: Math.floor(mon_atk),
|
mon_atk: Math.floor(mon_atk),
|
||||||
mon_def: Math.floor(mon_def),
|
mon_def: Math.floor(mon_def),
|
||||||
mon_mdef: Math.floor(mon_mdef),
|
mon_mdef: Math.floor(mon_mdef),
|
||||||
init_damage: Math.floor(init_damage),
|
init_damage: Math.floor(init_damage),
|
||||||
per_damage: Math.floor(per_damage),
|
per_damage: Math.floor(per_damage),
|
||||||
hero_per_damage: Math.floor(hero_per_damage),
|
hero_per_damage: Math.floor(hero_per_damage),
|
||||||
turn: Math.floor(hero_turn),
|
turn: Math.floor(hero_turn),
|
||||||
mon_turn: Math.floor(mon_turn),
|
mon_turn: Math.floor(mon_turn),
|
||||||
damage: Math.floor(damage),
|
damage: Math.floor(damage),
|
||||||
};
|
};
|
||||||
/*TODO:怪物手册的修改(需要修改这里return的内容以及一些战后判断)
|
/*TODO:怪物手册的修改(需要修改这里return的内容以及一些战后判断)
|
||||||
1. 显示怪物是魔攻还是物攻(在怪物名字上做颜色变化,物攻是黄色,魔攻是蓝色)
|
1. 显示怪物是魔攻还是物攻(在怪物名字上做颜色变化,物攻是黄色,魔攻是蓝色)
|
||||||
2. 一防减伤是物防还是魔防(由怪物是物攻还是魔攻来转换)
|
2. 一防减伤是物防还是魔防(由怪物是物攻还是魔攻来转换)
|
||||||
3. 特殊战斗的怪物,在怪物手册里“伤害”写为“特殊战”*/
|
3. 特殊战斗的怪物,在怪物手册里“伤害”写为“特殊战”*/
|
||||||
}
|
/*TODO:怪物和勇士同时跑条到终点时,谁先出手的逻辑确定
|
||||||
|
怪物、勇士和装备同时跑条时的计算*/
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"actions": {
|
"actions": {
|
||||||
"onKeyUp": function (keyCode, altKey) {
|
"onKeyUp": function (keyCode, altKey) {
|
||||||
|
Loading…
Reference in New Issue
Block a user