Notice: fwrite(): Write of 44 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96
Kill Autoshadows
Main Menu
  • Welcome to The RPG Maker Resource Kit.

Kill Autoshadows

Started by modern algebra, January 29, 2008, 01:28:42 AM

0 Members and 1 Guest are viewing this topic.

modern algebra

Kill Autoshadows
Version: 2.0b
Author: modern algebra & Abt Plouton
Date: May 11, 2009

Version History




  • <Version 2.0b> 05.13.2009 - fixed a nasty bug that would appear whenever placing autoshadow producing tiles along the East and South edges of the map
  • <Version 2.0> 05.11.2009 - Made it more precisely target only autoshadow producing tiles, thus rectifying issues with table legs and allows for greater compatibility with any scripts that use the second layer
  • <Version 1.0> 01.28.2008 - Original Release

Description



This allows you to disable the appearance of autotiles and also to re-enable them if you want them to appear for certain maps.

Features


  • Allows you to get rid of annoying autoshadows
  • Easy to turn on and off in-game
  • precise targetting that allows for greater compatibility with scripts that make use of the second layer

Screenshots



Instructions

Place this script above Main and below Materials.

 To disable autoshadows, use this code in a call script: $game_map.autoshadows = false

 To enable them, use this code: $game_map.autoshadows = true

Script




#==============================================================================
#  Kill Autoshadows
#  Version: 2.0b
#  Author: modern algebra (rmrk.net) & Abt Plouton
#  Date: May 13, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to disable or re-enable autoshadows at any time.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below Materials.
#
#    To disable autoshadows, use this code in a call script:
#
#      $game_map.autoshadows = false
#
#    To enable them, use this code:
#
#      $game_map.autoshadows = true
#==============================================================================

#==============================================================================
# ** Game Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - setup
#    new writer instance variable - autoshadows
#    new method - autoshadows
#==============================================================================

class Game_Map
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Public Instance Variables
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 attr_writer :autoshadows
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Get Autoshadows
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def autoshadows
   return @autoshadows unless @autoshadows.nil?
   @autoshadows = false
   return false
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Setup
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias ma_remove_auto_shadows_on_setup setup
 def setup (map_id)
   ma_remove_auto_shadows_on_setup (map_id)
   # Rather than repeatedly call a method, set a local variable to have it's data
   ma_data = data
   return if autoshadows
   # For all squares on the map
   for x in 0...(ma_data.xsize - 1)
     for y in 0...(ma_data.ysize - 1)
       # If house autotile
       if ma_data[x, y, 0] >= 4352 && ma_data[x, y + 1 ,0] >= 4352 &&
            ma_data[x + 1, y + 1, 0] < 4352
         # Delete auto Shadow
         ma_data[x, y, 1] = ma_data[x,y,0]
         ma_data[x, y, 0] = 0
       end
     end
   end
 end
end


Credit




  • modern algebra
  • Abt Plouton, for original code upon which I built

Thanks

  • Zeriab, for his Table Printing script, without which I could not have updated this script
  • Dainreth, for the request
  • Anaxim, for reporting a bug in 2.0

Support



Please post here at rmrk.net for the swiftest response

Known Compatibility Issues

[spoiler=Wall Extension Incompatibility Fix]
There was a major compatibility problem that allowed you to walk on to the right hand side of any autotiled ceiling or wall. The code below ought to fix it.

Replace the Kill Autoshadows Script with the following and make sure it is below the Wall Extension Script:


#==============================================================================
#  Kill Autoshadows
#  Version: 2.0b (Wall Extension Compatibility)
#  Author: modern algebra (rmrk.net) & Abt Plouton
#             & some code borrowed from Moon Man to make the scripts compatible
#  Date: May 13, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to disable or re-enable autoshadows at any time.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below Materials.
#
#    To disable autoshadows, use this code in a call script:
#
#      $game_map.autoshadows = false
#
#    To enable them, use this code:
#
#      $game_map.autoshadows = true
#==============================================================================

#==============================================================================
# ** Game Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - setup
#    new writer instance variable - autoshadows
#    new method - autoshadows
#==============================================================================

class Game_Map
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Public Instance Variables
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 attr_writer :autoshadows
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Get Autoshadows
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def autoshadows
   return @autoshadows unless @autoshadows.nil?
   @autoshadows = false
   return false
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Setup
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias ma_remove_auto_shadows_on_setup setup
 def setup (map_id)
   ma_remove_auto_shadows_on_setup (map_id)
   # Rather than repeatedly call a method, set a local variable to have it's data
   ma_data = data
   return if autoshadows
   # For all squares on the map
   for x in 0...(ma_data.xsize - 1)
     for y in 0...(ma_data.ysize - 1)
       if ma_data[x, y, 0] >= 4352 && ma_data[x, y + 1 ,0] >= 4352 &&
            ma_data[x + 1, y + 1, 0] < 4352
         tile_id = ma_data[x, y, 0]
         if (4352...5888).include?(tile_id) or
           (6272...6656).include?(tile_id) or
           (7040...7424).include?(tile_id) or
           (7808...8192).include?(tile_id)
           dummy_tile_id = 2000 + auto_(tile_id)
         else
           dummy_tile_id = 1952 + auto_(tile_id)
         end
         ma_data[x, y, 1] = ma_data[x, y, 0]
         ma_data[x, y, 0] = dummy_tile_id
       end
     end
   end
 end
end

[/spoiler]

Otherwise, no currently known compatibility problems.

Demo



Not required. Just plug the script in and see it work.

Author's Notes



On another forum, somebody was complaining about autoshadows so I wrote a little script to get rid of them if you so wish.

Also, I should mention that the main part of the script was written (apparently) by some guy named Abt Plouton for single maps. All I did was make it globally applicable and fix a few bug issues with bush and table tiles




Kokowam

Cool. :)

Quote from: modern algebra
@Rabu: I don't know. I haven't actually looked into the way auto shadows work.
LOL

modern algebra

Hey all, apparently there was a bit of a screw up and the code that was up also removed the bush effect from grass and stuff. I've fixed that now.

joy

Love this little snippet.

I am having a problem though, it also kills the shadows/legs of tables from TileA2.

Example:
http://img.photobucket.com/albums/v648/joymason/Problem-01.png

Is there any way to fix this without re-enabling shadows?

modern algebra

THat does seem to be a big problem. I will look into it, but I am not on my computer right now, so it might be a little while before I get back to you. I will probably be able to fix it though. Anyway, I like your tileset.

Grafikal

I'm positive I've been through this database dozens of time and I haven't seen this until now ._.   

I see how this is useful though. Ever have a cliff in VX that's 5 tiles high and the shadow is 4 tiles high? (You should cause it does that anyways) But the lighting is totally off for things like that, where the shadow should only be about 2-3 tiles high, that after you remove them with this script, you can draw them in with the half shadow tile in the map editor :3

I've thought of this a few times, but never cared enough. Lol

joy

Just wondering if there was any progress on the fix.

modern algebra

No, not yet. I did look into the problem but had difficulty diagnosing the problem since Tilemap is a hidden class. I fully intend to look into the problem again and will hopefully find a fix.

SolstICE

the script might break counter tiles and bush tiles too. at least that's what happened with the original by abt plouton. something else to look into when making your fix

modern algebra

No, bush tiles are fine. Haven't checked counter tiles.

modern algebra

#10
Alright, I've been looking into tilemaps for a terrain tags script I'm writing, and so I finally decided to get off my ass and figure out what to do about this fellow. SO now it's done and tables and everything works now, I think. Enjoy!

Grafikal


modern algebra

Updated to 2.0b, as Anaxim reported a bug that would occur whenever autoshadow-producing tiles were placed on the East or South edges of a map. If you have 2.0, then you must replace it with 2.0b

modern algebra

I created another version of the script for compatibility purposes with Moon Man's Wall Tile Extension script. It can be found in the original post under Known Compatibility Issues. It will only work if Moon Man's script is already installed.

Sebastian Cool ^-^

and it was I needed!! thanks!! Algebra!! :blizj:

Moxy

First let me say, nice little script...

Works as advertised. Problems:

1. The shadow tiles to replace the removed autoshadows are passable.
2. Obviously, this leads to "holes" on the map.
3. Setting the shadow tiles to non-passable means that creating a nice map becomes a tedious exercise.
4. So, why can't I place a tile as one state, change the state and place it without over-riding the original? Am I stupid?
5. Do I need to make E-tilesets to overcome this problem?
6. Sorry for being a noob but this problem is plagueing me.

I really do like the option of taking out the autoshadow because it's ugly. HELP!

modern algebra

I don't understand your problem at all. Why does having shadow tiles as passable create holes in the map? That's not obvious at all. Whatever it means I don't see how making them non-passable changes it. Maybe a screenshot would help?

The only thing that I can think you mean is that if you place a shadow over a tile that would normally be non-passable on the A layer, then that tile becomes passable and that's bad. If that's the case, then depending on how many of them there are, you could just use an event layer for the shadow on those tiles - set the graphic as the shadow or else make the event itself non-passable.

Moxy

Yeah that's about right. Didn't even cross my mind to use an event graphic. And not what I wanted
to hear! Dang... well back to it. Place strategic shadow events as non-passable and keep the rest as
normal. Wow, that will be a lot of events. Break the map up... hmm. OK, thanks m.a. for the quick
reply. If anybody else has any handy advice - always more than one way to skin a cat!

BTW, a screen shot would be superfluous. The map is like a tiered mountain side - a series of stepped
plateaus. Some of the shadows pop up in the wrong places, which is disconcerting.

Grafikal

Mmmmmmm wow. You DO realize that there are 2 sets of shadow tiles on TileB, right? One set is passable and the other set is non-passable. Obviously use them both. Use the non-passable shadows on cliffs or over things that shouldn't be able to be walked on and use the passable shadow tiles on things that could be walked on...

Moxy

Thanks grafikal, that information is EXACTLY what I didn't realize. Sometimes my bent
obscures the most simple solutions. My bad. And for those who are too shy to
ask stupid questions - just do it. You guys are great for the newbie support! Don't
worry I have a lot more innocent questions.

Grafikal

Lol, Ok. Glad you didn't know about that, cause it seemed too dumb to ask more from this script without knowing that. Glad we could help.