赞 | 451 |
VIP | 56 |
好人卡 | 75 |
积分 | 424 |
经验 | 124650 |
最后登录 | 2024-11-23 |
在线时间 | 7602 小时 |
Lv5.捕梦者 (管理员) 老黄鸡
- 梦石
- 0
- 星屑
- 42404
- 在线时间
- 7602 小时
- 注册时间
- 2009-7-6
- 帖子
- 13506
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 fux2 于 2012-1-15 13:34 编辑
范例在此
http://115.com/file/be4xpqz5
随机形象NPC范例.rar
由于Dir不能访问加密包,所以要加密的游戏请勿使用此脚本.
脚本如下- #~ 2012.1.11
- #~ by Fux2
- #~
- #~ 随机形象事件设置方法:
- #~ 1.随意给事件设置一个行走图
- #~ 2.事件名称后面加上\r
- #~ 随机脸图呼出方法:
- #~ 1.显示文章的内容末尾加上'fs
- #~ 脸图拼接时会有需要同步颜色的问题,将同步的文件名末尾加上!同步组编号
- #~ 末尾加上?的用途自行揣摩(PIA
- module Fux2
- Partres = ['Cloak','Body','Cloth','Glasses','Head','Kemono']
- FacePartres = ['RearHair!2','Neck','Face!1','Neck?','Eyes?','Eyes','Mouth!1','Nose!1','FrontHair?!2','FrontHair!2']
-
- def self.get_random_character
- bit = Bitmap.new(96,128)
- tbit=[]
- result = [];Partres.size.times{result<<[]}
- Dir["Graphics/rand_cha/*"].each do |i|
- Partres.each_with_index do |j,k|
- result[k] << i if i[/\/#{j}\d*\.png$/]
- end
- end
- result.each_index do |i|
- result[i]=result[i][rand(result[i].size)]
- tbit<<Bitmap.new(result[i])
- end
- tbit.each do |i|
- a=rand(i.width/96)*96
- b=rand(i.height/128)*128
- bit.blt(0,0,i,Rect.new(a,b,96,128))
- end
- return bit
- end
-
- def self.get_random_face
- bit = Bitmap.new(96,96)
- tbit = []
- ext = {};pext = {};rxt = {};pxt = {}
- result = [];FacePartres.size.times{result<<[]}
- Dir["Graphics/rand_face/*"].each do |i|
- FacePartres.each_with_index do |j,k|
- if j[/\?/]
- result[k] << i if i[/\/#{j.gsub(/\?|\!\d+/){''}}\d*[^\d]\.png$/]
- sorts = [k,FacePartres.index(j.gsub('?'){''})].sort!
- ext[sorts[0]] = sorts[1]
- pext[sorts[1]] = sorts[0]
- if j[/\!\d+$/]
- index = j.gsub(/^.*\!(\d+)$/){$1}.to_i
- rxt[index] ||= []
- rxt[index] << k unless rxt[index].include?(k)
- end
- elsif j[/\!\d+$/]
- result[k] << i if i[/\/#{j.gsub(/\!\d+/){''}}\d*\.png$/]
- index = j.gsub(/^.*\!(\d+)$/){$1}.to_i
- rxt[index] ||= []
- rxt[index] << k unless rxt[index].include?(k)
- else
- result[k] << i if i[/\/#{j}\d*\.png$/]
- end
- end
- end
- rxt.each_value{|i| i.sort!;[*1...i.size].each{|j| pxt[i[j]] = i[0]}}
- result.each_index do |i|
- if ext[i]
- num=rand(result[i].size)
- result[i]=result[i][num]
- result[ext[i]]=result[ext[i]][num]
- else
- result[i]=result[i][rand(result[i].size)] if result[i].is_a?(Array)
- end
- tbit<<Bitmap.new(result[i]) if result[i]
- end
- posiarr = []
- tbit.each_with_index do |i,j|
- if pext[j]
- a = posiarr[pext[j]][0]
- b = posiarr[pext[j]][1]
- bit.blt(-16,-16,i,Rect.new(a,b,128,128))
- elsif pxt[j]
- a = posiarr[pxt[j]][0]
- b = posiarr[pxt[j]][1]
- bit.blt(-16,-16,i,Rect.new(a,b,128,128))
- else
- a=rand(i.width/128)*128
- b=rand(i.height/128)*128
- bit.blt(-16,-16,i,Rect.new(a,b,128,128))
- end
- posiarr << [a,b]
- end
- return bit
- end
-
- end
- class Game_Event < Game_Character
-
- alias ini initialize unless $@
- def initialize(map_id, event)
- ini(map_id, event)
- end
-
- def randc
- return @event.name[/\\r/]
- end
- def name
- return @event.name.gsub(/\\r/){""}
- end
-
- end
- class Sprite_Character < Sprite_Base
-
- def set_character_bitmap
- if @character.is_a?(Game_Event) && @character.randc
- self.bitmap = Fux2.get_random_character
- sign = 66
- else
- self.bitmap = Cache.character(@character_name)
- sign = @character_name[/^[\!\$]./]
- end
- if sign == 66 or (sign && sign.include?('))
- @cw = bitmap.width / 3
- @ch = bitmap.height / 4
- else
- @cw = bitmap.width / 12
- @ch = bitmap.height / 8
- end
- self.ox = @cw / 2
- self.oy = @ch
- end
-
- end
- class Window_Message < Window_Base
- def new_page(text, pos)
- contents.clear
- if text[/'fs/]
- fux2randface = true
- text.gsub!(/'fs/){''}
- $game_message.face_name = "?"
- else
- fux2randface = false
- end
- draw_face($game_message.face_name, $game_message.face_index, 0, 0,true,fux2randface)
- reset_font_settings
- pos[:x] = new_line_x
- pos[:y] = 0
- pos[:new_x] = new_line_x
- pos[:height] = calc_line_height(text)
- clear_flags
- end
-
- end
- class Window_Base < Window
- def draw_face(face_name, face_index, x, y, enabled = true, randface = false)
- bitmap = randface ? Fux2.get_random_face : Cache.face(face_name)
- rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
- contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
- bitmap.dispose
- end
-
- end
复制代码 |
评分
-
查看全部评分
|