2144972924
Member
JavaScript:
//==================================================================================================================
/*:
* @plugindesc 独立技能(程序) 。
*
* @author 2144972924
*
* @help
* 〓 技能备注 〓
* 1:<NotUpgraded> 不需要升级的技能。
* 技能备注了这个,不得到经验不升级,并且不显示技能等级和EXP信息。
*
* 2:<ClassId:id> 技能经验依照备注的 职业ID 经验值来升级。
* id :职业ID。 例:备注技能根据 职业2 的经验升级 => <ClassId:2>
* 技能备注了这个职业ID,根据这个备注的职业经验曲线来升级。
* 未备注职业ID的技能,根据插件设置里的 hitExp 使用次数来升级。
*
* 3:<RptCount:num> 技能攻击次数依照该备注的等级差增加。
* num :等级差。未备注这个的技能,默认升级不提高攻击次数。
* 例:备注每升5级攻击次数 加1 => <RptCount:5>
* 技能1级时攻击次数 1,到5级时攻击次数 2,到10级时攻击次数 3 ...以此类推。
*
* 〓 说明 〓
* 1:技能有两种升级模式:A => 备注职业ID,依照职业经验升级;B => 依照设置的攻击次数升级。
* 2:职业经验升级的技能,只有在战斗中使用过该技能,才能加经验。
* 3:职业经验升级的技能,在战斗胜利时才增加经验。
*-------------------------------------------------------------------------------
* @param hitExp
* @desc 使用次数升级类的技能每级所对应的升级经验。该设置的经验个数为此类技能的最大等级(第一个必须为 0)。
* @default 0,10,25,45,70,100,135,175,220,270,325,385,450
*-------------------------------------------------------------------------------
* @param expRate
* @desc 战斗经验升级类的技能,胜利后所得战斗经验的百分比。
* @default 50
*-------------------------------------------------------------------------------
* @param dmgRate
* @desc 每升一级,技能的基本伤害值增加的百分比,也包括 魔法扣除量,TP扣除量 和 TP获得量。
* @default 5
*-------------------------------------------------------------------------------
* @param efcRate
* @desc 每升一级,技能的一些特殊效果数值增长的百分比。
* @default 5
*-------------------------------------------------------------------------------
*/
//==================================================================================================================
;var XdRsData = XdRsData || {};
XdRsData.UPVSkill = XdRsData.UPVSkill || {};
//==================================================================================================================
XdRsData.UPVSkill.pepr = PluginManager.parameters('XdRs_UPVSkill_A');
XdRsData.UPVSkill.expRate = +XdRsData.UPVSkill.pepr['expRate'] || 0;
XdRsData.UPVSkill.dmgRate = +XdRsData.UPVSkill.pepr['dmgRate'] || 0;
XdRsData.UPVSkill.efcRate = +XdRsData.UPVSkill.pepr['efcRate'] || 0;
XdRsData.UPVSkill.hitExp = ''+XdRsData.UPVSkill.pepr['hitExp'] || '';
XdRsData.UPVSkill.addData = 1;
//==================================================================================================================
var $baseSkills = null;
DataManager._databaseFiles.push({ name:'$baseSkills',src:'Skills.json'});
//==================================================================================================================
XdRsData.UPVSkill.deleteSkill = function(id){
$dataSkills[id] = null;
};
XdRsData.UPVSkill.addSkill = function(baseId){
this.setSkillId();
var newSkill = JSON.parse(JSON.stringify($baseSkills[baseId]));
$dataSkills[this.addData] = this.setupSkill(newSkill, baseId);
};
XdRsData.UPVSkill.setSkillId = function(){
this.addData = 1;
while(!!$dataSkills[this.addData]) this.addData++;
};
XdRsData.UPVSkill.setupSkill = function(skill, baseId){
skill.id = this.addData; skill.baseId = baseId;
skill.exp = 0; skill.level = 1;
this.setClassId(skill);
return skill;
};
XdRsData.UPVSkill.setClassId = function(skill){
skill.classId = 0;
if (!skill.note.match(<span style="color: #0066FF;">/<ClassId:(\d+)>/)) return;
skill.classId = +RegExp.$1 || 0;
};
XdRsData.UPVSkill.isSkill = function(skill){
return DataManager.isSkill(skill) && !!skill.level;
};
XdRsData.UPVSkill.expType = function(skill){
if (!this.isSkill(skill)) return 0;
return !!skill.classId ? 2 : 1;
};
XdRsData.UPVSkill.rptCount = function(skill){
if (!this.isSkill(skill)) return 0;
if (!skill.note.match(<span style="color: #0066FF;">/<RptCount:(\d+)>/)) return 0;
return +RegExp.$1;
};
XdRsData.UPVSkill.maxLevel = function(skill){
if (!skill.classId) return (skill.level === this.hitExp.split(',').length);
return skill.level === 99;
};
XdRsData.UPVSkill.notUpgraded = function(skill){
if (!this.isSkill(skill) || !skill.hitType) return true;
return !!skill.note.match(<span style="color: #0066FF;">/<NotUpgraded>/);
};
XdRsData.UPVSkill.nowExp = function(skill){
if (!this.isSkill(skill)) return 0;
return skill.exp - this.expForLevel(skill);
};
XdRsData.UPVSkill.nextExp = function(skill){
if (!this.isSkill(skill)) return 0;
return this.expForLevel(skill, 1) - this.expForLevel(skill);
};
XdRsData.UPVSkill.addExp = function(skill, num){
if (!this.isSkill(skill) || !num || this.notUpgraded(skill)) return;
skill.exp += num;
while(!this.maxLevel(skill) && skill.exp >= this.expForLevel(skill, 1)) this.levelUp(skill);
};
XdRsData.UPVSkill.expForLevel = function(skill, add){
add = add || 0; var level = skill.level + add;
if (!skill.classId) return +(this.hitExp.split(',')[level-1]);
var c = $dataClasses[skill.classId];
var basis = c.expParams[0],extra = c.expParams[1];
var acc_a = c.expParams[2],acc_b = c.expParams[3];
return Math.round(basis*(Math.pow(level-1, 0.9+acc_a/250))*level*
(level+1)<span style="color: #0066FF;">/(6+Math.pow(level,2)/50/acc_b)+(level-1)*extra);
};
XdRsData.UPVSkill.levelUp = function(skill){
skill.level++; this.renewSkill(skill);
};
XdRsData.UPVSkill.renewSkill = function(skill){
if (!!skill.mpCost) skill.mpCost += Math.ceil(skill.mpCost * XdRsData.UPVSkill.dmgRate / 100);
if (!!skill.tpCost) skill.tpCost += Math.ceil(skill.tpCost * XdRsData.UPVSkill.dmgRate / 100);
if (!!skill.tpGain) skill.tpGain += Math.ceil(skill.tpGain * XdRsData.UPVSkill.dmgRate / 100);
if (!!skill.successRate) {
var add = Math.ceil(skill.successRate * XdRsData.UPVSkill.dmgRate / 100);
skill.successRate = Math.min(skill.successRate+add, 100);
}
if (!!skill.repeats && !!this.rptCount(skill) && skill.level % this.rptCount(skill) === 0) skill.repeats++;
this.renewEffects(skill.effects);
};
XdRsData.UPVSkill.renewEffects = function(effects){
if (!effects.length) return;
for (var i=0;i<effects.length;i++){
var ef = effects[i];
switch(ef.code){
case 11 : ef.value1 = this.numCount(ef.value1, 100);
ef.value2 = this.numCount(ef.value2, 999999);break;
case 12 : ef.value1 = this.numCount(ef.value1, 100);
ef.value2 = this.numCount(ef.value2, 999999);break;
case 13 : ef.value1 = this.numCount(ef.value1, 100); break;
case 31 : ef.value1 = this.numCount(ef.value1, 1000); break;
case 32 : ef.value1 = this.numCount(ef.value1, 1000); break;
case 42 : ef.value1 = this.numCount(ef.value1, 1000); break;
}
}
};
XdRsData.UPVSkill.numCount = function(num, max){
if (!num) return 0;
num = Math.ceil(num + num * XdRsData.UPVSkill.efcRate / 100);
return Math.min(num, max);
};
//==================================================================================================================
XdRsData.UPVSkill.DMmakeSaveContents = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
var contents = XdRsData.UPVSkill.DMmakeSaveContents.call(this);
contents.skills = $dataSkills;
return contents;
};
XdRsData.UPVSkill.DMextractSaveContents = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
XdRsData.UPVSkill.DMextractSaveContents.call(this,contents);
$dataSkills = contents.skills;
};
//==================================================================================================================
XdRsData.UPVSkill.BattleManagerGainExp = BattleManager.gainExp;
BattleManager.gainExp = function() {
XdRsData.UPVSkill.BattleManagerGainExp.call(this);
var exp = Math.ceil(this._rewards.exp * XdRsData.UPVSkill.expRate / 100);
$gameParty.allMembers().forEach(function(actor){actor.addSkillExp(exp);});
};
//==================================================================================================================
XdRsData.UPVSkill.GAevalDamageFormula = Game_Action.prototype.evalDamageFormula;
Game_Action.prototype.evalDamageFormula = function(target) {
var damage = XdRsData.UPVSkill.GAevalDamageFormula.call(this, target);
return damage + this.itemLvRate(damage);
};
Game_Action.prototype.itemLvRate = function(damage) {
if (!XdRsData.UPVSkill.isSkill(this.item())) return 0;
return Math.ceil(damage * (this.item().level-1) * XdRsData.UPVSkill.dmgRate / 100);
};
XdRsData.UPVSkill.GAexecuteDamage = Game_Action.prototype.executeDamage;
Game_Action.prototype.executeDamage = function(target, value) {
XdRsData.UPVSkill.GAexecuteDamage.call(this, target, value);
var type = XdRsData.UPVSkill.expType(this.item());
if (type === 1) XdRsData.UPVSkill.addExp(this.item(), 1);
if (type === 2) this.subject().dataUsed(this.item().id);
};
//==================================================================================================================
Game_Actor.prototype.isLearnedSkill = function(baseId) {
if (!this.skills().length) return false;
for (var i=0;i<this.skills().length;i++){
if (this.skills()[i].baseId === baseId) return true;
}
return false;
};
Game_Actor.prototype.learnSkill = function(baseId) {
if (!this.isLearnedSkill(baseId)) {
XdRsData.UPVSkill.addSkill(baseId);
this._skills.push(XdRsData.UPVSkill.addData);
this._skills.sort(function(a, b) {return a - b;});
}
};
Game_Actor.prototype.forgetSkill = function(baseId) {
if (!this.isLearnedSkill(baseId)) return;
for (var i=0;i<this.skills().length;i++){
if (this.skills()[i].baseId === baseId) {
this._skills.splice(i, 1);
XdRsData.UPVSkill.deleteSkill(this.skills()[i].id);
return;
}
}
};
Game_Actor.prototype.addSkillExp = function(exp) {
if (!this._usedData || !this._usedData.length) return;
for (var i=0;i<this._usedData.length;i++){
XdRsData.UPVSkill.addExp($dataSkills[this._usedData[i]], exp);
}
this._usedData.length = 0;
};
Game_Actor.prototype.dataUsed = function(skillId) {
if (XdRsData.UPVSkill.notUpgraded[$dataSkills[skillId]]) return;
this._usedData = this._usedData || [];
if (!this._usedData.contains(skillId) && this._usedData.push(skillId)){}
};
//==================================================================================================================
//==================================================================================================================
/*:
* @plugindesc 独立技能(显示) 。
*
* @author 2144972924
*
* @help
*/
//==================================================================================================================
;var XdRsData = XdRsData || {};
XdRsData.UPVSkill = XdRsData.UPVSkill || {};
//==================================================================================================================
function XdRs_SkillHelp() {
this.initialize.apply(this, arguments);
}
XdRs_SkillHelp.prototype = Object.create(Sprite.prototype);
XdRs_SkillHelp.prototype.constructor = XdRs_SkillHelp;
XdRs_SkillHelp.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this._dataSkill = this._skill = null;
this.visible = false;
};
XdRs_SkillHelp.prototype.setSkill = function(skill) {
if (this._skill === skill) return;
this._skill = skill;
};
XdRs_SkillHelp.prototype.setPlace = function(x,y) {
if (!this.visible || !this.bitmap) return;
x = x.clamp(0,Graphics.width -this._w);
y = y.clamp(0,Graphics.height-this._h);
if (this.x === x && this.y === y) return;
this.move(x,y);
};
XdRs_SkillHelp.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateSkill();
};
XdRs_SkillHelp.prototype.updateSkill = function() {
if (this._dataSkill !== this._skill && this.refurbish()){}
};
XdRs_SkillHelp.prototype.refurbish = function() {
this._dataSkill = this._skill;
if (!!this._skill && (this.setBitmap() || this.drawAll())){}
this.visible = !!this._skill;
};
XdRs_SkillHelp.prototype.setBitmap = function() {
this._w = 260; this._h = this.heightCount();
if (!!this.bitmap) {
this.removeChild(this.con);
this.bitmap = this.con = null;
}
this.bitmap = new Bitmap(this._w, this._h);
this.con = new Sprite(new Bitmap(this._w, this._h));
this.addChild(this.con);
};
XdRs_SkillHelp.prototype.heightCount = function() {
var num = Window_Base._iconHeight + 186;
num += !!this.desLine() ? this.desLine()*30+15 : 0;
if (!!this.eftWords().length) num += this.eftWords().length * 32 + 10;
if (!XdRsData.UPVSkill.notUpgraded(this._skill)) num += 44;
return num;
};
XdRs_SkillHelp.prototype.drawAll = function() {
this.drawBack();this.drawSkillName();
this.drawSkillLevel();this.drawSkillBase();
this.drawSkillEft();this.drawSkillDes();
};
XdRs_SkillHelp.prototype.drawRect = function(x,y,w,h) {
var num = 70;
for (var i = 0; i< 3; i++){
this.bitmap.clearRect(x,y,w,h)
var color = 'rgba('+num+','+num+','+num+',0.8)';
this.bitmap.fillRect(x,y,w,h,color);
x++;y++;w-=2;h-=2;num-=20;
}
};
XdRs_SkillHelp.prototype.drawBack = function() {
var a = 0.2;
var x = y = 0, w = this._w, h = this._h;
for (var i = 0; i< 4; i++){
var color = 'rgba(0,0,0,'+a+')';
this.bitmap.fillRect(x,y,w,h,color);
x++;y++;w-=2;h-=2;a+=0.2;
this.bitmap.clearRect(x,y,w,h);
}
this.bitmap.fillRect(x,y,w,h,'rgba(0,0,0,0.8)');
this._ax = this._ay = 10;
};
XdRs_SkillHelp.prototype.drawSkillName = function() {
var aw = Window_Base._iconWidth + 6, ah = Window_Base._iconHeight + 6;
this.drawRect(this._ax,this._ay,aw,ah);
this.drawRect(this._ax+aw+5,this._ay,240-aw-5,ah);
var bitmap = ImageManager.loadSystem('IconSet');
var index = this._skill.iconIndex;
var pw = Window_Base._iconWidth,ph = Window_Base._iconHeight;
var sx = index % 16 * pw, sy = Math.floor(index / 16) * ph;
this.con.bitmap.blt(bitmap, sx, sy, pw, ph, this._ax+3, this._ay+3);
this.con.bitmap.fontSize = ah * 2 / 3;
this.con.bitmap.drawText(this._skill.name, this._ax+aw+5,this._ay+3,240-aw-5,ph,'center');
this._ay += ah + 10;
};
XdRs_SkillHelp.prototype.drawSkillLevel = function() {
if (XdRsData.UPVSkill.notUpgraded(this._skill)) return;
this.drawRect(this._ax,this._ay,240,34);
this.con.bitmap.fontSize = 22;
this.con.bitmap.textColor = 'rgb(0,255,255)';
var cw = this.con.bitmap.measureTextWidth('Lv: ');
this.con.bitmap.drawText('Lv: ',this._ax+5, this._ay+5, cw, 24);
this.con.bitmap.textColor = 'rgb(255,255,255)';
this.con.bitmap.drawText(''+this._skill.level,this._ax+5+cw, this._ay+5, 48, 24);
this.drawExp(this._ax+90,this._ay+2);
this._ay += 44;
};
XdRs_SkillHelp.prototype.drawExp = function(x, y) {
this.con.bitmap.fillRect(x,y+8,142,16);
var text = !!this._skill.classId ? 'exp' : 'hit';
this.con.bitmap.fontSize = 14;
this.con.bitmap.textColor = 'rgb(200,120,0)';
this.con.bitmap.drawText(text, x-25, y+6, 40, 18);
var aw = XdRsData.UPVSkill.nowExp(this._skill) * 140 / XdRsData.UPVSkill.nextExp(this._skill);
this.con.bitmap.fillRect(x+1,y+9,aw,14,'rgb(0,80,0)');
this.con.bitmap.fontSize = 18;
this.con.bitmap.textColor = 'rgb(255,255,255)';
text = ''+XdRsData.UPVSkill.nowExp(this._skill)+'/'+XdRsData.UPVSkill.nextExp(this._skill);
this.con.bitmap.drawText(text, x, y+6, 142, 20, 'center');
};
XdRs_SkillHelp.prototype.drawSkillBase = function() {
this.drawRect(this._ax,this._ay,240,150);
var words = ['技能类型: ','效果范围: ','技能消耗: ','攻击次数: ','命中几率: '];
var nums = [this.typeWord(),this.scopeWord(),this.costWord(),this.rptWord(),this.rateWord()];
for (var i = 0; i<5;i++){
this.con.bitmap.fontSize = 18;
this.con.bitmap.textColor = 'rgb(0,255,255)';
this.con.bitmap.drawText(words[i], this._ax+5, this._ay+5+i*30, 100, 18);
this.con.bitmap.textColor = 'rgb(120,120,120)';
this.con.bitmap.drawText('- - - - - - - - - - - - - -', this._ax+95, this._ay+20+i*30, 130, 10);
this.con.bitmap.fontSize = 16;
this.con.bitmap.textColor = 'rgb(255,255,255)';
this.con.bitmap.drawText(nums[i], this._ax+100, this._ay+4+i*30, 130, 20);
}
this._ay += 160;
};
XdRs_SkillHelp.prototype.drawSkillEft = function() {
var data = this.eftWords();
if (!data.length) return;
this.con.bitmap.fontSize = 18;
this.con.bitmap.textColor = 'rgb(180,0,180)';
for (var i=0;i<data.length;i++){
this.drawRect(this._ax,this._ay+i*32,240,30);
this.con.bitmap.drawText(data[i], this._ax+5, this._ay+6+i*32, 230, 18);
}
this._ay += data.length * 32 + 10;
};
XdRs_SkillHelp.prototype.drawSkillDes = function() {
if (!this.desLine()) return;
this.drawRect(this._ax,this._ay,240,this.desLine()*30+5);
this.con.bitmap.fontSize = 20;
this.con.bitmap.textColor = 'rgb(255,255,255)';
var text = this._skill.description.split('');
var ax = this._ax+5+40,ay = this._ay+5;
for (var i=0;i<text.length;i++){
var cw = this.con.bitmap.measureTextWidth(text[i]);
if (ax+cw > 240) {ax = this._ax+5; ay += 30;}
this.con.bitmap.drawText(text[i], ax, ay, cw, 20);
ax += cw;
}
};
XdRs_SkillHelp.prototype.typeWord = function() {
return !!this._skill.hitType ? this._skill.hitType == 1 ? '物理' : '魔法' : '- -';
};
XdRs_SkillHelp.prototype.scopeWord = function() {
var data = ['- -','敌人单体','敌人全体','随机敌人1','随机敌人2','随机敌人3','随机敌人4','己方单体',
'己方全体','己方单体(死亡)','己方全体(死亡)','使用者'];
return data[this._skill.scope];
};
XdRs_SkillHelp.prototype.costWord = function() {
var text = '';
if (!!this._skill.mpCost) text += TextManager.mpA + ' = '+this._skill.mpCost+' ';
if (!!this._skill.tpCost) text += TextManager.tpA + ' = '+this._skill.tpCost;
return !!text ? text : '- -';
};
XdRs_SkillHelp.prototype.rptWord = function() {
return !!this._skill.repeats ? ''+this._skill.repeats : '- -';
};
XdRs_SkillHelp.prototype.rateWord = function() {
return ''+this._skill.successRate + ' %';
};
XdRs_SkillHelp.prototype.eftWords = function() {
if (!this._skill.effects.length) return [];
var data = [],text;
for (var i=0;i<this._skill.effects.length;i++){
eft = this._skill.effects[i];
switch(eft.code){
case 11:text = '★ 恢复 '+TextManager.hpA +' ';
if (!!eft.value1) text += eft.value1 * 100 + '%';
if (!!eft.value1 && !!eft.value2) text += '+';
if (!!eft.value2) text += eft.value2;break;
case 12:text = '★ 恢复 '+TextManager.mpA +' ';
if (!!eft.value1) text += eft.value1 * 100 + '%';
if (!!eft.value1 && !!eft.value2) text += '+';
if (!!eft.value2) text += eft.value2;break;
case 13:text = '★ 恢复 '+TextManager.tpA +' '+eft.value1;break;
case 21:text = '★ '+eft.value1*100+'% 几率附加状态:'+$dataStates[eft.dataId].name;break;
case 22:text = '★ '+eft.value1*100+'% 几率消除状态:'+$dataStates[eft.dataId].name;break;
case 31:text = '★ 增加 '+TextManager.param(eft.dataId)+' 持续 '+eft.value1+' 回合';break;
case 32:text = '★ 减少 '+TextManager.param(eft.dataId)+' 持续 '+eft.value1+' 回合';break;
case 33:text = '★ 消除 增加'+TextManager.param(eft.dataId)+' 的效果 ';break;
case 34:text = '★ 消除 减少'+TextManager.param(eft.dataId)+' 的效果 ';break;
case 42:text = '★ '+TextManager.param(eft.dataId)+'增加 '+eft.value1 ;break;
case 43:text = '★ 可习得技能:'+$baseSkills[eft.dataId].name;break;
}
if (!!text) data.push(text);
}
return data;
};
XdRs_SkillHelp.prototype.desLine = function() {
if (!this._skill.description) return 0
var test_bitmap = new Bitmap(20,20);
test_bitmap.fontSize = 20;
var cw = test_bitmap.measureTextWidth(this._skill.description) + 40;
return Math.ceil(cw/240);
};
//==================================================================================================================
XdRsData.UPVSkill.SScreate = Scene_Skill.prototype.create;
Scene_Skill.prototype.create = function() {
XdRsData.UPVSkill.SScreate.call(this);
this.createXrHelp();
};
Scene_Skill.prototype.createXrHelp = function() {
this._xrHelp = new XdRs_SkillHelp();
this.addChild(this._xrHelp);
};
Scene_Skill.prototype.update = function() {
Scene_ItemBase.prototype.update.call(this);
this.updateXrHelp();
};
Scene_Skill.prototype.updateXrHelp = function() {
if (!this._itemWindow.isOpenAndActive()){this._xrHelp.setSkill(null); return;}
this._xrHelp.setSkill(this._itemWindow.item());
var x = (this._itemWindow.index() + 1) % 2 * 400 + 100;
var y = Math.floor(this._itemWindow.index()/2) * 32 + 300;
this._xrHelp.setPlace(x,y);
};
//==================================================================================================================
XdRsData.UPVSkill.SBcreateAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function() {
XdRsData.UPVSkill.SBcreateAllWindows.call(this);
this.createXrHelp();
};
Scene_Battle.prototype.createXrHelp = function() {
this._xrHelp = new XdRs_SkillHelp();
this.addChild(this._xrHelp);
};
XdRsData.UPVSkill.SBupdate = Scene_Battle.prototype.update;
Scene_Battle.prototype.update = function() {
XdRsData.UPVSkill.SBupdate.call(this);
this.updateXrHelp();
};
Scene_Battle.prototype.updateXrHelp = function() {
if (!this._skillWindow.isOpenAndActive()){this._xrHelp.setSkill(null); return;}
this._xrHelp.setSkill(this._skillWindow.item());
var x = (this._skillWindow.index() + 1) % 2 * 400 + 100;
var y = Math.floor(this._skillWindow.index()/2) * 32 + 150;
this._xrHelp.setPlace(x,y);
};
//==================================================================================================================