Instance Actors

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

By default, RPG Maker does not support the creation of new actors during the game. When you create your game, you would set up actors in the database, and then during the game, those actors will be used.

With this plugin, the possibility of creating completely new actors during the game is open for you.

For example, you could create a mechanic where you capture enemies during battle, which are converted to actors before they are added to the party. These actors did not exist when you first created your project, nor do they exist in other save files.

This plugin provides the functionality for managing custom actors that are generated at run-time.

Download

Plugin: download here (right-click, save as)

Installation

Download the plugin and place it in the “plugins” folder in your project’s “js” folder. Then open your Plugin Manager (F10), double-click an empty row, and select the HIME_InstanceActors plugin.

Once it is in your list of plugins, turn the plugin on.

Usage

Setup

In the plugin parameters, choose the “Template Actor ID”. This is the “default” actor that all newly created actors will be based on.

Then set the “Start ID”, which represents how the custom actors will be identified. Once the game starts, you have no way to change these ID’s, so if you are expecting to add more actors to your project, you should take that into consideration when choosing the the start ID. I would go with something like 1000 just to be safe.

Creating Actors

To create a new actor, use the script call

var newActor = InstanceManager.addActor()

The game would create a new actor for you, using the template actor as the base.
It would basically be a copy of it with a new ID.

If you wanted to base it on a different template, you can specify that in the script call like this

var newActor = InstanceManager.addActor( 2 )

Which will use actor 2 as the template.

The actor creation process simply creates an actor. It doesn’t automatically add it to your party, because you might not want to do that. If you want to add it to your party, you could write

var newActor = InstanceManager.addActor()
$gameParty.addActor(newActor.id)

Deleting Actors

This plugin does not provide support for deleting actors, because that actor might be in use by other objects. It is safer to simply not use the actor.

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

You may also like...

16 Responses

  1. Vanderson says:

    Is there a way to store the Actor ID in a variable?

  2. Coninuumg says:

    I made the following snippet so I could easily make summoning spells:
    Game_Party.prototype.summon = function(id,level) {
    var newActor = InstanceManager.addActor(id)
    $gameActors.actor(newActor.id).changeLevel(level, false);
    $gameActors.actor(newActor.id).recoverAll();
    this.addActor(newActor.id);
    }
    But whenever I use it, instead of getting one new actor, I get a number equal to the number of actors already in the party. I really don’t feel like summoning exponential slimes.

  3. User says:

    Has there been any further development in this plugin? A RemoveActor function is sorely needed.

    • Hime says:

      Removing actor is not planned to be implemented.
      It would be better to simply replace an actor with a new one if needed.

  4. En says:

    var newActor = InstanceManager.addActor()
    $gameParty.addActor(newActor.id)

    When I type that I get the error:

    TypeError:
    Cannot read property ‘0’ of undefined

  5. Anonymous says:

    how to remove them from party? >___<

    • Hime says:

      You would need to use plugins or techniques that allow you to manage actors without knowing who they are beforehand.
      What are you trying to do?

      • Vazad says:

        I don’t know about the original poster but I would very much like a functionality similar to the Box from Pokemon or the Farm from Dragon Quest Monsters where you can store unused actors with the ability to switch them in and out of the party and delete unwanted actors.

        I came here from your [Dev] Capturing enemies, recruit them as actors! from the forums and am curious if you ever made headway on that, it looks like it would be quite useful.

        • Hime says:

          You can sort of create one using the Party Switching Scene plugin, where you would move actors to a separate party if you do not wish to use them.

          • Vazad says:

            Alright, that might work. Hmmm, I’ll see what I can Kludge together, thanks for making all these wonderful mods.

          • Hime says:

            If you need something specific or would like to know how to build something specific, let me know.
            A lot of things could be evented, but if you want a dedicated scene for it that could be done as well.

          • Vazad says:

            (Can’t reply to your latest comment for some reason)

            Well, I’m trying to work on a Monster tamer ala Pokemon. I think I can see how to create a “box” for storage so I’ll just work on getting things set up the best I can for now. The big wall I’m going to run into are functionality as I’m still rather new to programming at all.

            The main thing that would be useful would be allowing people to somehow remove actors they don’t need. Do you think it would be possible to add a menu event that deletes by slot in the second party that is acting as the “box”?

            I can think of workarounds for everything else I need using the tools created already but that is a big sticking point to me as I can imagine players getting annoyed without the functionality.

  6. Grilled Mormons says:

    Thank you for this, without this script i would have to completely change my vision.
    One question though,
    How would i go about name input for the instanced actor?

    • Hime says:

      You have a few options when it comes to name input.
      If you are setting up names directly after creation, you will be able to use the ID.
      SceneManager.push(Scene_Name);
      SceneManager.prepareNextScene( ACTOR_ID , MAX_LETTERS );

      If you would like to rename them afterwards, when you don’t have access to the ID, you would need to reference them somehow.
      For example, you might need to produce a list of actors for the player to choose, and then given a reference to the actor, you can then grab the ID.

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax