Project1

标题: 通用(狂野)游戏加速代码 [打印本页]

作者: zths    时间: 2020-2-29 11:59
标题: 通用(狂野)游戏加速代码
本帖最后由 zths 于 2020-2-29 13:06 编辑

对付没有加速跳过的游戏的神器。(针对玩家)
对所有状态生效:包括但不限于 行走 战斗 对话
原理是加倍调用Scene 和 Window 的 update方法。。
理论上对各种插件的游戏均能有效兼容。。

使用方法是 下面代码丢到index.html里。
然后在游戏里按下ctrl即可加速

配置:

由于每秒调用10次 可能会对性能有影响?(应该不会)

HTML 代码复制
  1. <script>
  2. keys = {};
  3. function isKeyPressed(kc){
  4.         if(typeof(kc) == "undefined"){
  5.                 return false
  6.         }
  7.         return keys[kc] === true
  8. }
  9. if(typeof(handleWkd) == "undefined"){
  10.     handleWkd = true
  11.     jQuery(window).on("keydown",function(ev) {
  12.         keys[ev.keyCode] = true;
  13.     });
  14.     jQuery(window).on("keyup",function(ev) {
  15.         keys[ev.keyCode] = false;
  16.     });
  17. }
  18. AlwaysMulti = false
  19. pauseSence = false
  20. updateMainMultiply_Multiply = 1
  21. updateMainMultiply_MultiplyActiveKey  = 17
  22. function SceneHook(){
  23.     if(typeof updateMainMultiply_Multiply === "undefined"){updateMainMultiply_Multiply = 1;}
  24.     if(typeof AlwaysMulti === "undefined"){AlwaysMulti = false;}
  25.     if(typeof pauseSence === "undefined"){pauseSence = false;}
  26.     if(typeof SceneManager === "undefined"){return;}
  27.     if(typeof SceneManager._scene === "undefined"){return;}
  28.         if(typeof SceneManager._scene.update === "undefined"){return;}
  29.     if(typeof SceneManager._scene.updateBk === "undefined"){
  30.         SceneManager._scene.updateBk = SceneManager._scene.update
  31.     }
  32.     SceneManager._scene.update = function(){
  33.                 if(pauseSence){return;}
  34.         if(isKeyPressed(updateMainMultiply_MultiplyActiveKey) || AlwaysMulti){
  35.             for(var i=0;i<updateMainMultiply_Multiply;i++){
  36.                 this.updateBk.apply(this,arguments);
  37.             }
  38.         }
  39.         return this.updateBk.apply(this,arguments);
  40.     }
  41.         if(typeof SceneManager._scene._windowLayer === "undefined"){return;}
  42.         if(typeof SceneManager._scene._windowLayer.children === "undefined"){return;}
  43.         if(typeof SceneManager._scene._windowLayer.children.length === "undefined"){return;}
  44.     for(var i=0;i<SceneManager._scene._windowLayer.children.length;i++){
  45.         if(
  46.             SceneManager._scene._windowLayer.children[i]
  47.             && typeof SceneManager._scene._windowLayer.children[i].update !== "undefined"
  48.             && typeof SceneManager._scene._windowLayer.children[i].updateBk === "undefined"
  49.         ){
  50.             SceneManager._scene._windowLayer.children[i].updateBk = SceneManager._scene._windowLayer.children[i].update
  51.         }
  52.         SceneManager._scene._windowLayer.children[i].update = function(){
  53.                         if(pauseSence){return;}
  54.             if(isKeyPressed(updateMainMultiply_MultiplyActiveKey) || AlwaysMulti){
  55.                 for(var i=0;i<updateMainMultiply_Multiply;i++){
  56.                     this.updateBk.apply(this,arguments);
  57.                 }
  58.             }
  59.             return this.updateBk.apply(this,arguments);
  60.         }
  61.     }
  62. }
  63. if(typeof SceneHookInv !== "undefined"){
  64.     clearInterval(SceneHookInv);
  65. }
  66. SceneHookInv = setInterval(SceneHook,100);</script>

作者: Zeldashu    时间: 2020-3-3 18:28
约等于变数齿轮?
作者: walf_man    时间: 2020-3-3 18:51
牛,好东西呀,会不会手机发烫?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1