Help - Search - Members - Calendar
Full Version: Event reference a Character ID for its image
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
Helskyth
Solved with script - Credits to Night_Runner

So to skip to the point, I was moving onto making some of the games characters appear in Inns and Taverns after they join you, but before I started to set this up it occurred to me that I was going to make these characters have alternate costumes. Rather than make an additional event-controller to switch out with the new costume (which I figure I can still do as a fall back), or rather than go and make another x-amount of pages with the eventing I planned on doing, with the event-tile set to the new costume. I was curious if there was a way to make an event tile set its image based on characters ID within the database.
Which means the only thing that needs be done is make one event, and once the alternate costumes enabled and changes out the original with the new within the database, the events relating to those characters would always display the correct image.

So far I've had no luck turning up any information regarding this, not even a script. Anyone have any ideas or thoughts?

Like I said, if there's no simple way to do this, then I'll use the fall back of making an additional event controller in the necessary scenes to switch out positions of normal costumed event with the alternate. (i just hope it doesn't conflict with other events running on the same scenes, specifically the more complex of my cinematic ones >_< )

Thanks in advance for any assistance. smile.gif
Night_Runner
Let me know how this goes for you!

CODE
#==============================================================================
# ** XP: Night_Runner's Event Abides Hero Graphic Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 21/Feb/2012
#  Created for: Helskyth
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=55426
#
# Description:
#  This script allows the developer to set an event to follow a hero's
#  graphic.
#
# How to Install:
#  Copy this entire script. In your game editor select Tools >> Script
#  Editor. Along the left hand side scroll to the bottom, right click on
#  'Main' and select 'Insert'. Past on the right.
#==============================================================================



#==============================================================================
# ** Customization
#==============================================================================

module NR_EventAbidesHeroGraphic
  #---------------------------------------------------------------------------
  Data = {} # DO NOT TOUCH
  #---------------------------------------------------------------------------
  # Format: Data[[map_id, event_id]] = hero_id
  Data[[1, 5]] = 4 # Map 1, event 5 follows hero 4's graphic
end


#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  Edited to have the actors match the window positions
#==============================================================================

class Game_Event
  #--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  alias nr_eventAbidesHeroGraphic_refresh  refresh  unless $@
  #--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  def refresh(*args, &block)
    # Run the original refresh
    nr_eventAbidesHeroGraphic_refresh(*args, &block)
    # Check if this event abides by a hero's graphic
    hero_id = NR_EventAbidesHeroGraphic::Data[[@map_id, @id]]
    return if not hero_id.is_a?(Integer)
    # Set the character name and hue
    @character_name = $game_actors[hero_id].character_name
    @character_hue = $game_actors[hero_id].character_hue
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


I'll give the eventer's a chance to see if this can be done easily through events, otherwise I'll move this to the Script Requests happy.gif
Helskyth
QUOTE (Night_Runner @ Feb 21 2012, 12:38 AM) *
Let me know how this goes for you!

CODE
#==============================================================================
# ** XP: Night_Runner's Event Abides Hero Graphic Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 21/Feb/2012
#  Created for: Helskyth
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=55426
#
# Description:
#  This script allows the developer to set an event to follow a hero's
#  graphic.
#
# How to Install:
#  Copy this entire script. In your game editor select Tools >> Script
#  Editor. Along the left hand side scroll to the bottom, right click on
#  'Main' and select 'Insert'. Past on the right.
#==============================================================================



#==============================================================================
# ** Customization
#==============================================================================

module NR_EventAbidesHeroGraphic
  #---------------------------------------------------------------------------
  Data = {} # DO NOT TOUCH
  #---------------------------------------------------------------------------
  # Format: Data[[map_id, event_id]] = hero_id
  Data[[1, 5]] = 4 # Map 1, event 5 follows hero 4's graphic
end


#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  Edited to have the actors match the window positions
#==============================================================================

class Game_Event
  #--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  alias nr_eventAbidesHeroGraphic_refresh  refresh  unless $@
  #--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  def refresh(*args, &block)
    # Run the original refresh
    nr_eventAbidesHeroGraphic_refresh(*args, &block)
    # Check if this event abides by a hero's graphic
    hero_id = NR_EventAbidesHeroGraphic::Data[[@map_id, @id]]
    return if not hero_id.is_a?(Integer)
    # Set the character name and hue
    @character_name = $game_actors[hero_id].character_name
    @character_hue = $game_actors[hero_id].character_hue
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


I'll give the eventer's a chance to see if this can be done easily through events, otherwise I'll move this to the Script Requests happy.gif


Ah, Night Runner, this would be the second time you've pulled my head back above the water. xD
If I'm understanding this script right, I'm adding the additional lines within the region of-

#---------------------------------------------------------------------------
# Format: Data[[map_id, event_id]] = hero_id
Data[[1, 5]] = 4 # Map 1, event 5 follows hero 4's graphic region,
end

- right under the Data, in order to make more event tiles match the graphics?

-edit-
nevermind, I jumped the gun and risked breaking it anyway xD
There is one thing I did find. The event runs on a conditional for its appearance, it was visible even when the conditions are not met, but since this is only a concern in Tavern or Inn instances, I fixed it with a parallel event process to to move the event to its position when required. So all is very well! biggrin.gif

Thank you very much once again happy.gif
Night_Runner
CODE
#==============================================================================
# ** XP: Night_Runner's Event Abides Hero Graphic Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 22/Feb/2012
#  Created for: Helskyth
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=55426
#
# Description:
#  This script allows the developer to set an event to follow a hero's
#  graphic.
#
# How to Install:
#  Copy this entire script. In your game editor select Tools >> Script
#  Editor. Along the left hand side scroll to the bottom, right click on
#  'Main' and select 'Insert'. Past on the right.
#
# Customization:
#  Refer to line 39 as a template for how to setup an event to abide by a
#   hero's graphic.
#   Apply this to more than 1 event, just use that template to make more
#   commands, make sure that the extra commands are before the end command.
#  Lines 63 - 68 introduce more (and occassionally overlapping) features,
#   where the graphic will not be updated depending on certain scenario's.
#   Delete any of these scenario's if they are not necessary.
#==============================================================================



#==============================================================================
# ** Customization
#==============================================================================

module NR_EventAbidesHeroGraphic
  #---------------------------------------------------------------------------
  Data = {} # DO NOT TOUCH
  #---------------------------------------------------------------------------
  # Format: Data[[map_id, event_id]] = hero_id
  Data[[1, 2]] = 4 # Map 1, event 5 follows hero 4's graphic
end


#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  Edited to have the actors match the window positions
#==============================================================================

class Game_Event
  #--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  alias nr_eventAbidesHeroGraphic_refresh  refresh  unless $@
  #--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  def refresh(*args, &block)
    # Run the original refresh
    nr_eventAbidesHeroGraphic_refresh(*args, &block)
    # Check if this event abides by a hero's graphic
    hero_id = NR_EventAbidesHeroGraphic::Data[[@map_id, @id]]
    return if not hero_id.is_a?(Integer)
    # Do not change the graphic if no page conditions are met for the event.
    return if @page == nil
      # Do not change the graphic if the event didn't already have a graphic
      return if @character_name == ""
    # Do not change the graphic if the event is erased
      return if @erased
    # Set the character name and hue
    @character_name = $game_actors[hero_id].character_name
    @character_hue = $game_actors[hero_id].character_hue
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


That should take care of that problem smile.gif
Helskyth
It certain did. It no longer appears if an event condition is not met. But it will also not appear when the event tile is set to "none". Which is strange, but I don't see this as a problem, since so long as the script is active, the event will be altered to the required one regardless. This also means using any graphic to position the direction of the character, rather than making a custom movement to make sure it faces the correct position at the start of the scene.

Thanks again ^__^
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.