本帖最后由 andrewx 于 2016-3-10 21:56 编辑
事件里执行脚本:
var actorId = 1, lowerBound = 1, upperBound = 15, learnNum = 4; //修改以上参数,分别是角色ID,最小技能ID,最大技能ID,学习个数 var actor = $gameActors.actor(actorId); var unlearned = 0; for (var i = lowerBound; i <= upperBound; i++) {if (!actor.isLearnedSkill(i)) {unlearned++;}} if (unlearned <= learnNum) {for (var i = lowerBound; i <= upperBound; i++) {actor.learnSkill(i);}} else {for (var i = 0; i < learnNum; i++) {while (true) {var skillId = Math.floor(Math.random() * (upperBound - lowerBound + 1) + lowerBound);if (!actor.isLearnedSkill(skillId)) {actor.learnSkill(skillId);break;}}}}
var actorId = 1, lowerBound = 1, upperBound = 15, learnNum = 4;
//修改以上参数,分别是角色ID,最小技能ID,最大技能ID,学习个数
var actor = $gameActors.actor(actorId);
var unlearned = 0; for (var i = lowerBound; i <= upperBound; i++) {if (!actor.isLearnedSkill(i)) {unlearned++;}}
if (unlearned <= learnNum) {for (var i = lowerBound; i <= upperBound; i++) {actor.learnSkill(i);}} else {for (var i = 0; i < learnNum; i++) {while (true) {var skillId = Math.floor(Math.random() * (upperBound - lowerBound + 1) + lowerBound);if (!actor.isLearnedSkill(skillId)) {actor.learnSkill(skillId);break;}}}}
或者:
var memberIndex = 0, lowerBound = 1, upperBound = 15, learnNum = 4; //修改以上参数,分别是队列index,最小技能ID,最大技能ID,学习个数 var actor = $gameParty.members()[memberIndex]; var unlearned = 0; for (var i = lowerBound; i <= upperBound; i++) {if (!actor.isLearnedSkill(i)) {unlearned++;}} if (unlearned <= learnNum) {for (var i = lowerBound; i <= upperBound; i++) {actor.learnSkill(i);}} else {for (var i = 0; i < learnNum; i++) {while (true) {var skillId = Math.floor(Math.random() * (upperBound - lowerBound + 1) + lowerBound);if (!actor.isLearnedSkill(skillId)) {actor.learnSkill(skillId);break;}}}}
var memberIndex = 0, lowerBound = 1, upperBound = 15, learnNum = 4;
//修改以上参数,分别是队列index,最小技能ID,最大技能ID,学习个数
var actor = $gameParty.members()[memberIndex];
var unlearned = 0; for (var i = lowerBound; i <= upperBound; i++) {if (!actor.isLearnedSkill(i)) {unlearned++;}}
if (unlearned <= learnNum) {for (var i = lowerBound; i <= upperBound; i++) {actor.learnSkill(i);}} else {for (var i = 0; i < learnNum; i++) {while (true) {var skillId = Math.floor(Math.random() * (upperBound - lowerBound + 1) + lowerBound);if (!actor.isLearnedSkill(skillId)) {actor.learnSkill(skillId);break;}}}}
第二种是按队列位置,注意index从0开始,即第一个队员index=0
未详细测试,如果指定范围内未学技能数量小于等于学习个数,则强制学习未学的全部技能。其他情况随机在未习得技能里学习指定个数技能,不过这随机的效率很差。
扔完就跑,你问我为啥不换行?谁让编辑器只能写12行呢wwwww |