Joined
Jan 25, 2022
Messages
77
Reaction score
65
First Language
English
Primarily Uses
RMVXA
I'm trying to make my battle system resemble the original Final Fantasy on the NES. As you can see here, the enemies are positioned on a grid. I'm trying to emulate this look, however it's not as easy in the RMVXA troops tab.troops3.png

To begin with, the grid that RM uses is bigger than the grid I've drawn on the test battleback to help me position them properly. When I move the battlers around the movement isn't as precise as I'd like in order to position them where I want them.

troops1.PNG

What's more is that when running the actual battle, the dimensions of the troops screen doesn't line up with the actual dimensions of the battle:
troops2.png

I am using a script that changes the resolution to 640x416 (Yanfly's Ace Core Engine), so it seems that's why it doesn't conform with the troops menu. However, even if I do account for that, it doesn't change that I still can't fit them into the grid I'm going for.

TL;DR - I'm ideally looking for a script that can allow me to specify an enemy battler's position with coordinates rather than using the troops tab in the DB.
 

AkiraKotatsuhime

炬燵姫
Veteran
Joined
Jan 2, 2013
Messages
285
Reaction score
200
First Language
DE / ドイツ語
Primarily Uses
N/A
You can hold ALT while moving an enemy-graphic around in the troops-tab for mor precision, but since your grid is very odd and the area scaled-down, I guess this won't help much. Also, RPG Makers usually disable the ADD-button for troop-enemies when you have 8 of them placed, so 15 like seen on the grid-template never can appear in battle using this data.

Let's try this little piece of code I stacked together to auto-line-up enemies based on their member-ID in troop. Under class constants, there are some values you need to adjust first (especially the base-position's rectangle), their functions are explained in the header. I made the default configuration to place three enemies from top to down and then continue with next column to the right.

Ruby:
#==============================================================================
# ** Apply fixed Grid to Enemies of Troop (Ace)
#------------------------------------------------------------------------------
#  © 2022 Akira Kotatsuhime / KotatsuAkira
#  Do not redistribute without this copyright-notice intact.
#------------------------------------------------------------------------------
#  GRID_BASE: Grid's X, Y, width and height of where first enemy is placed.
#  GRID_FROMRIGHT: Make enemies line-up to the left when set to true.
#  GRID_FROMBOTTOM: Begin line-up at the bottom when set to true.
#  GRID_VERTICAL: Priorize line-up on Y before X when set to true.
#  GRID_COLUMNS: Number of columns per line (or lines per column if vertical).
#==============================================================================

class Game_Troop < Game_Unit
  #--------------------------------------------------------------------------
  # * Class Constants
  #--------------------------------------------------------------------------
  GRID_BASE = Rect.new(0, 0, 0, 0)
  GRID_FROMRIGHT = false
  GRID_FROMBOTTOM = false
  GRID_VERTICAL = true
  GRID_COLUMNS = 3
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(st)
    clear
    @troop_id = st
    @enemies = []
    troop.members.each_with_index do |sm, si|
      next unless $data_enemies[sm.enemy_id]
      se = Game_Enemy.new(@enemies.size, sm.enemy_id)
      se.hide if sm.hidden
      sa = (si / GRID_COLUMNS)
      sb = (si % GRID_COLUMNS)
      sc = GRID_FROMRIGHT ? -1 : 1
      sd = GRID_FROMBOTTOM ? -1 : 1
      if GRID_VERTICAL
        se.screen_x = GRID_BASE.x + (GRID_BASE.width * sa * sc)
        se.screen_y = GRID_BASE.y + (GRID_BASE.height * sb * sd)
      else
        se.screen_x = GRID_BASE.x + (GRID_BASE.width * sb * sc)
        se.screen_y = GRID_BASE.y + (GRID_BASE.height * sa * sd)
      end
      @enemies.push(se)
    end
    init_screen_tone
    make_unique_names
  end
end

~炬燵あ
 
Last edited:
Joined
Jan 25, 2022
Messages
77
Reaction score
65
First Language
English
Primarily Uses
RMVXA
You can hold ALT while moving an enemy-graphic around in the troops-tab for mor precision, but since your grid is very odd and the area scaled-down, I guess this won't help much. Also, RPG Makers usually disable the ADD-button for troop-enemies when you have 8 of them placed, so 15 like seen on the grid-template never can appear in battle using this data.

Let's try this little piece of code I stacked together to auto-line-up enemies based on their member-ID in troop. Under class constants, there are some values you need to adjust first (especially the base-position's rectangle), their functions are explained in the header. I made the default configuration to place three enemies from top to down and then continue with next column to the right.

Ruby:
#==============================================================================
# ** Apply fixed Grid to Enemies of Troop (Ace)
#------------------------------------------------------------------------------
#  © 2022 Akira Kotatsuhime / KotatsuAkira
#  Do not redistribute without this copyright-notice intact.
#------------------------------------------------------------------------------
#  GRID_BASE: Grid's X, Y, width and height of where first enemy is placed.
#  GRID_FROMRIGHT: Make enemies line-up to the left when set to true.
#  GRID_VERTICAL: Priorize line-up on Y before X when set to true.
#  GRID_COLUMNS: Number of columns per line (or lines per column if vertical).
#==============================================================================

class Game_Troop < Game_Unit
  #--------------------------------------------------------------------------
  # ** Class Constants
  #--------------------------------------------------------------------------
  GRID_BASE = Rect.new(0, 0, 0, 0)
  GRID_FROMRIGHT = false
  GRID_VERTICAL = true
  GRID_COLUMNS = 3
  #--------------------------------------------------------------------------
  # ** Setup
  #--------------------------------------------------------------------------
  def setup(st)
    clear
    @troop_id = st
    @enemies = []
    troop.members.each_with_index do |sm, si|
      next unless $data_enemies[sm.enemy_id]
      se = Game_Enemy.new(@enemies.size, sm.enemy_id)
      se.hide if sm.hidden
      sa = (si / GRID_COLUMNS) * GRID_FROMRIGHT ? -1 : 1
      sb = (si % GRID_COLUMNS) * GRID_FROMRIGHT ? -1 : 1
      if GRID_VERTICAL
        se.screen_x = GRID_BASE.x + (GRID_BASE.width * sa)
        se.screen_y = GRID_BASE.y + (GRID_BASE.height * sb)
      else
        se.screen_x = GRID_BASE.x + (GRID_BASE.width * sb)
        se.screen_y = GRID_BASE.y + (GRID_BASE.height * sa)
      end
      @enemies.push(se)
    end
    init_screen_tone
    make_unique_names
  end
end

~炬燵あ
Oh wow, I never knew that holding Alt lets you do that.

And the extra spaces on the grid was to account for a wider area in which to place enemies, in case I wanted to space them out for specific encounters or something, especially in cases where the sprites are bigger than 64x64, which is the smallest standard sprite size I'm using for enemies.

And thank you so much for the script! I'll give it a whirl in a bit when I get home.
 

AkiraKotatsuhime

炬燵姫
Veteran
Joined
Jan 2, 2013
Messages
285
Reaction score
200
First Language
DE / ドイツ語
Primarily Uses
N/A
Added some little adjustments to the code, fixed a mistake which accidentally could make the Y-order depend on the setting for from-right, now it uses a new setting for from-bottom.

~炬燵あ
 
Joined
Jan 25, 2022
Messages
77
Reaction score
65
First Language
English
Primarily Uses
RMVXA
Added some little adjustments to the code, fixed a mistake which accidentally could make the Y-order depend on the setting for from-right, now it uses a new setting for from-bottom.

~炬燵あ
Oh thank you. Sorry to leave you hanging, had something come up and I wasn't able to sit down with RM until now.

Edit: This works really well! Thank you so much.
 
Last edited:

Latest Threads

Latest Profile Posts

Is there an item disassemble plugin for MZ?
Working on... stuff. :3
1685464160206.png
Grading the last exams for this semester and I need a break because I am laughing too hard xD
edit: Video link removed due to well Internet problems making it essentially nothing anyway. :kaoswt:
Sleep logic:
4 hours or less = I feel like I'm dying
5-6 hours: Feeling well rested
More than 6 hours: I feel like I'm dying

Forum statistics

Threads
131,543
Messages
1,220,704
Members
173,220
Latest member
ZecaVn
Top