Project1

标题: 向各位前辈请教一下关于战斗中的一些小东西 [打印本页]

作者: 包拯    时间: 2010-7-25 08:56
标题: 向各位前辈请教一下关于战斗中的一些小东西

恳请大家先看一副这幅图片,我想在左面,也就是我所画的地方添加上敌人战斗图以及敌人血槽,位置就在我所画的地方,请问一下,通过脚本如何就能够实现?

作者: 包拯    时间: 2010-7-25 09:52
各位,你们能帮帮我么
作者: rmg_mage    时间: 2010-7-25 17:11
很少有人这样用的,自己学脚本自己写把(我也不会)

BTW:那个幽灵是欧洲中世纪的,你觉得放那儿合适吗?
作者: 包拯    时间: 2010-7-25 17:23
很少有人这样用的,自己学脚本自己写把(我也不会)

BTW:那个幽灵是欧洲中世纪的,你觉得放那儿合适吗? ...
rmg_mage 发表于 2010-7-25 17:11

这只是一个战斗小测试,因为是脚本盲嘛,所以才……



作者: 逸豫    时间: 2010-7-25 19:44
  1. class Window_BattleEnemy < Window_Base
  2.   def initialize(enemy = nil)
  3.     @enemy = enemy
  4.     super(0,64,160,120)
  5.     self.contents = Bitmap.new(width - 32, height - 32)
  6.     refresh
  7.   end
  8.   def refresh
  9.     self.contents.clear
  10.     draw_actor_battler(@enemy, 0, 0) if @enemy != nil
  11.     carol3_draw_hp_bar(@enemy , 160 - 32 - 128 , 0) if @enemy != nil
  12.   end
  13.   def enemy=(e)
  14.     @enemy = e
  15.     refresh
  16.   end
  17.   def draw_actor_battler(actor, x, y)
  18.     bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  19.     cw = bitmap.width
  20.     ch = bitmap.height
  21.     src_rect = Rect.new(0, 0, cw, ch)
  22.     self.contents.blt(x, y, bitmap, src_rect)
  23.   end
  24.   def carol3_draw_hp_bar(actor, x, y, width = 128) #宽度可调
  25.    self.contents.font.color = system_color
  26.    w = width * actor.hp / [actor.maxhp,1].max
  27.    if actor.maxhp != 0
  28.      rate = actor.hp.to_f / actor.maxhp
  29.    else
  30.      rate = 0
  31.    end
  32.    color1 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 150)
  33.    self.contents.fill_rect(x+1, y+15, width+2,1, Color.new(0, 0, 0, 255))
  34.    self.contents.fill_rect(x+1, y+16, width+2,1, Color.new(255, 255, 192, 192))
  35.    self.contents.fill_rect(x+1, y+17, w,6,color1)
  36.    self.contents.fill_rect(x+1, y+23, width+2,1, Color.new(255, 255, 192, 192))
  37.    self.contents.fill_rect(x+1, y+24, width+2,1, Color.new(0, 0, 0, 255))
  38.    self.contents.fill_rect(x, y+16, 1,8, Color.new(255, 255, 192, 192))
  39.    self.contents.fill_rect(x-1, y+15, 1,10, Color.new(0, 0, 0, 255))
  40.    self.contents.fill_rect(x+129, y+16, 1,8, Color.new(255, 255, 192, 192))
  41.    self.contents.fill_rect(x+130, y+15, 1,10, Color.new(0, 0, 0, 255))
  42.    self.contents.draw_text(x-53,y,128,32,$data_system.words.hp,1)
  43.    if actor.hp>actor.maxhp/3
  44.      self.contents.font.color = Color.new(255, 255, 255, 250)
  45.    end
  46.    if actor.hp>=actor.maxhp/6 and actor.maxhp/3>actor.hp
  47.      self.contents.font.color = Color.new(200, 200, 0, 255)
  48.    end
  49.    if actor.maxhp/6>actor.hp
  50.      self.contents.font.color = Color.new(200, 0, 0, 255)
  51.    end
  52.    self.contents.draw_text(x+47,y,128,32,actor.hp.to_s,1)
  53.   end
  54.   def carol3_draw_sp_bar(actor, x, y, width = 128)
  55.    self.contents.font.color = system_color
  56.    if actor.maxsp != 0
  57.      rate = actor.sp.to_f / actor.maxsp
  58.    else
  59.      rate = 0
  60.    end
  61.    color2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
  62.    w = width * actor.sp / [actor.maxsp,1].max
  63.    self.contents.fill_rect(x+1, y+15, width+2,1, Color.new(0, 0, 0, 255))
  64.    self.contents.fill_rect(x+1, y+16, width+2,1, Color.new(255, 255, 192, 192))
  65.    self.contents.fill_rect(x+1, y+17, w,6,color2)
  66.    self.contents.fill_rect(x+1, y+23, width+2,1, Color.new(255, 255, 192, 192))
  67.    self.contents.fill_rect(x+1, y+24, width+2,1, Color.new(0, 0, 0, 255))
  68.    self.contents.fill_rect(x, y+16, 1,8, Color.new(255, 255, 192, 192))
  69.    self.contents.fill_rect(x-1, y+15, 1,10, Color.new(0, 0, 0, 255))
  70.    self.contents.fill_rect(x+129, y+16, 1,8, Color.new(255, 255, 192, 192))
  71.    self.contents.fill_rect(x+130, y+15, 1,10, Color.new(0, 0, 0, 255))
  72.    self.contents.draw_text(x-53,y,128,32,$data_system.words.sp,1)
  73.    if actor.hp>actor.maxsp/3
  74.      self.contents.font.color = Color.new(255, 255, 255, 250)
  75.    end
  76.    if actor.hp>=actor.maxsp/6 and actor.maxsp/3>actor.sp
  77.      self.contents.font.color = Color.new(200, 200, 0, 255)
  78.    end
  79.    if actor.maxsp/6>actor.sp
  80.      self.contents.font.color = Color.new(200, 0, 0, 255)
  81.    end
  82.    self.contents.draw_text(x+47,y,128,32,actor.sp.to_s,1)
  83.   end
  84. end
  85. class Scene_Battle
  86.   alias main_6r main
  87.   def main
  88.     @be_window = Window_BattleEnemy.new
  89.     @be_window.back_opacity = 160
  90.     main_6r
  91.     @be_window.dispose
  92.   end
  93.   alias upes update_phase3_enemy_select
  94.   def update_phase3_enemy_select
  95.     upes
  96.     unless Input.trigger?(Input::C) or Input.trigger?(Input::B)
  97.       @be_window.enemy = $game_troop.enemies[@enemy_arrow.index]
  98.     else
  99.       @be_window.enemy = nil
  100.     end
  101.   end
  102. end
复制代码

作者: 包拯    时间: 2010-7-25 21:14
感谢,但是在RMXP1.03中显示不出来,我用的是1.03版的,能请求修改一下么
作者: 逸豫    时间: 2010-7-25 21:36
这个貌似跟RMXP的版本无关吧= =|||
怀疑是脚本冲突,提供工程
作者: 包拯    时间: 2010-7-26 12:16
回复 逸豫 的帖子
范例的下载地址:http://www.rayfile.com/zh-cn/files/11c28d4f-986b-11df-914c-0015c55db73d/
作者: wuliao1997    时间: 2010-7-26 12:50
本帖最后由 wuliao1997 于 2010-7-26 13:42 编辑

LZ你不是已经整合好了吗....
只要再调一下XY的值:(基本上是这个大小)super(90,390,140,90)
再加上这句以免被战斗框挡住self.z = 9999
再修改血条位置和大小就可以了...
(PS:LZ你想再做一个上古神器2么...还有啊……妮可99级佩戴那剑每次打幽灵都是失误...你是咋设置的...每次都请重新再来...)
----------------------------------------------------------------------------
更改后的范例:http://u.115.com/file/f21006ecc5

作者: 包拯    时间: 2010-7-26 12:54
呵呵,就是因为我不懂这些,所以才……
作者: 逸豫    时间: 2010-7-26 14:04
本帖最后由 逸豫 于 2010-7-26 14:05 编辑


这不可以么……
作者: 包拯    时间: 2010-7-26 14:10
那啥,位置,在说了,为什么只有选中时才显示?继续补充:敌人我只设一个,所以嘛……
作者: 逸豫    时间: 2010-7-26 14:46
  1. class Window_BattleEnemy < Window_Base
  2.   def initialize(enemy = nil)
  3.     @enemy = $game_troop.enemies[0]
  4.     @hp_memory = @enemy.hp
  5.     super(0,64,160,120)
  6.     self.contents = Bitmap.new(width - 32, height - 32)
  7.     self.opacity = 160
  8.     refresh
  9.   end
  10.   def refresh
  11.     self.contents.clear
  12.     draw_actor_battler(@enemy, 0, 0) if @enemy != nil
  13.     carol3_draw_hp_bar(@enemy , 160 - 32 - 128 , 0) if @enemy != nil
  14.   end
  15.   def enemy=(e)
  16.     @enemy = e
  17.     refresh
  18.   end
  19.   def update
  20.     if @hp_memory != @enemy.hp
  21.       @hp_memory = @enemy.hp
  22.       refresh
  23.     end
  24.   end
  25.   def draw_actor_battler(actor, x, y)
  26.     bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  27.     cw = bitmap.width
  28.     ch = bitmap.height
  29.     src_rect = Rect.new(0, 0, cw, ch)
  30.     self.contents.blt(x, y, bitmap, src_rect)
  31.   end
  32.   def carol3_draw_hp_bar(actor, x, y, width = 128) #宽度可调
  33.    self.contents.font.color = system_color
  34.    w = width * actor.hp / [actor.maxhp,1].max
  35.    if actor.maxhp != 0
  36.      rate = actor.hp.to_f / actor.maxhp
  37.    else
  38.      rate = 0
  39.    end
  40.    color1 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 150)
  41.    self.contents.fill_rect(x+1, y+15, width+2,1, Color.new(0, 0, 0, 255))
  42.    self.contents.fill_rect(x+1, y+16, width+2,1, Color.new(255, 255, 192, 192))
  43.    self.contents.fill_rect(x+1, y+17, w,6,color1)
  44.    self.contents.fill_rect(x+1, y+23, width+2,1, Color.new(255, 255, 192, 192))
  45.    self.contents.fill_rect(x+1, y+24, width+2,1, Color.new(0, 0, 0, 255))
  46.    self.contents.fill_rect(x, y+16, 1,8, Color.new(255, 255, 192, 192))
  47.    self.contents.fill_rect(x-1, y+15, 1,10, Color.new(0, 0, 0, 255))
  48.    self.contents.fill_rect(x+129, y+16, 1,8, Color.new(255, 255, 192, 192))
  49.    self.contents.fill_rect(x+130, y+15, 1,10, Color.new(0, 0, 0, 255))
  50.    self.contents.draw_text(x-53,y,128,32,$data_system.words.hp,1)
  51.    if actor.hp>actor.maxhp/3
  52.      self.contents.font.color = Color.new(255, 255, 255, 250)
  53.    end
  54.    if actor.hp>=actor.maxhp/6 and actor.maxhp/3>actor.hp
  55.      self.contents.font.color = Color.new(200, 200, 0, 255)
  56.    end
  57.    if actor.maxhp/6>actor.hp
  58.      self.contents.font.color = Color.new(200, 0, 0, 255)
  59.    end
  60.    self.contents.draw_text(x+47,y,128,32,actor.hp.to_s,1)
  61.   end
  62.   def carol3_draw_sp_bar(actor, x, y, width = 128)
  63.    self.contents.font.color = system_color
  64.    if actor.maxsp != 0
  65.      rate = actor.sp.to_f / actor.maxsp
  66.    else
  67.      rate = 0
  68.    end
  69.    color2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
  70.    w = width * actor.sp / [actor.maxsp,1].max
  71.    self.contents.fill_rect(x+1, y+15, width+2,1, Color.new(0, 0, 0, 255))
  72.    self.contents.fill_rect(x+1, y+16, width+2,1, Color.new(255, 255, 192, 192))
  73.    self.contents.fill_rect(x+1, y+17, w,6,color2)
  74.    self.contents.fill_rect(x+1, y+23, width+2,1, Color.new(255, 255, 192, 192))
  75.    self.contents.fill_rect(x+1, y+24, width+2,1, Color.new(0, 0, 0, 255))
  76.    self.contents.fill_rect(x, y+16, 1,8, Color.new(255, 255, 192, 192))
  77.    self.contents.fill_rect(x-1, y+15, 1,10, Color.new(0, 0, 0, 255))
  78.    self.contents.fill_rect(x+129, y+16, 1,8, Color.new(255, 255, 192, 192))
  79.    self.contents.fill_rect(x+130, y+15, 1,10, Color.new(0, 0, 0, 255))
  80.    self.contents.draw_text(x-53,y,128,32,$data_system.words.sp,1)
  81.    if actor.hp>actor.maxsp/3
  82.      self.contents.font.color = Color.new(255, 255, 255, 250)
  83.    end
  84.    if actor.hp>=actor.maxsp/6 and actor.maxsp/3>actor.sp
  85.      self.contents.font.color = Color.new(200, 200, 0, 255)
  86.    end
  87.    if actor.maxsp/6>actor.sp
  88.      self.contents.font.color = Color.new(200, 0, 0, 255)
  89.    end
  90.    self.contents.draw_text(x+47,y,128,32,actor.sp.to_s,1)
  91.   end
  92. end
  93. class Scene_Battle
  94.   alias update_bz update
  95.   def update
  96.     @be_window.update
  97.     update_bz
  98.   end
  99. end
复制代码
★Scene_Battle 1 25行下添加
    @be_window = Window_BattleEnemy.new
82行下添加
    @be_window.dispose

大小&位置在脚本第五行调整
四个参数分别为x,y,宽度,高度
作者: 包拯    时间: 2010-7-26 14:51
我试试




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1