Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var COLD = COLD || {};
- COLD.BREED = COLD.BREED || {};
- /*:
- * @plugindesc Makes a breeding system.
- * @author Jeremy Cannady
- *
- * @param StatsIncrease
- * @desc How much to increase the base stats. Number not percentage.For now...
- * @default 10
- *
- * @param Hatch Animation
- * @desc Animation to play when hatching an egg.
- * @default 1
- *
- * @param Hatch Final Animation
- * @desc Animation to play after the main hatching animation.
- * @default 2
- *
- * @param Hatch Ani Repeats
- * @desc How many times to repeat the animation.
- * @default 2
- *
- * @param Notification Text
- * @desc Text to notify that your egg is about to hatch.
- * @default Oh...?
- *
- * @param Second Notification Text
- * @desc Text indicating that your egg is hatching.
- * @default Your egg appears to be hatching!
- *
- * @param Third Notification Text
- * @desc Text to notify that your egg hatched.
- * @default Your egg hatched! Would you like to name it?
- *
- * @param First Egg Text
- * @desc Egg description of a new egg.
- * @default A new egg.
- *
- * @param Second Egg Text
- * @desc Egg description of egg not close to hatching.
- * @default The egg is nowhere close to hatching.
- *
- * @param Third Egg Text
- * @desc Egg description of egg near hatching
- * @default The egg moves occasionally.
- *
- * @param Fourth Egg Text
- * @desc Egg description of egg very close to hatching.
- * @default Sounds can be heard inside!
- *
- * @param Monster Races
- * @desc List of races and there egg Icon index,and steps to hatch, each separated by a comma.
- * @default Dragon,150,10,Elf,160,50
- *
- * @param Breeding Pairs
- * @desc List of monsters that can breed with each other.
- * @default {"Dragon":"Elf","Elf":"Dragon,Elf"}
- *
- * @help
- * Version 1.0
- Note tag <race:Dragon> Everything is case sensitive.
- PluginCommand: makeEgg 1 3, where 1 is actor id of the father and 3 is actor id of mother.
- *
- */
- aliasDM_extractSaveContents = DataManager.extractSaveContents;
- DataManager.extractSaveContents = function(contents) {
- aliasDM_extractSaveContents.call(this,contents)
- for(var i = 0; i < $gameSystem.generatedActors.length;i++){
- $dataActors.push($gameSystem.generatedActors[i]);
- };
- for(var i = 0; i < $gameSystem.generatedItems.length;i++){
- $dataItems.push($gameSystem.generatedItems[i]);
- };
- };
- COLD.BREED.Parameters = PluginManager.parameters('BreedingSystem');
- COLD.Param = COLD.Param || {};
- COLD.Param.BSystemStatsIncrease = Number(COLD.BREED.Parameters['StatsIncrease'] || 10);
- COLD.Param.BSystemAnimation = Number(COLD.BREED.Parameters['Hatch Animation'] || 1);
- COLD.Param.BSystemAnimationR = Number(COLD.BREED.Parameters['Hatch Ani Repeats'] || 2);
- COLD.Param.BSystemFAnimation = Number(COLD.BREED.Parameters['Hatch Final Animation'] || 2);
- COLD.Param.BSystem1Text = COLD.BREED.Parameters['Notification Text'];
- COLD.Param.BSystem2Text = COLD.BREED.Parameters['Second Notification Text'];
- COLD.Param.BSystem3Text = COLD.BREED.Parameters['Third Notification Text'];
- COLD.Param.BSystem1EggText = COLD.BREED.Parameters['First Egg Text'];
- COLD.Param.BSystem2EggText = COLD.BREED.Parameters['Second Egg Text'];
- COLD.Param.BSystem3EggText = COLD.BREED.Parameters['Third Egg Text'];
- COLD.Param.BSystem4EggText = COLD.BREED.Parameters['Fourth Egg Text'];
- COLD.Param.BSystemRaces = COLD.BREED.Parameters['Monster Races'].split(',');
- COLD.Param.BSystemPairs = JSON.parse(COLD.BREED.Parameters['Breeding Pairs']);
- (function(){
- COLD.Param.BSystemConvertedPairs = {};
- for(var key in COLD.Param.BSystemPairs) {
- COLD.Param.BSystemConvertedPairs[key] = (COLD.Param.BSystemPairs[key].split(','));
- }
- COLD.BREED.storeGenerated = Game_System.prototype.initialize;
- Game_System.prototype.initialize = function() {
- COLD.BREED.storeGenerated.call(this);
- this.generatedActors = [];
- this.generatedItems = [];
- };
- var newEgg_pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- newEgg_pluginCommand.call(this, command, args);
- if (command === "newEgg") {
- COLD.BREED.makeEgg($dataActors[(args[0])], $dataActors[(args[1])]);
- };
- };
- COLD.BREED.makeChild = function(egg){
- var mother = $dataActors[egg.meta.mother];
- var father = $dataActors[egg.meta.father];
- var sex = (egg.sex === "female") ? true : false;
- child = {
- "id":$dataActors.length,
- "traits":[],
- "initialLevel":1,
- "maxLevel":99,
- "profile":"",
- "mother":{"id":mother.id,"lvl":egg.motherLvl, "stats":egg.motherStats},
- "father":{"id":father.id,"lvl": egg.fatherLvl, "stats":egg.fatherStats},
- "sex":egg.sex,
- "battlerName":(sex) ? mother["battlerName"] : father["battlerName"],
- "characterIndex":(sex) ? mother["characterIndex"]:father["characterIndex"],
- "characterName": (sex) ? mother["characterName"]:father["characterName"],
- "faceIndex":(sex) ? mother["faceIndex"]:father["faceIndex"],
- "faceName":(sex) ? mother["faceName"]:father["faceName"],
- "name":(sex) ? mother["name"]:father["name"],
- "nickname":(sex) ? mother["nickname"]:father["nickname"],
- "note":(sex) ? mother["note"]:father["note"],
- "classId":(sex) ? mother["classId"]:father["classId"],
- "equips": [],
- "intialStatBoost":false
- };
- $dataActors.push(child)
- $gameSystem.generatedActors.push(child);
- return child;
- };
- COLD.BREED.makeSex = function(){
- var sex = (Math.random() < 0.5) ? "female":"male";
- return sex;
- };
- COLD.BREED.makeEgg = function(father, mother){
- if( COLD.Param.BSystemConvertedPairs[mother.meta.race].indexOf(father.meta.race) != -1 ||
- COLD.Param.BSystemConvertedPairs[father.meta.race].indexOf(mother.meta.race) != -1 ||
- father.meta.race == mother.meta.race){
- egg = {"id":null,
- "animationId":120,
- "consumable":false,
- "damage":{"critical":false,"elementId":0,"formula":"0","type":0,"variance":0},
- "steps":0,
- "effects":[{"code":11, "dataId":0, "value1":0, "value2":0}],
- "hitType":0,
- "itypeId":1,
- "name":"Egg",
- "meta":{
- "hatchEgg":true,
- "father" :father.id,
- "mother":mother.id
- },
- "note":"",
- "occasion":0,
- "price":0,
- "repeats":1,
- "scope":0,
- "speed":0,
- "successRate":100,
- "sex":COLD.BREED.makeSex(),
- "motherLvl": mother._level,
- "fatherLvl": father._level,
- "tpGain":0,
- "maxItem":99};
- var iconIfFemale = COLD.Param.BSystemRaces[(COLD.Param.BSystemRaces.indexOf(mother.meta.race) + 1)];
- var iconIfMale = COLD.Param.BSystemRaces[(COLD.Param.BSystemRaces.indexOf(father.meta.race) + 1)];
- var stepsIfFemale = COLD.Param.BSystemRaces[(COLD.Param.BSystemRaces.indexOf(mother.meta.race) + 2)];
- var stepsIfMale = COLD.Param.BSystemRaces[(COLD.Param.BSystemRaces.indexOf(father.meta.race) + 2)];
- egg.stepsToHatch = egg.sex ? stepsIfFemale : stepsIfMale;
- egg["id"] = $dataItems.length;
- egg["description"] = COLD.BREED.hatchStatus(egg);
- egg["iconIndex"] = egg.sex ? iconIfFemale : iconIfMale;
- $dataItems.push(egg);
- $gameSystem.generatedItems.push(egg);
- $gameParty.gainItem($dataItems[egg.id],1);
- };
- };
- COLD.BREED.hatchStatus = function(egg){
- var text;
- var progress = egg.steps / egg.stepsToHatch;
- if(progress > 0.75){
- text = COLD.Param.BSystem4EggText;
- }else if(progress > 0.50){
- text = COLD.Param.BSystem3EggText;
- }else if(progress > 0.25){
- text = COLD.Param.BSystem2EggText;
- }else{
- text = COLD.Param.BSystem1EggText;
- }
- egg.description = text;
- }
- Object.defineProperties(Game_BattlerBase.prototype, {
- // Maximum Hit Points
- mhp: { get: function() {if(this.hatched == true){
- return Math.round(this.param(0) + COLD.Param.BSystemStatsIncrease);
- }else return this.param(0); }, configurable: true },
- // Maximum Magic Points
- mmp: { get: function() { if(this.hatched == true){
- return Math.round(this.param(1) + COLD.Param.BSystemStatsIncrease);
- }else return this.param(1); }, configurable: true },
- // ATtacK power
- atk: { get: function() { if(this.hatched == true){
- return Math.round(this.param(2) + COLD.Param.BSystemStatsIncrease);
- }else return this.param(2); }, configurable: true },
- // DEFense power
- def: { get: function() { if(this.hatched == true){
- return Math.round(this.param(3) + COLD.Param.BSystemStatsIncrease);
- }else return this.param(3);}, configurable: true },
- // Magic ATtack power
- mat: { get: function() {if(this.hatched == true){
- return Math.round(this.param(4) + COLD.Param.BSystemStatsIncrease);
- }else return this.param(4); }, configurable: true },
- // Magic DeFense power
- mdf: { get: function() { if(this.hatched == true){
- return Math.round(this.param(5) + COLD.Param.BSystemStatsIncrease);
- }else return this.param(5); }, configurable: true },
- // AGIlity
- agi: { get: function() { if(this.hatched == true){
- return Math.round(this.param(6) + COLD.Param.BSystemStatsIncrease);
- }else return this.param(6); }, configurable: true },
- // LUcK
- luk: { get: function() { if(this.hatched == true){
- return Math.round(this.param(7) + COLD.Param.BSystemStatsIncrease);
- }else return this.param(4); }, configurable: true }
- });
- COLD.BREED.aliasSMapIsBusy = Scene_Map.prototype.isBusy;
- COLD.BREED.newisBusy = function(){
- return $gameMessage.isBusy();
- };
- COLD.BREED.changeSMapisBusy = function(value){
- if(value == true){
- Scene_Map.prototype.isBusy = COLD.BREED.newisBusy;
- }else{
- Scene_Map.prototype.isBusy = COLD.BREED.aliasSMapIsBusy;
- };
- };
- COLD.BREED.hatchEgg = function(egg){
- var child = this.makeChild(egg);
- COLD.BREED.hatchingActorID = child.id;
- COLD.BREED.hatchEggCurrent = egg;
- $gameParty.gainItem(egg, -1);
- COLD.BREED.changeSMapisBusy(true);
- $gameMessage.add(COLD.Param.BSystem1Text);
- SceneManager.push(COLD.BREED.Scene_Hatch);
- };
- COLD.BREED.hatchEggCurrent = null;
- COLD.BREED.hatchingActorID = null;
- Game_Party.prototype.increaseSteps = function() {
- this._steps++;
- var items = $gameParty.items().length;
- for(var i = 0; i < items ; i++){
- if($gameParty.items()[i].meta.hatchEgg == true){
- COLD.BREED.hatchStatus($gameParty.items()[i]);
- if($gameParty.items()[i].steps >= $gameParty.items()[i].stepsToHatch ){
- COLD.BREED.hatchEgg($gameParty.items()[i]);
- break;
- };
- $gameParty.items()[i].steps += 1;
- };
- };
- };
- /**
- * Create a scene for hatching.
- */
- COLD.BREED.Scene_Hatch = function() {
- this.initialize.apply(this, arguments);
- }
- COLD.BREED.Scene_Hatch.prototype = Object.create(Scene_MenuBase.prototype);
- COLD.BREED.Scene_Hatch.prototype.constructor = COLD.BREED.Scene_Hatch;
- COLD.BREED.Scene_Hatch.prototype.initialize = function() {
- Scene_MenuBase.prototype.initialize.call(this);
- };
- COLD.BREED.Scene_Hatch.prototype.create = function() {
- Scene_MenuBase.prototype.create.call(this);
- this.createBackground();
- this.createAnimation();
- this.createNewActor();
- this.createWindowLayer();
- this.createAllWindows();
- };
- COLD.BREED.Scene_Hatch.prototype.createAllWindows = function() {
- this.createMessageWindow();
- };
- COLD.BREED.Scene_Hatch.prototype.createMessageWindow = function() {
- this._messageWindow = new Window_Message();
- this.addWindow(this._messageWindow);
- this._messageWindow.subWindows().forEach(function(window) {
- this.addWindow(window);
- }, this);
- };
- COLD.BREED.Scene_Hatch.prototype.isBusy = function(){
- return $gameMessage.isBusy();
- };
- COLD.BREED.Scene_Hatch.prototype.counter = 0;
- COLD.BREED.Scene_Hatch.prototype.startCounter = false;
- COLD.BREED.Scene_Hatch.prototype.startAnimation = false;
- COLD.BREED.Scene_Hatch.prototype.update = function() {
- Scene_Base.prototype.update.call(this);
- if(this.counter == 0 && this.startCounter == false){
- $gameMessage.add(COLD.Param.BSystem2Text)
- this.startCounter = true;
- this.startAnimation = true;
- };
- if(this.startAnimation == true && !this.isBusy()){
- this.activateAnimations()
- this.startAnimation = false;
- };
- if(this.startCounter == true && !this.isBusy()){
- if(this.counter == this.hatchTime){
- this.startCounter = false;
- this.bitmap3.opacity = 255;
- var actorId = $gameActors._data.length - 1
- $gameParty.addActor(actorId);
- $gameActors.actor(actorId)["hatched"] = true;
- $gameMessage.add(COLD.Param.BSystem3Text)
- this.activateNameChange();
- }
- this.counter++;
- };
- };
- COLD.BREED.Scene_Hatch.prototype.createBackground = function() {
- this._backSprite1 = new Sprite(ImageManager.loadBattleback1($gameMap.battleback1Name()));
- this._backSprite2 = new Sprite(ImageManager.loadBattleback2($gameMap.battleback2Name()));
- this.addChild(this._backSprite1);
- this.addChild(this._backSprite2);
- };
- COLD.BREED.Scene_Hatch.prototype.createNewActor = function() {
- var characterName = $gameActors.actor(COLD.BREED.hatchingActorID)._characterName;
- var characterIndex = $gameActors.actor(COLD.BREED.hatchingActorID)._characterIndex;
- this.bitmap3 = new Sprite(ImageManager.loadCharacter(characterName));
- this.bitmap3.move(Graphics.width / 2 - 24,Graphics.height / 2 -24);
- var n = characterIndex;
- var sx = (n % 4 * 3 + 1) * 48;
- var sy = (Math.floor(n / 4) * 4) * 48;
- this.bitmap3.setFrame(sx, sy, 48, 48);
- this.bitmap3.opacity = 0;
- this.addChild(this.bitmap3);
- };
- COLD.BREED.Scene_Hatch.prototype.createAnimation = function() {
- this._animation = new Sprite_Base();
- this._animation.x = Graphics.width / 2;
- this._animation.y = Graphics.height / 2;
- this.addChild(this._animation);
- };
- COLD.BREED.Scene_Hatch.prototype.activateAnimations = function(){
- var animation = $dataAnimations[COLD.Param.BSystemAnimation];
- var finishingAnimation = $dataAnimations[COLD.Param.BSystemFAnimation];
- var animationFrames = animation.frames.length;
- var fAnimationFrames = finishingAnimation.frames.length;
- var repeats = COLD.Param.BSystemAnimationR;
- for(var i = 0; i < repeats; i++){
- this._animation.startAnimation(animation, false, i * animationFrames * 4);
- };
- this._animation.startAnimation(finishingAnimation, false, (4 * repeats * animationFrames))
- this.hatchTime = (4 * repeats * animationFrames) + (4 * fAnimationFrames);
- };
- COLD.BREED.Scene_Hatch.prototype.activateNameChange = function(){
- SceneManager.goto(Scene_Name);
- SceneManager.prepareNextScene(COLD.BREED.hatchingActorID, 8);
- COLD.BREED.changeSMapisBusy(false);
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement