#==============================================================================# Fog of War# Version: 1.0# Author: modern algebra (rmrk.net) (conversion: Nelderson) (rpgmakerweb.com)# Date: July 6, 2010#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Description:## This script allows you to create "fog of war" on specified maps. This is a# concept familiar to RTS games as it is used to hide the movement of enemy # units when they are not in range of your own units. This script brings that# concept to RMVX, and allows for two layers: a permanent one that is cleared# forever once a unit explores the area, and a temporary one that is clear # only for as long as it is within range of a unit. You can use either layer# or both for any given map.## This script also allows for other events (not just the player) to have # vision, and will hide other events not within direct vision of a unit # unless you specify that event to show anyway.#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Instructions:## Paste this script above Main and below other custom scripts in the Script# Editor.## You can specify a map to use Fog of War in one of three ways:# 1) Add it to the FOW_MAPS hash at line 154# Simply add a line between the { and } brackets like this:# map_id => mode,# map_id : the ID of the map you are setting up# mode : the type of fow you want.# 0 => use both the permanent and temporary layers# 1 => use only the permanent layer# 2 => use only the temporary layer# 2) Use the following code in a script command:# show_fow (mode, map_id)# mode : same as line 31. If excluded, defaults to system value# map_id : the map ID. If excluded, defaults to the current map.# 3) Use this code in a comment on the first line of an event page:# \show_fow[mode]# mode : same as line 31. If excluded, defaults to system value## Any one of those ways will set the fog of war up; you don't need to use # all three. I included so many options just for greater utility and since # some ways may be easier depending on the type of game you're making.## You can hide a fog of war in one of two ways:# 1) Use the following code in a script command:# hide_fow (map_id)# map id : the Map ID. If excluded, defaults to current map.# 2) Use this code in a comment on the first line of an event page:# \hide_fow## You can clear the fog of war entirely using this code in a script command:# clear_fow (map_id, xrange, yrange)# map_id : the ID of the map. If excluded, it defaults to current map# xrange : The x range (a... to clear. If excluded, it will clear the# whole width of the map# yrange : the y range (c...d) to clear. If excluded, it will clear the# whole height of the map# Note that unlike hide_fog, this will completely clear the permanent fog # layer. So, if you were to turn the fog back on, there would be no # permanent fog layer. If you wanted to retain what was not yet revealed, # then you should use hide_fog instead.## You can reset the fog of war by using this code in a script command:# reset_fow (map_id, xrange, yrange)# map_id : the ID of the map. If excluded, it defaults to current map# xrange : The x range (a... to clear. If excluded, it will reset the# whole width of the map# yrange : the y range (c...d) to clear. If excluded, it will reset the# whole height of the map# This will shroud the entire map, effectively meaning that any progress in# revealing the map before will be entirely erased.## You can give an event vision in either of two ways:# 1) Use this code in a comment on the first line of an event page:# \fow_vision[radius, circular?]# radius : the range within sight. i.e. # squares in each direction# If excluded, defaults to value of FOW_DEFAULT_SIGHT at line 152# circular? : either true or false. If true, the vision range will be# circular. If false, it will be a diamond. If excluded, defaults to # the value of FOW_CIRCLE_SIGHT at line 153# 2) Use the following code in a script command:# set_unit_vision (event_id, radius, circular?)# event_id : ID of the event you want to change. If 0, sets the # vision of the current event; if -1, sets the player vision.# radius : same as at line 71# circular? : same as at line 73# Note that unit vision will reset any time it advances to the next page,# so comments are by far the better way to go.## You can set some events to be visible even when covered by fog of war. # This is particularly useful if you are using events as an extra layer of # mapping. To do so, place this comment in the first line of a comment on # an event page.# \ignore_fow## You can change the autotiles used for fog of war with the code in a script# command:# change_fow_autotile (layer, filename)# layer : either :permanent or :temporary, and it changes that layer# filename : the new filename# Note that it will not change it for the current map until you leave and# come back, so if doing this, it should be done in the map before you need# it.## Lastly, you can check if a square is visible by using the following code# in a script call of a conditional branch:# square_visible? (x, y)# x, y : coordinates to check.## Note that whereever you do something by comment, it will only apply for # that page of the event and only when that page is first created.## See the Configurable Region at line 122 for some default configuration# options that you can set. There you can set which autotiles you want to use# to create the fog, as well as the opacity of each layer. In addition, you # can set up the default values for vision radius and circle function, as # well as set up which maps have fog of war.#==============================================================================# Configurable Region#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# FOW_PERMANENT_AUTOTILE - the name of the autotile file you want to use for# the permanent layer of the fog of war. The file must be saved in System.# FOW_PERMANENT_OPACITY - the opacity of the permanent layer of the fog of war# FOW_TEMPORARY_AUTOTILE - the name of the autotile file you want to use for# the temporary layer of the fog of war. The file must be saved in System.# FOW_TEMPORARY_OPACITY - the opacity of the temporary layer of the fog of war# FOW_DEFAULT_SIGHT - the default radius of vision for the player. It is also# the default if you set an event to have vision but do not specify radius.# FOW_CIRCLE_SIGHT - the default boolean value for whether player vision # should be circular. true => circular; false => diamond. It is also the # default value when setting an event to have vision if left unspecified# FOW_MAPS - one of the ways of specifying a map to have fog of war. It will# apply only once the very first time the player enters a map, and other # ways of setting fog of war will take priority. To set a map up, just add# a new line between the curly brackets that looks like this:# map_id => mode,# map_id : the ID of the map you are setting up# mode : the type of fow you want.# 0 => use both the permanent and temporary layers# 1 => use only the permanent layer# 2 => use only the temporary layer# Don't neglect the comma; it's important.#==============================================================================FOW_PERMANENT_AUTOTILE = "FogOfWar2"FOW_PERMANENT_OPACITY = 255FOW_TEMPORARY_AUTOTILE = "FogOfWar"FOW_TEMPORARY_OPACITY = 160FOW_DEFAULT_SIGHT = 3FOW_CIRCLE_SIGHT = trueFOW_MAPS = { 38 => -1, 53 => -1#54 => 0, 56 => 0, 57 => 0, 58 => 0, 59 => 0, 60 => 0}FOW_MAPS.default = 0#==============================================================================# *** Cache#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Summary of Changes:# aliased method - self.system#==============================================================================module Cache class << self #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Self.system #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias ma_fow_systm_2fk9 system def system (filename, *args) if filename == "FOW Autotile H78J" begin ma_fow_systm_2fk9(filename, *args) rescue @cache[filename] = create_default_autotile end else ma_fow_systm_2fk9(filename, *args) end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Create Default Autotile #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def create_default_autotile autotile = Bitmap.new(64, 96) # Create a Default FOW Autotile if the FOW autotile specified doesn't exist default_autotile = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 128, 128, 128, 128, 128, 64, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 128, 128, 192, 192, 192, 192, 192, 128, 128, 128, 128, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 64, 128, 128, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 64, 128, 128, 128, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 128, 128, 128, 192, 255, 255, 255, 255, 255, 255, 255, 192, 192, 192, 128, 128, 128, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 64, 64, 64, 128, 128, 128, 128, 128, 192, 192, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 128, 128, 128, 128, 128, 192, 192, 192, 128, 128, 128, 64, 64, 64, 64, 64, 64, 64, 64, 128, 128, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 64, 128, 128, 128, 192, 192, 192, 192, 192, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 128, 128, 192, 192, 192, 192, 192, 255, 255, 255, 255, 192, 192, 128, 128, 128, 128, 128, 128, 128, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 64, 128, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 64, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 128, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 128, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 128, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 128, 64, 64, 0, 0, 0, 0, 0, 0], [0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 128, 64, 64, 0, 0, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 128, 64, 64, 0, 0, 0, 0], [0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 128, 64, 64, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 128, 64, 64, 0, 0], [0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 64, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 64, 0, 0], [0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0], [0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 64, 64, 0, 0], [0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 64, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0], [0, 64, 64, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0], [0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 64, 64, 0, 0, 0], [0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0], [0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 64, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0], [64, 64, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0], [64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0], [64, 128, 192, 255, 255, 192, 192, 192, 192, 192, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0], [64, 128, 192, 192, 192, 128, 128, 128, 128, 128, 128, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0], [64, 128, 192, 128, 128, 64, 64, 64, 64, 64, 64, 64, 128, 128, 192, 192, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 64, 64, 0, 0, 0], [64, 128, 128, 64, 64, 64, 0, 0, 0, 0, 0, 64, 64, 64, 128, 128, 128, 128, 192, 192, 192, 192, 255, 255, 255, 255, 255, 255, 192, 192, 128, 64, 64, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0], [0, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 128, 128, 128, 128, 192, 192, 192, 192, 192, 192, 192, 128, 64, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 128, 128, 128, 128, 128, 128, 128, 128, 64, 0, 0, 64, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 64, 64, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 64, 64, 64, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0], [0, 64, 128, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 64, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0], [64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 128, 128, 64, 0, 0, 64, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 64, 64, 0], [128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 64, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0], [128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 128, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 64, 64], [192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 0, 0, 0, 64, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 64, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 64, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 128, 64, 64, 0], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 64, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 64, 64, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 44, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [255, 255, 192, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 6, 0, 0, 64, 128, 192, 192, 192, 192, 192, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [192, 192, 128, 128, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 3, 0, 0, 64, 64, 128, 128, 128, 128, 128, 128, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 128, 128, 128, 128, 128, 128, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [192, 128, 64, 64, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 192, 3, 1, 0, 2, 64, 64, 64, 64, 64, 64, 64, 64, 128, 128, 192, 192, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 128, 128, 64, 64, 64, 64, 64, 64, 64, 64, 128, 128, 128, 192, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64], [128, 64, 0, 1, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 128, 2, 1, 0, 1, 2, 0, 0, 0, 0, 0, 0, 64, 64, 64, 128, 128, 128, 128, 128, 192, 192, 192, 255, 255, 255, 255, 255, 255, 255, 192, 128, 128, 128, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 128, 128, 128, 192, 192, 192, 192, 255, 255, 255, 255, 255, 255, 192, 192, 128, 64], [64, 0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 192, 128, 64, 64, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 128, 128, 128, 128, 192, 192, 192, 192, 192, 128, 128, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 128, 128, 128, 128, 192, 192, 192, 192, 192, 192, 192, 128, 64, 0], [0, 0, 0, 64, 128, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 128, 128, 128, 128, 128, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 128, 128, 128, 128, 128, 128, 128, 128, 64, 0], [0, 0, 64, 128, 192, 192, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 64, 64, 64, 0, 0] ] color = Color.new(0, 0, 0) for i in 0...64 for j in 0...96 color.alpha = default_autotile[i][j] autotile.set_pixel(i, j, color) end end return autotile end endend#==============================================================================# ** Game_System#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Summary of Changes:# new public variables - fow_perm_autotile; fow_temp_autotile, fow_data# new methods - clear_fog, reset_fog#============================================================================== class Game_System #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_writer :fow_perm_autotile attr_writer :fow_temp_autotile #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Lazy Instantiation of the new variables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def fow_perm_autotile @fow_perm_autotile = FOW_PERMANENT_AUTOTILE if !@fow_perm_autotile return @fow_perm_autotile end def fow_temp_autotile @fow_temp_autotile = FOW_TEMPORARY_AUTOTILE if !@fow_temp_autotile return @fow_temp_autotile end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Fog of War Data #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def fow_data (map_id = $game_map.map_id) @fow_data = {} if !@fow_data fow_reset_data (map_id) if !@fow_data[map_id] return @fow_data[map_id] end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Reset Fow Data #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def fow_reset_data(map_id) map = load_data(sprintf("Data/Map%03d.rvdata2", map_id)) @fow_data[map_id] = Table.new(map.width, map.height, 3) paint_fog(map_id, 0, 2816) paint_fog(map_id, 1, 2864) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Fow Active #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def fow_active (map_id = $game_map.map_id) @fow_active = {} if !@fow_active if !@fow_active[map_id] @fow_active[map_id] = FOW_MAPS[map_id] == -1 ? [false, 0] : [true, FOW_MAPS[map_id]] end return @fow_active[map_id] end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Fow Set Active #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def fow_set_active(index, value, map_id = $game_map.map_id) @fow_active = {} if !@fow_active @fow_active[map_id] = fow_active(map_id) @fow_active[map_id][index] = value end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Paint Fog #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def paint_fog(map_id, layer, value, xrange = -1..0, yrange = -1..0) data = fow_data(map_id) xrange = 0...data.xsize if xrange.first < 0 yrange = 0...data.ysize if yrange.first < 0 for x in xrange for y in yrange data[x, y, layer] = value end end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Square Visible? # x, y : coordinates of event #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def square_visible?(x, y) return true unless $game_map.fow_active return fow_data[x, y, 0] == 0 && fow_data[x, y, 1] == 0 endend#==============================================================================# ** Game_Temp#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Summary of Changes:# new instance variables - fow_temp_updatables, fow_perm_updatables#==============================================================================class Game_Temp #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_accessor :fow_temp_updatables attr_accessor :fow_perm_updatables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias malgbr_fow_iniz_4tj2 initialize def initialize(*args) malgbr_fow_iniz_4tj2(*args) @fow_temp_updatables = [] @fow_perm_updatables = [] endend#==============================================================================# ** Game_Map#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Summary of Changes:# new instance variable - fow_active, fow_permanent, fow_temporary# aliased method - setup#==============================================================================class Game_Map #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_accessor :fow_active attr_accessor :fow_permanent attr_accessor :fow_temporary #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Setup #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias malg_fwar_setup_6dx9 setup def setup(*args) malg_fwar_setup_6dx9(*args) # Run Original Method @fow_active = $game_system.fow_active[0] @fow_permanent = $game_system.fow_active[1] != 2 @fow_temporary = $game_system.fow_active[1] != 1 $game_system.paint_fog(map_id, 0, 0) unless @fow_temporary $game_system.paint_fog(map_id, 1, 0) unless @fow_permanent endend#==============================================================================# ** Game_Character#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Summary of Changes:# aliased method - update, initialize# new methods - create_vision_field, update_fow#==============================================================================class Game_Character #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Update #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias mornal_fogwr_udt_3pk9 update def update(*args) mornal_fogwr_udt_3pk9(*args) # Run Original Method update_fow if @vision_field && $game_map.fow_active end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Update Fog of War #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def update_fow if @fow_origin != [@x, @y] diff_x = @x - @fow_origin[0] diff_y = @y - @fow_origin[1] @fow_origin = [@x, @y] new_field = [] @vision_field.each{ |x, y| new_field.push ([x + diff_x, y + diff_y]) } $game_temp.fow_temp_updatables |= @vision_field - new_field @vision_field.clear @vision_field = new_field end $game_temp.fow_perm_updatables |= @vision_field end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Create Vision Field #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def create_vision_field(radius = FOW_DEFAULT_SIGHT, circle = FOW_CIRCLE_SIGHT) delete_vision_field @fow_origin = [@x, @y] @vision_field = [] return [] if radius == 0 radius = radius.abs if radius < 0 if circle for i in -1*radius..radius for j in -1*radius..radius @vision_field.push([@x + i, @y + j]) if (i**2 + j**2) <= radius**2 + 1 end end else @vision_field.push([@x, @y + radius], [@x, @y - radius], [@x + radius, @y], [@x - radius, @y]) for i in -1*(radius - 1)..(radius - 1) for j in -1*(radius - 1)..(radius - 1) @vision_field.push([@x + i, @y + j]) if (i.abs + j.abs) <= radius end end end $game_temp.fow_perm_updatables |= @vision_field unless !$game_map.fow_active return @vision_field end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Delete Vision Field #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def delete_vision_field return unless @vision_field $game_temp.fow_temp_updatables |= @vision_field @vision_field.clear @vision_field = nil endend#==============================================================================# ** Game_Event#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Summary of Changes:# aliased methods - setup, transparent#==============================================================================class Game_Event #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Setup #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #alias modernalg_fow_setup_2fg8 setup alias modernalg_fow_setup_2fg8 initialize def initialize(map_id, event) modernalg_fow_setup_2fg8(map_id, event) if @page == nil @ignore_fow = false else # Get comment i = 0 comment = "" while [108, 408].include?(@page.list[i].code) comment += @page.list[i].parameters[0] i += 1 end @ignore_fow = !comment[/\\IGNORE_FOW/i].nil? if comment[/\\FOW_VISION\[(\d*),?\s*(\w*)\]/i] != nil r = $1.empty? ? FOW_DEFAULT_SIGHT : $1.to_i c = $2.empty? ? FOW_CIRCLE_SIGHT : $2.downcase == "true" create_vision_field(r, c) elsif comment[/\\FOW_VISION/i] != nil create_vision_field else delete_vision_field end if comment[/SHOW_FOW\[(\d+)\]/i] != nil $game_map.interpreter.show_fow($game_map.map_id, $1.to_i) elsif comment[/SHOW_FOW/i] != nil $game_map.interpreter.show_fow elsif comment[/HIDE_FOW/i] != nil $game_map.interpreter.hide_fow end end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Transparent #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias malg_fow_trnsp_hider_6yh3 transparent def transparent(*args) return true if !@ignore_fow && !$game_system.square_visible?(@x, @y) return malg_fow_trnsp_hider_6yh3(*args) endend#==============================================================================# ** Game_Player#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Summary of Changes:# aliased method - initialize#==============================================================================class Game_Player #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modrnl_fogw_initz_6iu8 initialize def initialize(*args) modrnl_fogw_initz_6iu8(*args) # Run Original Method x, y = @x, @y @x, @y = -100, -100 create_vision_field @x, y = x, y endend#==============================================================================# ** Game_Interpreter#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Summary of Changes:# new methods - show_fow, hide_fow, clear_fow, reset_fow, set_event_vision,# delete_event_vision#==============================================================================class Game_Interpreter #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Show Fog of War #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def show_fow(mode = -1, map_id = $game_map.map_id) $game_system.fow_set_active(0, true, map_id) $game_system.fow_set_active(1, mode, map_id) if mode != -1 $game_map.fow_active = true $game_map.fow_permanent = $game_system.fow_active[1] != 2 $game_map.fow_temporary = $game_system.fow_active[1] != 1 $game_system.paint_fog(map_id, 0, 0) unless $game_map.fow_temporary $game_system.paint_fog(map_id, 1, 0) unless $game_map.fow_permanent end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Hide Fog of War #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def hide_fow(map_id = $game_map.map_id) $game_system.fow_set_active(0, false, map_id) $game_map.fow_active = false end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Clear Fog of War #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def clear_fow(map_id = $game_map.map_id, xrange = -1..0, yrange = -1..0) $game_system.fow_set_active(1, 1, map_id) $game_map.fow_temporary = false $game_system.paint_fog(map_id, 0, 0, xrange, yrange) $game_system.paint_fog(map_id, 1, 0, xrange, yrange) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Reset Fog of War #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def reset_fow(map_id = $game_map.map_id, xrange = -1..0, yrange = -1..0) $game_system.paint_fog(map_id, 0, 2816, xrange, yrange) $game_system.paint_fog(map_id, 1, 2864, xrange, yrange) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Set Charact Vision #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def set_unit_vision(event_id, r = FOW_DEFAULT_SIGHT, c = FOW_CIRCLE_SIGHT) event_id = @event_id if event_id == 0 character = event_id < 0 ? $game_player : $game_map.events[event_id] return if character.nil? character.create_vision_field(r, c) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Delete Event Vision #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def delete_unit_vision(event_id) return if $game_map.events[event_id].nil? $game_map.events[event_id].delete_vision_field end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Square Visible? #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def square_visible?(x, y) return $game_system.square_visible?(x, y) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Change FOW Autotile #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def change_fow_autotile(layer, filename) case layer when :permanent then $game_system.fow_perm_autotile = filename when :temporary then $game_system.fow_temp_autotile = filename end endend#==============================================================================# ** Tilemap FogofWar#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# This tilemap shows a fog layer for the fog of war#==============================================================================class Tilemap_FogofWar < Tilemap #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization # permanent : the type of layer this is # autotile : the name of the autotile to use # viewport : the viewport to use #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def initialize(viewport = nil) super(viewport) begin perm_autotile = Cache.system($game_system.fow_perm_autotile) rescue perm_autotile = Cache.system("FOW Autotile H78J") end begin temp_autotile = Cache.system($game_system.fow_temp_autotile) rescue temp_autotile = Cache.system("FOW Autotile H78J") end self.map_data = $game_system.fow_data self.bitmaps[0] = Bitmap.new(512, 384) self.bitmaps[1] = Bitmap.new(512, 384) self.bitmaps[1].blt(0, 0, temp_autotile, temp_autotile.rect, FOW_TEMPORARY_OPACITY) self.bitmaps[1].blt(64, 0, perm_autotile, perm_autotile.rect, FOW_PERMANENT_OPACITY) self.bitmaps[2] = Bitmap.new(512, 256) self.bitmaps[3] = Bitmap.new(512, 480) self.bitmaps[4] = Bitmap.new(256, 512) for i in 5...9 do self.bitmaps[i] = Bitmap.new(512, 512) end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Get FOW Tilemap ID # x, y : coordinates to check # layer : the layer of the tilemap, permanent or temporary #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def fow_tilemap_id(x, y, layer = 0) data = self.map_data return 0 if x < 0 || y < 0 || data[x, y, layer] == 0 base = layer == 0 ? 2816 : 2864 count = 0 # Check Adjacent squares first count += 1 if data[x - 1, y, layer] == 0 count += 2 if data[x, y - 1, layer] == 0 count += 4 if data[x + 1, y, layer] == 0 count += 8 if data[x, y + 1, layer] == 0 id = case count when 0 then fow_check_corners(x, y, layer) when 1 then 16 + ((fow_check_corners(x, y, layer, [2, 4])) / 2) when 2 then 20 + ((fow_check_corners(x, y, layer, [4, 8])) / 4) when 3 then 34 + ((fow_check_corners(x, y, layer, [4])) / 4) when 4 then 24 + ([0,8,1,9].index(fow_check_corners(x, y, layer, [1, 8]))) when 5 then 32 when 6 then 36 + ((fow_check_corners(x, y, layer, [8])) / 8) when 7 then 42 when 8 then 28 + fow_check_corners(x, y, layer, [1, 2]) when 9 then 40 + ((fow_check_corners(x, y, layer, [2])) / 2) when 10 then 33 when 11 then 43 when 12 then 38 + fow_check_corners(x, y, layer, [1]) else 31 + count end return base + id end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Check Corners # x, y : coordinates to check # corners : the corners to check and account for #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def fow_check_corners(x, y, layer, corners = [1, 2, 4, 8]) count = 0 data = self.map_data count += 1 if corners.include?(1) && data[x - 1, y - 1, layer] == 0 count += 2 if corners.include?(2) && data[x + 1, y - 1, layer] == 0 count += 4 if corners.include?(4) && data[x + 1, y + 1, layer] == 0 count += 8 if corners.include?(8) && data[x - 1, y + 1, layer] == 0 return count end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Frame Update #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def update data = self.map_data # $game_temp.fow_perm_updatables = squares currently in vision # $game_temp.fow_temp_updatables = squares that are no longer in vision perm_update_squares = [] temp_update_squares = [] if $game_map.fow_temporary ($game_temp.fow_temp_updatables - $game_temp.fow_perm_updatables).each{ |x, y| data[x, y, 0] = 2816 for i in ([x - 1, 0].max)..([x + 1, data.xsize - 1].min) for j in ([y - 1, 0].max)..([y + 1, data.ysize - 1].min) temp_update_squares |= [[i, j]] end end } $game_temp.fow_perm_updatables.each{ |x, y| if data[x, y, 0] != 0 data[x, y, 0] = 0 for i in ([x - 1, 0].max)..([x + 1, data.xsize - 1].min) for j in ([y - 1, 0].max)..([y + 1, data.ysize - 1].min) temp_update_squares |= [[i, j]] end end end } end if $game_map.fow_permanent $game_temp.fow_perm_updatables.each{ |x, y| if data[x, y, 1] != 0 data[x, y, 1] = 0 for i in ([x - 1, 0].max)..([x + 1, data.xsize - 1].min) for j in ([y - 1, 0].max)..([y + 1, data.ysize - 1].min) perm_update_squares |= [[i, j]] end end end } end temp_update_squares.each{ |x, y| data[x, y, 0] = fow_tilemap_id(x, y, 0) } perm_update_squares.each{ |x, y| data[x, y, 1] = fow_tilemap_id(x, y, 1) } $game_temp.fow_perm_updatables.clear $game_temp.fow_temp_updatables.clear endend#==============================================================================# ** Spriteset_Map#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# Summary of Changes:# aliased methods - create_tilemap, update_tilemap, dispose_tilemap#==============================================================================class Spriteset_Map #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Create Tilemap #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modrnb_fow_crttilmp_5tf2 create_tilemap def create_tilemap(*args) modrnb_fow_crttilmp_5tf2(*args) # Run Original Method # Create viewport between tile and picture layers @fow_viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @fow_viewport.z = 40 data = $game_system.fow_data $game_system.fow_reset_data($game_map.map_id) if @tilemap.map_data.xsize != data.xsize || @tilemap.map_data.ysize != data.ysize @fow_tilemap = Tilemap_FogofWar.new(@fow_viewport) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Dispose of Tilemap #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias malgbr_fow_dispmap_7yh2 dispose_tilemap def dispose_tilemap(*args) malgbr_fow_dispmap_7yh2(*args) # Run Original Method for i in 0...9 do @fow_tilemap.bitmaps[i].dispose end @fow_tilemap.dispose end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Update Tilemap #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias monaba_fogwar_tilmup_2fu8 update_tilemap def update_tilemap(*args) monaba_fogwar_tilmup_2fu8(*args) # Run Original Map @fow_tilemap.ox = @tilemap.ox @fow_tilemap.oy = @tilemap.oy @fow_viewport.visible = $game_map.fow_active @fow_tilemap.update endend