Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: jcsnider on July 25, 2008, 08:20:44 pm

Title: Get actor graphic and save it....
Post by: jcsnider on July 25, 2008, 08:20:44 pm
With a character maker or w/e it changes the players graphic just like it would if u Set Move route Player change graphic... but when you add a different acotr is changes to that graphic... is there a script or something that it gets the same of your actors graphic and never lets it change?

Thanks
Title: Re: Get actor graphic and save it....
Post by: Fantasist on July 26, 2008, 12:29:26 am
You can do it, but I'm just curious... why do you need it? There might be a better way.
Title: Re: Get actor graphic and save it....
Post by: Blizzard on July 26, 2008, 06:09:35 am
He's making a pokemon game where the player sprite needs to be independent from actor sprites.
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 26, 2008, 07:03:35 am
Maybe even change it a little it might be able to do something like this... In a common event at the start of hte game run a conditional branch that does like a script...
If actor.character.graphic = ""
Controll switches "100" = On
Else

End
Would that be posssible?
Title: Re: Get actor graphic and save it....
Post by: Fantasist on July 26, 2008, 09:58:19 am
QuoteWould that be posssible?

I don't get what you're saying there, but I'll try this out :)
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 26, 2008, 10:17:28 am
maybe this will clear it up some...
Spoiler: ShowHide
(http://www.fileden.com/files/2007/5/14/1079196/branch.PNG)


SO it finds out what the current character graphic is and if it is a certant one it turns a switch on...

Does this clear it up some?

by Blizzard: Use spoilers for images. -_-
Title: Re: Get actor graphic and save it....
Post by: Fantasist on July 26, 2008, 10:23:48 am
It clears up everything but the point of it, but that's none of my concern, but here's the code needed to check the player's graphic:
$game_party.actors[0].character_name


Use it like this in a conditional branch:
$game_party.actors[0].character_name = '001Fighter01'


If it doesn't work, try adding the fle extension to the filename (like "001Fighter01.png").
Title: Re: Get actor graphic and save it....
Post by: Blizzard on July 26, 2008, 10:26:43 am
Wrong, this would be the first actor again. You have to use "$game_player" instead of "$game_party.actors[0]". And the extension must be omitted.
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 26, 2008, 10:30:52 am
now i have an undefined method for character_name im testing this in a nomral project not the neptlay right now.
Title: Re: Get actor graphic and save it....
Post by: Blizzard on July 26, 2008, 10:33:40 am
You need to add this extra script first:

class Game_Character
  attr_accessor :character_name
end
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 26, 2008, 10:44:43 am
what that is doing is just changing my char sprite to that sprite... I need it so it finds out what sprite I have and then do something if it is and something else if it isnt... Like...

If it IS 001-Fighter01.png then Controll switch 1 to on

else controll switch 2 ot on or something like that...
Title: Re: Get actor graphic and save it....
Post by: Fantasist on July 26, 2008, 10:56:17 am
Old confusing post: ShowHide
Yeah, realized that, I was looking through the code just now. The Game_Player#refresh needs to be modded too. I considered the following code:

FIX_MAP_GRAPHIC_SWITCH = 12 #####

class Game_Character
 attr_accessor :character_name, :character_hue
end

class Game_Player
 
 alias fts_jcsnider_fix_map_graphic_refresh refresh
 def refresh
   if $game_switches[FIX_MAP_GRAPHIC_SWITCH] #####
     @opacity, @blend_type = 255, 0
   else     #####
     fts_jcsnider_fix_map_graphic_refresh #####
   end #####
 end
 
end


But I get an "Undefined local var or method 'refresh' for Game_Player:class" :?


Here you go:


class Game_Player
 
  attr_accessor :character_name, :character_hue
 
  def refresh
    @opacity, @blend_type = 255, 0
  end
 
end


There's a good chance the player might be invisible at the beginning of the game, so set the graphic when the game starts.

You can't use the 'Change Graphic' event command anymore on the player. You can use it to change your pokemons' graphics, though. For changing the player's graphic, use this code in a call script command:

$game_player.character_name = '001-Fighter01'
$game_player.character_hue = 0 (a number b/w 0 and 360, both included)


You won't need to change the hue if I'm right, since you'll be using a customized graphic anyway.

For checking the name of the graphic, use this in a Conditional Branch:
$game_player.character_name == '001-Fighter01'


Don't forget to use the double '=' when checking for the graphic.
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 27, 2008, 08:47:34 am
Yes in a normal project it works... but when I tried it in my netplay project... I can't call the change player graphic without knowing what the players graphic is... that is why I wanted this script.... before you are even to the first map you go through a char select which changes your graphic to what you choose then you go right into the game. But when you do the sprite is now invisable so it dosn't lemme call the script to figure out what the actors sprite is... Is there anyway to make it so it dosnt become an invisable sprite?
Title: Re: Get actor graphic and save it....
Post by: Fantasist on July 27, 2008, 09:03:17 am
Okay, you just need to edit the character select script. Can you post/PM it?

EDIT:

Oh boy! Netplay has totally bizzare stuff and I have no idea what's going on (not that I really tried). I can only guess how to make it work, because I can't test it. So here's what you try:

In the Scripts.rxdata you gave me, find the script slot named: "[SC] Scene_Character". Find "$game_player.refresh" (should be somewhere near line 225) and add these lines:

$game_player.character_name = @character
$game_player.character_hue = @hue


Remember this change, just in case. (just add a comment to the right so you can find it).
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 28, 2008, 10:13:36 am
I sent a link to you... did you receive it?
Title: Re: Get actor graphic and save it....
Post by: Fantasist on July 28, 2008, 11:12:53 am
If you mean your scripts file, I did, and my last post is edited, check it out. I think it should work.
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 28, 2008, 08:33:54 pm
ok now it seems to work but when you try to add a character you get an error in this script

#==============================================================================
# ** Game_Player
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_characterdisplay_gplayer_refresh refresh
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Original Refresh Method
    seph_characterdisplay_gplayer_refresh
    # Gets First Actor
    actor = $game_party.actors[0]
    # Determines Text
    case Player_Text
    when 'Name'
      txt = $game_party.actors[0].name
    when 'Class'
      txt = actor.class_name
    when 'Level'
      txt = "Level: #{actor.level}"
    when 'Hp'
      txt = "HP: #{actor.hp} / #{actor.maxhp}"
    when 'Sp'
      txt = "SP: #{actor.sp} / #{actor.maxsp}"
    else
      txt = ''
    end
    @text_display = [txt, Player_Color]
  end
end

#==============================================================================
# ** Sprite_Character
#==============================================================================

class Sprite_Character < RPG::Sprite
 
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_characterdisplay_scharacter_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Original update Method
    seph_characterdisplay_scharacter_update
    # Character Display Update Method
    update_display_text
   
    if $game_temp.new_guild
    @_g_display = nil if @_g_display != nil
    $game_temp.new_guild = false
    end
   
  end
  #--------------------------------------------------------------------------
  # * Create Display Sprite
  #--------------------------------------------------------------------------
  def create_display_sprite(args)
    # Creates Display Bitmap
    bitmap = Bitmap.new(160, 24)
    bitmap.font.size = 16
     
    # Draws Text Shadow
    if bitmap.font.respond_to?(:draw_shadow)
      bitmap.font.draw_shadow = false
    end
    # Changes Font Color
    bitmap.font.color = args[1]
    # Draws Text
    bitmap.draw_text(0, 0, 160, 24, args[0], 1)
    # Creates Display Text Sprite
    @_text_display = Sprite.new(self.viewport)
    @_text_display.bitmap = bitmap
    @_text_display.ox = 80
    @_text_display.oy = 24
    @_text_display.x = self.x
    @_text_display.y = self.y - self.oy / 2 - 24
    @_text_display.z = 30001
    @_text_display.visible = self.visible #true
  end
 
  def create_display_guild(args)
    # Creates Display Bitmap
    bitmap = Bitmap.new(160, 24)
    bitmap.font.size = 16
     
    # Draws Text Shadow
    if bitmap.font.respond_to?(:draw_shadow)
      bitmap.font.draw_shadow = false
    end
    # Changes Font Color
    bitmap.font.color = args[1]
    # Draws Text
    bitmap.draw_text(0, 0, 160, 24, args[0], 1)
    $old_guild = args[0]
    # Creates Display Text Sprite
    @_g_display = Sprite.new(self.viewport)
    @_g_display.bitmap = bitmap
    @_g_display.ox = 80
    @_g_display.oy = 24
    @_g_display.x = self.x
    @_g_display.y = self.y - self.oy / 2 - 24
    @_g_display.z = 30001
    @_g_display.visible = self.visible #true
  end
 
  #--------------------------------------------------------------------------
  # * Dispose Display Sprite
  #--------------------------------------------------------------------------
  def dispose_display_text
    unless @_text_display.nil?
      @_text_display.dispose
    end
  end
 
  #--------------------------------------------------------------------------
  # * Update Display Sprite
  #--------------------------------------------------------------------------
  def update_display_text
   unless @character.text_display.nil?
      if @_text_display.nil?
        create_display_sprite(@character.text_display)
      end
      @_text_display.x = self.x
      @_text_display.y = self.y - self.oy / 2 - 24
   else
      unless @_text_display.nil?
        dispose_display_text
      end
    end

   unless !@character.is_a?(Game_Player)
    if $old_guild != $game_temp.guild_name and @_g_display != nil
      @_g_display.dispose
      @_g_display = nil
      create_display_guild([$game_temp.guild_name,Color.new(0,128,255)])
    end
    if $game_temp.guild_name != ""
      if @_g_display.nil?
        create_display_guild([$game_temp.guild_name,Color.new(0,128,255)])
      end
      @_g_display.x = self.x
      @_g_display.y = self.y - self.oy / 2 - 35
    end
   else
      unless @_g_display.nil?
      @_g_display.dispose
      end
    end
  end
 
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end


on the line  when 'Name'
      txt = $game_party.actors[0].name


undefined method name... it happens when you try to add a char to the party...


It also changes the char's name when the char is added... is there a way so when u choose ur char before you enter the game it shows the name of your character and not the first actor in the party.. so really I want it so while ur in the game and in the menu it shows the actors name and when u are choosing ur char it shows the name you choose in the first place? If you need my scripts I cna send them to anyone that cna help.
Title: Re: Get actor graphic and save it....
Post by: Berans on July 28, 2008, 09:58:39 pm
with that error, does it happen to say something like "for nil:Nilclass" after what you said?
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 28, 2008, 09:59:16 pm
yes
Title: Re: Get actor graphic and save it....
Post by: Berans on July 28, 2008, 10:05:22 pm
Figures lol, I've had to deal with a lot of those in my own scripts....errr....lets see. It means that at some point $game_party.actors[0] is called before the actors are loaded...you can try changing the line to
when Name
  unless $game_party.actors[0] == nil
    txt = $game_party.actors[0].name
  end


but since I didn't write the script I don't know what that exactly will do apart from stopping the error from ocurring :P
maybe you can send me the script, I'll see if I can find out.
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 28, 2008, 10:26:08 pm
no i just get another error... and if it gets the error on .name wont it happen on .class... .hp and the rest?


the error I got this time is right when I start the game
Uninstlalized content Game_player::Player_text

here r my scripts....
http://www.sendspace.com/file/p2y16b

it is in the event text display script


thanks
Title: Re: Get actor graphic and save it....
Post by: Berans on July 28, 2008, 10:32:06 pm
I figured something like that would happen lol, always worth a try :P
I'll have a look into it and see if I can come up with something...
EDIT: wow...you have a lot of scripts lol
anyway, I don't think I know quite enough about scripting yet to really find the root of your problem, so I guess you'll have to wait till fantasist comes back, was definitely worth a look though...
seriously, lots of scripts :P
Title: Re: Get actor graphic and save it....
Post by: Fantasist on July 29, 2008, 09:58:39 am
I'm downloading the script but are you absolutely positive that the error showed up after you changed what I said? It could be totally something else. I'll see what I can do anyway.
Quoteno i just get another error... and if it gets the error on .name wont it happen on .class... .hp and the rest?

But if .name was called first, RMXP stops evaluating any code after that and shows an error.

EDIT:

Okay. You need to add these lines to the script you posted in page 1 (the Game_Player stuff, Seph's event text script). Just after
class Game_Player < Game_Character


add these lines:

  # Player_Color: Constant used in refresh method
  Player_Color = Color.new(128, 128, 255)
 
  # Player_Name: Check the refresh method after the comment 'Determines Text'.
  #                      Change it here accordingly if needed.
  Player_Text = 'Name'


Basically, Player Text is not defined, or it does not have any valye when it's being used. You just need to define the constants.

If you get a syntax error in the same script (I got one), just comment out the very last "end".
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 29, 2008, 05:01:50 pm
Weird now i get tihs error...
(http://www.fileden.com/files/2007/5/14/1079196/error2.PNG)

Here is wat the txt display script looks like now...
#==============================================================================
# ** Game_Player
#==============================================================================

class Game_Player < Game_Character
  # Player_Color: Constant used in refresh method
  Player_Color = Color.new(128, 128, 255)
 
  # Player_Name: Check the refresh method after the comment 'Determines Text'.
  #                      Change it here accordingly if needed.
  Player_Text = 'Name'

  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_characterdisplay_gplayer_refresh refresh
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Original Refresh Method
    seph_characterdisplay_gplayer_refresh
    # Gets First Actor
    actor = $game_party.actors[0]
    # Determines Text
    case Player_Text
    when 'Name'
      txt = $game_party.actors[0].name
    when 'Class'
      txt = actor.class_name
    when 'Level'
      txt = "Level: #{actor.level}"
    when 'Hp'
      txt = "HP: #{actor.hp} / #{actor.maxhp}"
    when 'Sp'
      txt = "SP: #{actor.sp} / #{actor.maxsp}"
    else
      txt = ''
    end
    @text_display = [txt, Player_Color]
  end
end

#==============================================================================
# ** Sprite_Character
#==============================================================================

class Sprite_Character < RPG::Sprite
 
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_characterdisplay_scharacter_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Original update Method
    seph_characterdisplay_scharacter_update
    # Character Display Update Method
    update_display_text
   
    if $game_temp.new_guild
    @_g_display = nil if @_g_display != nil
    $game_temp.new_guild = false
    end
   
  end
  #--------------------------------------------------------------------------
  # * Create Display Sprite
  #--------------------------------------------------------------------------
  def create_display_sprite(args)
    # Creates Display Bitmap
    bitmap = Bitmap.new(160, 24)
    bitmap.font.size = 16
     
    # Draws Text Shadow
    if bitmap.font.respond_to?(:draw_shadow)
      bitmap.font.draw_shadow = false
    end
    # Changes Font Color
    bitmap.font.color = args[1]
    # Draws Text
    bitmap.draw_text(0, 0, 160, 24, args[0], 1)
    # Creates Display Text Sprite
    @_text_display = Sprite.new(self.viewport)
    @_text_display.bitmap = bitmap
    @_text_display.ox = 80
    @_text_display.oy = 24
    @_text_display.x = self.x
    @_text_display.y = self.y - self.oy / 2 - 24
    @_text_display.z = 30001
    @_text_display.visible = self.visible #true
  end
 
  def create_display_guild(args)
    # Creates Display Bitmap
    bitmap = Bitmap.new(160, 24)
    bitmap.font.size = 16
     
    # Draws Text Shadow
    if bitmap.font.respond_to?(:draw_shadow)
      bitmap.font.draw_shadow = false
    end
    # Changes Font Color
    bitmap.font.color = args[1]
    # Draws Text
    bitmap.draw_text(0, 0, 160, 24, args[0], 1)
    $old_guild = args[0]
    # Creates Display Text Sprite
    @_g_display = Sprite.new(self.viewport)
    @_g_display.bitmap = bitmap
    @_g_display.ox = 80
    @_g_display.oy = 24
    @_g_display.x = self.x
    @_g_display.y = self.y - self.oy / 2 - 24
    @_g_display.z = 30001
    @_g_display.visible = self.visible #true
  end
 
  #--------------------------------------------------------------------------
  # * Dispose Display Sprite
  #--------------------------------------------------------------------------
  def dispose_display_text
    unless @_text_display.nil?
      @_text_display.dispose
    end
  end
 
  #--------------------------------------------------------------------------
  # * Update Display Sprite
  #--------------------------------------------------------------------------
  def update_display_text
   unless @character.text_display.nil?
      if @_text_display.nil?
        create_display_sprite(@character.text_display)
      end
      @_text_display.x = self.x
      @_text_display.y = self.y - self.oy / 2 - 24
   else
      unless @_text_display.nil?
        dispose_display_text
      end
    end

   unless !@character.is_a?(Game_Player)
    if $old_guild != $game_temp.guild_name and @_g_display != nil
      @_g_display.dispose
      @_g_display = nil
      create_display_guild([$game_temp.guild_name,Color.new(0,128,255)])
    end
    if $game_temp.guild_name != ""
      if @_g_display.nil?
        create_display_guild([$game_temp.guild_name,Color.new(0,128,255)])
      end
      @_g_display.x = self.x
      @_g_display.y = self.y - self.oy / 2 - 35
    end
   else
      unless @_g_display.nil?
      @_g_display.dispose
      end
    end
  end
 
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
#end




Line 134 is this
unless @character.text_display.nil?




THE ERRORS NEVER END!!!  :angry:

lol :D
Title: Re: Get actor graphic and save it....
Post by: Fantasist on July 31, 2008, 08:44:24 am
I didn't get any error, did you change/add anything else? Because I've tested that code in the above post in the Scripts.rxdata file you gave me and I got no error... I guess this is beyond my power now (-_-)'

EDIT: Wait, when did you get this error? I'm guessing just after you go into a map (new game or load game). Did this error occur even before you tried my script?
Title: Re: Get actor graphic and save it....
Post by: jcsnider on July 31, 2008, 10:17:01 am
Right after you choose your character and click on play when it sends u to the map it now gives me that error
Title: Re: Get actor graphic and save it....
Post by: Fantasist on August 02, 2008, 02:51:46 am
Okay, i'm starting to get more and more confused. I don't know if that error occured even before you used my code, but here's one blind guess of mine. Remember this script:

class Game_Player
 
  attr_accessor :character_name, :character_hue
 
  def refresh
    @opacity, @blend_type = 255, 0
  end
 
end


The first line: class Game_Player

Change it to class Game_Player < Game_Character