Wandelwicht

Villager
Member
Joined
Jan 19, 2015
Messages
5
Reaction score
0
First Language
German
Primarily Uses
Hey there,

I'm currently testing things out in ACE since I've only worked with RPGM2003 so far. The issue I have is that I'd like to insert busts during battle - more precisely: during any party member's turn, I want to insert a picture (named busts) of the actor above the bottom text window. So the question is: how do I get the current actor and how do I get to insert his or her picture during the battles' action phase.

I'd be happy if someone offered a step by step explanation. I do NOT want to implement one of the popular scripts from the webs since I want to learn this stuff and understand what I'm doing to be able to do these things on my own in the future.

Thanks a lot in advance!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,718
Reaction score
15,843
First Language
English
Primarily Uses
RMMV
I don't know if it's possible to do this without scripts.


The question is not so much how to get the current actor or insert his/her picture, but how to determine WHEN the actor should be shown or should change. That is controlled by the scripts, and it doesn't come back to you until it's done.


So unless you want a step-by-step explanation of how to create a script to do it, I think using an existing script is the only option.
 

Wandelwicht

Villager
Member
Joined
Jan 19, 2015
Messages
5
Reaction score
0
First Language
German
Primarily Uses
Thanks for answering :) Yup, I know that that is not possible without scripts, however I anticipated that it wouldn't be too complicated. I imagined it was just a [in battle, is action turn?, get actor, get pic, show pic] thing. So if it really is a short script, I'd be happy if someone was nice enough to show me how to do it. I understand however If it's too complitated.
 

Wandelwicht

Villager
Member
Joined
Jan 19, 2015
Messages
5
Reaction score
0
First Language
German
Primarily Uses
Bump, is it really that difficult?

What I've come up with so far is getting the actor ID:

$game_variables[13] = BattleManager.actor.id.to_iAt the moment, everything I try to script happens in the Scene_Battle script. My plan was to show pictures of every actor with 0 opacity when the battle starts, which I was able to accomplish with a common event and then "move" them to 255 opacity as soon as an actor is determined, then move them back transparent again. I thought that might be an easy way to do it.

I've run into some problems however. First of all I tried to move the pictures out of transparency with a common event:

screen.pictures[$game_variables[13]].move(0, 0, 140, 100, 100, 255, 0, 1)I called that event from the start_actor_command_selection method in Scene_Battle. The thing is, an actor picture was shown, but not during the command input but only after I had put in all commands of the party and the game started queueing those off. And it was only the last actor's pic that was shown. Now I don't know what exactly is the problem: The common event being called in the wrong place or the battle events not being able to call the common event in the middle of another scene or something completely different.

So, first of all: is my method a "valid" one, or is there a more efficient or simpler one? If so, how could I implement it?

Then: I was struggling showing and moving pictures from inside other scripts, the Scene_Battle script here. What would be the exact script to call a show or move picture command from there?

Any help solving the issue is much appreciated
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,201
Reaction score
858
First Language
Hungarian
Primarily Uses
RMVXA
You can't use common events in battles.


The only time the engine checks for common events in the battle is after an action is performed by default.


If you are scripting something directly, forget about variables and all those eventing stuff, that will just slow you down actually.


You create your own variables and methods in the script itself.


You don't need a $game_variable to store something which is temporary.


You don't need common events either, you can code it directly in the script. It is more flexible and less tiresome.


It seems you are at the right place. But before you can show a real image, initialize your sprite in SCene_Battle (in the 'def start' method with an instance variable - these start with a '@' sign).


Now get back to the actor selection method you already found. Make a new method there.


The new method should start with sprite.bitmap.clear to clear the bitmap automatically when the method is called. Make an 'if !bitmap.nil?' check for that clearing line because it won't have a bitmap when we first run that method.


You still can't call the image itself. Now you got a sprite ready to be filled, and you got the currently selecting actor. Yes, the whole actor class is at your disposal now! So you can make a method in Game_Actor or RPG::Actor, which would return the file name of the image used for the actor. When you are done with this, you can simply call this method to get the correct image to be used on the sprite.


And this would be it in short.


Remember to dispose your new sprite and it's bitmap after the battle!


I haven't tested this, but in theory, it should work.


It kinda sounds awesome, so maybe I will make a little script for it sometimes. :D


It sounds complicated at first, and it probably is for a beginner, but when you get better, things like this will be a breeze to do. :)


Just remember, forget about the eventing stuffs and try to script it instead!


Good luck and have fun learning! :)


If you have any other questions, just ask away!
 

Wandelwicht

Villager
Member
Joined
Jan 19, 2015
Messages
5
Reaction score
0
First Language
German
Primarily Uses
Thanks a lot for your help :) Sooo I think I was able to reconstruct the first part of your guide:

@sprite1 = Sprite.new    @bitmap1 = Bitmap.new(544,416)    @sprite1.bitmap = @bitmap1    insertspritein the start method and:

def insertsprite    if !@bitmap1.nil?      @sprite1.bitmap.clear    end  endas an own method in Scene_Battle. It works so far, so I hope it's correct :D

Could you please elaborate how to proceed? I think I'm able to get the actor ID with the line I posted above, but the pictures I want to show are not directly connected with the actors. Can I link them somehow during the actor setup (thing is, i need to be able to change the picture of one actor during the battle, metamorphosis and stuff)? Or might it be enough to just name the pictures 1,2,3,n so I can just check their names for the actor ID?
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,201
Reaction score
858
First Language
Hungarian
Primarily Uses
RMVXA
After testing my theory, it was almost right... almost. :D

Instead of calling the method for showing the images in the 'start_actor_command_selection' method, you should call it in the 'next_command' and 'prior_command'. This is to simplify the required modifications later on.

So, when you create a sprite, you need to assign a bitmap to it.

You created a sprite in the right way. However, make sure to use unique names for your variables, because if you use something like you just used, it might happen that you overwrite some previously created variable with the same name. @sprite1 is not really unique. Use something what actually describes what the thing is, like @battle_bust or something similar.

Now, if you want to assign an image directly to a sprite, you will need to assign a bitmap to the sprite and assign an image for the bitmap.

Use the cache for assigning the image for the bitmap. It is recommended to use the cache for images which appear a lot of times in your game. The battle busts will appear a lot of times, so you should use it here.

Here is how it would look like:

@bust.bitmap = Cache.picture("image file name goes here")This would assign an image from the folder Graphics/Pictures/ to the bitmap and will keep it in the memory for future uses until the game has been shut down.Look at the 'Cache' module at the top of the script list in the editor to see what kind of folders are available to use by default. You can create new usable folders by following the same format for your definition like the default ones in the 'Cache' module.

As soon as you assign an image to the bitmap assigned to the sprite, the image will appear on the screen.

Okay, now we know how to create the bust image. Now it is time to tie the correct images to the correct actors...

For this, we will jump into modules, and later, into another class.

First, create your module, name it however you like, but be sure to make it unique!

Example:

module Sixth_Battle_Busts # The contents of the module will go here!endWhen you are done, you can start to create your new, additional database.For the sake of flexibility, we will use a hash for creating the battle bust images.

Name it however you like.

A simple hash looks like this:

Example_Hash = { # <-- This kind of bracket indicates a hash! # The contents of the hash will go here!} # <-- This closes the hash, never forget this!Now we will populate the hash with the data needed for the bust images.For this, we will use the ID of the actors to name our keys in the hash. Keys are the names of the actual data.

Let's see what will we need for an image...

1. The file name of the image, obviously.

- This is defined with a simple string. Strings are enclosed by " signs.

2. Position of the image on the screen. # Optional for more flexibility!

- This is defined with integer numbers. We can use an array of 2 numbers for X and Y position.

3. The 'z' value for the image. # Optional for more flexibility!

- This is defined with integer numbers. The 'z' value affects what will be below the image and what will be above it.

4. The opacity value of the image. # Optional for more flexibility!

- This is defined with integer numbers. Valid values range from 0 to 255, 0 being fully transparent. This can be used to make the bust image a bit transparent, so that the player can still see what is behind the image in case something important can happen there.

So, let's see how would a complete setting look like for an actor:

1 => { :image => "actor1bust", :pos => [120,230], :opacity => 255, :z => 150,},Notice the ' => ' signs. When you are in a hash, the thing from the left of that sign is the key/name of the setting while the thing on the right is the data it holds.Define a setting like this for each actor and you are done with creating your battle bust database.

Now to put this database to good use, we will use it in Game_Actor to initialize and assign the correct pictures for the correct actors.

Head over to 'Game_Actor' and in the 'initialize(actor_id)' method, you can use the 'actor_id' to assign the images to the actors.

So, how can we use the newly created database in methods?

Remember the module and hash name we used at the start? Well, we need to use that like this:

Sixth_Battle_Busts::Example_HashThis returns the entire database we just created.If you use this and make something like this in the initialize method:

@battle_bust = Sixth_Battle_Busts::Example_Hash[actor_id]We will assign the correct images to the correct actors.To make it able to read and overwrite this new data for the actors, we need to add a simple line immediately below the "class Game_Actor" line, outside of any method. It looks like this:

attr_accessor :battle_bustThis will make it possible to call for this new data outside of the current class.Notice that you need to make the same name for it like the name of the variable you used, but instead of a ' @ ' sign, you use a ' : ' sign before the name.

And finally we are ready to make the pictures appear in the battle! Yayy!

Remember the methods I mentioned at the start? Yeah, me neither! :p

So, they were 'next_command' and 'prior_command' in 'Scene_Battle'.

In both of them, you will need to call the new method we will create now.

Make the new method, name it something unique and let's start the process!

As I mentioned, we need to clear the bitmap before each command selection starts. What I mixed up was clear and dispose. We need to use dispose here. It should look like this:

@bust.bitmap.dispose if !@bust.bitmap.nil? && !@bust.bitmap.disposed?We automated the image change after each confirm/cancel with this.Now we are ready to assign the image to the bitmap:

@bust_data = BattleManager.actor.battle_bust@bust.bitmap = Cache.picture(@bust_data[:image])See the method I used? That is calling the new data we just made on the currently selecting actor. From that data, we select the name of the image only here, hence we use '[:image]' after the method call.Got the picture on the screen, hoorray!

Now we can add the optional things we defined (the position, opacity and z values) below this line:

@bust.x = @bust_data[:pos][0]@bust.y = @bust_data[:pos][1]@bust.opacity = @bust_data[:opacity]@bust.z = @bust_data[:z]Now we positioned the image where we wanted to, and added any additional properties we wanted to.But what if there is no currently selecting actor on the scene? Than we will get into trouble unless we make a check for it before we actually run the above mentioned image assigning lines.

A simple check will do the trick:

@bust.bitmap.dispose if !@bust.bitmap.nil? && !@bust.bitmap.disposed?if !BattleManager.actor.nil? # Do the above mentioned image assigning lines here! endSo, when there is no actor selecting commands, it will simply get rid of any images showing. How convenient!Okay, but there are some circumstances where the images should be get rid of outside of those two methods we just edited. That is the 'turn_start' method. When the last actor is finished the command selection, we need to make the last image disappear. Use the same method we used to do it.

And finally, we need to dispose our sprite and bitmap at the end of the battle.

You can do it in the 'dispose_spriteset' method in 'Scene_Battle' with these lines:

@bust.bitmap.dispose if !@bust.bitmap.nil? && !@bust.bitmap.disposed?@bust.dispose if !@bust.nil? && !@bust.disposed?And this is the basic of creating what you want.For making this thing happen in the right way, you will need to learn and use aliases or else there can, and there will most probably be some compatibility issues with other custom scripts used.

This explanation got bigger than I expected. o.o

I guess I will need to split it up into 2 posts... Let's see...
 

Wandelwicht

Villager
Member
Joined
Jan 19, 2015
Messages
5
Reaction score
0
First Language
German
Primarily Uses
You, Sir, are a genius. I have hardly ever read a scripting tutorial so good, that even a non-programmer like me could understand and follow it. I followed every step and have the busts on my battle window now :) The only change I did was that I call the bust inserting method in start_actor_command_selection instead of prior_turn and next_turn (well at the moment, I call it in every one of the three. works fine right now). I tried those, but the correct bust would only show up _after_ the actor had made his command input, so it would always be one input late. Also, the bust needs to be disposed at command_skill and command_item and reinstated again in on_skill_cancel and on_item_cancel.

I can't thank you enough for your help :) I'll do some bit of testing with my metamorphosis skills and leave the thread open until I got it working correctly, some questions might still pop up.

Thanks again for showing how to do it and teaching me some Ruby while you were at it.. :)

EDIT: Alright, did the Metamorphosis trick with another hash key :altimage and a few ifs and switches :)
 
Last edited by a moderator:

Latest Threads

Latest Profile Posts


Look at the pretty pictures, they're so lifelike, touch them... Yes... Do so.... It will be fine... Promise. :LZSgrin:
The power of tutorials. This was fun to make,parallax lightning makes more sense to me now. Now comes the annoying step of doing stuff without a step by step show though !_!
With the new phone, I can now play a lot of old RPGs that my old phone just didn't have room for. Some RPGs definitely show their age even with updated graphics and quick saving.

Forum statistics

Threads
121,966
Messages
1,145,528
Members
160,246
Latest member
Izanami_
Top