The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on January 29, 2008, 01:28:42 AM

Title: Kill Autoshadows
Post by: modern algebra on January 29, 2008, 01:28:42 AM
Kill Autoshadows
Version: 2.0b
Author: modern algebra & Abt Plouton
Date: May 11, 2009

Version History



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


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg22.imageshack.us%2Fimg22%2F9706%2Fkillautoshadows.png&hash=0b75f3134b0fc21fbc8346897c7f64db97caffd2)

Instructions

Place this script above Main and below Materials.

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

  To enable them, use this code:
Code: [Select]
$game_map.autoshadows = true

Script


Code: [Select]
#==============================================================================
#  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



Thanks


Support


Please post here at rmrk.net for the swiftest response

Known Compatibility Issues

Spoiler for 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:

Code: [Select]
#==============================================================================
#  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

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 (http://www.rpgmakervx.net/Shadows-t379.html) 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


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: [RMVX] No Autoshadows
Post by: Kokowam on February 05, 2008, 01:31:30 AM
Cool. :)

Quote from: modern algebra
@Rabu: I don't know. I haven't actually looked into the way auto shadows work.
LOL
Title: Re: [RMVX] No Autoshadows
Post by: modern algebra on March 23, 2008, 05:47:04 PM
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.
Title: Re: Kill Autoshadows
Post by: joy on December 17, 2008, 03:22:21 PM
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 (http://img.photobucket.com/albums/v648/joymason/Problem-01.png)

Is there any way to fix this without re-enabling shadows?
Title: Re: Kill Autoshadows
Post by: modern algebra on December 17, 2008, 03:28:46 PM
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.
Title: Re: Kill Autoshadows
Post by: Grafikal on December 17, 2008, 04:56:38 PM
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
Title: Re: Kill Autoshadows
Post by: joy on January 03, 2009, 09:20:31 PM
Just wondering if there was any progress on the fix.
Title: Re: Kill Autoshadows
Post by: modern algebra on January 03, 2009, 10:22:13 PM
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.
Title: Re: Kill Autoshadows
Post by: SolstICE on January 13, 2009, 05:02:35 AM
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
Title: Re: Kill Autoshadows
Post by: modern algebra on January 13, 2009, 05:13:29 AM
No, bush tiles are fine. Haven't checked counter tiles.
Title: Re: Kill Autoshadows
Post by: modern algebra on May 12, 2009, 01:03:05 AM
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!
Title: Re: Kill Autoshadows
Post by: Grafikal on May 12, 2009, 01:15:20 AM
:lol: awesommeeee
Title: Re: Kill Autoshadows
Post by: modern algebra on May 13, 2009, 05:12:24 PM
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
Title: Re: Kill Autoshadows
Post by: modern algebra on July 27, 2009, 09:40:06 PM
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.
Title: Re: Kill Autoshadows
Post by: Sebastian Cool ^-^ on November 11, 2009, 02:33:02 PM
and it was I needed!! thanks!! Algebra!! :blizj:
Title: Re: Kill Autoshadows
Post by: Moxy on May 27, 2010, 10:19:10 PM
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!
Title: Re: Kill Autoshadows
Post by: modern algebra on May 27, 2010, 11:16:59 PM
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.
Title: Re: Kill Autoshadows
Post by: Moxy on May 28, 2010, 03:40:55 AM
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.
Title: Re: Kill Autoshadows
Post by: Grafikal on May 28, 2010, 03:44:16 AM
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...
Title: Re: Kill Autoshadows
Post by: Moxy on May 28, 2010, 01:52:35 PM
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.
Title: Re: Kill Autoshadows
Post by: Grafikal on May 28, 2010, 03:11:48 PM
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.