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

Project1

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

[已经解决] 请问谁有mog_chaincommand的代码?

[复制链接]

Lv2.观梦者

梦石
0
星屑
440
在线时间
679 小时
注册时间
2014-3-15
帖子
292

开拓者

跳转到指定楼层
1
发表于 2017-5-24 19:08:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
打算把RGSS3的chaincommand(不是技能的,是大地图上的)给移植到MV上,苦于电脑不是windows的没法用RMVA打开,有谁手里有这个代码麻烦给我一份,多谢啦

Lv1.梦旅人

梦石
0
星屑
216
在线时间
154 小时
注册时间
2017-2-27
帖子
167

开拓者

2
发表于 2017-5-24 19:46:58 | 只看该作者
  1. //=============================================================================
  2. // MOG_ChainCommands.js
  3. //=============================================================================

  4. /*:
  5. * @plugindesc (v1.3) Skill Chain Combos.
  6. * @author Moghunter
  7. *
  8. * @param X-Axis
  9. * @desc General X-axis definition.
  10. * @default 0
  11. *
  12. * @param Y-Axis
  13. * @desc General Y-axis definition.
  14. * @default 0
  15. *
  16. * @param Key X-Axis
  17. * @desc Definition of the X-axis of the button.
  18. * @default 16
  19. *
  20. * @param Key Y-Axis
  21. * @desc Y-axis definition of the button.
  22. * @default -32
  23. *
  24. * @param Gauge X-Axis
  25. * @desc X-axis definition of the time meter.
  26. * @default 17
  27. *
  28. * @param Gauge Y-Axis
  29. * @desc Y-axis definition of the time meter.
  30. * @default 1
  31. *
  32. * @param Name X-Axis
  33. * @desc X-axis definition of the skill name.
  34. * @default 15
  35. *
  36. * @param Name Y-Axis
  37. * @desc Y-axis definition of the skill name.
  38. * @default 18
  39. *
  40. * @help
  41. * ================================================================= ============================
  42. * +++ MOG - Chain Commands (v1.3) +++
  43. * By Moghunter
  44. * https://atelierrgss.wordpress.com/
  45. * ================================================================= ============================
  46. * The system allows you to execute combos by executing the sequence of buttons.
  47. * The files will be needed. (img/system/)
  48. *
  49. * Chain_A.png
  50. * Chain_B.png
  51. * Chain_B.png
  52. *
  53. * ================================================================= ============================
  54. * USE
  55. * ================================================================= ============================
  56. * Use the comment below in the skill notes box.
  57. *
  58. * Chain Action: SKILL_ID: NUMBER_OF_INPUTS: INPUT_TIME
  59. *
  60. * SKILL_ID - Skill ID.
  61. * NUMBER_OF_INPUTS - Number of times to push the button.
  62. * INPUT_TIME - Time to press the buttons.
  63. *
  64. * (Example)
  65. *
  66. * Chain Action: 10: 5: 60
  67. * ================================================================= ============================
  68. * HITÓRICO
  69. * ================================================================= ============================
  70. * (1.3) - Fixed the error of activating the command at the end of the battle.
  71. * (1.2) - Fixed the compatibility code.
  72. * (1.1) - Fixed the error of allowing input during the collapse of the enemy.
  73. *
  74. */

  75. //=============================================================================
  76. // ** PLUGIN PARAMETERS
  77. //=============================================================================
  78.   var Imported = Imported || {};
  79.   Imported.MOG_ChainCommands = true;
  80.   var Moghunter = Moghunter || {};

  81.    Moghunter.parameters = PluginManager.parameters('MOG_ChainCommands');
  82.         Moghunter.chainCom_x = Number(Moghunter.parameters['X-Axis'] || 0);
  83.         Moghunter.chainCom_y = Number(Moghunter.parameters['Y-Axis'] || 0);
  84.         Moghunter.chainCom_Key_x = Number(Moghunter.parameters['Key X-Axis'] || 16);
  85.         Moghunter.chainCom_Key_y = Number(Moghunter.parameters['Key Y-Axis'] || -32);
  86.         Moghunter.chainCom_Meter_x = Number(Moghunter.parameters['Gauge X-Axis'] || 17);
  87.         Moghunter.chainCom_Meter_y = Number(Moghunter.parameters['Gauge Y-Axis'] || 1);
  88.         Moghunter.chainCom_Name_x = Number(Moghunter.parameters['Name X-Axis'] || 15);
  89.         Moghunter.chainCom_Name_y = Number(Moghunter.parameters['Name Y-Axis'] || 18);
  90.        
  91. //=============================================================================
  92. // ** Game Temp
  93. //=============================================================================

  94. //==============================
  95. // * Initialize
  96. //==============================
  97. var _alias_mog_bchain_gtemp_initialize = Game_Temp.prototype.initialize;
  98. Game_Temp.prototype.initialize = function() {
  99.         _alias_mog_bchain_gtemp_initialize.call(this);
  100.         this._bchainTemp = false;
  101.         this.clearBchain();
  102. };

  103. //==============================
  104. // * Clear Bchain
  105. //==============================
  106. Game_Temp.prototype.clearBchain = function() {
  107.     this._bchainData = [false,null,null,null,null,0,0,null,false,false,false,false];
  108. };

  109. //=============================================================================
  110. // ** Game Action
  111. //=============================================================================

  112. //==============================
  113. // * applyItemUserEffect
  114. //==============================
  115. var _mog_bchain_gaction_applyItemUserEffect = Game_Action.prototype.applyItemUserEffect;
  116. Game_Action.prototype.applyItemUserEffect = function(target) {
  117.         $gameTemp._bchainData[11] = true;
  118.         _mog_bchain_gaction_applyItemUserEffect.call(this,target)
  119. };

  120. //=============================================================================
  121. // ** Battle Manager
  122. //=============================================================================

  123. //==============================
  124. // * Start Action
  125. //==============================
  126. var _mog_bchain_bmngr_startAction = BattleManager.startAction;
  127. BattleManager.startAction = function() {
  128.          $gameTemp.clearBchain();
  129.          if (this.canCheckChainCommands()) {this.checkChainAction()};
  130.         _mog_bchain_bmngr_startAction.call(this);
  131. };

  132. //==============================
  133. // * Can Check Chain Commands
  134. //==============================
  135. BattleManager.canCheckChainCommands = function() {
  136.         if (this._subject.isEnemy()) {return false};
  137.     if (!this._subject.currentAction()) {return false};
  138.         if (!this._subject.currentAction().item()) {return false};
  139.         return true;
  140. };

  141. //==============================
  142. // * Check Chain Action
  143. //==============================
  144. BattleManager.checkChainAction = function() {       
  145.         var item = this._subject.currentAction().item();
  146.         var item_notes = item.note.split(/[\r\n]+/);
  147.     item_notes.forEach(function(note) {
  148.          var note_data = note.split(': ')
  149.                  if (note_data[0].toLowerCase() == "chain action"){                         
  150.                          var par = note_data[1].split(':');
  151.                          var action = $dataSkills[Number(par[0])];
  152.                       var times = Math.min(Math.max(Number(par[1]),1),999);
  153.                          var duration = Math.min(Math.max(Number(par[2]),10),999);                         
  154.                          if (action) {
  155.                             $gameTemp._bchainData[1] = action;
  156.                                 $gameTemp._bchainData[6] = times;
  157.                                 $gameTemp._bchainData[7] = duration;
  158.                          };
  159.          };
  160.         },this);
  161. };

  162. //==============================
  163. // * Invoke Action
  164. //==============================
  165. var _mog_bchain_bmngr_invokeAction = BattleManager.invokeAction;
  166. BattleManager.invokeAction = function(subject, target) {
  167.     if ($gameTemp._bchainData[1]) {BattleManager.setBchainPosition(subject, target)};
  168.         _mog_bchain_bmngr_invokeAction.call(this,subject, target);       
  169. };

  170. //==============================
  171. // * set Bchain Position
  172. //==============================
  173. BattleManager.setBchainPosition = function(subject, target) {
  174.         if (this._subject.isActor()) {
  175.                 $gameTemp._bchainData[8] = target;
  176.                 if ($gameTemp._bchainData[1].scope === 1 ||
  177.                     $gameTemp._bchainData[1].scope === 7 ||
  178.                         $gameTemp._bchainData[1].scope === 9) {
  179.                         $gameTemp._bchainData[4] = target;
  180.                 } else {
  181.                 if ($gameSystem.isSideView()) {
  182.                             $gameTemp._bchainData[4] = this._subject;
  183.                         } else {
  184.                                 $gameTemp._bchainData[2] = Graphics.boxWidth / 2;
  185.                                 $gameTemp._bchainData[3] = Graphics.boxHeight / 2;               
  186.                         };       
  187.                 };
  188.         };
  189. };       
  190.        
  191. //==============================
  192. // * End Action
  193. //==============================
  194. var _mog_bchain_bmngr_endAction = BattleManager.endAction;
  195. BattleManager.endAction = function() {
  196.         if (BattleManager.canUseChainAction()) {
  197.                 $gameTemp._bchainData[0] = true;
  198.                 $gameTemp._bchainTemp = true;
  199.                 if ($gameTemp._bchainData[9]) {this.executeChainAction()};
  200.                 return;
  201.           };
  202.          _mog_bchain_bmngr_endAction.call(this);
  203.          $gameTemp.clearBchain();
  204.          $gameTemp._bchainTemp = false;
  205. };

  206. //==============================
  207. // * can Use Chain Action
  208. //==============================
  209. BattleManager.canUseChainAction = function() {
  210.         if (!$gameTemp._bchainData[1]) {return false};
  211.         if (!$gameTemp._bchainData[11]) {return false};
  212.         if (!this._subject) {return false};
  213.         if (!this._subject.canInput()) {return false};
  214.         if (this._subject.isDead()) {return false};
  215.         if ($gameParty.isAllDead()) {return false};
  216.         if ($gameTroop.isAllDead()) {return false};
  217.         if (!this._subject.canUse($gameTemp._bchainData[1])) {return false};
  218.         if ($gameTemp._bchainData[1].scope === 1 ||
  219.                  $gameTemp._bchainData[1].scope === 7 ||
  220.                  $gameTemp._bchainData[1].scope === 9) {
  221.              if (!$gameTemp._bchainData[8]) {return false};
  222.                  if ($gameTemp._bchainData[8].isDead()) {return false};
  223.     }
  224.         return true;
  225. };

  226. //==============================
  227. // * execute Chain Action
  228. //==============================
  229. BattleManager.executeChainAction = function() {
  230.         if ($gameTemp._bchainData[10]) {
  231.             this._subject.forceAction($gameTemp._bchainData[1].id, -2);               
  232.                 $gameTemp.clearBchain();
  233.             BattleManager.processTurn();
  234.         } else {
  235.                 $gameTemp.clearBchain();
  236.         };
  237. };

  238. //=============================================================================
  239. // ** Sprite Battler
  240. //=============================================================================

  241. //==============================
  242. // * update Main
  243. //==============================
  244. var _mog_bchain_sprbattler_updateMain = Sprite_Battler.prototype.updateMain;
  245. Sprite_Battler.prototype.updateMain = function() {
  246.         _mog_bchain_sprbattler_updateMain.call(this);
  247.         if (this.needUpdateBchainPosition()) {this.updateBchainPosition()};
  248. };

  249. //==============================
  250. // * need Update Bchain Pos
  251. //==============================
  252. Sprite_Battler.prototype.needUpdateBchainPosition = function() {
  253.    if (!$gameTemp._bchainData[4]) {return false};
  254.    if ($gameTemp._bchainData[4] != this._battler) {return false};
  255.    return true;       
  256. };

  257. //==============================
  258. // * update B Chain Position
  259. //==============================
  260. Sprite_Battler.prototype.updateBchainPosition = function() {
  261.         $gameTemp._bchainData[2] = this.x;
  262.         $gameTemp._bchainData[3] = this.y;
  263.         if (this._mainSprite) {
  264.         $gameTemp._bchainData[3] -= this._mainSprite.height;
  265.         } else if (this._bitmap) {       
  266.             $gameTemp._bchainData[3] -= this._bitmap.height / 2;
  267.         };
  268. };

  269. //=============================================================================
  270. // ** Spriteset Battle
  271. //=============================================================================

  272. //==============================
  273. // * create Upper Layer
  274. //==============================
  275. var _mog_bchain_sprset_createUpperLayer = Spriteset_Battle.prototype.createUpperLayer;
  276. Spriteset_Battle.prototype.createUpperLayer = function() {
  277.         _mog_bchain_sprset_createUpperLayer.call(this);
  278.     this.createBchain();       
  279. };

  280. //==============================
  281. // * create B Chain
  282. //==============================
  283. Spriteset_Battle.prototype.createBchain = function() {
  284.     this._bchain = new BattleChainSprite();
  285.         this._bchain.z = 25;
  286.         this.addChild(this._bchain);
  287. };

  288. //==============================
  289. // * Update
  290. //==============================
  291. var _mog_bchain_sprtbat_update = Spriteset_Battle.prototype.update;
  292. Spriteset_Battle.prototype.update = function() {
  293.     _mog_bchain_sprtbat_update.call(this)
  294.         if (this._bchain && Imported.MOG_BattleCamera) {
  295.            this._bchain.x = this._battleField.x;
  296.            this._bchain.y = this._battleField.y;
  297.         };
  298. };

  299. if (Imported.MOG_BattleCamera) {
  300.         //==============================
  301.         // * Update Focus
  302.         //==============================
  303.         var _mog_bchaincom_sprbat_updateFocus = Spriteset_Battle.prototype.updateFocus;
  304.         Spriteset_Battle.prototype.updateFocus = function() {
  305.                 if ($gameTemp._bchainTemp) {$gameTemp._bcam_user[2] = 0};
  306.                 _mog_bchaincom_sprbat_updateFocus.call(this);
  307.         };
  308. };

  309. //=============================================================================
  310. // * Battle Chain Sprite
  311. //=============================================================================
  312. function BattleChainSprite() {
  313.     this.initialize.apply(this, arguments);
  314. };

  315. BattleChainSprite.prototype = Object.create(Sprite.prototype);
  316. BattleChainSprite.prototype.constructor = BattleChainSprite;

  317. //==============================
  318. // * Initialize
  319. //==============================
  320. BattleChainSprite.prototype.initialize = function() {
  321.     Sprite.prototype.initialize.call(this);       
  322.         this.z = 25;
  323.         this._data = [-1,-1,false];
  324.         this._keyIndex = 0;
  325.         this._duration = 0;
  326.     this.loadImages();
  327.         this.createLayout();
  328.         this.createMeter();       
  329.         this.createKeys();
  330.         this.createName();
  331. };

  332. //==============================
  333. // * Load Images
  334. //==============================
  335. BattleChainSprite.prototype.loadImages = function() {
  336.         this._keysImg = ImageManager.loadSystem("Chain_A");
  337.         this._layoutImg = ImageManager.loadSystem("Chain_B");
  338.         this._meterImg = ImageManager.loadSystem("Chain_C");
  339. };

  340. //==============================
  341. // * getData
  342. //==============================
  343. BattleChainSprite.prototype.getData = function() {       
  344.     this._data[0] = Math.floor(this._keysImg.width / 6);
  345.         this._data[1] = this._keysImg.height;
  346. };

  347. //==============================
  348. // * create Layout
  349. //==============================
  350. BattleChainSprite.prototype.createLayout = function() {       
  351.         this._layout = new Sprite(this._layoutImg);
  352.         this._layout.opacity = 0;
  353.         this._layout.anchor.x = 0.5;
  354.         this._layout.anchor.y = 0.5;
  355.         this.addChild(this._layout);
  356. };

  357. //==============================
  358. // * create Name
  359. //==============================
  360. BattleChainSprite.prototype.createName = function() {
  361.         this._name = new Sprite(new Bitmap(100,32));
  362.         this._name.opacity = 0;
  363.         this._name.anchor.x = 0.5;
  364.         this._name.anchor.y = 0.5;
  365.         this._name.bitmap.fontSize = 20;
  366.         this.addChild(this._name);
  367. };

  368. //==============================
  369. // * create Keys
  370. //==============================
  371. BattleChainSprite.prototype.createKeys = function() {
  372.         this._keys = new Sprite(this._keysImg);
  373.         this._keys.opacity = 0;
  374.         this._keys.anchor.x = 0.5;
  375.         this._keys.anchor.y = 0.5;       
  376.         this.addChild(this._keys);
  377. };

  378. //==============================
  379. // * create Meter
  380. //==============================
  381. BattleChainSprite.prototype.createMeter = function() {
  382.         this._meter = new Sprite(this._meterImg);
  383.         this._meter.opacity = 0;
  384.         this._meter.anchor.x = 0;
  385.         this._meter.anchor.y = 0.5;       
  386.         this.addChild(this._meter);       
  387. };

  388. //==============================
  389. // * Need Refresh
  390. //==============================
  391. BattleChainSprite.prototype.needRefresh = function() {
  392.         if ($gameTemp._bchainData[0] == this._data[2]) {return false};
  393.         if (!this.item()) {return false};
  394.         if (!this.posX()) {return false};
  395.         return true;
  396. };

  397. //==============================
  398. // * Item
  399. //==============================
  400. BattleChainSprite.prototype.item = function() {
  401.    return $gameTemp._bchainData[1];
  402. };

  403. //==============================
  404. // * posX
  405. //==============================
  406. BattleChainSprite.prototype.posX = function() {
  407.    return $gameTemp._bchainData[2] + Moghunter.chainCom_x;
  408. };

  409. //==============================
  410. // * posY
  411. //==============================
  412. BattleChainSprite.prototype.posY = function() {
  413.    return $gameTemp._bchainData[3] + Moghunter.chainCom_y;
  414. };

  415. //==============================
  416. // * Times
  417. //==============================
  418. BattleChainSprite.prototype.times = function() {
  419.    return $gameTemp._bchainData[6];
  420. };

  421. //==============================
  422. // * Duration
  423. //==============================
  424. BattleChainSprite.prototype.duration = function() {
  425.    return $gameTemp._bchainData[7];
  426. };

  427. //==============================
  428. // * Refresh
  429. //==============================
  430. BattleChainSprite.prototype.refresh = function() {       
  431.         this._data[2] = $gameTemp._bchainData[0];
  432.         this._duration = this.duration();
  433.         this._layout.opacity = 255;
  434.         this._keys.opacity = 255;
  435.         this._keys.scale.x = 2.0;
  436.         this._keys.scale.y = 2.0;
  437.         this._meter.opacity = 255;
  438.         this._name.opacity = 255;
  439.         this._name.bitmap.clear();
  440.         this._name.bitmap.drawText(this.item().name,0,0,100,32,"center");
  441.         this._keys.setFrame(this._data[0] * this._keyIndex,0,this._data[0],this._data[1]);
  442. };

  443. //==============================
  444. // * need Update Action
  445. //==============================
  446. BattleChainSprite.prototype.needUpdateAction = function() {
  447.         if (!this.item()) {return false};
  448.         if (!this.posX()) {return false};
  449.         if (this._layout.opacity == 0) {return false};
  450.         return true;
  451. };

  452. //==============================
  453. // * Update Action
  454. //==============================
  455. BattleChainSprite.prototype.updateAction = function() {
  456.      this.updatePosition();
  457.          this.updateCommands();
  458.          if (this._duration > 0) {this.updateTime()};
  459. };

  460. //==============================
  461. // * Update Action
  462. //==============================
  463. BattleChainSprite.prototype.updateTime = function() {
  464.       this._duration --
  465.       this.updateMeter();
  466.           if (this._duration <= 0) {this.setWrong();};
  467. };

  468. //==============================
  469. // * Update Meter
  470. //==============================
  471. BattleChainSprite.prototype.updateMeter = function() {
  472.           var rate = this._duration * this._meterImg.width / this.duration();
  473.           this._meter.setFrame(0,0,rate,this._meterImg.height)
  474. };

  475. //==============================
  476. // * Update Action
  477. //==============================
  478. BattleChainSprite.prototype.check_key = function(value) {
  479.     if (value == this._keyIndex) {               
  480.             this.nextKey();
  481.         } else {
  482.         this.setWrong();
  483.         };
  484. };

  485. //==============================
  486. // * set Wrong
  487. //==============================
  488. BattleChainSprite.prototype.setWrong = function(value) {
  489.         SoundManager.playBuzzer();
  490.         this.clearCommands();
  491. };

  492. //==============================
  493. // * Next Key
  494. //==============================
  495. BattleChainSprite.prototype.nextKey = function(value) {
  496.         if (this.times() <= 0) {this.enableAction();return};       
  497.         SoundManager.playCursor();
  498.     this._keyIndex = Math.randomInt(6);
  499.         $gameTemp._bchainData[6] -= 1;
  500.         this.refresh();
  501. };

  502. //==============================
  503. // * enable Action
  504. //==============================
  505. BattleChainSprite.prototype.enableAction = function(value) {
  506.         SoundManager.playUseSkill();
  507.         $gameTemp._bchainData[10] = true;
  508.         this.clearCommands();
  509. };

  510. //==============================
  511. // * Set Wrong
  512. //==============================
  513. BattleChainSprite.prototype.clearCommands = function() {
  514.         this._layout.opacity = 0;
  515.         this._keys.opacity = 0;
  516.         this._meter.opacity = 0;
  517.         this._name.opacity = 0;       
  518.         this._duration = 0;
  519.         this._data[2] = false;
  520.         $gameTemp._bchainData[9] = true;
  521. };

  522. //==============================
  523. // * Update Commands
  524. //==============================
  525. BattleChainSprite.prototype.updateCommands = function() {
  526.         if (Input.isTriggered("right")) {this.check_key(0)}
  527.         else if (Input.isTriggered("left")) {this.check_key(1)}
  528.         else if (Input.isTriggered("down")) {this.check_key(2)}
  529.         else if (Input.isTriggered("up")) {this.check_key(3)}
  530.         else if (Input.isTriggered("ok")) {this.check_key(4)}
  531.         else if (Input.isTriggered("cancel")) {this.check_key(5)}        ;
  532. };

  533. //==============================
  534. // * Update Position
  535. //==============================
  536. BattleChainSprite.prototype.updatePosition = function() {
  537.         this._layout.x = this.posX();
  538.         this._layout.y = this.posY();
  539.         this._keys.x = this.posX() + Moghunter.chainCom_Key_x;
  540.         this._keys.y = this.posY() + Moghunter.chainCom_Key_y;       
  541.         this._meter.x = this.posX() - (this._meterImg.width / 2) + Moghunter.chainCom_Meter_x;
  542.         this._meter.y = this.posY() + Moghunter.chainCom_Meter_y;                
  543.     this._name.x = this.posX() + Moghunter.chainCom_Name_x;
  544.     this._name.y = this.posY() + Moghunter.chainCom_Name_y;
  545. };

  546. //==============================
  547. // * Update
  548. //==============================
  549. BattleChainSprite.prototype.update = function() {
  550.     Sprite.prototype.update.call(this);       
  551.         if (this._data[0] === -1) {
  552.            if (this._keysImg.isReady() && this._meterImg.isReady()) {this.getData()};
  553.            return;
  554.     };
  555.         if (this.needRefresh()) {this.nextKey()};
  556.         if (this.needUpdateAction()) {this.updateAction()};
  557.         if (this._keys.scale.x > 1.00) {this._keys.scale.x -= 0.1};
  558.         this._keys.scale.y = this._keys.scale.x
  559. };
复制代码

是这个吗

点评

不是这个啊……RGSS3 – Chain Commands m  发表于 2017-5-24 20:29
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
15517
在线时间
3951 小时
注册时间
2015-9-14
帖子
1333

开拓者

3
发表于 2017-5-24 19:57:15 | 只看该作者
本帖最后由 wabcmcc 于 2017-5-24 20:35 编辑

MOG - Chain Commands (v1.4)
https://atelierrgss.wordpress.com/rgss3-chain-commands-m/
代码复制
  1. #===============================================================================
  2. # +++ MOG - Chain Commands (v1.4) +++
  3. #===============================================================================
  4. # By Moghunter                                                               
  5. # [url]https://atelierrgss.wordpress.com/[/url]                  
  6. #===============================================================================
  7. # Sistema de sequência de botões para ativar switchs.
  8. #
  9. # Serão necessárias as seguintes imagens. (Graphics/System)
  10. #
  11. # Chain_Cursor.png
  12. # Chain_Command.png
  13. # Chain_Layout.png
  14. # Chain_Timer_Layout.png
  15. # Chain_Timer_Meter.png
  16. #
  17. #===============================================================================
  18. #
  19. # Para ativar o script use o comando abaixo.  (*Call Script)
  20. #
  21. # chain_commands(ID)
  22. #
  23. # ID - Id da switch.
  24. #
  25. #===============================================================================
  26.  
  27. #==============================================================================
  28. # ● Histórico (Version History)
  29. #==============================================================================
  30. # v 1.4 - Correção do crash aleatório.
  31. # v 1.3 - Melhoria no sistema de dispose
  32. # v 1.2 - Melhoria na codificação e correção de alguns glitches.
  33. # v 1.1 - Animação de fade ao sair da cena de chain.
  34. #       - Opção de definir a prioridade da hud na tela.
  35. #==============================================================================
  36.  
  37. module MOG_CHAIN_COMMANDS
  38. #==============================================================================
  39. # CHAIN_COMMAND = { SWITCH_ID => [COMMAND] }
  40. #
  41. # SWITCH_ID = ID da switch
  42. # COMMANDS = Defina aqui a sequência de botões.
  43. #            (Para fazer a sequência use os comandos abaixo)   
  44. #  
  45. # "Down" ,"Up" ,"Left" ,"Right" ,"Shift" ,"D" ,"S" ,"A" ,"Z" ,"X" ,"Q" ,"W"
  46. #
  47. # Exemplo de utilização
  48. #
  49. # CHAIN_SWITCH_COMMAND = {
  50. # 25=>["Down","D","S","Right"],
  51. # 59=>["Down","Up","Left","Right","Shift","D","S","A","Z","X","Q","W"],
  52. # 80=>["Shift","D"]
  53. # }
  54. #==============================================================================
  55. CHAIN_SWITCH_COMMAND = {
  56. 5=>["X","Right","Left","Z","Z"],
  57. 6=>["Left","Right","Left","Right","Left","Right","Q","Z","Up","A","S",
  58.       "Down","D","Z","Right","Up","Up","Z","W","Left","Down","D","A","W"],
  59. 8=>["Up","Down","Left","Right","Z"]
  60. }
  61. #Duração para colocar os comandos. (A duração é multiplicado pela quantidade
  62. #de comandos) *60 = 1 sec
  63. CHAIN_INPUT_DURATION = 30
  64. #Som ao acertar.
  65. CHAIN_RIGHT_SE = "Chime1"
  66. #Som ao errar.
  67. CHAIN_WRONG_SE = "Buzzer1"
  68. #Switch que ativa o modo automático.
  69. CHAIN_AUTOMATIC_MODE_SWITCH_ID = 20
  70. #Definição da prioridade da hud na tela
  71. CHAIN_HUD_Z = 300
  72. end
  73.  
  74.  
  75. #===============================================================================
  76. # ■ Chain Commands
  77. #===============================================================================
  78. class Chain_Commands
  79.    include MOG_CHAIN_COMMANDS
  80. #--------------------------------------------------------------------------
  81. # ● Initialize
  82. #--------------------------------------------------------------------------      
  83.   def initialize
  84.       @action_id = $game_temp.chain_switch_id
  85.       @chain_command = CHAIN_SWITCH_COMMAND[@action_id]
  86.       @chain_command = ["?"] if @chain_command == nil  
  87.       duration = [[CHAIN_INPUT_DURATION, 1].max, 9999].min
  88.       @timer_max = duration * @chain_command.size
  89.       @timer = @timer_max
  90.       @slide_time = [[60 / duration, 10].max, 60].min
  91.       @change_time = 0
  92.       if $game_switches[CHAIN_AUTOMATIC_MODE_SWITCH_ID]
  93.          @auto = true
  94.       else
  95.          @auto = false
  96.       end
  97.       @com = 0  
  98.   end   
  99.  
  100. #--------------------------------------------------------------------------
  101. # ● Main
  102. #--------------------------------------------------------------------------     
  103. def main
  104.      dispose
  105.      @background_sprite = Sprite.new
  106.      @background_sprite.bitmap = SceneManager.background_bitmap2
  107.      create_chain_command
  108.      create_cusrsor
  109.      create_layout
  110.      create_meter
  111.      create_text
  112.      create_number
  113.      Graphics.transition
  114.      loop do
  115.           Graphics.update
  116.            Input.update
  117.            update
  118.            break if SceneManager.scene != self
  119.      end
  120.      dispose
  121. end  
  122.  
  123. #--------------------------------------------------------------------------
  124. # ● Create Cursor
  125. #--------------------------------------------------------------------------            
  126. def create_cusrsor
  127.      @fy_time = 0
  128.      @fy = 0
  129.      @com_index = 0
  130.      @cursor = Sprite.new
  131.      @cursor.bitmap = Cache.system("Chain_Cursor")
  132.      @cursor.z = 4 + CHAIN_HUD_Z
  133.      @cursor_space = ((@bitmap_cw + 5) * @chain_command.size) / 2
  134.      if @chain_command.size <= 20
  135.         @cursor.x = (544 / 2) - @cursor_space + @cursor_space * @com_index
  136.      else   
  137.         @cursor.x = (544 / 2)
  138.      end  
  139.      @cursor.y = (416 / 2) + 30   
  140. end
  141.  
  142. #--------------------------------------------------------------------------
  143. # ● Create Chain Command
  144. #--------------------------------------------------------------------------      
  145. def create_chain_command
  146.      @image = Cache.system("Chain_Command")     
  147.      width_max = ((@image.width / 13) + 5) * @chain_command.size
  148.      @bitmap = Bitmap.new(width_max,@image.height * 2)
  149.      @bitmap_cw = @image.width / 13
  150.      @bitmap_ch = @image.height  
  151.      index = 0
  152.      for i in @chain_command
  153.          command_list_check(i)
  154.          bitmap_src_rect = Rect.new(@com * @bitmap_cw, 0, @bitmap_cw, @bitmap_ch)
  155.          if index == 0
  156.             @bitmap.blt(index * (@bitmap_cw + 5) , 0, @image, bitmap_src_rect)
  157.          else
  158.             @bitmap.blt(index * (@bitmap_cw + 5) , @bitmap_ch, @image, bitmap_src_rect)
  159.          end
  160.          index += 1
  161.      end
  162.      @sprite = Sprite.new
  163.      @sprite.bitmap = @bitmap
  164.      if @chain_command.size <= 15
  165.         @sprite.x = (544 / 2) - ((@bitmap_cw + 5) * @chain_command.size) / 2
  166.         @new_x = 0
  167.      else   
  168.         @sprite.x = (544 / 2)
  169.         @new_x = @sprite.x
  170.      end   
  171.      @sprite.y = (416 / 2) + 30  - @bitmap_ch  - 15
  172.      @sprite.z = 3 + CHAIN_HUD_Z
  173.      @sprite.zoom_x = 1.5
  174.      @sprite.zoom_y = 1.5
  175. end
  176.  
  177. #--------------------------------------------------------------------------
  178. # * create_layout
  179. #--------------------------------------------------------------------------  
  180. def create_layout
  181.      @back = Plane.new
  182.      @back.bitmap = Cache.system("Chain_Layout")
  183.      @back.z = 0
  184.      @layout = Sprite.new
  185.      @layout.bitmap = Cache.system("Chain_Timer_Layout")
  186.      @layout.z = 1 + CHAIN_HUD_Z
  187.      @layout.x = 160
  188.      @layout.y = 150
  189.   end
  190.  
  191. #--------------------------------------------------------------------------
  192. # * create_meter
  193. #--------------------------------------------------------------------------  
  194. def create_meter
  195.      @meter_flow = 0
  196.      @meter_image = Cache.system("Chain_Timer_Meter")
  197.      @meter_bitmap = Bitmap.new(@meter_image.width,@meter_image.height)
  198.      @meter_range = @meter_image.width / 3
  199.      @meter_width = @meter_range * @timer / @timer_max
  200.      @meter_height = @meter_image.height
  201.      @meter_src_rect = Rect.new(@meter_range, 0, @meter_width, @meter_height)
  202.      @meter_bitmap.blt(0,0, @meter_image, @meter_src_rect)
  203.      @meter_sprite = Sprite.new
  204.      @meter_sprite.bitmap = @meter_bitmap
  205.      @meter_sprite.z = 2 + CHAIN_HUD_Z
  206.      @meter_sprite.x = 220
  207.      @meter_sprite.y = 159
  208.      update_flow
  209. end  
  210.  
  211. #--------------------------------------------------------------------------
  212. # ● Create Text
  213. #--------------------------------------------------------------------------        
  214. def create_text
  215.      @text = Sprite.new
  216.      @text.bitmap = Bitmap.new(200,32)
  217.      @text.z = 2 + CHAIN_HUD_Z
  218.      @text.bitmap.font.name = "Georgia"
  219.      @text.bitmap.font.size = 25
  220.      @text.bitmap.font.bold = true
  221.      @text.bitmap.font.italic = true
  222.      @text.bitmap.font.color.set(255, 255, 255,220)
  223.      @text.x = 230
  224.      @text.y = 100
  225. end
  226.  
  227. #--------------------------------------------------------------------------
  228. # ● Create Number
  229. #--------------------------------------------------------------------------        
  230. def create_number
  231.      @combo = 0
  232.      @number = Sprite.new
  233.      @number.bitmap = Bitmap.new(200,64)
  234.      @number.z = 2 + CHAIN_HUD_Z
  235.      @number.bitmap.font.name = "Arial"
  236.      @number.bitmap.font.size = 24
  237.      @number.bitmap.font.bold = true
  238.      @number.bitmap.font.color.set(0, 255, 255,200)
  239.      @number.bitmap.draw_text(0, 0, 200, 32, "Ready",1)         
  240.      @number.x = 30
  241.      @number.y = 100
  242. end
  243.  
  244. #--------------------------------------------------------------------------
  245. # ● Pre Dispose
  246. #--------------------------------------------------------------------------      
  247. def exit
  248.      loop do
  249.          Graphics.update
  250.          @sprite.x += 5
  251.          @layout.x -= 5
  252.          @meter_sprite.x -= 5
  253.          @text.x -= 2
  254.          @text.opacity -= 5
  255.          @sprite.opacity -= 5
  256.          @layout.opacity -= 5
  257.          @meter_sprite.opacity -= 5
  258.          @number.opacity -= 5
  259.          @back.opacity -= 5
  260.          @cursor.visible = false   
  261.          break if @sprite.opacity == 0
  262.      end
  263.      SceneManager.call(Scene_Map)
  264. end
  265.  
  266. #--------------------------------------------------------------------------
  267. # ● Dispose
  268. #--------------------------------------------------------------------------      
  269. def dispose
  270.      return if @layout == nil
  271.      Graphics.freeze
  272.      @background_sprite.bitmap.dispose
  273.      @background_sprite.dispose
  274.      @bitmap.dispose
  275.      @sprite.bitmap.dispose
  276.      @sprite.dispose
  277.      @cursor.bitmap.dispose
  278.      @cursor.dispose  
  279.      @meter_image.dispose
  280.      @meter_bitmap.dispose
  281.      @meter_sprite.bitmap.dispose
  282.      @meter_sprite.dispose
  283.      @layout.bitmap.dispose  
  284.      @layout.dispose
  285.      @layout = nil
  286.      @back.bitmap.dispose
  287.      @back.dispose
  288.      @text.bitmap.dispose
  289.      @text.dispose
  290.      @number.bitmap.dispose
  291.      @number.dispose
  292.      @image.dispose
  293. end
  294.  
  295. #--------------------------------------------------------------------------
  296. # ● Update
  297. #--------------------------------------------------------------------------      
  298. def update
  299.      update_command
  300.      update_cursor_slide
  301.      update_flow
  302.      update_change_time
  303. end
  304.  
  305. #--------------------------------------------------------------------------
  306. # ● Change_Time
  307. #--------------------------------------------------------------------------        
  308. def update_change_time
  309.      return unless @auto
  310.      @change_time += 1
  311.      check_command(-1) if @change_time >= CHAIN_INPUT_DURATION - 1
  312. end
  313.  
  314. #--------------------------------------------------------------------------
  315. # ● Update Flow
  316. #--------------------------------------------------------------------------      
  317. def update_flow
  318.      @timer -= 1
  319.      @meter_sprite.bitmap.clear
  320.      @meter_width = @meter_range * @timer / @timer_max
  321.      @meter_src_rect = Rect.new(@meter_flow, 0, @meter_width, @meter_height)
  322.      @meter_bitmap.blt(0,0, @meter_image, @meter_src_rect)  
  323.      @meter_flow += 20
  324.      @meter_flow = 0 if @meter_flow >= @meter_image.width - @meter_range      
  325.      wrong_command if @timer == 0 and @auto == false
  326.   end  
  327.  
  328. #--------------------------------------------------------------------------
  329. # ● Update Command
  330. #--------------------------------------------------------------------------      
  331. def update_command
  332.      return if @auto
  333.      if Input.trigger?(Input::X)
  334.         check_command(0)
  335.      elsif Input.trigger?(Input::Z)  
  336.         check_command(1)
  337.      elsif Input.trigger?(Input::Y)  
  338.         check_command(2)
  339.      elsif Input.trigger?(Input::A)   
  340.         check_command(3)
  341.      elsif Input.trigger?(Input::C)           
  342.         check_command(4)
  343.      elsif Input.trigger?(Input::B)        
  344.         check_command(5)
  345.      elsif Input.trigger?(Input::L)        
  346.         check_command(6)
  347.      elsif Input.trigger?(Input::R)        
  348.         check_command(7)        
  349.      elsif Input.trigger?(Input::RIGHT)      
  350.         check_command(8)
  351.      elsif Input.trigger?(Input::LEFT)
  352.         check_command(9)
  353.      elsif Input.trigger?(Input::DOWN)
  354.         check_command(10)
  355.      elsif Input.trigger?(Input::UP)  
  356.         check_command(11)
  357.      end   
  358. end  
  359.  
  360. #--------------------------------------------------------------------------
  361. # ● command_list_check
  362. #--------------------------------------------------------------------------      
  363. def command_list_check(command)
  364.      case command
  365.          when "A"
  366.             @com = 0  
  367.          when "D"
  368.             @com = 1  
  369.          when "S"
  370.             @com = 2
  371.          when "Shift"
  372.             @com = 3
  373.          when "Z"
  374.             @com = 4
  375.          when "X"
  376.             @com = 5
  377.          when "Q"
  378.             @com = 6
  379.          when "W"
  380.             @com = 7            
  381.          when "Right"
  382.             @com = 8
  383.          when "Left"
  384.             @com = 9
  385.          when "Down"
  386.             @com = 10
  387.          when "Up"  
  388.             @com = 11
  389.          else   
  390.             @com = 12           
  391.      end
  392. end   
  393.  
  394. #--------------------------------------------------------------------------
  395. # ● check_command
  396. #--------------------------------------------------------------------------            
  397. def check_command(com)
  398.      index = 0
  399.      if com != -1
  400.         right_input = false
  401.         for i in @chain_command
  402.            if index == @com_index
  403.               command_list_check(i)
  404.               right_input = true if @com == com
  405.            end  
  406.           index += 1  
  407.        end  
  408.      else  
  409.        command_list_check(@com_index)
  410.        @change_time = 0
  411.        right_input = true
  412.      end  
  413.      if right_input
  414.         refresh_number
  415.         next_command
  416.      else  
  417.         wrong_command
  418.      end  
  419. end  
  420.  
  421. #--------------------------------------------------------------------------
  422. # ● Next Command
  423. #--------------------------------------------------------------------------            
  424. def next_command   
  425.      @com_index += 1   
  426.      Audio.se_play("Audio/SE/" + CHAIN_RIGHT_SE, 100, 100)
  427.      if @com_index == @chain_command.size
  428.         $game_switches[@action_id] = true
  429.         exit
  430.         $game_map.need_refresh = true
  431.      end  
  432.      refresh_command
  433.      refresh_text(0)
  434. end     
  435.  
  436. #--------------------------------------------------------------------------
  437. # ● wrong_command
  438. #--------------------------------------------------------------------------              
  439. def wrong_command
  440.      Audio.se_play("Audio/SE/" + CHAIN_WRONG_SE, 100, 100)
  441.      refresh_text(1)
  442.      exit
  443.      $game_player.jump(0,0)
  444. end
  445.  
  446. #--------------------------------------------------------------------------
  447. # ● Refresh Command
  448. #--------------------------------------------------------------------------               
  449. def refresh_command
  450.      @sprite.bitmap.clear
  451.      index = 0
  452.      for i in @chain_command
  453.          command_list_check(i)
  454.          bitmap_src_rect = Rect.new(@com * @bitmap_cw, 0, @bitmap_cw, @bitmap_ch)
  455.          if @com_index == index
  456.             @bitmap.blt(index * (@bitmap_cw + 5) , 0, @image, bitmap_src_rect)
  457.          else
  458.             @bitmap.blt(index * (@bitmap_cw + 5) , @bitmap_ch, @image, bitmap_src_rect)
  459.          end
  460.          index += 1
  461.        end
  462.      if @chain_command.size > 15  
  463.         @new_x = (544 / 2) - ((@bitmap_cw + 5) * @com_index)
  464.      else   
  465.         @cursor.x = (544 / 2) - @cursor_space + ((@bitmap_cw + 5) * @com_index)
  466.      end
  467. end  
  468.  
  469. #--------------------------------------------------------------------------
  470. # ● Refresh Text
  471. #--------------------------------------------------------------------------               
  472. def refresh_text(type)
  473.      @text.bitmap.clear
  474.      if type == 0
  475.         if @com_index == @chain_command.size
  476.            @text.bitmap.font.color.set(55, 255, 55,220)
  477.            @text.bitmap.draw_text(0, 0, 200, 32, "Perfect!",1)              
  478.         else  
  479.            @text.bitmap.font.color.set(55, 155, 255,220)
  480.            @text.bitmap.draw_text(0, 0, 200, 32, "Success!",1)              
  481.         end
  482.      else
  483.         @text.bitmap.font.color.set(255, 155, 55,220)
  484.         if @timer == 0
  485.            @text.bitmap.draw_text(0, 0, 200, 32, "Time Limit!",1)  
  486.         else  
  487.            @text.bitmap.draw_text(0, 0, 200, 32, "Fail!",1)   
  488.         end
  489.      end  
  490.      @text.x = 230   
  491.      @text.opacity = 255
  492. end
  493.  
  494. #--------------------------------------------------------------------------
  495. # ● Refresh Number
  496. #--------------------------------------------------------------------------               
  497. def refresh_number
  498.      @combo += 1
  499.      @number.bitmap.clear
  500.      @number.bitmap.font.size = 34
  501.      @number.bitmap.draw_text(0, 0, 200, 32, @combo.to_s,1)         
  502.      @number.opacity = 255
  503.      @number.zoom_x = 2
  504.      @number.zoom_y = 2
  505. end
  506.  
  507. #--------------------------------------------------------------------------
  508. # ● Update Cursor Slide
  509. #--------------------------------------------------------------------------           
  510. def update_cursor_slide   
  511.      @sprite.zoom_x -= 0.1 if @sprite.zoom_x > 1
  512.      @sprite.zoom_y -= 0.1 if @sprite.zoom_y > 1
  513.      @text.x -= 2 if @text.x > 210
  514.      @text.opacity -= 5 if @text.opacity > 0
  515.      @sprite.x -= @slide_time if @sprite.x > @new_x and @chain_command.size > 15
  516.      if @number.zoom_x > 1
  517.         @number.zoom_x -= 0.1
  518.         @number.zoom_y -= 0.1
  519.      end
  520.      if @fy_time > 15
  521.         @fy += 1
  522.      elsif @fy_time > 0
  523.         @fy -= 1
  524.      else   
  525.         @fy = 0
  526.         @fy_time = 30
  527.      end  
  528.      @fy_time -= 1
  529.      @cursor.oy = @fy     
  530. end  
  531. end
  532.  
  533. #==============================================================================
  534. # ■ Game Temp
  535. #==============================================================================
  536. class Game_Temp
  537.  
  538. attr_accessor :chain_switch_id
  539.  
  540. #--------------------------------------------------------------------------
  541. # ● Initialize
  542. #--------------------------------------------------------------------------         
  543.   alias mog_chain_commands_initialize initialize
  544.   def initialize
  545.       @chain_switch_id = 0
  546.       mog_chain_commands_initialize
  547.   end  
  548.  
  549. end
  550.  
  551. #==============================================================================
  552. # ■ Game_Interpreter
  553. #==============================================================================
  554. class Game_Interpreter
  555.  
  556. #--------------------------------------------------------------------------
  557. # ● Chain Commands
  558. #--------------------------------------------------------------------------           
  559.   def chain_commands(switch_id = 0)
  560.       return if switch_id <= 0
  561.       $game_temp.chain_switch_id = switch_id
  562.       SceneManager.call(Chain_Commands)
  563.       wait(1)
  564.   end
  565.  
  566. end
  567.  
  568. #===============================================================================
  569. # ■ SceneManager
  570. #===============================================================================
  571. class << SceneManager
  572.   @background_bitmap2 = nil
  573.  
  574.   #--------------------------------------------------------------------------
  575.   # ● Snapshot For Background2
  576.   #--------------------------------------------------------------------------
  577.   def snapshot_for_background2
  578.       @background_bitmap2.dispose if @background_bitmap2
  579.       @background_bitmap2 = Graphics.snap_to_bitmap
  580.   end
  581.  
  582.   #--------------------------------------------------------------------------
  583.   # ● Background Bitmap2
  584.   #--------------------------------------------------------------------------
  585.   def background_bitmap2
  586.       @background_bitmap2
  587.   end
  588.  
  589. end
  590.  
  591. #===============================================================================
  592. # ■ Scene Map
  593. #===============================================================================
  594. class Scene_Map < Scene_Base
  595.  
  596.   #--------------------------------------------------------------------------
  597.   # ● Terminate
  598.   #--------------------------------------------------------------------------  
  599.   alias mog_chain_commands_terminate terminate
  600.   def terminate
  601.       SceneManager.snapshot_for_background2
  602.       mog_chain_commands_terminate      
  603.   end
  604.  
  605. end  
  606.  
  607. $mog_rgss3_chain_commands = true

点评

多谢!  发表于 2017-5-24 20:54
OK  发表于 2017-5-24 20:36
对就是这个,不是windows没法打开,能否烦请把这段代码复制粘贴一份给我  发表于 2017-5-24 20:31
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
21932
在线时间
8564 小时
注册时间
2011-12-31
帖子
3362
4
发表于 2017-5-24 20:01:18 | 只看该作者
本帖最后由 tseyik 于 2017-5-24 20:03 编辑

MOG自己己移殖不小VA脚本到MV了
https://atelierrgss.wordpress.com/rpg-maker-mv/
RMV – Chain Commands

Ver 1.3 – Last Updated 2016 / 03/ 14
File Name – MOG_ChainCommands.js
https://atelierrgss.wordpress.com/rmv-chain-commands/MOG自己

点评

不是这个啊……RGSS3 – Chain Commands m 是这个  发表于 2017-5-24 20:30
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
440
在线时间
679 小时
注册时间
2014-3-15
帖子
292

开拓者

5
 楼主| 发表于 2017-5-24 20:34:02 | 只看该作者
各位,不是MOG-skillcommandchain,是RGSS3的Chain Commands1.4,就是在地图上用的那个插件。我不是windows系统没办法安装RMVA,所以恳求有用VA的能从脚本管理器拷贝出一份给我,多谢啦
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2631
在线时间
1045 小时
注册时间
2015-11-1
帖子
271
6
发表于 2017-5-24 20:35:55 | 只看该作者
  1. #===============================================================================
  2. # +++ MOG - Chain Commands (v1.4) +++
  3. #===============================================================================
  4. # By Moghunter                                                               
  5. # http://www.atelier-rgss.com                     
  6. #===============================================================================
  7. # Sistema de sequência de botões para ativar switchs.
  8. #
  9. # Serão necessárias as seguintes imagens. (Graphics/System)
  10. #
  11. # Chain_Cursor.png
  12. # Chain_Command.png
  13. # Chain_Layout.png
  14. # Chain_Timer_Layout.png
  15. # Chain_Timer_Meter.png
  16. #
  17. #===============================================================================
  18. #
  19. # Para ativar o script use o comando abaixo.  (*Call Script)
  20. #
  21. # chain_commands(ID)
  22. #
  23. # ID - Id da switch.
  24. #
  25. #===============================================================================

  26. #==============================================================================
  27. # ● Histórico (Version History)
  28. #==============================================================================
  29. # v 1.4 - Correção do crash aleatório.
  30. # v 1.3 - Melhoria no sistema de dispose
  31. # v 1.2 - Melhoria na codificação e correção de alguns glitches.
  32. # v 1.1 - Animação de fade ao sair da cena de chain.
  33. #       - Opção de definir a prioridade da hud na tela.
  34. #==============================================================================

  35. module MOG_CHAIN_COMMANDS
  36. #==============================================================================
  37. # CHAIN_COMMAND = { SWITCH_ID => [COMMAND] }
  38. #
  39. # SWITCH_ID = ID da switch
  40. # COMMANDS = Defina aqui a sequência de botões.
  41. #            (Para fazer a sequência use os comandos abaixo)   
  42. #  
  43. # "Down" ,"Up" ,"Left" ,"Right" ,"Shift" ,"D" ,"S" ,"A" ,"Z" ,"X" ,"Q" ,"W"
  44. #
  45. # Exemplo de utilização
  46. #
  47. # CHAIN_SWITCH_COMMAND = {
  48. # 25=>["Down","D","S","Right"],
  49. # 59=>["Down","Up","Left","Right","Shift","D","S","A","Z","X","Q","W"],
  50. # 80=>["Shift","D"]
  51. # }
  52. #==============================================================================
  53. CHAIN_SWITCH_COMMAND = {
  54. 5=>["X","Right","Left","Z","Z"],
  55. 7=>["X","X","X","X","X"],
  56. 6=>["Left","Right","Left","Right","Left","Right","Q","Z","Up","A","S",
  57.       "Down","D","Z","Right","Up","Up","Z","W","Left","Down","D","A","W"],
  58. 8=>["Up","Down","Left","Right","Z"]}
  59. #Duração para colocar os comandos. (A duração é multiplicado pela quantidade
  60. #de comandos) *60 = 1 sec
  61. #上面的锁代表成功输入这些按键后会开启相应的开关
  62. CHAIN_INPUT_DURATION = 30
  63. #Som ao acertar.
  64. CHAIN_RIGHT_SE = "Chime1"
  65. #Som ao errar.
  66. CHAIN_WRONG_SE = "Buzzer1"
  67. #Switch que ativa o modo automático.
  68. CHAIN_AUTOMATIC_MODE_SWITCH_ID = 20
  69. #Definição da prioridade da hud na tela
  70. CHAIN_HUD_Z = 300
  71. end


  72. #===============================================================================
  73. # ■ Chain Commands
  74. #===============================================================================
  75. class Chain_Commands
  76.    include MOG_CHAIN_COMMANDS
  77. #--------------------------------------------------------------------------
  78. # ● Initialize
  79. #--------------------------------------------------------------------------      
  80.   def initialize
  81.       @action_id = $game_temp.chain_switch_id
  82.       @chain_command = CHAIN_SWITCH_COMMAND[@action_id]
  83.       @chain_command = ["?"] if @chain_command == nil  
  84.       duration = [[CHAIN_INPUT_DURATION, 1].max, 9999].min
  85.       @timer_max = duration * @chain_command.size
  86.       @timer = @timer_max
  87.       @slide_time = [[60 / duration, 10].max, 60].min
  88.       @change_time = 0
  89.       if $game_switches[CHAIN_AUTOMATIC_MODE_SWITCH_ID]
  90.          @auto = true
  91.       else
  92.          @auto = false
  93.       end
  94.       [url=home.php?mod=space&uid=10462]@Com[/url] = 0  
  95.   end   
  96.   
  97. #--------------------------------------------------------------------------
  98. # ● Main
  99. #--------------------------------------------------------------------------     
  100. def main
  101.      dispose
  102.      @background_sprite = Sprite.new
  103.      @background_sprite.bitmap = SceneManager.background_bitmap2
  104.      create_chain_command
  105.      create_cusrsor
  106.      create_layout
  107.      create_meter
  108.      create_text
  109.      create_number
  110.      Graphics.transition
  111.      loop do
  112.           Graphics.update
  113.            Input.update
  114.            update
  115.            break if SceneManager.scene != self
  116.      end
  117.      dispose
  118. end  
  119.       
  120. #--------------------------------------------------------------------------
  121. # ● Create Cursor
  122. #--------------------------------------------------------------------------            
  123. def create_cusrsor
  124.      @fy_time = 0
  125.      @fy = 0
  126.      @com_index = 0
  127.      @cursor = Sprite.new
  128.      @cursor.bitmap = Cache.system("Chain_Cursor")
  129.      @cursor.z = 4 + CHAIN_HUD_Z
  130.      @cursor_space = ((@bitmap_cw + 5) * @chain_command.size) / 2
  131.      if @chain_command.size <= 20
  132.         @cursor.x = (544 / 2) - @cursor_space + @cursor_space * @com_index
  133.      else   
  134.         @cursor.x = (544 / 2)
  135.      end  
  136.      @cursor.y = (416 / 2) + 30   
  137. end

  138. #--------------------------------------------------------------------------
  139. # ● Create Chain Command
  140. #--------------------------------------------------------------------------      
  141. def create_chain_command
  142.      @image = Cache.system("Chain_Command")     
  143.      width_max = ((@image.width / 13) + 5) * @chain_command.size
  144.      @bitmap = Bitmap.new(width_max,@image.height * 2)
  145.      @bitmap_cw = @image.width / 13
  146.      @bitmap_ch = @image.height  
  147.      index = 0
  148.      for i in @chain_command
  149.          command_list_check(i)
  150.          bitmap_src_rect = Rect.new(@com * @bitmap_cw, 0, @bitmap_cw, @bitmap_ch)
  151.          if index == 0
  152.             @bitmap.blt(index * (@bitmap_cw + 5) , 0, @image, bitmap_src_rect)
  153.          else
  154.             @bitmap.blt(index * (@bitmap_cw + 5) , @bitmap_ch, @image, bitmap_src_rect)
  155.          end
  156.          index += 1
  157.      end
  158.      @sprite = Sprite.new
  159.      @sprite.bitmap = @bitmap
  160.      if @chain_command.size <= 15
  161.         @sprite.x = (544 / 2) - ((@bitmap_cw + 5) * @chain_command.size) / 2
  162.         @new_x = 0
  163.      else   
  164.         @sprite.x = (544 / 2)
  165.         @new_x = @sprite.x
  166.      end   
  167.      @sprite.y = (416 / 2) + 30  - @bitmap_ch  - 15
  168.      @sprite.z = 3 + CHAIN_HUD_Z
  169.      @sprite.zoom_x = 1.5
  170.      @sprite.zoom_y = 1.5
  171. end

  172. #--------------------------------------------------------------------------
  173. # * create_layout
  174. #--------------------------------------------------------------------------  
  175. def create_layout
  176.      @back = Plane.new
  177.      @back.bitmap = Cache.system("Chain_Layout")
  178.      @back.z = 0
  179.      @layout = Sprite.new
  180.      @layout.bitmap = Cache.system("Chain_Timer_Layout")
  181.      @layout.z = 1 + CHAIN_HUD_Z
  182.      @layout.x = 160
  183.      @layout.y = 150
  184.   end

  185. #--------------------------------------------------------------------------
  186. # * create_meter
  187. #--------------------------------------------------------------------------  
  188. def create_meter
  189.      @meter_flow = 0
  190.      @meter_image = Cache.system("Chain_Timer_Meter")
  191.      @meter_bitmap = Bitmap.new(@meter_image.width,@meter_image.height)
  192.      @meter_range = @meter_image.width / 3
  193.      @meter_width = @meter_range * @timer / @timer_max
  194.      @meter_height = @meter_image.height
  195.      @meter_src_rect = Rect.new(@meter_range, 0, @meter_width, @meter_height)
  196.      @meter_bitmap.blt(0,0, @meter_image, @meter_src_rect)
  197.      @meter_sprite = Sprite.new
  198.      @meter_sprite.bitmap = @meter_bitmap
  199.      @meter_sprite.z = 2 + CHAIN_HUD_Z
  200.      @meter_sprite.x = 220
  201.      @meter_sprite.y = 159
  202.      update_flow
  203. end  

  204. #--------------------------------------------------------------------------
  205. # ● Create Text
  206. #--------------------------------------------------------------------------        
  207. def create_text
  208.      @text = Sprite.new
  209.      @text.bitmap = Bitmap.new(200,32)
  210.      @text.z = 2 + CHAIN_HUD_Z
  211.      @text.bitmap.font.name = "Georgia"
  212.      @text.bitmap.font.size = 25
  213.      @text.bitmap.font.bold = true
  214.      @text.bitmap.font.italic = true
  215.      @text.bitmap.font.color.set(255, 255, 255,220)
  216.      @text.x = 230
  217.      @text.y = 100
  218. end

  219. #--------------------------------------------------------------------------
  220. # ● Create Number
  221. #--------------------------------------------------------------------------        
  222. def create_number
  223.      @combo = 0
  224.      @number = Sprite.new
  225.      @number.bitmap = Bitmap.new(200,64)
  226.      @number.z = 2 + CHAIN_HUD_Z
  227.      @number.bitmap.font.name = "Arial"
  228.      @number.bitmap.font.size = 24
  229.      @number.bitmap.font.bold = true
  230.      @number.bitmap.font.color.set(0, 255, 255,200)
  231.      @number.bitmap.draw_text(0, 0, 200, 32, "Ready",1)         
  232.      @number.x = 30
  233.      @number.y = 100
  234. end

  235. #--------------------------------------------------------------------------
  236. # ● Pre Dispose
  237. #--------------------------------------------------------------------------      
  238. def exit
  239.      loop do
  240.          Graphics.update
  241.          @sprite.x += 5
  242.          @layout.x -= 5
  243.          @meter_sprite.x -= 5
  244.          @text.x -= 2
  245.          @text.opacity -= 5
  246.          @sprite.opacity -= 5
  247.          @layout.opacity -= 5
  248.          @meter_sprite.opacity -= 5
  249.          @number.opacity -= 5
  250.          @back.opacity -= 5
  251.          @cursor.visible = false   
  252.          break if @sprite.opacity == 0
  253.      end
  254.      SceneManager.call(Scene_Map)
  255. end
  256.    
  257. #--------------------------------------------------------------------------
  258. # ● Dispose
  259. #--------------------------------------------------------------------------      
  260. def dispose
  261.      return if @layout == nil
  262.      Graphics.freeze
  263.      @background_sprite.bitmap.dispose
  264.      @background_sprite.dispose
  265.      @bitmap.dispose
  266.      @sprite.bitmap.dispose
  267.      @sprite.dispose
  268.      @cursor.bitmap.dispose
  269.      @cursor.dispose  
  270.      @meter_image.dispose
  271.      @meter_bitmap.dispose
  272.      @meter_sprite.bitmap.dispose
  273.      @meter_sprite.dispose
  274.      @layout.bitmap.dispose  
  275.      @layout.dispose
  276.      @layout = nil
  277.      @back.bitmap.dispose
  278.      @back.dispose
  279.      @text.bitmap.dispose
  280.      @text.dispose
  281.      @number.bitmap.dispose
  282.      @number.dispose
  283.      @image.dispose
  284. end

  285. #--------------------------------------------------------------------------
  286. # ● Update
  287. #--------------------------------------------------------------------------      
  288. def update
  289.      update_command
  290.      update_cursor_slide
  291.      update_flow
  292.      update_change_time
  293. end

  294. #--------------------------------------------------------------------------
  295. # ● Change_Time
  296. #--------------------------------------------------------------------------        
  297. def update_change_time
  298.      return unless @auto
  299.      @change_time += 1
  300.      check_command(-1) if @change_time >= CHAIN_INPUT_DURATION - 1
  301. end

  302. #--------------------------------------------------------------------------
  303. # ● Update Flow
  304. #--------------------------------------------------------------------------      
  305. def update_flow
  306.      @timer -= 1
  307.      @meter_sprite.bitmap.clear
  308.      @meter_width = @meter_range * @timer / @timer_max
  309.      @meter_src_rect = Rect.new(@meter_flow, 0, @meter_width, @meter_height)
  310.      @meter_bitmap.blt(0,0, @meter_image, @meter_src_rect)  
  311.      @meter_flow += 20
  312.      @meter_flow = 0 if @meter_flow >= @meter_image.width - @meter_range      
  313.      wrong_command if @timer == 0 and @auto == false
  314.   end  
  315.    
  316. #--------------------------------------------------------------------------
  317. # ● Update Command
  318. #--------------------------------------------------------------------------      
  319. def update_command
  320.      return if @auto
  321.      if Input.trigger?(Input::X)
  322.         check_command(0)
  323.      elsif Input.trigger?(Input::Z)  
  324.         check_command(1)
  325.      elsif Input.trigger?(Input::Y)  
  326.         check_command(2)
  327.      elsif Input.trigger?(Input::A)   
  328.         check_command(3)
  329.      elsif Input.trigger?(Input::C)           
  330.         check_command(4)
  331.      elsif Input.trigger?(Input::B)        
  332.         check_command(5)
  333.      elsif Input.trigger?(Input::L)        
  334.         check_command(6)
  335.      elsif Input.trigger?(Input::R)        
  336.         check_command(7)        
  337.      elsif Input.trigger?(Input::RIGHT)      
  338.         check_command(8)
  339.      elsif Input.trigger?(Input::LEFT)
  340.         check_command(9)
  341.      elsif Input.trigger?(Input::DOWN)
  342.         check_command(10)
  343.      elsif Input.trigger?(Input::UP)  
  344.         check_command(11)
  345.      end   
  346. end  
  347.    
  348. #--------------------------------------------------------------------------
  349. # ● command_list_check
  350. #--------------------------------------------------------------------------      
  351. def command_list_check(command)
  352.      case command
  353.          when "A"
  354.             @com = 0  
  355.          when "D"
  356.             @com = 1  
  357.          when "S"
  358.             @com = 2
  359.          when "Shift"
  360.             @com = 3
  361.          when "Z"
  362.             @com = 4
  363.          when "X"
  364.             @com = 5
  365.          when "Q"
  366.             @com = 6
  367.          when "W"
  368.             @com = 7            
  369.          when "Right"
  370.             @com = 8
  371.          when "Left"
  372.             @com = 9
  373.          when "Down"
  374.             @com = 10
  375.          when "Up"  
  376.             @com = 11
  377.          else   
  378.             @com = 12           
  379.      end
  380. end   

  381. #--------------------------------------------------------------------------
  382. # ● check_command
  383. #--------------------------------------------------------------------------            
  384. def check_command(com)
  385.      index = 0
  386.      if com != -1
  387.         right_input = false
  388.         for i in @chain_command
  389.            if index == @com_index
  390.               command_list_check(i)
  391.               right_input = true if @com == com
  392.            end  
  393.           index += 1  
  394.        end  
  395.      else  
  396.        command_list_check(@com_index)
  397.        @change_time = 0
  398.        right_input = true
  399.      end  
  400.      if right_input
  401.         refresh_number
  402.         next_command
  403.      else  
  404.         wrong_command
  405.      end  
  406. end  
  407.    
  408. #--------------------------------------------------------------------------
  409. # ● Next Command
  410. #--------------------------------------------------------------------------            
  411. def next_command   
  412.      @com_index += 1   
  413.      Audio.se_play("Audio/SE/" + CHAIN_RIGHT_SE, 100, 100)
  414.      if @com_index == @chain_command.size
  415.         $game_switches[@action_id] = true
  416.         exit
  417.         $game_map.need_refresh = true
  418.      end  
  419.      refresh_command
  420.      refresh_text(0)
  421. end     

  422. #--------------------------------------------------------------------------
  423. # ● wrong_command
  424. #--------------------------------------------------------------------------              
  425. def wrong_command
  426.      Audio.se_play("Audio/SE/" + CHAIN_WRONG_SE, 100, 100)
  427.      refresh_text(1)
  428.      exit
  429.      $game_player.jump(0,0)
  430. end
  431.    
  432. #--------------------------------------------------------------------------
  433. # ● Refresh Command
  434. #--------------------------------------------------------------------------               
  435. def refresh_command
  436.      @sprite.bitmap.clear
  437.      index = 0
  438.      for i in @chain_command
  439.          command_list_check(i)
  440.          bitmap_src_rect = Rect.new(@com * @bitmap_cw, 0, @bitmap_cw, @bitmap_ch)
  441.          if @com_index == index
  442.             @bitmap.blt(index * (@bitmap_cw + 5) , 0, @image, bitmap_src_rect)
  443.          else
  444.             @bitmap.blt(index * (@bitmap_cw + 5) , @bitmap_ch, @image, bitmap_src_rect)
  445.          end
  446.          index += 1
  447.        end
  448.      if @chain_command.size > 15  
  449.         @new_x = (544 / 2) - ((@bitmap_cw + 5) * @com_index)
  450.      else   
  451.         @cursor.x = (544 / 2) - @cursor_space + ((@bitmap_cw + 5) * @com_index)
  452.      end
  453. end  

  454. #--------------------------------------------------------------------------
  455. # ● Refresh Text
  456. #--------------------------------------------------------------------------               
  457. def refresh_text(type)
  458.      @text.bitmap.clear
  459.      if type == 0
  460.         if @com_index == @chain_command.size
  461.            @text.bitmap.font.color.set(55, 255, 55,220)
  462.            @text.bitmap.draw_text(0, 0, 200, 32, "Perfect!",1)              
  463.         else  
  464.            @text.bitmap.font.color.set(55, 155, 255,220)
  465.            @text.bitmap.draw_text(0, 0, 200, 32, "Success!",1)              
  466.         end
  467.      else
  468.         @text.bitmap.font.color.set(255, 155, 55,220)
  469.         if @timer == 0
  470.            @text.bitmap.draw_text(0, 0, 200, 32, "Time Limit!",1)  
  471.         else  
  472.            @text.bitmap.draw_text(0, 0, 200, 32, "Fail!",1)   
  473.         end
  474.      end  
  475.      @text.x = 230   
  476.      @text.opacity = 255
  477. end

  478. #--------------------------------------------------------------------------
  479. # ● Refresh Number
  480. #--------------------------------------------------------------------------               
  481. def refresh_number
  482.      @combo += 1
  483.      @number.bitmap.clear
  484.      @number.bitmap.font.size = 34
  485.      @number.bitmap.draw_text(0, 0, 200, 32, @combo.to_s,1)         
  486.      @number.opacity = 255
  487.      @number.zoom_x = 2
  488.      @number.zoom_y = 2
  489. end

  490. #--------------------------------------------------------------------------
  491. # ● Update Cursor Slide
  492. #--------------------------------------------------------------------------           
  493. def update_cursor_slide   
  494.      @sprite.zoom_x -= 0.1 if @sprite.zoom_x > 1
  495.      @sprite.zoom_y -= 0.1 if @sprite.zoom_y > 1
  496.      @text.x -= 2 if @text.x > 210
  497.      @text.opacity -= 5 if @text.opacity > 0
  498.      @sprite.x -= @slide_time if @sprite.x > @new_x and @chain_command.size > 15
  499.      if @number.zoom_x > 1
  500.         @number.zoom_x -= 0.1
  501.         @number.zoom_y -= 0.1
  502.      end
  503.      if @fy_time > 15
  504.         @fy += 1
  505.      elsif @fy_time > 0
  506.         @fy -= 1
  507.      else   
  508.         @fy = 0
  509.         @fy_time = 30
  510.      end  
  511.      @fy_time -= 1
  512.      @cursor.oy = @fy     
  513. end  
  514. end

  515. #==============================================================================
  516. # ■ Game Temp
  517. #==============================================================================
  518. class Game_Temp

  519. attr_accessor :chain_switch_id

  520. #--------------------------------------------------------------------------
  521. # ● Initialize
  522. #--------------------------------------------------------------------------         
  523.   alias mog_chain_commands_initialize initialize
  524.   def initialize
  525.       @chain_switch_id = 0
  526.       mog_chain_commands_initialize
  527.   end  
  528.    
  529. end

  530. #==============================================================================
  531. # ■ Game_Interpreter
  532. #==============================================================================
  533. class Game_Interpreter
  534.   
  535. #--------------------------------------------------------------------------
  536. # ● Chain Commands
  537. #--------------------------------------------------------------------------           
  538.   def chain_commands(switch_id = 0)
  539.       return if switch_id <= 0
  540.       $game_temp.chain_switch_id = switch_id
  541.       SceneManager.call(Chain_Commands)
  542.       wait(1)
  543.   end
  544.   
  545. end

  546. #===============================================================================
  547. # ■ SceneManager
  548. #===============================================================================
  549. class << SceneManager
  550.   @background_bitmap2 = nil
  551.   
  552.   #--------------------------------------------------------------------------
  553.   # ● Snapshot For Background2
  554.   #--------------------------------------------------------------------------
  555.   def snapshot_for_background2
  556.       @background_bitmap2.dispose if @background_bitmap2
  557.       @background_bitmap2 = Graphics.snap_to_bitmap
  558.   end
  559.   
  560.   #--------------------------------------------------------------------------
  561.   # ● Background Bitmap2
  562.   #--------------------------------------------------------------------------
  563.   def background_bitmap2
  564.       @background_bitmap2
  565.   end
  566.   
  567. end

  568. #===============================================================================
  569. # ■ Scene Map
  570. #===============================================================================
  571. class Scene_Map < Scene_Base
  572.   
  573.   #--------------------------------------------------------------------------
  574.   # ● Terminate
  575.   #--------------------------------------------------------------------------  
  576.   alias mog_chain_commands_terminate terminate
  577.   def terminate
  578.       SceneManager.snapshot_for_background2
  579.       mog_chain_commands_terminate      
  580.   end
  581.   
  582. end  

  583. $mog_rgss3_chain_commands = true
复制代码

点评

多谢啦,是这个  发表于 2017-5-24 20:53
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
440
在线时间
679 小时
注册时间
2014-3-15
帖子
292

开拓者

7
 楼主| 发表于 2017-5-24 20:55:19 | 只看该作者
感谢各位的热心帮助!
等移植完了我会把代码放出来的。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 03:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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