查看: 3060|回复: 5

[已经解决] 自制地图显示血量,SP,金钱.脚本还有些细节问题请教

[复制链接]
梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

发表于 2017-6-17 13:43:40 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 戴迪 于 2017-6-17 14:49 编辑

我不会脚本,只会稍微模仿.
自己搜帖发现现有的脚本是鼠标响应图片显示血条的,但自己不需要鼠标操作,于是乎,就照着现有教程东拼西凑写出了这个脚本.现在能实现显示血条(虽然说很丑),SP,金钱.但只能实现显示指定角色的HP,SP,本脚本中显示的是数据库里17号角色的HP.SP.

希望实现谁在队伍的首位就显示谁的HP,SP,请问怎么改,求大神赐教~
[pre lang="ruby" line="1"]#==============================================================================
# ■ Window_Mapshow
#------------------------------------------------------------------------------
#  显示血条的窗口。
#==============================================================================
class Window_Mapshow < Window_Base
  Hide_Window_Mapshow = 33                    #-----控制窗口的开关为33号开关
  #--------------------------------------------------------------------------
  # ● 初始化窗口
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 40 + 32)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 描绘HP槽
  #--------------------------------------------------------------------------
  def draw_actor_hp_bar(actor, x, y,width = 200)
    self.contents.fill_rect(36,4,width + 4,24,Color.new(255,255,255,255))
    self.contents.fill_rect(36 + 2,4 + 2,width ,20,Color.new(0,0,0,255))
    w1 = (1.0 * $game_actors[17].hp  / $game_actors[17].maxhp) * width #---------方括号里是数据库里的角色编号,要改的话下面所有方括号的都要改
    self.contents.fill_rect(36 + 2,4 + 2,w1 ,20,Color.new(200,0,0,255))
  end
  #--------------------------------------------------------------------------
  # ● 描绘SP槽
  #--------------------------------------------------------------------------
  def draw_actor_sp_bar(actor, x, y,width = 200)
    self.contents.fill_rect(36 + 240 ,4,width + 4,24,Color.new(255,255,255,255))
    self.contents.fill_rect(36 + 2 + 240 ,4 + 2,width ,20,Color.new(0,0,0,255))
    w2 = (1.0 * $game_actors[17].sp / $game_actors[17].maxsp) * width                              
    self.contents.fill_rect(36 + 2 + 240,4 + 2,w2 ,20,Color.new(248,112,0,255))
  end
  #--------------------------------------------------------------------------
  # ● 描绘金钱数目
  #--------------------------------------------------------------------------
  def draw_actor_gold(actor, x, y,width = 200)
    cx = contents.text_size($data_system.words.gold).width  #cx = 11
    self.contents.font.color = normal_color
    self.contents.draw_text(538, 0, 64-cx-2 ,32, $game_party.gold.to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(600-cx, 0, cx, 32, $data_system.words.gold, 2)
  end
  #--------------------------------------------------------------------------
  # ● 刷新--通常在这绘制位图
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_hp_bar($game_actors[17], 0, 20)
    draw_actor_sp_bar($game_actors[17], 0, 20)
    draw_actor_gold($game_party.gold.to_s, 0, 20)
    self.contents.font.color = Color.new(255,255,255,255)                           #------------------颜色可调
    self.contents.draw_text(0,0 , 36, 32, "HP:")                                             #------------------坐标可调
    self.contents.draw_text(70,0 , 36, 32,$game_actors[17].hp.to_s)
    self.contents.draw_text(70 + 63,0 + 1, 36, 32, "/")
    self.contents.draw_text(70 + 63 + 42,0 + 1, 36, 32,$game_actors[17].maxhp.to_s)
    self.contents.draw_text(0 + 240,0 , 36, 32, "SP:")
    self.contents.draw_text(70 + 240,0 , 36, 32,$game_actors[17].sp.to_s)
    self.contents.draw_text(70 + 63 + 240,0 + 1, 36, 32, "/")
    self.contents.draw_text(70 + 105 + 240,0 + 1, 36, 32,$game_actors[17].maxsp.to_s)
  end
  def update
    super
    self.visible = !$game_switches[Hide_Window_Mapshow]
    return unless self.visible                 #-----unless相当于if not
    rest_hp = $game_actors[17].hp
    max_hp = $game_actors[17].maxhp
    rest_sp = $game_actors[17].sp
    max_sp = $game_actors[17].maxsp
    gold = $game_party.gold
    if $l7_old_hp != rest_hp || ($l7_old_maxhp != max_hp) || $l7_old_sp != rest_sp || ($l7_old_maxsp != max_sp) || $l7_old_gold != gold
       $l7_old_hp = rest_hp
       $l7_old_maxhp = max_hp
       $l7_old_sp = rest_sp
       $l7_old_maxsp = max_sp
       refresh
    end
  end
end
[/pre]

如果谁觉得这样也可以凑合着用的话就拿去吧(还要在Scene_Map这个分类里改下东西),等我的问题解决了再重发一贴分享~

地图显示(如血条,金钱).rar

192.2 KB, 阅读权限: 10, 下载次数: 36

路人党员

梦石
0
星屑
52
在线时间
2276 小时
注册时间
2010-12-30
回帖
3011
发表于 2017-6-17 14:57:20 | 显示全部楼层
把所有的  $game_actors[17]  改成  $game_party.actors[0]  就行了

点评

OK已解决,谢了  发表于 2017-6-17 15:27

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到engshun@1ppl.me咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2017-6-17 14:58:11 | 显示全部楼层
其他的我不管。
脚本中$game_actors[17]是数据库中17号的意思。
$game_party.actors[0]是队伍库中第1位

点评

OK已解决,谢了  发表于 2017-6-17 15:28

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
100
在线时间
5 小时
注册时间
2021-7-27
回帖
30
发表于 2021-7-30 08:51:51 | 显示全部楼层
脚本中$game_actors[17]是数据库中17号的意思。
$game_party.actors[0]是队伍库中第1位
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部