"Item recieved" message script

Started by zephrael, June 02, 2013, 05:02:01 pm

Previous topic - Next topic

zephrael

Evening all,

In my game, whenever an item is received, a message is displayed on a special windowskin, semi-transparent, across the middle of the screen, saying "You got 3 whatevers, 2 somethings and some whatchamacallit!" alongside the items' icons, like so:
Spoiler: ShowHide

However, I'm using the Hermes message system, which allows me to have 'asynchronised' messages running simultaneously (As in more than one at once, and the player can still move while the messages show), like so:
Spoiler: ShowHide

BUT because I change the windowskin to a special one for the item messages, if an item is received at the same time as one of these asynchronised messages, that message gets the item windowskin and looks wrong, like so (look at the top-right!):
Spoiler: ShowHide

I know very little about scripting, but I assume that something like this, that generates a message in the middle on a special windowskin and uses the icons etc like in my screenshot, would be quite simple to script. Does anybody know of a similar system, or would anybody be kind enough to whip something up - if it's as easy as I guess?

Zexion

Mog actually already made one.
http://www.atelier-rgss.com/
RGSS section.

You'll need to modify a few lines here and there, but it's basically what you want.

KK20

I would have suggested making a picture that looks like your windowskin and just use the Show Picture command.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

exile360

June 03, 2013, 07:22:11 am #3 Last Edit: June 03, 2013, 07:26:52 am by exile360
Actually, I am using the MOG one myself and love it, but it has a very annoying bug. Namely, when the item is DECREASED, the message still shows up. Manually disabling it with switches doesn't help, unless they're on a separate event, which is not very useful. Not sure why, I guess the switch or script doesn't update until the event processing is done? Anyway, it should either show nothing at all upon removing an item, or a different picture (item decreased or something) and different SE (to make it more recognizable). If someone could take a look, it'd be greatly appreciated, and also help the OP if he decides to use it. Thanks! :)

zephrael

June 04, 2013, 06:30:23 am #4 Last Edit: June 04, 2013, 06:39:32 am by zephrael
Yeah, this script is useful, but I've noticed that error too :/ Also, there's very little instruction in this script, so would anybody be able to take a look and suggest to me what to change to make the "(number)X" text in line and the same size as the displayed item name?

EDIT: With a bit of tinkering, I managed to align the text properly. But I'd also possibly like it if somebody could alter the script to allow the message to be shown when the player recieves gold as well, and possibly play a different sound in this instance?

exile360

Giving this a little bump. Could anyone please take a look at the bugs we described in the MOG script?

KK20

#_________________________________________________
# MOG_Treasure_Name V1.7           
#_________________________________________________
# By Moghunter
# http://www.atelier-rgss.com
#_________________________________________________
module MOG
  #Font Name.
  MPFONT = "Georgia"
  #Fade ON/OFF (True - False).
  MPITFD = true
  #Fade Time.
  MPITTM = 7
  #Window Position.
  # 0 = Upper.
  # 1 = Left.
  # 2 = Right.
  # 3 = Lower.
  MPITPS = 0
  # Disable Window Switch.
  MPITVIS = 5
  # SE played when item gain and item loss
  MPITSE = "056-Right02"
  MPITSE2 = "014-Move02"
end

#===============================================================================
# Game_Temp
#===============================================================================
class Game_Temp
  attr_accessor :fdittm
  attr_accessor :mpit_x
  attr_accessor :mpit_y
  attr_accessor :it_id
  attr_accessor :item_typ
  attr_accessor :item_qua
  #--------------------------------------------------------------------------
  # Update Status
  #--------------------------------------------------------------------------
  alias mog25_initialize initialize
  def initialize
    mog25_initialize
    @fdittm = 0
    @it_id = 1
    @wp_id = 1
    @ar_id = 1
    @item_typ = 0
    @mpit_x = 0
    @mpit_y = 0
    @item_qua = 1
  end
end

#===============================================================================
# Interpreter
#===============================================================================
class Interpreter
  #--------------------------------------------------------------------------
  # Update Status
  #-------------------------------------------------------------------------- 
  alias mog25_command126 command_126
  def command_126
    mog25_command126
    return if $game_switches[MOG::MPITVIS]
    $game_temp.item_typ = 1
    $game_temp.fdittm = 255 + 40 * MOG::MPITTM
    $game_temp.it_id = @parameters[0]
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    $game_temp.item_qua = value
    if value > 0
      Audio.se_play("Audio/SE/" + MOG::MPITSE, 100,100) rescue nil
    else
      Audio.se_play("Audio/SE/" + MOG::MPITSE2, 100,100) rescue nil
    end
    $ref = true
  end
  #--------------------------------------------------------------------------
  # command_127
  #-------------------------------------------------------------------------- 
  alias mog25_command127 command_127
  def command_127
    mog25_command127
    return if $game_switches[MOG::MPITVIS]
    $game_temp.item_typ = 2
    $game_temp.fdittm = 255 + 40 * MOG::MPITTM
    $game_temp.it_id = @parameters[0]
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    $game_temp.item_qua = value
    if value > 0
      Audio.se_play("Audio/SE/" + MOG::MPITSE, 100,100) rescue nil
    else
      Audio.se_play("Audio/SE/" + MOG::MPITSE2, 100,100) rescue nil
    end
    $ref = true
  end
  #--------------------------------------------------------------------------
  # command_128
  #-------------------------------------------------------------------------- 
  alias mog25_command128 command_128
  def command_128
    mog25_command128
    return if $game_switches[MOG::MPITVIS]
    $game_temp.item_typ = 3
    $game_temp.fdittm = 255 + 40 * MOG::MPITTM
    $game_temp.it_id = @parameters[0]
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    $game_temp.item_qua = value
    if value > 0
      Audio.se_play("Audio/SE/" + MOG::MPITSE, 100,100) rescue nil
    else
      Audio.se_play("Audio/SE/" + MOG::MPITSE2, 100,100) rescue nil
    end
    $ref = true
  end
  #--------------------------------------------------------------------------
  # * Change Gold
  #--------------------------------------------------------------------------
  alias mog25_command125 command_125
  def command_125
    mog25_command125
    return if $game_switches[MOG::MPITVIS]
    $game_temp.item_typ = 4
    $game_temp.fdittm = 255 + 40 * MOG::MPITTM
    value = operate_value(@parameters[0], @parameters[1], @parameters[2])
    $game_temp.item_qua = value
    if value > 0
      Audio.se_play("Audio/SE/" + MOG::MPITSE, 100,100) rescue nil
    else
      Audio.se_play("Audio/SE/" + MOG::MPITSE2, 100,100) rescue nil
    end
    $ref = true
  end
end 

#===============================================================================
# Game_Map
#===============================================================================
class Game_Map
  attr_reader   :map_id 
  #--------------------------------------------------------------------------
  # mpitnm
  #--------------------------------------------------------------------------   
  def mpitnm
    $mpitnm = load_data("Data/Items.rxdata")
    $mpitnm[$game_temp.it_id].name
  end
  #--------------------------------------------------------------------------
  # mpwpnm
  #--------------------------------------------------------------------------   
  def mpwpnm
    $mpwpnm = load_data("Data/Weapons.rxdata")
    $mpwpnm[$game_temp.it_id].name
  end
  #--------------------------------------------------------------------------
  # mparnm
  #--------------------------------------------------------------------------   
  def mparnm
    $mparnm = load_data("Data/Armors.rxdata")
    $mparnm[$game_temp.it_id].name
  end
end

#===============================================================================
# Window_Base
#===============================================================================
class Window_Base < Window
  #--------------------------------------------------------------------------
  # draw_mpitem
  #--------------------------------------------------------------------------   
  def draw_mpitem(x,y)
    if $game_temp.item_qua > 0
      mapic = RPG::Cache.picture("Itname") rescue RPG::Cache.picture("")
    else
      mapic = RPG::Cache.picture("Itname2") rescue RPG::Cache.picture("")
    end
    cw = mapic.width 
    ch = mapic.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x , y - ch + 65, mapic, src_rect)
    self.contents.font.name = MOG::MPFONT
    self.contents.font.size = 22
    self.contents.font.color = Color.new(0,0,0,255)
    self.contents.draw_text(x - 19, y + 19, 110, 32, $game_temp.item_qua.to_s + "X",1)
    case $game_temp.item_typ
    when 1 #==========================================
    self.contents.draw_text(x + 80, y + 29, 110, 32, $game_map.mpitnm,1)
    self.contents.font.color = Color.new(255,255,255,255)
    self.contents.draw_text(x + 81, y + 30, 110, 32, $game_map.mpitnm,1)
    self.contents.draw_text(x - 20, y + 18, 110, 32, $game_temp.item_qua.to_s + "X",1)
    icon_name = $data_items[$game_temp.it_id].icon_name
    when 2 #==========================================
    self.contents.draw_text(x + 80, y + 30, 110, 32, $game_map.mpwpnm,1)
    self.contents.font.color = Color.new(255,255,255,255)
    self.contents.draw_text(x + 81, y + 29, 110, 32, $game_map.mpwpnm,1)
    self.contents.draw_text(x - 20, y + 18, 110, 32, $game_temp.item_qua.to_s + "X",1)
    icon_name = $data_weapons[$game_temp.it_id].icon_name
    when 3 #==========================================
    self.contents.draw_text(x + 80, y + 30, 110, 32, $game_map.mparnm,1)
    self.contents.font.color = Color.new(255,255,255,255)
    self.contents.draw_text(x + 81, y + 29, 110, 32, $game_map.mparnm,1)
    self.contents.draw_text(x - 20, y + 18, 110, 32, $game_temp.item_qua.to_s + "X",1)
    icon_name = $data_armors[$game_temp.it_id].icon_name
    when 4
    self.contents.draw_text(x + 80, y + 30, 110, 32, $data_system.words.gold,1)
    self.contents.font.color = Color.new(255,255,255,255)
    self.contents.draw_text(x + 81, y + 29, 110, 32, $data_system.words.gold,1)
    self.contents.draw_text(x - 20, y + 18, 110, 32, $game_temp.item_qua.to_s + "X",1)
    return
    end
    icon_pic = RPG::Cache.icon(icon_name.to_s)
    self.contents.blt(x + 55, y + 34, icon_pic, Rect.new(0, 0, 24, 24), 255)
  end
end

#===============================================================================
# Mpitem
#===============================================================================
class Mpitem < Window_Base
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------     
  def initialize
    super($game_temp.mpit_x, $game_temp.mpit_y, 250, 100)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------       
  def refresh
    self.contents.clear
    draw_mpitem(10,0) 
  end
end

#===============================================================================
# Scene_Map
#===============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # main
  #--------------------------------------------------------------------------       
  alias mog25_main main
  def main
    @mpit =  Mpitem.new
    if  $game_switches[MOG::MPITVIS] == true
      @mpit.visible = false
    else
      @mpit.visible = true
    end
    @mpit.contents_opacity = $game_temp.fdittm
    mog25_main
    @mpit.dispose
  end
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------       
  alias mog25_update update
  def update
  mog25_update
  if $ref == true
    @mpit.refresh
    if MOG::MPITPS == 0
      @mpit.x = 200
      @mpit.y = -150
    elsif MOG::MPITPS == 1
      @mpit.x = -240
      @mpit.y = 200 
    elsif MOG::MPITPS == 2
      @mpit.x = 640
      @mpit.y = 200 
    else
      @mpit.x = 200
      @mpit.y = 480   
    end 
    $ref = false
  end
  if $game_switches[MOG::MPITVIS] == true or $game_temp.fdittm <= 0
    @mpit.visible = false
  else
    @mpit.visible = true 
  end
  $game_temp.mpit_x = @mpit.x
  $game_temp.mpit_y = @mpit.y
  if MOG::MPITPS == 0
    if @mpit.y < 0
      @mpit.y += 8
    elsif @mpit.x >= 0
      @mpit.y = 0
    end   
  elsif MOG::MPITPS == 1
    if @mpit.x < 0
      @mpit.x += 10
    elsif @mpit.x >= 0
      @mpit.x = 0
    end
  elsif MOG::MPITPS == 2
    if @mpit.x > 400
      @mpit.x -= 10
    elsif @mpit.x >= 400
      @mpit.x = 400
    end 
  else
    if @mpit.y > 380
      @mpit.y -= 8
    elsif @mpit.y >= 380
      @mpit.y = 380
    end
  end
  @mpit.contents_opacity = $game_temp.fdittm
  if MOG::MPITFD == true
    $game_temp.fdittm -= 3 if $game_temp.fdittm > 0
  end
  end
end

$mog_rgss_Treasure_Name = true

Added all the features you guys posted. Removing item uses picture 'Itname2'. Added removal sound effect. Doing "Switch ON, Item Gain, Switch OFF" will disable the window (it wasn't how the game updated switches that was the problem, MOG didn't write the script correctly. In fact, there's a lot in this script that I don't agree with and changed it).

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

exile360

Truly amazing work there, tested it and works like a charm, exactly how I requested. I can't thank you enough! :haha: