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?
Battlebacks!
RPG Maker MZ SupportYou're in luck 😉
Setup regions something like this:
Then...
Use this:
[RMMV-MZ] Custom Script Anywhere by CT_Bolt
ct-bolt.itch.io
Like this:
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 ☺️
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:
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
[img]https://i.imgur.com/fUBGaEq.png[/img]
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
[img]https://i.imgur.com/fUBGaEq.png[/img]
@coyotecraft also had a good suggestion ☺️
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:
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;
};
If you use the region method I mentioned above in conjunction with this. Regions will take priority over terrain 😉
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.
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";
}
};
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?
Original thread: https://forums.rpgmakerweb.com/threads/battlebacks.147705/