Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Sprite Changing Script

Daphoa

Member

First of all, I don't technically need a script. I have some basic programming experience, but not any with Ruby so I've started my own script (shown at the end), but it's not exactly working - also I've only got a part of what I want.

What I want is to add an attack that creates "an illusion." Basically it changes a character's field sprite (and battle sprite if possible) and flicks a switch on depending on what is chosen.

The script would have a main menu in which the player could select either Enemy, Animal, or Person (or exit). Then, depending on the option, a new menu would appear, giving the option to choose a specific sprite (doesn't require a sprite preview, but I'm not complaining if you want to). Also, this script only has to work on one Character.

Also, whenever a sprite is changed a switch is activated. Enemy sprites would activate a certain variable that would give the player a rank against other enemies but I think I can play with that myself. The only thing other is that the sprites would not all be available from the start. They would have to be unlocked.

The Animal/Person sprites would be unlocked by changing a variable or switch. I have no problem unlocking the sprites linearly.

The Enemy sprites would be unlocked by the Character using a specific skill on the enemy . If that's too hard, then simply seeing the enemy should be fine. Ideally all enemy sprites in the game will be accessible. (Note that in my game only the sprites the come with RPG Maker XP are used).

That's it. To me this seems relatively simple, but I don't know about you. Anyway, even if you can't do everything, anything that you do would be great. And the more you explain what your doing the better, because I will look at these afterwards and attempt to fix it. Anyway, thanks for at least reading this much.

EDIT: Old Animal Script has been removed. It currently works and will post the whole package in the script analysis once it is complete.
 
Firstly, it would help a lot if you put it in [ code ] tags, so that we can all see the indentation.

Second, in the main loop, there should be no @ in front of animal_refresh. You seem to have a Scene set up here, but it's named as a Game object. If you called it as $scene = Game_Illusion_Animal.new, it would present a blank screen with your command window.

Third, you want to use $game_actors[], not $data_actors[].

Fourth, if you want to mix the order a bit, you can install the SDK (or just this one function from it) to use @command_window.command, which returns the name of the command currently selected. This way you could make a case @command_window.command instead of @command_window.index, and use your @animal1..5 variables instead of integers.

I suppose I could see this working if you used my layering Scene_Base, however this involves installing the full SDK and then using the Scene_Base I provide you (for XP). If you were to do that, you could use Game_Illusion_Animal as a scene (after solving these things) by running a call script "$scene.new_layer(Game_Illusion_Animal)" and you would need to use "new_scene(nil)" to remove it in the Cancel command. For the full impact of this, you'd want to fully SDK it as a Scene, using main_variable to define your variables and main_window to define the command window, as well as changing the name of def animal_refresh to def update. The main loop is handled in Scene_Base, so you wouldn't need it anymore.
 

Daphoa

Member

Alright, so I fixed the suggestions you gave and reposted it (I didn't use the code tag originally because I didn't want to take up too much space) except for the inclusion of the SDK. I personally do not see the use of the inclusion SDK, but maybe you can persuade me.

Anyway, I still have a problem, and I think it is simply calling the script (yes, I am very new at this). I'm creating an event with the script "$Scene_Illusion_Animal.new" (without the quotes). What script should I use to call this script? Thanks in advance.
 

Daphoa

Member

That's great. I finally got real errors and have managed to fix it.
The animal script officially works (I'm pulling it out of this forum - I'll post it in the script analysis page once I complete the other two scripts).

Now I just have one question. Is there a way I can determine what any given enemy's sprite is? I'm 99% sure there is, I just don't know what it is.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top