SHARE
TWEET

Untitled

a guest Apr 16th, 2019 20 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     _Game_CharacterBase_realMoveSpeed = Game_CharacterBase.prototype.realMoveSpeed
  2.     Game_CharacterBase.prototype.realMoveSpeed = function() {
  3.         var rms = _Game_CharacterBase_realMoveSpeed.call(this)
  4.         return this._move8Direction ? rms * 0.8 : rms
  5.     }
  6.  
  7.     _Game_CharacterBase_moveStraight = Game_CharacterBase.prototype.moveStraight
  8.     Game_CharacterBase.prototype.moveStraight = function(d) {
  9.         this._move8Direction = false
  10.         _Game_CharacterBase_moveStraight.call(this, d)
  11.     }
  12.  
  13.     Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
  14.         var diag = this.canPassDiagonally(this._x, this._y, horz, vert)
  15.         var norm = this.canPass(this._x, this._y, horz) || this.canPass(this._x, this._y, vert)
  16.  
  17.         if (diag) {
  18.             this._move8Direction = this.getMove8Direction(horz, vert)
  19.             this._x = $gameMap.roundXWithDirection(this._x, horz)
  20.             this._y = $gameMap.roundYWithDirection(this._y, vert)
  21.             this._realX = $gameMap.xWithDirection(this._x, this.reverseDir(horz))
  22.             this._realY = $gameMap.yWithDirection(this._y, this.reverseDir(vert))
  23.             this.increaseSteps()
  24.         } else if (norm) {
  25.             this._move8Direction = false
  26.             this.moveStraight(this.getNormalDirection(horz, vert))
  27.         }
  28.  
  29.         if (this._direction === this.reverseDir(horz)) {
  30.             this.setDirection(horz)
  31.         }
  32.         if (this._direction === this.reverseDir(vert)) {
  33.             this.setDirection(vert)
  34.         }
  35.     }
  36.  
  37.     Game_CharacterBase.prototype.getMove8Direction = function(horz,vert) {
  38.         if (horz === 4 && vert === 8) {
  39.             return 1
  40.         }
  41.         if (horz === 4 && vert === 2) {
  42.             return 3
  43.         }
  44.         if (horz === 6 && vert === 8) {
  45.             return 7
  46.         }
  47.         if (horz === 6 && vert === 2) {
  48.             return 9
  49.         }
  50.         return 0
  51.     }
  52.  
  53.     Game_CharacterBase.prototype.getNormalDirection = function(horz, vert) {
  54.         return this.canPass(this._x, this._y, horz) ? horz : vert
  55.     }
  56.  
  57.     /* Game_Player */
  58.  
  59.     Game_Player.prototype.getInputDirection = function() {
  60.         return Input.dir8
  61.     }
  62.  
  63.     var _Game_Player_executeMove = Game_Player.prototype.executeMove
  64.     Game_Player.prototype.executeMove = function(direction) {
  65.         if (direction % 2 == 0) {
  66.             _Game_Player_executeMove.call(this, direction)
  67.         } else if (Math.abs(direction % 2) == 1) {
  68.             var dirArray = this.getMove8Position(direction)
  69.             this.moveDiagonally(dirArray[0], dirArray[1])
  70.         }
  71.     }
  72.  
  73.     Game_Player.prototype.getMove8Position = function(direction) {
  74.         switch (direction) {
  75.             case 1:
  76.                 return [4,2]
  77.             case 3:
  78.                 return [6,2]
  79.             case 7:
  80.                 return [4,8]
  81.             case 9:
  82.                 return [6,8]
  83.             default:
  84.                 return [0,0]
  85.         }
  86.     }
  87.  
  88.     /* Sprite_Character */
  89.  
  90.     Sprite_Character.prototype.isMove8Sprite = function() {
  91.         var index = this._character.characterIndex()
  92.         return !this._isBigCharacter && this._character._move8Direction && index < 4
  93.     }
  94.  
  95.     var _Sprite_Character_characterPatternY = Sprite_Character.prototype.characterPatternY
  96.     Sprite_Character.prototype.characterPatternY = function() {
  97.         if (this.isMove8Sprite()) {
  98.             return this.move8PatternX(this._character._move8Direction)
  99.         } else {
  100.             return _Sprite_Character_characterPatternY.call(this)
  101.         }
  102.     }
  103.  
  104.     Sprite_Character.prototype.move8PatternX = function(direction) {
  105.         switch (direction) {
  106.             case 3:
  107.                 return 0
  108.             case 1:
  109.                 return 1
  110.             case 9:
  111.                 return 2
  112.             case 7:
  113.                 return 3
  114.             default:
  115.                 return
  116.         }
  117.     }
  118.  
  119.     var _Sprite_Character_characterBlockX = Sprite_Character.prototype.characterBlockX
  120.     Sprite_Character.prototype.characterBlockX = function() {
  121.         if (this.isMove8Sprite()) {
  122.             var index = this._character.characterIndex() + 4
  123.             return index % 4 * 3
  124.         } else {   
  125.             return _Sprite_Character_characterBlockX.call(this)
  126.         }
  127.     }
  128.  
  129.     var _Sprite_Character_characterBlockY = Sprite_Character.prototype.characterBlockY
  130.     Sprite_Character.prototype.characterBlockY = function() {
  131.         if (this.isMove8Sprite()) {
  132.             var index = this._character.characterIndex() + 4
  133.             return Math.floor(index / 4) * 4
  134.         } else {
  135.             return _Sprite_Character_characterBlockY.call(this)
  136.         }
  137.     }
  138.  
  139.     /* Game_Character */
  140.  
  141.     Game_Character.prototype.turnTowardCharacter = function(character) {
  142.         var sx = this.deltaXFrom(character.x)
  143.         var sy = this.deltaYFrom(character.y)
  144.  
  145.         var absSx = Math.abs(sx)
  146.         var absSy = Math.abs(sy)
  147.  
  148.         if (absSx === absSy) {
  149.             if (sx < 0) {
  150.                 this._move8Direction = sy > 0 ? 9 : 3
  151.             } else if (sx > 0) {
  152.                 this._move8Direction = sy > 0 ? 7 : 1
  153.             }
  154.         } else {
  155.             this._move8Direction = 0
  156.         }
  157.  
  158.         if (absSx > absSy) {
  159.             this.setDirection(sx > 0 ? 4 : 6)
  160.         } else if (sy !== 0) {
  161.             this.setDirection(sy > 0 ? 8 : 2)
  162.         }
  163.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top