赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1381 |
最后登录 | 2017-6-2 |
在线时间 | 10 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 10 小时
- 注册时间
- 2017-1-18
- 帖子
- 11
|
//删除,到时候可以读取data
var changeList = [];
changeList[0] = {
class: 2, //当前职业Id
target: 3, //目标职业Id
level: 0, //转职等级
variable: ["1>4"], //变量1大于4
item: [{ type: 0, id: 1, count: 5 }, { type: 1, id: 2, count: 5}], //物品类型,物品id,数量
add: { skill: [], param: [5, 5, 5]}//增加的技能,属性
}
Game_Party.prototype.AdvancedClass = function (i) {
var actor = this.members[i];
var change = null;
for (var j in changeList) {
if (changeList[j].class == actor._classId) {
change = changeList[j]; break;
}
}
if (change != null) {
if (actor._level >= change.level) {
var okVariable = true;
for (var k in change.variable) {
var temp = change.variable[k].split('>');
if (temp.length == 2 && $gameVariables[temp[0]] < temp[1]) {
okVariable = false; break;
}
}
//变量条件不足!
if (!okVariable) {
$gameMessage.add(actor._name + "的机缘未到!"); return false;
}
var okItem = true;
for (var l in change.item) {
var item = null;
switch (change.item[l].type) {
case 0: item = $dataItems[change.item[l].id]; break;
case 1: item = $dataWeapons[change.item[l].id]; break;
case 2: item = $dataArmors[change.item[l].id]; break;
}
if (this.numItems(item) < change.item[l].count) {
okItem = false; break;
}
}
if (!okVariable) {
$gameMessage.add("物品不够!"); return false;
}
//减少物品
for (var l in change.item) {
var item = null;
switch (change.item[l].type) {
case 0: item = $dataItems[change.item[l].id]; break;
case 1: item = $dataWeapons[change.item[l].id]; break;
case 2: item = $dataArmors[change.item[l].id]; break;
}
this.gainItem(item, -change.item[l].count, true);
}
//更改职业保留经验
actor.changeClass(change.target, true);
//学习技能
$.each(change.add.skill, function (idx, obj) {
actor.learnSkill(obj);
});
//增加属性
$.each(change.add.param, function (idx, obj) {
actor.addParam(idx, obj);
});
}
else {
$gameMessage.add(actor._name + "等级不够!");
return false;
}
}
else {
$gameMessage.add(actor._name + "没有职业可转!");
}
}
未测试大概可以这样子 |
|