Instantiating Actors from Template (that can be deleted)

cubanvirus

Villager
Member
Joined
Oct 6, 2016
Messages
10
Reaction score
0
First Language
English
Primarily Uses
In games like Pokemon, Megami Tensei, Dragon Quest, SaGa, Final Fantasy, etc., battle actors are created from an unchanging, precreated template. So although your Black Mage can level up, there are stats for a template Black Mage- the "Parent"- within the game, and as many unique clones or "children" can be created as you want.


It seems as though RMMV needs all its actors to be defined in the Actors Database, so there's no built-in functionality for these instances. There are currently a few available plugins that allow you to create these instances (HimeWorks' Instance Actors and DreamX's Capture Enemies being the main ones) , but they are severely limited, lacking the ability to remove actors added to the Actors Database. Without a method for the deletion of actors inserted, you run into several problems: players end up with having every captured enemy they've ever encountered dumped into their inventory. This is sometimes desirable, but in cases like Pokemon or Dragon Quest, being able to release/fire/delete these extraneous party members is important from a management standpoint. Though you could simply hide them in another party (using Yanfly's Party Manager or something), there is also an issue of memory management. Many of these plugins add to the Actors database endlessly with no method of managing when it's too "full." While, admittedly, you're unlikely to ever hit the upper limit of the array's length, it's also a bad idea to keep around discarded or otherwise pointless data no longer in use.


Perhaps you could do something like the following:


Parameters:

  • Starting Index Number for Instance Actors in Actor Database [int]
  • Maximum Number of Slots [int]



Internal Variables:

  • Is Initialized [bool]


    Whether the plugin has been run before
  • False by default.

[*]Empty Slots Array [Array of Ints]

  • stores the index number of Slots flagged as not in use, in order.

[*]Previous Starting Index Number for Instance Actors in Actor Database [int]

[*]Previous Maximum Number of Slots [int]

  • When saving, these two values should probably also be saved, to check if the bounds in the plugin options have increased or decreased between saves, and handle any issues accordingly.




Functions:

  • Initialize Plugin


    Run on first startup, when not loading from save
  • Check if Is Initialized is true. If not:

    Initialize "Removed Actors Array" by Pushing numbers from "Starting Index Number for Instance Actors in Actor Database" to ("Starting Index Number for Instance Actors in Actor Database + Maximum Number of Slots) - 1

    This means that if you set your Starting Index to 5 and Max Slots to 5, you'd have an array of [ 5, 6, 7, 8, 9]

[*]set "Is Initialized" to true.
 



[*]Add Actor (Parent ID Number)

  • If there are values in the Empty Slots Array:

    Pop the first value from Removed Actors to a variable called "Insertion Point."
  • Call: Insert Actor (Parent ID Number, Insertion Point)

[*]If not, return some value so you can handle this (for instance, telling users that they have no available spaces in their party.)




  • Remove Actor (Actor ID Number)


    Do whatever functions are required to remove the actor from UIs
  • Push the Actor ID Number into the Empty Slots Array,
  • Notice that you don't actually DELETE the actor. You're just flagging it to be overwritten.



  • Insert Actor (Parent ID Number, Insertion Point)


    Copy the data from the Actors Database at the Parent ID Number, creating a duplicate of our Template Actor
  • Insert the duplicate data into the Actors Database at the Insertion Point.
  • By splitting this from Add Actor checks, you can allow for things like Pokemon-style evolution.




Then some kind of Plugin Commands for each of the three functions, and save the Internal Variables somewhere. You would also probably need some functionality in the Load/Save functions to perform cleanup in case the Starting Index/Maximum Slots change, such as looping through the Empty Slots and splicing out those that no longer exist, or adding them if the bounds have increased.


The concept being that you will be overwriting the same set of slots by the oldest "Removed" actor, recycling the same slots in the database. Since you'd never be deleting any values from the built-in Actor Database, only overwriting, you might not run into issues of deleted things still being needed, especially since only actors long since removed from play are overwritten. You would also have a controlled selection of available slots, so you wouldn't run into any issues with memory storage growing out of control. And since the slots that are "removed" are controlled by the plugin, that would mean that Parent actors would never be deleted accidentally, as well.


The plugin commands would also allow for you to easily create menu options to release party members, or even options to sell them. The idea of removed actors still being in memory might open up some other interesting ideas, too, such as having monsters you released show up as NPCs or as ghosts, or being able to buy them back, depending on what further extension plugins were created.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top