设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 75|回复: 0

[转载发布] Class change when equip weapon type.

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29925
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38778

    灌水之王

    发表于 4 天前 | 显示全部楼层 |阅读模式
    WeaponClassChange.js v1.0
    Jeremy Cannady

    Introduction
    Changes your class when you equip a different weapon. Your exp is saved so when you reequip you go back to your old level. The class must be-able to equip the weapon.

    Download

    http://pastebin.com/uah4Ek1i


    Screenshots
     This does not apply to all scripts, specially to those which don't have any visual effect.

    How to Use
    Give instructions on how to install and use the script. Also, make sure that you include the instructions in the script header(together with the version number and your name) so that the user can consult it when needed).

    Demo
    Don't have a demo at the moment.

    Script
    Make sure that you place your script using the code feature, do not use quotes. Again, if spoiler tag is available in the future then use the spoiler tag together with the code tag.

    Spoiler//=============================================================================// WeaponClassChange.js//=============================================================================/*: * @plugindesc Changes class when actor equips a different weapon type. * @author Jeremy Cannady * * @param Weapon Types * @desc List the weapon types. * @default 1,2,3,4,5,6,7,8,9,10 * * @param Classes * @desc List the classes. * @default 1,2,3,4,5,6,7,8,9,10 * * @param Unequipped Class * @desc The is the class you want to be when you dont have a weapon equipped. * @default 1 * Example one: * Weapon Type : 1,2,3,4,5,6,7,8,9,10 * | | | | | | | | | | * Class: 1,2,3,4,5,6,7,8,9,10 * When you equip weapon type one your class changes to class #1 in your database. *  When you equip weapon type 5 your class changes to class #5 in your database. * * Example two: * Weapon Type: 1,2,3,4,5,6,7,8,9,10 * | | | | | | | | | |  * Class: 1,2,8,4,5,6,7,8,9,10 *  When you equip weapon type three or eight your class changes to class #8 in your database. * * @help The parameter order determines the class change.Classes 1,2,3,4,5,6,7,8,9,10 *For example when you equip weapon type 1 then your class changes to class 1.Classes 2,2,3,4,5,6,7,8,9,10 *In this example when you equip weapon type 1 then your class changes to class 2. *Please see script text for a simple graphic. * * **/(function() {//Retrieve the parametersvar parameters = PluginManager.parameters('WeaponClassChange');var weaponType = parameters['Weapon Types'];  var classes = parameters['Classes'];var defaultClass = Number(parameters['Unequipped Class']);//Store the parameters into an string array and get rid of the commasvar weaponTypeArray = weaponType.split(',');var classesArray = classes.split(',');//Convert the parameters into number arrayfor(var i=0; i<weaponTypeArray.length; i++) { weaponTypeArray = parseInt(weaponTypeArray, 10); } for(var i=0; i<classesArray.length; i++) { classesArray = parseInt(classesArray, 10); } //Lets make a copy of Game_Actor.prototype.setup so we can add to itvar Game_Actor_setup = Game_Actor.prototype.setup;Game_Actor.prototype.setup = function(actorId) {Game_Actor_setup.call(this,actorId);this._classExp = [];var length = $dataClasses.lengthfor(var i = 0; i<length;i++){//Sets the default value for each class starting exp to 0this._classExp.push(0); };}//This function compares which weapon type you have equipped and gives you the class that corresponds to it.Game_Actor.prototype.getNewClassId = function(){var wtypeId = this.weapons()[0] ? this.weapons()[0].wtypeId : 0;//Takes the position of the weapon parameter and makes newClassId equal to the the parameter that is in the same position as the weapon type.var newClassId = classesArray[weaponTypeArray.indexOf(wtypeId)];//If the actor has unequipped a weapon then make the newClassId into the 'Unequipped Class' in the parameters.if($gameActors.actor(this.actor().id).hasNoWeapons()){newClassId = defaultClass;};//When we call this function then return what our class should be based upon which wepaon we have equippedreturn newClassId;}; //Make a copy of changeEquip so we can edit itvar copyOfChangeEquip = Game_Actor.prototype.changeEquip;//Overide Game_Actor.prototype.changeEquipGame_Actor.prototype.changeEquip = function(slotId, item) {//When we change our equipment then do what we used to do in the origial Game_Actor.prototype.changeEquipcopyOfChangeEquip.call(this,slotId,item);//but also do thisthis.changeToNewClass(this.actor().id);};Game_Actor.prototype.changeToNewClass = function(currentActor){//When we call the function changeToNewClass then do these things.//Current Actor IDvar actor = $gameActors.actor(currentActor);//Current Class Idvar currentClassId = actor.currentClass().id;var newClassId = actor.getNewClassId();//Current Expvar currentExp = actor.currentExp();//Put the curent exp back in to the arrayactor._classExp[currentClassId] = currentExp;//Change the classactor.changeClass(newClassId, false);//Change the exp to the correct valuevar newExp = actor._classExp[newClassId];actor.changeExp(newExp,false)//Forget old skillsactor._skills.forEach(function(skill){        var index = actor._skills.indexOf(skill);        if (index >= 0) {            actor._skills.splice(index, 1);};}, actor);//Learn new skillsactor.currentClass().learnings.forEach(function(learning) {          if (learning.level <= actor._level) {              actor.learnSkill(learning.skillId);          }      }, actor);}; })();/*:CreditsArcherBanish ---> http://forums.rpgmakerweb.com/index.php?/topic/47747-custom-class-change-v100/?hl=classchange//I used his code for forgetting and learning new skillsYoji Ojima//I used the plugin TitleCommand Position to learn how to operate the parameters*/ 






    Credit and Thanks
    - Jeremy Cannady
    ArcherBanish ---> http://forums.rpgmakerweb.com/index.php?/topic/47747-custom-class-change-v100/?hl=classchange
    I used his code for forgetting and learning new skills

    Yoji Ojima
    I used the plugin TitleCommand Position to learn how to operate the parameters

    Author's Notes
    This is optional



    本贴来自国际rpgmaker官方论坛作者:Jeremy Cannady处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/class-change-when-equip-weapon-type.48693/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 06:38 , Processed in 0.112592 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表