Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var _upt = Scene_Map.prototype.update;
  2. Scene_Map.prototype.update = function(){
  3.     _upt.call(this);
  4.     if(Input.isTriggered("ok")){
  5.         $gamePlayer.attack();
  6.     }
  7. }
  8.  
  9.  
  10. Game_Player.prototype.attack = function(){
  11.     if (this.attacking) return;
  12.     this.attacking = true;
  13.     this.baseCharset = this._characterName;
  14.     this._characterName = this.baseCharset + "_attack";
  15.     this._stepAnime = true;
  16.     this.attackingIndex = 0;
  17.     var x2 = $gameMap.roundXWithDirection(this.x,this.direction());
  18.     var y2 = $gameMap.roundYWithDirection(this.y,this.direction());
  19.     if (this.isCollidedWithEvents(x2,y2) && $gameMap.getEventInPos(x2,y2).isEnemy())
  20.         $gameMap.getEventInPos(x2,y2).damage(this);
  21.     //this.moveStraight(this.direction());
  22. }
  23.  
  24. var _gpUdt = Game_Player.prototype.update;
  25.  
  26. Game_Player.prototype.update = function(sa){
  27.     _gpUdt.call(this,sa);
  28.     if (this.attacking){
  29.         if (this.attackingIndex >= 20){
  30.             this._characterName = this.baseCharset;
  31.             this.attacking = false;
  32.             this.attackingIndex = 0;
  33.             this._stepAnime = true;
  34.         }
  35.         this.attackingIndex++;
  36.     }
  37. }
  38.  
  39. var _gpCm = Game_Player.prototype.canMove;
  40. Game_Player.prototype.canMove = function(){
  41.     if (this.attacking)
  42.         return false;
  43.     return _gpCm.call(this);
  44. }
  45.  
  46. Game_Map.prototype.getEventInPos = function(x,y){
  47.     for(var i of this.events()){
  48.         if (i.x == x && i.y == y)
  49.             return i;
  50.     }
  51. }
  52.  
  53. var _geInit = Game_Event.prototype.initialize;
  54. Game_Event.prototype.initialize = function(eid,x,y){
  55.     _geInit.call(this,eid,x,y);
  56.     this.hp = parseInt(this.event().meta["enemy"]);
  57. }
  58.  
  59. Game_Event.prototype.isEnemy = function(){
  60.     return this.event().meta["enemy"] != undefined;
  61. }
  62. Game_Event.prototype.damage = function(attacker){
  63.     if (this.isRecievingDamage) return;
  64.     this.blinkIndex = 0;
  65.     this.hp--;
  66.     if (this.hp <= 0)
  67.         $gameSelfSwitches.setValue([this._mapId,this._eventId,"C"],true);
  68.     this.isRecievingDamage = true;
  69.     this.damageIndex = 0;
  70. }
  71.  
  72. var _geUdt = Game_Event.prototype.update;
  73. Game_Event.prototype.update = function(){
  74.     _geUdt.call(this);
  75.     if (this.isRecievingDamage){
  76.         if (this.blinkIndex > 3) {
  77.             this.opacity() > 0 ? this._opacity = 0 : this._opacity = 255;
  78.             this.blinkIndex = 0;
  79.         }
  80.         else
  81.             this.blinkIndex++;
  82.         if (this.damageIndex >= 60) {
  83.             this.isRecievingDamage = false;
  84.             this._opacity = 255;
  85.         }
  86.     }
  87.     this.damageIndex++;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement