扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 140|回复: 0

[转载发布] 自制半即时战斗系统

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    2025-2-4 02:05
  • 签到天数: 110 天

    连续签到: 2 天

    [LV.6]常住居民II

    2327

    主题

    395

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10475
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13225

    灌水之王

    发表于 2024-3-4 10:06:34 | 显示全部楼层 |阅读模式
    发一个自制的半即时战斗系统,长相就是下面图片的样子……
    不太会用的也可以参考范例工程~

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

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


                 本帖来自P1论坛作者xsrong2,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=479546  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-10 22:15 , Processed in 0.086446 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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