#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Script Calls / AMS by Nathmatt
# Version: 1.00
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# PART 2
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# Window_Message
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
x = y = 0
@cursor_width = 0
# Indent if choice
if $game_temp.choice_start == 0
x = 8
end
# If waiting for a message to be displayed
if $game_temp.message_text != nil
text = $game_temp.message_text
# Control text processing
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
# calls shop messages with \shop[id]
text.gsub!(/\\[Ss]hop\[(\S+)\]/) { $calls.Shop($1) }
# calls Inn messages with \inn[inn name,price]
text.gsub!(/\\[Ii]nn\[([\S, ]+)\]/) {
data = $1.split(',')
$calls.Inn(data[0],data[1]) }
# calls basic messages with \basic[npc's name,id]
text.gsub!(/\\[Bb]asic\[([\S, ]+)\]/) {
data = $1.split(',')
$calls.Basic_Messages(data[0],data[1].to_i) }
end until text == last_text
# calls actors name with \n[id]
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# calls random messages with \r[gender]
text.gsub!(/\\[Rr]\[(\S+)\]/) do
$calls.random_message($1)
end
# calls map name with \m
text.gsub!(/\\[Mm]/) do
$calls.Map_Name
end
text.gsub!(/\\[Gg]old/) do
$data_system.words.gold
end
# returns \\
text.gsub!(/\\\\/) {"\000"}
# changes text color with \c[id]
text.gsub!(/\\[Cc]\[([0-9]+)\]/) {"\001[#{$1}]"}
# calls gold window with \g
text.gsub!(/\\[Gg]/) {"\002"}
# calls name window with \name[name]
text.gsub!(/\\[Nn]ame\[(.+?)\]/) {"\003[#{$1}]"}
# calls face Graphic with \name[name]
text.gsub!(/\\[Ff]\[(\S+)\]/) {"\004[#{$1}]" }
# calls icon with \i[type,id] type is i for item a for armor w for weapon
# & s for skills
text.gsub!(/\\[Ii]\[([\S, ]+)\]/) {"\005[#{$1}]" }
# Get 1 text character in c (loop until unable to get text)
while ((c = text.slice!(/./m)) != nil)
# If \\
if c == "\000"
# Return to original text
c = "\\"
end
# If \C[n]
if c == "\001"
# Change text color
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
# go to next text
next
end
# If \G
if c == "\002"
# Make gold window
if @gold_window == nil
@gold_window = Window_Gold.new
@gold_window.x = 560 - @gold_window.width
if $game_temp.in_battle
@gold_window.y = 192
else
@gold_window.y = self.y >= 128 ? 32 : 384
end
@gold_window.opacity = self.opacity
@gold_window.back_opacity = self.back_opacity
end
# go to next text
next
end
if c == "\003"
# Make name window
text.sub!(/\[(.+?)\]/, "")
@name_window = Name_Window.new($1,self.x,self.y)
nwidth = contents.text_size($1).width
@name_back = Window_Base.new(self.x,self.y-32,nwidth+8,32)
@name_back.opacity = self.opacity
@name_back.back_opacity = self.back_opacity
next
end
if c == "\004"
# Make face window
text.sub!(/\[(\S+)\]/, "")
if @face_window == nil
@face_window = Face_Window.new($1,self.x-10,self.y-10)
left = true
end
next
end
if c == "\005"
# Make Icons
text.sub!(/\[([\S, ]+)\]/, "")
data = $1.split(',')
data = $calls.Icon(data[0].to_s,data[1].to_i)
self.contents.blt(x + (left != nil ? 96 : 0), y, data[0],
Rect.new(0, 0, 24, 24), opacity)
x += 24
w = self.contents.text_size(data[1]).width
self.contents.draw_text(4 + x + (left != nil ? 96 : 0),
32 * y, w, 32, data[1])
x += w
next
end
# If new line text
if c == "\n"
# Update cursor width if choice
if y >= $game_temp.choice_start
@cursor_width = [@cursor_width, x].max
end
# Add 1 to y
y += 1
x = 0
# Indent if choice
if y >= $game_temp.choice_start
x = 8
end
# go to next text
next
end
# Draw text
self.contents.draw_text(4 + x + (left != nil ? 96 : 0),
32 * y, 40, 32, c)
# Add x to drawn text width
x += self.contents.text_size(c).width
end
end
# If choice
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
end
# If number input
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.number = number
@input_number_window.x = self.x + 8
@input_number_window.y = self.y + $game_temp.num_input_start * 32
end
end
alias cms_terminate_message terminate_message
def terminate_message
cms_terminate_message
if @name_window != nil
@name_window.dispose
@name_window = nil
end
if @name_back != nil
@name_back.dispose
@name_back = nil
end
if @face_window != nil
@face_window.dispose
@face_window = nil
end
end
alias cms_update update
def update
if @contents_showing && Graphics.frame_rate == 80
if $game_temp.choice_max > 0
$game_system.se_play($data_system.decision_se)
$game_temp.choice_proc.call(self.index)
end
terminate_message
end
cms_update
end
end
#==============================================================================
# Name_Window
#==============================================================================
class Name_Window < Sprite
def initialize(name,x,y)
super()
w = (name.length * 32)
self.bitmap = Bitmap.new(w, 32)
self.x = x
self.y = y - 32
self.z = 500
@name = name
refresh
end
def refresh
w = bitmap.text_size(@name).width
self.bitmap.draw_text(4,0,w,32,@name.to_s)
end
end
#==============================================================================
# Face_Window
#==============================================================================
class Face_Window < Sprite
def initialize(file,x,y,flip = nil)
super()
self.bitmap = RPG::Cache.picture(file + '.png')
self.x = x +20
self.y = y +20
self.z = 9999
if flip
self.mirror = true
self.x += (460-self.bitmap.width)
end
end
def size
return self.bitmap.width
end
end