Change the terrain_tag at runtime

nihilath

Villager
Member
Joined
Jul 6, 2014
Messages
21
Reaction score
2
Primarily Uses
Did you try just running the two commands in the post above?
Of course. And it didn't seem to work. I changed the tiles on the map and than run $game_map.setup_surfaces and $game_map.merge_surfaces and nothing happend :(

I am quite certain that what you are suggesting is somehow possible. I just think that I am just not able to write that code. Especially because Khas Awesome Light Effects has no code documentation or some simple inline comments (aside from setup, licensing and such). So its not really easy to really get whats going on in the script.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,268
Reaction score
1,422
First Language
English
Primarily Uses
RMXP
The terrain tag read depends on the current tile_id at the location starting at the top-layer, the one you are modifying.

I.e. the terrain tag is change automatically when you change the map data.

I bet the problem is rather in Khas' Light Effect script. He probably scripted with the assumption that the terrain tag will not change on-the-fly.

*hugs*

 - Zeriab
 

nihilath

Villager
Member
Joined
Jul 6, 2014
Messages
21
Reaction score
2
Primarily Uses
I tested it with $game_map.terrain_tag($game_player.x, $game_player.y). The terrain tag doesn't seem to change with $game_map.data. It stays on its initial tag, at least in my case :(
 

nihilath

Villager
Member
Joined
Jul 6, 2014
Messages
21
Reaction score
2
Primarily Uses
This is a screenshot of the event that is changing the game_map.data:



And here is what it looks like with Khas lights:



If that helps...
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,268
Reaction score
1,422
First Language
English
Primarily Uses
RMXP
That's strange. It worked just fine when I tested it. I did use the Get Location event command, but that just calls $game_map.terrain_tag(x, y) so I don't see how that should be any different.

Can you create a test project for me?

On a different note I suggest you make sure the map is not reloaded on saves when you have created any modifications. You can check my Map copy script for a solution to that problem.

*hugs*

 - Zeriab
 

nihilath

Villager
Member
Joined
Jul 6, 2014
Messages
21
Reaction score
2
Primarily Uses
It works in the test project as you said (without Khas script)..... problem must be somewhere else... thanks for the suggestion.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,268
Reaction score
1,422
First Language
English
Primarily Uses
RMXP
Ok, making it work was actually quite fun ^^

Whether a specific tile is a roof, wall or block depends on the terrain tag. The terrain tag is refer from the top layer first (x,y,2) then (x,y,1) and down to (x,y,0) until it finds a non-zero terrain tag. You put a tile on layer 1 that had terrain tag 0, where layer 0 had terrain tag 7. So fetching 7 is to be expected.

The actual tile ids fetched are dependent on layer 0 so the walls you put on layer 1 is ignore then. Moreover autotiles have a significant impact. I.e. you may have to change the tiles surrounding the tiles you are changing.

Here is a link to the fixed demo: https://www.mediafire.com/?c1wckdq4q7q1xq1

I have added two methods to Game_Map which should help you. Call $game_map.map_data_change when the lights should be updated after changes to the game map data.

The $game_map.change_shadow_data(x, y, new_value) is used to simplify removing shadows from the game map while preserving any Region ID there might be specified.

I have been very specific with the autotile ids so there is work left generalizing those, but I hope this is enough to help you progress further on your own.

*hugs*

 - Zeriab
 

nihilath

Villager
Member
Joined
Jul 6, 2014
Messages
21
Reaction score
2
Primarily Uses

nihilath

Villager
Member
Joined
Jul 6, 2014
Messages
21
Reaction score
2
Primarily Uses
Works like a charm! Thanks again for hacking that out!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
nihilath, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


Just edit your last post instead.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,268
Reaction score
1,422
First Language
English
Primarily Uses
RMXP
Good to hear that it works for you ^_^

Feel free to use my copy script as much as you want. My suggestion was aimed more specifically at my solution to preserving the map when loading a save.

This is the interesting part from that point of view:

### Change reload mechanism#class Game_Map  attr_accessor :data_modificationsendmodule DataManager  class << self    unless self.method_defined?:)zeriab_copy_reload_map_if_updated)      alias_method:)zeriab_copy_reload_map_if_updated, :reload_map_if_updated)    end     ##    # Reload must not occur when we have made any runtime data changes.    # Otherwise we may throw our changes away    #    def reload_map_if_updated      if !$game_map.data_modifications        # No copy changes so we are save to use the normal reload code        zeriab_copy_reload_map_if_updated      end    end  endend
With that you can simply use the following command when you have changed the map data:

# This map is no longer safe to reload when loading$game_map.data_modifications = true
Now when loading the game the changes should be preserved. Otherwise if you have done any changes in the editor since then the map is likely to be reset clearing what changes you have done.

Note: Leaving the map and coming back still clears everything.

*hugs*

 - Zeriab
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top