Project1
标题:
如何使某一事件页的发动条件为使用某物品
[打印本页]
作者:
0newing
时间:
2013-3-3 11:47
标题:
如何使某一事件页的发动条件为使用某物品
本帖最后由 0newing 于 2013-3-8 00:04 编辑
事件页的原本发动条件为某开关打开,或者某独立开关打开,或者某物品持有……
现在我想做出这种效果——对事件块使用某物品,就执行此事件页的内容。应该如何处理?
已经有了一个用物品的公共事件解决的方案,公共事件判断主角位置是否与事件块相邻,然后再执行事件。但感觉太繁琐……尤其是对那种可移动的事件块。
记得在VX看到过一个这种脚本,能提供帮助,或者将此脚本转为VA的,在下感激不尽……
module Event_Trigger_Object
LAST_USE_ITEM = 1
end
class Game_Battler
alias tig_eto_skill_can_use? skill_can_use?
def skill_can_use?(skill)
return false unless skill.is_a?(RPG::Skill)
return false unless movable?
return false if silent? and skill.spi_f > 0
return false if calc_mp_cost(skill) > mp
unless $game_temp.in_battle
id = 1000 + skill.id
if $game_player.check_event_trigger_object(id, true)
return true
end
if skill.scope == 0
return skill.common_event_id > 0
end
end
return tig_eto_skill_can_use?(skill)
end
end
class Game_Party < Game_Unit
attr_accessor :use_skill
attr_accessor :skill_user
alias tig_eto_initialize initialize
def initialize
tig_eto_initialize
@use_skill_id = nil
@skill_user_id = nil
end
alias tig_eto_item_can_use? item_can_use?
def item_can_use?(item)
return false unless item.is_a?(RPG::Item)
return false if item_number(item) == 0
unless $game_temp.in_battle
if $game_player.check_event_trigger_object(item.id, true)
return true
end
if item.scope == 0
return item.common_event_id > 0
end
end
return tig_eto_item_can_use?(item)
end
end
class Game_Event < Game_Character
attr_reader :erased
alias tig_eto_initialize initialize
def initialize(map_id, event)
@event_trigger_all_items = false
@event_trigger_all_skills = false
@event_trigger_all_weapons = false
@event_trigger_all_armors = false
@event_trigger_type = []
@event_trigger_id = []
tig_eto_initialize(map_id, event)
end
alias tig_eto_conditions_met? conditions_met?
def conditions_met?(page)
return if @erased
if set_event_object_trigger(page)
return false if $game_player.trigger_object_id == nil
return object_trigger?($game_player.trigger_object_id)
end
return tig_eto_conditions_met?(page)
end
def object_trigger?(object_id)
if object_id < 1000
return true if @event_trigger_all_items
object = $data_items[object_id]
elsif object_id < 2000
return true if @event_trigger_all_skills
object = $data_skills[object_id - 1000]
elsif object_id < 3000
return true if @event_trigger_all_weapons
object = $data_weapons[object_id - 2000]
elsif object_id < 4000
return true if @event_trigger_all_armors
object = $data_armors[object_id - 3000]
end
return true if @event_trigger_id.include?(object_id)
if object != nil
return true if @event_trigger_type.include?(object.event_trigger_type)
end
return false
end
def set_event_object_trigger(page)
if page.list.size > 0
command = page.list[0]
if command.code == 108
if /^启动条件[<<]/ =~ command.parameters[0]
@event_trigger_all_items = /[<<\s\//]items[>>\s\//]/ =~ command.parameters[0]
@event_trigger_all_skills = /[<<\s\//]skills[>>\s\//]/ =~ command.parameters[0]
@event_trigger_all_weapons = /[<<\s\//]weapons[>>\s\//]/ =~ command.parameters[0]
@event_trigger_all_armors = /[<<\s\//]armors[>>\s\//]/ =~ command.parameters[0]
if /[<<\s]all[>>\s]/ =~ command.parameters[0]
@event_trigger_all_items = true ; @event_trigger_all_skills = true
@event_trigger_all_weapons = true ; @event_trigger_all_armors = true
end
@event_trigger_id = []
if /[<<\s\//]item[-_]id:\d+[>>\s\//]/ =~ command.parameters[0]
item_id = command.parameters[0].scan(/[<<\s\//]item[-_]id:(\d+)[>>\s\//]/)
item_id = item_id.flatten
item_id.size.times {|n|item_id[n] = item_id[n].to_i}
@event_trigger_id += item_id.compact
end
if /[<<\s\//]skill[-_]id:\d+[>>\s\//]/ =~ command.parameters[0]
skill_id = command.parameters[0].scan(/[<<\s\//]skill[-_]id:(\d+)[>>\s\//]/)
skill_id = skill_id.flatten
skill_id.size.times { |n|
skill_id[n] = skill_id[n].to_i
skill_id[n] += 1000
}
@event_trigger_id += skill_id.compact
end
if /[<<\s\//]weapon[-_]id:\d+[>>\s\//]/ =~ command.parameters[0]
weapon_id = command.parameters[0].scan(/[<<\s\//]weapon[-_]id:(\d+)[>>\s\//]/)
weapon_id = weapon_id.flatten
weapon_id.size.times { |n|
weapon_id[n] = weapon_id[n].to_i
weapon_id[n] += 2000
}
@event_trigger_id += weapon_id.compact
end
if /[<<\s\//]armor[-_]id:\d+[>>\s\//]/ =~ command.parameters[0]
armor_id = command.parameters[0].scan(/[<<\s\//]armor[-_]id:(\d+)[>>\s\//]/)
armor_id = armor_id.flatten
armor_id.size.times { |n|
armor_id[n] = armorl_id[n].to_i
armor_id[n] += 3000
}
@event_trigger_id += armor_id.compact
end
words = command.parameters[0].scan(/[<<\s\//]type:(\S+)[>>\s\//]/)
words = words.flatten
words = [] if words == nil
@event_trigger_type = words
return true
end
end
end
return false
end
end
class Game_Player < Game_Character
attr_accessor :trigger_object_id
attr_reader :last_trigger_object_id
alias tig_eto_initialize initialize
def initialize
tig_eto_initialize
@trigger_object_id = nil
@last_trigger_object_id = nil
end
def check_event_trigger_object(object_id, test = false)
return false if $game_map.interpreter.running?
result = false
$game_variables[Event_Trigger_Object::LAST_USE_ITEM] = object_id
@trigger_object_id = object_id
@last_trigger_object_id = object_id
for event in $game_map.events_xy(@x, @y)
event.refresh
next if event.erased
next unless event.object_trigger?(object_id)
next if event.priority_type == 1
event.start unless test
result = true
end
if result == false
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
for event in $game_map.events_xy(front_x, front_y)
event.refresh
next if event.erased
next unless event.object_trigger?(object_id)
next if event.priority_type != 1
event.start unless test
result = true
end
end
@trigger_object_id = nil
return result
end
end
class Game_Interpreter
alias tig_eto_command_end command_end
def command_end
tig_eto_command_end
$game_variables[Event_Trigger_Object::LAST_USE_ITEM] = 0
end
def event_trigger_type?(type)
id = $game_player.last_trigger_object_id
object = nil
if id < 1000
object = $data_items[id]
elsif id < 2000
object = $data_skills[id - 1000]
elsif id < 3000
object = $data_weapons[id - 2000]
elsif id < 4000
object = $data_armors[id - 3000]
end
return false if object == nil
if /启动条件[<<]type[::](\S+)[>>]/ =~ object.note
return type == $1
else
return false
end
end
def event_trigger_item_type?(type)
object = $data_items[$game_player.last_trigger_object_id]
return false if object == nil
if /启动条件[<<]type[::](\S+)[>>]/ =~ object.note
return type == $1
else
return false
end
end
def event_trigger_skill_type?(type)
object = $data_skills[$game_player.last_trigger_object_id - 1000]
return false if object == nil
if /启动条件[<<]type[::](\S+)[>>]/ =~ object.note
return type == $1
else
return false
end
end
def event_trigger_weapon_type?(type)
object = $data_weapons[$game_player.last_trigger_object_id - 2000]
return false if object == nil
if /启动条件[<<]type[::](\S+)[>>]/ =~ object.note
return type == $1
else
return false
end
end
def event_trigger_armor_type?(type)
object = $data_armors[$game_player.last_trigger_object_id - 3000]
return false if object == nil
if /启动条件[<<]type[::](\S+)[>>]/ =~ object.note
return type == $1
else
return false
end
end
def consume_skill_cost
skill = $game_party.use_skill
user = $game_party.skill_user
return if $game_party.use_skill == nil
user.mp -= user.calc_mp_cost(skill)
end
end
class Window_Message < Window_Selectable
alias tig_eto_convert_special_characters convert_special_characters
def convert_special_characters
object_id = $game_player.last_trigger_object_id
if object_id != nil
if object_id < 1000
object = $data_items[object_id]
elsif object_id < 2000
object = $data_skills[object_id - 1000]
elsif object_id < 3000
object = $data_weapons[object_id - 2000]
elsif object_id < 4000
object = $data_armors[object_id - 3000]
end
if object != nil
@text.gsub!(/\\N\[启动条件オブジェクト\]/i) { object.name }
end
end
tig_eto_convert_special_characters
end
end
class Scene_Item < Scene_Base
alias tig_eto_determine_item determine_item
def determine_item
if $game_player.check_event_trigger_object(@item.id)
$scene = Scene_Map.new
return
end
tig_eto_determine_item
end
end
class Scene_Skill < Scene_Base
alias tig_eto_determine_skill determine_skill
def determine_skill
id = 1000 + @skill.id
if $game_player.check_event_trigger_object(id)
$game_party.use_skill = @skill
$game_party.skill_user = @actor
$scene = Scene_Map.new
return
end
tig_eto_determine_skill
end
end
class RPG::BaseItem
def event_trigger_type
if /启动条件[<<]type[::](\S+)[>>]/ =~ self.note
return $1
else
return ""
end
end
end
复制代码
作者:
弗雷德
时间:
2013-3-3 16:12
在使用物品里添加一个公共事件打开开关,当此开关开启时执行此事件。
作者:
429259591
时间:
2013-3-3 22:38
对着事件块使用物品是怎么回事?难道说是面向事件块然后打开菜单使用?依旧可以用公共事件实现...
作者:
429259591
时间:
2013-3-4 12:12
物品触发公共事件,然后变量操作得到X坐标,Y坐标,一个方向判定一次...
比如是向上,当X坐标=事件X坐标时,Y坐标-=1,Y坐标=事件Y坐标时,角色面向朝上时-执行
事件页的条件设置为变量,具体应该怎么设置就看情况了,
当然,如果不想用变量的话,开关也行
作者:
0newing
时间:
2013-3-4 17:48
429259591 发表于 2013-3-4 12:12
物品触发公共事件,然后变量操作得到X坐标,Y坐标,一个方向判定一次...
比如是向上,当X坐标=事件X坐标时 ...
如果事件块是固定不移动的,那这个方法是可行的,如果是一个,移动的事件块,要如何在公共事件中确定一个移动的坐标?还有就是,这个方法我已经试过了,包括在VA中还可以用地形标志来实现位置,从而不用做出更加复杂的判断。。。总得来说,这个问题我们已经解决一半了,还剩下,事件块移动的情况
作者:
429259591
时间:
2013-3-4 18:19
移动的事件块要怎样对着使用........和固定的一样?..和角色一样用变量来取得事件的X坐标和Y坐标..........
作者:
viva0072008
时间:
2013-3-5 18:44
用MOG的传感器脚本也可以实现吧,这脚本效果就是可以设定事件为中心的一个范围,主角接近事件到那个范围内,就会打开那个事件的独立开关D。
事件设置两页,都是并行处理,第一页关闭X开关,第二页独立开关D打开时执行,内容为打开X开关。也就是说主角在事件旁边的时候,X开关会打开,然后这时候使用物品(物品特性那里按楼上的调用公共事件打开Y开关),你再设置个事件当XY开关都打开时执行就行了,大概是这么个思路吧。
作者:
熊喵酱
时间:
2013-3-8 12:05
物品選擇處理再用變量判定是否對的
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1