战斗动画

This commit is contained in:
草莓 2025-03-02 20:18:12 +08:00
parent c0617ac80f
commit 77ca6530cc
2 changed files with 2772 additions and 2455 deletions

View File

@ -284,10 +284,11 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
},
"afterBattle": function (enemyId, x, y) {
// 战斗结束后触发的事件
var enemy = core.material.enemys[enemyId];
// 获得战斗伤害信息
var damageInfo = core.getDamageInfo(enemyId, null, x, y) || {};
var enemy = damageInfo.enemyInfo;
var special = enemy.special;
console.log(enemy)
// 播放战斗音效和动画
// 默认播放的动画;你也可以使用
var animate = "hand"; // 默认动画
@ -306,8 +307,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (x != null && y != null) core.drawAnimate(animate, x, y);
else core.drawHeroAnimate(animate);
// 获得战斗伤害信息
var damageInfo = core.getDamageInfo(enemyId, null, x, y) || {};
// 战斗伤害
var damage = damageInfo.damage;
// 当前战斗回合数,可用于战后所需的判定
@ -757,7 +757,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
hero_def = core.getRealStatusOrDefault(hero, "def"),
hero_mdef = core.getRealStatusOrDefault(hero, "mdef"),
hero_speed = core.getRealStatusOrDefault(hero, "speed");
var mon_id = core.getEnemyValue(enemy, "id", x, y, floorId),
mon_name = core.getEnemyValue(enemy, "name", x, y, floorId);
var mon_hp = core.getEnemyValue(enemy, "hp", x, y, floorId),
mon_atk = core.getEnemyValue(enemy, "atk", x, y, floorId),
mon_def = core.getEnemyValue(enemy, "def", x, y, floorId),
@ -877,6 +878,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 也可以按需增加各种自定义内容
return {
id: mon_id,
name: mon_name,
hp: Math.floor(mon_hp),
atk: Math.floor(mon_atk),
def: Math.floor(mon_def),
@ -1135,6 +1138,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
turn: Math.floor(hero_turn),
mon_turn: Math.floor(mon_turn),
damage: Math.floor(damage),
enemyInfo: enemyInfo
};
/*TODO:return
1. 显示怪物是魔攻还是物攻在怪物名字上做颜色变化物攻是黄色魔攻是蓝色

View File

@ -4741,10 +4741,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
this._timer++;
};
// 申请并描绘canvas
PopSprite.prototype.requestCanvas = function () {
core.createCanvas(this._symbol, this._x, this._y, this._width, this._height, this._z);
var canvas = core.ui.getContextByName(this._symbol);
var canvas = core.getContextByName(this._symbol)
canvas.font = this._fontSize + 'px ' + this._font; // 动态设置字体大小
canvas.fillStyle = this._fontColor; // 动态设置字体颜色
canvas.strokeStyle = this._outlineColor; // 动态设置描边颜色
@ -4760,13 +4762,14 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
var textRect = uiContext.measureText(this._text);
this._width = textRect.width + 4;
this._height = this._fontSize * 1.4 + 4; // 动态设置高度
this._z = uiContext.canvas.style.zIndex ? uiContext.canvas.style.zIndex + PopSprite._count : PopSprite._baseZOrder + PopSprite._count;
this._z = uiContext.canvas.style.zIndex ? Number(uiContext.canvas.style.zIndex) + PopSprite._count : PopSprite._baseZOrder + PopSprite._count;
this._symbol = 'popSprite' + PopSprite._count++;
this._alive = true;
this._vx = this._speedX; // 使用传入的水平速度
this._vy = this._speedY; // 使用传入的垂直速度
this._floorY = this._y + PopSprite._floorDis;
this._timer = 0;
};
// 判断是否存活
@ -4774,10 +4777,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
return this._alive;
};
// 释放
PopSprite.prototype.dispose = function () {
this._alive = false;
core.deleteCanvas(this._symbol);
core.deleteCanvas(this._symbol, );
};
},
@ -4844,9 +4849,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
var func = core.enemys[name];
core.enemys[name] = function () {
var args =
arguments.length === 1
? [arguments[0]]
: Array.apply(null, arguments);
arguments.length === 1 ?
[arguments[0]] :
Array.apply(null, arguments);
if (typeof args[0] == "string") args[0] = core.enemys.enemys[args[0]];
return func.apply(core.enemys, args);
};
@ -9586,8 +9591,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
const type = checkAudioType(data);
if (type === "") {
console.error(
"Unknown audio type. Header: '" +
[...toCheck]
"Unknown audio type. Header: '" + [...toCheck]
.map((v) => v.toString().padStart(2, "0"))
.join(" ")
.toUpperCase() +
@ -9772,8 +9776,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
this.audioType = checkAudioType(data);
if (!this.audioType) {
console.error(
"Unknown audio type. Header: '" +
[...toCheck]
"Unknown audio type. Header: '" + [...toCheck]
.map((v) => v.toString(16).padStart(2, "0"))
.join(" ")
.toUpperCase() +
@ -16865,45 +16868,74 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
boss8.style.transform = "translate(-50%,-50%)";
const ctx8 = boss8.getContext("2d");
main.dom.boss8 = boss8;
const { imagelighter } = core.plugin.utils
boss.onclick = function (e) {
function getClick() {
return new Promise(resolve => {
function handleBossClick(e) {
try {
e.preventDefault();
if (core.isPlaying()) return false;
if (!core.isPlaying()) return false;
const left = core.dom.gameGroup.offsetLeft;
const top = core.dom.gameGroup.offsetTop;
const px = Math.floor((e.clientX - left) / core.domStyle.scale),
py = Math.floor((e.clientY - top) / core.domStyle.scale);
if (core.domStyle.isVertical) {
core.ui.boss.click(1248 - py * 3, px * 3)
} else {
core.ui.boss.click(px * 3, py * 3);
}
let x, y;
if (core.domStyle.isVertical) {
x = py * 3;
y = 1248 - px * 3;
} else {
x = px * 3;
y = py * 3;
}
core.ui.boss.click(x, y);
if (x > 1050 && x < 1450 && y > 250 && y < 390 && !core.ui.boss.show && core.ui.boss.hasEnemy()) {
// 移除事件监听器
boss.removeEventListener('click', handleBossClick);
resolve("普通攻击") //有小怪时点击普通攻击
return; // 退出函数
}
if (x > 850 && x < 1250 && y > 250 && y < 390 && !core.ui.boss.show && !core.ui.boss.hasEnemy()) {
// 移除事件监听器
boss.removeEventListener('click', handleBossClick);
resolve("普通攻击") //无小怪时点击普通攻击
return; // 退出函数
}
} catch (ee) {
main.log(ee);
}
};
}
boss.addEventListener('click', handleBossClick);
})
}
const { sleep } = core.plugin.utils
class Boss {
constructor() {
//绘制需要的变量
this.enemyfarme = 0
this.bg = "bg_3512.webp";
this.heroImage = "tati_310101.webp"
this.hero = { hp: 1000, atk: 100, def: 100, spell: 100, speed: 10, mdef: 10 }
this.hero = { id: "hero", name: "凯伊姆", hp: 1000, atk: 150, def: 100, spell: 100, speed: 10, mdef: 10 }
this.boss = { name: "菲奥奈", id: "angel", image: "tati_050143.webp", hp: 1000, atk: 200, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 }
this.enemy = []
this.enemy = [
{ name: "小蝙蝠", id: "bat", image: "tati_020125a.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
{ name: "红蝙蝠", id: "redBat", image: "tati_050301.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
{ name: "小蝙蝠", id: "bat", image: "tati_020125a.webp", hp: 1000, atk: 100, def: 20, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
{ name: "红蝙蝠", id: "redBat", image: "tati_050301.webp", hp: 1000, atk: 100, def: 120, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
{ name: "大蝙蝠", id: "bigBat", image: "tati_120101.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
{ name: "绿色史莱姆", id: "greenSlime", image: "tati_340115.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
{ name: "红色史莱姆", id: "redSlime", image: "tati_430101.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
{ name: "黑色史莱姆", id: "blackSlime", image: "tati_440101.webp", hp: 1000, atk: 100, def: 100, speed: 10, mdef: 10, skill: ['普通攻击', '重斩'], index: 0 },
]
this.selection = "boss"
this.herobuff = ["sword1:1", "fly:30"]
this.bossbuff = ["fly:2", "book:12"]
this.herobuff = [{ id: 'sword1', count: 1 }, { id: 'fly', count: 30 }]
this.bossbuff = [{ id: 'fly', count: 2 }, { id: 'book', count: 12, hp: 100 }]
this.enemybuff = [
[],
[],
@ -16918,11 +16950,189 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
this.skillShow = { //技能说明
"普通攻击": "常规攻击形式,伤害为自身攻击-对手防御"
}
this.turn = 0;
this.playingAnimate = new Set();
this.playerTurn = false
this.show = false
}
buffshow(a) { //buff说明均未实装之后改为实际需要的buff
let text = ""
switch (a.id) {
case "sword1":
text = `\r[rgb(30,66,30)]剑气:\r造成伤害提升\r[red]${10*a.count}%\r`
break;
case "fly":
text = `羽翼守护:接下来\r[gold]${a.count}回合\r不受速度差值影响`
break;
case "book":
text = `恢复之书:接下来\r[#000033]${a.count}回合\r,每回合行动时回复\r[green]${a.hp}\r点生命`
break;
}
return text
}
shake(hero) {
let time = 0,
farme = 0;
const xlist = [Math.random() * 40 + 10, Math.random() * -40 - 10, 0]
return new Promise(resolve => {
core.registerAnimationFrame("shake", true, (temptime) => {
if (temptime - time > 1000 / 60) {
time = temptime
const x = xlist[Math.floor(farme / 5) % 3]
if (hero) {
const img = imagelighter(core.material.images.images[this.heroImage])
core.clearMap(ctx2)
if (core.domStyle.isVertical) {
ctx2.canvas.width = 1248;
ctx2.canvas.height = 2028;
ctx2.save(); //保存设置
ctx2.translate(1248, 0); //重新定位右上角为基准
ctx2.rotate(Math.PI / 2); //旋转90度
} else {
ctx2.canvas.width = 2028;
ctx2.canvas.height = 1248;
}
core.drawImage(ctx2, img, x, 168, 750, 1080)
ctx2.restore();
} else {
core.clearMap(ctx3)
if (core.domStyle.isVertical) {
ctx3.canvas.width = 1248;
ctx3.canvas.height = 2028;
ctx3.save(); //保存设置
ctx3.translate(1248, 0); //重新定位右上角为基准
ctx3.rotate(Math.PI / 2); //旋转90度
} else {
ctx3.canvas.width = 2028;
ctx3.canvas.height = 1248;
}
if (this.selection === "boss" || this.selection === "") {
const img = imagelighter(core.material.images.images[this.boss.image])
core.drawImage(ctx3, img, 1400 + x, 168, 750, 1080)
} else {
const img = imagelighter(core.material.images.images[this.enemy[this.selection].image])
core.drawImage(ctx3, img, 1400 + x, 168, 750, 1080)
}
ctx3.restore();
}
farme++
if (farme > 30) {
core.unregisterAnimationFrame("shake")
this.drawhero()
this.drawboss()
resolve()
}
}
})
})
}
popDamage(damage, onhero) {
if (core.domStyle.isVertical) {
ctx.canvas.width = 1248;
ctx.canvas.height = 2028;
ctx.save(); //保存设置
ctx.translate(1248, 0); //重新定位右上角为基准
ctx.rotate(Math.PI / 2); //旋转90度
} else {
ctx.canvas.width = 2028;
ctx.canvas.height = 1248;
}
let color = "#FFFFFF"
if (typeof damage === "number") {
color = damage < 0 ? '#22FF44' : 'lightcoral'
}
let farme = 0,
time = 0;
let posx = onhero ? 300 : 1800
const speed = 9
return new Promise(resolve => {
core.registerAnimationFrame("popDamageonboss", true, (temptime) => {
if (temptime - time > 1000 / 60) {
time = temptime
core.clearMap(ctx)
core.setTextAlign(ctx, "center")
core.fillBoldText1(ctx, damage, posx, 800 - speed * farme, color, "#000000", 6, "bold 72px Arial")
farme++
ctx2.restore();
if (farme > 30) {
core.unregisterAnimationFrame("popDamageonboss")
core.clearMap(ctx)
resolve()
}
}
})
})
}
async skill(sk, a, b) { //a为发起方属性,sk为技能名
let damage = 0
switch (sk) { //所有技能效果及动画写在这里
case "普通攻击":
damage = Math.max(a.atk - b.def, 0) //基础伤害
damage = Math.floor(damage * a.speed / b.speed) //速度比值伤害加成
b.hp -= damage //承受伤害
if (b.id === "hero") core.status.hero.statistics.battleDamage += damage; //数据统计记录伤害
if (damage === 0) damage = "抵抗"
switch (a.id) { //根据id选取不同的特效
case "hero":
this.popDamage(damage, false)
if (damage > 0 && typeof damage !== "string") this.shake(false)
await this.playanimate("sword", 1800, 800)
break
case "angel":
this.popDamage(damage, true)
if (damage > 0 && typeof damage !== "string") this.shake(true)
await this.playanimate("sword", 350, 800) //播放动画sword
break;
case "bat":
this.popDamage(damage, true)
if (damage > 0 && typeof damage !== "string") this.shake(true)
await this.playanimate("sword", 350, 800) //播放动画sword
break;
case "redBat":
this.popDamage(damage, true)
if (damage > 0 && typeof damage !== "string") this.shake(true)
await this.playanimate("Fire01", 350, 800) //播放动画Fire01
break;
case "bigBat":
this.popDamage(damage, true)
if (damage > 0 && typeof damage !== "string") this.shake(true)
await this.playanimate("Fire02", 350, 800) //播放动画Fire02
break;
case "greenSlime":
this.popDamage(damage, true)
if (damage > 0 && typeof damage !== "string") this.shake(true)
await this.playanimate("005-Attack03", 350, 800) //播放动画005-Attack03
break;
case "redSlime":
this.popDamage(damage, true)
if (damage > 0 && typeof damage !== "string") this.shake(true)
await this.playanimate("012-Heal01", 350, 800) //播放动画012-Heal01
break;
case "blackSlime":
this.popDamage(damage, true)
if (damage > 0 && typeof damage !== "string") this.shake(true)
await this.playanimate("sword", 350, 800) //播放动画sword
break;
}
break; //下面写其余技能
}
await sleep(500) //等待1000ms
}
click(px, py) {
//点击效果
@ -16939,37 +17149,178 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
return sx <= x && x <= dx && sy <= y && y <= dy;
};
const pos = [px, py];
if (!this.playerTurn || main.replayChecking || core.isReplaying()) return
if (main.replayChecking || core.isReplaying()) return
const enemyStatusBox = makeBox([50, 50], [1900, 200]),
heroStatusBox = makeBox([600, 920], [900, 300]),
bossBox = makeBox([800, 300], [100, 150]),
enemyBox = makeBox([700, 500], [300, 300]),
imageBox = makeBox([1500, 250], [550, 1000]);
let enemy = true;
this.enemy.forEach(v => { if (v.hp > 0) enemy = false })
if (this.show) { //清除展示画面
this.show = !this.show
core.clearMap(ctx8)
} else {
if (inRect(pos, enemyStatusBox) && this.selection !== "" && enemy) { //绘制怪物详情
if (inRect(pos, enemyStatusBox) && this.selection !== "" && this.selection !== "boss" && this.hasEnemy()) { //绘制怪物详情
this.show = !this.show
this.moreShow(this.selection)
} else if (inRect(pos, enemyStatusBox) && !enemy) { //绘制boss详情
} else if (inRect(pos, enemyStatusBox) && (!this.hasEnemy() || this.selection === "boss")) { //绘制boss详情
this.show = !this.show
this.moreShow("boss")
} else if (inRect(pos, heroStatusBox)) { //绘制勇士详情
this.show = !this.show
this.moreShow("hero")
} else if (inRect(pos, bossBox) && enemy) { //切换selection为boss
} else if (inRect(pos, bossBox) && this.hasEnemy()) { //切换selection为boss
this.selection = 'boss'
this.update()
} else if (inRect(pos, enemyBox) && enemy) { //绘制勇士详情
this.selection = Math.floor((px - 700) / 3) + Math.floor((py - 500) / 150) * 3
} else if (inRect(pos, enemyBox) && this.hasEnemy()) { //切换selection为enemy
const symbol = Math.floor((px - 700) / 100) + Math.floor((py - 500) / 150) * 3
if (this.enemy[symbol] && this.enemy[symbol].hp > 0) {
this.selection = symbol
this.update()
}
}
}
}
drawchoose() {
if (core.domStyle.isVertical) {
ctx7.canvas.width = 1248;
ctx7.canvas.height = 2028;
ctx7.save(); //保存设置
ctx7.translate(1248, 0); //重新定位右上角为基准
ctx7.rotate(Math.PI / 2); //旋转90度
} else {
ctx7.canvas.width = 2028;
ctx7.canvas.height = 1248;
}
boss7.style.display = "block"
core.clearMap(ctx7)
if (this.hasEnemy()) {
core.drawWindowSkin("winskin.webp", ctx7, 1050, 250, 400, 660, null, null, null, 3)
core.fillBoldText1(ctx7, "普通攻击", 1120, 350, "#FFFFFF", "#000000", 6, "bold 64px Verdana")
core.drawLine(ctx7, 1050, 390, 1450, 390, "#FFFFFF", 6)
} else {
core.drawWindowSkin("winskin.webp", ctx7, 850, 250, 400, 660, null, null, null, 3)
core.fillBoldText1(ctx7, "普通攻击", 920, 350, "#FFFFFF", "#000000", 6, "bold 64px Verdana")
core.drawLine(ctx7, 850, 390, 1250, 390, "#FFFFFF", 6)
}
}
moreShow(select) {
if (core.domStyle.isVertical) {
ctx8.canvas.width = 1248;
ctx8.canvas.height = 2028;
ctx8.save(); //保存设置
ctx8.translate(1248, 0); //重新定位右上角为基准
ctx8.rotate(Math.PI / 2); //旋转90度
} else {
ctx8.canvas.width = 2028;
ctx8.canvas.height = 1248;
}
core.clearMap(ctx8)
core.fillRect(ctx8, 100, 100, 1800, 1000, "rgba(0,0,0,0.7)")
core.drawWindowSkin("winskin.webp", ctx8, 100, 100, 1800, 1000, null, null, null, 3)
let posy = 200
switch (select) {
case "hero":
//勇士技能/buff
core.fillBoldText1(ctx8, this.hero.name, 1000, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
posy += 100
if (this.herobuff.length === 0) {
core.fillBoldText1(ctx8, "当前无特殊状态", 200, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
posy += 100
} else {
this.herobuff.forEach(v => {
core.drawTextContent(ctx8, this.buffshow(v), {
left: 200,
top: posy,
bold: true,
color: "#FFFFFF",
align: "left",
fontSize: 48,
time: 0,
font: "Verdana",
maxWidth: 1600,
});
posy += 100
})
}
posy += 50
core.fillBoldText1(ctx8, "技能说明", 1000, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
posy += 100
core.fillBoldText1(ctx8, "普通攻击:" + this.skillShow["普通攻击"], 200, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
break;
case "boss":
core.fillBoldText1(ctx8, this.boss.name, 1000, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
posy += 100
//boss技能/buff
if (this.bossbuff.length === 0) {
core.fillBoldText1(ctx8, "当前无特殊状态", 200, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
posy += 100
} else {
this.bossbuff.forEach(v => {
core.drawTextContent(ctx8, this.buffshow(v), {
left: 200,
top: posy,
bold: true,
color: "#FFFFFF",
align: "left",
fontSize: 48,
time: 0,
font: "Verdana",
maxWidth: 1600,
});
posy += 100
})
}
posy += 50
core.fillBoldText1(ctx8, "当前技能", 1000, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
posy += 100
core.fillBoldText1(ctx8, this.boss.skill[this.boss.index] + this.skillShow[this.boss.skill[this.boss.index]], 200, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
break;
default:
const enemy = this.enemy[select]
const enemybuff = this.enemybuff[select]
core.fillBoldText1(ctx8, enemy.name, 1000, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
posy += 100
if (enemybuff.length === 0) {
core.fillBoldText1(ctx8, "当前无特殊状态", 200, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
posy += 100
} else {
enemybuff.forEach(v => {
core.drawTextContent(ctx8, this.buffshow(v), {
left: 200,
top: posy,
bold: true,
color: "#FFFFFF",
align: "left",
fontSize: 48,
time: 0,
font: "Verdana",
maxWidth: 1600,
});
posy += 100
})
}
posy += 50
core.fillBoldText1(ctx8, "当前技能", 1000, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
posy += 100
core.fillBoldText1(ctx8, enemy.skill[enemy.index] + this.skillShow[enemy.skill[enemy.index]], 200, posy, "#FFFFFF", "#000000", 6, "bold 48px Verdana")
break;
}
ctx8.restore()
}
hasEnemy() {
let enemy = false;
this.enemy.forEach(v => { if (v.hp > 0) enemy = true })
return enemy
}
async bossStart() {
boss.style.display = "block"
this.selection = "boss"
@ -17009,25 +17360,22 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
for (const v of fightList) {
switch (v[0]) {
case 'hero':
await this.playanimate("sword", 1800, 800) //播放动画sword
await sleep(200) //等待200ms
this.drawchoose()
const skill = await getClick()
let select = this.boss
if (this.selection !== "" && this.selection !== "boss") select = this.enemy[this.selection]
this.skill(skill, this.hero, select)
core.clearMap(ctx7)
break;
case 'boss':
if (this.boss.hp > 0) {
this.selection = "boss"
this.update()
await sleep(200) //等待200ms
switch (this.boss.skill[this.boss.index]) { //这里写boss技能的效果
case "普通攻击":
damage = Math.max(this.boss.atk - this.hero.def, 0) //基础伤害
damage = Math.floor(damage * this.boss.speed / this.hero.speed) //速度比值伤害加成
this.hero.hp -= damage //承受伤害
core.status.hero.statistics.battleDamage += damage; //数据统计记录伤害
await this.playanimate("sword", 350, 800) //播放动画sword
await sleep(200) //等待200ms
break;
await sleep(500) //等待500ms
//这里写boss技能的效果
this.skill(this.boss.skill[this.boss.index], this.boss, this.hero)
}
this.boss.index++
if (this.boss.index >= this.boss.skill.length) this.boss.index = 0
}
@ -17037,48 +17385,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
if (enemy.hp > 0) {
this.selection = v[0]
this.update()
await sleep(200) //等待200ms
switch (enemy.skill[enemy.index]) { //这里写boss召唤物小怪的技能效果
case "普通攻击":
damage = Math.max(enemy.atk - this.hero.def, 0) //基础伤害
damage = Math.floor(damage * enemy.speed / enemy.speed) //速度比值伤害加成
this.hero.hp -= damage //承受伤害
core.status.hero.statistics.battleDamage += damage; //数据统计记录伤害
switch (enemy.id) { //根据怪物id选取不同的特效
case "bat":
await this.playanimate("sword", 350, 800) //播放动画sword
break;
case "redBat":
await this.playanimate("Fire01", 350, 800) //播放动画Fire01
break;
case "bigBat":
await this.playanimate("Fire02", 350, 800) //播放动画Fire02
break;
case "greenSlime":
await this.playanimate("005-Attack03", 350, 800) //播放动画005-Attack03
break;
case "redSlime":
await this.playanimate("012-Heal01", 350, 800) //播放动画012-Heal01
break;
case "blackSlime":
await this.playanimate("sword", 350, 800) //播放动画sword
break;
}
await sleep(200) //等待200ms
break;
}
await sleep(500) //等待500ms
this.skill(enemy.skill[enemy.index], enemy, this.hero)
enemy.index++
if (enemy.index >= enemy.skill.length) enemy.index = 0
}
break;
}
await sleep(200)
await sleep(1000)
this.selection = ""
this.update()
@ -17146,14 +17461,14 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}
drawenemy() {
let block,
time = 0,
farme = 0;
time = 0;
boss5.style.display = 'block'
core.registerAnimationFrame('enemyanimate', true, (temptime) => {
if (temptime - time > 1000 / 60) {
time = temptime
farme += 1
let animate = Math.floor(farme / 30),
this.enemyfarme += 1
let animate = Math.floor(this.enemyfarme / 30),
posx = 700,
posy = 500;
core.clearMap(ctx5)
@ -17167,9 +17482,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
ctx5.canvas.width = 2028;
ctx5.canvas.height = 1248;
}
let enemy = false
this.enemy.forEach(v => { if (v.hp > 0) enemy = true })
if (enemy) {
if (this.hasEnemy()) {
core.drawWindowSkin("winskin.webp", ctx5, 650, 250, 400, 660, null, null, null, 3)
if (this.selection === "boss") core.strokeRect(ctx5, 800, 300, 100, 150, "yellow", 6)
@ -17607,12 +17921,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
let posx = 980
this.herobuff.forEach(v => {
if (v) {
const a = v.split(":")
core.drawIcon(ctx4, a[0], posx, 950, 64, 64)
core.drawIcon(ctx4, v.id, posx, 950, 64, 64)
core.setTextAlign(ctx4, "right")
core.fillBoldText1(
ctx4,
a[1],
v.count,
posx + 50,
1000,
"#FFFFFF",
@ -17624,9 +17938,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
posx += 80
}
})
let enemy = true;
this.enemy.forEach(v => { if (v.hp > 0) enemy = false })
if (this.selection === "boss" || enemy) {
if (this.selection === "boss" || !this.hasEnemy()) {
core.drawWindowSkin("winskin.webp", ctx4, 50, 50, 1900, 200, null, null, null, 3)
core.fillBoldText1(
ctx4,
@ -17723,12 +18036,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
let posx = 600
this.bossbuff.forEach(v => {
if (v) {
const a = v.split(":")
core.drawIcon(ctx4, a[0], posx, 80, 64, 64)
core.drawIcon(ctx4, v.id, posx, 80, 64, 64)
core.setTextAlign(ctx4, "right")
core.fillBoldText1(
ctx4,
a[1],
v.count,
posx + 50,
130,
"#FFFFFF",
@ -17837,12 +18150,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
let posx = 600
this.enemybuff[this.selection].forEach(v => {
if (v) {
const a = v.split(":")
core.drawIcon(ctx4, a[0], posx, 80, 64, 64)
core.drawIcon(ctx4, v.id, posx, 80, 64, 64)
core.setTextAlign(ctx4, "right")
core.fillBoldText1(
ctx4,
a[1],
v.count,
posx + 50,
130,
"#FFFFFF",
@ -17960,12 +18273,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
let posx = 980
this.herobuff.forEach(v => {
if (v) {
const a = v.split(":")
core.drawIcon(ctx4, a[0], posx, 950 + posy, 64, 64)
core.drawIcon(ctx4, v.id, posx, 950 + posy, 64, 64)
core.setTextAlign(ctx4, "right")
core.fillBoldText1(
ctx4,
a[1],
v.count,
posx + 50,
1000 + posy,
"#FFFFFF",
@ -18053,12 +18366,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
let posx = 600
this.bossbuff.forEach(v => {
if (v) {
const a = v.split(":")
core.drawIcon(ctx4, a[0], posx, 80 - posy / 2, 64, 64)
core.drawIcon(ctx4, v.id, posx, 80 - posy / 2, 64, 64)
core.setTextAlign(ctx4, "right")
core.fillBoldText1(
ctx4,
a[1],
v.count,
posx + 50,
130 - posy / 2,
"#FFFFFF",
@ -18146,12 +18459,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
let posx = 600
this.enemybuff[this.selection].forEach(v => {
if (v) {
const a = v.split(":")
core.drawIcon(ctx4, a[0], posx, 80 - posy / 2, 64, 64)
core.drawIcon(ctx4, v.id, posx, 80 - posy / 2, 64, 64)
core.setTextAlign(ctx4, "right")
core.fillBoldText1(
ctx4,
a[1],
v.count,
posx + 50,
130 - posy / 2,
"#FFFFFF",