Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Heretic86

XP Script - Flat Sprites Render as Flat!

Recommended Posts

Anyone ever try to use this Graphic for an Event?

 

trouble_sprite.jpg

 

Your Character has a problem of "Walking Behind or Under" that Graphic. Like this:

 

trouble_sprite2.jpg

 

That isnt what we want. I wont bother to explain the problem in technical terms, but I will offer a FIX.

 

trouble_sprite3.jpg

 

THAT is what we want! Did you notice the Characters are now on TOP of the Graphic?

 

The problem is that the engine "Thinks" that the Graphic is a Character that is standing up and not laying on the ground. This script tells the Engine to just render it as "Flat" instead of as "Standing Up".

 

 

# Heretic Fix Flat Sprites
#
# People stand up straight off the ground, but
# Rugs lay flat on the ground.
#
# The intention of this script is to allow a quick fix for
# Sprites that are supposed to look like they should lay flat
# Namely, the "Support 7" Graphics.  They look like they should
# lay flat, and not stack in front of the characters EVER.
#
# The "Support 7" Graphic, make an event, give it a Graphic
# and find "Support 7", it is one up from the bottom of the list.
#
# ALWAYS_ON_TOP MUST BE OFF!!!
#
# To define an event to be FLAT, change the NAME of the EVENT
# and add \z_flat, so a Rug would be "Rug\z_flat"
#
# If you have trouble with your Event stacking correctly
# you can try using the optional parameter field to specify a Z-Index to add
# I.E. - "Sign\z_flat[32]", 32 per tile you want higher.
#
# This is useful if you have TWO EVENTS you want to stack, like a TREE
# I sometimes use EVENTS to hold GRAPHICS when I need to put more
# than Three Layers of Graphics
#
# Another option is "Name\z_add[32]" which REQUIRES a Number
#
# This is intended also for fixing things like Graphic Events.  To make it
# stack on top of Characters, give it a nice high number, but less than 999
# as 999 is the Z-Index for "Always On Top", thus allowing even more
# Graphic Events to stack on top of that.  500 is a good number to work with.
#
# This whole thing gives you MUCH MORE CONTROL over the way that events stack
# when they occupy the same space.  Normally, the engine just cycles through
# Events in order, so if you have 3 Graphic Events stacked on top of one another
# the Event with the LOWEST EVENT ID will be on Bottom of that Stack.
#
# Needless to say, if you are fighting with the Stacking Order and trying to
# figure out Event ID's, then change tons of other stuff, this script will
# save you time from heavy modifications.
#
#
# Shouldnt affect performance because it is only called when the map is loaded
# which would be the only place you might take a performance hit.
#
# If you use my revision of Zeriab's Caterpillar, place this BELOW that script
# and above MAIN

class Game_Event < Game_Character

 unless self.method_defined?('flat_sprite_initialize')
alias flat_sprite_initialize initialize
 end

 def initialize(map_id, event, *args)
flat_sprite_check(event)
flat_sprite_initialize(map_id, event, *args)
 end
 unless self.method_defined?('flat_sprite_screen_z')
alias flat_sprite_screen_z screen_z
 end

 def screen_z (height = 0)
if not @z_flat.nil? and [email="!@always_on_top"]!@always_on_top[/email]
  return z = (@real_y - $game_map.display_y + 3) / 4 + @z_flat
end

if not @z_add.nil? and [email="!@always_on_top"]!@always_on_top[/email]
  return z = (@real_y - $game_map.display_y + 3) / 4 + 32 + @z_add
end
#Run Original screen_z
flat_sprite_screen_z(height)

 end

 def flat_sprite_check(event)
# Options
#
# "Name\z_flat"
# "Name\z_flat[32]" for characters manual adjustments, for whatever reason
# "Name\z_add[32]" for characters higher than 32 pixels high

event.name.gsub(/\\z_flat/) [email="{@z_flat"]{@z_flat[/email] = 0}
return if @z_flat
event.name.gsub(/\\z_flat\[([0-9]+)\]/i) [email="{@z_flat"]{@z_flat[/email] = $1.to_i }
return if @z_flat

# Handles Negative GSub cuz I suck with Regexp
event.name.gsub(/\\z_flat\[[-]([0-9]+)\]/i) [email="{@z_flat"]{@z_flat[/email] = -1 * $1.to_i }
return if @z_flat

event.name.gsub(/\\z_add\[([0-9]+)\]/i) [email="{@z_add"]{@z_add[/email] = $1.to_i }
return if @z_add

# Handles Negative GSub cuz I suck with Regexp
event.name.gsub(/\\z_add\[[-]([0-9]+)\]/i) [email="{@z_add"]{@z_add[/email] = -1 * $1.to_i }
return if @z_add
 end

end

 

 

To do this, change the Name of the event to include \z_flat, so "Rug\z_flat" will force the engine to render characters on top of it correctly.

 

Will anyone find this to be useful?

Edited by Heretic86

Share this post


Link to post
Share on other sites

Well, I don't really use RPG Maker XP anymore..... BUT, I can say this is actually really nifty. I'm sure it could be VERY useful.

 

alright.gif

Share this post


Link to post
Share on other sites

That's awesome, I know exactly what you are talking about. I have had that same problem and never used that graphic because of it. This is definitely a huge help, very nice to be able to control this.

Great job, slick creation mate.

 

-Cheers

Share this post


Link to post
Share on other sites

Wasnt really looking for a way to fix this, I just came across it when messing with other stuff. Thought I'd share tho, very quick script...

Edited by Heretic86

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...