Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _Game_CharacterBase_realMoveSpeed = Game_CharacterBase.prototype.realMoveSpeed
- Game_CharacterBase.prototype.realMoveSpeed = function() {
- var rms = _Game_CharacterBase_realMoveSpeed.call(this)
- return this._move8Direction ? rms * 0.8 : rms
- }
- _Game_CharacterBase_moveStraight = Game_CharacterBase.prototype.moveStraight
- Game_CharacterBase.prototype.moveStraight = function(d) {
- this._move8Direction = false
- _Game_CharacterBase_moveStraight.call(this, d)
- }
- Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
- var diag = this.canPassDiagonally(this._x, this._y, horz, vert)
- var norm = this.canPass(this._x, this._y, horz) || this.canPass(this._x, this._y, vert)
- if (diag) {
- this._move8Direction = this.getMove8Direction(horz, vert)
- this._x = $gameMap.roundXWithDirection(this._x, horz)
- this._y = $gameMap.roundYWithDirection(this._y, vert)
- this._realX = $gameMap.xWithDirection(this._x, this.reverseDir(horz))
- this._realY = $gameMap.yWithDirection(this._y, this.reverseDir(vert))
- this.increaseSteps()
- } else if (norm) {
- this._move8Direction = false
- this.moveStraight(this.getNormalDirection(horz, vert))
- }
- if (this._direction === this.reverseDir(horz)) {
- this.setDirection(horz)
- }
- if (this._direction === this.reverseDir(vert)) {
- this.setDirection(vert)
- }
- }
- Game_CharacterBase.prototype.getMove8Direction = function(horz,vert) {
- if (horz === 4 && vert === 8) {
- return 1
- }
- if (horz === 4 && vert === 2) {
- return 3
- }
- if (horz === 6 && vert === 8) {
- return 7
- }
- if (horz === 6 && vert === 2) {
- return 9
- }
- return 0
- }
- Game_CharacterBase.prototype.getNormalDirection = function(horz, vert) {
- return this.canPass(this._x, this._y, horz) ? horz : vert
- }
- /* Game_Player */
- Game_Player.prototype.getInputDirection = function() {
- return Input.dir8
- }
- var _Game_Player_executeMove = Game_Player.prototype.executeMove
- Game_Player.prototype.executeMove = function(direction) {
- if (direction % 2 == 0) {
- _Game_Player_executeMove.call(this, direction)
- } else if (Math.abs(direction % 2) == 1) {
- var dirArray = this.getMove8Position(direction)
- this.moveDiagonally(dirArray[0], dirArray[1])
- }
- }
- Game_Player.prototype.getMove8Position = function(direction) {
- switch (direction) {
- case 1:
- return [4,2]
- case 3:
- return [6,2]
- case 7:
- return [4,8]
- case 9:
- return [6,8]
- default:
- return [0,0]
- }
- }
- /* Sprite_Character */
- Sprite_Character.prototype.isMove8Sprite = function() {
- var index = this._character.characterIndex()
- return !this._isBigCharacter && this._character._move8Direction && index < 4
- }
- var _Sprite_Character_characterPatternY = Sprite_Character.prototype.characterPatternY
- Sprite_Character.prototype.characterPatternY = function() {
- if (this.isMove8Sprite()) {
- return this.move8PatternX(this._character._move8Direction)
- } else {
- return _Sprite_Character_characterPatternY.call(this)
- }
- }
- Sprite_Character.prototype.move8PatternX = function(direction) {
- switch (direction) {
- case 3:
- return 0
- case 1:
- return 1
- case 9:
- return 2
- case 7:
- return 3
- default:
- return
- }
- }
- var _Sprite_Character_characterBlockX = Sprite_Character.prototype.characterBlockX
- Sprite_Character.prototype.characterBlockX = function() {
- if (this.isMove8Sprite()) {
- var index = this._character.characterIndex() + 4
- return index % 4 * 3
- } else {
- return _Sprite_Character_characterBlockX.call(this)
- }
- }
- var _Sprite_Character_characterBlockY = Sprite_Character.prototype.characterBlockY
- Sprite_Character.prototype.characterBlockY = function() {
- if (this.isMove8Sprite()) {
- var index = this._character.characterIndex() + 4
- return Math.floor(index / 4) * 4
- } else {
- return _Sprite_Character_characterBlockY.call(this)
- }
- }
- /* Game_Character */
- Game_Character.prototype.turnTowardCharacter = function(character) {
- var sx = this.deltaXFrom(character.x)
- var sy = this.deltaYFrom(character.y)
- var absSx = Math.abs(sx)
- var absSy = Math.abs(sy)
- if (absSx === absSy) {
- if (sx < 0) {
- this._move8Direction = sy > 0 ? 9 : 3
- } else if (sx > 0) {
- this._move8Direction = sy > 0 ? 7 : 1
- }
- } else {
- this._move8Direction = 0
- }
- if (absSx > absSy) {
- this.setDirection(sx > 0 ? 4 : 6)
- } else if (sy !== 0) {
- this.setDirection(sy > 0 ? 8 : 2)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement