| 
 
| 赞 | 11 |  
| VIP | 0 |  
| 好人卡 | 0 |  
| 积分 | 7 |  
| 经验 | 0 |  
| 最后登录 | 2023-7-13 |  
| 在线时间 | 42 小时 |  
 Lv2.观梦者 
	梦石0 星屑735 在线时间42 小时注册时间2019-11-26帖子28 | 
| 本帖最后由 xsrong2 于 2019-12-4 13:47 编辑 
 首先,敌人是没有tp这一说的……
 
 发一个我自己写的渣脚本,刚刚增加了显示tp的代码,默认是注释掉的。
 如果你给敌人自定义了tp和mtp属性,可以将tp部分的代码去掉注释就可以了。
 
 
 复制代码// 设置显示血条长度
var barWidth = 120;
// 设置是否显示hp条
var showEnemyHP = true;
// 设置是否显示mp条
var showEnemyMP = true;
// // 设置是否显示tp条
// var showEnemyTP = true;
Game_Enemy.prototype.createBar = function(x, y, width, height, color1, color2) {
  bitmap = new Bitmap(width, height);
  bitmap.gradientFillRect(0, 0, width, height, color1, color2, false);
  sprite = new Sprite(bitmap);
  sprite.x = x;
  sprite.y = y;
  return sprite
}
Spriteset_Battle.prototype.createEnemyHPBar = function(height, colorBottom, colorCover1, colorCover2) {
  var enemies = $gameTroop.members();
  var barBottoms = [];
  var barCovers = [];
  
  for (var i = 0; i < enemies.length; i++) {
    battler = enemies[i];
    barBottom = battler.createBar(enemies[i].screenX(), enemies[i].screenY() - height * 2, barWidth, height, colorBottom, colorBottom);
    barCover = battler.createBar(enemies[i].screenX(), enemies[i].screenY() - height * 2, enemies[i].hp / enemies[i].mhp * barWidth, height, colorCover1, colorCover2);
    barBottoms[i] = barBottom;
    barCovers[i] = barCover;
    this._battleField.addChild(barBottoms[i]);
    this._battleField.addChild(barCovers[i]);
  }
  this._enemyHPBars = barCovers;
}
Spriteset_Battle.prototype.createEnemyMPBar = function(height, colorBottom, colorCover1, colorCover2) {
  var enemies = $gameTroop.members();
  var barBottoms = [];
  var barCovers = [];
  
  for (var i = 0; i < enemies.length; i++) {
    battler = enemies[i];
    barBottom = battler.createBar(enemies[i].screenX(), enemies[i].screenY() - height, barWidth, height, colorBottom, colorBottom);
    barCover = battler.createBar(enemies[i].screenX(), enemies[i].screenY() - height, enemies[i].mp / enemies[i].mmp * barWidth, height, colorCover1, colorCover2);
    barBottoms[i] = barBottom;
    barCovers[i] = barCover;
    this._battleField.addChild(barBottoms[i]);
    this._battleField.addChild(barCovers[i]);
  }
  this._enemyMPBars = barCovers;
}
Spriteset_Battle.prototype.createEnemyTPBar = function(height, colorBottom, colorCover1, colorCover2) {
  var enemies = $gameTroop.members();
  var barBottoms = [];
  var barCovers = [];
  for (var i = 0; i < enemies.length; i++) {
    battler = enemies[i];
    barBottom = battler.createBar(enemies[i].screenX(), enemies[i].screenY(), barWidth, height, colorBottom, colorBottom);
    barCover = battler.createBar(enemies[i].screenX(), enemies[i].screenY(), enemies[i].tp / enemies[i].mtp * barWidth, height, colorCover1, colorCover2);
    barBottoms[i] = barBottom;
    barCovers[i] = barCover;
    this._battleField.addChild(barBottoms[i]);
    this._battleField.addChild(barCovers[i]);
  }
  this._enemyTPBars = barCovers;
}
Spriteset_Battle.prototype.updateEnemyBars = function() {
  enemies = $gameTroop.members()
  for (var i = 0; i < enemies.length; i++) {
    if (showEnemyHP) {
      hpSprite = this._enemyHPBars[i];
      hpSprite.width = enemies[i].hp / enemies[i].mhp * barWidth;
    }
    if (showEnemyMP) {
      mpSprite = this._enemyMPBars[i];
      mpSprite.width = enemies[i].mp / enemies[i].mmp * barWidth;
    }
    // if (showEnemyTP) {
    //   tpSprite = this._enemyTPBars[i];
    //   tpSprite.width = enemies[i].tp / enemies[i].mtp * 120;
    // }
  }
}
xsrong_createEnemies = Spriteset_Battle.prototype.createEnemies
Spriteset_Battle.prototype.createEnemies = function() {
  xsrong_createEnemies.call(this);
  this._enemyBars = [];
  if (showEnemyHP) {
    this.createEnemyHPBar(6, 'black', '#e08040', '#f0c040');
  }
  if (showEnemyMP) {
    this.createEnemyMPBar(6, 'black', '#4080c0', '#40c0f0');
  }
  // if (showEnemyTP) {
  //   this.createEnemyTPBar(6, 'black', '#00a040', '#00e060');
  // }
}
xsrong_update = Spriteset_Battle.prototype.update
Spriteset_Battle.prototype.update = function() {
  xsrong_update.call(this);
  this.updateEnemyBars();
}
 | 
 |