[VXAce] Yanfly Event Window and VLU Random Weapons Compatibility

jason1313

Villager
Member
Joined
Apr 22, 2021
Messages
22
Reaction score
2
First Language
English
Primarily Uses
RMVXA
Hello,

Would someone please assist me in making these two scripts compatible with each other?

Yanfly Event Window:

VLU Random Weapons:

The problem is, the prefixes do not appear on the bottom left hand (event window) whenever I obtain a random weapon/armor from say a chest.

Thanks for any help you can offer.
 

Roninator2

Gamer
Regular
Joined
May 22, 2016
Messages
5,226
Reaction score
1,557
First Language
English
Primarily Uses
RMVXA
I assume you are using the script calls to add weapons and armours?
e.g. add_weapon(1, 1)
If so then you just need to add the interpreter call to add the text after the item has been given its affix, prefix.
i.e. event_window_make_item_text(item, am)

Add in the code to the interpreter commands for vlue's script.
like so...
Ruby:
class Game_Interpreter
  def add_weapon(id, am)
    item = $game_party.add_weapon(id,am)
    popup(1,item.id,am) if USE_ITEM_POPUP
    event_window_make_item_text(item, am)
    item
  end
  def add_armor(id, am)
    item = $game_party.add_armor(id, am)
    popup(2,item.id,am) if USE_ITEM_POPUP
    event_window_make_item_text(item, am)
    item
  end
  def add_item(id, am)
    item = $game_party.add_item(id, am)
    popup(0,item.id,am) if USE_ITEM_POPUP
    event_window_make_item_text(item, am)
    item
  end
end

Or put this below both scripts and it covers picking up items by default as well.
Use it if you like it that way.
Ruby:
class Game_Interpreter
  def add_weapon(id, am)
    item = $game_party.add_weapon(id,am)
    popup(1,item.id,am) if USE_ITEM_POPUP
    event_window_make_item_text(item, am)
    item
  end
  def add_armor(id, am)
    item = $game_party.add_armor(id, am)
    popup(2,item.id,am) if USE_ITEM_POPUP
    event_window_make_item_text(item, am)
    item
  end
  def add_item(id, am)
    item = $game_party.add_item(id, am)
    popup(0,item.id,am) if USE_ITEM_POPUP
    event_window_make_item_text(item, am)
    item
  end
end
class Game_Interpreter
  def command_126
    value = operate_value(@params[1], @params[2], @params[3])
    item = add_item($data_items[@params[0]].id, value)
  end
  def command_127
    value = operate_value(@params[1], @params[2], @params[3])
    item = add_weapon($data_weapons[@params[0]].id, value)
  end
  def command_128
    value = operate_value(@params[1], @params[2], @params[3])
    item = add_armor($data_armors[@params[0]].id, value)
  end
end
 
Last edited:

jason1313

Villager
Member
Joined
Apr 22, 2021
Messages
22
Reaction score
2
First Language
English
Primarily Uses
RMVXA
Wow, thanks for the quick response @Roninator2 , that worked perfectly!

Would you be able to make Yanfly's Event Window and Hime's Item Rarity compatible as well?

I have a legendary weapon that has a purple name using Hime's Item Rarity, but whenever I pick it up from a chest, the Event Window displays it in the default white text.

Here's Hime's Item Rarity script:



Thanks for helping out a noob.
 

Roninator2

Gamer
Regular
Joined
May 22, 2016
Messages
5,226
Reaction score
1,557
First Language
English
Primarily Uses
RMVXA
That one is proving to be much harder.
This code works, but it will only show the last item received.
If I let it stack then it gives a lot of duplicate text. Can't understand what it is doing.
1638737687701.png
1638738106136.png
If you only gave one item every time (not an armour and a weapon in the same event, but just one of those), then it works for the first item but then looks like the picture after a second item is collected.
If there is another scripter that can make sense of what I was trying to do and tell me how to change it, that would be great.
Ruby:
class Window_EventWindow < Window_Selectable
  def draw_item(index)
    $game_temp.clear_event_window_data if $game_temp.event_window_data.nil?
    #### renamed item to text, since it is a string text
    text = $game_temp.event_window_data[index]
    return if text.nil?
    ########## additions
    rarity_colour = @item_colour != nil ? @item_colour : 0
    length = text.length
    item_length = @item_name.size
    pos1 = text.index(@item_name)
    pos1 = 0 if pos1.nil?
    pos2 = pos1 + item_length
    temp_text = text
    start = temp_text.slice(0..pos1-1)
    temp_text = text
    middle = temp_text.slice(pos1, item_length)
    temp_text = text
    final = temp_text.slice(pos2..-1)
    convert_escape_characters(start)
    ##### part of original code
    rect = item_rect(index)
    draw_background(rect)
    rect.x += 4
    rect.width -= 8
    #### changed draw text ex to draw text except the first 
    #### part because it uses escape codes and draws icons
    draw_text_ex(rect.x, rect.y, start)
    adjust_x = start.size * (Font.default_size / 2)
    change_color(rarity_colour)
    draw_text(rect.x + 100, rect.y, rect.width, rect.height, middle)
    change_color(normal_color)
    final_x = middle.size * (Font.default_size / 2) + 80
    draw_text(rect.x + final_x, rect.y, rect.width, rect.height, final)
    #### cleared data to prevent garbage text from showing up
    $game_temp.clear_event_window_data
  end
  # gather item name
  def r2_item_name(item)
    @item_name = item.name
  end
  # find item rarity color if exists
  def r2_item_colour_rarity(item)
    @item_colour = item.rarity_colour
  end
end
class Game_Interpreter
  alias r2_event_colour_make_item_text   event_window_make_item_text
  def event_window_make_item_text(item, value)
    return unless SceneManager.scene_is?(Scene_Map)
    return if Switch.hide_event_window
    # push item data to map scene before it is lost
    SceneManager.scene.r2_map_item_colour_rarity(item)
    r2_event_colour_make_item_text(item, value)
  end
end
class Scene_Map < Scene_Base
  # pass data to window
  def r2_map_item_colour_rarity(item)
    @event_window.r2_item_colour_rarity(item)
    @event_window.r2_item_name(item)
  end
end
This is the result with this script
1638737628074.png
 

Latest Threads

Latest Profile Posts

I have completed what is clearly the most important part of participating in the game jam: coming up with a name!
My shrink has me trying to limit 30 mins a day for each of my personal projects so I can have a healthier life. But lately the rpg making in particular has been hard to pull away from and I keep getting lost in it.
Everyone has a test project named like this...right?

1701263020760.png
Pardon my japanese but this is my honest reaction to yesterday's "tangent":
1701262223568.png
I know these are all simple things for experienced users, but working on this Game Jam I have officially learned how to:
  • Use my own title screen image
  • Use scrolling text
  • Fade in a picture
  • Use any image for the Face in a dialog box
Probably silly for many people, but observable progress for me!

Forum statistics

Threads
136,570
Messages
1,267,672
Members
180,253
Latest member
DIwii
Top