Change Class with Different Weapon Type

Hello Everyone,

This is my first script that I have been making.
I haven't done any coding before.

Took me quite a while to make this work.

Below is my script of changing the class of your actor when you equip a different weapon type.

Please note this is not when you change a weapon but when the weapon type changes.

I need help completing the script.

The script seems to long and I think I may have done this the long way.

If anyone can shorten things that would be great.

Also I would like to git rid of the old classes skills and have only the current class skills.

Anyone know how to do this?

Please note the file is a .txt format and not .js.

I have notepad ++ and I can convert it easily.

 

//=============================================================================

// WeaponClassChange.js

//=============================================================================

 

/*:

 * @plugindesc Changes the class of an actor when they equip a different weapon type.

 * @author Jeremy Cannady

 *

 * @param Weapon Types

 * @desc 

 * @default 1,2,3,4,5,6,7,8,9,10

 *

 * @param Classes

 * @desc 

 * @default 1,2,3,4,5,6,7,8,9,10

 *

 * @help The paramter order determines the class change.

 *For example when you equip weapon type 1 then your class changes to class 1.

 *If you changed the Classes parameter to 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.

 *Note that class number 11 is a reserved class for when you have nothing equipped 

 *so make sure that class 11 in your database has something in it.

 *

 *

 *

*/

 

//Opens the debug window, delete the next three '//' to access this.

//var _debugWindow = require('nw.gui').Window.get().showDevTools();

//_debugWindow.moveTo(0, 0);

//window.focus();

 

(function() {

 

//Retrieve the parameters

var parameters = PluginManager.parameters('WeaponClassChange');

    var weaponType = parameters['Weapon Types'];

    var classes = parameters['Classes'];

 

//Store the parameters into an string array and get rid of the commas

var weaponTypeArray = weaponType.split(',');

var classesArray = classes.split(',');

 

//Convert the parameters into number array

for(var i=0; i<weaponTypeArray.length; i++) { weaponTypeArray = parseInt(weaponTypeArray, 10); } 

for(var i=0; i<classesArray.length; i++) { classesArray = parseInt(classesArray, 10); } 

 

//This function compares which weapon type you ahve equipped and gives you the class that corresponds to it.

Game_Actor.prototype.changeClassWeapon = function(){

//Stores what weapon type you have equipped into variable wtypeId

var weapons = this.weapons();

var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;

//Stores the current actor into a variable so we can use it later.

var currentActor = this.actor().id;

//Finds the position of the equipped weapon in the parameters array and stores it into the variable

var position = weaponTypeArray.indexOf(wtypeId);

//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[position];

//If the actor has unequipped a weapon then make the newClassId into call 11 which is 'Unarmed'

if($gameActors.actor(currentActor).hasNoWeapons()){newClassId = 11;};

//Returns the new class when this function is called

return newClassId;

};

 

//Whenever there is an equipment change then this function runs

Game_Actor.prototype.changeEquip = function(slotId, item) {

    if (this.tradeItemWithParty(item, this.equips()[slotId]) &&

            (!item || this.equipSlots()[slotId] === item.etypeId)) {

        this._equips[slotId].setObject(item);

        this.refresh();

//Don't edit the above, was taken directly from the rpg.objects.js file

 

//Stores the actor id into a variable for later use

var currentActor = this.actor().id;

//Stores our current exp so we know what it is

var currentEXP = $gameActors.actor(currentActor).currentExp();

//Changes our class based on what our function changeClassWeapon gave us in the return

$gameActors.actor(currentActor).changeClass($gameActors.actor(currentActor).changeClassWeapon());

//Changes our exp back to what it was before the class change

$gameActors.actor(currentActor).changeExp(currentEXP,false);

    };

};

 

})();

 

 

 

 

 

 

 

 

 
 

 

 

 

WeaponClassChange.txt

Original thread: https://forums.rpgmakerweb.com/threads/change-class-with-different-weapon-type.47037/