diff --git a/libs/core.js b/libs/core.js index d89d08cf..502a5130 100644 --- a/libs/core.js +++ b/libs/core.js @@ -335,8 +335,7 @@ core.prototype.loadMusic = function (callback) { } else { var music = new Audio(); - if (!core.musicStatus.startDirectly) - music.preload = 'none'; // 默认不加载 + music.preload = core.musicStatus.startDirectly?'auto':'none'; music.src = 'sounds/'+t; music.loop = 'loop'; core.material.bgms[t] = music; diff --git a/libs/enemys.js b/libs/enemys.js index c08ae30e..00541d09 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -101,6 +101,8 @@ enemys.prototype.getSpecialText = function (enemyId) { if (this.hasSpecial(special, 16)) text.push("夹击"); if (this.hasSpecial(special, 17)) text.push("仇恨"); if (this.hasSpecial(special, 18)) text.push("阻击"); + if (this.hasSpecial(special, 19)) text.push("自爆"); + if (this.hasSpecial(special, 20)) text.push("无敌"); return text.join(" "); } @@ -161,22 +163,27 @@ enemys.prototype.getCriticalDamage = function (monsterId) { // 1防减伤计算 enemys.prototype.getDefDamage = function (monsterId) { var monster = core.material.enemys[monsterId]; - return this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, - monster.hp, monster.atk, monster.def, monster.special) - - this.calDamage(core.status.hero.atk, core.status.hero.def + 1, core.status.hero.mdef, - monster.hp, monster.atk, monster.def, monster.special) + var nowDamage = this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, + monster.hp, monster.atk, monster.def, monster.special); + if (nowDamage == 999999999) return "???"; + return nowDamage - this.calDamage(core.status.hero.atk, core.status.hero.def + 1, core.status.hero.mdef, + monster.hp, monster.atk, monster.def, monster.special); } enemys.prototype.calDamage = function (hero_atk, hero_def, hero_mdef, mon_hp, mon_atk, mon_def, mon_special) { - // 魔攻 - if (this.hasSpecial(mon_special,2)) hero_def = 0; - // 坚固 - if (this.hasSpecial(mon_special,3) && mon_def < hero_atk - 1) mon_def = hero_atk - 1; + + if (this.hasSpecial(mon_special, 20) && !core.hasItem("cross")) // 如果是无敌属性,且勇士未持有十字架 + return 999999999; // 返回无限大 + // 模仿 if (this.hasSpecial(mon_special,10)) { mon_atk = hero_atk; mon_def = hero_def; } + // 魔攻 + if (this.hasSpecial(mon_special,2)) hero_def = 0; + // 坚固 + if (this.hasSpecial(mon_special,3) && mon_def < hero_atk - 1) mon_def = hero_atk - 1; if (hero_atk <= mon_def) return 999999999; // 不可战斗时请直接返回999999999 var per_damage = mon_atk - hero_def; diff --git a/libs/events.js b/libs/events.js index 6f1f9710..e82bfc8e 100644 --- a/libs/events.js +++ b/libs/events.js @@ -540,6 +540,10 @@ events.prototype.afterBattle = function(enemyId,x,y,callback) { if (core.enemys.hasSpecial(special, 17)) { core.setFlag('hatred', parseInt(core.getFlag('hatred', 0)/2)); } + // 自爆 + if (core.enemys.hasSpecial(special, 19)) { + core.status.hero.hp = 1; + } // 增加仇恨值 core.setFlag('hatred', core.getFlag('hatred',0)+core.values.hatred); core.updateStatusBar(); diff --git a/libs/floors/sample0.js b/libs/floors/sample0.js index 761bc5ed..1fab84e8 100644 --- a/libs/floors/sample0.js +++ b/libs/floors/sample0.js @@ -102,7 +102,6 @@ main.floors.sample0 = { "炸弹是只能炸面前的怪物还是四个方向的怪物,由data.js中的系统Flag所决定。\n如只能炸前方怪物则和上面的圣锤等价。\n不能被炸的怪物在enemys中可以定义,可参见样板里黑衣魔王和黑暗大法师的写法。", ], "10,4": ["“上楼”和“下楼”的目标层由 main.js 的 floorIds顺序所决定。"], - "10,3": ["十字架目前未被定义,可能需要自行实现功能。\n有关如何实现一个道具功能参见doc文档。"], "9,2": ["该道具默认是大黄门钥匙,如需改为钥匙盒直接修改 data.js 中的系统Flag即可。"], "10,2": ["屠龙匕首目前未被定义,可能需要自行实现功能。\n有关如何实现一个道具功能参见doc文档。"], }, diff --git a/libs/floors/sample1.js b/libs/floors/sample1.js index b28c41d1..3934514b 100644 --- a/libs/floors/sample1.js +++ b/libs/floors/sample1.js @@ -31,8 +31,9 @@ main.floors.sample1 = { "4,10": [ // 走到中间时的提示 "\t[样板提示]本层楼将会对各类事件进行介绍。", "左边是一个仿50层的陷阱做法,上方是商店、快捷商店的使用方法,右上是一个典型的杀怪开门的例子,右下是各类可能的NPC事件。", - "本样板目前支持的事件列表大致有:\ntext: 显示一段文字(比如你现在正在看到的)\ntip: 左上角显示提示\nshow: 使一个事件有效(可见、可被交互)\nhide: 使一个事件失效(不可见、不可被交互)\ntrigger: 触发另一个地点的事件\nbattle: 强制和某怪物战斗\nopenDoor: 无需钥匙开门(例如机关门、暗墙)\nopenShop: 打开一个全局商店\ndisableShop: 禁用一个全局商店\nchangeFloor: 传送勇士到某层某位置\nchangePos: 传送勇士到当层某位置;转向\nsetFg: 更改画面色调", - "move: 移动事件效果\nmoveHero: 移动勇士效果\nplaySound: 播放某个音频\nif: 条件判断\nchoices: 提供选项\nsetValue: 设置勇士属性道具,或某个变量/flag\nupdate: 更新状态栏和地图显伤\nwin: 获得胜利(游戏通关)\nlose: 游戏失败\nsleep: 等待多少毫秒\nexit: 立刻结束当前事件\nrevisit: 立刻结束事件并重新触发\nfunction: 自定义JS脚本\n更多支持的事件还在编写中,欢迎您宝贵的意见。", + "本样板目前支持的事件列表大致有:\ntext: 显示一段文字(比如你现在正在看到的)\ntip: 左上角显示提示\nshow: 使一个事件有效(可见、可被交互)\nhide: 使一个事件失效(不可见、不可被交互)\ntrigger: 触发另一个地点的事件\nbattle: 强制和某怪物战斗\nopenDoor: 无需钥匙开门(例如机关门、暗墙)", + "openShop: 打开一个全局商店\ndisableShop: 禁用一个全局商店\nchangeFloor: 传送勇士到某层某位置\nchangePos: 传送勇士到当层某位置;转向\nsetFg: 更改画面色调\nmove: 移动事件效果\nmoveHero: 移动勇士效果\nplayBgm: 播放某个背景音乐\npauseBgm: 暂停背景音乐\nresumeBgm: 恢复背景音乐的播放\nplaySound: 播放某个音频", + "if: 条件判断\nchoices: 提供选项\nsetValue: 设置勇士属性道具,或某个变量/flag\nupdate: 更新状态栏和地图显伤\nwin: 获得胜利(游戏通关)\nlose: 游戏失败\nsleep: 等待多少毫秒\nexit: 立刻结束当前事件\nrevisit: 立刻结束事件并重新触发\nfunction: 自定义JS脚本\n\n更多支持的事件还在编写中,欢迎您宝贵的意见。", "有关各事件的样例,可参见本层一些NPC的写法。\n所有事件样例本层都有介绍。\n\n一个自定义事件处理完后,需要调用{\"type\": \"hide\"}该事件才不会再次出现。", {"type": "hide"} ], diff --git a/libs/items.js b/libs/items.js index 0605a16e..449d2980 100644 --- a/libs/items.js +++ b/libs/items.js @@ -36,7 +36,7 @@ items.prototype.init = function () { 'fly': {'cls': 'constants', 'name': '楼层传送器', 'text': '可以自由往来去过的楼层'}, 'coin': {'cls': 'constants', 'name': '幸运金币', 'text': '持有时打败怪物可得双倍金币'}, 'snow': {'cls': 'constants', 'name': '冰冻徽章', 'text': '可以将四周的熔岩变成平地'}, - 'cross': {'cls': 'constants', 'name': '十字架', 'text': '该道具尚未被定义'}, + 'cross': {'cls': 'constants', 'name': '十字架', 'text': '持有后无视怪物的无敌属性'}, 'knife': {'cls': 'constants', 'name': '屠龙匕首', 'text': '该道具尚未被定义'}, 'shoes': {'cls': 'constants', 'name': '绿鞋', 'text': '持有时无视负面地形'}, diff --git a/libs/thirdparty/mid.min.js b/libs/thirdparty/mid.min.js deleted file mode 100644 index 434a8ae9..00000000 --- a/libs/thirdparty/mid.min.js +++ /dev/null @@ -1,3 +0,0 @@ -var sampleRate=44100;function AudioPlayer(generator,opts){if(!opts){opts={}}var latency=opts.latency||1;var checkInterval=latency*100;var audioElement=new Audio();var webkitAudio=window.AudioContext||window.webkitAudioContext;var requestStop=false;if(audioElement.mozSetup){audioElement.mozSetup(2,sampleRate);var buffer=[];var minBufferLength=latency*2*sampleRate;var bufferFillLength=Math.floor(latency*sampleRate);function checkBuffer(){if(buffer.length){var written=audioElement.mozWriteAudio(buffer);buffer=buffer.slice(written)}if(buffer.length';document.body.appendChild(c);var swf=document.getElementById("da-swf");var minBufferDuration=latency*1000;var bufferFillLength=latency*sampleRate;function write(data){var out=new Array(data.length);for(var i=data.length-1;i!=0;i--){out[i]=Math.floor(data[i]*32768)}return swf.write(out.join(" "))}function checkBuffer(){if(swf.bufferedDuration()>4;event.channel=eventTypeByte&15;event.type="channel";switch(eventType){case 8:event.subtype="noteOff";event.noteNumber=param1;event.velocity=stream.readInt8();return event;case 9:event.noteNumber=param1;event.velocity=stream.readInt8();if(event.velocity==0){event.subtype="noteOff"}else{event.subtype="noteOn"}return event;case 10:event.subtype="noteAftertouch";event.noteNumber=param1;event.amount=stream.readInt8();return event;case 11:event.subtype="controller";event.controllerType=param1;event.value=stream.readInt8();return event;case 12:event.subtype="programChange";event.programNumber=param1;return event;case 13:event.subtype="channelAftertouch";event.amount=param1;return event;case 14:event.subtype="pitchBend";event.value=param1+(stream.readInt8()<<7);return event;default:throw"Unrecognised MIDI event type: "+eventType}}}stream=Stream(data);var headerChunk=readChunk(stream);if(headerChunk.id!="MThd"||headerChunk.length!=6){throw"Bad .mid file - header not found"}var headerStream=Stream(headerChunk.data);var formatType=headerStream.readInt16();var trackCount=headerStream.readInt16();var timeDivision=headerStream.readInt16();if(timeDivision&32768){throw"Expressing time division in SMTPE frames is not supported yet"}else{ticksPerBeat=timeDivision}var header={"formatType":formatType,"trackCount":trackCount,"ticksPerBeat":ticksPerBeat};var tracks=[];for(var i=0;i0){synth.generateIntoBuffer(samplesToGenerate,data,dataOffset);dataOffset+=samplesToGenerate*2;samplesRemaining-=samplesToGenerate;samplesToNextEvent-=samplesToGenerate}handleEvent();getNextEvent()}else{if(samplesRemaining>0){synth.generateIntoBuffer(samplesRemaining,data,dataOffset); -samplesToNextEvent-=samplesRemaining}break}}return data}function handleEvent(){var event=nextEventInfo.event;switch(event.type){case"meta":switch(event.subtype){case"setTempo":beatsPerMinute=60000000/event.microsecondsPerBeat}break;case"channel":switch(event.subtype){case"noteOn":channels[event.channel].noteOn(event.noteNumber,event.velocity);break;case"noteOff":channels[event.channel].noteOff(event.noteNumber,event.velocity);break;case"programChange":channels[event.channel].setProgram(event.programNumber);break}break}}function replay(audio){console.log("replay");audio.write(generate(44100));setTimeout(function(){replay(audio)},10)}var self={"replay":replay,"generate":generate,"finished":false};return self}function Stream(str){var position=0;function read(length){var result=str.substr(position,length);position+=length;return result}function readInt32(){var result=((str.charCodeAt(position)<<24)+(str.charCodeAt(position+1)<<16)+(str.charCodeAt(position+2)<<8)+str.charCodeAt(position+3));position+=4;return result}function readInt16(){var result=((str.charCodeAt(position)<<8)+str.charCodeAt(position+1));position+=2;return result}function readInt8(signed){var result=str.charCodeAt(position);if(signed&&result>127){result-=256}position+=1;return result}function eof(){return position>=str.length}function readVarInt(){var result=0;while(true){var b=readInt8();if(b&128){result+=(b&127);result<<=7}else{return result+b}}}return{"eof":eof,"read":read,"readInt32":readInt32,"readInt16":readInt16,"readInt8":readInt8,"readVarInt":readVarInt}}function SineGenerator(freq){var self={"alive":true};var period=sampleRate/freq;var t=0;self.generate=function(buf,offset,count){for(;count;count--){var phase=t/period;var result=Math.sin(phase*2*Math.PI);buf[offset++]+=result;buf[offset++]+=result;t++}};return self}function SquareGenerator(freq,phase){var self={"alive":true};var period=sampleRate/freq;var t=0;self.generate=function(buf,offset,count){for(;count;count--){var result=((t/period)%1>phase?1:-1);buf[offset++]+=result;buf[offset++]+=result;t++}};return self}function ADSRGenerator(child,attackAmplitude,sustainAmplitude,attackTimeS,decayTimeS,releaseTimeS){var self={"alive":true};var attackTime=sampleRate*attackTimeS;var decayTime=sampleRate*(attackTimeS+decayTimeS);var decayRate=(attackAmplitude-sustainAmplitude)/(decayTime-attackTime);var releaseTime=null;var endTime=null;var releaseRate=sustainAmplitude/(sampleRate*releaseTimeS);var t=0;self.noteOff=function(){if(self.released){return}releaseTime=t;self.released=true;endTime=releaseTime+sampleRate*releaseTimeS};self.generate=function(buf,offset,count){if(!self.alive){return}var input=new Array(count*2);for(var i=0;i=0;i--){generators[i].generate(buffer,offset,samplesToGenerate);if(!generators[i].alive){generators.splice(i,1)}}}return{"sampleRate":sampleRate,"addGenerator":addGenerator,"generate":generate,"generateIntoBuffer":generateIntoBuffer}}; \ No newline at end of file diff --git a/libs/ui.js b/libs/ui.js index ab9e226e..bbb85c16 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -390,12 +390,12 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) { hero_hp -= core.enemys.getExtraDamage(monster); - if (core.enemys.hasSpecial(mon_special, 2)) hero_def=0; // 魔攻 - if (core.enemys.hasSpecial(mon_special, 3) && mon_def