Victor's Materia System Issues

So I have a few problems with Victor's Materia System for VX Ace. I'll just list the biggest one first since it'll require a bit of help to get right:

When you use the materia menu, it lists all of the equipment you have on your character even if they are not capable of holding materia.

i37B7nc.png


A visual example of what I mean. The Identifier Sleeve has bits you can put materia in, but the Silver Headband does not yet it's still listed. Which is annoying, since it eats up valuable space in this tiny menu.

It is listing all the equipment slots of a character even if said equipment has no bits to equip materia, or even slots that have no equipment in them (i.e if I were to take the Silver Headband off the character, I would still be able to hover over the empty space)

2dsbcTs.png


(Like this.)

Is there possibly a way to make it so it only lists equipment that have materia slots, as opposed to all of the character's equip slots (empty or not?)
Difficult. I gave it a go and even when getting the screen to show nothing (no equipment) you could still cycle down as if there was equipment. might try again sometime.
But you gave me the idea to do the opposite for my game. Show the equipment slot name for each one - even empty ones. That was much easier to do.
Difficult. I gave it a go and even when getting the screen to show nothing (no equipment) you could still cycle down as if there was equipment. might try again sometime.
But you gave me the idea to do the opposite for my game. Show the equipment slot name for each one - even empty ones. That was much easier to do.

Can I see what you mean about the opposite? 🙂
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Materia Equipment Name       ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║   Write the Equipment slot name     ║    25 Mar 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Plug and Play                                            ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

class Window_MateriaEquip < Window_Selectable
  def refresh
    super
    create_contents
    self.opacity = 0
    draw_equipments(8 + base_x - slot_width)
    draw_materias(28 + base_x - slot_width)
    draw_equip_name(8 + base_x - slot_width)
  end
  def draw_equip_name(x)
    actor.equips.each_with_index do |item, i|
      draw_slot_name(item, x, y + 50 * i + 1, i)
    end
  end
  def draw_slot_name(item, x, y, index)
    change_color(normal_color)
    draw_text(x + 20, y, width, line_height, Vocab::etype(@actor.equip_slots[index]), 1)
  end
end

This is the best I can get.
I'm not able to get the scene to understand that the first one is slot 1 when it is displayed in slot 0.
(weapon cannot hold materia)
It doesn't seem to understand the equip index and just defaults to equip_slot index.
But this will only let you scroll through valid equipment.
If you have equipment without any slots you can't move.
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Materia Slot Select          ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║   Skip slots that do not have       ╠════════════════════╣
# ║   equipment able to use materia     ║    25 Mar 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Plug and Play                                            ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

class Window_MateriaEquip < Window_Selectable
  #--------------------------------------------------------------------------
  # * initialize
  #--------------------------------------------------------------------------
  def initialize
    @equip = 0
    super(window_x, 0, Graphics.width -  window_x, 128)
    @index = 0
    @indexing = []
    @pos = 0
  end
  #--------------------------------------------------------------------------
  # * current_item_enabled?
  #--------------------------------------------------------------------------
  def current_item_enabled?
    return false if @slots < 0
    index < actor.materia_slots[equip].size
  end
  #--------------------------------------------------------------------------
  # * actor
  #--------------------------------------------------------------------------
  def actor=(actor)
    @actor = actor
    @pos = 0
    @index = 0
    @slots = -1
    @indexing = []
    actor.equips.each_with_index do |item, i|
      next if item.nil?
      equip = @actor.equips[i]
      next if equip.double_slots == 0 && equip.single_slots == 0
      @slots += 1
      @indexing << i
    end
    refresh
    self.equip = @indexing[@pos]
  end
  #--------------------------------------------------------------------------
  # * update_cursor
  #--------------------------------------------------------------------------
  def update_cursor
    ensure_cursor_visible
    return if @equip.nil?
    cursor_rect.set(item_rect(@index, @equip))
  end
  #--------------------------------------------------------------------------
  # * cursor_down
  #--------------------------------------------------------------------------
  def cursor_down(wrap = false)
    return if @slots == 0
    @pos += 1
    @pos = 0 if @pos > @slots
    self.equip = @pos
    self.equip = @indexing[@pos]
  end
  #--------------------------------------------------------------------------
  # * cursor_up
  #--------------------------------------------------------------------------
  def cursor_up(wrap = false)
    return if @slots == 0
    @pos -= 1
    @pos = @slots if @pos < 0
    self.equip = @indexing[@pos]
  end
end
Ruby:
class Window_MateriaEquip < Window_Selectable
  def refresh
    super
    create_contents
    self.opacity = 0
    draw_equipments(8 + base_x - slot_width)
    draw_materias(28 + base_x - slot_width)
    draw_equip_name(8 + base_x - slot_width)
  end
  def draw_equip_name(x)
    actor.equips.each_with_index do |item, i|
      draw_slot_name(item, x, y + 50 * i + 1, i)
    end
  end
  def draw_slot_name(item, x, y, index)
    change_color(normal_color)
    draw_text(x + 20, y, width, line_height, Vocab::etype(@actor.equip_slots[index]), 1)
  end
end

This is the best I can get.
I'm not able to get the scene to understand that the first one is slot 1 when it is displayed in slot 0.
(weapon cannot hold materia)
It doesn't seem to understand the equip index and just defaults to equip_slot index.
But this will only let you scroll through valid equipment.
If you have equipment without any slots you can't move.
Ruby:
#==============================================================================
# ** Window_MateriaEquip
#------------------------------------------------------------------------------
#  This window shows the actor equipe materia. Do not show the window frame.
#==============================================================================

class Window_MateriaEquip < Window_Selectable
  #--------------------------------------------------------------------------
  # * initialize
  #--------------------------------------------------------------------------
  def initialize
    @equip = 0
    super(window_x, 0, Graphics.width -  window_x, 128)
    @index = 0
    @indexing = []
    @pos = 0
  end
  #--------------------------------------------------------------------------
  # * actor
  #--------------------------------------------------------------------------
  def actor=(actor)
    @actor = actor
    @pos = 0
    @index = 0
    @slots = -1
    @indexing = []
    actor.equips.each_with_index do |item, i|
      next if item.nil?
      equip = @actor.equips[i]
      next if equip.double_slots == 0 && equip.single_slots == 0
      @slots += 1
      @indexing << i
    end
    refresh
    self.equip = @indexing[@pos]
  end
  #--------------------------------------------------------------------------
  # * update_cursor
  #--------------------------------------------------------------------------
  def update_cursor
    ensure_cursor_visible
    return if @equip.nil?
    cursor_rect.set(item_rect(@index, @equip))
  end
  #--------------------------------------------------------------------------
  # * cursor_down
  #--------------------------------------------------------------------------
  def cursor_down(wrap = false)
    return if @slots == 0
    @pos += 1
    @pos = 0 if @pos > @slots
    self.equip = @pos
    self.equip = @indexing[@pos]
  end
  #--------------------------------------------------------------------------
  # * cursor_up
  #--------------------------------------------------------------------------
  def cursor_up(wrap = false)
    return if @slots == 0
    @pos -= 1
    @pos = @slots if @pos < 0
    self.equip = @indexing[@pos]
  end
end

Wow those are both extremely cool scripts. I'm willing to overlook that it doesn't stop showing the other ineligible equipment because since this is far more convenient. 🙏

But there is one small issue:

xecIC3E.png


When I go to a character that doesn't have any equipment with materia slots and click confirm, this happens.
Updated
So I consider that enough of a fix to consider my original problem solved.

But now here's my second issue: How do you use materias in script calls?

When I try to use the "player has [x] armor (aka. what materia are counted as)" conditional branches, the game acts like they don't exist even if you have obtained them. So it leads me to believe that materias have their own script call, since I learned how to manipulate how much AP they can gain via script call on my own a while back.
Short answer - its $game_actor[id].materia_slots
but that is a hash copy of the equipment for the materia slots so you'll need to do some code to break it down.
Ruby:
$game_actors[1].materia_slots.each do |equip|
next if equip[1].empty?
equip[1].each do |item|
next if item.nil?
$game_switches[1] = true if item.id == 70
end
end
Here I check for actor 1 materia slots
check for each equipment slot
next if empty (checks array position 1 has the hash is like this - {0 -> [], 1 -> [materia, nil, nil], etc}
check for all materia slots in the item
next if no materia equipped in the slot (nil)
turn switch on if the materia id equals the armor id (70 - materia)
end
end

then do a conditional branch check for the switch on.

If you want to do that for all actors at once, that can also be done and you can even count the number of the same materia equipped. But I suppose that is kind of useless as like you asked, normally you would check for a specific actor having it equipped.

As for your actual question. There is only one focused script call for the materias -> call_materia_shop
It has a few variations, but other than that if you want a simple script call for the code above that can be added.

Ruby:
class Game_Interpreter
  def actor_materia(id, mid, sid)
    $game_actors[id].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_switches[sid] = true if item.id == mid
      end
    end
  end
  def count_actor_materia(id, mid, vid)
    $game_variables[vid] = 0
    $game_actors[id].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_variables[vid] += 1 if item.id == mid
      end
    end
  end
end

then you just need the script call actor_materia(1, 70, 1) # actor 1, materia 70, switch 1
Short answer - its $game_actor[id].materia_slots
but that is a hash copy of the equipment for the materia slots so you'll need to do some code to break it down.
Ruby:
$game_actors[1].materia_slots.each do |equip|
next if equip[1].empty?
equip[1].each do |item|
next if item.nil?
$game_switches[1] = true if item.id == 70
end
end
Here I check for actor 1 materia slots
check for each equipment slot
next if empty (checks array position 1 has the hash is like this - {0 -> [], 1 -> [materia, nil, nil], etc}
check for all materia slots in the item
next if no materia equipped in the slot (nil)
turn switch on if the materia id equals the armor id (70 - materia)
end
end

then do a conditional branch check for the switch on.

If you want to do that for all actors at once, that can also be done and you can even count the number of the same materia equipped. But I suppose that is kind of useless as like you asked, normally you would check for a specific actor having it equipped.

As for your actual question. There is only one focused script call for the materias -> call_materia_shop
It has a few variations, but other than that if you want a simple script call for the code above that can be added.

Ruby:
class Game_Interpreter
  def actor_materia(id, mid, sid)
    $game_actors[id].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_switches[sid] = true if item.id == mid
      end
    end
  end
  def count_actor_materia(id, mid, vid)
    $game_variables[vid] = 0
    $game_actors[id].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_variables[vid] += 1 if item.id == mid
      end
    end
  end
end

then you just need the script call actor_materia(1, 70, 1) # actor 1, materia 70, switch 1

Interesting! But uh. How... do you use it?

I copied that second bit of code and then made a script call, but for some odd reason it didn't... seem to do anything.

My assumption: Materia A is equipped onto Actor 1, so it says message "[x] is equipped" through a conditional branch. When Materia A is removed from Actor 1, it says "[x] is no longer equipped".

However, it always says the equipped message even if I don't have that materia at all. 😅
How are you doing the event?
You don't use the script call in a conditional branch, you use the switch you specified.
so you do the script call in a script command, then conditional branch check on the switch.
to have it directly return true in a conditional branch script call, I would need to change it a bit.

actor_materia_equipped(actor_id, Materia_id) <- returns true if materia is equipped
Ruby:
class Game_Interpreter
  def actor_materia(id, mid, sid)
    $game_actors[id].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_switches[sid] = true if item.id == mid
      end
    end
  end
  def actor_materia_equipped(id, mid)
    $game_actors[id].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        return true if item.id == mid
      end
    end
  end
  def count_actor_materia(id, mid, vid)
    $game_variables[vid] = 0
    $game_actors[id].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_variables[vid] += 1 if item.id == mid
      end
    end
  end
end
How are you doing the event?
You don't use the script call in a conditional branch, you use the switch you specified.
so you do the script call in a script command, then conditional branch check on the switch.
to have it directly return true in a conditional branch script call, I would need to change it a bit.

MIKoJGj.png
@RCXDan
you posted just as I updated.
check above

updated version
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Materia Script calls         ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║   Use script calls to check for     ╠════════════════════╣
# ║   equipped materia                  ║    26 Mar 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   5 script calls provided                                ║
# ║     1. actor_materia_(aid, mid, sid)                     ║
# ║        (actor id, materia id, switch id)                 ║
# ║        will turn switch on if materia is equipped        ║
# ║     2. actor_materia_equipped(aid, mid)                  ║
# ║         (actor id, materia id)                           ║
# ║        returns true if materia equipped                  ║
# ║        to be used in conditional branch script call      ║
# ║     3. count_actor_materia(aid, mid, vid)                ║
# ║        (actor id, materia id, variable id)               ║
# ║        counts how many times the actor has the           ║
# ║        materia equipped and add 1 to the variable        ║
# ║        for each one.                                     ║
# ║     4. count_party_materia(mid, vid)                     ║
# ║        (materia id, variable id)                         ║
# ║        counts how many times the party has the           ║
# ║        materia equipped and adds 1 to the variable       ║
# ║        for each one                                      ║
# ║     5. count_all_party_materia(mid, vid)                 ║
# ║        (materia id, variable id)                         ║
# ║        counts how many times the party has the           ║
# ║        materia and adds 1 to the variable                ║
# ║        for each one, equipped and in inventory           ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝
  
class Game_Interpreter
  def actor_materia(aid, mid, sid)
    $game_actors[aid].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_switches[sid] = true if item.id == mid
      end
    end
  end
  def actor_materia_equipped(aid, mid)
    $game_actors[aid].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        return true if item.id == mid
      end
    end
  end
  def count_actor_materia(aid, mid, vid)
    $game_variables[vid] = 0
    $game_actors[aid].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_variables[vid] += 1 if item.id == mid
      end
    end
  end
  def count_party_materia(mid, vid)
    $game_variables[vid] = 0
    $game_party.members.each do |actor|
      actor.materia_slots.each do |equip|
        next if equip[1].empty?
        equip[1].each do |item|
          next if item.nil?
          $game_variables[vid] += 1 if item.id == mid
        end
      end
    end
  end
  def count_all_party_materia(mid, vid)
    $game_variables[vid] = 0
    $game_party.members.each do |actor|
      actor.materia_slots.each do |equip|
        next if equip[1].empty?
        equip[1].each do |item|
          next if item.nil?
          $game_variables[vid] += 1 if item.id == mid
        end
      end
    end
    $game_party.materias.each do |mat|
      $game_variables[vid] += 1 if mat.id == mid
    end
  end
end
@RCXDan
you posted just as I updated.
check above

updated version
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Materia Script calls         ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║   Use script calls to check for     ╠════════════════════╣
# ║   equipped materia                  ║    26 Mar 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   4 script calls provided                                ║
# ║     1. actor_materia_(aid, mid, sid)                     ║
# ║        (actor id, materia id, switch id)                 ║
# ║        will turn switch on if materia is equipped        ║
# ║     2. actor_materia_equipped(aid, mid)                  ║
# ║         (actor id, materia id)                           ║
# ║        returns true if materia equipped                  ║
# ║        to be used in conditional branch script call      ║
# ║     3. count_actor_materia(aid, mid, vid)                ║
# ║        (actor id, materia id, variable id)               ║
# ║        counts how many times the actor has the           ║
# ║        materia equipped and add 1 to the variable        ║
# ║        for each one.                                     ║
# ║     4. count_party_materia(mid, vid)                     ║
# ║        (materia id, variable id)                         ║
# ║        counts how many times the party has the           ║
# ║        materia equipped and adds 1 to the variable       ║
# ║        for each one                                      ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝
 
class Game_Interpreter
  def actor_materia(aid, mid, sid)
    $game_actors[aid].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_switches[sid] = true if item.id == mid
      end
    end
  end
  def actor_materia_equipped(aid, mid)
    $game_actors[aid].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        return true if item.id == mid
      end
    end
  end
  def count_actor_materia(aid, mid, vid)
    $game_variables[vid] = 0
    $game_actors[aid].materia_slots.each do |equip|
      next if equip[1].empty?
      equip[1].each do |item|
        next if item.nil?
        $game_variables[vid] += 1 if item.id == mid
      end
    end
  end
  def count_party_materia(mid, vid)
    $game_variables[vid] = 0
    $game_party.members.each do |actor|
      actor.materia_slots.each do |equip|
        next if equip[1].empty?
        equip[1].each do |item|
          next if item.nil?
          $game_variables[vid] += 1 if item.id == mid
        end
      end
    end
  end
end

Very useful. I can imagine myself using these for parallel processing purposes on the map.

However, I do have one last favor to ask: A script call to check if party has [x] materia in their inventory, regardless if it's equipped or not? Because I have plans for an event-based shop where you have to trade in "bad" materia to get them fixed.
updated

It counts all the materia you own, unfortunately.

(In my testing, I had 4 total materia and only 2 copies of Materia A. It counted the total instead.)
That's what you asked for. unless you mean only the actors in the party that have the materia equipped. which is #4. #5 is all.
Or is it only for inventory and not equipped?
That is something built in, just not a script call, but you can use
$game_party.materias.size

Oh I think I see. #5 counted all materia not just the specific one you're looking for.
right, silly mistake. give me a minute.

*updated
That's what you asked for. unless you mean only the actors in the party that have the materia equipped. which is #4. #5 is all.
Or is it only for inventory and not equipped?
That is something built in, just not a script call, but you can use
$game_party.materias.size

Oh I think I see. #5 counted all materia not just the specific one you're looking for.
right, silly mistake. give me a minute.

*updated

Wow, it works! I think that's all of my problems with this script solved.

That said, I'll leave the topic open for the future just in case I find new problems down the line.

Original thread: https://forums.rpgmakerweb.com/threads/victors-materia-system-issues.146106/