Advertisement
Guest User

Untitled

a guest
Apr 16th, 2016
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // SVActorPosition.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc Change actors' position on screen at sideview battle.
  7.  * @author Sasuke KANNAZUKI
  8.  *
  9.  * @param actor1 Xpos
  10.  * @desc X position of actor1's center. (default:600)
  11.  * @default 600
  12.  *
  13.  * @param actor1 Ypos
  14.  * @desc Y position of actor1's bottom. (default:280)
  15.  * @default 280
  16.  *
  17.  * @param actor2 Xpos
  18.  * @desc X position of actor2's center. (default:632)
  19.  * @default 632
  20.  *
  21.  * @param actor2 Ypos
  22.  * @desc Y position of actor2's bottom. (default:328)
  23.  * @default 328
  24.  *
  25.  * @param actor3 Xpos
  26.  * @desc X position of actor3's center. (default:664)
  27.  * @default 664
  28.  *
  29.  * @param actor3 Ypos
  30.  * @desc Y position of actor3's bottom. (default:376)
  31.  * @default 376
  32.  *
  33.  * @param actor4 Xpos
  34.  * @desc X position of actor4's center. (default:696)
  35.  * @default 696
  36.  *
  37.  * @param actor4 Ypos
  38.  * @desc Y position of actor4's bottom. (default:424)
  39.  * @default 424
  40.  *
  41.  * @help
  42.  * This plugin assumes the use of diffrent (from specified) size SV actor graphics.
  43.  *
  44.  * Plugin Command:
  45.  * SVActorPosition arg0 arg1 arg2
  46.  * arg0 must be '1', '2', '3', or '4'.
  47.  * arg1 must be 'X' or 'Y'.
  48.  * arg2 must be the value of coordinate position.
  49.  *
  50.  * ex.
  51.  * SVActorPosition 1 X 640    # set sideview actor 1's X position 640.
  52.  * SVActorPosition 4 Y 472    # set sideview actor 4's Y position 472.
  53.  *
  54.  * configuration at Actor's note:
  55.  * <SVWeaponHeight:12>
  56.  * Weapon animation's height of the sideview actor.
  57.  * In this case, Y position is heigher 12px by the defalut.
  58.  * - It also accepts minus value,
  59.  *   because it assumes when you make smaller actor.
  60.  * - If this isn't written, default value 0 is used.
  61.  *
  62.  * Weapon animation's X position is automatically corrected
  63.  *   according to the actor graphics size.
  64.  * If you feel it isn't natural, you can optimize the X position.
  65.  * <SVWeaponRight:20>
  66.  * In this case weapon animation moves right 20 pixels.
  67.  * If the value is minus, animation moves left.
  68.  */
  69. /*:ja
  70.  * @plugindesc サイドビュー戦闘においてアクター達の画面表示位置を設定します。
  71.  * @author 神無月サスケ
  72.  *
  73.  * @param actor1 Xpos
  74.  * @desc アクター1の中心のX座標です。(初期値:600)
  75.  * @default 600
  76.  *
  77.  * @param actor1 Ypos
  78.  * @desc アクター1の足元のY座標です。(初期値:280)
  79.  * @default 280
  80.  *
  81.  * @param actor2 Xpos
  82.  * @desc アクター2の中心のX座標です。(初期値:632)
  83.  * @default 632
  84.  *
  85.  * @param actor2 Ypos
  86.  * @desc アクター2の足元のY座標です。(初期値:328)
  87.  * @default 328
  88.  *
  89.  * @param actor3 Xpos
  90.  * @desc アクター3の中心のX座標です。(初期値:664)
  91.  * @default 664
  92.  *
  93.  * @param actor3 Ypos
  94.  * @desc アクター3の足元のY座標です。(初期値:376)
  95.  * @default 376
  96.  *
  97.  * @param actor4 Xpos
  98.  * @desc アクター4の中心のX座標です。(初期値:696)
  99.  * @default 696
  100.  *
  101.  * @param actor4 Ypos
  102.  * @desc アクター4の足元のY座標です。(初期値:424)
  103.  * @default 424
  104.  *
  105.  * @help
  106.  * このプラグインは、標準素材とは異なったサイズのSVアクター画像での使用を
  107.  * 想定しています。
  108.  *
  109.  * プラグインコマンドの書式:
  110.  * SVActorPosition arg0 arg1 arg2
  111.  * arg0 は '1', '2', '3', か '4' にします。
  112.  * arg1 は 'X' か 'Y' にします。
  113.  * arg2 は 座標の値にします。
  114.  * ex.
  115.  * SVActorPosition 1 X 640    # SV画面のアクター1のX座標を640にします。
  116.  * SVActorPosition 4 Y 472    # SV画面のアクター4のY座標を472にします。
  117.  *
  118.  * アクターのメモによる設定:
  119.  * <SVWeaponHeight:12>
  120.  * サイドビューアクターの武器アニメの表示Y座標の高さを設定します。
  121.  * この例では、通常より12ピクセル高い位置に表示されます。
  122.  * - 標準より小さなアクター画像の作成を想定して、マイナス値も受け付けます。
  123.  * - 記述を省略した場合、デフォルトの0が採用されます。
  124.  *
  125.  * 武器アニメのX座標は、アクター画像のサイズによって自動的に補正されます。
  126.  * もしそれで不自然な場合は、以下の書式でメモに書いてください。
  127.  * <SVWeaponRight:20>
  128.  * サイドビューアクターの武器アニメの表示X座標を右寄りに補正します。
  129.  * この例では、通常より20ピクセル右位置に表示されます。
  130.  * マイナス値にすることで、左寄りの表示も可能です。
  131.  */
  132.  
  133. (function() {
  134.  
  135.   var parameters = PluginManager.parameters('SVActorPosition');
  136.   var SVActor1X = Number(parameters['actor1 Xpos'] || 600);
  137.   var SVActor2X = Number(parameters['actor2 Xpos'] || 632);
  138.   var SVActor3X = Number(parameters['actor3 Xpos'] || 664);
  139.   var SVActor4X = Number(parameters['actor4 Xpos'] || 696);
  140.   var SVActor1Y = Number(parameters['actor1 Ypos'] || 280);
  141.   var SVActor2Y = Number(parameters['actor2 Ypos'] || 328);
  142.   var SVActor3Y = Number(parameters['actor3 Ypos'] || 376);
  143.   var SVActor4Y = Number(parameters['actor4 Ypos'] || 424);
  144.  
  145.   // --------------------
  146.   // process plugin commands
  147.   // --------------------
  148.   var _Game_Interpreter_pluginCommand =
  149.    Game_Interpreter.prototype.pluginCommand;
  150.   Game_Interpreter.prototype.pluginCommand = function(command, args) {
  151.     _Game_Interpreter_pluginCommand.call(this, command, args);
  152.     if (command === 'SVActorPosition') {
  153.       // check whether sv array is already defined or not
  154.       if(!$gameSystem.svActorArrayDefined()){
  155.         $gameSystem.defineSvActorArray();
  156.       }
  157.       // inspect and process parameters
  158.       var value = Number(args[2]);
  159.       if(value){
  160.         switch(args[0]){
  161.         case '1':
  162.           if(args[1] === 'x' || args[1] === 'X'){
  163.             $gameSystem.svActorX[0] = value;
  164.           } else if(args[1] === 'y' || args[1] === 'Y'){
  165.             $gameSystem.svActorY[0] = value;
  166.           }
  167.           break;
  168.         case '2':
  169.           if(args[1] === 'x' || args[1] === 'X'){
  170.             $gameSystem.svActorX[1] = value;
  171.           } else if(args[1] === 'y'|| args[1] === 'Y'){
  172.             $gameSystem.svActorY[1] = value;
  173.           }
  174.           break;
  175.         case '3':
  176.           if(args[1] === 'x' || args[1] === 'X'){
  177.             $gameSystem.svActorX[2] = value;
  178.           } else if(args[1] === 'y'|| args[1] === 'Y'){
  179.             $gameSystem.svActorY[2] = value;
  180.           }
  181.           break;
  182.         case '4':
  183.           if(args[1] === 'x' || args[1] === 'X'){
  184.             $gameSystem.svActorX[3] = value;
  185.           } else if(args[1] === 'y'|| args[1] === 'Y'){
  186.             $gameSystem.svActorY[3] = value;
  187.           }
  188.         }
  189.       }
  190.     }
  191.   };
  192.  
  193.   // --------------------
  194.   // define arrays for save sv actors' position
  195.   // --------------------
  196.   var _Game_System_initialize = Game_System.prototype.initialize;
  197.   Game_System.prototype.initialize = function() {
  198.     _Game_System_initialize.call(this);
  199.     this.defineSvActorArray();
  200.   };
  201.  
  202.   Game_System.prototype.defineSvActorArray = function() {
  203.     this.svActorX = [null, null, null, null];
  204.     this.svActorY = [null, null, null, null];
  205.   };
  206.  
  207.   Game_System.prototype.svActorArrayDefined = function() {
  208.     return !!this.svActorX;
  209.   };
  210.  
  211.   // --------------------
  212.   // set actors' position (overwrited)
  213.   // --------------------
  214.   Sprite_Actor.prototype.setActorHome = function(index) {
  215.     // check whether sv array is already defined or not
  216.     if(!$gameSystem.svActorArrayDefined()){
  217.       $gameSystem.defineSvActorArray();
  218.     }
  219.     // set default values
  220.     var x = 600 + index * 32;
  221.     var y = 280 + index * 48;
  222.     // apply option values
  223.     switch(index) {
  224.     case 0:
  225.       x = $gameSystem.svActorX[0] || SVActor1X;
  226.       y = $gameSystem.svActorY[0] || SVActor1Y;
  227.       break;
  228.     case 1:
  229.       x = $gameSystem.svActorX[1] || SVActor2X;
  230.       y = $gameSystem.svActorY[1] || SVActor2Y;
  231.       break;
  232.     case 2:
  233.       x = $gameSystem.svActorX[2] || SVActor3X;
  234.       y = $gameSystem.svActorY[2] || SVActor3Y;
  235.       break;
  236.     case 3:
  237.       x = $gameSystem.svActorX[3] || SVActor4X;
  238.       y = $gameSystem.svActorY[3] || SVActor4Y;
  239.     }
  240.     // set position
  241.     this.setHome(x, y);
  242.   };
  243.  
  244.   // --------------------
  245.   // set weapon animation's position
  246.   // --------------------
  247.   var _Sprite_Weapon_setup = Sprite_Weapon.prototype.setup;
  248.   Sprite_Weapon.prototype.setup = function(weaponImageId) {
  249.     _Sprite_Weapon_setup.call(this, weaponImageId);
  250.     this.setPosition();
  251.   };
  252.  
  253.   Sprite_Weapon.prototype.setPosition = function() {
  254.     // set X position by actor sprite size
  255.     var actorBitmap = this.parent._mainSprite.bitmap;
  256.     var actorSpriteWidth = actorBitmap ? actorBitmap.width / 9 : 64;
  257.     this.x = -16 - (actorSpriteWidth - 64) / 2;
  258.     // set Y default position
  259.     this.y = 0;
  260.     // change X,Y position by actor's note
  261.     var battler = this.parent._battler;
  262.     if(battler){
  263.       this.x += (Number(battler.actor().meta.SVWeaponRight) || 0);
  264.       this.y -= (Number(battler.actor().meta.SVWeaponHeight) || 0);
  265.     }
  266.   };
  267.  
  268. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement