Save-Point
Change event graphic? - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Change event graphic? (/thread-8202.html)



Change event graphic? - Bennerdeben - 11-14-2020

Hi guys!

Lately im trying to change an event ("This Event") graphic in case the hero touches it through code.
(Why not through events? Well, specific reasons).

This is what ive got working so far:


For the hero

Code:
# After set_graphic (character_name, character_hue, battler_name, battler_hue)
$game_actors[1].set_graphic("basis_run", 0, "undead72", 0)
$game_player.refresh 


But the code below doesn't work:

Code:
$game_map.events[@event_id].set_graphic("basis_run", 0 ,"undead72", 0)


Saying set_graphic is not defined.
How would one define this, or what code would be useful?

Excuse my Ruby noobiness!


RE: Change event graphic? - DerVVulfman - 11-14-2020

I'm at work, so I do not have my RPGMAKER XP system handy right now.  However, I do not recall ever seeing a 'set_graphic' method within the Game_Actor class.  So I would suggest looking for 'def set_graphic' within the default Game_Actor code.  Chances are, you will need to do a 'little' bit more with this code.  

The 'Interpreter' class does handle the code for changing Game_Event graphics, which even the Player is looked at as an event.  The reason is that both the Game_Actor and Game_Event methods link to Game_Character which handles character graphics, speed and animation pattern.

Even so, it would likely NOT take effect immediately.  Kid you not.  But you were on the right track with $game_player.refresh.  But you will need to refresh the Game Map with $game_map.need_refresh = true...   or just $game_map.refresh

EDIT:  Yeah, I re-read the request.  You're not complaining about changing the hero or actor, but the EVENT graphic.  Oookay. 

Normally, you would change an event's graphic with the "MOVE ROUTE" event command.  But you want it scripted.  Well, events do not have 'Set Graphic'   That would be too easy, wouldn't it?  Well, the MOVE ROUTE command in the event list goes directly into the Game_Character class.

Ah, the quandry.  You'd think you could edit $game_map.events[1] as an example to change the character graphic.  But the Game_Character class set up the 'character_name' value to be a bit... stubborn.  It can only allow changes within the class itself, and prevents anything like a script call from sending a character name graphic from outside the class.  SO....

Add:
Code:
#==============================================================================
# ** Game_Character (part 1)
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :character_name           # character file name
  attr_accessor :character_hue            # character hue
end

... Setting the character_name and character_hue values to the 'attr_accessor' attribute allows you more access.  And since Game_Event is a 'child' class of Game_Character, the change made here will automatically affect Game_Event.

Okay, once that has been edited/added/whatever.....  (I prefer not to directly edit the base original code)....

Code:
$game_map.events[1].character_name = "002-Fighter02"
That should work, even in an event's  "Script Call".  It did for me.


RE: Change event graphic? - Bennerdeben - 11-15-2020

Got it working! Thanks Very cheery