赞 | 7 |
VIP | 7 |
好人卡 | 58 |
积分 | 1 |
经验 | 111901 |
最后登录 | 2021-11-5 |
在线时间 | 385 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 65
- 在线时间
- 385 小时
- 注册时间
- 2007-7-27
- 帖子
- 4106
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
……自己做游戏的副产品
主要就是模仿空之轨迹还有ff12等游戏,到了NPC面前会显示「Talk」,到了门前会显示门后面的地点,等等……【囧】
功能:
1.路牌:在路口显示此方向通往哪里
2.门牌:显示门通向哪里
3.NPC响应:靠近时显示「Talk」「Trade」「Check」等图标。 使用方法:
1.路牌:
在路口画一个区域,不用很大,取名为 方向,名称
方向请用2,4,6,8代替。
示例:
2.门牌。
门牌可以四个方向响应。
示例:
请在第一行插入注释Door
之后使用如图格式写注释。
注意,可以只写一个方向,也可以写两个方向……【囧丁乙】
一个注释栏写不下可以分多个
其实XXX_name表示门牌框的名字,XXX_type表示名字下面显示的建筑类型,XXX_range表示离主角多少距离就显示门牌。请不要大于4。
最后请用Door_END表示注释完成。
3.NPC响应。
示例:
NPC:
商人:
宝箱:(或表示隐藏物品)
请在事件的第一行用注释写上"NPC"或"Item",type中写入类型。name表示名字。最后用"NPC_END"或"Item_END"表示注释结束。 脚本:已经分成两块,并可以和地名显示(点我)一起使用。
一、通用块。用来自定义设置和存储常量,和地名显示那里的是一样的,不用重复插入了……
- #▼▼▼通用变量、方法、模块、类▼▼▼
- #==============================================================================
- # ■ (模块)T_m
- #------------------------------------------------------------------------------
- # 用来存储常用常量
- #=============================================================================
- module T_m
- #-----------------------------------------------------------------------------
- # ● 地名窗口常量
- #-----------------------------------------------------------------------------
- #▼地名窗口
- WIDTH = 150 # 窗口宽度最小值
- IN_TIME = 20 # 窗口出现时间
- SHOW_TIME = 60 # 窗口显示时间
- FADE_TIME = 30 # 窗口淡去时间
- TEXT1_SIZE = 19 # 地图名,区域名的字体大小
- TEXT2_SIZE = 13 # 地区名的字体大小
- TEXT1_COLOR = Color.new(255,255,255) # 地图名,区域名的默认颜色
- TEXT2_COLOR = Color.new(255,60,60) # 地区名的默认颜色
- SKIN = "window" # 窗口皮肤的文件名
- VX_H = 416 # VX窗口高度
- VX_W = 544 # VX窗口宽度
- ZONE_NUM =8 # 地区名占用角色名的编号
- Map_W_S=1 # 控制是否显示的开关
- #▼地区名窗口
- Z_IN_TIME = 30 # 窗口出现时间
- Z_SHOW_TIME = 70 # 窗口显示时间
- Z_FADE_TIME = 30 # 窗口淡去时间
- ZONE_W_S=2 # 控制是否显示开关
- #▼计算
- HEIGHT = TEXT1_SIZE + TEXT2_SIZE + 34 # 窗口高度
- MWINDOW_Y = VX_H - HEIGHT - 16 # 窗口Y坐标
- #----------------------------------------------------------------------------
- # ● 路牌门牌NPC常量
- #----------------------------------------------------------------------------
- #▼路口窗口
- RT_WIDTH=240 #窗口宽度的最小值
- RT_Y=30 #窗口Y值
- RT_INTIME=20 #窗口出现时间
- RT_ONTIME=60 #窗口持续时间
- RT_FADETIME=20 #窗口消失时间
- RT_S=3 #控制开关
- RT_TEXTSIZE=20 #字体大小
- RT_TEXTCOLOR=Color.new(255,255,255) #字体颜色
- #▼NPC窗口
- NPC_ICON_TALK="talk" #「谈话」图标名
- NPC_ICON_TRADE="trade" #「交易」图标名
- NPC_ICON_CHECK="check" #「调查」图标名
- NPC_NAME_SIZE=16 #「NPC」人名字号
- NPC_S=4 #「NPC控制开关」编号
- #▼门牌窗口
- DOOR_NAME_SIZE=22 #门牌「名称」字号
- DOOR_TYPE_SIZE =16 #门牌「类型」字号
- DOOR_S=5 #「门牌」控制开关编号
- #----------------------------------------------------------------------------
- # ●其他
- #----------------------------------------------------------------------------
- def self.preview_dis
- return @preview_dis
- end
- def self.preview_dis=(a)
- return @preview_dis=a
- end
- @preview_dis=false
- end
- #----------------------------------------------------------------------------
- # ● 方法:读取属性
- #----------------------------------------------------------------------------
- def readattr(str,section,ignore_caps = false)
- str="" if str.class!=String
- result=''
- section.upcase! if ignore_caps
- s = section.to_sym
- temp = str.split(/=/)
- temp.each{|i|i.strip!}
- temp[0].upcase! if ignore_caps
- temp[0]=" " if temp[0]==nil
- if temp[0].to_sym==s
- unless temp[1]==nil
- result=temp[1]
- end
- end
- return result
- end
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # 对Game_Map类的追加定义。
- #=============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ● 获取所在场景名称
- #--------------------------------------------------------------------------
- def name
- load_data("Data/MapInfos.rvdata")
- end
- end
- #==============================================================================
- # ■ Game_Character
- #------------------------------------------------------------------------------
- # 判断当前人物所在区域id(by beside)。
- #=============================================================================
- class Game_Character
- def area_id
- for area in $data_areas.values
- if in_area?(area)
- return area.id
- end
- end
- end
- end
-
- #==============================================================================
- # ◎ GPRA_Bitmap
- #------------------------------------------------------------------------------
- # ◎ Bitmap功能加强
- #------------------------------------------------------------------------------
- # 制作者:绿梨子红苹果
- # 个人主页:vbgm.9126.com
- # E-Mail:[email protected]
- # QQ:42378361
- #==============================================================================
- class Bitmap
- # 影子字
- def draw_text_s(x, y, width, height, str, align=0)
- # 保存当前颜色
- r=self.font.color.red
- g=self.font.color.green
- b=self.font.color.blue
- # 颜色更改成黑色
- self.font.color.set(0, 0, 0)
- # 绘制影子
- self.draw_text(x+2, y+2, width, height, str, align)
- # 恢复原始字色
- self.font.color.set(r,g,b)
- # 绘制原来的字
- self.draw_text(x, y, width, height, str, align)
- end
- # 描边字
- def draw_text_f(x, y, width, height, str, align=0)
- # 保存当前颜色
- r=self.font.color.red
- g=self.font.color.green
- b=self.font.color.blue
- # 颜色更改成黑色
- self.font.color.set(0, 0, 0)
- # 绘制边框
- self.draw_text(x-1, y-1, width, height, str, align)
- self.draw_text(x-1, y+1, width, height, str, align)
- self.draw_text(x+1, y-1, width, height, str, align)
- self.draw_text(x+1, y+1, width, height, str, align)
- self.draw_text(x, y-1, width, height, str, align)
- self.draw_text(x, y+1, width, height, str, align)
- self.draw_text(x-1, y, width, height, str, align)
- self.draw_text(x+1, y, width, height, str, align)
- # 恢复原始字色
- self.font.color.set(r,g,b)
- # 绘制原来的字
- self.draw_text(x, y, width, height, str, align)
- end
- end
复制代码
二:NPC响应,门牌,路牌块
- $npc_window=[]
- #==============================================================================
- # ■ Window_Roadtip
- #------------------------------------------------------------------------------
- # 路口窗口
- #==============================================================================
- class Window_Roadtip < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize
- super(0,0,100,100)
- self.opacity=0
- self.contents_opacity=0
- @id=$game_player.area_id
- @time=0
- @name=""
- end
- #--------------------------------------------------------------------------
- # ● 得到区域名
- #--------------------------------------------------------------------------
- def area_name(id=$game_player.area_id)
- name=$data_areas[id].name
- return name
- end
- #--------------------------------------------------------------------------
- # ● 进行判断并取得值
- #--------------------------------------------------------------------------
- def judge
- @continue=0
- if area_name.split(/,/)[0].to_i==2||6||4||8
- @direction=area_name.split(/,/)[0]
- @name=area_name.split(/,/)[1]
- @continue=1
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制地图
- #--------------------------------------------------------------------------
- def draw
- @d=""
- case @direction.to_i
- when 2
- @d="↓"
- when 4
- @d="←"
- when 6
- @d="→"
- when 8
- @d="↑"
- end
-
- create_contents
- self.contents.clear
- self.contents.font.size=T_m::RT_TEXTSIZE
- self.contents.font.color=T_m::RT_TEXTCOLOR
- self.contents.draw_text(0,0,self.width-32,self.height-32,@d+@name,1)
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def update
- if @id!=$game_player.area_id
- @id=$game_player.area_id
- if $game_player.area_id.is_a?(Numeric)==true
- if $game_switches[T_m::RT_S] == true
- judge
- if @continue==1
- self.height=T_m::RT_TEXTSIZE+32
- @name="" if @name==nil
- self.width=[T_m::RT_WIDTH,(T_m::RT_TEXTSIZE)*(@name.size)/3+50].max
- self.x=(T_m::VX_W-self.width)/2
- self.y=T_m::RT_Y
- if [email protected]_i
- @time=T_m::RT_INTIME+T_m::RT_ONTIME+T_m::RT_FADETIME
- draw
- T_m::preview_dis=true
- end
- end
- end
- end
- end
- if @time>T_m::RT_ONTIME+T_m::RT_FADETIME
- self.opacity = 255*(T_m::RT_INTIME+T_m::RT_ONTIME+T_m::RT_FADETIME-@time)/(T_m::RT_INTIME-1)
- self.contents_opacity = 255*(T_m::RT_INTIME+T_m::RT_ONTIME+T_m::RT_FADETIME-@time)/(T_m::RT_INTIME-1)
- @time-=1
- elsif @time>T_m::RT_FADETIME
- @time-=1
- elsif @time>0
- self.opacity = 255*(@time-1)/(T_m::RT_FADETIME-1)
- self.contents_opacity = 255*(@time-1)/(T_m::RT_FADETIME-1)
- @time-=1
- else
- self.opacity = 0
- self.contents_opacity = 0
- end
- end
- end
- #==============================================================================
- # ■ Window_NPC
- #------------------------------------------------------------------------------
- # NPC响应窗口,门牌窗口。
- #=============================================================================
- class Window_NPC < Window_Base
- def initialize(type,name,add="",dir=0)
- super(0,0,100,100)
- self.opacity=0
- self.contents_opacity=255
- @time=0
- @type=type
- case type
- when "NPC"
- self.height=T_m::NPC_NAME_SIZE+32+Cache.system(T_m::NPC_ICON_TALK).height
- self.width=[name.size/3*T_m::NPC_NAME_SIZE,Cache.system(T_m::NPC_ICON_TALK).width].max+32
- create_contents
- self.contents.font.size=T_m::NPC_NAME_SIZE
- self.contents.draw_text(0,Cache.system(T_m::NPC_ICON_TALK).height+1,self.width-32,T_m::NPC_NAME_SIZE,name,1)
- self.contents.blt((self.width-Cache.system(T_m::NPC_ICON_TALK).width-32)/2,0,Cache.system(T_m::NPC_ICON_TALK),Rect.new(0,0,Cache.system(T_m::NPC_ICON_TALK).width,Cache.system(T_m::NPC_ICON_TALK).height))
- @time=10
- when "Item"
- self.height=32+Cache.system(T_m::NPC_ICON_CHECK).height
- self.width=Cache.system(T_m::NPC_ICON_CHECK).width+32
- create_contents
- self.contents.blt((self.width-Cache.system(T_m::NPC_ICON_CHECK).width-32)/2,0,Cache.system(T_m::NPC_ICON_CHECK),Rect.new(0,0,Cache.system(T_m::NPC_ICON_CHECK).width,Cache.system(T_m::NPC_ICON_CHECK).height))
- @time=10
- when "Trade"
- self.height=32+Cache.system(T_m::NPC_ICON_TRADE).height+T_m::NPC_NAME_SIZE
- self.width=[Cache.system(T_m::NPC_ICON_TRADE).width+32,name.size/3*T_m::NPC_NAME_SIZE+32].max
- create_contents
- self.contents.font.size=T_m::NPC_NAME_SIZE
- self.contents.draw_text(0,Cache.system(T_m::NPC_ICON_TRADE).height+1,self.width-32,T_m::NPC_NAME_SIZE,name,1)
- self.contents.blt((self.width-Cache.system(T_m::NPC_ICON_TRADE).width-32)/2,0,Cache.system(T_m::NPC_ICON_TRADE),Rect.new(0,0,Cache.system(T_m::NPC_ICON_TRADE).width,Cache.system(T_m::NPC_ICON_TRADE).height))
- @time=10
- when "Door"
- self.opacity=255
- self.height=T_m::DOOR_NAME_SIZE+T_m::DOOR_TYPE_SIZE+32+2
- self.width=[(name.size/3+1)*T_m::DOOR_NAME_SIZE,add.size/3*T_m::DOOR_TYPE_SIZE].max+32
- create_contents
- dire=""
- case dir
- when 2
- dire="↑"
- when 4
- dire="→"
- when 6
- dire="←"
- when 8
- dire="↓"
- end
- self.contents.font.size=T_m::DOOR_NAME_SIZE
- self.contents.draw_text(0,0,self.width-32,T_m::DOOR_NAME_SIZE,dire+name,1)
- self.contents.font.size=T_m::DOOR_TYPE_SIZE
- self.contents.font.color=Color.new(105,105,105)
- self.contents.draw_text(0,T_m::DOOR_NAME_SIZE+3,self.width-32,T_m::DOOR_TYPE_SIZE,add,1)
- @time=10
- end
- end
- def refresh(x1,y1)
- if @type!="Door"
- self.x=x1-self.width/2
- self.y=y1-self.height+10
- if @time>0
- self.contents_opacity=255*(10-@time)/9
- @time-=1
- elsif @time<-1
- self.contents_opacity=255*(-@time-2)/9
- @time+=1
- elsif @time==-1
- self.dispose
- else
- self.contents_opacity=255
- end
- else
- @player_height= Cache.character($game_player.character_name).height / 4/2
- self.x=$game_player.screen_x-self.width/2
- self.y=$game_player.screen_y-@player_height-self.height-10
- if @time>0
- self.contents_opacity=255*(10-@time)/9
- @time-=1
- elsif @time<-1
- self.contents_opacity=255*(-@time-2)/9
- @time+=1
- elsif @time==-1
- self.dispose
- else
- self.contents_opacity=255
- end
- end
- end
- def disappear
- @time=-11 if @time==0
- end
- end
- #==============================================================================
- # ■ Game_Event
- #------------------------------------------------------------------------------
- # 对门牌窗口和NPC响应的追加定义
- # 感觉会很有冲突OTZ
- #==============================================================================
- class Game_Event < Game_Character
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- alias t_initialize initialize
- def initialize(map_id, event)
- t_initialize(map_id, event)
- get_info
- end
- #--------------------------------------------------------------------------
- # ● 设置事件页
- #--------------------------------------------------------------------------
- alias t_setup setup
- def setup(new_page)
- t_setup(new_page)
- self.NPC_dispose
- get_info
- end
- #--------------------------------------------------------------------------
- # ● 获取信息
- #--------------------------------------------------------------------------
- def get_info
- event=self
- section=[]
- @title=""
- return if event.list==nil
- if event.list[0].code==108
- case event.list[0].parameters[0]
- when "NPC"
- end_s="NPC_END"
- @title="NPC"
- @type="NPC"
- @name=""
- section=["type","name"]
- when "Item"
- end_s="Item_END"
- @title="Item"
- section=[]
- when "Door"
- end_s="Door_END"
- @title="Door"
- section=["type","left_name","left_range","left_type",
- "right_name","right_range","right_type",
- "up_name","up_range","up_type",
- "down_name","down_range","down_type"]
- @type="Door"
- @left_name=""
- @left_range=0
- @left_type=""
- @right_name=""
- @right_range=0
- @right_type=""
- @up_name=""
- @up_range=0
- @up_type=""
- @down_name=""
- @down_range=0
- @down_type=""
- end
- end
-
-
- @event_width = Cache.character(event.character_name).width / 4/4
- @event_height = Cache.character(event.character_name).height / 4/2
- for i in 0...event.list.size
- for j in section
- temp=readattr(event.list[i].parameters[0],j)
- if temp!=nil && temp != ""
- case j
- when "type"
- @type=temp
- when "name"
- @name=temp
- when "left_name"
- @left_name=temp
- when "left_range"
- @left_range=temp.to_i
- when "left_type"
- @left_type=temp
- when "right_name"
- @right_name=temp
- when "right_range"
- @right_range=temp.to_i
- when "right_type"
- @right_type=temp
- when "up_name"
- @up_name=temp
- when "up_range"
- @up_range=temp.to_i
- when "up_type"
- @up_type=temp
- when "down_name"
- @down_name=temp
- when "down_range"
- @down_range=temp.to_i
- when "down_type"
- @down_type=temp
- end
- end
- if event.list[i].parameters[0]==end_s
- breakable=true
- break
- else
- breakable=false
- end
- end
- break if breakable==true
- end
- end
- #--------------------------------------------------------------------------
- # ● 处理信息
- #--------------------------------------------------------------------------
- def t_dis
- x1=self.x
- x2=$game_player.x
- y1=self.y
- y2=$game_player.y
- temp_x=x1-x2
- temp_x=-temp_x if temp_x<0
- temp_y=y1-y2
- temp_y=-temp_y if temp_y<0
- if !(temp_x>5||temp_y>5)
- if @title!="Door"
- if $game_switches[T_m::NPC_S]==true
- if ((x1-x2==1 ||x2-x1==1) && y1==y2)||((y1-y2==1 ||y2-y1==1) && x1==x2)
- case @title
- when "NPC"
- if $npc_window[self.id].class!=Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@name) if $npc_window[self.id].class!=Window_NPC
- end
- if $npc_window[self.id].class==Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@name) if $npc_window[self.id].disposed?
- end
- when "Item"
- if $npc_window[self.id].class!=Window_NPC
- $npc_window[self.id]=Window_NPC.new("Item","") if $npc_window[self.id].class!=Window_NPC
- end
- if $npc_window[self.id].class==Window_NPC
- $npc_window[self.id]=Window_NPC.new("Item","") if $npc_window[self.id].disposed?
- end
- end
- elsif $npc_window[self.id].class==Window_NPC
- $npc_window[self.id].disappear
- end
- end
- elsif @title=="Door"
- if $game_switches[T_m::DOOR_S]==true
- if (@left_range!=0&&y1==y2 && x2-x1<0 && x1-x2<=@left_range)
- if $npc_window[self.id].class!=Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@left_name,@left_type,4) if $npc_window[self.id].class!=Window_NPC
- end
- if $npc_window[self.id].class==Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@left_name,@left_type,4) if $npc_window[self.id].disposed?
- end
-
-
- elsif (@right_range!=0&&y1==y2&&x2-x1>0&&x2-x1<=@right_range)
- if $npc_window[self.id].class!=Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@right_name,@right_type,6) if $npc_window[self.id].class!=Window_NPC
- end
- if $npc_window[self.id].class==Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@right_name,@right_type,6) if $npc_window[self.id].disposed?
- end
-
-
- elsif (@up_range!=0&&x1==x2&&y2-y1<0&&y1-y2<=@up_range)
- if $npc_window[self.id].class!=Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@up_name,@up_type,8) if $npc_window[self.id].class!=Window_NPC
- end
- if $npc_window[self.id].class==Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@up_name,@up_type,8) if $npc_window[self.id].disposed?
- end
-
-
- elsif (@down_range!=0&&x1==x2&&y2-y1>0&&y2-y1<=@down_range)
- if $npc_window[self.id].class!=Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@down_name,@down_type,2) if $npc_window[self.id].class!=Window_NPC
- end
- if $npc_window[self.id].class==Window_NPC
- $npc_window[self.id]=Window_NPC.new(@type,@down_name,@down_type,2) if $npc_window[self.id].disposed?
- end
-
-
- elsif $npc_window[self.id].class==Window_NPC
- $npc_window[self.id].disappear
- end
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 释放$npc_window[self.id]
- #--------------------------------------------------------------------------
- def NPC_dispose
- $npc_window[self.id].dispose if ($npc_window[self.id].class==Window_NPC&&(!$npc_window[self.id].disposed?))
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- alias t_update update
- def update
- t_dis
- if $npc_window[self.id].class==Window_NPC
- $npc_window[self.id].refresh(self.screen_x,self.screen_y-@event_height) unless $npc_window[self.id].disposed?
- end
- if $npc_window[self.id].class==Window_NPC && $game_player.transfer?
- $npc_window[self.id].dispose unless $npc_window[self.id].disposed?
- end
- t_update
- end
- end
- #==============================================================================
- # ■ Scene_Map
- #------------------------------------------------------------------------------
- # 对Scene_Map的追加定义。
- #==============================================================================
- class Scene_Map < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理时建立对象
- #--------------------------------------------------------------------------
- alias t_start start
- def start
- @window_roadtip = Window_Roadtip.new
- t_start
- end
- #--------------------------------------------------------------------------
- # ● 释放时释放对象
- #--------------------------------------------------------------------------
- alias t_terminate terminate
- def terminate
- @window_roadtip.dispose
- for event in $game_map.events.values
- event.NPC_dispose
- end
- t_terminate
- end
- #--------------------------------------------------------------------------
- # ● 刷新时刷新对象
- #--------------------------------------------------------------------------
- alias t_update update
- def update
- @window_roadtip.update
- t_update
- end
- end
复制代码
[本贴由 八云紫 于 2008-10-30 12:48:19 进行了编辑] |
|