Cecil199

Villager
Member
Joined
Mar 18, 2020
Messages
28
Reaction score
16
First Language
English
Primarily Uses
RMMV
Hello everyone continuing to learn more and more with this program and have a quick question. My world map is almost finished but how do I change the battleback when my character enters lets say a forested area on the world map? I have monsters enabled on the world map with grassy area labeled but what if there is a small desert on my world map and a battle is started over it any easy way to implement a fix on this?
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,174
Reaction score
724
First Language
Javascript
Primarily Uses
RMMZ
Hello everyone continuing to learn more and more with this program and have a quick question. My world map is almost finished but how do I change the battleback when my character enters lets say a forested area on the world map? I have monsters enabled on the world map with grassy area labeled but what if there is a small desert on my world map and a battle is started over it any easy way to implement a fix on this?
You're in luck ;)

Setup regions something like this:
1652852817427.png

Then...

Use this:

Like this:
1652852665796.png
Class: Game_Player
Property of Function: prototype
Function: update
Post Script:
JavaScript:
var currentRegion = $gameMap.regionId(this.x, this.y);
if (this._lastRegion !== currentRegion){
  this._lastRegion = currentRegion;
  if (currentRegion === 1){
    $gameMap.changeBattleback('GrassMaze', 'GrassMaze');
  }else if (currentRegion === 2){
    $gameMap.changeBattleback('Desert', 'Desert');
  }else{
    $gameMap.changeBattleback($dataMap.battleback1Name, $dataMap.battleback2Name);
  };
};

Of course you can change or add any code to that you want to add more regions or get the desired effect :cutesmile:

I will probably also make a specific plugin for Region Changes to execute code when changing regions though soon.

..maybe idk yet lol

The above will definitely work as you need it to though.

Looks like this in-game:
 
Last edited:

coyotecraft

Mythographer
Veteran
Joined
Mar 13, 2012
Messages
300
Reaction score
172
First Language
English
Primarily Uses
N/A
If the Tileset mode is set to "World Type" then the battle backgrounds are picked by cases defined in rmmz_sprites.js

Open this in a text editor (I use Notepad++) to make changes to it.
You just need to add a case for autotile number and return the "filename" like this

fUBGaEq.png
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,174
Reaction score
724
First Language
Javascript
Primarily Uses
RMMZ
If the Tileset mode is set to "World Type" then the battle backgrounds are picked by cases defined in rmmz_sprites.js

Open this in a text editor (I use Notepad++) to make changes to it.
You just need to add a case for autotile number and return the "filename" like this

fUBGaEq.png
@coyotecraft also had a good suggestion :cutesmile:

Expanding on what was mentioned by @coyotecraft
I generally advise against editing the core scripts directly, for a few reasons...
..one being if they get an update it will overwrite what you change

...but you can also do this with my CustomScriptAnywhere plugin:

Setup is like this:
1652854922655.png
1652854964163.png
Class: Sprite_Battleback
Property of Function: prototype
Function: terrainBattleback1Name
Post Script:
JavaScript:
switch (type) {
  case 20:  r = "GrassMaze"; break;
  case 29:  r = "Desert";    break;
};


Class: Sprite_Battleback
Property of Function: prototype
Function: terrainBattleback2Name
Post Script:
JavaScript:
switch (type) {
  case 20:  r = "GrassMaze"; break;
  case 29:  r = "Desert";    break;
};
Of course you can edit to anyway you desire :cutesmile:
If you use the region method I mentioned above in conjunction with this. Regions will take priority over terrain ;)
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,663
Reaction score
2,754
First Language
EN
Primarily Uses
RMMZ
Personally, I'd go with the World Type tileset option like @coyotecraft mentions. If necessary you can just substitute/rename battlebacks to conform to the existing standard, no plugin needed.

Otherwise I'd consider using a plugin for an override instead of a direct core script edit, since like @ct_bolt says, the latter is harder to track and will be removed if/when you update your project's core script version.
This just reapplies the defaults, you'll need to edit the names to fit your tileset/battlebacks.
JavaScript:
/*:
 * @target MZ
 * @plugindesc Overrides battle back names for World Type tilesets.
 * @help Terms of use: free to use and/or modify for any project.
 */
Sprite_Battleback.prototype.terrainBattleback1Name = function(type) {
    switch (type) {
        case 24:
        case 25:
            return "Wasteland";
        case 26:
        case 27:
            return "DirtField";
        case 32:
        case 33:
            return "Desert";
        case 34:
            return "Lava1";
        case 35:
            return "Lava2";
        case 40:
        case 41:
            return "Snowfield";
        case 42:
            return "Clouds";
        case 4:
        case 5:
            return "PoisonSwamp";
        default:
            return null;
    }
};

Sprite_Battleback.prototype.terrainBattleback2Name = function(type) {
    switch (type) {
        case 20:
        case 21:
            return "Forest";
        case 22:
        case 30:
        case 38:
            return "Cliff";
        case 24:
        case 25:
        case 26:
        case 27:
            return "Wasteland";
        case 32:
        case 33:
            return "Desert";
        case 34:
        case 35:
            return "Lava";
        case 40:
        case 41:
            return "Snowfield";
        case 42:
            return "Clouds";
        case 4:
        case 5:
            return "PoisonSwamp";
    }
};
 

Cecil199

Villager
Member
Joined
Mar 18, 2020
Messages
28
Reaction score
16
First Language
English
Primarily Uses
RMMV
You're in luck ;)

Setup regions something like this:

Then...

Use this:

Like this:
View attachment 226605
Class: Game_Player
Property of Function: prototype
Function: update
Post Script:
JavaScript:
var currentRegion = $gameMap.regionId(this.x, this.y);
if (this._lastRegion !== currentRegion){
  this._lastRegion = currentRegion;
  if (currentRegion === 1){
    $gameMap.changeBattleback('GrassMaze', 'GrassMaze');
  }else if (currentRegion === 2){
    $gameMap.changeBattleback('Desert', 'Desert');
  }else{
    $gameMap.changeBattleback($dataMap.battleback1Name, $dataMap.battleback2Name);
  };
};

Of course you can change or add any code to that you want to add more regions or get the desired effect :cutesmile:

I will probably also make a specific plugin for Region Changes to execute code when changing regions though soon.

..maybe idk yet lol

The above will definitely work as you need it to though.

Looks like this in-game:
Hey I downloaded the plugin and have done what you said but its not changing do I need to put anything into Pre Script. Other than that I have followed everything.
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
1,174
Reaction score
724
First Language
Javascript
Primarily Uses
RMMZ
Hey I downloaded the plugin and have done what you said but its not changing do I need to put anything into Pre Script. Other than that I have followed everything.
Are you doing this by region id or by the world type tileset map way?

Can I see a screenshot of your parameters setup?
 

Latest Threads

Latest Posts

Latest Profile Posts

Let there be light!
title2 copy.png

Just a little mood-piece for the game I'm working on with @spillycat :)
Logo of the new game I‘ve been working on with @Finnuval ! F05668FB-8AE1-4214-948F-0F58397FF282.jpeg
"What!? 2000!? There's no way that can be right!""It's over 2900!"
New musics has been made. Praise be!

Forum statistics

Threads
123,059
Messages
1,153,679
Members
161,395
Latest member
Almagesta
Top