RPGWaldorf

Untitled

Jul 25th, 2023
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 4.78 KB | Software | 0 0
  1. //=============================================================================
  2. // Plugin compatibility for Random Human Enemies - MZ
  3. //=============================================================================
  4. /*:
  5. * @target MZ
  6. * @plugindesc [Rpg Maker MZ] [Version 0.5] This plugin is to use random generated characters as enemy battlers. Visustella BattleCore and MMP_CharacterMake needed.
  7. * @url https://waldorf.itch.io/
  8. * @target MZ
  9. * @author RPGWaldorf
  10.  
  11.  
  12. * @help How to use:
  13.  
  14. 1) Add Visustella BattleCore to your game
  15.    --NOTE: CoreEngine is NOT strictly needed--
  16.    --On the contrary, it's not compatible with a function you may or may not use of the MMP plugin (Displaying generated characters on map)--
  17.    Add MPP_CharacterMake and MPP_CharacterMakeOp1 too -
  18.    https://woodpenguin.web.fc2.com/MV_Plugin/CharacterMake.html
  19.    Add this plugin under those two.
  20.  
  21. 2) Add the "generator" folder with generation parts in your game folder root
  22.     You can copy it from the installation folder of RPG Maker MZ
  23.     Playtest the game once (and after every generator folder change) to allow the plugin to elaborate datas
  24.  
  25. 3) Generate Characters:
  26.     You need to save them on Actor indexes, keep a few empty.
  27.     Method 1:Generate them with MPP_CharacterMake plugin commands:
  28.         -First, use the first command to select its category (parameter 1: ActorId. Parameter 2: Gender)
  29.         -Then use the last command to randomly generate it (Parameter 1: ActorId)
  30.         (But if too many appears in battle at once it might lag while it loads)
  31.     Method 2: You can preload them with the plugin command of this plugin.
  32.         -It's still suggested you don't preload many of them at once.
  33.         NOTE: after closing the game, the character is still saved, but the preloaded one isn't.
  34.         So you can use it again, even if it falls under the previous option.
  35.  
  36. 4) Make them appear in battle!
  37.     Use the tag on the enemy
  38.     <SIDEVIEW BATTLER: &ID>
  39.     Where "ID" is the Actor id where you generated the character.
  40.  
  41. *
  42. * @command Preload Human Enemies
  43. * @desc Generates characters in actor slots 11+.
  44. * @arg actorSlotId
  45.     * @text Actor Slot ID
  46.     * @type number
  47.     * @default 11
  48.     * @desc Actor slot from where start the character generation
  49. * @arg number
  50.     * @text Quantity
  51.     * @type number
  52.     * @default 4
  53.     * @desc Number of character battlers to generate
  54. * */
  55.  
  56.  
  57. (function() {
  58.  
  59.     const pluginName = "RandomHumanEnemies";
  60.  
  61.     var tempPreloadEnemyHuman = [];
  62.  
  63.     PluginManager.registerCommand(pluginName, "Preload Human Enemies", args => {
  64.        
  65.         var number = parseInt(args["number"]);
  66.         var actorId =  parseInt(args["actorSlotId"]);
  67.         var genderValues = ["Male", "Female", "Kid"/*, "MaleMV", "FemaleMV", "KidMV"*/]; //you can add more categories there and
  68.  
  69.        
  70.  
  71.         for (let id = actorId; id < actorId + number; id++) {
  72.  
  73.             //Chooses a random category between Male, Female, Kid.
  74.             var randomGender = genderValues[Math.floor(Math.random() * genderValues.length)];
  75.            
  76.             //Calls the MPP plugin
  77.             PluginManager.callCommand(
  78.                 $gameMap._interpreter,
  79.                 "MPP_CharacterMake",
  80.                 "setActorKind",
  81.                 { actorId: id, kind: randomGender}
  82.             );
  83.  
  84.             PluginManager.callCommand(
  85.                 $gameMap._interpreter,
  86.                 "MPP_CharacterMake",
  87.                 "Op1:changePartsRandom",
  88.                 { actorId: id }
  89.             );
  90.  
  91.             //saves the generated character in a variable
  92.             tempPreloadEnemyHuman[id] = ImageManager.loadGeneratorBitmap($gameActors.actor(id)._geneBattlerName, 'SV');
  93.  
  94.  
  95.         }
  96.     });
  97.  
  98.  
  99.     //feeds the preloaded character into Visustella. Uses aliases, so it doesn't ovverride.
  100.     const _ImageManager_loadSvActor = ImageManager.loadSvActor;
  101.     ImageManager.loadSvActor = function(filename) {
  102.         if(/^MppGeneSV/.test(filename)){
  103.             return this.loadGeneratorBitmap(filename, 'SV');
  104.         } else{
  105.             if(filename.startsWith("&")){
  106.                
  107.                 if(tempPreloadEnemyHuman[parseInt(filename.substring(1))] !== undefined){
  108.                     //method that uses the preloaded characters
  109.                     return tempPreloadEnemyHuman[parseInt(filename.substring(1))]
  110.                 } else{
  111.                     //method that loads them all at onece on battle start, but lags while it loads.
  112.                     return this.loadGeneratorBitmap($gameActors.actor(parseInt(filename.substring(1)))._geneBattlerName, 'SV');
  113.                 }
  114.                
  115.             } else {
  116.                 return _ImageManager_loadSvActor.apply(this, arguments);
  117.             }
  118.            
  119.         }
  120.        
  121.     };
  122.  
  123.  
  124. })();
  125.  
  126.  
  127.  
Tags: RPG Maker MZ
Add Comment
Please, Sign In to add comment