CODE
#--------------------------------------------------
#in a event add a new script : #
#change_color(eventid,color) #
#to self event id use "@event_id" #
#By Zarby, no credit needed #
#--------------------------------------------------
class Game_Interpreter
def change_color(eventid,color)
$game_map.events[eventid].changecolor(color)
end
end
class Spriteset_Map
def create_characters
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i],$game_map.events[i].color)
@character_sprites.push(sprite)
end
for vehicle in $game_map.vehicles
sprite = Sprite_Character.new(@viewport1, vehicle)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
end
end
class Sprite_Character < Sprite_Base
def initialize(viewport, character = nil,color = 0)
super(viewport)
@character = character
@balloon_duration = 0
@color = color
update
end
def update_bitmap
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_index != @character.character_index
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_index = @character.character_index
if @tile_id > 0
sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
sy = @tile_id % 256 / 8 % 16 * 32;
self.bitmap = tileset_bitmap(@tile_id)
self.src_rect.set(sx, sy, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = @character.bitmap
sign = @character_name[/^[\!\$]./]
@cw = self.bitmap.width / 3
@ch = self.bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
if @character.color != @character.oldcolor
self.bitmap.hue_change(@character.color)
@character.oldcolor = @character.color
end
end
def update_src_rect
if @tile_id == 0
index = 0
pattern = @character.pattern < 3 ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
end
class Game_Player < Game_Character
def refresh
if $game_party.members.size == 0
@character_name = ""
@character_index = 0
else
actor = $game_party.members[0] # Get front actor
@character_name = actor.character_name
@character_index = actor.character_index
set_graphic(@character_name,@character_index)
end
end
end
class Game_Event < Game_Character
def setup(new_page)
@page = new_page
if @page == nil
@tile_id = 0
@character_name = ""
@character_index = 0
@move_type = 0
@through = true
@trigger = nil
@list = nil
@interpreter = nil
else
@tile_id = @page.graphic.tile_id
@character_name = @page.graphic.character_name
@character_index = @page.graphic.character_index
if @tile_id == 0
set_graphic(@character_name,@character_index)
end
if @original_direction != @page.graphic.direction
@direction = @page.graphic.direction
@original_direction = @direction
@prelock_direction = 0
end
if @original_pattern != @page.graphic.pattern
@pattern = @page.graphic.pattern
@original_pattern = @pattern
end
@move_type = @page.move_type
@move_speed = @page.move_speed
@move_frequency = @page.move_frequency
@move_route = @page.move_route
@move_route_index = 0
@move_route_forcing = false
@walk_anime = @page.walk_anime
@step_anime = @page.step_anime
@direction_fix = @page.direction_fix
@through = @page.through
@priority_type = @page.priority_type
@trigger = @page.trigger
@list = @page.list
@interpreter = nil
if @trigger == 4 # Trigger is [Parallel Process]?
@interpreter = Game_Interpreter.new # For parallel processing
end
end
update_bush_depth
end
end
class Game_Character
attr_accessor :color
attr_accessor :oldcolor
attr_accessor :bitmap
def initialize
@id = 0
@x = 0
@y = 0
@real_x = 0
@real_y = 0
@tile_id = 0
@character_name = ""
@character_index = 0
@opacity = 255
@blend_type = 0
@direction = 2
@pattern = 1
@move_route_forcing = false
@priority_type = 1
@through = false
@bush_depth = 0
@animation_id = 0
@balloon_id = 0
@transparent = false
@original_direction = 2 # Original direction
@original_pattern = 1 # Original pattern
@move_type = 0 # Movement type
@move_speed = 4 # Movement speed
@move_frequency = 6 # Movement frequency
@move_route = nil # Move route
@move_route_index = 0 # Move route index
@original_move_route = nil # Original move route
@original_move_route_index = 0 # Original move route index
@walk_anime = true # Walking animation
@step_anime = false # Stepping animation
@direction_fix = false # Fixed direction
@anime_count = 0 # Animation count
@stop_count = 0 # Stop count
@jump_count = 0 # Jump count
@jump_peak = 0 # Jump peak count
@wait_count = 0 # Wait count
@locked = false # Locked flag
@prelock_direction = 0 # Direction before lock
@move_failed = false # Movement failed flag
@color = 0
@oldcolor = 0
@bitmap = Bitmap.new(96,128)
end
def set_graphic(character_name, character_index)
@tile_id = 0
@character_name = character_name
@character_index = character_index
frombitmap = Cache.character(@character_name)
@bitmap.clear
if @character_name.include?('!')
if @character_index <= 3
ch = frombitmap.height/2
@bitmap = Bitmap.new(96,ch)
@bitmap.blt(0,0,frombitmap,Rect.new(@character_index*96,0,96,ch))
end
if @character_index > 3
ch = frombitmap.height/2
@ci = @character_index-4
@bitmap = Bitmap.new(96,ch)
@bitmap.blt(0,0,frombitmap,Rect.new(@ci*96,ch,96,ch))
end
end
if @character_name.include?('$')
@bitmap.clear
@bitmap = Bitmap.new(frombitmap.width,frombitmap.height)
@bitmap.blt(0,0,frombitmap,Rect.new(0,0,frombitmap.width,frombitmap.height))
end
if @character_name.include?('$') == false and @character_name.include?('!') == false
@bitmap.clear
if @character_index <= 3
@bitmap.blt(0,0,frombitmap,Rect.new(@character_index*96,0,96,128))
end
if @character_index > 3
@ci = @character_index-4
@bitmap.blt(0,0,frombitmap,Rect.new(@ci*96,128,96,128))
end
end
@bitmap.hue_change(@color)
end
def changecolor(color)
@color = color
refresh
end
end