Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
273
First Language
English
I have made a script that changes your class when you equip a new weapon.

I would like some feedback and suggestions.

This script does the following:

when you equip a different weapon type then your class changes.
You also lose your exp when you changes classes but it isn't gone, when you change back you back at your old level.
 
 

Code:
//=============================================================================// 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[i] = parseInt(weaponTypeArray[i], 10); } for(var i=0; i<classesArray.length; i++) { classesArray[i] = parseInt(classesArray[i], 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 ---> [URL="http://forums.rpgmakerweb.com/index.php?/topic/47747-custom-class-change-v100/?hl=classchange//I"]http://forums.rpgmakerweb.com/index.php?/topic/47747-custom-class-change-v100/?hl=classchange//I[/URL] used his code for forgetting and learning new skillsYoji Ojima//I used the plugin TitleCommand Position to learn how to operate the parameters*/
 
Last edited by a moderator:

fm2107

Veteran
Veteran
Joined
Jun 12, 2014
Messages
81
Reaction score
22
First Language
english
i just noticed this, but you might want to have it moved to script releases, you'll get more feed back there 
 

bretk0923

Warper
Member
Joined
Nov 1, 2015
Messages
4
Reaction score
0
First Language
English
This is an awesome plugin and it gives incredible functionality to games. 

Would there be an easy way (or link to a different plugin) to modify this so that equipping a certain piece of armor changes the class? I've seen scripts for previous versions of RPG Maker that do so, but none so far for MV.
 

KlausAidon

Veteran
Veteran
Joined
Oct 15, 2012
Messages
62
Reaction score
17
First Language
English
Primarily Uses
I was actually looking into trying to do something like this. Though I wanted it to be a specific feature of one character, and it to be tied to his dual wielding. I wanted his class to change depending on, say, if he was holding two swords, or two daggers, or a sword and pistol, etc etc. Different combinations allowing different abilities to be usable. But from what I can tell from this, it doesn't look at the off hand weapon equip? That's the dead end I hit, trying to do this with common events instead of JS. I couldn't figure out how to get RPGMV to look at the off hand.
 

glokplopit

Villager
Member
Joined
Nov 18, 2015
Messages
10
Reaction score
0
Primarily Uses
Is it possible to change the class with individual weapons rather than weapon types? Thank you!
 

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
273
First Language
English
Hmmm lets see I think there is a script out there for this. You would have to use the note tag system to specify what class you want to change into. I would have to dig around for the exact person who made it though.
 

OZiO

Veteran
Veteran
Joined
Jul 21, 2016
Messages
40
Reaction score
39
First Language
English
Primarily Uses
Hey Guys,


Not sure if any of you have ran into this, but I'm a bit stuck on implementing this. Whenever I run this with my classes/weapon types set up I get this error back. I was wondering if you any of you had any insight on this?

2016-09-16 14_41_52-Project Bersona.png
 

Latest Threads

Latest Profile Posts

My game has a (much needed) tutorial now...
Game Making Every Day #20:kaohi:

ScreenShot_8_14_2022_11_55_51.png
FINALLY added the comic bubble to the Title Screen...
I know I'll put one of my game's sprites here to give the illusion that I am a productive member of game society.
handelspriteanim.gif

Forum statistics

Threads
124,507
Messages
1,164,110
Members
163,332
Latest member
Gaggo
Top