TRIHAN'S "MAKE ME A SCRIPT" TOPIC!

Posts

Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Oh well, can't win 'em all. :P I almost had it working but I was trying not to use notetags unless absolutely necessary.
author=Trihan
shiningriver: Basically I would do that by making sprite objects for all the on-screen elements, placing them where they need to be, and coding custom update methods for when you press arrow keys, esc, enter etc.

I'm not sure whether you're just looking for advice on implementing it yourself or just want someone to write it for you, but for what's essentially a complete menu system rewrite I would have to charge you if you wanted me to just make it for you.


The thing is, I have no idea on how to code in this language (I've coded programs before, but not on this language), so I have no idea how to call elements, draw, make necessary actions, etc... If you could teach me how to do so, then that would be awesome.
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
I finished kentona's request since fomar's didn't have the same-type thing and I didn't want to just build on his because I prefer writing my own scripts. ^_^ I'll be submitting the version without that addition too.
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Here's your map script Mr_Detective! (I've dropped the animated map name idea for now but will likely revisit it in the future)

#==============================================================================
# ** Window_MapName
#------------------------------------------------------------------------------
# This window displays the map name.
#==============================================================================

class Window_MapName < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, 92)
self.opacity = 0
self.contents_opacity = 0
@show_count = 0
refresh
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 232
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
unless $game_map.display_name.empty?
bmp = Cache.picture($game_map.display_name)
src_rect = Rect.new(0, 0, bmp.rect.width, bmp.rect.height)
self.contents.blt(0, 0, bmp, src_rect)
end
end
end

Just name your graphic the same as the "display name" box in map properties and it will show the image instead of displaying it as text.
author=Trihan
Feldschlacht: Not hard at all. Making custom windows is a piece of cake and you can show pretty much anything you want in them. Slotting new options into the menu takes seconds.

As for enemy AI, depends on how sophisticated you want to make it. If you can figure out the logic behind it, you can probably code it. I could quite easily do enemies that heal the most damaged ally, won't use a spell on a hero if they've used it before and it turned out said hero absorbed the spell's element etc.


Sounds awesome.

1. I can whip up the custom windows; as in, I can make a template of what I want the database to look like. Once I send you/show you that, would you be able to code out the rest so I can edit it as I please?

2. As far as the enemy AI, would it be alright if I took a day or two to hash out a small list of the behavior improvements I'd like and post back?
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
As long as it's not too extensive, I guess I could try to slot that in.
Could you put together a quick, simple and easy to use RTB script for VX that supports button remapping/joypad use or refurbish one of the already existing scripts to do so?
author=Trihan
Here's your map script Mr_Detective! (I've dropped the animated map name idea for now but will likely revisit it in the future)
Just name your graphic the same as the "display name" box in map properties and it will show the image instead of displaying it as text.


Thank you very much for putting the time and effort to do this. :D

The thing is, with your script, every map requires a picture, and that is really time consuming. I should have clarified that all the maps use the same background, and the name will be displayed through the editor. :(

Oh well, nice script, anyway. ;)
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
It shouldn't require every map to have a picture. It only applies if you've set a display name for the map.
author=Trihan
It only applies if you've set a display name for the map.


Yup, that's exactly the case.
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
I'm not sure what the problem is then.
author=Trihan
I'm not sure what the problem is then.


All the maps have a display name, and I want all of them to show the names, so I would need to have a bunch of background pictures. :)
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
...how else were you planning on doing it?
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
shiningriver, here's what I've been able to do so far with the resources you've provided:



Here's the code for it. Note that there are a few bandaid code additions dotted around to get positionings right.

#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
#  This command window appears on the menu screen.
#==============================================================================

class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Get Rectangle for Drawing Items
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = item_width
    rect.height = item_height
    rect.x = index % col_max * (item_width + spacing)
    rect.y = (index / col_max * item_height) + (index * 5)
    rect
  end
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(10, 94)
    self.opacity = 0
    select_last
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Get Number of Lines to Show
  #--------------------------------------------------------------------------
  def visible_line_number
    item_max + 1
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    draw_bgs
    add_main_commands
  end
  def draw_bgs
    for i in 0..5
      eval("@cmd_#{i}_sprite = Sprite.new")
      eval("@cmd_#{i}_sprite.bitmap = Cache.picture('MenuButton')")
      eval("@cmd_#{i}_sprite.y = 100 + (29 * i)")
    end
  end
  #--------------------------------------------------------------------------
  # * Add Main Commands to List
  #--------------------------------------------------------------------------
  def add_main_commands
    add_command("Items",    :item,    main_commands_enabled)
    add_command("Skill",    :skill,   main_commands_enabled)
    add_command("Party",    :party,   main_commands_enabled)
    add_command("Bunshin",  :bunshin, main_commands_enabled)
    add_command("Status",   :status,  main_commands_enabled)
    add_command("Config",   :config,  main_commands_enabled)    
  end
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Create Background
  #--------------------------------------------------------------------------
  def create_background
    @background_sprite = Sprite.new
    @background_sprite.bitmap = Cache.picture("BG")
    @top_sprite = Sprite.new
    @top_sprite.bitmap = Cache.picture("1")
  end
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_command_window
    create_gold_window
    #create_status_window
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_MenuCommand.new
    @command_window.set_handler(:item,    method(:command_item))
    @command_window.set_handler(:skill,   method(:command_personal))
    @command_window.set_handler(:party,   method(:command_party))
    @command_window.set_handler(:bunshin, method(:command_bunshin))
    @command_window.set_handler(:status,  method(:command_personal))
    @command_window.set_handler(:config,  method(:command_config))
  end
  #--------------------------------------------------------------------------
  # * Create Gold Window
  #--------------------------------------------------------------------------
  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = Graphics.height - (@gold_window.height + 24)
    @gold_window.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * [Skill] and [Status] Commands
  #--------------------------------------------------------------------------
  def command_personal
    @status_window.select_last
    @status_window.activate
    @status_window.set_handler(:ok,     method(:on_personal_ok))
    @status_window.set_handler(:cancel, method(:on_personal_cancel))
  end
  #--------------------------------------------------------------------------
  # * [Party] Command
  #--------------------------------------------------------------------------
  def command_party
    SceneManager.call(Scene_Party)
  end
  #--------------------------------------------------------------------------
  # * [Bunshin] Command
  #--------------------------------------------------------------------------
  def command_bunshin
    SceneManager.call(Scene_Bunshin)
  end
  #--------------------------------------------------------------------------
  # * [Config] Command
  #--------------------------------------------------------------------------
  def command_config
    SceneManager.call(Scene_Config)
  end
  #--------------------------------------------------------------------------
  # * [OK] Personal Command
  #--------------------------------------------------------------------------
  def on_personal_ok
    case @command_window.current_symbol
    when :skill
      SceneManager.call(Scene_Skill)
    when :status
      SceneManager.call(Scene_Status)
    end
  end
  #--------------------------------------------------------------------------
  # * [Cancel] Personal Command
  #--------------------------------------------------------------------------
  def on_personal_cancel
    @status_window.unselect
    @command_window.activate
  end
end
You.Are.Awesome.

I'll go and try figure out the stat menu on the right... :-)

I've noticed that the white rectangle is still there (Like the one on the picture... How do I remove it?
http://rpgmaker.net/users/shiningriver/locker/untitled.JPG
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
I set self.index to -1 so it wouldn't show to begin with but to remove it entirely you could just overload the update_cursor method so it shows your highlighted graphic and doesn't set a new rect for the cursor rectangle.
Okay, so after overloading the update_cursor, I removed the annoying white rectangle. Is it possible to replace the bg image of the item to another one instead of the annoying white rectangle? Is this going to be part of the update_cursor?
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Okay, I think I got it. I placed this code... (I know it's not that efficient, hehehe).
def update_cursor
    if @cursor_all
      cursor_rect.set(0, 0, contents.width, row_max * item_height)
      self.top_row = 0
    elsif @index < 0
      cursor_rect.empty
    else
      #ensure_cursor_visible
      #cursor_rect.set(item_rect(@index))
      cursor_rect.empty
      change_bg(@index)
    end
  end
  
  def change_bg(i)
    if i == 0
      @cmd_0_sprite.bitmap = Cache.picture('3')
      @cmd_1_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_2_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_3_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_4_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_5_sprite.bitmap = Cache.picture('MenuButton')
    elsif i == 1
      @cmd_0_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_1_sprite.bitmap = Cache.picture('3')
      @cmd_2_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_3_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_4_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_5_sprite.bitmap = Cache.picture('MenuButton')
    elsif i == 2
      @cmd_0_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_1_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_2_sprite.bitmap = Cache.picture('3')
      @cmd_3_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_4_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_5_sprite.bitmap = Cache.picture('MenuButton')
    elsif i == 3
      @cmd_0_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_1_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_2_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_3_sprite.bitmap = Cache.picture('3')
      @cmd_4_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_5_sprite.bitmap = Cache.picture('MenuButton')
    elsif i == 4
      @cmd_0_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_1_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_2_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_3_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_4_sprite.bitmap = Cache.picture('3')
      @cmd_5_sprite.bitmap = Cache.picture('MenuButton')
    elsif i == 5
      @cmd_0_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_1_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_2_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_3_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_4_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_5_sprite.bitmap = Cache.picture('3')
    else
      @cmd_0_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_1_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_2_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_3_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_4_sprite.bitmap = Cache.picture('MenuButton')
      @cmd_5_sprite.bitmap = Cache.picture('MenuButton')
    end
  end


I saw that the "create_status_window" is quoted out... and voila, it turns out that this is the right part of the screen. To edit this, I need to...
def create_status_window
   #some code here
end

Correct? Does it also follow that the parts inside it can be edited on this segment?
What object inside this code should I use to set height, width, dimensions, etc?
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
If you look at the way I coded the initial layout for you, you can get rid of all that case crap and have a dynamic for statement that loops through the numbers so you only need the bitmap-changing code once.

You are correct on both counts. The dimensions are set in the initialize method of Window_MenuStatus; by default the height is Graphics.height, and width is Graphics.width - 160. If you look at the creation of @status_window in Scene_Menu, the X coordinate is set to the width of the command window (so it fits in nicely however wide or narrow the command list is)