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
class Window_BattleEnemy < Window_Base
def initialize(enemy = nil)
@enemy = enemy
super(0,64,160,120)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
draw_actor_battler(@enemy, 0, 0) if @enemy != nil
carol3_draw_hp_bar(@enemy , 160 - 32 - 128 , 0) if @enemy != nil
end
def enemy=(e)
@enemy = e
refresh
end
def draw_actor_battler(actor, x, y)
bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x, y, bitmap, src_rect)
end
def carol3_draw_hp_bar(actor, x, y, width = 128) #宽度可调
self.contents.font.color = system_color
w = width * actor.hp / [actor.maxhp,1].max
if actor.maxhp != 0
rate = actor.hp.to_f / actor.maxhp
else
rate = 0
end
color1 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 150)
self.contents.fill_rect(x+1, y+15, width+2,1, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+1, y+16, width+2,1, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+1, y+17, w,6,color1)
self.contents.fill_rect(x+1, y+23, width+2,1, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+1, y+24, width+2,1, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x, y+16, 1,8, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x-1, y+15, 1,10, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+129, y+16, 1,8, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+130, y+15, 1,10, Color.new(0, 0, 0, 255))
self.contents.draw_text(x-53,y,128,32,$data_system.words.hp,1)
if actor.hp>actor.maxhp/3
self.contents.font.color = Color.new(255, 255, 255, 250)
end
if actor.hp>=actor.maxhp/6 and actor.maxhp/3>actor.hp
self.contents.font.color = Color.new(200, 200, 0, 255)
end
if actor.maxhp/6>actor.hp
self.contents.font.color = Color.new(200, 0, 0, 255)
end
self.contents.draw_text(x+47,y,128,32,actor.hp.to_s,1)
end
def carol3_draw_sp_bar(actor, x, y, width = 128)
self.contents.font.color = system_color
if actor.maxsp != 0
rate = actor.sp.to_f / actor.maxsp
else
rate = 0
end
color2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
w = width * actor.sp / [actor.maxsp,1].max
self.contents.fill_rect(x+1, y+15, width+2,1, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+1, y+16, width+2,1, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+1, y+17, w,6,color2)
self.contents.fill_rect(x+1, y+23, width+2,1, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+1, y+24, width+2,1, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x, y+16, 1,8, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x-1, y+15, 1,10, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+129, y+16, 1,8, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+130, y+15, 1,10, Color.new(0, 0, 0, 255))
self.contents.draw_text(x-53,y,128,32,$data_system.words.sp,1)
if actor.hp>actor.maxsp/3
self.contents.font.color = Color.new(255, 255, 255, 250)
end
if actor.hp>=actor.maxsp/6 and actor.maxsp/3>actor.sp
self.contents.font.color = Color.new(200, 200, 0, 255)
end
if actor.maxsp/6>actor.sp
self.contents.font.color = Color.new(200, 0, 0, 255)
end
self.contents.draw_text(x+47,y,128,32,actor.sp.to_s,1)
end
end
class Scene_Battle
alias main_6r main
def main
@be_window = Window_BattleEnemy.new
@be_window.back_opacity = 160
main_6r
@be_window.dispose
end
alias upes update_phase3_enemy_select
def update_phase3_enemy_select
upes
unless Input.trigger?(Input::C) or Input.trigger?(Input::B)
@be_window.enemy = $game_troop.enemies[@enemy_arrow.index]
else
@be_window.enemy = nil
end
end
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
class Window_BattleEnemy < Window_Base
def initialize(enemy = nil)
@enemy = $game_troop.enemies[0]
@hp_memory = @enemy.hp
super(0,64,160,120)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 160
refresh
end
def refresh
self.contents.clear
draw_actor_battler(@enemy, 0, 0) if @enemy != nil
carol3_draw_hp_bar(@enemy , 160 - 32 - 128 , 0) if @enemy != nil
end
def enemy=(e)
@enemy = e
refresh
end
def update
if @hp_memory != @enemy.hp
@hp_memory = @enemy.hp
refresh
end
end
def draw_actor_battler(actor, x, y)
bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x, y, bitmap, src_rect)
end
def carol3_draw_hp_bar(actor, x, y, width = 128) #宽度可调
self.contents.font.color = system_color
w = width * actor.hp / [actor.maxhp,1].max
if actor.maxhp != 0
rate = actor.hp.to_f / actor.maxhp
else
rate = 0
end
color1 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 150)
self.contents.fill_rect(x+1, y+15, width+2,1, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+1, y+16, width+2,1, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+1, y+17, w,6,color1)
self.contents.fill_rect(x+1, y+23, width+2,1, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+1, y+24, width+2,1, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x, y+16, 1,8, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x-1, y+15, 1,10, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+129, y+16, 1,8, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+130, y+15, 1,10, Color.new(0, 0, 0, 255))
self.contents.draw_text(x-53,y,128,32,$data_system.words.hp,1)
if actor.hp>actor.maxhp/3
self.contents.font.color = Color.new(255, 255, 255, 250)
end
if actor.hp>=actor.maxhp/6 and actor.maxhp/3>actor.hp
self.contents.font.color = Color.new(200, 200, 0, 255)
end
if actor.maxhp/6>actor.hp
self.contents.font.color = Color.new(200, 0, 0, 255)
end
self.contents.draw_text(x+47,y,128,32,actor.hp.to_s,1)
end
def carol3_draw_sp_bar(actor, x, y, width = 128)
self.contents.font.color = system_color
if actor.maxsp != 0
rate = actor.sp.to_f / actor.maxsp
else
rate = 0
end
color2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
w = width * actor.sp / [actor.maxsp,1].max
self.contents.fill_rect(x+1, y+15, width+2,1, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+1, y+16, width+2,1, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+1, y+17, w,6,color2)
self.contents.fill_rect(x+1, y+23, width+2,1, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+1, y+24, width+2,1, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x, y+16, 1,8, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x-1, y+15, 1,10, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+129, y+16, 1,8, Color.new(255, 255, 192, 192))
self.contents.fill_rect(x+130, y+15, 1,10, Color.new(0, 0, 0, 255))
self.contents.draw_text(x-53,y,128,32,$data_system.words.sp,1)
if actor.hp>actor.maxsp/3
self.contents.font.color = Color.new(255, 255, 255, 250)
end
if actor.hp>=actor.maxsp/6 and actor.maxsp/3>actor.sp
self.contents.font.color = Color.new(200, 200, 0, 255)
end
if actor.maxsp/6>actor.sp
self.contents.font.color = Color.new(200, 0, 0, 255)
end
self.contents.draw_text(x+47,y,128,32,actor.sp.to_s,1)
end
end
class Scene_Battle
alias update_bz update
def update
@be_window.update
update_bz
end
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