Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var _upt = Scene_Map.prototype.update;
- Scene_Map.prototype.update = function(){
- _upt.call(this);
- if(Input.isTriggered("ok")){
- $gamePlayer.attack();
- }
- }
- Game_Player.prototype.attack = function(){
- if (this.attacking) return;
- this.attacking = true;
- this.baseCharset = this._characterName;
- this._characterName = this.baseCharset + "_attack";
- this._stepAnime = true;
- this.attackingIndex = 0;
- var x2 = $gameMap.roundXWithDirection(this.x,this.direction());
- var y2 = $gameMap.roundYWithDirection(this.y,this.direction());
- if (this.isCollidedWithEvents(x2,y2) && $gameMap.getEventInPos(x2,y2).isEnemy())
- $gameMap.getEventInPos(x2,y2).damage(this);
- //this.moveStraight(this.direction());
- }
- var _gpUdt = Game_Player.prototype.update;
- Game_Player.prototype.update = function(sa){
- _gpUdt.call(this,sa);
- if (this.attacking){
- if (this.attackingIndex >= 20){
- this._characterName = this.baseCharset;
- this.attacking = false;
- this.attackingIndex = 0;
- this._stepAnime = true;
- }
- this.attackingIndex++;
- }
- }
- var _gpCm = Game_Player.prototype.canMove;
- Game_Player.prototype.canMove = function(){
- if (this.attacking)
- return false;
- return _gpCm.call(this);
- }
- Game_Map.prototype.getEventInPos = function(x,y){
- for(var i of this.events()){
- if (i.x == x && i.y == y)
- return i;
- }
- }
- var _geInit = Game_Event.prototype.initialize;
- Game_Event.prototype.initialize = function(eid,x,y){
- _geInit.call(this,eid,x,y);
- this.hp = parseInt(this.event().meta["enemy"]);
- }
- Game_Event.prototype.isEnemy = function(){
- return this.event().meta["enemy"] != undefined;
- }
- Game_Event.prototype.damage = function(attacker){
- if (this.isRecievingDamage) return;
- this.blinkIndex = 0;
- this.hp--;
- if (this.hp <= 0)
- $gameSelfSwitches.setValue([this._mapId,this._eventId,"C"],true);
- this.isRecievingDamage = true;
- this.damageIndex = 0;
- }
- var _geUdt = Game_Event.prototype.update;
- Game_Event.prototype.update = function(){
- _geUdt.call(this);
- if (this.isRecievingDamage){
- if (this.blinkIndex > 3) {
- this.opacity() > 0 ? this._opacity = 0 : this._opacity = 255;
- this.blinkIndex = 0;
- }
- else
- this.blinkIndex++;
- if (this.damageIndex >= 60) {
- this.isRecievingDamage = false;
- this._opacity = 255;
- }
- }
- this.damageIndex++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement