This script allows you to manipulate the sprite of any event (using characterset), by setting its horizontal/vertical position.
When is it usefull?
1 - When some of the objects in the map are characters, and you don't want them to look like they're placed on a gridlines.
2 - When you're using characters that require some space in the bottom (i.e. for steps animation). In that situation the graphic is ussually moved up, and it may cause some weird situations when calculatin passability or coordinates.
3 - When you want to place graphics from several events in one place, without moving them. This is helpful in making lanterns, torches, etc.
Screenshot:
http://www.eimg.org/images/745026corr.jpg[/IMG]
Script:
Usage:
Paste the script above "Main". Set the first page of an event to parallel or autostart. Put a "Call Script" command with:
Turn on any local switch, and make another page with the sam graphic.
Adjust the numbers (but not the ones in the brackets) to move the sprite left/right and up/down.
For example: the characters on the right side of the screenshot have a "Call script" command like this:
This way the correction is different for each character, and you can still copy/paste
Now, I know a lot of people are using scripts that already alter Game_Character and Sprite_Character, and I can't alias the Sprite_Character's def update to work properly so here's what you need to do if you want to add this method to, for example, pixelmovement:
Find the Sprite_Character class. In its 'def update' find:
and replace it with:
The Game_Character class is aliased so there's no need to do anything with it.
Enjoy the script
When is it usefull?
1 - When some of the objects in the map are characters, and you don't want them to look like they're placed on a gridlines.
2 - When you're using characters that require some space in the bottom (i.e. for steps animation). In that situation the graphic is ussually moved up, and it may cause some weird situations when calculatin passability or coordinates.
3 - When you want to place graphics from several events in one place, without moving them. This is helpful in making lanterns, torches, etc.
Screenshot:
http://www.eimg.org/images/745026corr.jpg[/IMG]
Script:
Code:
#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
attr_accessor :correction_x
attr_accessor :correction_y
#--------------------------------------------------------------------------
alias normal_initialize initialize
def initialize
@correction_x = 0
@correction_y = 0
normal_initialize
end
end
#==============================================================================
# ** Sprite_Character
#==============================================================================
class Sprite_Character < RPG::Sprite
def update
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2 - @character.correction_x
self.oy = @ch - @character.correction_y
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
Usage:
Paste the script above "Main". Set the first page of an event to parallel or autostart. Put a "Call Script" command with:
Code:
get_character(0).correction_x = 0
get_character(0).correction_y = 0
Adjust the numbers (but not the ones in the brackets) to move the sprite left/right and up/down.
For example: the characters on the right side of the screenshot have a "Call script" command like this:
Code:
x = -8 + rand(16)
y = -8 + rand(16)
get_character(0).correction_x = x
get_character(0).correction_y = y
Now, I know a lot of people are using scripts that already alter Game_Character and Sprite_Character, and I can't alias the Sprite_Character's def update to work properly so here's what you need to do if you want to add this method to, for example, pixelmovement:
Find the Sprite_Character class. In its 'def update' find:
Code:
self.ox = @cw / 2
self.oy = @ch
Code:
self.ox = @cw / 2 - @character.correction_x
self.oy = @ch - @character.correction_y
Enjoy the script