Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # // Skill Interaction By FenixFyreX
- # // Ported to RMVXA By IceDragon
- # // Date Ported : 04/06/2012
- # // Port Version : 1.1
- # // To use:
- # // put:
- # // <interact id>
- # // <interact id, id, id...>
- # // in an event comment.
- # // EG1. <interact 51>
- # // EG2. <interact 51, 65, 98, 129>
- module Interaction
- BUTTONS = [:X, :Y, :A, :F5]
- # Do you want to use the HUD?
- USE_HUD = true
- # What icon shows on unassigned buttons?
- NA_ICONINDEX = 359
- # What button opens the Interaction HUD?
- OPEN_HUD_BUTTON = Input::F6
- # Game Variable used to store used skill id
- USED_SKILL_ID_VAR = 900
- end
- class Game_Player < Game_Character
- alias stop_c_button_interact check_event_trigger_there
- def check_event_trigger_there(*args,&block)
- return false if($game_map.interpreter.running?)
- 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)
- return false if(event.custom_skill_interact?)
- end
- stop_c_button_interact(*args,&block)
- end
- def update_nonmoving(last_moving)
- return if($game_map.interpreter.running?)
- return if(moving?)
- return if(check_touch_event) if(last_moving)
- return if(update_interaction)
- update_encounter if(last_moving)
- end
- def update_interaction
- return if($game_message.busy? || $game_message.visible)
- if Input.trigger?(:C)
- return true if(get_on_off_vehicle)
- return true if(check_action_event)
- end
- Interaction::BUTTONS.each do |button|
- check_event_trigger_interaction(button) if(Input.trigger?(button))
- end
- end
- def can_start_event_interact(event,button)
- return false unless(event.custom_skill_interact?())
- skl_id = $game_party.equipped_skills[button]
- $game_variables[Interaction::USED_SKILL_ID_VAR] = skl_id
- return(event.interact_comment?(true).include?(skl_id))
- end
- def check_event_trigger_interaction(button)
- return false if($game_map.interpreter.running?)
- 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)
- if can_start_event_interact(event,button)
- event.start
- result = true
- end
- end
- if(!result and $game_map.counter?(front_x, front_y))
- front_x = $game_map.x_with_direction(front_x, @direction)
- front_y = $game_map.y_with_direction(front_y, @direction)
- for event in $game_map.events_xy(front_x, front_y)
- if triggers.include?(event.trigger) and event.priority_type == 1
- event.start
- result = true
- end
- end
- end
- return result
- end
- end
- class Game_Event < Game_Character
- alias eqkls_setup_page setup_page
- def setup_page(*args,&block)
- eqkls_setup_page(*args,&block)
- @interact_comment = nil
- interact_comment?(true)
- end
- def custom_skill_interact?()
- return interact_comment?(false)
- end
- def interact_comment?(return_data=false)
- if(@interact_comment.nil?)
- @interact_comment = false if(@interact_comment.nil?())
- if(@list)
- comment_a = [108,408]
- for item in @list
- next unless(comment_a.include?(item.code))
- case(item.parameters.join(""))
- when /<interact[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- id_int = $1.to_s.scan(/(\d+)/i).collect{|i|i.join("").to_i}
- @interact_comment = id_int
- end
- end
- end
- end
- return return_data ? @interact_comment : !!@interact_comment
- end
- end
- class Game_Party < Game_Unit
- attr_accessor :equipped_skills
- alias initialize_equip_skills initialize
- def initialize(*args,&block)
- initialize_equip_skills(*args,&block)
- @equipped_skills = {}
- end
- def party_skills
- return members.inject([]){|r,m|r+m.skills.collect{|s|s ? s.id : 0}}.uniq
- end
- def equip_skill(button, id)
- return if @equipped_skills[button] == id
- return unless party_skills.include? id
- return if max_skill_equip(button, id)
- @equipped_skills[button] = id
- end
- def max_skill_equip(button, id)
- if(@equipped_skills.keys.size >= Interaction::BUTTONS.size)
- return true if(!@equipped_skills.keys.include?(button))
- end
- return false
- end
- alias remove_actor_quip_skills remove_actor
- def remove_actor(*args,&block)
- remove_actor_quip_skills(*args,&block)
- skls = party_skills
- @equipped_skills.each_pair { |key,value|
- @equipped_skills[key] = nil unless(skls.include?(value))
- }
- end
- end
- class Scene_Skill
- def equip_skill(button)
- item = @item_window.item
- $game_party.equip_skill(button, item ? item.id : 0)
- if($game_party.equipped_skills.keys.include?(button))
- Sound.play_ok
- show_equipped_message(button, item)
- else
- Sound.play_buzzer
- end
- end
- def show_equipped_message(button, item)
- @item_window.deactivate
- name = item ? item.name : ""
- butn = button.to_s
- txt = sprintf('%s was equipped to %s.', name, butn)
- @help_window.set_text(txt)
- 40.times { update_basic }
- @item_window.activate
- end
- alias skleq_update update
- def update()
- skleq_update()
- update_skill_equip() if(@item_window.active)
- end
- def update_skill_equip
- Interaction::BUTTONS.each{|button|equip_skill(button) if(Input.trigger?(button))}
- end
- end
- if Interaction::USE_HUD
- class Interact_HUD < Window_Base
- def initialize
- super(0,Graphics.height,Graphics.width,64)
- @buttons = nil
- refresh
- end
- def refresh
- self.contents.clear
- @buttons = $game_party.equipped_skills
- @item_max = Interaction::BUTTONS.size
- for i in 0..@item_max-1
- draw_item(i)
- end
- end
- def item_rect(index)
- rect = Rect.new(0,0,0,0)
- rect.width = Graphics.width / @item_max
- rect.height = 32
- rect.x = index*(Graphics.width/@item_max)
- rect.y = 0
- return rect
- end
- def draw_item(index)
- rect = item_rect(index)
- button = Interaction::BUTTONS[index]
- butn = button.to_s
- draw_text(rect, butn, 0)
- indx = $game_party.equipped_skills[button]
- skl = indx ? $data_skills[indx] : nil
- cw = self.contents.text_size(butn).width+8
- if(skl)
- draw_item_name(skl,rect.x+cw,rect.y+4)
- else
- draw_icon(Interaction::NA_ICONINDEX,rect.x+cw,rect.y+4)
- end
- end
- def update()
- super()
- refresh if(@buttons != $game_party.equipped_skills)
- end
- end
- class Scene_Map
- alias initialize_interaction start
- def start
- initialize_interaction
- @inter_win = Interact_HUD.new
- end
- alias update_interact_hud update
- def update
- update_interact_hud
- update_inter_win_input
- @inter_win.update if(@inter_win)
- end
- def update_inter_win_input
- return if $game_map.interpreter.running?
- return if @message_window.openness > 0
- if Input.press?(Interaction::OPEN_HUD_BUTTON)
- @inter_win.y -= 4 unless @inter_win.y <= (Graphics.height-@inter_win.height)
- else
- @inter_win.y += 4 unless @inter_win.y >= Graphics.height
- end
- end
- alias terminate_interwin pre_terminate
- def terminate
- @inter_win.dispose if(@inter_win)
- terminate_interwin
- end
- end
- end # // USE_HUD
- #=■==========================================================================■=#
- # // ● End of File ● // #
- #=■==========================================================================■=#
Advertisement
Add Comment
Please, Sign In to add comment