Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Dialogue
- #Coordinates for avatars
- COORDS = {
- "AJ" => [[-64, 124],[388, 124]],
- "PP" => [[-64, 140],[388, 140]],
- "FS" => [[-64, 140],[388, 140]],
- "RD" => [[-64, 140],[388, 140]],
- "TS" => [[-64, 140],[388, 140]],
- "RR" => [[-64, 140],[338, 140]],
- "SP" => [[ 30, 200], nil ],
- "LR" => [ nil ,[100, -26]],
- "TR" => [[-64, 140],[388, 140]]}
- def initialize
- @characters = []
- @active_char = [nil, false, false, false, false]
- end
- def reset_actives
- @active_char = [nil, false, false, false, false]
- end
- def actived?(id)
- return @active_char[id]
- end
- #=============================================================================
- # LEFT SIDE AVATARS
- #=============================================================================
- #Show first avatar
- def show10(char, emote)
- show_pic(char, emote, 4, "l")
- return nil
- end
- #Show second avatar
- def show20(char, emote)
- show_pic(char, emote, 2, "l")
- return nil
- end
- #Change emotion for avatar
- def set10(emote)
- change_emote(emote, 4)
- return nil
- end
- def set20(emote)
- change_emote(emote, 2)
- return nil
- end
- #Change avatar
- def change10(char, emote)
- change_avatar(4, char, emote)
- return nil
- end
- def change20(char, emote)
- change_avatar(2, char, emote)
- return nil
- end
- #=============================================================================
- # RIGHT SIDE AVATARS
- #=============================================================================
- #Show first avatar
- def show01(char, emote)
- show_pic(char, emote, 3, "r")
- return nil
- end
- #Show second avatar
- def show02(char, emote)
- show_pic(char, emote, 1, "r")
- return nil
- end
- #Change emotion for avatar
- def set01(emote)
- change_emote(emote, 3)
- return nil
- end
- def set02(emote)
- change_emote(emote, 1)
- return nil
- end
- #Change avatar
- def change01(char, emote)
- change_avatar(3, char, emote)
- return nil
- end
- def change02(char, emote)
- change_avatar(1, char, emote)
- return nil
- end
- #=============================================================================
- # ACTIONS
- #=============================================================================
- def change_avatar(id, char, emote)
- case id
- when 1, 3
- face_side = "Right side faces"
- x1, y1 = COORDS[char][1][0], COORDS[char][1][1]
- out = 500
- when 2, 4
- face_side = "Left side faces"
- x1, y1 = COORDS[char][0][0], COORDS[char][0][1]
- out = -500
- end
- x = $game_map.screen.pictures[id].x
- y = $game_map.screen.pictures[id].y
- name = "Avatars/#{face_side}/#{char}/#{emote}.png"
- nm = $game_map.screen.pictures[id].name
- $game_map.screen.pictures[10].show(nm, 0, x, y, 100, 100, 255, 0)
- $game_map.screen.pictures[10].move(0, x + out, y, 100, 100, 255, 0, 30)
- $game_map.screen.pictures[id].show(name, 0, x1 + out, y1, 100, 100, 255, 0)
- $game_map.screen.pictures[id].move(0, x1, y1, 100, 100, 255, 0, 30)
- @characters[id] = char
- end
- def change_emote(emote, id)
- old_name = $game_map.screen.pictures[id].name
- arr = []
- i = 0
- while i < old_name.size
- arr[i] = old_name[i]
- i +=1
- end
- while arr[-1] != "/"
- arr.pop
- end
- name = arr.join + emote
- x = $game_map.screen.pictures[id].x
- y = $game_map.screen.pictures[id].y
- tona = $game_map.screen.pictures[id].tone
- $game_map.screen.pictures[id].show(name, 0, x, y, 100, 100, 255, 0)
- $game_map.screen.pictures[id].start_tone_change(tona, 1)
- end
- def show_pic(char, emote, id, side)
- case side
- when "l"
- face_side = "Left side faces"
- x, y = COORDS[char][0][0], COORDS[char][0][1]
- if char == "SP"
- out = x - 300
- else
- out = x - 500
- end
- when "r"
- face_side = "Right side faces"
- x, y = COORDS[char][1][0], COORDS[char][1][1]
- if char == "SP"
- out = x + 300
- else
- out = x + 500
- end
- end
- name = "Avatars/#{face_side}/#{char}/#{emote}.png"
- puts name
- if File.exist?("Graphics/Pictures/#{name}")
- case id
- when 1
- y -= 30
- x -= 30
- when 2
- y -= 30
- x += 30
- when 3
- x += 30
- when 4
- x -= 30
- end
- if char == "SP"
- time = 15
- else
- time = 30
- end
- $game_map.screen.pictures[id].show(name, 0, out, y, 100, 100, 255, 0)
- $game_map.screen.pictures[id].move(0, x, y, 100, 100, 255, 0, time)
- $game_map.screen.pictures[id].start_tone_change(Tone.new(-50, -50, -50, 0), 1)
- @characters[id] = char
- p @characters
- else
- puts "Oops! Probably Image is not exist in your folder."
- end
- end
- def select(id)
- x = []
- y = []
- x[1], y[1] = COORDS[@characters[1]][1][0] - 30, COORDS[@characters[1]][1][1] - 30 if @characters[1] != nil
- x[2], y[2] = COORDS[@characters[2]][0][0] + 30, COORDS[@characters[2]][0][1] - 30 if @characters[2] != nil
- x[3], y[3] = COORDS[@characters[3]][1][0] + 30, COORDS[@characters[3]][1][1] if @characters[3] != nil
- x[4], y[4] = COORDS[@characters[4]][0][0] - 30, COORDS[@characters[4]][0][1] if @characters[4] != nil
- case id
- when "01"
- char_id = 3
- when "02"
- char_id = 1
- when "10"
- char_id = 4
- when "20"
- char_id = 2
- end
- reset_actives
- @active_char[char_id] = true if char_id != nil
- if $game_map.screen.pictures[1].name != ""
- @active_char[1] ? x1 = x[1] - 30 : x1 = x[1]
- $game_map.screen.pictures[1].move(0, x1, y[1], 100, 100, 255, 0, 20)
- end
- if $game_map.screen.pictures[2].name != ""
- @active_char[2] ? x2 = x[2] + 30 : x2 = x[2]
- $game_map.screen.pictures[2].move(0, x2, y[2], 100, 100, 255, 0, 20)
- end
- if $game_map.screen.pictures[3].name != ""
- @active_char[3] ? x3 = x[3] - 30 : x3 = x[3]
- $game_map.screen.pictures[3].move(0, x3, y[3], 100, 100, 255, 0, 20)
- end
- if $game_map.screen.pictures[4].name != ""
- @active_char[4] ? x4 = x[4] + 30 : x4 = x[4]
- $game_map.screen.pictures[4].move(0, x4, y[4], 100, 100, 255, 0, 20)
- end
- (1..4).each do |i|
- if actived?(i)
- if $game_map.screen.pictures[i].name != ""
- $game_map.screen.pictures[i].start_tone_change(Tone.new( 0, 0, 0, 0), 1)
- end
- else
- if $game_map.screen.pictures[i].name != ""
- $game_map.screen.pictures[i].start_tone_change(Tone.new(-50, -50, -50, 0), 1)
- end
- end
- end
- return nil
- end
- def hide_all
- hide_char("01")
- hide_char("02")
- hide_char("10")
- hide_char("20")
- end
- def hide_char(inp)
- case inp
- when "01"
- char_id = 3
- when "02"
- char_id = 1
- when "10"
- char_id = 4
- when "20"
- char_id = 2
- end
- if @characters[char_id] != nil
- x = $game_map.screen.pictures[char_id].x
- y = $game_map.screen.pictures[char_id].y
- if char_id == 2 or char_id == 4
- targ = $game_map.screen.pictures[char_id].x - 600
- elsif char_id == 1 or char_id == 3
- targ = $game_map.screen.pictures[char_id].x + 600
- end
- if $game_map.screen.pictures[char_id].name != ""
- $game_map.screen.pictures[char_id].move(0, targ, y, 100, 100, 255, 0, 20)
- end
- end
- return ''
- end
- def dialogue_end
- if $game_map.screen.pictures[1].name != ""
- $game_map.screen.pictures[1].erase
- end
- if $game_map.screen.pictures[10].name != ""
- $game_map.screen.pictures[10].erase
- end
- if $game_map.screen.pictures[2].name != ""
- $game_map.screen.pictures[2].erase
- end
- if $game_map.screen.pictures[3].name != ""
- $game_map.screen.pictures[3].erase
- end
- if $game_map.screen.pictures[4].name != ""
- $game_map.screen.pictures[4].erase
- end
- end
- end
- module DataManager
- def self.create_game_objects
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_timer = Game_Timer.new
- $game_message = Game_Message.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.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
- $dialog = Dialogue.new
- end
- end
- class Window_Base < Window
- def convert_escape_characters(text)
- result = text.to_s.clone
- result.gsub!(/\\/) { "\e" }
- result.gsub!(/\e\e/) { "\\" }
- result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
- result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
- result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
- result.gsub!(/\eG/i) { Vocab::currency_unit }
- result.gsub!(/\eALD\[(.+?), (.+?)\]/i) { $dialog.show10($1, $2)}
- result.gsub!(/\eALU\[(.+?), (.+?)\]/i) { $dialog.show20($1, $2)}
- result.gsub!(/\eARD\[(.+?), (.+?)\]/i) { $dialog.show01($1, $2)}
- result.gsub!(/\eARU\[(.+?), (.+?)\]/i) { $dialog.show02($1, $2)}
- result.gsub!(/\eEMLD\[(.+?)\]/i) { $dialog.set10($1)}
- result.gsub!(/\eEMLU\[(.+?)\]/i) { $dialog.set20($1)}
- result.gsub!(/\eEMRD\[(.+?)\]/i) { $dialog.set01($1)}
- result.gsub!(/\eEMRU\[(.+?)\]/i) { $dialog.set02($1)}
- result.gsub!(/\eCHALD\[(.+?), (.+?)\]/i) { $dialog.change10($1, $2)}
- result.gsub!(/\eCHALU\[(.+?), (.+?)\]/i) { $dialog.change20($1, $2)}
- result.gsub!(/\eCHARD\[(.+?), (.+?)\]/i) { $dialog.change01($1, $2)}
- result.gsub!(/\eCHARU\[(.+?), (.+?)\]/i) { $dialog.change02($1, $2)}
- result.gsub!(/\eSWITCH\[(.+?)\]/i) { $dialog.select($1)}
- result.gsub!(/\eEND/i) { $dialog.dialogue_end}
- result.gsub!(/\eHIDEA/i) { $dialog.hide_all}
- result.gsub!(/\eHIDE\[(.+?)\]/i) { $dialog.hide_char($1)}
- result
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment