Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // 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.
- *
- *
- *
- */
- var COLD = COLD || {};
- COLD.WeaponClassChange = {
- Game_Actor_Setup : Game_Actor.prototype.setup,
- Game_Actor_changeEquip : Game_Actor.prototype.changeEquip,
- Parameters : PluginManager.parameters('WeaponClassChange'),
- };
- COLD.WeaponClassChange.weaponType = COLD.WeaponClassChange.Parameters['Weapon Types'].split(',');
- COLD.WeaponClassChange.classes = COLD.WeaponClassChange.Parameters['Classes'].split(',');;
- COLD.WeaponClassChange.defaultClass = Number(COLD.WeaponClassChange.Parameters['Unequipped Class']);
- //Convert the parameters into number array
- for(var i = 0; i < COLD.WeaponClassChange.weaponType.length; i++) { COLD.WeaponClassChange.weaponType[i] = parseInt(COLD.WeaponClassChange.weaponType[i], 10); }
- for(var i = 0; i < COLD.WeaponClassChange.classes.length; i++) { COLD.WeaponClassChange.classes[i] = parseInt(COLD.WeaponClassChange.classes[i], 10); }
- (function() {
- Game_Actor.prototype.setup = function(actorId) {
- COLD.WeaponClassChange.Game_Actor_Setup.call(this,actorId);
- this._classExp = [];
- var length = $dataClasses.length
- for(var i = 0; i<length; i++){
- //Sets the default value for each class starting exp to 0
- this._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 = COLD.WeaponClassChange.classes[COLD.WeaponClassChange.weaponType.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 = COLD.WeaponClassChange.defaultClass;
- };
- //When we call this function then return what our class should be based upon which wepaon we have equipped
- return newClassId;
- };
- //Overide Game_Actor.prototype.changeEquip
- Game_Actor.prototype.changeEquip = function(slotId, item) {
- //When we change our equipment then do what we used to do in the origial Game_Actor.prototype.changeEquip
- COLD.WeaponClassChange.Game_Actor_changeEquip.call(this,slotId,item);
- //but also do this
- COLD.WeaponClassChange.changeToNewClass(this.actor().id);
- };
- COLD.WeaponClassChange.changeToNewClass = function(currentActor){
- //When we call the function changeToNewClass then do these things.
- //Current Actor ID
- var actor = $gameActors.actor(currentActor);
- //Current Class Id
- var currentClassId = actor.currentClass().id;
- var newClassId = actor.getNewClassId();
- //Current Exp
- var currentExp = actor.currentExp();
- //Put the curent exp back in to the array
- actor._classExp[currentClassId] = currentExp;
- //Change the class
- actor.changeClass(newClassId, false);
- //Change the exp to the correct value
- var newExp = actor._classExp[newClassId];
- actor.changeExp(newExp,false)
- //Forget old skills
- actor._skills.forEach(function(forget){
- var index = actor._skills.indexOf(forget);
- if (index >= 0) {
- actor._skills.splice(index, 1);
- };
- }, actor);
- //Learn new skills
- actor.currentClass().learnings.forEach(function(learning) {
- if (learning.level <= actor._level) {
- actor.learnSkill(learning.skillId);
- }
- }, actor);
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement