赞 | 23 |
VIP | 207 |
好人卡 | 31 |
积分 | 31 |
经验 | 48797 |
最后登录 | 2024-5-11 |
在线时间 | 1535 小时 |
Lv3.寻梦者 孤独守望
- 梦石
- 0
- 星屑
- 3132
- 在线时间
- 1535 小时
- 注册时间
- 2006-10-16
- 帖子
- 4321
|
9楼
楼主 |
发表于 2008-4-6 23:13:56
|
只看该作者
制作完毕,新定义的方法名很邪恶{/hx}
- =begin
- 说明:调用方法如下:
- $scene.cut_new(num,hp_or_not,can_die,matrix,whom)
- num : 字面数字,不超过9999
- hp_or_not : 该值为真,扣血;反之扣魔
- can_die : 允许死亡?
- matrix : 数据处理的时候乘上该数值,[-1]扣数值,1加数值
- whom : 给谁扣血?写-1的话全体
- 例如,$scene.cut_new(200,true,false,-1,[0,1])
- 则给队伍上前面两个人扣血200点,不允许死亡。
- 0.9更新说明:允许多个处理同时存在,后面的处理将在上面。
- 方法作了修改
- =end
- #==============================================================================
- # ■ Cuter
- #------------------------------------------------------------------------------
- # 地图上面削血用脚本
- # IamI制作
- #==============================================================================
- class Cuter < Sprite
- #常量表
- #数字图片的位置,每一横列必须是0123456789。
- PIC_NAME = "Graphics/Windowskins/num"
- #有多少列?
- Y_NUM = 5
- #扣血的时候用多少步?40步相当于1s
- STEPS = 20
- #一开始的时候等待多少帧?
- START_WAIT = 10
- #非全体扣血的列
- ONE_HP_CUT = 1
- #全体扣血的列
- ALL_HP_CUT = 2
- #非全体加血的列
- ONE_HP_GET = 4
- #全体加血的列
- ALL_HP_GET = 4
- #非全体扣魔的列
- ONE_SP_CUT = 3
- #全体扣魔的列
- ALL_SP_CUT = 3
- #非全体加魔的列
- ONE_SP_GET = 5
- #全体加魔的列
- ALL_SP_GET = 5
- #对外接口
- attr_accessor :cutting
- attr_accessor :up_num
- attr_accessor :where_is
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize
- super
- @cutting = false
- @from_bitmap = Bitmap.new(PIC_NAME)
- self.bitmap = Bitmap.new(640,480)
- self.x = 0
- self.y = 0
- self.z = 9999
- self.ox = 0
- self.oy = 0
- @one_rect_x = @from_bitmap.width / 10
- @one_rect_y = @from_bitmap.height / Y_NUM
- @hp_or_not = true
- @can_die = false
- @matrix = -1
- @all_num = 100
- @now_num = 0
- @type = 1
- @now_step = 0
- @whom = []
- @real_step = STEPS
- @wait_count = 0
- @up_num = 0
- @where_is = -1
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def update(up_num = 0)
- if disposed?
- return
- end
- super()
- if @wait_count > 0
- @wait_count -= 1
- return
- end
- self.bitmap.clear
- if @cutting == true
- @up_num = up_num
- @now_num = @now_num - @all_num / @real_step
- broke(@now_num,@type)
- @now_step += 1
- if @now_step >= @real_step
- @now_step = 0
- @cutting = false
- cut_num
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 最后的数值处理
- #--------------------------------------------------------------------------
- def cut_num
- for i in @whom
- actor = $game_party.actors[i]
- if @hp_or_not == true
- if @can_die == true
- actor.hp += @all_num * @matrix
- if $game_party.all_dead?
- $scene = Scene_Gameover.new
- end
- else
- actor.hp = [actor.hp + @all_num * @matrix,1].max
- end
- else
- actor.sp = [actor.sp + @all_num * @matrix,0].max
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 对外的方法
- # num : 字面数字,不超过9999
- # hp_or_not : 该值为真,扣血;反之扣魔
- # can_die : 允许死亡?
- # matrix : 数据处理的时候乘上该数值,-1扣数值,1加数值
- # whom : 给谁扣血?写[-1]的话全体
- #--------------------------------------------------------------------------
- def cut(num,hp_or_not,can_die,matrix,whom,up_num = 0)
- if num > 9999
- return
- end
- @all_num = num
- @now_num = num
- @hp_or_not = hp_or_not
- @can_die = can_die
- @matrix = matrix
- @type = 0
- if hp_or_not == true
- if whom == -1
- if matrix > 0
- @type = ALL_HP_GET
- else
- @type = ALL_HP_CUT
- end
- else
- if matrix > 0
- @type = ONE_HP_GET
- else
- @type = ONE_HP_CUT
- end
- end
- else
- if whom == -1
- if matrix > 0
- @type = ALL_SP_GET
- else
- @type = ALL_SP_CUT
- end
- else
- if matrix > 0
- @type = ONE_SP_GET
- else
- @type = ONE_SP_CUT
- end
- end
- end
- if whom[0] < 0
- @whom = 0..$game_party.actors.size - 1
- else
- @whom = whom
- end
- @real_step = STEPS
- if @all_num < STEPS
- @real_step = @all_num
- end
- @up_num = up_num
- broke(@all_num,@type)
- @wait_count = START_WAIT
- @cutting = true
- end
- def set_for_water_water(num,up_num,type,where_is)
- @all_num = num
- @now_num = num
- @type = type
- @up_num = up_num
- @real_step = STEPS
- if @all_num < STEPS
- @real_step = @all_num
- end
- @where_is = where_is
- @cutting = true
- end
- #--------------------------------------------------------------------------
- # ● 拆数字,并且向下调用draw方法
- # num : 数字(xxxx)
- # type : 类型,即第几列
- #--------------------------------------------------------------------------
- def broke(num,type)
- # num必须是一个最高千位数字
- gotnum = num
- # 千位获取
- thousand = gotnum / 1000
- gotnum -= thousand * 1000
- # 百位获取
- hundred = gotnum / 100
- gotnum -= hundred * 100
- # 十位获取
- ten = gotnum / 10
- gotnum -= ten * 10
- # 个位……不能算获取,应该叫捡便宜= =b
- one = gotnum
- # 开始描画
- if @where_is < 0
- gotx = $game_player.real_x / 4.0
- goty = $game_player.real_y / 4.0
- else
- gotx = $game_map.events.values[@where_is - 1].x * 32.0
- goty = $game_map.events.values[@where_is - 1].y * 32.0
- end
- gotx = gotx + 16 - (@one_rect_x * 2)
- goty = goty - @one_rect_y - 16 - @up_num * @one_rect_y
- draw(thousand,type,gotx + @one_rect_x * 0,goty)
- draw(hundred, type,gotx + @one_rect_x * 1,goty)
- draw(ten, type,gotx + @one_rect_x * 2,goty)
- draw(one, type,gotx + @one_rect_x * 3,goty)
- end
- #--------------------------------------------------------------------------
- # ● 描画单个的数字
- # num : 数值(x)
- # type : 类型,即第几列
- # x : x实际坐标
- # y : y实际坐标
- #--------------------------------------------------------------------------
- def draw(num,type,x,y)
- rectangle = Rect.new(num * @one_rect_x ,(type - 1) * @one_rect_y, @one_rect_x,@one_rect_y)
- self.bitmap.blt(x, y, @from_bitmap,rectangle)
- end
-
- end
- #==============================================================================
- # ■ Scene_Map
- #------------------------------------------------------------------------------
- # 接入系统的处理
- #==============================================================================
- class Scene_Map
- attr_accessor :cuter
- alias old_main main
- def main
- @cuter = []
- old_main
- @cuter = []
- end
- alias old_update update
- def update
- old_update
- for i in [email protected] - 1
- if @cuter[i].where_is < 0 then
- @cuter[i].update(i)
- else
- @cuter[i].update
- end
- end
- for i in [email protected] - 1
- if @cuter[i].cutting == false
- @cuter[i].dispose
- @cuter.delete_at i
- break
- end
- end
- end
- alias old_call_menu call_menu
- def call_menu
- unless @cuter == []
- old_call_menu
- end
- end
- def cut_new(num,hp_or_not,can_die,matrix,whom)
- p = Cuter.new
- p.cut(num,hp_or_not,can_die,matrix,whom,@cuter.size)
- @cuter.push(p)
- end
- def water_cut(num,type,where_is)
- p = Cuter.new
- p.set_for_water_water(num,0,type,where_is)
- @cuter.push(p)
- end
- end
复制代码
(原来给主角的调用仍然不变)
调用为:$scene.water_cut(num,type,where_is)
num:字面数字
type:第几行的数字
where_is:事件的ID
一个事件不允许进行两个调用
顶楼暂不刷新。
喵,刚才改脚本半个小时没去逛自由提问区,水水要……算了,反正也全都是你在答题{/gg} |
|