| 赞 | 189 |
| VIP | |
| 好人卡 | |
| 积分 | 96 |
| 经验 | |
| 最后登录 | 2026-5-4 |
| 在线时间 | 5074 小时 |
- 梦石
- 0
- 星屑
- 9557
- 在线时间
- 5074 小时
- 注册时间
- 2013-6-21
- 回帖
- 3459
  
|
楼主 |
发表于 2015-5-17 17:11:28
|
显示全部楼层
本帖最后由 RyanBern 于 2016-7-8 19:16 编辑
本楼层作为图书馆的仓库使用。有些脚本和范例找不到原帖,但是资源还是在的,为了避免重开一帖的麻烦,类似的资源会储存在本楼。
[fold=01.全键盘脚本]
[pre lang="Ruby"]#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#
# 全键盘
# ★、Kboard.press?(键位) 返回是否按下这个键的判断。
# 比如条件分歧:Kboard.keyboard($R_Key_H)
# 则当按下键盘H键的时候条件分歧成立
#
# ★、Kboard.repeat?(键位) == 1 当连续按住某键返回真,否则为false
# 比如条件分歧:Kboard.keyb($R_Key_U) == 1
# 则当持续按下键盘U的时候条件分歧成立
#
# ★、Kboard.trigger?(键位,1) 似乎可以做开关用。按下一次变为true,再按变false
# 修改:夏娜
#
#============================================================================
module Kboard
#==========================================================================
# 以下是全键盘按键列表
#--------------------------------------------------------------------------
$Rmouse_BUTTON_L = 0x01 # left mouse button
$Rmouse_BUTTON_R = 0x02 # right mouse button
$Rmouse_BUTTON_M = 0x04 # middle mouse button
$Rmouse_BUTTON_4 = 0x05 # 4th mouse button
$Rmouse_BUTTON_5 = 0x06 # 5th mouse button
#--------------------------------------------------------------------------
$R_Key_BACK = 0x08 # BACKSPACE key
$R_Key_TAB = 0x09 # TAB key
$R_Key_RETURN = 0x0D # ENTER key
$R_Key_SHIFT = 0x10 # SHIFT key
$R_Key_CTLR = 0x11 # CTLR key
$R_Key_ALT = 0x12 # ALT key
$R_Key_PAUSE = 0x13 # PAUSE key
$R_Key_CAPITAL = 0x14 # CAPS LOCK key
$R_Key_ESCAPE = 0x1B # ESC key
$R_Key_SPACE = 0x20 # SPACEBAR
$R_Key_PRIOR = 0x21 # PAGE UP key
$R_Key_NEXT = 0x22 # PAGE DOWN key
$R_Key_END = 0x23 # END key
$R_Key_HOME = 0x24 # HOME key
$R_Key_LEFT = 0x25 # LEFT ARROW key
$R_Key_UP = 0x26 # UP ARROW key
$R_Key_RIGHT = 0x27 # RIGHT ARROW key
$R_Key_DOWN = 0x28 # DOWN ARROW key
$R_Key_SELECT = 0x29 # SELECT key
$R_Key_PRINT = 0x2A # PRINT key
$R_Key_SNAPSHOT = 0x2C # PRINT SCREEN key
$R_Key_INSERT = 0x2D # INS key
$R_Key_DELETE = 0x2E # DEL key
#--------------------------------------------------------------------------
$R_Key_0 = 0x30 # 0 key
$R_Key_1 = 0x31 # 1 key
$R_Key_2 = 0x32 # 2 key
$R_Key_3 = 0x33 # 3 key
$R_Key_4 = 0x34 # 4 key
$R_Key_5 = 0x35 # 5 key
$R_Key_6 = 0x36 # 6 key
$R_Key_7 = 0x37 # 7 key
$R_Key_8 = 0x38 # 8 key
$R_Key_9 = 0x39 # 9 key
#--------------------------------------------------------------------------
$R_Key_A = 0x41 # A key
$R_Key_B = 0x42 # B key
$R_Key_C = 0x43 # C key
$R_Key_D = 0x44 # D key
$R_Key_E = 0x45 # E key
$R_Key_F = 0x46 # F key
$R_Key_G = 0x47 # G key
$R_Key_H = 0x48 # H key
$R_Key_I = 0x49 # I key
$R_Key_J = 0x4A # J key
$R_Key_K = 0x4B # K key
$R_Key_L = 0x4C # L key
$R_Key_M = 0x4D # M key
$R_Key_N = 0x4E # N key
$R_Key_O = 0x4F # O key
$R_Key_P = 0x50 # P key
$R_Key_Q = 0x51 # Q key
$R_Key_R = 0x52 # R key
$R_Key_S = 0x53 # S key
$R_Key_T = 0x54 # T key
$R_Key_U = 0x55 # U key
$R_Key_V = 0x56 # V key
$R_Key_W = 0x57 # W key
$R_Key_X = 0x58 # X key
$R_Key_Y = 0x59 # Y key
$R_Key_Z = 0x5A # Z key
#--------------------------------------------------------------------------
$R_Key_LWIN = 0x5B # Left Windows key (Microsoft Natural keyboard)
$R_Key_RWIN = 0x5C # Right Windows key (Natural keyboard)
$R_Key_APPS = 0x5D # Applications key (Natural keyboard)
#--------------------------------------------------------------------------
$R_Key_NUMPAD0 = 0x60 # Numeric keypad 0 key
$R_Key_NUMPAD1 = 0x61 # Numeric keypad 1 key
$R_Key_NUMPAD2 = 0x62 # Numeric keypad 2 key
$R_Key_NUMPAD3 = 0x63 # Numeric keypad 3 key
$R_Key_NUMPAD4 = 0x64 # Numeric keypad 4 key
$R_Key_NUMPAD5 = 0x65 # Numeric keypad 5 key
$R_Key_NUMPAD6 = 0x66 # Numeric keypad 6 key
$R_Key_NUMPAD7 = 0x67 # Numeric keypad 7 key
$R_Key_NUMPAD8 = 0x68 # Numeric keypad 8 key
$R_Key_NUMPAD9 = 0x69 # Numeric keypad 9 key
$R_Key_MULTIPLY = 0x6A # Multiply key (*)
$R_Key_ADD = 0x6B # Add key (+)
$R_Key_SEPARATOR = 0x6C # Separator key
$R_Key_SUBTRACT = 0x6D # Subtract key (-)
$R_Key_DECIMAL = 0x6E # Decimal key
$R_Key_DIVIDE = 0x6F # Divide key (/)
#--------------------------------------------------------------------------
$R_Key_F1 = 0x70 # F1 key
$R_Key_F2 = 0x71 # F2 key
$R_Key_F3 = 0x72 # F3 key
$R_Key_F4 = 0x73 # F4 key
$R_Key_F5 = 0x74 # F5 key
$R_Key_F6 = 0x75 # F6 key
$R_Key_F7 = 0x76 # F7 key
$R_Key_F8 = 0x77 # F8 key
$R_Key_F9 = 0x78 # F9 key
$R_Key_F10 = 0x79 # F10 key
$R_Key_F11 = 0x7A # F11 key
$R_Key_F12 = 0x7B # F12 key
#--------------------------------------------------------------------------
$R_Key_NUMLOCK = 0x90 # NUM LOCK key
$R_Key_SCROLL = 0x91 # SCROLL LOCK key
#--------------------------------------------------------------------------
$R_Key_LSHIFT = 0xA0 # Left SHIFT key
$R_Key_RSHIFT = 0xA1 # Right SHIFT key
$R_Key_LCONTROL = 0xA2 # Left CONTROL key
$R_Key_RCONTROL = 0xA3 # Right CONTROL key
$R_Key_L_ALT = 0xA4 # Left ALT key
$R_Key_R_ALT = 0xA5 # Right ALT key
#--------------------------------------------------------------------------
$R_Key_SEP = 0xBC # , key
$R_Key_DASH = 0xBD # - key
$R_Key_DOTT = 0xBE # . Key
#--------------------------------------------------------------------------
module_function
@R_Key_Hash = {}
@R_Key_Repeat = {}
GetKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
#--------------------------------------------------------------------------
def press?(rkey)
return GetKeyState.call(rkey) != 0
end
#--------------------------------------------------------------------------
def repeat?(rkey)
result = GetKeyState.call(rkey)
if result != 0
if @R_Key_Repeat[rkey].nil?
@R_Key_Repeat[rkey] = 0
return true
end
@R_Key_Repeat[rkey] += 1
else
@R_Key_Repeat[rkey] = nil
@R_Key_Hash[rkey] = 0
end
if !@R_Key_Repeat[rkey].nil? and @R_Key_Repeat[rkey] > 4 # 4乃准确数字
@R_Key_Repeat[rkey] = 0
return true
else
return false
end
end
#--------------------------------------------------------------------------
def trigger?(rkey)
result = GetKeyState.call(rkey)
if @R_Key_Hash[rkey] == 1 and result != 0
return false
end
if result != 0
@R_Key_Hash[rkey] = 1
return true
else
@R_Key_Hash[rkey] = 0
return false
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================[/pre]
[/fold]
[fold=02.物品颜色]
[pre lang="Ruby"]#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#
# 脚本功能:给不同物品显示不同颜色,类似暗黑破坏神,比如套装为绿色,超级为金色
# 可以更改的种类包括物品、防具、特技、武器。
#
# 使用方法:对于不想为白色表示的物品,在描述中最后添加@6,@4一类的即可。
# 数字为颜色编号,和对话框中的一样。
# ——————————————————————————————————————
module RPG
class Skill
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def name_color_66RPG
name_color = @description.split(/@/)[1]
return name_color != nil ? name_color.to_i : 0
end
end
class Weapon
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def name_color_66RPG
name_color = @description.split(/@/)[1]
return name_color != nil ? name_color.to_i : 0
end
end
class Item
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def name_color_66RPG
name_color = @description.split(/@/)[1]
return name_color != nil ? name_color.to_i : 0
end
end
class Armor
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def name_color_66RPG
name_color = @description.split(/@/)[1]
return name != nil ? name_color.to_i : 0
end
end
end
# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 描绘物品名
# item : 物品
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_item_name(item, x, y)
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = text_color(item.name_color_66RPG)
self.contents.draw_text(x + 28, y, 212, 32, item.name.to_s)
end
end
# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_Item
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = text_color(item.name_color_66RPG)
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == disabled_color ? 128 : 255
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
end
# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 项目的描绘
# index : 项目符号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = text_color(item.name_color_66RPG)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
end
# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 描绘羡慕
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
# 获取物品所持数
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
# 价格在所持金以下、并且所持数不是 99 的情况下为普通颜色
# 除此之外的情况设置为无效文字色
if item.price <= $game_party.gold and number < 99
self.contents.font.color = text_color(item.name_color_66RPG)
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == disabled_color ? 128 : 255
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
end
end
# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_ShopSell < Window_Selectable
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目标号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
# 可以卖掉的显示为普通颜色、除此之外设置成无效文字颜色
if item.price > 0
self.contents.font.color = text_color(item.name_color_66RPG)
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == disabled_color ? 128 : 255
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
end
# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_Skill
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = text_color(skill.name_color_66RPG)
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == disabled_color ? 128 : 255
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
[/pre][/fold]
[fold=03.技能熟练度]
[pre lang="Ruby"]#=====================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#====================================================================
#====================================================================
# ■ スキルアップデート Ver. 4.4.0 by Claimh
#---------------------------------------------------------------
# スキルごとにレベル制を導入する
# 戦闘中にスキルを使用するほど、威力上昇、消費SP減少、命中率上昇
#==============================================================
module Skill_updata
S_MIGHT = []
S_COST = []
S_HIT = []
S_LEVEL = []
S_INTER = []
S_SLOPE = []
S_ANIME = []
S_ELEMENT = []
S_STATE_P = []
S_STATE_N = []
#=============================================================
# □ 自定义内容
#==============================================================
# 威力上升使用true/false
SKILL_MIGHT_UP = true
# SP消耗减少使用true/false
SP_COST_DOWN = true
# 命中率上升使用true/false
SKILL_HIT_UP = true
# 属性变化的使用true/false
ELEMENT_CHANGE = true
# 状态变化的使用true/false
STATE_CHANGE = true
# 显示特技等级上升true/false
SHOW_SKILL_LV_UP = true
# 等级上升的声效,不用的时候就=nil
SKILLUP_SE = "056-Right02"
# 菜单使用计数true/false
MENU_COUNT = false
# 升级所需次数
UPDATA_INTERVAL = 1
# 等级上限
LEVEL_LIMIT = 20
# 威力上升率(%%)
MIGHT_RATE = 0.5
# SP消耗减少率(%)
COST_RATE = 3
# 命中上升率(%)
HIT_RATE = 1
#-------------------------------------------------------------
# 特别技能的详细设定,57和61号特技分别是十字斩和扫荡,大家最熟悉的两个招数
#----------------------------------------------------------------
# 界限水平
# S_LEVEL[技艺ID]=[角色ID=>界限,…]
S_LEVEL[57] = {1=>18, 2=>12, 3=>5, 4=>12, 5=>12, 6=>12, 7=>12, 8=>12}
S_LEVEL[61] = {1=>12, 2=>18, 3=>15, 4=>12, 5=>12, 6=>12, 7=>12, 8=>12}
# 技艺&actor威力上升率
# S_MIGHT[技艺ID]=[角色ID=>威力上升率,…]
S_MIGHT[57] = {1=>8, 2=>2, 3=>5, 4=>2, 5=>2, 6=>2, 7=>2, 8=>2}
S_MIGHT[61] = {1=>2, 2=>8, 3=>5, 4=>2, 5=>2, 6=>2, 7=>2, 8=>2}
# 技艺&actorSP消费减少率
# S_COST[技艺ID]=[角色ID=>SP消费减少率,…]
S_COST[57] = {1=>8, 2=>2, 3=>5, 4=>2, 5=>2, 6=>2, 7=>2, 8=>2}
S_COST[61] = {1=>2, 2=>8, 3=>5, 4=>2, 5=>2, 6=>2, 7=>2, 8=>2}
# 技艺&actor命中率
# S_HIT[技艺ID]=[角色ID=>命中上升率,…]
S_HIT[57] = {1=>2, 2=>1, 3=>1, 4=>1, 5=>1, 6=>1, 7=>1, 8=>1}
S_HIT[61] = {1=>1, 2=>2, 3=>1, 4=>1, 5=>1, 6=>1, 7=>1, 8=>1}
#-----------------------------------------------------------------
# 技能成长的具体调节
#-----------------------------------------------------------------
# 技艺的增长图形
# 0:使用技艺一定回数的话提高水平
# 1:技艺一定回数+每水平の使用提高水平
SKILL_PATTERN = 0
# 技艺水平上升间隔每(使用几回Lv提高)
# ※没有设定的情况→基本设定被适应
# S_INTER[技艺ID]=[actorID=>上升间隔,…]
S_INTER[57] = {1=>5, 2=>8, 3=>8, 4=>8, 5=>8, 6=>8, 7=>8, 8=>8}
# スキルレベル上昇の傾き(パターン1を使用する場合のみ必要)
# ※設定がない場合は1となります。
# S_SLOPE[スキルID] = [アクターID=>上昇の傾き, …]
S_SLOPE[57] = {1=>5, 2=>8, 3=>8, 4=>8, 5=>8, 6=>8, 7=>8, 8=>8}
#-------------------------------------------------------------
# 技艺增长的话使之动画变化
# 记录格式: S_ANIME[技艺ID] = [角色ID=>[[等级, 动画ID]], ・・・]
#------------------------------------------------------------
# 实施技艺增长的动画变化?
USE_S_ANIME = true
# 設定例
# 1号角色,57号特技,lv5,lv10动画变化
# 2号角色,Lv.11动画变化
S_ANIME[57] = {1=>[[5, 69], [10, 70]], 2=>[[11, 70]]}
#-------------------------------------------------------------------
# 属性変化/状态変化
#------------------------------------------------------------------
# 属性変化
# S_ELEMENT[技艺ID] = {角色ID=>{水平=>[属性ID,属性ID…]}, ・・・・}
S_ELEMENT[57] = {1=>{1=>[1], 2=>[2], 3=>[3]}, 2=>{1=>[2], 2=>[5]}}
# 状态変化+
# S_STATE_P[技艺ID] = {角色ID=>{水平=>[属性ID,属性ID…]}, ・・・・}
S_STATE_P[57] = {1=>{1=>[1], 2=>[2], 3=>[3]}, 2=>{1=>[2], 2=>[5]}}
# 状态変化-
# S_STATE_N[技艺ID] = {角色ID=>{水平=>[属性ID,属性ID…]}, ・・・・}
S_STATE_N[57] = {1=>{1=>[1], 2=>[2], 3=>[3]}, 2=>{1=>[2], 2=>[5]}}
#==================================================================
# □ 自定义内容终了
#==================================================================
end
class Game_Actor
include Skill_updata
attr_accessor :skill_use # スキル使用回数
attr_accessor :skill_level # スキルレベル
attr_accessor :skill_power # スキル威力更新値
attr_accessor :skill_sp_cost # スキルSP消費更新値
attr_accessor :skill_hit # スキル命中率
attr_accessor :skill_up # レベルアップフラグ
attr_accessor :skill_list # スキルEXPリスト
alias skill_updata_init setup
def setup(actor_id)
skill_updata_init(actor_id)
@skill_use = []
@skill_level = []
@skill_power = []
@skill_sp_cost = []
@skill_hit = []
@skill_up = false
@skill_list = []
for id in 1...$data_skills.size
@skill_use[id] = 0
@skill_level[id] = 0
@skill_power[id] = $data_skills[id].power
@skill_sp_cost[id] = $data_skills[id].sp_cost
@skill_hit[id] = $data_skills[id].hit
@skill_list[id] = make_skill_list(id)
end
end
#-------------------------------------------------------------
# ● スキルEXP 計算
#------------------------------------------------------------
def make_skill_list(skill_id)
interval = S_INTER[skill_id]
up_interval = ( (interval != nil and interval[@actor_id] != nil) ? interval[@actor_id] : UPDATA_INTERVAL )
slope = S_SLOPE[skill_id]
up_slope = ( (slope != nil and slope[@actor_id] != nil) ? slope[@actor_id] : 1 )
limit = S_LEVEL[skill_id]
limit_lv = ( (limit != nil and limit[@actor_id] != nil) ? limit[@actor_id] : LEVEL_LIMIT )
list = []
list[0] = 0
for lv in 1...limit_lv+1
exp = 0
case SKILL_PATTERN
when 0
exp = up_interval * lv
when 1
exp = list[lv-1] + up_slope * lv + up_interval
end
list[lv] = exp.truncate
end
return list
end
end
class Game_Battler
include Skill_updata
#-----------------------------------------------------------------
# ● スキルの効果適用
# user : スキルの使用者 (バトラー)
# skill : スキル
#-------------------------------------------------------------
alias skill_effect_update skill_effect
def skill_effect(user, skill)
up_flag = false
if user.is_a?(Game_Actor) and ($scene.is_a?(Scene_Battle) or MENU_COUNT)
skill_update_main(user, skill)
skill_base = skill.dup
# 威力上昇
if SKILL_MIGHT_UP
skill.power = user.skill_power[skill.id]
end
# 命中率上昇
if SKILL_HIT_UP
skill.hit = user.skill_hit[skill.id]
end
# 属性変化
if ELEMENT_CHANGE and S_ELEMENT != []
ele1 = S_ELEMENT[skill.id]
if ele1 != nil and ele1[user.id] != nil
ele2 = ele1[user.id]
if ele2 != [] and ele2[user.skill_level[skill.id]] != nil
skill.element_set = ele2[user.skill_level[skill.id]]
end
end
end
# ステート変化
if STATE_CHANGE
if S_STATE_P != []
pst1 = S_STATE_P[skill.id]
if pst1 != nil and pst1[user.id] != nil
pst2 = pst1[user.id]
if pst2 != nil and pst2[user.skill_level[skill.id]] != nil
skill.plus_state_set = pst2[user.skill_level[skill.id]]
# p skill.plus_state_set
end
end
end
if S_STATE_N != []
nst1 = S_STATE_N[skill.id]
if nst1 != nil and nst1[user.id] != nil
nst2 = nst1[user.id]
if nst1 != nil and nst2[user.skill_level[skill.id]] != nil
skill.minus_state_set = nst2[user.skill_level[skill.id]]
end
end
end
end
up_flag = true
end
ret = skill_effect_update(user, skill) # 原物
if up_flag
skill = skill_base
# Miss時には後戻し
if self.damage == "Miss"
skill_use_recount(user, skill)
end
end
return ret
end
#------------------------------------------------------------
# ● スキルアップデータメイン
#-------------------------------------------------------------
def skill_update_main(actor, skill)
# スキル使用回数のカウント
actor.skill_use[skill.id] += 1
# リミット取得
limit = S_LEVEL[skill.id]
s_limit = ( (limit != nil and limit[actor.id] != nil) ? limit[actor.id] : LEVEL_LIMIT)
# 書き換え限界到達
if s_limit == false or actor.skill_level[skill.id] < s_limit
# レベルアップ間隔取得
interval = actor.skill_list[skill.id]
# 書き換え回数到達
if actor.skill_use[skill.id] == interval[actor.skill_level[skill.id]+1]
# スキルレベル上昇
actor.skill_level[skill.id] += 1
actor.skill_up = true
# 威力上昇 = 有効
if SKILL_MIGHT_UP
might = S_MIGHT[skill.id]
might_rate = ((might != nil and might[actor.id] != nil) ? might[actor.id] : MIGHT_RATE)
# 補正値更新
actor.skill_power[skill.id] += skill.power * might_rate / 100
actor.skill_power[skill.id] = actor.skill_power[skill.id].truncate
end
# SP消費減少 = 有効
if SP_COST_DOWN
cost = S_COST[skill.id]
cost_rate = ((cost != nil and cost[actor.id] != nil) ? cost[actor.id] : COST_RATE)
actor.skill_sp_cost[skill.id] -= skill.sp_cost * cost_rate / 100
actor.skill_sp_cost[skill.id] = actor.skill_sp_cost[skill.id].truncate
# SP消費が0以下はありえない
if actor.skill_sp_cost[skill.id] < 0
actor.skill_sp_cost[skill.id] = 0
end
end
# 命中率上昇 = 有効
if SKILL_HIT_UP
hit = S_HIT[skill.id]
hit_rate = ((hit != nil and hit[actor.id] != nil) ? hit[actor.id] : HIT_RATE)
actor.skill_hit[skill.id] += skill.hit * hit_rate / 100
actor.skill_hit[skill.id] = actor.skill_hit[skill.id].truncate
# 100以上はありえない
if actor.skill_hit[skill.id] > 100
actor.skill_hit[skill.id] = 100
end
end
end
end
end
#---------------------------------------------------------
# ● 再カウント
#------------------------------------------------------
def skill_use_recount(actor, skill)
if actor.skill_up
actor.skill_level[skill.id] -= 1
# 威力を再計算
if SKILL_MIGHT_UP
actor.skill_power[skill.id] = skill.power
might = S_MIGHT[skill.id]
might_rate = ((might != nil and might[actor.id] != nil) ? might[actor.id] : MIGHT_RATE)
for i in 1...actor.skill_level[skill.id]
actor.skill_power[skill.id] += skill.power * might_rate / 100
actor.skill_power[skill.id] = actor.skill_power[skill.id].truncate
end
end
# SP消費再計算
if SP_COST_DOWN
actor.skill_sp_cost[skill.id] = skill.sp_cost
cost = S_COST[skill.id]
cost_rate = ((cost != nil and cost[actor.id] != nil) ? cost[actor.id] : COST_RATE)
for i in 1...actor.skill_level[skill.id]
actor.skill_sp_cost[skill.id] -= skill.sp_cost * cost_rate / 100
actor.skill_sp_cost[skill.id] = actor.skill_sp_cost[skill.id].truncate
end
# SP消費が0以下はありえない
if actor.skill_sp_cost[skill.id] < 0
actor.skill_sp_cost[skill.id] = 0
end
end
# 命中率再計算
if SKILL_HIT_UP
actor.skill_hit[skill.id] = skill.hit
hit = S_HIT[skill.id]
hit_rate = ((hit != nil and hit[actor.id] != nil) ? hit[actor.id] : HIT_RATE)
for i in 1...actor.skill_level[skill.id]
actor.skill_hit[skill.id] += skill.hit * hit_rate / 100
actor.skill_hit[skill.id] = actor.skill_hit[skill.id].truncate
end
# 100以上はありえない
if actor.skill_hit[skill.id] > 100
actor.skill_hit[skill.id] = 100
end
end
actor.skill_up = false
end
actor.skill_use[skill.id] -= 1
end
end
#=================================================================
# スキル成長によるアニメーション変化
#=================================================================
class Scene_Battle
include Skill_updata
#--------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション)
#-----------------------------------------------------------
alias update_phase4_step4_skillup update_phase4_step4
def update_phase4_step4
update_phase4_step4_skillup
if @active_battler.is_a?(Game_Actor) and USE_S_ANIME
s_anime = S_ANIME[@skill.id]
# 設定がないなら無視
if s_anime != nil and s_anime[@active_battler.id] != nil
s_anime_set = s_anime[@active_battler.id]
for i in 0...s_anime_set.size
s_anime_def = s_anime_set
# 規定レベル以上
if @active_battler.skill_level[@skill.id] >= s_anime_def[0]
# 対象側アニメーション
for target in @target_battlers
target.animation_id = s_anime_def[1]
end
end
end
end
end
end
end
#=================================================================
# 以下、レベルアップ表示部分(レベルアップ表示がいらないなら消してもOK)
#=================================================================
class Scene_Battle
include Skill_updata
if SHOW_SKILL_LV_UP
#----------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
#----------------------------------------------------------
alias update_phase4_step2_skillup update_phase4_step2
def update_phase4_step2
if @active_battler.is_a?(Game_Actor)
@active_battler.skill_up = false
end
@skillup = false
update_phase4_step2_skillup # 原物
end
#-------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション)
#-----------------------------------------------------------
alias update_phase4_step3_skillup update_phase4_step3
def update_phase4_step3
if @active_battler.is_a?(Game_Actor) and @active_battler.skill_up != false
@skillup = true
@skill_up_window = Window_Skillup.new(@active_battler)
if SKILLUP_SE != nil
Audio.se_play("Audio/SE/" + SKILLUP_SE)
sleep(0.1)
end
end
update_phase4_step3_skillup
end
#--------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
#--------------------------------------------------------------
alias update_phase4_step5_skillup update_phase4_step5
def update_phase4_step5
if @active_battler.is_a?(Game_Actor) and @skillup
@skill_up_window.dispose
@active_battler.skill_up = false
@skillup = false
end
update_phase4_step5_skillup # 原物
end
#---------------------------------------------------------------
# ● フレーム更新
#----------------------------------------------------------------
alias update_skillup update
def update
if @active_battler.is_a?(Game_Actor) and @active_battler.skill_up and @skillup
@skill_up_window.contents_opacity -= 4
end
update_skillup # 原物
end
end # if SHOW_SKILL_LV_UP
end
class Window_Skillup < Window_Base
#--------------------------------------------------------------
# ● オブジェクト初期化
# actor : アクター
#-------------------------------------------------------------
def initialize(actor)
super(actor.screen_x-140, 260, 250, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.contents.font.color = Color.new(255, 64, 0)
self.contents.draw_text(80, 0, 150, 32, "LEVEL UP!")
end
end
#====================================================================
# 以下、再定義部分を含む(SP消費減少の機能がいらないなら消してもOK)
#====================================================================
class Window_Skill < Window_Selectable
#----------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#-----------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
#-修正-----
@actor.skill_level[skill.id] = 0 if @actor.skill_level[skill.id] == nil
name_level = skill.name + "(Lv" + @actor.skill_level[skill.id].to_s + ")"
self.contents.draw_text(x + 28, y, 204, 32, name_level, 0)
@actor.skill_sp_cost[skill.id] = skill.sp_cost if @actor.skill_sp_cost[skill.id] == nil
self.contents.draw_text(x + 232, y, 48, 32, @actor.skill_sp_cost[skill.id].to_s, 2)
#----------
end
end
class Scene_Skill
#----------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#-------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# ターゲットウィンドウを消去
@skill_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# SP 切れなどで使用できなくなった場合
unless @actor.skill_can_use?(@skill.id)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にスキルの使用効果を適用
used = false
for i in $game_party.actors
used |= i.skill_effect(@actor, @skill)
end
end
# ターゲットが使用者の場合
if @target_window.index <= -2
# ターゲットのアクターにスキルの使用効果を適用
target = $game_party.actors[@target_window.index + 10]
used = target.skill_effect(@actor, @skill)
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにスキルの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.skill_effect(@actor, @skill)
end
# スキルを使った場合
if used
# スキルの使用時 SE を演奏
$game_system.se_play(@skill.menu_se)
#-----修正---------------------------------------------
@actor.skill_sp_cost[@skill.id] = @skill.sp_cost if @actor.skill_sp_cost[@skill.id] == nil
# SP 消費
@actor.sp -= @actor.skill_sp_cost[@skill.id]
#------------------------------------------------
# 各ウィンドウの内容を再作成
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @skill.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @skill.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# スキルを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
class Scene_Battle
include Skill_updata
#------------------------------------------------------
# ● スキルアクション 結果作成
#-------------------------------------------------------
alias make_skill_action_result_skill_update make_skill_action_result
def make_skill_action_result
make_skill_action_result_skill_update
# SP 消費
if SP_COST_DOWN and @active_battler.is_a?(Game_Actor)
@active_battler.sp += @skill.sp_cost
@active_battler.sp -= @active_battler.skill_sp_cost[@skill.id]
end
end
end
class Game_Battler
#--------------------------------------------------------
# ● スキルの使用可能判定
# skill_id : スキル ID
#------------------------------------------------------
alias skill_update_can_use? skill_can_use?
def skill_can_use?(skill_id)
ret = skill_update_can_use?(skill_id)
if !ret and SP_COST_DOWN
# SP が足りない場合は使用不可となった?
if $data_skills[skill_id].sp_cost > self.sp
if self.is_a?(Game_Actor)
skill_sp_cost = self.skill_sp_cost[skill_id]
if skill_sp_cost < self.sp
ret = true
end
end
end
end
return ret
end
end
#===============================================================
# イベントスクリプト操作
#===============================================================
class Interpreter
include Skill_updata
#-----------------------------------------------------------
# ● スキルレベル設定(レベルセット)
# actor_id : アクターID
# skill_id : スキルID
# level : 設定レベル
#-----------------------------------------------------------
def set_skill_level(actor_id, skill_id, level)
actor = $game_actors[actor_id]
skill = $data_skills[skill_id]
# リミット取得
limit = S_LEVEL[skill_id]
s_limit = ( (limit != nil and limit[actor.id] != nil) ? limit[actor.id] : LEVEL_LIMIT)
if level > s_limit or level < 0
return
end
# レベル
actor.skill_level[skill.id] = level
# 使用回数
use_list = actor.skill_list[skill.id]
actor.skill_use[skill.id] = use_list[level]
# 威力を再計算
if SKILL_MIGHT_UP
actor.skill_power[skill.id] = skill.power
might = S_MIGHT[skill.id]
might_rate = ((might != nil and might[actor.id] != nil) ? might[actor.id] : MIGHT_RATE)
for i in 0...level
actor.skill_power[skill.id] += skill.power * might_rate / 100
actor.skill_power[skill.id] = actor.skill_power[skill.id].truncate
end
end
# SP消費再計算
if SP_COST_DOWN
actor.skill_sp_cost[skill.id] = skill.sp_cost
cost = S_COST[skill.id]
cost_rate = ((cost != nil and cost[actor.id] != nil) ? cost[actor.id] : COST_RATE)
for i in 0...level
actor.skill_sp_cost[skill.id] -= skill.sp_cost * cost_rate / 100
actor.skill_sp_cost[skill.id] = actor.skill_sp_cost[skill.id].truncate
end
# SP消費が0以下はありえない
if actor.skill_sp_cost[skill.id] < 0
actor.skill_sp_cost[skill.id] = 0
end
end
# 命中率再計算
if SKILL_HIT_UP
actor.skill_hit[skill.id] = skill.hit
hit = S_HIT[skill.id]
hit_rate = ((hit != nil and hit[actor.id] != nil) ? hit[actor.id] : HIT_RATE)
for i in 0...level
actor.skill_hit[skill.id] += skill.hit * hit_rate / 100
actor.skill_hit[skill.id] = actor.skill_hit[skill.id].truncate
end
# 100以上はありえない
if actor.skill_hit[skill.id] > 100
actor.skill_hit[skill.id] = 100
end
end
end
#---------------------------------------------------------
# ● スキルレベル設定(レベルアップ)
# actor_id : アクターID
# skill_id : スキルID
#--------------------------------------------------------
def skill_level_up(actor_id, skill_id)
actor = $game_actors[actor_id]
set_skill_level(actor_id, skill_id, actor.skill_level[skill_id]+1)
end
#-------------------------------------------------------
# ● スキルレベル設定(レベルダウン)
# actor_id : アクターID
# skill_id : スキルID
#--------------------------------------------------------
def skill_level_down(actor_id, skill_id)
actor = $game_actors[actor_id]
set_skill_level(actor_id, skill_id, actor.skill_level[skill_id]-1)
end
end
#==================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==================================================================
[/pre][/fold]
[fold=04.空手攻防]
[pre lang="Ruby"]#=========================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#=========================================================================
# 空手的攻击防御力 by Claimh
#------------------------------------------------------------------
# http://www.k3.dion.ne.jp/~claimh/
#========================================================================
module Arm_Element
ARM_ATK = []
ARM_PDEF = []
ARM_MDEF = []
ARM_ELEMENT = []
ARM_ELE_PLUS = []
ARM_ELE_MINUS = []
ARM_ANIMATION1 = []
ARM_ANIMATION2 = []
#===================================================================
# 自定义开始
#====================================================================
# 空手时1号角色攻击力与力量值的百分比关系(60%)
ARM_ATK[1] = 0.6
# 空手时2号角色攻击力与力量值的百分比关系(70%),以下类推,不一一举例。
ARM_ATK[1] = 0.7
# 空手时1号角色防御力与灵巧值的百分比关系(60%)
ARM_PDEF[1] = 0.6
# 空手时1号角色魔法防御力与速度值的百分比关系(60%)
ARM_MDEF[1] = 0.6
# 空手时攻击方动画编号
ARM_ANIMATION1[1] = 1
# 空手时挨打方动画编号
ARM_ANIMATION2[1] = 4
#————以下几个慎用,是空手时的属性增减,不推荐修改
ARM_ELEMENT[1] = [1]
ARM_ELE_PLUS[1] = []
ARM_ELE_MINUS[1] = []
end
class Game_Actor < Game_Battler
include Arm_Element
#--------------------------------------------------------------------
#------------------------------------------------------------------
alias base_atk_arm base_atk
def base_atk
if @weapon_id == 0 and ARM_ATK[@actor_id] != nil
return $data_actors[@actor_id].parameters[2, @level] * ARM_ATK[@actor_id]
end
return base_atk_arm
end
#--------------------------------------------------------------------
#-------------------------------------------------------------------
alias base_pdef_arm base_pdef
def base_pdef
if @weapon_id == 0 and ARM_PDEF[@actor_id] != nil
return base_pdef_arm + $data_actors[@actor_id].parameters[3, @level] * ARM_PDEF[@actor_id]
end
return base_pdef_arm
end
#--------------------------------------------------------------------
#--------------------------------------------------------------------
alias base_mdef_arm base_mdef
def base_mdef
if @weapon_id == 0 and ARM_MDEF[@actor_id] != nil
return base_mdef_arm + $data_actors[@actor_id].parameters[4, @level] * ARM_MDEF[@actor_id]
end
return base_mdef_arm
end
#------------------------------------------------------------------
#--------------------------------------------------------------
alias element_set_arm element_set
def element_set
if @weapon_id == 0 and ARM_ELEMENT[@actor_id] != []
return ARM_ELEMENT[@actor_id]
end
return element_set_arm
end
#-----------------------------------------------------------------
#-------------------------------------------------------------------
alias plus_state_set_arm plus_state_set
def plus_state_set
if @weapon_id == 0 and ARM_ELE_PLUS[@actor_id] != []
return ARM_ELE_PLUS[@actor_id]
end
return plus_state_set_arm
end
#-------------------------------------------------------------------
#------------------------------------------------------------------
alias minus_state_set_arm minus_state_set
def minus_state_set
if @weapon_id == 0 and ARM_ELE_MINUS[@actor_id] != []
return ARM_ELE_MINUS[@actor_id]
end
return minus_state_set_arm
end
#------------------------------------------------------------------
#-----------------------------------------------------------------
alias animation1_id_arm animation1_id
def animation1_id
if @weapon_id == 0 and ARM_ANIMATION1[@actor_id] != nil
return ARM_ANIMATION1[@actor_id]
end
return animation1_id_arm
end
#---------------------------------------------------------------------
#------------------------------------------------------------------
alias animation2_id_arm animation2_id
def animation2_id
if @weapon_id == 0 and ARM_ANIMATION2[@actor_id] != nil
return ARM_ANIMATION2[@actor_id]
end
return animation2_id_arm
end
end
#=====================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#=====================================================================
[/pre][/fold]
[fold=05.地图显示变量]
[pre lang="Ruby"]#==========================================================================
# 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。
#==========================================================================
VAR_SWITCH = 26 # 26号开关打开此脚本才工作,关闭则停止运算,并且透明
VAR_REFRESH_SWITCH = 27 # 27号开关控制强制刷新,使用时机:1、把窗口由透明变为不透明(包括第一次使用时),2、游戏中用脚本更改了$var
$var = []
$var = [[1,0,0],[2,32,32],[3,64,32]] #所有需要显示在地图并且刷新的变量,可在游戏中用脚本更改。格式:[变量编号,x坐标,y坐标]
#==============================================================================
# ■ Window_Var
#------------------------------------------------------------------------------
# 显示变量的窗口。
#==============================================================================
class Window_Var < Window_Base#注意前面那个window_var是文件名
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(-16, -16, 640+32, 480+32)#最后面那个数字是宽要显示多个需要改大,前面一个是长~
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 255 # 这个是背景透明
self.opacity = 255 # 这个是边框和背景都透明
self.contents_opacity = 255 # 这个是内容透明
self.visible = false
self.z=9999
@var = $var
@var_a = []
for var_draw in $var
@var_a[var_draw[0]] = $game_variables[var_draw[0]]
end
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if $game_switches[VAR_SWITCH]
@var = $var # 记录现在变量数组结构
self.contents.clear # 清除以前的东西
for var_draw in @var
@var_a[var_draw[0]] = $game_variables[var_draw[0]] # 记录现在的游戏变量
self.contents.draw_text(var_draw[1],var_draw[2],640,32,@var_a[var_draw[0]].to_s)
end
end
end
#--------------------------------------------------------------------------
# ● 判断文字刷新。节约内存用
#--------------------------------------------------------------------------
def judge
for var_draw in $var
if @var_a[var_draw[0]] != $game_variables[var_draw[0]] #如果现在记录的变量和游戏变量不同,刷新
return true
end
end
if $game_switches[VAR_REFRESH_SWITCH] # 强制刷新的时候,刷新
$game_switches[VAR_REFRESH_SWITCH] = false
return true
end
return false
end
end
class Scene_Map
alias var_66rpg_main main
def main
@var_window = Window_Var.new
@var_window.opacity = 0
var_66rpg_main
@var_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
alias var_66rpg_update update
def update
var_66rpg_update
if $game_switches[VAR_SWITCH]
@var_window.visible = true
@var_window.refresh if @var_window.judge
else
@var_window.visible = false
end
end
end
#==========================================================================
# 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。
#==========================================================================
[/pre][/fold]
[fold=06.跳过标题画面]
[pre lang="Ruby"]#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
class Scene_Title
#==============================================================================
# 脚本作者:朱仔メ龍 QQ:251724722
# 脚本转载请保留以上信息
#==============================================================================
def main
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
$game_system = Game_System.new
Graphics.frame_count = 0
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$game_party.setup_starting_members
$game_map.setup($data_system.start_map_id)
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$game_map.autoplay
$game_map.update
$scene = Scene_Map.new
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
[/pre][/fold]
[fold=07.图片标题]
[pre lang="Ruby"]=begin
使用方法
全选后插入到main前面,只有在Pictures\下面放入6张图片:start-1.png,start-2.png,continue-1png,continue-2.png,exit-1.png,exit-2.png
脚本冲突可能:各种涉及了Title的脚本都有可能冲突。
编者注:建立一个新工程,然后将下载的范例提供的内容全部粘贴过去,替换原文件
=end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#==============================================================================
# ■ 图片标题菜单1.0
# Scene_Title
#------------------------------------------------------------------------------
# 作者:chaochao
# http://zhuchao.go1.icpcn.com
#==============================================================================
class Scene_Title
def main
if $BTEST
battle_test
return
end
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
$game_system = Game_System.new
# 生成标题图形
@sprite = [Sprite.new]
for i in 0..6
@sprite = Sprite.new
@sprite.opacity = 0
end
@sprite[0].bitmap = RPG::Cache.title($data_system.title_name)
@sprite[0].opacity = 0
#开始游戏的图片
@sprite[1].bitmap = Bitmap.new("Graphics/Pictures/start-1.png")
@sprite[2].bitmap = Bitmap.new("Graphics/Pictures/start-2.png")
#继续游戏的图片
@sprite[3].bitmap = Bitmap.new("Graphics/Pictures/continue-1.png")
@sprite[4].bitmap = Bitmap.new("Graphics/Pictures/continue-2.png")
#结束游戏的图片
@sprite[5].bitmap = Bitmap.new("Graphics/Pictures/exit-1.png")
@sprite[6].bitmap = Bitmap.new("Graphics/Pictures/exit-2.png")
#图片位置
for i in 1..6
x=110
y=(i+1)/2*35+240
@sprite.x =x
@sprite.y =y
end
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
if @continue_enabled
@command_index = 1
else
@command_index = 0
@sprite[3].tone = Tone.new(0, 0, 0, 255)
@sprite[4].tone = Tone.new(0, 0, 0, 255)
end
$game_system.bgm_play($data_system.title_bgm)
Audio.me_stop
Audio.bgs_stop
Graphics.transition
loop do
Graphics.update
#淡出背景圖形
if @sprite[0].opacity <= 255
@sprite[0].opacity += 15
end
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
# 釋放圖形
for i in 0..6
@sprite.bitmap.dispose
@sprite.dispose
end
end
def update
chaochaocommandchaochao
if Input.trigger?(Input::C)
case @command_index
when 0
command_new_game
when 1
command_continue
when 2
command_shutdown
end
end
end
def chaochaocommandchaochao
if Input.trigger?(Input::UP)
@command_index -= 1
if @command_index < 0
@command_index = 2
end
$game_system.se_play($data_system.cursor_se)
end
if Input.trigger?(Input::DOWN)
@command_index += 1
if @command_index > 2
@command_index = 0
end
$game_system.se_play($data_system.cursor_se)
end
case @command_index
when 0
if @sprite[1].opacity >= 0
@sprite[1].opacity -= 30
end
if @sprite[2].opacity <= 240
@sprite[2].opacity += 30
end
if @sprite[3].opacity <= 210
@sprite[3].opacity += 30
end
if @sprite[4].opacity >= 0
@sprite[4].opacity -= 30
end
if @sprite[5].opacity <= 210
@sprite[5].opacity += 30
end
if @sprite[6].opacity >= 0
@sprite[6].opacity -= 30
end
when 1
if @sprite[1].opacity <= 210
@sprite[1].opacity += 30
end
if @sprite[2].opacity >= 0
@sprite[2].opacity -= 30
end
if @sprite[3].opacity >= 0
@sprite[3].opacity -= 30
end
if @sprite[4].opacity <= 240
@sprite[4].opacity += 30
end
if @sprite[5].opacity <= 210
@sprite[5].opacity += 30
end
if @sprite[6].opacity >= 0
@sprite[6].opacity -= 30
end
when 2
if @sprite[1].opacity <= 210
@sprite[1].opacity += 30
end
if @sprite[2].opacity >= 0
@sprite[2].opacity -= 30
end
if @sprite[3].opacity <= 210
@sprite[3].opacity += 30
end
if @sprite[4].opacity >= 0
@sprite[4].opacity -= 30
end
if @sprite[5].opacity >= 0
@sprite[5].opacity -= 30
end
if @sprite[6].opacity <= 240
@sprite[6].opacity += 30
end
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
[/pre][/fold]
[fold=08.人物介绍]
[pre lang="Ruby"]#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
# 人物介绍 Ver. 1.1 作者: Claimh 翻译与修正:柳柳
#------------------------------------------------------------------------------
# http://www.k3.dion.ne.jp/~claimh/
#==============================================================================
#——功能简介:在状态页面按下回车键会进入人物介绍页面。
#——如果想自行建立功能,使用$scene = Scene_Charactor.new(角色编号)即可
#——如果自行建立了功能不想使用默认的切换,去掉217行以后的内容
#——以下数组,如果人物超过8人,请自行继续添加(一般游戏没那么多主人公吧)
#——如果想更改内容,比如把“体重”改为“智商”,请修改102-107行的文字内容
# 从状态页面切换至人物介绍页面的按键
CHENGE_KEY = Input::C
#--------------------------------------------------------------------------
# 人物年龄 (自定义)
#--------------------------------------------------------------------------
CHARA_AGE = ["17","16","??","??","??","??","15","15"]
#--------------------------------------------------------------------------
# 人物出生地
#--------------------------------------------------------------------------
CHARA_FROM = ["希腊","罗马","??","??","??","??","雷都","日本东京"]
#--------------------------------------------------------------------------
# 人物身高
#--------------------------------------------------------------------------
CHARA_H = ["170","160","??","??","??","??","162","165"]
#--------------------------------------------------------------------------
# 人物体重
#--------------------------------------------------------------------------
CHARA_W = ["60","50","??","??","??","??","46","53"]
#--------------------------------------------------------------------------
# 人物介绍,可以写多行
#--------------------------------------------------------------------------
# 人物1号介绍
L1 = "RPG制作大师XP的标准主人公+形象代言人"
L2 = "是一个外表不经世事、内心坚强无比的小伙子"
L3 = ""
L_SET1 = [L1, L2, L3] # 人物1号的数组
# 人物2号介绍
L1 = "RPG制作大师XP的1号女主角"
L2 = "一个充满人性温情的女战士"
L3 = ""
L_SET2 = [L1, L2, L3] # 人物2号的数组
# 人物3号介绍
L1 = ""
L2 = ""
L3 = ""
L_SET3 = [L1, L2, L3]
# 人物4号介绍
L1 = ""
L2 = ""
L3 = ""
L_SET4 = [L1, L2, L3]
# 人物5号介绍
L1 = ""
L2 = ""
L3 = ""
L_SET5 = [L1, L2, L3]
# 人物6号介绍
L1 = ""
L2 = ""
L3 = ""
L_SET6 = [L1, L2, L3]
# 人物7号介绍
L1 = "充满冷酷的红魔法师"
L2 = "11岁,父母阵亡后加入了杀手组织"
L3 = "13岁,在一次行动失利中被抓到地牢严刑拷打长达半年"
L4 = "14岁,一个人杀光所有蹂躏她的狱卒,独自踏上旅途"
L_SET7 = [L1, L2, L3, L4]
# 人物8号介绍
L1 = "娇生惯养的贵族魔法师,从不懂人世艰难"
L2 = "自以为实力天下第一"
L3 = ""
L_SET8 = [L1, L2, L3]
# 人物介绍数组,如果不够继续添加。
CHARA_INFO = [L_SET1,L_SET2,L_SET3,L_SET4,L_SET5,L_SET6,L_SET7,L_SET8]
#==============================================================================
# Window_Charactor
#==============================================================================
class Window_Charactor < Window_Base
#--------------------------------------------------------------------------
# actor : 初始化的角色
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_battler_graphics(@actor, 100, 200)
self.contents.font.color.set(255, 255,50)
self.contents.draw_text(250, 10, 80, 32, "姓名")
self.contents.draw_text(250, 50, 80, 32, "年龄")
self.contents.draw_text(250, 90, 80, 32, "出生地")
self.contents.draw_text(250, 130, 80, 32, "身高")
self.contents.draw_text(250, 170, 80, 32, "体重")
self.contents.font.color = normal_color
draw_actor_name(@actor, 350, 10)
draw_actor_age(@actor, 350, 50)
draw_actor_from(@actor, 350, 90)
draw_actor_height(@actor, 350, 130)
draw_actor_weight(@actor, 350, 170)
draw_actor_other(@actor, 50, 250)
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def draw_battler_graphics(actor, x, y)
battler=RPG::Cache.battler(actor.battler_name, actor.battler_hue)
w = battler.width
h = battler.height
self.contents.blt(x-w/2, y-h, battler, Rect.new(0, 0, w,h))
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def draw_actor_age(actor, x, y)
self.contents.draw_text(x, y, 80, 32, CHARA_AGE[actor.id-1])
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def draw_actor_from(actor, x, y)
self.contents.draw_text(x, y, 180, 32, CHARA_FROM[actor.id-1])
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def draw_actor_height(actor, x, y)
self.contents.draw_text(x, y , 200, 32, CHARA_H[actor.id-1])
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def draw_actor_weight(actor, x, y)
self.contents.draw_text(x, y, 250, 32, CHARA_W[actor.id-1])
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def draw_actor_other(actor, x, y)
info = CHARA_INFO[actor.id-1]
for i in 0...info.size
self.contents.draw_text(x, y+32*i, 600, 32, info)
end
end
end
#==============================================================================
# Scene_Charactor
#==============================================================================
class Scene_Charactor
#--------------------------------------------------------------------------
# actor_index :角色编号
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def main
@actor = $game_party.actors[@actor_index]
@status_window = Window_Charactor.new(@actor)
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@status_window.dispose
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(3)
return
end
if Input.trigger?(Input::R)
$game_system.se_play($data_system.cursor_se)
@actor_index += 1
@actor_index %= $game_party.actors.size
$scene = Scene_Charactor.new(@actor_index)
return
end
if Input.trigger?(Input::L)
$game_system.se_play($data_system.cursor_se)
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
$scene = Scene_Charactor.new(@actor_index)
return
end
end
end
#==============================================================================
# Scene_Status
#==============================================================================
class Scene_Status
alias update_chara update
def update
if Input.trigger?(CHENGE_KEY)
$game_system.se_play($data_system.decision_se)
$scene = Scene_Charactor.new(@actor_index)
return
end
update_chara
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
[/pre][/fold]
[fold=09.双远景脚本]
[pre lang="Ruby"]#==============================================================================
# 本脚本来自www.66rpg.com,使用前请参考制作录像
#==============================================================================
# 用法:先在数据库上设置好第一张远景图,第二张远景图的文件名为 第一张远景图的
# 文件名 + "_2",例如第一张远景图的文件名是"map.png",第二张远景图的文件名就
# 是"map_2.png"。第二张远景图也要在 Graphics/Panoramas 文件夹里。
# 使用双远景图脚本时,要注意调整地图的设置,需要自行设置地图的通行和大小,地图
# 的宽应该设置为:远景图的宽 / 32;地图的高应该设置为:远景图的高 / 32。
#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
# 处理地图画面活动块和元件的类。本类在
# Scene_Map 类的内部使用。
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 200
@viewport3.z = 5000
# 生成元件地图
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names
@tilemap.autotiles = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# 生成远景平面
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
@panorama2 = Plane.new(@viewport1)
@panorama2.z = 3000
# 生成雾平面
@fog = Plane.new(@viewport1)
@fog.z = 3000
# 生成角色活动块
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
# 生成天气
@weather = RPG::Weather.new(@viewport1)
# 生成图片
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 释放元件地图
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles.dispose
end
@tilemap.dispose
# 释放远景平面
@panorama.dispose
@panorama2.dispose
# 释放雾平面
@fog.dispose
# 释放角色活动块
for sprite in @character_sprites
sprite.dispose
end
# 释放天候
@weather.dispose
# 释放图片
for sprite in @picture_sprites
sprite.dispose
end
# 释放计时器块
@timer_sprite.dispose
# 释放显示端口
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 远景与现在的情况有差异发情况下
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @panorama.bitmap != nil
@panorama.bitmap.dispose
@panarama2.bitmap.dispose
@panorama2.bitmap = nil
@panarama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
@panorama2.bitmap = RPG::Cache.panorama(@panorama_name+"_2", @panorama_hue)
end
Graphics.frame_reset
end
# 雾与现在的情况有差异的情况下
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
# 刷新元件地图
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
# 刷新远景平面
@panorama.ox = $game_map.display_x / 4
@panorama.oy = $game_map.display_y / 4
@panorama2.ox = @panorama.ox
@panorama2.oy = @panorama.oy
# 刷新雾平面
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
# 刷新角色活动块
for sprite in @character_sprites
sprite.update
end
# 刷新天候图形
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.ox = $game_map.display_x / 4
@weather.oy = $game_map.display_y / 4
@weather.update
# 刷新图片
for sprite in @picture_sprites
sprite.update
end
# 刷新计时器块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# 设置画面的闪烁色
@viewport3.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport3.update
end
end
#==============================================================================
# 本脚本来自www.66rpg.com,使用前请参考制作录像
#==============================================================================
[/pre][/fold]
[fold=10.物品分类]
[pre lang="Ruby"]#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#==============================================================================
# ■ Harts_Window_ItemTitle
#------------------------------------------------------------------------------
# アイテム画面で、タイトルを表示するウィンドウ。
#==============================================================================
class Harts_Window_ItemTitle < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
end
end
#==============================================================================
# ■ Harts_Window_ItemCommand
#------------------------------------------------------------------------------
# アイテムの種別選択を行うウィンドウです。
#==============================================================================
class Harts_Window_ItemCommand < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 64, 160, 288)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 8
@commands = ["一般用", "战斗用", $data_system.words.weapon, $data_system.words.armor1, $data_system.words.armor2, $data_system.words.armor3, $data_system.words.armor4, "特殊道具"]
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
# color : 文字色
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
y = index * 32
self.contents.draw_text(4, y, 128, 32, @commands[index])
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
case self.index
when 0
@text = @commands[0]
when 1
@text = @commands[1]
when 2
@text = @commands[2]
when 3
@text = @commands[3]
when 4
@text = @commands[4]
when 5
@text = @commands[5]
when 6
@text = @commands[6]
when 7
@text = @commands[7]
end
@help_window.set_text(@text)
end
end
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# アイテム画面で、所持アイテムの一覧を表示するウィンドウです。
#==============================================================================
class Harts_Window_ItemList < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(160, 0, 480, 416)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
end
#--------------------------------------------------------------------------
# ● アイテム一覧設定
# command : 選択中のコマンド
#--------------------------------------------------------------------------
def set_item(command)
refresh
case command
when 0
for i in 1...$data_items.size
if ($data_items.occasion == 0 or $data_items.occasion == 2) and $game_party.item_number(i) > 0
@data.push($data_items)
end
end
when 1
for i in 1...$data_items.size
if ($data_items.occasion == 1 and $game_party.item_number(i) > 0)
@data.push($data_items)
end
end
when 2
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons)
end
end
when 3
for i in 1...$data_armors.size
if $data_armors.kind == 0 and $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
when 4
for i in 1...$data_armors.size
if $data_armors.kind == 1 and $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
when 5
for i in 1...$data_armors.size
if $data_armors.kind == 2 and $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
when 6
for i in 1...$data_armors.size
if $data_armors.kind == 3 and $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
when 7
for i in 1...$data_items.size
if $data_items.occasion == 3 and $game_party.item_number(i) > 0
@data.push($data_items)
end
end
end
# 項目数が 0 でなければビットマップを作成し、全項目を描画
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 種類別アイテム数の取得
#--------------------------------------------------------------------------
def item_number
return @item_max
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ■ Harts_Scene_Item
#------------------------------------------------------------------------------
# アイテム画面の処理を行うクラスです。再定義
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
def main
# タイトルウィンドウを作成
@itemtitle_window = Harts_Window_ItemTitle.new
#コマンドウィンドウを作成
@itemcommand_window = Harts_Window_ItemCommand.new
@command_index = @itemcommand_window.index
#アイテムウィンドウを作成
@itemlist_window = Harts_Window_ItemList.new
@itemlist_window.active = false
#ヘルプウィンドウを作成
@help_window = Window_Help.new
@help_window.x = 0
@help_window.y = 416
# ヘルプウィンドウを関連付け
@itemcommand_window.help_window = @help_window
@itemlist_window.help_window = @help_window
# ターゲットウィンドウを作成 (不可視?非アクティブに設定)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# アイテムウィンドウ内容表示
@itemlist_window.set_item(@command_index)
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@itemtitle_window.dispose
@itemcommand_window.dispose
@itemlist_window.dispose
@help_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@itemtitle_window.update
@itemcommand_window.update
@itemlist_window.update
@help_window.update
@target_window.update
if @command_index != @itemcommand_window.index
@command_index = @itemcommand_window.index
@itemlist_window.set_item(@command_index)
end
# コマンドウィンドウがアクティブの場合: update_itemcommand を呼ぶ
if @itemcommand_window.active
update_itemcommand
return
end
# アイテムウィンドウがアクティブの場合: update_itemlist を呼ぶ
if @itemlist_window.active
update_itemlist
return
end
# ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (コマンドウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_itemcommand
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# メニュー画面に切り替え
$scene = Scene_Menu.new(0)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# 選択中のコマンドのアイテムがない場合
if @itemlist_window.item_number == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# アイテムウィンドウをアクティブにする
@itemcommand_window.active = false
@itemlist_window.active = true
@itemlist_window.index = 0
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (アイテムウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_itemlist
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテムウィンドウをアクティブにする
@itemcommand_window.active = true
@itemlist_window.active = false
@itemlist_window.index = 0
@itemcommand_window.index = @command_index
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムウィンドウで現在選択されているデータを取得
@item = @itemlist_window.item
# 使用アイテムではない場合
unless @item.is_a?(RPG::Item)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 使用できない場合
unless $game_party.item_can_use?(@item.id)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 効果範囲が味方の場合
if @item.scope >= 3
# ターゲットウィンドウをアクティブ化
@itemlist_window.active = false
@target_window.x = 304
@target_window.visible = true
@target_window.active = true
# 効果範囲 (単体/全体) に応じてカーソル位置を設定
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 効果範囲が味方以外の場合
else
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@itemlist_window.draw_item(@itemlist_window.index)
end
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテム切れなどで使用できなくなった場合
unless $game_party.item_can_use?(@item.id)
# アイテムウィンドウの内容を再作成
@itemlist_window.refresh
end
# ターゲットウィンドウを消去
@itemlist_window.active = true
@target_window.visible = false
@target_window.active = false
@itemlist_window.set_item(@command_index)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを使い切った場合
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にアイテムの使用効果を適用
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにアイテムの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# アイテムを使った場合
if used
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@itemlist_window.draw_item(@itemlist_window.index)
@itemlist_window.set_item(@command_index)
end
# ターゲットウィンドウの内容を再作成
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# アイテムを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
[/pre][/fold]
[fold=11.任务系统]
[pre lang="Ruby"]=begin
--------------------------------------------------------------------------
详尽任务显示界面 v2.1
--------------------------------------------------------------------------
By 叶子
日期与更新
3-29-2006 -v1.0
4-3-2006 -v2.0
-可以改变文字颜色,显示变量,显示图标,显示图片
-大幅简化了编写任务内容的过程,加入自动换行功能
-精简了窗口,使其还可以用作图鉴系统、日记系统等等
4-6-2006 -v2.1
-增加了获得全部任务与删除全部任务命令
-改正通假字,修改了示例任务3
--------------------------------------------------------------------------
顾名思义,就是显示任务资料的界面
任务资料要预先在这里设定好
下载范例工程,能帮助你更快更好地掌握使用方法
--------------------------------------------------------------------------
使用方法:
1、召唤任务显示界面:$scene = Scene_Task.new
可以在事件中的“脚本”指令加入这段东西,又或者修改 Scene_Menu 来增加一个显示
任务的选项。如果是修改 Scene_Menu 增加选项的话,在脚本倒数第30行左右,
把 $scene = Scene_Map.new 修改成 $scene = Scene_Menu.new(任务界面index)
2、设置任务资料
2.1、相关内容解析
所有内容文字必须用双引号括住
名称:任务的名字(显示在左边窗口中),大小为208×32,如果全部为文字的话,
够放九个全角字符
简介:任务的介绍(显示在右边窗口中),宽368,高不限
文字可以自动换行
2.1.1、控制码解析
名称和内容均可用控制码,注意两条反斜线都要打!
\\v[n] 显示n号变量
\\c[n] 改变字体颜色。
n=1~7 时同“显示文章”的\c[n],n=8 时为半透明色,n=9 时为系统色(青色)
\\n 显示i号角色名字
\\i[文件名] 显示图标
\\p[文件名] 显示图片
2.1.2、高级:内嵌表达式
请参考帮助-脚本入门-字符串-内嵌表达式相关内容。
它可以用来在任务的名称和简介那里显示变量。
常用的表达式(注意不要漏了井号和大括号):
#{$game_variables[n]} ——插入n号变量的值
#{$game_party.item_number(n)} ——插入持有n号物品数量
同理还有weapon_number,armor_number
还可以预先定义一个变量,再插入(例子见示例任务3-灵魂线)
2.2、注意事项
2.2.1、括号、逗号和双引号 [ ] , " 必须使用半角符号(英文输入),
引号内的内容则没有关系
2.2.2、单引号 ' 和双引号 " 的区别:
为了不出错误,全部用双引号吧!当然如果你对Ruby很熟悉,那就没所谓了
2.3、开始设置吧!
从107行开始设置任务资料,可以参考示例任务来设置,请仔细阅读附加讲解
3、接受任务
事件里的“脚本”指令输入:get_task(任务ID)
例如 get_task(1) 就是接受1号任务
3.1、获得全部任务
事件里的“脚本”指令输入:get_all_task
这个功能基本上是用来在编写好所有任务资料后测试排版的
4、完成/删除任务
事件里的“脚本”指令输入:finish_task(任务ID)
例如 finish_task(1) 就是完成1号任务
注意:本脚本不负责完成任务后的奖励之类的东西,请自行在事件中判断,
这里的完成任务指的是从任务列表中删去此任务
4.1、删除全部任务
事件里的“脚本”指令输入:finish_all_task
作为获得全部任务的对应功能存在,似乎不会怎么用到
=end
class Scene_Task
# 这里设置任务内容翻页音效
CHANGE_PAGE_SE = "Audio/SE/s系统-光标-重-004"
end
class Game_Party
#--------------------------------------------------------------------------
# ● 设置任务资料
#--------------------------------------------------------------------------
def get_tasks_info
@tasks_info = []
名称 = "\\i[108任务图标]\\c[3]悬赏任务 - 德古拉男爵"
简介 = "\\i[任务]\\c[6]悬赏任务 - 德古拉男爵\\p[分割线]
\\c[0]前所未有的危机!德古拉男爵被通灵在斐扬了!必须前往消灭!
在\\c[2]斐扬僵尸洞某处\\c[0]消灭首领级魔物\\c[2]德古拉男爵\\c[0]。
"
@tasks_info[1] = Game_Task.new(名称, 简介)
end
end
#==============================================================================
# ■ Interpreter
#------------------------------------------------------------------------------
# 执行事件命令的解释器。本类在 Game_System 类
# 与 Game_Event 类的内部使用。
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# ● 接受任务
#--------------------------------------------------------------------------
def get_task(id)
task = $game_party.tasks_info[id]
return true if (task.nil? or $game_party.current_tasks.include?(task.id))
$game_party.current_tasks.unshift(task.id)
return true
end
#--------------------------------------------------------------------------
# ● 获得全部任务
#--------------------------------------------------------------------------
def get_all_task
# 清空当前任务
$game_party.current_tasks.clear
for task in $game_party.tasks_info
next if task.nil?
$game_party.current_tasks.unshift(task.id)
end
return true
end
#--------------------------------------------------------------------------
# ● 完成/放弃任务
#--------------------------------------------------------------------------
def finish_task(id)
task = $game_party.tasks_info[id]
return true if task.nil?
$game_party.current_tasks.delete(task.id)
return true
end
#--------------------------------------------------------------------------
# ● 删除全部任务
#--------------------------------------------------------------------------
def finish_all_task
$game_party.current_tasks.clear
return true
end
end
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# 处理同伴的类。包含金钱以及物品的信息。本类的实例
# 请参考 $game_party。
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_writer :latest_task # 上次查看的任务
#--------------------------------------------------------------------------
# ● 取得任务资料
#--------------------------------------------------------------------------
def tasks_info
if @tasks_info.nil?
get_tasks_info
end
return @tasks_info
end
#--------------------------------------------------------------------------
# ● 取得当前任务
#--------------------------------------------------------------------------
def current_tasks
if @current_tasks.nil?
@current_tasks = []
end
return @current_tasks
end
#--------------------------------------------------------------------------
# ● 上次查看的任务
#--------------------------------------------------------------------------
def latest_task
if !current_tasks.include?(@latest_task)
@latest_task = current_tasks[0]
end
return @latest_task
end
end
#==============================================================================
# ■ Game_Task
#------------------------------------------------------------------------------
# 处理任务的类。包含任务的信息。
#==============================================================================
class Game_Task
attr_accessor :name # 名称
attr_accessor :briefing # 简介
def initialize(name, briefing)
@name = name
@briefing = briefing
end
def height
text = @briefing.clone
x = 0
y = 64
min_y = 0
# 限制文字处理
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# 为了方便、将 "\\\\" 变换为 "\000"
text.gsub!(/\\\\/) { "\000" }
# "\C" 变为 "\001"
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
# "\I" 变为 "\002"
text.gsub!(/\\[Ii]/) { "\002" }
# "\P" 变为 "\003"
text.gsub!(/\\[Pp]/) { "\003" }
# c 获取 1 个字 (如果不能取得文字就循环)
while ((c = text.slice!(/./m)) != nil)
# \\ 的情况下
if c == "\000"
# 还原为本来的文字
c = "\\"
end
# \C[n] 的情况下
if c == "\001"
# 更改文字色
text.sub!(/\[([0-9]+)\]/, "")
# 下面的文字
next
end
# 图标的情况下
if c == "\002"
icon_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
icon_name += cha
end
icon = RPG::Cache.icon(icon_name)
if x + icon.width > 368
x = 0
y += [32, min_y].max
min_y = 0
end
x += 28
next
end
# 图片的情况下
if c == "\003"
pic_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
pic_name += cha
end
pic = RPG::Cache.picture(pic_name)
if x + pic.width > 368
x = 0
y += [32, min_y].max
min_y = 0
end
x += pic.width
min_y = [pic.height, 32].max
next
end
# 另起一行文字的情况下
if c == "\n"
y += [32, min_y].max
min_y = 0
x = 0
# 下面的文字
next
end
# 自动换行处理
if x + 22 > 368
y += [32, min_y].max
min_y = 0
x = 0
end
# x 为要描绘文字的加法运算
x += 22
end
return (y + [32, min_y].max)
end
def id
return $game_party.tasks_info.index(self)
end
end
#==============================================================================
# ■ Window_Task_Name
#------------------------------------------------------------------------------
# 任务名称显示窗口。
#==============================================================================
class Window_Task_Name < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(tasks)
super(0, 0, 240, 480)
@tasks = []
for id in tasks
@tasks.push($game_party.tasks_info[id])
end
@item_max = tasks.size
self.contents = Bitmap.new(
self.width - 32, @item_max == 0 ? 32 : @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @tasks != []
for task in @tasks
draw_item(task)
end
else
draw_blank
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
#--------------------------------------------------------------------------
def draw_item(task)
text = task.name.clone
x = 0
y = @tasks.index(task) * 32
# 限制文字处理
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# 为了方便、将 "\\\\" 变换为 "\000"
text.gsub!(/\\\\/) { "\000" }
# "\\C" 变为 "\001"
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
# "\I" 变为 "\002"
text.gsub!(/\\[Ii]/) { "\002" }
# "\P" 变为 "\003"
text.gsub!(/\\[Pp]/) { "\003" }
# c 获取 1 个字 (如果不能取得文字就循环)
while ((c = text.slice!(/./m)) != nil)
# \\ 的情况下
if c == "\000"
# 还原为本来的文字
c = "\\"
end
# \C[n] 的情况下
if c == "\001"
# 更改文字色
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
elsif color == 8
self.contents.font.color = disabled_color
elsif color == 9
self.contents.font.color = system_color
end
# 下面的文字
next
end
# 图标的情况下
if c == "\002"
icon_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
icon_name += cha
end
icon = RPG::Cache.icon(icon_name)
if x + icon.width > self.contents.width
x = 0
y += [32, min_y].max
min_y = 0
end
self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
x += 28
next
end
# 图片的情况下
if c == "\003"
pic_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
pic_name += cha
end
pic = RPG::Cache.picture(pic_name)
if x + pic.width > self.contents.width
x = 0
y += [32, min_y].max
min_y = 0
end
self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
x += pic.width
next
end
# 描绘文字
self.contents.draw_text(4 + x, y, 40, 32, c)
# x 为要描绘文字的加法运算
x += self.contents.text_size(c).width
end
end
#--------------------------------------------------------------------------
# ● 描绘空行
#--------------------------------------------------------------------------
def draw_blank
self.contents.font.color = disabled_color
rect = Rect.new(4, 0, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, '当前没有任何任务')
end
#--------------------------------------------------------------------------
# ● 获取任务
#--------------------------------------------------------------------------
def task
return @tasks[self.index]
end
end
#==============================================================================
# ■ Window_Task
#------------------------------------------------------------------------------
# 任务内容显示窗口。
#==============================================================================
class Window_Task < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(task_id)
super(240, 0, 400, 480)
refresh(task_id)
end
#--------------------------------------------------------------------------
# ● 刷新内容
#--------------------------------------------------------------------------
def refresh(task_id)
self.oy = 0
self.visible = true
return if task_id.nil?
task = $game_party.tasks_info[task_id]
if !task.nil?
self.contents = Bitmap.new(self.width - 32, task.height)
else
self.contents = Bitmap.new(self.width - 32, self.height - 32)
return
end
self.contents.font.color = normal_color
# 描绘任务内容
draw_task_info(task)
end
#--------------------------------------------------------------------------
# ● 描绘任务内容
#--------------------------------------------------------------------------
def draw_task_info(task)
# 记录文字x坐标
x = 0
# 记录文字y坐标
y = 0
# 记录换行时y坐标最小加值
min_y = 0
self.contents.font.color = normal_color
# 描绘任务简介
text = task.briefing.clone
# 限制文字处理
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# 为了方便、将 "\\\\" 变换为 "\000"
text.gsub!(/\\\\/) { "\000" }
# "\C" 变为 "\001"
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
# "\I" 变为 "\002"
text.gsub!(/\\[Ii]/) { "\002" }
# "\P" 变为 "\003"
text.gsub!(/\\[Pp]/) { "\003" }
# c 获取 1 个字 (如果不能取得文字就循环)
while ((c = text.slice!(/./m)) != nil)
# \\ 的情况下
if c == "\000"
# 还原为本来的文字
c = "\\"
end
# \C[n] 的情况下
if c == "\001"
# 更改文字色
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
elsif color == 8
self.contents.font.color = disabled_color
elsif color == 9
self.contents.font.color = system_color
end
# 下面的文字
next
end
# 图标的情况下
if c == "\002"
icon_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
icon_name += cha
end
icon = RPG::Cache.icon(icon_name)
if x + icon.width > self.contents.width
x = 0
y += [32, min_y].max
min_y = 0
end
self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
x += 28
next
end
# 图片的情况下
if c == "\003"
pic_name = ''
while ((cha = text.slice!(/./m)) != ']')
next if cha == '['
pic_name += cha
end
pic = RPG::Cache.picture(pic_name)
if x + pic.width > self.contents.width
x = 0
y += [32, min_y].max
min_y = 0
end
self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
x += pic.width
min_y = [pic.height, 32].max
next
end
# 另起一行文字的情况下
if c == "\n"
y += [32, min_y].max
min_y = 0
x = 0
# 下面的文字
next
end
# 自动换行处理
if x + self.contents.text_size(c).width > self.contents.width
y += [32, min_y].max
min_y = 0
x = 0
end
# 描绘文字
self.contents.draw_text(4 + x, y, 40, 32, c)
# x 为要描绘文字的加法运算
x += self.contents.text_size(c).width
end
end
end
#==============================================================================
# ■ Scene_Task
#------------------------------------------------------------------------------
# 处理任务画面的类。
#==============================================================================
class Scene_Task
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 刷新任务资料
$game_party.get_tasks_info
# 生成任务名称窗口
@task_names_window = Window_Task_Name.new($game_party.current_tasks)
@task_names_window.active = true
if $game_party.current_tasks != []
@task_names_window.index = $game_party.current_tasks.index($game_party.latest_task)
end
# 生成任务内容窗口
@task_info_window = Window_Task.new($game_party.latest_task)
@task_info_window.active = true
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@task_names_window.dispose
@task_info_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@task_names_window.update
@task_info_window.update
update_task_names_window
end
#--------------------------------------------------------------------------
# ● 刷新任务名称窗口
#--------------------------------------------------------------------------
def update_task_names_window
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 这里设置返回的场景,返回地图是Scene_Map.new,菜单是Scene_Menu.new(任务界面index)
$scene = Scene_Menu.new(4)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 无任务可显示的话
if @task_names_window.task == nil
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 如果光标没有移动的话,翻页
if $game_party.latest_task == @task_names_window.task.id
if @task_info_window.oy + @task_info_window.height - 32 > @task_info_window.contents.height
@task_info_window.oy = 0
else
@task_info_window.oy += 480-32
end
if @task_info_window.contents.height > @task_info_window.height - 32
# 演奏翻页 SE
Audio.se_play(CHANGE_PAGE_SE)
end
else
@task_info_window.refresh(@task_names_window.task.id)
$game_party.latest_task = @task_names_window.task.id
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
end
end
end
end
[/pre][/fold]
[fold=12.CP战斗]
[pre lang="Ruby"]#========================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#========================================================================
#========================================================================
# ▼▲▼ XRXS_BP 1. CP制導入 ver..23 ▼▲▼
# by 桜雅 在土, 和希
#------------------------------------------------------------------------
# □ カスタマイズポイント
#========================================================================
module XRXS_BP1
#
# 对齐方式。0:左 1:中央 2:右
#
ALIGN = 0
#
# 人数
#
MAX = 4
end
class Scene_Battle_CP
#
# 战斗速度
#
BATTLE_SPEED = 0.5
#
# 战斗开始的时候气槽百分比
#
START_CP_PERCENT = 0
end
class Scene_Battle
# 效果音效,可以自己添加
DATA_SYSTEM_COMMAND_UP_SE = "Audio/SE/系统-确定.wav"
# 各项数值功能消耗的CP值
CP_COST_BASIC_ACTIONS = 0 # 基础共同
CP_COST_SKILL_ACTION = 65535 # 技能
CP_COST_ITEM_ACTION = 65535 # 物品
CP_COST_BASIC_ATTACK = 65535 # 攻撃
CP_COST_BASIC_GUARD = 32768 # 防御
CP_COST_BASIC_NOTHING = 65535 # 不做任何事情
CP_COST_BASIC_ESCAPE = 65535 # 逃跑
end
#========================================================================
# --- XRXS.コマンドウィンドウ?コマンド追加機構 ---
#------------------------------------------------------------------------
# Window_Commandクラスに add_command メソッドを追加します。
#========================================================================
module XRXS_Window_Command_Add_Command
#----------------------------------------------------------------------
# ○ コマンドを追加
#----------------------------------------------------------------------
def add_command(command)
# 初期化されていない場合、無効化判別用の配列 @disabled の初期化
#
if @disabled == nil
@disabled = []
end
if @commands.size != @disabled.size
for i in 0...@commands.size
@disabled = false
end
end
#
# 追加
#
@commands.push(command)
@disabled.push(false)
@item_max = @commands.size
self.y -= 32
self.height += 32
self.contents.dispose
self.contents = nil
self.contents = Bitmap.new(self.width - 32, @item_max * 32)
refresh
for i in 0...@commands.size
if @disabled
disable_item(i)
end
end
end
#----------------------------------------------------------------------
# ○ 項目の無効化
# index : 項目番号
#----------------------------------------------------------------------
def disable_item(index)
if @disabled == nil
@disabled = []
end
@disabled[index] = true
draw_item(index, disabled_color)
end
end
class Window_Command < Window_Selectable
#----------------------------------------------------------------------
# ○ インクルード
#----------------------------------------------------------------------
include XRXS_Window_Command_Add_Command
#----------------------------------------------------------------------
# ● 項目の無効化
# index : 項目番号
#----------------------------------------------------------------------
def disable_item(index)
super
end
end
#========================================================================
# □ Scene_Battle_CP
#========================================================================
class Scene_Battle_CP
#----------------------------------------------------------------------
# ○ 公開インスタンス変数
#----------------------------------------------------------------------
attr_accessor :stop # CP加算ストップ
#----------------------------------------------------------------------
# ○ オブジェクトの初期化
#----------------------------------------------------------------------
def initialize
@battlers = []
@cancel = false
@stop = false
@agi_total = 0
# 配列 count_battlers を初期化
count_battlers = []
# エネミーを配列 count_battlers に追加
for enemy in $game_troop.enemies
count_battlers.push(enemy)
end
# アクターを配列 count_battlers に追加
for actor in $game_party.actors
count_battlers.push(actor)
end
for battler in count_battlers
@agi_total += battler.agi
end
for battler in count_battlers
battler.cp = [[65535 * START_CP_PERCENT * (rand(15) + 85) * 4 * battler.agi / @agi_total / 10000, 0].max, 65535].min
end
end
#----------------------------------------------------------------------
# ○ CPカウントアップ
#----------------------------------------------------------------------
def update
# ストップされているならリターン
return if @stop
#
for battler in $game_party.actors + $game_troop.enemies
# 行動出来なければ無視
if battler.dead? == true
battler.cp = 0
next
end
battler.cp = [[battler.cp + BATTLE_SPEED * 4096 * battler.agi / @agi_total, 0].max, 65535].min
end
end
#----------------------------------------------------------------------
# ○ CPカウントの開始
#----------------------------------------------------------------------
def stop
@cancel = true
if @cp_thread != nil then
@cp_thread.join
@cp_thread = nil
end
end
end
#========================================================================
# ■ Game_Battler
#========================================================================
class Game_Battler
attr_accessor :now_guarding # 現在防御中フラグ
attr_accessor :cp # 現在CP
attr_accessor :slip_state_update_ban # スリップ?ステート自動処理の禁止
#----------------------------------------------------------------------
# ○ CP の変更
#-----------------------------------------------------------------------
def cp=(p)
@cp = [[p, 0].max, 65535].min
end
#----------------------------------------------------------------------
# ● 防御中判定 [ 再定義 ]
#----------------------------------------------------------------------
def guarding?
return @now_guarding
end
#----------------------------------------------------------------------
# ● コマンド入力可能判定
#----------------------------------------------------------------------
alias xrxs_bp1_inputable? inputable?
def inputable?
bool = xrxs_bp1_inputable?
return (bool and (@cp >= 65535))
end
#----------------------------------------------------------------------
# ● ステート [スリップダメージ] 判定
#----------------------------------------------------------------------
alias xrxs_bp1_slip_damage? slip_damage?
def slip_damage?
return false if @slip_state_update_ban
return xrxs_bp1_slip_damage?
end
#----------------------------------------------------------------------
# ● ステート自然解除 (ターンごとに呼び出し)
#----------------------------------------------------------------------
alias xrxs_bp1_remove_states_auto remove_states_auto
def remove_states_auto
return if @slip_state_update_ban
xrxs_bp1_remove_states_auto
end
end
#========================================================================
# ■ Game_Actor
#========================================================================
class Game_Actor < Game_Battler
#----------------------------------------------------------------------
# ● セットアップ
#----------------------------------------------------------------------
alias xrxs_bp1_setup setup
def setup(actor_id)
xrxs_bp1_setup(actor_id)
@cp = 0
@now_guarding = false
@slip_state_update_ban = false
end
end
#========================================================================
# ■ Game_Enemy
#========================================================================
class Game_Enemy < Game_Battler
#----------------------------------------------------------------------
# ● オブジェクト初期化
#----------------------------------------------------------------------
alias xrxs_bp1_initialize initialize
def initialize(troop_id, member_index)
xrxs_bp1_initialize(troop_id, member_index)
@cp = 0
@now_guarding = false
@slip_state_update_ban = false
end
end
class Window_All < Window_Base
def initialize
super(0,0,640,480)
self.opacity = 0
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
for actor in $game_troop.enemies
next if !actor.exist?
draw_actor_cp_meter(actor, actor.screen_x-42, actor.screen_y-50, 40, 0)
end
end
#----------------------------------------------------------------------
# ○ CPメーター の描画
#----------------------------------------------------------------------
# def draw_actor_cp_meter(actor, x, y, width = 156, type = 0)
def draw_actor_cp_meter(actor, x, y, width = 144, type = 0)
self.contents.font.color = system_color
self.contents.fill_rect(x, y+27, width+4,6, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+1, y+28, width+2,4, Color.new(192, 220, 192, 255))
self.contents.fill_rect(x+2, y+29, width,2, Color.new(30, 30, 0, 255))
if actor.cp == nil
actor.cp = 0
end
w = width * [actor.cp,65535].min / 65535
# self.contents.fill_rect(x+1, y+28, w,1, Color.new(255, 255, 128, 255))
# self.contents.fill_rect(x+1, y+29, w,1, Color.new(255, 255, 0, 255))
self.contents.fill_rect(x+2, y+29, w,1, Color.new(0, 192, 0, 255))
self.contents.fill_rect(x+2, y+30, w,1, Color.new(0, 128, 0, 255))
end
end
#========================================================================
# ■ Window_BattleStatus
#========================================================================
class Window_BattleStatus < Window_Base
#-----------------------------------------------------------------------
# ○ 公開インスタンス変数
#----------------------------------------------------------------------
attr_accessor :update_cp_only # CPメーターのみの更新
#----------------------------------------------------------------------
# ● オブジェクト初期化
#----------------------------------------------------------------------
alias xrxs_bp1_initialize initialize
def initialize
@update_cp_only = false
@wall = Window_All.new
xrxs_bp1_initialize
end
def dispose
super
@wall.dispose
end
#----------------------------------------------------------------------
# ● リフレッシュ
#----------------------------------------------------------------------
alias xrxs_bp1_refresh refresh
def refresh
unless @update_cp_only
xrxs_bp1_refresh
end
refresh_cp
@wall.refresh
end
#----------------------------------------------------------------------
# ○ リフレッシュ(CPのみ)
#----------------------------------------------------------------------
def refresh_cp
for i in 0...$game_party.actors.size
actor = $game_party.actors
width = [self.width*3/4 / XRXS_BP1::MAX, 80].max
space = self.width / XRXS_BP1::MAX
case XRXS_BP1::ALIGN
when 0
actor_x = i * space + 4
when 1
actor_x = (space * ((XRXS_BP1::MAX - $game_party.actors.size)/2.0 + i)).floor
when 2
actor_x = (i + XRXS_BP1::MAX - $game_party.actors.size) * space + 4
end
actor_x += self.x
draw_actor_cp_meter(actor, actor_x, 96, width, 0)
end
end
#----------------------------------------------------------------------
# ○ CPメーター の描画
#----------------------------------------------------------------------
def draw_actor_cp_meter(actor, x, y, width = 144, type = 0)
self.contents.font.color = system_color
self.contents.fill_rect(x, y+27, width,6, Color.new(0, 0, 0, 255))
self.contents.fill_rect(x+1, y+28, width-2,4, Color.new(192, 220, 192, 255))
self.contents.fill_rect(x+2, y+29, width-4,2, Color.new(30, 30, 0, 255))
if actor.cp == nil
actor.cp = 0
end
w = width * [actor.cp,65535].min / 65535
# self.contents.fill_rect(x+1, y+28, w,1, Color.new(255, 255, 128, 255))
# self.contents.fill_rect(x+1, y+29, w,1, Color.new(255, 255, 0, 255))
self.contents.fill_rect(x+2, y+29, w-4,1, Color.new(0, 192, 0, 255))
self.contents.fill_rect(x+2, y+30, w-4,1, Color.new(0, 128, 0, 255))
end
end
#========================================================================
# ■ Scene_Battle
#========================================================================
class Scene_Battle
#----------------------------------------------------------------------
# ● フレーム更新
#----------------------------------------------------------------------
alias xrxs_bp1_update update
def update
xrxs_bp1_update
# CP更新
@cp_thread.update
end
#----------------------------------------------------------------------
# ● バトル終了
# result : 結果 (0:勝利 1:敗北 2:逃走)
#----------------------------------------------------------------------
alias xrxs_bp1_battle_end battle_end
def battle_end(result)
# CPカウントを停止する
@cp_thread.stop
# 呼び戻す
xrxs_bp1_battle_end(result)
end
#----------------------------------------------------------------------
# ● プレバトルフェーズ開始
#----------------------------------------------------------------------
alias xrxs_bp1_start_phase1 start_phase1
def start_phase1
@agi_total = 0
# CP加算を開始する
@cp_thread = Scene_Battle_CP.new
# インデックスを計算
@cp_escape_actor_command_index = @actor_command_window.height/32 - 1
# アクターコマンドウィンドウに追加
@actor_command_window.add_command("逃跑")
if !$game_temp.battle_can_escape
@actor_command_window.disable_item(@cp_escape_actor_command_index)
end
# 呼び戻す
xrxs_bp1_start_phase1
end
#----------------------------------------------------------------------
# ● パーティコマンドフェーズ開始
#----------------------------------------------------------------------
alias xrxs_bp1_start_phase2 start_phase2
def start_phase2
xrxs_bp1_start_phase2
@party_command_window.active = false
@party_command_window.visible = false
# CP加算を再開する
@cp_thread.stop = false
# 次へ
start_phase3
end
#----------------------------------------------------------------------
# ● アクターコマンドウィンドウのセットアップ
#----------------------------------------------------------------------
alias xrxs_bp1_phase3_setup_command_window phase3_setup_command_window
def phase3_setup_command_window
# CPスレッドを一時停止する
@cp_thread.stop = true
# ウィンドウのCP更新
@status_window.refresh_cp
# @active_battlerの防御を解除
@active_battler.now_guarding = false
# 効果音の再生
Audio.se_play(DATA_SYSTEM_COMMAND_UP_SE) if DATA_SYSTEM_COMMAND_UP_SE != ""
#====================================================================
#@sprite = Sprite.new
#@sprite.bitmap = RPG::Cache.picture(@active_battler.name + "_b")
#====================================================================
# 呼び戻す
xrxs_bp1_phase3_setup_command_window
end
#----------------------------------------------------------------------
# ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド)
#----------------------------------------------------------------------
alias xrxs_bsp1_update_phase3_basic_command update_phase3_basic_command
def update_phase3_basic_command
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アクターコマンドウィンドウのカーソル位置で分岐
case @actor_command_window.index
when @cp_escape_actor_command_index # 逃げる
if $game_temp.battle_can_escape
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
#====================================================================
#====================================================================
# アクションを設定
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 4
# 次のアクターのコマンド入力へ
else
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
#====================================================================
#====================================================================
end
return
end
end
xrxs_bsp1_update_phase3_basic_command
end
#----------------------------------------------------------------------
# ● メインフェーズ開始
#----------------------------------------------------------------------
alias xrxs_bp1_start_phase4 start_phase4
def start_phase4
# 呼び戻す
xrxs_bp1_start_phase4
# CPスレッドを一時停止する
unless @action_battlers.empty?
@cp_thread.stop = true
end
end
#----------------------------------------------------------------------
# ● 行動順序作成
#----------------------------------------------------------------------
alias xrxs_bp1_make_action_orders make_action_orders
def make_action_orders
xrxs_bp1_make_action_orders
# 全員のCPを確認
exclude_battler = []
for battler in @action_battlers
# CPが不足している場合は @action_battlers から除外する
if battler.cp < 65535
exclude_battler.push(battler)
end
end
@action_battlers -= exclude_battler
end
#----------------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 1 : アクション準備)
#----------------------------------------------------------------------
alias xrxs_bp1_update_phase4_step1 update_phase4_step1
def update_phase4_step1
# 初期化
@phase4_act_continuation = 0
# 勝敗判定
if judge
@cp_thread.stop
# 勝利または敗北の場合 : メソッド終了
return
end
# 未行動バトラー配列の先頭から取得
@active_battler = @action_battlers[0]
# ステータス更新をCPだけに限定。
@status_window.update_cp_only = true
# ステート更新を禁止。
@active_battler.slip_state_update_ban = true if @active_battler != nil
# 戻す
xrxs_bp1_update_phase4_step1
# @status_windowがリフレッシュされなかった場合は手動でリフレッシュ(CPのみ)
if @phase4_step != 2
# リフレッシュ
@status_window.refresh
# 軽量化:たったコレだけΣ(?w?
Graphics.frame_reset
end
# 禁止を解除
@status_window.update_cp_only = false
@active_battler.slip_state_update_ban = false if @active_battler != nil
end
#----------------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
#----------------------------------------------------------------------
alias xrxs_bp1_update_phase4_step2 update_phase4_step2
def update_phase4_step2
# 強制アクションでなければ
unless @active_battler.current_action.forcing
# 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合
if @active_battler.restriction == 2 or @active_battler.restriction == 3
# アクションに攻撃を設定
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
end
# 制約が [行動できない] の場合
if @active_battler.restriction == 4
# アクション強制対象のバトラーをクリア
$game_temp.forcing_battler = nil
if @phase4_act_continuation == 0 and @active_battler.cp >= 65535
# ステート自然解除
@active_battler.remove_states_auto
# CP消費
@active_battler.cp -= 65535
# ステータスウィンドウをリフレッシュ
@status_window.refresh
end
# ステップ 1 に移行
@phase4_step = 1
return
end
end
# アクションの種別で分岐
case @active_battler.current_action.kind
when 0
# 攻撃?防御?逃げる?何もしない時の共通消費CP
@active_battler.cp -= CP_COST_BASIC_ACTIONS if @phase4_act_continuation == 0
when 1
# スキル使用時の消費CP
@active_battler.cp -= CP_COST_SKILL_ACTION if @phase4_act_continuation == 0
when 2
# アイテム使用時の消費CP
@active_battler.cp -= CP_COST_ITEM_ACTION if @phase4_act_continuation == 0
end
# ステート自然解除
@active_battler.remove_states_auto
# 呼び戻す
xrxs_bp1_update_phase4_step2
end
#----------------------------------------------------------------------
# ● 基本アクション 結果作成
#----------------------------------------------------------------------
alias xrxs_bp1_make_basic_action_result make_basic_action_result
def make_basic_action_result
# 攻撃の場合
if @active_battler.current_action.basic == 0 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_ATTACK # 攻撃時のCP消費
end
# 防御の場合
if @active_battler.current_action.basic == 1 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_GUARD # 防御時のCP消費
# @active_battlerの防御をON
@active_battler.now_guarding = true
end
# 敵の逃げるの場合
if @active_battler.is_a?(Game_Enemy) and
@active_battler.current_action.basic == 2 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_ESCAPE # 逃走時のCP消費
end
# 何もしないの場合
if @active_battler.current_action.basic == 3 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_NOTHING # 何もしない時のCP消費
end
# 逃げるの場合
if @active_battler.current_action.basic == 4 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_ESCAPE # 逃走時のCP消費
# 逃走可能ではない場合
if $game_temp.battle_can_escape == false
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 逃走処理
update_phase2_escape
return
end
# 呼び戻す
xrxs_bp1_make_basic_action_result
end
#----------------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
#----------------------------------------------------------------------
alias xrxs_bp1_update_phase4_step6 update_phase4_step6
def update_phase4_step6
# スリップダメージ
if @active_battler.hp > 0 and @active_battler.slip_damage?
@active_battler.slip_damage_effect
@active_battler.damage_pop = true
# ステータスウィンドウをリフレッシュ
@status_window.refresh
end
# 呼び戻す
xrxs_bp1_update_phase4_step6
end
end
#======================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#======================================================================
[/pre][/fold]
[fold=13.技能装备系统]
[pre lang="Ruby"]#==============================================================================
# ■ 技能装备系统 for RGSS1 by:VIPArcher
# -- 本脚本来自 https://rpg.blue 使用或转载请保留以上信息。
#==============================================================================
# 让技能可以像装备一样装备到角色身上,战斗中仅可使用已经装备的技能,其他场景可
# 以随意使用,技能装备场景技能槽栏激活状态下(如有队友)按左右键切换当前角色。
# $scene = Scene_SetEquipSkill.new(actor_index, skill_index) 呼出场景。
# actor_index : 该角色在队伍中的位置 ; skill_index : 技能槽光标的起始位置
#==============================================================================
$VIPArcherScript ||= {};$VIPArcherScript[:battle_skill] = 20150717
#-------------------------------------------------------------------------------
module VIPArcher end
#==============================================================================
# ★ 设定部分 ★
#==============================================================================
module VIPArcher::Battle_Skill
#技能槽名字
Skills_Slot_Name = ['技能槽一','技能槽二','技能槽三','技能槽四','技能槽五']
#可使用的场合名称
SKILL_OCCASION = ['平时', '战斗中', '菜单中', '不能使用']
#效果范围名称
SKILL_SCOPE = ['无', '敌单体', '敌全体', '己方单体', '己方全体',
'己方单体(战斗不能)', '己方全体(战斗不能)', '使用者']
#未装备技能时技能槽显示内容
BLANK_TEXT = '- 空技能槽 -'
#空技能槽帮助窗口文本
BLANK_HELP = '空的技能槽,可以装备战斗技能。'
#"[卸下技能]"的图标文件名(不需要则设置为 nil 或 false)
RELEASE_ICON = '047-Skill04'
#"[卸下技能]"帮助窗口文本
RELEASE_HELP = '卸下已装备的技能。'
#"[卸下技能]"按钮名称
RELEASE_TEXT = '[卸下技能]'
end
#==============================================================================
# ☆ 设定结束 ☆
#==============================================================================
class Symbol
def to_proc
Proc.new { |*args| args.shift.__send__(self, *args) }
end
end
class Game_Actor < Game_Battler
include VIPArcher::Battle_Skill
attr_reader :battle_skill #已装备技能
alias battle_skill_initialize initialize
def initialize(actor_id)
@battle_skill = Array.new(Skills_Slot_Name.size){ nil }
battle_skill_initialize(actor_id)
end
def add_battle_skill(skill,id)
@battle_skill[id] = nil if skill.zero?
return if @battle_skill.include?(skill)
@battle_skill[id] = skill if skills.include?(skill)
end
alias battle_skill_learn_skill learn_skill
def learn_skill(skill_id)
battle_skill_learn_skill(skill_id)
auto_add_battle_skill(skill_id) unless @battle_skill.include?(skill_id)
end
def auto_add_battle_skill(skill_id)
@battle_skill.each_index do |index|
return @battle_skill[index] = skill_id if @battle_skill[index].nil?
end
end
alias battle_skill_forget_skill forget_skill
def forget_skill(skill_id)
battle_skill_forget_skill(skill_id)
if @battle_skill.include?(skill_id)
@battle_skill[@battle_skill.index(skill_id)] = nil
end
end
end
class Window_Selectable < Window_Base
def create_contents
self.contents.dispose if self.contents
self.contents = Bitmap.new(width - 32, row_max * 32)
end
end
class Window_EquipSkillLeft < Window_Base
include VIPArcher::Battle_Skill
def initialize(actor, skill = nil)
super(0, 64, 272, 192)
self.contents = Bitmap.new(width - 32, height - 32)
@actor, @skill = actor, skill
refresh
end
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_level(@actor, 132, 0)
draw_skill_info unless @skill.nil?
end
def set_skill(skill)
@skill = skill
refresh
end
def draw_skill_info
self.contents.font.color = system_color
self.contents.draw_text(0, 32, 128, 32, '使用场合')
self.contents.font.color = normal_color
self.contents.draw_text(32, 64, 128, 32, SKILL_OCCASION[@skill.occasion])
self.contents.font.color = system_color
self.contents.draw_text(0, 96, 128, 32, '效果范围')
self.contents.font.color = normal_color
self.contents.draw_text(32, 128, 320, 32, SKILL_SCOPE[@skill.scope])
end
end
class Window_EquipSkillSlot < Window_Selectable
include VIPArcher::Battle_Skill
attr_writer :skill_info_window
def initialize(actor, skill_index = 0)
super(272, 64, 368, 192)
@actor, self.index = actor, skill_index
refresh
end
def data
@actor.battle_skill
end
def item
data[self.index] ? $data_skills[data[self.index]] : nil
end
def refresh
@item_max = data.size
create_contents
self.contents.font.color = system_color
Skills_Slot_Name.each_with_index do |name,id|
self.contents.draw_text(4, 32 * id, 92, 32, name)
end
data.each_with_index do |skill_id,id|
if skill_id.nil?
self.contents.font.color = normal_color
self.contents.draw_text(128 , 32 * id,192, 32, BLANK_TEXT)
else
draw_item_name($data_skills[skill_id], 128, 32 * id)
end
end
end
def update_help
@help_window.set_text(item.nil? ? BLANK_HELP : item.description)
@skill_info_window.set_skill(item) if @skill_info_window
end
end
class Window_SkillItem < Window_Selectable
include VIPArcher::Battle_Skill
attr_writer :skill_info_window
def initialize(actor)
super(0, 256, 640, 224)
@actor, @column_max, self.active, self.index = actor, 2, false, -1
refresh
end
def item
@data[self.index] ? $data_skills[@data[self.index]] : nil
end
def refresh
@data = []
skills = @actor.skills.select{|skill| !@actor.battle_skill.include?(skill)}
skills.each{|skill| @data.push(skill) }
@data.push(nil) # 添加[卸下装备]
@item_max = @data.size
create_contents
@data.each_index{|index| draw_item(index)}
end
def draw_item(index)
x = 4 + index % 2 * (288 + 32)
y = index/ 2 * 32 #这残念的Sublime Text高亮=。=
self.contents.font.color = normal_color
if @data[index]
skill = $data_skills[@data[index]]
bitmap = RPG::Cache.icon(skill.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(x + 28, y, 212, 32, skill.name)
else
bitmap = RPG::Cache.icon(RELEASE_ICON) if RELEASE_ICON
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) if bitmap
self.contents.draw_text(x + 28, y, 212, 32, RELEASE_TEXT)
end
end
def update_help
@help_window.set_text(item.nil? ? RELEASE_HELP : item.description)
@skill_info_window.set_skill(item) if @skill_info_window
end
end
class Window_Skill < Window_Selectable
def refresh
@data = []
if $scene.instance_of?(Scene_Battle)
@actor.battle_skill
else
@actor.skills
end.each do |skill|
@data.push($data_skills[skill]) unless skill.nil?
end
@item_max = @data.size
create_contents unless @item_max.zero?
@data.each_index{|index| draw_item(index) }
end
end
class Scene_SetEquipSkill
def initialize(actor_index = 0, skill_index = 0)
@actor_index, @skill_index = actor_index, skill_index
end
def main
@actor = $game_party.actors[@actor_index]
create_all_window
Graphics.transition
[Graphics,Input,self].map(&:update) while $scene.equal?(self)
Graphics.freeze
dispose_all_window
end
def create_all_window
@help_window = Window_Help.new
@right_window = Window_EquipSkillSlot.new(@actor,@skill_index)
@left_window = Window_EquipSkillLeft.new(@actor,@right_window.item)
@skillitem_window = Window_SkillItem.new(@actor)
@right_window.help_window = @help_window
@skillitem_window.help_window = @help_window
@right_window.skill_info_window = @left_window
@skillitem_window.skill_info_window = @left_window
end
def update
update_all_windows
return update_right if @right_window.active
return update_item if @skillitem_window.active
end
def update_right
return scene_return if Input.trigger?(Input::B)
return on_slot_ok if Input.trigger?(Input::C)
return process_pagedown if Input.trigger?(Input::RIGHT)
return process_pageup if Input.trigger?(Input::LEFT)
end
def update_item
return on_item_cancel if Input.trigger?(Input::B)
return on_item_ok if Input.trigger?(Input::C)
end
def on_item_ok
$game_system.se_play($data_system.equip_se)
skill = @skillitem_window.item
@actor.add_battle_skill(skill.nil? ? 0 : skill.id,@right_window.index)
@right_window.active = true
@skillitem_window.active = false
@skillitem_window.index = -1
@right_window.refresh
@skillitem_window.refresh
end
def on_item_cancel
$game_system.se_play($data_system.cancel_se)
@right_window.active = true
@skillitem_window.active = false
@skillitem_window.index = -1
end
def scene_return
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
def on_slot_ok
$game_system.se_play($data_system.decision_se)
@equipskill_id = @right_window.index
@right_window.active = false
@skillitem_window.active = true
@skillitem_window.index = 0
end
def process_pageup
$game_system.se_play($data_system.cursor_se)
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
$scene = Scene_SetEquipSkill.new(@actor_index, @right_window.index)
end
def process_pagedown
$game_system.se_play($data_system.cursor_se)
@actor_index += 1
@actor_index %= $game_party.actors.size
$scene = Scene_SetEquipSkill.new(@actor_index, @right_window.index)
end
def update_all_windows
instance_variables.each do |varname|
ivar = instance_variable_get(varname)
ivar.update if ivar.is_a?(Window)
end
end
def dispose_all_window
instance_variables.each do |varname|
ivar = instance_variable_get(varname)
ivar.dispose if ivar.is_a?(Window)
end
end
end
class Interpreter
#--------------------------------------------------------------------------
# ● 条件分支
#--------------------------------------------------------------------------
alias battle_skill_command_111 command_111
def command_111
result = false
# 条件判定
if [@parameters[0],@parameters[2]] == [4,2]
actor = $game_actors[@parameters[1]]
if actor != nil
if $scene.instance_of?(Scene_Battle)
result = (actor.battle_skill.include?(@parameters[3]))
else
result = (actor.skill_learn?(@parameters[3]))
end
end
# 判断结果保存在 hash 中
@branch[@list[@index].indent] = result
# 判断结果为真的情况下
if @branch[@list[@index].indent] == true
# 删除分支数据
@branch.delete(@list[@index].indent)
# 继续
return true
end
# 不符合条件的情况下 : 指令跳转
return command_skip
else
battle_skill_command_111
end
end
end[/pre][/fold]
[fold=14.种植系统]
[pre lang="Ruby"]#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Dynamic Gardening
# Author: ForeverZer0
# Date: 5.13.2011
# Version: v.3.0
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# VERSION HISTORY
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# v.1.1 (4.15.2010)
# - Improved coding
# - No longer uses game variables, events use self-switches instead
# - Added ability to create different graphics for every plant, without
# having to use more event pages
# - Much less tedious setting up multiple events and changing the every
# condition variable.
# v.2.0 (10.10.2010)
# - Total re-write. Code has been vastly improved and is much more efficient.
# - Event setup has been simplified. Now requires only a single comment, and
# does not require multiple pages.
# - Added configurability for the number of stages each item requires.
# - The timers no longer use Game_System to constantly update, but simply
# compare themselves with the Graphics.frame_count when the event exists
# on the current map, which also allows the plants to grow during scenes
# other than Scene_Map and Scene_Battle.
# - Got rid of Scene_Harvest. Scene_Garden now handles both aspects, and has
# been improved.
# - Added item icons to the help window display.
# v.3.0 (5.13.2011)
# - Restructured code completely
# - Increased compatibility and performance
# - Fixed bug with final graphic not behaving correctly
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
# This system allows the player to plant seeds, which will eventually grow
# into plants that can be harvested for items. The system is very similar in
# nature to that found in Legend of Mana. Seed's can be combined in different
# ways, which will effect the total growth duration, the number of stages the
# plant passes through, the graphics used, and of course the final result.
#
# Features:
#
# - Totally configurable growth rates, results, and graphics for every plant.
# - Can use arrays of items for each result, so the final item is not
# neccessarily the same every time.
# - Each plant timer is independent, and its progress is saved with the game.
# - Easy setup. Need only a single comment in one of the event's pages.
#
# Instructions:
#
# - Place script below Debug and above Main
# - Configure the options below (instructions are with each setting)
# - Create an event, setting the graphic to whatever you want. This will be the
# graphics used when nothing is growing on the plant.
# - At the very top event's page, place a comment that reads "Garden Event",
# omitting the quotation marks.
# - As long as the page's conditions are met, this event can be clicked on to
# initiate the Garden scene, and can grow plants.
# - Note that plants can be harvested early, but they will yield nothing until
# they are ripe.
#
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#===============================================================================
# ** Garden
#===============================================================================
module Garden
SEED_IDS = [524, 525, 526, 527, 528, 529, 530, 531]
# IDs of the items in the database that are seeds. Add them into the array in
# the order of value/rarity in your game
HARVEST_SE = '056-Right02'
# This is the SE that will be played when the player harvests the plant.
SEED_DISPLAY = true
# If true, all seeds will be displayed in the seed window, including those
# that the player does not have, though they will be disabled. If false, only
# seeds that that the player currently has will be displayed.
# Define the growth rates here. (the average of both seeds will be used)
def self.growth_rate(seed)
return case seed
# when SEED_ID then SECONDS
when 524 then 30
when 525 then 40
when 526 then 50
when 527 then 60
when 528 then 70
when 529 then 80
when 530 then 90
when 531 then 100
end
end
#-------------------------------------------------------------------------------
# Define the number of stages that each item uses. The stages will still cycle
# in the same order, but only use up to the defined number of them before going
# to the final graphic. This will not effect the duration that the seed takes to
# grow, only how many times the graphic changes.
#
# You do not have to define anything that uses a three stage configuration.
#-------------------------------------------------------------------------------
def self.number_stages(result)
case result
when 640,538,278,279,282,280,10,6
return 4
when 258,259,260,261,262,263,304,535,536
return 5
else
return 3
end
end
#-------------------------------------------------------------------------------
# Define the final result of the seeds. A random item from the array will be
# given as the final result.
#
# Each seed is given a value from 0 to the total number of seeds in the SEED_IDS
# array, and both values are added together to determine which 'produce' array
# will be used for the final result. This is why it is important that you have
# the SEED_IDS array in order of value/rarity. You can find the total number of
# cases you will need by subtracting 1 from the total number of different seeds
# in SEED_IDS, and multiplying that number by 2.
#
# EX. Player uses one each of the first and last seed in the SEED_IDS array,
# and there are 8 total seeds in the array...
#
# FIRST_SEED = 2
# LAST_SEED = 5 2 + 5 = RESULT
#
# By placing multiple copies of the same value in an array, you can increase
# the odds of receiving that item over another in the same array.
#-------------------------------------------------------------------------------
def self.produce(seed)
return case seed
when 0 then [278, 279] # Only if both seed are the lowest seeds
when 1 then [279, 282]
when 2 then [282, 280]
when 3 then [280, 538]
when 4 then [538, 10]
when 5 then [10, 6]
when 6 then [6, 258] # Every combination in between
when 7 then [258, 259]
when 8 then [259, 260]
when 9 then [260, 261]
when 10 then [261, 262]
when 11 then [262, 263]
when 12 then [263, 304]
when 13 then [304, 535]
when 14 then [536] # Only if both seeds are the highest seeds
end
end
#-------------------------------------------------------------------------------
# Define graphics for the final results, and each stage. Follow the below
# template to set it up.
#
# when ITEM_ID/STAGE then ['FILENAME', X, Y]
#
# ITEM_ID = The ID number of the item in your database
# STAGE = The stage during which to display the graphic
#
# FILENAME = The name of the character file the needed graphic is on
# X = The x-coordinate of the correct picture on the charset (1 - 4)
# Y = The y-coordinate of the correct picture on the charset (1 - 4)
#
# ← X → Ex. If the needed graphic was in the bottom
# 1 2 3 4 left corner: X = 1 Y = 4
# ┌──┬──┬──┬──┐
# 1 │ │ │ │ │
# ├──┼──┼──┼──┤
# ↑ 2 │ │ │ │ │
# Y ├──┼──┼──┼──┤
# ↓ 3 │ │ │ │ │
# ├──┼──┼──┼──┤
# 4 │ │ │ │ │
# └──┴──┴──┴──┘
#-------------------------------------------------------------------------------
def self.stage_graphics(stage)
return case stage
when 0 then ['Plants1', 1, 1]
when 1 then ['Plants1', 2, 3]
when 2 then ['Plants1', 2, 1]
when 3 then ['Plants1', 4, 2]
when 4 then ['Plants1', 2, 4]
end
end
def self.final_graphic(item)
return case item
when 283 then ['Garden Plants', 4, 4]
when 278 then ['Garden Plants', 4, 1]
when 279 then ['Garden Plants', 4, 2]
when 482 then ['Garden Plants', 4, 3]
when 280 then ['Garden Plants', 1, 1]
when 10 then ['Garden Plants', 1, 4]
when 6 then ['Garden Plants', 2, 1]
when 258 then ['Garden Plants', 2, 4]
when 259 then ['Garden Plants', 1, 2]
when 260 then ['Garden Plants', 2, 2]
when 261 then ['Garden Plants', 2, 3]
when 262 then ['Garden Plants', 1, 3]
when 263 then ['Garden Plants', 3, 3]
when 534 then ['Garden Plants', 3, 2]
when 535 then ['Garden Plants', 3, 1]
when 536 then ['Garden Plants', 3, 4]
end
end
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
def self.plant_seeds(seed1, seed2, event_id)
# Create a new instance of a Garden::Plant
plant = self::Plant.new(event_id, seed1, seed2)
if $game_system.garden[$game_map.map_id] == nil
$game_system.garden[$game_map.map_id] = [plant]
else
$game_system.garden[$game_map.map_id].push(plant)
end
end
def self.harvest(id)
# Find the appropriate plant.
plant = $game_system.garden[$game_map.map_id].find {|plant| plant.id == id }
return nil if plant == nil
# Return the result, and delete plant data from array.
result = plant.produce
plant.restore_event
$game_system.garden[$game_map.map_id] -= [plant]
return result
end
#===============================================================================
# ** Garden::Plant
#===============================================================================
class Plant
attr_reader :id, :ripe
def initialize(id, seed1, seed2)
# Initialize needed instance variables.
@id, @seed1, @seed2 = id, seed1, seed2
@ripe, @stage = false, -1
# Run setup method, using data in Garden config for this plant's seeds
setup
end
def setup
# Store original graphic, direction, and pattern in variable.
event = $game_map.events[@id]
@original_event = [event.character_name, event.direction, event.pattern]
# Calculate the total duration of the seed combination.
@duration = (Garden.growth_rate(@seed1) + Garden.growth_rate(@seed2))
# Find the produce that this combination will grow into
comb = Garden::SEED_IDS.index(@seed1) + Garden::SEED_IDS.index(@seed2)
@produce = Garden.produce(comb)
@produce = @produce[rand(@produce.size)]
# Get the number of stages this plant will use, then setup counts for it
number, count = Garden.number_stages(@produce), 0
dur = (@duration / number.to_f).to_i
@stages = (0...number).to_a
@stages.collect! {|i| $game_system.garden_counter + (i * dur) }
# Refresh the plant to apply changes
refresh
end
def refresh
unless @ripe
# Initialize local variable that will determine if graphic needs redrawn.
previous = @stage
count = @stages.find_all {|rate| $game_system.garden_counter <= rate }
@stage = (@stages.size - count.size)
@ripe = (@stage >= @stages.size - 1)
# Redraw bitmap if needed.
change_graphic(@ripe) if previous != @stage
end
end
def change_graphic(final)
# Set local variable to this plant's event
event = $game_map.events[@id]
data = final ? Garden.final_graphic(@produce) :
Garden.stage_graphics(@stage)
# Apply graphical change by simply altering event's stance and source
event.character_name = data[0]
event.direction = (2 * data[2])
event.pattern = (data[1] - 1)
event.refresh
end
def restore_event
# Restore event to original state before planting.
event = $game_map.events[@id]
event.character_name = @original_event[0]
event.direction = @original_event[1]
event.pattern = @original_event[2]
end
def produce
# Return nil if not yet ripe, else return an item ID.
return (@ripe ? @produce : nil)
end
end
end
#===============================================================================
# ** Game_System
#===============================================================================
class Game_System
attr_accessor :garden, :garden_counter
alias zer0_garden_init initialize
def initialize
# Initialize variables used for the garden system.
@garden_counter = 0
@garden = {}
zer0_garden_init
end
alias zer0_garden_upd update
def update
# Increase garden counter and check if update is needed every second.
if (Graphics.frame_count % 40) == 0
@garden_counter += 1
# Check if current map has any plants on it. If so, refresh them.
if @garden[$game_map.map_id] != nil && !@garden[$game_map.map_id].empty?
@garden[$game_map.map_id].each {|plant| plant.refresh }
end
end
zer0_garden_upd
end
end
#===============================================================================
# ** Game_Event
#===============================================================================
class Game_Event
attr_accessor :character_name, :direction, :pattern
alias zer0_garden_event_refresh refresh
def refresh
# Normal refresh method.
zer0_garden_event_refresh
# Set flag for this event being a garden event.
@garden_event = (@page != nil && @page.list[0].code == 108 &&
@page.list[0].parameters[0] == 'Garden Event')
end
alias zer0_garden_upd update
def update
# Skip update method foe this event if it is a plant.
@garden_event ? return : zer0_garden_upd
end
alias zer0_garden_event_start start
def start
# Redefine the 'start' method if Garden Event flag is present.
if @garden_event
plants, harvest = $game_system.garden[$game_map.map_id], false
# Check if plant exists, and if so check if it is ripe.
pick = plants != nil ? (plants.find {|obj| obj.id == @id }) != nil : false
$scene = Scene_Garden.new(@id, pick)
else
zer0_garden_event_start
end
end
end
#===============================================================================
# ** Game_Map
#===============================================================================
class Game_Map
alias zer0_garden_setup setup
def setup(map_id)
zer0_garden_setup(map_id)
# Refresh each plant when map is set up
if $game_system.garden[@map_id] != nil
$game_system.garden[@map_id].each {|obj| obj.change_graphic(obj.ripe) }
end
end
end
#===============================================================================
# * Window_Seed
#===============================================================================
class Window_Seed < Window_Selectable
def initialize
super(160, 304, 320, 160)
self.index = 0
refresh
end
def refresh
# Clear the bitmap.
self.contents = self.contents.dispose if self.contents != nil
# Determine what seeds to display.
@seeds = Garden::SEED_IDS.collect {|id| $data_items[id] }
unless Garden::SEED_DISPLAY
@seeds.reject! {|seed| $game_party.item_number(seed.id) < 1 }
end
@item_max = @seeds.size
# Draw the items on the bitmap.
if @item_max > 0
self.contents = Bitmap.new(width - 32, @item_max * 32)
@seeds.each_index {|i|
item = @seeds
number = $game_party.item_number(item.id)
self.contents.font.color = number > 0 ? normal_color : disabled_color
opacity = number > 0 ? 255 : 128
# Find icon bitmap and set it to window, and draw the text.
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(4, i*32+4, bitmap, Rect.new(8, 11, 48, 48), opacity)
self.contents.draw_text(38, i*32, 288, 32, item.name)
self.contents.draw_text(-32, i*32, 288, 32, ':', 2)
self.contents.draw_text(-4, i*32, 288, 32, number.to_s, 2)
}
end
end
def seed
# Returns currently highlighted seed item.
return @seeds[self.index]
end
end
#===============================================================================
# * Scene_Garden
#===============================================================================
class Scene_Garden
def initialize(id, harvest)
@event_id, @harvest = id, harvest
# Play SE to give impression that scene never changed.
$game_system.se_play($data_system.decision_se)
$game_player.straighten
garden = $game_system.garden[$game_map.map_id]
if garden != nil
@plant = garden.find {|plant| plant.id == id }
end
end
def main
# Create map sprite and required windows.
@map, @help_window = Spriteset_Map.new, Window_Help.new
# Create Confirmation window.
@confirm_window = Window_Command.new(128, ['是', '否'])
@confirm_window.x, @confirm_window.y = 496, 336
# Initialize sprites array. Used to handle all the sprites together.
@sprites = [@map, @help_window, @confirm_window]
# Create seed window if plant is not being harvested.
unless @harvest
@seed_window = Window_Seed.new
@sprites.push(@seed_window)
@seed_window.active = @seed_window.visible = false
@help_window.set_text('很肥沃的土地,要进行种植吗?')
else
@data = $game_system.garden[$game_map.map_id][@event_id]
if @plant != nil && @plant.ripe
text = '作物已经成熟,要进行收获吗?'
else
text = '作物还没有完全成熟,要提前进行收获吗?'
end
@help_window.set_text(text)
end
# Transition instantly then start main loop.
Graphics.transition(0)
loop { Graphics.update; Input.update; update; break if $scene != self }
# Dispose of all the sprites.
@sprites.each {|sprite| sprite.dispose }
# Have map refresh to update any changes made.
$game_map.need_refresh = true
end
def update
@sprites.each {|sprite| sprite.update }
# Branch update method depending on what window is active.
if @confirm_window.active
update_confirm
elsif @seed_window != nil && @seed_window.active
update_seed_select
end
end
def update_confirm
if Input.trigger?(Input::B)
# Branch by what action is being canceled.
if @harvest
back_to_map
else
@seed1 == nil ? back_to_map : cancel_seed_selection
end
elsif Input.trigger?(Input::C)
# Branch by what action is being confirmed.
if @harvest
if @confirm_window.index == 0
item_id = Garden.harvest(@event_id)
if item_id != nil
@confirm_window.active = @confirm_window.visible = false
# Gain item, play the harvest SE, then return to the map.
$game_party.gain_item(item_id, 1)
$game_system.se_play(RPG::AudioFile.new(Garden::HARVEST_SE, 80, 100))
show_results($data_items[item_id])
$scene = Scene_Map.new
else
back_to_map
end
else
back_to_map
end
else
# If asking if player would like to plant seeds at this location.
if @seed1 == nil
if @confirm_window.index == 0
@seed_window.active = @seed_window.visible = true
@confirm_window.active = @confirm_window.visible = false
@help_window.set_text('请选择您喜欢的种子,进行种植')
else
back_to_map
return
end
else # If confirming seed selection.
if @confirm_window.index == 0
# Plant seeds and return to map.
Garden.plant_seeds(@seed1.id, @seed2.id, @event_id)
$scene = Scene_Map.new
else # If canceling seed selection
cancel_seed_selection
return
end
end
$game_system.se_play($data_system.decision_se)
end
end
end
def show_results(result)
@help_window.contents.clear
# Display the message in the help window.
@help_window.draw_item_name(result, 0, 0)
cw = @help_window.contents.text_size(result.name).width + 32
@help_window.contents.draw_text(cw, 0, 608, 32, ' 已添加至您的背包!')
# Call Input.update to the clear key press.
Input.update
# Loop until it is pressed again.
until Input.trigger?(Input::C)
Graphics.update; Input.update; update
end
end
def cancel_seed_selection
# Play cancel SE, reset seeds, and activate/deactivate windows.
$game_system.se_play($data_system.cancel_se)
@seed_window.active = @seed_window.visible = true
@confirm_window.active = @confirm_window.visible = false
@help_window.set_text('请选择您喜欢的种子,进行种植')
@seed1 = @seed2 = nil
end
def back_to_map
# Play cancel SE and return to map.
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
def update_seed_select
if Input.trigger?(Input::B)
# If first seed is selected, go back to re-select, else return to map.
if @seed1 != nil
$game_party.gain_item(@seed1.id, 1)
@seed1 = nil
@seed_window.refresh
$game_system.se_play($data_system.cancel_se)
else
back_to_map
end
elsif Input.trigger?(Input::C)
# Play Cancle SE if displayed and party has none.
if $game_party.item_number(@seed_window.seed.id) < 1
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
# Set first seed if not defined, else set the second seed and continue.
if @seed1 == nil
@seed1 = @seed_window.seed
$game_party.lose_item(@seed1.id, 1)
else
@seed2, @seed_window.active = @seed_window.seed, false
$game_party.lose_item(@seed2.id, 1)
@confirm_window.active = @confirm_window.visible = true
end
# Refresh seed window to show changes in inventory.
set_help
@seed_window.refresh
end
end
def set_help
# Clear help window.
@help_window.contents.clear
# Draw items
text = @seed2 != nil ? '确定以它们进行种植吗?' : '请选择第二类种子'
@help_window.set_text(text)
@help_window.draw_item_name(@seed1, 224, 0)
if @seed2 != nil
cw = @help_window.contents.text_size(@seed1.name).width + 320
@help_window.draw_item_name(@seed2, cw, 0)
end
end
end
[/pre][/fold]
[fold=15.随机地图][pre lang="Ruby"]#
# 随机地图生成脚本 v0.80 by tonbi
#
# 汉化修改 66RPG bbschat(2006.1.2)
#
# 随机地图自动生成脚本。
#
# ●使用方法
#
# 首先,设定随机地图名称
#
# 地图名称请按照「XXXXX,随机,YYY,ZZZ」的样式来命名。
# XXXXX 地图名,随便起自己喜欢的名字。
# YYY 随机类型编号,参考样例。
# ZZZ 障碍物数量,参考样例。
#
# 接下来,参考样例在地图上按照一定的规则画上地图元件
# 画的时候注意一下层。参考样例把地图元件画在对应的层上。
#
# 最后设定以下事件
#
# 中继点设定方法:
# 事件名称为「XXXXX,中继点」或事件执行内容的第一行加上「◆注释 : 中继点」。
#
# 随机地图将按照中继点事件产生随机道路,并按照事件ID顺序依次通过数个中继点
# (当然肯定不是直线通过)
# 一般请在地图的两端设定中继点事件。
# 两个中继点之间请保留适当空间,少于5个地图元件的话就没有墙壁了。
# 不过就算没有中继点,也能生成随机地图。
# 增加中继点会减少墙壁的数量,所以不要太多,有几个中继点就可以了。
# 通常按照三角形的方位来设置3个中继点。
#
# 中继点以外的事件如果没有特别指定将随机放置在地图的道路上。
#
# 固定事件设定方法:
# 事件名称为「XXXXX,固定」或事件执行内容的第一行加上「◆注释 : 固定」。
#
# 该事件将被放置在离该事件位置最近的道路上。
#
# 完全固定事件设定方法:
# 事件名称为「XXXXX,完全固定」或事件执行内容的第一行加上「◆注释 : 完全固定」
#
# 该事件位置将保持不变。
# 自动执行和并行处理的事件或者希望放在地图边缘方便查找的事件可以使用完全固定。
#
# 墙壁事件设定方法:
# 事件执行内容的第一行为「◆注释 : 壁设置」
# 该事件将随机出现在地图的墙壁上。
# 门,火把之类的事件专用。注释形式类似「壁设置,1」这样,后面要跟一个数字,
# 数字为了保证可以添加类似于[横幅]这样的事件。(横幅1元件为0,3个元件为1。)
# 这样的话就可以使用一些较大的事件了。
#
# 墙壁固定事件设定方法:
# 事件页第一行为「◆注释 : 壁设置固定」
# 这是同时具有上述固定事件和墙壁事件两个性质的事件。
# 也就是放置在离该事件位置最近的墙壁上的事件。
# 如果使用「壁设置固定,1」这种形式,也可以使用较大的事件。
#
# 还有使用之前请按照自己的需要设定下面的参数。
#========================================================================
#========================================================================
#★Clipping距离指定(搞不懂什么意思的话就不要改。)
class Game_Character
DRAWRANGEX = 1920 # 地图角色的Sprite更新距离
DRAWRANGEY = 1664 # 使用较大CharChip?时请适当增加。
# 指定的是X:15 Y:13乘128的数值。
# 上面是X坐标(横)下面是Y坐标(纵)。
end
#========================================================================
#========================================================================
#★是否保存。(并不准备使用随机地图、只是为了节约制作时间。)
# 保存下来的地图可以复制到其他地方以节省制作时间。
class Game_Map
AUTO_MAP_SAVE = true # 是否保存为地图ID:999。
# true 保存 false 不保存
# 游戏做完发布后请设定为false。
end
#-------------------------------------------------------------------
# ●Game_Temp
#--------------------------------------------------------------------
class Game_Temp
alias initialize_tonbi1 initialize
def initialize
initialize_tonbi1
$onscreen = [] # Sprite是否画面内标志
end
end
#--------------------------------------------------------------------------
# ● Game_Character
#--------------------------------------------------------------------------
class Game_Character
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
alias update_tonbi1 update
def update
# 画面上的位置
sx = @real_x - $game_map.display_x - 1280
sy = @real_y - $game_map.display_y - 960
# 画面位置的绝对值
abs_sx = sx > 0 ? sx : -sx
abs_sy = sy > 0 ? sy-3 : -sy
# 纵横坐标超出 DRAWRANGE 元件的情况下
# if abs_sx > DRAWRANGEX or abs_sy > DRAWRANGEY
# # Sprite不更新
# $onscreen[@id]=false
# else
# Sprite更新
$onscreen[@id]=true
# end
update_tonbi1
end
end
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
attr_accessor :character_sprites
def initialize
$onscreen = []
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 200
@viewport3.z = 5000
# 生成元件地图
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names
@tilemap.autotiles = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# 生成远景平面
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
# 生成雾平面
@fog = Plane.new(@viewport1)
@fog.z = 3000
#########################################################★改变
# 生成角色活动块
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
####TOOL释放的行走图刷新
include XRXS_CTS_RefreshToken
alias xrxs_lib15_update update
#########################################################
# 生成天气
@weather = RPG::Weather.new(@viewport1)
# 生成图片
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 释放元件地图
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles.dispose
end
@tilemap.dispose
# 释放远景平面
@panorama.dispose
# 释放雾平面
@fog.dispose
############################################################★改变
# 释放角色活动块
for sprite in @character_sprites
sprite.dispose
end
############################################################
# 释放天候
@weather.dispose
# 释放图片
for sprite in @picture_sprites
sprite.dispose
end
# 释放计时器块
@timer_sprite.dispose
# 释放显示端口
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
#TOOL的行走图刷新XAS系统
xrxs_lib15_update
refresh_token if $game_map.need_refresh_token
###################
# 远景与现在的情况有差异发情况下
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @panorama.bitmap != nil
@panorama.bitmap.dispose
@panorama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
end
Graphics.frame_reset
end
# 雾与现在的情况有差异的情况下
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
# 刷新元件地图
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
# 刷新远景平面
@panorama.ox = $game_map.display_x / 8
@panorama.oy = $game_map.display_y / 8
# 刷新雾平面
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
#####################################################★改变
# 刷新角色活动块
for sprite in @character_sprites
sprite.update
end
#####################################################
# 刷新天候图形
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.ox = $game_map.display_x / 4
@weather.oy = $game_map.display_y / 4
@weather.update
# 刷新图片
for sprite in @picture_sprites
sprite.update
end
# 刷新计时器块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# 设置画面的闪烁色
@viewport3.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport3.update
end
end
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● 设置
# map_id : 地图 ID
#--------------------------------------------------------------------------
def setup(map_id)
# 地图 ID 记录到 @map_id
@map_id = map_id
# 地图文件装载后、设置到 @map
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
# 定义实例变量设置地图元件信息
tileset = $data_tilesets[@map.tileset_id]
@tileset_name = tileset.tileset_name
@autotile_names = tileset.autotile_names
@panorama_name = tileset.panorama_name
@panorama_hue = tileset.panorama_hue
@fog_name = tileset.fog_name
@fog_hue = tileset.fog_hue
@fog_opacity = tileset.fog_opacity
@fog_blend_type = tileset.fog_blend_type
@fog_zoom = tileset.fog_zoom
@fog_sx = tileset.fog_sx
@fog_sy = tileset.fog_sy
@battleback_name = tileset.battleback_name
@passages = tileset.passages
@priorities = tileset.priorities
@terrain_tags = tileset.terrain_tags
# 初始化显示坐标
@display_x = 0
@display_y = 0
check_special_map #★检查随机地图
# 清除刷新要求标志
@need_refresh = false
# 设置地图事件数据
@events = {}
for i in @map.events.keys
@events = Game_Event.new(@map_id, @map.events)
end
# 设置公共事件数据
@common_events = {}
for i in 1...$data_common_events.size
@common_events = Game_CommonEvent.new(i)
end
# 初始化雾的各种信息
@fog_ox = 0
@fog_oy = 0
@fog_tone = Tone.new(0, 0, 0, 0)
@fog_tone_target = Tone.new(0, 0, 0, 0)
@fog_tone_duration = 0
@fog_opacity_duration = 0
@fog_opacity_target = 0
# 初始化滚动信息
@scroll_direction = 2
@scroll_rest = 0
@scroll_speed = 4
end
#--------------------------------------------------------------------------
# ● 紧接读入地图之后的处理
#--------------------------------------------------------------------------
def check_special_map
# 取得地图名称
mapinfo = load_data("Data/MapInfos.rxdata")
# 地图名称包含“随机”的场合
if mapinfo[@map_id].subname == "随机"
if mapinfo[@map_id].subname(3)=="" or mapinfo[@map_id].subname(3) == nil
p3 = 0
else
p3 = mapinfo[@map_id].subname(3).to_i
end
if mapinfo[@map_id].subname(4)=="false"
p4 = false
end
make_random_map(2,mapinfo[@map_id].subname(2).to_i,p3,p4)
end
end
#--------------------------------------------------------------------------
# ● 生成随机地图
# wall = 墙壁的高 >> 现在无效
# type = 墙壁制作类型 >> 0以外没制作(汗 指定方法也未定) (<-- bbschat注:汗~原来日本人也会用汗)
# thoughplayer = 玩家在中继点中包含吗?
# connect = 中继点的连接方法 >> true=连续 false=2个各自独立
#
# ※所有参数全部省略 可以使用下面的例子
# ex. make_random_map(2,0,,true)
#--------------------------------------------------------------------------
def make_random_map(wall = 2, type = 0, objcnt = 0, connect = true)
# 非法参数处理
wall = 0 if wall == nil
type = 0 if type == nil
objcnt = 0 if objcnt == nil
unless objcnt.is_a?(Numeric)
objcnt = 0
end
if objcnt < 0
objcnt = 0
end
connect = true if connect != false
# 高度数据表
@heightdata = Table.new(@map.width,@map.height)
# 地形数据表
@maskdata = Table.new(@map.width,@map.height)
# 事件数据表
@oneventdata = Table.new(@map.width,@map.height)
# 遮照设定数组
@masksetting = []
# 制作方法数组
@makedata = []
# 演算方法初始化
@targettype=0
@chgtype=0
time = -1
# 数据初始化
for i in 0...@map.width
for j in 0...@map.height
time += 1
if time%2000 == 0
Graphics.update
end
@heightdata[i,j] = 0
@maskdata[i,j] = 0
end
end
for i in 0...100
@masksetting = true
end
# 取得中继点情报
needposx = []
needposy = []
# 增加中继点事件
for i in @map.events.keys.sort
time += 1
if time%200 == 0
Graphics.update
end
if event_settype(i) == 1
if connect == true
needposx.push(@map.events.x)
needposy.push(@map.events.y)
needposx.push(@map.events.x)
needposy.push(@map.events.y)
else
needposx.push(@map.events.x)
needposy.push(@map.events.y)
end
end
end
if connect == true
needposx.shift
needposy.shift
end
loop do
if needposx.size <= 2
needposx.push(rand(@map.width))
needposy.push(rand(@map.height))
else
break
end
end
# 这里设定制作方法数组
case type
when 0
# 类型0 >> 2层自然类型
@makedata.push([0,1,0])
@makedata.push([5,1])
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,0,-15,4,0])
@makedata.push([1,1,1,1,1])
@makedata.push([6,0,needposx[i*2],needposy[i*2]])
@makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
end
@makedata.push([4,0,1,1,1])
@makedata.push([4,0,1,1,1])
@makedata.push([4,1,1,1,1])
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,0])
@makedata.push([2,1,2])
@makedata.push([5,1])
when 1
# 类型1 >> 2层人工类型
@makedata.push([0,1,0])
@makedata.push([5,1])
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,0,-6,4,1,10])
@makedata.push([1,1,1,1,1])
@makedata.push([6,0,needposx[i*2],needposy[i*2]])
@makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
end
@makedata.push([4,0,2,3,1])
@makedata.push([4,1,2,2,1])
@makedata.push([4,0,1,1,1])
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,0])
@makedata.push([2,1,2])
@makedata.push([5,1])
when 2
# 类型2 >> 2层自然凸类型
@makedata.push([0,1,0])
@makedata.push([5,1])
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,0,-15,4,0])
@makedata.push([1,1,1,1,1])
@makedata.push([6,0,needposx[i*2],needposy[i*2]])
@makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
end
@makedata.push([4,0,2,2,1])
@makedata.push([4,1,1,1,1])
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,0])
@makedata.push([2,1,2])
@makedata.push([5,-1])
when 3
# 类型3 >> 2层人工凸类型
@makedata.push([0,1,0])
@makedata.push([5,1])
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,0,-15,4,1,10])
@makedata.push([1,1,1,1,1])
@makedata.push([6,0,needposx[i*2],needposy[i*2]])
@makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
end
@makedata.push([4,0,2,2,1])
@makedata.push([4,1,1,1,1])
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,0])
@makedata.push([2,1,2])
@makedata.push([5,-1])
when 4
# 类型4 >> 2层自然类型 之一
# 地形[0:洞 1:地面 2:墙壁]
# 基本设定
@makedata.push([0,1,0])
@makedata.push([5,0])
# 放置墙
@makedata.push([1,0,0,-1,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,0,-1,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,-1,0,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,0,-1,0,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([4,2,2,2,1])
# 随机放置洞
for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
@makedata.push([1,3,3,8,8])
@makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
end
# 生成周围的墙
@makedata.push([7,2])
@makedata.push([4,2,1,1,1])
# 生成道路
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,1,-8,4,0,5])
@makedata.push([1,1,1,1,1])
@makedata.push([6,1,needposx[i*2],needposy[i*2]])
@makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
end
# 扩张处理
@makedata.push([4,1,1,1,1])
@makedata.push([4,1,0,1,1])
@makedata.push([2,0,0])
@makedata.push([4,1,1,0,1])
@makedata.push([2,-1,1])
@makedata.push([4,2,1,1,1])
# 高度设定
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,-1])
@makedata.push([2,1,2])
@makedata.push([5,0])
@makedata.push([2,2,2])
@makedata.push([5,1])
when 5
# 类型5 >> 2层人工类型 之一
# 地形[0:洞 1:地面 2:墙壁]
# 基本设定
@makedata.push([0,1,0])
@makedata.push([5,0])
# 放置墙
@makedata.push([1,0,0,-1,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,0,-1,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,-1,0,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,0,-1,0,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([4,2,2,2,1])
# 随机放置洞
for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
@makedata.push([1,3,3,8,8])
@makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
end
# 生成周围的墙
@makedata.push([7,2])
@makedata.push([4,2,1,1,1])
# 生成道路
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,1,-8,4,1,5])
@makedata.push([1,1,1,1,1])
@makedata.push([6,1,needposx[i*2],needposy[i*2]])
@makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
end
# 扩张处理
@makedata.push([4,1,1,1,1])
@makedata.push([4,1,0,1,1])
@makedata.push([2,0,0])
@makedata.push([4,1,1,0,1])
@makedata.push([2,-1,1])
@makedata.push([4,2,1,1,1])
# 高度设定
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,-1])
@makedata.push([2,1,2])
@makedata.push([5,0])
@makedata.push([2,2,2])
@makedata.push([5,1])
when 6
# 类型6 >> 2层自然类型 之二
# 地形[0:洞 1:地面 2:墙壁]
# 基本设定
@makedata.push([0,1,0])
@makedata.push([5,0])
# 放置墙
@makedata.push([1,0,0,-1,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,0,-1,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,-1,0,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,0,-1,0,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([4,2,2,2,1])
# 随机放置洞
for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
@makedata.push([1,1,1,3,3])
@makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
end
# 洞扩大
@makedata.push([4,0,2,2,0])
@makedata.push([4,0,1,2,1])
# 生成周围的墙
@makedata.push([7,2])
@makedata.push([4,2,1,1,1])
# 生成道路
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,1,-15,4,0,5])
@makedata.push([1,1,1,1,1])
@makedata.push([6,1,needposx[i*2],needposy[i*2]])
@makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
end
# 扩张处理
@makedata.push([4,1,1,1,1])
@makedata.push([4,1,0,1,1])
@makedata.push([2,0,0])
@makedata.push([4,1,1,0,1])
@makedata.push([2,-1,1])
@makedata.push([4,2,1,1,1])
# 高度设定
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,-1])
@makedata.push([2,1,2])
@makedata.push([5,0])
@makedata.push([2,2,2])
@makedata.push([5,1])
when 7
# 类型7 >> 2层人工类型 之二
# 地形[0:洞 1:地面 2:墙壁]
# 基本设定
@makedata.push([0,1,0])
@makedata.push([5,0])
# 放置墙
@makedata.push([1,0,0,-1,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,0,-1,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,-1,0,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,0,-1,0,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([4,2,2,2,1])
# 随机放置洞
for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
@makedata.push([1,1,1,3,3])
@makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
end
# 洞扩大
@makedata.push([4,0,2,2,0])
@makedata.push([4,0,1,2,1])
# 生成周围的墙
@makedata.push([7,2])
@makedata.push([4,2,1,1,1])
# 生成道路
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,1,-15,4,1,5])
@makedata.push([1,1,1,1,1])
@makedata.push([6,1,needposx[i*2],needposy[i*2]])
@makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
end
# 扩张处理
@makedata.push([4,1,1,1,1])
@makedata.push([4,1,0,1,1])
@makedata.push([2,0,0])
@makedata.push([4,1,1,0,1])
@makedata.push([2,-1,1])
@makedata.push([4,2,1,1,1])
# 高度设定
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,-1])
@makedata.push([2,1,2])
@makedata.push([5,0])
@makedata.push([2,2,2])
@makedata.push([5,1])
####################
#####################
when 8
# 类型8 >> 叹气森林
# 地形[0:洞 1:地面 2:墙壁]
# 基本设定
@makedata.push([0,1,0])
@makedata.push([5,0])
# 放置墙
@makedata.push([1,0,0,-1,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,0,-1,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,-1,0,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,0,-1,0,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([4,2,2,2,1])
# 随机放置洞
for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
@makedata.push([1,1,1,3,3])
@makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
end
# 洞扩大
@makedata.push([4,0,2,2,0])
@makedata.push([4,0,1,2,1])
# 洞扩大
# @makedata.push([4,0,2,2,0])
# @makedata.push([4,0,1,2,1])
# 生成周围的墙
@makedata.push([7,2])
@makedata.push([4,2,1,1,1])
# 生成道路
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,1,-15,4,1,5])
@makedata.push([1,1,1,1,1])
@makedata.push([6,1,needposx[i*2],needposy[i*2]])
@makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
end
# 扩张处理
@makedata.push([4,1,1,1,1])
@makedata.push([4,1,0,1,1])
@makedata.push([2,0,0])
@makedata.push([4,1,1,0,1])
@makedata.push([2,-1,1])
@makedata.push([4,2,1,1,1])
# 高度设定
@makedata.push([0,0,0])
@makedata.push([2,0,2])
#水
@makedata.push([5,-1])
#水更多变
@makedata.push([2,1,2])
@makedata.push([5,0])
@makedata.push([2,2,2])
@makedata.push([5,1])
end
#############
################
#############
# 实际制作
for make_stat in @makedata
time += 1
if time%2 == 0
Graphics.update
end
case make_stat[0]
when 0 # 对象变化 (p1[0=高度 1=地形], p2[0=代入 1=加算])
rndmap_chtarget(make_stat[1],make_stat[2])
when 1 # 参数设定 (minx, miny, maxz, maxy)
rndmap_setstat(make_stat[1],make_stat[2],make_stat[3],make_stat[4])
when 2 # 遮照变化 (p1[-1:全部], p2[ 0=false 1=true 2=onlytrue])
rndmap_chmask(make_stat[1],make_stat[2])
when 3 # 生成道路 (值,中继点数,边缘确保,类型)
rndmap_mkroad(make_stat[1],make_stat[2],make_stat[3],make_stat[4],make_stat[5])
when 4 # 扩张 (对象,纵幅,横幅,类型)
rndmap_plus(make_stat[1],make_stat[2],make_stat[3],make_stat[4])
when 5 # 全变化 (值)
rndmap_allchg(make_stat[1])
when 6 # 指定点 (值,位置X,位置Y)
rndmap_putpos(make_stat[1],make_stat[2],make_stat[3])
when 7 # 周围 (值)
rndmap_edge(make_stat[1])
end
end
# 取得使用地图元件
@tilesetting = Table.new(3,40,3)
for i in [0,1,2]
for k in 0...40
for j in [0,1,2]
@tilesetting[j,k,i] = @map.data[j,k,i]
end
end
end
# 补正
time = 0
for k in 0...@map.height
for j in 0...@map.width
time += 1
# 定期画面更新
if time%500 == 0
Graphics.update
end
# 墙下的地图元件要是洞的话,地面变更
if @heightdata[j,k] == 1
if @heightdata[j,k+1]==-1
@heightdata[j,k+1] = 0
if @heightdata[j,k+2]==-1 and
@heightdata[j,k+3] == 0
@heightdata[j,k+2] = 0
end
end
end
end
end
# 生成地面 之一 >> 暂且全面铺上
time = 0
for k in 0...@map.height
for j in 0...@map.width
time += 1
# 定期画面更新
if time%500 == 0
Graphics.update
end
if @heightdata[j,k] == 0
if @heightdata[j,k+1] == -1 or
@heightdata[j,k-1] == -1 or
@heightdata[j+1,k] == -1 or
@heightdata[j-1,k] == -1
set_mapdata2(j,k,0,8)
else
set_mapdata2(j,k,0,0)
end
elsif @heightdata[j,k] == 1
if @heightdata[j,k+1] == -1 or
@heightdata[j,k-1] == -1 or
@heightdata[j+1,k] == -1 or
@heightdata[j-1,k] == -1
set_mapdata2(j,k,0,8)
elsif @heightdata[j,k+1] == 0 or
@heightdata[j,k-1] == 0 or
@heightdata[j+1,k] == 0 or
@heightdata[j-1,k] == 0
set_mapdata2(j,k,0,0)
else
set_mapdata2(j,k,1,4)
end
else
set_mapdata2(j,k,0,8)
end
end
end
# 生成地面 之二 >> 生成洞
time = 0
for k in 0...@map.height
for j in 0...@map.width
time += 1
# 定期画面更新
if time%500 == 0
Graphics.update
end
if @heightdata[j,k] == 0
if @heightdata[j,k+1] == -1
# 下面是洞------------------
if @heightdata[j-1,k] == -1
# 左边也是洞
for i in [0,1,2]
set_mapdata(j,k+i,0,13+i,1)
end
elsif @heightdata[j+1,k] == -1
# 右边也是洞
for i in [0,1,2]
set_mapdata(j,k+i,2,13+i,1)
end
else
# 两边是地面
for i in [0,1,2]
set_mapdata(j,k+i,1,13+i,1)
end
end
elsif @heightdata[j,k-1] == -1
# 上面是洞------------------
if @heightdata[j-1,k] == -1 or
(@heightdata[j-1,k] == 1 and
@heightdata[j-1,k-1] == -1)
# 左边也是洞
set_mapdata(j,k,0,11,2)
elsif @heightdata[j+1,k] == -1 or
(@heightdata[j+1,k] == 1 and
@heightdata[j+1,k-1] == -1)
# 右边也是洞
set_mapdata(j,k,2,11,2)
else
# 两边是地面
set_mapdata(j,k,1,11,2)
end
elsif @heightdata[j-1,k] == -1 or
(@heightdata[j-1,k] == 1 and
@heightdata[j-1,k-1] == -1)
# 左边是洞------------------
set_mapdata(j,k,0,12,1)
elsif @heightdata[j+1,k] == -1 or
(@heightdata[j+1,k] == 1 and
@heightdata[j+1,k-1] == -1)
# 右边是洞------------------
set_mapdata(j,k,2,12,1)
elsif @heightdata[j-1,k-1] == -1
# 左上面是洞------------------
set_mapdata(j,k,0,9,1)
elsif @heightdata[j-1,k+1] == -1
# 左下面是洞------------------
set_mapdata(j,k,0,10,1)
elsif @heightdata[j+1,k-1] == -1
# 右上面是洞------------------
set_mapdata(j,k,1,9,1)
elsif @heightdata[j+1,k+1] == -1
# 右下面是洞------------------
set_mapdata(j,k,1,10,1)
end
end
if @heightdata[j,k] == 1 and
@heightdata[j,k-1] != -1
if @heightdata[j,k+1] == -1
# 下面是洞------------------
if @heightdata[j-1,k] == -1
# 左边也是洞
for i in [0,1,2]
# set_mapdata(j,k+i,0,13+i,1)
end
elsif @heightdata[j+1,k] == -1
# 右边也是洞
for i in [0,1,2]
# set_mapdata(j,k+i,2,13+i,1)
end
else
# 两边是地面
for i in [0,1,2]
# set_mapdata(j,k+i,1,13+i,1)
end
end
elsif @heightdata[j,k-1] == -1
# 上面是洞------------------
if @heightdata[j-1,k] == -1
# 左边也是洞
set_mapdata(j,k,0,11,2)
elsif @heightdata[j+1,k] == -1
# 右边也是洞
set_mapdata(j,k,2,11,2)
else
# 两边是地面
set_mapdata(j,k,1,11,2)
end
elsif @heightdata[j-1,k] == -1
# 左边是洞------------------
set_mapdata(j,k,0,12,1)
elsif @heightdata[j+1,k] == -1
# 右边是洞------------------
set_mapdata(j,k,2,12,1)
elsif @heightdata[j-1,k-1] == -1
# 左上面是洞------------------
set_mapdata(j,k,0,9,1)
elsif @heightdata[j-1,k+1] == -1
# 左下面是洞------------------
set_mapdata(j,k,0,10,1)
elsif @heightdata[j+1,k-1] == -1
# 右上面是洞------------------
set_mapdata(j,k,1,9,1)
elsif @heightdata[j+1,k+1] == -1
# 右下面是洞------------------
set_mapdata(j,k,1,10,1)
end
end
end
end
# 生成地面 之三 >> 生成墙壁
time = 0
for k in 0...@map.height
for j in 0...@map.width
time += 1
# 定期画面更新
if time%500 == 0
Graphics.update
end
if @heightdata[j,k] == 1
if @heightdata[j,k+1] == 0 or
@heightdata[j,k+1] == -1
# 下面是洞------------------
if @heightdata[j-1,k] == 0 or
@heightdata[j-1,k] == -1
# 左边也是洞
set_mapdata(j,k+0,0,5+0,5)
set_mapdata(j,k+1,0,5+1,5)
set_mapdata(j,k+2,0,5+2,4)
if @heightdata[j,k+3] != 0 and
@heightdata[j,k+2] != 1 and
(@heightdata[j,k+2] != 0 or @heightdata[j-1,k+2] != 0)
set_mapdata(j,k+2,0,16,5)
for i in [0,1]
set_mapdata(j,k+3+i,0,14+i,1)
if @heightdata[j,k+3+i] != -1
break
end
end
end
elsif @heightdata[j+1,k] == 0 or
@heightdata[j+1,k] == -1
# 右边也是洞
set_mapdata(j,k+0,2,5+0,5)
set_mapdata(j,k+1,2,5+1,5)
set_mapdata(j,k+2,2,5+2,4)
if @heightdata[j,k+3] != 0 and
@heightdata[j,k+2] != 1 and
(@heightdata[j,k+2] != 0 or @heightdata[j+1,k+2] != 0)
set_mapdata(j,k+2,2,16,5)
for i in [0,1]
set_mapdata(j,k+3+i,2,14+i,1)
if @heightdata[j,k+3+i] != -1
break
end
end
end
else
# 两边是地面
set_mapdata(j,k+0,1,5+0,5)
set_mapdata(j,k+1,1,5+1,5)
set_mapdata(j,k+2,1,5+2,4)
if @heightdata[j,k+3] != 0 and
@heightdata[j,k+2] != 1
set_mapdata(j,k+2,1,16,5)
for i in [0,1]
set_mapdata(j,k+3+i,1,14+i,1)
if @heightdata[j,k+3+i] != -1
break
end
end
end
end
elsif @heightdata[j,k-1] == 0 or
@heightdata[j,k-1] == -1
# 上面是洞------------------
if @heightdata[j-1,k] == 0 or
@heightdata[j-1,k] == -1
# 左边也是洞
set_mapdata(j,k,0,3,4)
elsif @heightdata[j+1,k] == 0 or
@heightdata[j+1,k] == -1
# 右边也是洞
set_mapdata(j,k,2,3,4)
else
# 两边是地面
set_mapdata(j,k,1,3,4)
end
elsif @heightdata[j-1,k] == 0 or
@heightdata[j-1,k] == -1
# 左边是洞------------------
set_mapdata(j,k,0,4,4)
elsif @heightdata[j+1,k] == 0 or
@heightdata[j+1,k] == -1
# 右边是洞------------------
set_mapdata(j,k,2,4,4)
elsif @heightdata[j-1,k-1] == 0 or
@heightdata[j-1,k-1] == -1
# 左上面是洞------------------
set_mapdata(j,k,0,1,4)
elsif @heightdata[j-1,k+1] == 0 or
@heightdata[j-1,k+1] == -1
# 左下面是洞------------------
set_mapdata(j,k,0,2,4)
elsif @heightdata[j+1,k-1] == 0 or
@heightdata[j+1,k-1] == -1
# 右上面是洞------------------
set_mapdata(j,k,1,1,4)
elsif @heightdata[j+1,k+1] == 0 or
@heightdata[j+1,k+1] == -1
# 右下面是洞------------------
set_mapdata(j,k,1,2,4)
end
end
end
end
# 调整玩家位置
playerpos_reset($game_temp.player_new_x,$game_temp.player_new_y)
@oneventdata[$game_temp.player_new_x,$game_temp.player_new_y] = 1
time = 0
for i in @map.events.keys.sort
time += 1
if time%100 == 0
Graphics.update
end
# 事件设置类型>>完全固定(最优先)
case event_settype(i)
when 3
@oneventdata[@map.events.x,@map.events.y] = 1
end
end
for i in @map.events.keys.sort
time += 1
if time%100 == 0
Graphics.update
end
# 事件设置类型>>中继点
case event_settype(i)
when 1
set_defeventpos(i,@map.events.x,@map.events.y)
@oneventdata[@map.events.x,@map.events.y] = 1
end
end
# 调整事件位置
for i in @map.events.keys.sort
time += 1
if time%100 == 0
Graphics.update
end
j = event_settype(i)
case j
when 0 # 随机
set_defeventpos(i,rand(@map.width-4)+2,rand(@map.width-4)+2)
@oneventdata[@map.events.x,@map.events.y] = 1
when 2 # 固定
set_defeventpos(i,@map.events.x,@map.events.y)
@oneventdata[@map.events.x,@map.events.y] = 1
when 100..199 # 壁设置
set_defeventpos_wall(i,rand(@map.width-4)+2,rand(@map.width-4)+2,j-100)
@oneventdata[@map.events.x,@map.events.y] = 1
@oneventdata[@map.events.x,@map.events.y-1] = 1
for k in 1..(j-100)
@oneventdata[@map.events.x+k,@map.events.y] = 1
@oneventdata[@map.events.x+k,@map.events.y-1] = 1
@oneventdata[@map.events.x-k,@map.events.y] = 1
@oneventdata[@map.events.x-k,@map.events.y-1] = 1
end
when 200..299 # 壁设置固定
set_defeventpos_wall(i,@map.events.x,@map.events.y,j-200)
@oneventdata[@map.events.x,@map.events.y] = 1
@oneventdata[@map.events.x,@map.events.y-1] = 1
for k in 1..(j-200)
@oneventdata[@map.events.x+k,@map.events.y] = 1
@oneventdata[@map.events.x+k,@map.events.y-1] = 1
@oneventdata[@map.events.x-k,@map.events.y] = 1
@oneventdata[@map.events.x-k,@map.events.y-1] = 1
end
end
end
# 放置障碍
for i in 0...(rand(objcnt)+objcnt/2)
time += 1
if time%500 == 0
Graphics.update
end
j = rand(@map.width)
k = rand(@map.width)
case rand(10)
when 0..4
if standable_newtile?(1,0)
if standable?(j,k)
set_mapdata(j,k,1,0,6)
end
else
if standable2?(j,k)
set_mapdata(j,k,1,0,6)
end
end
when 5..7
if standable_newtile?(2,0)
if standable?(j,k)
set_mapdata(j,k,2,0,6)
end
else
if standable2?(j,k)
set_mapdata(j,k,2,0,6)
end
end
when 8..9
if standable2?(j,k)
if @map.data[j,k-1,2]==0 and
(@map.data[j,k,1]==0 or @map.data[j,k,2]==0)
set_mapdata(j,k,2,2,4) # 4>6?
set_mapdata(j,k-1,2,1,4) # 4>2?
end
end
end
end
# 释放变量的内容
@heightdata.resize(0,0)
@maskdata.resize(0,0)
@oneventdata.resize(0,0)
@masksetting.clear
@makedata.clear
@tilesetting.resize(0,0,0)
if AUTO_MAP_SAVE
# 保存机能
save_data(@map,sprintf("Data/Map%03d.rxdata", 999))
maplist = load_data("Data/MapInfos.rxdata")
mapinfo = RPG::MapInfo.new
mapinfo.name = sprintf("随机自动保存(%s)", maplist[@map_id].name)
mapinfo.parent_id = 0
mapinfo.order = 999
mapinfo.expanded = true
mapinfo.scroll_x = 0
mapinfo.scroll_y = 0
maplist[999]=mapinfo
save_data(maplist,"Data/MapInfos.rxdata")
end
end
#--------------------------------------------------------------------------
# ● 获得事件的位置类型
#--------------------------------------------------------------------------
def event_settype(i)
if @map.events.subname == "中继点"
return 1
end
if @map.events.subname == "固定"
return 2
end
if @map.events.subname == "完全固定"
return 3
end
for j in 0..1000
if @map.events.pages[0].list[j].code != 108
break
end
# 注释中有中继点
if @map.events.pages[0].list[j].parameters[0].split(/,/)[0] == "中继点"
return 1
end
# 注释中有完全固定
if @map.events.pages[0].list[j].parameters[0].split(/,/)[0] == "完全固定"
return 3
end
# 注释中有固定
if @map.events.pages[0].list[j].parameters[0].split(/,/)[0] == "固定"
return 2
end
# 注释中有壁设置
if @map.events.pages[0].list[j].parameters[0].split(/,/)[0] == "壁设置"
if @map.events.pages[0].list[j].parameters[0].split(/,/)[1] == nil
return 100
else
k = @map.events.pages[0].list[j].parameters[0].split(/,/)[1]
k = k.to_i
return 100+k
end
end
# 注释中有壁设置固定
if @map.events.pages[0].list[j].parameters[0].split(/,/)[0] == "壁设置固定"
if @map.events.pages[0].list[j].parameters[0].split(/,/)[1] == nil
return 200
else
k = @map.events.pages[0].list[j].parameters[0].split(/,/)[1]
k = k.to_i
return 200+k
end
end
end
return 0
end
#--------------------------------------------------------------------------
# ● 指定位置附近设置事件
#--------------------------------------------------------------------------
def set_defeventpos(id,x,y)
if standable2?(x,y)
@map.events[id].x=x
@map.events[id].y=y
return
end
for i in 1..([@map.width,@map.height].max)
if standable2?(x,y+i)
@map.events[id].x=x
@map.events[id].y=y+i
return
end
for j in 1..i
if standable2?(x-j,y+i)
@map.events[id].x=x-j
@map.events[id].y=y+i
return
end
if standable2?(x+j,y+i)
@map.events[id].x=x+j
@map.events[id].y=y+i
return
end
if standable2?(x-j,y-i)
@map.events[id].x=x-j
@map.events[id].y=y-i
return
end
if standable2?(x+j,y-i)
@map.events[id].x=x+j
@map.events[id].y=y-i
return
end
end
end
end
#--------------------------------------------------------------------------
# ● 指定位置附近的墙壁上设置事件
# p4 幅度
#--------------------------------------------------------------------------
def set_defeventpos_wall(id,x,y,p4)
if standable3?(x,y,p4)
@map.events[id].x=x
@map.events[id].y=y
return
end
for i in 1..([@map.width,@map.height].max)
if standable3?(x,y+i,p4)
@map.events[id].x=x
@map.events[id].y=y+i
return
end
for j in 1..i
if standable3?(x-j,y+i,p4)
@map.events[id].x=x-j
@map.events[id].y=y+i
return
end
if standable3?(x+j,y+i,p4)
@map.events[id].x=x+j
@map.events[id].y=y+i
return
end
if standable3?(x-j,y-i,p4)
@map.events[id].x=x-j
@map.events[id].y=y-i
return
end
if standable3?(x+j,y-i,p4)
@map.events[id].x=x+j
@map.events[id].y=y-i
return
end
end
end
end
#--------------------------------------------------------------------------
# ● 指定位置附近设置玩家
#--------------------------------------------------------------------------
def playerpos_reset(x,y)
if standable?(x,y)
$game_temp.player_new_x=x
$game_temp.player_new_y=y
return
end
for i in 1..([@map.width,@map.height].max)
if standable?(x,y+i)
$game_temp.player_new_x=x
$game_temp.player_new_y=y+i
return
end
for j in 0..i
if standable?(x-j,y+i)
$game_temp.player_new_x=x-j
$game_temp.player_new_y=y+i
return
end
if standable?(x+j,y+i)
$game_temp.player_new_x=x+j
$game_temp.player_new_y=y+i
return
end
if standable?(x-j,y-i)
$game_temp.player_new_x=x-j
$game_temp.player_new_y=y-i
return
end
if standable?(x+j,y-i)
$game_temp.player_new_x=x+j
$game_temp.player_new_y=y-i
return
end
end
end
end
#--------------------------------------------------------------------------
# ● 自己能通过吗?(障碍物元件)
# p1,p2 位置X,Y
#--------------------------------------------------------------------------
def standable_newtile?(p1,p2)
for i in [2, 1, 0]
tile_id = @tilesetting[p1, p2, i]
if tile_id == nil
return false
elsif @passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
end
return true
end
#--------------------------------------------------------------------------
# ● 在指定位置站立吗?
# p1,p2 位置X,Y
#--------------------------------------------------------------------------
def standable?(p1,p2)
if @heightdata[p1,p2] != 0
return false
end
if @oneventdata[p1,p2] ==1
return false
end
for i in [2, 1, 0]
tile_id = @map.data[p1, p2, i]
if tile_id == nil
return false
elsif @passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
end
return true
end
#--------------------------------------------------------------------------
# ● 放置在指定位置没问题吗?(考虑周围的事件)
# p1,p2 位置X,Y
#--------------------------------------------------------------------------
def standable2?(p1,p2)
# 站立位置判断
unless standable?(p1,p2)
return false
end
# 周围事件检查(能否前往尽头?)
# 去掉能到纵吗
if standable?(p1+1,p2-1) == false or
standable?(p1+1,p2) == false or
standable?(p1+1,p2+1) == false
if standable?(p1-1,p2-1) == false or
standable?(p1-1,p2) == false or
standable?(p1-1,p2+1) == false
# 去掉根本不能到纵的时候忽视
if standable?(p1,p2-1) == true and
standable?(p1,p2+1) == true
return false
end
end
end
# 去掉能到横吗
if standable?(p1+1,p2+1) == false or
standable?(p1,p2+1) == false or
standable?(p1-1,p2+1) == false
if standable?(p1+1,p2-1) == false or
standable?(p1,p2-1) == false or
standable?(p1-1,p2-1) == false
# 去掉根本不能到横的时候忽视
if standable?(p1-1,p2) == true and
standable?(p1+1,p2) == true
return false
end
end
end
if standable?(p1,p2-1) == false and
(standable?(p1-1,p2+1) == false or
standable?(p1,p2+1) == false or
standable?(p1+1,p2+1) == false)
return false
end
if standable?(p1,p2+1) == false and
(standable?(p1-1,p2-1) == false or
standable?(p1+1,p2-1) == false or
standable?(p1+1,p2-1) == false)
return false
end
if standable?(p1-1,p2) == false and
(standable?(p1+1,p2-1) == false or
standable?(p1+1,p2) == false or
standable?(p1+1,p2+1) == false)
return false
end
if standable?(p1+1,p2) == false and
(standable?(p1-1,p2-1) == false or
standable?(p1-1,p2) == false or
standable?(p1-1,p2+1) == false)
return false
end
return true
end
#--------------------------------------------------------------------------
# ● 放置在指定位置没问题吗?(墙壁版)
# p1,p2 位置X,Y
# p3 幅度
#--------------------------------------------------------------------------
def standable3?(p1,p2,p3)
# 站立位置判断
unless standable?(p1,p2+1)
return false
end
# 位置判断
if @oneventdata[p1,p2] == 1 or
@oneventdata[p1,p2-1] == 1 or
@heightdata[p1,p2-2] != 1 or
@heightdata[p1,p2-1] == 1 or
@heightdata[p1,p2+1] != 0
return false
end
for i in 1...p3+1
if@heightdata[p1+i,p2-2] != 1 or
@heightdata[p1+i,p2-1] == 1 or
@heightdata[p1+i,p2+1] != 0
return false
end
if@heightdata[p1-i,p2-2] != 1 or
@heightdata[p1-i,p2-1] == 1 or
@heightdata[p1-i,p2+1] != 0
return false
end
end
for i in 1...p3+1
if @oneventdata[p1+i,p2] == 1 or
@oneventdata[p1+i,p2-1] == 1
return false
end
if @oneventdata[p1-i,p2] == 1 or
@oneventdata[p1-i,p2-1] == 1
return false
end
end
return true
end
#--------------------------------------------------------------------------
# ● 地图元件信息变化
# p1,p2 起首处位置X,Y
# p3,p4 原参照位置X,Y
# p5 插入方法 0:通常 1:下一层 2:上一层 3:从下面 4:从上面 5:两边
#--------------------------------------------------------------------------
def set_mapdata(p1,p2,p3,p4,p5 = 0)
unless self.valid?(p1, p2)
return
end
if @tilesetting[p3,p4,0] != 0 # 0层普通放置
@map.data[p1,p2,0] = @tilesetting[p3,p4,0]
end
case p5
when 0 # 通常
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
end
if @tilesetting[p3,p4,2] != 0
@map.data[p1,p2,2] = @tilesetting[p3,p4,2]
end
when 1 # 放在下面
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
end
when 2 # 放在上面
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,2] = @tilesetting[p3,p4,1]
end
when 3 # 从下面放置
if @tilesetting[p3,p4,1] != 0
if @map.data[p1,p2,1] != 0
@map.data[p1,p2,2] = @map.data[p1,p2,1]
end
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
end
when 4 # 从上面放置
if @tilesetting[p3,p4,1] != 0
if @map.data[p1,p2,2] != 0
@map.data[p1,p2,1] = @map.data[p1,p2,2]
end
@map.data[p1,p2,2] = @tilesetting[p3,p4,1]
end
when 5 # 从两边放置
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
end
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,2] = @tilesetting[p3,p4,1]
end
when 6 # 能放置就放置
if @map.data[p1,p2,1] == 0
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
elsif @map.data[p1,p2,2] == 0
@map.data[p1,p2,2] = @tilesetting[p3,p4,1]
end
end
end
#--------------------------------------------------------------------------
# ● 地图元件信息变化2 >>没有范围外判断等
# p1,p2 起首处位置X,Y
# p3,p4 原参照位置X,Y
#--------------------------------------------------------------------------
def set_mapdata2(p1,p2,p3,p4)
@map.data[p1,p2,0] = @tilesetting[p3,p4,0]
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
@map.data[p1,p2,2] = @tilesetting[p3,p4,2]
end
#--------------------------------------------------------------------------
# ● 指定位置信息变化
# p1,p2 位置X,Y
# p3 值
#--------------------------------------------------------------------------
def set_height(p1,p2,p3)
return if p1<0
return if p1>=@map.width
return if p2<0
return if p2>=@map.height
@heightdata[p1,p2]=p3
end
#--------------------------------------------------------------------------
# ● 指定位置信息变化
# p1,p2 位置X,Y
# p3 值
#--------------------------------------------------------------------------
def set_grounddata(p1,p2,p3)
return if p1<0
return if p1>=@map.width
return if p2<0
return if p2>=@map.height
if @masksetting[@maskdata[p1,p2]] == true
if @targettype==0
if @chgtype==0
@heightdata[p1,p2]=p3
elsif @chgtype==1
@heightdata[p1,p2]+=p3
end
elsif @targettype==1
if @chgtype==0
@maskdata[p1,p2]=p3
elsif @chgtype==1
@maskdata[p1,p2]+=p3
end
end
end
end
#--------------------------------------------------------------------------
# ● 指定计算方法
# p1 对象 >> =0:高度 =1:地形 (現在、高度0=地面 1=墙壁
# p2 方法 >> =0:代入 =1:加算 地形只是遮照判断使用
#--------------------------------------------------------------------------
def rndmap_chtarget(p1,p2)
@targettype=p1
@chgtype=p2
end
#--------------------------------------------------------------------------
# ● 设定其他注释使用的值
# p1,p2 最小 X,Y
# p3,p4 最大 X,Y 设定制作道路的开始点,结束点等的时候使用
#--------------------------------------------------------------------------
def rndmap_setstat(p1,p2,p3,p4)
@minx=p1
@miny=p2
@maxx=p3
@maxy=p4
end
#--------------------------------------------------------------------------
# ● 设定地形遮照
# p1 = 对象地形 (-1= 全部)
# p2 = 变更值 (0= 禁止改写 1= 可以改写 2= 只有那个地形可以)
#--------------------------------------------------------------------------
def rndmap_chmask(p1,p2)
if p1>=0
if p2==0
@masksetting[p1]=false
elsif p2 == 1
@masksetting[p1]=true
elsif p2 == 2
for i in 0...100
@masksetting=false
end
@masksetting[p1]=true
end
end
if p1==-1
if p2==0
for i in 0...100
@masksetting=false
end
else
for i in 0...100
@masksetting=true
end
end
end
end
#--------------------------------------------------------------------------
# ● 2点之间生成道路
# 起点、终点在rndmap_setstat里设定
# p1 = 改写值
# p2 = 途中点数(减的话以地图大小40*40为基准相对变化)
# p3 = 确保边缘的宽度
# p4 = 途中点连接方法 (0=直线连接 1=直角线(?)连接)
# p5 = 无视中继点的距离
#--------------------------------------------------------------------------
def rndmap_mkroad(p1,p2,p3,p4,p5 = 5)
p5 = 5 if p5 == nil
localdata = Table.new(@map.width,@map.height)
aposx = []
aposy = []
aflag = []
for i in 0...@map.width
for j in 0...@map.height
localdata[i,j] = 0
end
end
if p2<0
p2=(p2*-1)*@map.width*@map.height/40/40
end
aposx[0]=@minx
aposy[0]=@miny
aposx[1]=@maxx
aposy[1]=@maxy
if aposx[0]<0
aposx[0]=@map.width+aposx[0]
end
if (aposx[0]>=1000) and (aposx[0]<=1100)
aposx[0]=@map.width*(aposx[0]-1000)/100
end
if aposy[0]<0
aposy[0]=@map.height+aposy[0]
end
if (aposy[0]>=1000) and (aposy[0]<=1100)
aposy[0]=@map.height*(aposy[0]-1000)/100
end
if aposx[1]<0
aposx[1]=@map.width+aposx[1]
end
if (aposx[1]>=1000) and (aposx[1]<=1100)
aposx[1]=@map.width*(aposx[1]-1000)/100
end
if aposy[1]<0
aposy[1]=@map.height+aposy[1]
end
if (aposy[1]>=1000) and (aposy[1]<=1100)
aposy[1]=@map.height*(aposy[1]-1000)/100
end
if p4==0 or p4==1 or p4==2
if p4 == 2
i4 = rand(2)
end
aflag[0] = true
aflag[1] = false
for i in 2...(p2+2)
aposx = rand(@map.width-p3*2) + p3
aposy = rand(@map.height-p3*2) + p3
aflag = false
end
i3=0
i1=aposx[i3]
i2=aposy[i3]
localdata[i1,i2] = 1
for i in 0...p2+2
i7=5000000
for j in 0...p2+2
if aflag[j] == false
i4 = aposx[j]-i1
i4=i4*-1 if i4 < 0
i5 = aposy[j]-i2
i5=i5*-1 if i5 < 0
if (i4**2+i5**2) <=(p5**2) and j != 1
aflag[j] = true
elsif i7 > (i4**2+i5**2)
i7=(i4**2+i5**2)
i6=j
end
end
end
# 起点ID:i3 终点ID:i6
if p4==0
if aposx[i3] > aposx[i6]
i8 = aposx[i3]
i9 = aposy[i3]
i10 = aposx[i6]
i11 = aposy[i6]
else
i8 = aposx[i6]
i9 = aposy[i6]
i10 = aposx[i3]
i11 = aposy[i3]
end
if i8!=i10
for i in 0..(i8-i10)
localdata[i+i10,(i9-i11)*i/(i8-i10)+i11] = 1
end
end
if aposy[i3] > aposy[i6]
i8 = aposx[i3]
i9 = aposy[i3]
i10 = aposx[i6]
i11 = aposy[i6]
else
i8 = aposx[i6]
i9 = aposy[i6]
i10 = aposx[i3]
i11 = aposy[i3]
end
if i9!=i11
for i in 0..(i9-i11)
localdata[(i8-i10)*i/(i9-i11)+i10,i+i11] = 1
end
end
end
if p4==1
i4 = rand(2)
if i4==0
for i in 0..([aposx[i3]-aposx[i6],aposx[i6]-aposx[i3]].max)
localdata[i+[aposx[i3],aposx[i6]].min,aposy[i3]] = 1
end
for i in 0..([aposy[i3]-aposy[i6],aposy[i6]-aposy[i3]].max)
localdata[aposx[i6],i+[aposy[i3],aposy[i6]].min] = 1
end
else
for i in 0..([aposx[i3]-aposx[i6],aposx[i6]-aposx[i3]].max)
localdata[i+[aposx[i3],aposx[i6]].min,aposy[i6]] = 1
end
for i in 0..([aposy[i3]-aposy[i6],aposy[i6]-aposy[i3]].max)
localdata[aposx[i3],i+[aposy[i3],aposy[i6]].min] = 1
end
end
end
i3=i6
i1=aposx[i3]
i2=aposy[i3]
aflag[i3]=true
if i3==1
break
end
end
end
for i in 0...@map.width
for j in 0...@map.height
if localdata[i,j] == 1
set_grounddata(i,j,p1)
end
end
end
end
#--------------------------------------------------------------------------
# ● 对象扩张
# p1 对象
# p2,p3 扩张幅度X,Y
# p4 扩张方法 (0=十字 1=四角)
#--------------------------------------------------------------------------
def rndmap_plus(p1,p2,p3,p4)
localdata = Table.new(@map.width,@map.height)
for i in 0...@map.width
for j in 0...@map.height
if @targettype==0
localdata[i,j] = @heightdata[i,j]
elsif @targettype==1
localdata[i,j] = @maskdata[i,j]
end
end
end
if p4 == 0
for i in 0...@map.width
for j in 0...@map.height
if p1==localdata[i,j]
for k in 1..p2
set_grounddata(i+k,j,p1)
set_grounddata(i-k,j,p1)
end
for k in 1..p3
set_grounddata(i,j+k,p1)
set_grounddata(i,j-k,p1)
end
end
end
end
elsif p4 == 1
for i in 0...@map.width
for j in 0...@map.height
if p1==localdata[i,j]
for k in (i-p2)..(i+p2)
for l in (j-p3)..(j+p3)
set_grounddata(k,l,p1)
end
end
end
end
end
end
end
#--------------------------------------------------------------------------
# ● 全部设定
# p1 值
#--------------------------------------------------------------------------
def rndmap_allchg(p1)
for i in 0...@map.width
for j in 0...@map.height
set_grounddata(i,j,p1)
end
end
end
#--------------------------------------------------------------------------
# ● 指定点
# p1 值
# p2,p3 位置X,Y
#--------------------------------------------------------------------------
def rndmap_putpos(p1,p2,p3)
i = rand(@maxx-@minx+1)+@minx
j = rand(@maxy-@miny+1)+@miny
for k in (p2-i)..(p2+i)
for l in (p3-j)..(p3+j)
set_grounddata(k,l,p1)
end
end
end
#--------------------------------------------------------------------------
# ● 周围
# p1 值
#--------------------------------------------------------------------------
def rndmap_edge(p1)
for i in 0...@map.width
set_grounddata(i,0,p1)
set_grounddata(i,@map.height-1,p1)
end
for i in 0...@map.height
set_grounddata(0,i,p1)
set_grounddata(@map.width-1,i,p1)
end
end
end
#==============================================================================
# □ RPG::MapInfo >>用subname取得 “,”后面的文字
#==============================================================================
module RPG
class MapInfo
def name
name = @name.split(/,/)[0]
return name != nil ? name : ''
end
def name=(str)
str2 = @name[/^[^,]*(,.*)/, 1]
@name = str2 != nil ? str + str2 : str
end
def subname(i = 1)
name = @name.split(/,/)
return name != nil ? name : ""
end
end
end
#==============================================================================
# □ RPG::Event >>用subname取得 “,”后面的文字
#==============================================================================
module RPG
class Event
def name
name = @name.split(/,/)[0]
return name != nil ? name : ''
end
def name=(str)
str2 = @name[/^[^,]*(,.*)/, 1]
@name = str2 != nil ? str + str2 : str
end
def subname(i = 1)
name = @name.split(/,/)
return name != nil ? name : ""
end
end
end[/pre][/fold] |
|