Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Shadonking on October 16, 2008, 08:38:22 am

Title: [RESOLVED]Skill notification
Post by: Shadonking on October 16, 2008, 08:38:22 am
im using blizz abs but im using my own hud which only has one problem, i cant see what skill has been selected. so i was hoping that some one will be able to make a script that shows the name of the skill and shows the icon in the top right of the screen.
Title: Re: Skill notification
Post by: Blizzard on October 16, 2008, 10:44:47 am
Here is a guideline:

If you use BlizzABS.player.player.battler.skill or BlizzABS.player.actors[0].battler.skill or $game_player.battler.skill or $game_party.actors[0].skill, you can obtain the skill ID assigned to the skill hotkey.
Title: Re: Skill notification
Post by: Shadonking on October 16, 2008, 11:59:21 am
ok, but i have no idea how to make a script.
Title: Re: Skill notification
Post by: Blizzard on October 17, 2008, 04:01:08 am
That's a guideline for the person that will take the request. :)
Title: Re: Skill notification
Post by: Shadonking on October 17, 2008, 07:52:16 am
ok

but now we will have to see if anyone will take the request. :bow:
Title: Re: Skill notification
Post by: Shadonking on October 27, 2008, 02:51:30 pm
hello, can some one please help.

edit

woo hoo Fantasist said he will help
Title: Re: Skill notification
Post by: Fantasist on November 07, 2008, 05:17:37 am
Okay, here's the code.

HUD:

#==============================================================================
# * module SHUD (Shadonking HUD)
#==============================================================================

module SHUD
  #:::::::: Config Begin ::::::::
  X = 8 # X position of the HUD
  Y = 8 # Y position of the HUD
  BG_Pic = 'HUD folder/HUD' # Name of the HUD image (in Pictures folder)
 
  HP_X = 47 # X pos of the HP bar (relative to HUD picture)
  HP_Y = 12 # Y pos of the HP bar (relative to HUD picture)
  HP_Width = 100 # Width of HP bar
  HP_Height = 4 # Height of HP bar
  HP_Color = nil # Color of HP bar ("nil" for dynamic coloring)
 
  SP_X = 56 # X pos of the SP bar (relative to HUD picture)
  SP_Y = 22 # Y pos of the SP bar (relative to HUD picture)
  SP_Width = 100 # Width of SP bar
  SP_Height = 4 # Height of SP bar
  SP_Color = nil # Color of SP bar ("nil" for blue color)
  #:::::::: Config End ::::::::
end

#==============================================================================
# * ShadonkingHUD
#==============================================================================

class ShadonkingHUD < Sprite
 
  def initialize(vp=nil)
    super(vp)
    @hp = @sp = 0
    @pic = Sprite.new(vp)
    @pic.bitmap = RPG::Cache.picture(SHUD::BG_Pic)
    self.bitmap = Bitmap.new(@pic.bitmap.width, @pic.bitmap.height)
    self.x, self.y = SHUD::X, SHUD::Y
  end
 
  def draw_bar(amount, x, y, w, h, c)
    self.bitmap.fill_rect(x, y, w, h, Color.new(0, 0, 0, 0))
    for i in (0...h)
      r = c.red - (c.red/2).to_f*i/h
      g = c.green - (c.green/2).to_f*i/h
      b = c.blue - (c.blue/2).to_f*i/h
      c1 = Color.new(r, g, b)
      self.bitmap.fill_rect(x, y+i, w*amount.to_f/100, 1, c1)
    end
  end
 
  def draw_hp
    hp_factor = @hp.to_f/lead_actor.maxhp
    unless SHUD::HP_Color
      hp_percent = (hp_factor*100).to_i
      color = case hp_percent
      when (0..10) then Color.new(192, 0, 0)
      when (11..20) then Color.new(255, 0, 0)
      when (21..30) then Color.new(255, 64, 0)
      when (31..40) then Color.new(255, 128, 0)
      when (41..50) then Color.new(255, 192, 0)
      when (51..60) then Color.new(255, 255, 0)
      when (61..70) then Color.new(160, 255, 0)
      when (71..80) then Color.new(128, 255, 0)
      when (81..90) then Color.new(64, 255, 0)
      when (91..100) then Color.new(0, 224, 0)
      end
    else
      color = SHUD::HP_Color
    end
    hp_x = SHUD::HP_X
    hp_y = SHUD::HP_Y
    draw_bar(SHUD::HP_Width*hp_factor, hp_x, hp_y,
    SHUD::HP_Width, SHUD::HP_Height, color)
  end
 
  def draw_sp
    sp_factor = @sp.to_f/lead_actor.maxsp
    unless SHUD::SP_Color
      color = Color.new(64, 64, 255) # Blue
    else
      color = SHUD::SP_Color
    end
    sp_x = SHUD::SP_X
    sp_y = SHUD::SP_Y
    draw_bar(SHUD::SP_Width*sp_factor, sp_x, sp_y,
    SHUD::SP_Width, SHUD::SP_Height, color)
  end
 
  def update
    super
    @pic.update
    return unless lead_actor
    if @hp != lead_actor.hp
      @hp = lead_actor.hp
      draw_hp
    end
    if @sp != lead_actor.sp
      @sp = lead_actor.sp
      draw_sp
    end
  end
 
  def lead_actor
    return nil unless $game_party.actors.size > 0
    return $game_party.actors[0]
  end
 
  def x=(xx)
    super(xx)
    @pic.x = xx
  end
 
  def y=(yy)
    super(yy)
    @pic.y = yy
  end
 
  def z=(zz)
    super(zz)
    @pic.z = zz + 0.1
  end
 
  def ox=(oxx)
    super(oxx)
    @pic.ox = oxx
  end
 
  def oy=(oyy)
    super(oyy)
    @pic.oy = oyy
  end
 
  def zoom_x=(zx)
    super(zx)
    @pic.zoom_x = zx
  end
 
  def zoom_y=(zy)
    super(zy)
    @pic.zoom_y = zy
  end
 
  def opacity=(oo)
    super(oo)
    @pic.opacity = oo
  end
 
  def visible=(val)
    super(val)
    @pic.visible = val
  end
 
  def dispose
    super
    @pic.dispose
  end
 
end

#==============================================================================
# * Spriteset_Map
#==============================================================================

class Spriteset_Map
 
  alias fts_shadonking_hud_spriteset_map_init initialize
  def initialize
    fts_shadonking_hud_spriteset_map_init
    @hud = ShadonkingHUD.new(@viewport2)
  end
 
  alias fts_shadonking_hud_spriteset_map_upd update
  def update
    fts_shadonking_hud_spriteset_map_upd
    @hud.update if @hud
  end
 
  alias fts_shadonking_hud_spriteset_map_dispose dispose
  def dispose
    fts_shadonking_hud_spriteset_map_dispose
    @hud.dispose if @hud
  end
 
end


BlizzABS Skill Notification addon:

#==============================================================================
# * module SHUD (Shadonking HUD)
#==============================================================================

module SHUD
  #:::::::: Config Begin ::::::::
  BABS_Skill_Icon = true # Enable/disable icon showing
  BABS_Skill_Icon_X = 38 # X pos of icon(relative to HUD picture)
  BABS_Skill_Icon_Y = 32 # Y pos of icon(relative to HUD picture)
  #:::::::: Config End ::::::::
end

#==============================================================================
# * ShadonkingHUD
#==============================================================================

class ShadonkingHUD
 
  alias shud_babs_skill_init initialize
  def initialize(vp=nil)
    super(vp)
    if SHUD::BABS_Skill_Icon
      @sicon = Sprite.new(vp)
      @sicon.bitmap = Bitmap.new(200, 28)
      @sicon.bitmap.font.size = 20
      @sicon.bitmap.font.bold = true
      @skill_id = -1
      @sicon.x = self.x - self.ox + SHUD::BABS_Skill_Icon_X
      @sicon.y = self.y - self.oy + SHUD::BABS_Skill_Icon_Y
    end
    shud_babs_skill_init(vp)
  end
 
  alias shud_babs_skill_upd update
  def update
    shud_babs_skill_upd
    if SHUD::BABS_Skill_Icon && @skill_id != lead_actor.skill
      @skill_id = lead_actor.skill
      set_skill
    end
  end
   
  def set_skill
    if @skill_id <= 0
      @sicon.bitmap.clear
      return
    end
    skill_name = $data_skills[@skill_id].name
    icon_bmp = RPG::Cache.icon($data_skills[@skill_id].icon_name)
    b = @sicon.bitmap
    b.clear
    b.blt(2, 2, icon_bmp, icon_bmp.rect)
    b.font.color = Color.new(0, 0, 0, self.opacity)
    b.draw_text(2+24+4-1, 2-1, 160-2-24-4, 24, skill_name)
    b.draw_text(2+24+4-1, 2+1, 160-2-24-4, 24, skill_name)
    b.draw_text(2+24+4+1, 2-1, 160-2-24-4, 24, skill_name)
    b.draw_text(2+24+4+1, 2+1, 160-2-24-4, 24, skill_name)
    b.font.color = Color.new(255, 255, 255, self.opacity)
    b.draw_text(2+24+4, 2, 160-2-24-4, 24, skill_name)
  end
 
  alias shud_babs_skill_x x=
  def x=(xx)
    shud_babs_skill_x(xx)
    return unless SHUD::BABS_Skill_Icon
    @sicon.x = xx - self.ox + SHUD::BABS_Skill_Icon_X
  end
 
  alias shud_babs_skill_y y=
  def y=(yy)
    shud_babs_skill_y(yy)
    return unless SHUD::BABS_Skill_Icon
    @sicon.y = yy - self.oy + SHUD::BABS_Skill_Icon_Y
  end
 
  alias shud_babs_skill_z z=
  def z=(zz)
    shud_babs_skill_z(zz)
    return unless SHUD::BABS_Skill_Icon
    @sicon.z = zz + 1
  end
 
  alias shud_babs_skill_opacity opacity=
  def opacity=(oo)
    shud_babs_skill_opacity(oo)
    return unless SHUD::BABS_Skill_Icon
    @sicon.opacity = oo
  end
 
  alias shud_babs_skill_visible visible=
  def visible=(val)
    shud_babs_skill_visible(val)
    return unless SHUD::BABS_Skill_Icon
    @sicon.visible = val
  end
 
  alias shud_babs_skill_dispose dispose
  def dispose
    shud_babs_skill_dispose
    return unless SHUD::BABS_Skill_Icon
    @sicon.dispose
  end
 
end


It worked fine with the project you posted, hope I got it right.

EDIT:
Oh, and you don't need the pics for the bars anymore (HP 0%, .... HP 100%, SP 0%, .... SP 100%). You just need that HUD picture.
Title: Re: Skill notification
Post by: Shadonking on November 07, 2008, 07:16:45 am
thank you, it works wonderfully.