设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3929|回复: 4
打印 上一主题 下一主题

[原创发布] 自制半即时战斗系统

[复制链接]

Lv2.观梦者

梦石
0
星屑
735
在线时间
42 小时
注册时间
2019-11-26
帖子
28
跳转到指定楼层
1
发表于 2019-12-11 17:28:55 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
发一个自制的半即时战斗系统,长相就是下面图片的样子……
不太会用的也可以参考范例工程~

注意:此脚本未经过严格的测试,可能发生BUG或与其它脚本不兼容的情况。
如有问题可以回帖或私信。

JAVASCRIPT 代码复制
  1. // 半即时战斗脚本
  2. // 作者:xsrong
  3. // ---------------------------------------------------
  4. // 插件简介:
  5. // 启用该脚本后,战斗系统将改变为蓄槽模式的半即时战斗。
  6. // ---------------------------------------------------  
  7. // 使用注意:
  8. // ※本插件为战斗每个成员新增了cp值,cp值按照该成员的敏捷值进行增长,
  9. // ※我方成员的cp值增长到10000后弹出战斗选项,敌方成员cp值增长至10000之后采取行动。
  10. // ※可以为每个技能和物品设定单独的cp cost,使用该技能和物品的话会扣除相应的cp。
  11. // ※设定方法:在物品或技能的备注栏备注<CPCOST xxxxx>。xxxxx最小为0,最大为10000。
  12. // ※未设定物品或技能的cp cost则默认为10000。
  13. // ※逃跑失败固定扣除10000cp。
  14. //
  15. // ※本插件更改了遇敌时决定先手和被袭击的条件,
  16. // ※使得明雷遇敌(在事件中呼叫战斗处理)也有几率触发先手和被袭击。
  17. // ※另外需要设置以下三个全局开关用以控制先手和被袭击:
  18. // ※在preemptiveSwitch储存的开关id打开的情况下必定先手
  19. // ※在surpriseSwitch储存的开关id打开的情况下必定被袭击
  20. // ※在noPreemptiveAndSurprise储存的开关id打开的情况下不会触发先手和被袭击
  21. // ※默认1号开关打开情况下每次战斗必先手,2号开关打开情况下必被偷袭,3号开关打开情况下不会发生先手或被偷袭。
  22. //
  23. // ※本插件为每个战斗成员新增了_turnCount属性,用以记录战斗成员的回合数。
  24. //
  25. // ※本插件新增了以下两个全局函数用以设置战斗事件的发生条件:
  26. // ※currentActionBattler() 调用该函数会返回当前正在行动的战斗成员
  27. // ※currentActionBattlerTurnCount() 调用该函数会返回当前正在行动的战斗成员的回合数
  28. // ※本插件向Game_Battler类新增了isCurrentActionBattler()函数,调用该方法会返回某Game_Battler实例是否是当前正在行动的成员的布尔值。
  29. // ※通过上面三个函数,可以在战斗事件中精确控制己方或地方成员每回合的动作。
  30. // ※具体设置方法可以参考范例工程。
  31. //
  32. // ※本插件更改了战斗中状态图标的显示,战斗中的状态图标右上角显示该状态有效的剩余回合数。
  33. // ※每个战斗成员的状态剩余回合数是独立控制的。该成员行动之后,该成员身上的状态会立即更新。
  34. // ---------------------------------------------------
  35.  
  36. // 设置战斗成员的初始cp
  37. Game_Battler.prototype._cp = 0;
  38.  
  39. // 控制每次战斗必先手的开关id
  40. var preemptiveSwitch = 1;
  41.  
  42. // 控制每次战斗必备偷袭的开关id
  43. var surpriseSwitch = 2;
  44. // 注:上面两个开关同时打开时,每次战斗必先手
  45.  
  46. // 控制战斗先手和被偷袭无效的开关id
  47. var noPreemptiveAndSurprise = 3;
  48.  
  49.  
  50. // ---------------------------------------------------
  51. // 绘制战斗成员行动槽的窗口
  52. // ---------------------------------------------------
  53. function Window_CPBar() {
  54.   this.initialize.apply(this, arguments)
  55. };
  56.  
  57. Window_CPBar.prototype = Object.create(Window_Base.prototype);
  58. Window_CPBar.prototype.constructor = Window_CPBar;
  59. Window_CPBar.prototype.initialize = function (x, y, w, h) {
  60.   Window_Base.prototype.initialize.call(this, x, y, w, h);
  61.   this.opacity = 0;               // 将窗口背景和框架透明化
  62.   this._actorFaceBitmaps = [];    // 保存行动槽上角色头像的数组
  63.   this._enemyFaceBitmaps = [];    // 保存行动槽上敌人头像的数组
  64.   this.createActorCPBarFaces();
  65.   this.createEnemyCPBarFaces();
  66. };
  67.  
  68. Window_CPBar.prototype.refresh = function() {
  69.   this.contents.clear();
  70.   this.drawCPBar(this.x + 20, this.y,  this.width - 80);
  71.   this.drawCPBarFaces()
  72. };
  73.  
  74. Window_CPBar.prototype.drawCPBar = function(x, y, width) {
  75.   width = width || 186;
  76.   var color1 = 'black';           // 行动槽左端颜色
  77.   var color2 = 'grey';            // 行动槽右端颜色
  78.   this.drawGauge(x, y, width, 1, color1, color2);
  79. };
  80.  
  81. Window_CPBar.prototype.createActorCPBarFace = function(faceName) {
  82.   var bitmap = ImageManager.loadFace(faceName);
  83.   this._actorFaceBitmaps.push(bitmap);
  84. }
  85.  
  86. Window_CPBar.prototype.createActorCPBarFaces = function() {
  87.   actors = $gameParty.members();
  88.   for (var i = 0; i < actors.length; i++) {
  89.     this.createActorCPBarFace(actors[i].faceName());
  90.   }
  91. }
  92.  
  93. Window_CPBar.prototype.createEnemyCPBarFace = function(battlerName) {
  94.   var bitmap = ImageManager.loadEnemy(battlerName);
  95.   this._enemyFaceBitmaps.push(bitmap);
  96. }
  97.  
  98. Window_CPBar.prototype.createEnemyCPBarFaces = function() {
  99.   enemies = $gameTroop.members();
  100.   for (var i = 0; i < enemies.length; i++) {
  101.     this.createEnemyCPBarFace(enemies[i].enemy().battlerName);
  102.   }
  103. }
  104.  
  105. Window_CPBar.prototype.drawActorCPBarFaces = function() {
  106.   actors = $gameParty.members();
  107.   for (var i = 0; i < actors.length; i++) {
  108.     if (actors[i].isAlive()) {
  109.       var pw = Window_Base._faceWidth;
  110.       var ph = Window_Base._faceHeight;
  111.       var rate = actors[i]._cp / 10000;
  112.       rate = Math.min(rate, 1);
  113.       var dx = rate * (this.width - 95);
  114.       var dy = 0;
  115.       var sx = actors[i].faceIndex() % 4 * pw;
  116.       var sy = Math.floor(actors[i].faceIndex() / 4) * ph;
  117.       this.contents.blt(this._actorFaceBitmaps[i], sx, sy, pw, ph, dx, dy, 30, 30);
  118.     }
  119.   }
  120. }
  121.  
  122. Window_CPBar.prototype.drawEnemyCPBarFaces = function() {
  123.   enemies = $gameTroop.members();
  124.   for (var i = 0; i < enemies.length; i++) {
  125.     if (enemies[i].isAlive()) {
  126.       var pw = this._enemyFaceBitmaps[i]._image.width;
  127.       var ph =  this._enemyFaceBitmaps[i]._image.height;
  128.       var rate = enemies[i]._cp / 10000;
  129.       rate = Math.min(rate, 1);
  130.       var dx = rate * (this.width - 95);
  131.       var dy = 0;
  132.       var sx = 0;
  133.       var sy = 0;
  134.       this.contents.blt(this._enemyFaceBitmaps[i], sx, sy, pw, ph, dx, dy, 30, 30);
  135.     }
  136.   }
  137. }
  138.  
  139. Window_CPBar.prototype.drawCPBarFaces = function() {
  140.   this.drawEnemyCPBarFaces();
  141.   this.drawActorCPBarFaces();
  142. }
  143.  
  144. // ---------------------------------------------------
  145. // 修改战斗场景
  146. // ---------------------------------------------------
  147. xsrongSceneBattleCreateAllWindows = Scene_Battle.prototype.createAllWindows;
  148. Scene_Battle.prototype.createAllWindows = function() {
  149.   xsrongSceneBattleCreateAllWindows.call(this);
  150.   this.createCPBarWindow();          // 向战斗场景中加入行动槽
  151. };
  152.  
  153. Scene_Battle.prototype.createCPBarWindow = function() {
  154.   this._cpBarWindow = new Window_CPBar(0, 0, Graphics.boxWidth, 72)
  155.   this._spriteset.addChild(this._cpBarWindow)
  156. };
  157.  
  158. Scene_Battle.prototype.updateCPBarWindow = function() {
  159.   var battlers = $gameParty.members().concat($gameTroop.members());
  160.   battlers.forEach(function(b) {
  161.     if (b.isAlive()) {
  162.       b._cp += b.agi;               // 战斗成员cp值的增加量为该成员的敏捷度
  163.     }
  164.   });
  165.   this._cpBarWindow.refresh();
  166. };
  167.  
  168. // 向战斗场景中的角色命令窗口增加逃跑选项
  169. xsrongSceneBattleCreateActorCommandWindow = Scene_Battle.prototype.createActorCommandWindow;
  170. Scene_Battle.prototype.createActorCommandWindow = function() {
  171.   this._actorCommandWindow = new Window_ActorCommand();
  172.   this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));
  173.   this._actorCommandWindow.setHandler('skill',  this.commandSkill.bind(this));
  174.   this._actorCommandWindow.setHandler('guard',  this.commandGuard.bind(this));
  175.   this._actorCommandWindow.setHandler('item',   this.commandItem.bind(this));
  176.   this._actorCommandWindow.setHandler('escape', this.commandEscape.bind(this));
  177.   this.addWindow(this._actorCommandWindow);
  178. };
  179.  
  180. xsrongSceneBattleCommandEscape = Scene_Battle.prototype.commandEscape;
  181. Scene_Battle.prototype.commandEscape = function() {
  182.   BattleManager.processEscape();
  183. };
  184.  
  185. BattleManager.processEscape = function() {
  186.   $gameParty.performEscape();
  187.   SoundManager.playEscape();
  188.   var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
  189.   if (success) {
  190.       this.displayEscapeSuccessMessage();
  191.       this._escaped = true;
  192.       this.processAbort();
  193.   } else {
  194.       this.actor()._cp -= 10000;                   // 逃跑失败扣除10000点cp
  195.       this.actor().onTurnEnd();                    // 逃跑失败更新该角色身上的状态
  196.       this.displayEscapeFailureMessage();
  197.       this._escapeRatio += 0.1;
  198.       $gameParty.clearActions();
  199.       this._phase = 'xsrong_wait';                 // 逃跑失败继续等待行动
  200.       this.xsrongWait();
  201.   }
  202.   return success;
  203. };
  204.  
  205. xsrongBattleManagerUpdate = BattleManager.update;
  206. BattleManager.update = function() {
  207.   if (!this.isBusy() && !this.updateEvent()) {
  208.     switch (this._phase) {
  209.     case 'start':
  210.       this.xsrongStart();
  211.       break;
  212.     case 'turn':
  213.       this.updateTurn();
  214.       break;
  215.     case 'action':
  216.       this.updateAction();
  217.       break;
  218.     case 'turnEnd':
  219.       this.updateTurnEnd();
  220.       break;
  221.     case 'battleEnd':
  222.       this.updateBattleEnd();
  223.       break;
  224.     case 'xsrong_wait':                          // 等待行动槽涨满
  225.       this.xsrongWait();
  226.       break;
  227.     case 'enemy_action':                         // 等待敌人行动
  228.       this.updateTurn();
  229.       break;
  230.     };
  231.   }
  232. };
  233.  
  234. xsrongBattleManagerUpdateEvent = BattleManager.updateEvent;
  235. BattleManager.updateEvent = function() {
  236.   switch (this._phase) {
  237.   case 'start':
  238.   case 'turn':
  239.   case 'enemy_action':
  240.       if (this.isActionForced()) {
  241.           this.processForcedAction();
  242.           return true;
  243.       } else {
  244.           return this.updateEventMain();
  245.       }
  246.   }
  247.   return this.checkAbort();
  248. };
  249.  
  250. BattleManager.processForcedAction = function() {
  251.   if (this._actionForcedBattler) {
  252.       this._subject = this._actionForcedBattler;
  253.       this._actionForcedBattler = null;
  254.       this.startAction();
  255.       this._subject.removeCurrentAction();
  256.       this._subject._turnCount++;               // 战斗事件中强制战斗行动后增加该成员的回合数
  257.       this._subject.onTurnEnd();                // 战斗事件中强制战斗行动后更新该成员身上的状态
  258.   }
  259. };
  260.  
  261. xsrongBattleManagerMakeActionOrders = BattleManager.makeActionOrders;
  262. BattleManager.makeActionOrders = function() {
  263.   var battlers = [];
  264.   battlers = battlers.concat($gameParty.members()).concat($gameTroop.members())
  265.   this._actionBattlers = battlers;
  266. };
  267.  
  268. // 设置战斗开始时每个战斗成员的cp
  269. BattleManager.setupMemberCP = function() {
  270.   if (this._surprise) {
  271.     $gameTroop.members().forEach(function(enemy) {
  272.       enemy._cp = 10000 - Math.floor(Math.random()*5) * 10;    // 被偷袭的场合,所有敌人的cp直接涨满
  273.     });
  274.   } else if (this._preemptive) {
  275.     $gameParty.members().forEach(function(actor){
  276.       actor._cp = 10000 - actor.agi;                           // 我方先手的场合,所有我方队员的cp直接涨满
  277.     });
  278.   } else {
  279.     for (var i = 0; i < this._actionBattlers.length; i++) {
  280.       randNum = Math.floor(Math.random()*20) * 50;
  281.       this._actionBattlers[i]._cp = this._actionBattlers[i].agi * 10 + randNum;    // 没有先手和被偷袭的场合,随机设置所有成员的初始cp
  282.     };
  283.   }
  284. }
  285.  
  286. BattleManager.setupMemberTurnCount = function() {
  287.   battlers = this._actionBattlers;
  288.   battlers.forEach(function(battler) {
  289.     battler._turnCount = 1;                             // 设置每个成员的初始回合数
  290.   })
  291. }
  292.  
  293. BattleManager.xsrongStart = function() {
  294.   this.makeActionOrders();
  295.   this.setupMemberCP();
  296.   this.setupMemberTurnCount();
  297.   this._phase = 'xsrong_wait';                      // 进入战斗后开始等待行动槽涨满
  298. };
  299.  
  300. BattleManager.xsrongWait = function() {
  301.   for (var i = 0; i < $gameParty.members().length; i++) {
  302.     var actor =  $gameParty.members()[i];
  303.     if (actor._cp >= 10000) {
  304.       this._phase = "turn"
  305.       this._subject = actor;
  306.       this._actorIndex = $gameParty.members().indexOf(actor);
  307.       if (!this.updateEvent()) {
  308.         this._phase = "input";                      // 角色没有被强制行动的话,输入战斗指令
  309.         actor.makeActions();
  310.       } else {
  311.         this.processForcedAction();                 // 角色被强制行动的话,无视已输入的指令,执行强制行动
  312.       }
  313.       break;
  314.     }
  315.   };
  316.  
  317.   for (var j = 0; j < $gameTroop.members().length; j++) {
  318.     var enemy = $gameTroop.members()[j];
  319.     if (enemy._cp >= 10000) {
  320.       $gameTroop.increaseTurn();
  321.       this._phase = "enemy_action";
  322.       enemy.makeActions();
  323.       this._subject = enemy;
  324.       break;
  325.     }
  326.   }
  327.  
  328.   SceneManager._scene.updateCPBarWindow();
  329. };
  330.  
  331.  
  332. xsrongBattleManagerSelectNextCommand = BattleManager.selectNextCommand;
  333. BattleManager.selectNextCommand = function() {
  334.   do {
  335.     this.startTurn();
  336.     break;
  337.   } while (!this.actor().canInput());
  338. };
  339.  
  340. xsrongBattleManagerUpdateTurnEnd = BattleManager.updateTurnEnd;
  341. BattleManager.updateTurnEnd = function() {
  342.   this.xsrongWait();                                         // 一个战斗成员的行动结束后,继续等待行动槽涨满
  343. };
  344.  
  345. xsrongBattleManagerOnEncounter = BattleManager.onEncounter
  346. BattleManager.onEncounter = function() {
  347.   xsrongBattleManagerOnEncounter.call(this);
  348.   if ($gameSwitches._data[preemptiveSwitch]) {
  349.     this._preemptive = true;                                  // 强制先手的开关打开时,战斗强制先手
  350.   }
  351.   if (!$gameSwitches._data[preemptiveSwitch] && $gameSwitches._data[surpriseSwitch]) {
  352.     this._surprise = true;                                    // 强制被偷袭的开关打开时,战斗强制被偷袭
  353.   }
  354.   if ($gameSwitches._data[noPreemptiveAndSurprise]) {
  355.     this._preemptive = false;                                 // 先手和被偷袭无效的开关打开时,先手和被偷袭无效
  356.     this._surprise = false;                       
  357.   }
  358. };
  359.  
  360. xsrongBattleManagerProcessTurn = BattleManager.processTurn
  361. BattleManager.processTurn = function() {
  362.   var subject = this._subject;
  363.   var action = subject.currentAction();
  364.   if (action) {
  365.       action.prepare();
  366.       if (action.isValid()) {
  367.           this.startAction();
  368.       }
  369.       subject.removeCurrentAction();
  370.       subject._turnCount++ ;                                   // 行动结束后增加战斗成员的回合数
  371.       subject.onTurnEnd();                                     // 行动结束后更新战斗成员身上的状态
  372.   } else {
  373.       subject.onAllActionsEnd();
  374.       this.refreshStatus();
  375.       this._logWindow.displayAutoAffectedStatus(subject);
  376.       this._logWindow.displayCurrentState(subject);
  377.       this._logWindow.displayRegeneration(subject);
  378.       this._subject = this.getNextSubject();
  379.   }
  380. };
  381.  
  382. xsrongBattleManagerEndTurn = BattleManager.endTurn
  383. BattleManager.endTurn = function() {
  384.   this._phase = 'turnEnd';
  385.   this._preemptive = false;
  386.   this._surprise = false;
  387.   this.allBattleMembers().forEach(function(battler) {          // 取消了在这里更新战斗成员状态的代码
  388.       this.refreshStatus();
  389.       this._logWindow.displayAutoAffectedStatus(battler);
  390.       this._logWindow.displayRegeneration(battler);
  391.   }, this);
  392. };
  393.  
  394. // 读取技能和物品需要的cp
  395. Game_BattlerBase.prototype.skillCpCost = function(skill) {
  396.   var pat = /<CPCOST\s\d+>/;
  397.   var str = pat.exec(skill.note);
  398.   var cpCost;
  399.   if (str) {
  400.       cpCost = parseInt(str.input.split(" ")[1]);
  401.       cpCost = Math.min(cpCost, 10000)
  402.       cpCost = Math.max(cpCost, 0)
  403.   } else {
  404.       cpCost = 10000;
  405.   }
  406.   return cpCost;
  407. };
  408.  
  409. Game_Battler.prototype.useItem = function(item) {
  410.   if (DataManager.isSkill(item)) {
  411.       this.paySkillCost(item);
  412.   } else if (DataManager.isItem(item)) {
  413.       this.consumeItem(item);
  414.       if ($gameParty.inBattle()) {                           // 在战斗中使用物品会被扣除相应的cp
  415.         var cpCost = this.skillCpCost(item);
  416.         this._cp -= cpCost;
  417.       }
  418.   }
  419. };
  420.  
  421. xsrongGameBattlerBasePaySkillCost = Game_BattlerBase.prototype.paySkillCost;
  422. Game_BattlerBase.prototype.paySkillCost = function(skill) {
  423.   xsrongGameBattlerBasePaySkillCost.call(this, skill);
  424.   if ($gameParty.inBattle()) {
  425.     this._cp -= this.skillCpCost(skill);                      // 在战斗中使用技能会被扣除相应的cp
  426.   }
  427. };
  428.  
  429. xsrongGameBattlerBaseDie = Game_BattlerBase.prototype.die
  430. Game_BattlerBase.prototype.die = function() {
  431.   xsrongGameBattlerBaseDie.call(this);
  432.   this._cp = 0;                                               // 角色倒下时cp归零
  433. };
  434.  
  435.  
  436. xsrongWindowActorCommandMakeCommandList = Window_ActorCommand.prototype.makeCommandList;
  437. Window_ActorCommand.prototype.makeCommandList = function() {
  438.   if (this._actor) {
  439.       this.addAttackCommand();
  440.       this.addSkillCommands();
  441.       this.addGuardCommand();
  442.       this.addItemCommand();
  443.       this.addEscapeCommand();
  444.   }
  445. };
  446.  
  447. Window_ActorCommand.prototype.addEscapeCommand = function() {
  448.   this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
  449. };
  450.  
  451. xsrongGameInterpreterCommand301 = Game_Interpreter.prototype.command301;
  452. Game_Interpreter.prototype.command301 = function() {
  453.   if (!$gameParty.inBattle()) {
  454.       var troopId;
  455.       if (this._params[0] === 0) {  
  456.           troopId = this._params[1];
  457.       } else if (this._params[0] === 1) {  
  458.           troopId = $gameVariables.value(this._params[1]);
  459.       } else {  
  460.           troopId = $gamePlayer.makeEncounterTroopId();
  461.       }
  462.       if ($dataTroops[troopId]) {
  463.           BattleManager.setup(troopId, this._params[2], this._params[3]);
  464.           BattleManager.onEncounter();                         // 采用明雷遇敌时增加偷袭和被偷袭功能
  465.           BattleManager.setEventCallback(function(n) {
  466.               this._branch[this._indent] = n;
  467.           }.bind(this));
  468.           $gamePlayer.makeEncounterCount();
  469.           SceneManager.push(Scene_Battle);
  470.       }
  471.   }
  472.   return true;
  473. };
  474.  
  475. xsrongDataManagerSetupBattleTest = DataManager.setupBattleTest;
  476. DataManager.setupBattleTest = function() {
  477.   this.createGameObjects();
  478.   $gameParty.setupBattleTest();
  479.   BattleManager.setup($dataSystem.testTroopId, true, false);
  480.   BattleManager.onEncounter();                               // 战斗测试中增加偷袭和被偷袭功能
  481.   BattleManager.setBattleTest(true);
  482.   BattleManager.playBattleBgm();
  483. };
  484.  
  485. Window_Base.prototype.drawActorIcons = function(actor, x, y, width) {
  486.   width = width || 144;
  487.   var icons = actor.allIcons().slice(0, Math.floor(width / Window_Base._iconWidth));
  488.   var states = actor._states.filter(function(s){
  489.       return $dataStates[s].iconIndex > 0;
  490.   })
  491.   var text;
  492.   for (var i = 0; i < icons.length; i++) {                  // 在角色状态图标上增加剩余回合数
  493.       this.drawIcon(icons[i], x + (Window_Base._iconWidth + 8) * i, y + 2);
  494.       if (i < states.length) {
  495.           stateId = states[i]
  496.           if ($dataStates[stateId].autoRemovalTiming == 1) {
  497.               text = actor._stateTurns[stateId]             // 能够自动解除的状态显示剩余回合数
  498.           } else {
  499.               text = "∞"                                    // 不能自动解除的状态显示剩余回合数无限
  500.           }
  501.       } else {
  502.           text = actor._buffTurns[i - states.length]        // 显示角色身上buff的剩余回合数
  503.       }
  504.       this.drawIconText(text, x + (Window_Base._iconWidth + 8) * i + 24, y);
  505.   }
  506. };
  507.  
  508. Window_Base.prototype.drawIconText = function(text, x, y) {
  509.   var bitmap = new Bitmap(this.width, this.height);
  510.   bitmap.drawCircle(16, 16, 16, 'red');
  511.   bitmap.drawText(text, 0, 0, 32, 32, 'center');
  512.   this.contents.blt(bitmap, 0, 0, 32, 32, x, y, 12, 12);
  513. };
  514.  
  515. Sprite_Enemy.prototype.updateStateTurnSpriteText = function() {
  516.   var states = this._enemy._states.filter(function(s) {
  517.       return $dataStates[s].iconIndex > 0;
  518.   });
  519.   var text;
  520.   if (this._stateIconSprite._animationIndex < states.length) {        // 在敌人状态图标上增加剩余回合数
  521.       if ($dataStates[this._enemy._states[this._stateIconSprite._animationIndex]].autoRemovalTiming == 1) {
  522.         text = this._enemy._stateTurns[this._enemy._states[this._stateIconSprite._animationIndex]];   // 能够自动解除的状态显示剩余回合数
  523.       } else {
  524.         text = "∞";                                                   // 不能自动解除的状态显示剩余回合数无限
  525.       }
  526.   } else {
  527.       text = this._enemy._buffTurns[this._stateIconSprite._animationIndex - states.length];    // 显示敌人身上buff的剩余回合数
  528.   }
  529.   this.drawStateTurnSprite(text);
  530.  
  531.   if (states.length > 0) {
  532.       this._stateTurnSprite.opacity = 255
  533.   } else {
  534.       this._stateTurnSprite.opacity = 0
  535.   }
  536. };
  537.  
  538. Sprite_Enemy.prototype.update = function() {
  539.   Sprite_Battler.prototype.update.call(this);
  540.   if (this._enemy) {
  541.       this.updateEffect();
  542.       this.updateStateSprite();
  543.       this._stateTurnSprite.y = this._stateIconSprite.y - 20
  544.       this._stateTurnSprite.x = 8
  545.       this.updateStateTurnSpriteText();
  546.   }
  547. };
  548.  
  549. Sprite_Enemy.prototype.createStateTurnSprite = function() {
  550.   var bitmap = new Bitmap(12, 12)
  551.   bitmap.outlineWidth = 0;
  552.   bitmap.fontSize = 10;
  553.   sp = new Sprite(bitmap);
  554.   this._stateTurnSprite = sp;
  555.   this.addChild(this._stateTurnSprite);
  556. };
  557.  
  558. Sprite_Enemy.prototype.drawStateTurnSprite = function(text) {
  559.   bitmap = this._stateTurnSprite.bitmap
  560.   bitmap.drawCircle(6, 6, 6, 'red');
  561.   bitmap.drawText(text, 0, 0, 12, 12, 'center');
  562. };
  563.  
  564. Sprite_Enemy.prototype.initMembers = function() {
  565.   Sprite_Battler.prototype.initMembers.call(this);
  566.   this._enemy = null;
  567.   this._appeared = false;
  568.   this._battlerName = '';
  569.   this._battlerHue = 0;
  570.   this._effectType = null;
  571.   this._effectDuration = 0;
  572.   this._shake = 0;
  573.   this.createStateIconSprite();
  574.   this.createStateTurnSprite();
  575. };
  576.  
  577.  
  578. // 判断某个Game_Battler实例对象是否正在行动
  579. Game_Battler.prototype.isCurrentActionBattler = function() {
  580.   return currentActionBattler() === this;
  581. }
  582.  
  583. // 返回正在行动的战斗成员的回合数
  584. currentActionBattlerTurnCount = function() {
  585.   var battler = currentActionBattler();
  586.   if (battler) {
  587.     return battler._turnCount;
  588.   }
  589. }
  590.  
  591. // 返回正在行动的战斗成员。如没有正在行动的战斗成员,则返回null
  592. currentActionBattler = function() {
  593.   if (BattleManager._subject) {
  594.     return BattleManager._subject;
  595.   } else if (BattleManager.actor()) {
  596.     return BattleManager.actor()
  597.   } else {
  598.     return null
  599.   }
  600. }

1.png (1014.75 KB, 下载次数: 65)

半即时战斗截图

半即时战斗截图

Project1.zip

333.93 KB, 下载次数: 267

范例工程

评分

参与人数 3+3 收起 理由
dst1996 + 1 精品文章
白嫩白嫩的 + 1 精品文章
枫叶的北方 + 1 我很赞同

查看全部评分

Lv1.梦旅人

梦石
0
星屑
144
在线时间
43 小时
注册时间
2020-10-31
帖子
75
2
发表于 2022-6-20 16:15:18 | 只看该作者
太帅了,那么MZ能用吗?》
自作主张蛛后之后
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1385
在线时间
120 小时
注册时间
2022-5-22
帖子
70
3
发表于 2022-6-23 07:14:05 | 只看该作者
这么长的代码,支持!
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3375
在线时间
175 小时
注册时间
2022-6-12
帖子
19
4
发表于 2022-6-23 07:56:59 | 只看该作者
支持楼主。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
992
在线时间
108 小时
注册时间
2022-7-2
帖子
149
5
发表于 2022-7-6 09:10:42 | 只看该作者
6666666666
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-26 22:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表