The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Atracious on March 13, 2007, 01:33:05 PM

Title: How would I put a battler in my CMS? [resolved]
Post by: Atracious on March 13, 2007, 01:33:05 PM
I am learning how to script and i plan on making a CMS, but i want to have the battler show up in one menu, or at least the face, how would i do this? Thanks for the help in advance!  ;D
Title: Re: How would I put a battler in my CMS?
Post by: blazinhandle on March 13, 2007, 05:36:13 PM
you would have to have a Window_Base definition of what exactly u want to draw....

this is for faces:

  #--------------------------------------------------------------------------
  # * Draw Face Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_graphic(actor, x, y)
    if $game_party.actors.size != 0
      bitmap = RPG::Cache.picture("Faces/" + actor.character_name)
      self.contents.blt(x - 40, y - 80, bitmap, Rect.new(0, 0, 80, 80))
    end
  end
  def draw_actor_graphicb(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end


but you need to have a folder called "Faces" inside of your "pictures" folder. In that Faces folder you'll need to have the faces you want but they must be 80x80.

THEN

in your CMS you'll just have to draw them with something like this:

draw_actor_graphic(@actor, X POSITION WHERE U WANT THE FACE PLACED, Y POSITION WHERE U WANT THE FACE PLACED)

as you can see....it says "draw_actor_graphic" and ur prolly thinking "don't i need to draw the face graphics?" Well, what you did in the Window_Base (you did place the coding above in window_base didn't you?) was redo the draw_actor_graphic to draw faces (I just have it titled draw face graphic in my comments so I can remember ;)) There you go!
Title: Re: How would I put a battler in my CMS?
Post by: Atracious on March 14, 2007, 01:48:41 AM
Quote from: blazinhandle on March 13, 2007, 05:36:13 PM
[spoiler]you would have to have a Window_Base definition of what exactly u want to draw....

this is for faces:

  #--------------------------------------------------------------------------
  # * Draw Face Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_graphic(actor, x, y)
    if $game_party.actors.size != 0
      bitmap = RPG::Cache.picture("Faces/" + actor.character_name)
      self.contents.blt(x - 40, y - 80, bitmap, Rect.new(0, 0, 80, 80))
    end
  end
  def draw_actor_graphicb(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end


but you need to have a folder called "Faces" inside of your "pictures" folder. In that Faces folder you'll need to have the faces you want but they must be 80x80.

THEN

in your CMS you'll just have to draw them with something like this:

draw_actor_graphic(@actor, X POSITION WHERE U WANT THE FACE PLACED, Y POSITION WHERE U WANT THE FACE PLACED)

as you can see....it says "draw_actor_graphic" and ur prolly thinking "don't i need to draw the face graphics?" Well, what you did in the Window_Base (you did place the coding above in window_base didn't you?) was redo the draw_actor_graphic to draw faces (I just have it titled draw face graphic in my comments so I can remember ;)) There you go!
[/spoiler]
so what do i do with this? I'm pretty noob, I just went through the "read this before asking for help" thing and noticed there wasn't anything on Battlers :| Sorry for being a noob! And 80x80 is kinda small...
Also i don't want it to affect the existing battlers...
Title: Re: How would I put a battler in my CMS?
Post by: Tsunokiette on March 14, 2007, 02:18:19 AM
draw_actor_battler(actor_id,x,y)

?

Sorry I have to chuckle.

OVERCOMPLICATION
Title: Re: How would I put a battler in my CMS?
Post by: blazinhandle on March 14, 2007, 02:49:22 AM
Quote from: atracious on March 14, 2007, 01:48:41 AM
so what do i do with this? I'm pretty noob, I just went through the "read this before asking for help" thing and noticed there wasn't anything on Battlers :| Sorry for being a noob! And 80x80 is kinda small...
80x80 is small, so just adjust sizes in here by replacing the 80s with your desired size(but you need to adjust the position of it):
self.contents.blt(x - 40, y - 80, bitmap, Rect.new(0, 0, 80, 80))
Put this in the script called "Window_Base" using the script editor and Replace it for the default "draw_actor_graphic":
[spoiler]  def draw_actor_graphic(actor, x, y)
    if $game_party.actors.size != 0
      bitmap = RPG::Cache.picture("Faces/" + actor.character_name)
      self.contents.blt(x - 40, y - 80, bitmap, Rect.new(0, 0, 80, 80)) # Or w/e size u want
    end
  end
  def draw_actor_graphicb(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
[/spoiler]

Quote from: atracious on March 14, 2007, 01:48:41 AM
Also i don't want it to affect the existing battlers...
Quote from: atracious on March 14, 2007, 01:48:41 AM

Put this in window_base just as you did before:
  def draw_actor_battler(actor, x, y)
    battler = RPG::Cache.picture("Battlers/" + actor.character_name)
    bw = battler.width
    bh = battler.height
    src_rect = Rect.new(0, 0, bsw, bsh)
    self.contents.blt(x - bsw / 23, y - bsh, battler, src_rect)
  end


Now in window_status or window_menustatus or w/e window u want to draw the battler in...just place this in it:

draw_actor_battler(actor, X POSITION, Y POSITION)
Title: Re: How would I put a battler in my CMS?
Post by: Atracious on March 14, 2007, 04:30:55 AM
Quote from: Tsunokiette on March 14, 2007, 02:18:19 AM
draw_actor_battler(actor_id,x,y)

?

Sorry I have to chuckle.

OVERCOMPLICATION
I have to laugh back, I've tried that before, it doesn't work, that's why i made this topic. I get this:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg148.imageshack.us%2Fimg148%2F9000%2Fbattler1ai3.png&hash=38227e36ad95754662be0d90497f5eab8b4e0066)
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg386.imageshack.us%2Fimg386%2F8833%2Fbattler2wf8.png&hash=5ede4f4f75f860ff6abf72f604f447ca0fb2a13d)
Title: Re: How would I put a battler in my CMS?
Post by: Blizzard on March 14, 2007, 11:57:38 AM
  def draw_actor_battler(actor, x, y)
    if actor != nil and actor.battler_name != ""
      bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
      cw = bitmap.width
      ch = bitmap.height
      src_rect = Rect.new(0, 0, cw,ch)
      self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
    end
  end


You need to ADD THIS to Window_Base first. xD And it's "battler", not "battle".

Title: Re: How would I put a battler in my CMS?
Post by: Atracious on March 14, 2007, 02:34:18 PM
 :tpg: OMG IT WORKS! thank you Blizzard, Tsunokiette, and blazinhandle!